The engine
Air-standard, internally reversibleThe gas column height is proportional to V, so the piston travel is the real volume ratio of the cycle — not a cartoon. Reservoirs only make contact on the legs that actually exchange heat; on an adiabatic leg the cylinder wall is drawn hatched, meaning insulated. Each of the four processes gets exactly one quarter of the animation, which is a display choice, not kinematics. At cycle speed ×1 one complete cycle takes four seconds, so each leg lasts one second.
Where the gas is right now
Cycle totals
The two diagrams, live and side by side
P–V — the enclosed area is Wnet
- —
- —
- ■ 1–4 = the corner states, ● = the gas right now
T–S — the shaded areas are the heats
- —
- —
- —
- —
- —
Process-by-process bookkeeping
| Process | Kind | V | T | W = ∫P dV | Q (gas side) | Qext (crosses the boundary) | ΔU | ΔS | |ΔU − (Q − W)| rel. |
|---|---|---|---|---|---|---|---|---|---|
| — | — | — | — | — | — | — | — | — | — |
| — | — | — | — | — | — | — | — | — | — |
| — | — | — | — | — | — | — | — | — | — |
| — | — | — | — | — | — | — | — | — | — |
| Closed cycle Σ | — | returns to state 1 | returns to state 1 | — | — | — | — | — | — |
Residuals — the checks you can watch hold
The physics
Governing equations
Equation of state, and what γ buys youPV = nRT
cv = R/(γ − 1) , cp = γR/(γ − 1) , cp − cv = R
- γ comes from the number of active degrees of freedom f: cv = (f/2)R, so γ = 1 + 2/f. Three translations give 5/3; add two rotations for a linear molecule and you get 7/5; add a third rotation and you get 4/3.
- cp − cv = R (Mayer's relation) is exact for an ideal gas and is shown as a live readout — it is a check on the arithmetic, not an assumption.
- U = ncvT for an ideal gas: internal energy depends on temperature alone, never on volume. That is why every ΔU column in the table is just ncvΔT.
dU = δQ − δW , W = ∫ P dV
- Q > 0 means heat enters the gas; W > 0 means the gas pushes the piston out. The opposite convention (W = work done on the gas) flips signs everywhere — check which one a textbook is using before comparing numbers.
ΔS = ncv ln(T2/T1) + nR ln(V2/V1) = ncp ln(T2/T1) − nR ln(P2/P1)
- S is a state function: it depends only on the endpoints, never on the path. That is why Σ ΔS around the closed cycle must be zero, and the residual is on screen.
- Only differences matter, so this page sets S1 ≡ 0 and plots S − S1. Every shaded area on the T–S diagram is a difference, so the choice is free.
- For an internally reversible process, δQ = T dS. Every process on this page is internally reversible, which is exactly why the shaded T–S areas are the heats.
| Process | Held fixed | W | Q | ΔU | ΔS |
|---|---|---|---|---|---|
| Isothermal | T | nRT ln(V2/V1) | = W | 0 | nR ln(V2/V1) |
| Adiabatic | S (Q = 0) | −ncv(T2−T1) | 0 | ncv(T2−T1) | 0 |
| Isochoric | V | 0 | ncv(T2−T1) | = Q | ncv ln(T2/T1) |
| Isobaric | P | P(V2−V1) = nRΔT | ncp(T2−T1) | ncv(T2−T1) | ncp ln(T2/T1) |
Every row satisfies ΔU = Q − W identically. For the isobar that is Mayer's relation in disguise: ncvΔT − ncpΔT + nRΔT = 0.
Reversible adiabat (isentrope)TVγ−1 = const , PVγ = const , TP(1−γ)/γ = const
Closing the loopWnet = ∮ P dV = ∮ T dS = Qin − Qout
η = Wnet/Qin = 1 − Qout/Qin , MEP = Wnet/(Vmax − Vmin)
- The two closed-loop integrals are equal because Σ ΔU = 0 around any cycle and both integrals reduce to ΣQ = ΣW. They are computed here by two separate numeric quadratures over the sampled path, so their agreement is a real check, not an identity the code assumes.
- Back-work ratio comes in two flavours and this page reports both, because they are not the same number. The closed-system one is the ∫P dV absorbed while the gas is compressed over the ∫P dV delivered while it expands, Σ|W−| / ΣW+. The steady-flow one — the number a gas-turbine engineer quotes — is cp(T2−T1) / cp(T3−T4), because a compressor and a turbine are open devices whose work is −Δh and whose flow work is already inside the enthalpy; the constant-pressure legs then contribute no shaft work at all. For Brayton the two even trend in opposite directions with pressure ratio, so the distinction is not pedantry. In a real gas turbine the steady-flow value is 0.4–0.6: nearly half the turbine output goes straight back into the compressor.
- MEP is the constant pressure that would produce the same net work over the same swept volume. It is how engine builders compare cycles independently of size, and it is the number that tells you a Carnot engine is useless in hardware.
ΔSuniv = ΔSgas + ΔSH + ΔSC = 0 − Qin/TH + Qout/TC ≥ 0
- The gas returns to state 1, so its own entropy change over a cycle is exactly zero. All the entropy generated shows up in the reservoirs.
- Rearranged, ΔSuniv ≥ 0 is η ≤ 1 − TC/TH. They are the same statement: η = 1 − Qout/Qin and Qout/Qin ≥ TC/TH.
- For Carnot, ΔSuniv = 0 identically: all heat crosses the boundary at the reservoir's own temperature, so nothing is generated. For Otto and Brayton the heat is added over a range of gas temperatures from a single reservoir at TH, and that finite temperature difference is the whole loss.
- Strictly, each leg's heat should be charged to the reservoir it is actually touching: ΔSuniv = Σ (−Qext,i/Tres(i)). The model computes it that way, because that form is provably non-negative for any parameters. What decides whether it collapses to the shorthand above is not TH > TC — it is whether each leg's external heat carries the sign its own reservoir implies: heat in on the leg touching the hot block, heat out on the leg touching the cold one. Given TH > TC, which the two non-overlapping sliders do guarantee, that holds on Carnot and on Stirling by construction. On Otto and Brayton it holds only while T2 < T3 as well — the temperature sliders cannot buy you this one. Push the compression past TH (experiment 6) and the leg bolted to the hot block starts rejecting heat, at which point the shorthand charges that rejection to TC and the two forms part company: at Otto, monatomic, r = 20, TH = 520 K, TC = 500 K the residual panel reads 4 × 10⁻², not 10⁻¹⁶. On any working engine the two agree to the last bit, and the residual panel turns amber when they stop.
- The regenerator is internal. Over one cycle it returns to its own initial state, so an ideal one contributes nothing to ΔSuniv and nothing to the energy balance — only the (1 − ε) remainder crosses the boundary, and it does so at the reservoir temperature.
| Cycle | η | Depends on |
|---|---|---|
| Carnot | 1 − TC/TH | the two temperatures only — not γ, not the expansion ratio, not n |
| Otto | 1 − r1−γ | compression ratio and γ only — not the temperatures |
| Brayton | 1 − rp(1−γ)/γ | pressure ratio and γ only |
| Stirling | nR(TH−TC)lnr ⁄ [nRTHlnr + (1−ε)ncv(TH−TC)] | temperatures, volume ratio, γ and the regenerator |
Otto and Brayton fall out of the same trick. Both have Qout/Qin = (T4 − T1)/(T3 − T2), and on both cycles T2/T1 = T3/T4 = x, so the ratio collapses to 1/x and every trace of TH and TC cancels. Set ε = 1 in the Stirling expression and it collapses to Carnot.
How much entropy Otto and Brayton actually generateΔSuniv = nc ( u + 1/u − 2 ) ≥ 0 , u = TH / (x TC)
- c = cv and x = rγ−1 for Otto; c = cp and x = rp(γ−1)/γ for Brayton.
- u + 1/u − 2 = (√u − 1/√u)² is a perfect square, so this can never be negative — no parameter choice exists that breaks the second law, which is why the sweep in the test hook passes for every seed.
- It vanishes only at u = 1, which is precisely where Qin → 0 and the engine stops producing work. Reversibility and usefulness are in direct competition; that is the whole subject in one equation.
V(u) = Va(Vb/Va)u ⟹ S(u) = Sa + u ΔS
- The cycle is walked as a continuous path parametrised by u ∈ [0,1] on each leg, with volume (or temperature, on an isochor) interpolated geometrically. Substituting into the entropy expression makes ln(T/Ta) and ln(V/Va) both linear in u — on all four process types. That is a property of the parametrisation, not an approximation.
- P is then obtained from P = nRT/V at every sample, so PV = nRT holds to the last bit and the residual readout is pure rounding.
What to try
- Watch Carnot sit exactly on the bound. Leave everything at its defaults (Carnot, air, TH = 900 K, TC = 300 K, V₂/V₁ = 2) and read the two efficiency boxes. Expected: η = 66.67 % and ηCarnot = 66.67 %, η/ηCarnot = 1.000, and ΔSuniv ≈ 0 at the 10⁻¹⁶ level — not "small", zero. Now change the gas to monatomic, then to polyatomic, then drag the expansion ratio from 1.2 to 8. Expected: Wnet, Qin, the shapes of both diagrams and the MEP all move, and η does not budge by one digit. Carnot efficiency depends on the two temperatures and on nothing else whatsoever.
- Otto: efficiency is geometry, not heat. Switch to Otto (air, TH = 1800 K). Sweep the compression ratio from 4 to 16. Expected: η climbs from 42.6 % to 67.0 %, following 1 − r1−γ exactly. Now put r back to 9 and drag TH from 1200 K to 2200 K. Expected: η is frozen at 58.5 % the whole way — but Wnet and the MEP roughly triple (Qin ∝ TH − T2, and T2 is stuck at 722 K), while the gap to ηCarnot widens from 16.5 to 27.9 points. Raising peak temperature buys you power, not efficiency; only squeezing harder buys efficiency.
- The working gas changes the answer. Stay on Otto at r = 9 and step the gas through monatomic → diatomic → polyatomic. Expected: η = 76.9 %, 58.5 %, 51.9 %. Argon wins because a monatomic atom has nowhere to put energy except translation, so all of the heat raises the temperature that pushes the piston; CO₂ hides energy in rotation, which never pushes on anything. This is not academic — argon-cycle engines and helium closed-cycle turbines exist for exactly this reason, and it is also why a real engine's efficiency drops as combustion products (triatomic H₂O and CO₂) dilute the charge.
- Turn the regenerator on and watch a cycle become reversible. Switch to Stirling (TH = 900 K, TC = 300 K, r = 3, air) and set ε = 0. Expected: η ≈ 26.5 % against ηCarnot = 66.67 %, and ΔSuniv ≈ 1.11 J·K⁻¹ per cycle. Now drag ε to 1.00. Expected: η rises to exactly 66.67 %, ΔSuniv collapses to zero, and Wnet does not change by a single joule — the regenerator moved no work at all, it only stopped you paying twice for the same heat. On the T–S diagram the two shaded regions shrink to the isothermal legs alone.
- Brayton: the pressure ratio that maximises work is not the one that maximises efficiency. Switch to Brayton with TH = 1400 K, TC = 300 K, air. Sweep rp from 2 to 30 and watch two readouts at once: η and Wnet. Expected: η rises monotonically (18.0 % at rp = 2, 57.5 % at 20, 62.2 % at 30) while Wnet peaks near rp ≈ 15 (about 470 J at n = 0.040 mol) and then falls — 464 J at 20, 439 J at 30. The optimum for specific work is at rp = (TH/TC)γ/2(γ−1) ≈ 14.8 here. Meanwhile the steady-flow back-work ratio climbs from 0.261 at rp = 2 to 0.504 at 20 and 0.566 at 30: at high pressure ratio the compressor is eating most of the turbine's output, and a small drop in component efficiency wipes the whole machine out. Watch the closed-system back-work readout beside it: that one falls from 0.609 to a minimum of about 0.446 near rp ≈ 8.3 — it is already climbing again by rp = 15, where it reads 0.464. Note that its minimum sits well below the pressure ratio that maximises Wnet, which is one more reason the two back-work definitions must not be conflated. Two quantities, two shapes, one name — which is why the equations column defines both. Real aero and industrial gas turbines live between these two optima for exactly this reason.
- Try to beat Carnot — and find out why you cannot. Set Otto, monatomic gas (γ = 5/3), r = 20, TC = 200 K. η is now locked at 1 − 20−2/3 = 86.43 %. To beat Carnot you would need ηCarnot < 86.43 %, i.e. TH < 1474 K. Drag TH down toward 1480 K. Expected: η stays pinned at 86.43 %, ηCarnot falls to 86.49 %, and the "fraction of the Carnot limit" readout reaches 0.9993 — while at that same setting Qin has collapsed to 3.2 J, Wnet to 2.8 J and ΔSuniv to 9 × 10⁻⁶ J·K⁻¹, because the compression alone has already lifted the gas to TH and there is nothing left to heat. The bound is approached only in the limit where the engine delivers nothing. Push TH below 1474 K and the page tells you it is no longer a heat engine.
- Watch the two areas agree. Pick any cycle and any parameters and read |WTS − WPV| / Wnet in the residual panel. Expected: around 10⁻⁷ or smaller, everywhere, for every cycle. Those two numbers come from independent numeric integrals of different quantities over different planes; if the state list were wrong anywhere they would disagree in the third digit, not the seventh. It is the single most informative number on the page.
Assumptions and limits
- Ideal gas. PV = nRT with no molecular volume and no attraction. Air at 5 MPa and 700 K has a compressibility factor Z ≈ 1.01, so the error is small at everyday conditions — but at cryogenic temperatures, or near a critical point, this model is simply wrong. A Rankine cycle, which crosses the saturation dome, cannot be described by anything on this page. It fails just as badly under extreme compression, and that failure mode is reachable from these very sliders: Carnot with custom γ = 1.15, TH = 2200 K, TC = 200 K and the expansion ratio V2/V1 pushed to its maximum of 8 demands a 7 × 10⁷ : 1 volume ratio, which puts the gas at a molar volume of 3.6 × 10⁻¹⁰ m³·mol⁻¹ — about 10⁻⁵ of air's own van der Waals excluded volume b ≈ 3.6 × 10⁻⁵ m³·mol⁻¹ — and a peak pressure of 51 TPa. Z there is not 1.01; it is wrong by orders of magnitude. The warning strip says so when you get there, but the numbers on screen are arithmetic at that point, not physics.
- Constant specific heats — "cold-air-standard". Real air's cp rises from about 1.005 to 1.24 kJ·kg⁻¹·K⁻¹ between 300 K and 2000 K as vibrational modes wake up, so γ falls from 1.400 to about 1.30. Holding γ fixed at 1.4 over-predicts Otto efficiency by several percentage points at realistic peak temperatures. A variable-cp ("air-standard") analysis using gas tables is the next step up, and it is what a real design calculation uses.
- γ = 4/3 for polyatomics is the rigid-rotor equipartition value (6 degrees of freedom). Real CO₂ at 300 K has γ = 1.289 because its bending modes are already partly excited. Treat the polyatomic option as "a gas with more internal degrees of freedom", not as a data sheet for CO₂.
- Internally reversible and quasi-static. The gas is uniform at one T and one P at every instant, there is no friction, no throttling, no pressure drop, no turbulence and no finite-rate heat transfer inside the gas. Every real process is slower or faster than the gas can equilibrate, and the difference is lost work.
- Air-standard closed cycle. Otto and Brayton are really open cycles: they induct air, burn fuel in it and throw the products away. Modelling them as a fixed mass of air with external heat addition is the standard idealisation, but it discards combustion chemistry, the mass and enthalpy of the fuel, residual exhaust gas, valve and intake losses, and the pumping loop. Real indicated efficiency is well below the air-standard value.
- The piston is a stand-in. A Brayton cycle runs in a steady-flow compressor and turbine, and a Stirling engine uses two pistons and a displacer. The single cylinder drawn here visualises the specific volume of the working fluid around the cycle, not the hardware. Nothing on this page is a mechanism drawing.
- Reservoirs are infinite and isothermal. Real heat sources have finite capacity and a temperature glide as they give heat up. Against a finite source the reversible bound is lower than 1 − TC/TH, and pinch analysis rather than a single Carnot number is the right tool.
- Only external irreversibility is counted. ΔSuniv on this page comes solely from heat crossing a finite temperature difference at the machine's boundary. Friction, mixing, unrestrained expansion, finite-rate combustion, heat leak and mechanical losses all add more. The efficiency shown is therefore an upper bound on any real machine passing through the same states, never a prediction.
- Indicated work, not brake work. There is no crank friction, no bearing loss, no oil pump, no alternator. A real engine's brake efficiency is typically 0.75–0.90 of its indicated efficiency.
- Ideal regenerator. Effectiveness ε is applied as a clean fraction of the isochoric heat, with no dead volume, no pressure drop, no mass carry-over and infinite thermal capacity. Real Stirling regenerators reach ε ≈ 0.95–0.99, and the last percent costs real money.
- Equal time per leg. Each process gets a quarter of the animation. A real crank spends its time quite differently, and the Otto blowdown is nearly instantaneous. The path drawn is a thermodynamic path; there is no kinematics or dynamics in this page at all.
- Entropy is relative. S1 ≡ 0. Absolute entropies need the third law and a reference state; nothing here requires them, and no result would change.
- Numerical honesty. The two closed-loop integrals are composite trapezoid rules on 2000 samples per leg. Their ≈10⁻⁷ relative error is the only number on the page larger than double-precision rounding, and it is quadrature error, not physics.
Why an engineer should care
Every number in the readout panel has a direct counterpart on a real machine's data sheet. The compression ratio in experiment 2 is limited in a spark-ignition engine not by thermodynamics but by knock — the end gas auto-ignites once T2 gets too high — which is why petrol engines sit near r = 10–12 while a diesel, compressing air alone and injecting fuel afterwards, runs 15–22 and is correspondingly more efficient. The back-work ratio in experiment 5 is why a gas turbine's compressor absorbs 40–60 % of the turbine's gross output, why a shaft failure is catastrophic rather than merely expensive, and why compressor polytropic efficiency is worth a fortune per point. The choice between the pressure ratio that maximises specific work and the one that maximises efficiency is a live argument in every gas-turbine selection: aero engines lean toward specific work because weight matters, industrial frames lean toward efficiency because fuel does.
The exhaust temperature T4 that experiment 5 leaves at 700–800 K is the entire commercial basis of the combined cycle: a bottoming steam Rankine plant harvests the Brayton exhaust and lifts overall efficiency from the high forties into the low sixties, which is the largest single efficiency gain in the history of thermal power generation. And the same second-law bookkeeping — Q(1 − T0/T), the exergy of a heat stream — is what an engineer actually writes on a plant heat balance to decide where the losses are worth chasing. A 200 MW loss at 1400 K and a 200 MW loss at 320 K are the same joules and are not remotely the same problem.
One thing this page also shows by omission: the Carnot bound applies to heat engines, and only to heat engines. A battery, a fuel cell and a photovoltaic module convert energy without a thermal intermediate, so 1 − TC/TH simply does not constrain them — which is exactly why a BESS round-trip efficiency of 88 % is unremarkable while a heat engine at 88 % would be a Nobel prize.