Enhanced Integration Algorithms: Leapfrog Method & Hard Sphere Repulsion, Papers of Physics

Advanced integration algorithms for solving newton's laws of motion for multiple interacting particles using the leapfrog method. The limitations of the euler method, the derivation of the leapfrog algorithm, and its implementation for simulating hard sphere repulsion. The document also includes python code examples.

Typology: Papers

Pre 2010

Uploaded on 08/09/2009

koofers-user-q40
koofers-user-q40 🇺🇸

10 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lec2
dt errors. Leapfrog algorithm
Many particles - balls in boxes
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Enhanced Integration Algorithms: Leapfrog Method & Hard Sphere Repulsion and more Papers Physics in PDF only on Docsity!

Lec

  • dt errors. Leapfrog algorithm
  • Many particles - balls in boxes

Recap week 1

  • Discussed (simplest) method for solving New- ton’s laws for motion of single particle un- der external force
  • Write as two first order equations:

dr dt

= v dv dt

m

F

  • Use Euler algorithm to evolve (update) in discrete time
  • Harmonic oscillators (1,2 dims), projectiles
  • Discussed python code to implement this algorithm

More accurate integrators

Using Taylor ....

x(t + dt) = x(t) + v(t)dt + a(t)dt^2 /2 + O(dt^3 )

leading to

xn+1 = xn + vndt + andt^2 / 2

Subtracting x(t − dt) from x(t + dt) find

v(t) = x(t + dt) − x(t − dt) + O(dt^3 )

leading to

vn+1 = xn+2 − xn 2 dt Substiting for xn+2 using previous equation:

vn+1 = vn + dt 2

(an + an+1)

leapfrog algorithm Accurate to O(dt^2 )

Leapfrog errors

Almost as simple to implement in code.

  • Compute and store new variable oldforce to keep initial acceleration.
  • force() function same as before.
  • See much smaller errors in energy. Consis- tent with ∆ EE ∼ dt^2

Newton’s 2nd law

If many mutually interacting particles:

Fa =

∑ b

Fab

where label b runs over all particles in system

dxa dt

= va dva dt

= Fa/ma

Get a pair of (vector) equations for each parti- cle. Simulating system requires summing over all particles.

Example - balls in box

  • Consider a force of form

Fab = Ae −

(ra−r r 0 b

) 2

n

  • n is unit vector from ballb to balla.
  • Take r0 to be 1/10 radius of ball say. Sim- ulates hard sphere repulsion.
  • Take dt <

√ b/A. Stable integration.

More for loops

To carry out a sum over all balls use for com- mand eg.

for ball in system: ball.pos=ball.pos+ball.vel*dt+...

  • Note indentation – all statements at same level are executed before passing to next element of list
  • Note give each ball a position, velocity and (2) accelerations.
  • Use leapfrog to update.
  • Add elastic force for walls of container - reverse velocity if hits wall.

Integrate module

  • Change force function to newforce. Latter is passed the labels to two individual balls and computes mutual force vector.
  • Function totalforce gets total force on a single ball.

Summary

  • Discussed improved interation algorithms
  • Developed code to study multiparticle sys- tems – here hard spheres
  • Hard sphere replusion leads to chaotic tra- jectories