Physics · Thermodynamics Seven steps · seven instruments U   H   F   G   μ

The energy ledger

Thermodynamics hands you four different “energies” — internal energy, enthalpy, Helmholtz free energy, Gibbs free energy — and never quite says why there are four. This page builds them one at a time, out of a single accounting problem, using one running example: a cylinder of water sitting in a room.

The whole idea, in one sentence

You are always just maximising the entropy of the entire universe — and the different “energies” are that one rule rewritten so you never have to look outside your own cylinder.

Here is the running example. A sealed cylinder holds some water. It sits in a room. The room is enormous compared to the cylinder: it holds the temperature at \(T\) no matter how much heat the water dumps into it, and it presses on the cylinder’s piston with a pressure \(P\) no matter how much the water expands. Everything below is about one question — which way will the water go, and what will it do on the way?

Two vocabulary items before we start, both defined properly as they come up. Internal energy \(U\) is all the energy stored inside the cylinder: the kinetic energy of the molecules plus the energy in the bonds between them. Entropy \(S\) counts how many distinct microscopic arrangements of those molecules look identical from outside; \(S = k_B \ln \Omega\), where \(\Omega\) is that count and \(k_B\) is Boltzmann’s constant, a fixed conversion factor between counting and the units we happen to measure temperature in.

Step 1The only law there is

Nature does not minimise energy. It maximises count.

A widespread half-truth says systems “seek the lowest energy state.” If that were true, every room-temperature glass of water would already be ice, since ice is the lower-energy arrangement. It is not, so something else is being optimised.

The actual law is about counting. Energy moves around blindly, and every microscopic arrangement consistent with the total energy is equally likely. So the system spends almost all its time in whatever macroscopic situation has the most microscopic arrangements behind it. Written with \(S = k_B \ln \Omega\), that is the second law:

\[ \Delta S_{\text{universe}} = \Delta S_{\text{system}} + \Delta S_{\text{surroundings}} \;\ge\; 0. \]

The words system and surroundings just mean the cylinder and the room. And notice what the inequality does not say: it does not say \(\Delta S_{\text{system}} \ge 0\). The water is entirely free to become more ordered, as long as the room becomes disordered by more than it gains. Freezing does exactly this.

The widget below is the smallest honest model of that trade. A tiny “droplet” of 12 oscillators passes quanta of energy back and forth with a “room” of 200 that already holds 70 quanta of its own. We cram 60 more into the droplet and let energy hop at random. Watch which entropy goes down.

A hot droplet dumping its energy into a cold room

live simulation · press run · energy is exactly conserved

Every hop moves one quantum from a randomly chosen oscillator to another randomly chosen oscillator — no rule tells energy to leave the droplet. It leaves because there are overwhelmingly more ways to arrange it once it has.

The formal version

Each solid is an Einstein solid: \(N\) identical quantum oscillators sharing \(q\) indistinguishable quanta of energy. The number of ways to distribute them is the number of ways to place \(q\) balls in \(N\) boxes, \[ \Omega(N,q) = \binom{q+N-1}{q}. \] Sanity check by hand: for \(N=3,\,q=3\) this gives \(\binom{5}{3}=10\). Two such solids with \(N_A=N_B=3\) sharing \(q=6\) quanta have \(\Omega_A\Omega_B = 10\times 10 = 100\) at the even split, and \(\sum_{q_A} \Omega_A \Omega_B = \binom{11}{6} = 462\) in total — so the single most likely split already holds 22% of everything. The widget uses \(N_A = 12\) and \(N_B = 200\) sharing 130 quanta, 60 of which start in the droplet. The entropy maximum sits at \(q_A = 6\), where \(\Omega_A = \binom{17}{6} = 12376\). Along the way \(S_A/k_B\) falls by \(19.15\) and \(S_B/k_B\) rises by \(60.69\), for a net gain of \(41.54\) — a decrease in the droplet, an increase in the universe.

Step 2Eliminating the room

A big room has a boring entropy: a straight line.

Step 1 leaves us with an impractical law. To predict what the water does, we apparently have to count arrangements of the entire room too. Nobody wants to do that.

We get away with not doing it because of one fact: a large reservoir’s entropy is a straight line in the energy it gives away. The room is so big that handing over a droplet’s worth of energy barely changes its temperature, and a function whose slope does not change is a line. That slope has a name. Define

