Genesis: Cosmic Web Formation
arwahussain2008
A real-time GPU-accelerated N-body simulation showing how gravity alone turns a near-uniform universe into filaments, voids, and clusters — no scripting, just physics.

What it does
What it does
This simulates Jeans instability — the real mechanism behind how the universe's large-scale structure formed. We start with ~10,000–15,000 equal-mass particles scattered almost uniformly through a 3D volume, each with a tiny random density perturbation and zero initial velocity — mimicking the near-smooth early universe with its faint fluctuations. From there, nothing is scripted: every particle pulls on every other particle via real Newtonian gravity, computed as a full pairwise force summation and parallelized on the GPU using Taichi, integrated forward in time with a symplectic (velocity Verlet) integrator for long-term stability. What emerges — filaments connecting dense nodes, with empty voids opening up between them — is a direct, honest output of the physics: the smallest initial over-densities pull in more mass, grow faster, and merge, exactly as they did in the real universe.
The camera rotates slowly around the 3D volume on its own, so the depth of the structure is actually visible rather than flattened into a 2D pattern. Each particle is colored and brightened by its local density (computed live via nearest-neighbor sampling) — deep blue/violet in sparse voids, rising to white/gold in dense filaments and cluster nodes — so color is a direct visualization of a real computed quantity, not decoration. Users can click once anywhere in empty space to inject their own small density seed and watch gravity amplify it into a new filament in real time, right alongside the structure forming on its own — turning the core physics into something you cause, not just observe.
What we had to figure out: the hardest part wasn't the gravity math itself — it was tuning the initial perturbation amplitude so that visible structure reliably emerges within a 30–60 second demo window rather than taking simulated millennia or collapsing too fast into a single blob. We verified this headlessly first, logging a density-clustering metric over simulated time before ever writing rendering code, specifically to avoid shipping initial conditions that looked plausible but never actually produced structure in a reasonable time. We also had to get the softening length right — too small and close particle encounters blow up into numerical singularities; too large and it artificially smooths out the very small-scale clumping the whole simulation is supposed to be demonstrating.