%
% Example 3.4: Simple Aerated Tank
%
% Bob Newell, March 1996
%
%-----------------------------------------------------------
%
function y = Simple_Aerated_Tank_Outputs( t, x )
global p
%
% x = [ 1=V 2=Ss 3=So ];
% y = [ 1=v_in 2=Ss_in 3=So_in, 
%       4=v_out 5=Ss_out 6=So_out,
%       7=v_a ];
% p = [ 1=Ka 2=So_sat ];
%
%-----------------------------------------------------------
  [ n, m ] = size( x );
  if m == 1,
    x = x';
    n = 1;
  end;
  y = zeros( n, 2 );
%
  for i = 1:n,
    % influent conditions
    y(i,1) = 5;
    y(i,2) = 200;
    y(i,3) = 0.2;
    % air flowrate
    if t(i) < 0.125,
      y(i,7) = 1;
    elseif t(i) < 0.5,
      y(i,7) = 5;
    else,
      y(i,7) = 9;
    end; 
    % constant volume
    y(i,4) = y(i,1);
    % well mixed
    y(i,5) = x(i,2);
    y(i,6) = x(i,3);
  end;
%-----------------------------------------------------------
% the end!   
