# ComputationalFluidDynamics (CFD)

by

Dr. Sharad N. Pachpute (PhD, IIT Delhi)

## Introduction to Flow Analysis Techniques

In general, science and engineering have been traditionally divided into two parts; experimental and theoretical disciplines.

### Theoretical or analytical Analysis

• Theory is based  on assumptions, postulations and laws of actions
• In physics, chemistry and other science subjects, many theorems are studied  and mathematics helps in quantification and understanding
• These theorems are presented  in terms of independent and dependent parameters
• Analytical analysis helps to provide physical dependency of parameters but it difficult to solve complex real world problem  example: weather prediction, flows of rives, testing of large airships etc.  ### Experimental Analysis

• Using theory and mathematical formulation we can solve simple problems in our real life and nature
• Experiment is conducted for simple cases to understand the details of objectives
• Carrying out experiments is expensive, risky and time consuming
•  There are many limitations  to get solutions for complex problems either by theory and experiments

### Modeling and Simulation

• Modeling and simulation has emerged as a third pillar in many fields like engineering, molecular dynamics and astronomy
• Modeling and simulation is a technique to prediction the science and explore new knowledge
• It is useful  to  solve real world problems which can not be solved by theory and may be expensive by experimental analysis
• Computational fluid dynamics (CFD) is  a technique of modeling and simulation based on numerical modeling for fluid flow
• Using the CFD technique, heat and mass transfer, reactive flow, multi-phase flow and combustion can be analyzed using various numerical models
•  Modelings and Simulation is called as a third pillar of science and technology in the 21st century.

## What is Computational Fluid Dynamics (CFD)

### Definition of CFD

• Computational fluid dynamics (CFD) is  a technique of flow predictions by  numerical solving governing equations of fluid flows. Governing equations are conservation of mass, momentum, heat and mass transfer. Numerical methods are used to convert partial differential equations in to algebraic set of equations. After solving iteratively using computer programs, engineers visualize predicted velocity, pressure and temperature.
• Computational fluid dynamics (CFD) comprises majorly three  steps:
• Pre-processing: Creation of geometry and meshing
• Simulation: Solving governing equations over a meshed model
• Post-processing and results analysis: Predicted physical quantities need to be analyzed qualitatively and quantitatively
• Computational fluid dynamics (CFD) is an interdisciplinary subject. Hence, CFD users have to be familiar with the following subjects as per their specific requirement.

### Essential Subjects for CFD Modeling

1) Mathematics:

• Partial differential equations, integration
• Numerical Methods:  finite volume method (FVM), finite element method (FEM), finite difference method (FDM)

2) Flow Physics:

3) Computer science:

Programming tools like C or C++ need to be learnt by CFD users initially. Familiarity with CFD software is essential for geometry, meshing,  simulation and post-processing. Parallel computing may need for complex industrial problems,  large eddy simulations (LES ) and DNS.

• Hardware : Laptop, PC, HPC, Supercomputer
• Programming tools: C, C++, Python etc
• CFD software: ANSYS FLUENT, OpenFOAM, Star CCM, COMSOL

4) Experimental data for validation:

• Validation of CFD results is essential for credibility of numerical models
•  Results of CFD simulations need to be reliable and consistent with experimental results

## Scope of CFD Modeling

### Comparison of Simulation (CFD) and Experimental Analysis

• As discussed above, simulation and experiment are two commonly used methods for design and analysis
• Simulations provide a thorough analysis at a lower cost compared to experimental analysis
• Hence CFD is used in a wide range of industrial applications where fluid flow is involved like automotive, aerospace, power generation, etc
• CFD is used for design and optimization of industrial problems

• CFD has a large potential to solve industrial problems at bigger scale due to continuous improvement in computational power  and numerical models

• The cost of analysis is low compared to experiments
• Provide detailed information
• It can applied to a variety of problems
• CFD analysis requires less time to get results compared to experimental for most of complex cases. Hence, wind tunnels are replaced with CFD simulations in many universities and industries as shown below
• CFD analysis is an effective method for design optimization in many automobile, aerospace and chemical industries
• To carry out a wind tunnel test is expensive and it requires a lot time for experimental set up
• For measurement in experiments, we can not fix the probes or sensors to measure velocity and pressure at all locations.

