You are on page 1of 37

Finite Difference Method

Kush Bhatia Dept. of Computer Science & Engg. IIT Delhi

Tutors: Prof. U. Rüde, Prof. G. Biswas

Contents
 Introduction to Differential Equations  Finite Difference Method : Overview  Finite Difference Approximations  Explicit and Implicit Methods  Errors In Discretization  Consistency, Convergence and Stability Analysis  Fluid-Flow Modeling

 Conservative Property

Differential Equations
 Newton Cooling Model

 1 Dimensional Wave Equation

Solving Differential Equations  Analytical Methods: Finding Closed form Solution  Numerical Methods: Approximating Numerical Solutions to Differential Equations  Finite Difference Method  Finite Elements Method .

Contents  Introduction to Differential Equations  Finite Difference Method : Overview  Finite Difference Approximations  Explicit and Implicit Methods  Errors In Discretization  Consistency. Convergence and Stability Analysis  Fluid-Flow Modeling  Conservative Property .

Finite Difference Method: Overview  A finite difference method for solving differential equations involves the following steps:  Grid Generation  Derivative Substitution  Solving System Of Algebraic Equation .

Grid Generation .

Convergence and Stability Analysis  Fluid-Flow Modeling  Conservative Property .Contents  Introduction to Differential Equations  Finite Difference Method : Overview  Finite Difference Approximations  Explicit and Implicit Methods  Errors In Discretization  Consistency.

Finite Difference Approximations  Consider the following differential Equation:  Numerical Approximation requires replacing the derivatives with Numerical approximations  Use Taylor Series Expansion for the approximation .

Finite Difference Approximations  The Taylor Series:  On replacing 𝑥 by 𝑥 + ℎ and 𝑎 by 𝑥  Combining higher order terms .

Finite Difference Approximations P Q P1 P P2 Forward/Backward Difference Approximation Central Difference Approximation .

Finite Difference Approximations  Forward Difference Approximation  Backward Difference Approximation  Central Difference Approximation .

Finite Difference Approximations  Taylor Series Expansion for Function of 2 independent variables  The Partial Derivative Approximations:  Forward :  Backward :  Central : .

similarly by considering higher order terms in the Taylor Series. we can approximate the higher order derivatives as well  Second Order Derivative:  Second Order Partial Derivative: .Finite Difference Approximations  As we approximated the first derivative.

Contents  Introduction to Differential Equations  Finite Difference Method : Overview  Finite Difference Approximations  Explicit and Implicit Methods  Errors In Discretization  Consistency. Convergence and Stability Analysis  Fluid-Flow Modeling  Conservative Property .

the following two cases may arrive: Explicit Method Implicit method Where 𝑗 denotes the spacial dimension and 𝑛 denotes the temporal dimension .Explicit & Implicit Methods  On Substituting the approximations to the derivatives in the differential equation.

𝑡𝑛 .  To denote the solution 𝑢(𝑥. 𝑡𝑛 ) with uniform time step size Δ𝑡 = 𝑡𝑛+1 − 𝑡𝑛 and uniform space step Δ𝑥 = 𝑥𝑖+1 − 𝑥𝑖 .Explicit & Implicit Method : Example  Consider the Differential Equation:  Constructing the Grid: Consider a rectangular Mesh (𝑥𝑖 . use 𝑢𝑖 ≈ 𝑢 𝑥𝑖 . 𝑡) at the required point on 𝑛 the grid. .

can determine 𝑢 at 𝑥𝑖 for time 𝑡𝑛+1 .  Solutions takes the form of a “marching” in steps of time.Explicit & Implicit Method : Example  Substituting the forward difference approximations in the differential equation  Given that we know value of 𝑢 at all 𝑥 for time 𝑡 from initial condition. also the Explicit Euler Method of Finite Difference .

Explicit & Implicit Method : Example  Substituting the spatial difference on RHS by time average of n and n+1 (Crank-Nicolson Method)  The unknown value 𝑢 at time 𝑛 + 1 is expressed in terms of known values at time 𝑛 and unknown values at time 𝑛 + 1.  To solve this equation. we formulate it at all points 𝑥𝑖 for time 𝑡𝑛+1 to obtain a system of algebraic equations .

Explicit & Implicit Method : Example  The equation can be rearranged as With 𝑟 = 𝛼 Δ𝑡 . 2 Δ𝑥  On applying equation at all points from 𝑖 = 1 𝑡𝑜 𝑘 + 1 and applying the boundary conditions.  B is the coefficient Matrix and X is the Solution Vector . representation of the form B𝑋 = 𝐶 can be obtained.

 Computing time per time step is small. Algorithm requires more involved process  Stability can be maintained over larger values of Δ𝑡.  Computing time per step is larger.Explicit Vs Implicit Methods Explicit Method  Solution Algorithm is Implicit Method  Setting up Solution simple to set up.  Stability Constraint puts a restriction on time step given a spatial step. .

Contents  Introduction to Differential Equations  Finite Difference Method : Overview  Finite Difference Approximations  Explicit and Implicit Methods  Errors In Discretization  Consistency. Convergence and Stability Analysis  Fluid-Flow Modeling  Conservative Property .

 The errors can be controlled by controlling the grid spacing in the chosen mesh.Errors in Discretization  Numerical Solution of a differential Equation is influenced by the following sources of errors:  Discretization Error = Truncation Error + Error due to treatment of Boundary Conditions  Round Off Error = Numerical Error induced due to finite precision of decimals in computer memory  For implicit methods. there is an additional Algebraic Error induced by introducing an iterative method for the Linear System. .

