Вы находитесь на странице: 1из 42

Selected Differential System Examples

from Lectures
Liquid Storage Tank
wi

V = Ah

wo

 Standing assumptions
» Constant liquid density r
» 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 ( rAh) dh
 wi  w0  rA  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


rA  wi  Cv h h(0)  h0
dt
 Nonlinear ODE model
dh
rA  wi  Cv h h(0)  h0
dt
Stirred Tank Chemical Reactor
 Overall mass balance
d ( rV )
 0  rqi  rq  qi  q
dt
 Component balance
A B
k

d (VC A )
r  kCA  qi C Ai  qC A  kCAV
dt
dC A q
 (C Ai  C A )  kCA C A (0)  C A0
dt V
 Assumptions
» Pure reactant A in feed stream
» Perfect mixing
» Constant liquid volume
» Constant physical properties (r, k)
» Isothermal operation
Plug-Flow Chemical Reactor

qi, CAi qo, CAo


CA(z) Dz

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

qi, CAi qo, CAo


CA(z) Dz

z
 Overall mass balance  Component balance

( rq) z  ( rq) z  Dz  0 (qC A ) z  (qC A ) z  Dz  kCA ADz  0


     
   
Mass in Mass out A in A out A consumed

 (q) z  (q) z  Dz   q (C A ) z  (C A ) z  Dz 
0 lim  kCA   0
lim   Dz 0  A Dz
Dz 0
 Dz   
q dC A
dq   kCA  0
 0 A dz
dz q dC A
qi  q0  q  kCA  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
m X  biomass concentrat ion (g/L)
X dt

 Yield coefficients
» Biomass/substrate: YX/S = -DX/DS
» Product/substrate: YP/S = -DP/DS
» Product/biomass: YP/X = DP/DX
» Assumed to be constant
 Substrate limited growth
mm S
m (S ) 
KS  S

» S = concentration of rate limiting substrate


» Ks = saturation constant
» mm = 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/Xm
» Nongrowth associated products: q = b
» Mixed growth associated products: q = YP/Xmb
Mass Balance Equations
 Cell mass
dX dX
VR   FX  VR mX    DX  mX
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  FS0  FS  VR mX   D( S 0  S )  mX
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 (DH )k0 exp(  E / RT )C A UA(Tc  T )
 (T f  T )   T (0)  T0
dt V rC p rVC p
 Vector representation
 q 
 ( C  C )  k exp(  E / RT )C 
C A  V
Af A 0 A
y    f (y )   q (  DH ) k exp(  E / RT )C UA 
T   (T f  T )  0 A
 (Tc  T )
V rC p rC 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
 B 
C (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 ) 2t 0 2t 1 t
y (t )     c1x e  c2 x e  c1  e  c2  e
CB (t ) 1 1
Isothermal Batch Reactor cont.
 Linear ODE solution:
C A (t ) 0 2t 1 t
y(t )     c1  e  c2  e
CB (t ) 1 1
 Apply initial conditions:
C A (0) 0 1 10
y (0)     c1    c2     
CB (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 2t 1 t  10e t 
C (t )  101e  101e    2t t 
 B      10e  10e 
Isothermal CSTR
 Nonlinear ODE model
dC A q
2A 
 B
k
 (C Af  C A )  2kCA2  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  mX
dt

 Product mass balance

dP
  DP  qX
dt

 Substrate mass balance


dS 1
 D( S 0  S )  mX
dt YX / S
Steady-State Solutions
 Simplified model equations
dX mm S
  DX  m ( S ) X  f1 ( X , S ) m (S ) 
dt KS  S
dS 1
 D( S 0  S )  m (S ) X  f 2 ( X , S )
dt YX / S
 Steady-state equations
mm S
 DX  m ( S ) X  0 m (S ) 
KS  S
1
D( S 0  S )  m (S ) X  0
YX / S

 Two steady-state points


KS D
Non - Trivial : m ( S )  D  S  X  YX / S ( S0  S )
mm  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
 mm X m m XS 
 
 m S   D X     2
S
 K S  S K S  S  
 Substrate concentration equation
dS   f 2   f 2 
 f 2 ( X , S )    X  X     S  S 
dt     X  X , S  S  X , S
zero
1 mm S  1  m X m 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, mm = 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
mm  D
 Linear model coefficients (units h-1)
mm X m m XS
a11  0 a12    1.472
KS  S K S S
2

1 mm S 1  m m X m m XS 
a21    0.375 a22     D  3.529
YX / S KS  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)
m max S
a11   D  0.303 a12  0
KS  S
1 m max S 1  m max X m max XS 
a21    1.132 a22     D  0.15
YX / S KS  S YX / S  K S  S K S  S  
2

 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
