Models
Abstract
This chapter presents many mathematical models that all end up with ODEs of the type \(u^{\prime}=au+b\). The applications are taken from biology, finance, and physics, and cover population growth or decay, interacting predatorprey populations, compound interest and inflation, radioactive decay, chemical and biochemical reaction, spreading of diseases, cooling of objects, compaction of geological media, pressure variations in the atmosphere, viscoelastic response in materials, and air resistance on falling or rising bodies.
This chapter presents many mathematical models that all end up with ODEs of the type \(u^{\prime}=au+b\). The applications are taken from biology, finance, and physics, and cover population growth or decay, interacting predatorprey populations, compound interest and inflation, radioactive decay, chemical and biochemical reaction, spreading of diseases, cooling of objects, compaction of geological media, pressure variations in the atmosphere, viscoelastic response in materials, and air resistance on falling or rising bodies.
Before we turn to the applications, however, we take a brief look at the technique of scaling, which is so useful in many applications.
4.1 Scaling
Real applications of a model \(u^{\prime}=au+b\) will often involve a lot of parameters in the expressions for a and b. It can be quite a challenge to find relevant values of all parameters. In simple problems, however, it turns out that it is not always necessary to estimate all parameters because we can lump them into one or a few dimensionless numbers by using a very attractive technique called scaling. It simply means to stretch the u and t axis in the present problem – and suddenly all parameters in the problem are lumped into one parameter if \(b\neq 0\) and no parameter when b = 0!
4.1.1 Dimensionless Variables
4.1.2 Dimensionless Numbers
The parameter β is a dimensionless number. From the equation we see that b must have the same unit as the term au. The initial condition I must have the same unit as u, so Ia has the same unit as b, making the fraction \(b/(Ia)\) dimensionless.
An important observation is that \(\bar{u}\) depends on \(\bar{t}\) and β. That is, only the special combination of \(b/(Ia)\) matters, not what the individual values of b, a, and I are. The original unscaled function u depends on t, b, a, and I.
A second observation is striking: if b = 0, the scaled problem is independent of a and I! In practice this means that we can perform a single numerical simulation of the scaled problem and recover the solution of any problem for a given a and I by stretching the axis in the plot: \(u=I\bar{u}\) and \(t=\bar{t}/a\). For \(b\neq 0\), we simulate the scaled problem for a few β values and recover the physical solution u by translating and stretching the u axis and stretching the t axis.
In general, scaling combines the parameters in a problem to a set of dimensionless parameters. The number of dimensionless parameters is usually much smaller than the number of original parameters. Section 4.11 presents an example where 11 parameters are reduced to one!
4.1.3 A Scaling for Vanishing Initial Condition
It is common to drop the bars after scaling and write the scaled problem as \(u^{\prime}=u\), \(u(0)=1\beta\), or \(u^{\prime}=1u\), \(u(0)=0\). Any implementation of the problem \(u^{\prime}=au+b\), \(u(0)=I\), can be reused for the scaled problem by setting a = 1, b = 0, and \(I=1\beta\) in the code, if \(I\neq 0\), or one sets a = 1, b = 1, and I = 0 when the physical I is zero. Falling bodies in fluids, as described in Sect. 4.11, involves \(u^{\prime}=au+b\) with seven physical parameters. All these vanish in the scaled version of the problem if we start the motion from rest!
Many more details about scaling are presented in the author’s book Scaling of Differential Equations [9].
4.2 Evolution of a Population
4.2.1 Exponential Growth
4.2.2 Logistic Growth
4.3 Compound Interest and Inflation
4.4 Newton’s Law of Cooling
The cooling law (Ch4.E8) needs an initial condition \(T(0)=T_{0}\).
4.5 Radioactive Decay
An atomic nucleus of an unstable atom may lose energy by emitting ionizing particles and thereby be transformed to a nucleus with a different number of protons and neutrons. This process is known as radioactive decay. Actually, the process is stochastic when viewed for a single atom, because it is impossible to predict exactly when a particular atom emits a particle. Nevertheless, with a large number of atoms, N, one may view the process as deterministic and compute the mean behavior of the decay. Below we reason intuitively about an ODE for the mean behavior. Thereafter, we show mathematically that a detailed stochastic model for single atoms leads to the same mean behavior.
4.5.1 Deterministic Model
The parameter a can for a given nucleus be expressed through the halflife \(t_{1/2}\), which is the time taken for the decay to reduce the initial amount by one half, i.e., \(u(t_{1/2})=0.5\). With \(u(t)=e^{at}\), we get \(t_{1/2}=a^{1}\ln 2\) or \(a=\ln 2/t_{1/2}\).
4.5.2 Stochastic Model
4.5.3 Relation Between Stochastic and Deterministic Models
With \(p=e^{\lambda t}\) we get the expected number of original atoms at t as \(N_{0}p=N_{0}e^{\lambda t}\), which is exactly the solution of the ODE model \(N^{\prime}=\lambda N\). This also gives an interpretation of a via λ or vice versa. Our important finding here is that the ODE model captures the mean behavior of the underlying stochastic model. This is, however, not always the common relation between microscopic stochastic models and macroscopic ‘‘averaged’’ models.
Also of interest, is that a Forward Euler discretization of \(N^{\prime}=\lambda N\), \(N(0)=N_{0}\), gives \(N^{m}=N_{0}(1\lambda\Delta t)^{m}\) at time \(t_{m}=m\Delta t\), which is exactly the expected value of the stochastic experiment with N_{0} atoms and m small intervals of length \(\Delta t\), where each atom can decay with probability \(\lambda\Delta t\) in an interval.
4.5.4 Generalization of the Radioactive Decay Modeling
The modeling in Sect. 4.5 is in fact very general, despite a focus on a particular physical process. We may instead of atoms and decay speak about a set of items, where each item can undergo a stochastic transition from one state to another. In Sect. 4.6 the item is a molecule and the transition is a chemical reaction, while in Sect. 4.7 the item is an ill person and the transition is recovering from the illness (or an immune person who loses her immunity).
4.6 Chemical Kinetics
4.6.1 Irreversible Reaction of Two Substances
This reaction is known as a firstorder reaction, where each molecule of A makes an independent decision about whether to complete the reaction, i.e., independent of what happens to any other molecule.
4.6.2 Reversible Reaction of Two Substances
4.6.3 Irreversible Reaction of Two Substances into a Third
4.6.4 A Biochemical Reaction
4.7 Spreading of Diseases
The modeling of spreading of diseases is very similar to the modeling of chemical reactions in Sect. 4.6. The field of epidemiology speaks about susceptibles: people who can get a disease; infectives: people who are infected and can infect susceptibles; and recovered: people who have recovered from the disease and become immune. Three categories are accordingly defined: S for susceptibles, I for infectives, and R for recovered. The number in each category is tracked by the functions \(S(t)\), \(I(t)\), and \(R(t)\).
Equations (Ch4.E27)–(Ch4.E29) are known as the SIR model in epidemiology. The model can easily be extended to incorporate vaccination programs, immunity loss after some time, etc. Typical diseases that can be simulated by the SIR model and its variants are measles, smallpox, flu, plague, and HIV.
4.8 PredatorPrey Models in Ecology
A model for the interaction of predator and prey species can be based on reasoning from population dynamics and the SIR model. Let \(H(t)\) be the number of preys in a region, and let \(L(t)\) be the number of predators. For example, H may be hares and L lynx, or rabbits and foxes.
4.9 Decay of Atmospheric Pressure with Altitude
4.9.1 The General Model
4.9.2 Multiple Atmospheric Layers
i  h _{ i }  \(\bar{T}_{i}\)  L _{ i } 

