5. FVM Discretization and Solution Procedure
Total Page:16
File Type:pdf, Size:1020Kb
5. FVM discretization and Solution Procedure 1. The fluid domain is divided into a finite number of control volumes (cells of a computational grid). 2. Integral form of the conservation equations are discretized and applied to each of the cells. 3. The objective is to obtain a set of linear algebraic equations, where the total number of unknowns in each equation system is equal to the number of cells. 4. Solve the equation system with an solution algorithm with proper equation solvers. 1 Discretization– Solution Methods We want to transform the partial differential equations (PDE) to a set of algebraic equations: With Finite Volume Methods, the equation is first integrated. This is different from Finite Difference Method where the derivatives are approximated by truncated Taylor series expansions. Advantage with FDM is it is easy to use, but is limited to structured grids (simpler geometry). 2 Discretization– FDM vs. FVM The key difference is Gauss’ theorem FDM FVM 1 2 3 1 2 3 2w 2e Δ푥 푑휙 න 푑푉 ≈ 휙퐴 − 휙퐴 푑푥 2푒 2푤 퐶푉2 푑휙 휙2 − 휙1 휙 − 휙 휙 − 휙 ≈ 3 2 2 1 푑푥 Δ푥 = − 2 Δx Δx 3 Conservation Equations We have the conservation equations: - Mass (mass is conserved) - Momentum (The sum of forces equals the time rate of change of momentum) - Energy (Energy can not be created nor destroyed) These equations can be expressed as a single generalized transport equation 4 Discretization– transport equation 휕 휌휙 휕 휕 휕휙 + 휌푢푗휙 = Γ + 푆휙 휕푡 휕푥푗 휕푥푗 휕푥푗 Transient Convective Diffusive Source 휙 = 1 gives continuity (mass) 휙 = 푢 gives momentum 휙 can also be temperature or other scalars, but need to check if the equation is still satisfied. Source terms can be external body forces, like gravity. Observe also that the pressure gradient is included in 푆휙 for momentum 5 Solution procedure – momentum equations Insertion of velocity in the transport equation gives us transport of momentum. The resulting equation requires different treatment than transport of any scalar (like temperature) because of the following reasons: 1. The convective terms are non-linear since they contain 푈2 2. All equations are coupled because velocity component appears in all 3. Momentum equation contain a pressure gradient (inside source term) without an own explicit equation for pressure in the equation set 6 Discretization– Finite Volume Method The equation is first integrated. Discretization is done in the second step. When it’s integrated, Gauss’ theorem is applied and the net fluxes on cell faces must be expressed from values at the cell centers using interpolation. Advantage is flexibility with regard to cell geometry. Advantage in less memory usage. There are also well developed solvers for this method. FVM has the broadest applicability of all CFD methods. 7 Discretization– integration of transport equation Integrated over the cell volume: 휕 휌휙 휕 휕 휕휙 න 푑푉 + න 휌푢푗휙 푑푉 + න Γ 푑푉 + න 푆휙 푑푉 Δ푉 휕푡 Δ푉 휕푥푗 Δ푉 휕푥푗 휕푥푗 Δ푉 The second and third terms can be expressed as fluxes (Gauss’ theorem). That is transport across the CV boundaries. If the time term is included, we must integrate in time as well. 8 Discretization FVM– discrete transport equation 휕 휌휙 휌휙푉 푛+1 − 휌휙푉 푛 න 푑푉 ≈ 퐶푉 휕푡 Δ푡 휕 න 휌풖휙 푑퐴 ≈ 휌휙풖 ⋅ 풏 푓 휕푥푗 퐴 푓 휕 휕휙 휕휙 න Γ 푑퐴 ≈ Γ ⋅ 풏 휕푥푗 휕푥푗 휕푥푗 퐴 푓 푓 9 Discretization– system of equations We have already mentioned that we wish to discretize the PDE’s and express them as linear algebraic equations of the form: 푎푃휙푃 = 푎푛푏휙푛푏 + 푆휙 푛푏 Solving these set of equations (for each cell) requires an equation solver. If the algebraic equations are non-linear they may be linearized. In addition to having an efficient solver for the algebraic equations, we need a solution algorithm solves the equations in the correct order. 10 A simple numerical example (On blackboard) Steady-state one-dimensional diffusion equation: 푇 푑 푑휙 푇 Γ = 0 Solution 퐿 푑푥 푑푥 (if Γ const.) 푇0 휙 can be temperature, and Γ thermal conductivity. 푥 푇 = 푇 0 푇 = 푇퐿 11 A simple numerical example - Physics Classification of the problem: 1. What does this equation describe if 휙 is temperature? 2. 푘 is a function of temperature, but can be taken as constant in many situations Physical boundary conditions: 1. Dirichlet: 푇 = 푐표푛푠푡. -> constant temperature 푑푇 2. Neumann: = 푐표푛푠푡. -> constant heat flux, constant normal temperature 푑푥 gradient 12 Derivative vs. Numerical 푓(푥) Definition derivative of function 푓 = 푓(푥): 휕푓 휕푓 Δ푓 = 퐶 → 푓 푥 = 퐶 ⋅ 푥 + 퐶 → ≈ 휕푥 1 1 2 휕푥 Δ푥 Δ푥 푥푖 휕2푓 휕푓 푥2 2 = 퐶1 → = 퐶1 ⋅ 푥 + 퐶2 → 푓 푥 = 퐶1 ⋅ + 퐶2 ⋅ 푥 + 퐶3 휕푥 휕푥 2 푓(푥) 휕푓 휕푓 휕푓 Δ푓 Δ푓 2 Δ − − Δ푥 휕 푓 휕푥 휕푥 Δ푥/2 Δ푥/2 Δ푥 휕푥 2 1 2 1 2 → ≈ = = 2 휕푥2 Δ푥 Δ푥 Δ푥 푥푖 13 Approximation of the first derivative, the FDM approach st Forward-differences (FD), 1 order accuracy: CD with higher order is 푑휙 휙 − 휙 휙 − 휙 ≈ 푖+1 푖 = 푖+1 푖 normally applied to 푑푥 푥 − 푥 Δ푥 푖 푖+1 푖 diffusion terms Backward-differencing (BD), 1st order: Local interior grid 푑휙 휙 − 휙 휙 − 휙 ≈ 푖 푖−1 = 푖 푖−1 푑푥 푥 − 푥 Δ푥 푖 푖 푖−1 푖 − 1 푖 푖 + 1 Central-differencing (CD), 2nd order: 푑휙 휙푖+1 − 휙푖−1 휙푖+1 − 휙푖−1 ≈ = Δ푥 푑푥 푥 − 푥 2Δ푥 푖 푖+1 푖−1 14 Approximation of the second derivative… Evaluate the inner derivative at half-way between nodes, and central differences with Δ푥 spacing for the outer derivative: 푑휙 푑휙 Γ − Γ 푑 푑휙 푑푥 푖+1/2 푑푥 푖−1/2 Γ ≈ Local interior grid 푑푥 푑푥 Δ푥 푖 Where 푖 − 1 푖 푖 + 1 푑휙 휙 − 휙 푑휙 휙 − 휙 푖 − 1/2 푖 + 1/2 ≈ 푖+1 푖 , ≈ 푖 푖−1 푑푥 Δ푥 푑푥 Δ푥 푖+1/2 푖−1/2 15 Approximation of the second derivative (FDM) Evaluate the inner derivative at half-way between nodes, and central differences with Δ푥 spacing for the outer derivative: 휙 − 휙 휙 − 휙 Γ 푖+1 푖 − Γ 푖 푖−1 푑 푑휙 푖+1/2 Δ푥 푖−1/2 Δ푥 Γ ≈ Local interior grid 푑푥 푑푥 Δ푥 푖 Γ + Γ Γ ≈ 푖 푖+1 푖+1/2 2 푖 − 1 푖 푖 + 1 If Γ = 푐표푛푠푡.: 푖 − 1/2 푖 + 1/2 −2휙 + 휙 + 휙 = 푖 푖+1 푖−1 Δ푥2 16 Resulting equation system We wish to express the resulting system in a form 푎푃휙푃 = 푎푛푏휙푛푏 + 푆휙 푛푏 With constant Γ we get: 2 ⋅ 휙푖 − 휙푖+1 − 휙푖−1 = 0 퐴푖 = 2, 퐴푛푏 = 1 and 푄푖 = 0 17 Resulting equation system On a structured mesh (FDM), mesh and the 휙1 = 휙0 equation matrix is much of the same thing. 2 휙2 − 휙1 − 휙3 = 0 2 휙3 − 휙2 − 휙4 = 0 … … . 휙푁 = 휙퐿 A x = b 1 0 0 0 0 휙1 휙0 -1 2 -1 0 0 휙2 0 0 -1 2 -1 0 * 휙3 = 0 0 0 -1 2 -1 휙4 0 0 0 0 0 1 휙5 휙퐿 18 Discretization– Finite-Volume Approach 푑 푑휙 푑휙 푑휙 න Γ 푑푉 = Γ퐴 − Γ퐴 = 0 푑푥 푑푥 푑푥 푑푥 Δ푉 푒 푤 Local interior grid Γ + Γ Γ + Γ Γ = 푃 퐸 Γ = 푊 푃 푒 2 푤 2 Fluxes 푊 푤 푃 푒 퐸 푑휙 휙퐸 − 휙푃 Γ퐴 = Γ 퐴 Δ푥 푑푥 푒 푒 Δ푥 푒 푃퐸 푑휙 휙 − 휙 Γ퐴 = Γ 퐴 푃 푊 푑푥 푤 푤 Δ푥 푤 푊푃 Central differences 19 Discretization– Finite-Volume Approach Express on this form (algebraic equation): 푎푃휙푃 = 푎푛푏휙푛푏 + 푆휙 푛푏 Local interior grid Γ 퐴 Γ 퐴 푒 푒 푤 푤 푊 푃 퐸 휙퐸 − 휙푃 − 휙푃 − 휙푊 = 0 푤 푒 Δ푥푃퐸 Δ푥푊푃 Δ푥 Γ푒퐴푒 Γ푤퐴푤 Γ푒퐴푒 Γ푤퐴푤 + 휙푃 = 휙퐸 + 휙푊 + 0 Δ푥푃퐸 Δ푥푊푃 Δ푥푃퐸 Δ푥푊푃 Fluxes 푎푃 푎퐸 푎푊 푆푃 20 Discretization– 2D Diffusion fluxes 푑 푑휙 푑휙 푑휙 푑휙 푑휙 න Γ 푑푉 = Γ퐴 − Γ퐴 + Γ퐴 − Γ퐴 푑푥 푑푥 푑푥 푑푥 푑푥 푑푥 Δ푉 푒 푤 푛 푠 Its a CV equation just like we showed 푁 earlier. Flux in equals out 푛 Approximating face absolute values and 푊 푤 푒 퐸 derivatives poses similar problems as in FDM. 푠 휕휙 Need discretization of 휕푥 푆 21 Discretization– 1D Convection fluxes 푑 න 휌푢휙 푑푉 = 퐴푒 휌푢휙 푒 − 퐴푤 휌푢휙 푤 Δ푉 푑푥 Dealing with these terms are not straightforward, and central differences as for the diffusion leads to unphysical results for high velocities. Local interior grid Introduction of the Peclet number: 푃 퐸 휌푢 푊 푤 푒 푃푒 = Γ/Δ푥 Δ푥 Expresses ratio between convection and diffusion 22 Discretization– 1D Convection fluxes The right discretization scheme is important for the convective fluxes at high Peclet numbers. Different alternatives: First-order upwind scheme: 휙푒 = 휙푃 (if 휌푢휙 푒 > 0) Second-order upwind Local interior grid Hybrid scheme: Combination of central- and upstream QUICK scheme 푊 푤 푃 푒 퐸 General: Central differences only if 푃푒 < 2 Δ푥 If large Peclet numbers, use the upstream value 23 Solution – Residuals Convergence criteria when solving: σ 푎푛푏휙푛푏 + 푆휙 − 푎푃휙푃 푛푏 < 휖 (small number) 푎푃휙푃 24 Solution – Residuals Decreasing residuals means the solution may not be converged If they flatten out and have a low value, like 1E-4 or lower we may assume that convergence have been reached. But this depends on the case. Increasing residuals is normally a bad sign. Correct residuals only mean that our algebraic equation system have been solved, not that the solution is correct.