DOC PREVIEW
UMD ASTR 415 - The Leapfrog Integrator

This preview shows page 1 out of 3 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Class 15. ODEs, Part 2The Leapfrog Integrator• Very useful for second-order DEs in which d2x/dt2= f(x), e.g., SHM, N-body, etc.– NOTE: Now dropping the prime (0) from f...• Suppose x is position, so d2x/dt2is acceleration.• Procedure: define v = dx/dt at the midpoints of the steps, i.e., velocities staggeredwrt positions.– Set vn+1/2= v(tn+12h).– Then advance xnto xn+1and vn+1/2to vn+3/2:xn+1= xn+ hvn+1/2,vn+3/2= vn+1/2+ hf(xn+1).x0x1x2v1/2v3/2v5/2t0t1/2t1t3/2t2t5/2• Complication: need to “jumpstart” and “resync”...vn+1/2= vn+ (h/2)f(xn) [opening “kick”: Euler]xn+1= xn+ hvn+1/2[“drift”]vn+1= vn+1/2+ (h/2)f(xn+1) [closing “kick”: resync]– Note vn+3/2= vn+1+ (h/2)f(xn+1) = vn+1/2+ hf(xn+1).• Also have “drift-kick-drift” (DKD) scheme.• Like midpoint method, Leapfrog is second order:x(t + h) = x(t) + hv(t + h/2),butv(t + h/2) = v(t) + (h/2)f(t) + O(h2).Thereforex(t + h) = x(t) + hv(t) + (h2/2)f(t) + O(h3).– This is formally equivalent to midpoint method.1• So why is L eapfro g so great?...• Answer: Leapfrog is time reversible.• Suppose we step back from (tn+1, xn+1, vn+3/2) to (tn, xn, vn+1/2). Applying the algo-rithm:vn+1/2= vn+3/2+ (−h)f(xn+1),xn= xn+1+ (−h)vn+1/2.• These are precisely the steps (in reverse) that we took to advance the system in thefirst place!• Hence if we Leapfrog forward in time, then reverse to t = 0, we’re back to where westarted, precisely.• Leapfrog is time reversible because of the symmetric way in which it is defined, unlikethe other schemes.– In Euler, fo rward and backward steps do not cancel since they use different deriva-tives at different times.– In Midpoint, the estimate of the derivative is based on an extrapolation from theleft-hand side of the interval. On time reversal, the estimate would be based onthe right-hand side, not the same.– Similarly, RK4 is not time reversible.• Time reversibility is importa nt because it guarantees conservation of energy, angularmomentum, etc. (in many cases).– Suppose the integrator makes an error ε after one orbital period. Now reverse.Is the error −ε? No! The time-reversed o r bit is a solution of the original ODE(with v replaced with −v), so the energy error is still +ε. But we’ve returned toour starting point, so we know the final energy error is zero. Hence ε = 0!• Leapfrog is only second order, but very stable.• Leapfrog is an example of a class of “ symplectic” integrato rs that conserve phase-spacevolume: exactly solves an approximate Hamiltonian system.H = HD+ HK+ Herr=12v2+ V (r) + Herr,or D(h/2)K(h)D(h/2), with Herr∼ O(h3). You can also construct the usual kick-drift-kick scheme, K(h/2)D(h)K(h/2), because the Hamiltonian is separable.2Adaptive Stepsize Control• Up to now, have assumed stepsize h is constant.• Clearly prefer choosing h small when |f0| is large, and h large when |f0| is small. (We’vereintroduced the prime (0) notation, just to be confusing...)• The tradeoff is extra trial steps to determine optimum h, but may achieve factor of 10to 100 increase in stepsize, so it’s often worth it.• NRiC provides a routine odeint() for RK4 with adapat ive stepsize control. Compli-cated to


View Full Document

UMD ASTR 415 - The Leapfrog Integrator

Download The Leapfrog Integrator
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view The Leapfrog Integrator and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view The Leapfrog Integrator 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?