## Applications of CFD Modeling

• Simulations provide insight into physical parameters (e.g. velocity, temperature, pressure, pollution level,.etc.) that are difficult to study using traditional (experimental) techniques.

i) To find the impact of Smoke and pollution level:  Flow pattern for an oil fire

ii) Turbo machinery Analysis
• Flow pattern for Turbo-machinery is shown below
• First step of CFD is to Identify the flow physics involved in pump:turbo-machinery, turbulent flow, multi-phase flow  (water and air)

iii) To predict the temperature distribution in boiler

• CFD analysis of boiler is shown below:Temperature  for Turbulent Combustion of a coal fired boiler
• First step of CFD is to Identify the flow physics involved in boiler: turbulent flow, heat transfer (conduction, convection and radiation), multi-phase flow (particle and flue gas), reactive flow (combustion)

.

## Classification of Fluid Flow

•  Fluid flow is classified based on type of physics involved in a particular flow. CFD user has to select correct CFD Models as per flow physics
• For each flow physics, different numerical models have been developed based on assumptions and mathematics. All models are to be consistent with experiments
• A variety of numerical models are available in most of commercial CFD solvers. Read the follwoing articles for complex flow modeling.

• Re < Recr:  Laminar flow
• Re > Recr : Turbulent Flow flow
• The transition from laminar to turbulent flow depends on the surface geometry, surface roughness, free-stream velocity, surface temperature, and type of fluid, among other things.
•  If flow becomes turbulent for the small sectional area, then CFD user has to select an appropriate turbulence model  while modeling the flows
• To simulate complex turbulent flow, turbulence models are used for numerical simulation

### Regime for Laminar and turbulent Internal Flow

• Example 1: Buoyant flow from a cigarette  shows that laminar and turbulent regions are formed in fluid flow
• Example 2:  Water falling from a tap  Water falling from a tap
• Example 3:  Water channel flows show that laminar flows in the channel and turbulent around the gate due to increase in velocity

### Forced Flow vs Natural (free) Flow

• Forced flow: the flow is driven by external means like fan, pump and blower etc.
• Natural (free) flow: the Flow is driven by the density difference between hot and cold fluids ### Fluid Flow with  Fixed vs Moving Boundary

• Fixed/stationary boundary :boundaries/ walls are fixed
• Example (1) of a fixed wall boundary: for flow through a circular pipe , the pipe wall is fixed and stationary (no-slip)
• Example of a moving wall boundary: Moving/dynamic boundary : the boundaries/ wall move relative to the fluid: (a) Air flow over a moving car, (b) Air flow over a wind mill
• In flow over a windmill, air flows over blades  which  rotate about its axis. The lift force created due to pressure difference causes torque for rotation of blades.
•  For flow through the pump, impeller rotates and push the fluid through outlet pipe. Due to a change in boundaries, the flow physics and CFD models are also changed compared to a simple pipe flow problems

### Single vs Multi-phase flow

• Single Phase flow : only one phase exits in the fluid system Examples: water through a pipe, air flow over a surface etc.
Fig.11 Examples of a single phase flow
• Multi-phase flow : more than two or more phases interact each other.
• Examples of multi-phase flows: Boiling flow, condensation, bubble column etc..
• Water evaporation and boiling consists of two phases water and steam
• Condensation consists of two phases water and steam
• To model the flow when two  (inter penetrating or separated)phases, multiphase models are used based on approximation and cost of simulations

### Passive Flow vs Reactive Flow

• Non-reactive flows: no chemical reaction takes place between the species
• Reactive flows : chemical reaction takes place between the species
(a) Liquid combustion
(b) Flame from a match stick
• For details of reactive flow modeling, read basics of combustion in this website. Majority of flow in combustion is turbulent for good mixing of fuel and air. It can lead to stable flames. Turbulent combustion modeling need to be studied in details before CFD modeling.

