Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

2.3. Ensemble Averages

Course-wide Conventions & Notation

Overview and Learning Objectives

Once microstate probabilities are known, thermodynamic properties follow as ensemble averages. This section derives canonical expressions for internal energy, heat capacity, and pressure in terms of derivatives of ln⁡Q\ln Q. A recurring theme is that fluctuations are not a nuisance—they encode response functions such as CVC_V.

Section 2.1 emphasized that macroscopic properties are expectation values of microscopic properties, with the expectation taken over the microstate probabilities. Section 2.2 derived the canonical probability distribution for a closed system’s microstates. Here, we connect these results by computing ensemble averages that determine macroscopic properties.

Learning objectives:

Core Ideas and Derivations

Thermodynamic Equilibrium

Recall from Section 1.1 that thermodynamic equilibrium is a state of simultaneous mechanical, thermal, and chemical equilibrium. Below are working definitions of each type of equilibrium:

Thermal contact
A state in which two systems can exchange energy.
Chemical contact
A state in which two systems can exchange matter.
Mechanical equilibrium
A state in which the net force on each particle in the system is zero.
Thermal equilibrium
A state in which there is no net exchange of energy between systems in thermal contact.
Chemical equilibrium
A state in which there is no net exchange of matter between systems in chemical contact.

Internal Energy

The internal energy UU of a macroscopic system at thermodynamic equilibrium is defined as the ensemble average ⟨E⟩\langle E \rangle of the microstate energy EE:

U  =  ⟨E⟩  =  ∑i=1MEi pi,U \;=\; \langle E \rangle \;=\; \sum_{i=1}^M E_i\,p_i,

where EiE_i is the energy of microstate ii, pip_i is the probability of that microstate, and MM is the total number of microstates.

For the canonical ensemble, using the Boltzmann factor and the partition function QQ, we have

U  =  1Q∑i=1MEi e−βEi,U \;=\; \frac{1}{Q} \sum_{i=1}^M E_i\,e^{-\beta E_i},

where β=1/(kBT)\beta = 1/(k_{\mathrm B} T) and

Q  =  ∑i=1Me−βEi.Q \;=\; \sum_{i=1}^M e^{-\beta E_i}.

Partial Derivative of the Partition Function

Taking the partial derivative of QQ with respect to β\beta gives

(∂Q∂β)N,V=  ∑i=1M∂∂β(e−βEi)=  −∑i=1MEi e−βEi.\left(\frac{\partial Q}{\partial \beta}\right)_{N,V} =\; \sum_{i=1}^M \frac{\partial}{\partial \beta}\left(e^{-\beta E_i}\right) =\; -\sum_{i=1}^M E_i\,e^{-\beta E_i}.

Substituting this result into the expression for UU yields

U=  −1Q (∂Q∂β)N,V=  −(∂ln⁡Q∂β)N,V.U =\; -\frac{1}{Q}\,\left(\frac{\partial Q}{\partial \beta}\right)_{N,V} =\; -\left(\frac{\partial \ln Q}{\partial \beta}\right)_{N,V}.

Example: Two-State System

For a two-state system with energies E1E_1 and E2E_2, the partition function is

Qtwo-state=e−βE1+e−βE2.Q_{\text{two-state}} = e^{-\beta E_1} + e^{-\beta E_2}.

Then the internal energy is

Utwo-state=  −∂∂β ln⁡(e−βE1+e−βE2)=  E1 e−βE1+E2 e−βE2e−βE1+e−βE2,U_{\text{two-state}} =\; -\frac{\partial}{\partial \beta}\,\ln\left(e^{-\beta E_1} + e^{-\beta E_2}\right) =\; \frac{E_1\, e^{-\beta E_1} + E_2\, e^{-\beta E_2}}{e^{-\beta E_1} + e^{-\beta E_2}},

which is the ensemble average ⟨E⟩\langle E\rangle.

Source
import numpy as np
import matplotlib.pyplot as plt
from scipy.constants import k, eV
from labellines import labelLines

kB = k / eV  # Boltzmann constant in eV/K

# Define the partition function for a two-state system
def partition_function_two_state(E1, E2, T):
    beta = 1 / (kB * T)
    return np.exp(-beta * E1) + np.exp(-beta * E2)

# Calculate the partition function for a two-state system
E1 = 0
E2 = 0.01  # Energy difference between the two states in eV
T_values = np.linspace(1, 1000, 1000)
Q_values = [partition_function_two_state(E1, E2, T) for T in T_values]

# Calculate the internal energy for a two-state system
beta_values = 1 / (kB * T_values)
ln_Q_values = np.log(Q_values)
U_values = -np.gradient(ln_Q_values, beta_values)

