Computational Fluid Dynamics
MPE 447
Elective course III
L6: Discretization – Finite Difference
Method
Dr. Mohamed El-Ghandour
2024-2025
Last Lecture Contents
• Introduction
• Discretization
• Finite difference method
contents
• Review of the last lecture
• Polynomial distribution
• Basic Aspects of Finite-Difference Equations
• Explicit approach
• Implicit approach
• Errors and an Analysis of Stability
Polynomial distribution
• Consider the situation of the nodes near the wall as
shown in Fig. 5-2.
• The problem is how to estimate the
second ordered first derivative at point
1 at the wall.
• Using Taylor series as we had just 𝑢 = 𝑎 + 𝑏∆𝑦 + 𝑐
studied fails to estimate this
requirement as it needs two points in
both sides of point 1, which is not
feasible.
• An alternative is to assume a polynomial distribution
of the velocity as
• This is our desired second-order-accurate difference
quotient at the boundary.
• Both Eqs. (5.15) and (5.22) are called one-sided
differences, because they express a derivative at a
point in terms of dependent variables on only one
side of the point.
• Many other one-sided differences can be formed,
with higher degrees of accuracy, using additional grid
points to one side of the given point.
• It is not unusual to see four- and five-point one-sided
differences applied at a boundary.
Basic Aspects of Finite-Difference Equations
• Consider the following model equation, in which we
assume that the dependent variable u is a function
of x and t.
• If we replace the time derivative in Eq. (5.23) with a
forward difference, and the spatial derivative with a
central difference, the result is:
In Eq. (5.24), the index for time usually appears as a superscript in CFD, where n denotes
conditions at time t, (n+1) denotes conditions at time (t+Δt), and so forth.
The subscript still denotes the grid point location; for the one spatial dimension
considered here, clearly we need only one index, i.
What is the truncation error for the complete finite-
difference equation? There must be a truncation error
because each one of the finite difference quotients has
its truncation error. Let us address this question.
Combining Eqs. (5.23) and (5.24) and explicitly writing
the truncation errors associated with the difference
quotients (from Eqs. (5.4) and (5.10)), we have
• Examining Eq. (5.25), on the left-hand side is the original
partial differential equation, the first two terms on the right-
hand side are the finite difference representation of this
equation and the terms in the square brackets are the
truncation error for the complete equation.
• Note that the truncation error for this representation is O[Δt,
(Δx)2].
• Does the finite-difference equation reduce to the original
differential equation as the number of grid points goes to
infinity, i.e., i.e.asΔx→0andΔt→0?
• Examining Eq.(5.25), we note that the truncation error
approaches zero, and hence the difference equation does
indeed approach the original differential equation.
• When this is the case, the finite-difference representation of
the partial differential equation is said to be consistent.
Examining Eq.(5.24),we see that it contains only one
unknown, namely 𝑢𝑗𝑛+1 .
In this fashion, the dependent variable at time (t+Δt)
can be obtained explicitly from the known results at
time t, i.e. 𝑢𝑗𝑛+1 is obtained directly from the known
𝑛
values 𝑢𝑗+1 , 𝑢𝑗𝑛 ,and 𝑢𝑗−1
𝑛
.This is an example of an
explicit finite-difference solution.
As a counter example, let us be daring and return to
the original partial differential equation given by
Eq.(5.23). This time, we write the spatial differences on
the right-hand side in terms of average properties
between n and (n+1), that is
The differencing shown in Eq.(5.26) is called the Crank-Nicolson
form.
Examine Eq. (5.26) closely. The unknown 𝑢𝑗𝑛+1 i is not only
expressed in terms of the known quantities at time index n,
𝑛
namely 𝑢𝑗+1 , 𝑢𝑗𝑛 ,and 𝑢𝑗−1
𝑛
, but also in terms of unknown
𝑛+1 𝑛+1
quantities at time index n+1, namely 𝑢𝑗+1 and 𝑢𝑗−1 . Hence,
Eq.(5.26) applied at a given grid point in the solution for 𝑢𝑗𝑛+1 .
Rather, Eq.(5.26) must be written at all grid points, resulting in a
system of algebraic equations from which the unknown 𝑢𝑗𝑛+1 for
all I can be solved simultaneously. This is an example of an
implicit finite-difference solution. Because they deal with the
solution of large systems of simultaneous linear algebraic
equations, implicit methods are usually involved with the
manipulation of large matrices. The relative major advantages
and disadvantages of these two approaches are summarized as
follows.
Explicit approach
Advantage:
Relatively simple to setup and program.
Accurate for unsteady solutions
Disadvantage:
In terms of our above example, for a given Δx, Δt must
be less than some limit imposed by stability constraints.
In many cases, Δt must be very small to maintain
stability; this can result in long computer running times
to make calculations over a given interval of t.
Implicit approach
Advantage:
Stability can be maintained over much larger values of Δt, hence
using considerably fewer time steps to make calculations over a
given interval of t. This results in less computer time.
Disadvantage:
More complicated to set up and program.
Since massive matrix manipulations are usually required at each
time step, the computer time per time step is much larger than
in the explicit approach.
Since large Δt can be taken, the truncation error is larger, and the
use of implicit methods to follow the exact transients (time
variations of the independent variable) may not be as accurate
as an explicit approach. However, for a time-dependent solution
in which the steady state is the desired result, this relative time-
wise inaccuracy is not important.
Implicit approach
Disadvantage cont.:
During the period 1969 to about 1979, the vast majority of
practical CFD solutions involving ‘marching’ solutions (such
as in the above example) employed explicit methods.
Today, they are still the most straightforward methods for
flow field solutions. However, many of the more
sophisticated CFD applications—those requiring very
closely-spaced grid points in some regions of the flow—
would demand inordinately large computer running times
due to the small marching steps required. This has made
the advantage listed above for implicit methods very
attractive, namely the ability to use large marching steps
even for a very fine grid. For this reason, implicit methods
are today the major focus of CFD applications.
5.4 Errors and an Analysis of Stability
The numerical solution of this equation is influenced by two
sources of error:
1. Discretization error.
The difference between the exact analytical solution of the
partial differential equation (for example, Eq. (5.23)) and
the exact (round-off free) solution of the corresponding
difference equation (for example, Eq. (5.24)).
The discretization error is simply the truncation error for
the difference equation plus any errors introduced by the
numerical treatment of the boundary conditions.
2. Round-off error.
The numerical error introduced after a repetitive number of
calculations in which the computer is constantly rounding
the numbers to some significant figure.
If we let
A = analytical solution of the partial differential
equation,
D = exact solution of the difference equation, and
N = numerical solution from a real computer with finite
accuracy then, From Eq. (5.27), we can write
Discretization error = A−D,
Round-off, ε = N−D (5.27)
Hence, N = D + ε (5.28)
• The solution will be stable if the εi’s shrink, or at best
stay the same, as the solution progresses from step n
to n+1;
• On the other hand, if the εi’s grow larger during the
progression of the solution from steps n to n+1, then
the solution is unstable.
• That is, for a solution to be stable,
Amplification factor
(5.29)
Equation (5.29) gives the stability requirement for the
solution of the difference equation, Eq. (5.24), to be stable.
Clearly, for a given Δx, the allowed value of Δt must be small
enough to satisfy Eq. (5.41).
Here is a stunning example of the limitation placed on the
marching variable by stability considerations for explicit
finite difference models.
As long as Δt/(Δx)2 ≤ 1/2 , the error will not grow for
subsequent marching steps in t, and the numerical solution
will proceed in a stable manner.
On the other hand, if Δt/(Δx)2 > 1/2 , then the error will
progressively become larger, and will eventually cause the
numerical marching solution to ‘blow up’ on the computer.