45
Chapter 2 Finite Difference Method 2.1 Classification of Partial Differential Equations For analysing the equations for fluid flow problems, it is convenient to consider the case of a second-order differential equation given in the general form as A 2 φ ∂x 2 + B 2 φ ∂x∂y + C 2 φ ∂y 2 + D ∂φ ∂x + E ∂φ ∂y + = G(x, y) (2.1) In the coefficients A, B, C, D, E and F are either constants or functions of only (x, y) (do not contain φ or its derivatives), it is said to be a linear equation, otherwise it is a non-linear equation. An important subclass of non-linear equa- tions is quasilinear equations. In this case, the coefficients may contain φ or its first derivative but not the second (highest) derivative. If G = 0, the aforesaid equation is homogeneous, otherwise it is non-homogeneous. Again for the above mentioned equation if B 2 4AC =0, the equation is parabolic if B 2 4AC < 0, the equation is elliptic if B 2 4AC > 0, the equation is hyperbolic The unsteady Navier-Stokes equations are elliptic in space and parabolic in time. At steady-state, the Navier-Stokes equations are elliptic. In elliptic problems, the boundary conditions must be applied on all confining surfaces. These are boundary value problems. A physical problem may be steady or unsteady. In the following text, we shall discuss mathematical aspects of some of the equations that describe fluid flow and heat transfer problems. The Laplace equations and the Poisson equations are generally associated with the steady-state problems. These are elliptic equations and can be written 1

Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Chapter 2

Finite Difference Method

2.1 Classification of Partial Differential

Equations

For analysing the equations for fluid flow problems, it is convenient to considerthe case of a second-order differential equation given in the general form as

A∂2φ

∂x2+ B

∂2φ

∂x∂y+ C

∂2φ

∂y2+ D

∂φ

∂x+ E

∂φ

∂y+ Fφ = G(x, y) (2.1)

In the coefficients A, B, C, D, E and F are either constants or functions of only(x, y) (do not contain φ or its derivatives), it is said to be a linear equation,otherwise it is a non-linear equation. An important subclass of non-linear equa-tions is quasilinear equations. In this case, the coefficients may contain φ or itsfirst derivative but not the second (highest) derivative. If G = 0, the aforesaidequation is homogeneous, otherwise it is non-homogeneous.

Again for the above mentioned equation

if B2 − 4AC = 0, the equation is parabolic

if B2 − 4AC < 0, the equation is elliptic

if B2 − 4AC > 0, the equation is hyperbolic

The unsteady Navier-Stokes equations are elliptic in space and parabolicin time. At steady-state, the Navier-Stokes equations are elliptic. In ellipticproblems, the boundary conditions must be applied on all confining surfaces.These are boundary value problems. A physical problem may be steady orunsteady. In the following text, we shall discuss mathematical aspects of someof the equations that describe fluid flow and heat transfer problems.

The Laplace equations and the Poisson equations are generally associatedwith the steady-state problems. These are elliptic equations and can be written

1

Page 2: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.2 Computational Fluid Dynamics

respectively as

∂2φ

∂x2+

∂2φ

∂y2= 0 (2.2)

∂2φ

∂x2+

∂2φ

∂y2+ S = 0 (2.3)

The velocity potential in steady, inviscid, incompressible, and irrotational flowssatisfies the Laplace equation. The temperature distribution for steady-state,constant-property, two-dimensional conduction satisfies the Laplace equation ifno volumetric heat source is present in the domain of interest and the Poissonequation if a volumetric heat source is present.

The parabolic equation in conduction heat transfer is of the form

∂φ

∂t= B

∂2φ

∂x2(2.4)

The one-dimensional unsteady conduction problem is governed by this equa-tion when t and x are identified as the time and space variables, respectivelyφ denotes the temperature and B is the thermal diffusivity. The boundaryconditions at the two ends and an initial condition are needed to solve suchequations. The unsteady conduction problem in two- dimensions is governed byan equation of the form

∂φ

∂t= B

(

∂2φ

∂x2+

∂2φ

∂y2

)

+ S (2.5)

Here t denotes the time variable, and a source term S is included. By com-paring the highest derivatives in any two of the independent variables, withthe help of the conditions given earlier, it can be concluded that Eq. (2.5) isparabolic in time and elliptic in space. An initial condition and two conditionsfor the extreme ends in each spacial coordinate is required to solve this equation.

Fluid flow problems generally have nonlinear terms due to the inertia oracceleration component in the momentum equation. These terms are calledadvection terms. The energy equation has nearly similar terms, usually calledthe convection terms, which involve the motion of the flow field. For unsteadytwo-dimensional problems, the appropriate equations can be represented as

∂φ

∂t+ u

∂φ

∂x+ v

∂φ

∂y= B

(

∂2φ

∂x2+

∂2φ

∂y2

)

+ S (2.6)

where φ denotes velocity, temperature or some other transported property, uand v are velocity components, B is the diffusivity for momentum or heat, andS is a source term. The pressure gradients in the momentum or the volumetricheating in the energy equation can be appropriately substituted in S. Eq. (2.6)is parabolic in time and elliptic in space. However, for very high-speed flows,the terms on the left side dominate, the second-order terms on the right handside become trivial, and the equation becomes hyperbolic in time and space.

Page 3: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.3

2.1.1 Boundary and Initial Conditions

In addition to the governing differential equations, the formulation of the prob-lem requires a complete specification of the geometry of interest and appropriateboundary conditions. An arbitrary domain and bounding surfaces are sketchedin Fig. 2.1. The conservation equations are to be applied within the domain.The number of boundary conditions required is generally determined by theorder of the highest derivatives appearing in each independent variable in thegoverning differential equations.

Surface A

n

r A

A

A

x

y

32

1

Figure 2.1: Schematic sketch of an arbitrary domain.

The unsteady problems governed by a first derivative in time will requireinitial condition in order to carry out the time integration. The diffusion termsrequire two spatial boundary conditions for each coordinate in which a secondderivative appears.The spatial boundary conditions in flow and heat transfer problems are of threegeneral types. They may be stated

φ = φ1(r) ∈ A1 (2.7)

∂φ

∂n= φ2(r) ∈ A2 (2.8)

a(r)φ + b(r)∂φ

∂n= φ3(r) ∈ A3 (2.9)

where A1, A2 and A3 denote three separate zones on the bounding surface inFig. 2.1. The boundary conditions on φ in Eqns. (2.7) to (2.9) are usuallyreferred to as Dirchlet, Neumann and mixed boundary conditions, respectively.The boundary conditions are linear in the dependant variable φ.In Eqns. (2.7) to (2.8), ~r = ~r(x, y) is a vector denoting position on the boundary,

Page 4: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.4 Computational Fluid Dynamics

∂nis the directional derivative normal to the boundary, and φ1, φ2, φ3, a, and

b are arbitrary functions. The normal derivative may be expressed as

∂φ

∂n= −→n · ∇φ

= (nx i + ny j) ·

(

∂φ

∂xi +

∂φ

∂yj

)

= nx∂φ

∂x+ ny

∂φ

∂y(2.10)

Here, −→n is the unit vector normal to the boundary, ∇ is the nabla operator, [·]denotes the dot product, (nx, ny) are the direction-cosine components of −→n and

(i, j) are the unit vectors aligned with the (x, y) coordinates.

2.2 Finite Differences

Analytical solutions of partial differential equations provide us with closed-formexpressions which depict the variation of the dependant variables in the domain.The numerical solutions, based on finite differences, provide us with the values atdiscrete points in the domain which are known as grid points. Consider Fig. 2.2,which shows a domain of calculation in the x − y plane. Let us assume thatthe spacing of the grid points in the x−direction is uniform, and given by ∆x.Likewise, the spacing of the points in the y−direction is also uniform, and givenby ∆y. It is not necessary that ∆x or ∆y be uniform. We could imagine unequalspacing in both directions, where different values of ∆x between each successivepairs of grid points are used. The same could be presumed for ∆y as well.However, often, problems are solved on a grid which involves uniform spacingin each direction, because this simplifies the programming, and often resultsin higher accuracy. In some class of problems, the numerical calculations areperformed on a transformed computational plane which has uniform spacing inthe transformed-independent-variables, but non-uniform spacing in the physicalplane. These typical aspects will be discussed later in the Chapter on gridgeneration. In the present chapter we shall consider uniform spacing in eachcoordinate direction. According to our consideration, ∆x and ∆y are constants,but it is not mandatory that ∆x be equal to ∆y.

Let us once again refer to Fig. 2.2. The grid points are identified by an indexi which increases in the positive x-direction, and an index j, which increases inthe positive y-direction. If (i, j) is the index of point P in Fig. 2.2, then the pointimmediately to the right is designated as (i+1, j) and the point immediately tothe left is (i−1, j). Similarly the point directly above is (i, j +1), and the pointdirectly below is (i, j − 1). The basic philosophy of finite difference methods isto replace the derivatives of the governing equations with algebraic differencequotients. This will result in a system of algebraic equations which can be solvedfor the dependant variables at the discrete grid points in the flow field. Let us

Page 5: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.5

now look at some of the common algebraic difference quotients in order to beacquainted with the methods related to discretization of the partial differentialequations.

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

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

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

P

x

y∆

x

y

Figure 2.2: Discrete grid points.

2.2.1 Elementary Finite Difference Quotients

Finite difference representations of derivatives are derived from Taylor seriesexpansions. For example, if ui,j is the x−component of the velocity ui+1,j atpoint (i+1, j) can be expressed in terms of Taylor series expansion about point(i, j) as

ui+1,j = ui,j +

(

∂u

∂x

)

i,j

∆x +

(

∂2u

∂x2

)

i,j

(∆x)2

2+

(

∂3u

∂x3

)

i,j

(∆x)3

6+ · · · (2.11)

Mathematically, Eq. (2.11) is an exact expression for ui+1,j if the series con-verges. In practice, ∆x is small and any higher-order term of ∆x is smallerthan ∆x. Hence, for any function u(x), Eq. (2.11) can be truncated after afinite number of terms. For example, if terms of magnitude (∆x)3 and higherorder are neglected, Eq. (2.11) becomes

ui+1,j ≈ ui,j +

(

∂u

∂x

)

i,j

∆x +

(

∂2u

∂x2

)

i,j

(∆x)2

2· · · (2.12)

Page 6: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.6 Computational Fluid Dynamics

Eq. (2.12) is second-order accurate, because terms of order (∆x)3 and higherhave been neglected. If terms of order (∆x)2 and higher are neglected, Eq. (2.12)is reduced to

ui+1,j ≈ ui,j +

(

∂u

∂x

)

i,j

∆x (2.13)

Eq. (2.13) is first-order accurate. In Eqns. (2.12) and (2.13) the neglected higher-order terms represent the truncation error. Therefore, the truncation errors forEqns. (2.12) and (2.13) are

∞∑

n=3

=

(

∂nu

∂xn

)

i,j

(∆x)n

n!

and∞∑

n=2

=

(

∂nu

∂xn

)

i,j

(∆x)n

n!

It is now obvious that the truncation error can be reduced by retaining moreterms in the Taylor series expansion of the corresponding derivative and reducingthe magnitude of ∆x.

Let us once again return to Eq. (2.11) and solve for (∂u/∂x)i,j as:

(

∂u

∂x

)

i,j

=ui+1,j − ui,j

∆x−

(

∂2u

∂x2

)

i,j

∆x

2−

(

∂3u

∂x3

)

i,j

(∆x)2

6+ · · ·

or(

∂u

∂x

)

i,j

=ui+1,j − ui,j

∆x+ O(∆x) (2.14)

In Eq. (2.14) the symbol O(∆x) is a formal mathematical nomenclature whichmeans “terms of order of ∆x”,expressing the order of magnitude of the trunca-tion error. The first-order-accurate difference representation for the derivative(∂u/∂x)i,j expressed by Eq. (2.14) can be identified as a first-order forwarddifference. We now consider a Taylor series expansion for ui−1,j , about ui,j

ui−1,j = ui,j +

(

∂u

∂x

)

i,j

(−∆x) +

(

∂2u

∂x2

)

i,j

(−∆x)2

2+

(

∂3u

∂x3

)

i,j

(−∆x)3

6+ · · ·

or

ui−1,j = ui,j −

(

∂u

∂x

)

i,j

(∆x)+

(

∂2u

∂x2

)

i,j

(∆x)2

2−

(

∂3u

∂x3

)

i,j

(∆x)3

6+ · · · (2.15)

Solving for (∂u/∂x)i,j , we obtain

(

∂u

∂x

)

i,j

=ui,j − ui−1,j

∆x+ O(∆x) (2.16)

Page 7: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.7

Eq. (2.16) is a first-order backward expression for the derivative (∂u/∂x) atgrid point (i, j).

Subtracting Eq. (2.15) from ( 2.11)

ui+1,j − ui−1,j = 2

(

∂u

∂x

)

i,j

(∆x) +

(

∂3u

∂x3

)

i,j

(∆x)3

3+ · · · (2.17)

and solving for (∂u/∂x)i,j from Eq. (2.17) we obtain(

∂u

∂x

)

i,j

=ui+1,j − ui−1,j

2∆x+ O(∆x)2 (2.18)

Eq. (2.18) is a second-order central difference for the derivative (∂u/∂x) atgrid point (i, j).

In order to obtain a finite-difference for the second-order partial derivative(∂2u/∂x2)i,j , add Eq. (2.11) and (2.15). This produces

ui+1,j + ui−1,j = 2ui,j +

(

∂2u

∂x2

)

i,j

(∆x)2 +

(

∂4u

∂x4

)

i,j

(∆x)4

12+ · · · (2.19)

Solving Eq. (2.19) for (∂2u/∂x2)i,j , we obtain

(

∂2u

∂x2

)

i,j

=ui+1,j − 2ui,j + ui−1,j

(∆x)2+ O(∆x)2 (2.20)

Eq. (2.20) is a second-order central difference form for the derivative (∂2u/∂x2)at grid point (i, j).

Difference quotients for the y-derivatives are obtained in exactly the similarway. The results are analogous to the expressions for the x-derivatives.

(

∂u

∂y

)

i,j

=ui,j+1 − ui,j

∆y+ O(∆y) [Forward difference]

(

∂u

∂y

)

i,j

=ui,j − ui,j−1

∆y+ O(∆y) [Backward difference]

(

∂u

∂y

)

i,j

=ui,j+1 − ui,j−1

2∆y+ O(∆y)2 [Central difference]

(

∂2u

∂y2

)

i,j

=ui,j+1 − 2ui,j + ui,j−1

(∆y)2+ O(∆y)2 [Central difference of second

derivative]

It is interesting to note that the central difference given by Eq. (2.20) can beinterpreted as a forward difference of the first order derivatives, with backwarddifferences in terms of dependent variables for the first-order derivatives. Thisis because

(

∂2u

∂x2

)

i,j

=

[

∂x

(

∂u

∂x

)]

i,j

=

(

∂u∂x

)

i+1,j−

(

∂u∂x

)

i,j

∆x

Page 8: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.8 Computational Fluid Dynamics

or(

∂2u

∂x2

)

i,j

=

[(

ui+1,j − ui,j

∆x

)

(

ui,j − ui−1,j

∆x

)]

1

∆x

or(

∂2u

∂x2

)

i,j

=ui+1,j − 2ui,j + ui−1,j

(∆x)2

The same approach can be made to generate a finite difference quotient for themixed derivative (∂2u/∂x∂y) at grid point (i, j). For example,

∂2u

∂x∂y=

∂x

(

∂u

∂y

)

(2.21)

In Eq. (2.21), if we write the x−derivative as a central difference of y-derivatives,and further make use of central differences to find out the y−derivatives, weobtain

∂2u

∂x∂y=

∂x

(

∂u

∂y

)

=

(

∂u∂y

)

i+1,j−

(

∂u∂y

)

i−1,j

2(∆x)(

∂2u

∂x∂y

)

=

[(

ui+1,j+1 − ui+1,j−1

2(∆y)

)

(

ui−1,j+1 − ui−1,j−1

2(∆y)

)]

1

2(∆x)(

∂2u

∂x∂y

)

=1

4∆x∆y(ui+1,j+1+ui−1,j−1−ui+1,j−1−ui−1,j+1)+O[(∆x)2, (∆y)2]

(2.22)Combinations of such finite difference quotients for partial derivatives form finitedifference expressions for the partial differential equations. For example, theLaplace equation ∇2u = 0 in two dimensions, becomes

ui+1,j − 2ui,j + ui−1,j

(∆x)2+

ui,j+1 − 2ui,j + ui,j−1

(∆y)2= 0

or

ui+1,j + ui−1,j + λ2(ui,j+1 + ui,j−1) − 2(1 + λ2)ui,j = 0 (2.23)

where λ is the mesh aspect ratio (∆x)/(∆y). If we solve the Laplace equationon a domain given by Fig. 2.2, the value of ui,j will be

ui,j =ui+1,j + ui−1,j + λ2(ui,j+1 + ui,j−1)

2(1 + λ2)(2.24)

It can be said that many other forms of difference approximations can be ob-tained for the derivatives which constitute the governing equations for fluid flowand heat transfer. The basic procedure, however, remains the same. In order toappreciate some more finite difference representations see Tables 2.1 and 2.2.Interested readers are referred to Anderson, Tannehill and Pletcher (1984) formore insight into different kind of discretization methods.

Page 9: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.9

2.3 Basic Aspects of Finite-Difference Equations

Here we shall look into some of the basic aspects of difference equations. Con-sider the following one dimensional unsteady state heat conduction equation.The dependent variable u (temperature) is a function of x and t (time) and αis a constant known as thermal diffusivity.

∂u

∂t= α

∂2u

∂x2(2.25)

It is to be noted that Eq. (2.25) is classified as a parabolic partial differentialequation.

If we substitute the time derivative in Eq. (2.25) with a forward difference,and a spatial derivative with a central difference (usually called FTCS, ForwardTime Central Space method of discretization), we obtain

un+1i − un

i

∆t= α

[

uni+1 − 2un

i + uni−1

(∆x2)

]

(2.26)

In Eq. (2.26), the index for time appears as a superscript, where n denotesconditions at time t, (n+1) denotes conditions at time (t+∆t), and so on. Thesubscript denotes the grid point in the spatial dimension.

However, there must be a truncation error for the equation because each oneof the finite-difference quotients has been taken from a truncated series. Con-sidering Eqns. (2.25) and (2.26), and looking at the truncation errors associatedwith the difference quotients we can write

∂u

∂t− α

∂2u

∂x2=

un+1i − un

i

∆t− α

uni+1 − 2un

i + uni−1

(∆x2)

+

[

(

∂2u

∂t2

)n

i

(∆t)

2+ α

(

∂4u

∂x4

)n

i

(∆x)2

12+ · · ·

]

(2.27)

In Eq. (2.27), the terms in the square brackets represent truncation errorfor the complete equation. It is evident that the truncation error (TE) for thisrepresentation is O[∆t,(∆x)2].

With respect to Eq. (2.27), it can be said that as ∆x → 0 and ∆t → 0,the truncation error approaches zero. Hence, in the limiting case, the differenceequation also approaches the original differential equation. Under such circum-stances, the finite difference representation of the partial differential equation issaid to be consistent.

2.3.1 Consistency

A finite difference representation of a partial differential equation (PDE) is saidto be consistent if we can show that the difference between the PDE and itsfinite difference (FDE) representation vanishes as the mesh is refined, i.e,

limmesh→0

(PDE − FDE) = limmesh→0

(TE) = 0

Page 10: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.10 Computational Fluid Dynamics

Table 2.1: Difference Approximations for Derivatives

(

∂3u

∂x3

)

i,j

=ui+2,j − 2 ui+1,j + 2 ui−1,j − ui−2,j

2 h3+ O(h2)

(

∂4u

∂x4

)

i,j

=ui+2,j − 4 ui+1,j + 6 ui,j − 4 ui−1,j + ui−2,j

h4+ O(h2)

(

∂2u

∂x2

)

i,j

=−ui+3,j + 4 ui+2,j − 5 ui+1,j + 2 ui,j

h2+ O(h2)

(

∂u

∂x

)

i,j

=−ui+2,j + 8 ui+1,j − 8 ui−1,j + ui−2,j

12 h+ O(h4)

(

∂2u

∂x2

)

i,j

=−ui+2,j + 16 ui+1,j − 30 ui,j + 16 ui−1,j − ui−2,j

12 h2+ O(h4)

h = grid spacing in x-direction

Table 2.2: Difference Approximations for Mixed Partial Derivatives

(

∂2u

∂x∂y

)

i,j

=1

∆x

(

ui+1,j − ui+1,j−1

∆y−

ui,j − ui,j−1

∆y

)

+ O(∆x, ∆y)

(

∂2u

∂x∂y

)

i,j

=1

∆x

(

ui,j+1 − ui,j

∆y−

ui−1,j+1 − ui−1,j

∆y

)

+ O(∆x, ∆y)

(

∂2u

∂x∂y

)

i,j

=1

∆x

(

ui+1,j+1 − ui+1,j−1

2∆y−

ui,j+1 − ui,j−1

2∆y

)

+ O[(∆x), (∆y)2 ]

(

∂2u

∂x∂y

)

i,j

=1

2 ∆x

(

ui+1,j+1 − ui+1,j−1

2∆y−

ui−1,j+1 − ui−1,j−1

2∆y

)

+ O[(∆x)2, (∆y)2]

(

∂2u

∂x∂y

)

i,j

=1

2 ∆x

(

ui+1,j − ui+1,j−1

∆y−

ui−1,j − ui−1,j−1

∆y

)

+ O[(∆x)2, (∆y)]

Page 11: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.11

A questionable scheme would be one for which the truncation error is O(∆t/∆x)and not explicitly O(∆t) or O(∆x) or higher orders. In such cases the schemewould not be formally consistent unless the mesh were refined in a mannersuch that (∆t/∆x) → 0. Let us take Eq. (2.25) and the Dufort-Frankel (1953)differencing scheme. The FDE is

un+1i − un−1

i

2∆t= α

[

uni+1 − un+1

i − un−1i + un

i−1

(∆x2)

]

(2.28)

Now the leading terms of truncated series form the truncation error for thecomplete equation:

α

12

(

∂4u

∂x4

)n

i

(∆x)2 − α

(

∂2u

∂t2

)n

i

(

∆t

∆x

)2

−1

6

(

∂3u

∂t3

)n

i

(∆t)2

The above expression for truncation error is meaningful if (∆t/∆x) → 0 togetherwith ∆t → 0 and ∆x → 0. However, (∆t) and (∆x) may individually approachzero in such a way that (∆t/∆x) = β. Then if we reconstitute the PDE fromFDE and TE, we shall obtain

lim∆t,∆x→0

(PDE − FDE) = limmesh→0

(TE) = −αβ2

(

∂2u

∂t2

)

and finally PDE becomes

∂u

∂t+ αβ2 ∂2u

∂t2= α

∂2u

∂x2

We started with a parabolic one and ended with a hyperbolic one!So, DuFort-Frankel scheme is not consistent for the 1D unsteady state heat

conduction equation unless (∆t/∆x) → 0 together with ∆t → 0 and ∆x → 0.

2.3.2 Convergence

A solution of the algebraic equations that approximate a partial differentialequation (PDE) is convergent if the approximate solution approaches the exactsolution of the PDE for each value of the independent variable as the grid spacingtends to zero. The requirement is

uni = u(xi, tn) as ∆x, ∆t → 0

where, u(xi, tn) is the solution of the system of algebraic equations.

2.3.3 Explicit and Implicit Methods

The solution of Eq. (2.26) takes the form of a “marching” procedure (or scheme)in steps of time. We know the dependent variable at all x at a time level

Page 12: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.12 Computational Fluid Dynamics

from given initial conditions. Examining Eq. (2.26) we see that it containsone unknown, namely un+1

i . Thus, the dependent variable at time (t + ∆t) isobtained directly from the known values of un

i+1, uni and un

i−1.

un+1i − un

i

∆t= α

[

uni+1 − 2un

i + uni−1

(∆x2)

]

(2.29)

This is a typical example of an explicit finite difference method.Let us now attempt a different discretization of the original partial differentialequation given by Eq. (2.25) . Here we express the spatial differences on theright-hand side in terms of averages between n and (n + 1) time level

un+1i − un

i

∆t=

α

2

[

un+1i+1 + un

i+1 − 2un+1i − 2un

i + un+1i−1 + un

i−1

(∆x2)

]

(2.30)

The differencing shown in Eq. (2.30) is known as the Crank-Nicolson implicitscheme. The unknown un+1

i is not only expressed in terms of the known quan-tities at time level n, but also in terms of unknown quantities at time level(n + 1). Hence Eq. (2.30) at a given grid point i, cannot itself result in a so-lution of un+1

i . Eq. (2.30) has to be written at all grid points, resulting in asystem of algebraic equations from which the unknowns un+1

i for all i can besolved simultaneously. This is a typical example of an implicit finite-differencesolution (Fig. 2.3). Since they deal with the solution of large systems of simulta-neous linear algebraic equations, implicit methods usually require the handlingof large matrices.

Generally, the following steps are followed in order to obtain a solution.Eq. (2.30) can be rewritten as

un+1i − un

i =r

2[un+1

i+1 + uni+1 − 2un+1

i − 2uni + un+1

i−1 + uni−1] (2.31)

where r = α(∆t)/(∆x)2 or

−r un+1i−1 + (2 + 2r)un+1

i − r un+1i+1 = run

i−1 + (2 − 2r)uni + run

i+1

or

−un+1i−1 +

(

2 + 2r

r

)

un+1i − un+1

i+1 = uni−1 +

(

2 − 2r

r

)

uni + un

i+1 (2.32)

Eq. (2.32) has to be applied at all grid points, i.e., from i = 1 to i = k + 1. Asystem of algebraic equations will result (refer to Fig. 2.3).

at i = 2 − A + B(1)un+12 − un+1

3 = C(1)

at i = 3 − un+12 + B(2)un+1

3 − un+14 = C(2)

at i = 4 − un+13 + B(3)un+1

4 − un+15 = C(3)

......

at i = k − un+1k−1 + B(k − 1)un+1

k − D = C(k − 1)

Page 13: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.13

n

n+1

n+2

i=1 i=k+1

x=0 x=L

x

t

BC u = A at BC u = D at

Figure 2.3: Crank Nicolson implicit scheme.

Finally the equations will be of the form:

B(1) −1 0 0 . . . 0−1 B(2) −1 0 . . . 00 −1 B(3) −1 . . . 0...0 0 0 . . . −1 B(k − 1)

un+12

un+13

un+14...

un+1k

=

(C(1) + A)n

C(2)n

C(3)n

...(C(k − 1) + D)n

(2.33)Here, we express the system of equations in the form of Ax = C, where C isthe right-hand side column vector (known), A the tridiagonal coefficient matrix(known) and x the solution vector (to be determined). Note that the boundaryvalues at i = 1 and i = k + 1 are transferred to the known right-hand side.

For such a tridiagonal system, different solution procedures are available. Inorder to derive advantage of the zeros in the coefficient-matrix, the well knownThomas algorithm (1949) can be used (see appendix).

Page 14: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.14 Computational Fluid Dynamics

2.3.4 Explicit and Implicit Methods for Two-Dimensional

Heat Conduction Equation

The two-dimensional conduction equation is given by

∂u

∂t= α

(

∂2u

∂x2+

∂2u

∂y2

)

(2.34)

Here, the dependent variable, u (temperature) is a function of space (x, y) andtime (t) and α is the thermal diffusivity. If we apply the simple explicit methodto the heat conduction equation, the following algorithm results

un+1i,j − un

i,j

∆t= α

[

uni+1,j − 2un

i,j + uni−1,j

(∆x2)+

uni,j+1 − 2un

i,j + uni,j−1

(∆y2)

]

(2.35)

When we apply the Crank-Nicolson scheme to the two-dimensional heat con-duction equation, we obtain

un+1i,j − un

i,j

∆t=

α

2(δ2

x + δ2y)(un+1

i,j + uni,j) (2.36)

where the central difference operators δ2x and δ2

y in two different spatial directionsare defined by

δ2x[un

i,j] =un

i+1,j − 2uni,j + un

i−1,j

(∆x2)

δ2y [un

i,j] =un

,j+1 − 2uni,j + un

i,j−1

(∆y2)(2.37)

The resulting system of linear algebraic equations is not tridiagonal because ofthe five unknowns un+1

i,j , un+1i+1,j , u

n+1i−1,j , u

n+1i,j+1 and un+1

i,j−1. In order to examinethis further, let us rewrite Eq. (2.36) as

a un+1i,j−1 + b un+1

i−1,j + d un+1i,j + b un+1

i+1,j + a un+1i,j+1 = cn

i,j (2.38)

where

a = −α∆t

2(∆y)2= −

1

2Py

b = −α∆t

2(∆x)2= −

1

2Px

d = 1 + Px + Py

cni,j = un

i,j +α∆t

2(δ2

x + δ2y)un

i,j

Eq. (2.38) can be applied to the two-dimensional (6× 6) computational gridshown in Fig. 2.4. A system of 16 linear algebraic equations have to be solved

Page 15: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.15

i= 1 2 3 4 5 imaxj=1

2

3

4

5

jmax

u = u bb

x

y

u = u = boundary value

Figure 2.4: Two-dimensional grid on the (x-y) plane.

at (n + 1) time level, in order to get the temperature distribution inside thedomain. The matrix equation will be as the following:

d b 0 0 a 0 0b d b a0 b d b a0 b d b aa 0 d b a0 a b d b a

a 0 b d b aa b d 0 a

a 0 d b aa b d b a

a b d b a 0a b d 0 a

a 0 d b 0a b d b 0

a b d ba b d

u2,2

u3,2

u4,2

u5,2

u2,3

u3,3

u4,3

u5,3

u2,4

u3,4

u4,4

u5,4

u2,5

u3,5

u4,5

u5,5

=

c′′′

2,2

c′

3,2

c′

4,2

c′′′

5,2

c′′

2,3

c3,3

c4,3

c′′

5,3

c′′

2,4

c3,4

c4,4

c′′

5,4

c′′′

2,5

c′

3,5

c′

4,5

c′′′

5,5

(2.39)where

c′

= c − a ub

c′′

= c − b ub

c′′′

= c − (a + b)ub

The system of equations, described by Eq. (2.39) requires substantially morecomputer time as compared to a tridiagonal system. The equations of this type

Page 16: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.16 Computational Fluid Dynamics

are usually solved by iterative methods. These methods will be described in asubsequent section. The quantity ub is the boundary value.

2.3.5 ADI Method

The difficulties described in the earlier section, which occur when solving thetwo-dimensional equation by conventional algorithms, can be removed by alter-nating direction implicit (ADI) methods. The usual ADI method is a two-stepscheme given by

un+1/2i,j − un

i,j

∆t/2= α(δ2

xun+1/2i,j + δ2

yuni,j) (2.40)

and

un+1i,j − u

n+1/2i,j

∆t/2= α(δ2

xun+1/2i,j + δ2

yun+1i,j ) (2.41)

The effect of splitting the time step culminates in two sets of systems of linearalgebraic equations. During step 1, we get the following

un+1/2i,j − un

i,j

(∆t/2)= α

[{

un+1/2i+1,j − 2u

n+1/2i,j + u

n+1/2i−1,j

(∆x2)

}

+

{

uni,j+1 − 2un

i,j + uni,j−1

(∆y2)

}

]

or

[b ui−1,j + (1 − 2b)ui,j + b ui+1,j]n+1/2 = un

i,j − a [ui,j+1 − 2ui,j + ui,j−1]n

Now for each “j” rows (j = 2, 3...), we can formulate a tridiagonal matrix, forthe varying i index and obtain the values from i = 2 to (imax− 1) at (n + 1/2)level Fig. 2.5(a). Similarly, in step-2, we get

un+1i,j − u

n+1/2i,j

(∆t/2)= α

[{

un+1/2i+1,j − 2u

n+1/2i,j + u

n+1/2i−1,j

(∆x2)

}

+

{

un+1i,j+1 − 2un+1

i,j + un+1i,j−1

(∆y2)

}]

or

[a ui,j−1 + (1 − 2a)ui,j + a ui,j+1]n+1 = u

n+1/2i,j − b[ui+1,j − 2ui,j + ui−1,j ]

n+1/2

Now for each “i” rows (i = 2, 3....), we can formulate another tridiagonal matrixfor the varying j index and obtain the values from j = 2 to (jmax − 1) at nthlevel Figure 2.5(b).With a little more effort, it can be shown that the ADI method is also second-

Page 17: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.17

ni2 3 4 5 . . . .

23

4.

IMPLICIT

IMPLICIT

n+1

t t

1−2n+

12−n+

(b)(a)

x = i x

y = j y

Figure 2.5: Schematic representation of ADI scheme.

order accurate in time. If we use Taylor series expansion around un+1/2i,j on

either direction, we shall obtain

un+1i,j = u

n+1/2i,j +

(

∂u

∂t

) (

∆t

2

)

+1

2!

(

∂2u

∂t2

) (

∆t

2

)2

+1

3!

(

∂3u

∂t3

) (

∆t

2

)3

+ · · ·

and

uni,j = u

n+1/2i,j −

(

∂u

∂t

) (

∆t

2

)

+1

2!

(

∂2u

∂t2

) (

∆t

2

)2

−1

3!

(

∂3u

∂t3

) (

∆t

2

)3

+ · · ·

Subtracting the latter from the former, one obtains

un+1i,j − un

i,j =

(

∂u

∂t

)

(∆t) +2

3!

(

∂3u

∂t3

) (

∆t

2

)3

+ · · ·

or

∂u

∂t=

un+1i,j − un

i,j

∆t−

1

3!

(

∂3u

∂t3

) (

∆t

2

)2

+ · · ·

The procedure above reveals that the ADI method is second-order accurate witha truncation error of O [(∆t)2, (∆x)2, (∆y)2].

The major advantages and disadvantages of explicit and implicit methodsare summarized as follows:

Explicit:

• Advantage: The solution algorithm is simple to set up.

• Disadvantage: For a given ∆x, ∆t must be less than a specific limit im-posed by stability constraints. This requires many time steps to carry outthe calculations over a given interval of t.

Page 18: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.18 Computational Fluid Dynamics

Implicit:

• Advantage: Stability can be maintained over much larger values of ∆t.Fewer time steps are needed to carry out the calculations over a giveninterval.

• Disadvantages:

- More involved procedure is needed for setting up the solution algo-rithm than that for explicit method.

- Since matrix manipulations are usually required at each time step,the computer time per time step is larger than that of the explicitapproach.

- Since larger ∆t can be taken, the truncation error is often large, andthe exact transients (time variations of the dependant variable forunsteady flow simulation) may not be captured accurately by theimplicit scheme as compared to an explicit scheme.

Apparently finite-difference solutions seem to be straightforward. The over-all procedure is to replace the partial derivatives in the governing equations withfinite difference approximations and then finding out the numerical value of thedependant variables at each grid point. However, this impression is indeed in-correct! For any given application, there is no assurance that such calculationswill be accurate or even stable! Let us now discuss about accuracy and stability.

2.4 Errors and Stability Analysis

2.4.1 Introduction

There is a formal way of examining the accuracy and stability of linear equations,and this idea provides guidance for the behavior of more complex non-linearequations which are governing the equations for flow fields.

Consider a partial differential equation, such as Eq. (2.25). The numericalsolution of this equation is influenced by the following two sources of error.

Discretization:

