%
% Example 4.8: Compartmental Clarifier Model
%
% - constant total volume
% - well mixed compartments
% - constant thickening factor
% - lagged blanket concentration factor
% - settling proportional to overflow concentration
%
% Bob Newell, May 1996
%
%-----------------------------------------------------------
% parameters
Vol = 2000;
alpha = 0.01;
Ks = 1771.25;
Kc = 2.01875;
Kt = 53016393.44;
%
global p
p = [ Vol alpha Ks Kc Kt ];
%-----------------------------------------------------------
% initial states
Mc = 12000;
Ms = 6000000;
Xs = 6000;
%
xo = [ Mc Ms Xs ];
%-----------------------------------------------------------
% integrate the state equation
to = clock;
hours = 6;
[ t, x ] = ode45( 'Compartment_Clarifier', [ 0 hours ], xo );
secs = etime( clock, to )
vs = x(:,2) ./ x(:,3);
xo = x(:,1) ./ ( p(1) - vs );
%-----------------------------------------------------------
% plot the results
fontsz = 16;
figure;
subplot( 2, 2, 1 );
plot( t, xo );
axis( [ 0 hours 10 20 ] );
set( gca, 'fontsize', fontsz );
sylabel( '\16Overflow Conc {\times \it X_o}' );
%
subplot( 2, 2, 3 );
plot( t, Kc*x(:,3) );
axis( [ 0 hours 12000 13000 ] );
set( gca, 'fontsize', fontsz );
xlabel( 'Time in hours' );
sylabel( '\16Underflow Conc {\times \it X_u}' );
%
subplot( 2, 2, 2 );
plot( t, x(:,2)/1000000 );
axis( [ 0 hours 5 10 ] );
set( gca, 'fontsize', fontsz );
sylabel( '\16Sludge Holdup {\times \it M_s}' );
%
subplot( 2, 2, 4 );
plot( t, vs );
axis( [ 0 hours 800 1600 ] );
set( gca, 'fontsize', fontsz );
xlabel( 'Time in hours' );
sylabel( '\16Sludge Volume {\times \it V_s}' );
%
print -f1 -deps2 ex4-8x.eps
%
%-----------------------------------------------------------
% the end!   
