Você está na página 1de 59

Kinetics and Differential Equation Systems

A script by Stefan Trapp


former versions with Arno Rein

last update August 2019 by stt

graphs by Amelie
Table of Contents

0 Introduction
1 Ordinary Linear Differential Equations
1.1 Compartments
1.2 Mass balances / linear differential equations
1.3 From Mass to Concentration
1.4 Basic solution

2 Numerical solution methods for ordinary differential equations


2.1 Advantages and disadvantages of numerical methods
2.2 One-step Euler scheme
2.3 Four-step Runge-Kutta scheme
2.4 Comparison between Euler, Runge-Kutta scheme and analytical solution

3 Transport Processes
3.1 Advection (convection)
3.2 Diffusion
3.3 Dispersion
3.4 Combination of diffusion, dispersion and advection

4 Reaction, metabolism and elimination

5 Coupled differential equations - linear systems


5.1 Matrix format
5.2 Steady-state solution
5.3 Pulse input
5.4 Constant input for some time
5.5 General solution
5.6 Example simulation

6 Addition of metabolism and growth (non-linear terms)


6.1 Michaelis-Menten kinetics
6.2 Bacterial metabolism and growth kinetics
6.3 Determination of kinetic parameters

7 Non-linear systems dynamics

Appendix: ex 5.2 Solution of special compartment systems

2
0 Introduction

This script serves as reading material for the contribution of Stefan Trapp, Ordinary Differential
Equations, to the course 12 104 Environmental modeling.

The course is given only since 2009, and this is the third edition of this script. So, if you find errors,
please do not keep them but bring them to the author. They will be removed, if you do so.

The first chapters are a bit old (done with the DOS operation system in 1994) so forgive the design.
Thank you.

The script is only part of the teaching material. Other material are the lectures (usually available as
hand-out), the exercises, the tutorials and the assignments. All material will be placed in due time on
Campusnet.

Below find the relation between teaching and reading.

Table 0.1 Lectures related to this script and reading list


week Lecture Reading
1 Chemical kinetics (transport and degradation) Ch. 1-4
2 Systems, coupled differential equations Ch. 5-6
2 Tutorial, environmental models based on coupled ODEs Ch. 5-6
3 Assignment secret

Chapter 7 is needed only in years where food-chain simulations are done in the assignment. But it is
interesting, it is about chaotic systems :-)

Parts of the text were taken from the book Trapp & Matthies 1998: Chemodynamics. This is the book
we use(d) in 12233 Water Pollution. So of course, this script may also be helpful for other courses :-)

3
1 Ordinary Linear Differential Equations

The definition of ordinary differential equations (ODE) and many ways to solve them with ease is the
main topic of this script.

1.1 When do ordinary differential equations occur?


But when does the ordinary student meet ordinary differential equations? Isn’t the world always
changing in time and space? Well, at least these ODE are easy to recognize; any of them is written with
the “d”, for example

dm
= something
dt

In words, this means “change of money with time is ... something”. There is only one “derivative”, that is
time. The variable that changes is the money. If the change of money would vary with time and space,
we would have

∂m ∂e
= − + something
∂t ∂x

which means that the money changes in time, depending also on the change of expenses e with space
x. And now we have two derivatives (the variable can change in two ways, time and space). The sign ∂
is required to indicate a partial differential equation. This is perhaps far too trivial for the dear readers,
but the ordinary university teacher can still often seen this confused. Never mind.

So where, in real systems, do we have only a change with one derivative, usually time? For example,
well mixed reactors; closed glass vessels; many lab systems; and compartment systems, where the
mixing inside of one compartment is fast, compared to other changes. And because ordinary differential
equations are very easy to solve (yes, just wait a bit), a frequently and successfully applied approach is
the division of the environment into compartments. These compartments are assumed to be
homogeneously mixed and to exchange energy or matter (or else) between them. The detailed inner
structure of a compartment is neglected. Compartments can also be called 'reactor', 'boxes',
'reservoirs', 'tanks', 'pools'. Mathematically, the definition of compartments allows to derive equations as
ordinary differential equations (only variable with time, but not with space).

4
1.2 Mass balances / linear differential equations

The law of mass conservation is the basis for modelling substance fluxes (1st law of thermodynamics).
For compartments this means: the change of mass, ∆m(t), in the time interval ∆t within the
compartment is equal to source minus sink 1:

∆m(t) = { source (t) - sink (t) } ∆t

Source and sink are variable with time. The resulting new mass at time t = t0 + ∆t is

m(t) = m0 + ∆m(t) = m0 + { source (t) - sink (t) } ∆t

For continuous processes, and infinitively small time steps, the difference becomes the differential:

∆m dm
lim ∆t =
∆t →0 dt

If the source is independent of m(t), but the sink is proportional to m(t), then

∆m dm
lim ∆t = = −k m + I
∆t →0 dt

1.3 From Mass to Concentration

Despite we often make a mass balance, it is the concentration that we measure and that we wish to
know. For liquids (such as water), the concentration is mass (of chemical) divide by volume (of the
containing medium). See Figure 1.2 for concentrations in chemistry.

SI: unit is kg m-3


conventional unit: mg L-1 (= g m-3)

1
This is similar to the profit in an economic context: profit = d$/dt = {expenditure - costs} per time period

5
For solids (such as soils or sediments), the concentration is mass (of chemical) divide by mass (of the
containing medium).

SI: unit is kg kg-1


conventional unit: mg kg-1

Generally:

Concentration = mass m per volume V (liquids, gases)


or
Concentration = mass m per mass M (solids)

From derive concentrations, mass is divided by volume, thus

dm
= I −k ×m
dt
dC I
= − k ×C
dt V

These equations are linear differential equations of the first order with constant coefficient k and an
external input function I(t).

6
1.4 Basic solution

The solution depends on the initial value C(t0) = C0 and the input function I(t). Without input and with t0

= 0, the homogeneous linear differential equation of the first order arises with the solution

C (t ) = C 0 e − kt

Radioactive decay and many chemical reactions follow this equation. Half-life t1/2 is defined as
-1
t1/2 = ln 2 / k = 0.693 k

Residence time τr is the reciprocal of the elimination rate k:


-1
τr = k

With constant input I(t) = I0 the solution of the inhomogeneous linear differential equation of the first

order is

I
C (t ) = C 0 e − kt + (1 − e − kt ) Remember this equation.
Vk

Example 1.1: Well-mixed lake

A substance flows with a small river into a lake, is mixed into the lake and flows with the river out again.

Input: I = Cin x Q where Cin is inflow concentration (g m-3) and Q is volume flow of the river (m3 s-1)
Loss rate k (s-1) is Q/V where V is lake volume (m3). The basic equation is then, as before

dC I
= − k ×C
dt V

The analytical solution with C0 = 0 is (see Figure 1.2)

I
C (t ) = (1 − e − kt )
Vk
7
The steady-state concentration (= no change with time) can be found for t→∞
I
C (t = ∞) =
Vk

Alternatively, the steady-state can be found from setting the derivative dC/dt to zero:
dC I
= − k ×C = 0
dt V

Figure 1.1 Time course of concentration C(t) in the lake.

8
2 Numerical solution methods for ordinary differential equations

2.1Advantages and disadvantages of numerical methods


Numerics is a special field within mathematics. It deals with the solution of equations, i.e. finding the
most exact value. Numerical methods are iterative, i.e. they proceed step by step. This is extremely
troublesome by 'hand', but numerical schemes are frequently applied on computers.
Some of the advantages and disadvantages of analytical solution methods are (see Table 2.1):
Analytical solutions are easier to handle than numerical methods, they are stable and avoid numerical
errors. The resulting computer codes can run on small computers or even on table calculators. The
great disadvantage is that analytical solutions can only be found for special conditions. Variable initial
and boundary conditions can rarely be considered.

Numerical solution methods do not have these limitations. This allows advanced model formulations,
but then data and computation required increase considerably. A significant problem is the accuracy of
the numerical solution: a numerical process could give extremely unreal values. Note that all linear
differential equation systems with constant coefficients and constant input can be solved analytically.
Analytical solutions are more transparent for the reader and thus are didactically of more importance.

Table 2.1. Advantages of numerical and analytical solution.


Numerical solution Analytical solution
Easy on computer Easy by hand
May be wrong Always exact
For variable coefficients For constant coefficients only
Free input function Only few input functions
Can take time Exists only for special problems
Difficult to check calculation Transparent
needs computer needs brain
Good for practical work Good for education

2.2 One-step Euler scheme


The one-step Euler scheme is the easiest of all numerical schemes for the solution of ordinary
differential equations (and by no means the most accurate). It is suitable for the conveyance of the
principle.

