Search

Search papers and lessons

Canonical Ensemble

Level 3 · 12 min read

The canonical ensemble gives the probability of each state of a system held at a fixed temperature: lower energy is more likely, weighted by an exponential Boltzmann factor.

On this page

  • Colour = topic mix
  • Discrete math
  • Probability
  • Information theory
  • Thermal physics
  • Sign in to see your progress

TL;DR

A canonical ensemble describes a system that is not isolated but sits in contact with a much larger body at a fixed temperature TT. Each possible state of the system, called a microstate, gets a probability that falls off exponentially with its energy. Low-energy states are the most likely, and raising the temperature makes the high-energy states more common.

The normalising sum over all states is called the partition function ZZ. Once you know ZZ, you can recover the average energy, the entropy and the free energy of the system.

Where you'll see it: in the populations of energy levels in a gas, in the physics of magnetic resonance, and in Monte Carlo simulations of molecules that sample states at a set temperature.

This lesson is physics, not engineering advice or a guide to any real device; the numbers are for illustration.

Intuition

A small system in a large bath

Picture a single molecule in a box of air. It bumps into its neighbours constantly, trading energy back and forth. The rest of the air is so large that it barely changes temperature when the molecule gives up or takes energy. The air acts as a heat bath, a reservoir that fixes TT and absorbs any energy exchanged with the system.

The canonical ensemble is the bookkeeping for that situation. We do not know which exact state the molecule is in at a given moment. We know only that it is in thermal contact with the bath, so over time it visits many states, and the bath sets how often each one is visited.

Two forces pulling in opposite directions

Two things compete. Energy wants the system to settle into its lowest states. Entropy, the count of ways a state can be realised, wants the system to spread across many states. The bath is the tiebreaker. A state with energy EE is penalised by the factor e−E/(kBT)e^{-E/(k_B T)}, where kBk_B is Boltzmann's constant. At low temperature the penalty is steep, so the system sits near the bottom. At high temperature the penalty is gentle, so many states are populated.

The plot below shows that penalty, called the Boltzmann factor, for three temperatures. Energies are in the same units as kBTk_B T, so the curves show the shape rather than absolute numbers.

01234500.20.40.60.81energy E (units of k_B T at T = 1)unnormalised weight
  • T = 0.5
  • T = 1
  • T = 2
The Boltzmann factor is largest at zero energy and falls faster when T is low. Heating the bath flattens the curve and gives high-energy states more weight.

The math

Consider a system with discrete microstates labelled i=1,2,3,…i = 1, 2, 3, \dots, where state ii has energy EiE_i. The canonical ensemble assigns state ii the probability

pi=e−βEiZ,β=1kBT,p_i = \frac{e^{-\beta E_i}}{Z}, \qquad \beta = \frac{1}{k_B T},

where β\beta is the inverse temperature, kBk_B is Boltzmann's constant, and ZZ is the partition function

Z=∑ie−βEi.Z = \sum_i e^{-\beta E_i}.

Dividing by ZZ makes the probabilities add to 1, since ∑ipi=1\sum_i p_i = 1 by construction. If several microstates share the same energy, the sum simply counts each of them, so ZZ also equals ∑Eg(E) e−βE\sum_E g(E)\, e^{-\beta E} with g(E)g(E) the number of states at energy EE.

Where the formula comes from

The Boltzmann factor is what you get by maximising entropy, subject to the constraints that the probabilities sum to 1 and the mean energy is fixed. The Gibbs entropy of a distribution is

S=−kB∑ipiln⁡pi.S = -k_B \sum_i p_i \ln p_i.

This is the same quantity as the Shannon entropy in Entropy, multiplied by kBk_B and written with the natural logarithm. Measured in bits, Shannon's HH satisfies S=kBln⁡2⋅HS = k_B \ln 2 \cdot H.

Maximise SS with Lagrange multipliers: one multiplier α\alpha enforces ∑ipi=1\sum_i p_i = 1, and another, λ\lambda, enforces ∑ipiEi=U\sum_i p_i E_i = U. Setting the derivative of the constrained function with respect to pip_i to zero gives

−kB(ln⁡pi+1)−α−λEi=0,-k_B (\ln p_i + 1) - \alpha - \lambda E_i = 0,

so ln⁡pi=const−λEi/kB\ln p_i = \text{const} - \lambda E_i / k_B. Exponentiating, pi∝e−λEi/kBp_i \propto e^{-\lambda E_i/k_B}. The normalisation fixes the constant, and matching the result to thermodynamics identifies the multiplier with β=1/(kBT)\beta = 1/(k_B T). So the exponential form is not an extra assumption. It is the least-biased distribution consistent with a given average energy.

Thermodynamic quantities from ZZ

Three results follow directly from ZZ. The average energy is

U=⟨E⟩=∑iEipi=−∂ln⁡Z∂β.U = \langle E \rangle = \sum_i E_i p_i = -\frac{\partial \ln Z}{\partial \beta}.

The Helmholtz free energy is

F=−kBTln⁡Z,F = -k_B T \ln Z,

and the entropy follows from S=(U−F)/TS = (U - F)/T:

S=UT+kBln⁡Z.S = \frac{U}{T} + k_B \ln Z.

These three relations mean that knowing the partition function as a function of temperature is enough to get the thermodynamics of the system. The probabilities themselves follow from ZZ as well.

Worked examples

Example
A two-level system by hand

