You are on page 1of 42

Selected Differential System Examples

from Lectures
Liquid Storage Tank
wi

V = Ah

wo

Standing assumptions
Constant liquid density
Constant cross-sectional area A
Other possible assumptions
Steady-state operation
Outlet flow rate w0 known function of liquid level h
Mass Balance
Mass balance on tank
d ( Ah) dh
wi w0 A wi w0
dt dt
in out
accumulation

Steady-state operation: 0 wi w0 w0 wi
Valve characteristics
Linear wo Cv h Nonlinear wo Cv h

Linear ODE model dh


A wi Cv h h(0) h0
dt
Nonlinear ODE model
dh
A wi Cv h h(0) h0
dt
Stirred Tank Chemical Reactor
Overall mass balance

d ( V )
0 qi q qi q
dt
Component balance
A k B
d (VC A )
r kC A qi C Ai qC A kC AV
dt
dC A q
(C Ai C A ) kC A C A (0) C A0
dt V
Assumptions
Pure reactant A in feed stream
Perfect mixing
Constant liquid volume
Constant physical properties (, k)
Isothermal operation
Plug-Flow Chemical Reactor

qi, CAi qo, CAo


CA(z) z

z A k B
r kC A
Assumptions
Pure reactant A in feed stream
Perfect plug flow
Steady-state operation
Isothermal operation
Constant physical properties (, k)
Plug-Flow Chemical Reactor cont.

qi, CAi qo, CAo


CA(z) z

z
Overall mass balance
Component balance

( q) z ( q ) z z 0 (qC A ) z (qC A ) z z kC A Az 0


Mass in Mass out A in A out A consumed

(q ) z (q ) z z q (C A ) z (C A ) z z
lim 0 lim kC A 0
z 0 A z
z 0
z
dq q dC A
0 kC A 0
A dz
dz q dC A
qi q0 q kC A 0 C A (0) C Ai
A dz
Continuous Biochemical Reactor

Exit Gas Flow

Fresh Media Feed


(substrates)

Agitator

Exit Liquid Flow


(cells & products)
Cell Growth Modeling
Specific growth rate
1 dX
X biomass concentration (g/L)
X dt
Yield coefficients
Biomass/substrate: YX/S = -X/S
Product/substrate: YP/S = -P/S
Product/biomass: YP/X = P/X
Assumed to be constant
Substrate limited growth
S
(S ) m
KS S

S = concentration of rate limiting substrate


Ks = saturation constant
m = maximum specific growth rate (achieved when S >> Ks)
Continuous Bioreactor Model
Assumptions
Sterile feed
Constant volume
Perfect mixing
Constant temperature and pH
Single rate limiting nutrient
Constant yields
Negligible cell death

Product formation rates


Empirically related to specific growth rate
Growth associated products: q = YP/X
Nongrowth associated products: q =
Mixed growth associated products: q = YP/X
Mass Balance Equations
Cell mass
dX dX
VR FX VR X DX X
dt dt
VR = reactor volume
F = volumetric flow rate
D = F/VR = dilution rate
Product
dP dP
VR FP VR qX DP qX
dt dt
Substrate
dS 1 dS 1
VR FS 0 FS VR X D( S 0 S ) X
dt YX / S dt YX / S
S0 = feed concentration of rate limiting substrate
Exothermic CSTR
A k B
k (T ) k0 exp E / RT
Q UA(Tc T )
Scalar representation
dC A q
(C Af C A ) k0 exp( E RT ) C A C A (0) C A0
dt V
dT q ( H )k0 exp( E / RT )C A UA(Tc T )
(T f T ) T (0) T0
dt V C p VC p
Vector representation
q
(C C ) k exp( E / RT )C
CA V
Af A 0 A
y f (y ) q (H )k0 exp( E / RT )C A UA
T (T f T ) (Tc T )
V C p C pV
dy C A0
f (y ) y (0)
dt T
0
Isothermal Batch Reactor
CSTR model: A B C
dC A dC B
k1C A k1C A k 2C B C A (0) 10, C B (0) 0
dt dt
Eigenvalue analysis: k1 = 1, k2 = 2
C A (t ) dy 1 0
y (t ) y Ay
C
B (t ) dt 1 2
0 1
1 2 x (1)
2 1 x
( 2)