0  0  288  \(\)0.0065 
1  11,000  216  0.0 
2  20,000  216  0.001 
3  32,000  228  0.0028 
4  47,000  270  0.0 
5  51,000  270  \(\)0.0028 
6  71,000  214  \(\)0.002 
4.9.3 Simplifications
Constant layer temperature
One common simplification is to assume that the temperature is constant within each layer. This means that L = 0.
Onelayer model
Another commonly used approximation is to work with one layer instead of seven. This onelayer model is based on \(T(z)=T_{0}Lz\), with sea level standard temperature \(T_{0}=288\) K and temperature lapse rate L = 0.0065 K\(/\)m.
4.10 Compaction of Sediments
Sediments, originally made from materials like sand and mud, get compacted through geological time by the weight of new material that is deposited on the sea bottom. The porosity ϕ of the sediments tells how much void (fluid) space there is between the sand and mud grains. The porosity drops with depth, due to the weight of the sediments above. This makes the void space shrink, and thereby compaction increases.
4.11 Vertical Motion of a Body in a Viscous Fluid
A body moving vertically through a fluid (liquid or gas) is subject to three different types of forces: the gravity force, the drag force, and the buoyancy force.
4.11.1 Overview of Forces
Taking the upward direction as positive, the gravity force is \(F_{g}=mg\), where m is the mass of the body and g is the acceleration of gravity. The uplift or buoyancy force (‘‘Archimedes force’’) is \(F_{b}=\varrho gV\), where \(\varrho\) is the density of the fluid and V is the volume of the body.
4.11.2 Equation of Motion
4.11.3 Terminal Velocity
4.11.4 A Crank–Nicolson Scheme
Using a geometric mean instead of an arithmetic mean in the Crank–Nicolson scheme is an attractive method for avoiding a nonlinear algebraic equation when discretizing a nonlinear ODE.
4.11.5 Physical Data
Suitable values of μ are \(1.8\cdot 10^{5}\,\text{Pa}\,\text{s}\) for air and \(8.9\cdot 10^{4}\,\text{Pa}\,\text{s}\) for water. Densities can be taken as \(1.2\,\mathrm{kg/m}^{3}\) for air and as \(1.0\cdot 10^{3}\,\mathrm{kg/m}^{3}\) for water. For considerable vertical displacement in the atmosphere one should take into account that the density of air varies with the altitude, see Sect. 4.9. One possible density variation arises from the onelayer model in the mentioned section.
The drag coefficient C_{D} depends heavily on the shape of the body. Some values are: 0.45 for a sphere, 0.42 for a semisphere, 1.05 for a cube, 0.82 for a long cylinder (when the center axis is in the vertical direction), 0.75 for a rocket, 1.01.3 for a man in upright position, 1.3 for a flat plate perpendicular to the flow, and 0.04 for a streamlined, dropletlike body.
4.11.6 Verification
To verify the program, one may assume a heavy body in air such that the F_{b} force can be neglected, and further assume a small velocity such that the air resistance F_{d} can also be neglected. This can be obtained by setting μ and \(\varrho\) to zero. The motion then leads to the velocity \(v(t)=v_{0}gt\), which is linear in t and therefore should be reproduced to machine precision (say tolerance \(10^{15}\)) by any implementation based on the Crank–Nicolson or Forward Euler schemes.
Another verification, but not as powerful as the one above, can be based on computing the terminal velocity and comparing with the exact expressions. The advantage of this verification is that we can also test the situation \(\varrho\neq 0\).
As always, the method of manufactured solutions can be applied to test the implementation of all terms in the governing equation, but then the solution has no physical relevance in general.
4.11.7 Scaling
4.12 Viscoelastic Materials
4.13 Decay ODEs from Solving a PDE by Fourier Expansions
Remark
Since a_{k} depends on k and the stability of the Forward Euler scheme demands \(a_{k}\Delta t\leq 1\), we get that \(\Delta t\leq\alpha^{1}L^{2}\pi^{2}k^{2}\) for this scheme. Usually, quite large k values are needed to accurately represent the given functions I and f so that \(\Delta t\) in the Forward Euler scheme needs to be very small for these large values of k. Therefore, the Crank–Nicolson and Backward Euler schemes, which allow larger \(\Delta t\) without any growth in the solutions, are more popular choices when creating timestepping algorithms for partial differential equations of the type considered in this example.
4.14 Exercises
Problem 4.1 (Radioactive decay of Carbon14)
The Carbon14 isotope, whose radioactive decay is used extensively in dating organic material that is tens of thousands of years old, has a halflife of 5,730 years. Determine the age of an organic material that contains 8.4 % of its initial amount of Carbon14. Use a time unit of 1 year in the computations. The uncertainty in the half time of Carbon14 is ±40 years. What is the corresponding uncertainty in the estimate of the age?
Hint 1
Let A be the amount of Carbon14. The ODE problem is then \(A^{\prime}(t)=aA(t)\), \(A(0)=I\). Introduced the scaled amount \(u=A/I\). The ODE problem for u is \(u^{\prime}=au\), \(u(0)=1\). Measure time in years. Simulate until the first mesh point t_{m} such that \(u(t_{m})\leq 0.084\).
Hint 2
Use simulations with \(5{,}730\pm 40\) y as input and find the corresponding uncertainty interval for the result.
Filename: carbon14.
Exercise 4.2 (Derive schemes for Newton’s law of cooling)
Filename: schemes_cooling.
Exercise 4.3 (Implement schemes for Newton’s law of cooling)
The goal of this exercise is to implement the schemes from Exercise 4.2 and investigate several approaches for verifying the implementation.
 a)
