function xprime=multicomAB_lv(t,X) 
% sample usage:   [t,x]=ode15s('multicomA_lv',[0 20000],0.5*ones(1,NC*NT));[used SS values];
% keep record of results: lengthx=size(x); Xinit=x(lengthx(1),:)';

% multicomA_lv - Subroutine for simulation with LV-configuration.
%           It calls the model multicomA, 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 'multicomA_lv.m'. Outputs are liquid compositions 
%           for light and intermediate components and
%           liquid hold up for stages 1 through NT, given in x. 

% Number of stages in the column
NT=40;
%Number of component
NC=5;
% Inputs and disturbances
LT=8.6;
%LT=6.0; % Reflux kmol/min
%LT=14.1;
VB=11.85;                        % Boilup kmol/min
%VB=9.9;
F=11.6;                          % Feedrate kmol/min
%F=12.21;
qF=0.579;                        % Feed liquid fraction
%qF=0.5;
zF=[0.00 0.00206825 0.22003723 0.47840547 0.29948906];% Feed compositions for component A to component NC (CO2+C1+C2,C3,iC4,nC4,C5+)%% P-Controllers for control of reboiler and condenser hold up.
%%
KcB=0.5;  KcD=0.02;                     % controller gains
MDs=62; MBs=18;                   % Nominal holdups kmol
Ds=8.1; Bs=3.5;                  % Nominal flows % kmol/min
%Ds=8.1; Bs=4.11;
MB=X((NC-1)*NT+1);  MD=X(NC*NT);     % Actual reboiler and condenser holdup Kmol
D=Ds+(MD-MDs)*KcD;                   % Distillate flow Kmol/min
B=Bs+(MB-MBs)*KcB;                   % Bottoms flow  Kmol/min   

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

xprime=multicomAB_mat(t,X,U);

