Plotting Radioactive Decay with Fortran and ES-Plot

One of the assignments in Fortran last semester was to plot the exponential population growth of the United States between the years 1790 and 1860. Since I had recently taken Chemistry that summer, I also wrote a program to model the decay of the radioactive isotope Carbon-14, the isotope used in Radiocarbon Dating.

This program calculates the data, exports it to a CSV file, and finally calls the ES-Plot program and feeds it the CSV for data. An example output is below:

Decay model of the Carbon-14 isotope

In the graphic above, the vertical axis is number of moles present, and the horizontal axis is the number of years since the start of decay. It is difficult to read the numbers, but the first labeled tick mark is “1E+4”, 10,000 years. The average half-life of Carbon-14 is 5,730±40 years, not labeled here. The last tick mark is 40,000 years.

The user can input any quantity in moles for the program to calculate, but calculation will stop at 0.01% of the calculated mass because anything less than that is trivial in this case and is difficult to see in the resulting graphic. You will notice, therefore, that subsequent calculations result in the same graphic. That is because the decay rate of Carbon-14 is the same, regardless of quantity.

~Jonathan

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
! ----------------------------------------------------------
! Programmer:   Jonathan Landrum
! Date:         22 October 2011
! Class:        CSC 204
! ----------------------------------------------------------
! Program:      decay.f95
! Purpose:      Calculates and plots the radioactive decay
!               of Carbon-14. The half-life of Carbon-14 is
!               5,730 +/- 40 years. I have chosen 5,730 for
!               this model's lambda, as it is the mean.
! Assumptions:  1.) ES-Plot is installed.
!                   http://goo.gl/wmhZw
! ----------------------------------------------------------
 
PROGRAM decay
 
    IMPLICIT NONE
 
    CHARACTER                   :: response
    INTEGER                     :: t
    REAL                        :: p0, mass
    DOUBLE PRECISION, PARAMETER :: e = 2.71828182845904523536 !     ln 0.5
    DOUBLE PRECISION, PARAMETER :: k = -0.0001209680943385594 ! k = ------
                                                              !     lambda
 
    WRITE (*,*) '*******************************************'
    WRITE (*,*) '*                                         *'
    WRITE (*,*) '*FORTRAN CARBON RADIOACTIVE DECAY MODELLER*'
    WRITE (*,*) '*                                         *'
    WRITE (*,*) '*******************************************'
    WRITE (*,*)
    WRITE (*,*) 'Copyright (c) 2011 Jonathan Landrum'
    WRITE (*,*)
    WRITE (*,*) 'Calculates and plots the radioactive decay'
    WRITE (*,*) 'of Carbon-14 to the stable Nitrogen isotope'
    WRITE (*,*) 'Nitrogen-14, its most common isotope.'
    WRITE (*,*)
    WRITE (*,*) 'The half-life of Carbon-14 is 5,730 +/- 40'
    WRITE (*,*) 'years. I have chosen 5,730 for this model,'
    WRITE (*,*) 'as it is the mean.'
    WRITE (*,*)
    WRITE (*,*) 'Assumptions: 1.) ES-Plot is installed.'
    WRITE (*,*) '                 http://goo.gl/wmhZw'
    WRITE (*,*)
    WRITE (*,*) '------------------------------------------'
    WRITE (*,*)
    WRITE (*,*) 'Would you like to continue? [Y/N]'
    WRITE (*,*)
    READ  (*,*) response
    WRITE (*,*)
 
    ! Any response beginning with the letter "y" will work.
    WHILE (response == 'y' .OR. response == 'Y') DO
 
        WRITE  (*,*) 'How many moles of Carbon-14 do you want'
        WRITE  (*,*) 'to test?'
        WRITE  (*,*)
        READ   (*,*) p0
 
        t      = 0
        mass   = p0
 
        OPEN   (UNIT=8, FILE='decay.csv', status='unknown')
 
1       FORMAT (1X,I6,A2,F6.3)
 
        WRITE  (*,*) 'Year,   Mass'
        WRITE  (*,*) '------------'
        WRITE  (8,*) '$ Carbon-14 Decay Model'
 
        WHILE  (mass >= (p0 * 0.01)) DO
            mass  = (p0 * (e ** (k * t)))
            WRITE (8,*) t, ', ', mass
            WRITE (*,1) t, ', ', mass
            t     = t + 1
        END DO
 
        CLOSE  (8)
 
        WRITE  (*,*)
        WRITE  (*,*) '------------'
        WRITE  (*,*) 'End of list.'
        WRITE  (*,*)
        WRITE  (*,*) 'File "decay.csv" successfully created.'
        WRITE  (*,*) 'Calling ESPlot...'
 
        CALL SYSTEM ('"C:\Program Files (x86)\ESPlot\esplot.exe" decay.csv')
 
        WRITE  (*,*) 'Process Complete'
        WRITE  (*,*)
        WRITE  (*,*) '------------------------------------------'
        WRITE  (*,*) 'Would you calculate another mass? [Y/N]'
        WRITE  (*,*)
        READ   (*,*) response
        WRITE  (*,*)
    END DO ! Continue loop
    WRITE (*,*) '\\//_ Live long and prosper.'
END PROGRAM decay

Jonathan Landrum
Jonathan Landrum is a full-time husband and student, and a part-time research assistant and IT guy. He both works and studies at Mississippi College, where he is pursuing a Bachelor of Science in Computer Science.

Name:
Email:
Message:

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">