% Example 18-5: \mathrm{Using}\,a\,\mathrm{Tracer}\,\mathrm{to}\,\mathrm{Determine}\,\mathrm{Model}\,\mathrm{Parameters}\,\mathrm{in}\,a\,\mathrm{CSTR}\,\mathrm{with}\,\mathrm{Dead}\,\mathrm{Space}\,\mathrm{and}\,\mathrm{Bypass}\,\mathrm{Model}
%

alpha=0.7;
beta=0.2;
k=0.28;
CA0=2;
tau=linspace(0.1,50,200);
for i=1:200
taus(i) = alpha*tau(i)/(1 - beta);
CAS(i) = (-1 + sqrt(1 + 4*taus(i)*k*CA0))/(2*taus(i)*k);
CA(i) = beta*CA0 + (1 - beta)*CAS(i);
CACSTR(i) = (-1 + sqrt(1 + 4*tau(i)*k*CA0))/(2*tau(i)*k);
X(i) = 1 - CA(i)/CA0;
XCSTR(i) = 1 - CACSTR(i)/CA0;
end
tiledlayout(1,2)
set (gcf,'Position',[0,0.1,1000,400])
nexttile
plot(tau,CA(1:200),tau,CACSTR(1:200),'LineWidth',2)
xlabel('Space time, \tau (min)')
ylabel('Concentration (kmol/m^3)')
leg=legend('C_A (Model)','C_A (Ideal CSTR)');
leg.ItemTokenSize=[10,10];
axis([0 50 0 2])
title(' Concentration Profile')
grid on
nexttile
plot(tau,X(1:200),tau,XCSTR(1:200),'LineWidth',2)
xlabel('Space time, \tau (min)')
ylabel('Conversion,X')
leg=legend('X (Model)','X (Ideal CSTR)');
leg.ItemTokenSize=[10,10];
axis([0 50 0 1])
title('Conversion Profile')
grid on

%