Piston-cylinder: one device, two modes, four-phase cycle. A 1D
compressible gas (Lagrangian mass coordinate, von Neumann–Richtmyer
artificial viscosity q) in a cylinder closed at the left,
with a piston at the right pushed by gas pressure and resisted by an
external load F. If F < p_gas the gas
expands and pushes the piston out (engine mode, work out, gas cools).
If F > p_gas the load drives the piston in (pump mode,
work in, gas heats). The Cycle button drives a four-phase
Stirling-like cycle: compress → hold-hot (reject
Qhot to a Thot bath) → expand
→ hold-cold (absorb Qcold from a Tcold
bath). Cumulative dissipation D = ∫(−q·du)dt sets
η_engine = W_net/Q_hot below the Carnot bound 1 − T_cold/T_hot.
EOS p = γρT, T = ε, γ = 0.1.