Galaxy Merger N-body Lab

Two spiral galaxies, live halos, Barnes-Hut gravity: watch tidal tails, bridges and dynamical friction. Drag to orbit, wheel to zoom.

Presets

Playback

Orbit and masses

Changing these restarts the encounter.

Disc orientation

Tilt 0 = disc rotates with the orbit (prograde): long tails. 180 = retrograde: short tails.

Star colours

Camera follow

Numerics

Live: smaller theta = more accurate, slower.

Appearance

Camera

Layers

Quality

Model checks

The science

What is simulated

Two galaxies are placed on a Keplerian two-body orbit with eccentricity e and pericentre r_p: r = p/(1 + e cosν), p = r_p(1 + e), relative speed from v² = G M_tot (2/r - 1/a). Each galaxy has a heavy bulge particle, a live dark-matter halo of equal-mass particles drawn from a Plummer sphere (ρ(r) ∝ (1 + r²/a²)-5/2, a = 12 kpc (M/5×1011)1/3) and an exponential stellar disc (Σ ∝ exp(-R/R_d), R_d = 3 kpc scaled with mass) of massless tracer stars started on near-circular orbits, v_c² = G M R²/(R² + a²)3/2 with 5% velocity dispersion.

Gravity: Barnes-Hut tree

Heavy particles are inserted in an octree. A cell of size s at distance d is replaced by its centre of mass when s/d < θ; otherwise it is opened. This turns the O(N²) force sum into O(N log N). Forces are Plummer-softened, a = G m r / (r² + ε²)3/2, and integrated with kick-drift-kick leapfrog with a global adaptive step dt = 0.3 √(ε/a_max) so the close bulge passage is resolved. Tracer stars use a grouped tree walk (one interaction list for a cluster of neighbouring stars, slightly larger opening angle).

Dynamical friction

The lighter galaxy moving through the other galaxy's halo gathers a gravitational wake that pulls it back (Chandrasekhar 1943). The decay time quoted from Binney and Tremaine (2008, eq. 8.13) is t_df = (1.17/lnΛ) r² v_c / (G M_sat), Λ = r v_c²/(G M_sat). Here friction is not put in by hand: it emerges because the halos are made of interacting particles. The orbital-energy graph shows the orbit losing energy to the halos at each pericentre passage.

Tidal tails and bridges

A star feels the difference between the pull of the intruder on the near and far side of the disc (tidal force ≈ 2 G M r / D³). Stars rotating in the same sense as the orbit (prograde, tilt 0) are resonantly flung out into long tails; retrograde discs (tilt 180) stay compact. That is the Toomre and Toomre (1972) result, reproduced here with self-consistent halos instead of point masses.

Numerical checks shown live

(1) Barnes-Hut accelerations on a random sample against the exact O(N²) sum; (2) total energy of the heavy particles from a direct pair sum, which does not use the tree; (3) conservation of total angular momentum and linear momentum, plus the initial disc rotation speed at 8 kpc against the analytic v_c.

Honest simplifications

Stars are massless tracers (no disc self-gravity, so no bars or grand-design spirals form), gas, star formation, supermassive black holes and feedback are not modelled, tree forces use monopoles only, and the Blender-rendered disc image is a visual impostor that fades as the disc is disturbed (its rotation is illustrative). Particle numbers (a few thousand) give a qualitative picture, not a precision merger-time prediction; real merger times depend on halo profile and orbit and agree with these estimates only to a factor of two or so. Units: kpc, 1010 M☉, km/s, 1 time unit = 977.8 Myr.

Loading model...
Loading Blender model...
Separation of the two bulges
Orbital energy (dynamical friction drains it)
Tail and unbound stars
Made with 🟠 Blender · Three.js