%
% Example 18.4: GMC of DO on Carbon Removal Process
%
% - constant volume
% - well mixed
% - Monod kinetics
% - no biomass in effluent
% - no clarifier dynamics
% - same substrate in effluent, recycle & wastage
% - no oxygen in recycle & wastage
%
% Bob Newell, April 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;
%
So_d = 3;
tau = 35/1440;
damp = 0.5/1440;
K1 = 2 * tau / damp;
K2 = 1 / tau / tau;
Tm = 18 / 1440;
Kp = 0.02218 / Tm;
Ki = 1.277 / Tm;
%
law = 2;
%
global p
p = [ muhat Ks Koh Yh bh fp a b So_sat ...
                             So_d K1 K2 Kp Ki law ];
%-----------------------------------------------------------
% initial states
%
V = 12.5;
Ss = 4.366;
So = 3;
Xh = 850.2;
z = 0;
OUR = 357.6;
%
xo = [ V Ss So Xh z OUR ];
%-----------------------------------------------------------
% integrate the state equation
%
to = clock;
days = 12/24;
[ t, x ] = ode23( 'Carbon_Removal', [ 0 days ], xo );
secs = etime( clock, to )
%-----------------------------------------------------------
% evaluate the outputs
y = Carbon_Removal_Outputs( t, x );
%-----------------------------------------------------------
% plot the results
%
figure;
hax = plotyy( 24*t, y(:,7), 24*t, y(:,9) );
axesyy( hax, [ 0 12 -6 6 0 30 ], ...
   'Time in hours', ...
   'DO in mg/l', ...
   'Air flowrate in m^3/min', 2, ...
   [ 0 2 4 6 ], [ 0 5 10 15 ] );
%
printsto -f1 -deps2 fig18-8.eps
%
%-----------------------------------------------------------
% the end!   
