%% Essential parameters
% Number of stages (including reboiler and total condenser: 
NT = 5; 

% Location of feed stage (stages are counted from the bottom):
NF = NT-1;

% Relative volatilities:
alpha1 = [1.45*10^3 1 2.35*10 3.06*10 4.48*10 2.81*10];
R = 8.314; %i.g. constant
% Number of components
NC = length(alpha1);
Mw = [32.042 878 616 354 92.095 294];  


%% Dynamics
Dc = 1.5;                               % Diameter of column [m]
hw = 0.05;                              % Heigth of weir [m]
lw = 0.77*Dc;                           % Length of weir [m]
area_plate = pi*0.88*(Dc/2)^2;          % Area of plate [m^2]
volume_plate = area_plate * hw;         % Volume of plate [m^3]

%tau_1 = 0.063; %min

%% Density

% Density data:
%       Ar        Br    Cr     Dr
AR = [2.3267   0.27073 512.5 0.24713    % MetOH
      0.026085 0.14259 934.6 0.28571    % TG
      0.026085 0.14259 934.6 0.28571    % DG
      0.026085 0.14259 934.6 0.28571    % MG
      0.92382  0.24386 850   0.22114    % GL
      0.20469  0.23737 767.4 0.28571];  % BD

%% UNIQUAC parameters:
Re = 1.98721;   % universal gas constant [cal/molK]
z = 10;         % the coordination number

% UNIQUAC Parameters:
%      TG       DG       MG       BD      GL        MetOH
W = [   0     -48.519   213.876  47.076   836.044  3030.060
      59.273     0      -79.159  26.437   757.300  -89.061
     -139.052  114.633    0      219.802  317.795  -113.482
     -45.259   -16.759  -125.764   0      823.302     0
     -266.224  -274.223 -60.390  -262.612    0     411.932
     -704.965  870.689  534.174    0      -267.337    0    ];
 
% Coefficients for the vapour pressure equations [kPa]:
%      A            B           C          D          E
A = [505.205  -9.41262*10^4  -59.7879  5.8959*10^-19  6     %TG
     18.1551  -7.16544*10^3  -0.847809 3.18337*10^-20 6     %DG
     145.254  -2.11542*10^4  -16.8740  1.74025*10^-18 6     %MG
     107.534  -1.56037*10^4  -12.2136  1.79996*10^-18 6     %BD
     169.211  -1.68937*10^4  -21.8125  1.14067*10^-5  2     %GL
     59.8373  -6.28289*10^3  -6.37873  4.61746*10^-6  2];   %MetOH

% Volume parameters of pure components:
%       TG       DG     MG      BD    GL    MetOH
RP = [39.6176 28.0103 16.403 13.5084 4.7957 1.4311];

% Area parameters of pure components:
%      TG     DG    MG    BD    GL   MetOH
Q = [32.094 23.032 13.97 11.11 4.908 1.432];

%% Optimisation and control
% Prices
pMetOH = 180*10^-3;     % [$/kg]
pTG    = 338*10^-3;     % [$/kg] 
pBD    = 600*10^-3;     % [$/kg]
pGL    = 1200*10^-3;    % [$/kg]
% pGL    = 750*10^-3;     % [$/kg]
pLPS   = (6.8*10^-3);     % [$/ton]
pCW    = (0.007*10^-3);   % [$/kg]

% Soft constraint for the GL_tot:
% alpha_e = 30000000;
alpha_e = 100;


% Maximum and minimum boilup: 
VBmax = 8.5;
VBmin = 0.01;

% P-controllers for control of reboiler and condenser hold up.
KcB = -10;  KcD = -10;                  % controller gains
MDs = 5; MBs = 5;                       % Nominal holdups - these are rather small  
Ds  = 57/60; Bs  = 293/60;              % Nominal flows

