0% found this document useful (0 votes)
17 views12 pages

Discretization: Discrete Points

Uploaded by

THE SEZAR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views12 pages

Discretization: Discrete Points

Uploaded by

THE SEZAR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

DISCRETIZATION

Discretization is an important step in numerical solutions. The nature of numerical


solutions requires calculation of dependent variables at finite number of discrete points
in the problem domain. These discrete points are called grid points, nodes,
computational mesh, etc.

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.

By a systematic discretization, dependent variables at grid points are expressed as a


set of algebraic equations.

A systematic discretization of the dependent variables in space and time makes it


possible to place the governing equations with simple algebraic equations.

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

Finite Difference Method: The differential terms in the


governing equations are approximated with finite difference
formulas at grid points, and hence the governing equations are
approximated as algebraic equations at grid points.

Finite Volume Method: The problem domain is divided into


finite control volumes and governing equations are integrated
in these finite control volumes and hence governing equations
are approximated as algebraic equations at grid points .

2 Discretization (Taylor Series) 1


Finite element Method: The problem domain is divided into
finite number of elements (sub domains). Variations of the
dependent variables in these elements are represented by
linear (or quadratic) functions in terms of unknown coefficients.
Substituting these functions into the differential equations, a set
of algebraic equations is obtained for the unknown coefficients.

Spectral Method: Unknown dependent variables are


represented by Fourier series or Chebyshev polynomials over
whole problem domain. Substitution of this series into
differential equations yields a set of algebraic equations for the
coefficients of the series.

Finite Difference Method


Objective is to express the differential terms as finite difference formulas. For this,
Taylor series expansion can be used.
 d 
2
d 
 dx   ?  2 ?
Taylor Series Formulation:    dx 
f

f(x+ x)
To apply Taylor series, function has to be
f(x) continuous.
f(x- x)

x1= x-x x x1=x+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!

2 Discretization (Taylor Series) 2


h h

1 3 h=x
2
x

Using Taylor series, 𝝋1 and 𝝋3 can be expressed in terms of values of 𝝋 at point 2.

𝑑𝝋 𝑑 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= 𝟐𝒉
+ 𝑶 𝒉

Neglecting the higher order terms causes truncation errors.

Adding equations 1 and 2, we get

𝑑2𝜑 𝜑 −2𝜑 +𝜑 2 𝑶 ℎ 2 Shows the order of the truncation


( 𝑑𝑥2 )2= 1 ℎ22 3 +𝑶 ℎ error.

𝒅𝝋 𝒅𝟐 𝝋
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.

By substituting these expressions into differential equations, finite difference


equations of the differential equations are obtained at grid points.

2 Discretization (Taylor Series) 3


𝒅𝝋
Forward and Backward Finite Difference Formulas for 𝒅𝒙
𝝋

𝝋 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

Neglecting the higher order terms, we get


𝑑𝜑 𝝋 𝑥+ℎ −𝝋(𝑥) 𝒅𝝋
( 𝑑𝑥 )x= + 𝑶 ℎ Forward finite difference formula for (
𝒅𝒙
)

Also expressing 𝝋(x-h) using Taylor series, we get


𝒅𝝋 𝒅𝟐 𝝋 𝒉 𝟐 𝒅𝟑 𝝋 (𝒉)𝟑
𝝋 𝒙 − 𝒉 = 𝝋(x) − 𝐱𝐡 + − ….. (2)
𝒅𝒙 𝒅𝒙𝟐 𝟐! 𝒅𝒙𝟑 𝟑!

𝑑𝝋
Solving for , we get
𝑑𝑥

𝑑𝜑 𝝋 𝑥 −𝝋(𝑥−ℎ) 𝑑2 𝝋 ℎ 𝑑3 𝝋 ℎ 2
( 𝑑𝑥 )x= − − 𝑑𝑥 3 6 − ….
ℎ 𝑑𝑥 2 2

