2013lectures 8a odes

Upload: wuckwcuk

Post on 03-Jun-2018

237 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 2013Lectures 8a ODEs

    1/17

    Ordinary Differential Equations

    =

    + + =

    = + + =

    2

    2

    2

    Example falling brick

    1/ 2

    Order since highest derivative is

    Spring mass damper

    0

    Order

    Set of 1st order ODEs

    , 0

    dv Kg vdt m

    d x dx m c Kx

    dt dt

    dx dv v m cv Kx

    dt dt

  • 8/12/2019 2013Lectures 8a ODEs

    2/17

    Sets of ODEs

    So ODE problems can be reduced to a set of N first-order

    ODEs

    Not completely specified needs boundary conditions initial value problems

    boundary value problems

    Niyyyxfdx

    xdyNi

    i ,...,1),...,,()(

    21 == equationsfor

  • 8/12/2019 2013Lectures 8a ODEs

    3/17

    General Procedure

    Re-write the dyand dxterms as yand x and multiply

    by x

    Literally doing this is Eulers method

    Niyyyxfdx

    xdyNi

    i ,...,1),...,,()(

    21 == equationsfor

    xyxfyy

    yxfx

    xy

    yxf

    dx

    xdy

    iiii +=

    =

    =

    + ),(

    ),()(

    ),()(

    1

  • 8/12/2019 2013Lectures 8a ODEs

    4/17

    Tank mixing problem

    ( )

    ( ) tccV

    Vcc

    tccV

    V

    dt

    tdc

    iinin

    ii

    inin

    +=

    =

    +

    tank

    tank

    &

    &

    1

    )()(

  • 8/12/2019 2013Lectures 8a ODEs

    5/17

    Mixing tank

    0.0185

    0.05515

    0.391000.1950

    0.61150

    1.4300

    0.0113

    0.03610

    0.1130

    Error Et

    at t=600

    t

  • 8/12/2019 2013Lectures 8a ODEs

    6/17

    Quantify the error

    ( ) ( )

    order?iserrorSo

    oncentredforseriesTaylorWrite

    ...6

    )(

    2

    )()()()(

    321

    1

    +

    +

    ++=+

    +

    ttc

    ttc

    ttctctc

    cc

    iiiii

    ii

  • 8/12/2019 2013Lectures 8a ODEs

    7/17

    Not quite accumulation of errors

    ( )

    ( ) Ntc

    t

    tc

    EEEEE

    N

    i

    Ntotal

    2

    2

    321

    2

    2

    )(

    ...

    =

    ++++=

    errordaccumulatetotalsoerror,thishasstepeachBut

    order1stwaserrorthethatbeforesawWe

  • 8/12/2019 2013Lectures 8a ODEs

    8/17

    Euler Error

    Local error

    lk=yk-y*k-1(tk)

    Global error

    ek=yk-y(tk)

    y

    t

  • 8/12/2019 2013Lectures 8a ODEs

    9/17

    Euler Stability (1)

    0

    1

    0

    ( )

    Euler

    (1 )

    So that

    (1 )

    x

    i i i

    i

    k

    k

    dyy y x y e

    dx

    y y y x

    y x

    y y x

    +

    = =

    = +

    = +

    = +

  • 8/12/2019 2013Lectures 8a ODEs

    10/17

    Euler Stability (2)

    0 0Real solution ( ) Euler (1 )

    For negative

    If small

    If big

    x k

    k

    dyy y x y e y y x

    dx

    x

    x

    = = = +

  • 8/12/2019 2013Lectures 8a ODEs

    11/17

    In terms of integration

    dxyxfxyxxy

    dxyxfxyxxy

    dxyxfdxdx

    dy

    xxx

    yxf

    dx

    dy

    xx

    x

    xx

    x

    xx

    x

    xx

    x

    +

    +

    ++

    +=+

    =+

    =

    +

    =

    ),()()(

    ),()()(

    ),(

    ),(

    fromsidesbothIntegrate

  • 8/12/2019 2013Lectures 8a ODEs

    12/17

    Runge-Kutta

    slope)a(akafunctionincrementis

    formGeneral

    integraltheevaluatetoquadratureGaussianuseOr

    betweenlocationsatevaluatedfofvaluesonbased

    integralforfitl)(polynomiaorderhigheruseCould

    hyy

    hxx

    dxyxfxyhxyyxfdx

    dy

    ii

    hx

    x

    +=

    +

    +=+=

    +

    +

    1

    ),()()(),(

  • 8/12/2019 2013Lectures 8a ODEs

    13/17

    R-K General form

    )...,(

    ),(

    ),(

    ),(

    ,,,

    11,122,111,11

    22212123

    11112

    1

    21

    2211

    1

    hkqhkqhkqyhpxfk

    hkqhkqyhpxfk

    hkqyhpxfk

    yxfk

    aaa

    where

    kakaka

    hyy

    nnnnninin

    ii

    ii

    ii

    n

    nn

    ii

    +

    +++++=

    +++=

    ++=

    =

    +++=

    +=

    M

    K

    K

    constants

    :asWrite

    formGeneral

  • 8/12/2019 2013Lectures 8a ODEs

    14/17

    R-K 1st Order Form

    ( ) hyxfyy

    yxfka

    ka

    hyy

    iiii

    ii

    ii

    ),(1

    ),(constant1

    where

    formGeneral

    1

    1

    1

    11

    1

    +=

    =

    =

    =

    +=

    +

    +

  • 8/12/2019 2013Lectures 8a ODEs

    15/17

    RK 4th Order( )

    ),(

    )2

    1,2

    1(

    )2

    1,

    2

    1(

    ),(

    226

    1

    34

    23

    12

    1

    43211

    hkyhxfk

    hkyhxfk

    hkyhxfk

    yxfk

    hkkkkyy

    ii

    ii

    ii

    ii

    ii

    ++=

    ++=

    ++=

    =

    ++++=+y(x)

    xi xi+1 x

  • 8/12/2019 2013Lectures 8a ODEs

    16/17

    RK4 if f(x,y)=f(x)

    ( )

    ( )hhxfhxfxf

    hkkkkdxxf

    dxxfyyxfdx

    dy

    xfyf

    iii

    hx

    x

    hx

    xii

    )()2/(4)(6

    1

    226

    1)(

    )()(

    )(),(

    4321

    1

    ++++=

    +++=

    +==

    =

    +

    +

    +

    hasRK4

    If

  • 8/12/2019 2013Lectures 8a ODEs

    17/17

    Example y=x+y, y(0)=0

    4.3896.3935.7155.6545.0503.2501.8

    3.2505.0524.4984.4483.9532.3531.6

    2.3533.9553.5013.4613.0551.6551.4

    1.6553.0572.6852.6522.3201.1201.2

    1.1202.3222.0171.9901.7180.7181

    0.7181.7201.4701.4481.2260.4260.8

    0.42551.2271.0231.0040.8220.2220.6

    0.22210.8230.6560.6410.4920.0920.4

    0.09180.4930.3560.3440.2210.02140.2

    0.021400.2220.110.1000

    yn=y+1/6(k

    1+2k

    2+2k

    3+k

    4)hk

    4=f(x+h,y+hk

    3)k

    3=f(x+h/2,y+h/2k

    2)k

    2=f(x+h/2,y+h/2k

    1)k

    1=f(x,y)yx

    0

    0.5

    1

    1.5

    2

    2.5

    3

    3.5

    0 0.5 1 1.5 2

    x

    y

    Euler

    analytical

    RK4