Back to the on-screen lesson ·

Partition functions and free energy

The Helmholtz free energy as $-kT\ln Z$, thermodynamic quantities as its derivatives, partition functions of composite systems, the $1/N!$ for identical particles, and the ideal gas and paramagnet derived in a few lines.

Paper packet. Every task here also exists on screen, where it is checked automatically; answers written on paper are not assessed by Nydus. When you are back at a device, enter your answers there.

1. What you will learn

By the end of this lesson you will be able to find a free energy from a partition function, derive entropy, pressure and magnetization from it, combine the partition functions of independent parts, and decide when identical particles need the $1/N!$.

2. What you already have

You can write the partition function of a small system and find its average energy as $-\partial\ln Z/\partial\beta$, and you know the Helmholtz free energy $F = U - TS$ and that $dF = -S\,dT - P\,dV + \mu\,dN$. This lesson joins them: the free energy is the logarithm of the partition function, and everything else follows from it.

3. Words for this lesson

TermWhat it means
Free energy from $Z$$F = -kT\ln Z$.
Composite systemA system made of independent parts; its partition function is the product of theirs.
Distinguishable particlesParticles that can be told apart, such as atoms at fixed lattice sites: $Z = Z_1^N$.
Indistinguishable particlesIdentical particles free to move, such as molecules of a gas: $Z = Z_1^N/N!$.
Translational partition function$Z_{\text{tr}} = V/v_Q$ for one molecule in a box of volume $V$.
Rotational partition function$Z_{\text{rot}} \approx kT/(\sigma\epsilon_r)$ for a linear molecule well above its rotational spacing.
Symmetry number$\sigma$, the number of orientations of a molecule that look identical: $2$ for $\text{N}_2$, $1$ for CO.

4. The free energy is the logarithm of the partition function

For a system in contact with a reservoir, the partition function turns out to be directly the free energy:

$$F = -kT\ln Z.$$

One way to see it: with $\beta = 1/kT$, $F = U - TS$ and $U = -\partial\ln Z/\partial\beta$, differentiating $-kT\ln Z$ with respect to $T$ gives $-S$, exactly as the thermodynamic relation $S = -\partial F/\partial T$ requires, and at $T = 0$ both sides equal the ground-state energy. Once $F$ is known, the thermodynamic identity $dF = -S\,dT - P\,dV + \mu\,dN$ hands over everything:

$$S = -\frac{\partial F}{\partial T}, \qquad P = -\frac{\partial F}{\partial V}, \qquad \mu = \frac{\partial F}{\partial N}.$$

Combining partition functions. If a system consists of independent parts, its energy is a sum, its Boltzmann factors are products, and so is its partition function: $Z = Z_AZ_B$. Then $\ln Z = \ln Z_A + \ln Z_B$ and the free energies add. A molecule's partition function is the product of its translational, rotational and vibrational parts. For $N$ distinguishable particles, $Z = Z_1^N$; for $N$ identical particles free to swap places,

$$Z = \frac{Z_1^N}{N!},$$

because each distinct state appears $N!$ times among the labeled assignments.

The ideal gas. A molecule in a box has $Z_1 = V/v_Q$ (times any internal part). Then $\ln Z = N\ln V + (\text{terms without } V)$, and $P = -\partial F/\partial V = kT\,N/V$: the ideal gas law in one line.

Another way: picture

Think of $Z$ as a count of the states a system can reach, each weighted by how affordable it is at temperature $T$. Its logarithm, like the logarithm of a multiplicity, is an entropy-like measure of how much room the system has, and $-kT\ln Z$ turns that room into an energy. Any change that gives the system more affordable states — a bigger box, a higher temperature — lowers $F$, and the rate at which it does so is the pressure, the entropy or the chemical potential.

