Iii PDF

You might also like

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

MODEL 3

Heat Transfer in Circular Pipes

Mathematical Aspect:

Numerical solution of PDEs: initial value problems

Heat transfer in pipes


Consider laminar, developed flow in a pipe of radius R. The fluid is at a uniform temperature
T0 for z<0 (Figure 1) and, at z=0, it enters a region at which the temperature of the wall changes
to Tw≠T0. We would like to study how the temperature of the fluid evolves with z. To analyze
this problem, we will consider that the process is at steady state, that viscous dissipation is
negligible, and that physical properties of the fluid are uniform. In addition, we will assume that
the temperature field is symmetric in the angular direction of a cylindrical coordinate system, so
that we seek a solution for the temperature field of the form T=T(r,z).

Figure 1. A fluid flowing at uniform temperature T0 encounters a sudden change in wall


temperature to a value Tw at z=0.

First, consider the expected shape for the radial temperature profiles along the pipe for the
case Tw>T0 (Figure 2). The profile starts uniform at z=0 (1), but the wall temperature increases
suddenly. At short distances (2), the fluid at the core still will be at T0, but sharp temperature
gradients occur near the wall. Further downstream (3), even the fluid at the center of the pipe
will start to heat up and the temperature profile will span the whole cross section of the pipe. At
long distances (4), the temperature will tend to approach the wall temperature everywhere.

Figure 2. Evolution of radial temperature profiles along a pipe (see text for explanation).
1

For steady, incompressible, developed flow, the only nonzero component of the velocity
vector is

 r2 
v z = 2 < v z > 1 −  (1)
 R2 

where <vz> is the cross-sectional averaged velocity (related to the volumetric flow rate by
<vz>=Q/πR2).
Under the conditions listed, the thermal energy equation in cylindrical coordinates simplifies
to

∂T 1 ∂  ∂T  ∂ 2 T 
ρc p v z = k r +  (2)
∂z  r ∂r  ∂r  ∂z 2 

where ρ and cp are density and constant-pressure heat capacity, respectively, and k is the fluid's
thermal conductivity.
The boundary conditions are:
(1) It will be assumed that the fluid reaches the section at which the wall temperature changes
(z=0) with uniform temperature:

T=T0, z=0 (3)

(2) For z>0

T=Tw, r=R (4)

(3) The temperature is symmetric around the pipe axis:

∂T
= 0 , r=0 (5)
∂r

Each term in the PDE (2) can be identified with an energy transport mechanism: the term on
the left-hand side represents the axial (z) transport of thermal energy by convection; the first
term on the right-hand side represents heat conduction in the radial direction (note that this
mechanism will be directly responsible for the temperature change in the fluid, since it will
account for the heat exchange between the fluid and the wall); and the last term represents axial
heat conduction.
The relative magnitude of the two transport mechanisms in the axial direction can be
compared by performing an order of magnitude analysis. Let L be a characteristic length in the z
direction over which significant temperature changes (∆T) occur. We can state

∂T  ∆T 
ρc p v z = O ρc p < v z >  (6)
∂z  L 
2

∂ 2T  ∆T 
k = O k  (7)
∂z 2  L2 

We will explore the conditions for which convection dominates over conduction in the axial
direction. This will happen when

∆T ∆T
ρc p < v z > »k (8)
L L2

Simplifying and rearranging leads to

ρc p < v z > L
» 1 , convection dominates over conduction in z (9)
k

The dimensionless number that appears in this constraint compares the relative magnitude of
convection and diffusion in the axial direction. In general, L is not known, so a dimensionless
number is defined using the pipe diameter (known) as characteristic length. This dimensionless
number is called the Péclet number:

ρc p < v z > 2 R < v z > 2 R


Pe = = (10)
k α

where α=k/ρcp is the thermal dispersivity.


The constraint (10) can be expressed as

L
Pe »1 (11)
2R

If this constraint is satisfied, we can neglect axial conduction in the thermal energy equation.
This is the most interesting problem from the point of view of convection, since fluid motion is
responsible for energy transport along the pipe. We will consider in our solution that constraint
(11) is satisfied. The thermal energy equation (2) combined with the velocity profile (1)
simplifies to

 r 2  ∂T α ∂  ∂T 
2 < v z > 1 −  = r  (12)
 R 2  ∂z r ∂r  ∂r 

Note that the absence of the axial conduction term has transformed this equation into a first order
differential equation in z. Consequently, only one boundary condition is needed in z (equation 3).
The problem to solve consists of the partial differential equation (12) subject to boundary
conditions (3) to (5). To reduce the number of parameters in the formulation, we will express the
problem in dimensionless form. Dimensionless temperature and radial coordinate are defined by
3

T − T0
Θ= (13)
Tw − T0

r
η= (14)
R

Substituting into equation (12) we get, after manipulations and use of equation (10)

∂Θ 1 ∂  ∂Θ 
PeR (1 − η2 ) = η  (15)
∂z η ∂η  ∂η 

