How to use it
The box holds a gas made of small discs that fly in straight lines and bounce off each other and off the walls. The right-hand wall is a piston. Drag it, or move the Volume slider, to squeeze the gas or let it expand. Heat and Cool add or remove energy, and the Gas sliders add or remove particles. The readouts show pressure p, volume V, particle number N and temperature T, and compare p·V with N·k·T. For an ideal gas the two are equal; here they agree to within a few percent.
Start with the presets. Each process preset sets up the gas and runs one textbook process while the p–V diagram draws its curve next to the theoretical one.
Controls
- Mouse or touch: drag the piston. It travels toward the dashed target line at the chosen piston speed. The page does not scroll while your finger is on the simulation.
- Keyboard (focus the simulation first): Left and Right move the piston, Up and Down heat and cool, Space plays or pauses, the period key advances one step, R resets.
- Buttons: Play/Pause, Step, Reset, Heat and Cool (each press changes the temperature by 10 %), plus a speed slider from 0.25× to 4×.
- Gas: the number of light and heavy particles (a heavy one has four times the mass), and one large Brownian particle with an optional trail.
- Thermostat: holds the gas at the temperature on its slider. Switched off, the box is insulated.
- Piston: its speed, and a free piston that is pushed inward by a constant load instead of being held in place.
- Clear diagram: erases the p–V trace and sets work and heat back to zero.
How it works
Every particle moves in a straight line. When two discs overlap while approaching, they exchange momentum along the line joining their centres. That is an elastic collision: total momentum and kinetic energy are unchanged. A particle that hits the piston bounces with its speed measured relative to the piston, so a piston moving inward sends particles back faster (work heats the gas) and a retreating piston slows them down.
The simulation is two-dimensional, which changes the units. “Volume” V is the area of the box, and pressure p is force per unit length of wall. A light particle has mass 1, the box is 6 units tall and up to 10 wide, and the Boltzmann constant k is 1, so temperature is measured in energy units. Pressure is the momentum handed to the walls, divided by time and wall length, averaged over the last few time units. Temperature is the mean kinetic energy per particle, because in two dimensions each particle has two degrees of freedom carrying ½kT each:
Speeds follow the two-dimensional Maxwell–Boltzmann distribution, drawn as the curve over the histogram:
With the thermostat on, a slow compression is isothermal and follows pV = constant. With it off, no heat flows and the process is adiabatic: pVγ = constant with γ = 2 for this flat gas (for a monatomic gas in three dimensions γ = 5/3). The internal energy is U = NkT, and it changes by the work W done on the gas plus the heat Q added, which the readouts track.
Things to try
- Run the isothermal and then the adiabatic compression and compare the curves. The adiabat is steeper because the work stays in the gas.
- With the thermostat on, halve the volume and check that the pressure doubles. This is Boyle’s law.
- Push the piston in at the fastest speed, then pull it back just as fast. The gas ends hotter than it began: a fast compression cannot be undone.
- Fix the piston and press Heat a few times. Pressure rises in step with temperature while the trace climbs straight up.
- Mix light and heavy particles. Both kinds settle to the same mean kinetic energy, so the heavy ones move at half the speed.
- Add the Brownian particle with its trail and watch its random walk.
Frequently asked questions
Why is pV not exactly equal to NkT?
Two reasons. With a few hundred particles the pressure fluctuates, because wall hits arrive at random. And the discs have a size: if they cover a fraction η of the box, the pressure is higher by a factor of about 1 + 2η. For 300 light particles in the full box that is close to 3 %. Squeeze a crowded box and the excess grows, just as real gases depart from the ideal law at high density.
Why does compressing a gas heat it?
A particle that bounces off a wall moving toward it leaves faster than it arrived, like a ball hit by a bat. Many such bounces raise the mean kinetic energy, which is the temperature.
What is Brownian motion?
In 1827 the botanist Robert Brown saw tiny particles from pollen grains jiggling in water. In 1905 Albert Einstein explained the jiggling as the result of uneven bombardment by molecules. The large particle here is pushed around in the same way.
How does the thermostat work?
It rescales all speeds by a factor very close to 1 many times per time unit, nudging the temperature toward the target. It stands in for walls kept at a fixed temperature.