9
Example: Reaction of the first order, no input
dC
= −k × C
dt
Substitute the differential quotient dC/dt with the differences quotient ∆C/∆t. By definition, dC/dt is the
limit of ∆C/∆t for ∆t→ 0. We get:

∆C
= −k × C and
∆t

∆C = − k × C × ∆ t

For C(t+∆t):

C(t+∆t) = C(t) + ∆C(t) = C(t) - k C(t) ∆t

and again:

C(t+∆t+∆t) = C(t+∆t) + ∆C(t+∆t) = C(t+∆t) - k C(t+∆t) ∆t ...

The selection of the time step ∆t is critical for this solution scheme. ∆t must be small enough to avoid
deviations of the linear approximation. But if the time step is too small, rounding errors occur. There is
no exact criterion for the best time step with the Euler scheme. In any case, it should be smaller than
the inverse of the fastest rate, ∆t < 1/k. Usually, when the time step is varied and the results do not
change (3 to 4 digits), the selected time step may be used. Problems occur mainly with rapid changes.
In this case, a very small ∆t needs to be selected.

2.3 Four-step Runge-Kutta scheme

Although the Euler scheme is easy, it is rarely used. A classical and frequently applied method is the
four-step Runge-Kutta scheme. The standard MatLab ode solver ode45 is based on such a fourth-order
Runge-Kutta solution. At first, four approximations for C(t+∆t) or y(x+∆x) are calculated; one partial
result is used for the next, and so on. The result for the total time step is calculated from the four partial
steps. In our example with the first-order reaction kinetics, this is:

Runge-Kutta scheme 4th Order


first step
s1 = -k C

10
second step
s2= -k (C + 1/2 ∆t s1)

third step
s3= -k (C + 1/2 ∆t s2)

fourth step
s4= -k (C + 1/2 ∆t s3)

and complete step


∆C = ∆t (s1 + 2 s2 + 2 s3 + s4)/6

and analogous to 2.33:


C(t+∆t) = C(t) + ∆C

and so on for all following time steps.

A criterion for the time step selection of the Runge-Kutta scheme is: testrk = |(s2 - s3)/(s1 - s2)| < 0.05
and this allows to find a time step before-hand.

2.4 Comparison between Euler, Runge-Kutta scheme and analytical solution

The comparison between the solution methods is shown by the example of the exercise (Table 2.2)..
The selected time step is large. The Euler scheme fails, but the Runge-Kutta scheme is only a few per
cent away from the (correct) analytical solution. Both Euler and Runge-Kutta schemes can be used for
the integration of ordinary differential equations. The latter is advantageous, although it involves slightly
more effort for the programmer.

Table 2.2 Exponential decay of a compound; initial concentration C(0) = 100 mg/L, degradation rate
-1
constant = 0.01 d and time step ∆t = 50 days (very long).
Time (days) Euler Runge-Kutta Analytical (exact)
50 50 60.6771 60.6531

100 25 36.8171 36.7879

150 12.5 22.3395 22.313

200 6.25 13.555 13.5335

250 3.125 8.2247 8.2085

300 1.5625 4.9905 4.9787

350 0.7812 3.0281 3.0197

testrk |(s2 - s3)/(s1 - s2)| = 0.25 (should be <0.05).

11
There may be cases where the Euler scheme is superior to the Runge-Kutta scheme. This is when
-5
coefficients of the matrix differ greatly (“stiff matrix”), e.g. between 100 and 10 . This case occurs often
when dynamics of chemicals in different environmental media are simulated (e.g. water and sediment).
More elaborated methods for the solution of such problems are described in textbooks on numerical
mathematics. In MatLab, these solvers have the name “s”, like ode23s, for “stiff problem”.

150 150

50 50
C

C
-50 0 1 2 3 4 5 -50 0 1 2 3 4 5

-150 -150
t t

Analytical Numerical Analytical Numerical

Figure 2.3. Example for numerical solution; left: time step=2 d (too high); right: time step=0.3 d; rate k =
1 d-1.

12
Section 3 Transport Processes

Until now, we considered interactions in a compartment system without looking at the underlying
physico-chemical processes. In the environment, important processes are transport and reaction, e.g.
flowing with a river or degradation. We now will consider these processes in more detail. At first, the
physical transport processes of ad/convection, diffusion and dispersion are described, followed by
chemical reaction processes.

Diffusion, dispersion and advection are universal processes. They appear in all environmental media.
Their description is the basis of many transport models of chemicals in water, air and soil. The mass of
substance decreases neither by diffusion, nor by dispersion or advection. They are pure transport
processes.

3.1 Advection (convection)

By flowing movement of the medium, the substance contained in it will be co-transported. The process
is called ad- or convection. First of all we will again look at one dimension. A substance is dissolved in
-1
water with the concentration C. The water flows with current velocity u (m s ) through the cross-
sectional area A (m2) (perpendicular to u), which gives the volume flow Q (m3 s-1). The change of
chemical mass is

dm/dt = J A = A u C = Q C

where J is the unit flow (kg m-2 s-1). The concentration change in time by advective substance flux can
be expressed as

dC/dt = A/V u C = Q/V C

Here, as before in the lake example, volume flow divide by volume gives the rate k.

If C and u are not constant, but depend on space in the interval ∆x = -V/A, then

dC/dt = - ∆/∆x (u C)

Having a spatially continuous flow, the difference quotient can be replaced by the differential quotient

∂C/∂t = - ∂(u C)/∂x

13
Now we have a partial differential equation with two derivatives (concentration changes with time t and
with space x). This is indicated by the ∂.

The equation is the continuity equation, based on the conservation of mass and energy. In segments of
the environment, the flow velocity may be assumed to be constant, then

∂C/∂t = - u ∂C/∂x

Basically identical are deposition (of aerosol in air to surfaces such as soil surface and leaves) and
sedimentation (of particles in water). They are often described by a deposition velocity:
dm
= v dep × A × C
dt
where vdep is the deposition velocity (m s-1) and C (here: kg m-3) is the concentration (which is present in
the aerosol or the particulate matter, per m3 air or water). Also deposition with rain ("wet deposition") is
an advective process.

3.2 Diffusion

The microscopic movement of molecules by heat leads to mixing and to the equalization of
concentration gradients. Particles or molecules show a net flux from places of higher to places of lower
concentration. This was first mathematically formulated by Fick (Fick's First Law, Barrow 1977). The
-1
process is called molecular diffusion. In the one-dimensional case, the net substance flux dm/dt (kg s )
2 -3
through an area A (m ) of thickness ∆x (m) at a given concentration gradient ∆C (kg m ) is:

dm/dt = Jdiff A = - A D ∆C/∆x


-1 -2 2 -1
Jdiff is the net substance flux through the unit area (kg s m ), D is the diffusion coefficient (m s ) and
-3 -1
∆C/∆x is the concentration gradient (kg m m ). The driving force for the diffusion are the concentration
gradients. The minus sign is convention: flux is in a positive x-direction when the concentration gradient
is negative.

Fick's First Law is only valid when


- the medium is isotrope (diffusion coefficient is the same in all directions)
- the flux by diffusion is perpendicular to the cross section area
- the concentration gradient is constant (else, the 2nd Law of Diffusion applies, see below).

14
First-order loss by diffusion

Another way to write down Fick's 1st Law is


dm1
× (C1 − C 2 )
D
= −A×
dt Dx

For C2 → 0 and because C = m/V

dC1 A D
=− × × C1
dt V Dx

And because V/A is depth (height) h

dC1 1 D
=− × × C1
dt h Dx

Look at the units here: Units: D has m2 s-1; h has m; ∆x has m → this gives a rate (unit s-1 or d-1)

1 D
× = k diff
h Dx

Thus, for the change of concentration:

dC1
= −k diff × C1
dt

This means, if the concentration in compartment 2 is zero, we can express diffusional loss as a simple
first-order rate process.

Partition coefficients

On the other hand, if compartment 2 is not of teh same phase as compartment 1 (e.g., 1 is water, but 2
is air), then the concentration in "diffusive equilibrium" (i.e. when the diffusion stops) is not necessarily
the same in both compartments.

Let KAW be the "partition coefficient (L L-1) between water and air” (dimensionless Henry’s Law
constant). Then

15
dmW
× (CW − C A / K AW )
D
= −A×
dt Dx

The diffusion stops when the gradient is zero, thus, when

CW = C A / K AW

or

CA
= K AW
CW

The same equation (with different partition coefficient) holds for other mixed-phase-diffusion processes,
e.g., at the water - sediment or the soil - air interface.

Diffusion coefficients
-5 -4 2 -1 -9 2 -1
The diffusion coefficient D in gases is within the range of 10 to 10 m s , in liquids about 10 m s
-14 2 -1
and in solids about 10 m s . It can be seen that D primarily depends on the aggregate state, and
diffusion in gases is most significant. The diffusion coefficient is proportional to temperature and
inversely proportional to the molecule volume. This again is related to the root of the molar mass. The
relation between the diffusion coefficients of two substances is therefore approximately