Implement the θrule from Exercise 4.2 in a function
where T0 is the initial temperature, k is the heat transfer coefficient, T_s is a function of t for the temperature of the surroundings, t_end is the end time of the simulation, dt is the time step, and theta corresponds to θ. The cooling function should return the temperature as an array T of values at the mesh points and the time mesh t.
 b)
In the case \(\lim_{t\rightarrow\infty}T_{s}(t)=C=\text{const}\), explain why \(T(t)\rightarrow C\). Construct an example where you can illustrate this property in a plot. Implement a corresponding test function that checks the correctness of the asymptotic value of the solution.
 c)A piecewise constant surrounding temperature,corresponds to a sudden change in the environment at \(t=t^{*}\). Choose \(C_{0}=2T_{0}\), \(C_{1}=\frac{1}{2}T_{0}\), and \(t^{*}=3/k\). Plot the solution \(T(t)\) and explain why it seems physically reasonable.$$T_{s}(t)=\left\{\begin{array}[]{ll}C_{0},&0\leq t\leq t^{*}\\ C_{1},&t> t^{*},\end{array}\right.$$
 d)
We know from the ODE \(u^{\prime}=au\) that the Crank–Nicolson scheme can give nonphysical oscillations for \(\Delta t> 2/a\). In the present problem, this results indicates that the Crank–Nicolson scheme give undesired oscillations for \(\Delta t> 2/k\). Discuss if this a potential problem in the physical case from c).
 e)
