function xprime=colT200_lv(t,X) 
% sample usage:   [t,x]=ode15s('colT200_lv',[0 5000],0.5*ones(1,2*NT));
%
% cola_lv - Subroutine for simulation with LV-configuration.
%           It calls the model colT200, and 
%           includes control of condenser and reboiler level 
%           using two P-controllers with the LV-configuration. 
%
%            Inputs are reflux (LT) and boilup (VB). Disturbances
%            are feedrate and feed composition. These are set by directly
%            altering 'colT200_lv.m'. Outputs are liquid composition and
%            liquid hold up for stages 1 through NT, given in x. 

% Number of stages in the column
NT=94;

% Inputs and disturbances

MW=58.124;		%kg/kmol
feed=22795+000;		%kg/h
refluks=88680+0000;		%kg/h
oppkok=95290+0000;		%kg/
h=60;			%min/h
m1=2250;%7000;		%kg vaeske i koker
mn=8000;		%kg vaeske i kondenser


LT=(refluks/MW)/h;                             % Reflux
VB=(oppkok/MW)/h;                              % Boilup
F=(feed/MW)/h + 0.00;                          % Feedrate
zF=0.29;                              % Feed composition
qF=1;                              % Feed liquid fraction

% P-Controllers for control of reboiler and condenser hold up.
KcB=10;  KcD=10;            % controller gains
MDs=(mn/MW); MBs=(m1/MW);   % Nominal holdups - these are rather small  
Bs=LT+F-VB;  Ds=F-Bs;       % Nominal flows
MB=X(NT+1);  MD=X(2*NT);    % Actual reboiler and condenser holdup
D=Ds+(MD-MDs)*KcD;          % Distillate flow
B=Bs+(MB-MBs)*KcB;       % Bottoms flow     

% Store all inputs and disturbances
U(1)=LT; U(2)=VB; U(3)=D; U(4)=B; U(5)=F; U(6)=zF; U(7)=qF;

xprime=colT200(t,X,U);

