Ensembles in phase-space#

What you will learn

  • Counting microstates in quantum systems or lattice models is natural as these systems are already discretized

  • Defining microstates in classical mechanics requires us to divide phase-space into small volumes of size hN

  • Using classical hailtonians for non-interacting particles we can derive a number of useful relations between free energies chemical potentials.

  • Equipartition theorem says ever quadratic degree term in Hamiltonian contributes kT of energy

  • De Broglie wavelength demarcates domain of applicability of classical and quantum mechanics

Quantization of Phase Space in Units of h#

../_images/1d-pspace.png

Fig. 20 Illustration of phase space for a 1D particle in a box.#

  • In classical mechanics, a system’s state is represented as a point in phase space, with coordinates (x,p) for each degree of freedom. The number of microstates is, in principle, infinite because both position and momentum can vary continuously.

  • However, in quantum mechanics, the Heisenberg uncertainty principle imposes a fundamental limit on how precisely position and momentum can be specified:

  • This implies that we cannot resolve phase space with arbitrary precision. Instead, each distinguishable quantum state occupies a minimum phase space volume on the order of:

ΔxΔph
  • For a system with f degrees of freedom (e.g 3N for N particles in three dimensions), the smallest resolvable cell in phase space has volume:

(ΔxΔp)fhf
  • To compute the number of accessible microstates Ω in a given region of phase space, we divide the classical phase space volume Γ by the smallest quantum volume hf

  • Since N particles are indistingusihable and classical mechanics has no such concept we have to manually divide numer of microstates by N!

Ω(E)=ΓhfN!
  • An explicit expression for number of microstates for a given energy E is written by using delta function which counts all microstates in phase-space where H(pN,xN)=E

Microcanonical partition function in phase-space

Ω(E)=1N!hNdpNdxNδ(H(pN,xN)E)
Hide code cell source
import numpy as np
import matplotlib.pyplot as plt

# Set constants
hbar = 1.0
h = 2 * np.pi * hbar
m = 1.0
omega = 1.0

# Quantum numbers to plot
n_values = [0, 1, 2, 5, 10]

# Prepare plot
fig, ax = plt.subplots(figsize=(5, 4))

# Colors for each energy level
colors = plt.cm.viridis(np.linspace(0, 1, len(n_values)))

# Store areas for demonstration
areas = []

# Plot ellipses for each energy level
for i, n in enumerate(n_values):
    E_n = hbar * omega * (n + 0.5)
    a = np.sqrt(2 * E_n / (m * omega**2))  # x_max
    b = np.sqrt(2 * m * E_n)               # p_max
    theta = np.linspace(0, 2 * np.pi, 500)
    x = a * np.cos(theta)
    p = b * np.sin(theta)
    ax.plot(x, p, label=f"n = {n}", color=colors[i])
    
    # Area of ellipse = πab (quasi-classical action)
    A_n = np.pi * a * b
    areas.append((n, A_n / h))  # normalized by h

# Annotate areas
for n, A_h in areas:
    ax.text(0.1, 1.1 * np.sqrt(2 * m * hbar * omega * (n + 0.5)), 
            f"$A/h$ ≈ {A_h:.1f}", fontsize=9)

# Final plot settings
ax.set_xlabel("Position $x$")
ax.set_ylabel("Momentum $p$")
ax.set_title("Harmonic Oscillator Phase Space: Quasi-Classical Area $\oint p \\, dx$")
ax.set_aspect('equal')
ax.legend()
ax.grid(True)

plt.tight_layout()
plt.show()
../_images/87d045616f253e07bc6f2295dfa22389d0d9e494fba0569b718053c214a18ab9.png

Computing Z via classical mechanics#

  • In quantum mechanics counting microsites is easy, we have discrete energies and could simply sum over microstates to compute partition functions

Z=ieβEi
  • Counting microstates in classical mechanics is therefore done by discretizing phase space for N particle system xN,pN into smallest unit boxes of size hN.

idpdxh
  • Once agan to correct classical mechanics for “double counting” of microstates if we have N indistinguishable “particles” with a factor of N!

Classical partition function

Z(β)=1N!hNeβH(xN,pN)dxNdpN

The power and utility of NVT: The non-interacting system#

  • For the independent particle system, the energy of each particle enter the total energy of the system additively.

