<style> .reveal { font-size: 22px; } </style> ## CFD crash course ### Recognizing the bias in flow modeling <br/> ### --- Session i - Fundamentals of CFD --- --- ## The basic elements of a simulation <br/> Content - Domain: where is the game? - Physics: what are the governing equations? - Boundaries: How to combine the mathematics to phyiscs? - Numerics: How to keep the operation smooth? - Results: How to extract the information I want to see? --- #### --- The basic elements of a simulation: _Domain_ --- ### Define the playground: obtain everything where is fun! <br/> - Calculation Domain is a model of reality. - To determine the domain, you need to - understand the assignement - have a rough overview of relevant flow patterns - Identify the affected zone - everything which will impact the targeted phyiscal properties ---- #### --- The basic elements of a simulation: _Domain_ --- ### How to define the domain? <br/> - There is no doubt for internal flow, where the fixed boundaries are phyiscally defined. <img src="https://onlinelibrary.wiley.com/cms/asset/fe1a03a6-2e1c-480c-887e-3a899a619d86/eng212093-toc-0001-m.jpg?trick=1676615871010" width="40%"> <img src="https://www.learncax.com/images/blog/insights-on-cfd-for-combustion-in-ic-engines/InsightCombustion-01.png" width="53.0%"> - But it always requires a second thought when it comes to external flow. <img src="https://i.imgur.com/ekmXnhq.png" width="45%"> ---- #### --- The basic elements of a simulation: _Domain_ --- ### Where to set the limit? ||| | :----------: | :--------- | | <img src="https://www.mdpi.com/energies/energies-11-01485/article_deploy/html/images/energies-11-01485-g001-550.jpg" width="60%"> | Flow over complex terrain: where is the proper limit? | | <img src="https://blog.priceindustries.com/hubfs/OfficeVr01.jpg" width="60%"> | Indoor ventilation: can I take only one corner for simulation? | <div style="text-align: left "> - Where the boundary characteristics is certain! &rarr; __understanding of assignment__ and __preception of flow patterns in the target region__ necessary </div> --- #### --- The basic elements of a simulation: _Physics_ --- ### The governing equations General form of a transport equation (Eulerian observation method): $$ \begin{align} \iiint\frac{D}{Dt}\Phi\ dV &= \underbrace{\iiint \frac{\partial}{\partial t} \Phi \ dV}_{\text{time derivative}}+ \underbrace{\iiint \frac{\partial}{\partial x_j} u_j \Phi \ dV}_{\text{Convection}} \\ &=\underbrace{\iiint\mathit{P} \ dV}_{\text{Production}}+ \underbrace{\iiint \epsilon \ dV}_{\text{Dissipation}}+ \underbrace{\iiint\mathit{D}\ dV}_{\text{Diffusion}} + \underbrace{\iiint \mathit{s}\ dV}_{\text{Source}} \end{align} $$ <div style="text-align: left "> <br/> #### what is $dV$ in the equation? </div> ---- #### --- The basic elements of a simulation: _Physics_ --- ### Transport Properties -- $\Phi$ | Quantity | $\Phi$ | $\mathit{P}$ | $\epsilon$ | $\mathit{D}$ | $\mathit{s}$ | | --- | -------- | -------- | -------- | -------- | -------- | | Mass | $\rho$ | -- | -- | -- | -- | | Momentum | $\rho u_i$ | -- | -- | $-\frac{\partial P}{\partial x_i}+\frac{\partial}{\partial x_j}(\mu \frac{\partial u_i}{\partial x_j})$ | $\rho g_i$ | | Energy | $\rho(\frac{1}{2} u_i² + e)$ | -- | -- | $\frac{\partial}{\partial x_j }(\kappa\frac{\partial T}{\partial x_j}-Pu_i +u_i\frac{\partial}{\partial x_j}(\mu \frac{\partial u_i}{\partial x_j}))$ | $u_i\rho g_i$ | <br/> <div style="text-align: left "> - __*Convection*__ always combined with $u_j$, denoting the property is driven by the velocity of the medium. - __*Diffusion*__ always equipped with "$\frac{\partial}{\partial x_j}$", showing the diverging characteristics to all the directions - __*Conserved*__ properties have no __*Production*__ and __*Dissipation*__ </div> ---- #### --- The basic elements of a simulation: _Physics_ --- ### Gaussian integral theorem The volumetric integration of a divergent property = the flux of the property over its __*surface*__ ($\vec{n}d\vec{A}$) $$ \iiint \frac{\partial}{\partial x_j}F \ dV = \iint F n_i\ dA_i $$ <br/> | <img src='https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSzd7d104ROrgdhJRo66iC9x1oUeg4euV7veRKpEZ7_x9E5ESndOJB0g03DRIeOQeao9mc&usqp=CAU' width="100%"> | Convective term <br/> --> flux over control surface | | -------- | -------- | Transport equations with flux represented convetion term are the baseline principle of **Finite Volume Method (FVM)** ---- #### --- The basic elements of a simulation: _Physics_ --- ### What else can be transported? $\Large\frac{\partial \alpha}{\partial t} + \frac{\partial}{\partial x_j} u_j \alpha =\frac{\partial}{\partial x_j}(k\frac{\partial \alpha}{\partial x_j}) + s$ $\alpha$ can be: - Spcies in chemical reaction/combustion process - Concentration in mixing mechanism - ... <div style="text-align: left "> <br/> Every __material property__ can be transported --> Phyiscs of **Continuum Mechanics** </div> ---- #### --- The basic elements of a simulation: _Physics_ --- ### Select the Proper Equations for your task <br/> Thinking on: 1. Is it a flow type of - newtonian or non-newtonian fluid? - steady or unsteady state? - compressible or incompressible flow? 2. Is any of the terms (Convection, Diffusion, Source) negligible in this task? 3. Any simplification avialable? E.g. - Bousinesq approximation for density driven heat transfer - Shallow water assumption - Turbulence models for turbulent flows ---- #### --- The basic elements of a simulation: _Physics_ --- ### The Border of Material Transport --- where the continuum hits its limits--- <br/> _&rarr; additional modeling necessary_ | flow type| modeling strategy| motivation| | -------- | -------- | -----| | multiphase flows | volume of fluid (VoF) method | each phase is one continuum, capturing the transition | | solid boundary <br/> movement | fluid-structure interaction (FSI) | domain is changing, affecting to flow patterns| | turbulent flows | turbulence modeling(RANS, LES, etc.) | extremely high computational cost in resolving small eddies | ||| ---- #### --- The basic elements of a simulation: _Physics_ --- ### Special Features in OpenFOAM __*the governing equations doesn't have to be transport equations*__ | Solver type | Principle| Usage |Tutorial| | -------- | -------- | -------- | ----| | potential flow | solving Laplace euqation of Potential Theorem (Mass conservation) | create initial condition for high demanding convergence | [Potential flow](https://www.openfoam.com/documentation/tutorial-guide/2-incompressible-flow/2.2-flow-around-a-cylinder) | | adjoint optimization | eliminate the cost function with geometric optimization | shape optimization purposed |[shape optimization](https://www.xsim.info/articles/OpenFOAM/tutorials/images/adjointShapeOptimizationFoam-pitzDaily-alpha.png)<br/>[tutorial](https://www.openfoam.com/documentation/files/adjointOptimisationFoamManual.pdf)| |stress analysis| solve element displacement under stress condition| stress, d|[cantilever tutorial](https://www.youtube.com/watch?v=aw1GorWihu8)| |discrete method| solve particle movement for molecular dynamics| nano fluid flow pattern analysis|[nano nozzle](https://www.xsim.info/articles/OpenFOAM/en-US/tutorials/images/discreteMethods-molecularDynamics-mdFoam-nanoNozzle-moleculeCloud-1.png)| --- #### --- The basic elements of a simulation: _Boundaries_ --- ### Determining the Boundary Conditions <br/> __*where the domain boundary is set, where mathematical descriptions are required*__ <img src="https://www.cfdsupport.com/wp-content/uploads/2022/01/motorBike-bcgMesh.png" width=39%> <img src="https://www.cfdsupport.com/wp-content/uploads/2022/01/openfoam-tutorial-motor-bike-surface-model.png" width=35.2%> 100km/h driving speed, wheel rotates 670 rpm. &rarr; __*How to set the physical condition?*__ ---- #### --- The basic elements of a simulation: _Boundaries_ --- ### Type of boundaries: Dirichlet and Neumann <br/> | Dirichlet BC | |Neumann BC | | :-------: | :-----: |:--------: | | fixed value | |gradient <br/>of property | |$\psi(x) = \text{const}$||$\frac{\partial \psi}{\partial x_n} = \text{const}$| How about __*symmetry*__ and __*periodic*__? Which type of boundary conditions are they? <img src="https://i.imgur.com/1ASLAg1.png" width="50%"> ---- #### --- The basic elements of a simulation: _Boundaries_ --- ### Symmetry and Periodic boundary conditions <br/> How about __*symmetry*__ and __*periodic*__? Which type of boundary conditions are they? <img src="https://i.imgur.com/1ASLAg1.png" width="50%"> | Symmetry | |Periodic | | :-------: | :-----: |:--------: | | gradient <br/>of property = 0 | |fixed value, <br/>coupling of 2 patches | |$\frac{\partial \psi}{\partial x_n} _{\text{left}} = 0$||$\psi_{\text{left}}=\psi_{\text{right}}$| <br/> #### How about "__*WALL*__"? ---- #### --- The basic elements of a simulation: _Boundaries_ --- ### General features in CFD simulation *Every equation requires boundary condition on each boundary surface* e.g., Momentum equation of incompressible flows: ### $\frac{\partial u_i}{\partial t} + u_j \frac{\partial u_i}{\partial x_j} = -\frac{1}{\rho}\frac{\partial P}{\partial x_i} + \frac{\partial}{\partial x_j}\left( \nu^* \frac{\partial u_i}{\partial x_j} \right)$ - boundary condition required for $u_i$ and $P$ - *Wall*, *inlet* and *free stream*, what are the mathematical description for $u_i$ and $P$? <br/> ---- #### --- The basic elements of a simulation: _Boundaries_ --- ### Common setups in a CFD simulation <img src="https://i.imgur.com/nrrlWR6.jpg" width= "50%" style="float:left"> || Wall | Inlet | Outlet | | :--------: | :--------: | :--------: | :--------: | |$u_i$| $u_i = 0$ <br/>(**D**) | $u_n = \text{const}$ <br/>(**D**) | $\frac{\partial u_i}{\partial x_n} = 0$ <br/>(**N**) | |$P$| $\frac{\partial P}{\partial x_n} = 0$ <br/>(**N**) | $\frac{\partial P}{\partial x_n} = 0$ <br/> (**N**) | $P = \text{const}$ <br/>(**D**) | <br/> A mind game: - Why is velocity Dirichlet and pressure Neumann for wall? - How comes the velocity and pressure used to be the **D**-**N** combination - if both are Neumann, or both are Dirichlet, what is the flow type these conditions describe? - Does pressure value play any role? - if yes, why we see the $P = 0$ set in the literature? - if no, why it is not necessary? --- #### ---The basic elements of a simulation: _Numerics_ / _Mesh_ --- ### Mesh and the Calculation Quality <br/> why do we need mesh for simulation? <img src="https://www.simscale.com/wp-content/uploads/2018/03/mesh-of-a-Formula-1-car-1.jpg" width="80%"> ---- #### --- ---The basic elements of a simulation: _Numerics_ / _Mesh_ --- ### Why do we need mesh for simulation? <br/> - Equation with non-linear terms ($\frac{\partial}{\partial x_j} \Phi u_j$, $\frac{\partial² \Phi}{\partial x²_j}$) not solvable - approaching the solution (numerical method) <br/> instead of solving equation - discretize the terms in the 4-D manner to linearize the term, e.g. $\Large \frac{\partial \Phi_i}{\partial t} = \frac{\Phi_i(t+1)-\Phi_i(t)}{\Delta t}$ $\quad \Delta t \to 0$ (Euler method) $\Large \frac{\partial \Phi_i}{\partial x} = \frac{\Phi_i(x+1)-\Phi_i(x-1)}{2\Delta x}$ $\quad \Delta x \to 0$ (Central Differencing Scheme) <br/> - Linearized equation in the shape of a huge matrix system - _**size of matrix = number of cell in simulation domain**_ - solving the matrix system using linear algebra method ---- #### --- ---The basic elements of a simulation: _Numerics_ / _Mesh_ --- ### Another fine mesh _a grid convergent solution shows no change in refining the mesh resolution_ <br/> Grid Convergence index &rarr; refine the mesh to evaluate the changes in the targeted phyiscal properties <img src="https://external-preview.redd.it/f2lbf5ZtxZac8bTY0lZmGfACTfLAZBxDVTIK5Q00Z_s.jpg?auto=webp&s=52fddb5573bdf5c856cea7f2d8d46faef4fc4324" width="45.%"> <img src="https://www.researchgate.net/publication/334446983/figure/fig1/AS:780248102748161@1563037052380/Mesh-independence-test-results.ppm" width="38.0%"> GCI is not an objective assessment, since the refinement itself is subjective. ---- #### --- ---The basic elements of a simulation: _Numerics_ / _Mesh_ --- ### Basic rules generating a mesh _There is no perfect mesh. There are only better or worse meshes._ <br/> |||| | :--------: | :--------: | :--------: | |1. where it supposed to happen a lot, where requires fine mesh. e.g., boundary layer region || <img src="https://cdn.comsol.com/wordpress/2018/06/splitting-boundary-layer-mesh.png" width="70%"> | |2. gradient-wise cell size increment/reduction instead of abrupt patching ||<img src="https://www.researchgate.net/publication/223517704/figure/fig2/AS:304715519807489@1449661249203/Axisymmetric-schematic-of-the-cell-size-gradient.png" width="70%">| |3. flux generally better calculated using hexahedron cell. If possible, avoid usinf tetrahedron mesh. || <img src="https://images.ansys.com/is/image/ansys/2020-11-mosaic-wing-mesh?wid=1200" width="70%"> ---- #### --- ---The basic elements of a simulation: _Numerics_ / _Mesh_ --- ### Basic rules generating a mesh _There is no perfect mesh. There are only better or worse meshes._ <br/> |||| | :--------: | :--------: | :--------: | |4. mind the skewness of your cells. High sknewss cells are not preferred. || <img src="https://www.cadsys25.com/wp-content/uploads/2020/05/Annotation-2020-05-18-194925.png" width="60%"> | | 5. negative volume is no go! Check your mesh before press the START ||<img src="https://i.imgur.com/W05PbR5.png" width="60%">| | ---- #### --- The basic elements of a simulation: _Numerics_ / _Scheme_ --- ### __*Differencing scheme -- key to high resolution*__ <br/> Convective term $\frac{\partial}{\partial x_j}(u_j\Phi)$ dominants in the transport equation. High order scheme leads to fine resolution, but pays back in the convergence. <img src="https://i.ytimg.com/vi/zFwtF-WkBoU/maxresdefault.jpg" width="70%"> ---- #### --- The basic elements of a simulation: _Numerics_ / _Scheme_ --- ### Handling of Convective Terms <img src="https://i.imgur.com/0Uhqv1T.png" width="50%"> <br/> $\phi_f$ : persued value Evaluation all based on mass flow ($\dot{m}$) direction. (See where the flow comes from first!!) $$ \begin{align} \phi_f &= \phi_U\quad\quad\quad &&\text{1st order UDS} \\ \phi_f &= \lambda\phi_U + (1-\lambda)\phi_D\quad && \text{2nd order CDS} \end{align} $$ - Level of order: the number of involved cells - U: upwind cell, D: downwind cell - e.g. *linear upwind*: involving U and UU for evaluation - The more D involved, the sharper will be the numerical solution, accompanying with low numerical stability. - Higher order and non-linear combination also available e.g., QUICK, depend on the software preference and implementation. ---- #### --- The basic elements of a simulation: _Numerics_ / _Scheme_ --- ### Time step and Coirant number $\LARGE\text{CFL} = \frac{U \ \Delta t}{\Delta x}$ <br/> Courant (CFL) number quantifies the cell size ($\Delta x$) time step ($\Delta t$) behavior for the unsteady simulation. <img src="https://www.idealsimulations.com/wp-content/uploads/2020/08/resource_cfl_title.jpg"> &emsp;&emsp;&rarr; Keep the max. CFL number < 0.8 for correct data capturing ---- #### --- The basic elements of a simulation: _Numerics_ / _Converging_ --- ### Converging process *non-converged calculation results are not representative as CFD solution* <br/> General key parameters for smooth convergence: - *Correct boundary conditions*: understand your physics - *Decent mesh*: mind of your flow - *Initial condition*: provide an easy start - *Numerical handling*: preserve the running system - scheme, <br/> On the other hand, we are the ones who decide the convergence criterium. ---- #### --- The basic elements of a simulation: _Numerics_ / _Converging_ --- ### *Numerical Handling* in steady state simulations <br/> __*Relaxation factor*__ define the portion of updates after one iteration - the smaller the value, the update is smaller. - calculation is more stable but calculation lasts longer. - applicable for every to solved phyiscal property. - generally not feasible for transient simulation - except the multiple iterations implemented within one time step. ---- #### --- The basic elements of a simulation: _Numerics_ / _Converging_ --- ### *Monitoring* in steady state simulations -- Steady state residual control -- <img src="https://i.ibb.co/mGNwQmv/test1res.png" width="60%"> *Resuduals* are the unbalanced part in the equation. A converging process reflects in __*dropping evolution*__ of residuals - flat trend does not equal to converged, - convergence is only reached when the *residual* < *defined criterium* ---- #### --- The basic elements of a simulation: _Numerics_ / _Converging_ --- ### *Monitoring* in steady state simulations <br/> What kind of scenario could cause the following residual evolutions? <img src="https://conself.com/wp-content/uploads/2017/04/residuals-1.png" width="40%"> <img src="https://sklc-tinymce-2021.s3.amazonaws.com/comp/2022/11/What%20is%20CONVERGENCE%20in%20CFD%202_1669381258.jpg" width="30%"> <img src="https://i.imgur.com/OCLm2GX.jpg" width="55%"> <!--- <img src="https://d3i71xaburhd42.cloudfront.net/d93c1d23ba3522dcc88f623cd305bf41ff5c4ba3/5-Figure4-1.png" width="70%"> ---> --- #### --- The basic elements of a simulation: _Results_ --- ### Post-processing __*CFD*__ is not __*Colors for Directors!*__ __*You have to generate the valuable information form the calculation results.*__ Profile simulation -- airfoil lift and drag coefficient in diverse angle of attact <img src="http://www.cfd-ca.de/gallery/naca0012_struct_iso.png" width="24%">| <img src="https://www.femto.eu/wp-content/uploads/2022/05/Pressure_10deg.png" width="24%"> <img src="https://turbmodels.larc.nasa.gov/NACA0012_validation/CL_expdata.jpg" width="24%"> <img src="https://turbmodels.larc.nasa.gov/NACA0012_validation/CD_expdata.jpg" width="24%"> ---- #### --- The basic elements of a simulation: _Results_ --- ### Effects on emerse body: Forces and Heat Flux <br/> - Force = pressure force $\left(\iint P_\text{wall} \ dA \right)$ + shear force $\left(\iint \nu \frac{\partial u}{\partial y}|_\text{wall} \ dA\right)$ <img src="https://i.imgur.com/XVyXDdZ.png" width="70%"> - Heat flux = $\iint \alpha \frac{\partial T}{\partial y}|_\text{wall} \ dA\quad$ &rarr;&rarr; no gradient no heat transfer <br/> - $|_\text{wall}$ refers to the first cell from the solid surface - Physical value as the integration over the surface of emerse body ---- #### --- The basic elements of a simulation: _Results_ --- ### Streamline in the fluid domain <br/> | | | | | :--------: | :--------: | :------:| | <img src="https://www.researchgate.net/profile/Holger-Babinsky/publication/230910482/figure/fig3/AS:300352881610756@1448621115566/Streamlines-around-an-aerofoil-at-increasing-angle-of-attack_Q320.jpg" width="45%"> | <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f2/1915ca_abger_fluegel_%28cropped_and_mirrored%29.jpg/640px-1915ca_abger_fluegel_%28cropped_and_mirrored%29.jpg" width="88%"> | | Stream line is not necessary always the particle trajectory. This is only valid is teady state case.| Definition of streamline is simply the tangent of velocity vector | <br/> For pathlines in CFD, tracking particles is not a standard output. This requires multiple time steps results. ---- #### --- The basic elements of a simulation: _Results_ --- ### Mass flow of a nozzled system <br/> <img src="https://i.imgur.com/Tw2NEYp.png" width="80%"> Evaluation the mass flow, __*cross section*__ surface has to be defined. The __*flux*__ over the selected surface results to the mass flow rate ---- #### --- The basic elements of a simulation: _Results_ --- ### Validations are always needed _CFD simulations without validation in advanced is like driving without map, you never know if the results are feasible at the end._ <br/> Available measurement data are always a plus towards accurate simulation solution <img src="https://www.researchgate.net/publication/351786794/figure/fig6/AS:1026858472730637@1621833546915/Comparison-of-the-normalized-velocity-profiles-relative-to-the-measurement-on-the-2D.ppm" width="40%"> Numerical experiments are conducted based on the validated _phyiscal model/boundary condition/mesh/numerics_ --- ### Scenario i: Concentration in internal flow <br/> *fine particles are injected into a internal flow domain. Velocity distribution in the pipe system is given. Supposed the particles are so fine, where no impact to flow pattern can be expected. How can we simulate the distribution of concentration?* <img src="https://i.imgur.com/VdntPUV.png" width="50%"> - What are the proper __*transport equations*__ of system task/system? - Assume it is restriced to a 2-D assignement. How many patches do we have? What are the __*boundary conditions*__ for them? <!--- <img src="https://i.imgur.com/8HvLZOZ.png" width="60%"> ---> ---- ### Scenario ii: Solid body heat transfer <br/> *In the ironing process, stainless steel are heated in the oven of 2000K. The glow color and stiffness show in the dependency to diverse temperature level* ||| | ---: | :--- | |<img src="https://pic1.zhimg.com/80/v2-53abb7a7f89a83fa2cef45d87d4261ec_1440w.webp" width="80%"> | <img src="https://i.imgur.com/12TDAxq.png" width="70%"> | How would you describe the heating process? - What is the domain of the simulation? - What is the __*transport equations*__ when the iron is heated up? - How to set the __*boundary conditions*__ for heat source? - Base on the [glow color of steel](https://image.jimcdn.com/app/cms/image/transf/dimension=336x1024:format=jpg/path/sccb12de011035166/image/if0b2f46259d2bdf2/version/1452453251/image.jpg), how do you visualize the color in relation to time and position?
{"metaMigratedAt":"2023-06-17T19:53:53.337Z","metaMigratedFrom":"YAML","title":"CFD 4-Sessions Crash course - Session i","breaks":true,"slideOptions":"{\"theme\":\"solarized\"}","contributors":"[{\"id\":\"c4c1accb-f96c-47d2-b713-4ef0b4e7864b\",\"add\":43825,\"del\":21255}]"}
    520 views