Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 52

Introduction to

Computational
Fluid Dynamics
Instructor : Bibhab Kumar Lodh
Assistant Professor, Chemical Engg. Department
Class : M.Tech
Course : CFD (Elective)
Fluid (gas and liquid) flows are governed by
partial differential equations which
represent conservation laws for the mass,
momentum, and energy.

Computational Fluid Dynamics (CFD) is the


art of replacing such PDE systems
by a set of algebraic equations which can
be solved using digital computers.
What is fluid flow?
Fluid flows encountered in everyday life include

• meteorological phenomena (rain, wind, hurricanes, floods, fires)

• environmental hazards (air pollution, transport of contaminants)

• heating, ventilation and air conditioning of buildings, cars etc.

• combustion in automobile engines and other propulsion systems

• interaction of various objects with the surrounding air/water

• complex flows in furnaces, heat exchangers, chemical reactors etc.

• processes in human body (blood flow, breathing, drinking . . . )

• and so on and so forth


What is CFD?
Computational Fluid Dynamics (CFD) provides a qualitative (and sometimes even
quantitative) prediction of fluid flows by means of

• mathematical modeling (partial differential equations)


• numerical methods (discretization and solution techniques)
• software tools (solvers, pre- and postprocessing utilities)

CFD enables scientists and engineers to perform ‘numerical experiments’


(i.e. computer simulations) in a ‘virtual flow laboratory’ real experiment CFD
simulation.

Real experiment CFD simulation


Why use CFD?
Numerical simulations of fluid flow (will) enable

 architects to design comfortable and safe living environments

 designers of vehicles to improve the aerodynamic characteristics

 chemical engineers to maximize the yield from their equipment

 petroleum engineers to devise optimal oil recovery strategies

 surgeons to cure arterial diseases (computational hemodynamics)

 meteorologists to forecast the weather and warn of natural disasters

 safety experts to reduce health risks from radiation and other hazards

 military organizations to develop weapons and estimate the damage

 CFD practitioners to make big bucks by selling colorful pictures :-)


Examples of CFD
Examples of CFD
Experiments vs. Simulations
CFD gives an insight into flow patterns that are difficult, expensive or
impossible to study using traditional (experimental) techniques

Experiments Simulations
Quantitative description of flow Quantitative prediction of flow
phenomena using measurements phenomena using CFD software
• for one quantity at a time • for all desired quantities
• at a limited number of points • with high resolution in
and time instants space and time
• for a laboratory-scale model • for the actual flow domain
• for a limited range of problems • for virtually any problem and
and operating conditions realistic operating conditions

Error sources: measurement errors, Error sources: modeling,


flow disturbances by the probes discretization, iteration,
implementation
Experiments vs. Simulations
As a rule, CFD does not replace the measurements completely but the amount
of experimentation and the overall cost can be significantly reduced.

Experiments Simulations
Equipment and personnel
•Expensive •Cheap(er)
are difficult to transport
•Slow •Fast(er)
CFD software is portable,
•Sequential •parallel
easy to use and modify
•Single-Purpose •Multi-Purpose

The results of a CFD simulation are never 100% reliable because

• the input data may involve too much guessing or imprecision

• the mathematical model of the problem at hand may be inadequate

• the accuracy of the results is limited by the available computing power


Fluid characteristics
Macroscopic properties Classification of fluid flows

ρ density viscous inviscid

μ viscosity compressible incompressible

p pressure steady unsteady

T temperature laminar turbulent

v velocity single-phase multiphase

The reliability of CFD simulations is greater


• for laminar/slow flows than for turbulent/fast ones
• for single-phase flows than for multi-phase flows
• for chemically inert systems than for reactive flows
How does CFD make predictions?
CFD uses a computer to solve the mathematical equations for the problem
at hand. The main components of a CFD design cycle are as follows:

• the human being (analyst) who states the problem to be solved

• scientific knowledge (models, methods) expressed mathematically

• the computer code (software) which embodies this knowledge and


provides detailed instructions (algorithms) for

• the computer hardware which performs the actual calculations

• the human being who inspects and interprets the simulation results

CFD is a highly interdisciplinary research area which lies at the


interface of physics, applied mathematics, and computer science
CFD analysis process
1. Problem statement information about the flow

2. Mathematical model IBVP = PDE+IC+BC

3. Mesh generation nodes/cells, time instants

4. Space discretization coupled ODE/DAE systems

