Finite Difference Method: Applied To A Two-Dimensional, Steady-State, Heat Transfer Problem

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

Finite Difference Method

Applied to a two-dimensional, steady-state, heat transfer problem

MEMS1055, Computer Aided Analysis in Transport Phenomena


Dr. Peyman Givi
Seth Strayer
2/12/19
Contents
1 Introduction 1

2 Formulation 2
2.1 Deriving the Heat Diffusion Equation for Finite Difference . . . . . . . . . . . . . . . 2
2.2 Iterative Solving Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.3 Heat Transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

3 Results 4
3.1 Temperature Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.2 Method Trends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.3 Mesh Dependence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.4 Heat Transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

4 Conclusion 8

5 Appendix 9
5.1 SOR Method MATLAB Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

i
1 Introduction
In this report, we wish to use the finite difference method to solve for the steady-state temperature
distribution in a pipe whose cross-section is shown in Figure 1. Three different iterative methods
will be used to solve this problem, namely, the Jacobian, Gauss-Seidel, and Successive
over-relaxation (SOR) methods. The boundary conditions for this problem, outlined in Figure 1,
are as follows:

Figure 1: Problem Layout Describing Geometry and Boundary Conditions

• Dirichlet boundary condition of Th = 300[K] applied to the upper-left and upper-right sides

• Dirichlet boundary condition of Tc = 200[K] applied the middle side joining the two arc
segments
• Neumann boundary condition applied to the bottom and lower-right sides

Furthermore, the following physical parameters for the system are assumed:

• Internal heat generation of q̇ = 5e + 7[W/m3 ]


• Thermal conductivity coefficient of k = 20[W/m · K]

Given these parameters, we would like to use the finite difference method to solve for the
steady-state temperature distribution in the rod. Particularly, we wish to:

• Create contour plots of the steady-state temperature distribution


• Calculate the total heat transfer per unit length [W/m] from the rod
• Comment on the differences between the Jacobian, Gauss-Seidel, and SOR methods

• Determine an optimum δR and δθ - i.e., determine the optimum ”step size”


• Determine if our system satisfies the First Law of Thermodynamics

1
Additionally, the residual error (E) will be closely monitored. In this report, residual error refers
to the maximum, absolute value of the difference between any two corresponding elements of the
current iterations temperature matrix and the previous iterations temperature matrix. Namely,
k k−1
E = max | Ti,j − Ti,j | (1)
for i = {1, 2, ..., m}, j = {1, 2, ..., n} and k = {1 : N }, where m and n are the number of rows and
columns, respectively, and N is the total number of iterations. The residual will first be monitored
as a function of the number of iterations, and second, as a function of the mesh grid size. It is
expected that as the number of iterations increases and the mesh grid size decreases (more
elements used), the residual error will decrease.

2 Formulation
2.1 Deriving the Heat Diffusion Equation for Finite Difference
In this subsection, the steady-state, heat diffusion equation in terms of the finite difference method
is derived. Consider the general form of the Laplace equation under steady-state conditions,
assuming a constant thermal conductivity, k, and internal heat generation q̇. In polar coordinates,
this is given by:

∂ 2 u 1 ∂u 1 ∂2u q̇
+ + = (2)
∂r2 r ∂r r2 ∂θ2 k
First and second order central finite difference methods show that, in general:
∂u ui+1,j − ui−1,j
= (3)
∂x 2δx

∂2u ui−1,j − 2ui,j + ui+1,j


2
= (4)
∂x δx2
Note that Equations 3 and 4 ignore any truncation error associated with the method. Then in
terms of the finite difference method, the Laplace Equation (2) can be written as:
ui−1,j − 2ui,j + ui+1,j 1 ui+1,j − ui−1,j 1 ui−1,j − 2ui,j + ui+1,j q̇
+ + = (5)
(δr)2 iδr 2δr (iδr)2 (δθ)2 k
By rearranging the terms in Equation 5 and solving for ui,j , we have means of implementing an
iterative algorithm to solve for the temperatures present at each node in the system. Note that in
order to solve using the finite difference method, there must be some initial guess for all unknown
temperatures in the system. We will assume an initial guess of zero for all unknown nodes. This is
accomplished by using the MATLAB command

T = zeros(rows, cols)
where T is the temperature matrix, rows is the number of gridpoints in the radial direction, and
cols is the number of gridpoints in the angular direction.

2.2 Iterative Solving Methods


In general, when solving for the nodal temperatures in our system, we are trying to solve a system
of n linear equations, where n is the total number of nodes in the system. This system is easily
described by:

2
Ax = b (6)
where A is a n x n matrix of coefficients, x is a vector of n unknown values, and b is a vector of n
constants. Rather than solving these equations directly, methods such as Jacobian, Gauss-Seidel,
and SOR solve these equations iteratively, which is very desirable for large systems. In general, the
Jacobian method is given by:
1 X
xk+1
i = (bi − aij xkj ) (7)
aii
j6=i