Di Mj
=
Dj Mi

M is the molar mass (g/mol), i and j are indices for two different chemicals. With this equation, an
unknown diffusion coefficient can be calculated approximately from known ones. The diffusion
coefficients of oxygen in aqueous solution, M (O2) = 32 g/mol, and of water vapour in air, M (H2O) = 18
g/mol, serve as reference values.
-5 2 2
DG (H2O) = 2.57 x 10 m /s = 2.22 m /d
-9 2 -4 2
DW (O2) = 2.0 x 10 m /s = 1.728 x 10 m /d

The quotient between diffusion coefficient D and diffusion length ∆x is conductance g (m/s), also known
as permeability P (m s-1), or as exchange velocity. Conductance g is inverse to resistance r (s/m):

D/∆x = 1/r = g = P

16
Unit r is s/m, unit g is m/s (a velocity). If more than one resistance occurs, the total resistance is
calculated from the Kirchhoff laws, similar to the electric resistance: with resistance in series (one after
another), the total resistance is the sum of the single resistances. When resistances are in parallel, the
conductances are added.

Resistances in series rtotal = r1 + r2 + ... + rn

Resistances in parallel gtotal = g1 + g2 + ... + gn

and r = 1 / g.

3.3 Dispersion

Molecular diffusion appears in all environmental media, e.g. in air, water and soil. Diffusion is a property
of the molecule (movement by heat, 2nd Law of thermodynamics). Other undirected mixing processes
can be described with similar equations, although the reason is not molecular diffusion. Turbulence of
the surrounding medium (random movement in one or all directions) causes a similar mixing process. It
is called dispersion. Dispersion is a property of the surrounding medium and is independent of
molecular properties. Dispersion is often orders of magnitudes faster than molecular diffusion. E.g. in
large rivers such as the Rhine, the dispersion coefficient, due to differences in flow velocity between
banks and middle of the river, is about 500 m2 s-1. Compare this to the molecular diffusion coefficient
(10-9 m2 s-1)!

Formally, dispersion can be described like molecular diffusion

dm/dt = Jdisp A = - Ddisp A ∆C/∆x

The molecular diffusion coefficient is replaced by the dispersion coefficient Ddisp. During turbulent
mixing, too, concentration gradients are equalized. The movement of the medium is the reason.
Dispersion is always connected to flow processes. Unlike diffusion, dispersion is unisotrop. The
transversal dispersion coefficient (perpendicular to the flow direction) is usually much smaller than the
longitudinal (in flow direction). During flow in porous media (e.g. soil or ground water), the dispersion is
caused by differences in flow length through different pores. In meteorology, the dispersion is called
"eddy diffusion". The dispersion coefficient is an empirical parameter and is found by calibration
("inverse modeling"), e.g. of tracer experiments.

17
3.4 Combination of diffusion, dispersion and advection

The combination of diffusive/dispersive and advective transport terms results in the diffusion/dispersion-
advection equation. With one dimension, where D is the sum of diffusion and dispersion coefficients:

∂C ∂ (uC ) ∂D∂C
=− +
∂t ∂x ∂x 2

Basic solution of the diffusion-advection equation


The mathematical advantage of compartmentilization of the environment is the independence of spatial
dimensions. Homogeneous mixing is assumed, leading to ordinary differential equations. But when
both spatial and dynamic changes are considered, partial diffential equations result. For the solution of
partial differential equations, not only initial conditions (time dependency), but also boundary conditions
(spatial dependency) need to be considered. Techniques for the analytical solution of partial differential
equations are separation of variables or Laplace transformation (Crank 1970).

For the initial and boundary conditions


- the diffusion/dispersion coefficient is constant in space and time,
2
- the cross-sectional area A (m ) and the flow velocity u (m/s) are constant,
- input m0 (kg) is at x=0 and time t=0,

- C(∞,t) = 0 (no boundary)


- degradation is with first-order rate k
the solution is

m0 ( x −ut )2
C ( x, t ) = A × e− 4 Dt
× e − kt
4π Dt

2
m0: substance input (kg) at t=0, A: cross-sectional area (m ), t: flow time (s), x: flow distance (m), u: flow
-1 2 -1
velocity (m s ), D: sum of diffusion and dispersion coefficients (m s ); k is degradation rate (s-1). The
advection is expressed as a transformation of the coordinate x with the flow distance u∗t. The equation
is very similar to the probability density of the normal distribution. This is because diffusion is an
independent stochastic movement of molecules, thus the resulting density (concentration) is normally
distributed.

18
Example 3.1: Accident, dispersion
A truck with a load of ten tonnes falls into the River Rhine; m0 = 10 000 kg. The Rhine in this segment
(near Cologne) has a width of approx. 333.3 m and a depth of 3 m, giving a cross-sectional area A of
2 2
1 000 m . An approximate value of the dispersion coefficent is 500 m /s (empirical value, >> molecular
diffusion). First of all let us just consider dispersion (flow velocity u = 0). We calculate concentration C
at x and t. The result is shown in Figure 3.1. The peak broadens due to dispersion. The mass is
unchanged. The peak concentration decreases, but a wider segment of the river is affected. Of course,
the example is completely fictitious, since dispersion does not exist without flow.

Example 3.2: Accident, dispersion plus advection


In rivers, dispersion, diffusion and advection occur simultaneously. At normal flow velocities, dispersion
is by far larger than diffusion. Advection is most important. Now, flow velocity u is 1 m/s. The result is
shown in Figure 3.2. While the water flows downstream, the peak broadens. At the same time, the
coordinate in flow direction changes due to advection. Again, the mass is conserved and the peak
concentration decreases, but now it flows downstream. Subsequently, new river segments are affected
downstream with lower concentration, but for a longer time period.

Figure 3.1 Effect of dispersion alone (left side) and dispersion plus advection.

19
4 Reaction, metabolism and elimination

The mass of the chemical can be changed by (bio)chemical reactions. Such reactions in the
environment could be, for example:
- hydrolysis (reaction with water, acids and bases)
- photolysis (reaction with sunlight, or with reactive radicals produced by light energy)
- biodegradation (reaction with enzymes or other biogenic compounds)
- oxidation (reaction with oxygen or burning)
- metabolism (transformation by biota without mineralization of the chemical)

In order to describe the time course of reactions, the velocity of a reaction is defined as concentration of
a reaction partner transformed per time period. Let us consider a reaction of the type

B+C→A

with concentrations B and C of the reaction partners and where C is our target compound (the
compound we observe, or measure). The reaction type depends mostly on the concentrations of
reaction partners B and C.

zero order
2
If the reaction velocity is independent of the
concentration of C (because there are many C but 1.5
few B and B is limiting), the reaction is of zero order:
1
C

dC
=λ 0.5
dt
C ( t ) = C ( 0 ) − λt 0
0 2 4 6 8 10

λ: reaction rate constant zero order, unit is Time

concentration per time.


100
first order
75
If there are only few white molecules C but many or
50
C

very many molecules B, the reaction type is usually


of the first order. 25

0 20
0 2 4 6 8 10
Time
dC
= − kC
dt
C (t ) = C (0) × e − kt

k is here the first order reaction rate constant with unit 1/time. When more reactions of first order type
occur, the rates can be added: k = k1+k2+...kn which is very practical for modeling (see above, first order
differential equations can be solved analytically).

second order
If both partner B and C are present in similar 100

amounts (which is not often the case), then the 75


reaction type is typically of the second order and

C
50
proportional to the product of the concentrations of
25
both partners B and C.
0
0 2 4 6 8 10
dC
= −k * × B × C Time
dt
C B
k* is the second order rate constant with the unit 1/(time ∗ concentration).

pseudo-first order
Second order reaction equations lead to non-linear (not 1st-order) differential equations which are
difficult to solve. But a reaction of the second order can be expressed as 'pseudo'-first order by
multiplying the second order rate constant with the concentration of the reaction partner B:

k = k* B

Michaelis-Menten kinetics
The velocity v of a enzymatically catalysed transformation (mass per time) depends on enzyme
concentration, substrate concentration (C), the affinity of the enzyme to the substrate (Km) and on the
maximal velocity (vmax). At high substance concentrations, a saturation effect will occur. This describes
the Michaelis-Menten equation:

21
v = (vmax C) / (Km + C)

where Km is the Michaelis-Menten constant. It gives the substrate concentration at which the enzyme
activity is half of the maximal velocity vmax. When C << Km, the transformation velocity is approximately

linear to C (first order reaction). When C >> Km, the transformation velocity is maximally vmax and

