The 3D equipartition simulator couples each diatomic molecule to an external Langevin heat bath — a stochastic differential equation injects random kicks and drag independently into translation, rotation and vibration, and the fluctuation-dissipation theorem guarantees each channel relaxes to (1/2)k_BT regardless of its own mass, inertia or stiffness.
This 2D version has no bath and no randomness after the initial condition. It is a genuine hard-disk molecular-dynamics gas: three species of physically different mass (light, medium, heavy) are dropped into the same box, each species deliberately started at a different mean kinetic energy per particle (a different "temperature"), and the only thing that happens afterward is deterministic elastic collisions:
every step: x += v·dt (free flight)
elastic wall bounce (reflect v component)
pairwise elastic collision when disks overlap:
n = (p_j − p_i)/|p_j − p_i|
v_rel = (v_i − v_j)·n
if v_rel > 0: J = 2·v_rel / (1/m_i + 1/m_j)
v_i −= (J/m_i)·n , v_j += (J/m_j)·n
That impulse formula conserves both total momentum and total kinetic energy of every single collision exactly (it's the standard billiard-ball elastic-collision law — for equal masses it reduces to a clean velocity swap). Nothing external adds or removes energy, so the system's total kinetic energy — and hence its system-average energy per degree of freedom — is fixed for the whole run. What is not fixed is how that fixed total is shared out: collisions between a fast light disk and a slow heavy disk redistribute kinetic energy between them exactly the way real gas molecules do, and after enough collisions per particle, every species' own average settles onto the same value as the system average — mass-independent equipartition emerging from ergodic collision dynamics rather than from an external bath.
- Particles N — more disks means more collisions per second, so equilibrium (and the correspondingly noisy but converged bars) is reached faster and with a smoother average.
- Mass ratio — how much heavier the heavy species is than the light one. A bigger ratio doesn't change the final energy per DOF at all (that's the point) — it only means the heavy disks start out moving much more slowly for the same kinetic energy.
- Initial temperature spread — how unequal the three species' starting energies are. Set it to 0 to start all three species already in equipartition (a sanity check: the bars should sit on the red line immediately); turn it up to watch a genuinely far-from-equilibrium gas relax.
Real-world relevance: this is essentially the textbook hard-sphere-gas derivation of the Maxwell-Boltzmann distribution and the equipartition theorem — the same argument (via the Boltzmann collision equation) that explains why a mixture of different gases in the same container reaches one common temperature, with the heavier species simply moving slower on average, never more energetically, once equilibrium is reached.