Kinetic Theory of Gases

How pressure, temperature and the speed distribution (Maxwell distribution) emerge from many colliding molecules. A free physics simulation in your browser (Equation of state, Maxwell distribution, Boyle's law).

How it works and what to look for

P A = N k T (2D ideal gas), f(v) = (mv/kT) exp(−mv²/2kT)

Pressure is measured from the impulse (2mv) of molecules bouncing off the walls, divided by time and wall length. Temperature is just the average kinetic energy of the molecules. If the measured PA/NkT is close to 1, the equation of state holds (it's slightly above 1 because molecules have size).

Press "Start with equal speeds": at first every molecule has the same speed, but collisions quickly spread out the speeds into the Maxwell distribution (yellow line). Every molecule follows the same laws, yet the whole settles into a definite distribution — that's the idea of statistical mechanics.

Halving the box width at constant temperature roughly doubles the pressure (Boyle's law). Turn off "Hold temperature constant" and squeeze the box: molecules hitting the moving piston speed up and the temperature rises (adiabatic compression). In a 2D gas, PA² stays constant.

Today's question: What happens to pressure if the box is halved at constant temperature?

  1. Turn isothermal mode on. Set 300 molecules, temperature 1, and box width 1.2.
  2. Let pressure settle. Record area, measured pressure, and the theoretical value.
  3. Change only width to 0.6. Let it settle again, then compare.

Read the explanation and model assumptions

This two-dimensional ideal gas obeys PA = NkT. At fixed molecule count and temperature, halving area roughly doubles pressure. Molecular momentum changes at the walls produce pressure.

A finite number of molecules gives fluctuating pressure. Compare settled readings rather than the moving-piston transient. In three dimensions, volume V replaces area A.

Everyday examples

Common misconceptions

Misconception: All gas molecules move at the same speed.
In fact: Their speeds vary and follow the Maxwell distribution. Temperature sets the average kinetic energy.
Misconception: Molecules are fast, so a smell fills a room instantly.
In fact: Molecules collide hundreds of millions of times a second and keep changing direction, so diffusion is much slower.

Related simulations