Cold collapse
A cold disk of stars falls in on itself, bounces and relaxes; spun up, it breaks into clumps.
The Maclaurin (Kalnajs) disk, of surface density Sigma0 sqrt(1 - r^2 / R^2), is the one flat mass distribution whose gravity is exactly linear inside it: the pull towards the centre is Omega0^2 r with Omega0^2 = pi^2 G Sigma0 / (2 R). Started at rest, every star falls as r0 cos(Omega0 t) and the whole disk reaches the centre at once, at t = pi / (2 Omega0). But a cold disk is gravitationally unstable on every scale, so the graininess of N stars grows during the fall (the stars start on rings of equal mass to keep it small) and breaks the homology before the end: the disk ends in a violent bounce, throws out about a third of its mass, and the bound rest trades energy in the fluctuating potential until it is in virial equilibrium, 2 K = -sum(m r . a), with a dense core and a halo (violent relaxation, Lynden-Bell 1967). Spun at Omega0 the same disk is in exact rotational equilibrium, but it is cold (Toomre’s Q = 0), so every wavelength is gravitationally unstable: it breaks up into clumps that spiral together. The bodies are point masses in a plane with the 1/r^2 force, by the Barnes-Hut walk of FlatQuadtree (theta = 0.5, Plummer softening 0.03) and the kick-drift-kick leapfrog. Units G = M = R = 1, so Omega0 = sqrt(3 pi / 4) and the collapse time is 1.023.
Source: examples/cold_collapse.py. Run it yourself with python examples/cold_collapse.py [--output examples/output] [--quick] (needs pip install "tree-d-3d[examples]").
Animations
Section titled “Animations”
Loading figure…the cold disk falling in, bouncing and relaxing, with the quadtree of every frame: the cells shrink with the disk, reach their deepest at the bounce and spread out into the halo.

Loading figure…the rotating disk breaking into clumps, with its quadtree: each clump becomes a knot of deep cells.
Figures
Section titled “Figures”
Loading figure…the median radius of the collapsing disk against the exact cos(Omega0 t): it follows it closely for the first half of the fall, then the growing clumps pull the stars in faster; after the bounce the core stays a tenth of the disk.

Loading figure…the virial ratio 2 K / |sum(m r . a)| of the bound stars of both disks (exact for the softened forces too, unlike 2 K / |W|), and the bound fraction of the mass: the collapsing disk overshoots and settles to 1 having lost a third of its mass; the rotating disk starts at 1 (rotation supports it) and stays near it while its ordered rotation turns into random motion in the clumps.
--quick uses fewer stars (well under a minute); --smoke is the tiny configuration the test suite runs. Needs Plotly (pip install 'tree-d-3d[examples]').