---
title: Real gases and the van der Waals equation
heading: Molecules with size and attraction, the critical point, and why a throttled gas cools
eyebrow: B11 · Lesson 34 · Real gases and the van der Waals equation
xp: 50
---

::: hook
The ideal gas of lesson 19 never condenses, yet a CO₂ fire extinguisher at room temperature holds liquid, and the nitrogen a cryostat runs on was made by letting compressed air expand through a valve until it got cold enough to liquefy. Both depend on the two things the ideal gas leaves out: molecules take up room, and they attract each other. Van der Waals put both into one equation in 1873. It's only roughly right in numbers, but it predicts a critical point above which no pressure can liquefy a gas, it gives the vapor pressure through Maxwell's equal-area rule, and with lesson 31's Maxwell relations it explains why throttling cools nitrogen but warms helium.
:::

::: play
- Isotherms of the van der Waals gas in reduced units, pressure against volume, each measured from the critical point: $p_r = \dfrac{8T_r}{3V_r - 1} - \dfrac{3}{V_r^2}$. The dashed curve is an ideal gas at the same temperature.
- Above $T_r = 1$ the isotherm falls steadily: compressing always raises the pressure. Below it, a loop appears where squeezing would lower the pressure. That part is unstable, and the real gas condenses at a constant pressure instead.
- At $T_r = 1$ the curve has a flat inflection at $V_r = 1$, $p_r = 1$: the critical point.
:::

```sim plot
view: graph
x: V = 0.45..4
y: p = 0..2
slider: T = 0.85..1.15 step 0.01 = 0.9
plot: 8*T/(3*V - 1) - 3/V^2 | label: van der Waals
plot: 8*T/(3*V) | dashed | label: ideal gas
readout: pressure at V_r 1 = 4*T - 3 | digits: 3
readout: Z at the critical point = 3/8 | digits: 3
```

::: predict
## Above what temperature can no amount of compression turn carbon dioxide into a liquid?

- [x] About 31 °C
- [ ] About 100 °C
- [ ] About −78 °C
- [ ] There is no such temperature

::: reveal
CO₂'s critical temperature is 304.1 K, 31 °C. Below it, compressing the gas eventually reaches the vapor pressure and liquid forms; above it, the gas just gets denser without ever separating into two phases. That's why a CO₂ extinguisher on a hot day holds a supercritical fluid instead of a liquid. −78 °C is where solid CO₂ sublimes at one atmosphere, a different point on the phase diagram.
:::
:::

::: nameit
## The van der Waals equation

$$\left(p + \frac{an^2}{V^2}\right)(V - nb) = nRT$$

- $b$ is the volume a mole of molecules occupies themselves, so only $V - nb$ is free.
- $a$ measures the attraction. A molecule near the wall is pulled back by its neighbors, which lowers the pressure by $an^2/V^2$: proportional to the density of molecules hitting the wall times the density pulling them back.

## The critical point and corresponding states

The critical isotherm has a flat inflection, $\partial p/\partial V = \partial^2p/\partial V^2 = 0$, which gives

$$V_c = 3nb, \qquad T_c = \frac{8a}{27Rb}, \qquad p_c = \frac{a}{27b^2}, \qquad Z_c = \frac{p_cV_c}{nRT_c} = \frac38$$

In reduced variables $p_r = p/p_c$, $V_r = V/V_c$, $T_r = T/T_c$ every van der Waals gas obeys the same equation, $p_r = \dfrac{8T_r}{3V_r - 1} - \dfrac{3}{V_r^2}$. Real gases follow this **law of corresponding states** roughly, which is why engineering charts of compressibility are drawn in reduced units.

## Vapor pressure by equal areas

Below $T_c$ the loop is unphysical. The liquid and vapor coexist at the pressure $p_{sat}$ where their Gibbs free energies match (lesson 33), and since $dG = V\,dp$ along an isotherm, that's the pressure at which the line $p = p_{sat}$ cuts equal areas above and below the loop: **Maxwell's construction**. At $T_r$ = 0.9, it gives $p_{sat}$ = 0.647 $p_c$.

## Low density: the virial expansion

Expanding in $1/V_m$ (molar volume),

$$Z = \frac{pV_m}{RT} \approx 1 + \frac{B(T)}{V_m}, \qquad B(T) = b - \frac{a}{RT}$$

At low temperature attraction wins and $Z < 1$; at high temperature size wins. They balance at the **Boyle temperature** $T_B = a/(Rb) = \frac{27}{8}T_c$.

## Throttling and the Joule–Thomson effect

