> restart;

> Sc:=T->Sc1*(T-T0)/(T1-T0); The volume rate of thermal energy produced by reactions is Sc. This is a simplification assuming a linear temperature independence.

[Maple Math]

> Qcond:=z->pi*R^2*qz(z); Thermal energy by conduction through the reactor at a point z.

[Maple Math]

> Qconv:=z->pi*R^2*rho1*v1*Cp*(T(z)-T0); Thermal energy by convection through the reactor at a point z.

[Maple Math]

> LHS:=limit((Qcond(z+dz)-Qcond(z)+Qconv(z+dz)-Qconv(z))/pi/R^2/dz,dz=0); Energy balance across a segment of length delta z. Taking the limit as delta z goes to 0 gives a differential equation.This equation does not include the energy production term.

[Maple Math]

> qz:=z->-keff*D(T)(z); Subsitutes Fourier's Law into differential equation.

[Maple Math]

> eq1:=simplify(LHS=0); Equation for Zone 1.

[Maple Math]

> eq2:=simplify(LHS=Sc(T(z))); Adds the term for heat generated by chemical reaction within the reactor.

[Maple Math]

> eq3:=simplify(LHS=0); Equation for Zone 3.

[Maple Math]

> with(PDEtools,dchange); Loads the dchange command.

[Maple Math]

> transf1:={z=Z*L,T(z)=Theta1*(T1-T0)+T0}; Sets up the dimensionless variable transfer vectors for the three sections of the reactor. These are used with dchange.

[Maple Math]

> transf2:={z=Z*L,T(z)=Theta2*(T1-T0)+T0};

[Maple Math]

> transf3:={z=Z*L,T(z)=Theta3*(T1-T0)+T0};

[Maple Math]

> eq1b:=dchange(transf1,eq1,[Theta1(Z),Z]):

> eq2b:=dchange(transf2,eq2,[Theta2(Z),Z]):

> eq3b:=dchange(transf3,eq3,[Theta3(Z),Z]):

Substitute for the other two dimensionless quantities, which are parameters for the system.

> v1:=B*keff/rho1/Cp/L:

> Sc1:=rho1*v1*Cp*(T1-T0)*N/L:

The dimensionless differential equations for each of the three zones simplified so that they are similar to BSL equations 9.5-23-25

> eq1c:=simplify(eq1b*L^2/B/keff/(-T1+T0));

[Maple Math]

> eq2c:=simplify(eq2b*L^2/B/keff/(-T1+T0));

[Maple Math]

> eq3c:=simplify(eq3b*L^2/B/keff/(-T1+T0));

[Maple Math]

Using dsolve to solve the differential equations.

> s1:=dsolve(eq1c,Theta1(Z));

>

[Maple Math]

> assign(s1); Theta1:=unapply(Theta1(Z),Z):

> _C1:=1; _C2:=c2; We know that c1=1 because at Z=-infinity, T is equal to T1 meaning that Theta equals 1.

[Maple Math]

[Maple Math]

> s2:=dsolve(eq2c,Theta2(Z));

[Maple Math]
[Maple Math]

> _C3:=c3; _C4:=c4;

[Maple Math]

[Maple Math]

> assign(s2); Theta2:=unapply(Theta2(Z),Z);

[Maple Math]
[Maple Math]

> s3:=dsolve(eq3c,Theta3(Z));

[Maple Math]

> assign(s3); Theta3:=unapply(Theta3(Z),Z);

[Maple Math]

> _C6:=0; _C5:=c5; We know that c6=0 because at z=infinity, T is finite.

[Maple Math]

[Maple Math]

> con:=solve({Theta1(0)=Theta2(0),D(Theta1)(0)=D(Theta2)(0),Theta2(1)=Theta3(1),D(Theta2)(1)=D(Theta3)(1)},{c2,c3,c4,c5}); Solving for the remaining constants using the given boundary conditions.

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

> assign(con);

The three final solutions are very complicated in Maple.

> simplify(Theta1(Z));

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

> simplify(Theta2(Z));

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

> simplify(Theta3(Z));

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

>

Some example cases using different values for the parameters B and N.

> B:=8;N:=1;

>

[Maple Math]

[Maple Math]

> PlotN11:=simplify(evalf(expand(Theta1(Z))));

>

[Maple Math]

> PlotN12:=simplify(evalf(expand(Theta2(Z))));

[Maple Math]
[Maple Math]