ba
 Approximate solution
5 1 1 t3
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) Dz

0 L
Ak
B
z r  kCA
q dC A
 kCA  0 C A (0)  C Ai
A dz
q C A ( z n 1 )  C A ( z n )
 kCA ( z n 1 )  0
A Dz
1
C A ( z n 1 )  C A ( z n ) C A ( z0 )  C Ai
1  kADz q
N
 1 
C A ( L)  C A ( z N )    C Ai
 1  kADz 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  kADz 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 
 Bk
 (C Af  C A )  2kCA2  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 )  2kCA,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))-
q = 2; 2*k*Ca(i)^2;

V = 2; Ca(i+1)= Ca(i)+h*f;

Caf = 2; end

k = 0.5; plot(t,Ca)

t(1) = 0; ylabel('Ca (g/L)')

Ca(1) = Cao; xlabel('Time (min)')


axis([0,2,0.75,2.25])
Euler Solution

>> iso_cstr_euler
2.2

1.8

1.6
C (g/L)
A

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  k2CB
2A 
r3
D r3  k3C A2

 CSTR model
dC A q
 (C Ai  C A )  k1C A  2k3C A2  f1 (C A , CB ) C A (0)  C A0
dt V
dCB q
  CB  k1C A  k 2CB  f 2 (C A , CB ) CB (0)  CB 0
dt V

 Forward Euler
q 2 
C A,n 1  C A,n  hf1 (C A,n , CB ,n )  C A,n  h  (C Ai  C A,n )  k1C A,n  2k3C A,n  C A,0  C A0
V 
 q 
CB ,n 1  CB ,n  hf 2 (C A,n , CB ,n )  CB ,n  h  CB ,n  k1C A,n  k 2CB ,n  CB,0  CB 0
 V 
Stiff System Example
 CSTR model: A  B  C
dC A q dCB q
 (C Ai  C A )  k1C A   CB  k1C A  k 2C B
dt V dt V
 Homogeneous system: C A' (t )  C A (t )  C A CB' (t )  CB (t )  CB
dC A' q ' dCB' q '
  C A  k1C A'   CB  k1C A'  k2CB'
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
dCB'
 C A'  201CB'  CB' ,n 1  CB' ,n  h(C A' ,n  201CB' ,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 
1
oscillator y but stable
h  1  oscillator y and unstable
 Second iterative equation
CB' ,n 1  CB' ,n  h(C A' ,n  201CB' ,n )  CB' ,n  (1  2h) n hC A' ,0  (1  201h) n CB' ,0
0  h  2011
 well behaved
1
201 h  201
2
 oscillator y but stable
h  201
2
 oscillator y and unstable
Implicit Solution
 Backward Euler
dC A'
 2C A'  C A' ,n 1  C A' ,n  h(2C A' ,n 1 )
dt
dCB'
 C A'  201CB'  CB' ,n1  CB' ,n  h(C A' ,n 1  201CB' ,n1 )
dt
 First iterative equation
1
C '
A, n 1 C '
 h(2C )  C 
'
A, n 1
'
C '

(1  2h) n
A, n A, n
A, 0

h  0  well behaved

 Second iterative equation


1 1
C '
B , n 1 C '
 h(C '
A, n 1  201C '
)  C 
B , n 1
'
hC '
 C '

(1  2h) n 1 (1  201h) n
B ,n B ,n A, 0 B,0

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
>> xlabel('Time (min)') 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
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
>> plot(ts,xs(:,2),'r') 0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
>> ylabel('Cb (g/L)') Time (min)

>> 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
H Heat » 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
VDH v  Q  V 
DH v
 Index 0 DAE model

dx F Q/H
 ( xF  x)  ( y  x) dx
 f ( x, y )
dt H DH
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

Вам также может понравиться