Example 8.12.mw

Example 8.12 Distribution of Overpotential in a Porous Electrode

Equation (8.1.28) is solved in Maple and the results obtained are given below:

> |

> | eq:=diff(u(x,t),t)=diff(u(x,t),x$2)-nu^2*u(x,t);

| (1)

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

| (2)

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

| (3)

> | bc2:=diff(u(x,t),x)=delta*beta;

| (4)

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

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

| (5)

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

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

| (6)

> | bc2:=laplace(bc2,t,s):

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

| (7)

> | dsolve(eqs,U(x));

| (8)

> | U(x):=c[1]*cosh((s+nu^2)^(1/2)*x)+c[2]*sinh((s+nu^2)^(1/2)*x);

| (9)

> | eq0:=eval(subs(x=0,bc1)):

> | eq1:=eval(subs(x=1,bc2)):

> | con:=solve({eq0,eq1},{c[1],c[2]}):

> | U(x):=subs(con,U(x));

| (10)

> | U(x):=factor(combine(simplify(U(x))));

| (11)

> | U1(x):=subs(s=s-nu^2,U(x));

| (12)

> | P(s):=numer(U1(x));

| (13)

> | Q(s):=denom(U1(x));

| (14)

> | solve(Q(s),s);

| (15)

> | _EnvAllSolutions := true;

| (16)

> | solve(Q(s),s);

| (17)

The roots are:

> | 0,0,nu^2,-n^2*Pi^2;

| (18)

> | mu0:=0;

| (19)

> | b[2]:=(s-mu0)^2*P(s)/Q(s);

| (20)

> | B[2]:=limit(b[2],s=0);

| (21)

> | b[1]:=diff(b[2],s):

> | B[1]:=limit(b[1],s=0);

| (22)

> | A(s):=P(s)/diff(Q(s),s):

> | A[n]:=simplify(subs(s=mu,A(s)));

| (23)

> | A[0]:=subs(mu^(1/2)=nu,mu^(3/2)=nu^3,mu=nu^2,A[n]):

> | A[0]:=simplify(A[0]);

| (24)

> | A[n]:=simplify(subs(mu^(1/2)=I*n*Pi,mu^(3/2)=-I*n^3*Pi^3,mu=-n^2*Pi^2,A[n])):

> | vars:={cos(n*Pi)=(-1)^n,sin(n*Pi)=0};

| (25)

> | A[n]:=simplify(subs(vars,A[n])):

> | A[n]:=simplify(subs(vars,expand(A[n])));

| (26)

> | b1s:=B[1]*subs(mu0=0,1/(s-mu0));

| (27)

> | b1t:=invlaplace(b1s,s,t);

| (28)

> | b2s:=B[2]*subs(mu0=0,1/(s-mu0)^2);

| (29)

> | b2t:=invlaplace(b2s,s,t);

| (30)

> | u0s:=subs(mu=nu^2,A[0]/(s-mu));

| (31)

> | u0t:=invlaplace(u0s,s,t);

| (32)

> | uns:=A[n]/(s-mu);

| (33)

> | unt:=invlaplace(uns,s,t);

| (34)

> | unt:=subs(mu=-n^2*Pi^2,unt);

| (35)

> | U:=b1t*exp(-nu^2*t)+b2t*exp(-nu^2*t)+simplify(u0t*exp(-nu^2*t))+exp(-nu^2*t)*Sum(unt,n=1..infinity);

| (36)

> | u:=piecewise(t=0,0,t>0,subs(infinity=20,U)):

> | pars:={nu=1,delta=1,beta=0.1};

| (37)

> | plot3d(subs(pars,u),x=0..1,t=0..0.5,axes=boxed,title="Figure Exp. 8.21.",labels=[x,t,"u"],orientation=[-60,60]);

> | plot([subs(t=0,pars,u),subs(t=0.05,pars,u),subs(t=0.1,pars,u),subs(t=0.2,pars,u)],x=0..1,axes=boxed,title="Figure Exp. 8.22.",thickness=5,labels=[x,"u"]);

In all the examples discussed in this chapter until now, the roots of q(s) were obtained analytically. This is not always possible. Often the roots should be obtained numerically as in section 7.1.4. This is illustrated in the next example.

> |