Lecture 4. Finite Difference Approimation 1
Discretization As stated in Lecture 1.0, there are three steps in numerically solving the differential equations. They are: 1. Discretization of the domain by placing a large number of nodes with help of grid generation techniques, as discussed in Module 3.. Approimating (or discretizing) the governing equations at the nodes identified in Step 1. 3. Solving the algebraic equations obtained in Step using direct or iterative methods. In this and in the following few lectures, finite difference method is chosen for the purpose of discretizing the governing equations.
Finite Difference Method Finite difference method computes the solution numerically at a predefined set of discrete points in the structured grid of a computational domain. These discrete points along with their inter connections are called nodal points of the grid or mesh. The procedure of identifying the grid points (or grid) for a given domain is called the discretization of the domain, which is the first step in the finite difference method. 3
In Module 3, various grid generation techniques have been highlighted. However for the regular domains chosen to eplain the finite difference method, placing nodal points uniformly and connecting them by straight lines gives the required grid therefore, we may not use the procedures given in the Module 3. For eample, the discretization of a one dimensional domain that is, an interval, can be realized as shown in Fig. 4..1 Fig. 4..1 Discretization of an interval 4
In this discretization, a set of uniformly distributed points 0, 1,. n are identified such that 0 = a, n = b and i i-1 = for i = 1,, n, as shown in Fig. 4..1. Where, is the step length. A uniform grid means the distance between any two consecutive points i and i-1 is constant. Otherwise, the discretization is called non-uniform. The coordinate of any mesh point in Fig. 4..1, is computed using i a i* i 0,1,... n (4..1) Function value u at any point i is represented by u i ui i 0,1,... n 5
If Ω is a rectangular two-dimension domain bounded by [a,b] [c,d], then it can be discretized as shown in Fig. 4... Fig. 4.. Discretization of a rectangular domain The coordinates of any point p( i,y j ) are obtained using i 0 i *, i 0,1,,..., n, y j y 0 j * y, j 0,1,,..., m (4..) 6
Further, the dependent variable u at any point P is represented using u i,j = u( i, y j ). A similar etension can be carried out for higher dimensional domains. For grid generation in arbitrary domains, refer to Module 3. The second step is the discretization of the governing equations. To realize this, there are several methods. In the present lecture, the Taylor series based method is highlighted. Consider a function u which depends on the independent variable in the interval [a, b]. 7
Let the function u be sufficiently smooth (differentiable) and it has values u i and u i + 1 at any two neighboring points, i and i + 1 respectively. By using Taylor series epansion, u i + 1 can be epressed in terms of u i and its higher derivatives as 3 ui 1 u i ui ui ui ui! 3! where the superscript stands for a derivative with respect to.... (4..3) From equation (4..3), u i can be written as u 1 u u i i i ui ui...! 3! ui 1 ui 1 O( ) ui O( ) (4..4) 8
where δ + is the forward difference operator defined by δ + u i = u i+1 u i Equation (4..4) is the first approimation to u at the node i. In this approimation ui! 3! ui... is the error. This error is called Truncation error, in which leading term. ui! is the Since the degree of the step size is one in the leading term of the error, (4..4) is a first order approimation for u. 9
The order of approimation is an important concept in the process of discretization which gives an immediate insight about what kind of accuracy can be epected from the scheme. Similarly, one can also write 3 u i 1 ui 1 ui ui ui ui! 3!... (4..5) ' 1 1 u u i u i i ui ui... ui O( )! 3! (4..6) where δ - is the backward difference operator defined by δ - u i = u i u i-1. Eq. (4..5) is again first order as the degree of the step size in the leading term of the error is also one. 10
From (4..5) and (4..4) (subtracting (4..5) from (4..4)) one can write 3 5 u 1 1 v i ui ui ui u... 3! 5! i (4..7) 1 1 u 0 ( i ui 1 ui 1 ui ui O ) 6 (4..8) Here, δ 0 is called the central difference operator defined by δ 0 u i = u i+1 u i-1. Equation (4..8) is a second order accurate approimation for u as the leading term of the error has in second degree. 11
Alternatively, adding (4..4) and (4..5) gives 4 u 1 1 iv i ui ui ui u...! 4! i ui 1 ui ui 1 iv 1 i i i u u u O( ) 1 (4..9) (4..10) where δ is the central difference operator for second derivative which is a second order accurate approimation. 1
Numerical Implementation The finite difference approimations (4..4), (4..6), (4..8), and (4..10) can be used to replace the first and second order derivative terms of a differential equation to convert it into a difference (possibly linear algebraic) equation at every nodal point of the interior of the domain. Note that the central approimation (4..8) is one order better accurate than the forward (4..4) and backward (4..6) approimations. To understand the implementation, consider the following boundary value problem (BVP). d u du d d u sin(ln ) 0, 1, u(1) 1and u() (4..11) 13
The analytical solution of the BVP Eq. (4..11) is.03831 u( ) 1.10869 3sin log( ) 5cos log 34 (4..1) The finite difference solution of Eq. (4..11) is obtained by replacing its first and second order derivative terms of with (4..7) and (4..8), respectively to get ui 1 ui ui 1 ui 1 ui 1 O( ) u sin log( ) 0 i i i i for i 1,,..., n 1 (4..13) Note that at node numbers 0 and n, we have boundary conditions and the given differential equation may not be valid at these points, therefore, at these nodes we have (from the boundary conditions) u 0 = 1.0 and u n =.0 (4..14)
Equation (4..13) has n-1 equations in n+1 variables, therefore adding Eq. (4..14) closes the system to solve for the unknowns u i, for i = 1,,..., n-1. Rearranging the terms in (4..13) gives 1 1 1 1 u 1 1 sin log( ) i u ( ) i u i i i i i i 1,,... n 1 (4..15) Equation (4..15) is a linear system with tri-diagonal coefficient matri. Solving such linear algebraic systems is the third and final step of the numerical schemes. (Refer Module 5). 15
After solving Eq. (4..15) with step lengths ( ) 1/40, 1/80 and 1/160, the absolute errors in the numerical solution are computed and compared in the Fig. 4..3 Fig. 4..3 Comparison absolute errors with three distinct discretizations 16
The corresponding infinity error norms, obtained using are u u Eact 3.8134 10-06, 9.5413 10-07,.3854 10-07, respectively for the step lengths 1/40, 1/80 and 1/160. It is clear from this demonstration that the accuracy is improved as the number of points is increased. The decimal place accuracy obtained with second order approimations is quite satisfactory, however, if one wishes to further improve the accuracy, higher order approimations to the derivatives can be obtained. Therefore, the topic of discussion in the net lecture is the higher 17 order finite difference approimation.
Eercise Problems Find a second order finite difference approimation for the PDE u uv v 1 1 0 c c y c y Find the truncation error in the above problem Generate a uniform grid in the circular region r <= 1. Describe the implementation of derivative boundary conditions using finite differences 18
Summary of Lecture 4. Finite difference approimations for partial derivatives are introduced in this lecture. END OF LECTURE 4. 19