Example5.2.6 Rev 1.mw

Example 5.2.6 The Shrinking Core Model for Catalyst Regeneration

> | restart;

> | with(linalg):with(plots):

> | ge:=diff(u(x,t),t)=diff(u(x,t),x$2)+2/x*diff(u(x,t),x);

| (1)

> | bc1:=u(x,t)-0;

| (2)

> | bc2:=u(x,t)-1;

| (3)

> | IC:=u(x,0)=0;

| (4)

> | ge2:=diff(xc[1](t),t)=-k*diff(u(x,t),x);

| (5)

> | k:=0.1;

| (6)

> | N:=10;

| (7)

> | L:=1;

| (8)

> | dydxf:=1/2*(-u[2](t)-3*u[0](t)+4*u[1](t))/h;

| (9)

> | dydxb:=1/2*(u[N-1](t)+3*u[N+1](t)-4*u[N](t))/h;

| (10)

> | dydx:=1/2/h*(u[m+1](t)-u[m-1](t));

| (11)

> | d2ydx2:=1/h^2*(u[m-1](t)-2*u[m](t)+u[m+1](t));

| (12)

> | bc1:=subs(diff(u(x,t),x)=dydxf,u(x,t)=u[0](t),bc1);

| (13)

> | bc2:=subs(diff(u(x,t),x)=dydxb,u(x,t)=u[N+1](t),bc2);

| (14)

> | eqX:=subs(diff(u(x,t),x)=dydxf,u(x,t)=u[0](t),ge2);

| (15)

> | eq[0]:=bc1;

| (16)

> | eq[N+1]:=bc2;

| (17)

> | 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=xc[1](t)+i*h,rhs(ge));od;

| (18)

> | u[0](t):=(solve(eq[0],u[0](t)));

| (19)

> | u[N+1](t):=solve(eq[N+1],u[N+1](t));

| (20)

> | h:=(1-xc[1](t))/(N+1);

| (21)

> | for i from 1 to N do eq[i]:=eval(eq[i]);od;

| (22)

> | eqX:=eval(eqX);

| (23)

> | eqs:=seq((eq[j]),j=1..N),eqX;

| (24)

> | Y:=seq(u[i](t),i=1..N),xc[1](t);

| (25)

> | ICs:=seq(u[i](0)=rhs(IC),i=1..N),xc[1](0)=0.999999;

| (26)

> | sol:=dsolve({eqs,ICs},{Y},type=numeric,stiff=true,abserr=1e-20,stop_cond=[u[2](t)-1,xc[1](t)],output=listprocedure);

| (27)

> | for i to N do U[i]:=subs(sol,u[i](t));od:

> | U[0]:=subs(u[1](t)=U[1],u[2](t)=U[2],u[0](t));

| (28)

> | U[N+1]:=subs(u[N](t)=U[N],u[N-1](t)=U[N-1],u[N+1](t));

| (29)

> | Xc:=subs(sol,xc[1](t));

| (30)

> | sol(2.);

Warning, cannot evaluate the solution further right of 1.8213372, stop condition #2 violated

Warning, cannot evaluate the solution further right of 1.8213372, stop condition #2 violated

Warning, cannot evaluate the solution further right of 1.8213372, stop condition #2 violated

Warning, cannot evaluate the solution further right of 1.8213372, stop condition #2 violated

Warning, cannot evaluate the solution further right of 1.8213372, stop condition #2 violated

Warning, cannot evaluate the solution further right of 1.8213372, stop condition #2 violated

Warning, cannot evaluate the solution further right of 1.8213372, stop condition #2 violated

Warning, cannot evaluate the solution further right of 1.8213372, stop condition #2 violated

Warning, cannot evaluate the solution further right of 1.8213372, stop condition #2 violated

Warning, cannot evaluate the solution further right of 1.8213372, stop condition #2 violated

Warning, cannot evaluate the solution further right of 1.8213372, stop condition #2 violated

Warning, cannot evaluate the solution further right of 1.8213372, stop condition #2 violated

| (31)

> | tf:=1.8213373*0.99;

| (32)

> | plot(Xc(t),t=0..tf,axes=boxed,title="Figure Exp. 5.1.15.",thickness=3,labels=[t,"xc"]);

> | pp:=plot([seq(U[i](t),i=0..N+1)],t=0..tf);

| (33)

> | display(pp,axes=boxed,title="Figure Exp. 5.2.16.",thickness=3,labels=[t,"u"]);

> | h:=subs(xc[1]=Xc,h);

| (34)

> | for j from 0 to 20 do p[j]:=plot([seq([evalf(subs(t=tf*j/20,Xc(t)+i*h)),evalf(subs(t=tf*j/20,U[i](t)))],i=0..N+1)]):od:

> | display({seq(p[j],j=0..20)},thickness=4,axes=boxed,title="Figure Exp. 5.2.17.",labels=[x,"u"]);

> | M:=30;

| (35)

> | T1:=[seq(tf*i/M,i=0..M)];

| (36)

> | PP:=matrix(N+2,M+1);

| (37)

> | for i from 1 to N+2 do PP[i,1]:=evalf(subs(x=(i-1)*L/(N+1),rhs(IC)));od:

> | for i from 1 to N+2 do for j from 1 to M+1 do PP[i,j]:=evalf(subs(t=T1[j],U[i-1](t)));od;od:

> | plotdata := [seq([ seq([eval(subs(t=T1[j],Xc(t)+(i-1)*h)),T1[j],PP[i,j]], i=1..N+2)], j=1..M+1)]:

> | surfdata(plotdata,axes=boxed,title="Figure Exp. 5.2.18.", labels=[x,t,u],orientation=[-90,0]);

> |