𝑑𝜑 𝝋 𝑥 −𝝋(𝑥−ℎ) Backward finite difference formula for (


𝒅𝝋
)
( )x= + 𝑶 ℎ 𝒅𝒙
𝑑𝑥 ℎ

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)
𝒅𝒙 𝒅𝒙𝟐 𝟐! 𝒅𝒙𝟑 𝟑!

Subtracting Eq. 2 from Eq. 1. , we get

𝑑𝜑 𝝋 𝑥+ℎ −𝝋(𝑥−ℎ) 𝑑3 𝝋 ℎ 2
( 𝑑𝑥 )x= + − ….
2ℎ 𝑑𝑥 3 6

Neglecting the higher order terms, we get

𝑑𝜑 𝝋 𝑥+ℎ −𝝋(𝑥−ℎ) 𝒅𝝋
( 𝑑𝑥 )x= + 𝑶 ℎ2 Central finite difference formula for (
𝒅𝒙
)
2ℎ

2 Discretization (Taylor Series) 5


𝒅𝟐 𝝋
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
𝑑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:
𝒅𝒙

𝑑2𝜑 𝝋 𝑥 −2𝝋 𝑥−ℎ +𝝋 𝑥−2ℎ Backward finite difference


( 𝑑𝑥2 )x= − 𝑶(𝒉) 𝒅𝟐𝝋
ℎ2 formula for ( )
𝒅𝒙𝟐

Similarly, using Taylor expansions for 𝝋(x-h) and 𝝋(x+h), we obtain a central
𝒅𝟐𝝋
difference formula for 𝟐 , as below:
𝒅𝒙

𝑑2𝜑 𝝋 𝑥+ℎ −2𝝋 𝑥 +𝝋 𝑥−ℎ Central finite difference


( 𝑑𝑥2 )x= − 𝑶(𝒉𝟐) 𝒅𝟐𝝋
ℎ2 formula for ( )
𝒅𝒙𝟐

2 Discretization (Taylor Series) 6


Finite Difference Formulas for Partial Differential Terms,

𝝏𝝋 𝝏𝟐 𝝋 𝝏𝝋 𝝏𝟐 𝝋
, , , =?
𝝏𝒙 𝝏𝒙𝟐 𝝏𝒚 𝝏𝒚𝟐

Consider variable 𝝋 = 𝝋(x, y)


y, j y x
𝝏𝝋
=?
𝝏𝒙
X, i
Like the finite difference formulas derived for ordinary differential terms above, finite
difference formulas for partial derivative terms can be obtained by writing Taylor
expansions about 𝝋(x, y).
Example:
𝝏𝝋 𝝏𝟐 𝝋 (∆𝒙)𝟐 𝝏𝟑 𝝋 (∆𝒙)𝟑
𝝋 𝒙 + ∆𝒙, 𝒚 = 𝝋(x,y) + 𝐱, 𝐲∆𝒙 + + + ………
𝝏𝒙 𝝏𝒙𝟐 𝟐! 𝝏𝒙𝟑 𝟑!
𝝏𝝋
Solving for , a forward difference formula is obtained as follows:
𝝏𝒙

𝝏𝜑 𝝋 𝑥+∆𝒙,𝑦 −𝝋(𝑥,𝑦) Forward finite difference


( 𝝏𝑥 )x,y= + 𝑶 ∆𝒙 𝝏𝝋
∆𝒙 formula for ( )
𝝏𝒙

Using index notation, we can write


𝝏𝜑 𝝋 𝑖+𝟏,𝑗 −𝝋(𝑖,𝑗)
( 𝝏𝑥 )i,j= + 𝑶 ∆𝒙
∆𝒙
𝝏𝝋
=?
𝝏𝒚 𝝏𝝋 𝝏𝟐 𝝋 (∆𝒚)𝟐 𝝏𝟑 𝝋 (∆𝒚)𝟑
𝝋 𝒙, 𝒚 + ∆𝒚 = 𝝋(x,y) + 𝐱, 𝐲∆𝒚 + + + ………
𝝏𝒚 𝝏𝒚𝟐 𝟐! 𝝏𝒚𝟑 𝟑!
𝝏𝝋
Solving for , a forward difference formula is obtained as follows:
𝝏𝒚

