0% found this document useful (0 votes)
7 views13 pages

ZME654 2 Discretization (Taylor Series)

The document outlines the basic steps for solving flow problems using Computational Fluid Dynamics (CFD), starting from mathematical formulation to post-processing of results. It details the discretization process, including methods such as Finite Difference, Finite Volume, Finite Element, and Spectral methods, which are used to approximate governing equations. Additionally, it explains the application of Taylor series for deriving finite difference formulas for derivatives, highlighting the importance of truncation errors in numerical solutions.

Uploaded by

dosahidayetoglu
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)
7 views13 pages

ZME654 2 Discretization (Taylor Series)

The document outlines the basic steps for solving flow problems using Computational Fluid Dynamics (CFD), starting from mathematical formulation to post-processing of results. It details the discretization process, including methods such as Finite Difference, Finite Volume, Finite Element, and Spectral methods, which are used to approximate governing equations. Additionally, it explains the application of Taylor series for deriving finite difference formulas for derivatives, highlighting the importance of truncation errors in numerical solutions.

Uploaded by

dosahidayetoglu
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/ 13

REVIEW

Basic Steps of Solution of a Flow Problem Using CFD

1. Mathematical formulation (modelling) of the problem: In this step,


the physical phenomena (flow, heat transfer, etc.) under
consideration is expressed in terms of mathematical terms. Using the
basic laws (conservation of mass, Newton's second law, conservation
of energy, etc.), equations governing the problem, and the boundary
and initial conditions are expressed in terms of mathematical terms.
These are generally partial differential equations.

2. The flow domain is discretized (Mesh generation): Problem domain


is approximated with finite number of points (nodes, grid points,
finite control volume, finite elements, etc.).

3. Discretization of Equations: Mathematical equations are discretized


and approximated by algebraic equations at discrete points (node,
grid points). This step yields a set of linear algebraic equations for all
the dependent variables of the problem.

4. Solution of set of algebraic equations: The discretization equations


(algebraic equations) are solved, and the values of the dependent
variables are obtained at all grid points.

5. Post processing: Evaluation of the results of the variables obtained at


the grid points and representing the results as graphs, tables, etc.

Generalized Equation for a general variable, 𝝋

The above three basic equations can be in terms of a general variable 𝝋


as follows:
𝝏 𝝏 𝝏 𝝏𝝋
(𝝆𝝋) + (𝝆𝒖𝒌 𝝋) = 𝜞 +𝑺
𝝏𝒕 𝝏𝒙𝒌 𝝏𝒙𝒋 𝝏𝒙𝒋

2 Discretization (Taylor Series) 1


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

2 Discretization (Taylor Series) 2


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.

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.

2 Discretization (Taylor Series) 3


Finite Difference Method

Objective is to express the differential terms as finite difference formulas.


For this, Taylor series expansion can be used.

 d   d 2 
 dx   ?  2 ?
   dx 

Taylor Series Formulation:

f(x+ Dx) To apply Taylor series, function has


f(x) to be continuous.
f(x- Dx)

x1= x-Dx x x2=x+Dx x

 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 Discretization (Taylor Series) 4


𝒅𝝋
Central Finite Difference Formulas for 𝒅𝒙
h h
h=Dx
1 x 2 3

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=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!

Neglecting the higher order terms, we get, (𝒅𝝋)2= 𝝋𝟑− 𝝋𝟏 + 𝑶 𝒉 𝟐


𝒅𝒙 𝟐𝒉

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

Neglecting the higher order terms causes truncation errors.


𝑶 ℎ 2 Shows the order of the truncation error.

2 Discretization (Taylor Series) 5


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


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

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

𝑑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) 7


Finite Difference Formulas for Partial Differential Terms,
𝝏𝝋 𝝏𝟐𝝋 𝝏𝝋 𝝏𝟐𝝋
, , , =?
𝝏𝒙 𝝏𝒙𝟐 𝝏𝒚 𝝏𝒚𝟐

Consider variable 𝝋 = 𝝋(x, y)


y, j Dy Dx
𝝏𝝋
=?
𝝏𝒙
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) 8
NOTES:
1. O(h), O(h2), O(Dx), O(Dx)2, O(Dy), O(Dy)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(Dx)2 is a less error than TE=O(Dx)
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) 9


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) 10


FINITE DIFFERENCE EQUATION FOR A DIFFERENTIAL EQUATION

Consider the heat equation, Dx Dx

𝜕𝑇 𝜕2𝑇 i+1 h=Dx


=𝛼 2 i-1 x i
𝜕𝑡 𝜕𝑥
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 𝑇 ∆𝑡 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 𝑇
− 𝜕𝑡 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.

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 analytical criteria for determination of 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) 12
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) 13

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy