Solution (source code)

= Solution

\b[The <Second law of thermodynamics> restricts which energy-conserving processes can occur.] In the <Kelvin-Planck statement of the second law>, no cyclic engine can have as its sole effect the extraction of <heat> from one reservoir and its complete conversion into work. In the <Clausius statement of the second law>, no process can have as its sole effect transferring <heat> from a colder reservoir to a hotter one. An engine or refrigerator combined with the reverse of a reversible device shows that a violation of either statement would violate the other.

A <heat engine> takes <heat> $Q_h>0$ from a reservoir at $T_h$, rejects $Q_c>0$ to one at $T_c<T_h$, and returns its working substance to the initial state. Energy conservation gives $W=Q_h-Q_c$ and efficiency $\eta=W/Q_h=1-Q_c/Q_h$. \b[<Carnot's theorem>] states that no engine between these reservoirs is more efficient than a reversible one, and that all reversible engines between them have the same efficiency. Otherwise, drive a reversible engine backwards with the work of a more efficient engine; the composite cycle transfers <heat> from cold to hot without external work, contradicting the Clausius statement.

A reversible <Carnot cycle> consists of two isotherms joined by two reversible adiabats. For an ideal gas, $Q_h=Nk_BT_h\log(V_2/V_1)$ and $Q_c=Nk_BT_c\log(V_3/V_4)$. The adiabats give $V_2/V_1=V_3/V_4$, so
$$
\boxed{\frac{Q_c}{Q_h}=\frac{T_c}{T_h},\qquad\eta_{\rm reversible}=1-\frac{T_c}{T_h}.}
$$
<Carnot's theorem> makes this independent of the working substance and defines the thermodynamic absolute-<temperature> scale consistently with ideal-gas <temperature>.<Classical Thermodynamics by David Tong>[Sections 4.3.1–4.3.2: heat engines, Carnot's theorem and temperature]{ref}

For any reversible cycle, $\oint\delta Q_{\rm rev}/T=0$. This makes the integral between two equilibrium states independent of the reversible path, defining the <state function> <entropy>:
$$
\boxed{S_B-S_A=\int_A^B\frac{\delta Q_{\rm rev}}T.}
$$
<Heat> itself is path dependent; <entropy> is not. An irreversible change can be evaluated using any imagined reversible path between its equilibrium endpoints. For example, a fixed amount of ideal gas with constant $C_V$ has $\Delta S=C_V\log(T_B/T_A)+Nk_B\log(V_B/V_A)$.

For a general cycle the <Clausius inequality> is $\oint\delta Q/T_{\rm boundary}\leq0$. The <entropy> balance for a process is $\Delta S\geq\int\delta Q/T_{\rm boundary}$, with equality for reversible <heat> exchange and no <entropy production>. The surroundings' <entropy> must be included, giving \b[$\Delta S_{\rm universe}\geq0$]. A system's own <entropy> can decrease by exporting <entropy>; an isolated system's cannot.

The engine's reservoirs have net <entropy> change $Q_c/T_c-Q_h/T_h\geq0$, so
$$
\boxed{\eta\leq1-\frac{T_c}{T_h},}
$$
with equality for a reversible engine. Friction, <heat> flow through a finite <temperature> difference and unrestrained expansion produce <entropy> and reduce usable work. Thus energy conservation fixes the balance of <heat> and work, while the second law fixes their direction and the attainable efficiency.<Classical Thermodynamics by David Tong>[Section 4.3.3: entropy as a state function and the second law]{ref}