function xprime=cola_lv_nonideal(t,X) 
% ******************************************************************************************
% ********************* Program written by Stathis Skouras, July 2001 **********************
% ******************************************************************************************

% cola_lv_nonideal - Subroutine for simulation with LV-configuration.
%           It calls the model 'colamod_nonideal', 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 and feed liquid fraction. 
%           Outputs are liquid compositions for light and intermediate components,
%           liquid holdup at each stage and temperature at each stage, given in Xss. 


% START: The following data must be changed for a new column:
% Number of stages in the column
NT=41;

% Inputs and disturbances
LT=2.70629;                          % Reflux
VB=3.20629;                          % Boilup
F=1.0 + 0.00;                        % Feedrate
zFA=0.4;                             % Feed composition of component A
zFB=0.4;                             % Feed composition of component B
zFC=0.2;                             % Feed composition of component C
qF=1.0;                              % Feed liquid fraction

% P-Controllers for control of reboiler and condenser hold up.
KcB=10;  KcD=10;                     % Controller gains
MDs=0.5; MBs=0.5;                    % Nominal holdups - these are rather small  
Ds=0.5; Bs=0.5;                      % Nominal flows

% END: The following data must be changed for a new column:

MB=X(2*NT+1);  MD=X(3*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)=zFA; U(7)=zFB; U(8)=zFC; U(9)=qF;

xprime=colamod_nonideal(t,X,U);
