Professional Documents
Culture Documents
'
2 0
0
2 0
( ) ( )
( )
( )
x t x t
x t
t t
( )
( )
( ), x t h x t hf x t t
1
+ = +
( ) ( )
( )
( )
( ),
( ),
x t h x t h
f x t t f x t h t h
+ = +
+ + +
(
(
1
2
( ) ( )
( ), ( ),
( ) ( )
2
f x t t f x t h t h
x t h x t h
+ + + (
+ = +
(
( ) x t h +
( )
( ), f x t h t h + +
School of Chemical Engineering and Advanced Materials
Newcastle University
22
Improved Eulers Method: geometric interpretation
x(t)
t
( ) ( )
1
( ), ( ),
( ) ( )
2
f x t t f x t h t h
x t h x t h
+ + + (
+ = +
(
t
0
x(t
0
)
h=At
t
1
( )
1
( ) ( ) ( ), x t h x t hf x t t + = +
1 1
( ) x t
( )
1 1 1
( ), f x t t
( )
0 0
( ), f x t t
( ) ( )
0 0 1 1 1
( ), ( ),
2
f x t t f x t t +
1
( ) x t
School of Chemical Engineering and Advanced Materials
Newcastle University
23
Modified Eulers Method
Is another variation of the basic Eulers Method with the
aim of improving accuracy
It makes use of a gradient evaluated between integration
intervals to generate the solutions to the underlying ODE
Problem: again, the formula requires which has
yet to be calculated
( ) ( )
( ) ( ) ,
2 2
x t x t h h
x t h x t hf t
+ +
| |
+ = + +
|
\ .
( ) x t h +
School of Chemical Engineering and Advanced Materials
Newcastle University
24
Modified Eulers Method
The unknown is first estimated using the basic
Eulers formula:
( )
( )
( )
( )
, x t h x t hf
x t x t h
t
h
+ = +
+ +
+
|
\
|
.
|
1
2 2
( )
( )
( )
( ), x t h x t hf x t t
1
+ = +
( ) ( )
( ) ( ) ,
2 2
x t x t h h
x t h x t hf t
+ +
| |
+ = + +
|
\ .
( ) x t h +
School of Chemical Engineering and Advanced Materials
Newcastle University
25
Modified Eulers Method: geometric interpretation
x(t)
t t
0
x(t
0
)
h=At
t
1
( )
1
( ) ( ) ( ), x t h x t hf x t t + = +
1 1
( ) x t
( )
0 0
( ), f x t t
1
( ) ( )
( ) ( ) ,
2 2
x t x t h h
x t h x t hf t
+ +
| |
+ = + +
|
\ .
0 1
( ) ( )
,
2 2
x t x t h
f t
+
| |
+
|
\ .
0 1 1
( ) ( )
2
x t x t +
h/2
1
( ) x t
School of Chemical Engineering and Advanced Materials
Newcastle University
26
Eulers Methods and variations
( ) ( ) . ( ( ), ) x t h x t h f x t t + = +
( )
( )
( )
( ), x t h x t hf x t t
1
+ = +
( ) ( )
( )
( )
( ),
( ),
x t h x t h
f x t t f x t h t h
+ = +
+ + +
(
(
1
2
( )
( )
( )
( )
, x t h x t hf
x t x t h
t
h
+ = +
+ +
+
|
\
|
.
|
1
2 2
( )
( )
( )
( ), x t h x t hf x t t
1
+ = +
Eulers Method
Improved
Eulers Method
Modified
Eulers Method
School of Chemical Engineering and Advanced Materials
Newcastle University
27
General form of ODE solution methods
New value
= old value + integration interval function of gradient
This is the basis for a family of algorithms used to provide
numerical solutions of ODEs
A particular class is the Runge-Kutta algorithms
| |
( ) ( ) ( ( ), ) x t h x t h function f x t t + = +
School of Chemical Engineering and Advanced Materials
Newcastle University
28
Runge-Kutta (RK) Algorithms
approximates the terms
are coefficients
The order of the solution is given by n
Theoretically, the higher the order of the solution, the
more accurate is the method
1
( ) ( )
n
i i
i
x t h x t a k
=
+ = +
, 1, 2, ,
i
k i n =
hf (.)
, 1, 2, ,
i
a i n =
School of Chemical Engineering and Advanced Materials
Newcastle University
29
Special cases of RK algorithms
1
( ) ( )
n
i i
i
x t h x t a k
=
+ = +
1 1
1, ( ( ), ) If a k hf x t t = =
1 2
1 1 1
1
;
2
( ( ), ); ( ( ) , )
If a a
k hf x t t k hf x t k t h
= =
= = + +
1 2
1
1 1
0; 1;
( ( ), ); ( ( ) , )
2 2
If a a
k h
k hf x t t k hf x t t
= =
= = + +
General form of RK algorithms
Basic Eulers Method
Improved
Eulers Method
Modified
Eulers Method
School of Chemical Engineering and Advanced Materials
Newcastle University
30
RK4 Algorithm (4
th
order method)
( )
( ) ( ) x t h x t k k k k + = + + + +
1
6
2 2
1 2 3 4
( ) k hf x t t
1
= ( ),
k hf x t
k
t
h
2
1
2 2
= + +
|
\
|
.
|
( ) ,
k hf x t
k
t
h
3
2
2 2
= + +
|
\
|
.
|
( ) ,
( ) k hf x t k t h
4 3
= + +
( ) ,
School of Chemical Engineering and Advanced Materials
Newcastle University
31
Solving sets of 1
st
order ODEs
Chemical engineering systems are often described by
more than 1 ODE, e.g. dynamic material and energy
balances
At each integration interval, the equations are solved one
at a time, using the same methods as for single ODEs,
dx
dt
f t x i n
i
1
1
12 = = ( , , , , )
dx
dt
f t x i n
i
2
2
12 = = ( , , , , )
dx
dt
f t x i n
n
n i
= = ( , , , , ) 12
School of Chemical Engineering and Advanced Materials
Newcastle University
32
Solving higher order ODEs
All numerical ODE solution methods are designed for
applications to 1
st
order ODES
Therefore, the mth order ODE must be reduced,
somehow, to an equivalent set of 1
st
order ODEs
This can be achieved by defining some new variables
( )
d x
dt
f t x x x x x
m
m
m
=
, , ' , ' ' , , ,
( ) ( ) 3 1
( )
dx
dt
f t x x x x
m
m
= , , , , ,
1 2 3
m 1
st
order ODEs
School of Chemical Engineering and Advanced Materials
Newcastle University
34
Instability of numerical solutions of ODEs
Can occur due to propagation of errors (truncation of
Taylor series)
Stability is improved by use of small step sizes
choose step size to be <10% of smallest time constant
stable solution does not mean accurate solution
Further difficulty when considering sets of ODEs
sets of ODEs can contain states which have vastly different
speeds of responses
known as stiff set of equations
to improve stability of solution
choose step-size to match fastest dynamics
apply adaptive step-size algorithms, e.g. Kutta-Merson
algorithm, Gears method
School of Chemical Engineering and Advanced Materials
Newcastle University
35
Example:
( )
10 ( ) 2 ( )
in
dh t
h t Q t
dt
+ =
where h(t) = level of liquid in the tank at time t
Q
in
(t) = flowrate of liquid into the tank at time t
Initial conditions: h(0) = 10 cm, Q
in
(0)= 5 cm
3
s
-1
The relationship between the level in a
tank and liquid inflow is given by the
following ODE:
Q
in
Q
out
h
School of Chemical Engineering and Advanced Materials
Newcastle University
36
Example: solution procedure
( )
10 ( ) 2 ( )
in
dh t
h t Q t
dt
+ =
2 ( ) ( ) ( )
10
in
Q t h t dh t
dt
=
( )
( ) ( )
dh t
h t t h t t
dt
+ A = + A
2 ( ) ( )
( ) ( )
10
in
Q t h t
h t t h t t
(
+ A = + A
(
Select a value for = 1 (<10% of time-constant) t A
t 0 2 3 .
h(t) h(0) h(1) h(2) h(3) .
t A t A t A
0 10 20 30 40 50
10
11
12
13
14
15
16
17
18
19
20
Plot graph
E.g. Apply Eulers formula
Given
School of Chemical Engineering and Advanced Materials
Newcastle University
37
Example: results using At = 0.5
t Qin Eulers I. Eulers M. Eulers Analytical
4.0000 5.0000 10.0000 10.0000 10.0000 10.0000
4.5000 5.0000 10.0000 10.0000 10.0000 10.0000
5.0000 10.0000 10.5000 10.4875 10.4875 10.0000
5.5000 10.0000 10.9750 10.9512 10.9512 10.4877
6.0000 10.0000 11.4263 11.3924 11.3924 10.9516
6.5000 10.0000 11.8549 11.8120 11.8120 11.3929
7.0000 10.0000 12.2622 12.2111 12.2111 11.8127
48.0000 10.0000 19.8847 19.8707 19.8707 19.8709
48.5000 10.0000 19.8904 19.8770 19.8770 19.8772
49.0000 10.0000 19.8959 19.8830 19.8830 19.8832
49.5000 10.0000 19.9011 19.8887 19.8887 19.8889
School of Chemical Engineering and Advanced Materials
Newcastle University
38
Example: results using At = 0.5
0 5 10 15 20 25 30 35 40 45 50
10
11
12
13
14
15
16
17
18
19
20
t
h
(
t
)
Euler's
Improved Euler's
Modified Euler's
Analytical
School of Chemical Engineering and Advanced Materials
Newcastle University
39
Example: results using At = 2
t Q
in
Eulers I. Eulers M. Eulers Analytical
0 5.0000 10.0000 10.0000 10.0000 10.0000
2.0000 5.0000 10.0000 10.0000 10.0000 10.0000
4.0000 5.0000 10.0000 10.0000 10.0000 10.0000
6.0000 10.0000 12.0000 11.8000 11.8000 12.5918
8.0000 10.0000 13.6000 13.2760 13.2760 13.9347
10.0000 10.0000 14.8800 14.4863 14.4863 15.0341
38.0000 10.0000 19.7748 19.6574 19.6574 19.6980
40.0000 10.0000 19.8199 19.7190 19.7190 19.7528
42.0000 10.0000 19.8559 19.7696 19.7696 19.7976
44.0000 10.0000 19.8847 19.8111 19.8111 19.8343
46.0000 10.0000 19.9078 19.8451 19.8451 19.8643
48.0000 10.0000 19.9262 19.8730 19.8730 19.8889
School of Chemical Engineering and Advanced Materials
Newcastle University
40
Example: results using At = 2
0 5 10 15 20 25 30 35 40 45 50
10
11
12
13
14
15
16
17
18
19
20
t
h
(
t
)
Euler's
Improved Euler's
Modified Euler's
Analytical
School of Chemical Engineering and Advanced Materials
Newcastle University
41
Example: results using At = 5
0 5 10 15 20 25 30 35 40 45
10
11
12
13
14
15
16
17
18
19
20
t
h
(
t
)
Euler's
Improved Euler's
Modified Euler's
Analytical
School of Chemical Engineering and Advanced Materials
Newcastle University
42
Numerical solution of ODEs: summary
All numerical ODE solution methods are based on the
Taylor Series
Eulers Method is the most basic and is a 1
st
order method
Improved and Modified Eulers methods are 2
nd
order
methods
Higher order methods give more accurate solutions
The size of the integration interval also influences the
accuracy of the solutions (should be less than 10% of the
time constant)
Solutions of sets of 1
st
order ODEs are done sequentially
Solutions of higher order ODEs are achieved by
decomposing the problem into a set of 1
st
order ODEs