Find an expression for the exact solution of \(T^{\prime}=k(TT_{s}(t))\), \(T(0)=T_{0}\). Construct a test case and compare the numerical and exact solution in a plot.
Find a value of the time step \(\Delta t\) such that the two solution curves cannot (visually) be distinguished from each other. Many scientists will claim that such a plot provides evidence for a correct implementation, but point out why there still may be errors in the code. Can you introduce bugs in the cooling function and still achieve visually coinciding curves?
Hint
The exact solution can be derived by multiplying (Ch4.E8) by the integrating factor \(e^{kt}\).
 f)
Implement a test function for checking that the solution returned by the cooling function is identical to the exact numerical solution of the problem (to machine precision) when T_{s} is constant.
Hint
Running this function shows that the diff variable is 3.55E15 as maximum so a tolerance of \(10^{14}\) is appropriate. This is a good test that the cooling function works!
Filename: cooling.
Exercise 4.4 (Find time of murder from body temperature)
A detective measures the temperature of a dead body to be 26.7 \({}^{\circ}\)C at 2 pm. One hour later the temperature is 25.8 \({}^{\circ}\)C. The question is when death occurred.
Assume that Newton’s law of cooling (Ch4.E8) is an appropriate mathematical model for the evolution of the temperature in the body. First, determine k in (Ch4.E8) by formulating a Forward Euler approximation with one time steep from time 2 am to time 3 am, where knowing the two temperatures allows for finding k. Assume the temperature in the air to be 20 \({}^{\circ}\)C. Thereafter, simulate the temperature evolution from the time of murder, taken as t = 0, when \(T=37\,^{\circ}\text{C}\), until the temperature reaches 25.8 \({}^{\circ}\)C. The corresponding time allows for answering when death occurred.
Filename: detective.
Exercise 4.5 (Simulate an oscillating cooling process)
Filename: osc_cooling.
Exercise 4.6 (Simulate stochastic radioactive decay)
The purpose of this exercise is to implement the stochastic model described in Sect. 4.5 and show that its mean behavior approximates the solution of the corresponding ODE model.
The simulation goes on for a time interval \([0,T]\) divided into N_{t} intervals of length \(\Delta t\). We start with N_{0} atoms. In some time interval, we have N atoms that have survived. Simulate N Bernoulli trials with probability \(\lambda\Delta t\) in this interval by drawing N random numbers, each being 0 (survival) or 1 (decay), where the probability of getting 1 is \(\lambda\Delta t\). We are interested in the number of decays, d, and the number of survived atoms in the next interval is then \(Nd\). The Bernoulli trials are simulated by drawing N uniformly distributed real numbers on \([0,1]\) and saying that 1 corresponds to a value less than \(\lambda\Delta t\):
Observe that uniform < lambda_*dt is a boolean array whose true and false values become 1 and 0, respectively, when converted to an integer array.
Repeat the simulation over \([0,T]\) a large number of times, compute the average value of N in each interval, and compare with the solution of the corresponding ODE model.
Filename: stochastic_decay.
Problem 4.7 (Radioactive decay of two substances)
 a)
