Isothermal ideal-gas work (source code)

= Isothermal ideal-gas work
{title2=$W_{\rm by,rev}=nRT\ln(V_f/V_i)$}

For a <reversible thermodynamic process> that changes the <volume (thermodynamics)> of a fixed amount of <ideal gas> at absolute <temperature> $T$, the <work> done by the <gas> is
$$
W_{\rm by,rev}=\int_{V_i}^{V_f}p\,dV
=nRT\int_{V_i}^{V_f}\frac{dV}{V}
=nRT\ln\frac{V_f}{V_i}
=nRT\ln\frac{p_i}{p_f}.
$$
Here $n$ is the <amount of substance>, $R$ the <molar gas constant>, $p$ the <pressure>, and $\ln$ the <natural logarithm>. The <ideal gas law> supplies $p=nRT/V$; the <integral> is the signed <area> under the <pressure>-<volume (thermodynamics)> curve. <Isothermal expansion> gives positive <work>; <isothermal compression> gives negative <work>. A convention counting <work> done on the <gas> instead has $W_{\rm on}=-W_{\rm by}$.<University Physics Volume 2 by Samuel J. Ling and others/3.2 Work, Heat, and Internal Energy>[§3.2, equations 3.3–3.4, Figure 3.5 and the isothermal integral following Figure 3.6]{ref}

For a calculated example, let $n=1\,\mathrm{mol}$, $T=300\,\mathrm K$ and $V_i=10\,\mathrm L$, $V_f=20\,\mathrm L$. The <pressure> falls from approximately $249.4$ to $124.7\,\mathrm{kPa}$, and
$$
W_{\rm by,rev}=Q=nRT\ln2\approx1.729\,\mathrm{kJ},\qquad \Delta U=0.
$$
Traversing the same <isothermal process> backward changes both transfer signs: $W_{\rm by,rev}=Q\approx-1.729\,\mathrm{kJ}$. Neither direction changes <internal energy of an ideal gas>. These stipulated values illustrate the <energy> balance; they are not experimental measurements.

\Image[/isothermal-ideal-gas-signed-work-area.png]
{title=Signed work along an ideal-gas isotherm: expansion and compression}

The shaded geometric <area> is positive in both panels; the direction of the <integral> supplies the sign of <work>. Knowing only the two equilibrium endpoints does not justify shading this curve for an irreversible process. For an idealized piston moving against a specified external resisting <pressure>, boundary <work> is $W_{\rm by}=\int p_{\rm ext}\,dV$. Substitution of the equilibrium <gas> <pressure> requires the appropriate reversible limit. In <free expansion> into <vacuum>, $p_{\rm ext}=0$ and this boundary <work> is zero.