Discretization: Discrete Points
Discretization: Discrete Points
In the discretization step, first the grid points (computational mesh) are formed in the
problem domain. Then, the governing equations (differential equations) and boundary
conditions of the problem are approximately expressed as algebraic equations at grid
points using different methods.
The solution of the set of algebraic equations yields the values of the dependent
variables at grid points. Values of the dependent variables between the grid points
can be obtained assuming a profile for the variation of the variable between the grid
points.
Discretization Methods
f(x+ x)
To apply Taylor series, function has to be
f(x) continuous.
f(x- x)
d 2 f x1 x d n f x1 x
2 n
df
f ( x1 ) f ( x) x1 x 2 ..... n ..
x
dx dx x 2! dx x n !
d 2 f x d n f x
2 n
df
f ( x x) f ( x) x 2 ..... n ..
x
dx dx x 2! dx x n !
𝑑𝑓 𝑑2 𝑓 (∆𝑥)2 𝑑𝑛 𝑓 (−∆𝑥)𝑛
𝑓 𝑥 − ∆𝑥 = 𝑓 𝑥 − 𝑥 + − ⋯ . . + 𝑑𝑥 𝑛 𝑛! …..
𝑑𝑥 𝑑𝑥 2 2!
1 3 h=x
2
x
𝑑𝝋 𝑑 2 𝝋 (ℎ)2 𝑑 3 𝝋 (ℎ)3
𝝋1 = 𝝋 𝑥 − ℎ = 𝝋2 − h+ − ….. (1)
𝑑𝑥 𝑑𝑥 2 2! 𝑑𝑥 𝑛 3!
𝑑𝝋 𝑑 2 𝝋 (ℎ)2 𝑑 3 𝝋 (ℎ)3
𝝋3 = 𝝋 𝑥 + ℎ = 𝝋2 + h+ + ….. (2)
𝑑𝑥 𝑑𝑥 2 2! 𝑑𝑥 3 3!
NOTE: h=x is very small. Hence, the terms with higher order of x, will be small.
Therefore, higher order terms can be neglected to simplify the expressions.
Subtracting Eq. (1) from Eq. (2), and neglecting the higher order terms we get,
d 3 h 3 2 d 3 h
3 2
d d
3 1 2 h 2 dx3 3! 2h dx3 3!
dx 2 x dx 2 x
𝒅𝝋 𝝋𝟑− 𝝋𝟏 𝟐
Neglecting the higher order terms, we get, ( 𝒅𝒙 )2= 𝟐𝒉
+ 𝑶 𝒉
𝒅𝝋 𝒅𝟐 𝝋
As seen in these expressions, differetial terms and 𝟐 are expressed at a point
𝒅𝒙 𝒅𝒙
(grid 2) in terms of the values of 𝝋 at neighboring grid points.
𝝋 x+ h)
𝝋(x)
𝝋(x- h)
x-h x x+h x
Writing the Taylor expansion about point at x, we express 𝝋 at point x+h as
𝒅𝝋 𝒅𝟐 𝝋 (𝒉)𝟐 𝒅𝟑 𝝋 (𝒉)𝟑
𝝋 𝒙 + 𝒉 = 𝝋(x) + 𝐱𝐡 + + ….. (1)
𝒅𝒙 𝒅𝒙𝟐 𝟐! 𝒅𝒙𝟑 𝟑!
𝑑𝝋
Solving for
𝑑𝑥
𝑑𝜑 𝝋 𝑥+ℎ −𝝋(𝑥) 𝑑2 𝝋 ℎ 𝑑3 𝝋 ℎ 2
( 𝑑𝑥 )x= − − − ….
ℎ 𝑑𝑥 2 2 𝑑𝑥 3 6
𝑑𝝋
Solving for , we get
𝑑𝑥
𝑑𝜑 𝝋 𝑥 −𝝋(𝑥−ℎ) 𝑑2 𝝋 ℎ 𝑑3 𝝋 ℎ 2
( 𝑑𝑥 )x= − − 𝑑𝑥 3 6 − ….
ℎ 𝑑𝑥 2 2
These finite difference formulas are first order. This implies that truncation is
proportional with (h).
2 Discretization (Taylor Series) 4
𝒅𝝋
Central finite difference formula for ( )
𝒅𝒙
𝒅𝝋 𝒅𝟐 𝝋 (𝒉)𝟐 𝒅𝟑 𝝋 (𝒉)𝟑
𝝋 𝒙 + 𝒉 = 𝝋(x) + 𝐱𝐡 + + ….. (1)
𝒅𝒙 𝒅𝒙𝟐 𝟐! 𝒅𝒙𝟑 𝟑!
𝒅𝝋 𝒅𝟐 𝝋 𝒉 𝟐 𝒅𝟑 𝝋 (𝒉)𝟑
𝝋 𝒙 − 𝒉 = 𝝋(x) − 𝐱𝐡 + − ….. (2)
𝒅𝒙 𝒅𝒙𝟐 𝟐! 𝒅𝒙𝟑 𝟑!
𝑑𝜑 𝝋 𝑥+ℎ −𝝋(𝑥−ℎ) 𝑑3 𝝋 ℎ 2
( 𝑑𝑥 )x= + − ….
2ℎ 𝑑𝑥 3 6
𝑑𝜑 𝝋 𝑥+ℎ −𝝋(𝑥−ℎ) 𝒅𝝋
( 𝑑𝑥 )x= + 𝑶 ℎ2 Central finite difference formula for (
𝒅𝒙
)
2ℎ
𝝋 x+ h)
𝝋(x)
𝝋(x- h)
x-h x x+h x
x+2h
𝒅𝝋 𝒅𝟐 𝝋 (𝒉)𝟐 𝒅𝟑 𝝋 (𝒉)𝟑
𝝋 𝒙 + 𝒉 = 𝝋(x) + 𝐱𝐡 + + ….. (1)
𝒅𝒙 𝒅𝒙𝟐 𝟐! 𝒅𝒙𝟑 𝟑!
𝒅𝝋 𝒅𝟐 𝝋 (𝟐𝒉)𝟐 𝒅𝟑 𝝋 (𝟐𝒉)𝟑
𝝋 𝒙 + 𝟐𝒉 = 𝝋(x) + 𝐱 𝟐𝐡 + + ….. (2)
𝒅𝒙 𝒅𝒙𝟐 𝟐! 𝒅𝒙𝟑 𝟑!
𝒅 𝟐𝝋
Adding -2×Eq. (1) and Eq. (2), neglecting the higher order terms and solving for 𝟐
𝒅𝒙
we get
𝑑2𝜑 𝝋 𝑥 −2𝝋 𝑥+ℎ +𝝋 𝑥+2ℎ 𝒅𝟑 𝝋 Forward finite difference
( 𝑑𝑥2 )x= − 𝒉 𝒅𝒙𝟑 𝒅𝟐𝝋
ℎ2 formula for ( )
𝒅𝒙𝟐
Similarly, using Taylor expansions for 𝝋(x-h) and 𝝋(x-2h), we obtain a backward
𝒅𝟐𝝋
difference formula for 𝟐 , as below:
𝒅𝒙
Similarly, using Taylor expansions for 𝝋(x-h) and 𝝋(x+h), we obtain a central
𝒅𝟐𝝋
difference formula for 𝟐 , as below:
𝒅𝒙
𝝏𝝋 𝝏𝟐 𝝋 𝝏𝝋 𝝏𝟐 𝝋
, , , =?
𝝏𝒙 𝝏𝒙𝟐 𝝏𝒚 𝝏𝒚𝟐
4. However, for practical purpose in CFD, generally 2 or 3 grid points are used to
express first and second order differential terms as finite difference.
𝝏𝜑
1) Derive the finite diffrence formula for the partial differential term ( )i,j , given
𝝏𝑥
below:
𝝏𝜑
2) For the grid system below, derive a finite difference expression for ( ) at grid
𝝏𝑥
point 1.
h1 h2
Note: h1 and h2 are not equal.
1 2 3
x
𝜕𝑇
The time dependent term can be expressed using forward difference formula as
𝜕𝑡
below:
Rewriting the differential equation and substituting the finite difference expressions,
we get the followings:
𝜕𝑇 𝜕2𝑇
− 𝛼 𝜕𝑥2=0
𝜕𝑡
𝑇 𝑛+1 − 𝑇 𝑛 𝛼
− 𝑇 − 2𝑇𝑖 + 𝑇𝑖+1 +
∆𝑡 (∆𝑥)2 𝑖−1
𝜕2 𝑇 ∆𝑡 (∆𝑥)2 𝜕4 𝑇
− )𝑛,𝑖 +𝛼 ) + …… = 0
𝜕𝑡 2 2 12 𝜕𝑥 4 𝑛,𝑖
Neglecting the higher order terms, the above equation can be written as
𝑇𝑖𝑛+1 − 𝑇𝑖𝑛 𝛼 𝑛
− 2
𝑇𝑖−1 − 2𝑇𝑖𝑛 + 𝑇𝑖+1
𝑛
+ 𝑶[∆𝑡, (∆𝑥)2 ] ≅ 0
∆𝑡 (∆𝑥)
2 Discretization (Taylor Series) 10
𝑇𝑖𝑛+1 − 𝑇𝑖𝑛 𝛼 𝑛
− 2
𝑇𝑖−1 − 2𝑇𝑖𝑛 + 𝑇𝑖+1
𝑛
+ 𝑶[∆𝑡, (∆𝑥)2 ] ≅ 0
∆𝑡 (∆𝑥)
Finite difference
equation.
The order of the truncation error is O(t) + O(x)2 or O(t, x2)
In practice, the truncation error is neglected and the finite difference equations for
each grid point is solved with a hope that the truncation error is small enough so
that the solutions would be acceptable.
For the truncation error to be in an acceptable level, the finite difference equation
should be consistent and stable.
In the above equation, as t and x tend to zero, TE approaches to zero and hence,
the finite difference equation becomes equal to the governing differential equation.
However, if the order of truncation error TE is for example O(t / x), the finite
difference equations (algebraic equations) is not consistent, since as x →0, TE does
not approach to zero. If grid spacing is formed such that t/x →0, the finite
difference equation becomes consistent. However, obtaining such a grid spacing is
very difficult.
To reduce the truncation error, the grid spacing, control volume size and element size
should approach to zero. For practical calculations, the grid spacing, control volume
size and element size must be finite. Hence, the optimum grid size is determined by
trial and error considering the efficient use of computing resources.
Use of higher order difference formulas also helps to reduce the truncation error.
Roundoff Error: Roundoff errors occur because computers have a limited ability to
represent numbers. For example, π has infinite digits, but due to precision limitations,
only 16 digits may be stored. While this roundoff error may seem significant, if
computational process involves multiple iterations that are dependent on one
another, these small errors may accumulate over time and result in a significant
deviation from the expected value.