%
% Example 3.3: Simple Buffer Tank
%
% Bob Newell, March 1996
%
%-----------------------------------------------------------
%
function y = Simple_Buffer_Tank_Outputs( t, x )
global p
%
% x = [ 1=V 2=Ss ];
% y = [ 1=v_in 2=Ss_in 3=v_out 4=Ss_out  ];
% p = [ 1= ];
%
%-----------------------------------------------------------
  [ n, m ] = size( x );
  if m == 1,
    x = x';
    n = 1;
  end;
  y = zeros( n, 2 );
%
  for i = 1:n,
    % influent conditions
    if t(i) < 0.25,
      y(i,1) = 5;
      y(i,2) = 200;
    elseif t(i) < 10/24,
      y(i,1) = 10;
      y(i,2) = 200;
    else,
      y(i,1) = 10;
      y(i,2) = 150;
    end;
    % constant volume 
    y(i,3) = y(i,1);
    % well mixed
    y(i,4) = x(i,2);
  end;
%-----------------------------------------------------------
% the end!   