1 1
Linear ODE solution:
C A (t ) (1) 1t ( 2 ) 2 t 0 2t 1 t
y (t ) c1x e c2 x e c1 e c2 e
C B (t ) 1 1
Isothermal Batch Reactor cont.
Linear ODE solution:
C A (t ) 0 2 t 1 t
y (t ) c1 e c2 e
C B (t ) 1 1
Apply initial conditions:
C A (0) 0 1 10
y (0) c1 c2
C B (0) 1 1 0
Formulate matrix problem:
0 1 c1 10 c1 10
1 1 c 0
c 10
2 2
Solution:
C A (t ) 0 2 t 1 t 10e t
C (t ) 10 e 10 e 2t t
B 1 1
10 e 10 e
Isothermal CSTR
Nonlinear ODE model
dC A q
2A B
k
(C Af C A ) 2kC A2 f (C A )
dt V

Find steady-state point (q = 2, V = 2, Caf = 2, k = 0.5)


q 2
f (C A ) (C Af C A ) 2kC A (2 C A ) (2)(0.5)C A2 0
2

V 2

C A2 C A 2 0

1 12 (4)(1)(2) 1 3
CA 1
(2)(1) 2
Isothermal CSTR cont.
Linearize about steady-state point:

dC A' f
f (C A ) C A'
dt C A CA
0
'
dC A
[C A (2)(2)(0.5)C A ]C A 3C A
' '

dt

This linear ODE is an approximation to the original


nonlinear ODE
Continuous Bioreactor
Cell mass balance
dX
DX X
dt

Product mass balance


dP
DP qX
dt

Substrate mass balance


dS 1
D( S0 S ) X
dt YX / S
Steady-State Solutions
Simplified model equations
dX m S
DX ( S ) X f1 ( X , S ) (S )
dt KS S
dS 1
D( S 0 S ) (S ) X f 2 ( X , S )
dt YX / S

Steady-state equations
m S
DX ( S ) X 0 (S )
KS S
1
D( S 0 S ) (S ) X 0
YX / S

Two steady-state points


KS D
Non - Trivial : ( S ) D S X YX / S ( S 0 S )
m D
Washout : S S0 X 0
Model Linearization
Biomass concentration equation
dX f1 f1
f1 ( X , S ) X X S S
dt X X ,S S X ,S
zero
m X m XS

S D X 2
S
K S S K S S
Substrate concentration equation
dS f 2 f 2
f2 ( X , S )
X X S S
dt X X , S S X , S
zero
1 m S 1 X X S
X m
m D S
YX / S K S S YX / S K S S K S S
2

Linear model structure: dX
a11 X a12 S
dt
dS
a21 X a22 S
dt
Non-Trivial Steady State
Parameter values
KS = 1.2 g/L, m = 0.48 h-1, YX/S = 0.4 g/g
D = 0.15 h-1, S0 = 20 g/L
Steady-state concentrations
KS D
S 0.545 g/L X YX / S ( S 0 S ) 7.78 g/L
m D
Linear model coefficients (units h-1)
m X m XS
a11 0 a12 1.472
KS S KS S 2

1 m S 1 m X m XS
a21 0.375 a22 D 3.529
YX / S K S S YX / S K S S K S S
2
Stability Analysis
Matrix representation
X dx 0 1.472
x x Ax
S dt 0.375 3.529
Eigenvalues (units h-1)
1.472
A I 1 0.164 1 3.365
0.375 3.529

Conclusion
Non-trivial steady state is asymptotically stable
Result holds locally near the steady state
Washout Steady State
Steady state: S Si 20 g/L X 0 g/L
Linear model coefficients (units h-1)
max S
a11 D 0.303 a12 0
KS S
1 max S 1 max X max
X S
a21 1.132 a22 D 0.15
YX / S KS S YX / S KS S K S 2
S
Eigenvalues (units h)
0.303 0
A I 1 0.303 1 0.15
1.132 0.15

Conclusion
Washout steady state is unstable
Suggests that non-trivial steady state is globally stable
Gaussian Quadrature Example
Analytical solution
5 5

e
1x 1x
2
dx 2e 2
21.067545
1 1

Variable transformation
2 x ( a b) 1
t 2 x 32 x 2t 3
ba
Approximate solution
5 1 1 t3
e dx e 2dt 2 e
1x 1 ( 2 t 3)
2 2 2
dt
1 1 1
1

t 32 0.77459 3 2 0 3 2 0.77459 3 2
e dt (0.55555)e (0.88889)e (0.55555)e 10.533346
1
5
e
1x
2
dx 2(10.533346) 21.066691
1

Approximation error = 4x10-3%


Plug-Flow Reactor Example

qi, CAi qo, CAo


CA(z) z