To eliminate all parameters from the PDE, we select the following dimensionless axial distance

z
ξ= (16)
PeR

to get

(1 − η2 ) ∂∂Θξ = η1 ∂∂η  η ∂∂Θη  (17)


 

The boundary conditions (3) to (5) transform to

Θ=0, ξ=0 (18)

∂Θ
= 0 , η=0 (19)
∂η

Θ=1, η=1 (20)

If a solution for this problem is attempted using separation of variables, the problem in the η
direction (Sturm-Liouville problem) does not have a known analytical solution. What
complicates the formulation is the variable coefficient (1-η2) in the PDE (17). Hence, a solution
to this problem should be found numerically.
Numerical algorithms used to solve PDEs are strongly influenced by the type of differential
equation; specifically, the order of the derivatives with respect to the independent variables
might affect the type of algorithm to be used. The present problem is a boundary-value problem
with respect to η, since the PDE contains second order derivatives of the dependent variable with
respect to η, and the two boundary conditions (equations 19 and 20) are imposed on two
different (extreme) points of the domain. However, the problem is an initial-value problem with
respect to ξ, since only first derivatives with respect to this variable are present in the PDE.
Initial-value problems (IVPs) are typically easier to treat than boundary-value problems so that
the IVP nature of the present problem will be the most important characteristic in establishing
4

the numerical method to be used. The approach used here to find a numerical solution for the
problem will be based on the general context of finite differences.

Introduction to finite difference discretization for PDEs


The method of finite differences is based on defining a certain number of points in the domain
(called nodes or discretization points) that, taken together, form a discretization mesh or grid.
After these points have been defined, the following steps are applied:
(1) The derivatives that appear in the PDE are expressed in terms of values of the dependent
variable at discretization points using approximate relations derived from truncated Taylor
series.
(2) The differential equation is evaluated at the discretization points, substituting the
derivatives by the expressions mentioned in (1). This leads to a system of equations having as
many equations as there are discretization points.
(3) The boundary conditions are used to represent boundary nodes.
(4) The system of equations is solved to find approximate values of the dependent variable at
all discretization points.
The method of finite differences was used in Model 1 to solve ODEs. We will start our
analysis following some of the derivations presented before. First, consider a function of a single
variable y=y(x) and a discretization of the independent variable in an interval a≤x≤b formed by
equidistant points defined by

x i = a + ih (21)

where

b−a
h= (22)
N +1

This scheme defines N+1 intervals and N+2 discretization points, with x0=a, xN+1=b, and N
interior points.
To find an expression to approximate the first derivative of y at point xi, consider a third-order
Taylor series for y(x) around x=xi:

1
y( x ) = y( x i ) + y' ( x i )( x − x i ) + y" ( x i )( x − x i ) 2 +
2
(23)
1 1
y' ' ' ( x i )( x − x i )3 + y iv (ζ )( x − x i ) 4
3! 4!

where ζ is between xi and x. If we evaluate this equation at x=xi+1 and recall that h= xi+1−xi, we
get

1 1 1
y( x i +1 ) = y( x i ) + y' ( x i )h + y" ( x i )h 2 + y' ' ' ( x i )h 3 + y iv (ζ i )h 4 (24)
2 3! 4!

with xi≤ζi≤xi+1. We can solve this equation for the first derivative to obtain
5

y( x i +1 ) − y( x i ) h h2 h 3 iv
y' ( x i ) = − y" ( x i ) − y' ' ' ( x i ) − y (ζ ) (25)
h 2 3! 4!

The first of the last three terms of this equation is dominant for small h, so that this equation can
be written as

y( x i +1 ) − y( x i )
y' ( x i ) = + O( h ) (26)
h

Truncation of this equation leads to an approximation of the first derivative:

y( x i +1 ) − y( x i )
y' ( x i ) ≈ (27)
h

This is a first-order forward difference formula, because the derivative at a point depends on the
value of the dependent variable at that point and at the next point.
To approximate the second derivative, we can see that equation (24) will not be enough due to
the presence of the first derivative. Therefore, we need an additional equation, which will be
equation (23) evaluated at x=xi-1=xi−h:

1 1 1
y( x i −1 ) = y( x i ) − y' ( x i )h + y" ( x i )h 2 − y' ' ' ( x i )h 3 + y iv (ζ i −1 )h 4 (28)
2 3! 4!

with xi−1≤ζi−1≤xi. Addition of equations (24) and (28) eliminates the first and third derivatives.
Solving the resulting equation for the second derivative yields

y( x i +1 ) − 2 y( x i ) + y( x i −1 ) 2 iv
y" ( x i ) = − [ y (ζ i +1 ) + y iv (ζ i −1 )]h 2 (29)
h2 4!

or

y( x i +1 ) − 2 y( x i ) + y( x i −1 )
y" ( x i ) = + O( h 2 ) (30)
h2

