%
% Example 4.9: Carbon Removal in a Batch Reactor
%
% - constant volume
% - well mixed
% - Monod kinetics
%
% Bob Newell, May 1996
%
%-----------------------------------------------------------
% parameters
muhat = 3.733;
Ks = 20;
Koh = 0.2;
Yh = 0.6;
bh = 0.4;
fp = 0.1;
a = 166;
b = 16;
So_sat = 10;
%
global p
p = [ muhat Ks Koh Yh bh fp a b So_sat ];
%-----------------------------------------------------------
% initial states
V = 12.5;
Ss = 75;
So = 3;
Xh = 850;
%
xo = [ V Ss So Xh ];
%-----------------------------------------------------------
% integrate the state equation
to = clock;
days = 2/24;
[ t, x ] = ode45( 'Batch_Reactor', [ 0 days ], xo );
secs = etime( clock, to )
qa = - 25 * ( x(:,3) - 3.0 );
index = find( qa > 25 );
qa(index) = 25 * ones( size( index ) );
%-----------------------------------------------------------
% plot the results
figure;
hax = plotyy( 24*t, [x(:,2) 10*x(:,3) x(:,4)/10], ...
   24*t, qa );
axesyy( hax, [ 0 24*days -80 100 0 100 ], ...
   'Time (hours)', ...
   'Reactant concentrations in mg/l', ...
   '\16Air flowrate in m^3/min', 2, ...
   [ 0 50 100 ], [ 0 20 40 ] );
%legend( 'Ss', '10*So', 'Xh/10', 'Air', -1 );
stext( 1.4, 10, '{\times \16 \it S_S}' );
stext( 1.4, 40, '{\times \16 \it S_O*10}' );
stext( 1.4, 80, '{\times \16 \it X_H /10}' );
%
%-----------------------------------------------------------
% the end!   
