Example4.7rev 1.mw

Example 4.7  Unsteady State Diffusion with a First-Order Reacton 

Consider the transient diffusion problem.[6]  The governing equation is 

 

Typesetting:-mrow(Typesetting:-mo(=DTypesetting:-mrow(Typesetting:-mfrac(Typesetting:-mrow(Typesetting:-mo( 

 

                                                                            u(x,0) = 0                                                    (4.1.7) 

 

                                                                                                                                 

                                                                          Typesetting:-mrow(Typesetting:-mi( (0,t) = 1 and u(∞,t) is defined     

 

where D is the diffusivity (m2/s)  and k is the rate constant (s-1) .  Equation (4.1.7) is solved in Maple below using the Laplace transform technique: 

> restart:with(linalg):with(inttrans):with(plots):
 

> eq:=diff(u(x,t),t)=D*diff(u(x,t),x$2)-k*u(x,t);
 

diff(u(x, t), t) = `+`(`*`(D, `*`(diff(diff(u(x, t), x), x))), `-`(`*`(k, `*`(u(x, t))))) (1)
 

> u(x,0):=0;
 

0 (2)
 

> bc1:=u(0,t)=1;
 

u(0, t) = 1 (3)
 

> bc2:=u(infinity,t)=defined;
 

u(infinity, t) = defined (4)
 

> eqs:=laplace(eq,t,s);
 

`*`(s, `*`(laplace(u(x, t), t, s))) = `+`(`*`(D, `*`(diff(diff(laplace(u(x, t), t, s), x), x))), `-`(`*`(k, `*`(laplace(u(x, t), t, s))))) (5)
 

> eqs:=subs(laplace(u(x,t),t,s)=U(x),eqs);
 

`*`(s, `*`(U(x))) = `+`(`*`(D, `*`(diff(diff(U(x), x), x))), `-`(`*`(k, `*`(U(x))))) (6)
 

> bc1:=laplace(bc1,t,s);
 

laplace(u(0, t), t, s) = `/`(1, `*`(s)) (7)
 

> bc1:=subs(laplace(u(0,t),t,s)=U(0),bc1);
 

U(0) = `/`(1, `*`(s)) (8)
 

> U(x):=rhs(dsolve({eqs,bc1}));
 

`+`(`-`(`/`(`*`(`+`(`-`(1), `*`(_C2, `*`(s))), `*`(exp(`/`(`*`(`^`(`+`(s, k), `/`(1, 2)), `*`(x)), `*`(`^`(D, `/`(1, 2))))))), `*`(s))), `*`(_C2, `*`(exp(`+`(`-`(`/`(`*`(`^`(`+`(s, k), `/`(1, 2)), `*`... (9)
 

> eqc:=coeff(U(x),exp(1/D^(1/2)*(s+k)^(1/2)*x));
 

`+`(`-`(`/`(`*`(`+`(`-`(1), `*`(_C2, `*`(s)))), `*`(s)))) (10)
 

> _C2:=solve(eqc,_C2);
 

`/`(1, `*`(s)) (11)
 

> U(x):=eval(U(x));
 

`/`(`*`(exp(`+`(`-`(`/`(`*`(`^`(`+`(s, k), `/`(1, 2)), `*`(x)), `*`(`^`(D, `/`(1, 2)))))))), `*`(s)) (12)
 

Here again Maple cannot find the inverse Laplace transform: 

> invlaplace(U(x),s,t);
 

invlaplace(`/`(`*`(exp(`+`(`-`(`/`(`*`(`^`(`+`(s, k), `/`(1, 2)), `*`(x)), `*`(`^`(D, `/`(1, 2)))))))), `*`(s)), s, t) (13)
 

From the poperty of the laplace transform,[7] we n=know that 

 

 

 

 

 

 

> U1:=U(x)*s;
 

exp(`+`(`-`(`/`(`*`(`^`(`+`(s, k), `/`(1, 2)), `*`(x)), `*`(`^`(D, `/`(1, 2))))))) (14)
 

Again, Maple cannot invert U1 directly: 

> invlaplace(U1,s,t);
 

invlaplace(exp(`+`(`-`(`/`(`*`(`^`(`+`(s, k), `/`(1, 2)), `*`(x)), `*`(`^`(D, `/`(1, 2))))))), s, t) (15)
 

Another formula[7] is used: 

 

 

 

> U2:=subs(s=s-k,U1);
 

exp(`+`(`-`(`/`(`*`(`^`(s, `/`(1, 2)), `*`(x)), `*`(`^`(D, `/`(1, 2))))))) (16)
 

The inverse transform for U2 is: 

> U2:=subs({D=D1,x=x1},U2);
 

exp(`+`(`-`(`/`(`*`(`^`(s, `/`(1, 2)), `*`(x1)), `*`(`^`(D1, `/`(1, 2))))))) (17)
 

> assume(D1>0,x1>0);
 

> u2:=invlaplace(U2,s,t);
 

`+`(`/`(`*`(`/`(1, 2), `*`(x1, `*`(exp(`+`(`-`(`/`(`*`(`/`(1, 4), `*`(`^`(x1, 2))), `*`(D1, `*`(t))))))))), `*`(`^`(`*`(D1, `*`(Pi)), `/`(1, 2)), `*`(`^`(t, `/`(3, 2)))))) (18)
 

> u2:=subs({D1=D,x1=x},u2);
 

`+`(`/`(`*`(`/`(1, 2), `*`(x, `*`(exp(`+`(`-`(`/`(`*`(`/`(1, 4), `*`(`^`(x, 2))), `*`(D, `*`(t))))))))), `*`(`^`(`*`(D, `*`(Pi)), `/`(1, 2)), `*`(`^`(t, `/`(3, 2)))))) (19)
 

The inverse transform for U1 iS: 

> u1:=exp(-k*t)*u2;
 

`+`(`/`(`*`(`/`(1, 2), `*`(exp(`+`(`-`(`*`(k, `*`(t))))), `*`(x, `*`(exp(`+`(`-`(`/`(`*`(`/`(1, 4), `*`(`^`(x, 2))), `*`(D, `*`(t)))))))))), `*`(`^`(`*`(D, `*`(Pi)), `/`(1, 2)), `*`(`^`(t, `/`(3, 2)))... (20)
 

> I1:=int(u1,t);
 

int(`+`(`/`(`*`(`/`(1, 2), `*`(exp(`+`(`-`(`*`(k, `*`(t))))), `*`(x, `*`(exp(`+`(`-`(`/`(`*`(`/`(1, 4), `*`(`^`(x, 2))), `*`(D, `*`(t)))))))))), `*`(`^`(`*`(D, `*`(Pi)), `/`(1, 2)), `*`(`^`(t, `/`(3, ... (21)
 

> with(student):
 

> I1:=simplify(changevar(t=x^2/4/D/T^2,I1,T));
 

`+`(`-`(`/`(`*`(2, `*`(x, `*`(int(`/`(`*`(exp(`+`(`-`(`/`(`*`(`/`(1, 4), `*`(`+`(`*`(k, `*`(`^`(x, 2))), `*`(4, `*`(`^`(T, 4), `*`(D)))))), `*`(D, `*`(`^`(T, 2)))))))), `*`(T, `*`(`^`(`/`(`*`(`^`(x, 2... (22)
 

> I1:=subs(T=T1,x=x1,D=D1,I1);
 

`+`(`-`(`/`(`*`(2, `*`(x1, `*`(int(`/`(`*`(exp(`+`(`-`(`/`(`*`(`/`(1, 4), `*`(`+`(`*`(k, `*`(`^`(x1, 2))), `*`(4, `*`(`^`(T1, 4), `*`(D1)))))), `*`(D1, `*`(`^`(T1, 2)))))))), `*`(T1, `*`(`^`(`/`(`*`(`... (23)
 

> assume(T1>0);
 

> I1:=simplify(I1);
 

`+`(`-`(`*`(`/`(1, 2), `*`(exp(`/`(`*`(x1, `*`(`^`(k, `/`(1, 2)))), `*`(`^`(D1, `/`(1, 2))))), `*`(erf(`+`(`/`(`*`(`/`(1, 2), `*`(`+`(`*`(2, `*`(D1, `*`(`^`(T1, 2)))), `*`(x1, `*`(`^`(D1, `/`(1, 2)), ...
`+`(`-`(`*`(`/`(1, 2), `*`(exp(`/`(`*`(x1, `*`(`^`(k, `/`(1, 2)))), `*`(`^`(D1, `/`(1, 2))))), `*`(erf(`+`(`/`(`*`(`/`(1, 2), `*`(`+`(`*`(2, `*`(D1, `*`(`^`(T1, 2)))), `*`(x1, `*`(`^`(D1, `/`(1, 2)), ...
(24)
 

> I1:=subs({x1=x,T1=T,D1=D},I1);
 

`+`(`-`(`*`(`/`(1, 2), `*`(exp(`/`(`*`(x, `*`(`^`(k, `/`(1, 2)))), `*`(`^`(D, `/`(1, 2))))), `*`(erf(`+`(`/`(`*`(`/`(1, 2), `*`(`+`(`*`(2, `*`(D, `*`(`^`(T, 2)))), `*`(x, `*`(`^`(D, `/`(1, 2)), `*`(`^... (25)
 

> I1:=expand(I1);
 

`+`(`-`(`*`(`/`(1, 2), `*`(exp(`/`(`*`(x, `*`(`^`(k, `/`(1, 2)))), `*`(`^`(D, `/`(1, 2))))), `*`(erf(`+`(T, `/`(`*`(`/`(1, 2), `*`(x, `*`(`^`(k, `/`(1, 2))))), `*`(`^`(D, `/`(1, 2)), `*`(T))))))))), `... (26)
 

> I2:=eval(subs(T=infinity,I1));
 

`+`(`-`(`*`(`/`(1, 2), `*`(exp(`/`(`*`(x, `*`(`^`(k, `/`(1, 2)))), `*`(`^`(D, `/`(1, 2)))))))), `-`(`/`(`*`(`/`(1, 2)), `*`(exp(`/`(`*`(x, `*`(`^`(k, `/`(1, 2)))), `*`(`^`(D, `/`(1, 2))))))))) (27)
 

> u:=I1-I2;
 

`+`(`-`(`*`(`/`(1, 2), `*`(exp(`/`(`*`(x, `*`(`^`(k, `/`(1, 2)))), `*`(`^`(D, `/`(1, 2))))), `*`(erf(`+`(T, `/`(`*`(`/`(1, 2), `*`(x, `*`(`^`(k, `/`(1, 2))))), `*`(`^`(D, `/`(1, 2)), `*`(T))))))))), `... (28)
 

> u:=collect(u,exp(x/D^(1/2)*k^(1/2)));
 

`+`(`*`(`+`(`-`(`*`(`/`(1, 2), `*`(erf(`+`(T, `/`(`*`(`/`(1, 2), `*`(x, `*`(`^`(k, `/`(1, 2))))), `*`(`^`(D, `/`(1, 2)), `*`(T)))))))), `/`(1, 2)), `*`(exp(`/`(`*`(x, `*`(`^`(k, `/`(1, 2)))), `*`(`^`(... (29)
 

> u:=convert(u,erfc);
 

`+`(`*`(`/`(1, 2), `*`(erfc(`+`(T, `/`(`*`(`/`(1, 2), `*`(x, `*`(`^`(k, `/`(1, 2))))), `*`(`^`(D, `/`(1, 2)), `*`(T))))), `*`(exp(`/`(`*`(x, `*`(`^`(k, `/`(1, 2)))), `*`(`^`(D, `/`(1, 2)))))))), `/`(`... (30)
 

> u:=subs(T=x/2/(D*t)^(1/2),u);
 

`+`(`*`(`/`(1, 2), `*`(erfc(`+`(`/`(`*`(`/`(1, 2), `*`(x)), `*`(`^`(`*`(D, `*`(t)), `/`(1, 2)))), `/`(`*`(`^`(`*`(D, `*`(t)), `/`(1, 2)), `*`(`^`(k, `/`(1, 2)))), `*`(`^`(D, `/`(1, 2)))))), `*`(exp(`/... (31)
 

> convert(expand(simplify(eval(subs(k=0,u)))),erfc);
 

erfc(`+`(`/`(`*`(`/`(1, 2), `*`(x)), `*`(`^`(`*`(D, `*`(t)), `/`(1, 2)))))) (32)
 

> expand(D*(expand(-eval(subs(x=0,diff(u,x))))));
 

`+`(`/`(`*`(D), `*`(`^`(Pi, `/`(1, 2)), `*`(exp(`*`(k, `*`(t))), `*`(`^`(`*`(D, `*`(t)), `/`(1, 2)))))), `*`(`^`(D, `/`(1, 2)), `*`(`^`(k, `/`(1, 2)), `*`(erf(`/`(`*`(`^`(`*`(D, `*`(t)), `/`(1, 2)), `... (33)
 

> pars:={D=1e-6,k=0.1};
 

{D = 0.1e-5, k = .1} (34)
 

> plot3d(subs(pars,u),x=1e-3..0,t=10..0,axes=boxed,labels=[x,t,"u"],orientation=[-60,60]);
 

Plot
 

> plot([subs(pars,t=0.01,u),subs(pars,t=0.1,u),subs(pars,t=1,u),subs(pars,t=2,u)],x=0..1e-3,axes=boxed,thickness=5,labels=[x,"u"]);
 

Plot_2d
 

>