---
title: Quantum gases lab
heading: Fermi–Dirac integrals, a Fermi gas's chemical potential and heat capacity at any temperature, Bose fugacities and exact thermionic emission
eyebrow: B11 · Lesson 25 · Quantum gases lab
xp: 50
---

::: hook
Lessons 23 and 24 treated quantum gases in their limits: a Fermi gas far below its Fermi temperature, where the Sommerfeld expansion works, and a Bose gas near condensation. Between the limits there are no closed forms, only integrals, and computing them is routine work for anyone modeling semiconductors, plasmas or cold atoms. In this lab you'll evaluate the Fermi–Dirac integral that sets carrier densities in degenerate semiconductors, find a Fermi gas's chemical potential and heat capacity from absolute zero to the classical limit, solve for a Bose gas's fugacity, and check Richardson's law against the exact emission integral.
:::

::: play
- The curve is the number of electrons per unit energy in a free Fermi gas, $\sqrt x\,f(x)$, with energy in units of $E_F$; the dashed curve is the zero-temperature filling.
- Raise $t = kT/E_F$: the edge softens over a few kT, and the chemical potential (from the Sommerfeld expansion, good below t of about 0.3) slips below $E_F$.
- The readouts give μ and the heat capacity per electron, $\frac{\pi^2}{2}t$. Steps 2 and 3 compute both exactly, at any t.
:::

```sim plot
view: graph
x: x = 0..2
y: n = 0..1.5
slider: t = 0.01..0.3 step 0.01 = 0.1
plot: sqrt(x)/(exp((x - (1 - pi^2/12*t^2 - pi^4/80*t^4))/t) + 1) | label: occupied states per unit energy | samples: 600
plot: sqrt(x)*step(1 - x) | dashed | color: ch2 | label: at absolute zero | samples: 600
readout: μ/E_F = 1 - pi^2/12*t^2 - pi^4/80*t^4 | digits: 5
readout: C per electron, units of k = pi^2/2*t | digits: 3
```

::: predict
## A Fermi gas is heated to $kT = E_F$. Is its chemical potential still near $E_F$?

- [ ] Yes, μ stays at $E_F$ at every temperature
- [ ] It rises above $E_F$
- [x] No: it has fallen to about zero, and goes negative as the gas becomes classical
- [ ] It's undefined once the gas is hot

::: reveal
It has fallen to about zero (−0.02 $E_F$ exactly). As the gas heats, electrons spread to higher energies, and to keep the same number the chemical potential must fall. In the classical limit $\mu = kT\ln(n/n_Q)$ is large and negative. The Sommerfeld formula, still predicting 0.18 $E_F$ at t = 1, has broken down by then; step 2 finds the exact value.
:::
:::

::: nameit
## The Fermi–Dirac integral

The density of electrons in a parabolic band with the Fermi level $\eta = \frac{\mu - E_c}{kT}$ above its edge is $n = N_cF_{1/2}(\eta)$, with

$$F_{1/2}(\eta) = \frac{2}{\sqrt\pi}\int_0^\infty\frac{\sqrt x\,dx}{1 + e^{x - \eta}}.$$

For $\eta \ll 0$ it's $e^\eta$, the Boltzmann result of lesson 37; at η = 0 it's 0.765; for $\eta \gg 1$ it approaches $\frac{4}{3\sqrt\pi}\eta^{3/2}$. Substituting $x = u^2$ removes the square root's singular slope and makes the integral easy to compute.

## A Fermi gas at any temperature

With energies in units of $E_F$ and t = kT/$E_F$, the number condition is $\int_0^\infty\sqrt x\,f(x)\,dx = \frac23$, which fixes μ by bisection. The energy is $U/N = \frac32\int_0^\infty x^{3/2}f(x)\,dx$, and the heat capacity its slope. The Sommerfeld expansion gives $\mu = E_F\left[1 - \frac{\pi^2}{12}t^2 - \frac{\pi^4}{80}t^4\right]$ and $C = \frac{\pi^2}{2}Nkt$ for small t; at large t the gas becomes classical, with $C \to \frac32Nk$.

## A Bose gas above condensation