Gas forced through a valve or porous plug keeps its enthalpy. Lesson 31's relation $(\partial S/\partial p)_T = -(\partial V/\partial T)_p$ gives the temperature change per unit pressure drop:

$$\mu_{JT} = \left(\frac{\partial T}{\partial p}\right)_H = \frac{T(\partial V/\partial T)_p - V}{C_p}$$

which is zero for an ideal gas. For a van der Waals gas at low pressure, $\mu_{JT} \approx \dfrac{2a/RT - b}{C_{p,m}}$. It's positive (the gas cools as the pressure falls) below the **inversion temperature** $T_{inv} = 2a/(Rb) = \frac{27}{4}T_c$ and negative above it.
:::

::: example
## For CO₂, $a$ = 0.364 Pa·m⁶/mol² and $b$ = 4.267 × 10⁻⁵ m³/mol. Find the van der Waals critical constants and compare them with the measured 304.1 K, 7.38 MPa and 94 cm³/mol.

::: solution
1. **Critical temperature.**
   $$\begin{aligned} T_c &= \frac{8a}{27Rb} \\ &= \frac{8 \times 0.364}{27 \times 8.314 \times 4.267 \times 10^{-5}} \\ &= 304.0\ \text{K} \end{aligned}$$
2. **Critical pressure.**
   $$\begin{aligned} p_c &= \frac{a}{27b^2} \\ &= 7.40\ \text{MPa} \end{aligned}$$
3. **Critical volume.**
   $$\begin{aligned} V_c &= 3b \\ &= 128\ \text{cm}^3\text{/mol} \end{aligned}$$
4. **Compare.** The temperature and pressure match almost exactly, but only because tables usually choose $a$ and $b$ to fit them.
5. **The real test.** The third number is the test: the measured volume is 94 cm³/mol, so the real $Z_c$ is
   $$\begin{aligned} Z_c &= \frac{7.38 \times 10^6 \times 94.1 \times 10^{-6}}{8.314 \times 304.1} \\ &= 0.275 \end{aligned}$$
   against the equation's 0.375.
6. **Why they differ.** Real molecules are softer and pack more tightly than hard spheres with a uniform pull.

**Answer:** van der Waals gives 304.0 K, 7.40 MPa and 128 cm³/mol; the first two match the measured values, but the volume is well above the measured 94 cm³/mol.
:::
:::

::: example
## Nitrogen has $a$ = 0.137 Pa·m⁶/mol² and $b$ = 3.87 × 10⁻⁵ m³/mol. At 300 K, estimate $Z$ at 1 MPa from the second virial coefficient, and compare the full van der Waals value at 1 MPa and at a cylinder's 20 MPa.

::: solution
1. **Second virial coefficient.**
   $$\begin{aligned} B &= b - \frac{a}{RT} \\ &= 3.87 \times 10^{-5} - \frac{0.137}{8.314 \times 300} \\ &= -1.62 \times 10^{-5}\ \text{m}^3\text{/mol} \end{aligned}$$
2. **Z at 1 MPa.**
   $$\begin{aligned} Z &\approx 1 + Bp/RT \\ &= 1 - 1.62 \times 10^{-5} \times 10^6/2494 \\ &= 0.9935 \end{aligned}$$
3. **Compare with the full cubic.** Solving the full cubic for $V_m$ gives 0.9937: one term is plenty at low density, and nitrogen at room temperature is below its Boyle temperature (426 K by this equation), so attraction wins slightly.
4. **At 20 MPa.** The cubic gives $V_m$ = 126 cm³/mol and $Z$ = 1.008, while the one-term expansion says 0.870.
5. **Why the expansion fails.** At that density $b/V_m$ is 0.31, the higher terms of $V/(V - b) = 1 + b/V + b^2/V^2 + \ldots$ matter, and the molecules' size has caught up with their attraction.
6. **For a gas cylinder.** A cylinder's contents can't be estimated from $pV = nRT$ to better than a few percent at these pressures, and the truncated expansion is worse.

**Answer:** at 1 MPa the virial estimate gives Z = 0.9935 against the full equation's 0.9937; at 20 MPa the full equation gives Z = 1.008, while the one-term expansion says 0.870.
:::
:::

::: example
## Estimate the Joule–Thomson coefficient of nitrogen at 300 K ($C_{p,m}$ = 29.1 J/(mol·K)), and the inversion temperatures of hydrogen ($a$ = 0.0248, $b$ = 2.66 × 10⁻⁵) and helium ($a$ = 0.00346, $b$ = 2.38 × 10⁻⁵, SI units).