independent of C (zero order reaction). Analogous are the Monod kinetics for microbial degradation.

Foto: Happy bacteria doing party in a wastewater treatment plant.

22
Section 5 Coupled differential equations

Analytical solution for dynamic simulations

The most trivial solution is usually the steady-state. Whether or not the steady-state approach is
applicable depends also on the type of input function. Only for constant input, steady-state may be
used. For non-constant input, the analytical solution of the differential equation system succeeds for
pulse input and constant-over-time input function (Figure a and b). If the input is irregular (Figure c) and
cannot be described by a pulse input of by a rectangular input function, the numerical integration of the
equations is the only method of solution. Several analytical solutions for coupled differential equation
system and various input functions exist. This section will deal with analytical solutions
150 150
150
b c
a 100 100
100
C

C
C

50 50 50

0 0 0
0 10 20 30 40 50 60 70 80 0 10 20 30 40 50 60 70 80 0 10 20 30 40 50 60 70 80
Time Time Time

C plant background C source C plant C I

Figure 5.1 Different input functions and their consequence for the resulting concentration course; a)
repeated pulse input plus constant background; b) input from quasi-constant external source (changing
at t = 30 units) and c) irregular, variable input function. Loss rate k in all three examples 0.2 per time
unit.

5.1 Matrix format

Linear differential equations are of the general form:

dC
= −kC + b
dt

for a given compartment, where C (mg kg-1) is concentration, k (d-1) is a first-order loss rate constant
and b (mg d-1 kg-1) is constant input from external sources into the compartment, with b = I/M, i.e. input I
(mg d-1) divided by compartment mass M (kg). If two or more compartments are linearly related, this
leads to a matrix of the general form

23

dC  
= AC + b
dt

For 4 matrix elements, i.e. 4 compartments, the respective diagonal matrix is given by:

− k1 0 0 0 
  
dC  k12 − k2 0 0  
= C + b
dt  0 k 23 − k3 0 
 0 0 k 34 − k 4 


with vector of concentration C (mg kg-1), transfer rate constants kij (d-1) are the transfer rates from
compartment i to j, loss rate constants ki (d-1) are the sum of all first-order loss processes in
compartment i and b is the input vector (mg kg-1 d-1). The matrix elements k and b can be derived from
the differential equations (for concentrations) above.

The formulation as matrix is mathematically identical to

dC1
= −k1C1 + b1
dt
dC 2
= + k12 C1 − k 2 C 2 + b2
dt
dC 3
= + k 23 C 2 − k 3 C 3 + b3
dt
dC 4
= + k 34 C 3 − k 4 C 4 + b4
dt

Such diagonal matrices can be solved analytically, depending on the initial conditions and the input
function (see appendix).

24
5.2 Steady-state solution

Linear differential equations approach steady state for t → ∞, i.e. the change of concentration with time
is zero, dC/dt = 0. The steady-state solutions for matrix equations 1, 2 and 3 with continuous input are
as follows:

I1 b
C1 (t → ∞) = = 1
k1 M 1 k1

I2 k
C2 (t → ∞) = + 12 C1 (t → ∞)
k2 M 2 k2

I3 k
C3 (t → ∞) = + 23 C2 (t → ∞)
k3 M 3 k3

etc.

The steady-state solution follows the general scheme:

In k
Cn (t → ∞) = + n −1,n × Cn −1 (t → ∞)
kn M n kn

where n is the compartment number.

25
5.3 Pulse input

The analytical solutions for the differential equations 1, 2 and 3 for a pulse input is the same as for
initial concentrations C(0) ≠ 0:

C1 (t ) = C1 (0) × e − k1t

 e − k1t e − k 2t 
C 2 (t ) = k12 C1 (0) ×  +  + C 2 (0) × e − k 2t
 ( k 2 − k1 ) ( k1 − k 2 ) 

 e − k1t e − k2t e − k3t 


=
C3 (t ) k12 k23C1 (0)  + + 
 (k1 − k2 )(k1 − k3 ) (k2 − k1 )(k2 − k3 ) (k3 − k1 )(k3 − k2 ) 
 e − k2 t e − k3t 
+ k23C2 (0) ×  + 
 ( k3 − k 2 ) ( k 2 − k3 ) 
+ C3 (0) × e − k3t

The general solution scheme for pulse input to compartiment 1, i.e. C1(0) ≠ 0 and Cn(0) = 0 with n > 2 is
as follows:

 
n −1 n −k jt 
 e 
Cn (t ) = C1 (0) × ∏ ki ,i +1 ∑ n 
i =1  j =1 ∏ (k k − k j ) 
 k =1,k ≠ j 

and for pulse input into all compartments, i.e. Cn(0) ≠ 0 with n > 1:

 
n −1
 n −1 − k t

 n
e j 
Cn (t ) = ∑  Ca (0) × ∏ ki ,i +1 × ∑  + Cn (0) × e
− k nt

a =1
 i =a j =a
∏ (kk − k j ) 
 k = a ,k ≠ j 

26
5.4 Constant input for some time

The common analytical solution for one compartment with constant input b and initial condition C(0) =
C0, is:

C (t ) = C 0 × e − kt +
b
k
(
1 − e − kt )

The analytical solutions for C(t) in the 4 compartments, with initial condition Cn(0) ≠ 0 (compartment i)
are:

C1 (t ) =
b1
k1
( )
1 − e − k1t + C1 (0) × e − k1t

( ) ( )
C 2 (t ) = A × e − k1t − e − k 2t + B × 1 − e − k 2t + C 2 (0 ) × e − k 2t

C (t ) = D × (e
3
− k1t
− e − k 3t ) + E × (e
− k 2t
) ( )
− e − k 3t + F × 1 − e − k 3t + C3 (0 ) × e − k 3t

C (t ) = G × (e
4
− k1t
− e− k 4t ) + H × (e − k 2t
− e− k 4t) + I × (e − k 3t
) ( )
− e − k 4 t + J × 1 − e − k 4 t + C4 (0 ) × e − k 4 t

with:

C1 (0 )k12 k1 − k12 b1 k12 b1 + k1b2


A= B=
(k 2 − k1 )k1 k1 k 2
k 23 k 23 (C2 (0 ) − A − B )
D=A E=
k3 − k1 k3 − k 2

k 23 B + b3 k34
F= G=D
k3 k 4 − k1

k34 (C3 (0 ) − D − E − F ) k34


I= H =E
k 4 − k3 k4 − k2

k34 F + b4
J=
k4

27
5.5 General solution

The equations were obtained by integration. Further compartments can be added by further integration,
or by applying the general scheme. The analytical matrix solution with initial concentrations Cn(0) ≠ 0
and constant input terms bn, for n ≥ 2 and t0 = 0, follows the scheme:

    
    
n −1  n −1  −k jt −knt n −1  n −k jt  
 n
1− e
Cn (t ) = ∑ ∏ ki ,i +1 ⋅ Ca (0) ⋅ ∑ n
e e
+ ba ⋅ n − ba ⋅ ∑ ∑ m  
(kk − k j )  k s ∏ (kk − k j )  
n
a =1  i = a  j =a
∏ ∏ kl m=a j =a
 ∏


 k = a, l =a  s =i k = a,  
 k≠ j  k≠ j  

+ Cn (0) ⋅ e − k n t +
bn
kn
(
1 − e− k nt )

Even though complex, this solution allows the direct calculation of concentrations in all compartments
at any time t and for pulse- and/or constant input.

Combination of all solutions and superposition

Also for repeated applications there is a solution. This is a situation in which one, two or more
subsequent pulse inputs occur. In that case, the resulting concentration can be calculated by adding
the concentrations resulting from steady state and one, two or more pulse inputs. To this purpose, the
simulation is split up into several periods. The concentration vector C(t) at the end of a specific period
serves as initial concentration vector C(0) for the next period. This refers to concentrations in any
compartment (i.e. soil, roots and leaves).

Concentrations are additive. This means, concentrations resulting from constant background
contamination (e.g., from air) add to those concentrations from pulse- or constant input. Constant input
can also be used to simulate "rectangular" input functions, by splitting the simulation up into several
periods with different constant input. During each period, the conditions and parameters need to be
constant, but they may differ from one to the other period. This allows to simulate seasonal changes, or
day/night conditions, or other non-constant conditions. Such superposition is used in the famous
“Cascade models” that we use for simulations (Rein et al. 2011, and many other papers).

28
5.7 Non-diagonal matrices

So far, we only considered "cascades", i.e. diagonal matrices: There was a transfer from compartment
1 to 2, or 2 to 3, but never back from 2 to 1 or from 3 to 2. A solution for such a "non-diagonal" 2 x 2
matrix is found in WN Nazaroff and L Alvarez-Cohen: Environmental engineering science, John Wiley &
Sons New York, 2001, page 624-625.

