Course-wide Conventions & Notation
Overview and Learning Objectives¶
The canonical ensemble describes a closed system in thermal contact with a large heat bath at fixed temperature. Its central result is the Boltzmann assignment , normalized by the partition function. This section derives and interprets that probability distribution and introduces a two-state system as a concrete model.
In a closed system (energy exchange allowed, matter exchange forbidden) in thermal contact with a heat bath, the appropriate statistical description is the canonical ensemble.
Source
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
from myst_nb import glue
# Helper function to plot a system
def plot_system(ax, title, annotations, boundary_color='b'):
box = mpatches.FancyBboxPatch((0, 0), 1, 1, boxstyle='roundtooth', ec=boundary_color, fc='w')
ax.add_patch(box)
ax.set_title(title, fontsize=14)
ax.text(0.5, 0.5, 'System', ha='center', va='center', fontsize=12)
ax.text(0.5, -0.65, 'Surroundings', ha='center', va='center', fontsize=12)
ax.text(0.5, 1.3, 'Boundary', ha='center', va='bottom', fontsize=12, color=boundary_color)
for annotation in annotations:
if "arrowprops" in annotation: # Arrow annotations
ax.annotate('', **annotation)
else: # Text annotations
ax.text(**annotation)
ax.set_xlim(-1, 2)
ax.set_ylim(-1, 2)
ax.set_aspect('equal')
ax.axis('off')
# Define annotations for each system
annotations = [
dict(xy=(-0.6, 0.15), xytext=(0.15, 0.15), arrowprops=dict(arrowstyle='<->', color='r')),
dict(x=-1, y=0.3, s='Energy', ha='left', va='bottom', fontsize=12, color='r'),
]
fig, ax = plt.subplots(1, 1, figsize=(4, 4))
plot_system(ax, "", annotations)
plt.show()
plt.close(fig)
A closed system exchanges energy—but not matter—with its surroundings.
Learning objectives:
Describe the physical meaning of a heat bath and why its temperature is approximately constant during energy exchange.
Derive the canonical probability and define and .
Use the partition function to normalize probabilities and compute ratios .
Apply the canonical distribution to a two-state system and interpret the low- and high-temperature limits.
Core Ideas and Derivations¶
Probability of a Microstate in the Canonical Ensemble¶
Consider an ensemble of identical closed systems in thermal contact with a heat bath at temperature . A heat bath is an environment so large that it can absorb or release energy with negligible change in temperature.
How Can an Environment Absorb or Release Energy Without Changing Its Temperature?
The key point is that the temperature of a collection of particles is determined by the average kinetic energy per particle. According to the equipartition theorem, for particles with three translational degrees of freedom, the total kinetic energy is
Thus, for a fixed amount of energy transfer, the corresponding change in temperature is
Because the environment has many more particles than the system (), the same energy transfer produces a much smaller in the environment. For example, if (e.g., and particles), then the same yields a temperature change that is ten times smaller for the environment.
This illustrates why an environment (a heat bath) can absorb or release energy nearly isothermally: its very large number of particles (and hence high heat capacity) makes the fractional change in average kinetic energy per particle negligible, even while energy is exchanged.
Thus, even though the total kinetic energy of the universe (system plus environment) remains constant, the environment’s temperature barely changes because any energy loss or gain is diluted among a huge number of particles.
Population ratios depend only on energy differences¶
Intuition tells us that a system is more likely to be found in lower-energy microstates.
Building This Intuition
Consider a raindrop that can exist at two different elevations: one high up at Lake Itasca in northern Minnesota and one low down in the Mississippi River in St. Louis. At the higher elevation, the raindrop has more gravitational potential energy, making that state less favorable. Consequently, the raindrop is more likely to be found at the lower elevation, where its gravitational potential energy is reduced. In essence, systems tend to prefer lower-energy states, which is why, on a macroscopic scale, water naturally flows downhill.
Let and denote the numbers of systems in microstates 1 and 2. We assume the population ratio depends only on the energy difference:
where and are the corresponding microstate energies.
Why Does the Ratio Depend Only on the Energy Difference?
The energy of a system is defined relative to an arbitrary (often convenient) reference level. For example,
The kinetic energy of a moving particle is defined relative to a stationary particle.
The gravitational potential energy of a raindrop is defined relative to the surface of the Earth.
Therefore, only energy differences—not the absolute zero of energy—enter into probability ratios.
Finding an Acceptable Form for ¶
Because ratios multiply, we can write
If is well behaved (e.g., continuous, measurable), it must be of the form
where is an undetermined constant. We will later identify .
Checking the Form of
Using this form for , the functional equation is satisfied:
Converting to a Probability¶
Separating the indices and ,
where is a constant. Therefore, the number of systems in a microstate with energy is
The constant is determined by the normalization condition
Solving for and substituting into the expression for gives
where is the probability of finding the system in microstate and is the partition function.
Alternative derivation roadmap: where does come from?
We will use the canonical-ensemble probability
throughout this module. Before we use it heavily, here are two quick (complementary) ways to see why the exponential “Boltzmann factor” appears.
Setup (common to both routes)¶
System : a closed system (fixed ) with discrete microstates and energies .
Reservoir / heat bath : very large, can exchange energy with , and stays at (approximately) constant temperature .
Universe is isolated, so the total energy is fixed:
Weak coupling: the interaction energy is negligible, so energies add.
The question is: What is the probability that the system is in microstate ?
Route A: “Counting” argument (microcanonical canonical)¶
Idea: the system is more likely to be in a microstate if the reservoir has many compatible microstates when the system has energy .
Fundamental postulate for an isolated system (the universe):
all accessible microstates of at fixed are equally likely.If is in microstate , then must have energy
The number of compatible universe microstates is therefore the number of reservoir microstates at that energy:
So
Convert multiplicity to entropy using Boltzmann’s definition:
Taking logs,
Reservoir is huge expand in a Taylor series around .
Because is “small” compared to the reservoir’s energy scale,Use the thermodynamic definition of temperature (for the reservoir):
So the linear term becomes .
The quadratic term is typically negligible because the reservoir’s heat capacity is enormous:
so the correction looks like , which is tiny when is very large.
Keep only the dominant (linear) term:
Exponentiate to get the Boltzmann factor:
The first exponential is just a constant (independent of ), so the physics is:
Normalize to turn “” into “”. Define the partition function
so
Route B: “Maximum entropy” argument (Gibbs entropy + constraints)¶
Idea: in equilibrium with a heat bath, the system adopts the probability distribution that maximizes entropy subject to what is fixed.
Start from the Gibbs/Shannon entropy functional for a probability distribution :
Impose the two canonical constraints:
normalization:
fixed mean energy:
Maximize with Lagrange multipliers and :
The maximizer satisfies
Rename :
Normalize exactly as before:
Identify with temperature by using the thermodynamic identity
For the canonical distribution one can show , so
Quick checks / intuition (why this form makes sense)¶
Energy differences matter, not absolute zero:
Shifting all energies by a constant leaves all probability ratios unchanged.
Low (large ): weights concentrate on the lowest-energy microstates.
High (small ): many microstates become appreciably populated.Degeneracy is automatic if we sum over microstates:
if many microstates share the same energy, that energy level is more probable because it appears many times in the sum.
Bottom line: In the canonical ensemble, the exponential appears because the reservoir’s multiplicity grows exponentially with its entropy, and the entropy changes approximately linearly with energy over the small energy exchanges relevant to a large heat bath.
Two-State System¶
Consider a system with two microstates (two “levels”): state 1 with energy and state 2 with energy .
Table 1:Chemical Contexts Where a Two-State Approximation Might be Appropriate
Chemical Context | State 1 | State 2 |
|---|---|---|
Electronic transitions in atoms or molecules | Ground state | Excited state |
Donor–acceptor electron transfer | Reduced state | Oxidized state |
Molecular isomerization | Reactant | Product |
Defects in solids | Defect-free | Defective |
Protein folding | Unfolded | Folded |
Partition Function for a Two-State System¶
The partition function for a two-state system is
where is the energy difference between the two states.
Probability of Finding the System in State 1¶
The probability of finding the system in state 1 is
Probability of Finding the System in State 2¶
The probability of finding the system in state 2 is
Partition Function as the Effective Number of Thermally Accessible Microstates¶
Source
import numpy as np
import matplotlib.pyplot as plt
from scipy.constants import k, eV
from labellines import labelLines
from myst_nb import glue
from matplotlib.patches import Rectangle
k_B = 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 / (k_B * 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 probabilities of finding the system in each state for a two-state system
p1_values = [np.exp(-1 / (k_B * T) * E1) / Q for T, Q in zip(T_values, Q_values)]
p2_values = [np.exp(-1 / (k_B * T) * E2) / Q for T, Q in zip(T_values, Q_values)]
# Plot the partition function and the probabilities of finding the system in each state
fig, axs = plt.subplots(1, 2, figsize=(8, 4))
# Plot the partition function on axs[0]
axs[0].plot(T_values, Q_values, 'k-')
axs[0].set_xlabel('Temperature (K)')
axs[0].set_ylabel('$Q_{\\text{two-state}}$')
axs[0].grid(True)
axs[0].annotate(
'$\\rightarrow 1$ accessible\nmicrostate', xy=(40, Q_values[0] + 0.01), xytext=(300, 1.1),
arrowprops=dict(arrowstyle='->', color='b'),
bbox=dict(boxstyle='round,pad=0.3', fc='w', ec='b'),
ha='center', va='center', color='b'
)
axs[0].annotate(
'$\\rightarrow 2$ accessible\nmicrostates', xy=(T_values[-1], Q_values[-1]), xytext=(750, 1.7),
arrowprops=dict(arrowstyle='->', color='m'),
bbox=dict(boxstyle='round,pad=0.3', fc='w', ec='m'),
ha='center', va='center', color='m'
)
axs[0].set_xlim(0, 1000)
axs[0].set_ylim(1, 2)
# Plot the probabilities of finding the system in each state on axs[1]
p1_line, = axs[1].plot(T_values, p1_values, 'b-', label='State 1')
p2_line, = axs[1].plot(T_values, p2_values, 'r-', label='State 2')
labelLines([p1_line, p2_line], zorder=2.5)
axs[1].set_xlabel('Temperature (K)')
axs[1].set_ylabel('Probability')
axs[1].grid(True)
axs[1].set_ylim(0, 1) # ensure y-axis spans from 0 to 1
# Add tall outlined rectangles around the probabilities at low and high temperatures.
# For T -> 0: highlight T from 1 to 50 K.
# For T = 1000: highlight T from 950 to 1000 K.
rect_low = Rectangle((1, 0), 50 - 1, 1, edgecolor='b', facecolor='b', linestyle='-', alpha=0.2)
rect_high = Rectangle((950, 0), 1000 - 950, 1, edgecolor='m', facecolor='m', linestyle='-', alpha=0.2)
axs[1].add_patch(rect_low)
axs[1].add_patch(rect_high)
axs[1].annotate(
'Only state 1 is accessed', xy=(50, 0.95), xytext=(100, 0.95),
arrowprops=dict(arrowstyle='-', color='b'),
ha='left', va='center', color='b'
)
axs[1].annotate(
'Both states are accessed', xy=(950, 0.05), xytext=(900, 0.05),
arrowprops=dict(arrowstyle='-', color='m'),
ha='right', va='center', color='m'
)
plt.tight_layout()
plt.show()
plt.close(fig)
Partition function and state probabilities for a two-state system as a function of temperature ().
Computational Studio: Two-State System¶
Explore how the canonical probabilities, partition function, and heat capacity respond to changes in the energy gap and temperature range.
You can open the studio in a new tab: Two-Level System Studio.
Worked Example¶
Two-level system probabilities¶
A single particle has two energy levels: and , with . Find and at .
Use , , and .
Compute
Compute the Boltzmann factor
Normalize
Result. At , about of systems occupy the excited state for this energy gap.
Concept Checks¶
Why must the argument of the exponential in be dimensionless?
What happens to as ? As ?
Which part of the canonical derivation relies on the reservoir being much larger than the system?
How does shifting all energies by a constant affect , and why?
Key Takeaways¶
In the canonical ensemble, microstate probabilities follow with .
The partition function normalizes probabilities and encodes thermodynamic information.
Probability ratios depend only on energy differences, not on the absolute zero of energy.
Two-level systems vividly illustrate how temperature controls population of higher-energy states.