Example 5.1b rev 1.mw

Example 5.1 Heat Conduction in a Rectangular Slab 

 

> restart;
 

> with(linalg):with(plots):
 

Enter the governing equation here: 

> ge:=diff(u(x,t),t)=diff(u(x,t),x$2);
 

diff(u(x, t), t) = diff(diff(u(x, t), x), x) (1)
 

Enter the boundary condition at x = 0: 

> bc1:=u(x,t);
 

u(x, t) (2)
 

Enter the boundary condition at x = L: 

> bc2:=u(x,t);
 

u(x, t) (3)
 

Enter the initial condition: 

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

u(x, 0) = 1 (4)
 

Enter the number of interior node points: 

> N:=10;
 

10 (5)
 

Enter the length of the domain: 

> L:=1;
 

1 (6)
 

Enter the three point backward difference expression (accurate to the order h2) for the first derivative at x = L: 

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

`+`(`/`(`*`(`/`(1, 2), `*`(`+`(`-`(u[2](t)), `-`(`*`(3, `*`(u[0](t)))), `*`(4, `*`(u[1](t)))))), `*`(h))) (7)
 

Enter the three point central difference expression (accurate to the order h2) for the second derivative at x = L: 

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

`+`(`/`(`*`(`/`(1, 2), `*`(`+`(u[9](t), `*`(3, `*`(u[11](t))), `-`(`*`(4, `*`(u[10](t))))))), `*`(h))) (8)
 

Convert the boundary conditions to the finite difference form: 

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

`+`(`/`(`*`(`/`(1, 2), `*`(`+`(u[`+`(m, 1)](t), `-`(u[`+`(m, `-`(1))](t))))), `*`(h))) (9)
 

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

`/`(`*`(`+`(u[`+`(m, `-`(1))](t), `-`(`*`(2, `*`(u[m](t)))), u[`+`(m, 1)](t))), `*`(`^`(h, 2))) (10)
 

The boundary conditions are stored in eq[0] and eq[N+1]. 

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

u[0](t) (11)
 

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

u[11](t) (12)
 

> eq[0]:=bc1;
 

u[0](t) (13)
 

> eq[N+1]:=bc2;
 

u[11](t) (14)
 

The governing equations are converted to the finite difference form: 

> 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;
 

 

 

 

 

 

 

 

 

 

diff(u[1](t), t) = `/`(`*`(`+`(u[0](t), `-`(`*`(2, `*`(u[1](t)))), u[2](t))), `*`(`^`(h, 2)))
diff(u[2](t), t) = `/`(`*`(`+`(u[1](t), `-`(`*`(2, `*`(u[2](t)))), u[3](t))), `*`(`^`(h, 2)))
diff(u[3](t), t) = `/`(`*`(`+`(u[2](t), `-`(`*`(2, `*`(u[3](t)))), u[4](t))), `*`(`^`(h, 2)))
diff(u[4](t), t) = `/`(`*`(`+`(u[3](t), `-`(`*`(2, `*`(u[4](t)))), u[5](t))), `*`(`^`(h, 2)))
diff(u[5](t), t) = `/`(`*`(`+`(u[4](t), `-`(`*`(2, `*`(u[5](t)))), u[6](t))), `*`(`^`(h, 2)))
diff(u[6](t), t) = `/`(`*`(`+`(u[5](t), `-`(`*`(2, `*`(u[6](t)))), u[7](t))), `*`(`^`(h, 2)))
diff(u[7](t), t) = `/`(`*`(`+`(u[6](t), `-`(`*`(2, `*`(u[7](t)))), u[8](t))), `*`(`^`(h, 2)))
diff(u[8](t), t) = `/`(`*`(`+`(u[7](t), `-`(`*`(2, `*`(u[8](t)))), u[9](t))), `*`(`^`(h, 2)))
diff(u[9](t), t) = `/`(`*`(`+`(u[8](t), `-`(`*`(2, `*`(u[9](t)))), u[10](t))), `*`(`^`(h, 2)))
diff(u[10](t), t) = `/`(`*`(`+`(u[9](t), `-`(`*`(2, `*`(u[10](t)))), u[11](t))), `*`(`^`(h, 2))) (15)
 

The boundary values u[0](t) and u[N+1](t) are eliminated: 

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