E(ϵ1,ϵ2,...ϵN)=ϵ1+ϵ2+...ϵN
  • The exponential factor in the partition function allows decoupling particle contributions eβ(ϵ1+ϵ2)=eβϵ1eβϵ2. This means that the partition function can be written as the product of the partition functions of individual particles!

Distinguishable states:

Z=z1z2z3...zN

Indistinguishable states:

Z=1N!zN

General strategy for using NVT for simple non-interacting systems

  1. Compute the single particle partition function z=eβϵ1+eβϵ2+...

  2. To compute full partition function, raise z to the power of N and apply factorial in case of indistinguishable particles Z=1N!z or take product in case of distinguishable identical particles zN

  3. Compute the free energy F=kBTlogZ

  4. Take derivatives of free energy to get the thermodynamic quantities. E.g one is often interested in computing temperature dependence of μ(T),U(T),S(T)

Maxwell-Boltzman distribution#

  • Since the kinetic and potential energy functions depend separately on momenta and positions, the total probability distribution factorizes into a product of position and momentum distributions:

H(pN,rN)=U(rN)+K(pN)=U(rN)+i=1Npi22m
  • This separation leads to:

P(rN,pN)=P(rN)P(pN)=VdrNeβU(rN)+dpNeβi=1Npi22m
  • The intergarlwith position-dependent potential for interacting particle system is impossible to evaluate except by simulations or numerical techniques

  • The momentum-dependent part splits into individaul integrals for every particle and is always a simple quadratic function, making it analytically tractable:

P(pN)=[+dpeβp22m]N
  • The momentum (or velocity) distribution follows the Maxwell-Boltzmann distribution in all equilibrium systems, regardless of the complexity of the molecular interactions.

Maxwell-Boltzmann distribution

  • Velocity component distribution (1D Gaussian):

f(vx)=m2πkBTe12mvx2/kBT
  • Speed distribution (Maxwell-Boltzmann form):

f(v)=4πv2(m2πkBT)3/2e12mv2/kBT
  • v is the speed of a particle,

  • m is the mass of a particle,

  • kB is Boltzmann’s constant,

  • T is the absolute temperature.

Hide code cell source
import numpy as np
import matplotlib.pyplot as plt

# Constants for Maxwell-Boltzmann Distribution (in arbitrary units)
k_B = 1.38e-23   # Boltzmann constant (J/K), not used directly since we'll use reduced units
T = 300          # Temperature in K
m = 4.65e-26     # Mass of nitrogen molecule (kg), approximate

# Define velocity range
v = np.linspace(0, 2000, 1000)

# Maxwell-Boltzmann distribution function
def f_MB(v, m, T):
    return 4 * np.pi * v**2 * (m / (2 * np.pi * k_B * T))**(3/2) * np.exp(-m * v**2 / (2 * k_B * T))

# Compute distribution
f_v = f_MB(v, m, T)

# Characteristic velocities
v_mp = np.sqrt(2 * k_B * T / m)         # Most probable speed
v_avg = np.sqrt(8 * k_B * T / (np.pi * m))  # Average speed
v_rms = np.sqrt(3 * k_B * T / m)        # Root mean square speed

# Plot
plt.figure(figsize=(10, 6))
plt.plot(v, f_v, label="Maxwell-Boltzmann Distribution", color='black')
plt.axvline(v_mp, color='blue', linestyle='--', label=f"$v_{{\\rm mp}}$ = {v_mp:.0f} m/s")
plt.axvline(v_avg, color='green', linestyle='--', label=f"$\\langle v \\rangle$ = {v_avg:.0f} m/s")
plt.axvline(v_rms, color='red', linestyle='--', label=f"$v_{{\\rm rms}}$ = {v_rms:.0f} m/s")
plt.title("Maxwell-Boltzmann Speed Distribution for $N_2$ at 300 K")
plt.xlabel("Speed (m/s)")
plt.ylabel("Probability Density")
plt.legend()
plt.grid(True)
plt.tight_layout()
plt.show()
../_images/2eca3706c13d6d566c127e5900c58f1af422805a488f2019ede5a86cf32f5bb6.png

