Introduction to Computational Fluid Dynamics Adapted from notes by: Tao Xing and Fred Stern The University of Iowa Outline What is CFD? Why use CFD? Where is CFD used? Physics Modeling Numerics CFD process Resources 2 What is CFD? What is CFD and its objective? – – – – Computational Fluid Dynamics Historically Analytical Fluid Dynamics (AFD) and EFD (Experimental Fluid Dynamics) was used. CFD has become feasible due to the advent of high speed digital computers. Computer simulation for prediction of fluid-flow phenomena. The objective of CFD is to model the continuous fluids with Partial Differential Equations (PDEs) and discretize PDEs into an algebra problem (Taylor series), solve it, validate it and achieve simulation based design. 3 Why use CFD? Why use CFD? – Analysis and Design Simulation-based design instead of “build & test” – More cost effectively and more rapidly than with experiments – CFD solution provides high-fidelity database for interrogation of flow field Simulation of physical fluid phenomena that are difficult to be measured by experiments – Scale simulations (e.g., full-scale ships, airplanes) – Hazards (e.g., explosions, radiation, pollution) – Physics (e.g., weather prediction, planetary boundary layer, stellar evolution) – Knowledge and exploration of flow physics 4 Where is CFD used? (Aerospace) • Where is CFD used? – Aerospace – – – – – – – – – – Appliances Automotive Biomedical Chemical Processing HVAC&R Hydraulics Marine Oil & Gas Power Generation Sports F18 Store Separation Wing-Body Interaction Hypersonic Launch Vehicle 5 Where is CFD used? (Appliances) • Where is CFD used? – Aerospace – Appliances – – – – – – – – – Automotive Biomedical Chemical Processing HVAC&R Hydraulics Marine Oil & Gas Power Generation Sports Surface-heat-flux plots of the No-Frost refrigerator and freezer compartments helped BOSCH-SIEMENS engineers to optimize the location of air inlets. 6 Where is CFD used? (Automotive) • Where is CFD used? – Aerospace – Appliances – Automotive – – – – – – – – Biomedical Chemical Processing HVAC&R Hydraulics Marine Oil & Gas Power Generation Sports External Aerodynamics Interior Ventilation Undercarriage Aerodynamics Engine Cooling 7 Where is CFD used? (Biomedical) • Where is CFD used? – Aerospace – Appliances – Automotive – Biomedical – – – – – – – Chemical Processing HVAC&R Hydraulics Marine Oil & Gas Power Generation Sports Medtronic Blood Pump Temperature and natural convection currents in the eye following laser heating. Spinal Catheter 8 Where is CFD used? (Chemical Processing) • Where is CFD used? – – – – Aerospace Appliances Automotive Biomedical – Chemical Processing – – – – – – HVAC&R Hydraulics Marine Oil & Gas Power Generation Sports Polymerization reactor vessel - prediction of flow separation and residence time effects. Twin-screw extruder modeling Shear rate distribution in twinscrew extruder simulation 9 Where is CFD used? (HVAC&R) • Where is CFD used? – – – – – Aerospace Appliances Automotive Biomedical Chemical Processing Streamlines for workstation ventilation – HVAC&R – – – – – Hydraulics Marine Oil & Gas Power Generation Sports Mean age of air contours indicate location of fresh supply air Particle traces of copier VOC emissions colored by concentration level fall behind the copier and then circulate through the room before exiting the exhaust. Flow pathlines colored by pressure quantify head loss in ductwork 10 Where is CFD used? (Hydraulics) • Where is CFD used? – – – – – – Aerospace Appliances Automotive Biomedical Chemical Processing HVAC&R – Hydraulics – – – – Marine Oil & Gas Power Generation Sports 11 Where is CFD used? (Marine) • Where is CFD used? – – – – – – – Aerospace Appliances Automotive Biomedical Chemical Processing HVAC&R Hydraulics – Marine – Oil & Gas – Power Generation – Sports 12 Where is CFD used? (Oil & Gas) • Where is CFD used? – – – – – – – – Aerospace Appliances Automotive Biomedical Chemical Processing HVAC&R Hydraulics Marine Volume fraction of gas Flow vectors and pressure distribution on an offshore oil rig Volume fraction of oil Volume fraction of water – Oil & Gas Analysis of multiphase separator – Power Generation – Sports Flow of lubricating mud over drill bit 13 Where is CFD used? (Power Generation) • Where is CFD used? – – – – – – – – – Aerospace Appliances Automotive Biomedical Chemical Processing HVAC&R Hydraulics Marine Oil & Gas Flow around cooling towers Flow in a burner – Power Generation – Sports Flow pattern through a water turbine. Pathlines from the inlet colored by temperature during standard 14 operating conditions Where is CFD used? (Sports) • Where is CFD used? – Aerospace – – – – – – – – – Appliances Automotive Biomedical Chemical Processing HVAC&R Hydraulics Marine Oil & Gas Power Generation – Sports 15 Physics CFD codes typically designed for representation of specific flow phenomenon – – – – – Viscous vs. inviscid (no viscous forces) (Re) Turbulent vs. laminar (Re) Incompressible vs. compressible (Ma) Single- vs. multi-phase (Ca) Thermal/density effects and energy equation (Pr, g, Gr, Ec) – Free-surface flow and surface tension (Fr, We) – Chemical reactions, mass transfer – etc… 16 Physics Fluid Mechanics Inviscid Viscous Laminar Compressible (air, acoustic) Incompressible (water) Turbulence Internal External (pipe,valve) (airfoil, ship) Components of Fluid Mechanics 17 Governing Equations (Equations based on “average” velocity) ux u y uz 0 t x y z Continuity u u u u p x u x x u y x u z x xx yx zx g x x y z x x y z t Equation of motion 18 Navier-Stokes Equations Claude-Louis Navier George Gabriel Stokes C.L. M. H. Navier, Memoire sur les Lois du Mouvements des Fluides, Mem. de l’Acad. d. Sci.,6, 398 (1822) C.G. Stokes, On the Theories of the Internal Friction of Fluids in Motion, Trans. Cambridge Phys. Soc., 8, (1845) Navier-Stokes Equations (constant and m) 2 ux 2 ux 2 ux u x u x u x u x p m 2 2 2 g x u x uy uz x y z x y z t x 2 2 2 u u u u u u uy y p y y y y y m 2 2 2 g y u x uy uz x y z y y z x t u z u z u z u z p 2 u z 2 u z 2 u z m 2 2 2 g z u x uy uz x y z z y z t x D v p m 2v g Dt 20 Navier–Stokes Example u y u y u y p 2 u y 2 u y 2 u y u y u x uy u z m 2 2 2 g y x y z y y z x t d 2uy dp 0 m 2 g dy dx x dp g C1 dx m dy x2 d p Integrate u y g C1 x C2 2m dy Integrate duy B.C. u y 0 at x 0, u y 0 at x L C1 L dp g 2m dy Final Expression u y C2 0 1 dp 2 g ( Lx x ) 2m dy Fluid L y x Laminar Flow Static Parallel Plates 21 Modeling Mathematical representation of the physical problem – Some problems are exact (e.g., laminar pipe flow) – Exact solutions only exist for some simple cases. In these cases nonlinear terms can be dropped from the NS equations which allow analytical solution. – Most cases require models for flow behavior [e.g., K-e, K-w, Reynolds Averaged Navier Stokes equations (RANS) or Large Eddy Simulation (LES) for turbulent flow] Initial —Boundary Value Problem (IBVP), include: governing Partial Differential Equations (PDEs), Initial Conditions (ICs) and Boundary Conditions (BCs) 22 Turbulent Flow Representation (K-e as an example) u i u u' Where : u' deviating velocity, u constant net veloci ty in the direction of flow, and u i instantane ous velocity 23 Turbulent Boundary Layer y Bulk Stream x U0 Edge of boundary layer Outer layer d Fully turbulent layer Sublayer + buffer layer Wall 24 Wall Shear Stress d U dy y 0 w y y d u y Friction Velocity u w Viscous Length Scale d u y+ is similar to a local Reynolds number. Small y+ - Viscous effects dominate Large y+ - Turbulence dominates 25 y+ and Turbulence Models COMSOL has many turbulent models available Low-Re models require a y+ resolution of < 1 to guarantee accuracy Low-Re models are necessary to accurately estimate skin friction and flow separation High-Re models use wall functions to approximate averaged turbulent flow properties Less accurate, but more computationally efficient In COMSOL, a minimum y+ of 11.06 is enforced. To maintain accuracy, ensure cells meet this requirement 26 Numerics / Discretization Computational solution of the IBVP Method dependent upon the model equations and physics Several components to formulation – Discretization and linearization – Assembly of system of algebraic equations – Solve the system and get approximate solutions 27 Finite Differences u x i, j u i 1, j u i , j 2u 2 x x x 3u 3 i, j 2 x Finite difference representation x 2 i, j 6 Truncation error Methods of Solution Direct methods Cramer’s Rule, Gauss elimination LU decomposition Iterative methods Jacobi method, Gauss-Seidel Method, SOR method 28 Numeric Solution (Finite Differences) u i 1, j u i , j jmax j+1 j j-1 o 2u u x 2 x i, j x x 2 3 u 3 i, j 2 x x 3 i, j 6 x y i-1 i i+1 Taylor’s Series Expansion u i,j = velocity of fluid imax x Discrete Grid Points 29 Finite Difference Truncation Error f x x f ( x ) f x x 2 f 2 x x 2 n f n 2 i , j x x n i , j n ! f ( x) sin 2 x at : x 0.2 f ( x) 0.9511 f (0.22) ???? f x x f ( x ) x 0.02 f x x f (0.22) f (0.2) 2 cos[ 2 (0.2)](0.02) 0.9899 Exact solution for f (0.22) 0.9823 Error 0.775 percent 30 CFD process Geometry description Specification of flow conditions and properties Selection of models Specification of initial and boundary conditions Grid generation and transformation Specification of numerical parameters Flow solution Post processing: Analysis, and visualization Uncertainty assessment 31 Geometry description Typical approaches – Make assumptions and simplifications – CAD/CAE integration – Engineering drawings – Coordinates include Cartesian system (x,y,z), cylindrical system (r, θ, z), and spherical system(r, θ, Φ) 32 Flow conditions and properties Flow conditions and properties required are unique for each flow code and application – FlowLab requires all variables in dimensional form – Because of focused application, research codes often use non-dimensional variables. 33 Selection of models for flow field Direct Numerical Simulations (DNS) is to solve the N-S equations directly without any modeling. Grid must be fine enough to resolve all flow scales. Applied for laminar flow and rare be used in turbulent flow. Reynolds Averaged Navier-Stokes (NS) equations (RANS) is to perform averaging of NS equations and establishing turbulent models for the eddy viscosity. Too many averaging might damping vortical structures in turbulent flows Large Eddy Simulation (LES), Smagorinsky’ constant model and dynamic model. Provide more instantaneous information than RANS did. Instability in complex geometries Detached Eddy Simulation (DES) is to use one single formulation to combine the advantages of RANS and LES. 34 Initial and boundary conditions For steady/unsteady flow IC should not affect final solution, only convergence path, i.e. iteration numbers needed to get the converged solution. Robust codes should start most problems from very crude IC, . But more reasonable guess can speed up the convergence. Boundary conditions – No-slip or slip-free on the wall, periodic, inlet (velocity inlet, mass flow rate, constant pressure, etc.), outlet (constant pressure, velocity convective, buffer zone, zero-gradient), and non-reflecting (compressible flows, such as acoustics), etc. 35 Grid generation Grids can either be structured (hexahedral) or unstructured (tetrahedral). Depends upon type of discretization scheme and application – Scheme Finite differences: structured Finite volume or finite element: structured or unstructured – Application Thin boundary layers best resolved with highly-stretched structured grids Unstructured grids useful for complex geometries Unstructured grids permit automatic adaptive refinement based on the pressure gradient, or regions of interest (FLUENT) 36 Grid Resolution 37 Grid generation and transformation Grids designed to resolve important flow features which are dependent upon flow parameters (e.g., Re) Commercial codes such as Gridgen, Gambit For research code, grid generated by one of several methods (algebraic vs. PDE based, conformal mapping) For complex geometries, body-fitted coordinate system will have to be applied (next slide). Grid transformation from the physical domain to the computational domain will be necessary Sample grid established by Gambit of FLUENT 38 Grid transformation y o x Physical domain Transformation between physical (x,y,z) and computational (,,z) domains, important for body-fitted grids. The partial derivatives at these two domains have the relationship (2D as an example) o Computational domain f f f f f x x x x x f f f f f y y y y y 39 Numerical parameters & flow solution Numerical parameters are used to control flow solution. – Under relaxation factor, tridiagonal or pentadiagonal solvers – CFD Labs using FlowLab Monitor residuals (change of results between iterations) Number of iterations for steady flow or number of time steps for unsteady flow Flow solution – Solve the momentum, pressure Poisson equations and get flow field quantities, such as velocity, turbulence intensity, pressure and integral quantities (drag forces) 40 Numerical parameters & flow solution Typical time history of residuals The closer the flow field to the converged solution, the smaller the speed of the residuals decreasing. Solution converged, residuals do not change after more iterations 41 Post-processing Analysis, and visualization – Calculation of derived variables Vorticity Wall shear stress – Calculation of integral parameters: forces, moments – Visualization (usually with commercial software) Simple X-Y plots Simple 2D contours 3D contour carpet plots Vector plots and streamlines (streamlines are the lines whose tangent direction is the same as the velocity vectors) Animations (dozens of sample pictures in a series of time were shown continuously) 42 Post-processing (Parallel Plates) 43 Post-Processing (example) Pressure contour and velocity vectors . Note the locations of the highest and lowest pressure regions. 44 Uncertainty assessment Rigorous methodology for uncertainty assessment using statistical and engineering concepts – Verification: process for assessing simulation numerical uncertainty Iterative convergence: monitoring point & integral quantities should change within the convergence criterions Grid independent studies: 3-grids and Richardson Extrapolation – Validation: process for assessing simulation modeling uncertainty by using benchmark experimental data Certification: full Verification and Validation done for a certain range of geometries & parameters which are well known and then extrapolated, qualitatively as well as quantitative – Simulating flows for which experiments are difficult (e.g., full- scale Reynolds numbers, hypersonic flows, off-design conditions) – Objective: Simulation-based design 45 CFD Example Sulzer Chemtech 250 Y Plastic Structured Packing 46 Geometry • CT > STL > CFD • CT = 0.322 mm Min Resolution • Copy/Pasted 2x • Surface Wrapping • Adaptive Meshing • Tetrahedral Mesh • Polyhedral Mesh 47 Mess Dimensions 48 Experiment vs. Simulation 160 Simulation N2 - July 27 N2 - July 28 150 140 130 Pressure Loss (Pa) 120 110 100 y = 23.462x1.8022 R² = 0.9998 90 80 y = 21.97910x1.76234 R² = 0.99996 70 60 50 40 30 20 10 0 0.25 0.5 0.75 1 1.25 1.5 1.75 2 F-factor (ft/s*[lb/ft3]1/2) 2.25 2.5 2.75 49 3 Velocity Map 50 Software and resources CFD software was built upon physics, modeling, numerics. Two types of available software – Commercial (e.g., FLUENT, CFX, Star-CCM, COMSOL) – Research (e.g., CFDSHIP-IOWA, U2RANS) More information on CFD can be got on the following website: – CFD Online: http://www.cfd-online.com/ – CFD software FLUENT: http://www.fluent.com/ COMSOL http://www.comsol.com/ CD-adapco: http://www.cd-adapco.com/ – Grid generation software Gridgen: http://www.pointwise.com GridPro: http://www.gridpro.com/ – Visualization software Tecplot: http://www.amtec.com/ Fieldview: http://www.ilight.com/ 51