FINITE DIFFERENCE METHODSDr. Sreenivas JayantiDepartment of Chemical EngineeringIIT-MadrasTHE CFD APPROACH• Assembling the governing equations• Identifying flow domain and boundary conditions• Geometrical discretization of flow domain• Discretization of the governing equations• Incorporation of boundary conditions• Solution of resulting algebraic equations• Post-solution analysis and reformulation, if neededOUTLINE• Basics of finite difference (FD) methods• FD approximation of arbitrary accuracy• FD formulas for higher derivatives• Application to an elliptic problem• FD for time-dependent problems• FD on non-uniform meshes•ClosureBasics of Finite Difference Methods• FD methods are quite old and somewhat dated for CFD problems butserve as a point of departure for CFD studies• The principal idea of CFD methods is to replace a governing partial differential equation by an equivalent and approximate set of algebraic equations• Finite difference techniques are one of several options for thisdiscretization of the governing equations• In finite difference methods, each derivative of the pde is replaced by an equivalent finite difference approximationBasics of Finite Difference Methods• The basis of a finite difference method is the Taylor series expansion of a function.• Consider a continuous function f(x). Its value at neighbouring points can be expressed in terms of a Taylor series as(1) f(x+ ∆x) = f(x) + df/dx (∆x) + d2f/dx2(∆x2)/ 2! + .. + dnf/dxn(∆xn)/n! + ..• The above series converges if ∆x is small and f(x) is differentiable• For a converging series, successive terms are progressively smallerFD Approximation for a First Derivative• The terms in the Taylor series expansion can be rearranged to givedf/dx = [f(x+ ∆x) - f(x)] / ∆x - d2f/dx2(∆x)/2! - …-dnf/dxn(∆xn-1)/n! - ...Or(2) df/dx ≈ [f(x+ ∆x) - f(x)] / ∆x + O(∆x)• Here O(∆x) implies that the leading term in the neglected terms of the order of ∆x, i.e., the error in the approximation reduces by a factor of 2 if ∆x is halved.• Equation (2) is therefore a first order-accurate approximation for the first derivative.Other Approximations for a First Derivative• Other approximations are also possible. Writing the Taylor series expansion for f(x- ∆x), we have(3) f(x-∆x) = f(x) - df/dx (∆x) + d2f/dx2(∆x2)/ 2! - .. + dnf/dxn(∆xn)/n! +• Equation (3) can be rearranged to give another first order approximation :(4) df/dx ≈ [f(x) - f(x-∆x)] / ∆x + O(∆x)• Subtracting (3) from (1) gives a second order approximation for df/dx :(5) df/dx ≈ [f(x+ ∆x) - f(x-∆x)] / (2∆x) + O(∆x2)FD Approximations on a Uniform Mesh• Consider a uniform mesh with a spacing of ∆x over an interval [0, L]• Denoting the mesh index by i, we can write fi= f(xi) = f(i ∆x) and fi+1 = f [(i+1) ∆x] and so on•Then(2) ⇒ df/dx ≈ [f(x+ ∆x) - f(x)] / ∆x = (fi+1 - fi)/∆x + O(∆x)(3) ⇒ df/dx ≈ [f(x) - f(x- ∆x) ] / ∆x = (fi- fi-1)/∆x + O(∆x)(5) ⇒ df/dx ≈ [f(x+ ∆x) - f(x-∆x)] / (2∆x) = (fi+1- fi-1)/(2∆x) + O(∆x2) are the forward “one-sided”backward “one-sided”central “symmetric”differencing formulas, respectively, for df/dx at x or node i• One-sided formulas are necessary at ends of domainsHigher Order Accuracy• Higher order of accuracy of approximation can be obtained by including more number of adjacent points• Let us seek a third-order, one-sided approximation for u(x). This requires four points and will be of the form (6) du/dx)i = [aui + bui+1 + cui+2 + dui+3]/ ∆x + O(∆x3)• This is equivalent to writing (6) as (7) du/dx)i = [aui + bui+1 + cui+2 + dui+3]/ ∆x + (0) d2u/dx2(∆x) + (0)d3u/dx3(∆x2) + (e) d4u/dx4(∆x3) or (8) aui + bui+1 + cui+2 + dui+3 = + du/dx (∆x) + (0) d2u/dx2(∆x2) + (0)d3u/dx3(∆x3) - (e) d4u/dx4(∆x4) • How to find a, b, c and d?Third-Order, One-sided Formula • Expand ui+1, ui+2 and ui+3 in Taylor series about ui: (9a) ui+1 = u(x+ 1∆x) = u(x) + du/dx (∆x) + d2u/dx2(∆x)2/ 2! + ...(9b) ui+2 = u(x+ 2∆x) = u(x) + du/dx (2∆x) + d2u/dx2(2∆x)2/ 2! + ...(9c) ui+3 = u(x+ 3∆x) = u(x) + du/dx (3∆x) + d2u/dx2(3∆x)2/ 2! + ...• Find { a ui + b (9a) + c(9b) + d (9c) } and rearrange to get(10) aui + bui+1 + cui+2 + dui+3 = pu +q du/dx (∆x) + r d2u/dx2(∆x2) + s d3u/dx3(∆x3) + t d4u/dx4(∆x4) • Compare the coefficients of (8) and (10) to geta = -11/6 b = 3 c = -3/2 d = 1/3or(11) du/dx)i = [-11 ui + 18 ui+1 - 9 ui+2 + 2 ui+3]/ (6∆x) + O(∆x3)Higher Derivatives • Finite difference approximation for second derivative: d2u/dx2)i = [d/dx( du/dx)]i≈ [ (du/dx)i+1/2- (du/dx)i-1/2] / ∆x ≈ [ (ui+1 - ui)/ ∆x -(ui-ui-1)/ ∆x ] / ∆x or(12) d2u/dx2)i ≈ [ (ui+1 -2 ui + ui-1) ] / ∆x2• Taylor series evaluation of equation (11) shows that the approximation is second order accurate; thus, (12a) d2u/dx2)i = [ (ui+1 -2 ui + ui-1) ] / ∆x2+ O(∆x2)• Note that use of central differences for the second derivative requires three points, viz., (i-1), i, (i+1), for a second order accurate formulaOther Formulas for Higher Derivatives • Using forward differencing throughout, one can get the following first order accurate formula involving three points for the second derivative: d2u/dx2)i = [d/dx( du/dx)]i≈ [ (du/dx)i+1- (du/dx)i] / ∆x ≈ [ (ui+2 - ui+1)/ ∆x - (ui+1 - ui)/ ∆x ] / ∆x or(13) d2u/dx2)i ≈ [ (ui+2 -2 ui+1 + ui) ] / ∆x2+ O(∆x)• A central, second order scheme for the third derivative needs four points: (14) d3u/dx3)i = [ (ui+2 -2 ui+1 + 2 ui-1 - ui-2) ] / (2∆x3) + O(∆x2)• If p = order of derivative, q = order of accuracy and n = no of points, then n = p + q -1 for central schemes n = p + q for one-sided schemesMixed Derivatives • Mixed derivatives can occur as a result of coordinate transformation to a non-orthogonal system (for example, to take account of non-regular shape of the flow domain). • Straightforward application of the method for higher derivatives: ∂2u/∂x∂y)i,j = [∂/∂x (∂u/ ∂y)]i,j ≈ [(∂u/∂y)i+1,j - (∂u/∂y)i-1,j] / (2∆x) ≈ [ (ui+1,j+1 - ui+1,j-1)/ 2∆y - (ui-1,j+1 - ui-1,j-1)/ 2∆y ] / (2∆x) or(15) ∂2u/∂x∂y)i,j ≈ [(ui+1,j+1 -ui+1,j-1 - ui-1,j+1 + ui-1,j-1)] / (4 ∆x∆y) + O(∆x2, ∆y2)• A large variety of schemes possibleExample: 2-D Poisson Equation (16) ∂2u/∂x2+ ∂2u/∂y2= f 0 < x < L and 0 < y < Wwith
View Full Document