0% found this document useful (0 votes)
33 views

Lecture 3

The document discusses discretization methods for computational fluid dynamics (CFD) simulations. It describes discretization as approximating differential equations with algebraic expressions at discrete points. The main discretization methods covered are finite difference, finite volume, and finite element. It provides examples of applying Taylor series expansions to derive first and second order finite difference approximations of derivatives. Higher order accuracy methods and the process of obtaining difference equations from partial differential equations are also summarized.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Lecture 3

The document discusses discretization methods for computational fluid dynamics (CFD) simulations. It describes discretization as approximating differential equations with algebraic expressions at discrete points. The main discretization methods covered are finite difference, finite volume, and finite element. It provides examples of applying Taylor series expansions to derive first and second order finite difference approximations of derivatives. Higher order accuracy methods and the process of obtaining difference equations from partial differential equations are also summarized.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Presented

by
Dr Ceri
Computational Methods -
Morris Week 8

Discretisation
Discretisation
• Process by which a differential or integral equation is
approximated by algebraic expressions to provide values at
a number of discrete points in the flow domain

• While an analytical solution provides a description over the


whole flow domain, a numerical CFD solution only provides
numerical values for the solution at discrete points in the
domain called grid points, mesh points, or nodes.

• Computers cannot solve differential (or integral) equations


unless they are put in a discretised form. This means with
CFD the PDEs are changed into algebraic equations
Discretisation Schemes
• Finite Difference
• Finite Volume
• Finite Element

• Less common: spectral methods, boundary element


methods and particle (vortex) methods

• Simulate finite problem of an infinite physical world;


leads to loss of information
The Finite Difference Method
• The FDM is based on the definition of derivatives
and on Taylor series expansions

• It is the easiest method to understand and apply

• It requires the use of a structured grid


(hexahedral or quadrilateral elements only)
Taylor Series

𝜕𝑓
𝑓 𝑥 + ∆𝑥
𝜕𝑥
𝜕𝑓 𝜕 𝑓 ∆𝑥
𝑓 𝑥 + ∆𝑥 +
𝜕𝑥 𝜕𝑥 2!
𝜕𝑓 𝜕 𝑓 ∆𝑥 𝜕 𝑓 ∆𝑥
𝑓 𝑥 + ∆𝑥 + +
𝜕𝑥 𝜕𝑥 2! 𝜕𝑥 3!
𝑓(𝑥)

𝑓 𝑥

𝑥 𝑥+∆𝑥
Taylor Series

𝑓 0.22 ≈0.9899 0.775% error


𝑓 𝑥 = sin 2𝜋𝑥

𝑓 0.22 = 0.9823
𝑓 0.22 ≈0.9824 0.001% error
𝑓(𝑥)

𝑓 0.2 = 0.9511

𝑓 0.22 ≈ 0.9511 3.176% error

𝑥 𝑥 + ∆𝑥
Finite difference
• Let us consider the terms in the Navier-Stokes equation
for incompressible flow in the x direction:

• Question: How can we approximate the partial


derivatives above?
• Answer: using the finite difference method. This
depends on the definition of derivatives and Taylor
series expansion.
u
• Let us see how the term may be approximated using
x
the FDM.
First Order Forward Difference
Taylor Series Expansion:

, ,
, , ,

Rearrange for :
,
𝑖, 𝑗 𝑖 + 1, 𝑗
, ,

, , ,

Finite Difference Truncation Error


Representation

, , , ,

, ,

First Order
Forward difference
First Order Backward Difference
Taylor Series Expansion:

, ,
, , ,

Rearrange for :
,
, , 𝑖 − 1, 𝑗 𝑖, 𝑗

, , ,

Finite Difference Truncation Error


Representation

, , , ,

, ,

First Order
Backward difference
Second Order Central Difference
Subtract Taylor Series expansion for , from expansion for , :

, ,
, ,

Rearrange for :
,
, , 𝑖 − 1, 𝑗 𝑖 + 1, 𝑗

, ,

Finite Difference Truncation Error


Representation

, , , ,

, ,
Second Order
Central difference
Second Order Central Second Difference

Navier-Stokes equation in x direction:

Summing Taylor Series expansions for , and , :

, , ,
, ,

Rearrange for :
,
𝑖 − 1, 𝑗 𝑖, 𝑗 𝑖 + 1, 𝑗
, , ,

,
Second Order
Central Second Difference
Finite Difference Expressions
𝜕𝑢 𝑢 ,−𝑢, 𝜕𝑢 𝑢, −𝑢 , 𝜕𝑢 𝑢 , −𝑢 , 𝜕 𝑢 𝑢 , − 2𝑢 , + 𝑢 ,
= = = =
𝜕𝑥 ∆𝑥 𝜕𝑥 ∆𝑥 𝜕𝑥 ,
2∆𝑥 𝜕𝑥 (∆𝑥)
, , ,