\[ \frac{1}{T} \;\equiv\; \left(\frac{\partial S}{\partial U}\right)_{V,N}, \]

which is what temperature actually is: how much entropy you buy per unit of energy you take in. A cold thing has a steep slope — energy is precious to it, each joule unlocks a lot of new arrangements. A hot thing has a shallow slope. Energy flows from shallow to steep because that is where the same joule buys more count, and that is the whole content of “heat flows from hot to cold.”

Now the bookkeeping collapses. If the cylinder absorbs energy \(U\), the room loses exactly that much, so along its straight line \(\Delta S_{\text{room}} = -U/T\), and

\[ S_{\text{univ}}(U) \;=\; S_{\text{sys}}(U) \;-\; \frac{U}{T}. \]

Multiply by \(-T\) — a negative number, so maxima become minima — and the right-hand side turns into a quantity built only from the cylinder’s own variables:

\[ -T\,S_{\text{univ}} \;=\; U - T S_{\text{sys}} \;\equiv\; F, \qquad \textbf{the Helmholtz free energy.} \]

\(F\) is not a new physical quantity. It is \(S_{\text{univ}}\) written upside down and rescaled. Minimising \(F\) is maximising the entropy of the universe, and you never once had to look at the room. Build the picture below layer by layer and watch the two maxima land on the same spot.

Why the room’s entropy curve straightens out

staged reveal · drag the room size

Horizontal axis: how many of the 60 quanta sit in the droplet. Shrink the room and its entropy curve visibly bends — and once it bends, \(F\) and \(S_{\text{univ}}\) stop agreeing about where equilibrium is. The straight line, the fixed \(T\), and the right to use \(F\) at all are one privilege that a reservoir earns by being large.

Step 3The move, named

Trading a variable you cannot hold for one you can.

Step 2 did something worth naming, because we are about to do it twice more. Look at what changed. Before, the natural description of the cylinder was \(U(S)\): tell me its entropy and I will tell you its energy. But in a lab you cannot dial in entropy. You can dial in temperature — you set the thermostat and wait.

So we swapped the variable. \(F(T) = U - TS\) contains exactly the same information as \(U(S)\), re-indexed by the slope \(T = \partial U/\partial S\) instead of by the position \(S\). That swap is called a Legendre transform, and it has a picture: instead of describing a convex curve by its points, describe it by its tangent lines — each tangent labelled by its slope, and recorded by where it crosses the axis.

That crossing is the free energy. Roll the tangent along the curve below and watch \(F(T)\) get traced out one intercept at a time. Nothing is lost: from the family of tangents you can rebuild the original curve as their envelope.

you cannot set
you can set
entropy  S
temperature  T  =  ∂U/∂S
volume  V
pressure  P  =  −∂U/∂V
particle number  N
chem. potential  μ  =  ∂U/∂N

Each row is a conjugate pair: an amount, and the price of one more unit of it. Every thermodynamic potential in this article is made by trading some of the left column for the right. That is the entire family tree.

Rolling a tangent along U(S) to trace out F(T)

live · drag the temperature slider

Model curve: \(U(S) = e^{S}\) in units where \(N k_B = 1\) — the energy–entropy relation of a simple solid. Then \(T = dU/dS = e^S\), so \(S = \ln T\), \(U = T\), and \(F = T - T\ln T\). At \(T = 2\) the intercept should read \(2 - 2\ln 2 = 0.614\).

The formal version, and a sign trap

For a convex \(U(S)\), the Legendre transform is \(U^\star(T) = \sup_S \,[\,TS - U(S)\,]\), and the physicists’ free energy is its negative: \(F = -U^\star = U - TS\). This sign flip is why \(F\) is minimised rather than maximised, and the reliable check is the derivative. From \(dU = T\,dS\) we get \[ dF = dU - T\,dS - S\,dT = -S\,dT \quad\Longrightarrow\quad \left(\frac{\partial F}{\partial T}\right)_V = -S. \] Every potential below can be checked the same way: the variable you traded away reappears as a derivative, with a sign set by whether it was added or subtracted. With volume in play, \(dU = T\,dS - P\,dV\) and \((\partial F/\partial V)_T = -P\), \((\partial G/\partial P)_T = +V\).

