The Control-Volume Finite-Difference Approimation to the Diffusion Equation ME 448/548 Notes Gerald Recktenwald Portland State Universit Department of Mechanical Engineering gerr@mepdedu ME 448/548: D Convection-Diffusion Equation Overview Develop a numerical model of the two-dimensional Poisson equation Demonstrate application of the finite volume method for a cartesian mesh Allow for non-uniform mesh, diffusion coefficient, and source term Implement in Matlab Demonstrate truncation error for a model problem with a simple solution Appl to full-developed flow in a rectangle ME 448/548: D Convection-Diffusion Equation page
Model Problem The two dimensional diffusion equation in Cartesian coordinates is Γ φ + Γ φ + S = () where φ is the scalar field, Γ is the diffusion coefficient, and S is the source term ME 448/548: D Convection-Diffusion Equation page D Cartesian Finite Volume Mesh 3 Interior node + + Boundar node Ambiguous corner node j = i = 3 ME 448/548: D Convection-Diffusion Equation page 3
Finite Volume Mesh Notation for a tpical control volume w e Regardless of whether the control volumes sizes are uniform, the node is alwas located in the geometric center of each control volume Thus, δ n W N P E n P w = e P = P s = n P = δ s s δ w S δ e ME 448/548: D Convection-Diffusion Equation page 4 Convert the Differential Equation to a Discrete Equation Integrate over the control volume w e n e s w = Γ φ d d n s Γ φ Γ φ d e w Γ φ Γ φ e w δ n δ s W δ w N P S δ e E n s Γ e φ E φ P δ e φ P φ W Γ w δ w ME 448/548: D Convection-Diffusion Equation page 5
Convert the Differential Equation to a Discrete Equation Integrate the source term e n w s Sdd S P () Note: The Control Volume Finite Difference (CVFD) method treats the source term and diffusion coefficients as piecewise constants This is a rather crude approimation, sa, compared to allowing the source term and diffusion coefficient to var linearl within the control volume However, piecewise constant profiles of S and Γ allow the method to be conservative, ie, conserving mass or energ, automaticall The conservative nature of the CVFD method is one of its primar strengths ME 448/548: D Convection-Diffusion Equation page 6 Convert the Differential Equation to a Discrete Equation Putting pieces back into the model equation gives the discrete sstem of equations where a E = a S φ S a W φ W + a P φ P a E φ E a N φ N = b (3) Γ e δ e, a W = Γ w δ w, a N = Γ n δ n, a S = Γ s δ s a P = a E + a W + a N + a S (4) b = S P (5) This is not a tridiagonal sstem of equations ME 448/548: D Convection-Diffusion Equation page 7
Non-uniform Γ Continuit of flues at the interface requires φ Γ P φ = Γ E φ = Γ e e e+ Use central difference approimations e material material P E Γ e φ E φ P δ e = Γ P φ e φ P δ e (6) δ e- δ e+ Γ e φ E φ P δ e = Γ E φ E φ e δ e+ (7) δ e ME 448/548: D Convection-Diffusion Equation page 8 Non-uniform Γ Equations 6 and 7 can be rearranged as material material φ e φ P = δ e Γ P φ E φ e = δ e+ Γ E Γ e δ e (φ E φ P ) (8) Γ e δ e (φ E φ P ) (9) P E Add Equation 8 and Equation 9 φ E φ P = Γ e δe (φ E φ P ) + δ e+ δ e Γ P Γ E Cancel the factor of (φ E φ P ) and solve for Γ e /δ e to get δ e- δ e δ e+ Γ e δe = + δ e+ = δ e Γ P Γ E Γ E Γ P δ e Γ E + δ e+ Γ P ME 448/548: D Convection-Diffusion Equation page 9
Non-uniform Γ Thus, the diffusion coefficient at the interface that results in flu continuit is Γ e = Γ E Γ P βγ E + ( β)γ P () where β δ e δ e = e P E P () An analogous derivation gives formulas for Γ w, Γ n,andγ s ME 448/548: D Convection-Diffusion Equation page Solving the Sstem of Equations Regardless of uniform or variable Γ, the discrete equation has a five-point stencil, and the discrete equation for an interior node can be written a S φ S a W φ W + a P φ P a E φ E a N φ N = b () To set up the matri for this sstem of equations, we need to re-number the unknowns ME 448/548: D Convection-Diffusion Equation page
Solving the Sstem of Equations Order the nodes: n = i +(j )n With natural ordering the neighbors in the compass point notation have these indices np = i + (j-)*n ne = np + nw = np - nn = np + n ns = np - n 3 + + j = i = 3 Interior node Boundar node Ambiguous corner node ME 448/548: D Convection-Diffusion Equation page Solving the Sstem of Equations This leads to a vector of unknowns φ, φ, φ n, φ, φ, φ i,j φ n,n φ φ φ n φ n+ φ n+ φ n φ N (3) ME 448/548: D Convection-Diffusion Equation page 3
Solving the Sstem of Equations A = a S a W ap a E a N ME 448/548: D Convection-Diffusion Equation page 4 Model Problems Choose the source term so that the eact solution is simple to compute Uniform source term Analtical solution eists, but requires an infinite series 3 Nonuniform diffusivit and concentrated source term This problem is meant to stress the numerical solution code ME 448/548: D Convection-Diffusion Equation page 5
Model Problem Choose a source term that ma be phsicall unrealistic, but one that gives an eact solution that is eas to evaluate π π π π S = + sin sin L L L L The eact solution is π π φ = sin sin L L ME 448/548: D Convection-Diffusion Equation page 6 Model Problem The eact solution is π π φ = sin sin L L 5 5 5 8 6 4 ME 448/548: D Convection-Diffusion Equation page 7
Solutions to Model Problem Show Correct Truncation Error The local truncation error at each node is e i O( ) Since the eact solution is known we can compute e N = e i N Nē N = ē N where N = n n is the total number of interior nodes in the domain, and ē is the average truncation error per node Measured error 3 4 5 6 Measured Theoretical error ~ ( 3 7 3 Since e i O( ), N n,and = L /(n + ), wecanestimate e N ē = O( ) = O L /(n + ) 3 O = O( 3 ) N n n n ME 448/548: D Convection-Diffusion Equation page 8 Model Problem Uniform source term: S = 8 7 6 5 4 3 5 8 6 4 ME 448/548: D Convection-Diffusion Equation page 9
Model Problem 3 Solution with α = Γ = αγ Γ = L 5L S = S = 5L 35 3 5 5L 5L L 5 5 5 8 6 4 ME 448/548: D Convection-Diffusion Equation page Model Problem 4: Full Developed Flow in a Rectangular Duct For simple full-developed flow the governing equation for the aial velocit w is µ w + w dp dz = This corresponds to the generic model equation with φ = w, Γ = µ (= constant), S = dp dz ME 448/548: D Convection-Diffusion Equation page
Model Problem 4: Full Developed Flow in a Rectangular Duct The smmetr in the problem allows alternative was of defining the numerical model Full Duct Quarter Duct L L L L For the full duct simulation depicted on the left hand side, the boundar conditions are no slip conditions on all four walls w(, ) = w(, L )=w(,)=w(l,)= (full duct) ME 448/548: D Convection-Diffusion Equation page Model Problem 4: Full Developed Flow in a Rectangular Duct The smmetr in the problem allows alternative was of defining the numerical model Full Duct Quarter Duct L L L L For the quarter duct simulation depicted on the right hand side, the boundar conditions are no slip conditions on the solid walls ( = L and = L ) w(l,)=w(, L )= (quarter duct) and smmetr conditions on the other two planes u = u = = = ME 448/548: D Convection-Diffusion Equation page 3