Example 5.6 Semianalytical Method for the Graetz Problem
Equation (5.1.30) is solved in Maple using the Maple program developed for example 5.2 by making very few changes:
| > | restart; |
| > | with(linalg):with(plots): |
| > | ge:=diff(u(x,t),t)=1/(1-x^2)*diff(u(x,t),x$2)+1/(1-x^2)/x*diff(u(x,t),x); |
![]() |
(1) |
| > | bc1:=diff(u(x,t),x); |
| (2) |
| > | bc2:=u(x,t)-1; |
| (3) |
| > | IC:=u(x,0)=0; |
| (4) |
| > | N:=10; |
| (5) |
| > | L:=1; |
| (6) |
| > | dydxf:=1/2*(-u[2](t)-3*u[0](t)+4*u[1](t))/h: |
| > | dydxb:=1/2*(u[N-1](t)+3*u[N+1](t)-4*u[N](t))/h: |
| > | dydx:=1/2/h*(u[m+1](t)-u[m-1](t)): |
| > | d2ydx2:=1/h^2*(u[m-1](t)-2*u[m](t)+u[m+1](t)): |
| > | bc1:=subs(diff(u(x,t),x)=dydxf,u(x,t)=u[0](t),x=0,bc1): |
| > | bc2:=subs(diff(u(x,t),x)=dydxb,u(x,t)=u[N+1](t),x=1,bc2): |
| > | eq[0]:=bc1; |
| (7) |
| > | eq[N+1]:=bc2; |
| (8) |
| > | for i from 1 to N do eq[i]:=diff(u[i](t),t)= subs(diff(u(x,t),x$2) = subs(m=i,d2ydx2),diff(u(x,t),x) = subs(m=i,dydx),u(x,t)=u[i](t),x=i*h,rhs(ge));od; |
| (9) |
| > | u[0](t):=(solve(eq[0],u[0](t))); |
| (10) |
| > | u[N+1](t):=solve(eq[N+1],u[N+1](t)); |
| (11) |
| > | for i from 1 to N do eq[i]:=eval(eq[i]);od; |
| (12) |
| > | eqs:=[seq(rhs(eq[j]),j=1..N)]: |
| > | Y:=[seq(u[i](t),i=1..N)]; |
| (13) |
| > | A:=genmatrix(eqs,Y,'b1'): |
| > | b:=matrix(N,1):for i to N do b[i,1]:=-eval(b1[i]);od:evalm(b); |
![]() |
(14) |
| > | h:=eval(L/(N+1)); |
| (15) |
| > | A:=map(eval,A): |
| > | if N > 4 then A:=map(evalf,A);end: |
| > | evalm(A); |
| (16) |
| > | mat:=exponential(A,t): |
| > | mat:=map(evalf,mat): |
| > | Y0:=matrix(N,1):for i from 1 to N do Y0[i,1]:=evalf(subs(x=i*h,rhs(IC)));od:evalm(Y0); |
| (17) |
| > | s1:=evalm(Y0+inverse(A)&*b): |
| > | Y:=evalm(mat&*s1-inverse(A)&*b): |
| > | Y:=map(simplify,Y): |
| > | Digits:=10; |
| (18) |
| > | for i from 1 to N do u[i](t):=evalf((Y[i,1]));od: |
| > | for i from 0 to N+1 do u[i](t):=eval(u[i](t));od; |
| (19) |
Set the colors for the curves:
| > | setcolors(["Red", "Blue", "LimeGreen", "Goldenrod", "maroon", "DarkTurquoise", "coral", "aquamarine", "magenta", "khaki", "sienna", "orange", "yellow", "gray"]); |
| (20) |
| > | pp:=plot([seq(u[i](t),i=0..N+1)],t=0..0.4,thickness=3); |
| (21) |
Plot the texts for the corresponding curves:
| > | arw:=arrow(<0.15,0.4>,<-0.05,0.63>,width=[1/700,relative=true],head_width=[1/200,relative=false],head_length=[1/30,relative=false]):
pt:=textplot([[0.25,0.35,typeset("Follow the arrow: ",u[0],"(t), ..., ",u[N+1],"(t).")]]): |
| > | display([pp,pt,arw],axes=boxed,title="Figure Exp. 5.19.",labels=[t,"u"]); |
![]() |
| > | tf:=0.2; |
| (22) |
| > | M:=30; |
| (23) |
| > | T1:=[seq(tf*i/M,i=0..M)]; |
| (24) |
| > | PP:=matrix(N+2,M+1); |
| (25) |
| > | for i from 1 to N+2 do PP[i,1]:=evalf(subs(x=(i-1)*h,rhs(IC)));od: |
| > | for i from 1 to N+2 do for j from 2 to M+1 do PP[i,j]:=evalf(subs(t=T1[j],u[i-1](t)));od;od: |
| > | plotdata := [seq([ seq([(i-1)*h,T1[j],PP[i,j]], i=1..N+2)], j=1..M+1)]: |
| > | surfdata(plotdata,axes=boxed,title="Figure Exp. 5.20.",labels=[x,t,u],orientation=[-135,45]); |
![]() |
| > | for i from 0 to N+1 do u[i](z):=subs(t=z/2/Pe,u[i](t));od: |
| > | pp:=plot([seq(subs(Pe=1,u[i](z)),i=0..N+1)],z=0..1,thickness=3); |
| (26) |
Plot the texts for the corresponding curves:
| > | arw:=arrow(<0.3,0.4>,<-0.15,0.63>,width=[1/700,relative=true],head_width=[1/150,relative=false],head_length=[1/30,relative=false]):
pt:=textplot([[0.55,0.35,typeset("Follow the arrow: ",u[0],"(z), ..., ",u[N+1],"(z).")]]): |
| > |
display([pp,pt,arw],axes=boxed,title="Figure Exp. 5.21.",labels=[z,"u"]); |
![]() |
| > | tf:=1.; |
| (27) |
| > | M:=30; |
| (28) |
| > | T1:=[seq(tf*i/M,i=0..M)]; |
| (29) |
| > | PP:=matrix(N+2,M+1); |
| (30) |
| > | for i from 1 to N+2 do PP[i,1]:=evalf(subs(x=(i-1)*h,rhs(IC)));od: |
| > | for i from 1 to N+2 do for j from 2 to M+1 do PP[i,j]:=evalf(subs(z=T1[j],Pe=1.,u[i-1](z)));od;od: |
| > | plotdata := [seq([ seq([(i-1)*h,T1[j],PP[i,j]], i=1..N+2)], j=1..M+1)]: |
| > | surfdata(plotdata,axes=boxed,title="Figure 5.22.",labels=[x,z,u],orientation=[-135,45]); |
![]() |
| > | pp:=plot([seq(subs(Pe=10,u[i](z)),i=0..N+1)],z=0..1,thickness=3); |
| (31) |
| > | display([pp],axes=boxed,title="Figure Exp. 5.23.",labels=[z,"u"],caption=typeset("From the bottom to the top of the figure: ",u[0],"(z), ..., ",u[N+1],"(z)")); |
![]() |
| > | tf:=1.; |
| (32) |
| > | M:=30; |
| (33) |
| > | T1:=[seq(tf*i/M,i=0..M)]; |
| (34) |
| > | PP:=matrix(N+2,M+1); |
| (35) |
| > | for i from 1 to N+2 do PP[i,1]:=evalf(subs(x=(i-1)*h,rhs(IC)));od: |
| > | for i from 1 to N+2 do for j from 2 to M+1 do PP[i,j]:=evalf(subs(z=T1[j],Pe=10.,u[i-1](z)));od;od: |
| > | plotdata:= [seq([ seq([(i-1)*h,T1[j],PP[i,j]], i=1..N+2)], j=1..M+1)]: |
| > | surfdata(plotdata,axes=boxed,title="Figure Exp. 5.24.",labels=[x,z,u],orientation=[-135,45]); |
![]() |
| > | ua0:=1-1.477*exp(-3.658*z/Pe)+0.81*exp(-22.178*z/Pe)-0.385*exp(-53.05*z/Pe); |
| (36) |
| > | u[0](z); |
| (37) |
| > | pars:=[0.1,0.2,0.25,0.5,1,2]; |
| (38) |
| > | M:=nops(pars); |
| (39) |
| > | seq(evalf(subs(z=Pe*pars[i],ua0)),i=1..M); |
| (40) |
| > | seq(evalf(subs(z=Pe*pars[i],z=10,u[0](z))),i=1..M); |
| (41) |
| > |