Truncation of this equation leads to an approximation of the second derivative:

y( x i +1 ) − 2 y( x i ) + y( x i −1 )
y" ( x i ) ≈ (31)
h2

This is a second-order centered difference formula for the second derivative, since it contains
values of the dependent variable in the two adjacent points to the point where the derivative is
evaluated.
A centered difference formula can be obtained for the first derivative too. To do this, we
subtract equation (28) from equation (24) so that the second derivative is eliminated. The result
6

is

y( x i +1 ) − y( x i −1 ) h 2 h3
y' ( x i ) = + y' ' ' ( x i ) + [ y iv (ζ i −1 ) − y iv (ζ i +1 )] (32)
2h 3! 2 × 4!

or

y( x i +1 ) − y( x i −1 )
y' ( x i ) = + O( h 2 ) (33)
2h

So that the centered-difference formula

y( x i +1 ) − y( x i −1 )
y' ( x i ) ≈ (34)
2h

has a truncation error of O(h2).


An alternative formula for the first derivative can be obtained directly from equation (28):

y( x i ) − y( x i −1 )
y' ( x i ) = + O( h ) (35)
h

which leads to the approximation

y( x i ) − y( x i −1 )
y' ( x i ) ≈ (36)
h

This is the first-order backward difference formula for the first derivative.
The formulas derived in this section will be used in the finite-difference discretization of the
problem given by equations (17) to (20). First, we will look at a scheme that is based on the
forward-difference formula (27) for the first derivative.

The forward-difference method


The domain in which the PDE (17) will be solved is 0≤η≤1, 0≤ξ. Since the domain in ξ has
no defined limit, we will pick a step size h in ξ that defines unlimited discretization points of the
form

ξi = ih , i=0,1,2… (37)

On the other hand, in the η direction we will use a step size g, given by (see equation 22)

1
g= (38)
N +1

so that discretization points in this direction are defined by


7

η j = gj , j=0,1,2…N+1 (39)

A discretization point in the grid thus created is given by the coordinates (ηj,ξi). The
discretization grid is shown in Figure 3.

Figure 3. Example of a finite difference discretization grid for the problem of heat transfer in a
pipe with N=3. Nodes for which j=0 (pipe center), j=N+1 (pipe wall) and i=0 (ξ=0) are boundary
nodes. The rest are interior nodes.

To discretize the differential equation, we need approximate expressions for derivatives with
respect to ξ and η. First, consider the first derivative with respect to ξ. To approximate it, we use
the forward-difference formula (27):

∂Θ Θ
ˆ (ξ i +1 , η j ) − Θ
ˆ (ξ i , η j )
(ξ i , η j ) ≈ (40)
∂ξ h

where we have evaluated the derivative at a fixed radial position ηj. From now on, to designate
the approximate nodal values of the dimensionless temperature, we will use the following
simplified notation:

Θ
ˆ (ξ i , η j ) = Θ
ˆ i, j (41)
8

Equation (40) can be expressed as

∂Θ Θ
ˆ i +1, j − Θ
ˆ i, j
(ξ i , η j ) ≈ (42)
∂ξ h

To discretize the right-hand side of the differential equation (17), first we expand the
derivative,

1 ∂  ∂Θ  1 ∂Θ ∂ 2 Θ
η = + (43)
η ∂η  ∂η  η ∂η ∂η2

The second derivative is approximated by the centered-difference formula (31):

∂ 2Θ Θ
ˆ i, j+1 − 2Θ
ˆ i, j + Θ
ˆ i, j−1
(ξ i , η j ) ≈ (44)
∂η2 g2

Since this formula has a truncation error of O(g2), we will use the centered-difference formula
(34) to approximate the first derivative in equation (43), to keep the same level of error in all
approximations,

∂Θ Θ
ˆ i, j+1 − Θ
ˆ i, j−1
(ξ i , η j ) ≈ (45)
∂η 2g

Now we use all these results (equations 42 to 45) into the evaluation of PDE (17) at a nodal point
(ξi , η j ) to get


ˆ i +1, j − Θ
ˆ i, j ) 1 Θˆ i, j+1 − Θ
ˆ i, j−1 Θˆ i, j+1 − 2Θ
ˆ i, j + Θ
ˆ i, j−1
(1 − η2j ) = + (46)
h ηj 2g g2

Note that all the values of the dependent variable in this equation except one are evaluated at ξi.
This means that this equation can be used to calculate the dimensionless temperature at ξi+1 from
values at the previous step in axial position, ξi, which leads to an explicit numerical scheme
similar to Euler's method, as seen in Model 1. Now we solve equation (46) for Θ ˆ i +1, j to get

h 1   
Θ
ˆ i +1, j =  + 1 Θ ˆ i, j+1 + 1 − 2h
Θˆ i, j
2 
g (1 − η j )  g 2 η 
j  g (1 − η j ) 
2 2
  , i=0,1…, j=1 to N (47)