Above $T_E$ the ideal Bose gas has $n\lambda_T^3 = g_{3/2}(z)$, where $z = e^{\mu/kT}$ is the fugacity and $g_{3/2}(z) = \sum_{n\ge1}\frac{z^n}{n^{3/2}}$. At $T_E$, z = 1 and $g_{3/2}(1) = 2.612$, so at $T = tT_E$ one solves $g_{3/2}(z) = \frac{2.612}{t^{3/2}}$. Below $T_E$ the pressure is $\frac{g_{5/2}(1)}{g_{3/2}(1)}nkT\left(\frac{T}{T_E}\right)^{3/2}$, only 0.514 of the classical value at $T_E$.

## Emission over a barrier, exactly

Electrons leave a metal when their energy of motion normal to the surface exceeds $E_F + W$. Integrating the Fermi–Dirac distribution over the two transverse directions first gives

$$J = \frac{4\pi mqk^2T^2}{h^3}\int_{W/kT}^\infty\ln(1 + e^{-\varepsilon})\,d\varepsilon,$$

and for $W \gg kT$ the integral is $e^{-W/kT}$: Richardson's law with $A = \frac{4\pi mqk^2}{h^3}$ = 120.2 A/(cm²·K²) (times $m^*/m$ in a semiconductor).
:::

::: example
## Sodium has $E_F$ = 3.24 eV. How far does its electrons' chemical potential fall between 0 K and 300 K, and by 3000 K?

::: solution
1. **Sommerfeld's shift.**
   $$\Delta\mu = -\frac{\pi^2}{12}\frac{(kT)^2}{E_F}$$
2. **At 300 K.** That's five parts in a hundred thousand:
   $$\begin{aligned} |\Delta\mu| &= \frac{0.8225 \times 0.02585^2}{3.24} \\ &= 0.17\ \text{meV} \end{aligned}$$
3. **At 3000 K.** It's a hundred times larger, 17 meV, still only 0.5% of $E_F$.
4. **Why it matters.** A metal's Fermi level hardly moves with temperature, which is why metal contacts make such steady references, and why the contact potential between two metals (lesson 38) barely depends on temperature.

**Answer:** the chemical potential falls by 0.17 meV at 300 K and by 17 meV at 3000 K.
:::
:::

::: example
## $F_{1/2}(0)$ = 0.765. By how much does Boltzmann statistics overestimate the electron density when the Fermi level sits at the band edge? How far below the edge must it be for Boltzmann to be within 1%?

::: solution
1. **At the band edge.** At η = 0 the Boltzmann formula gives $e^0$ = 1 against the true 0.765, a 31% overestimate.
2. **The error below the edge.** For η well below zero,
   $$F_{1/2}(\eta) \approx e^\eta - \frac{e^{2\eta}}{2^{3/2}}$$
   so the relative error is about $\frac{e^\eta}{2.83}$.
3. **Set the error to 1%.**
   $$\begin{aligned} \frac{e^\eta}{2.83} &= 0.01 \\ e^\eta &= 0.0283 \\ \eta &= -3.6 \end{aligned}$$
4. **The usual rule.** The rule that a semiconductor is nondegenerate when its Fermi level is more than 3kT below the band edge keeps errors to a couple of percent.

**Answer:** Boltzmann overestimates the density by 31% at the band edge, and the Fermi level must sit 3.6kT below the edge for a 1% error.
:::
:::

::: example
## An ideal Bose gas is held at twice its condensation temperature. What's its fugacity and chemical potential?

::: solution
1. **The condition on the fugacity.** Solve by bisection, summing the series term by term:
   $$\begin{aligned} g_{3/2}(z) &= \frac{2.612}{2^{3/2}} \\ &= 0.9236 \end{aligned}$$
2. **Fugacity and chemical potential.** The solution is z = 0.663, so
   $$\begin{aligned} \mu &= kT\ln z \\ &= -0.41kT \end{aligned}$$
3. **Compare with a classical gas.** A classical gas would have $z = n\lambda_T^3 \ll 1$; here the first correction term, $\frac{z^2}{2^{3/2}}$ = 0.156, is still 23% of the leading one.
4. **What it means.** Even at twice $T_E$ the gas is visibly quantum, which is why condensation sets in sharply but its precursors are already measurable above it.

