Example 7.6.mw

Example 7.6 Heat Conduction in a Slab with Radiation Boundary Conditions

> |

> | with(plots):

The governing equation, initial and boundary conditions are entered here:

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

| (1)

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

| (2)

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

| (3)

> | bc2:=diff(u(x,t),x)+u(x,t)=0;

| (4)

> | Eq:=subs(u(x,t)=X(x)*T(t),eq):

> | Eq:=expand(Eq/X(x)/T(t)):

> | Eq_T:=lhs(Eq)=-lambda^2:

> | T(t):=rhs(dsolve({Eq_T,T(0)=T0},T(t))):

> | Eq_X:=rhs(Eq)=-lambda^2:

> | Eq_X:=expand(Eq_X*X(x)):

> | dsolve({Eq_X},X(x)):

> | X(x):=c[1]*sin(lambda*x)+c[2]*cos(lambda*x):

> | Bc1:=diff(X(x),x)=0:

> | Bc2:=diff(X(x),x)+X(x)=0:

> | Eq_Bc1:=eval(subs(x=0,Bc1)):

> | c[1]:=solve(Eq_Bc1,c[1]):

> | Eq_Bc2:=eval(subs(x=1,Bc2)):

The eigenvalue equation is:

> | Eq_Eig:=cos(lambda)-lambda*sin(lambda);

| (5)

> | solve(Eq_Eig,lambda);

| (6)

Maple predicts negative eigenvalues:

> | fsolve(Eq_Eig,lambda);

| (7)

Positive eigenvalues can be obtained by specifying a positive range in the 'fsolve' command.

> | fsolve(Eq_Eig,lambda=0..3);

| (8)

The eigenvalue equation can be plotted as a function of the eigenvalue as:

> | plot(Eq_Eig,lambda=0..20,thickness=3,title="Figure Exp. 7.14.");

The first 20 eigenvalues are obtained as:

> | N:=20;

| (9)

> | l[1]:=fsolve(Eq_Eig,lambda=0..3);

| (10)

> | for i from 2 to N do l[i]:=fsolve(Eq_Eig,lambda=l[i-1]..l[i-1]+4);od:

> | seq(l[i],i=1..N);

| (11)

> | U:=eval(X(x)*T(t)):

> | Un:=subs(c[2]=A[n]/T0,lambda=lambda[n],U):

> | u(x,t):=Sum(Un,n=1..infinity);

| (12)

> | eq_An:=eval(subs(t=0,u(x,t)))=rhs(IC);

| (13)

> | phi[n]:=cos(lambda[n]*x):

> | r(x):=1:

> | I1:=int(phi[n]^2*r(x),x=0..1):

> | IC;

| (14)

> | I2:=int(rhs(IC)*phi[n]*r(x),x=0..1):

> | A[n]:=I2/I1;

| (15)

> | u(x,t):=eval(u(x,t));

| (16)

> | u(x,t):=subs(infinity=N,u(x,t)):

> | for i to N do lambda[i]:=l[i];od:

The transient analytical solution is:

> | Digits:=5:u(x,t):=evalf(u(x,t));

| (17)

> | uu:=piecewise(t=0,rhs(IC),t>0,u(x,t)):

The plots are obtained as:

> | plot3d(uu,x=1..0,t=0.5..0,axes=boxed,title="Figure Exp. 7.15.",labels=[x,t,"u"],orientation=[45,60]);

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

> |