h 1 
+  − 1 Θ ˆ i, j−1
g (1 − η2j )  g 2η j 
9

This equation applies to interior nodes only. Boundary nodes are governed by the discretized
form of the boundary conditions. Consider first boundary condition (20). This is the only non-
homogeneous condition and it will be, therefore, the condition that generates a non-trivial
temperature profile. Application of this boundary condition yields

Θ
ˆ i, N +1 = 1 , i=0,1,2… (48)

(note that ηN+1=1.) The other boundary condition in the radial direction (equation 19) specifies a
value for a radial derivative. We will use the forward-difference formula (27) to approximate the
derivative to get

∂Θ Θ
ˆ i,1 − Θ
ˆ i, 0
≈ (49)
∂η η= 0 g

so that boundary condition (19) yields

Θ
ˆ i ,0 = Θ
ˆ i,1 , i=0,1,2… (50)

Finally, boundary condition (18) leads to

Θ
ˆ 0, j = 0 , j=1 to N (51)

An algorithm used to solve the problem with the equations stated above can be formulated as
follows:

(1) The calculation starts at ξ=0 (i=0), imposing:


Boundary condition (51).
Boundary condition (48) for i=0.
At this point, all values of the dependent variable are known at the line of nodes i=0 (Figure 3).
(2) For each line of nodes i, apply the following equations sequentially until the desired final
value for the ξ coordinate is reached:
Equation (47), starting at i=0.
Equation (48).
Equation (50).

When this algorithm was applied to solve the problem, it was found that, for certain values of g,
unphysical oscillatory solutions were obtained unless h was small enough. For example, Figure 4
shows how a clearly unstable (oscillatory) solution is obtained for h=0.000202 at η=0.75 while a
stable solution is found for a slightly lower value h=0.000200. It should be pointed out that
unstable profiles are found for the latter h at other values of η. An interesting aspect of the
solution is that once h is low enough that the solution becomes stable, further reductions in h do
not change the solution appreciably, which indicates that the exact solution has been found
within the scale of the plot in Figure 4.
10

1
Θ
0.9 η=0.75
g=0.05
0.8
0.7
0.6
0.5 h=0.000202
0.4
h=0.000200
0.3
0.2
0.1
0
0 0.01 0.02 0.03 0.04 0.05 0.06
ξ
Figure 4. Calculated axial dimensionless temperature profile at η=0.75 for two values of h.
Further reduction of h below 0.000200 yields the same solution at the scale of the figure.

Figure 5 shows calculated radial temperature profiles for relatively low values of ξ. Note that,
as seen in Figure 4, the centerline temperature (ξ=0) will continue to increase until the
asymptotic profile Θ≡1 for all η is obtained as ξ→∞ (eventually the fluid will reach the wall
temperature.)
Another important physical parameter of this problem is the heat flux at the wall, since the
surroundings must provide the thermal energy necessary to keep the wall temperature uniform
(that is, if the wall is hotter than the fluid.) The heat flux in the radial direction us given by
Fourier's law,

∂T
q r = −k (52)
∂r

To express this equation in dimensionless form, we make use of equations (13) and (14) to get

Rq r ∂Θ
− = (53)
k (Tw − T0 ) ∂η

The left-hand side of this equation is a dimensionless heat flux. Let the value of this quantity at
r=R be
11

Rqr r=R
σ=− (54)
k (Tw − T0 )

1
Θ
0.9 g=0.05
h=0.0001
0.8
0.7
0.6
0.5
0.05
0.4
ξ=0.01
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
η
Figure 5. Calculated radial dimensionless temperature profiles for various axial positions.
Curves are shown at 0.01 intervals in ξ. Lower values of h would give the same solution at the
scale of the plot. Note how the profiles progressively penetrate into the fluid until the centerline
temperature (η=0) starts to rise.

Then, from equation (53) we have

∂Θ
σ= (55)
∂η η =1

After the numerical solution for the dimensionless temperature has been found, this
dimensionless heat flux can be calculated by approximating the derivative using the backward
difference formula (36), which yields

Θ
ˆ i, N +1 − Θ
ˆ i, N 1− Θ
ˆ i, N
σˆ i = = (56)
g g

Note that the Nth node is adjacent to the pipe wall (ηN=1−g). Figure 6 shows the dimensionless
heat flux at the wall calculated from this equation using the numerical solution. Note that the flux
12

decreases as ξ increases due to the reduction in heat transfer driving force as the temperature of
the fluid warms up. The flux will asymptotically approach zero as ξ→∞ and the temperature of
the fluid becomes uniform and equal to the wall temperature.

14
σ
12 h=0.0001
g=0.05

10

0
0 0.005 0.01 0.015 0.02 0.025
ξ
Figure 6. Dimensionless heat flux at the wall as a function of axial position.

