2.4.10Thermodynamics & Statistical Mechanics (Advanced)
Canonical ensemble — partition function Z
2,106 words10 min readdifficulty · medium6 backlinks
WHAT is the canonical ensemble?
Contrast:
- Microcanonical : energy fixed.
- Canonical : temperature fixed, energy fluctuates. ← this note.
- Grand canonical : particles and energy fluctuate.
WHY does a state of energy get weight ?
This is the heart of everything. Derive it, never memorize it.
Derivation from first principles:
where is the reservoir's number of microstates. Work with entropy , so . Since , Taylor-expand :
But thermodynamically (definition of temperature!). So:
Therefore:
The first factor is a constant (doesn't depend on ). Defining :
HOW to normalize: defining
Probabilities must sum to 1. So we need a normalizer:
The name "partition function" (German Zustandssumme = "sum over states") is literal: it's a sum over states.
WHY is the master key: getting thermodynamics out
Average energy — derive it:
Notice . Hence:
Energy fluctuations (and a route to heat capacity):
\sigma_E^2 = \langle E^2\rangle - \langle E\rangle^2 = \frac{\partial^2 \ln Z}{\partial\beta^2} = -\frac{\partial \langle E\rangle}{\partial \beta}$$ Using $C_V = \dfrac{\partial\langle E\rangle}{\partial T}$ and $\dfrac{\partial}{\partial\beta} = -k_BT^2\dfrac{\partial}{\partial T}$: $$\boxed{\sigma_E^2 = k_B T^2 C_V}$$ **Helmholtz free energy** — the cleanest link to classical thermodynamics: $$\boxed{F = -k_B T \ln Z}$$ From $F$ everything follows: $S = -\left(\dfrac{\partial F}{\partial T}\right)_{V}$, $\;P = -\left(\dfrac{\partial F}{\partial V}\right)_{T}$, $\;\langle E\rangle = F + TS$. ![[2.4.10-Canonical-ensemble-—-partition-function-Z.png]] --- ## Worked Example 1 — Two-level system (the "qubit") A single particle has two states: energy $0$ and energy $\varepsilon$. **Step 1 — Write $Z$.** *Why?* $Z$ is just the sum of Boltzmann factors over the two states. $$Z = e^{-\beta\cdot 0} + e^{-\beta\varepsilon} = 1 + e^{-\beta\varepsilon}$$ **Step 2 — Average energy.** *Why use $-\partial_\beta \ln Z$?* It's the derived shortcut. $$\ln Z = \ln(1+e^{-\beta\varepsilon}), \quad \langle E\rangle = -\frac{\partial \ln Z}{\partial\beta} = \frac{\varepsilon e^{-\beta\varepsilon}}{1+e^{-\beta\varepsilon}} = \frac{\varepsilon}{e^{\beta\varepsilon}+1}$$ **Step 3 — Check limits.** *Why?* Limits catch algebra errors instantly. - $T\to 0\;(\beta\to\infty)$: $\langle E\rangle\to 0$ ✓ (frozen in ground state). - $T\to\infty\;(\beta\to 0)$: $\langle E\rangle\to \varepsilon/2$ ✓ (both states equally likely). --- ## Worked Example 2 — One classical harmonic oscillator (1D) $H = \dfrac{p^2}{2m} + \dfrac{1}{2}m\omega^2 x^2$. **Step 1 — Classical $Z$.** *Why integrate?* Phase space is continuous. $$Z = \frac{1}{h}\int_{-\infty}^{\infty}\!\!\int_{-\infty}^{\infty} e^{-\beta\left(\frac{p^2}{2m}+\frac{1}{2}m\omega^2 x^2\right)}\,dx\,dp$$ **Step 2 — Gaussian integrals.** *Why this works?* It factorizes into two $\int e^{-ax^2}dx=\sqrt{\pi/a}$. $$\int e^{-\beta p^2/2m}dp = \sqrt{\frac{2\pi m}{\beta}}, \qquad \int e^{-\beta m\omega^2 x^2/2}dx = \sqrt{\frac{2\pi}{\beta m\omega^2}}$$ $$Z = \frac{1}{h}\sqrt{\frac{2\pi m}{\beta}}\sqrt{\frac{2\pi}{\beta m\omega^2}} = \frac{2\pi}{h\beta\omega} = \frac{k_B T}{\hbar\omega}$$ **Step 3 — Energy.** *Why differentiate?* Same master formula. $$\langle E\rangle = -\frac{\partial \ln Z}{\partial\beta} = -\frac{\partial}{\partial\beta}\big(-\ln\beta + \text{const}\big) = \frac{1}{\beta} = k_B T$$ This is **equipartition**: 2 quadratic DOF $\times\, \tfrac12 k_BT = k_BT$. ✓ --- ## Worked Example 3 — $N$ independent particles & factorization > [!intuition] WHY products? > If particles are independent, the total energy is a **sum** $E = \sum_k \epsilon_k$. The exponential of a sum is a **product** of exponentials, and the sum over all configurations factorizes. For $N$ **distinguishable** independent identical subsystems each with single-particle partition function $Z_1$: $$Z_N = Z_1^N$$ For $N$ **indistinguishable** particles (classical ideal gas), divide by overcounting $N!$: $$\boxed{Z_N = \frac{Z_1^N}{N!}}$$ *Why $N!$?* Swapping two identical particles gives the same physical state; the integral counted it $N!$ times. (This fixes the **Gibbs paradox**.) --- ## Forecast-then-Verify > [!example] Predict before you compute > **Q:** For the two-level system, at what $T$ is $\langle E\rangle = \varepsilon/4$? > **Forecast:** Need $\dfrac{\varepsilon}{e^{\beta\varepsilon}+1}=\dfrac{\varepsilon}{4}\Rightarrow e^{\beta\varepsilon}=3\Rightarrow \beta\varepsilon=\ln 3\Rightarrow T = \dfrac{\varepsilon}{k_B\ln 3}$. > **Verify:** Plug back: $\langle E\rangle = \varepsilon/(3+1)=\varepsilon/4$ ✓. --- ## Common mistakes (Steel-manned) > [!mistake] "$Z$ is a probability, so it must be ≤ 1." > **Why it feels right:** Boltzmann factors look like probabilities. **Reality:** $Z$ is a *normalizer*, a sum of weights — it can be huge (it roughly counts thermally accessible states). The probability is $e^{-\beta E_i}/Z$, *that's* what's ≤ 1. > [!mistake] "Use $\langle E\rangle = +\partial_\beta \ln Z$." > **Why it feels right:** Differentiation gives energy, sign easy to drop. **Fix:** Each term is $e^{-\beta E_i}$; $\partial_\beta$ brings down $-E_i$. The minus sign is physical — derive it once and you'll never forget: $\langle E\rangle = -\partial_\beta \ln Z$. > [!mistake] "Forget the $1/N!$ for an ideal gas." > **Why it feels right:** $Z_1^N$ looks complete. **Fix:** Classical identical particles are indistinguishable; without $1/N!$ entropy isn't extensive (Gibbs paradox). Always ask: *can I tell the particles apart?* > [!mistake] "Sum $Z$ over energy **levels** but forget degeneracy." > **Why it feels right:** Levels feel like "states." **Fix:** $Z=\sum_i e^{-\beta E_i}$ is over **microstates**. If you sum over levels, weight each by $g_n$: $Z=\sum_n g_n e^{-\beta E_n}$. --- ## #flashcards/physics Define the canonical ensemble (controlled variables). ::: Copies of a system in thermal contact with a heat bath; $(N,V,T)$ fixed, energy $E$ fluctuates. Why does microstate $i$ get weight $e^{-\beta E_i}$? ::: Taylor-expanding reservoir entropy $S_R(E_{tot}-E_i)$ with $\partial S_R/\partial E = 1/T$ gives $P_i \propto e^{-E_i/k_BT}$. Define the partition function $Z$. ::: $Z=\sum_i e^{-\beta E_i}$, sum over all microstates; the normalizer of Boltzmann probabilities. What is $\beta$? ::: $\beta = 1/(k_B T)$. Probability of microstate $i$? ::: $P_i = e^{-\beta E_i}/Z$. Average energy from $Z$? ::: $\langle E\rangle = -\partial \ln Z/\partial\beta$. Helmholtz free energy from $Z$? ::: $F = -k_B T \ln Z$. Energy fluctuation relation to heat capacity? ::: $\sigma_E^2 = \langle E^2\rangle-\langle E\rangle^2 = k_B T^2 C_V$. $Z$ for $N$ indistinguishable independent classical particles? ::: $Z_N = Z_1^N / N!$. $Z$ of a two-level system $(0,\varepsilon)$? ::: $Z = 1+e^{-\beta\varepsilon}$. $\langle E\rangle$ of a 1D classical harmonic oscillator? ::: $k_BT$ (equipartition, 2 quadratic DOF). Why divide by $N!$ for identical particles? ::: Indistinguishability overcounts permutations by $N!$; fixes Gibbs paradox / makes $S$ extensive. How get entropy from $Z$? ::: $S=-(\partial F/\partial T)_V$ with $F=-k_BT\ln Z$. --- > [!recall]- Feynman: explain to a 12-year-old > Imagine a tiny toy that can be in different "settings," and each setting costs some energy. The toy is sitting in a warm room. The room is like a giant piggy bank of energy. If a setting costs a lot, the piggy bank has less left over and fewer ways to arrange itself — so the toy almost never picks that expensive setting. Hot room → toy tries lots of settings; cold room → toy stays in the cheapest one. The partition function $Z$ is just **adding up the "likeliness scores" of every setting**. Once you've added them all, you can figure out the average energy, how jittery it is, everything — without re-checking each setting. It's the one number that knows it all. > [!mnemonic] Remember the toolbox > **"Z Builds Free Energy, Fluctuations Follow."** > $Z$ → **B**oltzmann weights → **F**ree energy $F=-k_BT\ln Z$ → **F**luctuations $\sigma_E^2=k_BT^2 C_V$. > And the master derivative: *"minus log-Z by beta gives E"* → $\langle E\rangle=-\partial_\beta\ln Z$. ## Connections - [[Boltzmann distribution]] — the $e^{-\beta E_i}$ weights $Z$ normalizes. - [[Microcanonical ensemble]] — fixed-energy cousin; canonical reduces to it as the bath grows. - [[Grand canonical ensemble — grand partition function]] — add particle exchange via $\mu$. - [[Helmholtz free energy F]] — the thermodynamic potential $-k_BT\ln Z$. - [[Equipartition theorem]] — each quadratic DOF contributes $\tfrac12 k_BT$, derivable from $Z$. - [[Gibbs paradox]] — why the $1/N!$ matters. - [[Heat capacity and fluctuations]] — $\sigma_E^2 = k_BT^2 C_V$. ## 🖼️ Concept Map ```mermaid flowchart TD POST[Fundamental postulate: equal microstates] -->|applied to| ISO[System plus reservoir isolated] ISO -->|Pi proportional to| OMEGA[Reservoir microstates Omega_R] OMEGA -->|via S equals kB ln Omega| ENT[Reservoir entropy S_R] ENT -->|Taylor expand small Ei| EXP[S_R minus Ei over T] TEMP[Temperature: dS/dE equals 1/T] -->|defines slope| EXP EXP -->|exponentiate| BOLTZ[Boltzmann factor e^-beta Ei] BOLTZ -->|normalize sum to 1| Z[Partition function Z] Z -->|weights states in| CANON[Canonical ensemble N,V,T] CANON -->|contrast fixed E| MICRO[Microcanonical N,V,E] CANON -->|contrast variable N| GRAND[Grand canonical mu,V,T] Z -->|differentiate| THERMO[All thermodynamic quantities] ``` ## 🔊 Hinglish (regional understanding) > [!intuition]- Hinglish mein samjho > Dekho, canonical ensemble ka matlab hai ek system jo ek bade heat bath (reservoir) ke saath thermal contact mein hai, fixed temperature $T$ pe. Yahan system ki energy fixed nahi hoti — wo bath ke saath energy le-de sakta hai, isliye energy fluctuate karti hai, par $N$, $V$, $T$ fixed rehte hain. Sabse important baat: har microstate $i$ jiski energy $E_i$ hai, usko probability milti hai $e^{-\beta E_i}$ ke proportional, jahan $\beta = 1/k_BT$. Yeh Boltzmann factor hai. > > Yeh exponential kahan se aaya? System + reservoir milke ek isolated cheez hai. Isolated system mein har microstate equally likely hota hai. Toh system ke state $i$ ki probability proportional hoti hai reservoir ke arrangements ki ginti, $\Omega_R(E_{tot}-E_i)$. Entropy use karke Taylor expand karo, aur $\partial S/\partial E = 1/T$ daalo — bas, $e^{-\beta E_i}$ nikal aata hai. Yaad rakhna: derive karo, ratna mat, sign galat ho jaayega warna. > > Ab partition function $Z = \sum_i e^{-\beta E_i}$ sirf normalizer hai — saare Boltzmann factors ka total. Probability banti hai $P_i = e^{-\beta E_i}/Z$. $Z$ probability nahi hai, isliye 1 se bada bhi ho sakta hai (yeh roughly batata hai kitne states thermally available hain). $Z$ ko "master key" bolte hain kyunki ek baar $Z$ mil gaya, toh sab kuch differentiation se nikal aata hai: average energy $\langle E\rangle = -\partial_\beta \ln Z$, free energy $F = -k_BT\ln Z$, aur entropy, pressure, heat capacity — sab. > > Practical tip: independent particles ke liye $Z_N = Z_1^N$, par agar particles identical aur indistinguishable hain (jaise ideal gas), toh $N!$ se divide karo — warna Gibbs paradox aa jaata hai. Exam mein two-level system aur harmonic oscillator wale examples bahut common hain, toh unhe khud derive karke practice karo. ![[audio/2.4.10-Canonical-ensemble-—-partition-function-Z.mp3]]Go deeper — visual, from zero
Test yourself — Thermodynamics & Statistical Mechanics (Advanced)
Connections
Maxwell-Boltzmann distribution — full derivationPhysics · 2.4.13Equipartition theorem — ½k_BT per quadratic degree of freedomPhysics · 2.4.14Specific heat capacity — calorimetryPhysics · 1.7.4Chemical potential μ = (∂G - ∂N)_{T,P}Physics · 2.4.5Average energy from partition functionPhysics · 2.4.11Free energy from partition functionPhysics · 2.4.12Quantum statistics — distinguishable vs indistinguishable particlesPhysics · 2.4.15Bose-Einstein statistics — bosonsPhysics · 2.4.16Fermi-Dirac statistics — fermions, Fermi energyPhysics · 2.4.17