N frictionless discs move in a box and exchange momentum through perfectly elastic pairwise collisions. For each overlapping pair, the impulse along the contact normal n̂ is:
J = 2·m1·m2·(v_rel · n̂) / (m1 + m2)
v1' = v1 − J·n̂/m1
v2' = v2 + J·n̂/m2
This conserves both total momentum and total kinetic energy exactly — no restitution coefficient, no damping. Walls only flip the perpendicular velocity component, so wall bounces never change a disc's speed.
- Type A / Type B — two populations (pink / cyan) with an adjustable mass ratio, so you can watch equipartition: lighter particles settle at higher average speed than heavier ones once both reach the same mean kinetic energy.
- Histogram — the current speed distribution of all N particles, redrawn every frame, with the theoretical 2D Maxwell-Boltzmann curve f(v) = (m/kT)·v·exp(−mv²/2kT) overlaid using the live temperature.
- Temperature — computed from T = m·⟨v²⟩/(2k) with k = 1 in simulation units, so it tracks the mean kinetic energy per particle directly.