5. Time discretization algebraic system Ax = b

6. Iterative solver discrete function values

7. CFD software implementation, debugging

8. Simulation run parameters, stopping criteria

9. Postprocessing visualization, analysis of data

10. Verification model validation / adjustment


Problem statement
• What is known about the flow problem to be dealt with?

• What physical phenomena need to be taken into account?

• What is the geometry of the domain and operating conditions?

• Are there any internal obstacles or free surfaces/interfaces?

• What is the type of flow (laminar/turbulent, steady/unsteady)?

• What is the objective of the CFD analysis to be performed?

– computation of integral quantities (lift, drag, yield)


– snapshots of field data for velocities, concentrations etc.
– shape optimization aimed at an improved performance

• What is the easiest/cheapest/fastest way to achieve the goal?


Mathematical model
1. Choose a suitable flow model (viewpoint) and reference frame.

2. Identify the forces which cause and influence the fluid motion.

3. Define the computational domain in which to solve the problem.

4. Formulate conservation laws for the mass, momentum, and energy.

5. Simplify the governing equations to reduce the computational effort:


• use available information about the prevailing flow regime
• check for symmetries and predominant flow directions (1D/2D)
• neglect the terms which have little or no influence on the results
• model the effect of small-scale fluctuations that cannot be captured
• incorporate a priori knowledge (measurement data, CFD results)

6. Add constituitive relations and specify initial/boundary conditions.


Discretization process
The PDE system is transformed into a set of algebraic equations

1. Mesh generation (decomposition into cells/elements)

• structured or unstructured, triangular or quadrilateral?


• CAD tools + grid generators
• mesh size, adaptive refinement in ‘interesting’ flow regions

2. Space discretization (approximation of spatial derivatives)

• finite differences/volumes/elements
• high- vs. low-order approximations

3. Time discretization (approximation of temporal derivatives)

• explicit vs. implicit schemes, stability constraints


• local time-stepping, adaptive time step control
Iterative solution strategy
The coupled nonlinear algebraic equations must be solved
iteratively

• Outer iterations: the coefficients of the discrete problem are updated using the
solution values from the previous iteration so as to

– get rid of the nonlinearities by a Newton-like method


– solve the governing equations in a segregated fashion

• Inner iterations: the resulting sequence of linear subproblems is typically solved


by an iterative method (conjugate gradients, multigrid) because
direct solvers (Gaussian elimination) are prohibitively expensive

• Convergence criteria: it is necessary to check the residuals, relative solution


changes and other indicators to make sure that the
iterations converge. As a rule, the algebraic systems to be
solved are very large (millions of unknowns) but sparse, i.e.,
most of the matrix coefficients are equal to zero.
CFD simulations
The computing times for a flow simulation depend on
• the choice of numerical algorithms and data structures

• linear algebra tools, stopping criteria for iterative solvers

• discretization parameters (mesh quality, mesh size, time step)


• cost per time step and convergence rates for outer iterations

• programming language (most CFD codes are written in Fortran)

• many other things (hardware, vectorization, parallelization etc.)


The quality of simulation results depends on

• the mathematical model and underlying assumptions

• approximation type, stability of the numerical scheme


• mesh, time step, error indicators, stopping criteria . . .
Postprocessing and analysis
Postprocessing of the simulation results is performed in order to
extract the desired information from the computed flow field

• calculation of derived quantities (streamfunction, vorticity)


• calculation of integral parameters (lift, drag, total mass)

• visualization (representation of numbers as images)

– 1D data: function values connected by straight lines


– 2D data: streamlines, contour levels, color diagrams
– 3D data: cutlines, cutplanes, isosurfaces, isovolumes
– arrow plots, particle tracing, animations . . .

• Systematic data analysis by means of statistical tools

• Debugging, verification, and validation of the CFD model


Uncertainty and error
Whether or not the results of a CFD simulation can be trusted
depends on the degree of uncertainty and on the cumulative
effect of various errors
• Uncertainty is defined as a potential deficiency due to the lack of
knowledge (turbulence modeling is a classical example)

• Error is defined as a recognizable deficiency due to other reasons

– Acknowledged errors have certain mechanisms for identifying,


estimating and possibly eliminating or at least alleviating them

– Unacknowledged errors have no standard procedures for detecting them


and may remain undiscovered causing a lot of harm

– Local errors refer to solution errors at a single grid point or cell

– Global errors refer to solution errors over the entire flow domain

