Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Bioprocess Engineering 23 (2000) 621±626 Ó Springer-Verlag 2000

Development of a MATLAB based bioprocess simulation tool


B. Sevella, G. Bertalan

621
Abstract A simple user friendly mathematical modelling part of them has to be replaced by such simulation prac-
tool was developed on the basis of MATLAB software. The tices. A rather simple batch fermentation run in a pilot-
program system provides the possibility of solving dif- scale bioreactor needs tens of hours of experimental time
ferential equation system with the aid of an easy-to-use and several hundreds of USD for materials and energy. At
graphical surface. It is suitable for bioprocess engineering the same time using a proper simulation program tens of
simulations to describe the dynamic behaviour of a great various ``experimental'' runs can be carried out during
series of various enzyme, fermentation and environmental several minutes with an almost negligible price, keeping
bioreaction systems. It is especially bene®cial that non- naturally in mind that real manual experimentation and
time interventions can also be modelled and graphical model based simulations together are able to effectively
representations can be realized on a wide palette. deepen our and our students' knowledge.
There have been a lot of efforts to develop math-based
List of symbols simulation tools for bioreaction engineering. One of the
ODE Ordinary differential equation best known is the MATLAB based program system de-
X, Xprey, Xpred Biomass, prey and predator biomass veloped by S-O. Enfors [1] which can be used for the
concentration simulation of a series of fermentation processes. It is
Xmax, Xmin Preset values of biomass in turbido- characteristic of this program system that
stat fermentation
S, Sfeed Concentration of C/energy source and ± In theory the whole MATLAB-served functionality can
its inlet concentration be exploited,
C, C Dissolved oxygen concentration and ± There are no clear de®nition-®le formats,
its saturation value ± In order to modify a given model, MATLAB ®les have
Yi Overall yield coef®cients to be modi®ed,
Ki Substrate saturation (MONOD) con- ± Parameter de®nition to the models is based upon
stants global variables and constants,
KLa Volumetric oxygen absorption coef®- ± The user surface is rather unfriendly and visualization
cient of results is not taylor made, functions can not be
a Luedeking±Piret proportionality con- scaled,
stant ± The user surface and visualization need individual
D Dilution rate developing work from model to model.
lmaxi Maximum speci®c growth rates
Another widely used approach is based upon the model-
ling work of Dunn et al. [2]. The earlier applied and a bit
1 cumbrous ISIM simulation language has recently been
Introduction replaced by the much more user friendly MADONNA
Nowadays mathematics based computer simulations be- software. Numerous chemical and biochemical as well as
come essential part of research and higher education environmental engineering model examples are now ac-
systems because of their cost effectiveness and time saving cessible as sharewere programs on the Web [3, 4].
features. This is of even higher importance in the case of MADONNA is an easily programmable software pro-
teaching bioengineers (one of the main educational ac- viding special modelling environment: an ``equation win-
tivity of TU Budapest, Chemical Engineering Faculty) dow'' for formulating the system de®nition ®le, a
where the necessarily many conventional laboratory ``parameter window'' to set numerical values of the equa-
courses are getting more and more expensive and at least a tion constants, and a ``graph window'' for visualization of
the simulation results, with some other bene®cial features
like possibility of multiple running with one start and
Received: 6 December 1999 statistical evaluation of the results and opportunity of
showing the results in table-format and others make this
B. Sevella, G. Bertalan (&)
Department of Agricultural Chemical Technology, approach a distinguished modelling tool. On the other
TU Budapest H-1521 Szt. GelleÂrt teÂr 4. Budapest Hungary hand an unpleasant disadvantage of the MADONNA is that
programmed changing of model parameters is possible
This work was supported by OTKA grant T-022182 and T-029882. exclusively in the function of time (as independent vari-
Bioprocess Engineering 23 (2000)

able). This does not make possible e.g. modelling those results can be graphed not only as time functions but
systems where non-time variables should regulate the bi- any of the model variables can be chosen as ``inde-
oreactions like in the case of turbidostat, varying feed rate pendent'' variable.
fed batch fermentations and so on. ± The graph axes of the functions are individually scal-
To overcome some unpleasant drawback of the known able.
simulation tools we developed a program system with ± Three dimensional graphical representations of the
which either simple unstructured and structured or more results are also possible.
sophisticated biological i.e. enzyme, microbial fermenta-
Designing of this simulation program based upon the use
tion and environmental bioreactions can be simulated with
of UML (Uni®ed Modelling Language) methodologies [5]
differential equation systems and the results can be
and the structure of the resulting system is shown in the
visualised on user-friendly graphical surfaces.
622 Fig. 1.
2
3
Designing the simulation program
Structure and use of the simulation program
Applying the built-in possibilities of the MATLAB 5.3
Starting a simulation run can be initiated on the command
software our simulation program development met a set of
window of MATLAB with the ``ODEmain'' command. The
requirements:
resulting window is empty with the only active ``Load
1. The mathematical models can be described in the ODE®le'' element which enables the loading of the de®-
ODE®le (ordinary differential equation) de®nition nition ®le of the actual mathematical model. For the sake
format of the MATLAB. of simplicity here the single limiting substrate MONOD-
2. Solution of the model equations can be performed by type model with bacterial growth, substrate consumption
the MATLAB ODEsolvers. and product formation serves as introductory example and
3. Simple use of the program: the built-in options of the the whole de®nition ®le is shown in the Appendix.
ODE®le and the proper ODEsolver can be chosen on Figure 2 shows the after-loading active picture of the
the graphic surface and the state of the running is
shown during the solution process therefore it can be
stopped at any time if the solution lasted too long.
4. Modi®cations of the initial conditions as well as the
parameters of the model differential equations are
possible on the same graphic surface.
5. Regarding the visual appearance of the simulation
results the following bene®cial features of the program
can be applied during various simulations:
± More than one result set can be shown at the same
time.
± The results can be stored in ®les and these ®les are
reloadable and are printable at any time. Fig. 2. Active picture of ODE Driver Main Window showing all
± Individual or arbitrary combinations of the resulting the intervention, changing and varying possibilities before
functions can be shown on preselected graphs and running a simulation

