🌡️ Maxwell-Boltzmann Distribution
N elastic hard-sphere molecules in a box. The live speed histogram builds up and converges to the theoretical Maxwell-Boltzmann distribution f(v) = 4π(m/2πkT)^(3/2) v² exp(−mv²/2kT).
Gas Parameters
Statistics
Presets
What It Demonstrates
The Maxwell-Boltzmann distribution is the probability distribution of molecular speeds in an ideal gas at thermal equilibrium. It arises from the statistical mechanics of many interacting particles and defines three characteristic speeds: vp (most probable), ⟨v⟩ (mean), and vrms (root mean square). Higher temperature or lower mass shifts the distribution to higher speeds.
How to Use
- Raise Temperature T and watch the histogram broaden and shift right
- Increase mass m (heavier gas) and watch the distribution narrow and move left
- The red curve is the theoretical Maxwell-Boltzmann; the blue bars are the live measured histogram
- Try the presets to compare H₂ vs Pb — the 300× mass difference is dramatic
Did You Know?
At room temperature (300 K), hydrogen molecules (H₂) have a mean speed of ~1,700 m/s — fast enough to escape Earth's gravity over geological time, which is why the atmosphere has so little hydrogen. Oxygen molecules (O₂) move at ~480 m/s, well below escape velocity.
About this simulation
This simulation shows N elastic hard-sphere gas molecules bouncing inside a 2D box, and builds a live histogram of their speeds while the physics runs. Each particle starts with a velocity drawn from a Gaussian (via Box-Muller sampling) scaled by temperature and mass, then simply reflects off the walls each frame. As thousands of frames accumulate, the measured histogram converges onto the theoretical Maxwell-Boltzmann speed distribution f(v) = 4π(m/2πkT)^(3/2)·v²·exp(−mv²/2kT), plotted as a red curve over the blue measured bars.
🔬 What it shows
N particles of mass m at temperature T moving in a box with elastic wall collisions. The live histogram (blue bars) of measured speeds is compared frame-by-frame against the theoretical Maxwell-Boltzmann curve (red line) computed from the same T and m, with markers for the most probable speed vₚ, mean speed ⟨v⟩ and root-mean-square speed v_rms.
🎮 How to use
Drag the Temperature T slider (100–2000 K) to heat or cool the gas, the Particle mass m slider (1–200 u) to swap between light and heavy molecules, and the Particle count N slider (30–300) to change the sample size. Use the preset buttons (H₂, He, N₂, O₂, CO₂, Pb) to jump to real gases at realistic temperatures, or press ↺ Re-randomise to reseed all particle positions and velocities and clear the histogram.
💡 Did you know?
The three characteristic speeds are always in the ratio vₚ : ⟨v⟩ : v_rms = √2 : √(8/π) : √3, regardless of temperature or mass — only their absolute scale changes with √(T/m). That's why hydrogen (H₂) molecules at 300 K move nearly 4× faster on average than the heavier oxygen (O₂) molecules at the same temperature.
Frequently asked questions
What is the Maxwell-Boltzmann distribution?
It is the probability distribution of molecular speeds in an ideal gas at thermal equilibrium, derived from statistical mechanics. For a gas at temperature T with molecular mass m, the fraction of molecules with speed near v is proportional to v² exp(−mv²/2kT), where k is Boltzmann's constant. This simulation draws that curve in red and overlays the actual measured speed histogram in blue so you can watch simulated molecules reproduce the theory in real time.
How does the simulation generate the initial particle speeds?
Each particle's vx and vy velocity components are sampled independently from a Gaussian distribution using the Box-Muller transform, with standard deviation σ = √(kT/m). This is exactly the statistical recipe that produces a Maxwell-Boltzmann speed distribution once you look at the magnitude √(vx²+vy²) of many such velocity vectors, which is what the histogram measures.
What do Temperature, mass and particle count actually change?
Temperature T and particle mass m both feed directly into the thermal speed formula σ = √(kT/m): raising T or lowering m increases average speed, shifting the whole histogram and theoretical curve to the right and widening them. Particle count N does not change the shape of the distribution, only how many data points fill the histogram and how quickly it stabilises to a smooth curve.
Why do the particles only bounce off the walls and not each other?
To keep the frame rate high with hundreds of particles, this simulation only implements wall collisions (elastic reflection that flips vx or vy), not particle-particle collisions. This is a reasonable approximation for a dilute ideal gas, where particle mass, size and the constant velocity resampling already reproduce the correct equilibrium speed distribution without needing to simulate every collision explicitly.
What do vₚ, ⟨v⟩ and v_rms mean, and why are they different?
vₚ is the most probable speed (the peak of the curve), ⟨v⟩ is the mean speed averaged over all molecules, and v_rms is the root-mean-square speed used to compute kinetic energy and pressure. They differ because the Maxwell-Boltzmann distribution is skewed rather than symmetric: v_rms > ⟨v⟩ > vₚ always, in the fixed ratio √3 : √(8/π) : √2.