Scenario
Playback
Physics and display
Camera
Quality
Model check
The science
What is simulated
Every body attracts every other body with Newton's law of gravitation. With softening eps the acceleration of body i is
a_i = G ∑j mj (rj − ri) / (|rj − ri|² + eps²)3/2.
Softening removes the singularity at zero distance; it is a modelling choice (it also stands in for the finite size of stars) and it slightly weakens close encounters.
Total energy is E = ∑ m v²/2 − G ∑i<j mi mj / sqrt(r² + eps²), angular momentum is L = ∑ m r × v.
Integrators
Leapfrog (kick-drift-kick) is symplectic: its energy error oscillates but does not grow, so orbits stay closed for millions of steps. RK4 is much more accurate per step but not symplectic, so energy slowly drifts. Explicit Euler is first order and spirals outward: switch to it and watch the red energy curve climb. Time steps: planets use 0.0016 yr (~0.6 day), the Pythagorean problem uses an adaptive step dt = 0.02 minij sqrt(r³/(G(mi+mj))), which is accurate but no longer strictly symplectic.
Force algorithms
Direct sum evaluates all pairs, O(N²). Barnes-Hut builds an octree and replaces a distant cell of width w at distance d by its centre of mass whenever w/d < theta, giving O(N log N) at a force error of about 1 % for theta = 0.6 (measured below). In the solar scenarios the asteroids are massless test particles that feel only the massive bodies, so no tree is needed.
Scenarios and data
- Solar System: Sun and eight planets from the JPL J2000 mean orbital elements (a, e, i, L, varpi, Omega) with real mass ratios, G = 4π² AU³/(Msun yr²). Body sizes are enlarged (the real Sun would be 0.5 px at this scale) and Earth and the Moon are one body.
- Kirkwood gaps: Sun, Jupiter, Saturn and thousands of asteroids. Jupiter's mean-motion resonances (a = aJ (1/q)2/3: 4:1 at 2.06 AU, 3:1 at 2.50, 5:2 at 2.82, 7:3 at 2.95, 2:1 at 3.28) pump the eccentricity of resonant asteroids, so the semi-major-axis histogram develops gaps. Real gaps need ~104–106 years; at the highest time rate you reach the first thousands in about a minute.
- Figure-eight: three equal masses on one curve, Chenciner & Montgomery (2000), initial data to 8 digits, period T = 6.3259 for G = m = 1.
- Pythagorean 3-body: Burrau (1913), masses 3-4-5 at rest on a 3-4-5 triangle. Chaotic: tiny changes in dt or eps give a different ending.
- Galaxy and collision: stars as softened point masses around a heavy bulge, kpc / km s-1 / 1010 Msun units, G = 43009 kpc (km/s)²/(1010 Msun), 1 time unit = 0.978 Gyr. Initial speed
v = sqrt(G M(<r) / r)with a little dispersion. There is no gas, no dark halo and few stars (N is 103, a real galaxy has 1011), so tails and arms are qualitatively right, not quantitative. - Plummer cluster: equal masses with density
ρ(r) ∝ (1 + r²/a²)-5/2in virial equilibrium (2K/|U| = 1), N-body units G = M = 1.
What to try
- Kirkwood gaps: set the time rate to maximum and read the histogram for dips at the orange 3:1 and 5:2 markers.
- Switch the integrator to Euler on the solar system and compare the energy curve with leapfrog.
- Fire a rogue star at the solar system, the figure-eight or the cluster and see how each responds.
- Figure-eight: raise softening above 0.05 and watch the dance break.
- Galaxy collision: follow "Galaxy 1 core" and compare face-on and edge-on views.
- Switch Barnes-Hut to direct sum and compare dE/E and speed.
Known simplifications
Newtonian gravity only (no relativity: Mercury's perihelion advance is missing), no collisions or mergers, no gas physics, no dark matter. The time rate is capped by your CPU; the readout says "CPU-limited" when it is. Displayed sizes of planets and asteroids are exaggerated. Not affiliated with any observatory or agency.