Step 4The second tax

Making room costs energy. That is enthalpy.

So far the cylinder had a fixed volume. Now unlock the piston. The room does not only supply heat — it also presses down with pressure \(P\), and if the water wants to expand it must shove the atmosphere out of the way. Pushing a piston of area \(A\) a distance \(d\) against pressure \(P\) costs \(P A d = P\,\Delta V\) of energy, handed to the room and gone.

This wrecks the simplest measurement in the lab. Put a flame under the cylinder and count the joules you deliver. If the piston is bolted shut, every joule lands in \(U\). If the piston is free, some of them leave again as shoving-work, and \(U\) rises by less. Same flame, same temperature rise, different bill.

So define the bill. Enthalpy is the internal energy plus the energy it took to clear a space of size \(V\) in a world at pressure \(P\):

\[ H \;\equiv\; U + PV. \]

Then at constant pressure, energy conservation \(\Delta U = Q - P\Delta V\) rearranges to \(\;Q = \Delta U + P\Delta V = \Delta H\). Enthalpy is the heat you actually have to pay at constant pressure, which is why every chemistry table lists \(\Delta H\) and not \(\Delta U\): reactions in open beakers happen at the atmosphere’s pressure, not at fixed volume. (The identity \(Q_P = \Delta H\) assumes the only work is the \(P\,dV\) kind — no electrical leads, no stirrer.)

Note the shape of \(H = U + PV\): it is the same Legendre move as \(F\), trading volume for pressure, just with the opposite sign because \(P\) is defined as \(-\partial U/\partial V\). Below, two identical gases are heated by identical amounts. One piston is bolted, one is free.

1 mol of argon, 300 K → 400 K
where the joules go
rise in internal energy  ΔU = 3/2 RΔT
+1247 J
shoved into the atmosphere  PΔV = RΔT
  831 J
heat you must supply  ΔH = 5/2 RΔT
+2078 J

Two cylinders, one bolted shut — heated side by side

live molecular dynamics · drag the thermostat

Real 2-D molecular dynamics: 250 particles per cylinder bouncing off a moving wall, with a velocity-rescaling thermostat whose every injection is metered. The piston is held at mechanical equilibrium rather than left to rattle freely — a rattling piston pumps energy into the gas and corrupts the meters — but every joule in the ledger is measured, not assumed: work counted at the piston is summed collision by collision as the kinetic energy each particle loses to the moving wall.

What number should the meters converge to?

A 2-D ideal gas has two translational degrees of freedom per particle, so \(U = N k_B T\) and \(C_V = N k_B\). At constant pressure the ideal gas law \(PV = N k_B T\) forces \(P\,\Delta V = N k_B \Delta T\), so \(C_P = C_V + N k_B = 2 N k_B\). The heat ratio for the same temperature rise should therefore settle near \[ \frac{C_P}{C_V} = 2.0 \qquad (\text{2-D}), \] and in general \(C_P - C_V = N k_B\), which for a mole is the familiar \(C_P - C_V = R\).

Press the experiment button and the widget ramps both thermostats from \(T = 1.0\) to \(1.4\) over about ten seconds — slowly enough that the piston stays near mechanical balance. It then reports \(\Delta U = 100.0\) and \(P\,\Delta V = 100.0\), each exactly the predicted \(N\,\Delta T = 250 \times 0.4\), and a ratio near \(1.9\).

The honest check is the pair of work rows, because they reach the same quantity by unrelated routes. \(P\,\Delta V\) is computed from how far the piston travelled. Work counted at the piston never looks at the piston’s position at all: it sums, collision by collision, the kinetic energy each individual particle is measured to lose to the moving wall. The two agree to within 5–10%, and it is that agreement, not any single meter, that says the simulation is doing mechanics rather than arithmetic.

The residual gap is a consistent shortfall in the collision-counted figure, and \(Q_P\) inherits it, which is why the ratio reads about \(1.9\) instead of \(2.0\). It is small, it is reproducible across every slider setting, and it has not been pinned down — discretising a moving wall into finite timesteps is the obvious suspect, but the simple lag argument predicts a surplus rather than a shortfall, so that explanation does not yet hold together. The books row, by contrast, proves nothing about the physics: heat in, energy stored and work out are the only three channels in the code, so it reads \(0.00\) by construction. Keep it as a regression check on the metering, not as evidence.