where xk is the kth iteration of x and i = 1, 2, ..., n. The Gauss-Seidel method employs forward
substitution and is given by:
i−1 n
1 X X
xk+1
i = (bi − aij xk+1
j − aij xkj ) (8)
aii j=1 j=i+1

for i = 1, 2, ..., n. The SOR method is very similar to the Guass-Seidel method except for the fact
that it employs a relaxation factor, ω, to achieve faster convergence.
i−1 n
ω X X
xk+1
i = (1 − ω)xki + (bi − aij xk+1
j − aij xkj ) (9)
aii j=1 j=i+1

for i = 1, 2, ..., n, and 0 < ω < 2. In all three cases, iterations are performed until the difference
between iterations reaches a specified tolerance. By definition of these iterative methods, we
predict that the SOR method will converge most rapidly while the Jacobian method will converge
least rapidly.

2.3 Heat Transfer


There is an internal heat generation of q̇ = 5 · 107 [W/m3 ]. The total heat generated per unit length
is given by:
0
qgen = q̇Ac (10)
Where Ac is the total cross-sectional area, given by a summation of the two arc segments:
1 2 1
Ac = R1 θ1 + R22 θ2
2 2
1 1
Ac = (0.007)2 (0.43633) + (0.010)2 (0.78540) = 4.996 · 10−5 (11)
2 2
Then from Equations 10 and 11:
0
qgen = (5 · 107 )(4.996 · 10−5 ) ≈ 2500[W/m] (12)
From the First Law of Thermodynamics, the internal heat generated should be equal in magnitude
to the total heat flux across the Dirichlet boundaries, namely:

˙ = Eout
Egen ˙ (13)
This energy balance will be verified in the MATLAB script to ensure that our system satisfies the
First Law. Results are given in Section 3.4.

3
3 Results
3.1 Temperature Distribution
A contour plot of the steady-state temperature distribution in the rod is shown in Figure 2.

Figure 2: Steady-State Temperature Distribution in the Rod

This temperature distribution was solved for using an initial temperature guess of zero for all
unknown nodes and a tolerance of tol = 1e − 004. Thus, the solution is reached at the first
iteration where the residual satisfies:

E < 1e − 004 (14)


Note that, in general, the temperature distribution will be the same regardless of which method is
used. However, the number of iterations associated with reaching this tolerance is highly
dependent on the method used, as will be discussed in the following section.

3.2 Method Trends


This section will discuss the effects that the varying finite difference methods have on convergence
rate. This study used a constant step size of dr = dt = 1. For the SOR method, a relaxation factor
of ω = 1.94 was used. This optimum value was determined via a ”guess-and-check” method, where
ω was altered until the number of iterations was minimized. Note that the optimum value of ω will
change based on the step size. A table summarizing convergence rates for each type of method is
shown on the following page.

4
Method Iterations, N Residual, E Solution Time [s]
Jacobian 15854 9.999313e-05 18.40
Gauss-Seidel 8594 9.994095e-05 10.42
SOR 279 4.456120e-05 0.91

Table 1: Convergence Rate of Finite Difference Methods

Table 1 indicates that, in regards to convergence rate, SOR peforms most effectively and Jacobian
method performs least effectively, which verifies the prediction made in Section 2.2. Figure 3 shows
a semi-log plot of residual error versus the first 500 iterations . We see that, at first, there is a
larger residual associated with the SOR method. However, while the slope of the Jacobian and
Gauss-Seidel methods plateau, the slope of the SOR method remains steep. This indicates
favorable convergence times for the SOR method. I.e., the reduction in residual error per iteration
of the SOR method remains relatively high compared to that of the Jacobian and Gauss-Seidel
methods. Note that, in general, we are satisfied with the results portrayed in Figure 3. The plot
verifies that as the number of iterations increases, the residual error decreases.

Figure 3: Residual Error vs. Number of Iterations; N = 0:500

3.3 Mesh Dependence


Having proved that the residual error decreases as the number of iterations increases, we would
next like to pick a set number of iterations and examine how the residual behaves with decreasing
mesh size (more elements used). For this study, only the Jacobian and Gauss-Seidel methods will
be examined, since the relaxation factor associated with the SOR method is dependent upon the
mesh grid size. If the SOR method was to be examined, an optimum relaxtion factor would have
to be calculated for each mesh size. A set number of iterations, namely N = 100, was used for this
study. The mesh grid size was halved until a mesh grid size factor, β, of 16 was achieved. For

5
equal step sizes in the radial and angular directions (which is assumed for this study), this factor is
given by Equation 15:
1 1 1
β= = = (15)
dr dt h
Thus, the smallest step size used was dr = dt = 0.0625. A semi-log plot of the normalized residual
error (residual divided by the total number of grid points) versus mesh grid size factor is shown in
Figure 4.

