Question

In: Computer Science

Consider a rectangular plate of width L and height W. Three of the sides (left, bottom,...

Consider a rectangular plate of width L and height W. Three of the sides (left, bottom, and right side) are maintained at a constant temperature of T1 whereas the top side is maintained at T2. Write a general computer program to solve for the steady state temperature solution of the plate using finite difference techniques and the Gauss-Seidel iterative method for any arbitrary grid mesh m x n. Obtain a temperature solution using a grid mesh of 10x10, 20x20, and 30x30 for the following conditions: L = 40 cm, W = 60 cm, T1 = 20℃, and T2 = 95℃. Compare in terms of percent error the three numerical solutions to the closed form solution at the following five points (L and W represent the width and height of the plate.

Solutions

Expert Solution

Solution:

This is matlab program to solve the steady state solution of the plate, try this code:

clear all

close all

%Specify grid size

Nx = 10;

Ny = 10;

%Specify boundary conditions

Tbottom = 100

Ttop = 150

Tleft = 250

Tright = 300

% initialize coefficient matrix and constant vector with zeros

A = zeros(Nx*Ny);

C = zeros(Nx*Ny,1);

% initial 'guess' for temperature distribution

T(1:Nx*Ny,1) = 100;

% Build coefficient matrix and constant vector

% inner nodes

for n = 2:(Ny-1)

for m = 2:(Nx-1)

i = (n-1)*Nx + m;

A(i,i+Nx) = 1;

A(i,i-Nx) = 1;

A(i,i+1) = 1;

A(i,i-1) = 1;

A(i,i) = -4;

end

end

% Edge nodes

% bottom

for m = 2:(Nx-1)

%n = 1

i = m;

A(i,i+Nx) = 1;

A(i,i+1) = 1;

A(i,i-1) = 1;

A(i,i) = -4;

C(i) = -Tbottom;

end

%top:

for m = 2:(Nx-1)

% n = Ny

i = (Ny-1)*Nx + m;

A(i,i-Nx) = 1;

A(i,i+1) = .5;

A(i,i-1) = .5;

A(i,i) = -5;

C(i) = -Ttop;

end

%left:

for n=2:(Ny-1)

%m = 1

i = (n-1)*Nx + 1;

A(i,i+Nx) = .5;

A(i,i+1) = 1;

A(i,i-Nx) = .5;

A(i,i) = -2;

end

%right:

for n=2:(Ny-1)

%m = Nx

i = (n-1)*Nx + Nx;

A(i,i+Nx) = 1;

A(i,i-1) = 1;

A(i,i-Nx) = 1;

A(i,i) = -4;

C(i) = -Tright;

DEFINE COEFFICIENT MATRIX AND CONSTANT VECTOR ELEMENTS HERE

end

% Corners

%bottom left (i=1):

i=1

A(i,Nx+i) = 1;

A(i,2) = 1;

A(i,1) = -4;

C(i) = -(Tbottom + Tleft);

%bottom right:

i = Nx

A(i,Nx+i) = 1;

A(i,2) = 1;

A(i,1) = -4;

C(Nx) = -(Tbottom + Tright);

%top left:

i = (Ny-1)*Nx + 1;

A(i,i+1) = .5

A(i,i) =

%top right:

i = Nx*Ny;

DEFINE COEFFICIENT MATRIX AND CONSTANT VECTOR ELEMENTS HERE

%Solve using Gauss-Seidel

residual = 100;

iterations = 0;

while (residual > 0.0001) % The residual criterion is 0.0001 in this example

7% You can test different values

iterations = iterations+1

%Transfer the previously computed temperatures to an array Told

Told = T;

%Update estimate of the temperature distribution

INSERT GAUSS-SEIDEL ITERATION HERE

%compute residual

deltaT = abs(T - Told);

residual = max(deltaT);

end

iterations % report the number of iterations that were executed

%Now transform T into 2-D network so it can be plotted.

delta_x = 0.03/(Nx+1)

delta_y = 0.03/(Ny+1)

for n=1:Ny

for m=1:Nx

i = (n-1)*Nx + m;

T2d(m,n) = T(i);

x(m) = m*delta_x;

y(n) = n*delta_y;

end

end

T2d

surf(x,y,T2d)

figure

contour(x,y,T2d)


Related Solutions

A wire of length L has a rectangular cross-section with height H and width W. The...
A wire of length L has a rectangular cross-section with height H and width W. The wire has a hole all the way through it of area a. The wire is made of material with constant resistivity ρ1 . A battery with a known voltage is applied across the ends of the wire. a. Find the electric field inside the material and the current flowing through the wire. b. If the hole is totally filled with a material that has...
The length l, width w, and height h of a box change with time. At a...
The length l, width w, and height h of a box change with time. At a certain instant the dimensions are l = 2 m and w = h = 3 m, and l and w are increasing at a rate of 7 m/s while h is decreasing at a rate of 5 m/s. At that instant find the rates at which the following quantities are changing. (a) The volume. m3/s (b) The surface area. m2/s (c) The length of...
You are shooting a rectangular target with width w and height h. Assume that hitting any...
You are shooting a rectangular target with width w and height h. Assume that hitting any point inside the rectangle is equally likely. Let X be the distance of the point you hit to the center of the rectangle. Find the PDF, CDF, mean and variance of X.
Consider a rectangular channel with a variable width b and horizontal channel bottom, a) Obtain the...
Consider a rectangular channel with a variable width b and horizontal channel bottom, a) Obtain the equation of water surface profile (dy/dx) as function of Froude number and channel width change (db/dx) in a channel transition assuming that over a short distance x, the energy losses can be neglected. b) Using the equation you have obtained, draw the water surface profile if flow is subcritical and if there is an enlargement in channel cross section b in downstream section (2)...
Consider a rectangular channel with a variable width b and horizontal channel bottom, a) Obtain the...
Consider a rectangular channel with a variable width b and horizontal channel bottom, a) Obtain the equation of water surface profile (dy/dx) as function of Froude number and channel width change (db/dx) in a channel transition assuming that over a short distance x, the energy losses can be neglected. b) Using the equation you have obtained, draw the water surface profile if flow is subcritical and if there is an enlargement in channel cross section b in downstream section (2)...
Consider a rectangular channel with a variable width b and horizontal channel bottom, a) Obtain the...
Consider a rectangular channel with a variable width b and horizontal channel bottom, a) Obtain the equation of water surface profile (dy/dx) as function of Froude number and channel width change (db/dx) in a channel transition assuming that over a short distance x, the energy losses can be neglected. b) Using the equation you have obtained, draw the water surface profile if flow is subcritical and if there is an enlargement in channel cross section b in downstream section (2)...
A rectangular waveguide of width w and height h has cut-off frequencies for TE10 and TE11...
A rectangular waveguide of width w and height h has cut-off frequencies for TE10 and TE11 modes in the ratio 1 : 2. The aspect ratio ?
Design a rectangular milk carton box of width w, length ll, and height h which holds...
Design a rectangular milk carton box of width w, length ll, and height h which holds 540 cm^3 of milk. The sides of the box cost 1 cent/cm^2 and the top and bottom cost 3 cent/cm^2. Find the dimensions of the box that minimize the total cost of materials used.
A high-­viscosity oil is transported through a wide rectangular duct of length L, width W and...
A high-­viscosity oil is transported through a wide rectangular duct of length L, width W and depth 2B via pressure-­driven flow. The duct is inclined at an angle b? below the horizontal plane (gravity may be assumed to act downwards in the vertical direction), and is sufficiently broad that edge effects may be neglected in the transverse (x2) direction. The pressure at the upstream end of the duct (x1=0) is Po, and at the downstream end (x1=L) is PL. The...
A rectangular loop has 17 turns with sides w=.03m and l=.06m. The current is 9A. What...
A rectangular loop has 17 turns with sides w=.03m and l=.06m. The current is 9A. What is the force on each side and the torque on the loop if the external field is 0.5 T and is directed: (a) parallel to the plane of the loop (B1) (along the positive x-axis)? (b) normal to the plane of the loop (B2) (into the paper)?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT