% *************************************************************************
% function for the dynamic equation of the tank in series 
% 
% 
% Block comment (Ctrl- R); block uncomment (Ctrl-T)
%
% x = state (level); u = inputs(flows); d = disturbances;   
% 
% p - Tank parameters 
%  -                 -         -      -
% |        Area       |       |  6000  | m^2
% |                   |   =   |        |
% | Nominal flow rate |       |   300  | m^3/min
% |                   |       |        |
%  -                 -         -      -
% 
% *************************************************************************

function dxdt  = TankODE(p,u,d)

    % tank parameters
    Area = p(1);
    
    % input, u, valve opening 0 - 100% 
    qIn = u(1)*p(2);  % inlet flow
    qOut = u(2)*p(2); % outlet flow
    
    % bottlenecks, hand valve openings
    zIn = d(1);
    zOut = d(2);

    % differential equation for the tank level
    dxdt = (zIn*qIn - zOut*qOut)/Area;
    
end
