Example 7.6.mw

Example 7.6 Heat Conduction in a Slab with Radiation Boundary Conditions 

> Typesetting:-mrow(Typesetting:-mi(
 

> with(plots):
 

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

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

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

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

u(x, 0) = 1 (2)
 

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

diff(u(x, t), x) = 0 (3)
 

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

`+`(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);
 

`+`(cos(lambda), `-`(`*`(lambda, `*`(sin(lambda))))) (5)
 

> solve(Eq_Eig,lambda);
 

RootOf(`+`(`*`(_Z, `*`(tan(_Z))), `-`(1))) (6)
 

Maple predicts negative eigenvalues: 

> fsolve(Eq_Eig,lambda);
 

-.8603335890 (7)
 

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

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

.8603335890 (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.");
 

Plot_2d
 

The first 20 eigenvalues are obtained as: 

> N:=20;
 

20 (9)
 

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

.8603335890 (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);
 

.8603335890, 3.425618459, 6.437298179, 9.529334405, 12.64528722, 15.77128487, 18.90240996, 22.03649673, 25.17244633, 28.30964285, 31.44771464, 34.58642422, 37.72561283, 40.86517033, 44.00501792, 47.14...
.8603335890, 3.425618459, 6.437298179, 9.529334405, 12.64528722, 15.77128487, 18.90240996, 22.03649673, 25.17244633, 28.30964285, 31.44771464, 34.58642422, 37.72561283, 40.86517033, 44.00501792, 47.14...
.8603335890, 3.425618459, 6.437298179, 9.529334405, 12.64528722, 15.77128487, 18.90240996, 22.03649673, 25.17244633, 28.30964285, 31.44771464, 34.58642422, 37.72561283, 40.86517033, 44.00501792, 47.14...
(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);
 

Sum(`*`(A[n], `*`(cos(`*`(lambda[n], `*`(x))), `*`(exp(`+`(`-`(`*`(`^`(lambda[n], 2), `*`(t)))))))), n = 1 .. infinity) (12)
 

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

Sum(`*`(A[n], `*`(cos(`*`(lambda[n], `*`(x))))), n = 1 .. infinity) = 1 (13)
 

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

> r(x):=1:
 

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

> IC;
 

u(x, 0) = 1 (14)
 

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

> A[n]:=I2/I1;
 

`+`(`/`(`*`(2, `*`(sin(lambda[n]))), `*`(`+`(`*`(cos(lambda[n]), `*`(sin(lambda[n]))), lambda[n])))) (15)
 

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

Sum(`+`(`/`(`*`(2, `*`(sin(lambda[n]), `*`(cos(`*`(lambda[n], `*`(x))), `*`(exp(`+`(`-`(`*`(`^`(lambda[n], 2), `*`(t))))))))), `*`(`+`(`*`(cos(lambda[n]), `*`(sin(lambda[n]))), lambda[n])))), n = 1 ..... (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));
 

`+`(`*`(1.1191, `*`(cos(`+`(`*`(.86033, `*`(x)))), `*`(exp(`+`(`-`(`*`(.74017, `*`(t)))))))), `-`(`*`(.15169, `*`(cos(`+`(`*`(3.4256, `*`(x)))), `*`(exp(`+`(`-`(`*`(11.735, `*`(t))))))))), `*`(0.46594...
`+`(`*`(1.1191, `*`(cos(`+`(`*`(.86033, `*`(x)))), `*`(exp(`+`(`-`(`*`(.74017, `*`(t)))))))), `-`(`*`(.15169, `*`(cos(`+`(`*`(3.4256, `*`(x)))), `*`(exp(`+`(`-`(`*`(11.735, `*`(t))))))))), `*`(0.46594...
`+`(`*`(1.1191, `*`(cos(`+`(`*`(.86033, `*`(x)))), `*`(exp(`+`(`-`(`*`(.74017, `*`(t)))))))), `-`(`*`(.15169, `*`(cos(`+`(`*`(3.4256, `*`(x)))), `*`(exp(`+`(`-`(`*`(11.735, `*`(t))))))))), `*`(0.46594...
`+`(`*`(1.1191, `*`(cos(`+`(`*`(.86033, `*`(x)))), `*`(exp(`+`(`-`(`*`(.74017, `*`(t)))))))), `-`(`*`(.15169, `*`(cos(`+`(`*`(3.4256, `*`(x)))), `*`(exp(`+`(`-`(`*`(11.735, `*`(t))))))))), `*`(0.46594...
`+`(`*`(1.1191, `*`(cos(`+`(`*`(.86033, `*`(x)))), `*`(exp(`+`(`-`(`*`(.74017, `*`(t)))))))), `-`(`*`(.15169, `*`(cos(`+`(`*`(3.4256, `*`(x)))), `*`(exp(`+`(`-`(`*`(11.735, `*`(t))))))))), `*`(0.46594...
`+`(`*`(1.1191, `*`(cos(`+`(`*`(.86033, `*`(x)))), `*`(exp(`+`(`-`(`*`(.74017, `*`(t)))))))), `-`(`*`(.15169, `*`(cos(`+`(`*`(3.4256, `*`(x)))), `*`(exp(`+`(`-`(`*`(11.735, `*`(t))))))))), `*`(0.46594...
`+`(`*`(1.1191, `*`(cos(`+`(`*`(.86033, `*`(x)))), `*`(exp(`+`(`-`(`*`(.74017, `*`(t)))))))), `-`(`*`(.15169, `*`(cos(`+`(`*`(3.4256, `*`(x)))), `*`(exp(`+`(`-`(`*`(11.735, `*`(t))))))))), `*`(0.46594...
`+`(`*`(1.1191, `*`(cos(`+`(`*`(.86033, `*`(x)))), `*`(exp(`+`(`-`(`*`(.74017, `*`(t)))))))), `-`(`*`(.15169, `*`(cos(`+`(`*`(3.4256, `*`(x)))), `*`(exp(`+`(`-`(`*`(11.735, `*`(t))))))))), `*`(0.46594...
(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
 

> 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"]);
 

Plot_2d
 

>