A gas cloud of mass M, radius R and velocity dispersion σ (σ² ∝ temperature T) is either bound by self-gravity or blown apart by its own thermal pressure. The virial theorem for a self-gravitating system states 2K + U = 0 at equilibrium, where K is kinetic energy and U is (negative) gravitational potential energy. Define the virial ratio:
α = 2K / |U|
α < 1 → gravity wins → collapse
α > 1 → pressure wins → disperses
This is exactly the Jeans instability criterion. For a uniform sphere of density ρ, the critical (Jeans) mass above which collapse occurs is:
M_J = (5σ²/G)^(3/2) · √(3 / 4πρ)
λ_J = √(15σ² / 4πGρ) (Jeans length)
In real molecular clouds σ² = k_B T / (μ m_H), so M_J shrinks as the cloud cools and grows as it heats — this is why star formation happens in the coldest, densest cores of molecular clouds. This simulator sets G = 1 and k_B/(μm_H) = 1 (scaled N-body units, standard practice for gravitational N-body codes) so σ² = T directly.
Every one of the ~400 particles here pulls on every other with softened Newtonian gravity a = ΣGmⱼ(rⱼ−rᵢ)/(|rⱼ−rᵢ|²+ε²)^1.5, integrated explicitly each frame. The Temperature slider acts as a mild Berendsen-style velocity thermostat, continuously nudging the cloud's kinetic energy toward the target σ² so you can watch collapse reverse into dispersal in real time.
- Cloud mass / Temperature — change live; watch α and M/M_J cross 1 and the cloud collapse or puff out.
- Initial radius + Reseed — redraws a fresh cloud of N particles in a sphere of that radius with a Maxwellian velocity distribution at the current temperature.
- Self-gravity toggle — turn gravity off to see pure thermal (pressure-driven) dispersal, with no attractive force at all.