%
% Example B.1: Carbon Removal Process
%
% Bob Newell, March 1996
%
%-----------------------------------------------------------
%
function dxdt = Carbon_Removal( t, x )
global p
%
% x = [ 1=V 2=Sn 3=So 4=Xb ];
% y = [ 1=v_in 2=Ss_in 3=So_in 4=Xh_in 
%       5=v_out 6=Ss_out 7=So_out 8=Xh_out
%       9=v_a 10=v_r 11=v_w ];
% p = [ 1=muhat 2=Ks 3=Koh 4=Yh 5=bh 6=fp
%       7=a 8=b 9=So_sat ];
%
%-----------------------------------------------------------
  y = Carbon_Removal_Outputs( t, x );
%
  dxdt = zeros( 4, 1 );
  mu = p(1) * y(6) * y(7) * y(8) / ( p(2) + y(6) ) ...
                         / ( p(3) + y(7) );
  kla = p(7) * ( 1 - exp( - y(9) / p(8) ) );
  dxdt(1) = y(1) - y(5);
  dxdt(2) = y(1) * ( y(2) - y(6) ) / x(1) ...
                - mu / p(4) + p(5) * y(8) * ( 1 - p(6) );
  dxdt(3) = ( y(1) * y(3) - ( y(1) + y(10) ) ...
                * y(7) ) / x(1) ...
                + mu * ( p(4) - 1 ) / p(4) ...
                + kla * ( p(9) - y(7) );
  dxdt(4) = ( y(1) * y(4) - y(11) * ( y(1) + y(10) ) ...
                * y(8) / ( y(10) + y(11) ) ) / x(1) ...
                + mu - p(5) * y(8);
%-----------------------------------------------------------
% the end!   