Make a simulation program that solves for \(u_{A}(t)\) and \(u_{B}(t)\).
 b)
Verify the implementation by computing analytically the limiting values of u_{A} and u_{B} as \(t\rightarrow\infty\) (assume \(u_{A}^{\prime},u_{B}^{\prime}\rightarrow 0\)) and comparing these with those obtained numerically.
 c)
Run the program for the case of \(A_{1/2}=10\) minutes and \(B_{1/2}=50\) minutes. Use a time unit of 1 minute. Plot u_{A} and u_{B} versus time in the same plot.
Exercise 4.8 (Simulate a simple chemical reaction)
Filename: chemcial_kinetics_AB.
Exercise 4.9 (Simulate an nth order chemical reaction)
Filename: chemcial_kinetics_ABn.
Exercise 4.10 (Simulate a biochemical process)
The purpose of this exercise is to simulate the ODE system (Ch4.E23)–(Ch4.E26) modeling a simple biochemical process.
 a)Scale (Ch4.E23)–(Ch4.E26) such that we can work with dimensionless parameters, which are easier to prescribe. Introducewhere appropriate scales are$$\bar{Q}=\frac{[ES]}{Q_{c}},\quad\bar{P}=\frac{P}{P_{c}},\quad\bar{S}=\frac{S}{S_{0}},\quad\bar{E}=\frac{E}{E_{0}},\quad\bar{t}=\frac{t}{t_{c}},$$with \(K=(k_{v}+k_{})/k_{+}\) (Michaelis constant). Show that the scaled system becomes$$Q_{c}=\frac{S_{0}E_{0}}{K},\quad P_{c}=Q_{c},\quad t_{c}=\frac{1}{k_{+}E_{0}},$$$$\frac{d\bar{Q}}{d\bar{t}} =\alpha(\bar{E}\bar{S}\bar{Q}),$$(4.54)$$\frac{d\bar{P}}{d\bar{t}} =\beta\bar{Q},$$(4.55)$$\frac{d\bar{S}}{d\bar{t}} =\bar{E}\bar{S}+(1\beta\alpha^{1})\bar{Q},$$(4.56)where we have three dimensionless parameters$$\epsilon\frac{d\bar{E}}{d\bar{t}} =\bar{E}\bar{S}+\bar{Q},$$(4.57)The corresponding initial conditions are \(\bar{Q}=\bar{P}=0\) and \(\bar{S}=\bar{E}=1\).$$\alpha=\frac{K}{E_{0}},\quad\beta=\frac{k_{v}}{k_{+}E_{0}},\quad\epsilon=\frac{E_{0}}{S_{0}}\thinspace.$$
 b)
 c)
 d)
Simulate a case with T = 8, \(\alpha=1.5\) and \(\beta=1\), and two ϵ values: 0.9 and 0.1.
Exercise 4.11 (Simulate spreading of a disease)
 a)Estimating the parameter β is difficult so it can be handy to scale the equations. Use \(t_{c}=1/\nu\) as time scale, and scale S, I, and R by the population size \(N=S(0)+I(0)+R(0)\). Show that the resulting dimensionless model becomes$$\frac{d\bar{S}}{d\bar{t}} =R_{0}\bar{S}\bar{I},$$(4.60)$$\frac{d\bar{I}}{d\bar{t}} =R_{0}\bar{S}\bar{I}\bar{I},$$(4.61)$$\frac{d\bar{R}}{d\bar{t}} =I,$$(4.62)$$\bar{S}(0) =1\alpha,$$(4.63)$$\bar{I}(0) =\alpha,$$(4.64)where R_{0} and α are the only parameters in the problem:$$\bar{R}(0) =0,$$(4.65)A quantity with a bar denotes a dimensionless version of that quantity, e.g, \(\bar{t}\) is dimensionless time, and \(\bar{t}=\nu t\).$$R_{0}=\frac{N\beta}{\nu},\quad\alpha=\frac{I(0)}{N}\thinspace.$$
 b)