::: solution
1. **Joule–Thomson coefficient of nitrogen.**
   $$\begin{aligned} \mu_{JT} &\approx \frac{2a/RT - b}{C_{p,m}} \\ &= \frac{1.099 \times 10^{-4} - 3.87 \times 10^{-5}}{29.1} \\ &= 2.45 \times 10^{-6}\ \text{K/Pa} \\ &= 0.245\ \text{K/bar} \end{aligned}$$
   This is close to the measured value for nitrogen near room temperature, about 0.22 K/bar.
2. **Liquefying air.** A throttle from 200 bar cools it by tens of kelvins, which is how the Linde process liquefies air once the cold outflow precools the incoming gas.
3. **Inversion temperature of hydrogen.**
   $$\begin{aligned} T_{inv} &= \frac{2a}{Rb} \\ &= \frac{2 \times 0.0248}{8.314 \times 2.66 \times 10^{-5}} \\ &= 224\ \text{K} \end{aligned}$$
4. **Inversion temperature of helium.** The same formula gives 35 K. Measured values are about 200 K for hydrogen and 40 K for helium.
5. **What it means for liquefiers.** Either way, both gases warm when throttled at room temperature, so a hydrogen liquefier first cools its gas with liquid nitrogen, and helium needs precooling to below about 40 K, which is why the cryocoolers in lesson 49 use expansion engines or regenerators before the final Joule–Thomson stage.

**Answer:** nitrogen's Joule–Thomson coefficient is about 0.245 K/bar at 300 K; the inversion temperatures come out 224 K for hydrogen and 35 K for helium.
:::
:::

::: check
given: a = 0.137 | 0.364 | 0.0248 | 0.553; b = 3.87 | 4.27 | 2.66 | 3.05
answer: 8*a/(27*8.314*b*1e-5)
unit: K
tolerance: 0.5%

## A gas has van der Waals constants $a$ = {a} Pa·m⁶/mol² and $b$ = {b} × 10⁻⁵ m³/mol. What is its critical temperature?

::: right
Right. $T_c = 8a/(27Rb)$ = {answer}.
:::

::: misses
- [a/(8.314*b*1e-5)] That's the Boyle temperature, $\frac{27}{8}T_c$.
- [2*a/(8.314*b*1e-5)] That's the inversion temperature, $\frac{27}{4}T_c$.
- [8*a/(27*8.314*b)] Put $b$ in m³/mol: multiply by 10⁻⁵.
- [any] Not yet. Use $T_c = 8a/(27Rb)$.
:::
:::

::: check
kind: parts
given: a = 0.137 | 0.364 | 0.553; b = 3.87 | 4.27 | 3.05

## A gas has $a$ = {a} Pa·m⁶/mol² and $b$ = {b} × 10⁻⁵ m³/mol.

::: part
answer: a/(27*(b*1e-5)^2)/1e6
unit: MPa
tolerance: 0.5%

### What is its van der Waals critical pressure, in MPa?

::: misses
- [a/(27*b*1e-5)/1e6] The critical pressure goes as $1/b^2$.
- [any] Not yet. $p_c = a/(27b^2)$.
:::
:::

::: part
answer: 3*b*10
unit: cm³/mol
tolerance: 0.5%

### What is its critical molar volume, in cm³/mol?

::: misses
- [b*10] The critical volume is three times $b$.
- [any] Not yet. $V_c = 3b$; 10⁻⁵ m³ is 10 cm³.
:::
:::

::: right
Right. With $T_c$ these give $Z_c = 3/8$ for every van der Waals gas, which real gases miss: most fall between 0.23 and 0.31.
:::
:::

::: check
given: T = 200 | 250 | 300; p = 0.5 | 1 | 2
answer: (3.87e-5 - 0.137/(8.314*T))*p*1e6/(8.314*T)*100
tolerance: 1%

## Using the second virial coefficient of the van der Waals equation, by what percentage does nitrogen's $Z$ differ from 1 at {T} K and {p} MPa? ($a$ = 0.137 Pa·m⁶/mol², $b$ = 3.87 × 10⁻⁵ m³/mol; give a negative number if $Z < 1$.)

::: right
Right. $B = b - a/RT$, and $Z - 1 \approx Bp/RT$ = {answer}%.
:::

