ZME654 2 Discretization (Taylor Series)
ZME654 2 Discretization (Taylor Series)
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.
d d 2
dx ? 2 ?
dx
d 2 f Dx d n f Dx
2 n
df
f ( x Dx) f ( x) Dx 2 ..... n ..
dx x dx x 2! dx x n !
𝑑𝑓 𝑑2 𝑓 (∆𝑥)2 𝑑𝑛 𝑓 (−∆𝑥)𝑛
f 𝑥1 = 𝑓 𝑥 − ∆𝑥 = 𝑓 𝑥 − D𝑥 + − ⋯ . . + 𝑑𝑥 𝑛 𝑛! …..
𝑑𝑥 𝑑𝑥 2 2!
𝑑𝑓 𝑑2 𝑓 (∆𝑥)2 𝑑𝑛 𝑓 (−∆𝑥)𝑛
f 𝑥2 = 𝑓 𝑥 + ∆𝑥 = 𝑓 𝑥 + D𝑥 + + ⋯..+ 𝑛 …..
𝑑𝑥 𝑑𝑥 2 2! 𝑑𝑥 𝑛!
𝑑𝝋 𝑑2 𝝋 (ℎ)2 𝑑3 𝝋 (ℎ)3
𝝋3 = 𝝋 𝑥 + ℎ = 𝝋2 + h + + ….. (2)
𝑑𝑥 𝑑𝑥 2 2! 𝑑𝑥 3 3!
NOTE: h=Dx is very small. Hence, the terms with higher order of Dx,
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 3 3
dx 2 dx x 3! dx 2 2h dx x 3!
or
𝑑𝜑 𝝋 𝑥+ℎ −𝝋(𝑥−ℎ) 𝒅𝝋
( 𝑑𝑥 )x= + 𝑶 ℎ2 Central finite difference formula for (
𝒅𝒙
)
2ℎ
𝝋 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) 6
𝒅𝟐 𝝋
Finite Difference Formulas for 𝒅𝒙𝟐
𝒅𝟐𝝋
To find a forward finite difference formula for , express 𝝋(x+h) and
𝒅𝒙𝟐
𝝋(x+2h) using Taylor expansion
𝝋
𝝋 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
𝒅𝒙𝟐
𝝏𝜑
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:
𝜕𝑇 𝑇𝑖𝑛−1 −𝑇𝑖𝑛 𝜕2 𝑇 ∆𝑡 2
= − - …. Time step is denoted by superscripts.
𝜕𝑡 ∆𝑡 𝜕𝑡2 2
𝝏𝟐 𝑻
Using central difference formula, the diffusion term can be expressed
𝝏𝒙𝟐
in finite difference as follows:
𝑇 𝑛+1 − 𝑇 𝑛 𝛼
− 𝑇 − 2𝑇𝑖 + 𝑇𝑖+1 +
∆𝑡 (∆𝑥)2 𝑖−1
𝜕2 𝑇 ∆𝑡 (∆𝑥)2 𝜕4 𝑇
− 𝜕𝑡 2 )𝑛,𝑖 2 + 𝛼 12 𝜕𝑥 4 )𝑛,𝑖 + …… = 0
Truncated terms (Truncation error).
Neglecting the higher order terms, the above equation can be written as
𝑇𝑖𝑛+1 − 𝑇𝑖𝑛 𝛼 𝑛
− 2
𝑇𝑖−1 − 2𝑇𝑖𝑛 + 𝑇𝑖+1
𝑛
+ 𝑶[∆𝑡, (∆𝑥)2 ] ≅ 0
∆𝑡 (∆𝑥)
2 Discretization (Taylor Series) 11
𝑇𝑖𝑛+1 − 𝑇𝑖𝑛 𝛼 𝑛
− 2
𝑇𝑖−1 − 2𝑇𝑖𝑛 + 𝑇𝑖+1
𝑛
+ 𝑶[∆𝑡, (∆𝑥)2 ] ≅ 0
∆𝑡 (∆𝑥)
Finite difference equation.
𝛼 ∆𝑡 Algebraic equation for differential
𝑜𝑟 𝑇𝑖𝑛+1 = 𝑇𝑖𝑛 + 2
𝑛
𝑇𝑖−1 − 2𝑇𝑖𝑛 + 𝑇𝑖+1
𝑛
∆𝑥 equation at grid point i.
The order of the truncation error is O(Dt) + O(Dx)2 or O(Dt, Dx2)
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.
Consistency: Consistency characterizes how good the finite difference
equation represents the differential equation. Consistent numerical
schemes produce systems of algebraic equations which can be
demonstrated to be equivalent to the original governing equation as the
grid spacing tends to zero.
In the above equation, as Dt and Dx 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(Dt / Dx), the
finite difference equations (algebraic equations) is not consistent, since as
Dx →0, TE does not approach to zero. If grid spacing is formed such that
Dt/Dx →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.