0 L
A k B
z r kC A
q dC A
kC A 0 C A (0) C Ai
A dz
q C A ( z n 1 ) C A ( z n )
kC A ( z n 1 ) 0
A z
1
C A ( z n 1 ) C A ( z n ) C A ( z0 ) C Ai
1 kAz q
N
1
C A ( L) C A ( z N ) C Ai
1 kAz q
Plug-Flow Reactor Example cont.
Analytical solution
kA
C A ( L) C Ai exp L
q
Numerical solution
N N
1 1
C A ( L) C Ai C Ai
1 kAz q 1 kAL Nq
Convergence formula
N

1
lim e a
N 1 a N

Convergence of numerical solution
N
1 kA
lim C Ai C Ai exp L
N
1 kA L Nq q
Matlab Example
Isothermal CSTR model
dC A q
2A B
k
(C Af C A ) 2kC A2 f (C A )
dt V

Model parameters: q = 2, V = 2, Caf = 2, k = 0.5


Initial condition: CA(0) = 2
Backward Euler formula
q 2
C A,n 1 C A,n h (C Af C A,n ) 2kC A,n C A,n hf (C A,n )
V
Algorithm parameters: h = 0.01, N = 200
Matlab Implementation: iso_cstr_euler.m
h = 0.01; for i=1:N
N = 200; t(i+1) = t(i)+h;

Cao = 2; f = q/V*(Caf-Ca(i))-
2*k*Ca(i)^2;
q = 2;
Ca(i+1)= Ca(i)+h*f;
V = 2; end
Caf = 2; plot(t,Ca)
k = 0.5; ylabel('Ca (g/L)')
t(1) = 0; xlabel('Time (min)')
Ca(1) = Cao; axis([0,2,0.75,2.25])
Euler Solution

>> iso_cstr_euler
2.2

1.8

1.6
CA (g/L)

1.4

1.2

0.8
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time (min)
Solution with Matlab Function
function f = iso_cstr(x) >> xss = fsolve(@iso_cstr,2)
Cao = 2; xss = 1.0000
q = 2; >> df = @(t,x) iso_cstr(x);
V = 2; >> [t,x] = ode23(df,[0,2],2);
Caf = 2; >> plot(t,x)
k = 0.5; >> ylabel('Ca (g/L)')
Ca = x(1); >> xlabel('Time (min)')
f(1) = q/V*(Caf-Ca)-2*k*Ca^2; >> axis([0,2,0.75,2.25])
Matlab Function Solution

2.2

2 Euler
Matlab

1.8

1.6
Ca (g/L)

1.4

1.2

0.8
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time (min)
CSTR Example
Van de Vusse reaction
A r1 B r2 C r1 k1C A r2 k 2C B
2 A r3 D r3 k3C A2

CSTR model
dC A q
(C Ai C A ) k1C A 2k3C A2 f1 (C A , C B ) C A (0) C A0
dt V
dC B q
C B k1C A k 2C B f 2 (C A , C B ) C B ( 0) C B 0
dt V

Forward Euler
q 2
C A,n 1 C A,n hf1 (C A,n , C B ,n ) C A,n h (C Ai C A,n ) k1C A,n 2k3C A,n C A, 0 C A 0
V
q
C B ,n 1 C B ,n hf 2 (C A,n , C B ,n ) C B ,n h C B ,n k1C A,n k 2C B ,n CB,0 CB 0
V
Stiff System Example
CSTR model: A B C
dC A q dC B q
(C Ai C A ) k1C A C B k1C A k 2C B
dt V dt V
Homogeneous system: C A' (t ) C A (t ) C A C B' (t ) C B (t ) C B

dC A' q ' dC B' q '


C A k1C A' C B k1C A' k 2C B'
dt V dt V

Eigenvalue analysis: q/V = 1, k1 = 1, k2 = 200


C A' (t ) dy ' 2 0
y ' (t ) ' y ' Ay '
C B (t ) dt 1 201
1 2 2 201
Explicit Solution
Forward Euler
dC A'
2C A' C A' ,n 1 C A' ,n h(2C A' ,n )
dt
dC B'
C A' 201C B' C B' ,n 1 C B' ,n h(C A' ,n 201C B' ,n )
dt
First iterative equation
C A' ,n 1 C A' ,n h(2C A' ,n ) (1 2h)C A' ,n C A' ,n (1 2h) n C A' , 0
0 h 12 well behaved
2 h 1 oscillatory but stable
1

h 1 oscillatory and unstable


Second iterative equation
C B' ,n 1 C B' ,n h(C A' ,n 201C B' ,n ) C B' ,n (1 2h) n hC A' ,0 (1 201h) n C B' ,0
0 h 201 1
well behaved
1
201 h 201
2
oscillatory but stable
h 201
2
oscillatory and unstable
Implicit Solution
Backward Euler
dC A'
2C A' C A' ,n 1 C A' ,n h(2C A' ,n 1 )
dt
dC B'
C A' 201C B' C B' ,n 1 C B' ,n h(C A' ,n 1 201C B' ,n 1 )
dt
First iterative equation
1
C '
A, n 1 C '
A, n h(2C ) C
'
A, n 1
'
C '
A, n
A, 0
(1 2h) n
h 0 well behaved

