Ch2-1

advertisement
Chapter 2
Iterative Methods for Solving Sets of Equations
2.1 The Gauss-Seidel Method
The Gauss-Seidel method may be used to solve a set of linear or nonlinear algebraic equations.
We will illustrate the method by solving a heat transfer problem. For steady state, no heat
generation, and constant k, the heat conduction equation is simplified to Laplace equation
2T = 0
For 2-dimensional heat transfer in Cartesian coordinate
 2T
 2T
+
=0
x 2
y 2
The above equation can be put in the finite difference form. We divide the medium of interest
into a number of small regions and apply the heat equation to these regions. Each sub-region is
assigned a reference point called a node or a nodal point. The average temperature of a nodal
point is then calculated by solving the resulting equations from the energy balance. Accurate
solutions can be obtained by choosing a fine mesh with a large number of nodes. We will discuss
an example from Incropera’s1 text to illustrate the method.
Example 2.1-1
A long column with thermal conductivity k = 1 W/moK is maintained at 500oK on three surfaces
while the remaining surface is exposed to a convective environment with h = 10 W/m2oK and
fluid temperature T. The cross sectional area of the column is 1 m by 1 m. Using a grid spacing
x = y = 0.25 m, determine the steady-state temperature distribution in the column and the heat
flow to the fluid per unit length of the column.
Solution
The cross sectional area of the column is divided into many sub-areas called a grid or nodal
network with 25 nodes as shown in Figure 2.1-1. There are 12 nodal points with unknown
temperature, however only 8 unknowns need to be solved due to symmetry so that the nodes to
the left of the centerline are the same as those to the right.
1
Incropera, F. P. and DeWitt, D. P., Fundamentals of Heat and Mass Transfer, John Wiley &
Son, 2002.
2-1
x
500 K
m, n+1
y
500 K
1
2
1
3
4
3
5
6
5
7
8
7
m-1, n
500 K
m, n
m+1, n
m, n-1
h= 300 K
h = 10 W/m2K
Figure 2.1-1 The grid for the column cross sectional area.
The energy balance is now applied to the control volume xy1 belongs to node 1 which is an
interior node. To make the derivation general, node 1 can be considered as a node with index (m,
n) in a two-dimensional grid as shown in Figure 2.1-1. The directions of conduction heat flow
are assumed to be the positive x and y directions. For steady state with no heat generation
q(m-1, n)(m, n) + q(m, n-1)(m, n) = q(m, n)(m+1, n) + q(m, n)(m, n+1)
(2.1-1)
where q(m-1, n)(m, n) is the conduction heat flow between nodes (m-1, n) and (m, n). Fourier’s law
can be used to obtain
q(m-1, n)(m, n) = k(y1)
Tm1,n  Tm,n
x
Tm1,n  Tm,n
is the finite-difference
x
approximation to the temperature gradient at the boundary between the two nodes. Appling
Fourier’s law to each term in Equation (2.1-1) yields
where (y1) is the heat transfer area with a unit depth and
k(y1)
T
T
T  Tm ,n 1
Tm1,n  Tm,n
T  Tm1,n
+ k(x1) m ,n 1 m ,n = k(y1) m,n
+ k(x1) m ,n
y
y
x
x
The equation is divided by k(xy1) and simplified to
T
 2Tm ,n  Tm ,n 1
