Where the Ideal Gas Starts to Lie — Compressibility Factor Z and the van der Waals Equation
Real gases through the compressibility factor, corresponding states, and the van der Waals loop
Take nitrogen at 100 bar and 200 K, compute its density with the ideal gas law, and you miss the real value by more than a quarter. Same pressure, same temperature — yet the molecules pull on each other and take up room of their own. This post is about catching that mismatch with a single number (the compressibility factor ), about how van der Waals mimicked a real gas with just two constants, and about the S-shaped curve below the critical point that splits liquid from vapor. At the end we see why all of this reaches straight into rocket-injector flow and the cells of a CFD grid.
Nitrogen at 100 bar is heavier than an ideal gas#
The ideal gas law treats molecules as points and ignores the forces between them. It works for dilute gases, where molecules sit far apart.
Raise the pressure and that breaks. Molecules crowd together. A weak attraction (the van der Waals force) pulls them in and shrinks the volume. At the same time, the molecules' own volume stops being negligible.
The two effects pull opposite ways. Attraction shrinks the volume; finite size inflates it. Which one wins is set by temperature and pressure. So "a real gas is heavier — or lighter — than an ideal gas" flips depending on the conditions.
The compressibility factor Z — one number for the mismatch#
That mismatch gets bundled into a single number.
is pressure, molar volume, the gas constant, temperature. If , the gas is ideal. The farther strays from 1, the larger the deviation.
means attraction dominates: molecules draw together and the real volume is smaller than ideal. means finite size dominates: molecules push apart and the volume grows. For the nitrogen above, , so the real density was times the ideal value.
The principle of corresponding states: where every gas looks alike#
Every gas has its own curve. Yet divide pressure and temperature by each gas's own critical values, and the curves nearly collapse onto one.
and are the critical pressure and temperature. The principle of corresponding states says this: at the same reduced pressure and reduced temperature , nearly all gases share nearly the same .
Nitrogen, methane, carbon dioxide — at , they have similar . It is not the species but the position relative to the critical point that sets behavior. That universality lets a single generalized chart cover countless gases.
van der Waals: mimicking molecules with two constants#
In 1873 van der Waals added two corrections to the ideal gas law.
is the pressure drop from intermolecular attraction; the denser the gas (the smaller ), the stronger it gets. is the volume the molecules themselves occupy, so the free space shrinks to .
The two constants are fixed at the critical point. There the – isotherm passes through an inflection where slope and curvature both vanish.
Solving both conditions gives the constants and the critical compressibility.
Here is a constant independent of which gas. Real gases have around 0.27–0.29, so van der Waals overshoots quantitatively — but the qualitative picture is exactly right.
Rewrite in reduced variables and the constants , disappear.
That single line is the equation form of corresponding states. The critical point is pinned at .
The S-curve below the critical point and the Maxwell construction#
For the isotherm decreases monotonically. Raise the pressure and the volume shrinks — the intuitive curve.
For it wobbles. An S-shaped loop appears. Its middle branch has : raise the pressure and the volume grows, which is mechanically unstable. Real matter simply skips this branch.
Instead a single horizontal line bridges liquid and vapor. Its height is the saturation pressure. The position comes from the Maxwell equal-area construction: pick the height at which the line cuts off two equal areas, above and below, from the loop. That condition is equivalent to the liquid and vapor sharing the same Gibbs free energy. It is the one pressure at which the two phases can coexist.
Play with the simulation below. Drag the reduced-temperature slider under 1 and the loop grows, while the Maxwell construction shades two equal-area regions (pink and cyan) and draws the saturation pressure.
Z(sat. vapor) = 0.633 · Z(sat. liquid) = 0.163
Drop to 0.85 and the gap in between saturated vapor and saturated liquid widens sharply. The liquid-side falls below 0.1, because the molecules nearly touch and attraction overwhelms. Push toward 1 and the two values merge into one point — the moment at the critical point where liquid and vapor stop being distinct.
Solving for Z in Python#
Rearrange the van der Waals equation for and you get a cubic. With nothing but the real gas's critical constants you can solve for at any , .
import numpy as np
R = 8.314 # J/(mol·K)
def vdw_constants(Tc, Pc):
"""van der Waals a, b from the critical constants."""
a = 27.0 * R**2 * Tc**2 / (64.0 * Pc)
b = R * Tc / (8.0 * Pc)
return a, b
def vdw_compressibility(P, T, Tc, Pc):
"""Physical root of Z^3 - (1+B)Z^2 + A Z - A B = 0."""
a, b = vdw_constants(Tc, Pc)
A = a * P / (R * T)**2 # dimensionless size of the attraction term
B = b * P / (R * T) # dimensionless size of the finite-volume term
coeffs = [1.0, -(1.0 + B), A, -A * B]
roots = np.roots(coeffs)
real = roots[np.abs(roots.imag) < 1e-8].real
real = real[real > B] # only v > b ⇒ Z > B is physical
return real.max(), real.min(), real.size
# Nitrogen: Tc = 126.2 K, Pc = 3.39 MPa, M = 28 g/mol
Tc, Pc, M = 126.2, 3.39e6, 0.028
P, T = 1.0e7, 200.0 # 100 bar, 200 K
Z_gas, Z_liq, n = vdw_compressibility(P, T, Tc, Pc)
rho_ideal = P * M / (R * T) # ideal-gas density
rho_real = rho_ideal / Z_gas # real density
print(f"roots = {n}, Z = {Z_gas:.4f}")
print(f"ideal density = {rho_ideal:6.1f} kg/m^3")
print(f"real density = {rho_real:6.1f} kg/m^3 ({100*(rho_real/rho_ideal-1):+.0f}%)")The output is:
roots = 1, Z = 0.7905
ideal density = 168.4 kg/m^3
real density = 213.0 kg/m^3 (+27%)Since , we are above critical. There is a single real root, so no liquid/vapor split. Even so, the ideal-gas density is 27% below the real one — exactly the "more than a quarter" error from the opening line.
Supercritical injection and CFD — why the equation of state shakes the grid#
This is not chalkboard-only. A liquid rocket engine's combustion chamber usually runs above the propellant's critical pressure. When LOX (liquid oxygen) or a cryogenic nitrogen jet sprays into such a chamber, no familiar droplets form.
Surface tension disappears. Cross the critical point and the boundary between liquid and gas dissolves. The jet does not break into drops; its density gradient unfurls like a comb and mixes with the surroundings. This is supercritical (or transcritical) injection, a central flow phenomenon in next-generation engine design.
Here the equation of state shakes the grid, because density is bound nonlinearly to pressure and temperature. If a CFD solver assumes an ideal gas, it gets the jet density wrong by tens of percent, and with it the momentum flux and the mixing length go off entirely. So real codes use real-gas models — a cubic EOS (Peng–Robinson, SRK) or NASG (Noble–Abel Stiffened Gas). The compressibility factor is exactly what those models solve in every grid cell.
Things to remember#
- The compressibility factor captures, in one number, how far a real gas departs from ideal. means attraction dominates; means finite volume dominates.
- The van der Waals equation reproduces the critical point, the loop, and the phase transition qualitatively with just two constants — attraction and molecular volume . In reduced variables it universalizes to .
- Beyond the critical point, supercritical flows mix without surface tension, and solving them in CFD requires a real equation of state — not the ideal gas — in every grid cell.
Share if you found it helpful.