## Transport Equation for CFD Modeling

### Physical transport phenomenon

• In fluid flow, transport of various physical quantities such as mass, momentum, energy and species is involved.
• CFD user must know the governing equations and the physical meaning of various terms in equations.

### A caricature of physical transport phenomenon:

• Transport of water is used  from source point to  the location of fire extinguishing

• CFD user must know the governing equations and the physical meaning of various terms in equations.

1) Conduction (diffusion): need a medium for transfer of mass, momentum, heat and species at molecular level.

2) Advection: need a medium for transfer of mass, momentum, heat and specie at bulk level.

3) Radiation: no need a medium for heat (Not applicable for mass, momentum and species)

## Numerical Solution Procedure

### Overview of CFD or Numerical Modeling

•  Computational fluid dynamics (CFD) is the science of predicting fluid flow, heat and mass transfer, chemical reactions, and related phenomena by solving numerically the set of governing mathematical equations• Governing (PDE) equations are Conservation of fluid flow, heat and mass transfer and species, etc.
• Generally, CFD works based on the Finite volume methods (Conservative Method).

• Fluid region of pipe flow is discretized into a finite set of control volumes (mesh/cells).
• Partial differential equations (PDEs) are discretized into a system of algebraic equations using finite volume method or finite element method
Fig.13 Computational domain defined for a circular pipe

### Steps for CFD Modelling

• Pre-processing comprises making geometry and meshing
• Solver: selection of physical models,  governing equations, solution procedures

## CFD Software

• Most commonly used CFD software and tools for numerical simulations  are shown below

### Comprehensive CFD Software

• These CFD solvers have been developed a wide varieties of complex flows like turbulent , multiphase and combustion etc.
• These solvers have been used in many industries and  well practiced numerical models are available there
• Many industries have compared their plant (practical) data with CFD results
• Example: ANSYS FLUENT and STAR CCM

### Semi-Comprehensive CFD Soft wares

• Some CFD solvers are developed for certain applications but not  practiced on large scales of industrial problems
• These solvers need to expand their scope of applications for large scale industries
• Example: COMSOL Multiphysics, CONVEREG

## Discretization of Computational Domain (Meshing)

### Elements of Meshing

Computational is divided into to finite number of volumes or elements in meshing. Meshing consists of  following important identitites.

• Cell : control volume into which domain is broken up
• Node : grid point
• Cell center :  center of a cell
• Edge: boundary of a face
• Face : boundary of a cell
• Face defines the cell zones (solid or fluid region) for two dimensional (2D) computational domain. Hecne, CFD users has to define fluid zone for face
• For, 3D domain, face can as boundary like inlet, outlet or wall etc.
• All essential faces should be named in meshing before exporting to CFD solver
• Zone:
• It is grouping of nodes faces, and cells
• For, 3D domain, volume region defines fluid or solid regions
• All essential cell zones should be named  either solid or fluid in meshing before exporting to CFD solver
• Domain : It is a group of node, face and cell zones

### Structured vs non-structured meshing

• The process of mesh generation is generally classified into two categories based on the topology of the elements that fill the domain
•  After the selection of CFD domain, next step is to divide the domain into finite number of volumes or cell based on the physics to be resolved.
• Types of Meshes for Computational domain.

### Assessment of Mesh Quality in CFD

• Mesh quality is essential for correct CFD simulations. Three ways are to  measure of the quality of mesh
• Skewness /Orthogonal quality:
• The skewness of mesh should low as much as possible
• Higher skewness can slow down the convergence of simulation and incorrect computations fluxes near walls.
• Skewness and orthogonal both are opposite each other. Higher orthogonal quality means lower the skewness of mesh
• For complete Hexahedral elements, skewness is zero. It is non-zero value for inclined faces.
• Smoothness (change in size):
• Sudden jumping in mesh should be avoided in high gradient region
• The growth factor of  1.2 is recommended
• Smoothness in mesh is very essential near wall boundaries.
• Aspect ratio:
• Select it as per need of simulation
• In the direction of high gradient region, aspect ratio should be less ( < 20)
• In the direction of no gradient region,higher aspect ratio (  ~ 250)  is enough to reduce the mesh size. ## Discretization Methods for CFD

