Example 7.1.mw
Example 7.1 Heat Conduction in a Rectangle
The Maple program used to solve example 7.1 is given below:
| > |
 |
The gorging equation is entered here:
| > |
eq:=diff(u(x,t),t)=diff(u(x,t),x$2); |
 |
(1) |
The initial condition is entered here:
 |
(2) |
The boundary conditions are entered here:
 |
(3) |
 |
(4) |
Next, u is separated as u = XT (equation 7.1.5)):
| > |
Eq:=subs(u(x,t)=X(x)*T(t),eq); |
 |
(5) |
 |
(6) |
The governing equation for T is:
| > |
Eq_T:=lhs(Eq)=-lambda^2; |
 |
(7) |
T can be solved as;
| > |
T(t):=rhs(dsolve({Eq_T,T(0)=T0},T(t))); |
 |
(8) |
The gorging equation for X is:
| > |
Eq_X:=rhs(Eq)=-lambda^2; |
 |
(9) |
X can be solved as:
 |
(10) |
Maple sometimes attaches _C1 with the sine function and sometimes with the cosine function. To avoid this, we can specify the initial conditions for X and its derivative:
| > |
X(x):=rhs(dsolve({Eq_X,D(X)(0)=c[1]*lambda,X(0)=c[2]},X(x))); |
![`+`(`*`(c[1], `*`(sin(`*`(lambda, `*`(x))))), `*`(c[2], `*`(cos(`*`(lambda, `*`(x))))))](images/Example 7.1_12.gif) |
(11) |
The boundary conditions for X are:
![`+`(`*`(c[1], `*`(sin(`*`(lambda, `*`(x))))), `*`(c[2], `*`(cos(`*`(lambda, `*`(x)))))) = 0](images/Example 7.1_13.gif) |
(12) |
![`+`(`*`(c[1], `*`(sin(`*`(lambda, `*`(x))))), `*`(c[2], `*`(cos(`*`(lambda, `*`(x)))))) = 0](images/Example 7.1_14.gif) |
(13) |
The constant c2 is solved using the boundary condition at X = 0:
| > |
Eq_Bc1:=eval(subs(x=0,Bc1)); |
![c[2] = 0](images/Example 7.1_15.gif) |
(14) |
| > |
c[2]:=solve(Eq_Bc1,c[2]); |
 |
(15) |
The second boundary condition at x = 1 gives:
| > |
Eq_Bc2:=eval(subs(x=1,Bc2)); |
![`*`(c[1], `*`(sin(lambda))) = 0](images/Example 7.1_17.gif) |
(16) |
If c1 is zero, then we get the trivial solution X = 0. Hence, sin(λ) should be zero:
 |
(17) |
The eigenvalue equation can be solved to get the eigenvalue, λ:
 |
(18) |
By default, Maple picks only one eigenvalue. We can ask Maple to find all the eigenvalues using the following command:
| > |
_EnvAllSolutions := true: |
 |
(19) |
_Z1 means the integer plane. Hence, the eigenvalues can be taken as λ = nπ, n = 1, 2, 3,...∞. The solution for u can be written as:
![`*`(c[1], `*`(sin(`*`(lambda, `*`(x))), `*`(T0, `*`(exp(`+`(`-`(`*`(`^`(lambda, 2), `*`(t)))))))))](images/Example 7.1_21.gif) |
(20) |
The constants c1 and T0 can be combined as a single constant An:
| > |
Un:=subs(c[1]=A[n]/T0,lambda=lambda[n],U); |
![`*`(A[n], `*`(sin(`*`(lambda[n], `*`(x))), `*`(exp(`+`(`-`(`*`(`^`(lambda[n], 2), `*`(t))))))))](images/Example 7.1_22.gif) |
(21) |
Hence, the solution can be written as an infinite series:
| > |
u(x,t):=Sum(Un,n=1..infinity); |
![Sum(`*`(A[n], `*`(sin(`*`(lambda[n], `*`(x))), `*`(exp(`+`(`-`(`*`(`^`(lambda[n], 2), `*`(t)))))))), n = 1 .. infinity)](images/Example 7.1_23.gif) |
(22) |
The values of the eigenvalues can be substituted as:
| > |
u(x,t):=subs(lambda[n]=n*Pi,u(x,t)); |
![Sum(`*`(A[n], `*`(sin(`*`(n, `*`(Pi, `*`(x)))), `*`(exp(`+`(`-`(`*`(`^`(n, 2), `*`(`^`(Pi, 2), `*`(t))))))))), n = 1 .. infinity)](images/Example 7.1_24.gif) |
(23) |
The constant An is obtained by applying the initial condition and by using the orthogonal property of the eigenfunction:
| > |
eq_An:=eval(subs(t=0,u(x,t)))=rhs(IC); |
![Sum(`*`(A[n], `*`(sin(`*`(n, `*`(Pi, `*`(x)))))), n = 1 .. infinity) = 1](images/Example 7.1_25.gif) |
(24) |
| > |
I1:=int((sin(n*Pi*x))^2,x=0..1); |
 |
(25) |
| > |
I2:=int(sin(n*Pi*x),x=0..1); |
 |
(26) |
The integrals can be simplified by substituting sin(nπ) = 0:
 |
(27) |
 |
(28) |
 |
(29) |
The dimensionless temperature profile is given by:
 |
(30) |
For plotting purposes, we replace ∞ by, N, an integer:
| > |
u(x,t):=subs(infinity=N,u(x,t)); |
 |
(31) |
N = 20 is enough for this problem:
 |
(32) |
The solution obtained is plotted at t = 0. We observe oscillations about initial condition 1. This is called Gibb's phenomenon. Theoretically it will take N = ∞ for this profile to become u = 1 at t = 0.
| > |
plot(eval(subs(t=0,ua)),x=0..1,axes=boxed,title="Figure Exp. 7.1.",thickness=3,labels=[x,"u(x,0)"]); |
Next, the initial condition is predicted using N = 100 terms in the series:
| > |
ua2:=subs(N=100,u(x,t)); |
 |
(33) |
| > |
plot(eval(subs(t=0,ua2)),x=0..1,axes=boxed,title="Figure Exp. 7.2.",thickness=3,labels=[x,"u(x,0)"]); |
We observe better predictions as the number of terms increase. However, we need more terms at t = 0. For values of t > 0, N = 20 is enough. Hence, a piecewise polynomial can be used to define the initial condition at t = 0 and the separation of variables solution obtained can be used for values of t > 0.
| > |
uu:=piecewise(t=0,rhs(IC),t>0,ua); |
 |
(34) |
A three dimensional plot can be made as:
| > |
plot3d(uu,x=1..0,t=0.3..0,axes=boxed,title="Figure Exp. 7.3.",labels=[x,t,"u"],orientation=[60,60]); |
The profiles across the slab at different times can be plotted as:
| > |
plot([subs(t=0,uu),subs(t=0.01,uu),subs(t=0.05,uu),subs(t=0.1,uu),subs(t=0.2,uu)],x=0..1,axes=boxed,title="Figure Exp. 7.4.",thickness=5,labels=[x,"u"],legend=["t=0","t=0.01","t=0.05","t=0.1","t=0.2"]); |