Fig. 1. Structure of the bioprocess simu-


lation program. After starting MATLAB
software only the ®xed ODEmain block
has to be started, all the others ± if they
are located in the same directory ± are
called automatically. The given model is
described in the De®nition ODE®le
B. Sevella, G. Bertalan: Development of a MATLAB based bioprocess simulation tool

``Main window'' on which the ®rst column de®nes the ± In the case of step by step simulations all the consec-
variables of the model and the second refers to the model utive set of results are shown on the same graph.
parameters. Under these two columns one can give the ± Saving the actual visible set of results in the form of
required numerical value of the variables initial values and reloadable and ASCII convertible ®les is possible.
the model parameters. The ranges in which they are shif- ± Scaling arbitrarily the variable axes thus making the
table have to be given in the ODE®le. The third column very much different order of magnitude results (e.g.:
gives choices between the MATLAB ODE®le de®nition biomass and dissolved oxygen tension) visible in one
options but the value of these may also be empty (as is coordinate system is a useful option.
shown in Fig. 2). At the right lower corner of this central ± Hiding or showing discretionary variable(s) simply
panel the time interval of the simulation can be given with clicking on the chosen curve(s) helps the thorough
setting the start and end time of the simulation, while at examination of the results.
623
the upper corner the actual differential equation solving ± Hiding and showing the parameters of the chosen set of
algorithm can be chosen out of seven different built-in simulation could also be fruitful.
MATLAB methods. During the simulation the picture of ± Any of the variables can be chosen as independent
the panel changes to the one shown in Fig. 3 where all the variable not only the time that makes easier to interpret
®elds and buttons are inactive but running coloured bars the results exploring the correlations between impor-
indicate the status of solution process. If these bars are tant process variables.
moving too slow (possibly the solution method is not ef- ± More than one simulation may also be graphed in a
fective enough) the process can be interrupted by the only three dimensional form, giving a clearer overview
active stop button. When the solution has completed the among the various curves.
button ``Display'' becomes active and the simulation re-
In the following section we demonstrate the use of our
sults are to be graphed. This can be carried out with the
simulation package through some practical instances with
use of the ODE Driver Display Window (Fig. 4), with
special regards to some programming and graphic repre-
which the following manipulations can be done with the
sentation advantages of the system.
results:

Case 1: Simulation of a special fed batch fermentation


