You are on page 1of 4

function dX = f3b(t,X)

k=0.02;
NA0=5e-3;
NB0=2E-3;
omega=0.01;
V0=1e-3
V=0.75*V0+0.25*V0*cos(omega*t);
R1=k*((NA0-NB0*X)/V)^0.5*((NB0*(1-X))/V);
dX=R1*V/NB0
end
t=0:100;
X0=0;
[t,X] = ode45(@f3b,t,X0);
n=length(t);
i=1;
while X(i)<0.9
i=i+1;
end
figure(1)
plot(t(1:i),X(1:i),'-')
title('Conversion of B as a function of time')
xlabel('Time, s')
ylabel('Conversion')
NAI=5e-3;
NBI=2E-3;
NA=NAI-NBI*X(1:i);
NB=NBI-NBI*X(1:i);
NC=NBI*X(1:i);
figure(2)
plot(t(1:i),NA,'-',t(1:i),NB,':',t(1:i),NC,'-.')
title('Moles of species as a function of time')
xlabel('Time, s')
ylabel('Moles')
hleg1=legend('NA','NB','NC')
VI=1e-3;
Omega=0.01;
VR=0.75*VI+0.25*VI*cos(Omega*(t));

figure(3)
plot(t(1:i),VR(1:i),'-')
title('Reactor volume')
xlabel('Time, s')
ylabel('Volume, m^3')
CA=NA./VR(1:i);
CB=NB./VR(1:i);
CC=NC./VR(1:i);
figure(4)
plot(t(1:i),CA,'-',t(1:i),CB,':',t(1:i),CC,'-.')
title('Concentation of species as a function of time')
xlabel('Time, s')
ylabel('Concentration, mol/m^3')
hleg1=legend('CA','CB','CC')
T=500;
R=0.082;
PA=CA*1E-3*R*T;
PB=CB*1E-3*R*T;
PC=CC*1E-3*R*T;
P=PA+PB+PC;
figure(5)
plot(t(1:i),P,'-')
title('Reactor pressure')
xlabel('time, s')
ylabel('pressure, atm')

function dX = convert(t,X)
k1=0.02;
NA0=5*0.001;
NB0=2*0.001;
R1=k1*((NA0-(NB0*X))^0.5*((NB0*(1-X));
dX=R1/NB0
end
t=0:100000000;
X0=0;
[t,X] = ode45(@f3b,t,X0);
n=length(t);
i=1;
while X(i)<0.9
i=i+1;
end
figure(1)
plot(t(1:i),X(1:i),'-')
title('Conversion of B as a function of time')
xlabel('Time, s')
ylabel('Conversion')
NAI=5e-3;
NBI=2E-3;
NA=NAI-NBI*X(1:i);
NB=NBI-NBI*X(1:i);
NC=NBI*X(1:i);
figure(2)
plot(t(1:i),NA,'-',t(1:i),NB,':',t(1:i),NC,'-.')
title('Moles of species as a function of time')
xlabel('Time, s')
ylabel('Moles')
hleg1=legend('NA','NB','NC')
CA=NA./1;
CB=NB./1;
CC=NC./1;
figure(3)
plot(t(1:i),CA,'-',t(1:i),CB,':',t(1:i),CC,'-.')
title('Concentation of species as a function of time')
xlabel('Time, s')
ylabel('Concentration, mol/m^3')
hleg1=legend('CA','CB','CC')
T=500;
R=0.082;

PA=CA*0.001*R*T;
PB=CB*0.001*R*T;
PC=CC*0.001*R*T;
P=PA+PB+PC;
figure(4)
plot(t(1:i),P,'-')
title('Reactor pressure')
xlabel('time, s')
ylabel('pressure, atm')

You might also like