Example 3.8b Cylindrical Catalyst Pellet
| > |
with(linalg):with(plots): |
 |
(1) |
 |
(2) |
| > |
eq:=diff(y(x),x$2)+1/x*diff(y(x),x)-phi^2*y(x); |
 |
(3) |
 |
(4) |
| > |
bc2:=diff(y(x),x)-1+y(x); |
 |
(5) |
The central difference expression for the second and first derivatives are
| > |
d2ydx2:=(y[m+1]-2*y[m]+y[m-1])/h^2; |
![`/`(`*`(`+`(y[`+`(m, 1)], `-`(`*`(2, `*`(y[m]))), y[`+`(m, `-`(1))])), `*`(`^`(h, 2)))](images/Example3.8 Rev 1_6.gif) |
(6) |
| > |
dydx:=(y[m+1]-y[m-1])/2/h; |
![`+`(`/`(`*`(`/`(1, 2), `*`(`+`(y[`+`(m, 1)], `-`(y[`+`(m, `-`(1))])))), `*`(h)))](images/Example3.8 Rev 1_7.gif) |
(7) |
The three point forward and backward difference expressions for the derivative are:
| > |
dydxf:=(-y[2]+4*y[1]-3*y[0])/(2*h); |
![`+`(`/`(`*`(`/`(1, 2), `*`(`+`(`-`(y[2]), `*`(4, `*`(y[1])), `-`(`*`(3, `*`(y[0])))))), `*`(h)))](images/Example3.8 Rev 1_8.gif) |
(8) |
| > |
dydxb:=(y[N-1]-4*y[N]+3*y[N+1])/(2*h); |
![`+`(`/`(`*`(`/`(1, 2), `*`(`+`(y[9], `-`(`*`(4, `*`(y[10]))), `*`(3, `*`(y[11]))))), `*`(h)))](images/Example3.8 Rev 1_9.gif) |
(9) |
The governing equation in finite difference form is:
| > |
Eq[m]:=subs(diff(y(x),x$2)=d2ydx2,diff(y(x),x)=dydx,y(x)=y[m],x=m*h,eq); |
![`+`(`/`(`*`(`+`(y[`+`(m, 1)], `-`(`*`(2, `*`(y[m]))), y[`+`(m, `-`(1))])), `*`(`^`(h, 2))), `/`(`*`(`/`(1, 2), `*`(`+`(y[`+`(m, 1)], `-`(y[`+`(m, `-`(1))])))), `*`(m, `*`(`^`(h, 2)))), `-`(`*`(`^`(phi...](images/Example3.8 Rev 1_10.gif) |
(10) |
The boundary conditions in finite difference form are:
| > |
Eq[0]:=subs(diff(y(x),x)=dydxf,y(x)=y[0],bc1); |
![`+`(`/`(`*`(`/`(1, 2), `*`(`+`(`-`(y[2]), `*`(4, `*`(y[1])), `-`(`*`(3, `*`(y[0])))))), `*`(h)))](images/Example3.8 Rev 1_11.gif) |
(11) |
| > |
Eq[N+1]:=subs(diff(y(x),x)=dydxb,y(x)=y[N+1],bc2); |
![`+`(`/`(`*`(`/`(1, 2), `*`(`+`(y[9], `-`(`*`(4, `*`(y[10]))), `*`(3, `*`(y[11]))))), `*`(h)), `-`(1), y[11])](images/Example3.8 Rev 1_12.gif) |
(12) |
A 'for loop' can be written for the interior node points as
| > |
for i to N do Eq[i]:=subs(m=i,Eq[m]);od; |
| > |
y[0]:=solve(Eq[0],y[0]); |
![`+`(`-`(`*`(`/`(1, 3), `*`(y[2]))), `*`(`/`(4, 3), `*`(y[1])))](images/Example3.8 Rev 1_23.gif) |
(14) |
| > |
y[N+1]:=solve(Eq[N+1],y[N+1]); |
![`/`(`*`(`+`(`-`(y[9]), `*`(4, `*`(y[10])), `*`(2, `*`(h)))), `*`(`+`(3, `*`(2, `*`(h)))))](images/Example3.8 Rev 1_24.gif) |
(15) |
 |
(16) |
| > |
for i to N do Eq[i]:=eval(Eq[i]);od; |
| > |
eqs:=[seq(Eq[i],i=1..N)]; |
| > |
vars:=[seq(y[i],i=1..N)]; |
![[y[1], y[2], y[3], y[4], y[5], y[6], y[7], y[8], y[9], y[10]]](images/Example3.8 Rev 1_40.gif) |
(19) |
| > |
A:=genmatrix(eqs,vars,'B1'); |
 |
(21) |
Maple generates a row vector, which can be converted to a column vector as:
| > |
B:=matrix(N,1):for i to N do B[i,1]:=B1[i]:od:evalm(B); |
 |
(22) |
The solution is obtained as
| > |
X:=evalm(inverse(A)&*B); |
| > |
for i to N do y[i]:=X[i,1];od; |
| > |
y[0]:=eval(y[0]);y[N+1]:=eval(y[N+1]); |
Now the result obtained is plotted for different values of Thiele modulus Φ:
| > |
display({seq(p[i],i=1..5)}); |
| Error, (in plots:-display) expecting plot structures but received: {p[2], p[4], p[5], p[3], p[1]} |
|
![[.1, .5, 1, 2, 5]](images/Example3.8 Rev 1_184.gif) |
(26) |
| > |
clr:=[black,red,green,gold,blue]; |
![[black, red, green, gold, blue]](images/Example3.8 Rev 1_185.gif) |
(27) |
| > |
for j from 1 to 5 do p[j]:=plot([seq([i*h,subs(phi=pars[j],y[i])],i=0..N+1)],thickness=4,title="Figure Exp 3.1.14.",axes=boxed,color=clr[j]):od:
|
| > |
display({seq(p[i],i=1..5)}); |