# Plot the internal energy as a function of temperature
fig, ax = plt.subplots(figsize=(4, 4))
ax.plot(T_values, U_values, 'k-')
ax.set_xlabel('Temperature (K)')
ax.set_ylabel('$U_{\\text{two-state}} - E_1$ (eV)')
ax.grid(True)
ax.annotate(
    '$U_{\\text{two-state}} \\rightarrow E_1$', xy=(40, U_values[0] + 0.0001), xytext=(300, 0.001),
    arrowprops=dict(arrowstyle='->', color='b'),
    bbox=dict(boxstyle='round,pad=0.3', fc='w', ec='b'),
    ha='center', va='center', color='b'
)
x_values_high_T = np.linspace(0, 1000, 1001)
y_values_high_T = ((E1 + E2) / 2) * np.ones_like(x_values_high_T)
line = ax.plot(x_values_high_T, y_values_high_T, 'm--', label='$U_{\\text{two-state}} \\rightarrow (E_1 + E_2) / 2$')
labelLines(line, zorder=2.5)
ax.set_xlim(0, 1000)
ax.set_ylim(0, 0.01)

plt.tight_layout()
plt.show()
plt.close(fig)
<Figure size 400x400 with 1 Axes>

Internal energy of a two-state system as a function of temperature, for an energy gap of 0.01 eV0.01\ \mathrm{eV}.

Heat Capacity at Constant Volume

From Section 1.1, heat is energy transferred due to a temperature difference. The heat capacity at constant volume, CVC_V, measures how much heat is required to change a system’s temperature at fixed NN and VV:

CV  =  (∂U∂T)N,V.C_V \;=\; \left(\frac{\partial U}{\partial T}\right)_{N,V}.

Heat Capacity and Energy Fluctuations

In statistics, the variance σX2\sigma_X^2 of a random variable XX is σX2=⟨(X−⟨X⟩)2⟩\sigma_X^2 = \langle (X - \langle X\rangle)^2\rangle. In statistical mechanics, σE2\sigma_E^2 quantifies fluctuations in the total energy:

σE2=  ⟨E2⟩−⟨E⟩2.\sigma_E^2 =\; \langle E^2\rangle - \langle E\rangle^2.

One can show that

σE2=  (∂2ln⁡Q∂β2)N,V=  kB T2 CV,\sigma_E^2 =\; \left(\frac{\partial^2 \ln Q}{\partial \beta^2}\right)_{N,V} =\; k_{\mathrm B}\,T^2\,C_V,

which implies

CV=  σE2kB T2.C_V =\; \frac{\sigma_E^2}{k_{\mathrm B}\,T^2}.

Pressure

In Module 5, we will derive:

  1. A=−kB Tln⁡QA = -k_{\mathrm B}\,T\ln Q, where AA is the Helmholtz free energy.

  2. P=−(∂A∂V)N,TP = -\left(\frac{\partial A}{\partial V}\right)_{N,T}, where PP is pressure.

Combining these expressions gives

P=  kB T(∂ln⁡Q∂V)N,T.P =\; k_{\mathrm B}\,T \left(\frac{\partial \ln Q}{\partial V}\right)_{N,T}.

Worked Example

Two-state internal energy and heat capacity

Consider a two-state system with E1=0E_1=0 and E2=εE_2=\varepsilon. Let x≡βεx\equiv \beta\varepsilon.

  1. Partition function

    Q=1+e−x.Q=1+e^{-x}.
  2. Internal energy

    U=0⋅1+εe−x1+e−x=εe−x1+e−x.U=\frac{0\cdot 1+\varepsilon e^{-x}}{1+e^{-x}} =\varepsilon\frac{e^{-x}}{1+e^{-x}}.
  3. Heat capacity at constant volume

    Differentiate UU with respect to TT (holding NN and VV fixed). Using x=ε/(kBT)x=\varepsilon/(k_{\mathrm B}T) and dx/dT=−x/Tdx/dT=-x/T,

    CV=(∂U∂T)N,V=kB x2 e−x(1+e−x)2.C_V=\left(\frac{\partial U}{\partial T}\right)_{N,V} = k_{\mathrm B}\,x^2\,\frac{e^{-x}}{(1+e^{-x})^2}.
  4. Numerical illustration

    For ε=0.010 eV\varepsilon=0.010\ \mathrm{eV} at T=300 KT=300\ \mathrm{K}, x=0.387x=0.387 and e−x=0.679e^{-x}=0.679, so

    U=0.010 eV×0.6791.679=4.04×10−3 eV,CVkB=x20.6791.6792=3.60×10−2.U = 0.010\ \mathrm{eV}\times \frac{0.679}{1.679}=4.04\times 10^{-3}\ \mathrm{eV}, \qquad \frac{C_V}{k_{\mathrm B}}=x^2\frac{0.679}{1.679^2}=3.60\times 10^{-2}.

Result. UU interpolates between 0 and ε/2\varepsilon/2, while CVC_V peaks when thermal energy is comparable to ε\varepsilon.

Concept Checks

  1. Why is UU obtained from a derivative of ln⁡Q\ln Q rather than from QQ directly?

  2. What does it mean physically when CVC_V is large? When it is small?

  3. In the two-state model, why does CV→0C_V\to 0 both as T→0T\to 0 and as T→∞T\to\infty?

  4. How do fluctuations in energy relate to the system’s ability to exchange heat with a reservoir?

Key Takeaways