First law of thermodynamics (source code)

= First law of thermodynamics
{title2=$dU=\delta Q-\delta W$}
{wiki}

The first law applies <conservation of energy> to a thermodynamic system. For a <closed system> with unchanged bulk <kinetic energy> and <potential energy>, write
$$
dU=\delta Q-\delta W,\qquad \Delta U=Q-W.
$$
Here $U$ is <internal energy>, $Q>0$ is <heat> entering the system and $W>0$ is <work> done by the system on its surroundings. Compression therefore gives negative $W$. Some references define <work> positive when done on the system; their plus sign represents the same balance with a different convention. If bulk <kinetic energy> or <potential energy> changes, include it in the total <energy> balance. <Thermodynamics and Propulsion>[MIT, First law and work sign convention]{ref}

Supplying $1000\,\mathrm J$ of <heat> while a gas does $300\,\mathrm J$ of <work> increases its <internal energy> by $700\,\mathrm J$. Compressing it with $200\,\mathrm J$ of input <work> in an <adiabatic process> instead gives $Q=0$, $W=-200\,\mathrm J$ and $\Delta U=200\,\mathrm J$.

The distinction between $d$ and $\delta$ records state versus path: <internal energy> is a <state function>, whereas <heat> and <work> depend on the process. For an <ideal gas> expanding reversibly at constant <temperature>, $W=Nk_BT\log(V_2/V_1)$ and $Q=W$, since <internal energy of an ideal gas> depends only on <temperature>. Choose $Nk_BT=1000\,\mathrm J$ and $V_2=2V_1$: then $Q=W=693.15\,\mathrm J$. An insulated <free expansion> into vacuum between the same equilibrium endpoints has $Q=W=0$. Both have $\Delta U=0$, yet their transfers differ. Their common <entropy> increase is $Nk_B\log2$. https://web.mit.edu/16.unified/www/FALL/thermodynamics/notes/node40.html[MIT, Ideal-gas entropy differences]{ref}

For a simple compressible equilibrium system of fixed composition, combining the laws gives
$$
dU=T\,dS-p\,dV.
$$
Here $p$ is <pressure> and $V$ is <volume>. This identity relates neighboring equilibrium states. Identifying $T\,dS$ with actual <heat> and $p\,dV$ with actual <work> requires a suitable <reversible thermodynamic process>; an irreversible piston calculation uses the external resisting <pressure> for boundary <work>. This distinction prevents applying a <reversible ideal-gas adiabat> to an <irreversible adiabatic piston compression>.