We have shown how the forward-difference method can be used to find a numerical solution
of a PDE that forms an IVP with respect to one of the independent variables (ξ in this case.)
However, the instability of the solution requires relatively low values of h to be used to find a
meaningful solution, which involves a relatively high computational effort. Important questions
at this point would be how to find out if a specific algorithm may be unstable and how to
formulate an algorithm to reduce or eliminate the instability problem. These issues will be
addressed in the following sections.

Stability analysis
The instability observed in the solution presented above is typical of the forward-difference
method and other explicit methods. Here we will explore how to determine if a method might
lead to unstable solutions taking the forward-difference method as a working example. We will
start with the most important equation of the algorithm (equation 47), which can be rewritten as
follows

Θ
ˆ i +1, j = A jΘ
ˆ i, j+1 + B jΘ
ˆ i, j + C jΘ
ˆ i, j−1 (57)

where A, B and C are constants for a given j (note that they depend on ηj.)
13

Now, suppose that in the calculation of Θ̂ i, j we have incurred in an error with absolute value
δ, constant for all j, so that, instead of calculating Θ̂ i, j , we have calculated an erroneous value
~
Θi, j (here, we will purposely leave out the cause of the calculation error.) This means that

~
Θ
ˆ i, j − Θ i, j = δ , for all j (58)

Consequently, when we apply equation (57) to determine Θ


ˆ i +1, j , we will calculate erroneous
values by doing
~ ~ ~ ~
Θi +1, j = A jΘ i, j+1 + B jΘi, j + C jΘ i, j−1 (59)

since the values at the previous step i are already erroneous. Subtracting equation (57) (which
would involve the correct values for dimensionless temperature) from this equation yields
~ ~ ~ ~
Θi +1, j − Θ
ˆ i +1, j = A j (Θ i, j+1 − Θ i, j+1 ) + B j (Θ i, j − Θ i, j ) + C j (Θ i, j−1 − Θ i, j−1 )
ˆ ˆ ˆ (60)

Now we take the absolute value of this equation and make use of the identities

a+b+c ≤ a + b + c (61)

ab = a b (62)

to write equation (60) as follows

~ ~ ~ ~
Θi +1, j − Θ
ˆ i +1, j ≤ A j Θ i, j+1 − Θ i, j +1 + B j Θ i, j − Θ i, j + C j Θ i, j−1 − Θ i, j−1
ˆ ˆ ˆ (63)

Using equation (58) we get

~
Θi +1, j − Θ
ˆ i +1, j ≤ ( A j + B j + C j )δ (64)

This equation gives an upper bound for the error that would be made in step i+1 in terms of the
error δ introduced in step i. We can see that, if A j + B j + C j ≤ 1 , the error at step i+1 will be at
most δ, so that successive calculations will either keep the error the same or will decrease it. On
the other hand, if A j + B j + C j > 1 , it is possible that the error will grow with successive
calculation steps. This could be a cause for instability since calculation errors are always present
(e.g. round off), and they can grow uncontrollably. In conclusion, we can say that the method
will be stable if
14

A j + B j + C j ≤ 1 , stability criterion (65)

It is said that the forward-difference method for the PDE studied here is conditionally stable,
since equation (65) represents a sufficient condition for stability. Let us explore this condition in
detail. First, comparing equations (47) and (57) we see that

h 1 
Aj =  + 1  (66)
g (1 − η2j )  g 2η j 

2h
B j = 1− (67)
g 2 (1 − η2j )

h 1 
Cj =  − 1  (68)
g (1 − η2j )  g 2η j 

We can see that Aj and Cj are always positive. Regarding Cj, note that 1/g>1/2ηj always, since
the minimum value that ηj can have is ηj=g for interior nodes. This means that A j =Aj, C j =Cj.
Using these facts and substituting equations (66) to (68) into equation (65) leads to, after
rearrangement,

2h 2h
1− ≤ 1− , stability criterion (69)
g 2 (1 − η2j ) g 2 (1 − η2j )

The absolute value of a number can never be less than the number itself. This means that
equation (69) can only be satisfied by the equality. The fact that a number is equal to its absolute
value means that the number is positive or zero. We then conclude that equation (69) is satisfied
only if

2h
0 ≤ 1− , stability criterion (70)
g 2 (1 − η2j )

Since this equation should be valid for any value of ηj, we will consider the least favorable case,
which corresponds to the value of ηj closest to 1 for an interior node, which is ηN =1-g (Figure
3). This turns equation (70) into

2h
0 ≤ 1− , stability criterion (71)
g 2 [1 − (1 − g ) 2 ]

which leads to
15

2h
0 ≤ 1− , stability criterion (72)
g 3 (2 − g)

Since we expect that g«2 (desirable to find a solution close to the exact solution), we can make
the approximation 2 − g ≈ 2 , and equation (72) becomes, after manipulations,

h ≤ g 3 , stability criterion (73)

For example, for the results presented in Figures 4 to 6, for g=0.05, equation (73) states that the
solution is stable if h≤0.000125, which is consistent with the results presented.
Next, we explore a numerical method that is always stable for the problem under
consideration.