The three-dimensional argon numbers in the ledger above give \(2078/1247 = 5/3\), the 3-D version of the same statement.

Step 5Both taxes at once

Gibbs free energy is the full bill for existing.

Now run the argument of step 2 again, with the piston unlocked. The room supplies heat and absorbs shoving-work, so it changes entropy on two counts. When the cylinder absorbs \(\Delta H\) worth of heat at constant \(P\), the room loses that much, and \(\Delta S_{\text{room}} = -\Delta H / T\). Therefore

\[ \Delta S_{\text{univ}} = \Delta S_{\text{sys}} - \frac{\Delta H}{T} \;=\; -\frac{1}{T}\Big(\underbrace{\Delta H - T\,\Delta S_{\text{sys}}}_{\textstyle \Delta G}\Big). \]

So Gibbs free energy \(G \equiv H - TS = U + PV - TS\) is the second law for anything sitting in an ordinary room: it falls, and it stops falling at equilibrium. Every term is a tax. \(U\) is what you store, \(+PV\) is rent paid to the atmosphere for the space you occupy, \(-TS\) is the rebate you get for being spread out over many arrangements.

The competition between those last two is the whole story of phases. Ice has low \(H\) (strong hydrogen bonds, so the energy term likes it) and low \(S\) (a rigid lattice, few arrangements). Steam is the opposite. Since \(G = H - TS\), plotting \(G\) against temperature gives each phase a line whose slope is \(-S\): high-entropy phases dive steeply. Whichever line is lowest is the phase you get, so the steep lines must eventually win, and the crossings are melting and boiling.

Every number in the widget below is real: \(\Delta H_{\text{fus}} = 6.01\) kJ/mol, \(\Delta H_{\text{vap}} = 40.66\) kJ/mol, and the standard entropy of ice, 41 J/mol·K. The crossings are not fitted — they fall out at 273.15 K and 373.15 K.

Three straight lines deciding whether you have ice, water or steam

staged reveal · drag T and the outside pressure

Lowering the pressure only moves the steam line, because only steam has enough volume for \(PV\) to matter. Drop to 0.5 atm and water boils at 81 °C — which is roughly Everest, and why tea is bad up there.

Where the pressure term and the straight lines come from

For a condensed phase, \(V\) is tiny and nearly constant, so \((\partial G/\partial P)_T = V\) barely moves the ice and water lines. For the vapour, treating it as ideal gives \(\int V\,dP = \int (RT/P)\,dP = RT\ln(P/P^\circ)\), so \(G_{\text{gas}}(T,P) = H_g - T S_g + RT\ln(P/P^\circ)\). Setting \(G_{\text{gas}} = G_{\text{liq}}\) gives the boiling point \[ T_b = \frac{\Delta H_{\text{vap}}}{\Delta S_{\text{vap}} - R\ln(P/P^\circ)}, \] which at \(P = 0.5\) atm evaluates to \(40660 / (108.97 + 5.76) = 354.4\) K \(= 81.3\) °C. The measured value is 81.3 °C.

The lines are drawn straight, which assumes each phase’s entropy is constant over the plotted range. In truth \((\partial^2 G/\partial T^2)_P = -C_P/T\), so each line is gently concave. Over 200 K that curvature shifts things by a few percent and moves no crossing appreciably; it is left out so the slope-is-entropy reading stays exact.

Step 6The word “free”

Free means extractable. The rest belongs to the bath.

Nothing so far explains why \(F\) and \(G\) are called free energies. Here is the reason, and it is the sharpest thing on this page.

Take the cylinder, hold it at temperature \(T\), and try to get useful work out of it. You have \(U\) joules stored. You cannot have them all. Extracting work means changing the system’s state, which generally lowers its entropy, and the second law will not permit that unless you pay the room off in heat. The size of that unavoidable payment is \(T\,\Delta S\). What is left over is what you may keep:

\[ W_{\text{out}} \;\le\; -\Delta F = -( \Delta U - T\Delta S ), \]

