N-body Dynamic Problems
newtonian_gravity.py -- Acceleration model for the N-body gravitational problem. Uses numpy arrays heavily, including very dangerous broadcasting rules.
nbody.tar.gz
-- All files in the example code which shows precession of the Mercury
perihelion due to the presence of Jupiter. Unpack the archive, make the
"perihelion_precession.py" file executable, and run it. How do you tell whether the results make sense?
Professional-grade calculation
of planetary orbits is performed by JPL using similar numerical
techniques. Inexact knowledge of planetary masses is the main source of
errors.
The "schoolbook" implementation of N-body dynamics results in an algorithm whose computational time scales as N2.
This doesn't look good for simulation of realistic systems (collections
of atoms and molecules, or groups of stars in galaxies). Fortunately,
certain problems in gravitation and electricity can be treated by Fast Multipole Methods whose running time scales as N log N.