Progress through quality Education Finite Difference Method

S. NADARAJA PILLAI

  

Progress through quality Education

Finite Difference Method

  School of Mechanical Engineering

  

SASTRA University

  Thanjavur – 613401 Email: nadarajapillai@mech.sastra.edu

  

@

Faculty Development Program on Computational Fluid Dynamics

June 2016

13 June 2016

  Outline Introduction Finite Difference Method Discretization Methods Forward Backward Central Difference Schemes Errors Examples

  

Progress through quality Education

13 June 2016

  Finite Difference Method (FDM)  Historically, the oldest of the three  Techniques published as early as 1910 by L. F. Richardson  Seminal paper by Courant, Fredrichson and Lewy (1928) derived stability criteria for explicit time stepping  First ever numerical solution: flow over a circular cylinder by Thom (1933)  Scientific American article by Harlow and Fromm (1965) clearly and publicly the idea of “computer experiments” for the first time — CFD is born!!

  

Progress through quality Education

13 June 2016

  Discretization methods

  • First step in obtaining a numerical solution is to discretize the geometric domain to define a numerical grid
  • Each node has one unknown and need one algebraic equation, which is a relation between the variable value at that node and those at some of the neighboring nodes.
  • The approach is to replace each term of the PDE at the particular node by a finite-difference approximation.
  • Numbers of equations and unknowns must be equal

  

Progress through quality Education