Errors in Discretization .

Convergence and Stability Analysis  Fluid-Flow Modeling  Conservative Property .Contents  Introduction to Differential Equations  Finite Difference Method : Overview  Finite Difference Approximations  Explicit and Implicit Methods  Errors In Discretization  Consistency.

the finite difference scheme as employed on the Newton Cooling Law is a consistent one.  Example : Consider the Newton Cooling Law:  The Truncation Error 𝑇ℎ is given by  And we observe that  Thus. .Consistency  A Finite Difference Scheme is said to be consistent if the limit of the truncation error is zero as ∆𝑡 𝑜𝑟 ∆𝑥 approaches zero.

. The red line denotes the exact solution. the grid spacing is 0. value of grid spacing has been set to 1. For the blue line.25. 𝑦 0 = 1. solution approaches the exact solution of the differential equation for each value of the independent variable as grid spacing approaches zero Numerical approximation to the differential equation 𝑦 ′ = 𝑦. while for the green line.Convergence  A Finite Difference scheme is said to be Convergent if the approx.

005) .01) Stable Finite Difference Scheme (Grid Size = 0.Stability Analysis Unstable Finite Difference Scheme (Grid Size = 0.

 Amplification of this error at time step 𝑛 + 1 is ε𝑛+1 = 𝑔ε𝑛 . . it is required that ε𝑛+1 ≤ ε𝑛 or 𝑔 ≤ 1.  For the stability of the finite difference scheme.  To find the stability criteria.  A Finite Difference Method Scheme Converges if it is stable and consistent and the discrete problem is uniquely solvable. one can use Von Neumann technique to determine error ε explicitly.Stability Analysis  Let ε𝑛 be the error which occurs at time step 𝑛. where g = amplification factor.

Contents  Introduction to Differential Equations  Finite Difference Method : Overview  Finite Difference Approximations  Explicit and Implicit Methods  Errors In Discretization  Consistency. Convergence and Stability Analysis  Fluid-Flow Modeling  Conservative Property .

𝜕𝑥  In the equation above 𝑢 refers to the velocity. Burgers Equation reduces to an analog of Eulers equation 𝜕𝜙 𝜕𝑡 + 𝜕𝜙 𝑢 𝜕𝑥 =0 .Application: Fluid Flow Modeling  Burgers presented a simple non-linear equation to model fluid flow 𝜕𝜙 𝜕𝑡 𝜕𝜙 + 𝑢 𝜕𝑥 = 𝜕2 ϕ 𝑣 2 .  If we neglect the viscous term. 𝑣 refers to the coefficient of viscosity and 𝜙 refers to any property which can be transported or diffused.

Contents  Introduction to Differential Equations  Finite Difference Method : Overview  Finite Difference Approximations  Explicit and Implicit Methods  Errors In Discretization  Consistency. Convergence and Stability Analysis  Fluid-Flow Modeling  Conservative Property .

 We say that a property is conserved in the system if the net rate of accumulation of property in the system equals the net inflow – net outflow. Inflow of property System Under Consideration Outflow of property .Conservative Property  Consider the following system with a property being verified for conservation.

Conservative Property  Consider the inviscid Burger Equation 𝜕𝜔 𝜕𝑡 = 𝜕 − (𝑢𝜔). .  On evaluating the integral 1 𝐼2 𝐼2 𝑛+1 n Σ𝑖=𝐼1 𝜔𝑖 Δ𝑥 − Σ𝑖=𝐼 𝜔 Δ𝑥 = 𝑢𝜔 1 i Δ𝑡 1 𝐼2 Σ 𝜔Δ𝑥 Δ𝑡 𝑖=𝐼1 ∶ − 𝑢𝜔 1 𝐼2 +2 1 𝐼1 −2 Thus the conservative property has been preserved. 𝜕𝑥  Its Finite Difference analog is given by 𝑛+1 𝑛 𝜔𝑖 −𝜔𝑖 Δ𝑡 =− 𝑛 𝑛 𝑛 𝑛 𝑢𝑖+1 𝜔𝑖+1 −𝑢𝑖−1 𝜔𝑖−1 2Δ𝑥  Consider a region 𝑅 running from 𝑖 = 𝐼1 𝑡𝑜 𝑖 = 𝐼2 .

Convergence and Stability Analysis  Fluid-Flow Modeling  Conservative Property .Overview  Introduction to Differential Equations  Finite Difference Method : Overview  Finite Difference Approximations  Explicit and Implicit Methods  Errors In Discretization  Consistency.

Christoph Pflaum  Numerical Simulation in Fluid Dynamics. Angermann  Lecture Notes.References  High Performance Computing. Michael Griebel. Zhilin Li  Numerical Methods: Finite Differences. Dowd & C.Severence  Finite Difference Method Basics. Peter Olver  2-D Finite Difference Methods. Simulation and Scientific Computing. Tilman Neunhoeffer . Knabner & L. P. Chris Johnson  Numerical Methods for Elliptic and Parabolic Partial Differential Equations. Thomas Dornseifer. K.

Thank You .