This is the difference between the exact analytical solution of the partial dif-ferential Eq. (2.25) and the exact (round-off free) solution of the correspond-ing finite-difference equation (for example, Eq. (2.26). The discretization errorfor the finite-difference equation is simply the truncation error for the finite-difference equation plus any errors introduced by the numerical treatment ofthe boundary conditions.

Page 19: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.19

Round-off:

This is the numerical error introduced for a repetitive number of calculations inwhich the computer is constantly rounding the number to some decimal points.If A = analytical solution of the partial differential equation.D = exact solution of the finite-difference equationN = numerical solution from a real computer with finite accuracyThen, Discretization error = A - D = Truncation error + error introduced dueto treatment of boundary conditionRound-off error = ǫ = N - Dor,

N = D + ǫ (2.42)

where, ǫ is the round-off error, which henceforth will be called “error” for con-venience. The numerical solution N must satisfy the finite difference equation.Hence from Eq. (2.26)

Dn+1i + ǫn+1

i − Dni − ǫn

i

∆t= α

[

Dni+1 + ǫn

i+1 − 2Dni − 2ǫn

i + Dni−1 + ǫn

i−1

(∆x2)

]

(2.43)By definition, D is the exact solution of the finite difference equation, hence itexactly satisfies

Dn+1i − Dn

i

∆t= α

[

Dni+1 − 2Dn

i + Dni−1

(∆x2)

]

(2.44)

Subtracting Eq. (2.44) from Eq. (2.43)

ǫn+1i − ǫn

i

∆t= α

[

ǫni+1 − 2ǫn

i + ǫni−1

(∆x2)

]

(2.45)

From Equation 2.45, we see that the error ǫ also satisfies the difference equation.If errors ǫi are already present at some stage of the solution of this equation,

then the solution will be stable if the ǫi’s shrink, or at least stay the same, asthe solution progresses in the marching direction, i.e from step n to n + 1. Ifthe ǫi’s grow larger during the progression of the solution from step n to n + 1,then the solution is unstable. Finally, it stands to reason that for a solution tobe stable, the mandatory condition is

ǫn+1i

ǫni

≤ 1 (2.46)

For Eq. (2.26), let us examine under what circumstances Eq. (2.46) holds good.Assume that the distribution of errors along the x−axis is given by a Fourier

series in x, and the time-wise distribution is exponential in t, i.e,

ǫ(x, t) = eat∑

m

eIkmx (2.47)

Page 20: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.20 Computational Fluid Dynamics

where I is the unit complex number and k the wave number 1Since the differenceis linear, when Eq. (2.47) is substituted into Eq. (2.45), the behaviour of eachterm of the series is the same as the series itself. Hence, let us deal with justone term of the series, and write

ǫm(x, t) = eateIkmx (2.48)

Substitute Eq. (2.48) into ( 2.45) to get

ea(t+∆t)eIkmx − eateIkmx

∆t= α

[

eateIkm(x+∆x) − 2eateIkmx + eateIkm(x−∆x)

(∆x)2

]

(2.49)Divide Eq. (2.49) by eateIkmx

ea∆t − 1

∆t= α

[

eIkm∆x − 2 + e−Ikm∆x

(∆x)2

]

or,

ea∆t = 1 +α(∆t)

(∆x)2

(

eIkm∆x + e−Ikm∆x − 2)

(2.50)

Recalling the identity

cos(km∆x) =eIkm∆x + e−Ikm∆x

2

Eq. (2.50) can be written as

ea∆t = 1 +α(2∆t)

(∆x)2(cos(km∆x) − 1)

or,

ea∆t = 1 − 4α(∆t)

(∆x)2 sin2[(km∆x)/2] (2.51)

From Eq. (2.48), we can write

ǫn+1i

ǫni

=ea(t+∆t)eIkmx

eateIkmx= ea∆t (2.52)

Combining Eqns. (2.51),(2.52) and (2.46), we have

ǫn+1i

ǫni

= |ea∆t| =

1 − 4α(∆t)

(∆x)2 sin2

[

(km∆x)

2

]

≤ 1 (2.53)

1Let a wave travel with a velocity v. The time period “T ′′ is the time required for the

wave to travel a distance of one wave length λ, so that λ=vT . Wave number k is defined by

k = 2π/λ.

Page 21: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.21

Eq. (2.53) must be satisfied to have a stable solution. In Eq. (2.53) the factor

1 − 4α(∆t)

(∆x)2 sin2

[

(km∆x)

2

]

is called the amplification factor and is denoted by G.

Evaluating the inequality in Eq. (2.53) , the two possible situations whichmust hold simultaneously are(a)

1 − 4α(∆t)

(∆x)2 sin2

[

(km∆x)

2

]

≤ 1

Thus,

4α(∆t)

(∆x)2 sin2

[

(km∆x)

2

]

≥ 0

Since α(∆t)/(∆x)2 is always positive, this condition always holds.(b)

1 − 4α(∆t)

(∆x)2 sin2

[

(km∆x)

2

]

≥ −1

Thus,

4α(∆t)

(∆x)2 sin2

[

(km∆x)

2

]

− 1 ≤ 1

For the above condition to hold

α(∆t)

(∆x)2 ≤

1

2(2.54)

Eq. (2.54) gives the stability requirement for which the solution of the differenceEq. (2.26) will be stable. It can be said that for a given ∆x the allowed value

of ∆t must be small enough to satisfy Eq. (2.54). For α(∆t)/(∆x)2 ≤ (1/2) theerror will not grow in subsequent time marching steps in t, and the numericalsolution will proceed in a stable manner. On the contrary, if α(∆t)/(∆x)

2>

(1/2), then the error will progressively become larger and the calculation willbe useless.

The above mentioned analysis using Fourier series is called as the Von Neu-mann stability analysis.

Page 22: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.22 Computational Fluid Dynamics

2.4.2 First-Order Wave Equation

Before we proceed further, let us look at the system of first-order equationswhich are frequently encountered in a class of fluid flow problems. Consider thesecond-order wave equation

∂2u

∂t2= c2 ∂2u

∂x2(2.55)

Here c is the wave speed and u is the wave amplitude. This can be written asa system of two first-order equations. If v = ∂u/∂t and w = c(∂u/∂x), then wemay write ∂v/∂t = c(∂w/∂x) and ∂w/∂t = c(∂v/∂x).

Rather, the system of equations may be written as

∂U

∂t+ [A]

∂U

∂x= 0

which is a first-order equation.It is implicit that U = { v

w } and A =[

0 −c−c 0

]

. The eigenvalues λ of the [A]matrix are found by

det [A − λI] = 0, or λ2 − c2 = 0

Roots of the characteristic equation are λ1 = +c and λ2 = −c, representing twotravelling waves with speeds given by

(

dx

dt

)

1

= c and

(

dx

dt

)

2

= −c

The system of equations in this example is hyperbolic and it has also been seenthat the eigenvalues of the A matrix represent the characteristic differentialrepresentation of the wave equation. Euler’s equation may be treated as asystem of first-order wave equations. For Euler’s equations, in two dimensions,we can write a system of first order as

∂E

∂t+ [A]

∂E

∂x+ [B]

∂E

∂y= [S] (2.56)

where

E =

{

uv

}

, A =

[

u 00 u

]

,

B =

[

v 00 v

]

and S =

−1

ρ

∂p

∂x

−1

ρ

∂p

∂y

2.4.3 Stability of Hyperbolic and Elliptic Equations

Let us examine the characteristics of the first-order wave equation given by

∂u

∂t+ c

∂u

∂x= 0 (2.57)

Page 23: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.23

Here we shall represent the spatial derivative by the central difference form

∂u

∂x=

uni+1 − un

i−1

2∆x(2.58)

We shall replace the time derivative with a first-order difference , where u(t) isrepresented by an average value between grid points (i + 1) and (i − 1), i.e

u(t) =1

2(un

i+1 + uni−1)

Then∂u

∂t=

un+1i − 1

2 (uni+1 + un

i−1)

∆t(2.59)

Substituting Eqns. (2.58) and (2.59) into (2.57), we have

un+1i =

uni+1 + un

i−1

2− c

∆t

∆x

(uni+1 − un

i−1)

2(2.60)

The time derivative is called Lax method of discretization, after the well knownmathematician Peter Lax who first proposed it. If we once again assume anerror of the form

ǫm(x, t) = eateIkmx (2.61)

as done previously, and substitute this form into Eq. (2.60), following the samearguments as applied to the analysis of Eq. (2.26), the amplification factorbecomes

ea∆t = cos(km∆x) − IC sin(km∆x)

where C = c(∆t/∆x). The stability requirement is |ea∆t| ≤ 1. Finally thecondition culminates in

C = c∆t

∆x≤ 1 (2.62)

In Eq. (2.62), C is the Courant number. This equation restricts ∆t ≤ ∆x/c forthe solution of Eq. (2.62) to be stable. The condition posed by Eq. (2.62) iscalled the Courant-Friedrichs-Lewy condition, generally referred to as the CFLcondition.

Physical Example of Unstable Calculation

Let us take the heat conduction once again,

∂u

∂t= α

∂2u

∂x2(2.63)

Applying FTCS discretization scheme depicts simple explicit representationas

un+1i − un

i

∆t= α

[

uni+1 − 2un

i + uni−1

(∆x2)

]

(2.64)

Page 24: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.24 Computational Fluid Dynamics

or

un+1i = r (un

i+1 + uni−1) + (1 − 2r)un

i , where r = α∆t/(∆x2) (2.65)

This is stable only if r ≤ 1/2.Let us consider a case when r > 1/2. For r = 1 (which is greater than thestability restriction), we get un+1

i = 1 · (100 + 100)+ (1− 2) · 0 = 200oC, (whichis impossible). The values of u are shown in Fig. 2.6.

Next, an example demonstrating the application of Von Neumann method

ni−1 i i+1

n+1

100 C 0 C 100 C

200 C

0 0 0

0

∆t+ t

Figure 2.6: Physical violations resulting from r=1.

to multidimensional elliptic problems is taken up. Let us take the vorticitytransport equation:

∂ω

∂t+ u

∂ω

∂x+ v

∂ω

∂y= ν

[

∂2ω

∂x2+

∂2ω

∂y2

]

(2.66)

We shall extend the Von Neumann stability analysis for this equation, assum-ing u and v as constant coefficients (within the framework of linear stabilityanalysis). Using FTCS scheme

ωn+1i,j − ωn

i,j

∆t= − u

[

ωni+1,j − ωn

i−1,j

2∆x

]

− v

[

ωni,j+1 − ωn

i,j−1

2∆y

]

+ ν

[

ωni+1,j − 2ωn

i,j + ωni−1,j

(∆x2)

]

+ ν

[

ωni,j+1 − 2ωn

i,j + ωni,j−1

(∆y2)

]

(2.67)

Let us consider N = D + ǫ with

ǫ(x, y, t) = eat∑

m

e(Ikmx+Ikmy) (2.68)

where N is the numerical solution obtained from computer, D the exact solutionof the FDE and ǫ error. Substituting Eq. (2.68) into Eq. (2.67) and using thetrignometric identities, we finally obtain

ǫn+1i,j

ǫni,j

=ea(t+∆t)eIkm(x+y)

eateIkm(x+y)= ea∆t = G

Page 25: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.25

where

G =1 − 2(dx + dy) + 2dx cos(km∆x) + 2dy cos(km∆y)

− I[Cx sin(km∆x) + Cy sin(km∆y)]

where

dx =ν∆t

(∆x)2 , dy =

ν∆t

(∆y)2 , Cx =

u∆t

∆x, Cy =

v∆t

∆y

The obvious stability condition |G| ≤ 1, finally leads to

dx + dy ≤1

2, Cx + Cy ≤ 1 (2.69)

when

dx = dy = d (for ∆x = ∆y), d ≤1

4

which meansν∆t

(∆x)2 ≤

1

4

This is twice as restrictive as the one-dimensional diffusive limitation (comparewith Eq. (2.54). Again for the special case (u = v and ∆x = ∆y)

Cx = Cy = C, hence C ≤1

2

which is also twice as restrictive as one dimensional convective limitation (com-pare with Eq. (2.62).

Finally, let us look at the stability requirements for the second-order waveequation given by

∂2u

∂t2= c2 ∂2u

∂x2

We replace both the spatial and time derivatives with central difference scheme(which is second-order accurate)

un+1i − 2un

i + un−1i

(∆t)2 = c2

[

uni+1 − 2un

i + uni−1

(∆x)2

]

(2.70)

Again assume

N = D + ǫ (2.71)

and

ǫni = eateIkmx (2.72)

Substituting Eq. (2.72) and (2.71) in (2.70) and dividing both sides by eateIkmx,we get

ea∆t − 2 + e−a∆t = C2[

eIkm∆x + e−Ikm∆x − 2]

(2.73)

Page 26: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.26 Computational Fluid Dynamics

where

C, the Courant number =c(∆t)

∆x(2.74)

From Eq. (2.73), using trignometric identities, we get

ea∆t + e−a∆t = 2 − 4C2 sin2

(

km∆x

2

)

(2.75)

and, the amplification factor

G =

ǫn+1i

ǫni

= |ea∆t| (2.76)

However, from Eq. (2.75) we arrive at

e2a∆t − 2

[

1 − 2C2 sin2

(

km∆x

2

)]

ea∆t + 1 = 0 (2.77)

which is a quadratic equation for ea∆t. This equation, quite obviously, has tworoots, and the product of the roots is equal to +1. Thus, it follows that themagnitude of one of the roots (value of ea∆t) must exceed 1 unless both theroots are equal to unity.

But ea∆t is the magnification factor. If its value exceeds 1, the error will growexponentially which will lead to an unstable situation. All these possibilitiesmean that Eq (2.77) should possess complex roots in order that both have thevalues of ea∆t equal to unity. This implies that the discriminant of Eq. (2.77)should be negative.

[

1 − 2C2 sin2

(

km∆x

2

)]2

− 1 < 0 (2.78)

or

C2 <1

sin2(

km∆x2

) (2.79)

which is always true if C < 1. Hence CFL condition (C < 1), must again besatisfied for the stability of second-order hyperbolic equations.

In light of the above discussion, we can say that a finite-difference procedurewill be unstable if for that procedure, the solution becomes unbounded, i.e theerror grows exponentially as the calculation progresses in the marching direction.In order to have a stable calculation, we pose different conditions based onstability analysis. Here we have discussed the Von Neumann stability analysiswhich is indeed a linear stability analysis.

However, situations may arise where the amplification factor is always lessthan unity. These conditions are referred to as unconditionally stable. In asimilar way for some procedures, we may get an amplification factor which isalways greater than unity. Such methods are unconditionally unstable.

Page 27: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.27

Over and above, it should be realized that such stability analysis are notreally adequate for practical complex problems. In actual fluid flow problems,the stability restrictions are applied locally. The mesh is scanned for the mostrestrictive value of the stability limitations and the resulting minimum ∆t is usedthroughout the mesh. For variable coefficients, the Von Neumann condition isonly necessary but not sufficient. As such, stability criterion of a procedure is notdefined by its universal applicability. For nonlinear problems we need numericalexperimentation in order to obtain stable solutions wherein the routine stabilityanalysis will provide the initial clues to practical stability. In other words, itwill give tutorial guidance only.

2.5 Fundamentals of Fluid Flow Modeling

We have discussed the finite-difference methods with respect to the solution oflinear problems such as heat conduction. The problems of fluid mechanics aremore complex in character. The governing partial differential equations forma nonlinear system which must be solved for the unknown pressures, densities,temperatures and velocities.

Before entering into the domain of actual flow modeling, we shall discusssome subtle points of fluid flow equations with the help of a model equation.The model equation should have convective, diffusive and time-dependent terms.Burgers (1948) introduced a simple nonlinear equation which meets the aforesaidrequirements (Burger’s equation).

∂ζ

∂t+ u

∂ζ

∂x= ν

∂2ζ

∂x2(2.80)

Here, u is the velocity, ν is the coefficient of diffusivity and ζ is any propertywhich can be transported and diffused. If the viscous term (diffusive term) onthe right-hand side is neglected, the remaining equation may be viewed as asimple analog of Euler’s equation.

∂ζ

∂t+ u

∂ζ

∂x= 0 (2.81)

Now we shall see the behavior of Burger’s equations for different kinds of dis-cretization methods. In particular, we shall study their influence on conservativeand transportive property, and artificial viscosity.

2.5.1 Conservative Property

A finite-difference equation possesses conservative property if it preserves in-tegral conservation relations of the continuum. Let us consider the vorticitytransport equation

∂ω

∂t= −(V · ∇)ω + ν ∇2 ω (2.82)

Page 28: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.28 Computational Fluid Dynamics

where ∇ is nabla or differential operator, V the fluid velocity and ω thevorticity. If we integrate this over some fixed space region ℜ, we get

∂ω

∂tdℜ = −

(V · ∇)ωdℜ +

ν∇2ωdℜ (2.83)

The first term of the Eq. (2.83) can be written as

∂ω

∂tdℜ =

∂t

ω dℜ

The second term of the Eq.( (2.83)) may be expressed as

(V · ∇)ω dℜ = −

∇ · (V ω) dℜ = −

Ao

(V ω) · n dA

Ao is the boundary of ℜ, n is unit normal vector and dA is the differentialelement of Ao. The remaining term of Eq. (2.83) may be written as

ν

∇2 ω dℜ = ν

Ao

(∇ω) · n dA

As because,

ν

Ao

(∇ω) · n dA = ν

∇ · (∇ω) dℜ = ν

∇2ω dℜ

Finally, we can write

∂t

ω dℜ = −

Ao

(V ω) · n dA + ν

Ao

(∇ω) · n dA (2.84)

which implies that the time rate of accumulation of ω in ℜ is equal to netadvective flux rate of ω across Ao into ℜ plus net diffusive flux rate of ω acrossAo into ℜ. The concept of conservative property is to maintain this integralrelation in finite difference representation.For clarity , again let us consider inviscid Burger’s equation ((2.81)). This timewe let ζ = ω = vorticity, which means

∂ω

∂t= −

∂x(uω) (2.85)

The finite difference analog is given by FTCS method as

ωn+1i − ωn

i

∆t= −

uni+1ω

ni+1 − un

i−1ωni−1

2∆x(2.86)

Page 29: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.29

Let us consider a region ℜ running from i = I1 to i = I2 see (Figure 2.7). We

evaluate the the integral1

∆t

I2∑

i=I1

ω ∆x as

1

∆t

[

I2∑

i=I1

ωn+1i ∆x −

i=I2∑

i=I1

ωni ∆x

]

=

I2∑

i=I1

−(un

i+1ωni+1) − (un

i−1ωni−1)

2

=1

2

i=I2∑

i=I1

[(u ω)ni−1 − (u ω)n

i+1] (2.87)

Summation of the right hand side (running i from I1 to I2) finally gives

1

∆t

[

I2∑

i=I1

ωn+1i ∆x −

I2∑

i=I1

ωni ∆x

]

=1

2

[

(u ω)nI1−1 + (u ω)n

I1

]

� � � � � � � � � � � � � � � � � � �

−1

2

[

(u ω)nI2 + (u ω)n

I2+1

]

= (u ω)nI1−

1

2

− (u ω)nI2+

1

2

(2.88)

Eq. (2.88) states that the rate of accumulation of ωi in ℜ is identically equalto the net advective flux rate across the boundary of ℜ running from i = I1 toi = I2. Thus the FDE analogous to inviscid part of the integral Eq. (2.86) haspreserved the conservative property. As such, conservative property depends onthe form of the continuum equation used. Let us take non-conservative form ofinviscid Burger’s equation (2.81) as

∂ω

∂t= −u

∂ω

∂x(2.89)

Using FTCS differencing technique as before, we can write

ωn+1i − ωn

i

∆t= −un

i

[

ωni+1 − ωn

i−1

2∆x

]

(2.90)

Now, the integration over ℜ running from i = I1 to i = I2, yields

1

∆t

[

I2∑

i=I1

ωn+1i ∆x −

i=I2∑

i=I1

ωni ∆x

]

=

I2∑

i=I1

−uni

(ωni+1 − ωn

i−1)

2

=1

2

I2∑

i=I1

[uni ωn

i−1 − uni ωn

i+1] (2.91)

While performing the summation of the right-hand side of Eq. (2.91), it canbe observed that terms corresponding to inner cell fluxes do not cancel out.

Page 30: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.30 Computational Fluid Dynamics

Consequently an expression in terms of fluxes at the inlet and outlet section, asit was found earlier, could not be obtained. Hence the finite-difference analogEq. (2.90) has failed to preserve the integral Gauss-divergence property, i,e., theconservative property of the continuum.The quality of preserving the conservative property is of special importance

I 2

i

I1

Figure 2.7: Domine running from i = I1 to i = I2.

with regards to the methods involving finite-volume approach(a special formof finite-difference equation). The use of conservative form depicts that the

advective flux rate of ω out of a control volume at the interface i = I2 +1

2is

exactly equal to flux rate of ω in to the next control volume and so on. Themeaning of calling Eq. (2.85)as “conservative form” is now clearly understood.However, the conservative form of advective part is of prime importance formodeling fluid flow and is often referred to as weak conservative form. For theincompressible flow in Cartesian coordinate system this form is :

∂u

∂t+

∂u2

∂x+

∂uv

∂y+

∂uw

∂z= −

1

ρ

∂p

∂x+ ν∇2u

∂v

∂t+

∂uv

∂x+

∂v2

∂y+

∂vw

∂z= −

1

ρ

∂p

∂y+ ν∇2v

∂w

∂t+

∂uw

∂x+

∂vw

∂y+

∂w2

∂z= −

1

ρ

∂p

∂z+ ν∇2w (2.92)

If all the terms in the flow equation are recast in the form of first- order deriva-tives of x, y, z and t , the equations are said to be in strong“ conservativeform”. We shall write the strong conservation form of Navier-Stokes equationin Cartesian coordinate system:

∂u

∂t+

∂x(u2 +

p

ρ− ν

∂u

∂x) +

∂y(uv − ν

∂u

∂y) +

∂z(uw − ν

∂u

∂z) = 0

∂v

∂t+

∂x(uv − ν

∂u

∂x) +

∂y(v2 +

p

ρ− ν

∂v

∂y) +

∂z(vw − ν

∂v

∂z) = 0

∂w

∂t+

∂x(uw − ν

∂w

∂x) +

∂y(wv − ν

∂w

∂y) +

∂z(w2 +

p

ρ− ν

∂w

∂z) = 0 (2.93)

Page 31: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.31

2.5.2 The Upwind Scheme

Once again,we shall start with the inviscid Burger’s equation. (2.81). Regardingdiscretization, we can think about the following formulations

ζn+1i − ζn

i

∆t+ u

ζni+1 − ζn

i

∆x= 0 (2.94)

ζn+1i − ζn

i

∆t+ u

ζni+1 − ζn

i−1

2 ∆x= 0 (2.95)

If Von Neumann’s stability analysis is applied to these schemes, we find thatboth are unconditionally unstable.

A well known remedy for the difficulties encountered in such formulations isthe upwind scheme which is described by Gentry, Martin and Daly (1966) andRunchal and Wolfshtein (1969). Eq. (2.94) can be made stable by substitutingthe forward space difference by a backward space difference scheme, providedthat the carrier velocity u is positive. If u is negative, a forward differencescheme must be used to assure stability. For full Burger’s equation. (2.80), theformulation of the diffusion term remains unchanged and only the convectiveterm (in conservative form) is calculated in the following way (Figure 2.8):

ζn+1i − ζn

i

∆t= −

u ζni − u ζn

i−1

∆x+ viscous term, for u > 0 (2.96)

ζn+1i − ζn

i

∆t= −

u ζni+1 − u ζn

i

∆x+ viscous term, for u < 0 (2.97)

It is also well known that upwind method of discretization is very much necessaryin convection (advection) dominated flows in order to obtain numerically stableresults. As such, upwind bias retains transprotative property of flow equation.Let us have a closer look at the transportative property and related upwindbias.

ii−2 i−1 i+1 i+2

∆ x

u

u

∆ x

Figure 2.8: The Upwind Scheme.

2.5.3 Transportive Property

A finite-difference formulation of a flow equation possesses the transportiveproperty if the effect of a perturbation is convected (advected) only in the di-rection of the velocity.

Page 32: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.32 Computational Fluid Dynamics

Consider the model Burger’s equation in conservative form

∂ζ

∂t= −

∂u ζ

∂x(2.98)

Let us examine a method which is central in space. Using FTCS we get

ζn+1i − ζn

i

∆t= −

u ζni+1 − u ζn

i−1

2∆x(2.99)

Consider a perturbation ǫm = δ in ζ. A perturbation will spread in all directionsdue to diffusion. We are taking an inviscid model equation and we want theperturbation to be carried along only in the direction of the velocity. So, foru > 0, ǫm = δ (perturbation at mth space location), all other ǫ = 0. Therefore,at a point (m + 1) downstream of the perturbation

ζn+1m+1 − ζn

m+1

∆t= −

0 − u δ

2∆x= +

u δ

2∆x

which is acceptable. However, at the point of perturbation (i = m),

ζn+1m − ζn

m

∆t= −

0 − 0

2∆x= 0

which is not very reasonable. But at the upstream station (i = m − 1) weobserve

ζn+1m−1 − ζn

m−1

∆t= −

u δ − 0

2∆x= −

u δ

2∆x

which indicates that the transportive property is violated.On the contrary, let us see what happens when an upwind scheme is used.

We know that for u > 0

ζn+1i − ζn

i

∆t= −

u ζni − u ζn

i−1

∆x(2.100)

Then for ǫm = δ at the downstream location (m + 1)

ζn+1m+1 − ζn

m+1

∆t= −

0 − u δ

∆x= +

u δ

∆x

which follows the rationale for the transport property.At point m of the disturbance

ζn+1m − ζn

m

∆t= −

u δ − 0

∆x= −

u δ

∆x

which means that the perturbation is being transported out of the affectedregion.Finally, at (m − 1) station, we observe that

ζn+1m−1 − ζn

m−1

∆t= −

0 − 0

∆x= 0

Page 33: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.33

This signifies that no perturbation effect is carried upstream. In other words, theupwind method maintains unidirectional flow of information. In conclusion, itcan be said that while space centred differences are more accurate than upwinddifferences, as indicated by the Taylor series expansion, the whole system is notmore accurate if the criteria for accuracy includes the transportive property aswell.

2.5.4 Upwind Differencing and Artificial Viscosity

Consider the model Burger’s equation. (2.80) and focus the attention on theinertia terms

∂ζ

∂t+ u

∂ζ

∂x= ν

∂2ζ

∂x2

As seen, the simple upwind scheme gives

ζn+1i − ζn

i

∆t= −

u ζni − u ζn

i−1

∆x+ · · · for u > 0

ζn+1i − ζn

i

∆t= −

u ζni+1 − u ζn

i

∆x+ · · · for u < 0

From Taylor series expansion, we can write

ζn+1i = ζn

i + ∆t∂ζ

∂t

n

i

+(∆t)

2

2

∂2ζ

∂t2

n

i

+ · · · (2.101)

ζni±1 = ζn

i ± ∆x∂ζ

∂x

n

i

+(∆x)

2

2

∂2ζ

∂x2

n

i

± · · · (2.102)

Substituting Eqns. (2.101) and (2.102) into (2.96) gives (dropping the subscripti and superscript n)

1

∆t

[

∆t∂ζ

∂t+

(∆t)2

2

∂2ζ

∂t2+ O(∆t)3

]

= −u

∆x

[

∆x∂ζ

∂x−

(∆x)2

2

∂2ζ

∂x2+ O(∆x)3

]

+ [Diffusive term]

or∂ζ

∂t= −u

∂ζ

∂x+

1

2

[

u ∆x

(

1 −u ∆t

∆x

)]

∂2ζ

∂x2+ ν

∂2ζ

∂x2+ O(∆x)2

which may be rewritten as

∂ζ

∂t= −u

∂ζ

∂x+ ν

∂2ζ

∂x2+ νe

∂2ζ

∂x2+ higher-order terms (2.103)

where

νe =1

2[u ∆x (1 − C)], C (Courant number)=

u ∆t

∆x

Page 34: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.34 Computational Fluid Dynamics

In deriving Eq. (2.103), ∂2ζ/∂t2 was taken as u2∂2ζ/∂x2. However, the non-physical coefficient νe leads to a diffusion like term which is dependent on thediscretization procedure. This νe is known as the numerical or artificial viscosity.Let us look at the expression.

νe =1

2[u ∆x (1 − C)] for u > 0 (2.104)

somewhat more critically. On one hand we have considered that u > 0 andon the other CFL condition demands that C < 1 (so that the algorithm canwork). As a consequence, νe is always a positive non-zero quantity (so that thealgorithm can work). If, instead of analysing the transient equation, we put∂ζ/∂t = 0 in Eq. (2.96) and expand it in Taylor series, we obtain

νe =1

2u ∆x (2.105)

Let us now consider a two-dimensional convective-diffusive equation with viscousdiffusion in both directions(Eq. (2.67) but with ω = ζ). For ui, vi > 0, upwinddifferencing gives

ζn+1i,j − ζn

i,j

∆t= −

u ζni,j − u ζn

i−1,j

∆x−

v ζni,j − v ζn

i,j−1

∆y

+ ν

[

ζni+1,j − 2ζn

i,j + ζni−1,j

(∆x)2

+ζni,j+1 − 2ζn

i,j + ζni,j−1

(∆y)2

]

(2.106)

The Taylor series procedure as was done for Eq. (2.103) will produce

∂ζ

∂t= −u

∂ζ

∂x− v

∂ζ

∂y+ (ν + νex)

∂2ζ

∂x2+ (ν + νey)

∂2ζ

∂y2(2.107)

where

νex =1

2[u ∆x(1 − Cx)],

νey =1

2[v ∆y(1 − Cy)]; with Cx =

u ∆t

∆x, Cy =

v ∆t

∆y

As such for u ≈ v and ∆x = ∆y, CFL condition is Cx = Cy ≤ (1/2). Thisindicates that for a stable calculation, artificial viscosity will necessarily bepresent. However, for a steady-state analysis, we get

νex =1

2u ∆x; νey =

1

2v ∆y (2.108)

We have observed that some amount of upwind effect is indeed necessary tomaintain transportive property of flow equations while the computations basedon upwind differencing often suffer from false diffusion (inaccuracy!). One ofthe plausible improvements is the usage of higher-order upwind method of dif-ferencing. Next subsection discusses this aspect of improving accuracy.

Page 35: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.35

2.5.5 Second Upwind Differencing or Hybrid Scheme

According to the second upwind differencing, if u is the velocity in x directionand ζ is any property which can be convected or diffused, then

∂(uζ)

∂x

i,j

=uR ζR − uL ζL

∆x(2.109)

One point to be carefully observed from Eq. (2.109) is that the second upwindshould be written in conservative form. However, the definition of uR and uL

are (see Fig. 2.9):

uR =ui,j + ui+1,j

2; uL =

ui,j + ui−1,j

2(2.110)

Now,

ζR = ζi,j for uR > 0 ; ζR = ζi+1,j for uR < 0 (2.111)

and

ζL = ζi−1,j for uL > 0 ; ζL = ζi,j for uL < 0 (2.112)

Finally, for uR > 0 and uL > 0, we get

∂(uζ)

∂x=

1

∆x

[(

ui,j + ui+1,j

2

)

ζi,j −

(

ui,j + ui−1,j

2

)

ζi−1,j

]

(2.113)

Let us discretize the second term of the convection part of unsteady x-directionmomentum equation. We have chosen this in order to cite a meaningful exampleof second upwind differencing. Using Eq. (2.113), we can write

∂u2

∂x

i,j

=1

∆x

[(

ui,j + ui+1,j

2

)

ui,j −

(

ui,j + ui−1,j

2

)

ui−1,j

]

=1

∆x

[(

ui,j + ui+1,j

2

) (

ui,j + ui+1,j + ui,j − ui+1,j

2

)

(

ui,j + ui−1,j

2

) (

ui−1,j + ui,j + ui−1,j − ui,j

2

) ]

=1

4∆x[(ui,j + ui+1,j)[(ui,j + ui+1,j) + (ui,j − ui+1,j)]

− (ui−1,j + ui,j)[(ui−1,j + ui,j) + (ui−1,j − ui,j)]]

=1

4∆x

[

(ui,j + ui+1,j)2 + (u2

i,j − u2i+1,j)

− (ui−1,j + ui,j)2 − (u2

i−1,j − u2i,j)

]

(2.114)

Page 36: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.36 Computational Fluid Dynamics

i−2,j i−1,j i,j i+1,j i+2,j

u uRL

x

Figure 2.9: Definition of uR and uL.

Here we introduce a factor η which can express Eq. (2.114) as a weightedaverage of central and upwind differencing. Invoking this weighted averageconcept in Eq. (2.114), we obtain

∂u2

∂x=

i,j

=1

4∆x

[

(ui,j + ui+1,j)2 + η|(ui,j + ui+1,j)|(ui,j − ui+1,j)

− (ui−1,j + ui,j)2 − η|(ui−1,j + ui,j)|(ui−1,j − ui,j)

]

(2.115)

where 0 < η < 1. For η = 0, Eq. (2.115) becomes centred in space and for η = 1it becomes full upwind. So η brings about the upwind bias in the differencequotient. If η is small, Eq. (2.115) tend towards centred in space. This upwindmethod was first introduced by Gentry, Martin and Daly (1966). Some morestimulating discussions on the need of upwinding and its minimization has beendiscussed by Roache (1972) who has also pointed out that the second upwind-formulation possesses both the conservative and transportive property providedthe upwind factor (formally called donorcell factor) is not too large. In principle,the weighted average differencing scheme can as well be called as hybrid scheme(see Raithby and Torrence, 1974) and the accuracy of the scheme can always beincreased by a suitable adjustment of η value.

2.5.6 Some More Suggestions for Improvements

Several researchers have tried to resolve the difficulty associated with the dis-cretization of the first-order terms which need some amount of artificial viscosityfor stability. Substantial progress has been made on the development of higher-order schemes which are suitable over a large range of velocities. However, noneof these prescriptions are universal. Depending on the nature of the flow andgeometry one can always go for the best suited algorithm. Now we shall discussone such algorithm which has been proposed by Khosla and Rubin (1974).

Consider the Burger’s equation. (2.80) once again. The derivatives in thisequation are discretized in the following way.

Page 37: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.37

For u > 0

∂ζ

∂t=

ζn+1i − ζn

i

∆t(Forward time)

∂ζ

∂x=

ζn+1i − ζn+1

i−1

∆x+

ζni+1 − 2ζn

i + ζni−1

2∆x

This is modified central difference in space, which for a converged solution(ζn+1

i = ζni ) reduces to space centred scheme. Now, consider the diffusion

term∂2ζ

∂x2=

ζn+1i+1 − 2ζn+1

i + ζn+1i−1

(∆x)2

This is central difference in space. Substituting the above quotients in Eq. (2.80),one finds

−Aζn+1i+1 + Bζn+1

i − Cζn+1i−1 = Di (2.116)

where

A =ν∆t

(∆x)2, C =

u∆t

∆x+

ν∆t

(∆x)2, B = 1 +

u∆t

∆x+ 2

ν∆t

(∆x)2

and

Di =

(

1 +u∆t

∆x

)

ζni −

u∆t

2∆x(ζn

i+1 + ζni−1) (2.117)

For ui > 0, Ai, Bi and Ci > 0 and Bi > Ai + Ci. The system of equations pro-duced from Eq. (2.116) is always diagonally dominant and capable of providinga stable solution. As the solution progresses (i.e. un

i → un+1i ), the convective

term approaches second-order accuracy. This method of implementing higher-order upwind is known as the “deferred correction procedure”.

Another widely suggested improvement is known as third-order upwind dif-ferencing (see Kawamura et al. 1986). The following example illustrates theessence of this discretization scheme.

(

u∂u

∂x

)

i,j

= ui,j

[

−ui+2,j + 8 (ui+1,j − ui−1,j) + ui−2,j

12 ∆x

]

+ |ui,j |

[

ui+2,j − 4 ui+1,j + 6 ui,j − 4 ui−1,j + ui−2,j

4 ∆x

]

(2.118)

Higher order upwinding is an emerging area of research in Computational FluidDynamics. However, so far no unique suggestion has been evolved as an opti-mal method for a wide variety of problems. Interested readers are referred to

Page 38: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.38 Computational Fluid Dynamics

Vanka (1987), Fletcher (1988) and Rai and Moin (1991) for more stimulatinginformation on related topics.

One of the most widely used higher order schemes is known as QUICK(Leonard, 1979). The QUICK scheme may be written in a compact manner inthe following way

f∂u

∂x

i

= fi

[

ui−2 − 8 ui−1 + 8 ui+1 − ui+2

12 ∆x

]

+ fi

{

(∆x)2

24

}[

−ui−2 + 2 ui−1 − 2 ui+1 + ui+2

(∆x)3

]

+ |fi|

{

(∆x)3

16

}[

ui−2 − 4 ui−1 + 6 ui − 4 ui+1 + ui+2

(∆x)4

]

(2.119)

The fifth-order upwind scheme (Rai and Moin, 1991) uses seven points stencilalong with a sixth-order dissipation. The scheme is expressed as

f∂u

∂x

i

= fi

[

ui+3 − 9 ui+2 + 45 ui+1 − 45 ui−1 + 9 ui−2 − ui−3

60 ∆x

]

− α|fi|

[

ui+3 − 6 ui+2 + 15 ui+1 − 20 ui + 15 ui−1 − 6 ui−2 + ui−3

60 ∆x

]

(2.120)

2.6 Some Non-Trivial Problems with Discretized

Equations

The discussion in this section is based upon some ideas indicated by Hirt (1968)which are applied to model Burger’s equation as

ζn+1i − ζn

i

∆t+ u

ζni+1 − ζn

i−1

2∆x= ν

[

ζni+1 − 2 ζn

i + ζni−1

(∆x)2

]

(2.121)

From this, the modified equation becomes[vide Art.2.5.4]

∂ζ

∂t+ u ζx =

(

ν −u2∆t

2

)

ζxx (2.122)

We define

r =ν(∆t)

(∆x)2; C =

u∆t

∆x= Courant number

It is interesting to note that the values r = 1/2 and C = 1 (which are extremeconditions of Von Neumannn stability analysis) unfortunately eliminates viscousdiffusion completely in Eq. (2.122) and produce a solution from Eq. (2.121)

Page 39: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.39

directly as ζn+1i = ζn

i−1 which is unacceptable. From Eq. (2.122) it is clear thatin order to obtain a solution for convection diffusion equation, we should have

ν −u2∆t

2> 0

For meaningful physical result in the case of inviscid flow we require

ν −u2∆t

2= 0

Combining these two criteria, for a meaningful solution

ν −u2∆t

2≥ 0

or

ν

[

1 −1

2

u ∆t

∆x·u ∆x

ν

]

≥ 0 (2.123)

Here we define the mesh Reynolds-number or cell-peclet number as

Re∆x =u∆x

ν= Pe∆x

So, we get

ν

[

1 −1

2C · Re∆x

]

≥ 0

or

Re∆x ≤2

C(2.124)

The plot of C vs Re∆x is shown in Fig. 2.10 to describe the significance ofEq. (2.124). From the CFL condition, we know that the stability requirement isC ≤ 1. Under such a restriction, below Re∆x = 2, the calculation is always sta-ble. The interesting information is that it is possible to cross the cell Reynoldsnumber of 2 if C is made less than unity.

References

1. Anderson, D.A., Tannehill, J.C, and Pletcher, R.H., Computaional FluidMechanics and Heat Transfer, Hemisphere Publishing Corporation, NewYork, USA, 1984.

2. Burgers, J.M., A Mathematical Model Illustrating the Theory of Turbu-lence, Adv. Appl. Mech., Vol. 1, pp. 171-199, 1948.

3. DuFort, E.C. and Frankel, S.P., Stability Conditions in the NumericalTreatment of Parabolic Differential Equations, Mathematical Tables and

Others Aids to Computation, Vol. 7, pp. 135-152, 1953.

Page 40: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.40 Computational Fluid Dynamics

02 4 6 8

1

2

Re∆x

CFLrestriction

C

3

Figure 2.10: Limiting Line (Re∆x ≤2

C).

4. Fletcher, C.A.J., Computational Techniques for Fluid Dynamics, Vol. 1(Fundamentals and General Techniques), Springer Verlag, 1988.

5. Gentry, R.A., Martin, R.E. and Daly, B.J., An Eulerian DifferencingMethod for Unsteady Compressible Flow Problems, J. Comput. Phys.,Vol. 1, pp. 87-118, 1966.

6. Hirt, C.W., Heuristic Stability Theory of Finite Difference Equation, J.

Comput. Phys., Vol. 2, pp. 339-355, 1968.

7. Kawamura, T., Takami, H. and Kuwahara, K., Computation of HighReynolds Number Flow around a Circular Cylinder with Surface Rough-ness, Fluid Dynamics Research, Vol. 1, pp. 145-162, 1986.

8. Khosla, P.K. and Rubin, S.G., A Diagonally Dominant Second Order Ac-curate Implicit Scheme, Computers and Fluids, Vol. 2, pp. 207-209, 1974.

9. Lax, P.D. and Wendroff, B. Systems of Conservation Laws, Pure Appl.

Math, Vol. 13, pp. 217-237, 1960.

10. Leonard, B.P., A Stable and Accurate Convective Modelling Procedurebased on Quadratic Upstream Interpolation, Comp. Methods Appl. Mech.

Engr., Vol. 19, pp. 59-98, 1979.

11. Rai, M.M. and Moin, P., Direct Simulations of Turbulent Flow UsingFinite Difference Schemes, J. Comput. Phys., Vol. 96, pp. 15-53, 1991.

Page 41: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.41

12. Raithby, G.D. and Torrance, K.E., Upstream-weighted Differencing Schemesand Their Applications to Elliptic Problems Involving Fluid Flow, Com-

puters and Fluids, Vol. 2, pp. 191-206, 1974.

13. Roache, P.J., Computational Fluid Dynamics, Hermosa, Albuquerque,New Mexico, 1972 (revised pritning 1985).

14. Runchal, A.K. and Wolfshtein, M., Numerical Integration Procedure forthe Steady State Navier-Stokes Equations, J. Mech. Engg. Sci., Vol. 11,pp. 445-452, 1969.

15. Thomas, L.H., Elliptic Problems in Linear Difference Equations Over aNetwork, Watson Sci. Comput. Lab. Rept., Columbia University, NewYork, 1949.

16. Vanka, S.P., Second-Order Upwind Differencing in a Recirculating Flow,AIAA J., Vol. 25, pp. 1435-1441, 1987.

Problems

1. Consider the nonlinear equation

u∂u

∂x= µ

∂2u

∂y2(2.125)

where µ is a constant and u the x component of velocity. The normaldirection is y.(a)Is this equation in conservative form? If not, suggest a conservativeform of the equation.(b) Consider a domain in x (x = 0 to x = L) and y (y = 0 to y = H)and assume that all the values of the dependent variable are known atx = 0 (along y = 0 to y = H at every ∆y interval). Develop an implicitexpression for determining u at all the points along (y = 0 to y = H) andthe next (x + ∆x)

2. Establish the truncation error of the following finite-difference approxima-tion to ∂T/∂y at the point (i, j) for a uniform mesh

∂T

∂y=

−3 Ti,j + 4 Ti,j+1 − Ti,j+2

2 (∆y)

What is the order of the truncation error? If you want to apply a second-order-accurate boundary condition for ∂T/∂y = 0 at the boundary (referto Fig. 2.11), can you make use of the above mentioned expression? Ifyes, what should be the expression for Ti,j at the boundary?

Page 42: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.42 Computational Fluid Dynamics

Boundary

y

1

2

3

∆y

∆y

Figure 2.11: Grid points at a boundary.

3. The Lax-Wendroff finite difference scheme (Lax and Wendroff , 1960) canbe derived from a Taylor series expansion in the following manner:

un+1i = un

i + ∆t ut +1

2(∆t)2utt + O[(∆t)3]

Using the wave equations

ut = −c ux

utt = c2 uxx

the Taylor series expansion may be written as

un+1i = un

i −c ∆t

2 (∆x)(un

i+1 − uni−1) +

c2(∆t)2

2 (∆x)2(un

i+1 − 2uni + un

i−1)

Prove that the CFL condition is the stability requirement for the abovediscretization scheme.

4. A three-level explicit discretization of

∂u

∂t= α

∂2u

∂x2

can be written as

Page 43: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.43

0.5 T n−1i − 2 T n

i + 1.5 T n+1i

∆t= α

[

(1 + d) (Ti−1 − 2 Ti + Ti+1)n

(∆x)2

−d (Ti−1 − 2 Ti + Ti+1)

n−1

(∆x)2

]

Expand each term as a Taylor series to determine the truncation error ofthe complete equation for arbitrary values of d. Suggest the general tech-nique where for a functional relationship between d and r[= α∆t/(∆x)2]the scheme will be fourth-order accurate in ∆x.

5. Consider the equation

∂T

∂t+ u

∂T

∂x+ v

∂T

∂y= α

[

∂2T

∂x2+

∂2T

∂y2

]

where T is the dependent variable which is convected and diffused. Theindependent variables , x and y, are in space while t is the time (evolution)coordinate. The coefficient u, v and α can be treated as constant. Em-ploying forward difference for the first-order derivatives and central-seconddifference for the second derivatives, obtain the finite-difference equation.What is the physical significance of the difference between the above equa-tion and the equation actually being solved? Suggest any method to over-come this difference.

Write down the expression for the Finite Difference Quotient for the con-vective term of the Burgers Equation given by

∂ω

∂t+ u

∂ω

∂x= ν

∂2ω

∂x2(2.126)

Use upwind differencing on a weak conservative form of the equation.The upwind differencing is known to retain the transportive property.Show that the formulation preserves the conservative property of the con-tinuum as well [you are allowed to exclude the diffusive term from theanalysis].

6. In order to investigate and analyze the properties of numerical schemes,often the following scalar (one-dimensional) convection equation is con-sidered:

∂ω

∂t+ λ

∂ω

∂x= 0

Here ω is any scalar parameter. The spatial derivative is approximated bya central difference scheme on an equidistant grid with ∆x = Constant.Please explain the following time-marching schemes based on the scalartransport equation:

Page 44: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

2.44 Computational Fluid Dynamics

A: explicit Euler scheme

B: implicit Euler scheme

C: three-point backward scheme (implicit)

D: Lax-Keller scheme (explicit)

E: Lax-Wendroff scheme (explicit)

F: Mac Cormack scheme (predictor-corrector, explicit)

G: Low-storage Runge-Kutta scheme (3 sub-steps, explicit)

AppendixThomas algorithm

We have already seen in Chapter2 that in Crank Nicolson solution procedure,we get a system of algebric equations which assumes the form of a tridiagonalmatrix problem. Here we shall discuss a very well known solution procedureknown as Thomas algorithm(1949) which utilizes efficiently the advantage ofthe tridiagonal form. A tridiagonal system is:

d1 a1 0 0 . . . . . . 0b2 d2 a2 0 0 .0 b3 d3 a3 0 0 .0 0 b4 d4 a4 0 0. 0 00 aN−1

0 . . . . . . . . . 0 bN dN

x1

x2

x3

x4

.

.xN

=

c1

c2

c3

c4

.

.cN

The Thomas Algorithm is a modified Gaussian matrix-solver applied to a tridaig-onal system. The idea is to transform the coefficient matrix into a upper trian-gular form. The intermediate steps that solve for x1, x2...xN :Change di and ci arrays as

dnewi = dold

i −

[

bi

di−1ai−1

]old

, i = 2, 3 . . .N

and

dnew1 = dold

1

Similarly

cnewi = cold

i −

[

bi

di−1ci−1

]old

, i = 2, 3 . . .N

and

cnew1 = cold

1

Page 45: Finite Difference Method · 2015. 9. 23. · Finite Difference Method 2.3 2.1.1 Boundary and Initial Conditions In addition to the governing differential equations, the formulation

Finite Difference Method 2.45

At this stage the matrix in upper triangular form. The solution is then obtainedby back substitution as

xN =cN

dN

and

xk =ck − ak xk+1

dk, k = N − 1, N − 2, N − 3, . . . 1