One of the disadvantages of many simulation tools is that
use of variables other than time as control variables is
dif®cult if not impossible. It is also clumsy if breaking the
time run is necessary and after that stop a new start is
needed. Such a typical event-control problem system is the
fed batch fermentation with a feed control on the basis of
dissolved oxygen tension. This system is widely used if a
relatively low C-source concentration is to be maintained
for some reasons, e.g. in the case of bakers yeast fermen-
tation. Saccharomyces cerevisiae is able to convert glucose
Fig. 3. Picture of the ODE Driver Main Window during solution to cell mass with high overall yield only if alcoholic fer-
process. This actually shows a state very near to the end of a mentation is excluded i.e. if the oxygen level is high en-
solution. It can be seen that during the solution process only the ough (Pasteur effect) and glucose concentration is low
stop button is active giving the opportunity to cease of running
the program enough (Crabtree effect). These conditions can be satis®ed
with an on-off controller. Depletion of the glucose results
in an increase of the dissolved oxygen level, if this exceeds
a certain preset level a substrate feeding pump has to start
the addition of glucose (ON state). As a consequence the
dissolved oxygen level (DO) change turns back because the
respiration rate of the microbes increases. When DO
crosses the setpoint downward the feeding stops (OFF
state) and it remains suspended until DO level goes
through the setpoint upward. With the proper choice of
the DO setpoint, substrate addition rate and allowed
overshoot above and underswing below the DO setpoint
makes it possible to maintain a stable fed batch yeast
fermentation.
The most important part of an ODE®le which is able to
simulate the behaviour of such a system is given below. In
Fig. 4. ODE Driver Display Window which shows the three this case the double substrate (carbon source and oxygen)
solutions of monod_b.m de®nition ®le describing a simple
MONOD-type system. Left hand side of the window shows some MONOD model was applied to model the growth with
possibilities of processing the results. Kinetic parameters: constant overall yields and the formation of one growth
KS = 1.3, YX/S = 0.6, a ˆ 0:667; lmax ˆ 0:5 and 0.25 on the associated product was also supposed, and the oxygen
steeper and ¯atter curve respectively transfer with constant KLa was described:
Bioprocess Engineering 23 (2000)

% function dydt ˆ dX S c
f (t, y, mumax, Ks, Ko, Yxsl, Yps1, Yos1, Yxs2, Yps2,
ˆ lmax X ;
dt KS ‡ S KO ‡ c
Yos2; Kla; c star, X
dS 1 S C
feed, Sfeed, Pfeed, Smin, Ffinal, c lim, c band) ˆ l X ;
dt YX=S max KS ‡ S KO ‡ C
global F t lim flag;
% Variables: dP dX
ˆa ;
x ˆ y…1†; dt dt
S ˆ y…2†; P ˆ y…3†; dC 1 S C
ˆ l X KL a…C  C† :
C ˆ y…4†; V ˆ y…5†; dt YO max KS ‡ S KO ‡ C
624 if isempty …flag† & S < Smin
flag ˆ 1; Figure 5 shows the simulation results at a given param-
t lim ˆ t; eter combination. The initial batch phase of the cultiva-
end; tion is consciously overemphasized, to demonstrate how
the system behaves when the substrate is getting
if t < t lim
exhausted.
Yxs ˆ Yxsl;
Yps ˆ Yps1;
Case 2: Simulation of turbidostat fermentation
Yos ˆ Yos1;
Turbidostat fermentation system is a useful experimental
else tool when diluted culture media and unicellular micro-
Yxs ˆ Yxs2; organisms are to be cultured. The growing cell mass in-
Yps ˆ Yps2; creases the turbidity of the culture broth (measured in the
Yos ˆ Yos2; form of optical density i.e. absorbancy of a monochro-
if c > c lim ‡ c band=2 matic light beam through a ¯ow cell) and this value as a
F ˆ F final;
measure of the cell mass can be used as control variable
for feeding of the fresh medium. When the turbidity of
elseifc < c lim c band=2
the broth reaches a preset value (Xmax) a timer system
F ˆ 0; starts a medium feeding pump and at the same time
end; culture broth is taken off the bioreactor with an other
end; pump and with the same volumetric speed. This results in
% Differential equations : a dilution of the culture broth thus the optical density
dydt ˆ ‰F=V  …Xfeed X† ‡ X  mumax  S=…S ‡ Ks† decreases. If it reaches another, arbitrarily chosen lower
c=…c ‡ Ko†; . . . turbidity setpoint (Xmin) both pumps stop and a new
F=V  …Sfeed S† X  …1=Yxs†  mumax  S=…S ‡ Ks†
growth period begins. Xmin is de®ned as a given percent
of Xmax.
c=…c ‡ Ko†; . . .
The following minute detail program is a part of the
F=V  …Pfeed P† ‡ X  …Yps=Yxs†  mumax  S=…S ‡ Ks† turbidostat simulating ODE®le and it is responsible for the
c=…c ‡ Ko†; . . . de®nition of the parameters, equations and the turbidity
Kla  …c star c† X  …Yos=Yxs†  mumax  S=…S ‡ Ks† control unit. The routine is apparently a chemostat-algo-
c=…c ‡ Ko†; %Kla rithm but during the growth periods dilution rate = 0
>> F=VFŠ; (thus it gives back a batch performance), while during the
medium addition and broth removal periods an enor-
mously high dilution rate is applied simulating a very high
speed pump operation. The variable subs determines the
amount of broth taken off during one pump operation
period.

