An Introduction To
Computational Fluid Dynamics (CFD)
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.
- 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
- Partial differential equations, integration
- Numerical Methods: finite volume method (FVM), finite element method (FEM), finite difference method (FDM)
2) Flow Physics:
- Fluid mechanics: Properties of fluid, Laminar, and Turbulent Flow
- Heat and mass transfer: Conduction, Convection, and radiation heat transfer
- Reaction in the flows: Passive flow in pipe or duct. reactive flow in the combustion
- Phases of material: One or more phases can interact each during flow
- single-phase: Example – air flow through pipe
- Multi-phase flow like boiling or condensation
- Other flow physics: Magnetic or electric field acting on the fluid
- Fixed or moving boundaries: Moving or stationary walls in turbo-machinery
- Multiscale and multi-domain: there can be multiple scales in the system like battery
3) Computer science:
Programming tools like C or C++ need to be learned 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. Most CFD solvers are developed in C or C++ which are easy to run multiple processors (HPC). Python or scripting languages are used to control the simulations on hardware.
- Hardware : Laptop, PC, HPC, Supercomputer
- Programming tools: C, C++, Python etc
- CFD software: ANSYS FLUENT, Open FOAM, 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 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
Advantage of CFD Analysis
- 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
- 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 the 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 following 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 the 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
The 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 a fan, pump, blower, etc.
- Natural (free) flow: the Flow is driven by the density difference between hot and cold fluids
Compressible Flow vs In-compressible Flow
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 (2) of a fixed wall boundary: for flow through a control valve , 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.
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.
- Multi-phase flow: more than two or more phases interact with 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
- 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
A caricature of physical transport phenomenon:
- Transport of water is used from source point to the location of fire extinguishing
• CFD users must know the governing equations and the physical meaning of various terms in equations.
1) Conduction (diffusion): need a medium for the transfer of mass, momentum, heat, and species at the molecular level.
2) Advection: need a medium for transfer of mass, momentum, heat, and species at the bulk level.
Convection = Advection + Diffusion
3) Radiation: no need for a medium for heat (Not applicable for mass, momentum, and species)
• In general, the conservation equation for any physical conserved variable is written as:
Unsteady term + Advection term = Diffusion term + Source /sink terms
Momentum and heat mechanism
General form of governing equation
The general form of governing equation (in compact form)
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
- Pre-processing comprises making geometry and meshing
- Solver selection of physical models, governing equations, solution procedures
- Post-processing of CFD results
- Steps for CFD modelings are given as below:
- Define the objectives of modeling
- Create the geometry or computational domain using the CAD tools like Space claim, solid works
- Create the meshing using the meshing software like ANSYS Meshing, Hyper mesh
- Set up the solver and physical models
- Compute and monitor the solution
- Examine and save the results in plots, contours, and flux reports
- Consider revisions to the numerical or physical model parameters, if necessary
- Most commonly used CFD software and tools for numerical simulations are shown below
Comprehensive CFD Software
- In the last four decades, CFD solvers have been developed for a wide variety 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, STAR CCM, and OpenFOAM
- Click here : ANSYS_FLUENT_THEORY_GUIDE
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, CONVERGE
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 identities.
- 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. Hence, CFD users has to define the fluid zone for the face
- For, the 3D domain, the face can be a boundary like an inlet, outlet or wall etc.
- All essential faces should be named in meshing before exporting to the CFD solver
- It is a grouping of nodes’ faces and cells
- For, 3D domain, the 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 the CFD domain, the next step is to divide the domain into a finite number of volumes or cells 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 be below 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
Meshing Thumb rules
- High-quality mesh and correct numerical schemes mean good convergence of residuals
- For ANSYS FLUENT: Orthogonal quality = 1 – cell skewness
- For complete Hexahedral elements, skewness is zero. It is a non-zero value for inclined faces
- Try to keep skewness below 0.98 so that the CFD simulation will not diverge due to unbounded solutions
- Mesh quality can be improved by converting the tetrahedral cells to polyhedral cells in CFD solvers (ANSYS FLUENT, Star CCM)
- For poor quality mesh, the solutions can be obtained by controlling the relaxation factor or selecting near-wall gradient schemes
- Try to keep at least three-element in narrow gaps which is a shadow or wake region.
- Add more elements (at least 10 cells) in high-velocity fluid zones to better numerical convergence
- Smoothness (change in size):
- Sudden jumping in the mesh should be avoided in the high gradient region (like inlet and near-wall)
- A growth factor of 1.2 is recommended between adjacent cells
- Smoothness in the mesh is very essential near wall boundaries.
- Aspect ratio:
- Select it as per the need for simulation
- In the direction of the high gradient region, the aspect ratio should be less ( < 20) for laminar and turbulent flow (RANS Modeling).
- A very low aspect ratio of 2-3 is needed for multiphase separated flows and large eddy simulations (LES)
- In the direction of no gradient region, a 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 discrediting with a numerical method, we can compute values based on initial and boundary conditions.
Discretization converts the transport equation (mass, momentum, and energy) in the partial differential form to a 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 coordinate 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’s 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 grids. 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 domain
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 discretization 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, Open FOAM)
Finite Element Methods (FEM)
- This numerical method 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 differences 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 research scholars 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
- The domain of interest is divided into finite number of cells or volumes
- Based on on the spatial information of nodal point, area faces and volume cells, governing equations (mass, momentum and energy) are dicretized for both space and time
- Different numerical techniques are used for each term in governing equations like unsteady term, convection term, diffusion, viscous and body forces
1) Upwind Differentiating Scheme (UDS)
- Flow direction-dependent Øe
- This approximation is of first-order (O(Δx))
- Numerically diffusive
Unsteady Term discretization
- Temporal derivatives can be integrated either by the explicit method or implicit method
- Explipit Method: Euler, Runge-Kutta
- Implicit method : Beam-Warming method
2) Implicit or backward Euler method:: accuracy in order O(Δt)
Solution of Linear Equations Systems
•the index l runs over the neighbor nodes involved, and the system of equations for the whole domain has the matrix form
Two types of methods for solving the system of linear algebraic equations
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)
- Conjugate gradient method (CG)
- Multi-grid methods
Grid based Coupling of Pressure and Velocity
- Node for pressure and velocity components at the control volume (CV) center.
- Same CV for all variables.
- Possible oscillations of pressure
- 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.
- Semi-implicit method for Pressure-linked Equations
- 1.Advance to the next iteration t(n)=t(n+1)
- Initialize u(n+1) and p(n+1) using latest available values of u and p
- Construct the momentum equations
- Under-relax the momentum matrix
- Solve the momentum equations to obtain a prediction for u (n+1)
- Construct the Pressure equation
- Solve the pressure equation for p(n+1)
- Under-relax p(n+1)
- Correct the velocity for u(n+1)
- If not converged, go back to step 2
- 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: Pressure–Implicit with Splitting of Operators (PISO)
- PISO consist of one predictor step and two corrector steps
- This method 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
- pimpleFoam: a combination of SIMPLE and PISO
Flow solvers available in ANSYS FLUENT
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
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.
- No fluid penetrates the boundary, i.e. convective flux is zero.
- Two types of wall conditions: no-slip (fluid is at rest at the wall) or free-slip (no frictional losses 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
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
- 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
For CFD Beginners:
- Jiyuan Tu Guan Heng Yeoh Chaoqun Liu, Computational Fluid Dynamics: A Practical Approach,Butterworth-Heinemann, Elsevier Publication,. 2018
For Intermediate CFD users:
- Henk Kaarle Versteeg, WeeratungeMalalasekera, An Introduction to Computational Fluid Dynamics: The Finite Volume Method,Pearson Education Limited, 2007
- Petrila, Titus, Trif, Damian, Basics of Fluid Mechanics and Introduction to Computational Fluid Dynamics, Springer Publication, 2012