%
% Example 14.5: Activated Sludge Aerobic Zone
%
% Batch formulation
%
% Simplified IAWQ No.2 Model assuming:
%  - C removal only
%  - biomass growth
%
% Bob Newell, May 1996
%
%-----------------------------------------------------------
%
function dxdt = Aerobic_Zone( t, x )
global p
%
% x = [ 1=Sf 2=So2 3=Xh 4=Xs ];
% p = [ 1=muhath 2=Kla 3=Koh 4=Kf 5=Yh ];
%
%-----------------------------------------------------------
  hydrate = 3.0 * x(4) / ( 0.1 + x(4) / x(3) );
  hetero = p(1) * x(1) * x(2) * x(3) ...
              / ( p(3) + x(2) ) / ( p(4) + x(1) );
  our = hetero * ( p(5) - 1 ) / p(5);
%
  bh = 0.99;
  dxdt = zeros( 4, 1 );
  dxdt(1) = hydrate - hetero / p(5);
  dxdt(2) = our + p(2) * ( 10 - x(2) );
  dxdt(3) = hetero - bh * x(3);
  dxdt(4) = - hydrate + 0.95 * bh * x(3);
%
%-----------------------------------------------------------
% the end!   