𝑖, 𝑗 𝑖 + 1, 𝑗
𝑖 − 1, 𝑗

1st order 1st order 2nd order 2nd order


forward difference backward difference central difference central 2nd difference
wrt x wrt x wrt x wrt x

𝜕𝑢 𝑢, −𝑢, 𝜕𝑢 𝑢, −𝑢, 𝜕𝑢 𝑢, −𝑢, 𝜕 𝑢 𝑢, − 2𝑢 , + 𝑢 ,


= = = =
𝜕𝑦 ∆𝑦 𝜕𝑦 ∆𝑦 𝜕𝑦 ,
2∆𝑦 𝜕𝑦 (∆𝑦)
, , ,
𝑖, 𝑗 + 1

𝑖, 𝑗 − 1
1st
order 1st
order 2nd order 2nd order
forward difference backward difference central difference central 2nd difference
wrt y wrt y wrt y wrt y
Higher Order Accuracy Finite Differences
E.g.
, , , , ,

,
Fourth Order
Central difference

• Can be derived by repeated application of Taylor’s series expanded about


grid points (i+1,j), (i,j), (i-1,j) 𝑖 − 1, 𝑗 𝑖 + 1, 𝑗
• Involves information at 5 grid points 𝑖 − 2, 𝑗 𝑖, 𝑗 𝑖 + 2, 𝑗

• Require more computer time since more grid points required


• May require fewer total grid points to achieve comparable accuracy
• May result in higher quality solution
Difference Equations
• A partial differential equation where all of the partial
derivatives are replaced by finite-difference quotients

• E.g. 2D Navier-Stokes
steady momeequation in x direction:

• Difference Equation using central differencing:


, , , ,

, , , , , ,
Example 1: 1D linear Convection
• Consider the equation
u u
c 0
t x
c = is the transport velocity, u = u (x,t) is a transported quantity
Since c = constant this a linear problem.
u u
• There are two partial derivatives: t and x so we need to discretise in
time t and space x: time-space discretisation.

• Let i be the index of the grid in x spatial direction


• Let n be the index of the grid in t
• Use a Finite Difference scheme such that:
• Forward differencing in time:
Superscript denotes change in time
n 1
u u  u n
 i i
Subscript denotes change in spatial
t t position

• Backward differencing in space


u uin  uin1

x x
The discretised form of the equation is then

uin 1  uin uin  uin1


c 0
t x

n and n+1 are two consecutive steps in time while i-1 and i are two
neighbouring spatial points.
Example 2: 1D Diffusion equation
u  2u
• Consider the PDE t   x 2
• Use Forward difference in time t, with index n
• Use central difference for space x, with index i
• The discretised form is uin1  uin  uin1  2uin  uin1 
   
t  x 2

• Solving for u n 1
i

 t
u n 1
u 
n
u n
 2uin  uin1 
i i
x  2 i 1
FD Method: Observations

• FDM is the oldest and easiest to apply, but its reliance on


a structured mesh to discretise the system of PDEs makes
it a method hard to apply to complex geometries in
multiple dimensions.

• This has motivated the development of more generalised


methods: finite element and finite volume techniques
Finite Volume Method (FVM)

• With FDM, the governing equations (in differential form) are


discretised, i.e. changed into a set of algebraic (arithmetic)
equations.

• FVM, however, uses a volume integral formulation of the


problem with a finite set of volumes to discretise the equations.

• Applicable on general unstructured mesh (can be used on


structured meshes too)

• FVM is most widely used (~85%) in engineering simulations


Finite Volume Method (FVM)
• Domain is discretised into a finite set
of control volumes (CV)

• Integral equations are transformed


into a set of algebraic (arithmetic)
equations, solved numerically by a
computer

• On each of the control volumes the


fluid equations based on the The fluid region of pipe flow
is discretised into a finite
conservation of mass, momentum
number of control volumes
and energy are then solved

• ANSYS Fluent CFD solvers are based


on the finite volume (FV) method.
Explicit Vs Implicit
• Difference equation • Dependent variables
with only 1 unknown based on several
for each variable unknowns

• Coupled sets of
equations

• Matrix or iterative
technique needed
Explicit Vs Implicit
• Simpler to set up and • Can use much larger values
program of Δt – fewer time steps
required

• In some cases Δt must be • More complicated to set


very small to maintain up and program
stability – can result in long • Computer time per time
running times step is much larger
• Large Δt results in large
truncation error for
transient simulations
Presented
by
Dr Ceri
Computational Methods -
Morris Week 8

