% Number of stages in the rectifying section: 
Nr = 51;
% Total number of 'stages'  
NT = Nr + 2;                                  % We include condenser and reboiler 
    
% Initial conditions
zFA=0.6*ones(1,NT);                           % Initial composition of light component
zFB=0.2*ones(1,NT);                           % Initial composition of intermediate component
Md=0.5;                                     % Initial holdup in condenser (kmol)
M1=1/510*ones(1,Nr);                          % Constant holdup in rectifying section (kmol)  
Mb=4.5;                                     % Initial holdup in reboiler (kmol) 
T0=(75+273.15)*ones(1,NT);                         % Initial temperature in each stage (K)

% Defining options and mass matrix for ODE solver 
M=eye(3*NT,3*NT);
M(3*NT+1:4*NT,3*NT+1:4*NT)=0;
options.Mass=M; 

% Running column
[t,x]=ode15s(@input_rectifier,[0 1],[zFA,zFB,Md,M1,Mb,T0],options);

% Save results
save x; 
lengthx=size(x); Xinit=x(lengthx(1),:)';
save Xinit;
save C:/4s/AIChE/Ethanol_Benzene_Water/rectifier/decanting/Xinit.mat

Results=[Xinit(2*NT+1), Xinit(3*NT);...
         Xinit(1), Xinit(NT);...
         Xinit(NT+1), Xinit(2*NT);...
         1-Xinit(1)-Xinit(NT+1), 1-Xinit(NT)-Xinit(2*NT)];