%COMMANDS TO RUN LINEARIZED MODEL
clear all; close all; clc;
global coldata dyndata hydraulic termodata alfa 
%% COLUMN DATA %%

% Number of stages
coldata.Nt = [12 12 12 12 12 12];
% Initial holdup stages
coldata.M0 = [1 1 1 1 1 1 1 1 1 1 1 1];
%Boiling point of ethanol, propanol and n-butanol
coldata.Tboil = [78.37 97 117.4];
termodata.P = 1.0;
hydraulic.k1 = 1/0.063;
%% THERMODYNAMIC DATA %%
alfa=[4.215374389	2.102194688	1] %ethanol propanol butanol
load Nominal_final.mat
dyndata.x_nom=x_nom;
dyndata.u_nom=u_nom;
Ls=1.398616622;
VBs=1.73186;
Rls= 0.382737297;
RVs= 0.587419639;
S1s=0.33385308;
Fs=1;
zFs=[0.333 0.333];
%qfs=1;
Ds=0.333243378;                                    % *1.04;
Bs=0.332903542;
%[A B C D]=Petlyuk_linearize('Petlyuk_openloop_lin',(dyndata.x_nom)',[Ls VBs Rls RVs S1s Fs zFs...
 %   Ds Bs])
[A B C D]=Petlyuk_linearize('Petlyuk_lv_lin',(dyndata.x_nom)',[Ls VBs Rls RVs S1s Fs zFs])
% Extracting disturbances from input matrices
%Ad=A;                            
%Bd=[B(:,2),B(:,4),B(:,6:8)];
%B=[B(:,1),B(:,3),B(:,5)];
%Cd=C;
%Dd=[D(:,2),D(:,4),D(:,6:8)];
%D=[D(:,1),D(:,3),D(:,5)];
%The steady state gain matrix G(0)
Gy=-C/(A)*B+D; 

%get the LTI Model
%pmod=ss(A,B,C,D);
%dmod=ss(Ad,Bd,Cd,Dd);