Local errors contribute to the global error and may move throughout the
grid.
Classification of errors
Acknowledged errors

• Physical modeling error due to uncertainty and deliberate simplifications

• Discretization error approximation of PDEs by algebraic equations

– spatial discretization error due to a finite grid resolution

– temporal discretization error due to a finite time step size

• Iterative convergence error which depends on the stopping criteria

• Round-off errors due to the finite precision of computer arithmetic


Unacknowledged errors

• Computer programming error: “bugs” in coding and logical mistakes

• Usage error: wrong parameter values, models or boundary conditions


Verification of CFD codes
Verification amounts to looking for errors in the implementation
of the models (loosely speaking, the question is: “are we solving
the equations right”?)
• Examine the computer programming by visually checking the source
code, documenting it and testing the underlying subprograms individually

• Examine iterative convergence by monitoring the residuals, relative


changes of integral quantities and checking if the prescribed tolerance is
attained

• Examine consistency (check if relevant conservation principles are


satisfied)

• Examine grid convergence: as the mesh and/or and the time step are
refined, the spatial and temporal discretization errors, respectively,
should asymptotically approach zero (in the absence of round-off errors)

• Compare the computational results with analytical and numerical


solutions for standard benchmark configurations (representative test
cases)
Structure of the course
1. Introduction, flow models.
2. Equations of fluid mechanics.
3. Finite Difference Method.
4. Finite Volume Method.
5. Finite Element Method.
6. Implementation of FEM.
7. Time-stepping techniques.
8. Properties of numerical methods.
9. Turbulence Modeling.
10.Pressure Correction Technique
11. Vorticity Stream Function
Getting started….
CFD notation
u u  u  pu
2
u
PDE of p-th order f(u, x, t, …, , , ,....., p )  0
x1 xn t x1x2 t
scalar unknowns u = u(x, t), x ∈ Rn, t ∈ R, n = 1, 2, 3

vector unknowns v = v(x, t), v ∈ Rm, m = 1, 2, . . .


  
Nabla Operator  i j  Where, x = (x, y, z), v = (vx, vy, vz)
x y z
T
u u u  u u u 
u  i  j k  , ,  Gradient
x y z  x y z 
vx v y vz
v    Divergence
x y z
CFD notation
 vz v y 
  
 i j k   y z
  
 X v det 
     vx vz
 


Curl
 x y z   z x
  
v vy vz   v y vx 
 x   
 x y 

 2u  2u  2u
u  u )   u  2  2  2
2
Laplacian
x y z

z v

y
k j
x i
Tensorial quantities in fluid dynamics
Velocity gradient
 vx v y vz 
 
 x x x 
 v v y vz 
v  vx , v y , vz    x 
 y y y  v
 vx v y vz 
 
 z z z 

Remark. The trace (sum of diagonal elements) of ∇v equals ∇ . v.


Deformation rate tensor (symmetric part of ∇v)
 vx 1 v y vx 1 vz vx 
 (  ) (  )
 x 2 x y 2 x z 
1  1 v v y v y 1 vz v y 
D(v)  (v  vT )   ( x  ) (  )
2  2 y x y 2 y z 
 1 v vz 1 v y vz vz 
 ( x  ) (  ) 
 2  z x 2 z y z 
Spin tensor S(v)= ∇v-D(v) (Skew symmetric part of ∇v)
Vector multiplication rules
Scalar product of two vectors

 b1 
 
a, b  R 3 , a . b  a b   a1 a2 a3   b2   a1b1  a2b2  a3b3  R
T

b 
 3
Example.

u u u
v.u  vx  v y  vz Convective derivative
x y z
Elementary tensor calculus
   tij },   {tij }  R3 X 3 ,   R

2.     {t  tij },
1 2
ij
1 2
 ,  R
1 2 3X 3
,aR
 t11 t12 t13  3
 
3. a .    a1 a2 a3   t21 t22 t23    ai ti1 , ti 2 , ti3 , ith row
t  i 1
 31 t32 t33 
 t11 t12 t13   a1  t1 j 
3  
  
4.  a   t21 t22 t23   a2    t2 j  a j ( j  thColumn)
t t33   a3 
j 1  
 31 t32 t
 3j 
Elementary tensor calculus

t111 t121 t131  t112 t122 t132 


     1 2
3
5.  .   t21 t22 t23  t21 t22 t23    tik tkj 
1 2 1 1 1 2 2 2

