458.308 Process Control & Design
Lecture 3: Dynamic Simulation and Analysis
Jong Min Lee
Chemical & Biomolecular Engineering Seoul National University
Standard Form of the Model
.2 dependent variables and 2 independent variables .
. . ...
x˙1=f1(x1, x2, u1, u2) x˙2=f2(x1, x2, u1, u2)
f1, f2: some (nonlinear) functions ofx1, x2, u1, u2
There can be many more dependent variables and many more independent variables. What would be the form withn
dependent variables andmindependent variables?
Example: Interacting Tanks
h1(t) Pa q0(t)
h2(t)
q1(t) q2(t)
Pa q1=C′v1√
(Pa+ρgh1)−(Pa+ρgh2) =C′v1√
ρg(h1−h2) =Cv1
√h1−h2
q2=C′v2√
(Pa+ρgh2)−Pa=C′v2√
ρgh2=Cv2
√h2
Standard Form
d(A1h1ρ)
dt = ρq0−ρCv1
√h1−h2
| {z }
q1
d(A2h2ρ)
dt = ρCv1
√h1−h2
| {z }
q1
−ρCv2
√h2
| {z }
q2
x1
=∆h1,x2
=∆h2,u1
=∆q0
dh1
|{z}dt
x˙1
= q0−Cv1
√h1−h2) A1
| {z }
f1(x1,x2,u1)
dh2
|{z}dt
x˙2
= Cv1√
h1−h2−Cv2√ h2
A2
| {z }
f2(x1,x2,u1)
What can you do with the model?
Numerical integration(``simulation") to investigate the time behaviour of the dependent variables to a particularx(0)(initial condition) andu(t), t≥0(independent variable).
What does ``numerical solving" the ODEs mean?
Given:x(0)andu(t), t≥0 Obtain:x(t), t≥0
Analysis
Linearization
Analytical solution via Laplace Transform
Numerical Integration
. ..
1 Start withx1(0)andx2(0). Sett= 0. .
..
2 Take an incremental step (of size∆t, which cannot be large, why?) forward in time by solving
Forward Euler: Explicit integration
x1(t+ ∆t) = x1(t) + ∆t·f1(x1(t), · · ·) x2(t+ ∆t) = x2(t) + ∆t·f2(x1(t), · · ·) Backward Euler: Implicit Integration
x1(t+ ∆t) = x1(t) + ∆t·f1(x1(t+ ∆t), · · ·) x2(t+ ∆t) = x2(t) + ∆t·f2(x1(t+ ∆t), · · ·) Trapezoidal (2nd order R-K): Implicit Integration
x1(t+ ∆t) = x1(t) + ∆t·f1(x1(t), · · ·) +f1(x1(t+ ∆t), · · ·) 2
x2(t+ ∆t) = x2(t) + ∆t·f2(x1(t), · · ·) +f2(x1(t+ ∆t), · · ·) 2
. ..
3 Repeat this until you reach the desired end time.
Equilibrium Calculation
At steady state,d/dt= 0
0 = f1(¯x1, ¯x2, ¯u1, ¯u2) 0 = f2(¯x1, ¯x2, ¯u1, ¯u2)
Giventhe steady state values ofthe independent variables, one can calculate the corresponding steady-state values of the dependent values by solving the above equation.
Solving Algebraic Equations Numerically
Newton Iteration [ 0
0 ]
=
[ f1(¯x1, ¯x2) f2(¯x1, ¯x2)
]
≈
[ f1(¯xi1, ¯xi2) f2(¯xi1, ¯xi2)
] +
[ ∂f
1
∂x1
∂f1
∂x2
∂f2
∂x1
∂f2
∂x2
]
(¯xi1,¯xi2)
[ ¯x1−¯xi1
¯x2−¯xi2 ]
¯xi: current guess of the solutions
By solving the above approximate equation, one gets iterative formula:
[ ¯xi+11
¯xi+12 ]
= [ ¯xi1
¯xi2 ]
− [ ∂f
1
∂x1
∂f1
∂x2
∂f2
∂x1
∂f2
∂x2
]−1 (¯xi1,¯xi2)
[ f1(¯xi1,¯xi2) f2(¯xi1,¯xi2)
]
Example
0 = ¯q0−Cv1
√
ρg(¯h1−h¯2) 0 = Cv1
√
ρg(¯h1−¯h2)−Cv2
√ ρg¯h2 [ ¯hi+11
¯hi+12 ]
= [ ¯hi1
¯hi2 ]
−M−i 1
¯q0−Cv1
√
ρg(¯hi1−¯hi2) Cv1(¯hi1−¯hi2)−Cv2
√ ρg¯hi2
Mi =
− Cv1√ρg
2√
(¯hi1−¯hi2)
Cv1√ρg 2√
(¯hi1−¯hi2) Cv1√ρg
2√
(¯hi1−¯hi2) −2√Cv1√ρg
(¯hi1−¯hi2)−C2v2√√¯ρg
hi2
Linearization: 1
stOrder Approximation of ODEs Around an Equilibrium
x˙1 =f1(x1, x2, u1, u2) x˙2 =f2(x1, x2, u1, u2)
1st-order Taylor series expansion at the equilibrium
(¯x1, ¯x2,¯u1, ¯u2) [ x˙1
x˙2
]
≈
[ f1(¯x1,¯x2,¯u1,u¯2) f2(¯x1,¯x2,¯u1,u¯2)
] +
[ ∂f
1
∂x1
∂f1
∂x2
∂f2
∂x1
∂f2
∂x2
]
(¯x1,¯x2,¯u1,¯u2)
[ x1−¯x1 x2−¯x2
]
+ [ ∂f
1
∂u1
∂f1
∂u2
∂f2
∂u1
∂u2
∂x2
]
(¯x1,¯x2,¯u1,¯u2)
[ u1−u¯1
u2−u¯2
]
Linearized Model
.Standard Form: 2×2 System .
.
. ...
[ x˙1
x˙2 ]
≈ [ ∂f
1
∂x1
∂f1
∂x2
∂f2
∂x1
∂f2
∂x2
]
(¯x1,¯x2,¯u1,¯u2)
[ x1−¯x1
x2−¯x2 ]
+ [ ∂f
1
∂u1
∂f1
∂u2
∂f2
∂u1
∂u2
∂x2
]
(¯x1,¯x2,¯u1,¯u2)
[ u1−¯u1 u2−¯u2
]
Deviation variables:x′1≡x1−¯x1, etc.
[ x˙′1 x˙′2
]
=A [ x′1
x′2 ]
+B [ u′1
u′2 ]
Example
dh1
|{z}dt
x˙1
= q0−Cv1√ h1−h2 A1
| {z }
f1(x1,x2,u1)
dh2
|{z}dt
x˙2
= Cv1√
h1−h2−Cv2√ h2 A2
| {z }
f2(x1,x2,u1)
Linearization at¯h1,¯h2,¯q0
[ dh′
1 dhdt′2 dt
]
=
− Cv1
2A1√
¯h1−¯h2
Cv1 2A1√
¯h1−¯h2 Cv1
2A2√
¯h1−¯h2 − Cv1
2A2√
¯h1−¯h2 − Cv2
2A2√
¯h2
[ h′1 h′2
] +
[ 1
A1
0 ]
q′0
Laplace Transform -- Main Idea
LinearODEs ) ( ) (t ut dt y
dy+ =
τ
Solution
( )
( )
τζ ζ ζ τd u y t
y
t t
t
) ( exp
) 0 ( exp ) (
∫
0 − −+
−
=
Laplace Transform
) ( ) ( ) 1
( τ s + Y s = U s
Integration
Inverse Laplace Transform
1 ) ) (
( = +
s s s U
Y τ
Algebraic Manipulation
Laplace Transform -- Key Points
.Definition .
. . ...
F(s) =L[f(t)] =∫∞
0 f(t)e−stdt Lapalace Transform for simple signals
Steps, ramps, exponential decay or rise, pulse, impulse, etc.
Can be found by evaluating the integral See Table 3.1
Must memorize the simple ones
.Important Properties .
.
. ...
L(
df dt
)
=sF(s)−f(0) L(
d2f dt2
)
=s2F(s)−sf(0)−f′(0) L(∫t
0f(ζ)dζ)
= 1sF(s) L(f(t−δ)) =F(s)e−δs
Key Points
.Warning: LT is a linear operation!
. . . ...
L(af1(t) +bf2(t)) =aF1(s) +bF2(s) L(
y2(t))
̸
=Y2(s) L(y(t)u(t))̸=Y(s)U(s)
.Final and Initial Value Theorem .
.
. ...
tlim→∞f(t) = lim
s→0sF(s) f(0) = lim
s→∞sF(s)
Inverse Laplace Transform
Needed to take the solution obtained through Laplace transform back to the time domain.
The formula involves complex contour integral.
Usepartial fractionexpansion to break the solution down to small pieces and use the table (or your memory) to invert.
.
1.. Break downX(s)into sum of fractions X(s) = A1
s−p1
+ A2
s−p2
+· · ·+ Am
s−pm
.
2.. Using linearity property, write
x(t) = L−1{X(s)}=L−1 { A1
s−p1 }
+L−1 { A2
s−p2 }
+· · ·+L−1 { Am
s−pm }
= A1ep1t+A2ep2t+· · ·+Amepmt
Transfer Function
Linear differential equationwith a general forcing function (input)
1storder adydt +y(t) =Ku(t) 2ndorder bddt22y+adydt+y(t) =Ku(t)
· · ·
We can solve the eqn. for a specific forcing function, but we can also leave it general and take Laplace transform (with the initial condition zero!) to arrive at ageneral relationship between output and input.
Y(s) = K
as+ 1U(s); Y(s) = K
bs2+as+ 1U(s) With the transfer function, one can conveniently calculate the response of the output to any input bymultiplication.
Y(s) =G(s)U(s)
Single-Tank Draining
Assume that you start at the steady state: q0(0) = ¯q0, h1(0) = ¯h1
h1(t) Pa q0(t)
q1(t)
q1=Cv1√
Pa+ρgh1−Pa=C′v1√
ρgh1=Cv1
√h1
0 t
0 t
-q0(0) )
0(t q′
)
0(t q
q0(0)
deviation variable
Mass Balances
d(A1h1ρ)
dt =ρq0−ρCv1√ h1
| {z }
q1
Q. Do you think you can solve the above using L.T.?
A. No.
Linearize!
A1dh′1
dt =q′0− ( Cv1
2√
¯h1 )
| {z }
1/R1
h′1
Note: The above can be solved (using L.T.) but will the linear model be valid throughout the entire draining experiment?
Solution Based on the Linearized Model
A1dhdt′1 =q′0− R11h′1 withh′1(0) = 0, q′0(s) =−¯qs0
⇓ L
(
A1s+ 1 R1
)
H1(s) =−¯q0
s, H1(s) = −¯q0R1
s + ¯q0R1
s+A1
1R1
⇓ L−∞
h′1(t) =−¯q0R1
( 1−exp
(
− t
A1R1 ))
†Note: We can see thath1(t)is an exponentially decaying function oft.
Real Solution
Integrate the differential equation from time 0 totto obtain A1dh′1
dt = −Cv1√
h1, h(0) = ¯h
√1 h1
dh1
dt = −Cv1 A1
⇓ 2(√
h1(t)−√
¯h1)
= −Cv1 A1 (t−0) h1(t) =
(−Cv1 2A1 t+√
¯h1 )2
Comparison
0 0.5 1 1.5 2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time
Tank Level (h)
Linear Approximation Exact Nonlinear Solution
Interacting Tanks -- Revisited
[ dh′
dt1
dh′2 dt
]
=
[ −A11R1 A11R1
A21R1 −A12 (
R11 +R1
2
) ] [ h′1 h′2
] +
[ 1
A1
0 ]
q′0
⇓ L [ H′1(s)
H′2(s) ]
=
(s+A1
2
(1 R1+R1
2
)) 1 A1
(s+A1
2
(1 R1+R1
2
))(s+A1
1R1
)−A 1
1A2R2 1
Q′0(s)
1 A1A2R1
(s+A1
2
(1 R1+R1
2
))(s+A1
1R1
)−A 1
1A2R2 1
Q′0(s)
Impulse Response
0 t
)
0(t q′
M/∆t
∆t Area
= M ∆t→0
Q'0=M
[ H′1(s) H′2(s)
]
=
[ G1(s)·M G2(s)·M
] Inverse L.T.⇒
[ h′1(t) h′2(t)
]
Properties of Transfer Functions
Steady-state gain:G(0)-- Output change under aunit step changein input ast→ ∞
The order of the denominator polynomial = the order of the equivalent differential equation
Physical realizability:n≥m G(s) = Y(s)
U(s) = bmsm+bm−1sm−1+· · ·+b0 ansn+an−1sn−1+· · ·+a0 Additiveandmultiplicativeproperty