Tm1,n  2Tm,n  Tm1,n
+ m ,n 1
=0
2
y 2
x
(2.1-2)
For x = y, Eq. (2.1-2) becomes
Tm,n =
Tm1,n  Tm,n1  Tm1,n  Tm,n1
4
2-2
(2.1-3)
The above result shows that the temperature of an interior node is just the average of the
temperatures of the four adjoining nodal points. Using this formula, the temperatures for the first
six nodes are
T1 =
T2 =
T3 =
T4 =
T5 =
T6 =
1
( T2 + T3 + 500 + 500)
4
1
( T1 + T4 + T1 + 500)
4
1
( T1 + T4 + T5 + 500)
4
1
( T2 + T3 + T6 + T3)
4
1
( T3 + T6 + T7 + 500)
4
1
( T4 + T5 + T8 + T5)
4
Nodes 7 and 8 are not interior points, therefore Eq. (2.1-3) is not applicable.
x
500 K
y
500 K
1
2
1
3
4
3
5
6
5
7
8
7
5
6
500 K
7
8
500 K
h = 300 K
2
h = 10 W/m K
Figure 2.1-2 Directions of heat flow for nodes 7 and 8.
Making energy balance for node 7 yields
k(
y
500  T7
y
T T
T T
1)
+ k(x1) 5 7 = k(
1) 7 8 + h(x1)(T7  300)
2
x
2
x
y
Multiplying the above equation by
2
we obtain
k
2-3
7
500  T7 + 2T5  2T7 = T7  T8 +
2hx
(T7  300)
k
2hx
2  10  0.25
=
= 5.0
k
1
1
T7 = (2T5 + T8 + 2000)
9
Similarly an energy balance for node 8 yields
k(
y
T T
y
T T
T T
1) 7 8 + k(x1) 6 8 = k(
1) 8 7 + h(x1)(T8  300)
2
x
2
x
y
Multiplying the above equation by
2
we obtain
k
T7  T8 + 2T6  2T8 = T8  T7 +
T8 =
2hx
(T8  300)
k
1
(2T6 + 2T7 + 1500)
9
We have 8 linear equations with 8 unknowns that can be solved by matrix method or iterations.
Table 2.1-1 lists the Matlab program using Gauss-Seidel iteration to solve for the temperatures.
Table 2.1-1 ________________________
% Finite
% Initial guesses for the temperatures
T=400*ones(8,1);
for i=1:100
Tsave=T;
T(1)=.25*(T(2)+T(3)+1000);
T(2)=.25*(2*T(1)+T(4)+500);
T(3)=.25*(T(1)+T(4)+T(5)+500);
T(4)=.25*(T(2)+2*T(3)+T(6));
T(5)=.25*(T(3)+T(6)+T(7)+500);
T(6)=.25*(T(4)+2*T(5)+T(8));
T(7)=(2*T(5)+T(8)+2000)/9;
T(8)=(2*T(6)+2*T(7)+1500)/9;
eT=abs(T-Tsave);
if max(eT)<.01, break, end
end
fprintf('# of iteration = %g\n',i)
for i=1:8
fprintf('Node %g, Temperature = %8.2f\n',i,T(i))
end
2-4
>> finite
# of iteration = 13
Node 1, Temperature =
Node 2, Temperature =
Node 3, Temperature =
Node 4, Temperature =
Node 5, Temperature =
Node 6, Temperature =
Node 7, Temperature =
Node 8, Temperature =
489.30
485.15
472.06
462.00
436.95
418.73
356.99
339.05
The heat transfer rate per unit depth from the column to the fluid is given as
q’/L = 2h[
x
x
(500  300) + x(T7  300) +
(T8  300)]
2
2
q’/L = (2)(10)(0.25)[100 + (356.99  300) + (0.5)(339.05  300)]
q’/L = 883 W/m
If the matrix is strictly diagonally dominant, the Gauss-Seidel method will converge. However,
convergence may also be achieved in many situations for which diagonal dominance cannot be
obtained, although the rate of convergence is slowed. An nn matrix A is diagonally dominant if
and only if
n
|ai,i| >
| a
j 1
i, j
i = 1, 2, , n
|,
j i
An example of a diagonally dominant system is the following set of equations
6x1
2x1
x1
 2x2 + x3
+ 7x2 + 2x3
+ 2x2  5x3
=
=
=
11
5
1
(6 > 2 +1)
(7 > 2 +2)
(5 > 1 + 2)
If possible, the equations should be reordered to provide diagonal elements whose magnitudes
are larger than those of other elements in the same row. The Gauss-Seidel method may also be
used to solve a set of nonlinear equations as shown in the next example.
Example 2.1-2
Use Gauss-Seidel method with the initial guess x = [0.1 0.1 0.1] to obtain the solutions to the
following equations2
2
Numerical Analysis by Burden and Faires
2-5
1
=0
2
x12  81(x2 + 0.1)2 + sin x3 + 1.06 = 0
10  3
e  x1x2 + 20x3 +
=0
3
3x1  cos(x2 x3) 
Solution
The above equations can be rearranged as follows
1
1
cos(x2 x3) +
3
6
1
1
(x2 + 0.1)2 =
( x12 + sin x3 + 1.06)  x2 = ( x12 + sin x3 + 1.06)1/2  0.1
81
9
1  x1x2 10  3
e
x3 = 

20
60
x1 =
Table 2.1-2 lists the Matlab program and the results using Gauss-Seidel iteration to obtain the
solutions.
Table 2.1-2 ________________________
% Example 2.1-2 (Ex2d1d2), Gauss-Seidel iteration
%
x=[.1 .1 -.1];
for i=1:100
xsave=x;
x(1)=cos(x(2)*x(3))/3+1/6;
x(2)=sqrt(x(1)*x(1)+sin(x(3))+1.06)/9-0.1;
x(3)=-exp(-x(1)*x(2))/20-(10*pi-3)/60;
if abs(max(xsave-x))<1e-5, break, end
fprintf('x = %11.5f %11.5f %11.5f\n',x)
end
fprintf('# of iterations = %g\n',i)
fprintf('x = %11.5f %11.5f %11.5f\n',x)
>> ex2d1d2
x = 0.49998 0.02223
x = 0.49998 0.00003
x = 0.50000 0.00000
# of iterations = 4
x = 0.50000 0.00000
-0.52305
-0.52360
-0.52360
-0.52360
2-6
Download