Selected Differential System Examples from Lectures

Preview:

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

Citation preview

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

Mass Balance

Mass balance on tank

Steady-state operation:

Valve characteristics

Linear ODE model

Nonlinear ODE model

0

out

0

inonaccumulati

)(ww

dt

dhAww

dt

Ahdii

ii wwww 000

hCwhCw vovo NonlinearLinear

0)0( hhhCwdt

dhA vi

0)0( hhhCwdt

dhA vi

Stirred Tank Chemical Reactor

Assumptions» Pure reactant A in feed stream

» Perfect mixing

» Constant liquid volume

» Constant physical properties (, k)

» Isothermal operation

A

k

kCr

BA

Overall mass balance

Component balance

qqqqdt

Vdii

0)(

0)0()(

)(

AAAAAiA

AAAiiA

CCkCCCV

q

dt

dC

VkCqCCqdt

VCd

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

kCr

BA

z

qi, CAi qo, CAoCA(z) z

Plug-Flow Chemical Reactor cont.

Overall mass balance

qqqdz

dqz

qq

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

dC

A

q

kCdz

dC

A

q

kCz

CC

A

q

zAkCqCqC

)0(0

0

0)()(

lim

0)()(

0

consumedA outA inA

Continuous Biochemical Reactor

Fresh Media Feed (substrates)

Exit Gas Flow

Agitator

Exit Liquid Flow(cells & products)

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

Xdt

dX

X

SK

SS

S

m

)(

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

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

Product

Substrate

» S0 = feed concentration of rate limiting substrate

XDXdt

dXXVFX

dt

dXV RR

qXDPdt

dPqXVFP

dt

dPV RR

XY

SSDdt

dSXV

YFSFS

dt

dSV

SXR

SXR

/0

/0

1)(

1

Exothermic CSTR

Scalar representation

Vector representation

00 )0()exp()( AAAAAfA CCCRTEkCC

V

q

dt

dC

00 )0(

)()/exp()()( TT

VC

TTUA

C

CRTEkHTT

V

q

dt

dT

p

c

p

Af

0

0

0

0

)0()(

)()/exp()(

)(

)/exp()()(

T

C

dt

d

TTVC

UA

C

CRTEkHTT

V

q

CRTEkCCV

q

T

C

A

cpp

Af

AAAfA

yyfy

yfy

)(

/exp)( 0

TTUAQ

RTEkTk

BA

c

k

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

dt

dCCk

dt

dC

1

11

1

02

21

01

)(

)()(

)2(2

)1(1 xx

A

yydt

dy

tC

tCty

B

A

tttt

B

A ecececectC

tCt

1

1

1

0

)(

)()( 2

21

)2(2

)1(1

21 xxy

Isothermal Batch Reactor cont.

Linear ODE solution:

Apply initial conditions:

Formulate matrix problem:

Solution:

tt

B

A ecectC

tCt

1

1

1

0

)(

)()( 2

21y

0

10

1

1

1

0

)0(

)0()0( 21 cc

C

C

B

Ay

10

10

0

10

11

10

2

1

2

1

c

c

c

c

tt

ttt

B

A

ee

eee

tC

tC

1010

10

1

110

1

010

)(

)(2

2

Isothermal CSTR

Nonlinear ODE model

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

)(2)(2 2AAAAf

Ak CfkCCCV

q

dt

dCBA

12

31

)1)(2(

)2)(1)(4(11

02

0)5.0)(2()2(2

22)()(

2

2

22

A

AA

AAAAAfA

C

CC

CCCkCCV

qCf

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

A

CAA

A

CCCCdt

dC

CC

fCf

dt

dC

A

Continuous Bioreactor

Cell mass balance

Product mass balance

Substrate mass balance

XDXdt

dX

qXDPdt

dP

XY

SSDdt

dS

SX

/

0

1)(

Steady-State Solutions

Simplified model equations

Steady-state equations

Two steady-state points

),()(1

)(

)(),()(

2/

0

1

SXfXSY

SSDdt

dSSK

SSSXfXSDX

dt

dX

SX

S

m

0)(1

)(

)(0)(

/0

XSY

SSD

SK

SSXSXD

SX

S

m

0:Washout

)()(:Trivial-Non

0

0/

XSS

SSYXD

DKSDS SX

m

S

Model Linearization

Biomass concentration equation

Substrate concentration equation

Linear model structure:

SSK

SX

SK

XXDS

SSS

fXX

X

fSXf

dt

Xd

S

m

S

m

SXSX

2

,

1

,

11

zero

),(

SDSK

SX

SK

X

YX

SK

S

Y

SSS

fXX

X

fSXf

dt

Sd

S

m

S

m

SXS

m

SX

SXSX

2//

,

2

,

22

11

zero

),(

SaXadt

Sd

SaXadt

Xd

2221

1211

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.31

375.01

472.10

2/

22/

21

21211

DSK

SX

SK

X

Ya

SK

S

Ya

SK

SX

SK

Xaa

S

m

S

m

SXS

m

SX

S

m

S

m

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

SSYXD

DKS SX

m

S

Stability Analysis

Matrix representation

Eigenvalues (units h-1)

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

Axxdt

dx

S

Xx

529.3375.0

472.10

365.3164.0529.3375.0

472.111

IA

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.01

132.11

0303.0

2

maxmax

/22

max

/21

12

max

11

DSK

SX

SK

X

Ya

SK

S

Ya

aDSK

Sa

SSSXSSX

S

g/L 0g/L 20 XSS i

15.0303.015.0132.1

0303.011

IA

Gaussian Quadrature Example

Analytical solution

Variable transformation

Approximate solution

Approximation error = 4x10-3%

067545.2125

1

5

1

21

21

xx edxe

32)(2

23

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

Plug-Flow Reactor Example

Ai

N

NAA

AiAnAnA

nAnAnA

AiAAA

CqzkA

zCLC

CzCzCqzkA

zC

zkCz

zCzC

A

q

CCkCdz

dC

A

q

1

1)()(

)()(1

1)(

0)()()(

)0(0

01

11

A

k

kCr

BA

z

qi, CAi qo, CAoCA(z) z

0 L

Plug-Flow Reactor Example cont.

Analytical solution

Numerical solution

Convergence formula

Convergence of numerical solution

Ai

N

Ai

N

A CNqkAL

CqzkA

LC

1

1

1

1)(

L

q

kACLC AiA exp)(

Lq

kACC

NqLkA AiAi

N

Nexp

1

1lim

a

N

Ne

Na

1

1lim

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 CfkCCCV

q

dt

dCBA

)(2)( ,,2

,,,1, nAnAnAnAAfnAnA ChfCkCCCV

qhCC

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])

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)

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])

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)