with equality only for a reversible — infinitely patient — process. \(-\Delta F\) is the maximum work a system at constant \(T\) can deliver; \(T\Delta S\) is the tax, and \(\Delta U\) is only the gross. \(G\) plays the same role once the atmosphere is also in the picture: \(-\Delta G\) is the maximum non-expansion work, because the \(P\,\Delta V\) part is already spoken for by shoving the air. That is the number a battery chemist or a biochemist quotes, and it is why ATP hydrolysis is advertised as \(\Delta G \approx -30\) kJ/mol rather than by its enthalpy.

The widget below expands one mole of gas isothermally from 1 to 2 litres and lets you choose how hard to push back. \(\Delta F\) does not care about your choice — it is a state function, fixed by the endpoints. Your winnings care enormously.

The same expansion, run greedily or patiently

live · set the load, then release the piston

At 100% the load balances the gas exactly, the piston creeps, and you collect the full 1729 J. At 50% the piston lurches out and you collect 864 J — the missing 865 J was never destroyed, it simply arrived in the room as heat instead of in your hands as work.

Step 7The third conjugate pair

When molecules can leave, they carry a price tag.

One column of the ledger in step 3 is still unused. We have traded entropy for temperature and volume for pressure. The last row trades particle number for its price:

\[ \mu \;\equiv\; \left(\frac{\partial G}{\partial N}\right)_{T,P} \]

— the chemical potential, the Gibbs free energy cost of adding one more molecule. Particles flow from high \(\mu\) to low \(\mu\) for exactly the reason heat flows from hot to cold: it raises the total count. Equilibrium is not equal numbers, it is equal \(\mu\).

And \(\mu\) has the same two-part structure as everything else on this page. For a dilute species,

\[ \mu = \underbrace{\varepsilon}_{\text{energy per molecule}} + \underbrace{k_B T \ln n}_{\text{crowding}}, \]

an energy term that pulls molecules toward the comfortable phase, and an entropy term that punishes crowding. Setting \(\mu_{\text{liquid}} = \mu_{\text{vapour}}\) and solving gives \(n_{\text{vap}}/n_{\text{liq}} = e^{-\Delta\varepsilon/k_B T}\) — the vapour pressure of a liquid, derived from a ledger.

Below, molecules hop at random between the liquid and the vapour above it. Nothing pushes them; each move is accepted or rejected by the Metropolis rule alone. Raise \(T\) and watch the population, and then the two \(\mu\) bars, find their own level.

Molecules hopping between liquid and vapour until the prices match

live Monte Carlo · drag T and the binding energy

With \(\Delta\varepsilon / k_B T = 1\) the equilibrium split of 200 molecules is 146 liquid / 54 vapour, since \(200/(1+e^{-1}) = 146.2\). Push \(T\) up and the entropy term wins: the liquid boils away.

Putting it together

There is one law — the universe maximises its arrangement count — and there is one problem with it, which is that you cannot audit the whole universe. Every potential in thermodynamics is a solution to that one problem: fold the surroundings into a correction term, then work with the system alone.

Which correction you need depends only on what the surroundings are allowed to supply. If they supply nothing, use \(U\) and maximise the system’s own entropy. If they supply heat at fixed \(T\), subtract the heat tax \(TS\) and minimise \(F\). If they supply room at fixed \(P\), add the space rent \(PV\) and you get \(H\). If they supply both, you get \(G\). If they also supply molecules, add \(-\mu N\).

Held fixedMinimiseDefinitionNatural variablesWhere you meet it
U, V, N−SS = k ln ΩU, V, Nisolated systems, the raw second law
S, V, NUUS, V, Ninsulated, rigid box
S, P, NHU + PVS, P, Nheats of reaction, calorimetry, flow
T, V, NFU − TST, V, Nstatistical mechanics, F = −kT ln Z
T, P, NGU + PV − TST, P, Nchemistry, phase diagrams, biology
T, V, μΩgrU − TS − μNT, V, μopen systems, adsorption, quantum gases

Read the table as one sentence repeated six times. Each row swaps an amount you cannot control for the price of that amount, which you can — the Legendre transform of step 3 — and each swap adds one term to the ledger. \(H\), \(F\) and \(G\) are not three energies. They are one entropy, seen through three different windows onto the room.

Step 1 and step 2 are covered much more slowly, with the microstate counting done from scratch, in the companion page Free Energy. If the entropy-as-counting move went by too fast here, start there.