**Answer:** the fugacity is 0.663 and the chemical potential is −0.41kT.
:::
:::

::: check
kind: python

## Step 1. Write `F12(eta)` returning the Fermi–Dirac integral $F_{1/2}(\eta)$, computed numerically with the substitution $x = u^2$.

```python starter
import math

def F12(eta):
    return math.exp(eta)

print(F12(0), F12(10))
```

```python solution
import numpy as np

def F12(eta):
    umax = np.sqrt(max(eta, 0) + 60)
    u = np.linspace(0, umax, 20001)
    a = np.clip(u * u - eta, -700, 700)
    y = u * u / (1 + np.exp(a))
    trap = np.trapezoid if hasattr(np, "trapezoid") else np.trapz
    return float(4 / np.sqrt(np.pi) * trap(y, u))

print(F12(0), F12(10))
```

```python tests
import math
assert abs(F12(0) - 0.765147) < 1e-5, f"F(0) = 0.765147; got {F12(0)}"
assert abs(F12(-5) - 0.0067220) < 1e-6, f"F(-5) = 0.0067220, just under e^-5; got {F12(-5)}"
assert abs(F12(10) - 24.08466) < 1e-3, f"F(10) = 24.0847; got {F12(10)}"
```

::: right
Right. Deep in the degenerate limit it approaches $\frac{4}{3\sqrt\pi}\eta^{3/2}$, 23.79 at η = 10, from above.
:::
:::

::: check
kind: python

## Step 2. Write `mu_fermi(t)` returning $\mu/E_F$ for a free Fermi gas at $t = kT/E_F$, by bisection on $\int_0^\infty\frac{\sqrt x\,dx}{e^{(x - \mu)/t} + 1} = \frac23$.

```python starter
import math

def mu_fermi(t):
    return 1 - math.pi**2 / 12 * t**2

print(mu_fermi(0.1), mu_fermi(1.0))
```

```python solution
import numpy as np

def count(m, t):
    x = np.linspace(0, max(m, 0) + 60 * t, 40001)
    y = np.sqrt(x) / (1 + np.exp(np.clip((x - m) / t, -700, 700)))
    trap = np.trapezoid if hasattr(np, "trapezoid") else np.trapz
    return trap(y, x)

def mu_fermi(t):
    lo, hi = -60.0, 1.5
    for _ in range(70):
        m = 0.5 * (lo + hi)
        if count(m, t) < 2 / 3:
            lo = m
        else:
            hi = m
    return 0.5 * (lo + hi)

print(mu_fermi(0.1), mu_fermi(1.0))
```

```python tests
assert abs(mu_fermi(0.1) - 0.991641) < 2e-4, f"At t = 0.1, μ = 0.99164 E_F; got {mu_fermi(0.1)}"
assert abs(mu_fermi(0.5) - 0.743117) < 5e-4, f"At t = 0.5, μ = 0.7431 E_F; got {mu_fermi(0.5)}"
assert abs(mu_fermi(1.0) + 0.021461) < 5e-4, f"At t = 1, μ = -0.0215 E_F; got {mu_fermi(1.0)}"
```

::: right
Right. Sommerfeld's two terms give 0.99165 at t = 0.1 but 0.18 at t = 1, where the exact answer is already negative.
:::
:::

::: check
kind: python

## Step 3. Write `heat_capacity(t)` returning a free Fermi gas's heat capacity per electron in units of k, from a central difference of $U/N = \frac32\int x^{3/2}f(x)\,dx$ (in units of $E_F$) with your `mu_fermi`.

```python starter
import math

def heat_capacity(t):
    return math.pi**2 / 2 * t

print(heat_capacity(0.1), heat_capacity(5))
```

