Example 3.3 

Consider diffusion with a first order reaction in a semi-infinite plane: 

 

Typesetting:-mrow(Typesetting:-mo( 

 

CTypesetting:-mrow(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mn( 

 

where C is the dimensionless concentration, D1 is the diffusion and k is the rate constant.  This equation is solved below using the procedure described above. 

> restart:
 

> with(linalg):with(plots):
 

> N:=2;
 

2 (1)
 

> eq:=diff(C(x),x$2)-k/D1*C(x);
 

`+`(diff(diff(C(x), x), x), `-`(`/`(`*`(k, `*`(C(x))), `*`(D1)))) (2)
 

> A:=matrix(N,N,[0,1,k/D1,0]);
 

`:=`(A, Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mtable(Typesetting:-mtr(Typesetting:-mtd(Typesetting:-mn( (3)
 

> mat:=exponential(A,x);
 

`:=`(mat, Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mtable(Typesetting:-mtr(Typesetting:-mtd(Typesetting:-mrow(Typesetting:-mverbatim( (4)
 

> Y0:=matrix(N,1,[1,c[1]]);
 

`:=`(Y0, Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mtable(Typesetting:-mtr(Typesetting:-mtd(Typesetting:-mn( (5)
 

> sol:=evalm(mat&*Y0);
 

`:=`(sol, Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mtable(Typesetting:-mtr(Typesetting:-mtd(Typesetting:-mrow(Typesetting:-mverbatim( (6)
 

> C:=sol[1,1];
 

`+`(`*`(`/`(1, 2), `*`(exp(`/`(`*`(`^`(`*`(D1, `*`(k)), `/`(1, 2)), `*`(x)), `*`(D1))))), `*`(`/`(1, 2), `*`(exp(`+`(`-`(`/`(`*`(`^`(`*`(D1, `*`(k)), `/`(1, 2)), `*`(x)), `*`(D1))))))), `/`(`*`(`/`(1,... (7)
 

This can be rewritten as 

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

`+`(`*`(`+`(`/`(1, 2), `/`(`*`(`/`(1, 2), `*`(D1, `*`(c[1]))), `*`(`^`(`*`(D1, `*`(k)), `/`(1, 2))))), `*`(exp(`/`(`*`(`^`(`*`(D1, `*`(k)), `/`(1, 2)), `*`(x)), `*`(D1))))), `*`(`/`(1, 2), `*`(exp(`+`... (8)
 

> C:=collect(C,exp(-1/D1*(D1*k)^(1/2)*x));
 

`+`(`*`(`+`(`/`(1, 2), `-`(`/`(`*`(`/`(1, 2), `*`(D1, `*`(c[1]))), `*`(`^`(`*`(D1, `*`(k)), `/`(1, 2)))))), `*`(exp(`+`(`-`(`/`(`*`(`^`(`*`(D1, `*`(k)), `/`(1, 2)), `*`(x)), `*`(D1))))))), `*`(`+`(`/`... (9)
 

Since C is finite as x tends to infinity, the second parenthesis must go to zero because exp(x) goes to infinity as x goes to infinity.  Consequently, the equation for c1 can be found by setting the coefficient of the second term equal to zero: 

> eqbc:=coeff(C,exp(1/D1*(D1*k)^(1/2)*x));
 

`+`(`/`(1, 2), `/`(`*`(`/`(1, 2), `*`(D1, `*`(c[1]))), `*`(`^`(`*`(D1, `*`(k)), `/`(1, 2))))) (10)
 

> c[1]:=solve(eqbc,c[1]);
 

`+`(`-`(`/`(`*`(`^`(`*`(D1, `*`(k)), `/`(1, 2))), `*`(D1)))) (11)
 

Thus, the desired solution for C is simply: 

> C:=eval(C);
 

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

Plots can be made by substituting values for the parameters D1 and k: 

> pars:={D1=1e-5,k=1};
 

{k = 1, D1 = 0.1e-4} (13)
 

> plot(subs(pars,C),x=0..1e-2,labels=[x,"C"],thickness=4,axes=boxed,title="Figure Exp. 3.1.6.");
 

Plot_2d
 

New plots can be made by substituting different values for the paramters. 

> pars:={D1=1e-7,k=1};
 

{k = 1, D1 = 0.1e-6} (14)
 

> plot(subs(pars,C),x=0..1e-2,labels=[x,"C"],thickness=4,axes=boxed,color=black,title="Figure Exp. 3.1.7.");
 

Plot_2d
 

We observe that as the diffusion coefficient decreases mass transfer limitations increase the length of the diffusion layer (distance required for C to drop to approximately 0) which decreases as expected. 

>