The backward-difference method


In this method, we approximate the first derivative with respect to ξ in equation (17) by using
the backward-difference formula (36):

∂Θ Θ
ˆ i, j − Θ
ˆ i −1, j
(ξ i , η j ) ≈ (74)
∂ξ h

The derivatives on the right-hand side of equation (17) will be once again represented by the
centered formulas (44) and (45). This leads to the following discretized form of the PDE:


ˆ i, j − Θ
ˆ i −1, j ) 1 Θˆ i, j+1 − Θ
ˆ i, j−1 Θˆ i, j+1 − 2Θ
ˆ i, j + Θ
ˆ i, j−1
(1 − η2j ) = + (75)
h ηj 2g g2

The main difference of this equation with the forward-difference method is that this equation
cannot be applied to explicitly calculate the dimensionless temperature in a step-by-step manner,
since the equation contains 3 different values of temperature at step i ( Θ ˆ i, j , Θ
ˆ i, j+1 , Θ
ˆ i, j−1 ).
Instead, a linear system of equations is found if the equation is rearranged as follows

h 1   
 − 1 Θ ˆ i, j−1 − 1 + 2h
Θˆ i, j
g (1 − η2j )  g 2η j   g 2 (1 − η2j ) 
  , i=1,2…, j=1 to N (76)
h 1 
+  + 1 Θ ˆ i, j+1 = −Θ
ˆ i −1, j
g (1 − η2j )  g 2η j 

For a given i, this is a system of N linear algebraic equations with N unknowns: Θ̂ i, j , j=1 to N.
The equations corresponding to j=1 and N can be simplified further by using the boundary
conditions in η, as follows,
(1) For j=1, ηj=g, and equation (50) (discretized form of boundary condition 19) applies. This
16

transforms equation (76) to, after manipulations,

 3h ˆ 3h
