Maple Code

Example 11.1-2. Heating of a Finite Slab

> restart;

Equation for heat conduction in a solid, after the insertion of Fourier's Law. (Eq. 11.1-2 for heat conduction in y direction)

> eqn1:=diff(T(y,t),t)-alpha*diff(T(y,t),y$2)=0;

[Maple Math]

Switch to dimensionless variables with dchange.

> with(PDEtools,dchange):

The first transformation is from Eq. 11.1-11. It is written so that Theta will correspond to the initial condition and two boundary conditions given in 11.1-15 and 11.1-16.

> transform:={T=T1-Theta*(T1-T0),y=b*eta,t=b^2*tau/alpha};

[Maple Math]

> eqn2:=dchange(transform,eqn1,[Theta(tau,eta),tau,eta]);

[Maple Math]

Eq. 11.1-14

> simplify(-eqn2*b^2/alpha/(T1-T0));

[Maple Math]

As Maple shows us, this equation can be solved by separation of variables because the solution depends on two linearly independent functions of one variable each.

> pdsolve(eqn2);

[Maple Math]

Defining Theta(eta,tau) as a product of the two linearly independent functions,

> Theta:=(eta,tau)->f(eta)*g(tau);

[Maple Math]

> eqn3:=diff(Theta(eta,tau),tau)=diff(Theta(eta,tau),eta$2);

[Maple Math]

> eqn4:=simplify(eqn3/(f(eta)*g(tau)));

[Maple Math]

Eqn4 is only valid if both sides equal a constant, which we will call -c^2.

> left:=lhs(eqn4)=-c^2;

[Maple Math]

> right:=rhs(eqn4)=-c^2;

[Maple Math]

We now solve each independently.

> gtau:=rhs(dsolve(left,g(tau)));

[Maple Math]

> feta:=rhs(dsolve(right,f(eta)));

[Maple Math]

In order to be consistent with the book, we will rename the constant of integration for gtau and feta.

> gtau:=subs(_C1=A,gtau);

[Maple Math]

> g:=unapply(gtau,tau);

[Maple Math]

> feta:=subs({_C1=C,_C2=B},feta);

[Maple Math]

> f:=unapply(feta,eta);

[Maple Math]

By symmetry, everything that goes on at the ends of the slab must be equal. This is shown in B.C.'s 1 and 2, since both are zero.

> eqn5:=f(1)=f(-1);

[Maple Math]

If sin(c)=0, then c=n*pi, where n is an integer. This would not work because cos(n*pi) does not equal zero, and the boundary conditions would not be true.

> assume(sin(c)=NumeralNonZero);

> B:=solve(eqn5,B);

[Maple Math]

> Theta(eta,tau);

[Maple Math]

> eqn6:=0=f(1);

[Maple Math]

> eqn7:=0=f(-1);

[Maple Math]

Let's see all of the solutions.

> _EnvAllSolutions:='true';

[Maple Math]

> solve({eqn6,eqn7},{c,C});

[Maple Math]

This is the eigenvalue. Cosine of this eigenvalue is the eigenfunction.

> c:=Pi*(n+1/2); assume(n,integer);

[Maple Math]

The eigenfunctions form a basis for the general solution. Thus we may multiply them together.

> simplify(Theta(eta,tau));

[Maple Math]

A and C may actually be different for each n. The most general solution of this form is obtained by adding the solutions of the form of Eq. 11.1-25 for all integral n from n= -infinity to n=+infinity. However, we will define a integration constant that allows us to sum from n=0 to n=+infinity. We will call it Dn as in the book (see Eq 11.1-26).

> Theta:=(eta,tau)->Dn*cos(1/2*Pi*(2*n+1)*eta)*exp(-1/4*Pi^2*(2*n+1)^2*tau);

[Maple Math]

This is Eq. 11.1-26

> Solution:=(eta,tau,N)->Sum(Theta(eta,tau),n=0..N);

[Maple Math]

This is Eq. 11.1-27. We get this by using the initial condition that tau=0 when Theta=1.

> eqn:=1=Solution(eta,0,N);

[Maple Math]

This is Eq. 11.1-29

> eqn2:=int(lhs(eqn)*cos((m+1/2)*Pi*eta),eta=-1..1)=int(rhs(eqn)*cos(((m+1/2)*Pi*eta)),eta=-1..1);

[Maple Math]

We will evaluate the right hand side by taking the summation outside of the integral.

> Right:=simplify(Sum(int(cos((m+1/2)*Pi*eta)*Dn*cos(1/2*Pi*(2*n+1)*eta),eta=-1..1),n=0..N));

[Maple Math]

When the integration is done, all the integrals in the summation on the right are identically zero, as we can see above, except when n=m. This is because all of the eigenfunctions are orthogonal. When we take the inner product of two orthogonal functions, it is zero. The only time that you do not have two orthogonal functions is when n=m. Thus we can drop the summation and take the limit of the rest as n approaches m. We drop the Dn term also so that we can solve for it later.

> limit((sin(Pi*(m-n))*m+sin(Pi*(m-n))+sin(Pi*(m-n))*n+sin(Pi*(m+1+n))*m-sin(Pi*(m+1+n))*n)/(m^2+m-n-n^2)/Pi,n=m);

[Maple Math]

This limit represents the right hand side of Eq. 11.1-29. To solve for Dm, we divide the left hand side of eqn2 by this limit.

> Dm:=simplify(lhs(eqn2)/%);

[Maple Math]

We now substitute a trig identity for the numerator and take advantage of the fact that sin(Pi*m) is zero and cos(Pi*m) is (-1)^m. We want Dn back again for our final solution. This is exactly the same as Eq. 11.1-30 by inspection.

> Dn:=subs({m=n,sin(Pi*m)=0,cos(Pi*m)=(-1)^n,sin(1/2*(2*m+1)*Pi)=sin(m*Pi)*cos(Pi/2)+cos(m*Pi)*sin(Pi/2)},Dm);

[Maple Math]

This is Eq. 11.1-31 and matches exactly.

> Solution(eta,tau,N);

[Maple Math]

> plot({Solution(eta,1,100),Solution(eta,.4,100),Solution(eta,.04,100)},eta=0..1);

[Maple Plot]

These are a couple of plots of the temperature profile at tau=1, 0.4, and 0.04. They match with the book's plots.