Integrate the Friedmann acceleration equation backward to the Big Bang and forward to a Big Freeze, Big Crunch or Big Rip, and watch a galaxy lattice expand.
With H0 = 1 as the time unit, the scale factor obeys the Friedmann equation
(da/dt)² = Ωm/a + Ωk + ΩDE a-1-3w (Ωk = 1 - Ωm - ΩDE) and the acceleration equation, obtained by differentiating it:
d²a/dt² = -Ωm/(2a²) - (1+3w)/2 · ΩDE a-2-3w. For a cosmological constant (w = -1) this is -Ωm/(2a²) + ΩΛ a: matter decelerates, Λ accelerates.
The second-order equation is integrated from today (a = 1, da/dt = +1) with classical 4th-order Runge-Kutta and a step proportional to a/|da/dt|, forward and backward. Using the second-order form lets the solution pass through turning points (a Big Crunch recollapse or a bounce) where the first-order square-root form breaks down. The first integral (Friedmann constraint) is not imposed but monitored: its drift is a built-in accuracy test.
Fates: Big Freeze - a grows without bound while the expansion rate settles (Lambda dominated). Big Crunch - da/dt reaches zero and a recollapses (high density, or negative Λ). Big Rip - for w < -1 ("phantom" energy) a diverges in finite time. Bounce - going backward, da/dt reaches zero at a finite a, so there was no Big Bang.
Closed forms used as tests: Einstein-de Sitter a = (3t/2)2/3; flat matter+Λ a = (Ωm/ΩΛ)1/3 sinh2/3(3√ΩΛ t / 2); matter-only closed universe is a cycloid a = A(1 - cos η), t = B(η - sin η) with crunch at t = π Ωm/(Ωm-1)3/2.
Simplifications: radiation is neglected (it matters only for a < 10-3), dark energy has constant w, the universe is perfectly homogeneous, and galaxies are drawn at fixed size to show that bound objects do not expand with space. Integration stops at a < 10-3, a > 200 or 8/H0 ≈ 110 Gyr (for H0 = 70). The galaxy lattice is illustrative, not data.
2D twin: the same equations as the 3D engine. The lower panel is a comoving lattice of galaxies drawn at fixed size inside a fixed window while the spaces between them scale with a(t).