Discretization of Convection Diffusion type Equation 8th Indo-German Winter Academy 2009 Piyush Kumar Sao Department of Electrical Engineering Indian Institute of technology Madras,Chennai Guides: Prof. Suman Chakraborty, IIT-Kharagpur Prof. Vivek V. Buwa, IIT-Delhi Presentation Outline o Introduction o Finite Volume Method o Spatial discretization o Source term discretization o Temporal discretization o Convergance o False diffusion 2 PIYUSH KUMAR SAO IIT MADRAS Introduction General transport equation for the conservation of property φ : ∂ ( ρφ ) + div( ρ u φ ) = div(Γ gradφ ) + S ∂t rate of change with time convection Here φ is the general variable ,Γ is diffusion diffusion source term constant corresponding to φ,S is source term. We shell look into different schemes for formulating set of linear equation to solve it numerically ,numerical stability of formulation and false diffusion. PIYUSH KUMAR SAO IIT MADRAS Finite Volume Method Basic methodology Divide domain into control volumes oIntegrate the differential equation over the control volume and apply divergence theorem oTo evaluate the derivative term , values at face of control volume are needed , assume a profile. oResult is set of linear algebraic equation :one for each control volume oSolve them iteratively or simultaneously 4 PIYUSH KUMAR SAO IIT MADRAS Finite Volume Method Basic methodology(1) oControl volumes do not over lap oNet flux through control volume is sum of flux through all four faces (6 in 3D) oValues at faces are not known in general and found by interpolation. 5 PIYUSH KUMAR SAO IIT MADRAS Finite Volume Method Basic methodology(1) So finally we get equation for cell P like apφ = aWφ + aEφ + aNφ + aSφ + b 6 PIYUSH KUMAR SAO IIT MADRAS Finite Volume Method 4 basic rules For solutions to be physically realistic and satisfy overall balance (conservative) There are some basic rules that need to be satisfied by the discretization equations. 1. Flux consistency at CV faces 2. Positive coefficients 3. Negative slope linearization of source term ( Sp should be negative) 4. Sum of neighbor coefficients 7 PIYUSH KUMAR SAO IIT MADRAS Spatial discretization (central difference and upwind) To start with we shell consider simplest case 1D steady state (with no source term) It should also satisfy continuity equation 8 PIYUSH KUMAR SAO IIT MADRAS Spatial discretization (central difference and upwind) Consider the 1-dimensional grid system (∆y and ∆z = 1): (δx) w (δx) e w e W P E ∆x We integrate diffusion convection over control volume dφ dφ ( ρ uφ ) e − ( ρ uφ ) w = Γ − Γ dx e dx w 9 PIYUSH KUMAR SAO IIT MADRAS Spatial discretization (central difference and upwind) Central Differencing Scheme If we assume linear profile W w P e E Γ (φ − φP ) Γw (φP − φW ) dφ dφ − = e E − Γ Γ dx dx ( δ x ) (δx) w w e e ( ρ u φ ) e − ( ρ uφ ) w = 10 1 1 ( ρ u ) e (φE + φP ) − ( ρ u ) w (φP + φW ) 2 2 PIYUSH KUMAR SAO IIT MADRAS Spatial discretization (central difference and upwind) Now we use following notation Our equation becomes 11 PIYUSH KUMAR SAO IIT MADRAS Spatial discretization (central difference and upwind) Conservativeness : Uses consistent expressions to evaluate convective and diffusive fluxes at CV faces. Hence Unconditionally Conservative Boundedness : will become negative if Scheme is conditionally bounded for Pe < 2 Transportiveness : The CDS uses influence at node P from all directions. Does not recognize direction of flow or strength of convection relative to diffusion Does not possess Transportiveness at high Peclet Numbers 12 PIYUSH KUMAR SAO IIT MADRAS Spatial discritization (central difference and upwind) Accuracy : Second Order in terms of Taylor series Stable and accurate only if Now Hence For stability and accuracy, either velocity should be very low or grid spacing should be small 13 PIYUSH KUMAR SAO IIT MADRAS Spatial discritization (central difference and upwind) First order upwind scheme Similarily for If φw [[ A, B ]] = Max( A, B ) Then discretization equation 14 PIYUSH KUMAR SAO IIT MADRAS Spatial discretization (central difference and upwind) First order upwind scheme Conservativeness : It is conservative Boundedness : When flow satisfies continuity equation, all coefficients are positive. Transportiveness : Direction of flow inbuilt in the formulation, thus accounts for transportiveness. Accuracy : When flow is not aligned with the grid lines, it produces false diffusion, which will form last part of our discussion. 15 PIYUSH KUMAR SAO IIT MADRAS Spatial discretization (exact solution) The governing transport equation: d d dφ (ρ u φ ) = Γ dx dx dx This can be exactly solved if Boundary conditions: Where 16 PIYUSH KUMAR SAO IIT MADRAS Γ is constant Spatial discretization Example Consider following convection diffusion equation Suppose f=0; then exact solution is 17 PIYUSH KUMAR SAO IIT MADRAS Spatial discretization Example Exact solutions for w = 1, 5, 10, 20 18 PIYUSH KUMAR SAO IIT MADRAS Spatial discretization Solution by CDS Suppose we choose N=4 on interval [0,1] then x0 = 0, x1 = Here 1 ∆x = 4 1 2 3 , x2 = , x3 = , x4 = 1 4 4 4 Hence Hence we get 3 equation as w 1 Fe = Fw = ; De = Dw = 2 ∆x ∆x w w 1 1 1 ui +1 = 0; i = 1,2,3 ui −i + 2 ui + − 2 + − 2 − ∆x ∆x 2∆x ∆x 2∆x 19 PIYUSH KUMAR SAO IIT MADRAS Spatial discretization Solution by CDS Further we need boundary condition , in this case it is u0 = 1; u4 = 0 − 16 + 2w 0 u1 16 + 2w 32 32 − 16 + 2w u2 = 0 − 16 − 2w u 0 w − 16 − 2 32 3 Now we solve it to get values of u1,u2 and u3 20 PIYUSH KUMAR SAO IIT MADRAS Solution by CDS Exact and numerical solution for u(x),w=40,N=5,10,15 and 20 21 PIYUSH KUMAR SAO IIT MADRAS Solution by First order upwind Here coefficients are different from CDS 2 w 1 1 w − 2 − ui −i + 2 + ui + − 2 ui +1 = 0; i = 1,2,3 ∆x ∆x ∆x ∆x ∆x Boundary condition u0 = 1; u4 = 0 − 16 0 u1 16 + 4w 32 + 4w − 16 u2 = 0 − 16 − 4w 32 + 4w u 0 w w − 16 − 4 32 + 4 3 22 PIYUSH KUMAR SAO IIT MADRAS Spatial discretization Solution by first order upwind Exact and numerical solution for u(x),w=40,N=5,10,15 and 20 23 PIYUSH KUMAR SAO IIT MADRAS Exponential scheme (exponential) Define Our transport equation becomes integrating over CV The exact solution derived above can be used as profile assumption with Substitution gives Where 24 PIYUSH KUMAR SAO IIT MADRAS Exponential scheme (exponential) After substitution of similar expression for standard form can be written as: J w , equation in our Merit: Guaranteed to produce exact solution for any Peclet number for 1-D steady convection-diffusion Demerits: 1. exponentials expensive to compute 2. not exact for 2-D, 3-D 25 PIYUSH KUMAR SAO IIT MADRAS Hybrid Scheme In exponential scheme P aE = Pe e De e −1 Hence Hybrid scheme is piecewise linear approximation of exponential scheme Pe < −2 26 P aE a a = − Pe ;−2 < Pe < 2 E = 1 − e ; Pe > 2 E = 0 2 De De De PIYUSH KUMAR SAO IIT MADRAS Power Law scheme Another approximation to exponential scheme Diffusion is set equal to zero for Otherwise calculated as follows 27 PIYUSH KUMAR SAO IIT MADRAS Second order upwind scheme We determine the value of φ from the cell values in the two cells upstream of the face. More accurate than the first order upwind scheme, but in regions with strong gradients it can result in face values that are outside of the range of cell values. It is then necessary to apply limiters to the predicted face values. 28 PIYUSH KUMAR SAO IIT MADRAS φW φ(x) interpolated value φP φe W P Flow direction e φE E Quick Scheme QUICK stands for Quadratic Upwind Interpolation for Convective Kinetics. A quadratic curve is fitted through two upstream nodes and one downstream node. This is a very accurate scheme, but in regions with strong gradients, overshoots and undershoots can occur. This can lead to stability problems in the calculation. 29 PIYUSH KUMAR SAO IIT MADRAS φW φ(x) interpolated value φP W P Flow direction φe φE e E Accuracy of different scheme o Each of the previously discussed numerical schemes assumes some shape of the function φ. These functions can be approximated by Taylor series polynomials: n ( xP ) φ ' ' ( xP ) φ φ ' ( xP ) ( xe − x P ) + ( xe − xP ) 2 + .... + φ ( xe ) = φ ( x P ) + ( xe − xP ) n + ... 2! n! 1! 30 The first order upwind scheme only uses the constant and ignores the first derivative and consecutive terms. This scheme is therefore considered first order accurate. For high Peclet numbers the power law scheme reduces to the first order upwind scheme, so it is also considered first order accurate. The central differencing scheme and second order upwind scheme do include the first order derivative, but ignore the second order derivative. These schemes are therefore considered second order accurate. QUICK does take the second order derivative into account, but ignores the third order derivative. This is then considered third order accurate. PIYUSH KUMAR SAO IIT MADRAS Spatial Discretization 2-D and 3-D Discretization in 2D Discretization in 3D 31 PIYUSH KUMAR SAO IIT MADRAS Spatial Discretization 2-D and 3-D Coefficients for 2-D, 3-D(HDS) 32 PIYUSH KUMAR SAO IIT MADRAS Source term discretization For 1-D, Discretization equation simply becomes, aPφP = aEφE + aW φW + b If the source term is a constant then If Source term is dependent of s.t. Hence b = S∆x φthen linearize S about P And all other coefficients remain the same 33 PIYUSH KUMAR SAO IIT MADRAS Temporal discretization For simplicity we consider time-dependent heat conduction: ρc ∂ ∂T ∂T = k ∂t ∂x ∂x We integrate in time (from t to t+∆t) and space: e t + ∆t 34 ρ c∫ ∫ w t ∂T dt dx = ∂t W PIYUSH KUMAR SAO IIT MADRAS t + ∆t e ∫∫ t w ∂ ∂T k dx dt ∂t ∂x (δx) w (δx) e w e P ∆x E Temporal discretization If we assume the value of T prevails over the entire volume: e t + ∆t ρ c∫ ∫ w t ∂T dt dx = ρ c∆x (TP1 − TP0 ) ∂t For the diffusion term: ρ c∆x (T − T ) = 1 P 0 P t + ∆t ∫ t 35 PIYUSH KUMAR SAO IIT MADRAS k e (TE − TP ) k w (TP − TW ) dt − (δx ) (δx ) w e Temporal discretization We need an assumption for the variation of T in time (between t and t+∆t): t + ∆t ∫ [ ] TP dt = f TP1 + (1 − f ) TP0 ∆t t where 0 < f < 1 f =0: Explicit scheme (first-order accurate) f = 0.5: CrankNicolcon (second-order accurate) f = 1: Implicit (firstorder accurate) 36 Explicit TP0 Crank-Nicolson TP1 PIYUSH KUMAR SAO IIT MADRAS Implicit Temporal discretization For stability, the Explicit scheme requires (on uniform grid): ∆t < ρ ( ∆x ) 2 2Γ To give realistic results, the Crank-Nicolson scheme requires: ∆t < ρ ( ∆x ) 2 Γ The Implicit scheme is always stable (but still only first-order)! Temporal and spatial discretization are strongly coupled 37 PIYUSH KUMAR SAO IIT MADRAS Temporal Discretization Schemes that are higher-order accurate in time exist, e.g.: ∂T 1 = (3 T n +1 − 4 T n + T n −1 ) ∂t 2∆ t 38 PIYUSH KUMAR SAO IIT MADRAS Iteration and Convergence At each iteration, at each cell, a new value for variable φ in cell P can then be calculated from that equation. It is common to apply relaxation as follows: φPnew, used = φPold + U (φPnew, predicted − φPold ) Here U is the relaxation factor: – U < 1 is underrelaxation. This may slow down speed of convergence but increases the stability of the calculation, i.e. it decreases the possibility of divergence or oscillations in the solutions. – U = 1 corresponds to no relaxation. One uses the predicted value of the variable. – U > 1 is overrelaxation. It can sometimes be used to accelerate convergence but will decrease the stability of the calculation. 39 PIYUSH KUMAR SAO IIT MADRAS Convergence o The iterative process is repeated until the change in the variable from one iteration to the next becomes so small that the solution can be considered converged. o At convergence: – All discrete conservation equations (momentum, energy, etc.) are obeyed in all cells to a specified tolerance. – The solution no longer changes much with additional iterations. Residuals measure imbalance (or error) in conservation equations. The absolute residual at point P is defined as: RP = a Pφ P − ∑ nb anbφ nb − b 40 PIYUSH KUMAR SAO IIT MADRAS Convergance Always ensure proper convergence before using a solution: unconverged solutions can be misleading!! Solutions are converged when the flow field and scalar fields are no longer changing. Determining when this is the case can be difficult. It is most common to monitor the residuals. 41 PIYUSH KUMAR SAO IIT MADRAS False Diffusion Often it is stated that the Central difference scheme is superior to the Upwind scheme because it is secondorder accurate whereas the Upwind scheme is only first-order accurate. If we compare the Central difference and Upwind schemes: ΓUpwind = Γ + ρ uδx 2 This added diffusion is considered bad, however it actually corrects the solution at large Peclet number (large cells)! 42 PIYUSH KUMAR SAO IIT MADRAS False Diffusion False diffusion is numerically introduced diffusion and arises in convection dominated flows, i.e. high Pe number flows. False diffusion is a multidimensional phenomenon and occures when the flow is NOT perpendicular to the grid lines! Consider If there is no false diffusion, the temperature will be exactly 100 ºC everywhere above the diagonal and exactly 0 ºC everywhere below the diagonal. 43 PIYUSH KUMAR SAO IIT MADRAS Hot fluid T = 100ºC Diffusion set to zero k=0 Cold fluid T = 0ºC False diffusion First-order Upwind 8x8 64 x 64 44 PIYUSH KUMAR SAO IIT MADRAS Second-order Upwind False diffusion An approximate expression for false diffusion is given by Γ false ρu∆x∆y sin 2θ = 4(∆y sin 3 θ + ∆x cos 3 θ ) False diffusion reduction: Use smaller ∆x and ∆y, allign grid lines more in direction of flow, Enough to make false diffusion << real diffusion CDS is no remedy for false diffusion. At high Pe, it produces unrealistic results 45 PIYUSH KUMAR SAO IIT MADRAS Summary We saw different scheme of discretizing convection diffusion equation,and considered their numerical accuracy stability and looked into false diffusion 46 PIYUSH KUMAR SAO IIT MADRAS References Numerical heat transfer ,S.Pathnkar Computational Science , Gilbert Strang 47 PIYUSH KUMAR SAO IIT MADRAS 48 PIYUSH KUMAR SAO IIT MADRAS