3. Solution of Ordinary Differential
Equations
There are analytical and numerical methods of solving
Ordinary differential equation.
The engineer would like to use the solution method
that gives the most insight into the system.
Therefore, analytical solutions are preferred in most
cases, because they can be used to:
1) Calculate specific numerical values,
2) Determine important functional relationships among
design and operating variables and system behavior,
3
4. Solution of ODEs …
3) Give insight into the sensitivity of the result to
changes in data.
These results are so highly prized that we often make
assumptions to enable us to obtain analytical
solutions; the most frequently used approximation is
linearizing nonlinear terms.
It is often cumbersome to obtain an analytical
expression for the response of a linearized system
when the system has more than one input and output.
4
5. Solution of ODEs …
It is not possible to derive analytical expression for
the response of a nonlinear system.
Numerical solution methods do not obtain analytic
solution.
Numerical solution methods provide a response that
is close to the true solution of the differential
equation.
The major drawback to numerical solutions is loss of
insight.
5
6. Solution of ODEs …
Analytical solutions: The analytical solution of linear
differential equations can be obtained using the
Laplace transform method.
The Laplace transform provides the engineer with a
powerful method for analyzing process control s/ms
Laplace transform changes ODEs into a set of
algebraic equations which are easier to solve &
analyze.
6
0
[ ( )] ( ) ( ) st
L f t F s f t e dt
1
( ) ( )
2
j
st
j
f t F s e ds
j
10. Solution of ODEs …
Since the Laplace transform is defined only for
single-valued functions, the transform and its inverse
are unique.
Example the fundamental model for deviation
variable of the CST: for C’A0 =∆CA0/s
Its solution from the table:
10
0 0
0
0
( ) ( ) ( ( ) ( ))
1 1 1
( ) ( ) ( ) (s)
1
A
A A A A A
A
A A A A
dC
V F C C VsC s F C s C s
dt
C
sC s C s C s C
s s
/
0( ) [1 ]t
A AC t C e
11. Solution of ODEs …
A nonlinear term can be approximated by a Taylor
series expansion to the nth order about a point if
derivatives up to nth order exist at the point:
Taylor series for functions of one and two variables:
- Function of one variable about xs
- Function of two variables about x1s , x2s
11
2
2
2
1
( ) ( ) ( ) ( ) ...
2!s s
s s s
x x
dF d F
F x F x x x x x
dx dx
Higher order
ignored
1 2 1 2
1 2 1 2 1 1 2 2
1 2, ,
( , ) ( , ) ( ) ( )
s s s s
s s s s
x x x x
F F
F x x F x x x x x x HO
x x
Deviation variable: (x - xs) = x' with xs = steady-state value
12. Solution of ODEs …
Example 2: Isothermal CSTR with a second-order
chemical reaction.
Goal: Determine the transient response of the tank
concentration in response to a step in the inlet
concentration for the nonlinear and linearized models.
Information: The process equipment and flow are
the same as shown in Figure of e.g. 1. The important
variable is the reactant concentration in the reactor.
Assumptions: The same as in Example 1.
12
13. Solution of ODEs …
Data: the chemical reaction rate is second order, with
rA = -kCA
2 and k = 0.5[(mole/m3) min]-1.
• F= 0.085 m3/min; V = 2.1 m3; CA0init = 0.925
mole/m3; ΔCA0 = 0.925 mole/m3; CAinit = 0.236
mole/m3;
• The reactor is isothermal.
Formulation:
13
0
2
0
( )
( )
A
A A A
A
A A A
dC
V F C C Vr
dt
dC
V F C C VkC
dt
14. Solution of ODEs …
Linearization of CA
2 using Tailor series:
Subtracting (2) from (1) gives
14
2
2 2 2 2C
(C ) (C ) ( ) (C ) (C ) 2 ( )
As
A
A As A As A As As A As
C
d
F F C C F F C C C
dx
2 2
2
0
C C 2 ( )
( ) [ 2 ( )]
A As As A As
A
A A As As A As
C C C
dC
V F C C VkC VkC C C
dt
Substituting CA
2 yields:
1
2
00 ( ) [ 2 ( )]As
A s As As As As As
dC
V F C C VkC VkC C C
dt
2
0( ) 2A
A A As A
dC
V F C C VkC C
dt
15. Solution of ODEs …
The resulting model is a first-order, linear ordinary
differential equation, which can be rearranged into
the standard form:
Then its Laplace transform is
The solution is
15
0
1
2
A
A A
As
dC F V
C C with
dt V F VkC
0
0
( )( 1) ( )
2
( )
( 1)
A p A p
As
p A
A
F
C s s k C s with k
F VkC
k C
C s
s s
/
0[1 ]t
A p AC k C e
16. Solution of ODEs …
For τ=3.62 min, kp=0.146 and ∆CA0= 0.925 mole/m3
Results Analysis: The linearized solution is plotted
in comparison with the solution to the original
nonlinear differential equation. The linear solution
can be seen to give a good semi quantitative
description of the true process response.
An important advantage of the linearized solution is
in the analytical relationships.
16
/3.62
0.135[1 ]t
AC e
18. Solution of ODEs …
The time constant (τ) and gain (kp) can be used to
learn how process equipment design and process
operating conditions affect the dynamic responses.
Clearly, the analytical solutions provide a great deal
of useful information on the relationship between
design and operating conditions and dynamic
behavior.
18
19. Solution of ODEs …
Numerical solutions: A first order initial value
problem of ODE may be written in the form
Example:
Numerical methods for ordinary differential
equations calculate solution on the points,
where h is the steps size
19
0( ) ( , ), (0)y t f y t y y
( ) 3 5, (0) 1
( ) 1, (0) 0
y t y y
y t ty y
htt nn 1
20. Solution of ODEs …
Euler Methods
Forward Euler Methods
Backward Euler Method
Modified Euler Method
Runge-Kutta Methods
Second Order
Third Order
Fourth Order
20
21. Solution of ODEs …
Forward Euler Method: Consider the forward
difference approximation for first derivative
Rewriting the above equation we have
So, is recursively calculated as
21
1
1,n n
n n n
y y
y h t t
h
1 , ( , )n n n n n ny y hy y f y t
1 0 0 0 0 0
2 1 1 1
1 1 1
( , )
( , )
( , )n n n n
y y hy y h f y t
y y h f y t
y y h f y t
ny
22. Solution of ODEs …
Example: solve
Solution:
etc
22
01, (0) 1, 0 1, 0.25y ty y y t h
1)0(,0for 00 yyt
1 1 0 0
0 0 0
for 0.25,
( 1)
1 0.25(0*1 1) 1.25
t y y hy
y h t y
2 2 1 1
1 1 1
for 0.5,
( 1)
1.25 0.25(0.25*1.25 1) 1.5781
t y y hy
y h t y
23. Solution of ODEs …
Backward Euler Method: Consider the backward
difference approximation for first derivative
Rewriting the above equation we have
So, is recursively calculated as
23
1
1,n n
n n n
y y
y h t t
h
1 , ( , )n n n n n ny y hy y f y t
1 0 1 0 1 1
2 1 2 2
1
( , )
( , )
( , )n n n n
y y hy y h f y t
y y h f y t
y y h f y t
ny
24. Solution of ODEs …
Example: solve
Solution:
Solving the problem using backward Euler method for
, yields
So, we have
24
01, (0) 1, 0 1, 0.25y ty y y t h
1 1
1
1
( 1)
1
n n n n n n
n n n n
n
n
n
y y hy y h t y
y ht y y h
y h
y
ht
333.1
25.0*25.01
25.01
1
,25.0for
1
0
11
ht
hy
yt
ny
26. Solution of ODEs …
Modified Euler method is derived by applying the
trapezoidal rule to integrating ; So, we have
If f is linear in y, we can solved for similar as
backward Euler method
If f is nonlinear in y, we necessary to used the method
for solving nonlinear equations i.e. successive
substitution method (fixed point)
26
( , )ny f y t
1 12 ( ), ( , )h
n n n n n n ny y y y y f y t
1ny
27. Solution of ODEs …
Example: solve
Solution:
f is linear in y. So, solving the problem using modified
Euler method for yields
27
01, (0) 1, 0 1, 0.25y ty y y t h
1 1 1 1 12 2
1 12 2
12
1
2
( ) ( 1 1)
(1 ) (1 )
(1 )
(1 )
h h
n n n n n n n n n
h h
n n n n
h
n
n nh
n
y y y y y t y t y
y t y t h
t
y y h
t
ny
28. Solution of ODEs …
For example 2 which is solved in the analytically, the
Euler method can be used, which involves the
solution of the following equation at each step, n:
An appropriate h was found by trial and error to be
0.05.
The numerical solution is shown in figure above
(dashes) as the result from the nonlinear model.
28
2
1 0[ ( ) k ]An An A n An An
F
C C h C C C
V
29. Solution of ODEs …
The second order Runge-Kutta (RK-2) method is
derived by applying the trapezoidal rule to integrating
over the interval . So, we have
We estimate by the forward Euler method.
29
( , )y f y t ],[ 1nn tt
),(),(
2
),(
11
1
1
nnnnn
t
t
nn
tyftyf
h
y
dttyfyy
n
n
1ny
30. Solution of ODEs …
So, we have
Or in a more standard form as
30
)),,((),(
2
11 nnnnnnnn ttyhfyftyf
h
yy
),(
),(where
2
1
112
1
211
nn
nn
nn
tkyhfk
tyhfk
kkyy
31. Solution of ODEs …
The third order Runge-Kutta (RK-3) method is
derived by applying the Simpson’s 1/3 rule to
integrating over the interval . So,
we have
We estimate by the forward Euler method.
31
( , )y f y t ],[ 1nn tt
1
1 1
2 2
1
1 16
( , )
( , ) 4 ( , ) ( , )
n
n
t
n n
t
h
n n n n n n n
y y f y t dt
y f y t f y t f y t
2
1ny
32. Solution of ODEs …
The estimate may be obtained by forward
difference method, central difference method for h/2,
or linear combination both forward and central
difference method. One of RK-3 scheme is written as
32
1ny
1
1 1 2 36
1
1
2 12 2
3 1 2 1
4
where ( , )
( , )
( 2 , )
n n
n n
h
n n
n n
y y k k k
k hf y t
k hf y k t
k hf y k k t
33. Solution of ODEs …
The fourth order Runge-Kutta (RK-4) method is
derived by applying the Simpson’s 1/3 or Simpson’s
3/8 rule to integrating over the interval
The formula of RK-4 based on the Simpson’s 1/3 is
written as
33
1
1 1 2 3 46
1
1
2 12
1
3 22
4 3
2 2
where ( , )
( , )
2
( , )
2
( , )
n n
n n
n n
n n
n n
y y k k k k
k hf y t
hk hf y k t
hk hf y k t
k hf y k t h
( , )y f y t ],[ 1nn tt
34. Solution of ODEs …
The fourth order Runge-Kutta (RK-4) method is
derived based on Simpson’s 3/8 rule is written as
34
1
1 1 2 3 48
1
1
2 13
1 1
3 1 23 3
4 1 2 3
3 3
where ( , )
( , )
3
2( , )
3
( 3 3 , )
n n
n n
n n
n n
n n
y y k k k k
k hf y t
hk hf y k t
hk hf y k k t
k hf y k k k t h