Unformatted text preview: Page 1 of 10
SCHOOL OF CHEMICAL, BIOLOGICAL and ENVIRONMENTAL ENGINEERING
OREGON STATE UNIVERSITY CHE 361  BIOREACTOR "Simulator"
DESCRIPTION OF SIMULINK BLOCKS
The bioreactor block diagram, bio_reac.mdl, is a simulation of a reactor with "full" dynamic
variables, not deviation variables. Because of this, several additional steps must be taken to
set up the model which are not done in simple dynamic simulations involving transfer
function models. Another feature is that the blocks in bio_reac have been designed so that it
is very simple to do parameter estimations for a transfer function model from a step response
experiment (see Chap. 7 in SEMD3) and frequency response analysis from a pulse response
experiment (see Chap. 14 in SEMD3). The revised diagram shown below contains 17
"blocks" and 2 "button boxes". The button boxes are used after a simulation has been
completed. The example shown here is set up for the response of the bug concentration
(B = y1) as output to a step increase of 10% in the fullvariable value of the nominal flow rate
(F = u1) as the input. Each type of block will be described, starting at the left of the diagram and following the flow
of information. "Open" a block by double clicking on it and change names by clicking on the
name. Draw lines from blocks using the left mouse button held down; draw lines from lines
using the right mouse button held down. Page 2 of 10
INPUT BLOCKS
The first two blocks, F_step_in and Ni_step_in, are subsystem blocks for setting up the input
variables F and Ni to the bioreactor. Double clicking on one of these blocks "opens" the
subsystem to reveal the components shown below. You must enter your nominal steadystate
values for F and Ni in the constant blocks, shown here as 1. and 5.2 in the example. The "F, +
step" block is used to run a positive Step Fcn block, the "F,  step" block is used to run a
negative Step Fcn block. Double clicking on either brings up a Step Fcn menu window with
Step time, Initial value, and Final value. The two steps can be used together to create a
rectangular pulse, as done in HW #7. The Sum2 blocks add the steadystate value of F to the
deviation variable made by Sum1 to get the "full" variable which is needed by the bioreactor
simulation and sent out of the subsystem F_step_in through the out_1 port block. The Mux
block combines the three signals t (from Clock1), the full F and deviation F' and sends them
as a vector to a workspace variable (which is an Nx3 matrix) called "tFin". If you entered
tFin in the MATLAB Command Window after the simulation you would see three columns
of numbers corresponding to t,F,F' values. The tUin Workspace block creates a variable
which is used by the PULSE_analysis button block. If your chosen input variable is Ni, the
tUin block needs to be moved to the Ni_step_in subsystem shown below (see step 7 in the
"checklist" on pg 6). Page 3 of 10
Bio361 BLOCK
Double click on this block to enter YOUR bioreactor parameters and Initial B and N to
YOUR nominal steadystate values, as shown in the Bio_reactor(Mask) menu below on the
left. Once you have done this be sure to SAVE the bio_reac.mdl file to your own account
on the fileserver or your laptop so that you can use it later. PLOT BLOCKS
The blocks named Fin, Nin, Bout and Nout are all plotting blocks and can be changed by
double clicking on them, which brings up a Graph scope (Mask) menu as shown on the right
above. You should adjust the Min y and Max y values to give you a good display and the
Time range value must agree with the “Stop Time” (here = 6 hours) you set in the
Configuration Parameters: option shown below which you get to from the “Simulation” pulldown menu option in the bio_reac.mdl block diagramWindow. Page 4 of 10
OUTPUT BLOCKS
The blocks named Store_tBout and Store_tNout record the numerical values of the outputs
to variables in the workspace. Double clicking on either opens up its subsystem shown
below, where you must enter your initial steadystate values of B and N. These operate
similarly to the input blocks in that the variables tBout and tNout are in columns of t,y,y' for
time, full value, deviation value. The workspace variable tYout corresponding to the
ORANGE block with that name must be moved to the Store_tNout block if your output is N
instead of B (see step 10 of the checklist that starts on pg. 8). Page 5 of 10
"BUTTON" BLOCKS (Chapters 7 & 14 in SEMD3 textbook)
STEP TEST FIT : The block named Step_Analysis is used AFTER you have run a step input
simulation. Double clicking this button block starts the step2g.p program which uses the
tYout.dat which is a matrix of (t,y,y’ ) columns created by the “tYout” Block. This data will
be for the “Bug” concentration or “Nutrient” concentration coming out of the reactor,
depending on where you connect the “tYout” Block.
The step2g.p program runs in the MATLAB Command Window and first plots the data and
then asks what kind of transfer function you want to use. Then it asks if you want a fixed KM
value for use with the response. If you respond that you do, it asks you for the fixed value,
which should correspond to your final output value at the new steady state.
Remember for the Bioreactor you must calculate the correct new final steady state of your
bioreactor output from the steady state equations (6) of the Bioreactor project handout and use
the deviation value of your y’ for your KM value. Obviously when you use different step
inputs, you are using different M values and will use different calculated final y’ values.
The step2g.p program next asks if you want a fixed time delay. For the bioreactor project,
you would normally respond that you do, and that the fixed value is 0. Then the program asks
for reasonable initial estimates of parameters for the particular type of G(s) you chose. One
you might try your local G(s) values. The program then draws a plot of the data as circles and
begins a search for the best variable parameters, in the sense that the norm of the error vector
is minimized by using a simplex type search of those variable parameters.
After you watch the program converge, the final parameters are reported to the MATLAB
Command Window, along with the location of any zero and the pole(s). The sum of the
squared errors and the sum divided by the number of data points are also reported and can be
used for comparison of the goodness of fit of two kinds of transfer functions, e.g. first over
second versus simple first order when the more complex transfer function may have polezero
"near cancellation". The button Reopt on the plotting window allows you to watch the
optimization again, however it will take just as long to redo. Here is an example of what could
appear in the Command Window with user inputs in bold:
step2g.m not found. (Don’t worry – we’re using step2g.p)
......... loading the response data file.
This file must have 3 columns containing
ascii data (t,yfull,ydev)
 it MUST be named tYout.dat
