TNK LAB

Thermalization & Maxwell Speed Distribution

A few "hot" particles launch into a box of particles at rest. Every collision is a perfectly elastic hard-disk collision — nothing here is random. Watch the initial spike of speeds spread out, purely through repeated collisions, into the equilibrium speed distribution.

Note: because this box is 2D, the equilibrium curve is not the familiar textbook 3D Maxwell-Boltzmann formula (the one with a v² prefactor). In 2D it's a Rayleigh distribution, ∝ v e−v²/2T — see the formula box below.

Setup

These don't apply live — click "Reset & Launch" below after changing them (it'll pulse red as a reminder).

Speed sets how much simulated time passes per rendered frame — every frame moves particles by some amount, never freeze-then-jump. Collision detection automatically subdivides that motion into enough pieces to keep fast particles from tunneling through each other, regardless of speed.

State

Elapsed Steps: 0
Total Collisions: 0

Total KE (should stay constant): -
Initial Total KE: -
Instantaneous T = KE/N: -

2D Maxwell Speed Distribution

$$P(v)\,dv = \frac{v}{T}\,e^{-v^2/2T}\,dv \qquad \text{(Rayleigh distribution)}$$
Each velocity component is independently Gaussian, $P(v_x)\propto e^{-v_x^2/2T}$ — that part is dimension-independent. The speed distribution comes from switching to polar coordinates in velocity space, $dv_x\,dv_y = v\,dv\,d\theta$, so in 2D the extra factor is just $v^1$, not the $v^2$ you get integrating over a 3D shell. Units here have mass = 1 and kB = 1, so temperature T is measured directly in energy-per-particle.
Why isn't this the formula from my textbook?
The familiar $4\pi v^2(m/2\pi T)^{3/2}e^{-mv^2/2T}$ formula comes from counting how much volume of 3D velocity space sits in a thin spherical shell at speed v — that shell has area $4\pi v^2$, hence the $v^2$.
This box only has two velocity components, $v_x$ and $v_y$. The "shell" at speed v in 2D velocity space is a thin ring, not a sphere, with circumference $2\pi v$ — one power of v, not two. Every dimension gets its own version of this distribution; 2D's happens to be the Rayleigh distribution specifically, with a clean closed form.
Nothing about the collision physics below assumes this formula — it's pure elastic hard-disk collisions. The Rayleigh curve is the independently-derived prediction; the histogram is what actually happens. Watching them converge is the point.

2D Particle Box

Slow
Medium
Fast

Speed Distribution P(v)

Measured histogram
Rayleigh prediction (from current T)

Velocity Component Distribution P(vx)

Measured histogram
Gaussian prediction (from current T)

Shannon Entropy of Speed Distribution

Measured S = −Σ p ln p
Equilibrium (Rayleigh) value, same bins
What kind of entropy is this, exactly?
pi here is the probability that one randomly-picked particle has speed in bin i — not the probability of the whole N-particle system occupying a specific microstate. This is a single deterministic trajectory, so at every instant it's in exactly one full microstate with probability 1; a literal Gibbs entropy over full-system states is trivial without an ensemble of runs to average over.
What's plotted is Boltzmann's H-function from kinetic theory, $S \propto -H = -\!\int f(v)\ln f(v)\,dv$, evaluated on the empirical single-particle speed distribution — exactly the quantity behind the H-theorem.
Its increase is only guaranteed under the molecular-chaos assumption (uncorrelated particles). Real elastic collisions build up correlations and the dynamics is time-reversible, so this curve is overwhelmingly likely to rise toward equilibrium but isn't forced to — that's why it fluctuates near the theory line instead of flattening out exactly.