Skip to content
Lab
n-body workbench symplectic integration · conservation · orbital mechanics

Cosmic Forge

How far does Newtonian gravity alone take you? Nine systems built from real data (the inner Solar System, the figure-eight three-body orbit, Jupiter's Trojans, Kepler-16, a gravity assist, the S-stars around Sgr A*, a planetesimal disk and more) run under four integrators, and the lab measures how well energy and angular momentum are conserved and how far each orbit drifts from its Kepler prediction. Click or drag in empty space to throw in your own bodies and watch collisions, mergers and mass-based classification.

t 0.000 yr N 0 Δt — RUNNING
Orbital plane selected osculating ellipse Kepler at t₀ launch preview barycentric frame
bodies (massive)—
total energy E—
|ΔE/E₀| incl. ledger—
|ΔL/L₀|—
mergers · ejected—
merger ledger ΔE—
largest body—
Conservation telemetry vs. time with merger/escape ledger raw (bodies only) selected r(t) Kepler q, Q
Orbit inspector — — host —
Elementnow · osculatingt₀ · Keplerdrift
Semi-major axis a — — —
Eccentricity e — — —
Period (Kepler) T — — —
Period (measured) peri → peri — — —
Periapsis q — — —
Apoapsis Q — — —
Arg. of periapsis ω — — —
Speed |v| — — —
Specific energy ε — — —
Jacobi constant CJ — — —
mass
—
radius (physical)
—
collision radius
—
luminosity
—
Teff · type
—
main-seq. lifetime
—
merger spin S
—
t₀ (selected at)
—
Integrator study queued

Same initial state, collisions off, heaviest 16 bodies. Right: max |ΔE/E| against total force evaluations for Δt × 4, 2, 1, ½, ¼ — the slope is the order of the method. Hollow: run hit the step cap.

Equations of motion

r̈i = −G Σj≠i mj (ri − rj) / (|rij|2 + ε2)3/2

E = Σ ½mivi2 − G Σi<j mimj / √(rij2 + ε2)

Units AU, yr, M☉, so G = 4π². Plummer softening ε; test particles (m = 0) feel but exert no force. Barnes–Hut: a quadtree cell of size s at distance d is used as one mass when s/d < θ. Adaptive mode shrinks Δt to η times the shortest pairwise dynamical time.

Integrators

KDK v½ = v + ½aΔt, x′ = x + v½Δt, v′ = v½ + ½a(x′)Δt

Y4 KDK(w1Δt) ∘ KDK(w0Δt) ∘ KDK(w1Δt), w1 = 1/(2 − ∛2), w0 = −∛2·w1

Symplectic maps exactly conserve a nearby "shadow" Hamiltonian, so their energy error oscillates but does not grow. Forward Euler and classical RK4 are not symplectic: their error accumulates. With an adaptive step leapfrog loses that guarantee.

Contact & classification

Merger: M = m1 + m2, P and centre of mass kept, orbital L about the pair → spin S, ΔE → ledger.

Classes by mass: 10 M⊕ (critical core), 13 M♃ (deuterium burning), 0.075 M☉ (hydrogen burning), 8 M☉ (core collapse), 150 M☉ (observed upper limit). Main sequence: R ∝ M0.8 / M0.57, piecewise L ∝ M2.3…4, Teff from L = 4πR²σT⁴, τ ≈ 10 Gyr·M/L. Black holes merge at 2rs.

Avg. step cost — µs (this browser).

What is modelled

What is actually computed

Newtonian gravity is summed over every pair (or a Barnes–Hut tree) and integrated with a fixed or adaptive step. Leapfrog and Yoshida-4 are symplectic, so their energy error oscillates instead of growing; Euler and RK4 accumulate it. The integrator study re-solves the same initial state in a Web Worker at five step sizes and measures each method's order of convergence. Mergers conserve mass, momentum and the centre of mass exactly, move orbital angular momentum into the remnant's spin, and book the lost energy (and whatever escaping bodies carry away) in a ledger, so the conservation plots stay honest.

units
AU · yr · M☉
G
4π²
integrators
4
scenarios
9
Honest scope

What is simplified

Every orbit lies in one plane (real inclinations are dropped) and there is no general relativity, so Mercury's relativistic 43″ per century and S2's Schwarzschild precession are not reproduced. The planetesimal disk and stellar forge inflate collision radii by hundreds to compress growth, and treat every contact as a perfectly inelastic merger: no gas, tides or fragmentation. Classes follow mass limits (13 M♃, 0.075 M☉, …) and main-sequence relations; stars never turn into black holes by merging. Real stellar evolution takes millions of years of nuclear burning.