verlet algoritma.pdf

15
What is the step error in the leapfrog algorithm? Might expect: Actually: Can be easily seen in a different derivation The Verlet algorithm Start from two Taylor expansions: Adding these gives the so-called Verlet algorithm Velocity defined by: Same as leapfrog, since

Upload: dwi-nurcahyo

Post on 28-Apr-2015

97 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: verlet algoritma.pdf

What is the step error in the leapfrog algorithm?   Might expect:   Actually:   Can be easily seen in a different derivation

The Verlet algorithm Start from two Taylor expansions:

Adding these gives the so-called Verlet algorithm

Velocity defined by:

Same as leapfrog, since

Page 2: verlet algoritma.pdf

Properties of Verlet/leapfrog algorithm   Time reversal symmetry (check for round-off errors)   Errors bounded for periodic motion (time-reversal)   High accuracy with little computational effort

Illustration: Harmonic oscillator (k=m=1),

do i=1,nt t=dt*(i-1) a=acc(x,t) v=v+dt*a x=x+dt*v enddo

Code almost identical to Euler (swicth 2lines!)

Remember, initialize v at the half-step -dt/2!

Page 3: verlet algoritma.pdf

Third equivalent form: velocity Verlet Original Verlet formula:

Add xn+1 on both sides of this equation

Define velocity using two time steps:

Gives equation for xn+1:

Vrite original Verlet for xn :

Add to Verlet formula for xn+1 gives

Gives equation for vn:

Page 4: verlet algoritma.pdf

Three equivalent Verlet/leapfrog methods

Verlet:

Velocity Verlet:

Leapfrog:

Page 5: verlet algoritma.pdf

Error build-up in Verlet/leapfrog method

Difference between numerical and exact solution:

Inserting this in Verlet equation

Error in x after N steps;

Discretized second derivative:

The equation of motion for the error is thus:

gives

Page 6: verlet algoritma.pdf

Exact solution satisfies: We are thus left with: Integrate to obtain error after time T:

Worst case: no error cancellations (same sign for all n):

Assume smoothness on scale of time-step, use continuum derivative (imagine a high-order interpolating polynomial between points)

Page 7: verlet algoritma.pdf

Verlet/leapfrog methods for damped systems We assumed velocity-independent forces in leapfrog method;

With velocity dependent we need vn but have only vn+1/2

To study this problem, separate damping from rest of force

Consider approximation:

The error made in a is which gives x-error We can do a second step using This renders the error in x

Page 8: verlet algoritma.pdf

Summary; leapfrog algorithm with damping:

Requires more work than standard leapfrog:

(vn used here in an)

Page 9: verlet algoritma.pdf

Special case; linear damping: Simpler algorithm can be constructed starting from Verlet form

Identify velocity vn+1/2 using

Page 10: verlet algoritma.pdf

Runge-Kutta method

Consider first single first-order equation:

Classic high-order scheme; error (4th order)

Warm-up: 2nd order Runge-Kutta

Use mid-point rule:

But we don’t know

Approximate it using Euler formula;

Sufficient accuracy for formula:

Page 11: verlet algoritma.pdf

4th-order Runga-Kutta (the real thing)

Uses Simpson’s formula:

Need to find approximations for Somewhat obscure scheme accomplishes this (can be proven correct using Taylor expansion)

Page 12: verlet algoritma.pdf

Runge-Kutta for two coupled equations

Page 13: verlet algoritma.pdf

Equations of motion, Runge-Kutta algorithm

Including damping is no problem here

Page 14: verlet algoritma.pdf

The RK method does not have time-reversal symmetry   Errors not bounded for periodic motion   Time-reversibility important in some applications

Advantages of RK relative to leapfrog:  Variable time-step can be used (uses only n-data for n+1)   Better error scaling (but more computations for each step)

harmonic oscillator (k=m=1)

Page 15: verlet algoritma.pdf

What algorithm to use? Recommendation

In the case of energy-conserving systems (no damping or external driving forces) •  Use the Verlet/leapfrog algorithm - good energy-conserving property (no divergence)

In the case of non-energy-conserving systems (including damping and/or external driving forces) •  Energy is not conserved, so no advantage for Verlet •  Use the Runge-Kutta algorithm - smaller discretization error for given integration time T