t1 t1 t1  t 2 t 2 t 2   k 1 
 31 32 33   31 32 33 
3 3
6.  :   tr ( .( ) )   t t
1 2 1 2 T 1 2
ik ik
i 1 k 1
Divergence theorem
Let   R3and n be the outward unit normal to the boundary  

Then


 fdx  f . n ds

for any differentiable function f(x)

Example. A sphere:

   x  R : x 1  ,    x  R : x  1
3 3

where x  x.x  x  y  z is the Euclidean norm of x


2 2 2
x
Consider f ( x)  x so that . f  3 in  & n  on 
x
Volume Integral :
4 3
 . f dx  3 dx  3   3  3  1   4
Surface Integral :

x.x

f . n ds  
 x
ds   x ds   ds  4
 
Governing equations of fluid dynamics
Physical principles Mathematical equations
1. Mass is conserved • continuity equation
2. Newton’s second law • momentum equations
3. Energy is conserved • energy equation

It is important to understand the meaning and significance of each equation


in order to develop a good numerical method and properly interpret the results

Description of fluid motion


Eulerian monitor the flow characteristics in a fixed
control volume

Lagrangian track individual fluid particles as


they move through the flow field
Description of fluid motion
Trajectory of a fluid particle
X = X(X0, t)

z x = x(x0, y0, z0, t)


(X1,y1,z1)
v
y = y(x0, y0, z0, t)
k (X0,y0,z0)
z = z(x0, y0, z0, t)
j
dx
i y
 vx ( x, y, z, t ), x t  x0
dt 0

x dy
 v y ( x, y, z, t ), y t  y0
dt 0

dz
 vz ( x, y, z, t ), z t  z0
dt 0
Definition :
A streamline is a curve which is tangent to the
velocity vector v = (vx, vy, vz) at every point.
y
It is given by the relation:
v
dy v y
dx dy dz 
 
y(x)
dx vx
vx vy vz
x

Streamlines can be visualized by injecting tracer particles into the flow


field.
Eulerian vs. Lagrangian viewpoint
Definition :
d
Substantial time derivative is the rate of change for a
dt 
moving fluid particle. Local time derivative is the rate of
t
change at a fixed point.
Let u = u(x, t), where x = x(x0, t). The chain rule yields

du u u dx u dy u dz u
      v.u
dt t x dt y dt z dt t

substantial derivative = local derivative + convective derivative


Reynolds transport theorem

d u ( x, t )

dt Vt
u ( x, t ) dV  
V Vt t
dV   u ( x, t )v. n dS
S  St

rate of change in rate of change in convective transfer


= +
a fixed volume a moving volume through the surface
Derivation of the governing equations
Modeling philosophy Generic conservation law

1. Choose a physical principle t V
u dV   f . n dS   q dV
S V

S n
• conservation of mass f  u  d u
• conservation of momentum
• conservation of energy v dS Flux Function
f
2. Apply it to a suitable flow model Divergence theorem yields
u
• Eulerian/Lagrangian approach
• for a finite/infinitesimal CV V t dV  V . f dV  V q dV
3. Extract integral relations or PDEs Partial differential equation
u
• which embody the physical  . f  q in V
principle t
Derivation of the continuity equation
Physical principle: conservation of mass

dm d 
dt

dt Vt
 dV  V V
t t
dV  
S  S t
 v.n dS  0

accumulation of mass inside CV = net influx through the surface


Divergence theorem yields Continuity equation
   
V 
 t
 .(  v ) 

dV  0
t
 .(  v )  0

Lagrangian representation
d
 .(  v)  v.   .v dt
 .v  0

Incompressible flows: d
 . v  0 (constant density)
dt
Conservation of momentum
Physical principle: f = ma (Newton’s second law)
dS Total force f   g dV  h dS where h   .n
dV n Body forces g gravitational, electromagnetic,. . .

h Surface forces h pressure + viscous stress

g Stress tensor    pI   momentum flux

For a newtonian fluid viscous stress is proportional to velocity gradients:

1 2
  (. v) I  2 D(v), where D (v)  (v  vT ),    
2 3
Conservation of momentum…………….
Normal stress: stretching

vx
 xx  . v  2  y
x
v y
 yy  . v  2   xx
y
vz
 zz  . v  2 
z
x
Shear stress: deformation
v y
vx  yx
 xy   yx   ( ) y
x y
v vz
 xz   zx  ( x  )