0 (16)
 

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

0 (17)
 

The governing equations are simplified as: 

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

 

 

 

 

 

 

 

 

 

diff(u[1](t), t) = `/`(`*`(`+`(`-`(`*`(2, `*`(u[1](t)))), u[2](t))), `*`(`^`(h, 2)))
diff(u[2](t), t) = `/`(`*`(`+`(u[1](t), `-`(`*`(2, `*`(u[2](t)))), u[3](t))), `*`(`^`(h, 2)))
diff(u[3](t), t) = `/`(`*`(`+`(u[2](t), `-`(`*`(2, `*`(u[3](t)))), u[4](t))), `*`(`^`(h, 2)))
diff(u[4](t), t) = `/`(`*`(`+`(u[3](t), `-`(`*`(2, `*`(u[4](t)))), u[5](t))), `*`(`^`(h, 2)))
diff(u[5](t), t) = `/`(`*`(`+`(u[4](t), `-`(`*`(2, `*`(u[5](t)))), u[6](t))), `*`(`^`(h, 2)))
diff(u[6](t), t) = `/`(`*`(`+`(u[5](t), `-`(`*`(2, `*`(u[6](t)))), u[7](t))), `*`(`^`(h, 2)))
diff(u[7](t), t) = `/`(`*`(`+`(u[6](t), `-`(`*`(2, `*`(u[7](t)))), u[8](t))), `*`(`^`(h, 2)))
diff(u[8](t), t) = `/`(`*`(`+`(u[7](t), `-`(`*`(2, `*`(u[8](t)))), u[9](t))), `*`(`^`(h, 2)))
diff(u[9](t), t) = `/`(`*`(`+`(u[8](t), `-`(`*`(2, `*`(u[9](t)))), u[10](t))), `*`(`^`(h, 2)))
diff(u[10](t), t) = `/`(`*`(`+`(u[9](t), `-`(`*`(2, `*`(u[10](t)))))), `*`(`^`(h, 2))) (18)
 

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

