14
2 Motivation
2.3.2 Task Description
Consider a substance that has an initial concentration of 100% and use a decay
constant of κ = 0.0001 per second (or κ = 10
−4
s
−1
). Choose different values of
the time step to verify whether the prediction becomes more accurate for a fine
temporal resolution. Explore both the explicit and the implicit scheme.
2.3.3 Instructions
Use any text editor to write the FORTRAN code and save the f le under the name
“Exercise1.f95”. Blanks or other unusual symbols are not permitted here. Other
filename may be used, but the reader should make sure that the f lename is not
too long and that it has something to do with the exercise. The f le extension “f95”
identifie this fil as a FORTRAN 95 source code.
2.3.4 Sample Code
The Fortran code for this exercise, called “winethief.f95” can be found in the folder
“Exercise 1” on the CD-ROM accompanying this book.
2.3.5 Results
As a result of the model run, the data output file “output1.txt” or “output2.txt”
should appear in the f le list. The MODE parameter in the code switches between
the explicit and the implicit schemes. To avoid the recompiling procedure, values
for “mode” could be alternatively read from the keyboard with “READ(5,*) mode”.
Figure 2.2 shows model results for a time step of Δt = 3600 s using either
the explicit scheme (2.3) or the implicit scheme (2.6). As can be seen, the explicit
scheme slightly underestimates the correct concentration, whereas the implicit
scheme slightly overestimates concentration. A semi-implicit approach would probably give the best solution, but this remains to be verifie by the reader.
With a time step of 3600 s, completion of the model run took only a few seconds
on my computer. The accuracy of the prediction can be substantially improved with
choice of a much fine temporal resolution with a time step of, say, Δt = 1s , which
the reader can easily verify.
2.3.6 Additional Exercise for the Reader
Repeat this exercise with use of the hybrid scheme (2.7) and explore the solutions
for α = 0.25, 0.5 and 0.75.
Précédent

- 28/185

Suivant