Presets
Playback
Gas
Molecule count, bath temperature and collision rate.
Piston
Move the piston, or let it float at an external pressure.
Layers
Model checks
The science
Pressure from impacts
Pressure is the average momentum handed to a wall per unit time and length. A molecule of mass m hitting the piston at normal speed v_x (piston speed u) gives it an impulse 2 m (v_x - u). Summing all hits, the simulation measures P directly, then compares it with the ideal-gas law, which in two dimensions reads P A = N k T with T = <(1/2) m v^2> / k (two degrees of freedom). The pressure readout and the ideal value agree within statistical noise.
Boyle, Charles, Gay-Lussac
With the heat bath ON the temperature is held fixed, so squeezing the piston gives P V = const (Boyle). With the free piston at a fixed external pressure, raising T raises V in proportion (Charles). With the piston held fixed, raising T raises P in proportion (Gay-Lussac).
Adiabatic change
With the bath OFF the gas is insulated. Compression does work on it and heats it. For a gas with f degrees of freedom gamma = (f + 2)/f; in 2D f = 2, so gamma = 2, giving T V^(gamma-1) = T V = const and P V^2 = const. The purple curves in the graphs show this adiabat.
Simplifications
Reduced units (mass = 1, k = 1, box height = 1). Point particles with no volume and no forces between them. Collisions are modelled as random elastic pair exchanges at an adjustable rate, which is what lets the gas stay isotropic and relax to a Maxwell speed distribution; they do not depend on position. The 3D gas would have gamma = 5/3, the 2D one has gamma = 2.
What to try
- Press the Boyle preset: halve L with the bath on and watch P double along the blue isotherm.
- Press the adiabatic squeeze preset: T rises as 1/V and the measured points follow the purple adiabat, steeper than the isotherm.
- Turn the collision rate to 0 and squeeze: only the x-motion heats up, so the adiabat no longer holds.
- Use the free piston, then raise the bath temperature: the gas expands to keep P equal to P_ext (Charles).