Show that the R_{0} parameter governs whether the disease will spread or not at t = 0.
Hint
Spreading means \(dI/dt> 0\).
 a)
Implement the scaled SIR model. Check at every time step, as a verification, that \(\bar{S}+\bar{I}+\bar{R}=1\).
 b)
Simulate the spreading of a disease where \(R_{0}=2,5\) and 2 % of the population is infected at time t = 0.
Exercise 4.12 (Simulate predatorprey interaction)
Section 4.8 describes a model for the interaction of predator and prey populations, such as lynx and hares.
 a)
Scale the equations (Ch4.E30)–(Ch4.E31). Use the initial population \(H(0)=H_{0}\) of H has scale for H and L, and let the time scale be \(1/(bH_{0})\).
 b)
Implement the scaled model from a). Run illustrating cases how the two populations develop.
 c)
The scaling in a) used a scale for H and L based on the initial condition \(H(0)=H_{0}\). An alternative scaling is to make the ODEs as simple as possible by introducing separate scales H_{c} and L_{c} for H and L, respectively. Fit H_{c}, L_{c}, and the time scale t_{c} such that there are as few dimensionless parameters as possible in the ODEs. Scale the initial conditions. Compare the number and type of dimensionless parameters with a).
 d)
Compute with the scaled model from c) and create plots to illustrate the typical solutions.
Exercise 4.13 (Simulate the pressure drop in the atmosphere)

one computing the pressure \(p(z)\) using a sevenlayer model and varying L,

one computing \(p(z)\) using a sevenlayer model, but with constant temperature in each layer, and

one computing \(p(z)\) based on the onelayer model.
Filename: atmospheric_pressure.
Exercise 4.14 (Make a program for vertical motion in a fluid)
Implement the Stokes’ drag model (Ch4.E40) and the quadratic drag model (Ch4.E43) from Sect. 4.11, using the Crank–Nicolson scheme and a geometric mean for \(vv\) as explained, and assume constant fluid density. At each time level, compute the Reynolds number Re and choose the Stokes’ drag model if \(\text{Re}<1\) and the quadratic drag model otherwise.
The computation of the numerical solution should take place either in a standalone function or in a solver class that looks up a problem class for physical data. Create a module and equip it with pytest/nose compatible test functions for automatically verifying the code.
A solution that is linear in t will also be an exact solution of the discrete equations in many problems. Show that this is true for linear drag (by adding a source term that depends on t), but not for quadratic drag because of the geometric mean approximation. Use the method of manufactured solutions to add a source term in the discrete equations for quadratic drag such that a linear function of t is a solution. Add a test function for checking that the linear function is reproduced to machine precision in the case of both linear and quadratic drag.
Apply the software to a case where a ball rises in water. The buoyancy force is here the driving force, but the drag will be significant and balance the other forces after a short time. A soccer ball has radius 11 cm and mass 0.43 kg. Start the motion from rest, set the density of water, \(\varrho\), to \(1000\,\mathrm{kg/m}^{3}\), set the dynamic viscosity, μ, to \(10^{3}\,\text{Pa\,s}\), and use a drag coefficient for a sphere: 0.45. Plot the velocity of the rising ball.
Filename: vertical_motion.
Project 4.15 (Simulate parachuting)
The aim of this project is to develop a general solver for the vertical motion of a body with quadratic air drag, verify the solver, apply the solver to a skydiver in free fall, and finally apply the solver to a complete parachute jump.
All the pieces of software implemented in this project should be realized as Python functions and/or classes and collected in one module.
 a)
Set up the differential equation problem that governs the velocity of the motion. The parachute jumper is subject to the gravity force and a quadratic drag force. Assume constant density. Add an extra source term to be used for program verification. Identify the input data to the problem.
 b)
