Science Lab · Chemistry & Physics
Gas in a Box
A box of helium and argon atoms, drawn to scale and slowed down a hundred billion times. Push the piston, heat the walls, pull out the divider, and watch what the atoms do. The gauge and the graphs show why squeezing a gas raises its pressure, why heating it does the same, and why a bike pump gets warm.
Scenes
Live numbers
- Temperature
- —
- Pressure
- —
- averaged over
- —
- Volume (area)
- —
- P·A
- —
- N·k·T
- —
- P·A ÷ N·k·T
- —
- Helium
- —
- Argon
- —
- Work by piston
- —
- Heat from walls
- —
Helium and argon: average speed and average kinetic energy of one atom. A 2-D pressure is a force per length of wall, in millinewtons per meter. 1 zJ (zeptojoule) = 10⁻²¹ J. The pressure is averaged from a moment after your last change, so wait a few seconds after each change.
Missions
Keys, with the box selected: ↑ ↓ move the piston, ← → change the temperature, D the divider, space pauses. Tap an atom to follow it.
What you're seeing
The box is a thin slice of gas, drawn to scale. It is 28 nanometers wide (a nanometer is a billionth of a meter). The gold dots are helium atoms, 0.14 nm in radius, and the blue dots are argon atoms, 0.188 nm. Each atom flies in a straight line until it hits a wall or another atom, then bounces off without losing any energy.
Real atoms are far too fast to watch. A helium atom at room temperature would cross this box in roughly 20 trillionths of a second, so the simulation runs about 100 billion times slower than real life: one second on screen shows 10 picoseconds (at 1×).
Every flash on a wall is an atom hitting it. The pressure gauge adds up those pushes. The thermometer reads the atoms' average kinetic energy, the histogram sorts the atoms by speed, and the P–V graph traces pressure against volume as you move the piston.
The box holds a few hundred atoms. A real one-liter bottle of air holds about 2.5 × 1022 molecules: 25 thousand billion billion. With that many, the pressure and temperature hold perfectly steady. With a few hundred, you can see them jitter.
The science
Temperature is motion
The temperature of a gas measures how fast its molecules move. More exactly, it measures their average kinetic energy, the energy of motion. In the real, three-dimensional world:
Here m is a molecule's mass, v its speed, T the temperature in kelvins, and k = 1.380649 × 10−23 J/K is Boltzmann's constant. Each direction a molecule can move in carries ½kT of energy on average. Our flat atoms can move in two directions, so they carry kT; real ones carry 3⁄2kT.
At 20 °C (293 K), nitrogen molecules in the air have a root-mean-square speed of about 511 m/s, faster than sound. For light helium atoms it is about 1,350 m/s, and for heavy argon atoms about 430 m/s. In our flat box the same temperature gives speeds about 18% lower, because two directions share less energy than three.
Pressure is collisions
When an atom bounces off a wall, its speed toward the wall, v⊥, flips around, so the wall gets a push of 2mv⊥. In air, each square centimeter of wall gets about 3 × 1023 of these pushes every second, and together they feel like one steady force. Pressure is that force spread over the wall: per square meter in the real world (pascals, N/m²), and per meter of wall in a flat 2-D world (N/m). Adding up the pushes gives the ideal-gas law:
N is the number of molecules and V the volume (in 2-D, the area A). The panel shows both sides of the law live, in zeptojoules. For one liter of air at sea-level pressure (101,325 Pa) and 20 °C, it gives N = PV / kT = 101,325 × 0.001 / (1.380649 × 10−23 × 293.15) ≈ 2.5 × 1022 molecules.
Boyle's law: squeeze it
Keep the temperature and the number of molecules fixed and halve the volume. The molecules are packed twice as tightly, so twice as many hit each bit of wall every second, and the pressure doubles. Pressure times volume stays the same.
Gay-Lussac's law: heat it
Keep the volume fixed and heat the gas. The molecules hit the walls harder and more often, and the pressure rises in proportion to the temperature in kelvins. Going from 300 K to 600 K doubles the pressure. Going from 20 °C to 40 °C does not: that is only 293 K to 313 K, a 7% rise.
Fast and slow at the same time: the Maxwell–Boltzmann distribution
In a gas at one temperature, molecules don't all move at the same speed. Collisions keep trading energy between them, so a few crawl, most move at middling speeds, and a few race at several times the average. The shape of that spread was worked out by James Clerk Maxwell and Ludwig Boltzmann. For a flat 2-D gas it is:
In 3-D, it is f(v) = 4π (m/2πkT)3/2 v² e−m v²/2kT, with root-mean-square speed √(3kT/m). The histogram compares the atoms' real speeds with the 2-D curve.
Heavy molecules move slower
At the same temperature, every kind of molecule has the same average kinetic energy. An argon atom is about 10 times heavier than a helium atom, so it moves √10 ≈ 3.16 times slower:
This is also why light gases leak out through tiny holes faster than heavy ones (Graham's law).
Mixing
Take out the divider, and each atom wanders off in a zigzag, knocked this way and that. Before long both gases fill the whole box. Nothing pushes them to mix. There are simply far more mixed arrangements than sorted ones, so random motion almost always ends up mixed. That is also why mixed gases never sort themselves out again.
Why a bike pump gets warm
When an atom bounces off a piston that is moving toward it, it comes back faster, like a tennis ball off a swinging racket. So pushing a piston in speeds up the atoms: the work you do becomes their kinetic energy, and the gas gets hotter. Pulling the piston out does the opposite, and the gas cools. The energy rule (the first law of thermodynamics) is:
If you pump fast, there is no time for the heat to leak out, so all of the work stays in the gas. For our flat gas of single atoms, squeezing it slowly to half its area doubles its temperature (T · A stays the same). Air in 3-D heats less, but still a lot: squeezed to half its volume with no heat lost, air at 20 °C would reach about 114 °C. In a real pump the air keeps leaking heat to the metal, and friction adds some warmth too, which is why the barrel ends up warm rather than hot. Diesel engines squeeze air so hard and so fast that it gets hot enough to light the fuel without a spark.
The cooling side matters too. Air that rises in the sky expands as the pressure drops, and it cools by about 9.8 °C for every kilometer it rises (when it is dry). That cooling is how clouds form.
Try this
A common mix-up
"When a gas gets hot, its molecules get bigger." They don't. A helium atom is the same size at 100 K and at 1,000 K, and so are the atoms in the box. What changes is their speed. Faster atoms hit the walls harder and more often, so the pressure rises. If the walls can give, as a balloon's can, the gas pushes them out and takes up more room. The gas expands, but each molecule stays the same size.
A related mix-up: "slow molecules are colder." In Two gases, the argon atoms are about three times slower than the helium atoms, but they are at exactly the same temperature, because temperature is about energy, not speed.
How the simulation works
The model. Each atom is a hard disk with its real mass (helium 4.0026 u, argon 39.948 u) and its van der Waals radius. Atoms feel no force except when they touch, and every collision is perfectly elastic. Helium and argon are good choices for this: they are single atoms with no parts to spin or wobble.
The steps. Each frame is cut into sub-steps short enough that no atom moves more than 0.08 nm. A grid of 0.55 nm cells finds the pairs that could touch, and for each one the exact moment of contact is solved for, so atoms bounce at the true distance. The walls are mirrors. The piston bounces atoms in its own moving frame, which is how it does work on the gas. Thermostat walls send each atom that hits them back with a random velocity drawn from the wall's temperature.
The readings. Pressure is the total momentum the atoms give the four outer walls, divided by the time and the length of wall. Temperature is the total kinetic energy divided by N k. The pressure shown is averaged from a moment after your last change, so it gets steadier the longer you wait.
What's simplified. The box is flat (2-D), it holds hundreds of atoms instead of 1022, and time is slowed 1011 times. Real atoms also pull on each other slightly when close, which is why real argon turns liquid below 87 K. Ours never attract, so they stay a gas at any temperature.
How it was checked
| Test | Result | Expected |
|---|---|---|
| Energy, 240 atoms, insulated walls, 3,000 ps, 95,243 collisions | drift 3 × 10−14 | 0 |
| Ideal-gas law with tiny atoms (P·A ÷ N·k·T) | 1.002 | 1 |
| Same, real-size helium, 100 atoms | 1.033 | 1.034 (hard-disk theory with wall effect) |
| Same, 250 atoms | 1.067 | 1.069 |
| Speeds vs. 2-D Maxwell–Boltzmann, after starting at one speed | largest gap 0.7% | 0 |
| Equipartition, He started at 600 K, Ar at 100 K: energy ratio | 1.002 | 1 |
| Same: average speed of He ÷ Ar | 3.159 | √(39.948 / 4.0026) = 3.159 |
| Thermostat walls at 600 K: gas temperature | 598.9 K | 600 K |
| Boyle: pressure at half the area ÷ full area (thermostat) | 2.04 | 2.07 (hard-disk theory; 2 for an ideal gas) |
| Gay-Lussac: pressure at 600 K ÷ 300 K | 2.001 | 2 |
| Very slow (5 m/s) insulated squeeze to half the area: temperature ratio | 2.099 | 2.093 (2 for an ideal gas) |
| Same squeeze with the piston at 100 m/s (Slow) and 800 m/s (Fast) | 2.111 and 2.570 | more than 2.093, since a moving piston does extra work |
| Same squeeze: work done by piston vs. energy gained | 685.126 zJ vs. 685.126 zJ | equal |
Our atoms take up a little room, and in a box only 28 nm wide that shows: the pressure runs a few percent above the ideal-gas law. The measured values match the equation of state for hard disks (Henderson, 1975), corrected for the space the atoms can't reach next to the walls.
Sources
- NIST, CODATA values: Boltzmann constant (1.380649 × 10−23 J/K, exact) and atomic mass constant.
- NIST, Atomic Weights and Isotopic Compositions (helium 4.002602, argon 39.948).
- OpenStax, College Physics 2e, 13.4 Kinetic Theory (nitrogen's rms speed of 511 m/s at 20 °C; average kinetic energy 3⁄2kT).
- OpenStax, Chemistry 2e: 9.4 Effusion and Diffusion of Gases (Graham's law) and 9.5 The Kinetic-Molecular Theory.
- OpenStax, University Physics Volume 2, 2.4 Distribution of Molecular Speeds and 3.6 Adiabatic Processes for an Ideal Gas.
- A. Bondi, "van der Waals Volumes and Radii," Journal of Physical Chemistry 68, 441 (1964): radii of helium (140 pm) and argon (188 pm).
- D. Henderson, "A simple equation of state for hard discs," Molecular Physics 30, 971 (1975).
- Wikipedia, Lapse rate (dry adiabatic lapse rate, 9.8 °C/km) and boiling points of the elements (argon, 87.3 K).