loading...
running...
How to use
Choose a preset. In free-piston mode the piston settles where the gas pressure equals the external pressure. Use the programmed mode for isothermal or adiabatic squeezes, or run the automatic Carnot cycle and watch the loop on the p-V diagram. Compare the particle speed histogram with the yellow Maxwell-Boltzmann curve, and the measured p-V path with the dashed isotherm and adiabat. Heat burst injects energy (counted in Q). Space pauses, R re-initialises.
Models and baked PBR textures made in Blender; Three.js r160 draws every atom of the same 3D particle model that the 2D page projects onto a side view.
The science
The gas is a set of N point particles (mass m = 1, kB = 1, reduced units) flying in a cylinder of cross-section 1 x 1 and length V. They move ballistically, bounce elastically off the side walls and the piston, and exchange momentum and energy in random pair collisions that conserve both (an isotropic scattering step in the spirit of direct-simulation Monte Carlo). Nothing is assumed about the gas law: pressure is measured as the momentum delivered to the piston per unit time and area,
p = (1/A) Σ Δpx / Δt compare p V = N k T, T = (2/3) <Ekin> / k, f(v) = 4π v² (m/2πkT)3/2 e-mv²/2kT
Processes. With thermostat walls (particles that hit them leave with a fresh Maxwell flux distribution at Tw) a slow compression is isothermal and p V stays constant. With insulated walls the gas is compressed adiabatically; collisions share the extra energy between all three directions, so
T Vγ-1 = const, p Vγ = const, γ = 5/3 (monatomic, 3 degrees of freedom)
The first law is counted explicitly: Q (energy given by the walls) - W (work done on the piston) = ΔU = (3/2) N k ΔT. In the Carnot cycle the piston is driven through an isothermal expansion at Th, an adiabatic expansion to Tc (V multiplied by (Th/Tc)3/2), an isothermal compression at Tc and an adiabatic compression back. The ideal efficiency is 1 - Tc/Th; the measured value is a little lower because the piston moves at a finite speed and the walls take time to equilibrate the gas (irreversibility).
Simplifications. Point particles with no volume or attraction (ideal gas, so no phase change), a constant collision rate instead of a velocity-dependent cross-section, a single monatomic species, noise of order 1/sqrt(N) in all measured quantities (try N = 100), and an artificial thermostat. The numbers are in reduced units; multiply by m, kB and a length scale to convert to a real gas. The checks below test pressure against N k T/V, the speed distribution, p-V and T-V laws and the Carnot efficiency, all measured from the particle motion.