```python solution
import numpy as np

def count(m, t):
    x = np.linspace(0, max(m, 0) + 60 * t, 40001)
    y = np.sqrt(x) / (1 + np.exp(np.clip((x - m) / t, -700, 700)))
    trap = np.trapezoid if hasattr(np, "trapezoid") else np.trapz
    return trap(y, x)

def mu_fermi(t):
    lo, hi = -60.0, 1.5
    for _ in range(70):
        m = 0.5 * (lo + hi)
        if count(m, t) < 2 / 3:
            lo = m
        else:
            hi = m
    return 0.5 * (lo + hi)

def energy(t):
    m = mu_fermi(t)
    x = np.linspace(0, max(m, 0) + 60 * t, 40001)
    y = x**1.5 / (1 + np.exp(np.clip((x - m) / t, -700, 700)))
    trap = np.trapezoid if hasattr(np, "trapezoid") else np.trapz
    return 1.5 * trap(y, x)

def heat_capacity(t):
    d = 1e-3 * t
    return float((energy(t + d) - energy(t - d)) / (2 * d))

print(heat_capacity(0.1), heat_capacity(5))
```

```python tests
assert abs(heat_capacity(0.1) - 0.47723) < 2e-3, f"At t = 0.1, C = 0.477k per electron; got {heat_capacity(0.1)}"
assert abs(heat_capacity(0.05) - 0.24488) < 2e-3, "At t = 0.05, C = 0.245k."
assert abs(heat_capacity(5) - 1.49115) < 3e-3, "At t = 5 the gas is nearly classical: C = 1.491k."
```

::: right
Right. At t = 0.1 the Sommerfeld value, 0.493, is already 3% high; the exact curve bends over toward 1.5.
:::
:::

::: check
kind: python

## Step 4. Write `bose_fugacity(t)` returning the fugacity z of an ideal Bose gas at $T = tT_E$: 1 for t ≤ 1, otherwise the root of $\sum_{n\ge1}\frac{z^n}{n^{3/2}} = \frac{2.6124}{t^{3/2}}$ by bisection.

```python starter
def bose_fugacity(t):
    return 1.0

print(bose_fugacity(2))
```

```python solution
import numpy as np

def g32(z):
    n = np.arange(1, 20001)
    return float(np.sum(z**n / n**1.5))

def bose_fugacity(t):
    if t <= 1:
        return 1.0
    target = 2.6123753 / t**1.5
    lo, hi = 0.0, 1.0
    for _ in range(60):
        z = 0.5 * (lo + hi)
        if g32(z) < target:
            lo = z
        else:
            hi = z
    return 0.5 * (lo + hi)

print(bose_fugacity(2))
```

```python tests
assert bose_fugacity(0.5) == 1.0, "Below T_E the fugacity is pinned at 1."
assert abs(bose_fugacity(2) - 0.663418) < 1e-4, f"At 2T_E, z = 0.6634; got {bose_fugacity(2)}"
assert abs(bose_fugacity(4) - 0.290786) < 1e-4, f"At 4T_E, z = 0.2908; got {bose_fugacity(4)}"
assert abs(bose_fugacity(1.5) - 0.851169) < 2e-4, "At 1.5T_E, z = 0.8512."
```

::: right
Right. Near z = 1 the series converges slowly, so many terms are needed; far above $T_E$ the first term dominates and $z \approx n\lambda_T^3$.
:::
:::

::: check
kind: python

## Step 5. Write `emission_ratio(W, T)` returning the ratio of the exact emission integral $\int_{W/kT}^\infty\ln(1 + e^{-\varepsilon})d\varepsilon$ to Richardson's $e^{-W/kT}$, for barrier `W` (eV) at `T` (K).

```python starter
def emission_ratio(W, T):
    return 1.0

print(emission_ratio(0.05, 300))
```

```python solution
import numpy as np

def emission_ratio(W, T):
    w = W / (8.617333e-5 * T)
    e = np.linspace(w, w + 60, 200001)
    trap = np.trapezoid if hasattr(np, "trapezoid") else np.trapz
    return float(trap(np.log1p(np.exp(-e)), e) / np.exp(-w))

print(emission_ratio(0.05, 300))
```

```python tests
assert abs(emission_ratio(0.05, 300) - 0.96601) < 1e-4, f"For a 50 meV barrier at 300 K the exact current is 3.4% below Richardson's; got {emission_ratio(0.05, 300)}"
assert abs(emission_ratio(4.5, 2000) - 1) < 1e-6, "For a real work function Richardson's law is exact to many digits."
```

