% LEP 8-4 : Series Reaction in a CSTR
%

R=1.987*10^-3;
k1o=0.5;
k2o=0.2;
E1=0.8;
E2=0.6;
T=450;
CA0=2;
k1=k1o*exp((E1/R)*(1/300-1/T));
k2=k2o*exp((E2/R)*(1/300-1/T));
tiledlayout(2,2)
set (gcf,'Position',[0,0.1,800,400])
tau=linspace(0,20,100);
for i=1:100
CA(i)=CA0/(1+tau(i)*k1);
CB(i)=tau(i)*k1*CA0/((1+tau(i)*k1)*(1+tau(i)*k2));
CC(i)=(tau(i)^2)*k1*k2*CA0/((1+tau(i)*k1)*(1+tau(i)*k2));
X(i)=(CA0-CA(i))/CA0;
end
z=size(tau);
nexttile
plot(tau,CA(1:z(1,2)),tau,CB(1:z(1,2)),tau,CC(1:z(1,2)),'LineWidth',2)
axis([0 20 0 5])
leg=legend('C_A','C_B','C_C');
leg.ItemTokenSize=[10,10];
xlabel('tau (hr)')
ylabel('C_i (mol/dm^3)')
title('Concentration Profiles')
grid on
nexttile
plot(tau,CB(1:z(1,2))./((CA0-CA(1:z(1,2)))+0.0000000000001),'LineWidth',2)
axis([0 20 0 1])
legend('Yield')
xlabel('tau (hr)')
ylabel('Yield')
leg=legend('Y_B');
title('Yield Profiles')
leg.ItemTokenSize=[10,10];
grid on
nexttile
plot(tau,CB(1:z(1,2))./(CC(1:z(1,2))+0.0000000000001),'LineWidth',2)
axis([0 20 0 50])
ylabel('Selectivity')
xlabel('tau (hr)')
leg=legend('S_B_/_C');
leg.ItemTokenSize=[10,10];
title('Selectivity Profiles')
grid on
nexttile
plot(tau,X(1:z(1,2)),'LineWidth',2)
axis([0 20 0 1])
ylabel('Conversion')
xlabel('tau (hr)')
leg=legend('X');
leg.ItemTokenSize=[10,10];
title('Conversion Profiles')
grid on