Definition of Steady

advertisement
TEMPERATURE DISTIBUTION
IN A FLAT PLATE
Dan A. Ward
17 April 2001
MEAE4960
Numerical Analysis for Engineering
FINAL PROJECT
TABLE OF CONTENTS
1.0
2.0
3.0
4.0
5.0
6.0
7.0
8.0
9.0
LIST OF SYMBOLS
LIST OF FIGURES AND TABLES
INTRODUCTION
PROBLEM DESCRIPTION AND FORMULATION
4.1 ANSYS Approach
4.2 Finite Difference Method
RESULTS
5.1 ANSYS Approach
5.2 Finite Difference Method
ERROR ANALYSIS
CONCLUSION AND DISCUSSION
REFERENCES
APPENDIX
9.1 Matrix for the System of Equations
9.2 MATLAB Code
9.3 MATLAB Results (Output)
9.4 ANSYS Results (Output)
1.0 LIST OF SYMBOLS
Dimensions of the Homogeneous Plate
Lx
Ly
x
y
t
Plate dimension in x-direction
Plate dimension in y-direction
Finite increment of plate model (x-dir)
Finite increment of plate model (y-dir)
Thickness of plate
10.0 cm
10.0 cm
1.0 cm (also h or x)
1.0 cm (also k or y)
Negligible
Temperature Values
T1
T2
T3
T4
Boundary condition temp. on Edge1
Boundary condition temp. on Edge2
Boundary condition temp. on Edge3
Boundary condition temp. on Edge4
1723 K (1400 C)
273 K (0 C)
273 K (0 C)
1723 K (1400 C)
Symbol Nomenclature
P(m,n) or wmn
Ni or Pi
Temperature at node (m,n)
Node location in mesh
2.0 LIST OF FIGURES AND TABLES
Figure 1: Sketch of the Homogeneous Flat Plate
Figure 2: ANSYS Model With Temperature Distribution
Figure 3: Original Mesh Used for the Finite Difference Method
Figure 4: Modified Model Used for the Finite Difference Method
Figure 5: Nodal Results Given by the ANSYS Analysis
Figure 6: Nodal Temperatures as Given by the Finite Difference Method
Table 1: Tabulated Results for the Temperature Distribution Matrix (ANSYS)
Table 2: Tabulated Results for the Temperature Distribution Matrix (Finite
Difference Method)
Table 3: Percent Errors at the Coincident Nodes for the Both Analyses
3.0 INTRODUCTION
Two methods for determining results for the heat distribution in a flat plate are
presented. The first is a computer generated thermal analysis which used
ANSYS and the second is a 'paper and pencil' approach using a finite difference
method. Both analyses assumed that the plate was heated on two adjacent ends
while the opposite ends were kept at a cool, constant temperature.
A finite element approach was used for the steady-state thermal analysis. Thus,
the presented analyses are both approximation techniques which solve a series
of continuous functions over a finite number of small sub-domains. The finite
difference solution in this report makes use of the Gauss-Seidel iterative
algorithm to solve the final system of equations and thus, determining the
temperature distribution in the plate. The algorithm was compiled using
MATLAB.
4.0 PROBLEM DESCRIPTION AND FORMULATION
In this study, calculations were performed on a flat, Homogeneous metal plate.
The heated edges were aligned with the x- and y-axes and both of the cooled
edges were the edges opposite the axes. Model construction for the ANSYS
approach and the finite difference method were both based on the sketch seen in
Figure 1.
Edge 2
273 K
(0 C)
Edge 3
1723 K
(1400 C)
Edge 1
z
y
x
Edge 4
Figure 1: Sketch of the Homogeneous Flat Plate
4.1 ANSYS Approach
Using the finite element analysis (FEA) package ANSYS, a model of a
simple, flat plate was constructed. A thermal analysis was conducted
using identical boundary conditions as those seen in Figure 1 with the
heat source placed along the plate's x- and y-axes. Figure 2 shows the
ANSYS model with the implied boundary conditions as well as the final
element results (averaged throughout each element's surface area).
1723 K
1723 K
273 K
273 K
Figure 2: ANSYS Model With Temperature Distribution
The resulting nodal results for this analysis are later discussed in the
Results section and the output file can be found in Appendix 9.4.
A mesh was created in such a way that elements and their nodes were
spaced exactly 1.0 cm apart. This mesh pattern can be seen as the light
lines criss-crossing inside the plate. Although more accurate results are
obtained using a more refined mesh (due to less averaging across
elements), the mesh structure was kept coarse in order to follow finite
difference method approach as closely as possible. In the next section,
an even coarser mesh was used to limit the amount of computation time.
In both approaches, a two-dimensional assumption was made for
simplicity. If convection on any edge were modeled, ANSYS would
require a three-dimensional model to generate results. [This would mean
that the finite difference method discussed below would no longer be valid
since convection creates a new set of boundary conditions which must be
solved using another approach.]
Ideally, a good mesh would have had x = y = 0.1cm. In this model,
however, there were 121 nodes and 100 elements. Numerical sequencing
for the nodes followed this pattern: node 1 (N1) is at Cartesian (0,0), N2 is
at (1,0) . . . N12 is at (0,1), N13 is at (1,1) . . . N121 is at (10,10).
4.2 Finite Difference Method
Staying with the convention of Figures 1 and 2, a coordinate system was
again placed at the intersection of edges 1 and 4 and the heat source was
placed on the x- and y-axes. The first step in solving the problem was to
discretize the model using elements and nodes. This was required since
the heat equation was used to determine temperatures at points along the
plate (ANSYS and other FEA packages use the same technique to solve
both thermal and structural problems).
This method used a similar element-node pattern as that seen in Figure 2
but was not as refined as the 100-element ANSYS model. As seen in
Figure 3, there were 25 elements and 26 nodes. Thus, the paper and
pencil method used the nodal sequence: N1 at (0,0), N2 at (2,0) . . . N7 at
(0,2), N8 at (2,2) . . . N36 at (10,10). So this model had 36 nodes and 25
elements.
w05
w15
w25
w35
w45
w55
w04
w14
w24
w34
w44
w54
w03
w13
w23
w33
w43
w53
w02
w12
w22
w32
w42
w52
w01
w11
w21
w31
w41
w51
w00
w10
w20
w30
w40
w50
Figure 3: Original Mesh Used for the Finite Difference Method
The external nodes were those along the plate's boundaries. The values
for these nodes were readily known with knowledge of the boundary
conditions. Similarly, internal nodes were those nodes inside the plate's
boundaries. Since these points were unknown, they had to be determined
using the finite difference method. For simplicity, the internal nodes were
renamed as points P1 through P16 as seen in the modified mesh of Figure
4.
w05
w15
w25
w35
w45
w55
w04
P13
P14
P15
P16
w54
w03
P9
P10
P11
P12
w53
w02
P5
P6
P7
P8
w52
w01
P1
P2
P3
P4
w51
w00
w10
w20
w30
w40
w50
Figure 4: Modified Model Used for the Finite Difference Method
Although 36 nodes can be seen in Figures 3 and 4, only 16 points
remained unknown (P1 through P16). So temperatures had to be found at
the following nodes: 8-11, 14-17, 20-23 and 26-29. Figure 3 also shows
the known nodal locations in color (blue and red for cold and hot
temperatures respectively) and the unknown nodes as unfilled squares.
After constructing the model, the next step was to apply the Poisson
equation (Equation 1) to the model above.
 2 T  2 T c u
Eq. 1


k t
x 2 y 2
As stated earlier, the analysis was steady state and all values were
assumed to not change with respect to time. As a result of this
assumption, the right hand side becomes zero and the constants can then
be ignored. The resulting equation is called Laplace's equation and is also
used as one form of the Heat equation (Equation 2).
 2u ( x, y )  2u ( x, y )
Eq. 2

0
x 2
y 2
This equation was applied within the set
R = { (x,y) | 0 < x < 0.1m, 0 < y < 0.1m}
and had the following boundary conditions
u(0,y) = T1, u(x,Ly) = T2, u(Lx,y) = T3, u(x,0) = T4.
For each interior mesh point, the Taylor series below was used to
generate the centered difference formula (Equations 3a and 3b).
 2u ( xi , y j ) u ( xi 1 , y j )  2u ( xi , y j )  u ( xi 1 , y ) h 2 4u ( i , y j )


x 2
h2
12x y
Eq. 3a
 2u ( xi , y j ) u ( xi , y j 1 )  2u ( xi , y j )  u ( x1 , y1 ) k 2 4u ( xi , j )


y 2
k2
12y y
Eq. 3b
where h and k are the mesh x and y respectively. On the right hand
side of Eqs. 3a and 3b, the 4th order terms were ignored.
Using these formulas it was then possible to express the Poisson's
equation at (xi, yj) by adding the right hand side of each equation together
and setting them equal to zero.
Applying this equation to the model in Figure 3 gave the Differenceequation formula
2
 h 2 
h
Eq. 4
2   1 wij  wi 1, j  wi 1, j     wi , j 1  wi , j 1   0
k
k






where wij approximates the value at Nij.
Since the mesh density is h = x = 1 and k = y = 1, the difference
equation is reduced to
4w(i,i) = w(i+1,j) + w(i-1,j) + w(i,j+1) + w(i,j-1) .
Eq. 5
Equation 5 also states the conservation of energy for the problem since it
proves that all heat into a node must be the same as the heat leaving a
node. For this to be true, heat flow only travels along the element edges
(from node to node).
With i = 0 - 5 and j = 0 - 5, equation 5 becomes the final system of
equations that the Gauss-Sidel algorithm uses to determine the
temperature distribution in the flat plate. As stated previously, there were
16 unknown temperatures. Therefore, 16 equations were necessary in
order to determine these 16 unknown temperatures. This system of
equations is represented as Equation 6 below (Nn = Pn, m = i and n = j).
Eq. 6
N1  m = 1, n = 1  4T(1,1) = T(1,2) + T(1,0) + T(2,1) + T(0,1)
N2  m = 2, n = 1  4T(2,1) = T(2,2) + T(2,0) + T(3,1) + T(1,1)
N3  m = 3, n = 1  4T(3,1) = T(3,2) + T(3,0) + T(4,1) + T(2,1)
...
...
N15  m = 3, n = 4  4T(3,4) = T(3,5) + T(3,3) + T(4,4) + T(2,4)
N16  m = 4, n = 4  4T(4,4) = T(4,5) + T(4,3) + T(5,4) + T(3,4)
where the 16 unknowns were
T(1,1), T(2,1), T(3,1), T(4,1),
T(1,2), T(2,2), T(3,2), T4,2),
T(1,3), T(2,3), T(3,3), T(4,3), and
T(1,4), T(2,4), T(3,4), T(4,4).
Similarly, the 16 known, external node temperatures in Equation 6 were
T(0,1) = T(0,2) = T(0,3) = T(0,4) = 1723 (Edge 1)
T(1,5) = T(2,5) = T(3,5) = T(4,5) = 273 (Edge 2)
T(5,1) = T(5,2) = T(5,3) = T(5,4) = 1723 (Edge 3)
T(1,0) = T(2,0) = T(3,0) = T(4,0) = 273 (Edge 4)
Before evoking MATLAB and the Gauss-Sidel Method, the last step
required was placing the values in their proper position in the matrix. This
matrix can be found in Appendix 10.1.
5.0 RESULTS
5.1 ANSYS Approach
Results to the steady state analysis are shown in the table below. Note:
only the coincident nodes are discussed in order to easily compare the
results of each approach (the values of the coincident nodes are
highlighted in yellow). Also, a sketch of the nodal results is shown in
Figure 5.
Table 1: Tabulated Results for the Temperature
Distribution Matrix (ANSYS)
P1
P10
P19
P28
P37
P46
P55
P64
P73
1684.0
1645.8
1605.4
1584.0
1517.0
1455.9
1362.1
1198.1
802.1
P2
P11
P20
P29
P38
P47
P56
P65
P74
1645.8
1568.8
1491.6
1411.6
1321.4
1213.2
1072.6
919.2
591.3
P3
P12
P21
P30
P39
P48
P57
P66
P75
1686.1
1481.6
1378.7
1265.4
1150.3
1026.9
881.4
703.7
494.8
P4
P13
P22
P31
P40
P49
P58
P67
P76
1564.6
1411.6
1265.4
1132.6
1009.2
934.6
750.4
666.4
439.4
P5
P14
P23
P32
P41
P50
P59
P68
P77
1517.8
1321.4
1150.3
1009.2
885.4
768.7
651.2
528.7
401.4
P6
P15
P24
P33
P42
P51
P60
P69
P78
1455.9
1213.2
1026.9
934.6
768.7
751.0
568.0
570.2
371.5
P7
P16
P25
P34
P43
P52
P61
P70
P79
162.1
1072.6
881.4
750.4
651.2
568.0
491.9
418.3
345.3
P8
P17
P26
P35
P44
P53
P62
P71
P80
1198.1
919.2
7.06.7
666.4
528.7
570.2
418.3
394.0
3207.6
P9
P18
P27
P36
P45
P54
P63
P72
P81
8020.7
591.3
494.8
439.4
401.4
371.5
345.3
320.8
296.8
w05
w15 273
w25 273
w35 273
w45 273
w55 273
w04 1723
w14 919.20
w24 666.40
w34 570.20
w44 394.00
w54 273
w03 1723
w13 1213.20
w23 934.60
w33 751.00
w43 570.20
w53 273
w02 1723
w12 1411.60
w22 1132.60
w32 934.60
w42 666.40
w52 273
w01 1723
w11 1568.80
w21 1411.60
w31 1213.20
w41 919.20
w51 273
w00 1723
w10 1723
w20 1723
w30 1723
w40 1723
w50
Figure 5: Nodal Results Given by the ANSYS Analysis
5.2 Finite Difference Method
Using a tolerance equal to 10-5, the results to the system of equations of
Equation 6 are seen in Table 2 below. A sketch of these results is shown
in Figure 6.
Table 2: Tabulated Results for the Temperature
Distribution Matrix (Finite Difference Method)
P1
P5
P9
P13
1597.3036
1471.6073
1311.3018
1012.5600
P2
P6
P10
P14
1471.6073
1254.8236
1038.0400
742.9382
P3
P7
P11
P15
1311.3018
1038.0400
843.0964
648.1527
P4
P8
P12
P16
1012.5600
742.9382
648.1527
460.5764
w05
w15 273
w25 273
w35 273
w45 273
w55 273
w04 1723
w14 1012.56
w24 742.94
w34 648.15
w44 460.58
w54 273
w03 1723
w13 1311.30
w23 1038.04
w33 843.10
w43 648.15
w53 273
w02 1723
w12 1471.61
w22 1254.82
w32 1038.04
w42 742.94
w52 273
w01 1723
w11 1597.30
w21 1471.61
w31 1311.30
w41 1012.56
w51 273
w00 1723
w10 1723
w20 1723
w30 1723
w40 1723
w50
Figure 6: Nodal Temperatures as Given by the Finite Difference Method
6.0 ERROR ANALYSIS
Table 3 summarizes the calculated error difference at each coincident node. A
trend for these errors was noticed and it seemed that the ANSYS solution was
the cause of the greatest errors. As a result, the topic of discussion in the next
section will focus on the error in the ANSYS analysis.
Table 3: Percent Differences at the Coincident Nodes for Both Analyses
P1
P5
P9
P13
1.7845
4.0777
7.4813
9.2202
P2
P6
P10
P14
4.0777
7.6155
9.9630
10.3007
P3
P7
P11
P15
7.4813
9.9630
10.9260
12.0269
P4
P8
P12
P16
9.2202
10.3007
12.0269
14.4485
7.0 DISCUSSION AND SUMMARY
Table 4 shows the percent error at each respective node. As expected, the error
at the boundaries is zero since these conditions were given in the initial problem
statement.
Table 4: Percent Error at Each Node Location
w05
w15 0
w25 0
w35 0
w45 0
w55 0
w04 0
w14 9.22
w24 10.30
w34 12.03
w44 14.45
w54 0
w03 0
w13 7.48
w23 9.96
w33 10.93
w43 12.03
w53 0
w02 0
w12 4.08
w22 7.62
w32 9.96
w42 10.30
w52 0
w01 0
w11 1.78
w21 4.08
w31 7.48
w41 9.22
w51 0
w00 0
w10 0
w20 0
w30 0
w40 0
w50
Generally an error of 5% or less is not a major concern unless it is at a designcritical locale. The quickest and easiest answer to these discrepancies would be
mesh size. As a mesh becomes more refined, temperatures will tend to increase
as local "hot spots" are readily found since the values are averaged across the
element's surface area.
As an element's surface area increases, averaging across the element becomes
more and more significant. Noticing the trend in Table 4 also supports this
explanation. Nodal locations further away from (0,0) have greater errors than
those closer to the origin. This is because of the assumed coordinate system
situated at the origin and element averaging (and associated error) is
compounded when the program moves on to calculate values at the next
element/node. As a result, the node errors become larger and larger as the
distance from zero increases.
In order to minimize error in FEA programs it is always good practice to refine the
mesh size. With a problem this simple, ANSYS could evaluate a 100 x 100
element model rather quickly. This would decrease element averaging greatly
and would produce results that more closely resembled those of the finite
difference method. However, for problems of greater complexity, dense meshes
can take hours, days, or even longer to compile. In industry, computation time
translates into cost. This brings up the familiar dilemma of cost versus accuracy
which designers face almost daily.
8.0 REFERENCES
[1] Burden, R. L. & Faires, J. D., "Numerical Analysis" 7th edition, Brooks/Cole
Publishing Company, Pacific Grove, CA, 2000.
[2] Fowley, D., Horton, M., "The Student Edition of MATLAB" v. 4, Prentice Hall,
Englewood Cliffs, NJ, 1995.
[3] Pollard, B., "The effects of minor elements on the welding characteristics of
stainless steel," National Technical Information Service, US Dep. Of Commerce,
Springfield, VA, 1986.
[4] Murugan, S.; Kumar, P.V.; Raj, B.; Bose, M.S.C., "Temperature distribution
during multipass welding of plates," International Journal of Pressure Vessels
and Piping v 75, Exeter England, 1998.
[5] Reddy, J.; Gartling, D.; "The Finite Element Method In Heat Transfer and
Fluid Dynamics, 2nd Edition," Lewis Publishers, Inc.; December 2000.
APPENDIX
8.1 MATRIX for the System of Equations
MATLAB input file for finding the 16 unknown temperatures:
-4 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0
1 -4 1 0 0 1 0 0 0 0 0 0 0 0 0 0
0 1 -4 1 0 0 1 0 0 0 0 0 0 0 0 0
0 0 1 -4 0 0 0 1 0 0 0 0 0 0 0 0
1 0 0 0 -4 1 0 0 1 0 0 0 0 0 0 0
0 1 0 0 1 -4 1 0 0 1 0 0 0 0 0 0
0 0 1 0 0 1 -4 1 0 0 1 0 0 0 0 0
0 0 0 1 0 0 1 -4 0 0 0 1 0 0 0 0
0 0 0 0 1 0 0 0 -4 1 0 0 1 0 0 0
0 0 0 0 0 1 0 0 1 -4 1 0 0 1 0 0
0 0 0 0 0 0 1 0 0 1 -4 1 0 0 1 0
0 0 0 0 0 0 0 1 0 0 1 -4 0 0 0 1
0 0 0 0 0 0 0 0 1 0 0 0 -4 1 0 0
0 0 0 0 0 0 0 0 0 1 0 0 1 -4 1 0
0 0 0 0 0 0 0 0 0 0 1 0 0 1 -4 1
0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 -4
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
-3446
-1723
-1723
-1996
-1723
0
0
-273
-1723
0
0
-546
-1996
-273
-546
-546
8.2 MATLAB Code
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%% GAUSS-SEIDEL ITERATIVE TECHNIQUE ALGORITHM %%%%%%%%%%%%%%%%
%%%%%%%%%%%%%
APPLIED TO A HOMOGENOUSE FLAT PLATE
%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%
ALGORITHM NAME: "matrix.m"
%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
fprintf(1,'THIS ALGORITHM COMPUTES THE TEMPERATURE DISTRIBUTION IN A\n');
fprintf(1,'HOMOGENEOUS FLAT PLATE. THE BOUNDARY CONDITIONS MUST BE KNOWN\n');
fprintf(1,'AND EDGE DEFINITION IS DEFINED AS CLOCKWISE AROUND THE\n');
fprintf(1,'POINT (0,0) ASSUMING ONE CORNER OF THE PLATE IS ON (0,0).\n');
fprintf(1,'THE OUTPUT GIVEN IS THE TEMPERATURE AT EACH NODE RESPECTIVELY\n');
fprintf(1,' \n');
%
fprintf(1,'The array will be input from a text file in the order\n');
fprintf(1,'A(1,1), A(1,2), ..., A(1,n+1), \n');
fprintf(1,'A(2,1), A(2,2), ..., A(2,n+1), \n');
fprintf(1,'..., A(n,1), A(n,2), ..., A(n,n+1)\n');
fprintf(1,' \n');
%
fprintf(1,'Temperature on each edge must be known and a data file must\n');
fprintf(1,'be available using the format above.\n');
TRUE = 1;
FALSE = 0;
fprintf(1,'Is all of this information available? - enter Y or N.\n');
AA = input(' ','s');
OK = FALSE;
clc
fprintf(1,'Input plate length in X-direction (Lx).\n');
Lx = input(' ')
fprintf(1,'Input plate width in Y-direction (Ly).\n');
Ly = input(' ')
clc
%fprintf(1,'Input Temp. on edge1 (T1).\n');
%fprintf(1,'If Temp. is a distribution along an edge, input the equation.\n');
%fprintf(1,'
For Ex: 10*T*(Lx) --> (Increasing T along x-axis edge.)\n');
%T1 = input(' ');
%fprintf(1,'Input Temp. on edge2 (T2).\n');
%T2 = input(' ');
%fprintf(1,'Input Temp. on edge3 (T3).\n');
%T3 = input(' ');
%fprintf(1,'Input Temp. on edge4 (T4).\n');
%T4 = input(' ');
%
if AA == 'Y' | AA == 'y'
fprintf(1,'Input the file name in the form - drive:\\name.ext\n');
fprintf(1,'for example:
A:\\DATA.DTA\n');
NAME = input(' ','s');
INP = fopen(NAME,'rt');
OK = FALSE;
while OK == FALSE
fprintf(1,'Input the number of equations - an integer.\n');
N = input(' ');
if N > 0
A = zeros(N,N+1);
X1 = zeros(1,N);
for I = 1 : N
for J = 1 : N+1
A(I,J) = fscanf(INP, '%f',1);
end;
end;
% Use X1 for X0
for I = 1 : N
X1(I) = fscanf(INP, '%f',1);
end;
OK = TRUE;
fclose(INP);
else
fprintf(1,'The number must be a positive integer\n');
end;
end;
OK = FALSE;
while OK == FALSE
fprintf(1,'Input the tolerance.\n');
TOL = input(' ');
if TOL > 0
OK = TRUE;
else
fprintf(1,'Tolerance must be a positive.\n');
end;
end;
OK = FALSE;
while OK == FALSE
fprintf(1,'Input maximum number of iterations.\n');
NN = input(' ');
if NN > 0
OK = TRUE;
else
fprintf(1,'Number must be a positive integer.\n');
end;
end;
else
fprintf(1,'The program will end so the input file can be created.\n');
end;
if OK == TRUE
% STEP 1
K = 1;
OK = FALSE;
% STEP 2
while OK == FALSE & K <= NN
% ERR is used to test accuracy - it measures the infinity-norm
ERR = 0;
% STEP 3
for I = 1 : N
S = 0;
for J = 1 : N
S = S-A(I,J)*X1(J);
end;
S = (S+A(I,N+1))/A(I,I);
if abs(S) > ERR
ERR = abs(S);
end;
X1(I) = X1(I) + S;
end;
% STEP 4
if ERR <= TOL
OK = TRUE;
% process is complete
else
% STEP 5
K = K+1;
% STEP 6 - is not used since only one vector is required
end;
end;
if OK == FALSE
fprintf(1,'Maximum Number of Iterations Exceeded.\n');
% STEP 7
% procedure completed unsuccessfully
else
fprintf(1,'Choice of output method:\n');
fprintf(1,'1. Output to screen\n');
fprintf(1,'2. Output to text file\n');
fprintf(1,'Please enter 1 or 2.\n');
FLAG = input(' ');
if FLAG == 2
fprintf(1,'Input the file name in the form - drive:\\name.ext\n');
fprintf(1,'for example:
A:\\OUTPUT.DTA\n');
NAME = input(' ','s');
OUP = fopen(NAME,'wt');
else
OUP = 1;
end;
fprintf(OUP, 'GAUSS-SEIDEL METHOD FOR LINEAR SYSTEMS\n\n');
fprintf(OUP, 'The solution vector is :\n');
for I = 1 : N
fprintf(OUP, ' %11.8f', X1(I));
end;
fprintf(OUP, '\nusing %d iterations\n', K);
fprintf(OUP, 'with Tolerance %.10e in infinity-norm\n', TOL);
if OUP ~= 1
fclose(OUP);
fprintf(1,'Output file %s created successfully \n',NAME);
end;
end;
end;
8.3 MATLAB Results (Output)
GAUSS-SEIDEL METHOD FOR LINEAR SYSTEMS
The
w11
w41
w32
w23
w14
w44
solution vector
= 1597.30362856
= 1012.55999587
= 1038.03998919
= 1038.03998919
= 1012.55999587
= 460.57636145
is :
w21 =
w12 =
w42 =
w33 =
w24 =
1471.60726252
1471.60726252
742.938176410
843.096354890
742.938176410
w31
w22
w13
w43
w34
=
=
=
=
=
1311.30180992
1254.82362300
1311.30180992
648.15272290
648.15272290
using 44 iterations with Tolerance 1.0000000000e-05 in infinity-norm
8.4 ANSYS Results (Output)
See attached file "ANSYS.output.doc."
Download