Another way: steps

  1. List the states of one part and write its $Z_1$.
  2. Combine parts: multiply; for identical free particles divide by $N!$.
  3. Take $F = -kT\ln Z$, using Stirling's approximation for $\ln N!$.
  4. Differentiate $F$ for the quantity wanted.
  5. Check extensivity and the known limits, such as $PV = NkT$.

5. The method, step by step, and how to check it

  1. One part first. Write $Z_1$ for one particle or one degree of freedom: $1 + e^{-\beta\epsilon}$ for two levels, $1/(1 - e^{-\beta\epsilon})$ for an oscillator, $2\cosh(\beta\mu B)$ for a spin in a field, $V/v_Q$ for a free particle.
  2. Combine. Multiply the partition functions of independent parts. Decide whether identical particles can swap: atoms at fixed sites cannot, gas molecules can and need the $1/N!$.
  3. Take the logarithm. Products become sums, powers become factors, and $\ln N! \approx N\ln N - N$.
  4. Differentiate. Hold the right variables fixed: $T$ and $N$ for pressure, $V$ and $N$ for entropy.

Checks. The free energy of $N$ independent parts must be $N$ times one part's, so it is extensive. Its derivative with respect to volume must give $PV = NkT$ for an ideal gas. The entropy $S = (U - F)/T$ must be positive and, for a system with $g$ states, at most $k\ln g$. And $F$ at very low temperature must approach the ground-state energy, since then $Z \approx e^{-\beta E_0}$.

6. The ideal gas from its partition function

Take $N$ identical molecules in a volume $V$, with no internal structure. One molecule's translational partition function is $Z_1 = V/v_Q$, where $v_Q = (h^2/2\pi mkT)^{3/2}$ is the quantum volume met in the lesson on the thermodynamic identity. Then

$$\ln Z = N\ln\frac{V}{v_Q} - \ln N! \approx N\left[\ln\frac{V}{Nv_Q} + 1\right].$$

So $F = -NkT[\ln(V/Nv_Q) + 1]$. Three derivatives recover three familiar results. With respect to $V$: $P = NkT/V$, the ideal gas law. With respect to $N$: $\mu = -kT\ln(V/Nv_Q)$, the chemical potential. With respect to $T$, remembering that $v_Q \propto T^{-3/2}$: $S = Nk[\ln(V/Nv_Q) + \tfrac{5}{2}]$, the Sackur-Tetrode equation. What took pages of counting earlier in the course takes a few lines here, which is why statistical physicists reach for the partition function first.

7. Molecules: multiplying the parts

A diatomic molecule's energy is, to a good approximation, the sum of its translational, rotational and vibrational energies, so its partition function is the product

$$Z_1 = Z_{\text{tr}}Z_{\text{rot}}Z_{\text{vib}}.$$

At room temperature $Z_{\text{rot}} \approx kT/(\sigma\epsilon_r)$ — about $52$ for nitrogen — and $Z_{\text{vib}} = 1/(1 - e^{-\epsilon_v/kT}) \approx 1.00001$ because the vibration is frozen. Taking logarithms, the free energy splits into a translational, a rotational and a vibrational part, and so does the heat capacity: $\tfrac{3}{2}R + R + (\text{nearly } 0) = \tfrac{5}{2}R$ for nitrogen, the value the first lesson counted by hand.

The symmetry number $\sigma$ is the same identical-particle correction as the $N!$ in a gas, applied to a single molecule: turning a nitrogen molecule end for end gives the same state, so half the orientations are counted twice.

8. Why the free energy is what experiments measure

The free energy is not just a mathematical convenience. For a system held at fixed temperature — a sample in a cryostat, a protein in water at body temperature — the equilibrium state is the one that minimizes $F$, and the work needed to change the system slowly at that temperature is the change in $F$. Stretching a single DNA molecule with optical tweezers, for example, measures the free energy of unzipping its base pairs directly, and those measurements agree with partition-function calculations built from the energies of each base pair. The logarithm of a sum over states has become something a laboratory force gauge can read.