::: misses
- [3.87e-5*p*1e6/(8.314*T)*100] That's only the size term; the attraction lowers $Z$.
- [-0.137/(8.314*T)*p*1e6/(8.314*T)*100] That's only the attraction; the molecules' size raises $Z$.
- [-(3.87e-5 - 0.137/(8.314*T))*p*1e6/(8.314*T)*100] Check the sign: below the Boyle temperature, attraction wins and $Z < 1$.
- [any] Not yet. $Z - 1 \approx (b - a/RT)p/RT$.
:::
:::

::: check
kind: parts
given: a = 0.137 | 0.0248 | 0.00346 | 0.364; b = 3.87 | 2.66 | 2.38 | 4.27

## A gas has $a$ = {a} Pa·m⁶/mol² and $b$ = {b} × 10⁻⁵ m³/mol.

::: part
answer: a/(8.314*b*1e-5)
unit: K
tolerance: 0.5%

### What is its Boyle temperature, where the second virial coefficient vanishes?

::: misses
- [2*a/(8.314*b*1e-5)] That's the inversion temperature, twice as high.
- [any] Not yet. $B = b - a/RT = 0$ at $T_B = a/Rb$.
:::
:::

::: part
answer: 2*a/(8.314*b*1e-5)
unit: K
tolerance: 0.5%

### Below what temperature does throttling at low pressure cool it?

::: misses
- [a/(8.314*b*1e-5)] That's the Boyle temperature; inversion needs $2a/RT = b$.
- [any] Not yet. $\mu_{JT} > 0$ when $2a/RT > b$.
:::
:::

::: right
Right. The inversion temperature is twice the Boyle temperature in this model; for helium and hydrogen both lie far below room temperature.
:::
:::

::: check
given: T = 250 | 300 | 350; cp = 29.1 | 37.1
answer: (2*0.364/(8.314*T) - 4.267e-5)/cp*1e5
tolerance: 1%

## For CO₂ ($a$ = 0.364 Pa·m⁶/mol², $b$ = 4.267 × 10⁻⁵ m³/mol), take $C_{p,m}$ = {cp} J/(mol·K). In kelvins per bar, what is the low-pressure Joule–Thomson coefficient at {T} K?

::: right
Right. $\mu_{JT} \approx (2a/RT - b)/C_{p,m}$ = {answer} K/bar: a gas with strong attraction cools a lot when throttled.
:::

::: misses
- [(2*0.364/(8.314*T) - 4.267e-5)/cp] That's in K/Pa. One bar is 10⁵ Pa.
- [(0.364/(8.314*T) - 4.267e-5)/cp*1e5] The attraction term is $2a/RT$, twice the virial coefficient's.
- [any] Not yet. Use $\mu_{JT} \approx (2a/RT - b)/C_{p,m}$ and convert to K/bar.
:::
:::

::: check
kind: choice

## Every van der Waals gas has the same compressibility factor $Z_c = p_cV_c/(nRT_c)$ at its critical point. What is it?

- [x] 3/8
- [ ] 1
- [ ] 8/27
- [ ] 27/64

::: right
Right. $p_c V_c/(nRT_c) = \frac{a}{27b^2}\cdot 3b \cdot \frac{27b}{8a} = \frac38$. Real gases come in lower, near 0.29 for simple ones and 0.27 for CO₂.
:::

::: misses
- [2] That's the ideal gas. At the critical point attraction is strong and $Z$ is well below 1.
- [3] $8/27$ appears in $T_c = 8a/27Rb$; it isn't $Z_c$.
- [4] That's the factor in $a = 27R^2T_c^2/(64p_c)$.
:::
:::

::: check
kind: derivation
vars: a = 0.01..0.6, b = 2e-5..5e-5

## Find the van der Waals critical point. Write $p = \dfrac{RT}{V - b} - \dfrac{a}{V^2}$ per mole and set $\partial p/\partial V = \partial^2p/\partial V^2 = 0$.

::: step
answer: 3*b

### Dividing the two conditions eliminates $T$. What is $V_c$?
:::

::: step
answer: 8*a/(27*8.314*b)

### Put $V_c$ back into $\partial p/\partial V = 0$. What is $T_c$? (Use R = 8.314.)
:::

::: step
answer: a/(27*b^2)

### And $p_c$, from the equation of state?
:::

::: right
Right. $V_c = 3b$, $T_c = 8a/27Rb$, $p_c = a/27b^2$. Two measured critical constants fix $a$ and $b$; the third is then a prediction, and it comes out about a third too large.
:::
:::

::: check
kind: python
given: t = 0.85 | 0.9 | 0.95