Make a Python module for computing the velocity of the motion. Also equip the module with functionality for plotting the velocity.
Hint 1
Use the Crank–Nicolson scheme with a geometric mean of \(vv\) in time to linearize the equation of motion with quadratic drag.
Hint 2
You can either use functions or classes for implementation. If you choose functions, make a function solver that takes all the input data in the problem as arguments and that returns the velocity (as a mesh function) and the time mesh. In case of a classbased implementation, introduce a problem class with the physical data and a solver class with the numerical data and a solve method that stores the velocity and the mesh in the class.
Allow for a timedependent area and drag coefficient in the formula for the drag force.
 a)
Show that a linear function of t does not fulfill the discrete equations because of the geometric mean approximation used for the quadratic drag term. Fit a source term, as in the method of manufactured solutions, such that a linear function of t is a solution of the discrete equations. Make a test function to check that this solution is reproduced to machine precision.
 b)
The expected error in this problem goes like \(\Delta t^{2}\) because we use a centered finite difference approximation with error \(\mathcal{O}(\Delta t^{2})\) and a geometric mean approximation with error \(\mathcal{O}(\Delta t^{2})\). Use the method of manufactured solutions combined with computing convergence rate to verify the code. Make a test function for checking that the convergence rate is correct.
 c)
Compute the drag force, the gravity force, and the buoyancy force as a function of time. Create a plot with these three forces.
Hint
You can either make a function forces(v, t, plot=None) that returns the forces (as mesh functions) and t, and shows a plot on the screen and also saves the plot to a file with name stored in plot if plot is not None, or you can extend the solver class with computation of forces and include plotting of forces in the visualization class.
 f)
Compute the velocity of a skydiver in free fall before the parachute opens.
Hint
Meade and Struthers [11] provide some data relevant to skydiving. The mass of the human body and equipment can be set to 100 kg. A skydiver in spreadeagle formation has a crosssection of 0.5 \(\text{m}^{2}\) in the horizontal plane. The density of air decreases with altitude, but can be taken as constant, 1 \(\mathrm{kg/m}^{3}\), for altitudes relevant to skydiving (0–4000 m). The drag coefficient for a man in upright position can be set to 1.2. Start with a zero velocity. A free fall typically has a terminating velocity of 45 m\(/\)s. (This value can be used to tune other parameters.)
 g)