The governing equation like mass, momentum and energy are expressed in terms of partial differential equations (PDEs). These equations are space and time-dependent. We can not solve PDEs like ordinary differential equations. However, partial differential equations are boundary value problems.  After discrertizing with a numerical method, we can compute values based on initial and boundary conditions.

Discretization  convert the transport equation (mass, momentum and energy) in partial differential form to set of algebraic equations. Three numerical methods are widely used to discretize the partial differential equations namely:

• Finite Difference Method (FDM)
• Finite Element Method (FEM)
• Finite Volume Method (FVM)

The discretization methods approximate the PDEs  of fluid flows with numerical model equations, which are solved using different numerical methods.

### Finite difference method (FDM)

• The computational domain is usually divided into hexahedral  elements (grids) and the numerical solution is obtained at each node .
• The finite difference method (FDM) is simple to understand when the physical elements are defined in the Cartesian co-ordinate system, but  the use of curvilinear transforms the method can be extended to domains that can not be easily represented using  brick-shaped elements
• The discretization results in a system of equations of the variable for grid points, and once a solution is obtained  then a  discrete representation of the solution is obtained. • Note the following points for FDM:
• It is applicable only for regular grid (equal size of meshing).
• This method is based on Taylor series of differentiation. Finite difference methods for spatial derivatives with different order of accuracies is obtained using Taylor expansions like first or second order upwind difference scheme (UDS), central differences schemes (CDS), etc.
• The FDM  is difficult to use for non-uniform grid. Hence it is rarely used for CFD solvers
• This method is not easy to implement conservation of mass, momentum and energy
• Taylor series of expansion dicretizes diferential terms in partial differential equations • Forward, backward and central schemes are commonly used finite difference schemes to discretize partial differential equations

###   • Discretization is carried out over all the nodes of computational doain

### Finite Volume  Methods (FVM)

• This approach is suitable for both irregular or irregular meshes. is based upon an integral form of the PDE to be solved (e.g. conservation of mass, momentum, or energy).
•  The governing equations are solved for a given finite volume (or cell) using finite volume methods
• The computational domain is discretized into finite volumes and then for every volume the governing equations are solved.
• The final forms equations after discretiazion involves fluxes of the conserved variable (mass, momentum and energy), and thus the calculation of fluxes is essential in this method Note:The Finite volume method is conservative (for mass, momentum and energy etc). Hence, the FVM discretization is widely used for many CFD solvers (e.g. ANSYS FLUENT, OpenFOAM.

### Finite  Element Methods (FEM)

• The FDM is based upon a piece wise representation of the solution in terms of specified basis functions.
• The computational domain is divided up into smaller domains (finite elements) and the solution in each element is constructed from the basis functions.
•  This can be a double-edged situation, as the section of basis functions is essential and boundary conditions can be more difficult to formulate for complex geometries. A set of equations is obtained (for nodal values) are solved to get a solution.
• To get numerical solutions, a  set of  equations are obtained using the conservation equation: Field variables are written as the basis functions, the equation is multiplied with appropriate test functions, and then integrated over an element. Since the FEM solution is defined in terms of specific  functions, a significant solution is obtained by solving the equations algebraically.
• The finite element method (FEM) is used to compute such approximations.Take, for example, a function u that may be the dependent variable in a PDE (i.e., temperature, electric potential, pressure, etc.) The function u can be approximated by a function uh using linear combinations of basis functions according to the following expressions: • The FEM discretization is  used by some CFD solvers (e.g. COMSOL). For COMSOL CFD solver, click here: COMSOL_NUMERICAL_METHOD

### Which method (FDM/FEM/FVM) is the best suited for CFD Modeling?

• The comparison of the three methods is not straightforward due to different in numerical procedures
• Finite volume method (FVM) and finite difference method (FDM) provide discrete solutions, but the finite element method (FEM) provides a continuous (up to a point) solution.
• FVM and FDM are generally considered to be easier for programming compared to FEM. This point may be vary user to user
• Most of research scholar adopt the FVM method for numerical modeling of fluid flows.
• The FVM  easily provide better conservation properties for mass, momentum and energy, If you are interested  to decide which method is more suitable, then go through the literatures on three methods

### Interpolation Scheme in CFD Solver

1) Upwind Differentiating Scheme (UDS)
• Flow direction dependent Øe
• This approximation is of first order (O(Δx))
•   Numerically diffusive
2) Central Difference Scheme (CDS):
Linear interpolation between the two nearest nodes
To construct a parabola for interpolation three points are necessary
This quadratic interpolation is of  third order, O(Δx3).

