function main
global F_FEED T0 P0 WEIGHT_cat R Ua F_G0 F_H2O0 F_N20 F_A0 F_AC0 F_AA0 F_FA0 F_T0;
F_FEED = 100;
T0 = 650;
P0 = 303975;
WEIGHT_cat = 100;
R = ToBeSpecified;
Ua = ToBeSpecified;
Feed = zeros(8,1);
Feed(1) = 0.014*F_FEED;
Feed(2) = 0.634*F_FEED;
Feed(3) = 0.352*F_FEED;
Feed(8) = T0;
F_G0 = Feed(1);
F_H2O0 = Feed(2);
F_N20 = Feed(3);
F_A0 = Feed(4);
F_AC0 = Feed(5);
F_AA0 = Feed(6);
F_FA0= Feed(7);
F_T0 = F_FEED;
[W,F] = ode45(@Reactors , [0 WEIGHT_cat], Feed);
end
function dFdW = Reactors(t,F)
global F_FEED T0 P0 WEIGHT_cat R Ua F_G0 F_H2O0 F_N20 F_A0 F_AC0 F_AA0 F_FA0 F_T0;
dFdW = zeros(8,1);
Hf_G = -577.9;
Hf_H2O = -241.818;
Hf_N2 = 0;
Hf_A = -65;
Hf_AC = -370.06;
Hf_AA = -166.1;
Hf_FA = -108.6;
Cp_G = -35.3267443 + 0.645106658*F(8) - 0.00061741*F(8)^2 + 0.000000239229*F(8)^3;
Cp_H2O = 32.95266198 - 0.00391977*F(8) + 0.0000222314*F(8)^2 - 0.0000000104953*F(8)^3;
Cp_N2 = 28.883 -0.00157*F(8)+ 0.00000808*F(8)^2 -0.000000002871*F(8)^3;
Cp_A = -14.9617445 + 0.373240705*F(8) - 0.00034559*F(8)^2 + 0.000000129748*F(8)^3;
Cp_AC = -11.7479865 + 0.402868987*F(8) - 0.00031782*F(8)^2 + 0.000000109142*F(8)^3;
Cp_AA = -5.82005966 + 0.23787576*F(8) - 0.00017362*F(8)^2 + 0.0000000543415*F(8)^3;
Cp_FA = 19.10519375 + 0.048680586*F(8) + 0.00000878405*F(8)^2 - 0.0000000150776*F(8)^3;
integraldeltaCp_rxn_1 = 2*(32.95266198*(F(8)-298) - 0.5*0.00391977*(F(8)^2-298^2) + (1/3)*0.0000222314*(F(8)^3-298^3) - (1/4)*0.0000000104953*(F(8)^4-298^4)) + (-14.9617445*(F(8)-298) + 0.5*0.373240705*(F(8)^2-298^2) - (1/3)*0.00034559*(F(8)^3-298^3) + (1/4)*0.000000129748*(F(8)^4-298^4)) - ((-35.3267443*(F(8)-298) + 0.5*0.645106658*(F(8)^2-298^2) - (1/3)*0.00061741*(F(8)^3-298^3) + (1/4)*0.000000239229*(F(8)^4-298^4)));
integraldeltaCp_rxn_2 = (32.95266198*(F(8)-298) - 0.5*0.00391977*(F(8)^2-298^2) + (1/3)*0.0000222314*(F(8)^3-298^3) - (1/4)*0.0000000104953*(F(8)^4-298^4) + (-11.7479865*(F(8)-298) + 0.5*0.402868987*(F(8)^2-298^2) - (1/3)*0.00031782*(F(8)^3-298^3) + (1/4)*0.000000109142*(F(8)^4-298^4)) - (32.95266198*(F(8)-298) - 0.5*0.00391977*(F(8)^2-298^2) + (1/3)*0.0000222314*(F(8)^3-298^3) - (1/4)*0.0000000104953*(F(8)^4-298^4)));
integraldeltaCp_rxn_3 = (32.95266198*(F(8)-298) - 0.5*0.00391977*(F(8)^2-298^2) + (1/3)*0.0000222314*(F(8)^3-298^3) - (1/4)*0.0000000104953*(F(8)^4-298^4) + (19.10519375*(F(8)-298) + 0.5*0.048680586*(F(8)^2-298^2) + (1/3)*0.00000878405*(F(8)^3-298^3) - (1/4)*0.0000000150776*(F(8)^4-298^4)) + (-5.82005966*(F(8)-298) + 0.5*0.23787576*(F(8)^2-298^2) - (1/3)*0.00017362*(F(8)^3-298^3) + (1/4)*0.0000000543415*(F(8)^4-298^4)) - (-35.3267443*(F(8)-298) + 0.5*0.645106658*(F(8)^2-298^2) - (1/3)*0.00061741*(F(8)^3-298^3) + (1/4)*0.000000239229*(F(8)^4-298^4)));
integraldeltaCp_rxn_4 = (32.95266198*(F(8)-298) - 0.5*0.00391977*(F(8)^2-298^2) + (1/3)*0.0000222314*(F(8)^3-298^3) - (1/4)*0.0000000104953*(F(8)^4-298^4) + (19.10519375*(F(8)-298) + 0.5*0.048680586*(F(8)^2-298^2) + (1/3)*0.00000878405*(F(8)^3-298^3) - (1/4)*0.0000000150776*(F(8)^4-298^4)) + (-5.82005966*(F(8)-298) + 0.5*0.23787576*(F(8)^2-298^2) - (1/3)*0.00017362*(F(8)^3-298^3) + (1/4)*0.0000000543415*(F(8)^4-298^4)) - (-35.3267443*(F(8)-298) + 0.5*0.645106658*(F(8)^2-298^2) - (1/3)*0.00061741*(F(8)^3-298^3) + (1/4)*0.000000239229*(F(8)^4-298^4)));
Hrxn_1 = 2*Hf_H2O + Hf_A - Hf_G + (integraldeltaCp_rxn_1);
Hrxn_2 = 2*Hf_H2O + Hf_AC - Hf_G + (integraldeltaCp_rxn_2);
Hrxn_3 = Hf_H2O + Hf_AA + Hf_FA - Hf_G + (integraldeltaCp_rxn_3);
Hrxn_4 = Hf_H2O + Hf_AA + Hf_FA - Hf_G + (integraldeltaCp_rxn_4);
VOLUMETRICFLOWRATEin = F_FEED*R*T0;
C_G0 = F_G0/VOLUMETRICFLOWRATEin;
C_H2O0 = F_H2O0/VOLUMETRICFLOWRATEin;
C_N20 = F_N20/VOLUMETRICFLOWRATEin;
C_A0 = 0;
C_AC0 = 0;
C_AA0 = 0;
C_FA0 = 0;
C_T0 = F_FEED/VOLUMETRICFLOWRATEin;
F_T = F(1) + F(2) + F(3) + F(4) + F(5) + F(6) + F(7);
C_G = C_T0*(F(1)/F_T)*(T0/F(8));
C_H2O = C_T0*(F(2)/F_T)*(T0/F(8));
C_N2 = C_T0*(F(3)/F_T)*(T0/F(8));
C_A = C_T0*(F(4)/F_T)*(T0/F(8));
C_AC = C_T0*(F(5)/F_T)*(T0/F(8));
C_AA = C_T0*(F(6)/F_T)*(T0/F(8));
C_FA = C_T0*(F(7)/F_T)*(T0/F(8));
k1 = 23.3244*exp(-45007.1/(R*F(8)));
k2 = 2528.8*exp(-79244.89/(R*F(8)));
k3 = 2150.595*exp(-73702.78/(R*F(8)));
k4 = 0.146768*exp(-24596.97/(R*F(8)));
r_1 = -k1*C_G;
r_2 = -k2*C_G;
r_3 = -k3*C_G;
r_4 = -k4*C_G;
r_G = -(k1+k2+k3+k4)*C_G;
r_N2 = 0;
r_H2O = k1*(C_G)^2+(k3+k4)*G_G;
r_A = k1*C_G;
r_AC = k2*C_G;
r_AA = (k3+k4)*C_G;
r_FA = (k3+k4)*C_G;
dFdW(1) = (r_G);
dFdW(2) = (r_H2O);
dFdW(3) = (r_N2);
dFdW(4) = (r_A);
dFdW(5) = (r_AC);
dFdW(6) = (r_AA);
dFdW(7) = (r_FA);
dFdW(8) = (Ua(Ta-T0)+(-r_1)*(-Hrxn_1)+(-r_2)*(-Hrxn_2)+(-r_3)*(-Hrxn_3)+(-r_4)*(-Hrxn_4))/(F(1)*Cp_G + F(2)*Cp_H2O + F(3)*Cp_N2 + F(4)*Cp_A + F(5)*Cp_AC + F(6)*Cp_AA + F(7)*Cp_FA);
end
Best Answer