Presets
Playback
Parameters
Camera
Layers
Quality
Model check
The science
What you see. A gas is a crowd of fast, tiny molecules. Each time one hits a wall it hands the wall a little momentum; billions of hits per second add up to a steady push, the pressure. Nothing else is simulated: no pressure formula is put in. The dial and the pressure readout are computed from the hits.
Model. N molecules of mass m = 4.65e-26 kg (nitrogen) move freely in a box. A hit on a fixed wall reverses the normal velocity and gives the wall 2 m vn; a hit on the moving piston uses the speed relative to the piston, v' = 2u − v, so a piston moving in adds energy and one moving out removes it (the origin of adiabatic heating). Pressure = (sum of the hand-overs) / (wall area × time), averaged over 60 ps. Temperature is defined from the kinetic energy, ½ m〈v²〉 = (f/2) k T with f = 3 (3D) or 2 (2D) degrees of freedom. Molecules also scatter off each other: random pairs get a new isotropic relative direction with the same speed, which conserves momentum and energy exactly and spreads the piston's work over all directions (mean-field, not hard spheres, collision rate 0.04 per molecule per picosecond).
Two ways to squeeze. With the heat bath on, the walls keep the temperature fixed, so halving the volume doubles the pressure (Boyle's law, P V = N k T). With it off the box is insulated: the piston does work, the gas heats up and T V2/f = const, P Vγ = const with γ = 5/3 (3D) or 2 (2D). The P-V graph draws both curves through the current point so you can see which one the gas follows.
Honest simplifications. A real 1 atm gas has about 1025 molecules per cubic metre; here a 20 nm box holds a few hundred, so the pressure fluctuates by a few per cent (see the “few molecules” preset). A real gas that small would collide with itself far less than the model (mean free path about 70 nm), so the collision rate is raised about ten times to keep the box in equilibrium; molecules are points (nitrogen's rotation is ignored, so f = 3, not 5, and gamma = 5/3, not the 7/5 of air). Molecules are drawn about 2.7 times too large, the lab is only a stage, and the box edge is fixed at 20 nm in the other directions.
Checks. (1) The pressure found from wall hits equals N k T / V within 4 %. (2) The speed histogram matches the Maxwell law (Kolmogorov-Smirnov distance below 0.04, mean speed within 2 %). (3) Halving the volume at fixed temperature doubles the pressure within 5 % (Boyle). (4) A slow insulated squeeze to half the volume raises T by 22/f within 6 %. All four run on the page when it loads.