%
% integrator function for "dosensor.m"
%
function dxdt = DO_Sensor( t, x )
%
% dSo/dt = OUR + Kla ( Sosat - So )
%
% OUR = 0.84 mg/l/min
%
global lastkla
%
if t < 0.5, 
  kla = 4; 
  lastkla = kla;
  sosat = 10;
else
  kla = 4.4;
  sosat = 10.4;
end;
dxdt = zeros( 2, 1 );
dxdt(1) = - 29.12 - 0.926 * x(1) / ( x(1) + 0.2 ) ...
                    + kla * ( 10 - x(1) );
%
dxdt(2) = - 29.12 - 0.926 * (x(2)-1) / ( (x(2)-1) + 0.2 ) ...
              + kla * ( sosat - (x(2)-1) ) + 350 * ( kla - lastkla );
lastkla = kla;
%
