
% Linearised model of the CSTR, 3 equations;
% state-space equations, Reaction A ----> B;

%   k0 = a1       [1/min];
%   g = a2        [K];
%   ro = a3       [kg/m3];
%   cp = a4       [kJ/kg.K];
%   V = a5        [m3];
%   Hr = a6       [kJ/kmol];
%   F = a7        [m2];
%   al = a8       [kJ/m2.min.K];
%   roc = a9      [kg/m3];
%   cpc = a10     [kJ/kg.K];
%   Vc = a11      [m3];
%   qs = a12      [m3/min];
%   Thvs = a13    [K];
%   cavs = a14    [kmol/m3];
%   Thcvs = a15   [K];
%   qcs = a16     [m3/min];
%   cas = a17     [kmol/m3];
%   Ths = a18     [K];
%   Thcs = a19    [K];

%   x(1) - concentration of A, dimensionless, deviation;
%   x(2) - temperature of the mixture, dimensionless, deviation; 
%   x(3) - jacket temperature, dimensionless, deviation;
%   u(1) - cooling flowrate, dimensionless, deviation;
%   u=qc/qcs ;
%   u(1)=<-0.2,   0.2> = cca<-0.001m3/min,0.001m3/min>;

a1=10000000000000; a2=11078;
a3=970; a4=4.05;
a5=1.8; a6=149280;
a7=5.04; a8=130;
a9=998; a10=4.18;
a11=0.7; a12=0.25;
a13=370; a14=0.88;
a15=285; a16=0.05;
a17=0.0345; a18=385.877;
a19=361.51753;

% Calculation of the state-space coefficients;
as11=-1-((a5*a1)/a12)*(exp(-a2/a18));
as12=-((a5*a1*a6*a2*a17)/(a12*a3*a4*((a18)^2)))*(exp(-a2/a18));
as13=0;
as21=((a5*a1)/a12)*(exp(-a2/a18));
as22=-1-((a7*a8)/(a12*a3*a4));
as22=as22 +((a5*a1*a6*a2*a17)/(a12*a3*a4*((a18)^2)))*(exp(-a2/a18));
as23=(a7*a8)/(a12*a9*a10);
as31=0;
as32=(a7*a8*a5)/(a12*a11*a3*a4);
as33=-(a7*a8*a5)/(a12*a11*a9*a10)-(a5*a16)/(a12*a11);
bs11=0; 
bs21=0;
bs31=-(a5*a16*a9*a10*a19)/(a12*a11*a14*a6);
bs31=bs31+(a9*a10*a5*a16*a15)/(a14*a6*a12*a11);



