🇬🇧 Astrophyzix Flagship Series GAL-01
LIVE RESTRICTED N-BODY LEAPFROG FLOAT64

Milky Way Galaxy Collision Simulator

Restricted N-body simulation of the Milky Way / Andromeda merger over 8 billion years. Two galaxy cores under full mutual gravity with Plummer softened potentials, plus thousands of massless tracer particles feeling both cores. Symplectic leapfrog integration in a background worker. Drag to rotate, scroll or pinch to zoom.

RESTRICTED N-BODY
LEAPFROG KDK
MIDPOINT TRACKED
UTC clock initialising...
t = 0.00 Gyr
PRE-PASSAGE
Sep: 770 kpc
DRAG TO TILT
0.00 Gyr
770 kpc
at origin
approaching
Initialising simulation: Milky Way + Andromeda + 3000 tracer particles. Press PLAY to begin.
Total mass1.2 x 10^12 M_sun
Plummer scale length15 kpc
Initial position(0, 0, 0) kpc
Initial velocity(0, 0, 0) km/s
Disk orientationxy plane (z normal)
Tracer distributionExponential disk, r_0 = 4 kpc
Total mass1.5 x 10^12 M_sun
Plummer scale length18 kpc
Initial position(770, 0, 0) kpc
Initial velocity (radial)-110 km/s (approaching)
Initial velocity (transv.)+17 km/s (van der Marel)
Disk orientationTilted 50 deg from MW plane
Tracer distributionExponential disk, r_0 = 5 kpc
Simulation time0.000 Gyr
Current separation770.00 kpc
Closest approach so far770.00 kpc
Relative speed111 km/s
PhasePre-passage
Active tracers3000
Step count0
dt (current)5.0 Myr

This module uses the restricted N-body method pioneered by Toomre and Toomre (1972) for galaxy merger simulations. Two galaxy cores carry the gravitational mass; they orbit each other under direct Newtonian gravity. Thousands of massless tracer particles represent stars, feeling the gravitational potential of both galaxy cores but not contributing to it.

This approach reproduces the iconic dynamical features of real galaxy mergers (bridges, tidal tails, disk warping, eventual coalescence) at a fraction of the computational cost of full self-gravitating N-body. It is still used in modern research where tidal kinematics, not internal galaxy structure, is the question of interest.

Toomre, A. and Toomre, J. (1972). Galactic Bridges and Tails. The Astrophysical Journal, 178, 623. The original paper that established restricted N-body as the canonical method for tidal interaction studies.
  • Galaxy cores :: each modelled as a Plummer softened point mass. Potential Phi(r) = -GM/sqrt(r^2 + a^2). Acceleration has no singularity at r=0, which keeps the integrator stable through close passages.
  • Core-core force :: full Newtonian mutual gravity. The two cores form a self-consistent two-body orbit (modified by Plummer softening at close range).
  • Tracer-core force :: each tracer feels the Plummer-softened pull of both galaxy cores simultaneously. Pulled toward whichever core dominates at its current position.
  • What is not in the model :: tracer-tracer self-gravity is omitted (the "restricted" in restricted N-body). This means dynamical friction, bar formation, and internal disk substructure are not captured. Central supermassive black holes, gas hydrodynamics, star formation, and dark matter halo distortion are also out of scope.
  • Symplectic leapfrog in kick-drift-kick (KDK) form. Time-reversible, energy-conserving to round-off over arbitrarily long integrations. Standard choice for collisionless N-body.
  • Timestep :: 5 Myr default. Adapted to the orbital period of the closest tracer (typically the inner-disk stars at ~100 Myr orbit) so dt is well below the dynamical time everywhere.
  • Float64Array state vectors throughout. The integrator runs in a Web Worker via inline Blob URL so the canvas render loop is never blocked.
  • MW-M31 separation :: 770 kpc, current best estimate from Cepheid and detached eclipsing binary distance ladder.
  • Approach velocity :: -110 km/s line-of-sight, measured from M31 systemic blueshift.
  • Transverse velocity :: +17 km/s (van der Marel et al. 2012, refined from HST proper motions). The transverse component was the largest open question until that paper.
  • MW mass :: 1.2 x 10^12 M_sun (total including dark matter halo).
  • M31 mass :: 1.5 x 10^12 M_sun (slightly more massive than MW per recent constraints).
  • Disk orientations :: MW disk in the xy plane; M31 disk inclined 50 deg from MW (real value approximately 77 deg from line of sight, but we orient relative to the merger plane for visual clarity).
  • 0 - 2 Gyr :: gradual approach phase. Tidal effects negligible.
  • 2 - 3.5 Gyr :: tidal interaction begins. Outer-disk stars start to feel the perturbation. Disks begin to warp.
  • 3.5 - 4.5 Gyr :: first close passage. Minimum separation around 30-50 kpc. Spectacular tidal bridges and tails form.
  • 4.5 - 6 Gyr :: apocentre after first passage at 100-200 kpc separation. Tidal tails fully developed. Disks heavily distorted.
  • 6 - 7 Gyr :: second passage and final coalescence. Both galaxies merge into a single elliptical-like remnant ("Milkomeda").
  • 7+ Gyr :: violently relaxed merger remnant.