The next task is to simulate a parachute jumper during free fall and after the parachute opens. At time t_{p}, the parachute opens and the drag coefficient and the crosssectional area change dramatically. Use the program to simulate a jump from z = 3000 m to the ground z = 0. What is the maximum acceleration, measured in units of g, experienced by the jumper?
Hint
Following Meade and Struthers [11], one can set the crosssection area perpendicular to the motion to 44 \(\text{m}^{2}\) when the parachute is open. Assume that it takes 8 s to increase the area linearly from the original to the final value. The drag coefficient for an open parachute can be taken as 1.8, but tuned using the known value of the typical terminating velocity reached before landing: 5.3 m\(/\)s. One can take the drag coefficient as a piecewise constant function with an abrupt change at t_{p}. The parachute is typically released after \(t_{p}=60\) s, but larger values of t_{p} can be used to make plots more illustrative.
Filename: parachuting.
Exercise 4.16 (Formulate vertical motion in the atmosphere)
Explain in detail how the governing equations can be discretized by the Forward Euler and the Crank–Nicolson methods. Discuss pros and cons of the two methods.
Filename: falling_in_variable_density.
Exercise 4.17 (Simulate vertical motion in the atmosphere)
Implement the Forward Euler or the Crank–Nicolson scheme derived in Exercise 4.16. Demonstrate the effect of air density variation on a falling human, e.g., the famous fall of Felix Baumgartner. The drag coefficient can be set to 1.2.
Filename: falling_in_variable_density.
Problem 4.18 (Compute \(y=x\) by solving an ODE)
Filename: signum.
Problem 4.19 (Simulate fortune growth with random interest rate)
The goal of this exercise is to compute the value of a fortune subject to inflation and a random interest rate. Suppose that the inflation is constant at i percent per year and that the annual interest rate, p, changes randomly at each time step, starting at some value p_{0} at t = 0. The random change is from a value p^{n} at \(t=t_{n}\) to \(p_{n}+\Delta p\) with probability 0.25 and \(p_{n}\Delta p\) with probability 0.25. No change occurs with probability 0.5. There is also no change if \(p^{n+1}\) exceeds 15 or becomes below 1. Use a time step of one month, \(p_{0}=i\), initial fortune scaled to 1, and simulate 1000 scenarios of length 20 years. Compute the mean evolution of one unit of money and the corresponding standard deviation. Plot the mean curve along with the mean plus one standard deviation and the mean minus one standard deviation. This will illustrate the uncertainty in the mean curve.
Hint 1
The following code snippet computes \(p^{n+1}\):
Hint 2
Filename: random_interest.
Exercise 4.20 (Simulate a population in a changing environment)
We shall study a population modeled by (Ch4.E3) where the environment, represented by r and f, undergoes changes with time.
 a)Assume that there is a sudden drop (increase) in the birth (death) rate at time \(t=t_{r}\), because of limited nutrition or food supply:This drop in population growth is compensated by a sudden net immigration at time \(t_{f}> t_{r}\):$$r(t)=\left\{\begin{array}[]{ll}\varrho,&t<t_{r},\\ \varrhoA,&t\geq t_{r}.\end{array}\right.$$Start with \(\varrho\) and make \(A> \varrho\). Experiment with these and other parameters to illustrate the interplay of growth and decay in such a problem.$$f(t)=\left\{\begin{array}[]{ll}0,&t<t_{f},\\ f_{0},&t\geq t_{a}.\end{array}\right.$$
 b)Now we assume that the environmental conditions changes periodically with time so that we may takeThat is, the combined birth and death rate oscillates around \(\varrho\) with a maximum change of ±A repeating over a period of length P in time. Set f = 0 and experiment with the other parameters to illustrate typical features of the solution.$$r(t)={\varrho}+A\sin\left(\frac{2\pi}{P}t\right)\thinspace.$$
Exercise 4.21 (Simulate logistic growth)
Filename: logistic_CN.
Exercise 4.22 (Rederive the equation for continuous compound interest)
The ODE model (Ch4.E7) was derived under the assumption that r was constant. Perform an alternative derivation without this assumption: 1) start with (Ch4.E5); 2) introduce a time step \(\Delta t\) instead of m: \(\Delta t=1/m\) if t is measured in years; 3) divide by \(\Delta t\) and take the limit \(\Delta t\rightarrow 0\). Simulate a case where the inflation is at a constant level I percent per year and the interest rate oscillates: \(r=I/2+r_{0}\sin(2\pi t)\). Compare solutions for \(r_{0}=I,3I/2,2I\).
Filename: interest_modeling.
Exercise 4.23 (Simulate the deformation of a viscoelastic material)
Stretching a rod made of polymer will cause deformations that are well described with a Kelvin–Voigt material model (Ch4.E49). At t = 0 we apply a constant force \(\sigma=\sigma_{0}\), but at \(t=t_{1}\), we remove the force so \(\sigma=0\). Compute numerically the corresponding strain (elongation divided by the rod’s length) and visualize how it responds in time.
Hint
To avoid finding proper values of the E and η parameters for a polymer, one can scale the problem. A common dimensionless time is \(\bar{t}=tE/\eta\). Note that \(\varepsilon\) is already dimensionless by definition, but it takes on small values, say up to 0.1, so we introduce a scaling: \(\bar{u}=10\varepsilon\) such that \(\bar{u}\) takes on values up to about unity.
Show that the material model then takes the form \(\bar{u}^{\prime}=\bar{u}+10\sigma(t)/E\). Work with the dimensionless force \(F=10\sigma(t)/E\), and let F = 1 for \(\bar{t}\in(0,\bar{t}_{1})\) and F = 0 for \(\bar{t}\geq\bar{t}_{1}\). A possible choice of t_{1} is the characteristic time \(\eta/E\), which means that \(\bar{t}_{1}=1\).
Filename: KelvinVoigt.
Copyright information
<SimplePara><Emphasis Type="Bold">Open Access</Emphasis> This chapter is distributed under the terms of the Creative Commons AttributionNonCommercial 4.0 International License (http://creativecommons.org/licenses/bync/4.0/), which permits any noncommercial use, duplication, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, a link is provided to the Creative Commons license and any changes made are indicated.</SimplePara> <SimplePara>The images or other third party material in this chapter are included in the work's Creative Commons license, unless indicated otherwise in the credit line; if such material is not included in the work's Creative Commons license and the respective action is not permitted by statutory regulation, users will need to obtain permission from the license holder to duplicate, adapt or reproduce the material.</SimplePara>