9. Statistical mechanics in three moves

Every calculation in this unit, and in the unit to come, follows the same three moves, and it is worth stating them plainly once.

First, list the states. Quantum mechanics supplies them: the levels of an oscillator, the orientations of a spin, the standing waves of a particle in a box, the rotational levels of a molecule. Each has an energy and, for a level, a degeneracy.

Second, sum the Boltzmann factors. The partition function $Z = \sum_s e^{-E(s)/kT}$ compresses the whole list into one function of temperature, volume and whatever else the energies depend on. Independent parts multiply; identical free particles divide by $N!$.

Third, differentiate the logarithm. $F = -kT\ln Z$, and every thermodynamic quantity is a derivative of $F$ or of $\ln Z$.

The method's power is that the hard physics is all in the first move, and the rest is mechanical. Change the list of states — a gas of photons instead of atoms, electrons that obey the exclusion principle, atoms that attract each other — and the same three moves predict new thermodynamics. That is exactly what the final unit does, and it is why partition functions sit at the center of every statistical mechanics course from here to research.

10. In the world: counting a molecule's rotations with microwaves

Microwave spectroscopy measures the spacing of a molecule's rotational levels directly. Carbon monoxide absorbs at $115.3$ GHz, its first rotational transition, giving a rotational constant of $\epsilon_r = 2.39 \times 10^{-4}$ eV. At $300$ K, $kT = 0.02585$ eV, and its rotational partition function is $kT/\epsilon_r \approx 108$: about a hundred rotational states are thermally accessible.

Radio astronomers use exactly this. Cold clouds of gas between the stars, where new stars form, are mostly hydrogen, which is nearly invisible, but they contain carbon monoxide whose $115$ GHz line the telescopes of the National Radio Astronomy Observatory detect across the galaxy. In a cloud at $15$ K, $kT/\epsilon_r \approx 5$, so only a few rotational levels are populated, and the ratio of the intensities of the first few lines — each a Boltzmann factor over the partition function — measures the cloud's temperature from hundreds of light-years away.

For nitrogen, with two identical atoms, the partition function is $kT/(2\epsilon_r) \approx 52$ at room temperature: the symmetry number removes the orientations that look the same, and the thermodynamic tables of every diatomic gas are built from these numbers.

11. In the world: why rubber and DNA are entropic springs

A polymer chain such as rubber or DNA can be modeled as $N$ links, each pointing forward or backward — a two-state system for each link, with a partition function per link of $2\cosh(fa/kT)$ when a force $f$ pulls on links of length $a$. This is the paramagnet with force in place of field and length in place of magnetization.

The average extension follows exactly as the magnetization did: $L = Na\tanh(fa/kT)$, which for small forces is $L \approx Na^2f/kT$. The chain behaves as a spring with stiffness $kT/(Na^2)$, and the stiffness is proportional to temperature — the signature of an entropic spring, whose restoring force comes from the free energy's $-TS$ term rather than from stretched bonds.

For a DNA molecule, the effective link length is about $100$ nm; a molecule $16$ μm long, pulled by optical tweezers, shows this entropic elasticity at forces below about $0.1$ pN, and the measured stiffness matches the partition-function prediction. Biophysicists use such measurements to watch single proteins unfold and single molecules of DNA unzip, reading free energies one molecule at a time.

12. The partition function is not just a normalization

Because $Z$ first appears as the number that makes probabilities add to one, it is easy to treat it as bookkeeping with no physics of its own. In fact it contains everything thermodynamics can say about the system: its logarithm is the free energy, and derivatives of that give energy, entropy, pressure, magnetization and chemical potential. Two systems with the same list of energy levels have the same $Z$ and the same thermodynamics, whatever they are made of.

