Flow through two tanks
two ODEs
Assume F0 = a, constant;
,
Two ODEs in two unknowns M1, M2:
General problem:
Approximate the derivative at the start of the step (tn):
NEW NOTATION!
xi(n) is the ith differential variable at time step n.
Explicit Euler:
Specify initial conditions: time t0, value of each differential variable xi(0).Vector notation:
Specify final time tf and step size h.
Initialise step counter n = 0.
do while tn < tfset tn+1 = tn + hend do
if tn+1 > tf thenset tn+1 = tfend if
redefine h = tf - tn
! DIFFERENT
do i=1,Mcalcend do![]()
calc xi(n+1) = xi(n) + h fi(n)
increment n by 1
return
Choose step size for initial local error of 1 kg on M1 and M2.
Calculation for M1
h = 10s.
Calculation for M2
h = 7.746s.
Details in section 4.4.6.1
So choose h < 7.746 s, say h = 7 s.
Results
Note minimum in M1.
Dynamic simulation reveals interesting, possibly unexpected behaviour.
Large tanks and vessels
large time constant
want large steps.
Small volumes or fast rate processes
small time constant
need small steps.
Step size is limited by the shortest time constant in the process:
(a) for accuracy of the fast dynamics,
(b) for numerical stability,even if fast dynamics no longer needs to be accurate.
If a system contains widely different time constants it is said to be stiff. Usually this means a range of at least 3 orders of magnitude in the time constants.
Assume total holdups in steady state. Recycle flow (F3) is fraction r of feed F0.
Model mole fraction of a dilute solute. Assume tanks are well stirred with mole fractions x1 and x2. Let T1 and T2 be tank residence times.
The solute mole fractions are modelled by
Model derivation in section 4.4.6.1
Simulate with T1 = 10s, T2 = 2000s, r = 0.6, x0 = 0.1 = constant.
ODEs:
| step | time | x(1) | x(2) |
| 0 | 0.0 | 0.00000 | 0.00000 |
| 1 | 1.0 | 0.01000 | 0.00000 |
| 2 | 2.0 | 0.01840 | 0.00001 |
| 3 | 3.0 | 0.02546 | 0.00002 |
| 4 | 4.0 | 0.03138 | 0.00004 |
| 5 | 5.0 | 0.03637 | 0.00007 |
| 10 | 10.0 | 0.05160 | 0.00024 |
| 20 | 20.0 | 0.06075 | 0.00069 |
| 40 | 40.0 | 0.06295 | 0.00167 |
| 100 | 100.0 | 0.06410 | 0.00457 |
| 200 | 200.0 | 0.06585 | 0.00922 |
| 300 | 300.0 | 0.06751 | 0.01364 |
| 800 | 800.0 | 0.07469 | 0.03271 |
| 900 | 900.0 | 0.07592 | 0.03599 |
2. h = 200 s ( = 10% of larger time constant)
| step | time | x(1) | x(2) |
| 0 | 0.0 | 0.000 | 0.000 |
| 1 | 200.0 | 2.000 | 0.000 |
| 2 | 400.0 | -60.000 | 0.320 |
| 3 | 600.0 | 1865.840 | -9.331 |
| 4 | 800.0 | -57951.014 | 290.696 |
Numerical instability destroys x(1) and then x(2).
Implicit Euler: solve a system of M NLAEs in M unknowns,
x1(n+1),..,xM(n+1):
Specify initial conditions: time t0, and each xi(0).
Specify tf and h.
Initialise step counter n = 0.
do while tn < tfset tn+1 = tn + hend do
if tn+1 > tf thenset tn+1 = tfend if
redefine h = tf - tn
! DIFFERENT FROM
! EXPLICIT EULER
solve simultaneous system of M NLAEsincrement n by 1![]()
...
return
Algorithm for NLAE solution insection 4.4.6.1
Example: two tanks with recycle.Linear ODEs and initial conditions as for explicit Euler.
h = 200 s
| step | time | x(1) | x(2) |
| 0 | 0.0 | 0.00000 | 0.00000 |
| 1 | 200.0 | 0.06381 | 0.00880 |
| 2 | 400.0 | 0.06875 | 0.01707 |
| 3 | 600.0 | 0.07163 | 0.02460 |
| 4 | 800.0 | 0.07421 | 0.03144 |
| 5 | 1000.0 | 0.07655 | 0.03766 |
| 10 | 2000.0 | 0.08543 | 0.06126 |
| 15 | 3000.0 | 0.09094 | 0.07592 |
| 20 | 4000.0 | 0.09437 | 0.08504 |
Implicit Euler solves the problem very effectively with a large time step.
Values are slightly behind (lower than) explicit Euler with h = 1 s.
Systems of ODEs
Stiff ODEs
Next - Section 4.4.7: Other Methods -
Euler is not the Only Method
Return to Section 4.4 Index
Return to Section 4 Index
Course Organiser Last modified: Wed Aug 5 12:33:01 BST