Second iterative equation


1 1
C '
B , n 1 C '
B ,n h(C '
A, n 1 201C '
) C
B , n 1
'
B ,n hC '
A, 0 C '
B ,0
(1 2h) n 1 (1 201h) n
h 0 well behaved
Matlab Solution
function f = stiff_cstr(x) >> xo = fsolve(@stiff_cstr,[1 1])
Cai = 2; xo = 1.0000 0.0050
qV = 1; >> df = @(t,x) stiff_cstr(x);
k1 = 1; >> [t,x] = ode23(df,[0,2],[2 0]);
k2 = 200; >> [ts,xs] = ode23s(df,[0,2],[2 0]);
Ca = x(1); >> size(t)
Cb = x(2); ans = 173 1
f(1) = qV*(Cai-Ca)-k1*Ca; >> size(ts)
f(2) = -qV*Cb+k1*Ca-k2*Cb; ans = 30 1
f = f';
Matlab Solution cont.
>> subplot(2,1,1)
>> plot(t,x(:,1))
>> hold 2
ode23
Current plot held ode23s

Ca (g/L)
>> plot(ts,xs(:,1),'r') 1.5

>> ylabel('Ca (g/L)')


>> ylabel('Ca (g/L)')
1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
>> xlabel('Time (min)') Time (min)
>> legend('ode23','ode23s') 0.01
>> subplot(2,1,2) ode23
ode23s
>> plot(t,x(:,2))
Cb (g/L)

0.005
>> hold
Current plot held
0
>> plot(ts,xs(:,2),'r') 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time (min)
>> ylabel('Cb (g/L)')
>> xlabel('Time (min)')
>> legend('ode23','ode23s')
Binary Flash Unit
Schematic diagram Assumptions
Saturated liquid feed
V, y
Vapor Perfect mixing
Negligible heat losses
Negligible vapor holdup
F, xF Negligible energy
Feed
Q accumulation
Heat
H Constant heat of
vaporization
L, x
Liquid Constant relative
volatility
Vapor-liquid equilibrium
x
y
1 ( 1) x
Model Formulation
Mass balance
dH
F V L
dt
Component balance

d ( Hx)
FxF Vy Lx
dt

d ( Hx) dH dx dx
x H x ( F V L) H
dt dt dt dt

dx
H ( F V L) x FxF Vy Lx F ( xF x) V ( y x)
dt
Model Formulation cont.
Steady-state energy balance
Q
VH v Q V
H v
Index 0 DAE model
dx F Q/H dx
( xF x) ( y x)
dt H H f ( x, y )
x dt
0 y 0 g ( x, y )
1 ( 1) x
Binary Flash Unit Revisited
DAE model
dx F V
( xF x) ( y x)
dt H H
x
0 y
1 ( 1) x

Parameter values: H = 5, F = 10, xF = 0.5, V = 2, = 10

MATLAB DAE Solution Codes


Solver Problems Method
ode15s Stiff DAEs up to index 1 Numerical differentiation
ode23t Moderately stiff DAEs Trapezoidal
up to index 1
binary_flash.m
function f = binary_flash(x)

H = 5;
F = 10;
xf = 0.5;
V = 2;
alpha = 10;

xv = x(1);
yv = x(2);

f(1) = F/H*(xf-xv)-V/H*(yv-xv);
f(2) = yv-alpha*xv/(1+(alpha-1)*xv);

f = f';
Matlab Commands
Results for V = 2
>> f = @(x) binary_flash(x);
>> xss = fsolve(f,[1 1],[])
xss = 0.4068 0.8727
>> df = @(t,x) binary_flash(x);
>> M = [1 0; 0 0];
>> options=odeset('Mass',M);
>> [t1,y1]=ode15s(df,[0,10],xss,options);
Change V = 1
>> [t2,y2]=ode15s(df,[0,10],xss,options);
Results for V = 2 and V = 1

0.9

0.85
Liquid
0.8
Vapor
0.75

0.7
Mole Fraction

0.65

0.6

0.55

0.5

0.45

0.4
0 1 2 3 4 5 6 7 8 9 10
Time

You might also like