::: right
Right. Richardson's law only needs correcting for barriers within a few kT, such as low Schottky barriers.
:::
:::

::: check
kind: parts
given: F = 3.24 | 7 | 11.7; T = 300 | 1000 | 5000

## A free-electron metal has $E_F$ = {F} eV, at {T} K.

::: part
answer: -pi^2/12*(0.00008617333*T)^2/F*1000
unit: meV
tolerance: 0.5%

### By how much has its chemical potential shifted from $E_F$?

::: misses
- [pi^2/12*(0.00008617333*T)^2/F*1000] It falls, so the shift is negative.
- [any] $-\frac{\pi^2}{12}\frac{(kT)^2}{E_F}$.
:::
:::

::: part
answer: pi^2/2*0.00008617333*T/F
tolerance: 0.5%

### What's its heat capacity per electron, in units of k?

::: misses
- [1.5] That's the classical value; only electrons near $E_F$ can absorb heat.
- [any] $\frac{\pi^2}{2}\frac{kT}{E_F}$.
:::
:::
:::

::: check
given: e = 20 | 50 | 200
answer: 4/(3*sqrt(pi))*e^1.5
tolerance: 0.5%

## Deep in the degenerate limit, what's $F_{1/2}(\eta)$ at η = {e}?

::: right
Right. $\frac{4}{3\sqrt\pi}\eta^{3/2}$, the zero-temperature filling of a parabolic band.
:::

::: misses
- [exp(e)] The Boltzmann form fails completely when the Fermi level is far inside the band.
- [any] $\frac{4}{3\sqrt\pi}\eta^{3/2}$.
:::
:::

::: check
given: t = 0.3 | 0.6 | 1
answer: 0.51351*t^1.5
tolerance: 0.5%

## An ideal Bose gas is at {t} of its condensation temperature. What's its pressure as a fraction of the classical nkT?

::: right
Right. Only the uncondensed atoms push: $\frac{g_{5/2}(1)}{g_{3/2}(1)}\left(\frac{T}{T_E}\right)^{3/2}$.
:::

::: misses
- [1 - t^1.5] That's the condensate fraction.
- [any] $0.514\left(\frac{T}{T_E}\right)^{3/2}$.
:::
:::

::: check
given: m = 0.067 | 0.26 | 1.08
answer: 120.173*m
unit: A/(cm²·K²)
tolerance: 0.5%

## What's the effective Richardson constant for carriers of effective mass {m}$m_e$?

::: right
Right. $A^* = \frac{4\pi m^*qk^2}{h^3}$ = 120.2 $m^*/m_e$ A/(cm²·K²).
:::

::: misses
- [120.173] Scale by the effective mass.
- [any] $A^* = 120.2\frac{m^*}{m_e}$.
:::
:::

::: explain
## Why does a Fermi gas's chemical potential fall as it's heated, even though no electrons leave?

::: model
At absolute zero every state up to $E_F$ is full. Heating smears the edge: some electrons move above $E_F$ and leave empty states below. Because the density of states grows with energy, as $\sqrt E$, there are more states just above $E_F$ than just below. If μ stayed at $E_F$, the symmetric smearing of the Fermi function would put more electrons into the many states above than it removed from the fewer states below, and the count would grow. To keep the number fixed, μ must slide down a little. At high temperature the effect takes over completely and μ heads toward the classical, strongly negative value.
:::
:::

::: practice

::: check
given: F = 5 | 9; T = 300 | 2000
answer: -pi^2/12*(0.00008617333*T)^2/F*1000
unit: meV
tolerance: 0.5%

## Sommerfeld shift of μ for $E_F$ = {F} eV at {T} K?

::: misses
- [any] $-\frac{\pi^2}{12}\frac{(kT)^2}{E_F}$.
:::
:::

::: check
given: e = 20 | 30 | 50 | 80 | 100 | 200
answer: 4/(3*sqrt(pi))*e^1.5
tolerance: 0.5%

## Degenerate $F_{1/2}$ at η = {e}?

::: misses
- [any] $\frac{4}{3\sqrt\pi}\eta^{3/2}$.
:::
:::
:::