The full 2 x 2 matrix

Consider the two coupled differential equations

dC1
= −a1C1 + a 21C 2 + I 1
dt

dC 2
= + a12 C1 − a 2 C 2 + I 2
dt

where a1 is the total loss rate from compartment 1 and is the sum of loss by degradation a11 (or other
elimination processes) plus loss from compartment 1 to compartment 2 with transfer rate a21; a2 is the
total loss rate from compartment 2 and is the sum of loss by degradation a22 (or other elimination
processes) plus loss to compartment 1 with transfer rate a12.

or, in matrix format



dC − a1 a 21   
= C + b
dt a12 − a2 

In words
The change of concentration (mass etc.) in compartment 1 is the loss proportional to the concentration
(the mass) in 1 plus the transfer from compartment 2 (proportional to concentration or mass in 2) plus
the input into compartment 1.

and

29
The change of concentration (mass etc.) in compartment 2 is the loss proportional to the concentration
(the mass) in 2 plus the transfer from compartment 1 (proportional to concentration or mass in 1) plus
the input into compartment 2.

This differs from all our earlier examples because there is a transfer from compartment 1 to 2 and
back from 2 to 1.

This we did not have before. And thus, it is no longer a diagonal matrix, and we require a very different
solution.

Step 1. Eight terms


Eight terms are formed.

Puh … what a set of equations. I hope I typed this in correctly! If you want to be sure check the original
text and/or compare to a numerical solution, yes?

And take care! When you defined from the beginning -a11 and -a22, all signs change, marked in red
above (Nazaroff and Alvarez-Cohen did so).

30
Step 2. Concentrations at time t

Once established you use these terms to calculate the concentrations at time t. Namely

C1 (t ) = T 6 + T 7 × e T 1∗t + T 8 × e T 2×t and

C 2 (t ) = T 3 + T 4 × e T 1∗t + T 5 × e T 2×t

And it works! Once you have used your time to program this solution, you can use these formulas to
solve ALL 2 x 2 linear differential equation systems! This solution can solve them almost all, with the
only exception that occasionally the constellation of rates leads to divide by zero errors, truly.

Real world example


The "full" matrix is very frequent - it is more or less the "generell case", that includes any other sub-
type of a 2 x 2 matrix.
Example: A chemical deposits from water (comp. 1) to sediment (comp. 2). This means loss from
compartment 1 (-a11) and gain for compartment 2 (+a12). Then the compound is resuspended back,
which is a loss for sediment (-a22) but a gain for water (a21) - and the matrix is full! Input may be via
emission or from outside (I1 or I2). And this is only one among many examples.

31
Test case (also for control of your solution)

Table. Matrix input data for example


Matrix names Nazaroff value Units
C1(0) B1 = C1(0) 1 kg/m3
I1 S1 = I1 1 kg/m3s
-a1 L1 = - a1 1 1/s
a12 A1 = a12 1 1/s
C2(0) B2 = C2(0) 3 kg/m3
I2 S2 = I2 3 kg/m3s
-a2 L2 = - a2 3 1/s
a21 A2 = a21 0.3 1/s

Calculated Terms
t1 r1 -0.8598246
t2 r2 -3.1401754
t3 C2ss 1.48148148
t4 F -0.1015569
t5 G 1.62007546
t6 C1ss 1.44444444
t7 H -0.2173497
t8 J -0.2270948

Resulting C1(t) and C2(t) Plotted C1 and C2 vs. t


Time (s) C 1 (t) C2(t)
0 1 3 3.5
0.1 1.079108 2.571767 3
0.2 1.14024742 2.260506 2.5
0.3 1.18798465 2.034564 2
C(t)

0.4 1.22567817 1.87083 1.5


0.5 1.25580227 1.752431
1
0.6 1.28018358 1.66705
0.7 1.30017403 1.605697
0.5
0.8 1.31677733 1.561813 0
0.9 1.33074152 1.530613 0 1 2 3
1 1.34262659 1.508608
Time

C 1 (t) C2(t)
C1 C2

In this figure, C1(t) and C2(t) were solved with the analytical solution above, while C1 and C2 represent
the result of a numerical solution method - there is almost no difference; and if, the numerical solution is
non-accurate.

32
Chapter 6 Metabolism and Growth (non-linear terms)

So far we considered only first-order (linear) systems. However, enzyme reactions typically follow the
Michelis-Menten kinetics, which is only in some cases first order.

6.1 Michaelis-Menten enzyme kinetics

In case of enzyme-mediated reactions, one reaction partner (the enzyme) is constant and is not used
up during reaction. The relation between concentration C and enzyme B can be so that
i) enzyme E is limiting or
ii) chemical C is limiting.

It is thus in between zero and first order reaction, depending on the amount of E and C. This leads to
the Michaelis-Menten kinetics of enzymatic processes

dm v C
= v = max × M
dt KM + C

where v (mg/d) is the removal of the substrate of concentration C (mg/L), vmax (mg d-1 g-1) is the
maximal removal rate per biomass (g organism), KM (mg/L) is the half-saturation constant (the
concentration C at which the reaction is half of maximum) and M is the mass of the organism (g). This
equation (the Michaelis-Menten kinetics) will lead to a first-order (exponential decay) curve when C <
KM; but it will lead to a linear decay when C > KM (see Figure).

Figure. Michaelis-Menten kinetics can be exponential (for C < KM) or linear (for C > KM).
33
6.2 Bacterial metabolism and growth kinetics

Most bacteria are heterotrophic organisms, that means, they need an organic substrate to feed on. This
substrate can be BOD (biological oxygen demand), or other carbon sources like xenobiotics, which are
then used by degrader bacteria. Bacteria have developed a wide range of enzymes that can chemically
alter xenobiotics. Xenobiotics can hereby be used as electron acceptor, electron donator, as energy
source or as precursor for other molecules. The growth of bacteria depends on the availability of
substrate. It is generally assumed that only dissolved molecules can be metabolised, and that the
chemical activity is the driving force for the reaction. There is no clear proof of the opposite yet.

Metabolism. Also the substrate consumption by bacterial enzymatic reactions is commonly described
by the Michaelis-Menten reaction kinetics. I write it here again because the units differ a bit from the
general formulation above:

dmM C
= v × X = vmax × X × (1)
dt KM + C

where X is the bacterial mass (g bacteria), t is time (d), vmax (g substrate / g bacteria /d) is the maximal
substrate consumption, C is the substrate concentration (g m-3); KM (g m-3) is the concentration at which
the true growth rate is half of the maximum growth rate (also known as Michaelis-Menten constant).

The substrate is used for growth and maintenance of bacteria (Uden 1967). The substrate requirements
for maintenance r (g substrate per gram bacteria and day = g g-1 d-1) is:

dmr
= −r × X (2)
dt
It is unclear whether "maintenance" means that naturally decaying bacteria (with death rate b) are replaced by
new-grown organisms, or whether maintenance needs are a basic metabolic need to keep the organism alive,
give it energy, replace proteins, fatty acids and other parts of the cells. Mathematically, this does not make a
difference.

After maintenance needs are satisfied, bacteria can use the remaining metabolized substrate for
growth. The substrate available for growth, mG, is thus

dmG dmM dmr C


= − = vmax × X × − r × X = (v − r ) X (3)
dt dt dt KM + C

34
Growth. Using the yield Y (g bacteria / g substrate), substrate consumption and bacterial growth and
maintenance can be related:

dX dmG dm dm C
= × Y = ( M − r ) × Y = vmax × X × ×Y − r × X ×Y (4)
dt dt dt dt KM + C

m max b
With Y = and Y = follows the equation for observed bacterial growth, dX/(X dt)
vmax r

dX
= µ −b (5)
X dt

where m is the "true" growth rate (d-1) and b is a maintenance, death or decay rate (Trapp et al. 2007).
The growth rate m depends on the substrate availability ("Monod-kinetics"),

m max C
m= (6)
KM + C

Then also directly

dX m C
= max × X − b × X (7)
dt KM + C

which is the Monod equation for bacterial growth kinetics expanded by a term for maintenance (Uden
1967, Bosma et al. 1997, Trapp et al. 2007).

6.3 Determination of kinetic parameters

In experiments, only bacterial mass X (or number) and substrate mass m can be observed directly.
Initially, neither mmax, nor b, r or Y are known. The experimentally observable growth rate is the change
of bacterial mass versus time per bacteria, dX/(X dt), not m.

Measured is dX/(X dt)

dX
= µ −b
X dt

and dm/dt

dmM
= v× X
dt

35
Yield. The experimentally derived yield Yexp (g bacteria / g substrate) is the ratio between change of
bacterial mass X and substrate mass m. If the only substrate loss is by metabolism, then