A second trap is the $N!$. Leaving it out of a gas's partition function gives an entropy that is not extensive — doubling the gas would not double its entropy — and predicts that removing a partition between two samples of the same gas creates entropy, the Gibbs paradox. Putting it into a crystal of spins at fixed sites is equally wrong, since those spins can be told apart by where they sit. The rule is physical: divide by $N!$ exactly when swapping two particles produces no new state.

13. The free energy and entropy of a two-level system

  1. A two-level system has upper-state factor $e^{-\epsilon/kT} = 0.5$. Write its partition function.

    $Z = 1 + 0.5 = 1.5$

    One factor for each state.

  2. Find the free energy.

    $\dfrac{F}{kT} = -\ln 1.5 = -0.405$

    $F = -kT\ln Z$.

  3. Find the average energy.

    $\dfrac{U}{kT} = \dfrac{\epsilon}{kT} \cdot \dfrac{0.5}{1.5} = \ln 2 \times 0.333 = 0.231$

    The upper state's energy, $\epsilon = kT\ln 2$, times its probability.

  4. Find the entropy.

    $\dfrac{S}{k} = \dfrac{U - F}{kT} = 0.231 + 0.405 = 0.637$

    From $F = U - TS$.

  5. Compare with the largest possible entropy.

    $\dfrac{S}{k} = 0.637 < \ln 2 = 0.693$

    Close to the maximum, since the two states are not far from equally likely.

14. The ideal gas law from the free energy

  1. Write the partition function of $N$ identical molecules in a box.

    $Z = \dfrac{1}{N!}\left(\dfrac{V}{v_Q}\right)^N$

    Independent molecules, divided by $N!$ because they are identical.

  2. Take the logarithm.

    $\ln Z = N\ln V - N\ln v_Q - \ln N!$

    Only the first term depends on $V$.

  3. Write the free energy.

    $F = -kT\ln Z = -NkT\ln V + (\text{terms without } V)$

    $F = -kT\ln Z$.

  4. Differentiate with respect to volume.

    $\left(\dfrac{\partial F}{\partial V}\right)_{T,N} = -\dfrac{NkT}{V}$

    The derivative of $\ln V$ is $1/V$.

  5. Change the sign for the pressure.

    $P = -\dfrac{\partial F}{\partial V} = \dfrac{NkT}{V}$

    From $dF = -S\,dT - P\,dV + \mu\,dN$.

  6. Recognize the result.

    $PV = NkT$

    The ideal gas law, from nothing but the list of a molecule's states.

15. A crystal of independent spins

  1. $N$ electron spins at fixed sites sit in a field $B$. Write one spin's partition function.

    $Z_1 = e^{\mu B/kT} + e^{-\mu B/kT} = 2\cosh\dfrac{\mu B}{kT}$

    Energies $-\mu B$ and $+\mu B$.

  2. Combine the spins.

    $Z = Z_1^N$

    Fixed sites make the spins distinguishable, so no $N!$.

  3. Write the free energy.

    $F = -NkT\ln\left(2\cosh\dfrac{\mu B}{kT}\right)$

    The logarithm of a power.

  4. Find the average energy from $-\partial\ln Z/\partial\beta$.

    $U = -N\dfrac{\partial}{\partial\beta}\ln(2\cosh\beta\mu B) = -N\mu B\tanh\dfrac{\mu B}{kT}$

    The derivative of $\ln\cosh u$ is $\tanh u$.

  5. Find the magnetization from the free energy.

    $M = -\dfrac{\partial F}{\partial B} = N\mu\tanh\dfrac{\mu B}{kT}$

    The field plays the role volume plays for a gas.

  6. Evaluate at $x = \mu B/kT = 0.672$, $1$ T and $1$ K.

    $\dfrac{F}{N} = -kT\ln(2\cosh 0.672) = -0.0862 \times \ln 2.468 = -0.0779\ \text{meV}$

    With $kT = 0.0862$ meV at $1$ K.

  7. Compare with the paramagnetism lesson.

    $\dfrac{M}{N\mu} = \tanh 0.672 = 0.586$

    The tanh law, derived there from counting and here from one partition function.

  8. Find the entropy per spin in the high-temperature limit.

    $x \to 0: \ \dfrac{S}{Nk} = \ln(2\cosh x) - x\tanh x \to \ln 2$

    Two equally likely states per spin.

