e - physically based modeling, principles and practice - implicit methods for differential equations

Upload: felipe-soares-maia

Post on 03-Jun-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 E - Physically Based Modeling, Principles and Practice - Implicit Methods for Differential Equations

    1/5

    Physically Based Modeling: Principles and Practice

    Implicit Methods for Differential Equations

    David Baraff

    Robotics Institute

    Carnegie Mellon University

    Please note: This document is1997 by David Baraff. This chapter may be freely

    duplicated and distributed so long as no consideration is received in return, and this

    copyright notice remains intact.

  • 8/12/2019 E - Physically Based Modeling, Principles and Practice - Implicit Methods for Differential Equations

    2/5

    Implicit Methods for Differential Equations

    David BaraffRobotics Institute

    Carnegie Mellon University

    1 Implicit Methods

    The methods we have looked at for solving differential equations in the first section of these notes

    (e.g. Eulers method, the midpoint method) are all called explicit methods for solving ODEs.

    However, sometimes an ODE can become stiff, in which case explicit methods dont do a very

    good job of solving them. Whenever possible, it is desirable to change your problem formulation so

    that you dont have to solve a stiff ODE. Sometimes however thats not possible, and you have justhave to be able to solve stiff ODEs. If thats the case, youll usually have to use an ODE solution

    method which is implicit.

    1.1 Example Stiff ODE

    First, what is the meaning and cause of stiff equations? Lets consider an example that arises fre-

    quently in dynamics. Suppose that we have a particle, with position(x(t),y(t)), and suppose that

    we want the y-coordinate to always be zero. One way of doing this is to add a componentky(t)

    to y(t)wherekis a large positive constant. Ifkis large enough, then the particle will never move

    too far away fromy(t)= 0, since theky(t)term always bringsy(t)back towards zero. However,

    lets assume that there is no restriction on thex-coordinate, and that we want a user to be able to pull

    the particle arbitrarily along thex-axis. So lets assume that over some time interval our differentialequation is simply

    Y(t) = d

    dt

    x(t)

    y(t)

    =

    x(t)

    ky(t)

    . (11)

    (Well also assume that the particle doesnt start exactly withy0 = 0.) Whats happening here is that

    the particle is strongly attracted to the line y = 0, and less strongly towardsx = 0. If we solve the

    ODE far enough forward in time, we expect the particles location to converge towards(0,0) and

    then stay there once it arrives.

    Nowsuppose we use Eulers method to solve the equation. If we take a step of sizeh,weget

    Ynew = Y0 + hY(t0) =

    x0y0

    + h

    x0ky0

    .

    This yields

    Ynew =

    x0 hx0y0 hky0

    =

    (1 h)x0(1 hk)y0

    .

    E1

  • 8/12/2019 E - Physically Based Modeling, Principles and Practice - Implicit Methods for Differential Equations

    3/5

  • 8/12/2019 E - Physically Based Modeling, Principles and Practice - Implicit Methods for Differential Equations

    4/5

    or

    Y h f(Y0)Y = h f(Y0)

    Rewriting this as

    1h I f

    (Y0)Y = f(Y0),

    whereI is the identity matrix, we can solve forYas

    Y =

    1

    hI f(Y0)

    1f(Y0) (13)

    ComputingYnew = Y0 +Yis clearly more work than using an explicit method, since we have

    to solve a linear system at each step. While this would seem a serious weakness, computationally

    speaking, dont despair (yet). For many types of problems, the matrix f will be sparsefor exam-

    ple, if we are simulating a spring-lattice, f will have a structure which matches the connectivity

    of the particles. As a result, it is usually possible to solve equation (13) in linear time (i.e. time

    proportional to the dimension ofY). In such cases, the payoff is dramatic: we can usually takeconsiderably large timesteps without losing stability (i.e. without divergence, as happens with the

    explicit case if the stepsize is too large). The time taken in solving each linear system is thus more

    than offset by the fact that our timesteps are often orders of magnitude bigger than we could manage

    using an explicit method. (Of course, the code needed to do all this is much more complicated than

    in the explicit case; like we said, make your problems un-stiff if you can, and if not, pay the price.)

    Lets apply the implicit method to equation (11). We have that f(Y(t)) is

    f(Y(t)) =

    x(t)

    ky(t)

    .

    Differentiating with respect toY yields

    f(Y(t)) = Y

    f(Y(t)) = 1 0

    0 k

    Then the matrix 1h

    I f(Y0)is 1

    h+ 1 0

    0 1h+ k

    =

    1+h

    h 0

    0 1+khh

    Inverting this matrix, and multiplying by f(Y0)yields

    Y =

    1+h

    h 0

    0 1+khh

    1 x0ky0

    =

    hh+1

    0

    0 h1+kh

    x0ky0

    =

    h

    h+ 1x0

    h

    1+ khky0

    SIGGRAPH 97 COURSE N OTES E3 PHYSICALLY B ASED M ODELING

  • 8/12/2019 E - Physically Based Modeling, Principles and Practice - Implicit Methods for Differential Equations

    5/5

    What is the limit on the stepsize in this case? The answer is: there is no limit! In this case, if we

    leth grow to infinity, we get

    limh

    Y = limh

    h

    h+ 1x0

    h

    1+ kh ky0

    =

    x0

    1

    kky0

    =

    x0y0

    .

    This means that we achieveYnew = Y0 + (Y0) = 0in a single step! For a general stiff ODE, we

    wont be able to take steps of arbitrary size, but we will be able to take much larger steps using an

    implicit method than using an explicit method. The extra cost of solving a linear equation is more

    than made up by the time saved by taking large timesteps.

    SIGGRAPH 97 COURSE N OTES E4 PHYSICALLY B ASED M ODELING