Euler

Matlab

CSTR Example

Van de Vusse reaction

CSTR model

Forward Euler

233

2211

3

21

2 Ar

BArr

CkrDA

CkrCkrCBA

0221

012

31

)0(),(

)0(),(2)(

BBBABABB

AABAAAAAiA

CCCCfCkCkCV

q

dt

dC

CCCCfCkCkCCV

q

dt

dC

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

00,2

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

),(

2)(),(

BBnBnAnBnBnBnAnBnB

AAnAnAnAAinAnBnAnAnA

CCCkCkCV

qhCCChfCC

CCCkCkCCV

qhCCChfCC

Stiff System Example

CSTR model: A B C

Homogeneous system:

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

BABB

AAAiA CkCkC

V

q

dt

dCCkCC

V

q

dt

dC211)(

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

'2

'1

''

'1

''

BABB

AAA CkCkC

V

q

dt

dCCkC

V

q

dt

dC

2012

''2011

02'

)(

)()('

21

'

'

yydt

dy

tC

tCty

B

A A

Explicit Solution

Forward Euler

First iterative equation

Second iterative equation

)201(201

)2(2

',

',

',

'1,

'''

',

',

'1,

''

nBnAnBnBBAB

nAnAnAAA

CChCCCCdt

dC

ChCCCdt

dC

unstable andy oscillator1

stablebut y oscillator1

behaved well0

)21()21()2(

21

21

'0,

',

',

',

',

'1,

h

h

h

ChCChChCC An

nAnAnAnAnA

unstable andy oscillator

stablebut y oscillator

behaved well0

)2011()21()201(

2012

2012

2011

2011

'0,

'0,

',

',

',

',

'1,

h

h

h

ChhChCCChCC Bn

An

nBnBnAnBnB

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

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

Matlab Solution cont.

>> subplot(2,1,1)

>> plot(t,x(:,1))

>> hold

Current 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))

>> hold

Current 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)

ode23

ode23s

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)

ode23

ode23s

Binary Flash Unit

Schematic diagram

Vapor-liquid equilibrium

x

xy

)1(1

FeedF, xF

Liquid

V, y

L, x

Vapor

QHeatH

Assumptions» Saturated liquid feed» Perfect mixing» Negligible heat losses» Negligible vapor holdup» Negligible energy

accumulation» Constant heat of

vaporization» Constant relative

volatility

Model Formulation

Mass balance

Component balance

)()()(

)()(

)(

xyVxxFLxVyFxxLVFdt

dxH

dt

dxHLVFx

dt

dxH

dt

dHx

dt

Hxd

LxVyFxdt

Hxd

FF

F

LVFdt

dH

Model Formulation cont.

Steady-state energy balance

Index 0 DAE model

vv H

QVQHV

x

xy

xyH

HQxx

H

F

dt

dxF

)1(10

)(/

)(

),(0

),(

yxg

yxfdt

dx

Binary Flash Unit Revisited

DAE model

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

x

xy

xyH

Vxx

H

F

dt

dxF

)1(10

)()(

Solver Problems Method

ode15s Stiff DAEs up to index 1 Numerical differentiation

ode23t Moderately stiff DAEs up to index 1

Trapezoidal

MATLAB DAE Solution Codes

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 1 2 3 4 5 6 7 8 9 100.4

0.45

0.5

0.55

0.6

0.65

0.7

0.75

0.8

0.85

0.9

Time

Mol

e F

ract

ion

Liquid

Vapor

Recommended