𝝏𝜑 𝝋 𝑥,𝑦+∆𝒚 −𝝋(𝑥,𝑦) Forward finite difference


( 𝝏𝑦 )x,y= + 𝑶 ∆𝒚 𝝏𝝋
∆𝒚 formula for ( )
𝝏𝒚

Using index notation, we can write


𝝏𝜑 𝝋 𝑖,𝑗+𝟏 −𝝋(𝑖,𝑗)
( 𝝏𝑦 )i,j= ∆𝒚
+ 𝑶 ∆𝒚
2 Discretization (Taylor Series) 7
NOTES:
1. O(h), O(h2), O(x), O(x)2, O(y), O(y)2, etc. do not give a value for truncation
error (TE). However, it provides information about the order of TE.

2. For example TE=O(x)2 is a less error than TE=O(x)


3. Theoretically, for any differential term infinitely many finite difference formula can
be derived using 2, 3, 4, 5, .. grid points.

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.

2 Discretization (Taylor Series) 8


HOMEWORK 1

𝝏𝜑
1) Derive the finite diffrence formula for the partial differential term ( )i,j , given
𝝏𝑥
below:

𝝏𝜑 3𝝋 𝑖,𝑗 −4𝝋 𝑖−1,𝑗 +𝝋 𝑖−2,𝑗 2


( 𝝏𝑥 )i,j= + 𝑶 ∆𝒙
∆𝒙

𝝏𝜑
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

2 Discretization (Taylor Series) 9


FINITE DIFFERENCE EQUATION FOR A DIFFERENTIAL EQUATION

Consider the heat equation, x x


𝜕𝑇 𝜕2𝑇
=𝛼 2 i i+1 h=x
i-1
𝜕𝑡 𝜕𝑥 x

To obtain a finite difference equation for this differential equation, we replace


differential terms by finite difference formula.

𝜕𝑇
The time dependent term can be expressed using forward difference formula as
𝜕𝑡
below:

𝜕𝑇 𝑇𝑖𝑛−1 −𝑇𝑖𝑛 𝜕2 𝑇 ∆𝑡 Time step is denoted by superscripts.


= − - ….
𝜕𝑡 ∆𝑡 𝜕𝑡2 2
𝝏𝟐 𝑻
Using central difference formula, the diffusion term can be expressed in finite
𝝏𝒙𝟐
difference as follows:

𝜕2 𝑇 𝑇𝑖−1 −2𝑇𝑖 +𝑇𝑖+1 𝜕4 𝑇 (∆𝑥)2


= − + …..
𝜕𝑥 2 (∆𝑥)2 𝜕𝑥 4 12

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.

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 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.

Stability: Stability is associated with damping of errors (truncation error, roundoff


error, ..) as the numerical solution proceeds. If a numerical technique is not stable,
wild oscillations may occur in the solution or it may diverge.

There is no any analytical criteria for stability of a numerical technique.

Convergence: Convergence is the property of a numerical method to produce a


solution which approaches to the exact solution as the grid spacing, control
volume size or element size is reduced to zero.

2 Discretization (Taylor Series) 11


Sources of Errors in Numerical Calculations
Truncation Error: Numerical methods use approximations for solving differential
equations. The errors introduced by the approximations are the truncation errors.
Truncation errors are introduced when exact mathematical formulas are represented
by approximations.

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.

As seen, truncation error decreases with increasing grid number (decreasing


distance between grid points). However, since number of computations increases
with increasing grid number, Roundoff error increases. Hence, an optimum grid
system (control volume size) is determined by trial-and-error procedure before
performing the final numerical computation for a given problem.

2 Discretization (Taylor Series) 12

You might also like