• Temporal derivatives can be integrated either by the explicit method  or implicit method
• Explipit Method: Euler, Runge-Kutta
• Implicit method : Beam-Warming method

Methods for time integration:
1) Explicit or forward Euler method: accuracy in order O(Δt),

2) Implicit or backward Euler method:: accuracy in order O(Δt)

3) Leapfrog method (midpoint rule): explicit method, accuracy in order O(¢t2)
4)Crank-Nicolson method (trapezoidal rule):
Summary of standard time stepping schemes are given below: #### Explicit Method

direct computation without solving a system of equations
easy to programme  and parallel computing
few number of operations per time step
Disadvantage: strong conditions on the time step for stability

#### Implicit Method

Advantage: much larger time steps possible, always stable
• every time step require the solution of a system of equations
• more number of operations
• difficult to programme  and parallel computing

### Solution of Linear Equations Systems

summing all the approximated integrals we produce an algebraic equation at each control volume
where the matrix A is always sparse.

### 1) Direct methods

• Gauss elimination
• LU decomposition
• Trid-iagonal matrix algorithm (TDMA)

### 2) Indirect or iterative methods:

• Jacobi method
• Gauss-Seidel method
• Successive over-relaxation (SOR)
• Multi-grid methods

## Grid based Coupling of Pressure and Velocity

### Colocated grid

• Node for pressure and velocity components at the control volume (CV) center.
• Same CV for all variables.
• Possible oscillations of pressure

### Staggered grid

• The different unknown variables are located at different grid nodes.
• Pressure located in the cell centers, velocities at cell faces.
• Strong coupling between the velocities and pressure helps to avoid  oscillations
• Other staggering method is the Arbitrary Lagrangian-Eulerian (ALE).

## Pressure Velocity Coupling – Algorithm

After the discretised form of the governing equation (Navier-Stokes system), we get a set of equations with  linear dependence of  pressure and velocity, or  vice-versa. This inter-equation coupling is called a pressure -velocity coupling. A special numerical treatment is necessary in order to the pressure-velocity  coupling. This is achieved by following algorithm such as SIMPLE, SIMPLEC, PISO, Coupled solver.

### SIMPLE Algorithm

• Semi-implicit method for Pressure-linked Equations
1. 1.Advance to the next iteration t(n)=t(n+1)
2. Initialize u(n+1) and p(n+1) using latest available values of u and p
3. Construct the momentum equations
4. Under-relax the momentum matrix
5. Solve the momentum equations to obtain a prediction for u (n+1)
6. Construct the Pressure equation
7. Solve the pressure equation for p(n+1)
8. Under-relax p(n+1)
9. Correct the velocity for u(n+1)
10. If not converged, go back to step 2
11. Correct the fluxes for ϕ(n+1) b) SIMPLEC:Semi-Implicit Method for Pressure Linked Equations-Consistent

• The pressure-correction under-relaxation factor is generally set to 1.0, which helps for faster  convergence
• This method is suitable for turbulent flow with pressure varying fields

C) PISO: PressureImplicit with Splitting of Operators (PISO)

• PISO  consist of one predictor step and two corrector steps
• This methods helps to check the  mass conservation in each iteration using predictor-corrector steps

d) Fractional step method

• This method solves  the incompressible Navier-Stokes equations with  primitive variables by  block LU decomposition.
• This method helps to solve issues of  boundary conditions for the intermediate flow variables and the pressure