function dydt ˆ f…t; y;mumax;Kmonod; Yieldxs;


; Sfeed; Xmax; subs†
global D;
% Constants :
Dfinal ˆ 1e6;
Dinit ˆ 0;
%Variables :
X ˆ y…1†;
S ˆ y…2†;
Fig. 5. Simulation results of a dissolved oxygen level controlled P ˆ y…3†;
fed batch bakers yeast fermentation. Parameters of the kinetic % Differential equations :
model: KS = 1.3, YX/S = 0.6, a ˆ 0:667; lmax ˆ 0:25, KO = 0.0006,

KLa = 200, C = 0.006 dydt ˆ ‰ D  X ‡ X  mumax  S=…S ‡ Kmonod†;.. .
B. Sevella, G. Bertalan: Development of a MATLAB based bioprocess simulation tool

D  …Sfeed S† X  …1=Yieldxs†  mumax  S=…S ‡ Kmonod†;.. .


D  P ‡ X  …Yieldps=Yieldxs†  mumax  S=…S ‡ Kmonod†Š;
if X > Xmax
D ˆ Dfinal;
elseif X < …1 subs†  Xmax
D ˆ Dinit;
end;

Example simulation results are shown in Fig. 6 where


one can see one of the bene®cial features of the developed
graphical surface: the possibility of three dimensional 625
representations. Here we wanted to examine the effect of
the broth removal. Fixing its value at three different levels
(0.7, 0.2 and 0.05) it can be seen that the ®rst run corre-
sponds to a highly discontinuous fermentation, as a matter
of fact it is a semi-continuous cultivation while the second
approaches and the third reaches a real continuous tur- Fig. 7. Simulation results of a predato/prey interaction. The
system is a chemostat (D = 0.05) with the kinetic constants of the
bidostat system behaviour. two species: KS1 = 0.1, Kprey2 = 0.25, Ypp = 0.5, Ysp = 0.5,
lmax 1 ˆ 0:5, lmax 2 ˆ 0:1

Fig. 6. Original printout of a turbidostat simulation. Parameters


of the MONOD-type model: same as in Fig. 5. Xmax = 3.5, Fig. 8. Phase plane graph of the predator/prey system which
Sfeed = 10. Curve 1: semicontinuous performance with 70% shows one stable oscillation around a non-existing steady state.
withdrawal of the broth. Curve 2: course of the turbidostat with Parameters are the same as in the Fig. 7
high Xmax Xmin . Curve 3: real turbidostat with small Xmax Xmin

(6). The preparation of the ®gure is based upon a ®le of the


