This simulation shows how collisions between molecules produce the Maxwell–Boltzmann distribution of molecular speeds in an ideal gas (statistical mechanics). Every molecule starts with exactly the same speed. Collisions alone reshuffle kinetic energy until the speeds settle onto the analytic curve, where f(v) is the probability density of molecular speed, that is, the fraction of molecules per unit speed at speed v:
Choose the gas, the temperature and a speed window, then watch the box and the curve.
After a restart and the brief pause, the histogram is a single spike at the rms speed. Within a few collisions per molecule it spreads into the curve. The kinetic temperature never moves: collisions redistribute energy, they do not add any.
Higher T or a lighter gas stretches the curve to higher speeds and lowers its peak, because the area under it stays 1. Compare H2 with Xe at the same T: same mean kinetic energy, very different speeds.
The shaded area under the curve between v1 and v2 is the fraction of molecules in that range. Narrow the window and it approaches f(v)·Δv.
Molecules are hard spheres with 3-D velocities in a 2-D slice; collisions conserve momentum and energy, with the out-of-plane direction chosen at random. Speeds plotted are full 3-D speeds. Animation time is scaled so every gas moves at a watchable pace. With few molecules the histogram is noisy; the noise value in parentheses after “Distance from equilibrium” is the distance expected for a single snapshot of a gas at equilibrium.
The probability density for the speed \(v\) of a molecule in an ideal gas at equilibrium. The product \(f(v)\,dv\) is the fraction of molecules with speeds between \(v\) and \(v+dv\), and the density is normalized, \(\int_0^\infty f\,dv=1\). The \(v^2\) factor counts the velocity directions available at speed \(v\); the exponential is the Boltzmann factor for the kinetic energy \(\tfrac12 m v^2\).
The molar mass \(M\) (in kg/mol) of the chosen gas divided by Avogadro’s number gives the mass of one molecule.
The most probable speed \(v_{\mathrm{mp}}\) is the peak of \(f(v)\), \(\langle v\rangle\) is the mean speed, and \(v_{\mathrm{rms}}\) is the root-mean-square speed. They always appear in the order \(v_{\mathrm{mp}}<\langle v\rangle<v_{\mathrm{rms}}\) because the curve has a long tail toward high speeds. After a restart every molecule has the speed \(v_{\mathrm{rms}}\), so the initial kinetic energy already equals the equilibrium value.
All ideal gases at the same temperature have the same mean kinetic energy per molecule, so lighter molecules must move faster.
\(F(v)\) is the fraction of molecules with speed below \(v\). The analytic value shown on the page is \(P_{\mathrm{window}}\). The simulated value is the number of molecules with \(v_1\le v<v_2\) divided by \(N\), smoothed over time to reduce the noise from the finite number of molecules.
Collisions conserve energy, so \(T_{\mathrm{sim}}\) stays equal to the temperature you chose even while the shape of the distribution changes.
The histogram has bins \(i\), each with a simulated fraction \(p_i^{\mathrm{sim}}\) and an analytic fraction \(p_i^{\mathrm{MB}}\). One extra bin collects speeds beyond the plotted range. \(D=0\) means the histogram matches the curve exactly and \(D=1\) means no overlap. Because \(N\) is finite, even a gas at equilibrium has a small distance \(D_{\mathrm{noise}}\), which is the “noise” value shown in parentheses next to the distance.
Each collision involves two molecules, so the average molecule has taken part in \(c\) collisions. A few collisions per molecule are enough for the distribution to relax.
| Symbol | Definition | Units |
|---|---|---|
| \(f(v)\) | Probability density of molecular speed | s/m |
| \(F(v)\) | Cumulative fraction of molecules with speed below \(v\) | – |
| \(v\) | Molecular speed | m/s |
| \(v_1,\ v_2\) | Lower and upper limits of the speed window | m/s |
| \(v_{\mathrm{mp}}\) | Most probable speed | m/s |
| \(\langle v\rangle\) | Mean speed | m/s |
| \(v_{\mathrm{rms}}\) | Root-mean-square speed | m/s |
| \(\langle v^2\rangle\) | Mean of the squared speed | m2/s2 |
| \(T\) | Temperature of the gas (set by the slider) | K |
| \(T_{\mathrm{sim}}\) | Kinetic temperature computed from the simulated speeds | K |
| \(m\) | Mass of one molecule | kg |
| \(M\) | Molar mass of the gas | kg/mol |
| \(k_B\) | Boltzmann constant, \(1.381\times10^{-23}\) | J/K |
| \(N_A\) | Avogadro’s number, \(6.022\times10^{23}\) | mol−1 |
| \(R\) | Gas constant, 8.314 | J/(mol·K) |
| erf | Error function | – |
| \(P_{\mathrm{window}}\) | Fraction of molecules with speed between \(v_1\) and \(v_2\) | – |
| \(N\) | Number of molecules in the simulation | – |
| \(N_{\mathrm{coll}}\) | Total number of collisions so far | – |
| \(c\) | Collisions per molecule | – |
| \(i\) | Index of a histogram bin | – |
| \(p_i^{\mathrm{sim}},\ p_i^{\mathrm{MB}}\) | Fraction of molecules in bin \(i\) from the simulation and from the Maxwell–Boltzmann distribution | – |
| \(D\) | Distance from equilibrium (half the sum of the bin differences) | – |
| \(D_{\mathrm{noise}}\) | Expected distance for a finite sample of an equilibrium gas | – |
This simulation was created in the Department of Chemical and Biological Engineering at University of Colorado Boulder for LearnChemE.com by John L. Falconer using Claude AI. It was prepared with financial support from the National Science Foundation (DUE 2336987 and 2336988). Address any questions or comments to LearnChemE@gmail.com.
A 2-D slice of a 3-D gas. Orange molecules have a speed inside your window.
Distance from equilibrium: