Galaxy Collision Simulator, Explained

After reading this you will know how two colliding disk galaxies grow tidal tails and bridges, why a prograde pass throws long streamers while a retrograde pass barely stirs the disk, and how a restricted three-body model reproduces those shapes with nothing but gravity.

What the simulator does

Two spiral galaxies swing past each other, pull each other apart, and eventually merge into one blob. The simulator uses the trick Alar Toomre and Juri Toomre published in 1972. Only the two heavy cores actually attract each other. Every visible star is a massless test particle: it feels the gravity of both cores but exerts no force back and no force on other stars. That reduces a problem with thousands of interacting bodies to a two-body core orbit plus thousands of independent particle orbits.

The hook is the tidal tail. Start a disk of stars on circular orbits, send a second galaxy past on a matching sense of rotation, and within a few hundred million years of simulated time a thin curved streamer of stars flings out to several disk radii. A bridge of stars reaches across toward the companion at the same time. These are the shapes seen in the real Antennae and Mice galaxies, and they appear here with no gas, no dark matter halo detail, and no star-by-star forces.

The stars have zero mass in this model, so a "collision" never involves stars hitting stars. Real galaxies pass through each other almost transparently: the average distance between stars is so large that direct stellar collisions are essentially never seen. What tears the disks apart is the changing gravity field, not contact.

When this model helps and when it misleads

Use the restricted model to build intuition about encounter geometry. It answers questions like: does a closer pass make a longer tail? (Yes.) Does flipping one disk retrograde suppress the tail? (Strongly.) Does a larger companion pull harder? (Yes, linearly in its mass.) Those trends are robust because they come from the tidal force law, and that law survives in full simulations.

Do not read absolute predictions off it. The model has no gas, so it cannot form new stars, drive shocks, or funnel material to the center. It has no live dark matter halo, so it misses dynamical friction, the drag that makes real galaxies actually spiral together and merge rather than sail past forever. In this toy, two galaxies on an unbound orbit simply separate again. A true merger in nature needs that friction to bleed off orbital energy.

Treat every number here as a scaled model number, not a measurement. Set your length unit to disk radius and your time unit to an orbital period, and the shapes are meaningful. The clock in the corner is model time, not calibrated to years unless you fix the scale yourself.

The forces and the integrator

Each test particle obeys Newtonian gravity from the two cores, but with a softening length added so a near-miss does not blow up. For a single core of mass M at position \mathbf{R}, the acceleration of a particle at \mathbf{r} is:

\mathbf{a} = -\frac{GM\,(\mathbf{r} - \mathbf{R})}{\left(|\mathbf{r} - \mathbf{R}|^2 + \varepsilon^2\right)^{3/2}}

Here G is the gravitational constant, |\mathbf{r} - \mathbf{R}| is the distance from particle to core, and \varepsilon is the softening length. When the distance is much larger than \varepsilon, the denominator is just distance cubed and you recover the usual inverse-square pull. When the particle drives right through the core, the \varepsilon^2 term keeps the force finite instead of infinite. The particle feels the sum of this from both cores.

The important physics is the difference in pull across the disk. A companion of mass M at distance d pulls the near edge of a disk harder than the far edge. The net stretching acceleration across a radius r is:

a_{\text{tidal}} \approx \frac{2GMr}{d^3}

The cube of distance in the denominator is why tides fall off fast: halve d and the tidal pull grows by 2^3 = 8. That is why the closest approach dominates the whole encounter.

Time is advanced with a leapfrog scheme. Positions and velocities are updated on interleaved half-steps. It is symplectic, which means the energy error wobbles around a fixed value instead of drifting off, so long runs stay physically reasonable even at a coarse step.

If a tail looks jagged or a star shoots off absurdly fast, shorten the time step before you touch anything else. A symplectic integrator is stable, not exact: too large a step during the fast close pass is the usual cause of garbage.

Worked example: the default prograde encounter

The demo button loads the field defaults: two galaxies of equal mass (mass ratio 1), a moderate initial separation, a modest impact parameter, and the second disk left prograde. Work through the tidal budget for one star.

  1. Set units so the disk radius is r = 1 and the companion mass gives GM = 1. A star on the disk edge orbits its own core with acceleration GM/r^2 = 1 inward.
  2. Take the moment of closest approach at model distance d = 3 between cores. The tidal stretch across the disk edge is 2GMr/d^3 = 2(1)(1)/27 \approx 0.074.
  3. Compare that to the star's own binding acceleration of 1. The tide is about 7.4 percent of the binding force, small but persistent, and it acts hardest on the outer stars.
  4. Now bring the pass in to d = 2. The tide becomes 2(1)(1)/8 = 0.25, so 25 percent of binding. Cutting the closest distance by a third more than tripled the disruption.
  5. Because the encounter is prograde, the outer stars are already moving in the same sense as the companion sweeps by. The tug lasts longer in their rotating frame, so momentum piles up and the outer disk unwinds into a long tail.

Flip that same star's home disk to retrograde and the companion sweeps past against the rotation. Each star spends far less time near the peak pull, the resonance is gone, and the tail all but disappears.

How closest approach controls the tail

The single most instructive number is the peak tidal force, set by the closest core separation. The table below runs the 2GMr/d^3 estimate for a unit disk with GM = 1, r = 1, and compares it to the star's own binding acceleration of 1.

Peak tidal pull on the disk edge versus closest core separation.
Closest dTidal accelFraction of bindingExpected tail
40.031253.1%barely a ripple
30.074077.4%short tail
20.250025%long tail and bridge
1.50.592659%violent disruption
The steep drop shows why the tail length depends almost entirely on the closest pass: at d = 4 the tide is 20 times weaker than at d = 1.5.

With disk radius r = 1 and GM = 1, the peak tidal acceleration is 2/d^3 at closest separation d, and roughly doubles again for a prograde pass because the pull acts in resonance with the stars' own motion. At d = 3 that is about 0.074 of the binding force; at d = 2 it is 0.25.

Reading the screen

Watch three things as the clock runs. First, the live core separation. When it stops falling and starts rising, the cores have made their closest pass, and the tail you see moments later was launched at that minimum. Second, the shape of each colored population. The tail is the streamer that points away from the companion, made of stars flung outward. The bridge is the arc of stars pulled from one disk toward the other, pointing between the cores. Third, the trail fade turns the moving stars into long-exposure streaks that trace the flow lines.

Color tells you provenance. Cyan and amber mark home galaxy, so after a merger you can see how thoroughly the two populations mixed. In a clean prograde pass the tail is almost purely one color, because tails are outer-disk stars that keep their identity while the cores sink together.

A rising core separation does not mean the galaxies will separate forever in reality. This model has no dynamical friction, so unbound orbits stay unbound. Do not conclude "they missed" from the toy. Nature's drag would pull them back for a second, closer pass.

Common mistakes

Expecting star-star collisions. There are none, and there should be none: the disks pass through each other cleanly.

Reading model time as years. The clock counts integration units. It becomes a real duration only when you pin the length scale to a disk radius in kiloparsecs and the mass to a core mass, then read off the orbital period.

Blaming the physics for a spraying disk. If stars fling out at absurd speed the moment the pass gets close, that is the time step, not the model. Softening keeps forces finite, but a step longer than the crossing time still overshoots.

Concluding retrograde does nothing. It does far less to the tail, roughly a factor of six weaker at the same distance in the worked estimate, but it still thickens and heats the disk. "Weak tail" is not "no effect".

Using too few stars to judge structure. With only a few hundred tracers per galaxy the tail looks patchy. Thin streamers need thousands of particles to read cleanly.

Related tools

If the sensitivity of these orbits to starting conditions interests you, the Double Pendulum shows nearby starts diverging in a simpler chaotic system. For gravity taken to its extreme, Black Hole Lensing warps light around a compact mass. To see how many independent sources sum into structure, in a different medium, try Wave Interference. And for another field drawn by paired sources, Magnetic Field Lines sketches the lines between two magnets.

Frequently asked questions

Why do tidal tails form at all?

Because gravity pulls the near side of a disk harder than the far side. That difference, about 2GMr/d^3 across radius r, stretches the disk. Stars on the near side gain, stars on the far side lag, and the outer disk winds out into a streamer.

Why does a prograde pass throw a longer tail than a retrograde one?

In a prograde pass the outer stars already orbit in the same sense the companion sweeps by, so the tug stays with them longer and adds up in resonance. In a retrograde pass they rotate against the sweep, feel the peak pull only briefly, and barely move. At the same closest distance the effective tail strength differs by roughly a factor of six.

Do the stars really have zero mass?

In this model, yes. Only the two cores attract. That is the restricted three-body simplification Toomre and Toomre used, and it is why thousands of stars run fast in a browser. Full simulations give every particle mass and cost far more compute.

Why do the galaxies not always merge?

The toy has no dynamical friction, the drag from a dark matter halo that bleeds orbital energy. Without it, an unbound pass stays unbound and the cores separate again. Real galaxies lose energy to friction and eventually sink together.

What does the softening length change?

It caps the force at very close range: F \propto r/(r^2 + \varepsilon^2)^{3/2}. Far from a core it does nothing. Near a core it prevents an infinite kick from a direct hit, which would otherwise wreck the integration.