Figure 4: Residual Error vs. Mesh Grid Size Factor

Figure 4 shows that as the mesh grid size is decreased (more elements used), the relative residual
error decreases. Thus, a smaller grid size implies less error associated with the solution. However,
decreased mesh size leads to significantly longer run-times, so, in practical settings, there must be
some balance between the two. The ”true” ideal mesh grid size occurs when round-off error meets
truncation error in a graph of error versus grid resolution. At this point, maximum error will be at
a minimum while achieving the most effective run-time.

3.4 Heat Transfer


To verify the accuracy of our solution, it suffices to show that the magnitude of internal heat
generation (per unit length) is equal to the magnitude of the heat flux across the Dirichlet
boundaries. By doing so, we are verifying that our system satisfies the First Law of
Thermodynamics (Section 2.3). Recall that the magnitude of the internal heat generation, given
by Equation 12, is:
0
qgen ≈ 2500[W/m]
The corresponding code used to calculate the total heat flux is given in the Appendix, Section 5.1,
lines 230-270. Note that due to roundoff/truncation errors when calculating the temperature

6
matrix values, the total heat flux may vary between different methods. However, we do not expect
these variations to be considerable. The SOR method was used for this study since it has a
favorable convergence rate and since the converged temperature matrix does not depend on the
relaxation factor. Using the SOR method with initial step size dr = dt = 1 and ω = 1.94, we
calculate a total heat flux (heat loss) of:

q 0 = 1050[W/m]
This is nearly a 58% error with the anticipated heat generation. Having ensured that the code is
correctly calculating the heat flux across the boundaries, we next hypothesize that the grid aspect
ratio is the cause of the high error. I.e., since heat is only leaving through the cold boundary, it is
necessary to have a sufficient amount of nodes in the radial direction. Employing a radial step size
of dr = 0.5 and an angular step size of dt = 1, we find that:

q 0 = 2098[W/m]
which maintains only a 16.08% error with the calculated heat generation term. A table
summarizing different mesh grid sizes and their corresponding percent errors is shown in Table 2.

Method dr dt Heat Flux [W/m] Percent Error


SOR 1 1 1050 58.00
SOR 0.5 1 2098 16.08
SOR 0.25 1 2908 16.32
SOR 0.25 0.5 -1427 157.08
SOR 0.125 0.5 -1304 152.16
SOR 0.0625 0.5 -1232 149.28

Table 2: Mesh Grid Sizes and their Corresponding Heat Flux

At dr = 0.5 and dt = 1, the aspect ratio is well defined such that there is more heat leaving the
cold boundary than is entering the system from the hot boundaries. Decreasing the grid size in the
radial direction any further (dr = 0.25, dt = 1) allows too much net heat to leave, and decreasing
the grid size in the angular direction would only result in a lower net heat loss (more heat flux over
the hot boundaries). Furthermore, if we significantly decrease the mesh size in the radial direction,
the inward heat flux across the hot boundary over a radius of r = 1 : 10 [mm] will overcome the
outward heat flux across the cold boundary. Thus, we conclude that this problem is somewhat
ill-posed, based on the boundary conditions. The optimum grid size in terms of satisfying the First
Law of Thermodynamics is dr = 0.5 and dt = 1, yielding a total heat flux of

q 0 = 2098[W/m] (16)
with an associated percent error of:
2500 − 2098
Error = · 100 = 16.08% (17)
2500

7
4 Conclusion
In this report, the finite difference method was used to solve for the steady-state temperature
distribution in a pipe whose cross-section is shown in Figure 1. Three different iterative schemes
were used, including the Jacobian, Gauss-Seidel, and Successive Over-Relaxation (SOR) methods.
The temperature distribution was solved through the use of MATLAB, and the contour plot of the
steady-state temperature distribution adhering to a tolerance of tol = 1e − 004 is shown in Figure
2. Some of the key findings obtained through this report are as follows:
0
• Total heat transfer per unit length from the rod is qgen ≈ 2500[W/m]

• SOR method performs most favorably in terms of convergence rate, while Jacobian perfroms
least favorably
– SOR performs the fewest number of iterations to achieve convergence, with the shortest
run-time
– Jacobian performs the largest number of iterations to achieve convergence, with the
longest run-time
• Residual Error is a function of the number of iterations performed and the mesh grid size
– Residual Error decreases as number of iterations increases (Figure 3)
– Relative Residual Error decreases as mesh grid size is refined (Figure 4)

• Total heat flux is dependent upon the mesh grid size


– Optimum step sizes, in terms of satisfying the First Law of Thermodynamics, are
dr = 0.5 and dt = 1 (Table 2)

Overall, we are satisfied with the results, and have implemented the finite difference method along
with three different iterative solver schemes to solve a steady-state heat transfer problem.

8
5 Appendix
5.1 SOR Method MATLAB Code

9
10
11
12
13
14
15

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy