function [sys] = MiniLoop_model(t,x,u,output,par)

% Simplified model for riser slugging
% By: Esmaeil Jahanshahi
% August 2009, NTNU, Norway

% x1: Mass of gas in the pipelien (m_G1)
% x2: Mass of liquid in the pipeline (m_L1)
% x3: Mass of gas in the riser (m_G2)
% x4: Mass of liquid in the riser (m_L2)

[xdot,y]=MiniLoop_model0(x,u,par);
Pnormal = 101325; % atmospheric pressure
if isequal(output,'derivatives')
    sys =xdot;
    if ~isreal(sys)
        disp('Complex')
        sys=0*sys;
    end
elseif isequal(output,'measurements')
    sys = [1e-3*(y(1) - Pnormal)     %Y1 kpa Gauge
           1e-3*(y(2) - Pnormal)     %Y2 kpa Gauge
           1000*60*y(3)              %Y3 litr/min
           60*y(4)];                 %Y4 Kg/min
end 

end