Finite Difference Method: Applied To A Two-Dimensional, Steady-State, Heat Transfer Problem
Finite Difference Method: Applied To A Two-Dimensional, Steady-State, Heat Transfer Problem
Finite Difference Method: Applied To A Two-Dimensional, Steady-State, Heat Transfer Problem
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:
• 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:
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:
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
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
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.
˙ = 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.
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:
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 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.
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 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.
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.
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)
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