van der Marel, R. P. et al. (2012). The M31 Velocity Vector. III. Future Milky Way-M31-M33 Orbital Evolution. ApJ 753, 9. Modern definitive constraint on transverse velocity and merger orbit.
Cox, T. J. and Loeb, A. (2008). The Collision Between The Milky Way And Andromeda. MNRAS 386, 461. Full-physics N-body + SPH simulation including gas and star formation.
Salomon, J.-B. et al. (2021). Refining the transverse velocity of M31 with Gaia eDR3. Current state of the art using Gaia astrometry.
1Module loads paused at t = 0 (today) with the Milky Way and Andromeda 770 kpc apart, both framed in view. The camera tracks the midpoint of the two galaxy cores so both stay on screen throughout the encounter. Press PLAY to begin time evolution.
2Default speed is 1x (about 300 Myr of simulation time per real second). The first close passage is reached after roughly 12 seconds of wall clock. Higher speeds (5x to 500x) are useful for the big picture but blur the tidal detail.
3Drag the canvas to rotate the view in 3D. Scroll or pinch to zoom. TOP snaps to plan view; SIDE snaps to edge-on.
MW tracers (blue)
M31 tracers (red)
MW core
M31 core
  • PLAY / PAUSE :: freeze or resume time evolution. Camera still rotates and zooms when paused.
  • RESET :: rewind to t = 0 (today). Regenerates the tracer distribution from scratch.
  • ZOOM +/- :: discrete zoom steps. Initial scale shows the full 770 kpc separation.
  • TOP :: snap to plan view (looking down the MW disk normal).
  • SIDE :: snap to edge-on view (showing disk thickness and orbit plane).
  • Speed :: time acceleration. 1x is the default (about 300 Myr per real second, full 7 Gyr merger in roughly 25 seconds). 500x compresses the entire merger into seconds; useful for context, less for studying tidal detail.
  • Particles :: total tracer count. 1k is sparse but fast. 3k is default. 10k is dense but may stutter on older mobile devices. Changing this resets the simulation.
  • 0 - 2 Gyr :: disks rotate normally. Approach is slow at this phase.
  • 3 - 4 Gyr :: outer-disk stars start being pulled toward the other galaxy. Bridges form between the two.
  • 4 - 5 Gyr :: first passage. Spectacular tidal tails on the far sides of each galaxy. Closest approach 30-50 kpc.
  • 5 - 6 Gyr :: apocentre. Galaxies briefly separate to 100-200 kpc. Tails are long streams.
  • 6 - 7 Gyr :: second close passage, then rapid coalescence into a single diffuse remnant.
  • No tracer self-gravity :: this is restricted N-body. Tracer particles do not pull on each other or on the cores. The merger timeline is therefore slightly idealised compared to full self-gravitating simulations.
  • No gas, no star formation, no central SMBHs :: purely gravitational kinematic simulation. The Cox and Loeb (2008) paper adds those physics.
  • Plummer softened potentials :: real galaxies have NFW dark halos plus disk plus bulge profiles. Plummer is a single-component approximation chosen for stability and clarity.
ASTROPHYZIX :: GAL-01 RESTRICTED N-BODY :: LEAPFROG
Copyright (c) 2026 Astrophyzix.org. All rights reserved.
Redistribution, mirroring, scraping, or republication of this module, its source code, embedded datasets, scientific methodology, or any derivative thereof is not allowed without the express written consent of Astrophyzix.org.