% Author: Housam Binous
% Finding best reactor set-up
% National Institute of Applied Sciences and Technology, Tunis, TUNISIA
% Email: binoushousam@yahoo.com
% This problem was solved graphically by O. Levenspiel in Chemical Reaction
% Engineering, 3rd Edition, Wiley, 1999.
clc
global X
% Volumetric Flow
v=0.1;
%Inlet concentration CA0, outlet concentration CA
%and space time Tau in a laboratory mixed flow reactor
CA0 = [2 5 6 6 11 14 16 24];
CA = [0.5 3 1 2 6 10 8 4];
Tau = [30 1 50 8 4 20 20 4];
chi=Tau./(CA0-CA)
X=sortrows([CA;chi]');
% Volume of a plug flow rector with recycle
figure(1)
hold on
Y=fsolve(@zeroreact,[2 6])
V=feval(@InvReact,Y(1))*(10-1)*v
R=(10-Y(2))/(Y(2)-1)
VR=R*v
x=1:10;
a=feval(@InvReact,Y(1))*ones(1,10);
b=zeros(1,10);
[ph,msg]=jbfill(x,a,b,rand(1,3),rand(1,3),0,rand(1,1));
x=1:0.1:Y(1);
a=feval(@InvReact,1:0.1:Y(1));
b=feval(@InvReact,Y(1))*ones(1,12);
[ph,msg]=jbfill(x,a,b,rand(1,3),rand(1,3),0,rand(1,1));
x=Y(1):0.1:Y(2);
b=feval(@InvReact,Y(1):0.1:Y(2));
a=feval(@InvReact,Y(1))*ones(1,51);
[ph,msg]=jbfill(x,a,b,rand(1,3),rand(1,3),0,rand(1,1));
axis([0 10 0 10])
plot(X(:,1),X(:,2),'r*')
xlabel('CA')
ylabel('-1/rA')
plot(0.5:0.2:10,spline(X(:,1),X(:,2),0.5:0.2:10),'b')
% Volume needed if one uses an arrangement of a plug flow reactor
% and a stirred tank reactor
figure(2)
hold on
V=v*(quadl(@InvReact,1,4)+feval(@InvReact,4)*(10-4))
x=1:0.1:4;
a=feval(@InvReact,x);
b=zeros(1,31);
[ph,msg]=jbfill(x,a,b,rand(1,3),rand(1,3),0,rand(1,1));
x=4:0.1:10;
a=feval(@InvReact,4)*ones(1,61);
b=zeros(1,61);
[ph,msg]=jbfill(x,a,b,rand(1,3),rand(1,3),0,rand(1,1));
axis([0 10 0 10])
plot(X(:,1),X(:,2),'r*')
xlabel('CA')
ylabel('-1/rA')
plot(0.5:0.2:10,spline(X(:,1),X(:,2),0.5:0.2:10),'b')
% Volume of two stirred tanks
K=fsolve(@diffreact,2)
V=v*(feval(@InvReact,1)*(K-1)+feval(@InvReact,K)*(10-K))
figure(3)
hold on
x=1:0.01:K;
a=feval(@InvReact,1)*ones(1,149);
b=zeros(1,149);
[ph,msg]=jbfill(x,a,b,rand(1,3),rand(1,3),0,rand(1,1));
x=K:0.1:10;
a=feval(@InvReact,K)*ones(1,76);
b=zeros(1,76);
[ph,msg]=jbfill(x,a,b,rand(1,3),rand(1,3),0,rand(1,1));
axis([0 10 0 10])
plot(X(:,1),X(:,2),'r*')
xlabel('CA')
ylabel('-1/rA')
plot(0.5:0.2:10,spline(X(:,1),X(:,2),0.5:0.2:10),'b')