Fed-Batch_By_Compute..

advertisement
Solving Engineering Problems by
Using Computer
A Case Study on Fed-Batch
Bioreactor
Fed-Batch Bioreactor (1)
• A fed-batch reactor is a reactor
that initially runs as a batch
reactor, with volume V0.
• As the substrate level drops, cell
growth rate and product formation
rates decrease.
• A feed stream is introduced to
input substrate and now it is
maintained at low cell growth rate.
• As the feed stream ia introduced,
the reactor volume changes from
V0 to Vt with time.
0, t  t1
F 
 F , t  t1
0, t  t 2
SF  
S F , t  t 2
V0
Feed
Vt
Fed-Batch Reactor (2)
• Governing equations:
Specific growth rate:
Reactor volume:
 t   max
St
K S  St
dVt
 Ft
dt
Biomass:
d  X t  Vt 
dV
dX
 X t  t  Vt  t  X t  Ft  Vt    X t 
dt
dt
dt
Substrate:
d S t  Vt 
dV
dS
 S t  t  Vt  t  S t  Ft  Vt
dt
dt
dt
Product:
d Pt  Vt 
dV
dP
 Pt  t  Vt  t  Pt  Ft  Vt
dt
dt
dt

  Xt
  Ft  S F ,t 
YXS

   X t  YPS
 
YXS







Fed-Batch Reactor (3)
• Governing equations (cont’)
Feed rate:
 0, 0  t  t1
F 
t  t1
F ,
Feed substrate conc.:
 0, 0  t  t1
SF  
t  t1
S F ,
Fed-Batch Reactor (4)
• Initial condition:
Reactor volume:
V t  0  V0
Biomass level:
X t  0  X 0
Substrate conc.:
S t  0  S 0
Product conc.:
Pt  0  P0
How to Solve It? (1)
• This is a typical differential equation problem
with initial value(s).
• We can solve it by using mathematical
software packages, such as Polymath, etc.
• When using the above software packages, the
only requirement is to input the governing
equations and they can be solved using built-in
functions.
How to Solve It? (2)
• Such differential equation problems are solved
by using numerical integration.
• When a differential equation is difficult or
impossible to solve analytically ,use numerical
integration to find approximate solutions.
How to Solve It? (3)
• There are many numerical integration methods, the
simplest one is called Euler’s method.
• To integrate a differential equation from time t0 to
time tfinal, this time period is divided into many
small steps: h.
•
•
•
•
dx
 f t , x, 
