CFD – Discretization
Department of Mechanical Engineering,
IST Islamabad
What is Discretization?
Discretization is the process by which a closed-form mathematical
expression, such as a function or a differential or integral equation
involving functions, all of which are viewed as having an infinite continuum
of values throughout some domain, is approximated by analogous (but
different) expressions which prescribe values at only a finite number of
discrete points or volumes in the domain.
Analytical solutions of partial differential
equations involve closed-form expressions
which give the variation of the dependent
variables continuously throughout the
domain. In contrast, numerical solutions can
give answers at only discrete points in the
domain, called grid points.
Discrete grid points.
1
What is Discretization?
Discretization is all about how to replace the partial derivatives ( or
integrals) in the governing equations of motion with discrete numbers.
Discretization of the partial differential equations is called finite
differences, and discretization of the integral form of the equations is
called finite volumes.
For a two-dimensional flow field which is governed by the Navier-Stokes
equations, or by the Euler equations, are partial differential equations. An
analytical solution of these equations would provide expressions for u, v,
p, density, etc., as functions of x and y, or the flow-field variables at any of
the infinite number of (x, y) points in the domain.
The partial differential equations are replaced by a system of algebraic
equations which can be solved for the values of the flow-field variables at
the discrete grid points only. In this sense, the original partial differential
equations have been discretized.
2
Finite Difference Method – FDM
The partial differential equation (PDE) can be replaced with an algebraic
equation using a finite difference method. Most common finite-difference
representations of derivatives are based on Taylor's series expansions.
For example, referring to Fig., if u(i, j) denotes the x component of
velocity at point (i, j), then the velocity u(i+1, j) at point (i + 1, j) can be
expressed in terms of a Taylor series expanded about point (i, j) as
follows:
This equation will be mathematically an exact
expression for u(i+1, j) if the number of terms
is infinite and the series converges and/or
∆x ->0.
Finite Difference Method – FDM
Consider a continuous function of x, namely, f (x), with all derivatives
defined at x. Then, the value off at a location x + ∆x can be estimated
from a Taylor series expanded about point x, that is,
𝜕𝑓 𝜕2𝑓 ∆𝑥2 𝜕𝑛𝑓 ∆𝑥𝑛
𝑓 𝑥 ∆𝑥 𝑓 𝑥 ∆𝑥 … … … …
𝜕𝑥 𝜕𝑥2 2! 𝜕𝑥𝑛 𝑛!
3
Finite Difference Method – FDM
𝐟 𝐱 𝐬𝐢𝐧 𝟐𝛑𝐱
𝑓 0.2 𝑠𝑖𝑛2 ∗ 𝜋 ∗ 0.2= 0.9511
Let ∆𝑥 0.02
𝑓 𝑥 ∆𝑥 𝑓 0.22 𝑠𝑖𝑛2 ∗ 𝜋 ∗ 0.22 0.9823
Using Taylor series
First order accurate 𝑓 0.2 𝑓 0.22 0.9511
2nd order accurate 𝑓 𝑥 ∆𝑥 𝑓 𝑥 ∆𝑥 𝑓 0.2
2𝜋 cos 2 ∗ 𝜋 ∗ 0.2 ∗ 0.02 0.9899
∆
3rd order accurate 𝑓 𝑥 ∆𝑥 𝑓 𝑥 ∆𝑥
!
0.9824
Finite Difference Method – FDM
Forward Difference with first order accuracy
4
Finite Difference Method – FDM
Backward Difference with first order accuracy
Central Difference with 2nd order accuracy
10
Finite Difference Method – FDM
2nd Order Derivative
Second order derivative
11
5
Finite Difference Method – FDM
12
Finite Difference Method – FDM
13
6
Finite Difference Method – FDM
Given the function 𝑓 𝑥 𝑥 compute the first derivative off 𝑓 at x = 2 using forward and backward
differencing of order (∆x). Compare the results with a central differencing of O(∆x)2 and the exact analytical
value. Use a step size of ∆x = 0.1. Repeat the computations for a step size of ∆x=0.4.
Forward Difference
Backward Difference
14
Finite Difference Method – FDM
Central Difference
Exact Solution
15
7
Finite Difference Method – FDM
Solution at ∆x=0.4
16
Problem
Consider the viscous flow of air over a flat plate. At a given station in the flow
direction, the variation of the flow velocity, u, in the direction perpendicular to the
plate (the y direction) is given by the expression
Eq # 1
where L = characteristic length = 1 in. The units of u are feet per second. The
viscosity coefficientµ= 3.7373 x 10-7 slug/(ft · s). We use this Eq. 1 to provide
the values of u at discrete grid points equally spaced in they direction, with ~y =
0.1 in. Specifically, we obtain from Eq. 1 are given in Table.
Using these discrete values, calculate the shear stress at
the wall Tw three different ways, namely: (a) Using a first-
order one-sided difference (b) Using the second-order one-
sided difference (c) Using the third-order one-sided
difference. Finally, compare these calculated finite-
difference results with the exact value of Tw.
17
8
Problem
where L = characteristic length = 1 in.
18
Problem
where L = characteristic length = 1 in.
(d) Exact value
19
9
FDM for 2D conduction problem
𝜕 2𝑇 𝜕 2𝑇 𝜕 2𝑇 1 𝜕𝑇
𝐻𝐺
𝜕𝑥2 𝜕𝑦2 𝜕𝑧2 𝛼 𝜕𝑡
𝜕 2𝑇 𝜕 2𝑇
0
𝜕𝑥2 𝜕𝑦2
𝑇𝑖 1, 𝑗 2𝑇𝑖 . 𝑗 𝑇𝑖 1, 𝑗 𝑇𝑖 , 𝑗 1 2𝑇𝑖 , 𝑗 𝑇𝑖 , 𝑗 1
→ 0
∆𝑥2 ∆𝑦2
21
1D Transient Heat Equation
𝜕𝑇 𝜕 2𝑇
𝛼
𝜕𝑡 𝜕𝑥2
𝜕 2𝑇 𝑇 2𝑇 𝑇
𝐻𝑂𝑇
𝜕𝑥2 ∆𝑥2
𝜕𝑇 𝑇 𝑇
𝐻𝑂𝑇
𝜕𝑡 ∆𝑡
𝑇 𝑇 𝑇 2𝑇 𝑇
𝛼
∆𝑡 ∆𝑥2
23
10
Explicit Method
Using 1D transient heat equation
𝑇 𝑇 𝑇 2𝑇 𝑇
𝛼
∆𝑡 ∆𝑥2
Rearranging above equation to get
Temperature at grid point i at time n+1
𝛼 ∆𝑡 𝑇 2𝑇 𝑇
𝑇 𝑇
∆𝑥 ∆𝑥2
In above equation temperature 𝑇 explicitly depends
upon the Temperature values at i-1, i and i+1 of time step n
and thus leads towards marching solution
27
Explicit Method
𝛼 ∆𝑡 𝑇 2𝑇 𝑇
𝑇 𝑇
∆𝑥 ∆𝑥2
𝛼 ∆𝑡 𝑇 2𝑇 𝑇
𝑇 𝑇
∆𝑥 ∆𝑥2
28
11
Implicit Method - Crank Nicholson Technique
1 1
𝑇 𝑇 𝑇 𝑇 𝑇 𝑇 𝑇 𝑇
𝛼2 2
∆𝑡 ∆𝑥2
Rearranging above equation to get Temperature at n+1 on left and n
on right hand side
∆ ∆ ∆ ∆
𝑇 1 𝑇 + 𝑇 𝑇 𝑇 2𝑇 𝑇 )
∆ ∆ ∆ ∆
29
Implicit Method - Crank Nicholson Technique
∆ ∆ ∆ ∆
𝑇 1 𝑇 + 𝑇 𝑇 𝑇 2𝑇 𝑇 )
∆ ∆ ∆ ∆
Let
𝛼 ∆𝑡
𝐴
2∆𝑥
𝛼 ∆𝑡
𝐵 1
∆𝑥
∆
𝐾 𝑇 𝑇 2𝑇 𝑇 )
∆
𝐴𝑇 𝐵𝑇 𝐴𝑇 𝐾
30
12
Implicit Method - Crank Nicholson Technique
AT BT AT K
Point 1 and 7 represents the temperature at boundaries
so known to us
• At point 2
AT BT AT K
BT AT K AT K
• At point 3
AT BT AT K
• At point 4
AT BT AT K
• At point 5
AT BT AT K
• At point 6
AT BT K AT K
31
Explicit and Implicit Method
Explicit Method Implicit Method
Advantage: Relatively simple to Advantage: Stability can be maintained over much larger values of
set up and program. ∆t, hence using considerable fewer time steps to make calculations
over a given interval oft. This results in less computer time.
Disadvantage: In terms of our Disadvantage: 1. More complicated to set up and program.
above example, for a given ∆x, ∆t 2. Massive matrix manipulations are usually required at each
must be less than some limit time step, the computer time per time step is much larger than in
imposed by stability constraints. In the explicit approach.
some cases, it must be very small 3. Since large ∆t can be taken, the truncation error is large, and the
to maintain stability; this can result use of implicit methods to follow the exact transients (time
in long computer running times to variations of the independent variable) may not be as accurate as
make calculations over a given an explicit approach.
interval of t.
32
13
Numerical Schemes for FDM
Laasonen scheme
Forward Time Central Space (FTCS) scheme
Richardson Scheme
DuFort-Frankel scheme
First-order upwind scheme
Runge-Kutta method
Crank-Nicolson method
Gauss-Seidel Iteration methods
Lax-Wendroff method
Richtmyer/Lax-Wendroff Multi-step method
MacCormack method
34
Type of Errors
Discretization error, the difference between the exact analytical solution
of the partial differential equation and the exact (round-off-free) solution of
the corresponding difference equation. The discretization error is simply
the truncation error for the difference equation plus any errors introduced
by the numerical treatment of the boundary conditions.
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.
35
14
Some terminologies
Consistency
A finite difference approximation of partial differential equation is
consistence if FDE approaches to PDE as the grid size approaches zero.
Stability
A numerical scheme is said to be stable if any error introduced in
the FDE does not grow with the iterations. They should either shrink or at
least stop growing.
Convergence
Convergence means the simulation's numerical values (like velocity,
pressure, temperature) no longer change significantly as the solver iterates
through the calculations.
36
Some terminologies
Boundedness
In CFD, boundedness refers to the property of a solution where all
flow properties (like velocity, pressure, and temperature) remain within their
physically meaningful bounds. Essentially, the numerical solution should
never exceed the maximum or minimum values observed at the boundaries
of the domain.
37
15
Thanks
38
16