Ideal Gas & Entropy

Colliding molecules settle into the Maxwell-Boltzmann distribution; push a piston and track entropy as two chambers mix.

  • Piston
Speed02× typical
100%

Molecules bounce off each other and the walls, blue when slow and red when fast. However they start, collisions share out the energy into the Maxwell-Boltzmann distribution. Drag the right wall to compress the gas, or tap to heat a spot, an event in time that Restart and share links leave out.

Setup
800
0%

How is Ideal Gas & Entropy working for you?

About Ideal Gas & Entropy

Speed distribution
Maxwell (1860), Boltzmann (1872)
Gas law in two dimensions
Pressure × area = N kT
Equipartition
kT/2 of kinetic energy per direction of motion
All on one side, 800 molecules
A chance of about 1 in 10^241

Good for: Learning by watching

Ideal Gas & Entropy fills a box with molecules that do nothing but fly in straight lines and bounce, elastically, off each other and the walls: the billiard-ball model of a gas that James Clerk Maxwell used in 1860. Colors show speed, blue for slow and red for fast. Start every molecule at exactly the same speed and watch collisions share out the energy until the speeds follow the Maxwell-Boltzmann distribution drawn over the histogram, the curve Maxwell derived and Ludwig Boltzmann showed in 1872 that collisions always drive a gas toward. Simulations of exactly such hard disks and spheres, pioneered by Berni Alder and Thomas Wainwright in 1959, launched the field of molecular dynamics.

Temperature is the molecules' average energy of motion, and pressure is their push on the walls, measured here from every bounce. The chart checks the gas law, pressure × area = N kT, which holds closely; real disks take up a little room, so the ratio sits slightly above 1. Drag the right wall in like a piston and the gas heats up, because molecules bounce faster off a wall moving toward them. Mix in molecules four times heavier and both kinds end up with the same average energy, so the heavy ones move at half the speed. Turn on gravity with walls held at a fixed temperature, and the air thins with height as the barometric formula predicts.

Open a hole between two chambers and the gas spreads until both sides hold about half, and it never gathers back by itself: with 800 molecules the chance of finding them all on one side is about 1 in 10^241, the reasoning Paul and Tatjana Ehrenfest illustrated with their urn model in 1907. Hot and cold chambers mix to one temperature. Press Reverse velocities to run the motion backward, a thought experiment known as Loschmidt's paradox: the gas starts to retrace its steps, but tiny rounding errors grow and the retracing soon breaks down. Tap to heat a spot, and export the molecules as CSV or record a video or GIF.

How to use Ideal Gas & Entropy

  1. Press Play. Molecules fly and bounce, blue when slow and red when fast. The Speeds chart compares their speeds with the Maxwell-Boltzmann distribution.
  2. Pick a start. Start sets how the molecules begin: all at One speed, already Maxwell-Boltzmann, packed into the Left half, or Hot left, cold right.
  3. Compress the gas. Drag the right wall, or set Box width, to push it in or pull it out, and watch the temperature and pressure change while pressure × area ÷ NkT stays near 1.
  4. Open the chambers. Turn on Divider and set the Hole size. The chart tracks the share of molecules in the left chamber, and the readout shows each side's temperature and the mixing entropy.
  5. Mix masses and add gravity. Raise Heavy molecules to mix in molecules four times heavier, or raise Gravity, ideally with Walls hold the temperature on, to see the air thin with height.
  6. Heat and reverse. Tap the gas to heat a spot, an event in time that Restart and share links leave out, change the Temperature, or press Reverse velocities to run the motion backward.
  7. Export. Save a PNG, a video or GIF, or every molecule's position and speed as a CSV file. Record 30 s from the start plays the same gas again from the beginning and records its first 30 seconds.

Frequently asked questions

What is the Maxwell-Boltzmann distribution?

The spread of molecular speeds in a gas at equilibrium. A few molecules are nearly still, a few are very fast, and most move at speeds around the typical one, which rises with temperature and falls with mass. In two dimensions, as here, the share at speed v is proportional to v × e^(−m v² / 2kT). Collisions reshape any starting mix of speeds into this curve.

What is temperature at the level of molecules?

A measure of the molecules' average kinetic energy. In this two-dimensional gas each molecule carries kT of kinetic energy on average, kT/2 for each direction it can move. Heating the gas, or pushing a wall into it, makes the molecules faster; cooling slows them down.

Why does pushing the piston in heat the gas?

A molecule that bounces off a wall moving toward it leaves faster than it arrived, as a ball does off a swung bat. Pushing the wall in does work on the gas, raising its energy and so its temperature. Pulling the wall out does the opposite and cools it, which is why a spray can gets cold.

Why do heavy and light molecules end up with the same energy?

Collisions keep trading energy between them until, on average, each molecule has the same kinetic energy whatever its mass, the equipartition of energy. Since kinetic energy is ½ m v², a molecule four times heavier ends up moving at about half the speed.

Why doesn't the gas go back into one chamber?

Because there are vastly more arrangements with the molecules spread over both chambers than with all of them on one side. Each molecule is equally likely to be on either side, so all N being on the left has a chance of (1/2)^N, which is effectively zero for hundreds of molecules. That is the statistical meaning of entropy increasing, and why the share in the left chamber hovers near half with small fluctuations.

Does the gas really retrace its steps when reversed?

For a while. The laws of motion work the same backward, so reversing every velocity should undo the motion exactly. But each collision is computed with tiny rounding errors, and in a gas those errors grow rapidly, so the retracing soon goes astray. This sensitivity is part of why we never see the reverse of everyday processes.

References

  1. Maxwell, J. C. (1860). Illustrations of the dynamical theory of gases. Part I. On the motions and collisions of perfectly elastic spheres. Philosophical Magazine 19(124), 19–32.
  2. Boltzmann, L. (1872). Weitere Studien über das Wärmegleichgewicht unter Gasmolekülen. Sitzungsberichte der Kaiserlichen Akademie der Wissenschaften in Wien 66, 275–370.
  3. Ehrenfest, P., & Ehrenfest, T. (1907). Über zwei bekannte Einwände gegen das Boltzmannsche H-Theorem. Physikalische Zeitschrift 8, 311–314.
  4. Alder, B. J., & Wainwright, T. E. (1959). Studies in molecular dynamics. I. General method. The Journal of Chemical Physics 31(2), 459–466.