dX m −b
Yexp = =
dmM v

This Yexp is not a constant, but depends on the growth rate. It is also not identically with the “true” Y,
which is needed to derive mathematically the growth from metabolism. From eqs. 4 and 5 follows for
the mathematically required “true yield” Y

µ −b
Y=
v−r

The maximum substrate consumption vmax is typically more than factor 10 larger than the resources
needed for maintenance, r, therefore the true yield Y is often approximated (with an error < 10%) by the
ratio of maximum observed growth rate, Xmax/(X dt) to maximum substrate consumption vmax

dX max
X dt
Y≅
vmax

However, Xmax/(X dt) is not exactly equal to mmax (but to mmax – b). An appropriate way to find the true,
mathematically required yield Y is thus non-linear fit. But ok ... we stop here and leave this for later
times, ok?

Escherichia coli, smiling

36
Chapter 7 Non-linear systems dynamics

(The Miracle of Life)

This section is about the simulation of nonlinear systems - systems with Michaelis-Menten metabolisms
kinetics, Monod growth kinetics, predator-prey (Lottka Volterra) kinetics and similar. The matrix of these
systems is “non-linear”, that means, terms that are not 1st order occur. Such systems easily get non-
determinable, they produce “chaos”. That goes very rapid, even with easy equations!

I wish to show this with a simple example for a small lake ecosystem. In our tutorial to lecture 1, only
transport processes were considered, and this was leading to a linear differential equation system. As
we have seen in the previous section, growth of organisms leads to non-linear differential equations,
and the output (result) depends strongly on the initial conditions. Now we go a step further and add two
organisms - one is algae, feeding on phosphate (Monod growth), and the second is zooplankton
feeding on the algae (predator-prey). This leads to a nice chaotic system!

7.1 Definition: Nonlinear systems

In a linear system, the exponent on the state variable (m, chemical mass in our case) is 1 (this is why it
is also named "1st order").

Example:

dm/dt = A mb + I

A = a11, a12, a13 etc.

b = 1 (1st order)

In nonlinear systems, the exponent b is not one, i.e.

dm/dt = A mb + I

b ≠ 1 (not 1st order)

37
7.2 Example lake system

Phosphorus P in a lake

The first state variable is the mass (mg or kg) of phosphorous, P, in the lake. Let's consider purely
abiotic processes first. The phosphorous P comes into the lake via inflow, and is lost due to
sedimentation and due to outflow.

Mass balance

dm P
= Qin C in − Qout C P − k sed m P
dt

where Q is the volume flow of water (in = out), m3/d, Cin is the concentration in the inflow (kg/m3) and
CP is the average concentration in the lake after mixing (= outflow concentration). Deposition into
sediment is with 1st order rate ksed (= 0.01 d-1).

Dividing by lake volume V (m3) gives the differential equation for P concentration

dC P Qin C in Qout C P
= − − k sed C P
dt V V

or

dC P I
= − k CP
dt V

where I = Qin Cin and k is Qout/V + kSed.

The transient (time-dynamic) solution of this DE is


I
C P (t ) =C P (0)× e −kt + (1 − e −kt )
kV

The steady-state solution is

Qin Cin Qout C P


0= − − k sed C P
V V
Qin
CP = V × C in
Qout
+ k sed
V

38
Example calculation
Using the data in the table gives as result for the P concentration

1
CP = —————————— x Cin = 0.215 Cin
1 a-1 + 0.01 * 365 a-1

If Cin is 0.1 mg/L (0.1 g/m3), CP in the lake is 0.0215 mg/L. If the inflow concentration doubles, the
concentration in the lake also doubles.

We learn: Linear systems are linear to the input, or double input, double output.

Table 7.1. Example data P in a lake


Volume of lake V 1 000 000 m3
Inflow Qin 1 000 000 m3 a-1
Outflow Qout 1 000 000 m3 a-1
Initial P CP(0) 0 mg/L
Inflow P CPin 0.1 mg/L=0.1 g/m3
Sedimentation rate kSed 0.01 d-1 = 3.65 a-1

Also, the shape of the curve remains the same even if concentration increases factor 100 (see figures
below)

0.025 2.5
0.02 2
CP (mg/L)

CP (mg/L)

0.015
1.5
0.01
1
0.005
0.5
0
0 2 4 0
0 1 2 3 4 5
Time (years) Time (years)
Figure: Calculated P concentration in a lake, with k = 0.01 d-1 and Cin = 0.1 mg/L (left side) or Cin = 10
mg/L (right side).

General properties of linear systems

Analytical solution exists always (and that is very nice :-). For one variable, we had
I
C P (t ) =C P (0)× e −kt + (1 − e −kt )
kV
Steady-state solutions exist always (for t --> oo), for one variable we had
I
C (t = ∞) =
kV
First-order rates can be added (that is also very nice :-), ktotal = k1 + k2 + k3 ... (if same unit).

39
Addition of algae

Algae contain about f = 0.9 % P per mass. Thus, when algae (A) grow, phosphorous P in lake water is
reduced, but when they die, it is released again.

Phosphorus balance with algae

dmP/dt = Q Cin - Q CP - ksed mP ± uptake by algae

Algae growth related to phosphorus

P is a limiting factor for algae A growth, Thus, if more P is available, A grows faster. However, if
sufficient P is available, other factors may become limiting, and more P does not increase the algae
growth further. This type of growth kinetics is known as Monod kinetics (compare previous section).
The equation for the growth velocity μ (1/d) is

m max × C P
mA =
K M + CP

where μ is the growth rate (d-1), μ max is the maximum growth rate (d-1), CP is the concentration of
phosphorous, and KM is the half-saturation constant (the concentration of P at which growth is half of
maximal velocity), or CP = KM where μ = 1/2 μmax (see Figure).

2
Growth rate u (1/d)

0
0 1 2 3

C (mg/L)

K = 0.2 K=1

Figure: Growth rate μ versus P with μmax = 2 d-1 and KM = 0.2 or 1 mg/L.

40
Population dynamics (mass balance) for A

The algae grow with rate μ (d-1), but they also die. As long as this death is due to arbitrary events, more
algae die when more algae live, so that the death occurs with a constant 1st order rate kdie (d-1).
Additionally, algae may flow in and out of the lake with the water.

This gives the mass balance for algae A

dm A
= m A × m A − k die m A ± in / outflow
dt or

dm A m C
= max P × m A − k die m A ± in / outflow
dt K M + CP

or, expressed as concentration:

dC A m C
= max P × C A − k die C A ± in / outflow
dt K M + CP

Now, if algae grow, they take up phosphate, and if they die, P is released again. The mass balance of P
is modified to

dm P dm A
= Qin C in − Qout C P − k sed m P + f A ×
dt dt
or
dmP m × CP
= Qin Cin − Qout C P − k sed mP − f A × max × m A + f A × k die × m A
dt K M + CP

where fA is the fraction of P in algae (f = 0.009 kg P / kg A).

Simplifying assumption:
- P is released immediately when algae die.

Example calculation

In this first example calculation, we neglect P sedimentation, and the algae do not die. As a result, the
algae grow until all P is fixed in A biomass. At this point, CP = 0, algae growth stops, and then the
system remains in this state (the steady-state) forever. The same result (though with other final CA) is
obtained with higher initial CP (see figures below).

41
Table 7.2. Data used for example calculation
Initial P CP(0) 0.1 – 10 mg/L
Inflow P CPin 0.1 – 10 mg/L
Inflow A CAin 0 mg/L
Initial A CA(0) 1 mg/L
max. growth rate μmax 2 d-1
half-growth const. KM 0.2 mg/L
death rate kdie 0 d-1
P sedimentation rate ksed 0 d-1

15

10
C

0
0 10 20 30 40
Time (days)

CP x 100 CA
Figure: Example calculation for P and A concentration, with kdie = 0. Initial CP = 0.1 mg/L

120
100
80
60
C

40
20
0
0 10 20 30 40
Time (days)

CP x 100 CA
Figure: Example calculation for P and A concentration, with kdie = 0. Initial CP = 10 mg/L --> same result
for CP (CP --> 0).

42
Modification 1: When the algae die, the P is released again

As next step, we introduce the death rate, with kdie is 0.3 d-1.

Why is this system non-linear ?

Our basic DE was

dmP m × CP
= Qin Cin − Qout C P − k sed mP − f A × max × m A + f A × k die × m A
dt K M + CP

We can (by rearranging some parameters and multiplying the Monod term with KM + CP) write

dmP
= I − k C P − (a × K M C P + aC P2 ) × m A + k × m A
dt

Now it can be seen that the exponent on the state variable, CP is 2. It is a quadratic DE.

If we plot the result, an equilibrium between P and A is established, and both elements co-exist in the
lake. However, only as long as the death rate is not too high (< 0.7 d-1). Else, the algae die out (see
example with death rate = 1 d-1).

This is known as bifurcation: due to small changes in the input, the system goes to a very different end
state. We learn: the shape of the non-linear system depends on the initial conditions. No more double
input, double output. In non-linear systems, small changes in input can lead to large (unexpected)
changes in output.

12
10
8
C

6
4
2
0
0 10 20 30 40

Time (days)

CP x 100 CA

Figure: Example calculation for P and A concentration, with kdie = 0. Initial CP = 0.1 mg/L, death rate 0.3
d-1.

43
12
10
8
6
C

4
2
0
0 10 20 30 40

Time (days)

CP x 100 CA
Figure: Example calculation for P and A concentration, with kdie = 0. Initial CP = 0.1 mg/L, death rate 1 d-
1
.

Addition of Zooplankton Z

The next element in the ecosystem (and in our model) is zooplankton. Zooplankton feeds on algae, and
by this takes reduces the number of algae and takes up phosphorous.

Let's formulate the kinetics of algae grazing by zooplankton as "second order reaction", i.e. the chance
for eating increases both with the number of Z and the number of A. The success rate of Z is "keat". And
if the zooplankton has got an algae, it digests it with the "digestion efficiency" e (kg Z / kg A), which
describes how many kilogram of zooplankton develops from 1 kilogram algae.

The zooplanktion biomass is reduced by death, which is again described by a death rate. Then, the
mass balance for zooplankton is

dmZ
= +e × keat × m A × mZ − k die mZ
dt

or, as concentration (keat is now related to concentration)

dC Z
= +eC × k eat × C A × C Z − k die C Z
dt

In the mass balance of algae, the term for loss by being eaten is added:

dm A
= ... − keat × m A × mZ
dt

This gives the new algae mass balance (for A > 0)


dm A m C
= max P × m A − k die m A − k eat × mZ ± in / outflow
dt K M + CP
44
dC A m C
= max P × C A − k dieC A − k eat × C Z ± in / outflow
dt K M + CP

Algae mass and concentration depend now on P and Z, but P and Z also depend on A.

Summary: Equations for the complete system

The complete mass balance is now

dmP dm A dm
= − fA × − f Z × Z + Qin × Cin − Qout × C P − k sed mP
dt dt dt

dm A m C
= max P × m A − k eat × m A × mZ − k dieA m A ± in / outflow
dt K M + CP

dmZ
= +e × k eat × m A × mZ − k die mZ ± in / outflow
dt

or, formulated as concentrations

dC P dC A dC Q Q
= − fA × − f Z × Z + in × Cin − out × C P − k sed C P
dt dt dt V V

dC A m C
= max P × C A − k eat × C A × C Z − k dieAC A ± in / outflow
dt K M + CP

dC Z
= +e × k eat × C A × C Z − k die C Z ± in / outflow
dt

Figure: How an algae bloom develops in a real system.

45
7.3 Example simulations

Realistic parameter for the system (taken from a study in lake Furesø) are listed in the Table 9.3. The
simulation with this set of equations gives curves of a very different type - and of a very variable type.
Regular or non-regular periods, bifurcations, and large changes with very small changes of the input
are common. This is due to the chaotic nature of the system.

Table 7.3 Example data set


Initial P CP(0) 0.1 mg/L
Inflow P CPin 0.1 mg/L
P sedimentation rate ksed 0.01 d-1
Algae max. growth rate umax(A) 2 d-1
Algae half-growth const. KA 0.2 mg P/L
Algae P content f 0.009
Initial A CA(0) 1 mg/L
Initial Z CZ(0) 0.1 mg/L

Zoo. max. growth rate umax(Z) 0.2 d-1


Zoo. half-growth const. KZ 0.05 mg A/L
Zoo. feeding rate keat 2 g A Z-1 d-1
Zoo. dying rate kdie (Z) 0.1 d-1
digestion efficiency e 0.1 g Z / g A

Example 1: Classical algae bloom

Here, the initial phosphorous P is consumed by the algae A. If the concentration of algae increases,
zooplankton Z grows and eats the algae. Finally, algae die out, P is released again, and Z also slowly
dies out. If we continue for longer time periods, a similar algae growth event (“algae bloom”) will occur.
25
20
15
C

10
5
0
0 20 40 60 80

Time (days)

CP x 100 CA CZ*10

46
Bifurcation

A bifurcation means that the system at some point goes to the one direction. If one value is just a little
bit different, it will go to a very different or even opposite direction.

Example: Bifurcation - higher Z leads to no algae bloom

Here, the only change of the data is that the initial concentration of zooplankton is higher, i.e. Z(0) = 0.3
(unit) (kdie = 0.1 d-1). Then, algae cannot bloom.
12
10
8
6
C

4
2
0
0 20 40 60 80
Time (days)

CP x 100 CA CZ*10
Figure: no more algae bloom – zooplankton eats them all

Example: Bifurcation - higher death rate of Z leads to no growth of Z and high algae concentration.

Compared to the simulation 2a, only the death rate of Z is higher, i.e. kdie (Z) = 0.196.
12
10
8
C

6
4
2
0
0 10 20 30 40

Time (days)

CP x 100 CA CZ*10

Figure: Bifurcation - even higher death rate of Z leads to extinction of Z


Here, the death rate kdie (Z) is 0.3 d-1 . As a result, Z vanishes completely.
The examples shows a "bifurkation” at kdie (Z) ca. 0.2 d-1

If kdie (Z) < 0.2 d-1 --> algae vanish


47
If kdie (Z) ~ 0.2 d-1 --> coexistence of algae and zooplankton
If kdie (Z) > 0.2 d-1 --> zooplankton vanishes

Small variations of just 1 parameter give a completely different result !

This serves as an example for “chaos”. All data have a certain uncertainty. In a linear system, the
uncertainty of the result is linear to the uncertainty of the input. In a non-linear, chaotic system, very
small changes in input may lead to a completely different output. This means that quite often, no
prediction of events is possible ! "Chaotic systems" have non-predictable results, even though all
equations and data are known.

Note that ecosystems indeed show chaotic behavior!

Finally. some longer simulations for an oligotrophic lake (low P, C = 0.1 mg/L) and an eutrophic lake (C
= 1 mg/L), As can be seen, left hand, the oligotrophic lake has an occasional algae bloom but then
develops a stable, quiet ecosystem. The right had simulation with high P load (eutrophic) shows a very
cyclic simulation result, with repeated algae blooms (every 2-3 months, as in real lakes, except in
winter).

Figure: 1 year simulation with (left) low and (right) high concentration of phosphorous P.

Enough for now, yours,


teacher Stefan

48
7.4 Comparison Linear to Nonlinear Systems

Most systems with 2 or more non-linear equations show “chaotic” behaviour – e.g. movement of
planets, ecosystems, life in lakes. That makes predictions for such systems (example: ecosystems) so
very difficult, if not impossible: input data vary and change all the time, and the outcome depends
critically on many (uncertain) input data.

For the engineer, that has the practical consequence that dynamic simulations are not an adequate
way to predict the future of such systems. But it is a nice example for education :-)

Table 7.4 Linear versus non-linear systems


Linear Non-linear
Has always an analytical solution Has rarely analytical solutions
Comes always to steady-state (for t --> oo) Comes sometimes to steady-state
Linear to input non-linear to input
double input – double result no fixed relation between input and result
“robust” “chaotic”
– small changes of input mean small changes of – small changes of input can give completely
result different result
Good for prediction Prediction almost impossible
(uncertainties in input data)
Good for explanation May explain unexpected results
explains the “real” life
Describes chemistry Describes life
Mathematically “easy” Mathematics quite exciting

49
References

All references are available. Please ask for when needed.

If you find mistakes - bring them to me and we will eliminate them, yes?

50
Appendix to Chapter 5 Solution of systems of differential equations

If mass or concentrations in more than one compartment are considered, a system of ordinary
differential equations results. All compartment systems leading to n linear differential equations (n
compartments) with constant coefficients are now considered. Vectors are given in bold print.

The system of DE is
dm1(t)/dt = a11 m1(t) + a12 m2(t) + ... + a1n mn(t) + I1(t)

dm2(t)/dt = a21 m1(t) + a22 m2(t) + ... + a2n mn(t) + I2(t)

dmn(t)/dt = an1 m1(t) + a12 m2(t) + ... + ann mn(t) + In(t)

For compartment i:
n
dmi(t)/dt = ∑ aij mj(t) + aii mi(t) + Ii(t)
j=1,j≠i

The first term on the right is the exchange with all other compartments j. The second term includes all
sinks from compartment i (e.g. degradation, aii is negative). The third term on the right represents all

external sources into compartment i.