[`/`(`*`(`+`(`-`(`*`(2, `*`(u[1](t)))), u[2](t))), `*`(`^`(h, 2))), `/`(`*`(`+`(u[1](t), `-`(`*`(2, `*`(u[2](t)))), u[3](t))), `*`(`^`(h, 2))), `/`(`*`(`+`(u[2](t), `-`(`*`(2, `*`(u[3](t)))), u[4](t))...
[`/`(`*`(`+`(`-`(`*`(2, `*`(u[1](t)))), u[2](t))), `*`(`^`(h, 2))), `/`(`*`(`+`(u[1](t), `-`(`*`(2, `*`(u[2](t)))), u[3](t))), `*`(`^`(h, 2))), `/`(`*`(`+`(u[2](t), `-`(`*`(2, `*`(u[3](t)))), u[4](t))...
[`/`(`*`(`+`(`-`(`*`(2, `*`(u[1](t)))), u[2](t))), `*`(`^`(h, 2))), `/`(`*`(`+`(u[1](t), `-`(`*`(2, `*`(u[2](t)))), u[3](t))), `*`(`^`(h, 2))), `/`(`*`(`+`(u[2](t), `-`(`*`(2, `*`(u[3](t)))), u[4](t))...
(19)
 

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

[u[1](t), u[2](t), u[3](t), u[4](t), u[5](t), u[6](t), u[7](t), u[8](t), u[9](t), u[10](t)] (20)
 

> A:=genmatrix(eqs,Y);
 

Typesetting:-mrow(Typesetting:-mverbatim( (21)
 

The node spacing, h, is evaluated here: 

> h:=eval(1/(N+1));
 

`/`(1, 11) (22)
 

The A matrix is simplified as: 

> A:=map(eval,A);
 

Typesetting:-mrow(Typesetting:-mverbatim( (23)
 

When more than four node points are used, the entries of the A matrix should be decimals.  This problem can be handled using the 'map(A,evalf)' as given below. 

> if N > 4 then A:=map(evalf,A);end:
 

> evalm(A);
 

Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mtable(Typesetting:-mtr(Typesetting:-mtd(Typesetting:-mn( (24)
 

The solution is obtained by finding the exponential matrix: 

> mat:=exponential(A,t):
 

> mat:=map(evalf,mat):
 

The initial condition is stored in the Y0 vector. 

> Y0:=matrix(N,1):for i from 1 to N do Y0[i,1]:=evalf(subs(x=i*h,rhs(IC)));od:evalm(Y0);
 

Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mtable(Typesetting:-mtr(Typesetting:-mtd(Typesetting:-mn( (25)
 

> Y:=evalm(mat&*Y0):
 

> Y:=map(simplify,Y);
 

Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
Typesetting:-mrow(Typesetting:-mverbatim(
(26)
 

Next the dependent variables can be stored in ui(t),i = 0..N+1. 

> 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;
 

 

 

 

 

 

 

 

 

 

 

 

0
`+`(`*`(0.4591e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.2886311186e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.2219e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))),...
`+`(`*`(0.4591e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.2886311186e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.2219e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))),...
`+`(`*`(0.4591e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.2886311186e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.2219e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))),...
`+`(`*`(0.4591e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.2886311186e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.2219e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))),...
`+`(`*`(0.7112e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `-`(`*`(0.485619465e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t)))))))), `-`(`*`(0.4402e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))...
`+`(`*`(0.7112e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `-`(`*`(0.485619465e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t)))))))), `-`(`*`(0.4402e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))...
`+`(`*`(0.7112e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `-`(`*`(0.485619465e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t)))))))), `-`(`*`(0.4402e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))...
`+`(`*`(0.7112e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `-`(`*`(0.485619465e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t)))))))), `-`(`*`(0.4402e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))...
`+`(`*`(0.661e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.528436521e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.6502e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), `...
`+`(`*`(0.661e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.528436521e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.6502e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), `...
`+`(`*`(0.661e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.528436521e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.6502e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), `...
`+`(`*`(0.661e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.528436521e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.6502e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), `...
`+`(`*`(0.411e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `-`(`*`(0.403462867e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t)))))))), `-`(`*`(0.8130e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t))))))...
`+`(`*`(0.411e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `-`(`*`(0.403462867e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t)))))))), `-`(`*`(0.8130e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t))))))...
`+`(`*`(0.411e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `-`(`*`(0.403462867e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t)))))))), `-`(`*`(0.8130e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t))))))...
`+`(`*`(0.411e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `-`(`*`(0.403462867e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t)))))))), `-`(`*`(0.8130e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t))))))...
`+`(`*`(0.181e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.150415791e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.8933e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), `...
`+`(`*`(0.181e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.150415791e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.8933e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), `...
`+`(`*`(0.181e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.150415791e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.8933e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), `...
`+`(`*`(0.181e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.150415791e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.8933e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), `...
`+`(`*`(0.220e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.150416304e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.9345e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), `...
`+`(`*`(0.220e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.150416304e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.9345e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), `...
`+`(`*`(0.220e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.150416304e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.9345e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), `...
`+`(`*`(0.220e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.150416304e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.9345e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), `...
`+`(`*`(0.395e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `-`(`*`(0.403461452e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t)))))))), `-`(`*`(0.9624e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t))))))...
`+`(`*`(0.395e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `-`(`*`(0.403461452e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t)))))))), `-`(`*`(0.9624e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t))))))...
`+`(`*`(0.395e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `-`(`*`(0.403461452e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t)))))))), `-`(`*`(0.9624e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t))))))...
`+`(`*`(0.395e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `-`(`*`(0.403461452e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t)))))))), `-`(`*`(0.9624e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t))))))...
`+`(`*`(0.4364e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.528438441e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.8839e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), ...
`+`(`*`(0.4364e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.528438441e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.8839e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), ...
`+`(`*`(0.4364e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.528438441e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.8839e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), ...
`+`(`*`(0.4364e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.528438441e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.8839e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), ...
`+`(`*`(0.2904e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `-`(`*`(0.485617674e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t)))))))), `-`(`*`(0.6611e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))...
`+`(`*`(0.2904e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `-`(`*`(0.485617674e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t)))))))), `-`(`*`(0.6611e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))...
`+`(`*`(0.2904e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `-`(`*`(0.485617674e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t)))))))), `-`(`*`(0.6611e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))...
`+`(`*`(0.2904e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `-`(`*`(0.485617674e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t)))))))), `-`(`*`(0.6611e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))...
`+`(`*`(0.1142e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.288632189e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.3389e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), ...
`+`(`*`(0.1142e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.288632189e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.3389e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), ...
`+`(`*`(0.1142e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.288632189e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.3389e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), ...
`+`(`*`(0.1142e-7, `*`(exp(`+`(`-`(`*`(474.1972996, `*`(t))))))), `*`(0.288632189e-1, `*`(exp(`+`(`-`(`*`(445.5833549, `*`(t))))))), `-`(`*`(0.3389e-6, `*`(exp(`+`(`-`(`*`(400.4762976, `*`(t)))))))), ...
0 (27)
 

Hence, an analytical solution in time is obtained for the dependent variables at all of the node points.  One can plot the concentration profiles by: 

> pp:=plot([seq(u[i](t),i=0..N+1)],t=0..0.4,thickness=3);
 

PLOT(CURVES([[0., 0.], [0.871886166666666594e-2, 0.], [0.163050965833333346e-1, 0.], [0.248366111666666682e-1, 0.], [0.334246781666666660e-1, 0.], [0.419719275833333322e-1, 0.], [0.498963219166666666e... (28)
 

> arw:=arrow(<0.10,0.8>,<-0.09,-0.6>,width=[1/500,relative],head_length=[1/20,relative]):
pt:=textplot([[0.2,0.9,"Follow the arrow:"],seq([0.18,0.9-i*0.06,typeset(u[5-i+1],"(t), ",u[6+i-1],"(t)")],i=1..6)]):
 

> display({pp,arw,pt},axes=boxed,title="Figure Exp. 5.3",labels=[t,"u"]);
 

Plot_2d
 

A  three dimensional plot can be made by storing the solution in a matrix (PP).  Enter the time up to which you want to plot your profiles (this time has to be changed depending on the problem): 

> tf:=0.1;
 

.1 (29)
 

Enter the number of time steps (excluding 0): 

> M:=30;
 

30 (30)
 

The time intervals are stored in T1: 

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

[0., 0.3333333333e-2, 0.6666666667e-2, 0.1000000000e-1, 0.1333333333e-1, 0.1666666667e-1, 0.2000000000e-1, 0.2333333333e-1, 0.2666666667e-1, 0.3000000000e-1, 0.3333333333e-1, 0.3666666667e-1, 0.400000...
[0., 0.3333333333e-2, 0.6666666667e-2, 0.1000000000e-1, 0.1333333333e-1, 0.1666666667e-1, 0.2000000000e-1, 0.2333333333e-1, 0.2666666667e-1, 0.3000000000e-1, 0.3333333333e-1, 0.3666666667e-1, 0.400000...
[0., 0.3333333333e-2, 0.6666666667e-2, 0.1000000000e-1, 0.1333333333e-1, 0.1666666667e-1, 0.2000000000e-1, 0.2333333333e-1, 0.2666666667e-1, 0.3000000000e-1, 0.3333333333e-1, 0.3666666667e-1, 0.400000...
[0., 0.3333333333e-2, 0.6666666667e-2, 0.1000000000e-1, 0.1333333333e-1, 0.1666666667e-1, 0.2000000000e-1, 0.2333333333e-1, 0.2666666667e-1, 0.3000000000e-1, 0.3333333333e-1, 0.3666666667e-1, 0.400000...
[0., 0.3333333333e-2, 0.6666666667e-2, 0.1000000000e-1, 0.1333333333e-1, 0.1666666667e-1, 0.2000000000e-1, 0.2333333333e-1, 0.2666666667e-1, 0.3000000000e-1, 0.3333333333e-1, 0.3666666667e-1, 0.400000...
(31)
 

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

array( 1 .. 12, 1 .. 31, [ ] ) (32)
 

The first column of PP is filled in by using the initial condition: 

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

The remaining columns are filled in using the solution obtained: 

> 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:
 

Next, data points are stored in plotdata for obtaining a 3D plot using Maple's 'surfdata' command. 

> 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.4",labels=[x,t,u],orientation=[45,60]);
 

Plot
 

>
 

We observe that the process slowly approaches the steady state.  We note that the profiles are symmetrical about x = 0.5, and, hence, we obtain u[0]=u[n+1],u[1]=u[N}, etc.