E.g.
dt
At t0, x = x0.
At (t0 + h), x = x0 + (h x slopet=0)
Repeat above steps until t = tfinal
How to Solve It? (4)
• E.g. Drops in reactant conc.
• Smaller h will have better approximation.
• But smaller h will need more computation time.
1
0.8
0.6
Exact
h = 6
h = 2
h = 1
0.4
0.2
0
0
-0.2
-0.4
2
4
6
8
10
12
14
16
Using Polymath (1)
Using Polymath (2)
Feed Stream As Step Function
Feed Stream Flow Rate
(L / hr)
• Step functions could be done by
using the IF-THEN-ELSE
statement to change value of
constants according to
simulation time:
0.12
0.1
0.08
0.06
0.04
0.02
0
0
2
4
6
Time (hr)
• F = IF ( time < 3.5 hr ) THEN (
F = 0 L/hr
) ELSE (
F = 0.1 L/hr
)
8
10
12
Using Polymath (3)
•
Feed Stream Substrate
Conc. (g/L)
• The multiple steps of feed
substrate concentration could
be done by using multiple
IF-THEN-ELSE statements:
Feed Stream As Step Function
600
500
400
300
200
100
0
0
2
4
6
8
Time (hr)
SFeed = IF ( time < 3.5 hr ) THEN (
SFeed = 0 g/L
) ELSE (IF ( time < 5.5 hr ) THEN (
SFeed = 100 g/L
) ELSE (IF ( time < 7.5 hr ) THEN (
SFeed = 180 g/L
) ELSE (IF ( time < 9.5 hr ) THEN
SFeed = 350 g/L
) ELSE (
SFeed = 600 g/L
)
)
)
)
10
12
Using Polymath (4)
• Advantages:
– Polymath already built-in numerical integration
methods;
– Users only need to input differential equations, etc.
– Step functions could be input by using the IF ...
THEN ... ELSE ... statement provided by
Polymath.
Using Polymath (5)
• Disadvantages:
– Number of steps in step functions should be known before setting up
the equations;
– The numbers of IF-THEN-ELSE statements
= number of steps - 1
– If user wants to add more steps, he / she needs to modify the IFTHEN-ELSE statement, i.e. no flexibility;
– Complicated IF-THEN-ELSE statements are not easy to read when
there are many steps.
– Polymath has limitation on the number of equations in a problem, for
differential equation problems (Polymath version 6.10):
Version
Educational
Professional
Max. # of simultaneous differential equations
30
300
Max. # of simultaneous explicit equations
40
300
Max. # of intermediate data points
152
1200
Using Polymath (6)
200
0.5
180
0.45
160
0.4
140
0.35
120
0.3
100
0.25
80
0.2
60
0.15
40
0.1
20
0.05
0
0
0
2
4
6
8
10
Time (hr)
X
S
P
μ
12
Spec. Growth Rate - μ (hr -1)
Conc. - X, S, P (g / L)
Polymath Result
Using Excel (1)
• It is possible to set
up an Excel
worksheet with
numerical
integration
methods.
• E.g. Reactor
volume with feed
stream:
Step
Time
Vol
Feed
0
t0 =
0
V0
IF ( ( Time < 3.5 hr ),
( F = 0 ),
( F = 0.1 ) )
1
t1 =
t0 + h
V1 =
V0 + F x h
IF ( ( Time < 3.5 hr ),
( F = 0 ),
( F = 0.1 ) )
2
t2 =
t1 + h
V2 =
V1 + F x h
IF ( ( Time < 3.5 hr ),
( F = 0 ),
( F = 0.1 ) )
3
t3 =
t2 + h
V3 =
V2 + F x h
IF ( ( Time < 3.5 hr ),
( F = 0 ),
( F = 0.1 ) )
4
t4 =
t3 + h
V4 =
V3 + F x h
IF ( ( Time < 3.5 hr ),
( F = 0 ),
( F = 0.1 ) )
Using Excel (2)
• Costs:
– Users need to set up their own numerical
integration.
• Advantages:
– Possible to perform numerical integration when no
mathematical software package is available.
• Disadvantages:
– The same style to input step functions as using
Polymath, i.e. no flexibility.
Using Excel (3)
200
0.5
180
0.45
160
0.4
140
0.35
120
0.3
100
0.25
80
0.2
60
0.15
40
0.1
20
0.05
0
0
0
2
4
6
8
10
Time (hr)
X
S
P
μ
12
Spec. Growth Rate - μ (hr-1)
Conc. - X, S, P (g / L)
Excel Equation Result
START
Read
input data
t = 0,
V = V0, etc.
IF t > tfinal
NO
Estimate slopes based
on last step data
YES
New value
= old value + h x slope
Print a line of
result
tn+1 = tn + h
End
Using Excel VBA
Programming (1)
• Numerical integration
should be set up by user
as VBA code.
• The program performs
loops to estimate the
solution until time > end
time (tfinal).
START
Using Excel VBA (2)
Read
input data
t = 0,
V = V0, etc.
• Can include feed stream
as a step function by
using IF statement.
IF t > tfinal
NO
YES
YES
IF t ≥ 3.5 hr
F = 0.1,
Sfeed = 100
NO
F = 0,
Sfeed = 0
Estimate slopes based
on last step data
New value
= old value + h x slope
End
Print a line of
result
tn+1 = tn + h
• But, how can we handle
multiple steps in those
step functions?
START
Using Excel VBA (3)
Read
input data
Read
1st step data
t = 0,
V = V0, etc.
tstep = tstep,1
F = 0, Sfeed = 0
IF t > tfinal
NO
IF t ≥ tstep
YES
NO
Estimate slopes based
on last step data
New value
= old value + h x slope
Print a line of
result
End
tn+1 = tn + h
YES
F = Fm,
Sfeed = Sfeed,m
Read
next step
data
tstep = tstep,m+1
• An automatic feed data
reading code is
introduced;
• It is possible to handle
any number of steps.
Using Excel VBA (4)
• Costs:
– Users need to write their own VBA program code.
• Advantages:
– It is more flexible and can handle various kinds of
decisions.
• Disadvantages:
– Need more time to set up the program;
– Programming is not easy for novices.
Using Excel VBA (5)
200
0.5
180
0.45
160
0.4
140
0.35
120
0.3
100
0.25
80
0.2
60
0.15
40
0.1
20
0.05
0
0
0
2
4
6
8
10
Time (hr)
X
S
P
μ
12
Spec. Growth Rate - μ (hr -1)
Conc. - X, S, P (g / L)
VBA Program Result
START
Read
sets of
feed
strategies
Feed set = 1
IF
set > total
number of
sets?
NO
YES
Perform
numerical
integration
END
Print
integration
result for this
set of feed
strategy
Next set
When Do We Need to
Write Our Own Program?
• For example:
• If it is needed to calculate the
effect of various conditions,
such as the case of 1 to many
steps etc.
• If it is needed to evaluate
different feed strategies.
Useful Reference
• M. Harris, SAMS Teach Yourself Microsoft
Excel 2000 Programming in 21 Days, SAMS,
1999
– Although this book is not for the latest version, it
is a good introductory book for Excel VBA
programming.
Download