Iterative Solvers
Iterative Solvers
• Consider simultaneous 4x + 2y + 3z = 8
equations shown: 3x - 5y + 2z = -14
-2x + 3y + 8z = 27

• Rearrange first equation to x = (8 -2y - 3z) / 4


give an expression for x
• Rearrange second equation y = (-14 - 3x - 2z) / -5
to give an expression for y
• Rearrange third equation to
give an expression for z z = (27 + 2x - 3y) / 8
Jacobi Method
Iteration 1
• First set y and z to 0 and solve for x
• Next set x and z to 0 and solve for y
• Then set x and y to 0 and solve for z

Iteration 2
• Take the y and z values from iteration 1 and solve for x
• Take the x and z values from iteration 1 and solve for y
• Take the y and z values from iteration 1 and solve for z

Iteration 3 – Take values from iteration 2 and continue…..


Iterative Solvers - Jacobi
0 1 2 3 4 5 6 7 8 9 10
X 0 2.000 -1.931 -2.794 -0.050 0.033 -1.819 -1.546 -0.355 -0.749 -1.476

Y 0 2.800 5.350 2.771 1.478 3.425 3.943 2.548 2.449 3.400 3.297

Z 0 3.375 2.825 0.886 1.637 2.808 2.099 1.442 2.033 2.368 1.913

2
Value

X
0 Y
-2 Z

-4
0 5 10 15 20 25 30
Iteration
Residuals
• Move all terms in each expression to the left hand side
• The right hand side should then equal zero
• Enter the values calculated for each iteration to give the
residual for that iteration
• Residuals show how far away the estimated values are
from perfectly satisfying the equation
Residuals - Jacobi
0 1 2 3 4 5 6 7 8 9 10
X 0.00 2.00 -1.93
-8.00 15.73 3.45
Y 0.00 2.80 5.35
14.00 12.75 -12.89
Z 0.00 3.38 2.83
-27.00 4.40 15.51
30

25

20 X
Residual

15 Y
10 Z

0
0 5 10 15 20 25 30
Iteration
Iterative Solvers – Gauss-Seidel
0 1 2 3 4 5 6 7 8 9 10
X 0.00 2.00 -1.78

Y 0.00 4.00 2.68

Z 0.00 2.38 1.92

5
4
3
2
Value

1 X
0 Y
-1 Z

-2
-3
0 2 4 6 8 10
Iteration
Residuals – Gauss-Seidel
0 1 2 3 4 5 6 7 8 9 10
X 0.00 2.00 -1.78
-8.00 15.13
Y 0.00 4.00 2.68
14.00 4.75
Z 0.00 2.38 1.92
-27.00 0.00
30
25
20 X
Residual

15 Y
10
Z
5
0
-5 0 2 4 6 8 10
Iteration
Initial Values
• Possible to use better estimates as initial values
instead of setting all variables to 0
• Reduce the number of iterations needed to
achieve a stable solution
• Common to set all values to those at a boundary,
e.g. inlet
Iterative Solvers
• These examples used very simple equations.
Imagine how long it would take to find a
solution to the Navier-Stokes equations for
several thousand or million cells

• Hence we need to use computers!


Relaxation Factors
• It is common to apply relaxation as follows:
 new , used
P   old
P  U ( new , predicted
P  old
P )
• Here U is the relaxation factor:
o U < 1 is underrelaxation. This may slow down speed of
convergence but increases the stability of the calculation, i.e.
it decreases the possibility of divergence or oscillations in
the solutions.
o U = 1 corresponds to no relaxation. One uses the predicted
value of the variable.
o U > 1 is overrelaxation. It can sometimes be used to
accelerate convergence but will decrease the stability of the
calculation.
Relaxation Factors

 new , used
P   old
P  U ( new , predicted
P  old
P )
• E.g. If velocity at a given point is calculated as 2 m/s after
10 iterations and the new, predicted value after iteration
11 is 2.4 m/s
• A U value of 0.5 will result in a new, used value for
iteration 11 of 2.2 m/s
• A U value of 0.75 will results in a new, used value for
iteration 11 of 2.3 m/s
• A U value of 1.5 will result in a new, used value for
iteration 11 of 2.6 m/s
Can you?
• Explain the difference between Explicit & Implicit Methods
o Explicit – 1 unknown per variable, simple, need small Δt for
stability
o Implicit - variables based on several unknowns, matrix/iterative
approach needed, more complex but stable for larger Δt

• Solve simple equations using Jacobi and Gauss-Seidel


methods and explain why Gauss-Seidel usually converges
more quickly.

• Explain why relaxation factors are used and the effect of


changing them

You might also like