This simulation needs WebAssembly, and it could not start in this browser.
The image is a frame from a real run. Check that JavaScript is on, or try another browser.
In 1860 James Clerk Maxwell asked how the speeds of the molecules in a gas are spread, and answered without knowing anything about the molecules: if the three velocity components are independent and no direction is special, the distribution must be a Gaussian in each component. Ludwig Boltzmann showed in 1872 that collisions alone drive a gas toward it from any start, and that the approach is irreversible, the first statistical explanation of the second law. This gas of hard discs starts far from equilibrium and lets you watch Maxwell’s distribution form.
What you see
150 discs of radius 7 in an 800 by 800 pixel box with reflecting walls, colored from white (slow) to red (fast) relative to the fastest disc. The inset shows the histogram of their speeds; the red curve is the Maxwell distribution at the gas’s current temperature, which does not change since collisions conserve energy. The panel shows the temperature in units of the starting temperature of the one-speed beam.
Model
The discs fly in straight lines and collide elastically: at contact, two discs exchange the velocity components along the line through their centers, which conserves momentum and kinetic energy exactly. In two dimensions the equilibrium distribution of speeds is
with mean speed and . It peaks at and has a long tail of fast discs.
A simple number tracks the relaxation: the ratio , which is 1 when all discs share one speed and 2 for the Maxwell distribution.
Presets
One speed: all discs start at 150 px/s in random directions, also the default. The histogram starts as a single spike. After one second the ratio above is 1.34, after five seconds 1.73, and after about 20 seconds it fluctuates around 2: the spike has spread into the Maxwell curve, slow discs included.
Hot spot: the 20 discs nearest the center start eight times as fast as the rest, which hold half the base speed. The fast discs scatter into the cold gas, the heat spreads across the whole box within about five seconds, and the gas settles at 2.35 times the beam’s temperature.
Equilibrium: speeds drawn from the Maxwell distribution from the start. The histogram fluctuates around the curve and never leaves it, which is what equilibrium means for 150 discs.
Parameters
Discs: 10 to 400, and Radius (px): 3 to 18; more and larger discs collide more often and relax faster. The number applies on Reset, the radius immediately.
Wall temperature: 0 to 4. At 1 the walls reflect; at other values they send discs back at speeds drawn for that temperature and so heat or cool the gas, and the curve follows.
The force sliders push every disc with a uniform acceleration, like gravity.