First look at the shape of the data response.
Then make your choice of the kind of transfer function.
You may now EXIT (pick 0) in order to
EDIT & PRINT this plot of only the data,
or you can go on to the fitting step .... Page 6 of 10 Specify general type of G(s)

 Enter:




0 to EXIT


1 for 1st order model


2 for 2nd order model


3 for 1st/2nd order model


4 for 1st/2nd with zero at origin 

Enter choice 1,2,3 or 4 : 1
HOW to treat KM
Enter 0 for computer adjusted
Enter 1 for fixed KM : 1
For standard G(s) form
Fixed KM = 0.09764
HOW to treat time delay
Enter 0 for computer adjusted
Enter 1 for fixed time delay : 1
For standard G(s) form
Fixed time delay = 0
Enter estimate of tau : 1
End
 Final Parameters Final KM
= 0.0976
Final time delay = 0.0000
Final tau
= 0.4827
 Poles and zeros One pole at s = 2.0716
How GOOD was your fit ??
The sum of the squares of
your model errors = 0.005687
but the more data points you have, the bigger the
number will be. Thus you need to divide by the
number of points to get the per_data_pt
contribution to the sum of the squared errors.
Your value for this model
and data set was = 9.1726e005
for a total of 62 data points. Page 7 of 10
PULSE TEST  Bode diagram. The PULSE_Analysis button box runs the program pulsec.p,
which does a number of operations to enable you to easily find the frequency response of your
bioreactor from a pulse response experiment:
Saves values of t,u,u’ in a matrix named tUin and a file uin.dat
Saves values of t,y,y’ in a matrix named tYout and a file yout.dat
Calculates the frequency response based on the rectangular pulse time response
Makes a Bode plot, then a separate Amplitude ratio and Phase angle plot.
The pulsec.p program runs in the MATLAB Command window. The following are appropriate for the Base
Case example of a bioreactor. You may need to use different values. After double clicking the RUN pulsec
block you should see in the MATLAB Command Window:
pulsec.m not found. (Don’t worry, we use pulsec.p instead) Use the Help browser Search tab to search the documentation, or
type "help help" for help command options, such as help for methods.
Enter min frequency to calculate : 0.01
Enter max frequency to calculate : 10
Enter number of freqencies to calculate : 200 The Figure above contains a BODE plot. Two additional Figures are made, one of the Amplitude vs.
Frequency, the other the Phase Angle in degrees vs. Frequency. These extra plots are sometimes easier
to analyze than the combined plot shown here – see Chap. 14 in SEMD3. Page 8 of 10 Checklist for Bioreactor Simulink Simulator Use
(1) Copy files in the folder named “Bioreactor” on the class webpage to your network
or laptop directory for CHE361 (or a USB jump drive). Each member of the team
should do this in their own directory ! DO NOT depend on your teammates to do
all the MATLAB related tasks. (2) START the MATLAB program, change the Current Directory to your directory for
CHE361. Then type >>bio_reac in the MATLAB Command Window after the >>
MATLAB prompt to open your block diagram. (4) Double click on the Bio361 block and change the 4 kinetic parameters to agree
with your values. (Volume should always be 1.0 liters) Then enter 2 values for
your nominal steadystate B and N concentrations in the reactor. (5) Double click on F_step_in and set your nominal steadystate value in the F
initial ss block. Set the F,+ step and F, step initial and final values to 0. (6) Double click on Ni_step_in and set your nominal steadystate value in the Ni
initial ss block. Set the Ni, + step and Ni,  step initial and final values to 0. (7) IF your input variable is to be Ni, you need to change the input which gets
recorded by the tUin block. First select and then delete the input arrows to the
ORANGE tUin block and the White Alt_input block. Then switch the positions of
those two blocks by clicking and dragging them around. Then click on the output
of the F_step_in box and connect it to the Alt_input box. Finally similarly click on
the output of the Ni_step_in box and connect it to the ORANGE tUin box = now
you are recording Ni as the input. (8) Outputs: Double click on the Store_tBout block and set your nominal steadystate value of B in the B initial ss block. (9) Double click on Store_tNout and set your nominal steadystate value of N in the
N initial ss block. Page 9 of 10
(10) IF your output variable is N instead of B, move the ORANGE tYout block from
the Store_tBout block to the Store_tNout block and connect the White
Alt_ouput block to the Store_tBout block in a similar manner to that described
in step (7) above for moving the Alt_input block. (11) Now setup the appropriate "Simulation" parameters and simulate the nominal
steadystate of your bioreactor (you must get straight lines on all plots).
Since all variables would be at their steadystate values, you should observe
horizontal lines on your four plot figures. If not, something is incorrectly setup
and you need to correct it before going any further. Be careful with “round off” ! __________________________________________________________________________________
(12) Make a “calibration” plot of steadystate values of your output vs. your
input for the feasible input range, showing your nominal steady state as a point
on this graph and the slope of the curve at that point as the gain of your local
transfer function model. (13) Run appropriate "small" and "large" STEP response experiments, possibly in both
+ and  directions and use the Step_Analysis “button block” for identification of
appropriate G(s) models. (14) Run appropriate "small" and "large" PULSE response experiments, possibly in
both + and  directions and use the PULSE_Analysis “button block” to make
Bode diagrams which you then can use to identify (by "hand" graphical methods)
appropriate G(s) models. NOTE: If you have a process with a negative gain,
you must change the signs of the SUM block in your output ( Store_tBout or
Store_tNout) to + instead of + to get “normal” phase angle behavior for analysis. (15) Analyze your results for the degree of nonlinear behavior your bioreactor exhibits
and show the plot for Class A, B, C or D and declare what Class your bioreactor is
in. This may require additional step tests to be performed. Include comparisons of
“experimental” transfer function models with your correct “local” G(s). (16) Write up your report in a clear and concise manner, using tables to report
parameter values for your various models and clearly identify all plots included in
the report. Each team member must edit and be satisfied with the final version of
the writing, since this is a team project and grade. Page 10 of 10 Tasks for CHE 361 Bioreactor Project Analysis
Pick nominal inputs and
parameter values to obtain
feasible nominal steadystate outputs.
Derive G(s)local Make changes to
bioreac.mdl
Setup input and output
subsystems. Not yet ! Straightline
simulation ? Perform Step Tests using
tYout.dat, step2g.p and
fitmodel.p files via
Button Box Gstep1, Gstep2 , etc. Perform Pulse Tests using
uin.dat, yout.dat and
pulsec.p files to create
freq.dat and plot a Bode
plot using chebode.p via
Button Box Gpulse1, Gpulse2 , etc. Run freqg.p to specify a
transfer function, generate
it’s frequency response via
the short cut method and
store in a frequency data
file like freqg2.dat Use chebode2i.p to make
Bode plots with freqg.dat
from pulse experiment
versus Glocal frequency
response file calculated by
freqg.p ...
View
Full
Document
This note was uploaded on 03/01/2012 for the course CHE 361 taught by Professor Staff during the Winter '08 term at Oregon State.
 Winter '08
 Staff

Click to edit the document details