02 finite differences per gadin

Upload: carlo-farlocchiano

Post on 03-Jun-2018

232 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 02 Finite Differences Per Gadin

    1/27

    Finite Differences

    Finite Difference Approximations

    Simple geophysical partial differential equationsFinite differences - definitionsFinite-difference approximations to pdes

    Exercises Acoustic wave equation in 2DSeismometer equationsDiffusion-reaction equation

    Finite differences and Taylor ExpansionStability -> The Courant CriterionNumerical dispersion

    1Computational Seismology

    dx x f dx x f f x )()( + +

  • 8/12/2019 02 Finite Differences Per Gadin

    2/27

    Finite Differences

    )( 222

    22

    zyx

    tspcp

    ++=

    += The acousticwave equation- seismology

    - acoustics- oceanography- meteorology

    Diffusion, advection,Reaction- geodynamics- oceanography- meteorology- geochemistry- sedimentology

    - geophysical fluid dynamics

    P pressure

    c acoustic wave speed

    s sources

    P pressure

    c acoustic wave speed

    s sources

    p RC C C k C t += v

    C tracer concentrationk diffusivity

    v flow velocity

    R

    reactivity

    p sources

    C tracer concentrationk diffusivity

    v flow velocity

    R reactivity

    p sources

    Partial Differential Equations in Geophysics

  • 8/12/2019 02 Finite Differences Per Gadin

    3/27

    Finite Differences

    Finite differences

    Finite volumes

    - time-dependent PDEs- seismic wave propagation- geophysical fluid dynamics- Maxwells equations- Ground penetrating radar -> robust, simple concept, easy to

    parallelize, regular grids, explicit method

    Finite elements- static and time-dependent PDEs- seismic wave propagation- geophysical fluid dynamics- all problems-> implicit approach, matrix inversion, well founded,

    irregular grids, more complex algorithms,engineering problems

    - time-dependent PDEs- seismic wave propagation- mainly fluid dynamics-> robust, simple concept, irregular grids, explicit

    method

    Numerical methods: properties

  • 8/12/2019 02 Finite Differences Per Gadin

    4/27

    Finite Differences

    Particle-basedmethods

    Pseudo spectralmethods

    - lattice gas methods- molecular dynamics- granular problems- fluid flow- earthquake simulations-> very heterogeneous problems, nonlinear problems

    Boundary elementmethods

    - problems with boundaries (rupture)

    - based on analytical solutions- only discretization of planes-> good for problems with special boundary conditions

    (rupture, cracks, etc)

    - orthogonal basis functions, special case of FD- spectral accuracy of space derivatives- wave propagation, ground penetrating radar -> regular grids, explicit method, problems with

    strongly heterogeneous media

    Other numerical methods

  • 8/12/2019 02 Finite Differences Per Gadin

    5/27

    Finite Differences

    What is a finite difference?

    Common definitions of the derivative of f(x):

    dx

    x f dx x f

    f dx x)()(

    lim0+=

    dx

    dx x f x f f

    dx x

    )()(lim

    0

    =

    dxdx x f dx x f

    f dx

    x 2)()(

    lim0

    +=

    These are all correct definitions in the limit dx->0.

    But we want dx to remain FINITE

  • 8/12/2019 02 Finite Differences Per Gadin

    6/27

    Finite Differences

    What is a finite difference?

    The equivalent approximations of the derivatives are:

    dx x f dx x f f x )()( + +

    dxdx x f x f f x

    )()(

    dxdx x f dx x f

    f x 2)()( +

    forward difference

    backward difference

    centered difference

  • 8/12/2019 02 Finite Differences Per Gadin

    7/27Finite Differences

    The big question :

    How good are the FD approximations?

    This leads us to Taylor series....

  • 8/12/2019 02 Finite Differences Per Gadin

    8/27Finite Differences

    Taylor Series

    Taylor series are expansions of a function f(x) for somefinite distance dx to f(x+dx)

    What happens, if we use this expression for

    dx x f dx x f

    f x)()( +

    +

    ?

    ...)(!4

    )(!3

    )(!2

    )(dx)()( ''''4

    '''3

    ''2

    ' ++= x f dx x f dx x f dx x f x f dx x f

  • 8/12/2019 02 Finite Differences Per Gadin

    9/27Finite Differences

    Taylor Series

    ... that leads to :

    The error of the first derivative using the forward

    formulation is of order dx .

    Is this the case for other formulations of the derivative?Lets check!

    )()(

    ...)(!3

    )(!2

    )(dx1)()(

    '

    '''3

    ''2

    '

    dxO x f

    x f dx

    x f dx

    x f dxdx

    x f dx x f

    +=

    +++=+

  • 8/12/2019 02 Finite Differences Per Gadin

    10/27Finite Differences

    ... with the centered formulation we get:

    The error of the first derivative using the centered

    approximation is of order dx2.

    This is an important results: it DOES matter which formulationwe use. The centered scheme is more accurate!

    Taylor Series

    )()(

    ...)(!3

    )(dx1)2/()2/(

    2'

    '''3

    '

    dxO x f

    x f dx x f dxdx

    dx x f dx x f

    +=

    ++=+

  • 8/12/2019 02 Finite Differences Per Gadin

    11/27Finite Differences

    x j 1 x j x j + 1 x j + 2 x j + 3

    f x j( )

    dx h

    desired x location

    What is the (approximate) value of the function or its (first,second ..) derivative at the desired location ?

    How can we calculate the weights for the neighboring points?

    x

    f(x)

    Alternative Derivation

  • 8/12/2019 02 Finite Differences Per Gadin

    12/27Finite Differences

    Lets try Taylors Expansion

    f x( )

    dx

    x

    f(x)

    dx x f x f dx x f )(')()( ++ (1)(2)

    we are looking for something like

    f x w f xi j

    i

    index j j L

    ( ) ( )

    ( ),( ) ( )

    =1

    Alternative Derivation

    dx x f x f dx x f )(')()(

  • 8/12/2019 02 Finite Differences Per Gadin

    13/27Finite Differences

    deriving the second-order scheme

    a f a f a f d x+ + '

    b f b f b f d x ' + + + + a f b f a b f a b f d x( ) ( ) '

    the solution to this equation for a and b leads toa system of equations which can be cast in matrix form

    dxba

    ba

    /1

    0

    =

    =+

    0

    1

    =

    =+

    ba

    baInterpolation Derivative

    2nd order weights

  • 8/12/2019 02 Finite Differences Per Gadin

    14/27Finite Differences

    Taylor Operators

    ... in matrix form ...

    =

    0

    1

    11

    11

    b

    a

    Interpolation Derivative

    ... so that the solution for the weights is ...

    =

    dxb

    a

    /1

    0

    11

    11

    =

    0

    1

    11

    11 1

    b

    a

    =

    dxb

    a

    /1

    0

    11

    11 1

  • 8/12/2019 02 Finite Differences Per Gadin

    15/27

  • 8/12/2019 02 Finite Differences Per Gadin

    16/27Finite Differences

    '''!3

    )2(''

    !2)2(

    ')2()2(32

    f dx

    f dx

    f dx f dx x f +*a |

    *b |

    *c |

    *d |

    ... again we are looking for the coefficients a,b,c,d with whichthe function values at x(2)dx have to be multiplied in order

    to obtain the interpolated value or the first (or second) derivative!

    ... Let us add up all these equations like in the previous case ...

    '''!3)(''

    !2)(')()(

    32 f dx f dx f dx f dx x f +

    '''

    !3

    )(''

    !2

    )(')()(

    32

    f dx

    f dx

    f dx f dx x f ++++

    '''!3

    )2(''

    !2)2(

    ')2()2(32

    f dx

    f dx

    f dx f dx x f ++++

    Higher order operators

  • 8/12/2019 02 Finite Differences Per Gadin

    17/27Finite Differences

    +++ +++ df cf bf af

    ++++ )( d cba f

    +++ )22(' d cbadxf

    ++++ )222

    2(''2 d cb

    a f dx

    )68

    61

    61

    68

    ('''3

    d cba f dx ++

    ... we can now ask for the coefficients a,b,c,d, so that the

    left-hand-side yields either f,f,f,f ...

    Higher order operators

  • 8/12/2019 02 Finite Differences Per Gadin

    18/27Finite Differences

    1=+++ d cba

    022 =++ d cba

    0222

    2 =+++ d cba

    06

    8

    6

    1

    6

    1

    6

    8 =++ d cba

    ... if you want the interpolated value ...

    ... you need to solve the matrix system ...

    Linear system

  • 8/12/2019 02 Finite Differences Per Gadin

    19/27Finite Differences

    High-order interpolation

    =

    0

    00

    1

    6/86/16/16/8

    22/12/122112

    1111

    d

    cb

    a

    ... with the result after inverting the matrix on the lhs ...

    =

    6/1

    3/2

    3/2

    6/1

    d

    c

    b

    a

    ... Interpolation ...

  • 8/12/2019 02 Finite Differences Per Gadin

    20/27Finite Differences

    =

    0

    0/1

    0

    6/86/16/16/8

    22/12/122112

    1111

    dx

    d

    cb

    a

    ... with the result ...

    =

    6/1

    3/4

    3/4

    6/1

    21dx

    d

    c

    b

    a

    ... first derivative ...

    First derivative

  • 8/12/2019 02 Finite Differences Per Gadin

    21/27Finite Differences

    Our first FD algorithm (ac1d.m) !

    )( 222

    22

    zyx

    tspcp

    ++=

    += P pressure

    c acoustic wave speed

    s sources

    P pressurec

    acoustic wave speed

    s sources

    Problem:

    Solve the 1D acoustic wave equation using the finite

    Difference method.

    Problem:

    Solve the 1D acoustic wave equation using the finiteDifference method.

    Solution:Solution:

    [ ]

    2

    2

    22

    )()(2

    )()(2)()(

    sdt dt t pt p

    dx x p x pdx x pdx

    dt cdt t p

    ++

    ++=+

  • 8/12/2019 02 Finite Differences Per Gadin

    22/27

  • 8/12/2019 02 Finite Differences Per Gadin

    23/27Finite Differences

    Problems: Dispersion

    [ ]2

    2

    22

    )()(2

    )()(2)()(

    sdt dt t pt p

    dx x p x pdx x pdx

    dt cdt t p

    ++

    ++=+

    Dispersion:

    The numericalapproximation has

    artificial dispersion, in other words, the wavespeed becomes frequencydependent (Derivation inthe board).You have to find afrequency bandwidthwhere this effect is small.

    The solution is to use a

    sufficient number of gridpoints per wavelength.

    Dispersion:

    The numericalapproximation hasartificial dispersion,in other words, the wavespeed becomes frequencydependent (Derivation inthe board).

    You have to find afrequency bandwidthwhere this effect is small.The solution is to use asufficient number of gridpoints per wavelength.

    True velocity

  • 8/12/2019 02 Finite Differences Per Gadin

    24/27Finite Differences

    Our first FD code!

    [ ]2

    2

    22

    )()(2

    )()(2)()(

    sdt dt t pt p

    dx x p x pdx x pdx

    dt cdt t p

    ++

    ++=+

    % Ti me st eppi ng

    f o r i =1: nt ,

    % FD

    di s p( s pr i nt f ( ' Ti me st ep : %i ' , i ) ) ;

    f o r j =2: nx- 1d2p( j ) =( p( j +1) - 2*p( j ) +p( j - 1) ) / dx 2; % space der i vat i ve

    endpnew=2*p- pol d+d2p*dt 2; % t i me ext r apol at i onpnew( nx/ 2) =pnew( nx/ 2) +sr c( i ) *dt 2; % add sour ce t er mpol d=p; % t i me l evel s

    p=pnew;p( 1) =0; % set boundar i es pr essur e f r eep( nx) =0;

    % Di spl aypl ot ( x, p, ' b- ' )t i t l e( ' FD ' )dr awnow

    end

  • 8/12/2019 02 Finite Differences Per Gadin

    25/27Finite Differences

    Snapshot Example

    0 1000 2000 3000 4000 50000

    500

    1000

    1500

    2000

    2500

    3000

    Distance (km)

    T i m

    e ( s )

    Velocity 5 km/s

  • 8/12/2019 02 Finite Differences Per Gadin

    26/27

  • 8/12/2019 02 Finite Differences Per Gadin

    27/27

    Finite Differences - Summary

    Conceptually the most simple of the numerical methods and

    can be learned quite quicklyDepending on the physical problem FD methods areconditionally stable (relation between time and spaceincrement)

    FD methods have difficulties concerning the accurateimplementation of boundary conditions (e.g. free surfaces,absorbing boundaries)FD methods are usually explicit and therefore very easy to

    implement and efficient on parallel computersFD methods work best on regular, rectangular grids