selected differential system examples from lectures

35
Selected Differential System Examples from Lectures

Upload: marty

Post on 19-Mar-2016

32 views

Category:

Documents


5 download

DESCRIPTION

Selected Differential System Examples from Lectures. w i. V = Ah. w o. Liquid Storage Tank. Standing assumptions Constant liquid density r Constant cross-sectional area A Other possible assumptions Steady-state operation Outlet flow rate w 0 known function of liquid level h. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Selected Differential System Examples from Lectures

Selected Differential System Examples from Lectures

Page 2: Selected Differential System Examples from Lectures

Liquid Storage Tank

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

V = Ah

wi

wo

Page 3: Selected Differential System Examples from Lectures

Mass Balance

Mass balance on tank

Steady-state operation: Valve characteristics

Linear ODE model

Nonlinear ODE model

0

out

0

inonaccumulati

)( wwdtdhAww

dtAhd

ii

ii wwww 000

hCwhCw vovo NonlinearLinear

0)0( hhhCwdtdhA vi

0)0( hhhCwdtdhA vi

Page 4: Selected Differential System Examples from Lectures

Stirred Tank Chemical Reactor

Assumptions» Pure reactant A in feed stream» Perfect mixing» Constant liquid volume» Constant physical properties (, k)» Isothermal operation

A

k

kCrBA

Overall mass balance

Component balance

qqqqdt

Vdii 0)(

0)0()(

)(

AAAAAiA

AAAiiA

CCkCCCVq

dtdC

VkCqCCqdtVCd

Page 5: Selected Differential System Examples from Lectures

Plug-Flow Chemical Reactor

Assumptions» Pure reactant A in feed stream» Perfect plug flow» Steady-state operation» Isothermal operation» Constant physical properties (, k)

A

k

kCrBA

z

qi, CAi qo, CAoCA(z) z

Page 6: Selected Differential System Examples from Lectures

Plug-Flow Chemical Reactor cont.

Overall mass balance

qqqdzdq

zqq

qq

i

zzz

z

zzz

0

0

out Massin Mass

0

0)()(lim

0)()(

z

qi, CAi qo, CAoCA(z) z

Component balance

AiAAA

AA

AzzAzA

z

AzzAzA

CCkCdz

dCAq

kCdz

dCAq

kCzCC

Aq

zAkCqCqC

)0(0

0

0)()(lim

0)()(

0

consumedA outA inA

Page 7: Selected Differential System Examples from Lectures

Continuous Biochemical Reactor

Fresh Media Feed (substrates)

Exit Gas Flow

Agitator

Exit Liquid Flow(cells & products)

Page 8: Selected Differential System Examples from Lectures

Cell Growth Modeling Specific growth rate

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 = concentration of rate limiting substrate» Ks = saturation constant» m = maximum specific growth rate (achieved when S >> Ks)

(g/L)ion concentrat biomass 1 X

dtdX

X

SKSS

S

m

)(

Page 9: Selected Differential System Examples from Lectures

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

Page 10: Selected Differential System Examples from Lectures

Mass Balance Equations Cell mass

» VR = reactor volume» F = volumetric flow rate» D = F/VR = dilution rate

Product

Substrate

» S0 = feed concentration of rate limiting substrate

XDXdtdXXVFX

dtdXV RR

qXDPdtdPqXVFP

dtdPV RR

XY

SSDdtdSXV

YFSFS

dtdSV

SXR

SXR

/0

/0

1)(1

Page 11: Selected Differential System Examples from Lectures

Exothermic CSTR

Scalar representation

Vector representation

00 )0()exp()( AAAAAfA CCCRTEkCC

Vq

dtdC

00 )0()()/exp()()( TT

VCTTUA

CCRTEkHTT

Vq

dtdT

p

c

p

Af

0

0

0

0

)0()(

)()/exp()()(

)/exp()()(

TC

dtd

TTVC

UAC

CRTEkHTTVq

CRTEkCCVq

TC

A

cpp

Af

AAAfA

yyfy

yfy

)(/exp)( 0

TTUAQRTEkTk

BA

c

k

Page 12: Selected Differential System Examples from Lectures

Isothermal Batch Reactor

CSTR model: A B C

Eigenvalue analysis: k1 = 1, k2 = 2

Linear ODE solution:

0)0(,10)0(211 BABAB

AA CCCkCk

dtdCCk

dtdC

11

110

2

2101

)()(

)(

)2(2

)1(1 xx

A

yydtdy

tCtC

tyB

A

tttt

B

A ecececectCtC

t

11

10

)()(

)( 22

1)2(

2)1(

121 xxy

Page 13: Selected Differential System Examples from Lectures

Isothermal Batch Reactor cont.

Linear ODE solution:

Apply initial conditions:

Formulate matrix problem:

Solution:

tt

B

A ecectCtC

t

11

10

)()(

)( 22

1y

010

11

10

)0()0(

)0( 21 ccCC

B

Ay

1010

010

1110

2

1

2

1

cc

cc

tt

ttt

B

A

eee

eetCtC

101010

11

1010

10)()(

22

Page 14: Selected Differential System Examples from Lectures

Isothermal CSTR

Nonlinear ODE model

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

)(2)(2 2AAAAf

Ak CfkCCCVq

dtdCBA

12

31)1)(2(

)2)(1)(4(11

02

0)5.0)(2()2(222)()(

2

2

22

A

AA

AAAAAfA

C

CC

CCCkCCVqCf

Page 15: Selected Differential System Examples from Lectures

Isothermal CSTR cont.

Linearize about steady-state point:

This linear ODE is an approximation to the original nonlinear ODE

'''

''

3])5.0)(2)(2([

0

)(

AAAAA

ACA

AA

CCCCdt

dC

CCfCf

dtdC

A

Page 16: Selected Differential System Examples from Lectures

Continuous Bioreactor Cell mass balance

Product mass balance

Substrate mass balance

XDXdtdX

qXDPdtdP

XY

SSDdtdS

SX

/

01)(

Page 17: Selected Differential System Examples from Lectures

Steady-State Solutions Simplified model equations

Steady-state equations

Two steady-state points

),()(1)(

)(),()(

2/

0

1

SXfXSY

SSDdtdS

SKSSSXfXSDX

dtdX

SX

S

m

0)(1)(

)(0)(

/0

XSY

SSD

SKSSXSXD

SX

S

m

0:Washout

)()(:Trivial-Non

0

0/

XSS

SSYXD

DKSDS SXm

S

Page 18: Selected Differential System Examples from Lectures

Model Linearization Biomass concentration equation

Substrate concentration equation

Linear model structure:

SSKSX

SKXXDS

SSSfXX

XfSXf

dtXd

S

m

S

m

SXSX

2

,

1

,

11

zero),(

SDSKSX

SKX

YX

SKS

Y

SSSfXX

XfSXf

dtSd

S

m

S

m

SXS

m

SX

SXSX

2//

,

2

,

22

11zero

),(

SaXadtSd

SaXadtXd

2221

1211

Page 19: Selected Differential System Examples from Lectures

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

Linear model coefficients (units h-1)

529.31375.01

472.10

2/

22/

21

21211

DSKSX

SKX

Ya

SKS

Ya

SKSX

SKXaa

S

m

S

m

SXS

m

SX

S

m

S

m

g/L 78.7)(g/L 545.0 0/

SSYXD

DKS SXm

S

Page 20: Selected Differential System Examples from Lectures

Stability Analysis Matrix representation

Eigenvalues (units h-1)

Conclusion» Non-trivial steady state is asymptotically stable» Result holds locally near the steady state

Axxdtdx

SX

x

529.3375.0

472.10

365.3164.0529.3375.0472.1

11

IA

Page 21: Selected Differential System Examples from Lectures

Washout Steady State Steady state: Linear model coefficients (units h-1)

Eigenvalues (units h)

Conclusion» Washout steady state is unstable» Suggests that non-trivial steady state is globally stable

15.01132.11

0303.0

2

maxmax

/22

max

/21

12

max

11

DSKSX

SKX

Ya

SKS

Ya

aDSKSa

SSSXSSX

S

g/L 0g/L 20 XSS i

15.0303.015.0132.1

0303.011

IA

Page 22: Selected Differential System Examples from Lectures

Gaussian Quadrature Example Analytical solution

Variable transformation

Approximate solution

Approximation error = 4x10-3%

067545.2125

1

5

121

21

xx edxe

32)(223

21

txxab

baxt

066691.21)533346.10(2

533346.10)55555.0()88889.0()55555.0(

22

5

1

1

1

77459.0077459.0

1

1

1

1

)32(5

1

21

23

23

23

23

23

21

21

dxe

eeedte

dtedtedxe

x

t

ttx

Page 23: Selected Differential System Examples from Lectures

Plug-Flow Reactor Example

Ai

N

NAA

AiAnAnA

nAnAnA

AiAAA

CqzkA

zCLC

CzCzCqzkA

zC

zkCz

zCzCAq

CCkCdz

dCAq

11)()(

)()(1

1)(

0)()()(

)0(0

01

11

A

k

kCrBA

z

qi, CAi qo, CAoCA(z) z

0 L

Page 24: Selected Differential System Examples from Lectures

Plug-Flow Reactor Example cont. Analytical solution

Numerical solution

Convergence formula

Convergence of numerical solution

Ai

N

Ai

N

A CNqkAL

CqzkA

LC

1

11

1)(

L

qkACLC AiA exp)(

LqkACC

NqLkA AiAi

N

Nexp

11lim

aN

Ne

Na

1

1lim

Page 25: Selected Differential System Examples from Lectures

Matlab Example

Isothermal CSTR model

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

Initial condition: CA(0) = 2 Backward Euler formula

Algorithm parameters: h = 0.01, N = 200

)(2)(2 2AAAAf

Ak CfkCCCVq

dtdCBA

)(2)( ,,2

,,,1, nAnAnAnAAfnAnA ChfCkCCCVqhCC

Page 26: Selected Differential System Examples from Lectures

Matlab Implementation: iso_cstr_euler.m

h = 0.01;

N = 200;

Cao = 2;

q = 2;

V = 2;

Caf = 2;

k = 0.5;

t(1) = 0;

Ca(1) = Cao;

for i=1:N

t(i+1) = t(i)+h;

f = q/V*(Caf-Ca(i))-2*k*Ca(i)^2;

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

end

plot(t,Ca)

ylabel('Ca (g/L)')

xlabel('Time (min)')

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

Page 27: Selected Differential System Examples from Lectures

Euler Solution

>> iso_cstr_euler

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

0.8

1

1.2

1.4

1.6

1.8

2

2.2

CA

(g/L

)

Time (min)

Page 28: Selected Differential System Examples from Lectures

Solution with Matlab Function

function f = iso_cstr(x)

Cao = 2;

q = 2;

V = 2;

Caf = 2;

k = 0.5;

Ca = x(1);

f(1) = q/V*(Caf-Ca)-2*k*Ca^2;

>> xss = fsolve(@iso_cstr,2)

xss = 1.0000

>> df = @(t,x) iso_cstr(x);

>> [t,x] = ode23(df,[0,2],2);

>> plot(t,x)

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

>> xlabel('Time (min)')

>> axis([0,2,0.75,2.25])

Page 29: Selected Differential System Examples from Lectures

Matlab Function Solution

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

0.8

1

1.2

1.4

1.6

1.8

2

2.2

Ca

(g/L

)

Time (min)

EulerMatlab

Page 30: Selected Differential System Examples from Lectures

CSTR Example Van de Vusse reaction

CSTR model

Forward Euler

233

2211

3

21

2 Ar

BArr

CkrDACkrCkrCBA

0221

012

31

)0(),(

)0(),(2)(

BBBABABB

AABAAAAAiA

CCCCfCkCkCVq

dtdC

CCCCfCkCkCCVq

dtdC

00,,2,1,,,,2,1,

00,2

,3,1,,,,1,1,

),(

2)(),(

BBnBnAnBnBnBnAnBnB

AAnAnAnAAinAnBnAnAnA

CCCkCkCVqhCCChfCC

CCCkCkCCVqhCCChfCC

Page 31: Selected Differential System Examples from Lectures

Stiff System Example

CSTR model: A B C

Homogeneous system:

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

BABB

AAAiA CkCkC

Vq

dtdCCkCC

Vq

dtdC

211)(

BBBAAA CtCtCCtCtC )()()()( ''

'2

'1

''

'1

''

BABB

AAA CkCkC

Vq

dtdCCkC

Vq

dtdC

2012

''201102'

)()(

)('

21

'

'

yydtdy

tCtC

tyB

A A

Page 32: Selected Differential System Examples from Lectures

Explicit Solution Forward Euler

First iterative equation

Second iterative equation

)201(201

)2(2

',

',

',

'1,

'''

',

',

'1,

''

nBnAnBnBBAB

nAnAnAAA

CChCCCCdt

dC

ChCCCdt

dC

unstable andy oscillator1stablebut y oscillator1

behaved well0)21()21()2(

21

21

'0,

',

',

',

',

'1,

hh

hChCChChCC A

nnAnAnAnAnA

unstable andy oscillatorstablebut y oscillator

behaved well0)2011()21()201(

2012

2012

2011

2011

'0,

'0,

',

',

',

',

'1,

hh

hChhChCCChCC B

nA

nnBnBnAnBnB

Page 33: Selected Differential System Examples from Lectures

Implicit Solution Backward Euler

First iterative equation

Second iterative equation

)201(201

)2(2

'1,

'1,

',

'1,

'''

'1,

',

'1,

''

nBnAnBnBBAB

nAnAnAAA

CChCCCCdt

dC

ChCCCdt

dC

behaved well0)21(

1)2( '0,

',

'1,

',

'1,

h

Ch

CChCC AnnAnAnAnA

behaved well0)2011(

1)21(

1)201( '0,

'0,1

',

'1,

'1,

',

'1,

h

Ch

hCh

CCChCC BnAnnBnBnAnBnB

Page 34: Selected Differential System Examples from Lectures

Matlab Solution

function f = stiff_cstr(x)Cai = 2;qV = 1;k1 = 1;k2 = 200;Ca = x(1);Cb = x(2);f(1) = qV*(Cai-Ca)-k1*Ca;f(2) = -qV*Cb+k1*Ca-k2*Cb;f = f';

>> xo = fsolve(@stiff_cstr,[1 1])xo = 1.0000 0.0050>> df = @(t,x) stiff_cstr(x);>> [t,x] = ode23(df,[0,2],[2 0]);>> [ts,xs] = ode23s(df,[0,2],[2 0]);>> size(t)ans = 173 1>> size(ts)ans = 30 1

Page 35: Selected Differential System Examples from Lectures

Matlab Solution cont.>> subplot(2,1,1)>> plot(t,x(:,1))>> holdCurrent plot held>> plot(ts,xs(:,1),'r')>> ylabel('Ca (g/L)')>> ylabel('Ca (g/L)')>> xlabel('Time (min)')>> legend('ode23','ode23s')>> subplot(2,1,2)>> plot(t,x(:,2))>> holdCurrent plot held>> plot(ts,xs(:,2),'r')>> ylabel('Cb (g/L)')>> xlabel('Time (min)')>> legend('ode23','ode23s')

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 21

1.5

2

Ca

(g/L

)

Time (min)

ode23ode23s

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 20

0.005

0.01C

b (g

/L)

Time (min)

ode23ode23s