Ideal Gas#

  • A useful approximation is to consider the limit of a very dilute gas, known as an ideal gas, where interactions between particles are neglected V=0.

  • Lets evaluate partition function for a single atom of idea gas:

z(β)=[1h0Ldx+dpep22mkBT]3=V(2πmkBTh2)3/2
z=VλT3=VnQ

De Broglie Thermal Wavelength and quantum concentration

λT=h2πmkBT
nQ=1λT3

On the Validity of the Classical Approximation

  • The classical approximation is valid when the average interatomic spacing n1/3 is much larger than λT, i.e., when:

nλT31
  • This ensures that wavefunction overlap is negligible and particles behave classically.

Classical partition function for N Atom Ideal gas

Z=ZNN!=(VnQ)NN!
F=kBTlogZ=kBTlogZ=NkBTlog(nQn)NkBT
μ=FN=kBTlog(nnQ(T))
  • We can also calculate entropy and other thermodynamic quantities and compare with expressions obtained inNVE ensemble

S=(FT)N,V=NkB[log(nQn)+52]
U=logZ(β)=32NkBT
p=FV=NkBTV

Equipartition Theorem#

  • Consider a classical system with a Hamiltonian containing a quadratic degree of freedom x, such that:

E(x)=12ax2
  • The canonical partition function for this degree of freedom is:

Z=eβ12ax2dx=2πβa
  • The average energy is:

E=logZβ
logZ=12log(2πβa)=const12logβ
E=β(12logβ)=12β=12kBT

equipartition function for f independent quadratic degrees of freedom

E=f2kBT

Examples#

  • Monatomic ideal gas: 3 translational degrees → E=32kBT

  • Diatomic molecule at high T: 3 translational + 2 rotational + n active vibrational modes
    E=(52+n)kBT

Note: Equipartition only applies when the quadratic modes are thermally accessible, i.e., when kBT energy level spacing (e.g., ω for vibrations).

Partition functions for non-interacting molecules#

  • Total energy and partition function for a molecule with separable degrees of freedom:

Partition Function for a Molecular Gas

E=Etransl+Evib+Erot+Eelec
Z=ZtranslZvibZrotZelec

Translational Degrees of Freedom: Particle in a Box#

  • For a particle in a 3D box of volume V=L3, the energy levels are:

Enx,ny,nz=2π22mL2(nx2+ny2+nz2)
  • To approximate the partition function at high temperatures (many levels populated), we replace the discrete sum with an integral:

Z=nx,ny,nzeβEnx,ny,nz[0dneβ2π22mL2n2]3
  • This is a Gaussian integral:

0ean2dn=12πa
Z=[12π2π22mL2β]3=(Lh2πmkBT)3=V(mkBT2π2)3/2=VnQ
  • For N indistinguishable molecules we obtain same result we go for ideal gas!

Z=(VnQ)NN!

Rotational Degrees of Freedom: Rigid Rotor Model#

  • For a linear molecule (diatomic rotor), the rotational energy levels are:

EJ=22IJ(J+1),with degeneracy (2J+1)
  • The partition function is:

Z=J=0(2J+1)eβ22IJ(J+1)
  • At high temperatures (kBT2/2I), this sum can be approximated as an integral:

Z0(2J+1)eβ22IJ(J+1)dJ
  • Let x=J(J+1)J2 for large J:

Z02Jeβ22IJ2dJ
  • This integral is:

0JeaJ2dJ=12a
Z1β22I=2IkBT2=Tθrot
  • Where θrot=22IkB is the rotational temperature.

Vibrational Degrees of Freedom: Harmonic Oscillator Model#

En=ω(n+12)
  • Partition function for one oscillator:

z=n=0eβω(n+12)=e12βωn=0(eβω)n=e12βω1eβω
  • For N independent oscillators:

Z=zN
  • Average energy would then be:

E=logZβ=Nlogzβ
logz=12βωlog(1eβω)
logzβ=12ω+ωeβω1eβω=12ω+ωeβω1
E=Nω(12+1eβω1)

Low and high temperature behaviours of harmonic oscillators#

  • Notice the two important limits. At low temperature quantization of energy becomes important while at high temperature result matches with classical mechanics predictions;

  • As T0, eβω1, so:

EN12ω
  • As T, eβω1+βω:

1eβω11βωENkBT
Hide code cell source
# Temperature range in Kelvin
T_vals = np.linspace(10, 5000, 500)

# Vibrational frequency (typical for molecular vibration)
# Use hbar*omega = energy quantum = ~0.2 eV (~3200 cm^-1 IR band), convert to J
hbar_omega = 0.2 * 1.602e-19  # in J

# Dimensionless variable x = hbar*omega / (k_B * T)
x = hbar_omega / (k_B * T_vals)

# Heat capacity C_v of harmonic oscillator (per mode)
# C_v = k_B * (x^2 * exp(x)) / (exp(x) - 1)^2
C_v = k_B * (x**2 * np.exp(x)) / (np.exp(x) - 1)**2

# Convert C_v to units of k_B
C_v_over_kB = C_v / k_B

# Plot
plt.figure(figsize=(8, 5))
plt.plot(T_vals, C_v_over_kB, color='darkorange')
plt.xlabel("Temperature (K)")
plt.ylabel("Heat Capacity $C_V / k_B$")
plt.title("Heat Capacity of a Quantum Harmonic Oscillator vs Temperature")
plt.grid(True)
plt.tight_layout()
plt.show()
../_images/996a82d262dbadf80d8a8a0d1ffcdcdc657b404d1963caecc84dd62081323243.png

On heat capacity of harmonic-oscillators#

Einstein Model of solids#

  • A simple model for solids due to Einstein describes it as N independent harmonic oscillators representing localized atomic vibrations.

  • The average energy of a quantum harmonic oscillator is:

E=ω(12+1eβω1)
  • The heat capacity is the derivative:

CV=ET=kB(x2ex(ex1)2),x=ωkBT

Key predictions of Einstein model of solids#

  • At low T: CV0 — the oscillator is frozen in its ground state.

  • At high T: CVkB — classical equipartition is recovered.

Debye Model of Solids#

  • The Debye model improves upon Einstein’s and matches experimental data much better than the Einstein model, especially at low temperatures.

  • Main distinguishing features of Debye model are:

    • Treating atomic vibrations as a continuum of phonon modes.

    • Including a full spectrum of frequencies up to a Debye cutoff ωD.

    • Predicting the correct low-temperature behavior of solids.

U=9NkBT(TTD)30TD/Tx3ex1dx
CV=9NkB(TTD)30TD/Tx4ex(ex1)2dx

Behavior of Debye Model#

  • Low T: CVT3 — from long-wavelength (acoustic) phonons.

  • High T: CV3R — classical limit.

Derivation of Debye Model and phonons

  • Instead of treating each atom as an independent oscillator (like in Einstein’s model), Debye considered collective vibrations of the entire lattice — i.e., phonons, which are quantized sound waves.

  • In 3D, the number of vibrational modes with frequencies less than ω is proportional to ω3:

g(ω)dω=9NωD3ω2dω
  • g(ω): phonon density of states

  • N: number of atoms

  • ωD: Debye cutoff frequency, chosen so total modes = 3N

  • Each mode contributes energy:

E(ω)=ωeβω1
  • Total internal energy:

U=0ωDg(ω)E(ω)dω=0ωD9NωD3ω2ωeβω1dω
x=ωkBTω=kBTx,dω=kBTdx
xD=ωDkBT=TDT
  • Then the internal energy becomes:

U=9NkBT(TTD)30xDx3ex1dx
  • Now take the derivative:

CV=dUdT=9NkB(TTD)30xDx4ex(ex1)2dx
Hide code cell source
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import quad

# Constants
k_B = 1.38e-23        # Boltzmann constant (J/K)
N_A = 6.022e23        # Avogadro's number
R = N_A * k_B         # Gas constant (J/mol·K)

# Debye model parameters
T_D = 400  # Debye temperature in Kelvin (can be adjusted)

# Debye heat capacity function
def debye_integral(x_D):
    integrand = lambda x: (x**4 * np.exp(x)) / (np.exp(x) - 1)**2
    val, _ = quad(integrand, 0, x_D)
    return val

# Temperature range
T_vals = np.linspace(1, 1000, 300)
C_v_debye = []

# Calculate heat capacity at each temperature
for T in T_vals:
    x_D = T_D / T
    if T == 0:
        C_v_debye.append(0)
    else:
        integral = debye_integral(x_D)
        C_v = 9 * R * (T / T_D)**3 * integral
        C_v_debye.append(C_v)

