You are on page 1of 3

Appendix A

Numerical solution to heat


equation

The heat equation is a PDE which describes the change in temperature in a given
spatial domain over time. In general form the heat equation is defined as (Widder,
1976):

∂T
= D∇2 T (A.1)
∂t
which in three spatial dimensions can be written as:
 2
∂ 2T ∂ 2T

∂T ∂ T
=D + + 2 (A.2)
∂t ∂x2 ∂y 2 ∂z

where x, y and z [m] are the spatial coordinates. The three-dimensional heat equation
can be discretised as (Ames, 1977):
"   new
T new − T T−x − 2T new + T+x
new

T−x − 2T + T+x
=D + (A.3)
∆t 2∆x2 2∆x2
  new
T−y − 2T new + T+y
new 

T−y − 2T + T+y
+ +
2∆y 2 2∆y 2
  new #
T−z − 2T new + T+z
new

T−z − 2T + T+z
+ +
2∆z 2 2∆z 2

where T and T new [K/◦ C] are the current and new temperatures respectively; ∆t [s]
is the temporal resolution; ∆x, ∆y and ∆z [m] are the spatial resolutions; and the
subscripts −x, −y, −z, +x, +y, +z refer to one positive or negative step in each
spatial direction with respect to the location of T and T new .
In this form, the three-dimensional heat equation has a total of seven unknown
new temperature values for every location of T (two in each spatial direction plus

137
the central point). The equation could potentially be solved in this form using the
Crank-Nicolson (CN) method (Crank and Nicolson, 1947), which combines explicit
and implicit form of the right-hand side and is unconditionally stable. CN method
works well with one-dimensional heat equations which can be solved in the tridiagonal
matrix form. However, in three dimensions, this would result in a sparse matrix with
seven diagonal matrix bands, which is computationally heavy to solve. This prob-
lem can be overcome by using so-called alternating direction implicit (ADI) method
(Ames, 1977) which applies the CN method one direction at a time using two inter-
mediate temperature fields T ∗ and T ∗∗ before obtaining the new temperature field
T new .
By applying the ADI method first in x-direction the equation (A.3) becomes:
r
z }|1 { "   ∗ #
∗ ∗
D∆t T−x − 2T + T+x T−x − 2T + T+x
T∗ − T = + (A.4)
∆x2 2 2
D∆t D∆t
+ 2
(T−y − 2T + T+y ) + 2
(T−z − 2T + T+z )
∆y |∆z
{z }
| {z }
r2 r3

By sorting the new and current temperatures on the left and right sides, respectively,
the equation can then be written as:
r1 ∗ r1 ∗ r1 r1
− T−x + (1 + r1 )T ∗ − T+x = T−x + T+x + r2 T−y + r2 T+y (A.5)
2 2 2 2
+ r3 T−z + r3 T+z + (1 − r1 − 2r2 − 2r3 )T


Now, on the left hand side, there are three unknown temperature values T−x , T∗

and T+x while the right hand side is known. Solving the equation over the whole
spatial domain results in a tridiagonal matrix. This can be efficiently done by using a
tridiagonal matrix algorithm, such as the Thomas algorithm (Ames, 1977), to obtain

the unknown intermediate temperature values T−x , T ∗ and T+x

for every x, y and z.
Next, by applying ADI method in y-direction, the equation (A.3) becomes:
"   ∗ #
∗ ∗
T−x − 2T + T+x T−x − 2T + T +x
T ∗∗ − T = r1 + (A.6)
2 2
"   ∗∗ #
T−y − 2T + T+y T−y − 2T ∗∗ + T+y
∗∗ 
+ r2 +
2 2
+ r3 (T−z − 2T + T+z )

138
which again can be sorted by placing the unknown temperature values on the left and
the known values on the right:
r2 ∗∗ r2 ∗∗ r1 r1 r1 ∗ r1 ∗
− T−y + (1 + r2 )T ∗∗ − T+y = T−x + T+x + T−x + T+x (A.7)
2 2 2 2 2 2
r2 r2
+ T−y + T+y + r3 T−z + r3 T+z
2 2
+ (1 − r1 − r2 − 2r3 )T − r1 T ∗

∗∗
This can again be solved using the tridiagonal matrix algorithm to obtain T−y , T ∗∗
∗∗
and T+y for every x, y and z. Finally, the z-direction values can be solved to obtain
the new temperature field as:
"   ∗ #
∗ ∗
T−x − 2T + T+x T−x − 2T + T+x
T new − T = r1 + (A.8)
2 2
"   ∗∗ #
T−y − 2T + T+y T−y − 2T ∗∗ + T+y
∗∗ 
+ r2 +
2 2
"   new #
T−z − 2T + T+z T−z − 2T new + T+z new
+ r3 +
2 2

which can be expressed as:


r3 new r3 new r1 r1 r1 ∗ r1 ∗
− T−z + (1 + r3 )T new − T+z = T−x + T+x + T−x + T+x (A.9)
2 2 2 2 2 2
r2 r2 r2 ∗∗ r2 ∗∗
+ T−y + T+y + T−y + T+y
2 2 2 2
r3 r3
+ T−z + T+z + (1 − r1 − r2 − r3 )T
2 2
− r1 T − r2 T ∗∗

new
Solving this equation for every x, y and z gives the new temperature values T−z , T new
new
and T+z over the whole spatial domain. All three iterations for x-, y- and z-directions
above have to done for each time step. However, because the solution is uncondition-
ally stable, the time step can be much larger than it would be in the explicit case.
 
The errors of ADI solution are in the order of O (∆t)2 and O (max[∆x, ∆y, ∆z])2 ,
which gives it an advantage over the explicit methods, whose errors are typically

O(∆t) and O (max[∆x, ∆y, ∆z])2 .

139

You might also like