## Find the reduced vapor pressure of a van der Waals gas at $T_r$ = `t` = {t} by Maxwell's construction. For a trial pressure $p$ between the loop's minimum and maximum, the reduced isotherm $p = \frac{8t}{3V - 1} - \frac{3}{V^2}$ crosses it at three volumes; use the smallest and largest, $V_l$ and $V_g$ (the roots of $3pV^3 - (p + 8t)V^2 + 9V - 3 = 0$, for instance with `numpy.roots`). The area between the curve and the line is $\int_{V_l}^{V_g}(p_{vdW} - p)\,dV = \frac{8t}{3}\ln\frac{3V_g - 1}{3V_l - 1} + \frac{3}{V_g} - \frac{3}{V_l} - p(V_g - V_l)$. Bisect on $p$ until it's zero, to 1e-10, and set `psat`, `Vl` and `Vg`.

```python starter
import numpy as np
psat = 4 * t - 3
Vl = Vg = 1.0
print(psat, Vl, Vg)
```

```python solution
import numpy as np
def vols(p):
    r = np.roots([3 * p, -(p + 8 * t), 9, -3])
    r = sorted(x.real for x in r if abs(x.imag) < 1e-9)
    return r[0], r[-1]
def area(p):
    vl, vg = vols(p)
    return 8 * t / 3 * np.log((3 * vg - 1) / (3 * vl - 1)) + 3 / vg - 3 / vl - p * (vg - vl)
pv = lambda V: 8 * t / (3 * V - 1) - 3 / V**2
Vs = np.linspace(0.4, 5, 200001)
ps = pv(Vs)
dps = np.diff(ps)
i_min = np.argmax(dps > 0)
i_max = i_min + np.argmax(dps[i_min:] < 0)
lo, hi = max(ps[i_min], 1e-9) + 1e-9, ps[i_max] - 1e-9
while hi - lo > 1e-12:
    m = (lo + hi) / 2
    if area(m) > 0: lo = m
    else: hi = m
psat = (lo + hi) / 2
Vl, Vg = vols(psat)
print(psat, Vl, Vg)
```

```python tests
import math
ref = {0.85: 0.504492, 0.9: 0.646998, 0.95: 0.811879}[t]
assert abs(psat - ref) < 1e-5, f"At T_r = {t} the equal-area pressure is {ref:.6f}; got {psat:.6f}."
f = lambda V: 8 * t / (3 * V - 1) - 3 / V**2
assert abs(f(Vl) - psat) < 1e-8 and abs(f(Vg) - psat) < 1e-8, "Vl and Vg should lie on the isotherm at psat."
assert Vl < 1 < Vg, "The liquid volume should be below V_c and the vapor's above it."
```

::: right
Right. The equal-area line is the vapor pressure, and $V_l$ and $V_g$ are the densities of the coexisting liquid and vapor. As $T_r \to 1$ they merge and the latent heat vanishes.
:::
:::

::: explain
## A helium liquefier can't just compress room-temperature helium and let it expand through a valve. Use the Joule–Thomson coefficient to explain why, and what the liquefier does instead.

::: model
Throttling keeps enthalpy fixed, and the temperature change per unit pressure drop is $\mu_{JT} \approx (2a/RT - b)/C_p$ at low pressure. The attraction term $2a/RT$ cools the gas, since molecules pulling apart lose kinetic energy, while the size term $b$ warms it. Helium's attraction is so weak that the size term wins at any temperature above its inversion temperature, about 40 K, so at room temperature an expansion through a valve warms it slightly. The liquefier therefore first cools the helium below that temperature by other means, such as expansion engines that make the gas do work, regenerators or a liquid-nitrogen precooler, and only then uses a Joule–Thomson valve for the last step, where the effect has the right sign and is large.
:::
:::

::: practice

::: check
given: Tc = 126 | 151 | 304
answer: 27/8*Tc
unit: K
tolerance: 0.5%

## A van der Waals gas has $T_c$ = {Tc} K. What is its Boyle temperature?

::: misses
- [27/4*Tc] That's the inversion temperature.
- [any] $T_B = a/Rb = \frac{27}{8}T_c$.
:::
:::

::: check
given: t = 1.1 | 1.3 | 1.5; v = 2 | 3
answer: 8*t/(3*v - 1) - 3/v^2
tolerance: 0.5%

## What is the reduced pressure of a van der Waals gas at $T_r$ = {t} and $V_r$ = {v}?

::: misses
- [8*t/(3*v)] That's the ideal gas in reduced units; include $b$ and $a$.
- [any] $p_r = 8T_r/(3V_r - 1) - 3/V_r^2$.
:::
:::
:::
