← Gallery
Simathon 01Open InnovationHas videoHas code

Cosmic Encounter: Ultra realistic Self-Gravitating Galaxy Collision

Carol

Two galaxies with 800,000 self-gravitating stars and gas particles collide in real time, complete with star formation and gravitational lensing.

Still from Cosmic Encounter: Ultra realistic Self-Gravitating Galaxy Collision

What it does

Cosmic Encounter is a real-time astrophysics simulation built with Taichi that models the collision of two spiral galaxies, one barred, one unbarred, each with its own NFW dark-matter halo, stellar disk, and gas disk. Unlike simple particle-pulled-toward-a-point setups, this simulation solves true self-gravity: a particle-mesh method deposits mass onto a 128³ grid every couple of frames and solves the Poisson equation with a Jacobi relaxation solver to compute the gravitational potential the whole system generates on itself, not just from the two central black-hole-like cores. Gas particles behave like an actual fluid, following a polytropic equation of state with pressure gradients computed directly on the grid. When gas gets compressed densely enough, like in the shockfront of the collision, it heats up and, with a bit of randomness, spontaneously converts into young stars, visualized as bright blue points bursting to life exactly where the galaxies smash together. A screen-space gravitational lensing pass then bends light around both galactic cores, distorting the final image the way mass genuinely warps spacetime. You can orbit and zoom the camera, speed up or slow down time, and pull particles around with your mouse to interact directly with the simulation. A "Learn Mode" toggle switches to a scientific heatmap showing real-time acceleration magnitude across all 800,000 particles alongside live technical telemetry (grid resolution, particle count, update cadence), making it as much an educational tool as a visual centerpiece.