Case 3: Simulation of a predator-prey system
simulation result saved in ASCII format which has been
A two species predator-prey interaction in a chemostat
processed by the Excel software.
culture can be described by the following set of differential
One of the favorable attributes of our program, that
equations:
any of the variables may be independent variable not
dXprey S exclusively the time, is demonstrated with Fig. 8. System
ˆ DXprey ‡ Xprey lmax 1 behaviour is represented on a phase plane diagram which
dt KS1 ‡ S
1 Xprey shows a hard-oscillation of the concentrations of the
Xpred lmax 2 ; predator and prey species along a stable limit cycle.
Ypp Kprey 2 ‡ Xprey
dXpred Xprey 4
ˆ Dpred Xpred ‡ Xpred lmax 2 ;
dt Kprey 2 ‡ Xprey Conclusion
dS 1 S Among recently used scienti®c approaches mathematical
ˆ D…Sfeed S† ‡ Xprey lmax 1 : modelling of bioprocesses plays an increasingly important
dt Ysp KS1 ‡ S
role. In numero experimentation i.e. mathematical simu-
A suitably written ODE®le composed similarly to that we lation serves as a cost effective and time saving method-
have shown above made possible to simulate this preda- ology besides in vivo and in vitro techniques.
tion system. A set of results are shown in the Fig. 7 where The kinetic representations of these systems usually
the kinetic parameters of the simulations refer to a system consist of ordinary differential equation systems, the so-
of predator Dictyostelium discoideum and E. coli as prey lution of which is possible with many well known com-
Bioprocess Engineering 23 (2000)

mercial softwares and sharewares. We intended to im- switch flag


prove some undesired features of these programs with the case `` % Return dy/dt ˆ f(t,y).
development of a MATLAB based simulation tool. This varargoutf1g ˆ f(t,y,mumax,Kmonod,Yxs,Yps);
work resulted in a ¯exible, easy to use program with the case `mumax' % Return by default,min,max.
characteristics as follows:
varargoutf1g ˆ ‰0:25; 0; 2Š;
± It makes possible to use any of the MATLAB served case `Kmonod'
differential equation solving functions and de®nitions, varargoutf1g ˆ ‰1:3; 0; 10Š;
± Extending the de®nition ®les the program serves as a
case `Yxs'
general modelling environment but does not require
the thorough knowledge of MATLAB. varargoutf1g ˆ ‰0:6; 0; 1Š;
626 ± It communicates with the model-maker through a user case `Yps'
friendly graphic surface on that results can be pre- varargoutf1g ˆ ‰0:4; 0; 1Š;
sented in suitable graphs. case `init' % Return default [tspan,y0,options].
± It is able to convert the results into a savable and [varargoutf1:3gŠ ˆ init(mumax);
further processable format. otherwise
± It can be further developed on demand.
error([`Unknown flag ```flag'''.']);
Testing the program with the presented cases prove the end
¯exibility and usefulness of the system.
function [tspan,y0,options] ˆ init(mumax)
References tspan ˆ [0; 100 mumax];
1. Enfors, S-O.: Continuous and fed batch operation of fermen- y0 ˆ ‰1; 10; 0Š;
tation processes. In: Bioreactor Engineering Course Notes EFB options ˆ odeset;
Working Party on Bioreactor Performance, SaltsjoÈbaden 1996
function dydt ˆ f(t,y,mumax,Kmonod,Yxs,Yps)
2. Dunn, I.J.; Heinzle, E.; Ingham, J.; Prenosil, J.E.: Biological
Reaction Engineering, Principles, Applications and Modelling % Constants:
with PC simulations. Weinheim: Wiley-VCH 1992 % Variables:
3. Macey, R.; Oster, G.; Zahnley, T.: Madonna User's Guide. X ˆ y…1†;
(1998): Univ. of California Dept. of Molecular and Cellular
Biology. Berkeley, CA, http://www.kagi.com/authors % P ˆ y…3† faster if defined in comment
4. Heinzle, E.: http://www.uni-sb.de/matfak/fb12/heinzle/ma- S ˆ y…2†;
donna
5. Rumbaugh, J.; Jacobson, I.; Booch, G.: The Uni®ed Modeling % Differential equations:
Language±Reference Manual. Addison Wesley Longman, Inc. dydt ˆ [X mumax S/(S ‡ Kmonod); . . .
Reading, MA, ISBN 0-201-30998-X (1999) X (1/Yxs) mumax S/(S ‡ Kmonod†; . . .
6. Blanch, H.W.; Clark, D.S.: Biochemical Engineering, Marcel
Dekker, Inc. New York, Basel, Hong Kong, 1996 X (Yps/Yxs) mumax S/(S ‡ Kmonod†Š;
%this is faster than transpose the matrix
Appendix

Definition file of the MONOD-model


function varargout ˆ monod(t,y,flag,mumax,Kmonod,Yxs,Yps)
% Batch fermentation with Monod kinetics
% This routine gives the differential equations that are used for
% a batch fermentation process with Monod kinetics.
% == It demonstrate the usage of extra parameters and the naming
%== conventions for the output values.

You might also like