− 1 +  Θ i,1 + Θ
ˆ = −Θ
ˆ i −1,1 (77)
2 − 2 2 − 2 ) i,2
 2 g (1 g )  2 g (1 g

(2) For j=N, ηj=1−g, and equation (48) (discretized form of boundary condition 20) applies.
This transforms equation (76) to, after manipulations,

(2 − 3g )h ˆ i, N −1 − 1 + 2h  ˆ h
Θ  g 3 (2 − g )  Θ i, N + = −Θ i −1, N − 2g 3 (1 − g )
ˆ (78)
2g 3 (2 − g )(1 − g )  

The resulting system of equations can be written in matrix form as follows

 b1 c1 0 0 L 0 0 0  Θ ˆ i,1   d1 
  ˆ 
 a2 b2 c2 0 L 0 0 0   Θ i,2   d 2 

 0 a3 b3 c3 L 0 0 0  Θ ˆ i,3   d 3 
  =  (79)
 M M M M M M M  M   M 
 0 0 0 0 L a N −1 b N −1 c N −1  Θˆ i, N −1  d N −1 
     
 0 0 0 0 0 0 aN b N   Θˆ i, N   d N 

where the coefficients are given by

 3h 
b1 = − 1 +  (80)
 2g 2 (1 − g 2 ) 

 2h 
b j = − 1 +  , j=2,3,…N (81)
 g 2 (1 − η2j ) 
 

h 1 
aj =  − 1  , j=2,3,…N (82)
g(1 − η2j )  g 2η j 

h 1 
cj =  + 1  , j=1,2,…N-1 (83)
g (1 − η2j )  g 2η j 

d j = −Θ
ˆ i −1, j , j=1,2,…N-1 (84)

h
d N = −Θ
ˆ i −1, N − (85)
2g 3 (1 − g )
17

The matrix in equation (79) has as only nonzero coefficients those along the diagonal and two
lines parallel and adjacent to the diagonal. For this reason, this is a tri-diagonal matrix. A linear
system of equations with a tri-diagonal matrix can be solved by the relatively simple Thomas
algorithm.

The Thomas algorithm


Consider the following linear system of equations (identical to equation 79):

 b1 c1 0 0 L 0 0 0   x1   d1 
 a2 b2 c2 0 L 0 0 0   x 2   d 2 

 0 a3 b3 c3 L 0 0 0  x3   d3 
  =  (86)
 M M M M M M M  M   M 
 0 0 0 0 L a N −1 b N −1 c N −1   x N −1  d N −1 
    
 0 0 0 0 0 0 aN b N   x N   d N 

This system can be manipulated by replacing a row (i.e. equation) by a different row that results
from the linear combination of the row in question with any other rows in the system. A
simplification of the system of equations is obtained if all rows j, for j=2,3,…N are modified by
using row j-1 to eliminate the j-1 column. For example, we can replace row 2 by the following
operation

a
row 2 ← row 2 − 2 row 1 (87)
b1

This will make the first coefficient of the second row equal to zero:

b1 c1 0 0 K 0  x  
1
d1 
 a2    a 
 0 b 2 − c1 c 2 0 L 0 x 2
   d 2 − 2 d1 
 b1 x  =  b1  (88)
 0 a b3 c3 L 0 3 d
3    3 
M M M M 
M M  M   M 
  

After this step, the second equation has only two nonzero coefficients (those corresponding to x2
and x3). This new equation can be used to eliminate the coefficient of x2 (a3 in equation 88) from
row 3. Sequential application of this procedure will lead to a matrix with zeroes in place of the
aj's of the original matrix. Once this process reaches the last row, after eliminating aN, the last
row will have only one nonzero coefficient (corresponding to xN) so that xN can be calculated
directly. Once xN is known, xN-1 can be calculated directly from row N-1, since this row will
have nonzero coefficients only for xN-1 and xN. Continuing this back substitution until row 1 is
reached gives the solution to the problem. This is the Thomas algorithm, which can be
formulated as follows:
Step 1 – Elimination:
From j=2 to N, eliminate coefficient of xj-1 in equation j:
18

aj
bj ← bj − c j−1 (89)
b j−1

aj
dj ←dj − d j−1 (90)
b j−1

Step 2 – Back substitution:


Find xN:

d
xN = N (91)
bN

From j=N-1 to 1, find xj:

1
xj = (d j − c j x j+1 ) (92)
bj

Use of the Thomas algorithm to solve equation (79) yields the nodal values of the
dimensionless temperature for a given step i in the ξ direction. Successive application for
increasing values of i yield the final numerical solution of the problem.
A comparison of the backward- and forward difference methods leads to the following
observations:
(1) Both methods have a truncation error of O(h+g2).
(2) The forward-difference method is explicit since values of the dependent variable at a
given step in ξ are expressed in terms of the values at the previous step. On the other hand, the
backward-difference method is implicit since values of the dependent variable at a given step in
ξ must be calculated by solving a system of equations.
(3) The forward-difference method is conditionally stable whereas the backward-difference
method is unconditionally stable, regardless of the discretization. This last fact can be proven by
performing an analysis similar to the one presented above for the forward-difference method.
Improving stability by using an implicit method apparently leads to an increase in
computational effort (e.g. needing to solve a system of equations instead of doing a direct
calculation.) However, the fact that a stable solution can be found with a relatively coarse grid
might make the backward-difference method more computationally efficient in some cases.
As was the case for ODEs (Model 1), it would be worth exploring higher order methods.
Specifically, the fact that both methods presented above have errors of O(h) in the axial direction
might not be optimal for the numerical solution. Next, we consider a method that improves the
error in the axial direction, while keeping unconditional stability and introducing a minimum of
extra computational effort.

The Crank-Nicolson method


Consider the first-order forward difference formula used before (equation 42). Going back to
the original Taylor series (equation 25), the exact expression is
19

∂Θ Θ i +1, j − Θ i, j h ∂ 2 Θ
(ξ i , η j ) = − (ξ i , η j ) + O( h 2 ) (93)
∂ξ h 2 ∂ξ 2

Similarly, consider the first-order backward difference formula (74). The exact expression based
on the Taylor series (28) is

∂Θ Θ i, j − Θ i −1, j h ∂ 2 Θ
(ξ i , η j ) = + (ξ i , η j ) + O( h 2 ) (94)
∂ξ h 2 ∂ξ 2

If this equation is evaluated at the next step i+1 instead of i, we have

∂Θ Θ i +1, j − Θ i, j h ∂ 2 Θ
(ξi +1 , η j ) = + (ξ i +1 , η j ) + O(h 2 ) (95)
∂ξ h 2 ∂ξ 2

We will take advantage of the fact that, in the two approximations for the derivative,
equations (93) and (95), the second derivative term appears with different signs. To see why this
will be helpful, consider the arithmetic average of equations (93) and (95):

1  ∂Θ ∂Θ  Θ i +1, j − Θ i, j
 (ξ i , η j ) + (ξ i +1 , η j ) = +
2  ∂ξ ∂ξ  h
(96)
h  ∂ 2Θ ∂ 2Θ 
 ( ξ i +1 , η j ) − (ξ i , η j )  + O ( h 2 )
4  ∂ξ 2 ∂ξ 2

Here, we are interested in the order with respect to h of the terms involving second derivatives in
this equation. To find out, we expand the function ∂ 2 Θ / ∂ξ 2 in a Taylor series in ξ (at constant
η=ηj) around ξ=ξi and evaluate the series at ξ=ξi+1 to get

∂ 2Θ ∂ 2Θ ∂ 3Θ
(ξi +1 , η j ) = (ξ i , η j ) + h (ξ i , η j ) + O( h 2 ) (97)
∂ξ 2 ∂ξ 2 ∂ξ3

It is clear from this equation that

∂ 2Θ ∂ 2Θ
(ξi +1 , η j ) − (ξ i , η j ) = O( h ) (98)
∂ξ 2 ∂ξ 2

so that the second term on the right-hand side of equation (96) is of O(h2) and can be assimilated
with other terms of the same order, which simplifies equation (96) to

1  ∂Θ ∂Θ  Θ i +1, j − Θ i, j
 (ξ i , η j ) + (ξi +1 , η j ) = + O( h 2 ) (99)
2  ∂ξ ∂ξ  h
20

Next, we evaluate the PDE (17) at the points (ξ i , η j ) and (ξi +1, η j ) after discretizing the right-
hand side using equations (43) to (45). If we keep the error terms, the resulting equations are

∂Θ Θ i, j+1 − Θ i, j−1 Θ i, j+1 − 2Θ i, j + Θ i, j−1


(ξ i , η j ) = + +O(g2) (100)
∂ξ 2gη j (1 − η j )
2 g (1 − η j )
2 2

∂Θ Θ i +1, j+1 − Θ i +1, j−1 Θ i +1, j+1 − 2Θ i +1, j + Θ i +1, j−1


(ξi +1 , η j ) = + +O(g2) (101)
∂ξ 2gη j (1 − η j )
2 g 2 (1 − η j )
2

We can take the arithmetic average of the first derivatives from these two equations, and then
substitute it into equation (99). The result is, after manipulations

Θ i +1, j − Θ i, j Θ i +1, j+1 + Θ i, j+1 − Θ i, j−1 − Θ i +1, j−1


+ O( h 2 ) = +
h 4gη j (1 − η2j )
(102)
Θ i +1, j+1 + Θ i, j+1 − 2Θ i, j − 2Θ i +1, j + Θ i, j−1 + Θ i +1, j−1
+ O( g 2 )
2g 2 (1 − η2j )

Eliminating higher order terms in this equation leads to an approximation scheme with a local
truncation error of O(h2+g2), which improves upon the approximation of the forward- and
backward-difference methods analyzed before. The resulting equation is the basic approximation
of the Crank-Nicolson method. The truncated form of equation (102) can be rearranged as
follows (note use of circumflex for approximated values)

a jΘ
ˆ i +1, j−1 + b jΘ
ˆ i +1, j + c jΘ
ˆ i +1, j+1 = −a jΘ
ˆ i, j−1 + k jΘ
ˆ i, j − c jΘ
ˆ i, j+1 , j=1…N (103)

where

h 1 
aj =  − 1  (104)
2g (1 − η2j )  g 2η j 

 
b j = − 1 + 
h
(105)
 g 2 (1 − η2 ) 
 j 

h 1 
cj =  + 1  (106)
2g (1 − η2j )  g 2η j 

h
k j = −1 + (107)
g 2 (1 − η2j )
21

When equation (103) is applied to calculate values of the dimensionless temperature at step i+1,
its right-hand side contains values evaluated at step i, so that equation (103) constitutes a tri-
diagonal system of equations. To build the tri-diagonal matrix, we use equation (103) for j=2 to
N-1, and the top and bottom rows are modified to account for the boundary conditions, as
follows,
(1) For j=1, boundary condition (19) implies (see equation 50):

Θ
ˆ
i +1,0 = Θi +1,1
ˆ (108)

and

Θ
ˆ =Θ
i ,0
ˆ
i,1 (109)

and equation (103) becomes

(a1 + b1 )Θ
ˆ
i +1,1 + c1Θi +1, 2 = ( −a1 + k1 )Θi,1 − c1Θi, 2
ˆ ˆ ˆ (110)

(2) For j=N, boundary condition (20) requires

Θ
ˆ
i +1, N +1 = Θi, N +1 = 1
ˆ (111)

and equation (103) becomes

a NΘ
ˆ
i +1, N −1 + b N Θi +1, N = −a N Θi, N −1 + k N Θi, N − 2c N
ˆ ˆ ˆ (112)

The resulting system of equations can be solved using Thomas' algorithm.


Figure 7 shows a comparison of the error in the calculation of the dimensionless temperature
at a point between the two implicit methods developed in this chapter as a function of h. The
difference in the dependence of the errors on h can be clearly seen. At low h, clearly, e=O(h) for
the backward-difference method and e=O(h2) for the Crank-Nicolson method. It is worthwhile to
point out that the forward-difference method is unstable in the range of h values used in Figure 7.
22

1.0E+00
e
1.0E-01
1.0E-02
1.0E-03
1.0E-04
1.0E-05
1.0E-06
1.0E-07
1.0E-08 Crank-Nicolson
1.0E-09 Backward Differences

1.0E-10
1.0E-05 1.0E-04 1.0E-03 1.0E-02 1.0E-01
h
Figure 7. Comparison of the error at ξ=0.05 and η=0.5 as a function of h (using g=0.01).
Arbitrary lines of slopes 1 and 2 are shown. The exact solution for the calculation of the error
was taken as the Crank-Nicolson solution with h=10-7 and g=10-3.

You might also like