Take a system with two states. The ground state has energy 00 and the excited state has energy ε\varepsilon. Choose the temperature so that βε=ln⁡4\beta \varepsilon = \ln 4, that is e−βε=14e^{-\beta \varepsilon} = \tfrac{1}{4}.

  1. Partition function: Z=e0+e−βε=1+14=54Z = e^{0} + e^{-\beta\varepsilon} = 1 + \tfrac{1}{4} = \tfrac{5}{4}.
  2. Ground-state probability: p0=15/4=45=0.8p_0 = \dfrac{1}{5/4} = \tfrac{4}{5} = 0.8.
  3. Excited-state probability: p1=1/45/4=15=0.2p_1 = \dfrac{1/4}{5/4} = \tfrac{1}{5} = 0.2.
  4. Check: p0+p1=1p_0 + p_1 = 1.
  5. Mean energy: U=ε p1=0.2 εU = \varepsilon \, p_1 = 0.2\,\varepsilon.

Interpretation: the excited state is a quarter as likely as the ground state, so one molecule in five sits in the higher level. Lowering the temperature makes βε\beta \varepsilon larger and pushes p1p_1 toward zero.

Example
Population of an excited state in air at room temperature

Take a molecule with an excited state 0.100.10 electronvolts above its ground state, at T=300T = 300 K. Boltzmann's constant times the temperature is kBT≈0.0259k_B T \approx 0.0259 eV.

  1. Ratio of the two populations: p1p0=e−ε/(kBT)\dfrac{p_1}{p_0} = e^{-\varepsilon / (k_B T)}.
  2. Exponent: 0.10/0.0259≈3.860.10 / 0.0259 \approx 3.86.
  3. Ratio: e−3.86≈0.021e^{-3.86} \approx 0.021.
  4. So about 2 molecules in every 100 sit in the excited state, while the rest are in the ground state.

Interpretation: at room temperature the thermal energy kBTk_B T is only a few hundredths of an electronvolt, so states that are a tenth of an electronvolt up are only slightly occupied. A state several times higher is almost empty. This is why most molecules in air at room temperature stay in their lowest vibrational and electronic levels.

Tradeoffs and failure modes

The canonical ensemble is the right tool when a system's temperature is fixed by a bath and its particle number and volume are fixed too. Other situations call for a different ensemble.

SituationWhat goes wrong with the canonical formBetter choice
The system is fully isolated, energy fixedThe energy fluctuates, which the isolated system does not allowMicrocanonical ensemble
Particles can be exchanged with a reservoirThe particle number is not fixedGrand canonical ensemble
The system is very smallEnergy fluctuations are large, so averages hide structureWork with the full distribution, not just the mean
Particles are identical quantum objects at low temperatureCounting states as if distinguishable gives wrong resultsFermi-Dirac or Bose-Einstein statistics, see Fermi-Dirac Statistics
The system has many interacting partsZZ is a sum over an enormous number of states and cannot be done exactlyMonte Carlo sampling with the Metropolis rule, or approximations

A common mistake is to treat ZZ as if it were the probability of a state. It is not. ZZ is a normalising sum. The probability of a state is its Boltzmann factor divided by ZZ.

History

Ludwig Boltzmann worked out the exponential energy distribution for gas molecules in the late 1860s and 1870s. He showed that a gas in equilibrium spreads its molecules over energies in this way, and he linked entropy to the number of ways a state can be realised. The constant that bears his name was introduced later, by Max Planck, when he wrote the physics in its modern form in the early 1900s.

Josiah Willard Gibbs generalised the idea in the early 1900s. His book Elementary Principles in Statistical Mechanics (1902) introduced the notion of an ensemble, a collection of imagined copies of a system, and treated the case of a system in contact with a heat bath as one of its central cases. The name "canonical" comes from his use of the term. Gibbs's framework is why the same formulas describe a single molecule, a crystal and a magnet.

The partition function became the working tool of statistical physics because it packs the whole thermodynamics into one function. That made the canonical ensemble the default starting point for calculations in chemistry, solid-state physics and, later, computer simulation.

Check yourself

QuestionWhat does the Boltzmann factor e−βEe^{-\beta E} tell you about a state with energy EE?Show answer

It gives the state's weight relative to other states at the same temperature. The probability of the state is this weight divided by the partition function ZZ, which sums the weights over all states. A higher-energy state has a smaller weight, so it is less likely, and the gap between weights grows as the temperature falls.

QuestionA two-level system has energies 0 and ε\varepsilon, with βε=ln⁡3\beta \varepsilon = \ln 3. What is the probability that the system is in the excited state?Show answer

The ratio of weights is e−βε=13e^{-\beta\varepsilon} = \tfrac{1}{3}. The partition function is Z=1+13=43Z = 1 + \tfrac{1}{3} = \tfrac{4}{3}. The excited-state probability is p1=1/34/3=14=0.25p_1 = \dfrac{1/3}{4/3} = \tfrac{1}{4} = 0.25.

QuestionWhy does raising the temperature make high-energy states more likely, even though they carry more energy?Show answer

Temperature sets how much energy the bath can exchange with the system. At high TT the Boltzmann factor e−E/(kBT)e^{-E/(k_B T)} decreases slowly with EE, so the penalty for a high-energy state is small. Meanwhile there are often many more high-energy states than low-energy ones, so their combined weight can become large. Entropy wins when the bath is hot.

QuestionA chemist reports entropy in joules per kelvin, and an information theorist reports the same kind of distribution's entropy as 3 bits. Both are describing one distribution. How do the two numbers relate?Show answer

Both use S=−∑pln⁡pS = -\sum p \ln p up to a constant. The chemist's SS is kBk_B times the natural-log sum, so it carries units of joules per kelvin. The information theorist's HH uses base-2 logarithms and is measured in bits. The two are related by S=kBln⁡2⋅HS = k_B \ln 2 \cdot H. Multiplying 3 bits by kBln⁡2k_B \ln 2 gives the chemist's entropy for the same distribution.

Sources