> PlotN13:=simplify(evalf(expand(Theta3(Z))));

[Maple Math]

> pN11:=plot(PlotN11,Z=-.6...0):

> pN12:=plot(PlotN12,Z=0...1):

> pN13:=plot(PlotN13,Z=1...1.3):

> with('plots'):

> display([pN11,pN12,pN13]); This generates a plot very similar to the one in BSL.

> N:=2;

[Maple Math]

> PlotN01:=simplify(evalf(expand(Theta1(Z))));

Error, (in Theta1) division by zero

> PlotN02:=simplify(evalf(expand(Theta2(Z))));

Error, (in Theta2) division by zero

> PlotN03:=simplify(evalf(expand(Theta3(Z))));

Error, (in Theta3) division by zero

> N:='N'; For N=2, we get a divide by 0 error. This can be solved by taking the limit as N goes to 2.

[Maple Math]

> PlotN21:=limit(simplify(evalf(expand(Theta1(Z)))),N=2);

[Maple Math]

> PlotN22:=limit(simplify(evalf(expand(Theta2(Z)))),N=2);

[Maple Math]

> PlotN23:=limit(simplify(evalf(expand(Theta3(Z)))),N=2);

[Maple Math]

> pN21:=plot(PlotN21(Z),Z=-.6...0):

> pN22:=plot(PlotN22(Z),Z=0...1):

> pN23:=plot(PlotN23(Z),Z=1...1.5):

> display([pN21,pN22,pN23]); This plot is also identical to that shown in BSL.

> N:=4;

[Maple Math]

> PlotN41:=simplify(evalf(expand(Theta1(Z))));

[Maple Math]

> PlotN42:=simplify(evalf(expand(Theta2(Z))));

[Maple Math]
[Maple Math]

> PlotN43:=simplify(evalf(expand(Theta3(Z))));

[Maple Math]

We find that with a value of B=8, that for values of N greater than 2 Maple gives an imaginary solution. This is because of the sqrt(-B(-B+4N)) term in our solutions. However these should cancel out to give a real answer.

> pN41:=plot(PlotN41(Z),Z=-.6...0):

> pN42:=plot(PlotN42(Z),Z=0...1):

> pN43:=plot(PlotN43(Z),Z=1...1.5):

> display([pN41,pN42,pN43]);

In the region in the reactor, the imaginary terms do not go away so we cannot generate a good plot. If we try the book's solutions a much better answer is obtained.

> m3:=1/2*B*(1-sqrt(1-4*N/B));

[Maple Math]

> m4:=1/2*B*(1+sqrt(1-4*N/B));

[Maple Math]

> T1book:=1+(m3*m4*(exp(m4)-exp(m3)))/(m4^2*exp(m4)-m3^2*exp(m3))*exp((m3+m4)*Z);

[Maple Math]

> Theta1bk:=simplify(expand(evalf(T1book)));

[Maple Math]

> T2book:=(m4*exp(m4)*exp(m3*Z)-m3*exp(m3)*exp(m4*Z))/(m4^2*exp(m4)-m3^2*exp(m3))*(m3+m4);

[Maple Math]
[Maple Math]
[Maple Math]

> Theta2bk:=(expand(simplify(evalf(T2book))));

[Maple Math]
[Maple Math]
[Maple Math]

> T3book:=(m4^2-m3^2)/(m4^2*exp(m4)-m3^2*exp(m3))*exp(m3+m4);

[Maple Math]

> Theta3bk:=(expand(simplify(evalf(T3book))));

[Maple Math]

> pbkN41:=plot(Theta1bk(Z),Z=-.6...0):

> pbkN42:=plot(Theta2bk(Z),Z=0...1):

> pbkN43:=plot(Theta3bk(Z),Z=1...1.5):

> display([pbkN41,pbkN42,pbkN43]);

Here the plot is significantly better, and we find that if we evaluate the function at a point between z=0 and L we get a real number.

> Z:=.5;Theta2bk;

[Maple Math]

[Maple Math]

If we evaluate the Maple solution at this point, we find almost the same answer only with a small imaginary term. This is probably due to round off error in the course of working the problem.

> PlotN42;

[Maple Math]

Maple cannot plot the function with such a small round off error, however it can be done in Matlab and the results are shown on the main page of the report. The imaginary term is so small that it can be neglected.The Matlab plot is done ignoring the imaginary term.

>