You are on page 1of 49

3/8/2007 Indo-German Winter Academy 1

Discretization Methods
in Fluid Dynamics
Mayank Behl
B-tech. 3
rd
Year
Department of Chemical Engineering
Indian Institute of Technology Delhi
Course 1: Fluid Mechanics and Energy Conversion
Supervisor:
Dr. G.Biswas
Indian Institute of Technology
Kanpur
Indo-German Winter Academy 2
3/8/2007
OUTLINE
1. Basics of PDE
2. Mathematical Overview of fluid flow
3. Need For Computational Methods
4. Basic Discretization Methods in use
5. Finite Difference Method
6. Fluid Flow Modeling
Indo-German Winter Academy 3
3/8/2007
Partial differential equations (PDEs) are used to
formulate and solve problems related to any phenomena
that is distributed in space and time :
Heat flow
Fluid flow
propagation of sound
electrodynamics,
Elasticity.
) , ( A
2
2 2
2
2
y x G F
y
E
x
D
y
C
y x
B
x
= +



Most of the fluid and related transport phenomena
can be modeled using PDEs
Indo-German Winter Academy 4
3/8/2007
Classification of PDEs
) , ( A
2
2 2
2
2
y x G F
y
E
x
D
y
C
y x
B
x
= +



B
2
4AC<0
Elliptic equation
B.V.P.
Irrotational flows
steady Heat Transfer
B
2
4AC=0
Parabolic equation
I.B.V.P;
Unsteady viscous
flows
B
2
4AC>0
Hyperbolic equation
Vibration problems
0
2
2
2
2
=

y

x

2
2
x t

2
2
2
2
2
x t

If A,B,C,Dall constants or f(x,y)


Linear PDE
If any of A,B,C,Dcontains , etc Non-linear PDE
Indo-German Winter Academy 5
3/8/2007
Boundary conditions
Dirchlet Boundary
condition:
Neumann Boundary
condition:
Mixed Boundary
condition:
) (
1
r =
) (
2
r
n

) (
3
r
n
b a

+
Given boundary temperature
Given boundary heat flux
Boundary heat flux dependent on boundary temperature
Indo-German Winter Academy 6
3/8/2007
Equation of continuity: a differential mass balance
t z
w
y
v
x
u


[ ]
t

=

u
In vector notation:
For constant density of the fluid:
0 = u
Mathematical description of flows;
Governing Equations of Fluid Dynamics
x
z
y
(x,y,z)
Indo-German Winter Academy 7
3/8/2007
Equation of motion:
g uu u + = +

p
t
Governing Equations of Fluid Dynamics (2)
for incompressible, Newtonian Fluids , under laminar flow:
g u u u u + + =

2
p
t
Navier-Stokes Equation
Indo-German Winter Academy 8
3/8/2007
The Navier-Stokes equations
(Non linear
PDEs)
x
g
z
u
y
u
x
u
x
p
z
u
w
y
u
v
x
u
u
t
u
+

2
2
2
2
2
2
1

y
g
z
v
y
v
x
v
y
p
z
v
w
y
v
v
x
v
u
t
v
+

2
2
2
2
2
2
1

z
g
z
w
y
w
x
w
z
p
z
w
w
y
w
v
x
w
u
t
w
+

2
2
2
2
2
2
1

In general, Analytical Solution Not Possible


Solution???
Indo-German Winter Academy 9
3/8/2007
Approaches to Fluid Dynamical Problems
1. Simplifications of the governing equations
AFD: Analytical Fluid Dynamic
2. Experiments on scale models
EFD: Experimental Fluid Dynamics
3. Discretize governing equations and solve by computers
CFD Computational Fluid Dynamics
CFD is the simulation of fluids engineering system using
modeling and numerical methods
Indo-German Winter Academy 10
3/8/2007
Need for Discretization methods
In general, no analytical solution exist for non-linear models
One of the way out is to approximate the solutions using
Numerical methods
Advent of digital computer and advanced improvements in
computer resources
Basis for CFD, which can provide unlimited details of results
Substantially more cost effective and more rapid than EFD
ability to study systems under hazardous conditions
Indo-German Winter Academy 11
3/8/2007
Finite Difference Method (focused in this lecture)
Finite Volume Method
Finite Element Method
Various Discretization Techniques
Indo-German Winter Academy 12
3/8/2007
Discretization Methods
Finite Difference Method (focused in this lecture)
1.Governing equations in differential formdomain with grid
replacing the partial derivatives by approximations in terms of node
values of the functionsone algebraic equation per grid nodelinear
algebraic equation system.
2. Applied to structured grids
Finite Volume Method
1. Governing equations in integral formsolution domain is subdivided
into a finite number of contiguous control volumesconservation
equation applied to each CV.
2. Computational node locates at the centroid of each CV.
3. Applied to any type of grids, especially complex geometries
Finite Element Method
1. Solution domain is subdivided into a finite number OF ELEMENTS,
the governing equation is solved for each element and then overall
solution is obtained by assembly.
2. Equations are multiplied by a weight function before integrated over
the entire domain.
Indo-German Winter Academy 13
3/8/2007
Consistency
A discretization method is said to be consistent if it can be
shown that the difference between PDEs and its finite
difference (FDE) vanishes as the mesh is refined.
Truncation error (TE): Difference between the discretized
equation and the exact one
Lim
mesh0
(TE) 0
Basics aspects of Discretization methods
O(x); O(t)
O(t/x)
Convergence: solution of the discretized equations
tends to the exact solution of the differential equation as the
grid spacing tends to zero.
Indo-German Winter Academy 14
3/8/2007
Basics aspects of Discretization methods
Stability : Differencing Method should not magnify the
errors that appear in the course off numerical solution
process
Conservation:
1. The numerical scheme should on both local and
global basis respect the conservation laws.
2. Automatically satisfied for control volume method,
either individual control volume or the whole domain.
3. Errors due to non-conservation are in most cases
appreciable only on relatively coarse grids, but hard to
estimate quantitatively
1
1

+
n
i
n
i

Indo-German Winter Academy 15


3/8/2007
Finite Difference Method
Replacing the derivatives of governing
PDE with finite, algebraic differences
quotients. It involves following steps:
Grid generation defining
geometric domain
Discretization of governing
equation using Taylor
series approximation.
Solution of simultaneous
algebraic equations.

i,j

i+1,j

i-1,j
x
y
Discrete grid points

i-1,j

i,j

i+1,j
Indo-German Winter Academy 16
3/8/2007
Finite Difference Method:grids
Grids
Structured grid
all nodes have the same number
of elements around it
only for simple domains
Unstructured grid
for all geometries
irregular data structure
Indo-German Winter Academy 17
3/8/2007
Finite Difference,
approximation of the first derivative
Taylor Series Expansion: Any continuous differentiable
function, in the vicinity of x
i
, can be expressed as a Taylor
series:
( ) ( ) ( )
( ) ( ) ( )
H
x n
x x
x
x x
x
x x
x
x x x x
i
n
n
n
i
i
i
i
i
i
i i
+


+ +


+ =
!
...
! 3 ! 2
3
3
3
2
2
2
( )
H
x
x x
x
x x
x x

x

i
i i
i
i i
i i
i i
i
+

+ +
+
+
3
3
2
1
2
2
1
1
1
6 2
Higher order derivatives are unknown and can be dropped when the
distance between grid points is small X
i+1
- X
i
is small
Indo-German Winter Academy 18
3/8/2007
By writing Taylor series at different nodes, x
i-1
, x
i+1
, or both
x
i-1
and x
i+1
, we can have:
O(x)
1
1


i i
i i
i
x x x
Backward Difference Scheme-BDS
O(x)
i i
i i
i
x x x


+
+
1
1
Forward Difference Scheme-FDS
order of accuracy
O(x)
1 1
1 1
+
+


i i
i i
i
x x x
Central Difference Scheme-CDS
O(x)
Indo-German Winter Academy 19
3/8/2007
Finite Difference,
approximation of the second derivative
Geometrically, the second derivative is the slope of the line
tangent to the curve representing the first derivative.
i i
i i
i
x x
x x
x


+
+
1
1
2
2
Estimate the outer derivative by FDS, and estimate the inner
derivatives using BDS, we get
For equidistant spacing of the points:
( ) ( ) ( )
( ) ( )
1
2
1
1 1 1 1 1 1
2
2
+
+ + +

+


i i i i
i i i i i i i i i
i
x x x x
x x x x x x
x
( )
2
1 1
2
2
2
x
x
i i i
i

+


+
Higher-order approximations for the second derivative can be
derived by including more data points, such as x
i-2
, and x
i+2
, even
x
i-3
, and x
i+3
Indo-German Winter Academy 20
3/8/2007
Discretization using Explicit Method
Consider unsteady viscous flow
2
2
x t

=



( )
2
1 1
1
2
x
t
i
n
i
n
i
n n
i
n
i

+
=


+
+

The Only unkown


:
i
n+1
Explicit method , values at time n+1 computed from values at time n
Advantages: solution algorithm is simple i.e.
- direct computation without solving system of algebraic equation
- few number of operations per time step
Disadvantage: strong conditions on time step for stability
Requires many time steps to carry out the calculations over
a given time interval
Indo-German Winter Academy 21
3/8/2007
Implicit Method
Crank-Nicholson Method
( )
2
1
1
1
1 1
1
1
1
2
2 2
x
u u u u u u
t
u u
n
i
i
n n
i
i
n n
i
i
n n
i
n
i

+ + +
=

+ +
+
+
+

2
2
x
u
t
u


values at time n+1 computed using the unknown values at time n+1
Second order accurate in time and space
to be solved simultaneously at all the grid points as a system of
algebraic equations
Unconditionally stable
rearranging the above equation as follows.
O(t)
2
,O(x)
2
Indo-German Winter Academy 22
3/8/2007
Indo-German Winter Academy 23
3/8/2007
This generates a Tridiagonal Matrix system which can be solved
using Thomas algorithm.
However, for higher dimensional flows, matrix system obtained are
much more complex and require substantially more computer time
Ax = C
Indo-German Winter Academy 24
3/8/2007
Alternating Direction Implicit Method
(ADI) for 2-D Flows
( )

+
+

+
=

+ +
+ +
+
2
2 / 1
1 ,
2 / 1
,
2 / 1
1 ,
2
, 1 , , 1 ,
2 / 1
,
2 2
2 / y
u u u
x
u u u
t
u u
n
j i
n
j i
n
j i
n
j i
n
j i
n
j i
n
j i
n
j i

2
2
2
2
y
u
x
u
t
u

Each time increment is executed into two steps:


First step
( )

+
+

+
=

+ +
+
+

+ +
+
+ +
2
2 / 1
1 ,
2 / 1
,
2 / 1
1 ,
2
1
, 1
1
,
1
, 1
2 / 1
,
1
,
2 2
2 / y
u u u
x
u u u
t
u u
n
j i
n
j i
n
j i
n
j i
n
j i
n
j i
n
j i
n
j i

Second step
Indo-German Winter Academy 25
3/8/2007
ADI method results in Tridiagonal Equations (for 2-d flow systems)
if it is applied along the dimension that is implicit. Thus on first step it is
applied along Y axis and on second step along on X axis
First direction Y
Second direction X
Indo-German Winter Academy 26
3/8/2007
Implicit method
Advantages:
Stability can be maintained over larger time
steps
Disadvantages
More computation time per time step, every time
step requires solving a system of equations.
Truncation error is often large , since larger
time steps are employed.
Overall, a more involved procedure
Indo-German Winter Academy 27
3/8/2007
Error and Stability analysis
Numerical solution is influenced by following:
Discretization errors or Truncation errors:
Analytical Solution (A) exact Finite Difference Solution (D)
= A D
Computational Round-Off Error (e)
=Numerical Solution (N) exact Finite Difference Solution (D)
N = D +
By definition, N,D follow the Discretized Equation
Thus, should also follow the equation:
( )
2
1 1
1
2
x
t
i
n
i
n
i
n n
i
n
i

+
=

+
+


Indo-German Winter Academy 28
3/8/2007
Errors and Stability Analysis
(Cont.)
Substituting the value
of
m
(x,t) in the F.D.E.,
Indo-German Winter Academy 29
3/8/2007
For stability:

=
m
x ik
at m
t x ) , (
Von Neumann Stability Analysis :
assuming error distribution follows Fourier series in space domain and
exponential in time
Putting an individual term in FD equation and using the above stability
criteria
2
1
) (
) (
2

x
t
1
1

+
n
i
n
i

Stability: Differencing Method should not magnify the errors that


appear in the course off numerical solution process
Indo-German Winter Academy 30
3/8/2007
Fluid Flow Modeling Using
Finite Difference Method
Nonlinear Fluid Flow equations involve:
time dependent multiple variables
Convective terms
Diffusive terms
Sample fluid flow equation : Burgers Equation

2
2
x x
u
t
u

0 =

x
u
t
u
Inviscid Burgers Equation
Indo-German Winter Academy 31
3/8/2007
Conservative Property: To maintain the integral conservation
relation of continuum in finite difference representation.
It depends on the form of continuum equation being
discretized.
Conservative form:
Non-conservative form:
Properties of Fluid Flow Equations
Effect of Finite Difference method on properties of
fluid flow equations
( )

u
x t

x
u
t


Indo-German Winter Academy 32
3/8/2007
2
) (
2
1
2
1
2
1
1 1 1 1
1

=
+ +
= =
+


I
I i
n
i
n
i
n
i
n
i
I
I i
I
I i
n
i
n
i
u u
t
x x
2 / 1 2 / 1
2 1
) ( ) (
+
=
I I
u u
x
x
u u
x
t
i
n
i
n n
i
n
i

+
+

2
) ( ) (
1 1
1


Integrating the
CONSERVATIVE FORM
I
1
I
2
Indo-German Winter Academy 33
3/8/2007
Week Conservative Form in Fluid Flow
Conservative form of advective part is of prime importance for
fluid flow modeling. Navier Stokes in week conservative form:
x
g
z
u
y
u
x
u
x
p
z
uw
y
uv
x
u
t
u
+

2
2
2
2
2
2 2
1

y
g
z
v
y
v
x
v
y
p
z
vw
y
v
x
uv
t
v
+

2
2
2
2
2
2 2
1

z
g
z
w
y
w
x
w
z
p
z
w
y
vw
x
uw
t
w
+

2
2
2
2
2
2 2
1

Indo-German Winter Academy 34


3/8/2007
Discretizing Fluid Flow equations using
Upwind Scheme
Upwind Scheme of discretization is necessary for convection
dominated flows
x
u
t


x
u u
t
i
n
i
n n
i
n
i


+
1
1

x
u u
t
i
n
i
n n
i
n
i

+
+

1
1
Backward Differencing Scheme for u>0
Forward Differencing Scheme for u<0
Indo-German Winter Academy 35
3/8/2007
Why use Upwind scheme
Upwind Scheme of discretization is necessary for convection
dominated flows for obtaining numerically stable results
Central Difference Scheme applied to highly convective flows
give unconditionally Unstable Results
0
2
1 1
1
=

+
+
x
u u
t
i
n
i
n n
i
n
i

CDS:
Violates
Von Neumann
Stability
Criteria
0 , 0
1
1
> =

+
+
u
x
u u
t
i
n
i
n n
i
n
i

FDS:
Indo-German Winter Academy 36
3/8/2007
Why use Upwind scheme
2
1 1
1 1
1
2
2 x x
u u
t
n
i
n
i
n
i
i
n
i
n n
i
n
i

+
=

+
+
+


CDS:
xx x
t u
u
t


= +

2
2
0
2
2

t u

0
2
1
1

x u
x
t u

x u
x
Re
0 Re *
2
1
1

C
C
2
Re
CELL Reynolds No.
For unsteady, convection-diffusion eqn.
Indo-German Winter Academy 37
3/8/2007
( )

u
x t

x
u u
t
i
n
i
n n
i
n
i

>

+
1
1
0) (u scheme upwind using

Upwind Scheme and Transportive Property
proprerty ive transport for the rationale the follows which
0

1) (m location downstream a at for Then
location m at occurs in on perturbati a let
1
1
1
th
x
u
x
u
t
n
m
n
m

+ =

+
+
+
+


At (m+1) location
region the of out ed transport being on perturbati

0

location (m) At
1
x
u
x
u
t
n
m
n
m

+

At (m) location
upstream carried on perturbati no
0
0 0
location 1) - (m At
1
1
1
=

x t
n
m
n
m

At (m-1) location
Indo-German Winter Academy 38
3/8/2007
Problems of Using Forward Time Central Space method (FTCS)
0
2 2
0
location 1) - (m At
1
1
1

x
u
x
u
t
n
m
n
m

Which indicates that Transportive Property is violated
Hence, only upwind method maintains unidirectional flow
of information.
Indo-German Winter Academy 39
3/8/2007
Upwind Method and Artificial Viscosity(1/2)
x
u u
t
i
n
i
n n
i
n
i


+
1
1

x
u u
t
i
n
i
n n
i
n
i

+
+
1
1

2
2
x x
u
t
u

Indo-German Winter Academy 40


3/8/2007
Upwind Method and Artificial Viscosity (2/2)
< 1
For algorithms stability, artificial viscosity will necessarily be present
0 >
e
v
Source of inaccuracy
Indo-German Winter Academy 41
3/8/2007
Upwind Differencing Method
Advantages and Limitations
Upwind effect necessary to maintain transportive property of flow
equations
Although space centered differences (CDS) are more accurate than
upwind scheme (as indicated by Taylor Series expansion), the whole
system is more realistically modeled using Upwind Differencing Scheme.
Leads to Artificial viscosity or false diffusion which is a cause of
inaccuracy.
0 >
e
v
Plausible Improvement: Higher order Upwind Method
Indo-German Winter Academy 42
3/8/2007
Second Upwind Differencing Scheme
where
Let us consider
Indo-German Winter Academy 43
3/8/2007
Here a factor is introduced which expresses a
weighted average of central and upwind differencing

u
Considering momentum equation
Indo-German Winter Academy 44
3/8/2007
Here 0<<1
For =0, above equation becomes centered in space
For =1, above equation follows full upwind
Hence, brings about an upwind bias in the difference quotient
Accuracy of the differencing scheme can be adjusted using value
Second upwind formulation possesses both
the conservative and transportive property
Indo-German Winter Academy 45
3/8/2007
Summary
Finite Difference methods discretizes the differential form of governing
equation using Taylor Series expansion.
The partial derivatives of governing PDE are replaced with finite,
algebraic differences quotients at the corresponding nodes.
Leads to linear algebraic equation system, with one algebraic equation
per grid node.
Best Suited for Structured Grids only.
Flow equation properties can be maintained using simple schemes
like upwind differencing.
Discretization methods provide more cost effective and more rapid
approach for solving Fluid Flow problems as compared to
experimental methods
Indo-German Winter Academy 46
3/8/2007
Summary
Finite Difference Approach
FD Approaches Can Be Divided Into Various
Categories Depending Upon Type of PDE Being
Solved:
1.Elliptic PDE: Algebraic System, Gauss Siedel
2.One-dimensional Parabolic PDE
A) Explicit
B) Implicit
3. Two-dimensional Parabolic PDE
ADI Method
Indo-German Winter Academy 47
3/8/2007
Acknowledgement
This lecture has been inspired by the
study material provided by Prof. G.Biswas
Indo-German Winter Academy 48
3/8/2007
References
Chapra and Canale, Numerical Methods for
Engineers,4
th
Ed., Tata McGraw-Hill.
Som and Biswas, Introduction to Fluid Mechanics and
Fluid Machines, Tata McGraw-Hill
Anderson.J; Computational Fluid Dynamics
Indo-German Winter Academy 49
3/8/2007
Thank you !

You might also like