### Pressure Velocity Coupling in OpenFOAM

For details of OpenFOAM schemes and algorithm refer the post.

• simpleFoam:  based on SIMPLE algorithm
• pisoFoam: based on PISO formulation
• combination of SIMPLE and PISO

## Properties of Fluid

• A  CFD user must be familiar with what fluid/solid properties are given to the CFD solver (e.g. FLUENT, OpenFOAM and COMSOL etc.) as input data and what properties will be calculated by the CFD solver

## Boundary Conditions

The following boundary conditions which are commonly used in a variety of  CFD domains:

#### 1) Inflow (inlet)condition:

• Convective flux is prescribed like velocity or mass flow rate inlet
• Input to be specified at he inlet: Momentum (velocity, mass flow rate, pressure, turbulent conditions), Thermal (temperature, emissivity and shell conduction), Species ( mole/mass fraction), Multi-phase (volume fraction of phase, particle size or distribution.

#### 2) Wall:

• No fluid penetrates the boundary, i.e. convective flux is zero.
• Two types of wall condition: no-slip (fluid is at rest at the wall) or free-slip (no frictional loses at the boundary).
• Wall can be slip or no-slip type
• Wall can be stationary or moving wall (like rotor for turbo-machinery)
• Input to be specified at the wall: Momentum (velocity, roughness), Thermal (temperature, convective HTC, emissivity and shell conduction), Species, Multi-phase

#### 3) Outflow (outlet) condition:

• Convective flux independent of the coordinate
• Normal to the boundary. zero gradient BC for all variables except pressure
• It is more suitable for a longer  pipe flow with a fully developed profiles of velocity or temperature
• It is also called zero-gradient BC  for (U,T,Y except P) in  OpenFOAM

#### 4) Symmetry condition:

• This boundary is used when flow does not cross the boundary
• Across the boundary all gradient are zero

#### 5) Periodic (cyclic) condition:

• Repetitive boundary conditions
• It can be transnational or angular
• Boundary conditions used for pipe flow or free stream flow over a circular cylinder
• Boundary conditions for flow through a pipe or duct is shown below. Inlet is specified with a fixed velocity
• Initial Boundary conditions for flow over a cylinder are defined as below
• Most of boundary conditions are defined based on fixed value and fixed gradients of velocity, pressure and temperature. That understanding will help decoding open FOAM CFD solver: Adiabatic wall ( dT/dx =0) and  Outlet (dT/dx=0)

## Example of CFD Modeling : Pipe Flow

### CFD Analysis of Laminar Flow Through the Circular Pipe

(a) Pipe flow for physical understanding
(b) CFD domain for pipe flow

### ANSYS FLUENT Set up

• Solver setting : Pressure based incompressible solver
• Physical Model: Viscous Laminar
• Boundary Conditions
• Inlet: fixed mass flow rate or velocity
• Outlet: outflow (zero gradient for velocity)
• Pressure Velocity Coupling: SIMPLE
• Numerical Discretization Schemes
• Pressure : Standard
• Momentum: QUICK
• Convergence criterion: 10^-06

### CFD Results and Analysis

Qualitative results: Contours and velocity vectors

### Validation of CFD Results

• Comparison of CFD results with theory/ experiment
• To get credibility of  CFD models, results obtained for numerical simulations need to be validated against theoretical or experimental data
•  In the follwing figure, the pressure drop and fully developed velocity profiles  are  same with that of CFD simulations and theoretical datafor lamiar flow through pipe

## Conclusion

• Computational fluid Dyanmic (CFD) is a flow prediction technqiues
• It is useful for design and optimization of problems in fluid mechanics, heat transfer, multiphase flows
• Due to low cost of flow analysis, CFD modeling is popular in many industries

## References

### 7 thoughts on “Basics of CFD Modeling for Beginners”

1. Excellent

2. 3. This is nice.please could i get resource materials for 3D meshes and solvers?

• Thank for your feedback, You can email to: info@cfdflowengineering.com to get learning materials

4. Very well written with nice figures for CFD beginners.

5. 6. 