Example 7.11.mw

Example 7.11 Heat Transfer in a Rectangle

> | restart:

> | with(plots):

Derivatives in y are entered on the left hand side and derivatives in x are entered on the right hand side.

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

| (1)

The boundary conditions at x = 0 and x = 1 are entered:

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

| (2)

> | bc2:=u(x,y)=0;

| (3)

The boundary conditions at y = 0 and y = 1 are entered:

> | bc3:=u(x,y)=0;

| (4)

> | bc4:=u(x,y)=1;

| (5)

The dependent variable is separated as:

> | Eq:=subs(u(x,y)=X(x)*Y(y),eq);

| (6)

> | Eq:=expand(Eq/X(x)/Y(y));

| (7)

> | Eq_Y:=lhs(Eq)=lambda^2:

> | Eq_Y:=eval(Eq_Y*Y(y));

| (8)

> | dsolve(Eq_Y,Y(y));

| (9)

Y(y) can be written as:

> | Y(y):=C[1]*sinh(lambda*y)+C[2]*cosh(lambda*y);

| (10)

The homogeneous boundary condition in y (at y = 0) is used to eliminate one of the constants.

> | Bc3:=Y(y)=0;

| (11)

> | Eq_Bc3:=eval(subs(y=0,Bc3));

| (12)

> | C[2]:=solve(Eq_Bc3);

| (13)

> | Y(y):=eval(Y(y));

| (14)

X(x) is obtained as in example 7.1:

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

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

| (15)

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

| (16)

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

| (17)

> | Bc1:=X(x)=0;

| (18)

> | Bc2:=X(x)=0;

| (19)

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

| (20)

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

| (21)

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

| (22)

> | Eq_Eig:=sin(lambda)=0;

| (23)

> | _EnvAllSolutions := true:

> | solve(Eq_Eig,lambda);

| (24)

> | U:=eval(X(x)*Y(y));

| (25)

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

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

The dimensionless temperature is:

> | u(x,y):=subs(lambda[n]=n*Pi,u(x,y));

| (26)

The constant An is obtained using the nonhomogeneous boundary condition at y = 1:

> | eq_An:=eval(subs(y=1,u(x,y)))=rhs(bc4);

| (27)

> | phi[n]:=sin(n*Pi*x);

| (28)

> | r(x):=1;

| (29)

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

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

> | vars:={sin(n*Pi)=0}:

> | I1:=subs(vars,I1):

> | I2:=subs(vars,I2):

> | A[n]:=I2/I1/sinh(n*Pi);

| (30)

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

| (31)

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

> | ua:=subs(N=20,u(x,y)):

> | uu:=piecewise(y<0.99,ua,y>0.99,1);

| (32)

> | plot3d(evalf(uu),x=0..1,y=1..0,axes=boxed,title="Figure Exp. 7.26.",labels=[x,y,"u"],orientation=[-120,60]);

> | plot([subs(y=0,uu),subs(y=0.4,uu),subs(y=0.6,uu),subs(y=0.8,uu),subs(y=0.9,uu),subs(y=1,uu)],x=0..1,title="Figure 7.27.",axes=boxed,thickness=5,labels=[x,"u"],legend=["y=0","y=0.4","y=0.6","y=0.8","y=0.9","y=1.0"]);

> |