Written as matrix:
.
m(t)= A m(t) + I(t)

where
.
m(t) = vector of differential quotient dmi(t)/dt (change of mass with time)
A = compartmental or systems matrix (although bold, not a vector)
m(t) = vector of masses, state variable
I(t) = input vector

51
5.1 Steady-state solutions

Steady-state means that the system does not change with time. The fluxes are in equilibrium, sources
and sinks are balanced. The differential term of the equation system is zero:

Am+I=0

A linear equation system results which is easily solved by the usual methods, e.g. by Gaussian
elimination. Linear differential equation systems come to a steady-state for t∞.

Example 1.2: Aquarium

Let us consider the "aquarium", a two-compartment system, Fig. 5.1

Figure 5.1 Two-compartment "aquarium" system with fish and water.

The fish takes up a substance from the surrounding water with the rate constant k1 and secretes it with

a clearance rate constant k2. The mass balance is:

dmW(t)/dt = -k1 mW(t) + k2 mF(t)

dmF(t)/dt = k1 mW(t) - k2 mF(t)

Assuming no substance is lost, we have a closed system. In a steady-state (dmF(t)/dt = dmW(t)/dt = 0)

the following concentration ratio between fish and water applies; * denotes steady-state conditions:

dmW/dt = -k1 mW* + k2 mF* = 0

52
k1 mW* = k2 mF*

k1/k2 = mF*/mW* = VF CF* / (VW CW*)


k1 VW / (k2 VF) = k1'/k2' =

= CF*/CW* = bioconcentration factor BCF

The concentration ratio at t∞ is thus determined by the quotient between uptake and clearance rate
constant at a given volume. This is frequently used for the experimental determination of the
bioconcentration factor. The concentration in the water is measured at different times. From the
concentration course (initially contaminated water and clean fish), the uptake rate k1' is calculated. The

fish is then brought into clean water. The clearance rate k2' is determined by the increase in

concentration there.

The OECD fish test for bioaccumulation of chemicals uses this principle: Uptake and clearance rates
are determined, and the bioconcentration factor BCF is the ratio of the rates.

53
Solution of special compartment systems
This Chapter is very ugly type-set, it is very old Word. It is about how to find the solutions that are listed
in Chapter 5. If you do not need this (and why should you?) you can go back to Chapter 5. If you need it
- ask for LaTech version, I have one. Otherwise, it is also seen in the book Trapp & Matthies,
Chemodynamics,1998.

In some special cases the differential equation systems can be directly solved by repeated integration.

Example Cascade
A liquid flows through a cascade of two tanks.

Figure 5.2 Cascade.

The mass balance is therefore

dm1(t)/dt = -k1 m1(t)

dm2(t)/dt = k1 m1(t) - k2 m2(t)

The initial substance masses are m1(0) = m0 and m2(0) = 0; with t0 = 0, m1(t) is:

m1(t) = m0 exp(-k1 t)

For m2(t) we get:


dm2(t)/dt = k1 m0 exp(-k1 t) - k2 m2(t)

From this it follows by integration for m2(t):

54
m2(t) = k1 m0/(k2 - k1) [exp(-k1 t) - exp(-k2 t)]

For a cascade of length three (= three compartments) we get:

exp(-k1t) exp(-k2t) exp(-k3t)

{ }
m3(t) = k1 k2 m0 ------------------- + ------------------ + -----------------
(k2-k1)(k3-k1) (k1-k2)(k3-k2) (k1-k3)(k2-k3)

Cascade, solution method

The general solution scheme for linear differential equation systems is applied to the cascade example.
The system for n=3 is:

dm1(t)/dt = - k1 m1(t)
dm2(t)/dt = + k1 m1(t) - k2 m2(t)

dm3(t)/dt = + k2 m2(t) - k3 m3(t)

Written as matrix:

.
m(t) = A m(t)

where
.
m(t) = vector of the differential quotients dmi/dt (change of mass); A = compartmental- or systems
matrix; m(t) = vector of masses

.  -k1 0 0 
m(t) =  k1 -k2 0  m(t)
 0 k2 -k3 

The corresponding homogeneous linear diffential equation system only has a non-vanishing solution if

det|A - λ E| = 0

55
 -k1-λ 0 0 
det  k1 -k2-λ 0  = 0
 0 k2 -k3-λ 

For n=3 the determinant can be found by the rule of Sarrus:

det = a11 a22 a33 - a11 a23 a32


+ a12 a23 a31 - a12 a21 a33

+ a13 a21 a32 - a12 a22 a31

det = (-k1-λ)(-k2-λ)(-k3-λ)

For the condition det = 0 = (-k1-λ)(-k2-λ)(-k3-λ) it follows

λ1 = -k1; λ2 = -k2; λ3 = -k3

The eigenvectors u of A are the non-vanishing solutions of

(A - λ E) u = 0 or λEu=Au

With the first eigenvalue λ1 for the eigenvector u1

λ1 u11 = -k1 u11 + 0 u12 + 0 u13

λ1 u12 = +k1 u11 + (-k2) u12 + 0 u13

λ1 u13 = 0 u11 + k2 u12 +(-k3) u13

since λ1 = -k1 it follows

u11 can be chosen arbitrarily, useful = 1

56
u12 = k1/(k2-k1)

u13 = (k1 k2)/[(k2-k1) (k3-k1)]

Analogously with λ2 and λ3 for u2 and u3:

u21 = 0; u22 = 1; u23 = k2/(k3-k2);

u31 = 0; u32 = 0; u33 = 1;

If these values are inserted into the general solution then

m(t) = c1 exp(λ1t) u1 + c2 exp(λ2t) u2 ... + cn exp(λnt) un

and
m1(t) = c1 exp(-k1 t)

c1 k1 exp(-k1 t)
m2(t) = ― ------------------------ + c2 exp(-k2 t)
k2 - k1

c1 k1 k2 exp(-k1 t) c2 k2 exp(-k2 t)
m3(t) = ------------------------- + ---------------------- + c3 exp(-k3 t)
(k2 - k1) (k3 - k1) (k3 - k2)
The coefficients ci follow from the initial conditions. With m1(t=0) = m0, m2(t=0) = 0 and m3(t=0) = 0 we

get

m1(0) = c1 exp(-k1 t); with exp(0) = 1 follows: c1 = m0;

m2(0) = c1 k1 / (k2-k1) + c2 = 0;

It follows that

c2 = -m0 k1 / (k2-k1)

57
c1 k1 k2 c2 k2
m3(0) = ------------------- + --------- + c3
(k2-k1)(k3-k1) k3-k2

m0 k1 k2
c3 = ------------------
(k1-k3)(k2-k3)

Finally, we get

m1(t) = m0 exp(-k1 t)

k1 m0
m2(t) = --------- [exp(-k1 t) - exp(-k2 t)]
k2-k1

exp(-k1 t) exp(-k2 t) exp(-k3 t)

m3(t)= k1 k2 m0 { ------------------ + ------------------- + -------------------}


(k2-k1)(k3-k1) (k1-k2)(k3-k2) (k1-k3)(k2-k3)

identical to the equations above.


General solution method for linear differential equation systems

Let us consider a system of linear differential equations of the form

.
m(t) = A m(t) + I(t)

where
.
m(t) = vector of differential quotients dmi/dt; A = compartmental or systems matrix (constants)
m(t) = vector of masses; I(t) = input vector

The corresponding homogeneous differential equation system (homogeneous in this context means: I =
0) only has a non-vanishing solution if:

58
det(A - λ E) = 0 (E is the unit matrix)

The eigenvalues λ of A are the roots of the 'characteristic polynomial'. The eigenvectors u of A are the
non-vanishing solutions of

(A - λ E) u = 0

If the n x n matrix A has n independent eigenvectors of the eigenvalues λ1,..,λn (λ1,..,λn need not be

different), then the general solution of the linear differential equation system is:

m(t) = c1 exp(λ1t) u1 + c2 exp(λ2t) u2 +...+ cn exp(λnt) un

The constants ci are calculated from the initial conditions (t=0). In the case of multiple eigenvalues,

independent eigenvectors can also always be found.

A solution can also be found for the inhomogeneous equation system with I(t):

t
m(t)= exp(A t) m0+ ∫ exp[A (t-t')] I(t') dt'
0

Instead of the scalar exponent, we have here the matrix exponential. If I(t) = 0, the homogeneous
solution is

m(t)= exp(A t) m0

The calculation of the matrix exponential exp(A t) can be found in mathematical text books.

Hello students! Don't worry: you do not need to derive these solutions of differential equation systems
yourself (it is sufficient if you know where to find the solutions, and know how and when to apply). But
we thought you might be interested to know how these solutions are found - just as a proof that we do
not lie.

59

Você também pode gostar