13 June 2016

  Finite Difference Techniques

  • Taylor Series Expansion : Any continuous differentiable function, in

  the vicinity of x , can be expressed as a Taylor series:

  i 2 2 3 n 3 n       ∂ Φ xx ∂ Φ xx ∂ Φ xx ∂ Φ

    ( ) ( ) ( ) i i i Φ ( ) x = Φ ( ) ( x x

  ... H + + + x ) + i i   2 3 n       ∂ x 2 ! ∂ x 3 ! ∂ x n ! ∂ x   i       i i i 2 2 3    

  ∂ Φ Φ − Φ xx ∂ Φ xx ∂ Φ   ( ) i 1 i i + +

  − H   2 3     ∂ x xx 2 ∂ x 6 ∂ x   i i 1 i

  • 1 i i 1 i = −
  • i i

     

  • Higher order derivatives are unknown and can be dropped when the distance between grid points is small.
  • By writing Taylor series at different nodes, x , x , or both x and

  i-1 i+1 i-1

  x , we can have:

  i+1 ∂ Φ Φ − Φ   i i1

  ∂ Φ Φ − Φ   i 1 i ≈  

  ≈

  •  

  Forward-FDS Backward-FDS ∂ x xx   i i i 1x xx

   

  • i i 1 i

  st ∂ Φ Φ − Φ   i 1 i − + 1

  1 order, order of accuracy P =1 kest

  ≈   ∂ x xx Central-FDS  

  • i i 1 i
  • 1 nd

      2 order, order of accuracy P =1 kest

      Progress through quality Education

    13 June 2016

      Finite Difference Techniques

    • • Numerical solutions can give answers at only discrete points in

      the domain, called grid points.
    • • If the PDEs are totally replaced by a system of algebraic

      equations which can be solved for the values of the flow-field variables at the discrete points only, in this sense, the original PDEs have been discretized. Moreover, this method of .

      discretization is called the method of finite differences

    Progress through quality Education

    13 June 2016

      Finite Difference Techniques

      A partial derivative replaced with a suitable algebraic difference quotient is • called finite difference. Most finite-difference representations of derivatives are based on Taylor’s series expansion. Taylor’s series expansion: •

      Consider a continuous function of x, namely, f(x), with all derivatives

      xx

    • defined at x. Then, the value of f at a location can be estimated

      from a Taylor series expanded about point x, that is,

      n

      2

      3 f 1 f 1 f 1 f

      ∂ ∂ ∂ ∂

      2

      3 n f x x f x x x x x ( ∆ ) = ( ) ∆ ∆ ∆ ... ( ∆ ) ... + + + + + + +

      ( ) ( ) n

      2

      3 x x x n x

      ∂ 2 ! ∂ 3 ! ∂ ! ∂

    • In general, to obtain more accuracy, additional higher-order terms must be included.

      

    Progress through quality Education

    13 June 2016

      

    Progress through quality Education

      Finite Difference Techniques

    13 June 2016

      Forward, Backward and Central Difference Scheme

      (1) Forward difference: Neglecting higher-order terms, we can get 2 2 3 3 n n

      ∂ f ( xx ) ∂ f xxf ( xx ) ∂ f ( ) i

    • 1 i i
    • 1 i i 1 i
    • i 1 i i i i
    • 2 3 n (a)

        f ( x ) = + + 1 i i i f ( x ) ( ) ( xx ) ( ) ( ) ... ( ) ... + + + +

        ∂ x 2 ! ∂ x 3 ! ∂ x n ! ∂ x ( ) ( ) ( ) ( ) ∂ f f xf x f xf x i + + 1 i i 1 i

        ( ) ; x x x = =

        ∆ = − i

      • i
      • 1 i 1 ix xxx 1 i i i + + 1 Progress through quality Education

          13 June 2016

        • − ∂ ∂ − =
        • ∂ ∂ − − + + ∂ ∂ −

          − − − = ∆

          Difference Scheme

          …(c) Forward, Backward and Central

          = ∂ ∂ i i i i i x x x f x f x f

          − + − + − −

          1 1 1 1 ) ( ) ( ) (

          (b)

          = ∂ ∂ i i i i i i i i i i i x x x

        x

        x f x f x x x f x f x f

          

        = − −

          ) ( − −

          

        Progress through quality Education

          1 1 1 1 ; ) ( ) ( ) ( ) (

          − − − − − i n n n i i n i i i

        i

        i i i i i i i x f n x x x f x x x f x x x x x f x f x f

          − ∂ ∂ −

          2 ) ( ) ( ) ( ) ( ) ( 1 3 3 3 1 2 2 2 1 1 1

          3 ) ( !

          ) ( ) ... 1 ( ) ( !

          ( ) ... ) ( !

          (2) Backward difference: Neglecting higher-order terms, we can get (3) Central difference: (a)-(b) and neglecting higher-order terms, we can get

        13 June 2016

          

        Progress through quality Education

          Forward, Backward and Central Difference Scheme

        13 June 2016

          Truncation Error

          Truncation error: • The higher-order term neglecting in Eqs. (a), (b), (c) constitute the truncation error. The general form of Eqs. (d), (e), (f) plus truncated terms can be written as

          f f f

          ∂ −

          1 i

        o x

          ( ) = ( ∆ ) Forward:

        • i

          i x x

          ∂ ∆

          f f f

          ∂ − Backward:

          i i

          1

        o x

          ( ) = ( ∆ + )

          i x x

          ∂ ∆

          f f f

          ∂ −

          2 i 1 i

        1 Central:

          o x

          ( ) = ( ∆ )

          i x x

          ∂ 2 ∆

          

        Progress through quality Education

        13 June 2016

        • Second derivatives:
          • Central difference:
            • 1
            • − =

        • Forward difference:
        • Backward difference:
          • − =
          • − =

          1

          2

          2

          2 x o x f f f x f i i i i

          ∆ + ∆

          ∂ ∂

          ) ( ) (

          2

          2 ) (

          2

          1

          2

          2 x o x f f f x f i i i i

          ∆ + ∆

          ∂ ∂

          − − Second Order Derivatives

          2

          2 ) (

          ) ( ) (

          1

          

        Progress through quality Education

          If , then (a)+(b) becomes

          x x x i i

          ∆ = ∆ = ∆

          2

          2

          1

          − +

          2

          2

          ) ( ) (

          2 ) (

          x o x f f f x f i i i i

          ∆ + ∆

          ∂ ∂

        13 June 2016

          Mixed Derivatives

          Mixed derivatives: •

        • Taylor series expansion:
        • 2 2 2 2 2

            ∂ ff ( ∆ x ) ∂ f ( ∆ y ) ∂ f ( ∆ x )( ∆ y ) ∂ f 3

          • 3

              2 [( ∆ ) , ( ∆ ) ] f x x y y f x y x y 2 2 o x y

            • ( ∆ , ∆ ) = ( , ) ∆ ∆

              ∂ xy

            2 ! ∂ x

            2 ! ∂ y 2 ! ∂ xy

            • Central difference:
            • 2

                − + + − − − + + 1 , 1 1 , 1 1 , 1 2 2 =

                f ff f − +   ∂ f i j i j i j i j 1 , 1

              • oxy

                [( ) , ( ) ]   x y x y

                ∂ ∂ 4 ( ∆ )( ∆ )   i j ,

              • Forward difference:
              • 2

                  ff − + f f   ∂ f i j i j i j i j 1 ,

                • 1 ,
                • 1 1 , , = ox ∆ + y [( ) , ( ) ]

                      x y x y

                    ∂ ∂ ( ∆ )( ∆ )   i j ,

                  • Backward difference:

                    fff f   ∂ f

                  • 2
                  • = oxy i j i j i j i j , − 1 , , − 1 − 1 , −
                  • 1

                    [( ) , ( ) ]   x y x y

                      ∂ ∂ ( ∆ )( ∆ )   i j ,

                    Progress through quality Education

                    13 June 2016

                      Errors Involved

                      In the solution of differential equations with finite differences, a variety of • schemes are available for the discretization of derivatives and the solution of the resulting system of algebraic equations. In many situations, questions arise regarding the •

                      round-off and truncation

                    errors involved in the numerical computations, as well as the consistency,

                      stability and the convergence of the finite difference scheme. Round-off errors:computations are rarely made in exact arithmetic. This • means that real numbers are represented in “floating point” form and as a result, errors are caused due to the rounding-off of the real numbers. In extreme cases such errors, called “round-off” errors, can accumulate and become a main source of error.

                      

                    Progress through quality Education

                    13 June 2016

                      Errors Involved

                      Truncation error: In finite difference representation of derivative with • Taylor’s series expansion, the higher order terms are neglected by truncating the series and the error caused as a result of such truncation is called the “truncation error”.

                      The truncation error identifies the difference between the exact solution of • a differential equation and its finite difference solution without round-off error.

                      

                    Progress through quality Education

                    13 June 2016

                    THANK YOU

                      

                    Progress through quality Education