Code for verlet frog leap method.

  • Thread starter Thread starter MathematicalPhysicist
  • Start date Start date
  • Tags Tags
    Code Method
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
9 replies · 11K views
Messages
4,662
Reaction score
372
im searching for a C code for verlet leap method, i.e a one the advances the system of particles with acceleration,velocities,displacements.

anyone knows where may i find such a code?

thanks in advance.
 
Physics news on Phys.org
too lazy to code yourself?
 
neurocomp2003 said:
too lazy to code yourself?

Now, now, take it easy. I'd love to help, but I have no idea of what a verlet leap method is. Anyone? :blushing:
 
its known also plainly as the leapfrog method which gives more hits for a search than verlet.

Basically you have some timestep dt...each halfstep you update v and each fullstep you update x. (you might also beable to update v each fullstep).

t=0 => initial cfg
t+0.5dt=> update v
t+1.0dt=> update x
t+1.5dt=> update v
etc.
 
Useful link, with both the pseudocode and additional info:

http://artcompsci.org/kali/vol/two_body_problem_2/ch01.html

[edit]: More general versions ('higher order leapfrog') are also available. fourth-, sixth- and eighth-order leapfrog methods are available online, all of which are (naturally) symplectic. Do a search for 'Yoshida integrator', that should turn up some useful results.
 
Last edited by a moderator:
The staggered leapfrog method is described in Numerical Recipes in C in chapter 19 (Partial Differential Equations) section 1 (Flux-Conservative Initial Value Problems) on the bottom half of page 842: http://www.nrbook.com/a/bookcpdf/c19-1.pdf