z x
v v y
 yz   zy  ( z  )
y z x
Derivation of the momentum equations
Newton’s law for a moving volume
d  (  v)
dt 
Vt
 v dV   V Vt t
dV   S  St
(  v  v ). n dS

 
V Vt
 g dV   S  S  . n dS
t

Transformation of surface integrals

  (  v) 
V  t  .(  v  v )  dV  V .   g  dV ,    pI  
 (  v)
Momentum equations  .(  v  v)  p  .   g
t

 (  v)  v     dv
 .(  v  v)     v. v   v   .(  v)   
t  t   t  dt
substantial derivative continuity equation
Conservation of energy
Physical principle: e  s  w (first law of thermodynamics)
dS
e accumulation of internal energy
dV n s heat transmitted to the fluid particle

w rate of work done by external forces


h

g Heating: s   qdV  f q dS (Fourier’s law of heat conduction)

q internal heat sources


f q   k T
fq diffusive heat transfer
the heat flux is proportional to
T absolute temperature the local temperature gradient

k thermal conductivity
Work done per unit time = total force × velocity

w  f . v   g . v dV  v .( . n) dS ,    pI  

Derivation of the energy equation


2
v
Total energy per unit mass: E  e
2

e specific internal energy due to random molecular motion

2
v
specific kinetic energy due to translational motion
2
Integral conservation law for a moving volume

d (  E )
dt 
Vt
 E dV  
V Vt t
dV  
S  S t
 Ev. n dS accumulation

  q dV   k T . n dS heating
V Vt S  St

  g. v dV   v .( . n) dS work done


V Vt S  St

Transformation of surface integrals

 (  E ) 
V  t  .(  Ev )  dV  V .(k T )   q  .( . v)   g. v  dV ,
where .( .v)  .( pv)  .( . v)  .( pv)  v.(. )  v : 
Different forms of the energy equation
Total energy equation

(  E )
 .(  Ev)  .(k T )   q  .( pv)  v.(. )  v :    g. v
t

(  E )  E     dE
 .(  Ev)     v. E   E   .(  v)   
t  t   t  dt
substantial derivative continuity equation
dv
Momentum equations   p  .   g (Lagrangian form)
dt

dE de dv (  e)
    v.    .(  ev)  v. p  .   g 
dt dt dt t
Internal energy equation

 (  e)
 .(  ev)  .(k T )   q  p. v  v : 
t
Dimensionless form of equations
Motivation: sometimes equations are normalized in order to

• facilitate the scale-up of obtained results to real flow conditions

• avoid round-off due to manipulations with large/small numbers

• assess the relative importance of terms in the model equations

Dimensionless variables and numbers

t X v p T  T0
t  ,
*
X  ,
*
v  ,
*
p 
*
, T 
*

t0 L0 v0  v0 2
T1  T0
Reynolds number  v0 L0 inertia
Re 
 vis cos ity
v inertia
Froude number Fr  0
L0 g gravity
v0 L0 convection
Peclet number Pe 
k diffusion
v
Mach number M
c

L0
Strouhal number St 
v0t0


Prandtl number Pr 
k
Model simplifications
Objective: derive analytical solutions / reduce computational cost
Compressible Navier-Stokes equations
 = const  0
Incompressible Navier-Stokes equations Compressible Euler equations

Derivation of a simplified model

1. determine the type of flow to be simulated


2. separate important and unimportant effects
3. leave irrelevant features out of consideration
4. omit redundant terms/equations from the model
5. prescribe suitable initial/boundary conditions
Discretization Methods

Required to convert the general transport


equation to set of algebraic equations

 Finite difference method

 Finite volume method

 Finite element method


Introduction to Finite Difference
Taylor series expansion

f  2 f (x) 2  n f (x) n
f ( x  x)  f ( x)  x  2  n 
x x 2 x n

gradient curvature
4
f ( x)

f  2 f (x) 2  n f (x) n 5
f ( x  x)  f ( x)  x   n  f ( x)
x x 2 2 x n 2

1 3

First guess Add to capture Add to account for


(Not very good) slope curvature

x x  x
Discretization
  2   x    3   x 
2 3
  
i 1, j  i , j    x   2   3  
 x i , j  x i , j 2  x i , j 6

x

i  1, j  1 i, j  1 i  1, j  1
y
P
i  1, j i, j i  1, j

i  1, j  1 i, j  1 i  1, j  1

You might also like