16. Your turn: two independent two-level systems each have partition function $1.5$. What is the partition function of the pair, and its free energy in units of $kT$?

  1. Multiply the partition functions.

    $Z = 1.5 \times 1.5 = 2.25$

    Independent parts multiply.

  2. Take the logarithm.

    $\ln 2.25 = 0.811$

    Twice $\ln 1.5$.

  3. Your turn: work this step out. Its working is at the end of the packet.

    Write the free energy.

17. Guided practice

A single molecule of an ideal gas in a box has partition function $Z_1$. What is the partition function of $9 \times 10^{20}$ identical molecules in the same box?

18. Guided practice

Complete the worked solution: a molecule has a two-level part whose upper state has factor $0.2$, and an independent three-level part with evenly spaced levels whose middle state has factor $0.2$. Find the molecule's partition function.

  1. Add the two-level part's factors.

    $Z_A = 1 + 0.2 =$ p

    Its two states.

  2. Add the three-level part's factors.

    $Z_B = 1 + 0.2 + (0.2)^2 =$ q

    Evenly spaced levels: the top factor is the square of the middle one.

  3. Multiply the two.

    $Z = Z_AZ_B =$ r

    The energies of independent parts add, so their Boltzmann factors multiply.

19. Guided practice

A system at $389$ K has Helmholtz free energy $F(T, V, N) = -kT\ln Z$. Match each quantity to how it follows from $F$.

$-(\partial F/\partial T)_{V,N}$$-(\partial F/\partial V)_{T,N}$$(\partial F/\partial N)_{T,V}$$F + TS$
entropy
pressure
chemical potential
energy

20. Practice

A two-level system has upper-state factor $f = e^{-\epsilon/kT} = 0.28$ and partition function $Z = 1.28$. Fill in $F/kT$, $U/kT$ and $S/k$ to four decimal places. Take $\ln 1.28 = 0.2469$ and $\epsilon/kT = -\ln 0.28$.

$F/kT$$U/kT$$S/k$
this system

21. Practice

A crystal holds $2000$ independent, distinguishable two-level defects, each with partition function $Z_1 = 1.6$. What is the crystal's free energy from these defects, in units of $kT$? Take $\ln 1.6 = 0.47$.

Answer:

22. Practice

An electron spin sits in a field of $4$ T at $2$ K, where $x = \mu_BB/kT = 1.3434$. What is its Helmholtz free energy, in meV?

Answer: meV

23. Somewhere new

Microwave spectroscopy gives the rotational constant of oxygen as $\epsilon_r = 0.000178$ eV, with symmetry number $\sigma = 2$. What is its rotational partition function at $300$ K? Use $kT = 0.025851$ eV.

Answer:

24. Lesson test

Lesson test: one question per skill, one attempt each, no hints. Your answers are checked when you submit.

25. Test question

A two-level system has upper-state factor $f = e^{-\epsilon/kT} = 0.28$ and partition function $Z = 1.28$. Fill in $F/kT$, $U/kT$ and $S/k$ to four decimal places. Take $\ln 1.28 = 0.2469$ and $\epsilon/kT = -\ln 0.28$.

$F/kT$$U/kT$$S/k$
this system

26. What you can do now

You can go from a list of states to a system's thermodynamics through its partition function. Explain to someone why a gas's partition function is divided by $N!$ but a crystal's is not.

Working for the steps left to you

16. Your turn: two independent two-level systems each have partition function $1.5$. What is the partition function of the pair, and its free energy in units of $kT$?, step 3

$\dfrac{F}{kT} = -0.811$

Twice one system's, as extensivity requires.