Iris — Laboratory

Bodies 0
Energy 0.0
Time 0.0s
FPS 60
Next mass 10
Type Planet
Click to place · Drag to set velocity · Scroll to adjust mass
Preset:
Next mass 10
Speed 1.0x
Trail length 200

What you're seeing

An N-body gravitational simulator where every body attracts every other body according to Newton's law of universal gravitation. There is no central force, no fixed orbits — just N(N−1)/2 pairwise interactions computed each frame. The integration uses the velocity Verlet method, a symplectic integrator that conserves energy far better than Euler stepping.

Collisions and mergers

When two bodies overlap, they merge into one. The new body conserves linear momentum: its velocity is the momentum-weighted average of its parents. Its mass is the sum of both. This is a simplified model of what happens in protoplanetary disks, where planetesimals collide and accrete into planets over millions of years. In this simulation it happens in seconds.

Building a solar system

Place a massive star at the center, then fling smaller bodies into orbit around it. The trick is getting the velocity just right — too slow and the planet falls inward, too fast and it escapes to infinity. The circular orbit velocity at distance r from a mass M is v = √(GM/r). Drag perpendicular to the line between your planet and the star, and aim for that sweet spot. Real solar systems formed from a collapsing gas cloud; the angular momentum of the original cloud is why everything orbits in roughly the same plane.

The figure-eight

The figure-eight preset loads the Chenciner-Montgomery solution: three equal masses chasing each other around a single figure-eight-shaped curve. Discovered numerically by Cristopher Moore in 1993 and proved rigorously in 2000, it is periodic, beautiful, and exquisitely unstable. Numerical noise will unravel it eventually — watch how long it lasts.

Gravitational softening

When two bodies pass very close, the force diverges toward infinity. To prevent numerical explosions, a small softening parameter ε is added: F = G m₁m₂ / (r² + ε²). This caps the maximum force at close approach. Every astrophysical N-body code uses some version of this trick. It is physically wrong but computationally necessary.

Energy

The info panel tracks total energy: kinetic (½mv² for each body) plus gravitational potential (−Gm₁m₂/r for each pair). In a perfect simulation, total energy is conserved. In practice, numerical integration introduces drift. The velocity Verlet integrator keeps this drift small, which is why it is the workhorse of molecular dynamics and astrophysical simulation. If you see energy climbing steadily, the system is becoming numerically unstable — usually from close approaches that the softening cannot fully tame.