%
% Example 14.2: Activated Sludge Anoxic Zone
%
% Batch formulation
%
% Simplified IAWQ No.2 Model assuming:
%  - denitrification, P uptake (?)
%  - biomass concentrations constant
%
% Bob Newell, March 1996
%
%-----------------------------------------------------------
%
function dxdt = Anoxic_Zone( t, x )
global p
%
% x = [ 1=Sf 2=Sno3 3=So 4=Xh ];
% p = [ 1=muhath 2=nuno3 3=Kf 4=Kno3
%       5=Yh 6=Koh ];
%-----------------------------------------------------------
  dxdt = zeros( 5, 1 );
  hydrate = 1.8 * x(5) ...
              / ( 0.1 + x(5) / ( x(4) + 1000 ) );
  grrate = p(1) * x(1) * x(3) * x(4) ...
              / ( p(3) + x(1) ) / ( p(6) + x(3) );
  denrate = p(1) * p(2) * x(1) * x(2) * p(6) * x(4) ...
              / ( p(3) + x(1) ) / ( p(4) + x(2) ) ...
              / ( p(6) + x(3) );
  dxdt(1) = hydrate - ( grrate + denrate ) / p(5);
  dxdt(2) = - ( 1 - p(5) ) * denrate / 2.86 / p(5);
  dxdt(3) = - ( 1 - p(5) ) * grrate / p(5);
  dxdt(4) = grrate / p(5) - 0.4 * x(4);
  dxdt(5) = - hydrate + 0.36 * x(4);
%
%-----------------------------------------------------------
% the end!   
