numerical methods 4 pde

Upload: bharavi-k-s

Post on 06-Apr-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 Numerical Methods 4 PDE

    1/44

    Numerical Methods for Partial

    Differential Equations

    CAAM 452

    Spring 2005

    Lecture 41-step time-stepping methods: stability, accuracy

    Runge-Kutta Methods,

    Instructor: Tim Warburton

  • 8/3/2019 Numerical Methods 4 PDE

    2/44

  • 8/3/2019 Numerical Methods 4 PDE

    3/44

    CAAM 452 Spring 2005

    Recall: AB2 v. AB3 v. AB4

    These are the margins of absolute stability for the AB methods:

    Starting with the yellow AB1 (Euler-Forward) we see that as the order ofaccuracy goes up the stability region shrinks.

    i.e. we see that to use the higher order accurate AB scheme we are requiredto take more time steps.

    Q) how many more?

  • 8/3/2019 Numerical Methods 4 PDE

    4/44

    CAAM 452 Spring 2005

    Recall:

    Requirements Starting Requirements

    AB1:

    AB2:

    AB3:

    1

    0

    1 1

    0

    3 1

    2 2n n n n

    u u dt

    u u

    u u dt f u f u

    !

    ! !

    0

    1

    0

    n n n

    u u

    u u dt f u

    !!

    2

    1

    0

    1 1 2

    2

    0

    23 16 512n n n n n

    u u dt

    u u dt

    u u

    dtu u f f f

    !

    !

    !

    !

    1 solution level for start

    2 solution levels for start

    3 solution levels for start

  • 8/3/2019 Numerical Methods 4 PDE

    5/44

    CAAM 452 Spring 2005

    cont

    So as we take higher order version of the AB

    scheme we also need to provide initial values at

    more and more levels.

    For a problem where we do not know the solution

    at more than the initial condition we may have to:

    Use AB1 with small dt to get the second restart level

    Use AB2 with small dt to get the third restart level

    March on using AB3 started with the three levels

    achieved above.

    AB1

    AB2

    AB3

  • 8/3/2019 Numerical Methods 4 PDE

    6/44

    CAAM 452 Spring 2005

    Recall: Derivation of AB Schemes

    The AB schemes were motivated by considering

    the exactly time integrated ODE:

    Which we approximated by using a pth order

    polynomial interpolation of the function f

    1

    1

    n

    n

    t

    n n

    t

    u t u t f u t dt

    !

    1

    1

    n

    n

    t

    n n p

    t

    u t u t I f u t dt

    $

  • 8/3/2019 Numerical Methods 4 PDE

    7/44

    CAAM 452 Spring 2005

    Leap Frog Scheme

    We could also have started the integral at:

    And used the mid point rule:

    Which suggests the leap frog scheme:

    1nt

    1

    1

    1 1

    n

    n

    t

    n n

    t

    u t u t f u t dt

    !

    1 1 2n n nu t u t dtf u t $

    1 1 2n n nu u dtf u !

  • 8/3/2019 Numerical Methods 4 PDE

    8/44

    CAAM 452 Spring 2005

    Volunteer Exercise

    1) accuracy: what is the local truncation error?

    2) stability: what is the manifold of absolute linear

    stability (try analytically) in the nu=dt*mu plane?

    2a) what is the region of absolute linear-stability?

    1 1 2n n nu u dtf u !

  • 8/3/2019 Numerical Methods 4 PDE

    9/44

    CAAM 452 Spring 2005

    cont

    3) How many starting values are required?

    4) Do we have convergence?

    5) What is the global order of accuracy?

    6) When is this a good method?

    1 1 2n n nu u dtf u !

  • 8/3/2019 Numerical Methods 4 PDE

    10/44

    CAAM 452 Spring 2005

    One Step Methods

    Given the difficulties inherent in starting the higher order ABschemes we are encouraged to look for one-step methodswhich only require to evaluate

    i.e.

    Euler-Forward is a one-step method:

    We will consider the one-step Runge-Kutta methods.

    For introductory details see: An introduction to numerical analysis, Suli and Mayers, 12.2

    (p317) and on

    Trefethen p75-

    Gustafsson,Kreiss and Oliger p241-

    nu 1nu

    1 , ;n n n nu u dt u t dt ! *

    1 , ; :n n n n n nu u dtf u u t dt f u ! * !

  • 8/3/2019 Numerical Methods 4 PDE

    11/44

    CAAM 452 Spring 2005

    Runge-Kutta Methods

    The Runge-Kutta are a family of one-step methods.

    They consist of s stages (i.e. require s evaluations

    off)

    They will be pth order accurate, for some p.

    They are self starting !!!.

  • 8/3/2019 Numerical Methods 4 PDE

    12/44

    CAAM 452 Spring 2005

    Example Runge-Kutta Method

    (Modified Euler)

    Modified Euler:

    Note how we only need one starting value.

    We can also reinterpret this through intermediatevalues:

    This looks like a half step to approximate the mid-interval u and then a full step.

    This is a 2-stage, 2nd order, single step method.

    1

    ,

    ,2 2

    n n

    n n

    n n

    a dtf u t

    a dtb dtf u t

    u u b

    ! !

    !

    1

    1 1 1/ 2

    ,

    2,

    n n n

    n n n

    dtu u f u t

    u u dtf u t

    !

    !

  • 8/3/2019 Numerical Methods 4 PDE

    13/44

    CAAM 452 Spring 2005

    Linear Stability Analysis

    As before we assume that fis linear in u and

    independent of time

    The scheme becomes (for some given mu):

    Which we simplify (eliminate the uhat variable):

    1

    1 1 1/ 2

    ,2

    ,

    n n n

    n n n

    dtu u f u t

    u u dtf u t

    !

    !

    1

    1 1

    2

    n n

    n n

    dtu u u

    u u dt u

    Q

    Q

    !

    !

    1

    1 1

    2

    n n

    n n

    dtu u u

    u u dt u

    Q

    Q

    !

    !

    2

    12

    n n n n

    dtu u dt u u

    QQ !

  • 8/3/2019 Numerical Methods 4 PDE

    14/44

    CAAM 452 Spring 2005

    cont

    We gather all terms on the right hand side:

    [ Note: the bracketed term is exactly the first 3

    terms of the Taylor series for exp(dt*mu), more on

    that later ]

    We also note for the numerical solution to be

    bounded, and the scheme stable, we require:

    2

    11

    2n n

    dtu dt u

    QQ

    !

    2

    1 1

    2

    dtdt

    QQ e

  • 8/3/2019 Numerical Methods 4 PDE

    15/44

    CAAM 452 Spring 2005

    cont

    The stability region is the set of nu=mu*dt in the complexplane such that:

    The manifold of marginal stability can be found (as in thelinear multistep methods) by fixing the multiplier to be of unitmagnitude and looking for the corresponding values of nuwhich produce this multiplier.

    i.e. for each theta find nu such that

    2

    1 12

    RR e

    2

    1

    2

    ie

    URR !

  • 8/3/2019 Numerical Methods 4 PDE

    16/44

    CAAM 452 Spring 2005

    cont

    We can manually find the roots of this quadratic:

    To obtain a parameterized representation of the

    manifold of marginal stability:

    2

    12

    ie

    URR !

    1 1 2 1 ie UR ! s

  • 8/3/2019 Numerical Methods 4 PDE

    17/44

    CAAM 452 Spring 2005

    Plotting Stability Region for

    Modified Euler

    1 1 2 1i

    e

    U

    R ! s

  • 8/3/2019 Numerical Methods 4 PDE

    18/44

    CAAM 452 Spring 2005

    Checking Modified Euler

    at the Imaginary Axis

    As before we wish to check how much of theimaginary axis is included inside the region of

    absolute stability.

    Here we plot the real part of the + root

  • 8/3/2019 Numerical Methods 4 PDE

    19/44

    CAAM 452 Spring 2005

    Is the Imaginary Axis in

    the Stability Region ?

    We can analytically zoom in by choosingnu=i*alpha (i.e. on the imaginary axis).

    We then check the magnitude of the multiplier:

    So we know that the only point on the imaginary

    axis with multiplier magnitude bounded above by 1is the origin.

    Modified Euler is not suitable for the advectionequation.

    2 2 22 2 2 4

    21 1 1 12 2 2 4

    iR E E ER E E ! ! !

  • 8/3/2019 Numerical Methods 4 PDE

    20/44

    CAAM 452 Spring 2005

    General 2 stage RK family

    Consider the four parameter family of RK schemesof the form:

    where we will determine the parameters

    (a,b,alpha,beta) by consideration of accuracy.

    [ Euler-Forward is in this family with a=1,b=0

    1

    2 1

    1 1 2

    ,

    ,

    n n

    n n

    n n

    k f u t

    k f u dtk t dt

    u u dt ak bk

    F E

    !

    !

    !

  • 8/3/2019 Numerical Methods 4 PDE

    21/44

    CAAM 452 Spring 2005

    cont

    The single step operator in this case is:

    1

    2 1

    1 1 2

    1

    ,

    ,

    ,

    where , , , ,

    n n

    n n

    n n

    n n n n

    n n n n n n n n

    k f u t

    k f u dtk t dt

    u u dt ak bk

    u u u t

    u t af u t bf u dtf u t t dt

    F E

    F E

    !

    !

    !

    p ! *

    * !

  • 8/3/2019 Numerical Methods 4 PDE

    22/44

    CAAM 452 Spring 2005

    cont

    We now perform a truncation analysis, similar tothat performed for the linear multistep methods.

    We will use the following fact:

    2

    2

    3

    3

    2 2 2 2

    2 2

    ,

    ,

    ...

    duf u t t

    dt

    d u d f f du f f f u t t f

    dt dt t u dt t u

    d u d f f f

    dt dt t u

    f f f f f f f f f f f

    t t u u t u u t u

    !

    x x x x ! ! !

    x x x x

    x x ! ! x x

    x x x x x x x x x x x x x x x x

  • 8/3/2019 Numerical Methods 4 PDE

    23/44

    CAAM 452 Spring 2005

    cont(accuracy)

    We expand Phi in terms of powers of dt using thebivariate Taylors expansion

    where:

    3

    2 22 2 2

    2 2

    , , , ,

    2! 2!

    n n n n nu t t af u t bf u dtf u t t dt

    f

    f faf b dt dtf O dt

    t u

    dt dtf f f f dt dt f t t u u

    F E

    E F

    E FE F

    * !

    x x ! x x

    x x x x x x x

    ,n n f f u t t !

  • 8/3/2019 Numerical Methods 4 PDE

    24/44

    CAAM 452 Spring 2005

    cont

    We construct the local truncation error as:

    Now we choose a,b,alpha,beta to minimize thelocal truncation error.

    Note we use subindexing to represent partialderivatives.

    22

    2 2

    2 4

    ,

    2

    2 3!

    2 2

    n n n n n

    t u tt tu uu u t u

    t u tt tu uu

    T u t dt u t dt u t t

    dt dt dt f f ff f f f f f f f f f

    dt dtf dt af b f dtf dtff f dt ff f O dt

    E FE F EF

    ! *

    !

  • 8/3/2019 Numerical Methods 4 PDE

    25/44

    CAAM 452 Spring 2005

    cont

    Consider terms which are the same order in dt in the localtruncation error:

    Condition 1:

    Condition 2:

    Under these conditions, the truncation is order 3 so the

    method is 2nd order accurate. It is not possible to further

    eliminate the dt^3 terms by adjusting the parameters.

    22

    2 2

    2 4

    23

    2

    2 !

    2

    n tt tu uu u t u

    tt

    t u

    t u tu uu

    dt f ff

    d

    dtf

    f f

    T dt f f f f f f f f f

    dt dtf dt a b f dt ff tf dtff f O dt E

    E F FEF

    !

    1 0a b !

    1 102 2

    t u t u f ff b dtf dtff f b bE F E F ! ! !

  • 8/3/2019 Numerical Methods 4 PDE

    26/44

    CAAM 452 Spring 2005

    Case: No Explicit t Dependence in f

    2 23

    2

    ,

    2!

    n nu t t bf u dtf u

    dtff fb f dtf O dt

    u u

    F

    FF

    * !

    x x!

    x x

    22 3 2

    2

    2 3 2,du d u f d u f f f u t f f f

    dt dt u dt u ux x x ! ! ! x x x

    1

    22

    2 2 4

    ;

    3! 22

    n n n n

    uu uuu uu

    T u t u t dt u t dt

    dtdtdt f f f f dt b f O d dtff f ff tdtf F F

    ! *

    !

    11,

    2b F ! !

    It is easier to generalize to higher order RK in this case when there is no explicit time dependence in f

  • 8/3/2019 Numerical Methods 4 PDE

    27/44

    CAAM 452 Spring 2005

    Second Example Runge-Kutta:

    Heuns Third Order Formula

    Traditional version In terms of intermediatevariables:

    1

    ,

    ,3 3

    2 2,

    3 3

    13

    4

    n n

    n n

    n n

    n n

    a dtf u t

    a dtb dtf u t

    b dtc dtf u t

    u u a c

    !

    !

    !

    !

    1

    2 1 1/3

    1 2 2 /3

    , 3

    2,

    3

    1

    , 3 ,4

    n n n

    n n

    n n n n n

    dt

    u u f u t

    dtu u f u t

    u u f u t f u t

    !

    !

    !

    This is a 3rd order, 3 stage single step explicit Runge-Kutta method.

  • 8/3/2019 Numerical Methods 4 PDE

    28/44

    CAAM 452 Spring 2005

    1

    2

    1

    2 3

    3

    2

    3 3

    234 3 3

    23 1 1

    4 3 3

    1 2 3

    n n

    n n n

    n n n n n n

    n n

    n

    dtu u u

    dt dt u u u u

    dt dt dt u u u u u u

    dt dt dt u u

    dt dt

    dt u

    Q

    Q Q

    Q Q Q Q

    Q Q Q Q

    Q Q

    Q

    !

    !

    !

    !

    !

    Again Lets Check the Stability Region

    1

    2 1 1/3

    1 2 2 /3

    ,3

    2,

    3

    1, 3 ,

    4

    n n n

    n n

    n n n n n

    dtu u f u t

    dtu u f u t

    u u f u t f u t

    !

    !

    !

    With f=mu*u reduces to a

    single level recursion with avery familiar multiplier:

  • 8/3/2019 Numerical Methods 4 PDE

    29/44

    CAAM 452 Spring 2005

    Stability of Heuns 3rd Order Method

    Each marginally stable mu*dt is such that themultiplier is of magnitude 1, i.e.

    This traces a curve in the nu=mu*dt complex plane.

    Since we are short on time we can plot this using

    Matlabs roots function

    2 3

    1 2 6

    i

    eUR R

    R !

  • 8/3/2019 Numerical Methods 4 PDE

    30/44

    CAAM 452 Spring 2005

    Stability Region for RK (s=p)

    rk2

    rk3

    rk4

  • 8/3/2019 Numerical Methods 4 PDE

    31/44

    CAAM 452 Spring 2005

    This time we consider points on the imaginary axiswhich are close to the origin:

    And this is bounded above by 1 if

    Heuns Method and The Imaginary Axis

    22 3

    2 22 3

    4 6

    12 6

    12 6

    112 36

    i

    i i

    R E

    E EE

    E EE

    E E

    !

    !

    !

    3 1.73E e $

    rk3

  • 8/3/2019 Numerical Methods 4 PDE

    32/44

    CAAM 452 Spring 2005

    Observation on RK linear stability

    For the sth order, s stage RKwe see that the stability regiongrows with increasing s:

    Consequently we can take alarger time step (dt) as theorder of the RK scheme

    increase.

    On the down side, we requiremore evaluations off

  • 8/3/2019 Numerical Methods 4 PDE

    33/44

    CAAM 452 Spring 2005

    Popular 4th Order Runge-Kutta Formula

    Four stages:

    1/ 2

    1/ 2

    1

    1

    ,

    / 2,

    / 2,

    ,

    1 2 26

    n n

    n n

    n n

    n n

    n n

    a dtf u t

    b dtf u a t

    c dtf u b t

    d dtf u c t

    u u a b c d

    !

    !

    !

    !

    !

    see: http://web.comlab.ox.ac.uk/oucl/work/nick.trefethen/1all.pdf p76 for details

    of minimum number of stages to achieve pth order.

  • 8/3/2019 Numerical Methods 4 PDE

    34/44

    CAAM 452 Spring 2005

    Imaginary Axis (again)

    With the obvious multiplier we obtain:

    For stability we require:

    22 3 4

    22 3 4 6 8

    2

    12 6 24

    1 12 6 24 72 24

    i

    i i

    R E

    R R RR

    E E E E EE

    !

    !

    !

    6 82

    28 i.e. 2 2 2.83

    72 24

    E EE Eu u e $

    rk4

  • 8/3/2019 Numerical Methods 4 PDE

    35/44

    CAAM 452 Spring 2005

    Imaginary Axis Stability Summary

    2.83 for the 4th Order Runge-Kutta method

    1.73 for Heuns 3rd Order Method

    0 for modified Euler

  • 8/3/2019 Numerical Methods 4 PDE

    36/44

    CAAM 452 Spring 2005

    Bounding the Global Error in Terms of the

    Local Truncation Error

    Theorem: Consider the general one-step method

    and we assume that Phi is Lipschitz continuouswith respect to the first argument (with constant )

    i.e. for

    Then assuming it follows that

    1 , ;n n n nu u dt u t dt ! *

    L*

    _ a

    0 max 0, , , , : ,

    we have:

    , ; , ;

    u t v t D u t t t t u u C

    u t dt v t dt L u v*

    ! e e e

    * * e

    0 1,2,..,nu t u t C n N e !

    00 1

    1 , 0,1,..., where maxn L t t

    n n nn N

    Tu u t e n N T T

    L

    *

    e e *

    e ! !

  • 8/3/2019 Numerical Methods 4 PDE

    37/44

    CAAM 452 Spring 2005

    cont

    Proof: we use the definition of the local truncationerror:

    to construct the error equation:

    we use the Lipschitz continuity of Phi:

    tidying:

    ,n n n n nT u t dt u t dt u t t ! *

    1 1 , ,n n n n n n n n nu t u u t u dt u t t u t T ! * *

    1 1n n n n n n n

    u t u u t u dtL u t u T * e

    1 1 1n n n n nu t u dtL u t u T * e

  • 8/3/2019 Numerical Methods 4 PDE

    38/44

    CAAM 452 Spring 2005

    proofcont

    _ a

    _ a

    _ a

    1 1

    1 1 1

    1

    0 0

    0

    0

    1

    1 10

    1 1

    1

    1 1

    1 1

    1

    1 1max 1 max

    1 1

    1 1 1

    n n n n n

    n n n n

    m nn m

    n m

    m

    m nm

    n m

    m

    nm nm

    m m

    m m nm

    n n dtL

    u t u dtL u t u T dtL dtL u t u T T

    dtL u t u T dtL

    T dtL

    dtLT dtL T

    dtLT T

    dtL edtL dtL

    *

    *

    * *

    !

    * *

    !

    !

    *!

    !*

    *

    e e e e! *

    *

    * *

    e

    e

    e

    e

    e !

    e e

    e

    1 0 1n L t t T

    e

    dtL

    *

    *

  • 8/3/2019 Numerical Methods 4 PDE

    39/44

    CAAM 452 Spring 2005

    proof summary

    We now have the global error estimate:

    Broadly speaking this implies that if the local truncation error

    is h^{p+1} then the error at a given time step will scale as

    O(h^p):

    Convergence follows under restrictions on the ODE which

    guarantee existance of a unique C1 solution and stable

    choice of dt.

    1 01 1 1n L t t n nT

    u t u edtL

    *

    *

    e

    1 1p

    n nu t u O h e

  • 8/3/2019 Numerical Methods 4 PDE

    40/44

    CAAM 452 Spring 2005

    Warning About Global Error Estimate

    It should be noted that the error estimate is ofalmost zero practical use.

    In the full convergence analysis we pick a final time

    tand we will see that exponential term again.

    Convergence is guaranteed but the constant canbe extraordinarily large for finite time:

    1 0

    1 11n

    L t t

    n n

    Tu t u e

    dtL

    *

    *

    e

    01

    1 L t t

    eL

    *

    *

  • 8/3/2019 Numerical Methods 4 PDE

    41/44

    CAAM 452 Spring 2005

    A Posteriori Error Estimate

    There are examples of RK methods which haveembedded lower order schemes.

    i.e. after one full RK time step, for some versions itis possible to use a second set of coefficients to

    reconstruct a lower order approximation. Thus we can compute the difference between the

    two different approximations to estimate the localtruncation error committed over the time step.

    google: runge kutta embedded

    Numerical recipes in C:

    http://www.library.cornell.edu/nr/bookcpdf/c16-2.pdf

  • 8/3/2019 Numerical Methods 4 PDE

    42/44

    CAAM 452 Spring 2005

    My Favorite s Stage

    Runge-Kutta Method

    There is an s stage Runge-Kutta method ofparticular simplicity due to Jameson-Schmidt-

    Turkel, which is of interest when there is no explicit

    time dependence forf

    1

    for m=0:s-1

    end

    n

    n

    n

    u u

    dt

    u u f us m

    u u

    !

    !

    !

  • 8/3/2019 Numerical Methods 4 PDE

    43/44

    CAAM 452 Spring 2005

    RK v. AB

    When should we use RK and when should we useAB?

    rk2

    rk3

    rk4

  • 8/3/2019 Numerical Methods 4 PDE

    44/44

    CAAM 452 S i 2005

    Class Cancelled on 02/17/05

    There will be no class on Thursday 02/17/05

    The homework due for that class will be due the

    following Thursday 02/24/05