# Convert to numpy array
C_v_debye = np.array(C_v_debye)

# Plot
plt.figure(figsize=(8, 5))
plt.plot(T_vals, C_v_debye / R, color='teal', label="Debye Heat Capacity")
plt.axhline(3, color='gray', linestyle='--', label="Dulong-Petit Limit ($3R$)")
plt.xlabel("Temperature (K)")
plt.ylabel("$C_V / R$")
plt.title("Debye Model Heat Capacity of a Solid")
plt.legend()
plt.grid(True)
plt.tight_layout()
plt.show()
/tmp/ipykernel_2245/174881513.py:15: RuntimeWarning: overflow encountered in scalar power
  integrand = lambda x: (x**4 * np.exp(x)) / (np.exp(x) - 1)**2
../_images/bd62542bffe4d4c43550e2445dc453fccf6926364823f63a2f82626e3ad486b0.png

Problems#

Problem-1 1D energy profiles#

Given an energy function E(x)=Ax4Bx2+C with constants (A=1,B=4,C=1)

  • Compute free energy difference between minima at temperature kBT=1,10,100

  • Compute free energy around minima of size δx=0.1,0.5,1

Problem-2 Maxwell-Boltzman#

You are tasked with analyzing the behavior of non-interacting nitrogen gas molecules described by Maxwell-Boltzman distirbution:

f(v)=4π(m2πkBT)3/2v2emv22kBT

Where:

  • f(v) is the probability density for molecular speed v

  • m is the mass of a nitrogen molecule

  • kB=1.38×1023J/K (Boltzmann constant)

  • T is the temperature in Kelvin

Step 1: Plot the Maxwell-Boltzmann Speed Distribution

At room temperature (T = 300, 400, 500, 600 K), plot the distribution f(v) for speeds ranging from 0 to 2000 m/s.

Step 2: Identify Most Probable, Average, and RMS Speeds

Compute and print:

  • The most probable speed vmp=2kBTm

  • The mean speed v¯=8kBTπm

  • The root mean square (RMS) speed vrms=3kBTm

Plot vertical lines on your plot from Step 1 to show these three characteristic speeds.

Step 3: Speed Threshold Analysis

Use numerical integration to calculate the fraction of molecules that have speeds:

  • (a) Greater than 1000 m/s

  • (b) Between 500 and 1000 m/s

Hint: Use scipy.integrate.quad to numerically integrate the Maxwell-Boltzmann distribution.

Problem-3 Elastic Collisions#

Complete the lab

  • In this problem need to modify the code to add elastic collisions to the ideal gas simulations

Problem-4 Elementary derivation of Boltzmann’s distirbution#

Let us do an elementary derivation of Boltzman distribution showing that when a macroscopic system is in equilibrium and coupled to a heat bath at temperatere T we have a universal dependence of probability for finding system at different energies:

P(r)/P(r)=eβ(U(r)U(r))

The essence of the derivation is this. Consider a vertical column of gas somehre in the mountains.

  • On one hand we have graviational force which acts on a column between h,h+dh with cross section A.

  • On the other hand we have pressure balance which thankfully keeps the molecules from dropping on the ground.

  • This means that we have a steady density of molecules at each distance n(h) for a fixed T. Write down this balance of forces (gravitational vs pressure ) and find show how density at h, n(h) is related to density at h=0, n(0).

Tip: you may use P=nkT for pressure and mgh for the gravitational force)

Problem-5 2D diploes on a lattice#

Consider a 2D square lattice with M lattice points. On each point we have a mangeetic moment that can point in four possible directions: +x,x,+y,y. Along y axis, the dipole has the energy ϵ>0 and along the x axis ϵ=0.

Dipoles are not interacting with each other and we also ingnore kinetic energy of diplos since they are fixed at lattice positions.

  • Write down parition function for this system Z

  • Compute the average energy.

  • Compute entropy per dipole s(T). Evaluate the difference S(T=)S(T=0)? Can you see a link with number of arrangements of dipols?

  • Compute microcanonical partition function Ω(Nϵ)

  • Show that we get the same entropy expression by using NVE and NVT ensembles.