Virial Equation of State

Every real gas obeys PV=NkBTPV=Nk_BT only in the limit of vanishing density. Squeeze it even slightly and molecules begin to feel one another — and the pressure departs from the ideal law in a way that is not chaotic but exquisitely organized. The virial equation of state writes the compressibility factor Z=PV/NkBTZ=PV/Nk_BT as a power series in the number density n=N/Vn=N/V: Z=1+B2(T) n+B3(T) n2+⋯Z=1+B_2(T)\,n+B_3(T)\,n^2+\cdots. The leading 11 is the ideal gas; the first correction B2(T)B_2(T) captures everything that happens when two molecules meet, B3(T)B_3(T) when three cluster, and so on. It is the systematic, controlled bridge from the ideal gas to the fully interacting fluid. The second virial coefficient is the star of the theory because it is both computable and measurable. Computable: it is a single integral over the pair potential, B2(T)=−12∫(e−βu(r)−1) d3rB_2(T)=-\tfrac12\int(e^{-\beta u(r)}-1)\,d^3r, the thermally weighted "excluded-or-attracted" volume of one molecular pair. Measurable: it is read directly off low-pressure PVTPVT data. Its temperature dependence is a fingerprint of the forces between molecules — positive and roughly constant at high temperature where the hard repulsive core dominates, negative at low temperature where the attractive tail wins, and passing through zero at a special temperature. That zero is the Boyle temperature TBT_B, where a real gas mimics an ideal one to first order in density over an extended pressure range. Above it repulsion dominates and Z>1Z>1 (harder to compress than ideal); below it attraction dominates and Z<1Z<1. The van der Waals equation is nothing but the leading virial correction B2=b−a/kBTB_2=b-a/k_BT resummed — the microscopic B2B_2 integral is what connects the phenomenological constants aa and bb to the actual shape of the intermolecular potential. This article owns that integral, its hard-sphere and square-well evaluations, and the sign story behind TBT_B.

Key takeaways
  • The virial equation of state expands the pressure in powers of number density: P/kBT=n+B2(T) n2+B3(T) n3+⋯P/k_BT=n+B_2(T)\,n^2+B_3(T)\,n^3+\cdots, reducing to PV=NkBTPV=Nk_BT as n→0n\to0.
  • The second virial coefficient is B2(T)=−12∫(e−βu(r)−1) d3rB_2(T)=-\tfrac12\int(e^{-\beta u(r)}-1)\,d^3r — a single integral over the pair potential, the workhorse of the whole theory.
  • Its sign encodes the physics: hard-core repulsion makes B2>0B_2>0 (gas harder to compress); attraction makes B2<0B_2<0. They cancel at the Boyle temperature TBT_B, where B2(TB)=0B_2(T_B)=0.
  • For hard spheres of diameter σ\sigma, B2=2π3σ3=4v0B_2=\tfrac{2\pi}{3}\sigma^3=4v_0 — exactly four times the molecular volume, the classic excluded-volume result.
  • The van der Waals equation is the leading virial correction resummed: B2=b−a/kBTB_2=b-a/k_BT with bb the excluded volume and aa the attraction, giving TB=a/bkBT_B=a/bk_B.
  • The series is asymptotic and breaks down at condensation — a phase transition cannot be reached by any finite-order density expansion.
  • Key idea: the second virial coefficient B2(T)=−12∫(e−βu−1) d3rB_2(T)=-\tfrac12\int(e^{-\beta u}-1)\,d^3r turns the microscopic pair potential directly into the first correction to the ideal gas, and the sign of B2B_2 — repulsion versus attraction — governs whether a gas is harder or easier to compress than ideal.
The core insight

The second virial coefficient B2(T)=−12∫(e−βu(r)−1) d3rB_2(T)=-\tfrac12\int(e^{-\beta u(r)}-1)\,d^3r is the thermally averaged excluded-or-attracted volume of one molecular pair. It converts the microscopic pair potential straight into the leading correction to the ideal gas law, and its sign — positive for repulsion, negative for attraction — decides whether the gas is harder or easier to compress than ideal, vanishing at the Boyle temperature.

Where this lives today

The virial equation of state remains the cleanest quantitative bridge between intermolecular forces and thermodynamics. In precision metrology, the second virial coefficient of helium is now computed from first-principles quantum chemistry to parts per million and used to realize the thermodynamic temperature scale by acoustic and dielectric gas thermometry — the equation of state of a dilute noble gas is a primary standard. In chemical engineering, truncated virial equations (through B3B_3) model moderately dense gases and gas mixtures more accurately than cubic equations, with combining rules for the cross coefficient B2(ij)B_2^{(ij)} of unlike molecules. In the theory of simple liquids, the Mayer cluster expansion that generates the virial coefficients is the starting point for integral-equation and perturbation theories of dense fluids. And the low-temperature quantum correction B2=∓λ3/25/2B_2=\mp\lambda^3/2^{5/2} — a second virial coefficient arising from statistics alone, with no forces — is measured directly in the equation of state of 3^3He and 4^4He, a textbook demonstration of quantum statistics entering thermodynamics through the thermal de Broglie wavelength.

The physical picture

Picture a gas dilute enough that any given molecule spends almost all its time alone, feeling no forces, moving in a straight line. The pressure is then the ideal nkBTnk_BT. The first correction comes from the rare, brief encounters when two molecules drift close enough to interact. The second virial coefficient B2(T)B_2(T) is precisely the average effect of one such encounter: how much a pair, weighted by its Boltzmann factor, either excludes volume from each other (repulsion, raising the pressure) or draws together (attraction, lowering it). The natural variable is the Mayer function f(r)=e−βu(r)−1f(r)=e^{-\beta u(r)}-1, which is nonzero only where the potential acts. Deep inside a repulsive core the potential is enormous, so e−βu≈0e^{-\beta u}\approx0 and f≈−1f\approx-1 — a full "hole" where the molecules cannot overlap. In an attractive well u<0u<0, so e−βu>1e^{-\beta u}>1 and f>0f>0. Far apart, u→0u\to0 and f→0f\to0. The whole virial machinery is bookkeeping for these localized bumps and dips.

Figure
The Mayer function f(r) = exp(−βu(r)) − 1 for a Lennard-Jones-like pair potential: f = −1 in the repulsive core (r < σ, a hole), positive in the attractive well, and zero far away. B₂ integrates this against 4πr².
separation r → f(r) 0 −1 σ core: f = −1 well: f positive f → 0

The second figure is the punchline: how B2(T)B_2(T) itself behaves as temperature changes. At high temperature, thermal energy overwhelms the shallow attractive well; molecules bounce off the hard core and B2B_2 is positive, approaching the excluded-volume constant bb. At low temperature the attractive tail dominates — molecules linger near each other — and B2B_2 swings negative. In between there is exactly one crossing point, the Boyle temperature TBT_B, where the repulsion and attraction cancel to first order and the gas looks ideal.

Figure
Punchline: B₂(T) versus temperature. Negative at low T (attraction dominates), crossing zero at the Boyle temperature T_B, then positive and rising toward the excluded-volume constant b at high T (repulsion dominates).
temperature T → B₂(T) b 0 → b (excluded volume) T_B (Boyle) attraction: B₂ negative repulsion: B₂ positive

The core equations

The organizing statement is the density expansion of the pressure. It is the definition of the virial coefficients and the reason the theory is called an "equation of state" — it gives PP as a function of nn and TT order by order.

PkBT=n+B2(T) n2+B3(T) n3+⋯ ,Z≡PVNkBT=1+B2(T) n+⋯(1)\frac{P}{k_BT}=n+B_2(T)\,n^2+B_3(T)\,n^3+\cdots,\qquad Z\equiv\frac{PV}{Nk_BT}=1+B_2(T)\,n+\cdots \qquad (1)

where: PP — pressure; n=N/Vn=N/V — number density; TT — temperature; Bk(T)B_k(T) — the kk-th virial coefficient (per-particle convention), a pure function of TT; ZZ — the compressibility factor, equal to 11 for an ideal gas. Reading it: each successive term corrects for larger clusters of interacting molecules; truncating after B2B_2 captures all two-body physics. The content of B2B_2 is a single integral over the pair potential, built from the Mayer function.

B2(T)=−12∫(e−βu(r)−1) d3r=−2π∫0∞(e−βu(r)−1) r2 dr(2)B_2(T)=-\frac12\int\big(e^{-\beta u(r)}-1\big)\,d^3r=-2\pi\int_0^\infty\big(e^{-\beta u(r)}-1\big)\,r^2\,dr \qquad (2)

where: u(r)u(r) — the pair potential at separation rr; β=1/kBT\beta=1/k_BT; d3rd^3r — the relative-coordinate volume element (angular integration gives the 4πr24\pi r^2 and the factor of 2π2\pi). Reading it: the integrand e−βu−1e^{-\beta u}-1 is −1-1 in a hard core (a hole of excluded volume, positive contribution to B2B_2) and positive in an attractive well (negative contribution). The sign of B2B_2 is the competition between these. For a hard sphere of diameter σ\sigma the integral collapses to a pure geometric result.

B2hard sphere=2π3σ3=4v0,v0=43π ⁣(σ2)3=πσ36(3)B_2^{\text{hard sphere}}=\frac{2\pi}{3}\sigma^3=4v_0,\qquad v_0=\frac{4}{3}\pi\!\left(\frac\sigma2\right)^3=\frac{\pi\sigma^3}{6} \qquad (3)

where: σ\sigma — the hard-core diameter; v0v_0 — the volume of one molecule (a sphere of radius σ/2\sigma/2). Reading it: the excluded volume per pair is four times the volume of a single molecule — the classic result, because two spheres of diameter σ\sigma cannot approach closer than σ\sigma center-to-center, carving out a forbidden sphere of radius σ\sigma (volume 8v08v_0) shared between the pair, hence 4v04v_0 each. Adding a shallow attractive tail and expanding for weak attraction gives the van der Waals form and the Boyle temperature.

B2vdW(T)=b−akBT,TB=ab kB  (where B2=0)(4)B_2^{\text{vdW}}(T)=b-\frac{a}{k_BT},\qquad T_B=\frac{a}{b\,k_B}\ \ (\text{where }B_2=0) \qquad (4)

where: b=2π3σ3b=\tfrac{2\pi}{3}\sigma^3 — the excluded-volume constant (temperature-independent, repulsive); aa — the attraction constant (from the well); TBT_B — the Boyle temperature. Reading it: at high TT the a/kBTa/k_BT term is negligible and B2→b>0B_2\to b>0; at low TT it dominates and B2<0B_2<0; they cancel at TBT_B.

Derivation AThe second virial coefficient from the configuration integral

The goal is to derive B2(T)=−12∫(e−βu−1) d3rB_2(T)=-\tfrac12\int(e^{-\beta u}-1)\,d^3r from first principles — to show that the leading correction to the ideal gas pressure is exactly the integrated Mayer function of a single pair. The strategy is to write the canonical configuration integral with the Boltzmann factor of each pair as 1+fij1+f_{ij}, keep only single-bond terms at low density, and read off the n2n^2 coefficient of the pressure. This is the first step of the full Mayer cluster expansion; higher coefficients follow the same diagrammatic bookkeeping.

Step 1. Write the NN-particle configuration integral QN=1N!∫∏id3ri∏i<j(1+fij)Q_N=\dfrac1{N!}\displaystyle\int\prod_i d^3r_i\prod_{i<j}\big(1+f_{ij}\big), where fij=e−βu(rij)−1f_{ij}=e^{-\beta u(r_{ij})}-1 is the Mayer function and the 1/N!1/N! is the correct Boltzmann counting for indistinguishable particles.

Step 2. Expand the product ∏i<j(1+fij)=1+∑i<jfij+⋯\prod_{i<j}(1+f_{ij})=1+\sum_{i<j}f_{ij}+\cdots. At low density the leading correction is the single-bond term; there are (N2)≈N2/2\binom N2\approx N^2/2 identical pair terms by translational invariance.

Step 3. The free-energy (or ln⁡QN\ln Q_N) contribution of the single-bond term is N22V∫f(r) d3r\dfrac{N^2}{2V}\displaystyle\int f(r)\,d^3r, so the pressure picks up PkBT=n+n22∫f(r) d3r⋅(−1)+⋯\dfrac{P}{k_BT}=n+\dfrac{n^2}{2}\displaystyle\int f(r)\,d^3r\cdot(-1)+\cdots once the logarithm and the density conversion are taken. Why the minus sign and the factor of a half. The half comes from double-counting each pair once (i<ji<j); the minus sign appears when the fugacity/density inversion converts the connected pair integral in ln⁡Ξ\ln\Xi into the density coefficient — the sign flip is what makes a repulsive core (where ∫f<0\int f<0) give a positive B2B_2.

Step 4. Match to P/kBT=n+B2 n2+⋯P/k_BT=n+B_2\,n^2+\cdots and perform the angular integration (d3r=4πr2 drd^3r=4\pi r^2\,dr): B2(T)=−12∫f(r) d3r=−2π∫0∞(e−βu−1) r2 drB_2(T)=-\tfrac12\int f(r)\,d^3r=-2\pi\int_0^\infty(e^{-\beta u}-1)\,r^2\,dr, equation (2). Verified: the hard-sphere evaluation B2=2π3σ3B_2=\tfrac{2\pi}{3}\sigma^3 (with f=−1f=-1 inside the core) and its identity with 4v04v_0 are confirmed symbolically in verify_aq-sm-virial-equation-of-state.py.

Go deeper · Derivation B · 1 minHard sphere, square well, and the van der Waals equation
Derivation BHard sphere, square well, and the van der Waals equation

The goal is to evaluate B2B_2 in closed form for the two canonical model potentials — the hard sphere and the square well — and to show that the square-well result, expanded for weak attraction, is exactly the van der Waals B2=b−a/kBTB_2=b-a/k_BT, delivering the Boyle temperature. The strategy is to split the Mayer integral into the repulsive core (where f=−1f=-1) and the attractive well (where f=eβϵ−1f=e^{\beta\epsilon}-1), integrate each region, and expand.

Step 1. Hard sphere: u=∞u=\infty for r<σr<\sigma (so f=−1f=-1) and u=0u=0 for r>σr>\sigma (so f=0f=0). Then B2=−12∫0σ(−1) 4πr2 dr=12⋅4π⋅σ33=2π3σ3B_2=-\tfrac12\int_0^\sigma(-1)\,4\pi r^2\,dr=\tfrac12\cdot4\pi\cdot\tfrac{\sigma^3}3=\tfrac{2\pi}3\sigma^3. This is positive and temperature-independent: pure excluded volume.

Step 2. Identify the excluded volume. One molecule has volume v0=43π(σ/2)3=πσ3/6v_0=\tfrac43\pi(\sigma/2)^3=\pi\sigma^3/6, so B2=2π3σ3=4v0B_2=\tfrac{2\pi}3\sigma^3=4v_0. The factor of four is geometric: two spheres of diameter σ\sigma exclude a sphere of radius σ\sigma (volume 8v08v_0), shared as 4v04v_0 per molecule.

Step 3. Square well: add an attractive shell u=−ϵu=-\epsilon for σ<r<λσ\sigma<r<\lambda\sigma (so f=eβϵ−1f=e^{\beta\epsilon}-1) and 00 beyond. The well contributes −12(eβϵ−1) ⁣∫σλσ4πr2dr=−2π3(eβϵ−1)(λ3−1)σ3-\tfrac12(e^{\beta\epsilon}-1)\!\int_\sigma^{\lambda\sigma}4\pi r^2 dr=-\tfrac{2\pi}3(e^{\beta\epsilon}-1)(\lambda^3-1)\sigma^3, giving B2=2π3σ3[1−(eβϵ−1)(λ3−1)]B_2=\tfrac{2\pi}3\sigma^3\big[1-(e^{\beta\epsilon}-1)(\lambda^3-1)\big].

Step 4. Weak attraction, ϵ≪kBT\epsilon\ll k_BT: expand eβϵ−1≈βϵe^{\beta\epsilon}-1\approx\beta\epsilon, so B2≈b−a/kBTB_2\approx b-a/k_BT with b=2π3σ3b=\tfrac{2\pi}3\sigma^3 and a=2π3ϵ(λ3−1)σ3a=\tfrac{2\pi}3\epsilon(\lambda^3-1)\sigma^3. Setting B2=0B_2=0 gives the Boyle temperature TB=a/bkBT_B=a/bk_B. Why resumming gives van der Waals. Promoting the excluded-volume term 1+bn→1/(1−bn)1+bn\to1/(1-bn) (the correct hard-core resummation) and isolating the attraction turns P/kBT=n+(b−a/kBT)n2P/k_BT=n+(b-a/k_BT)n^2 into (P+an2)(1−bn)=nkBT(P+an^2)(1-bn)=nk_BT, the van der Waals equation of state. Verified: the square-well closed form, the weak-attraction reduction to b−a/kBTb-a/k_BT, and the Boyle temperature TB=a/bkBT_B=a/bk_B are all confirmed symbolically in the verify script.

Limiting cases

The virial series interpolates between known regimes; each row is a limit or a special potential.

CaseResultMeaning
Ideal gas, n→0n\to0Z=1Z=1, B2=0B_2=0No interactions; PV=NkBTPV=Nk_BT recovered.
Hard spheres, diameter σ\sigmaB2=2π3σ3=4v0B_2=\tfrac{2\pi}3\sigma^3=4v_0Positive, TT-independent excluded volume.
Boyle temperatureB2(TB)=0B_2(T_B)=0Repulsion and attraction cancel; gas ideal to first order in nn.
High TT (repulsion wins)B2→b>0B_2\to b>0Gas harder to compress than ideal, Z>1Z>1.
Low TT (attraction wins)B2<0B_2<0Gas easier to compress than ideal, Z<1Z<1.
Ideal quantum gasB2=∓λ3/25/2B_2=\mp\lambda^3/2^{5/2}Statistics alone give B2B_2: bosons −- (attractive), fermions ++ (repulsive).

Worked examples

Example 1 — The second virial coefficient of nitrogen from its van der Waals constants (enumerate, apply, boundary number). Nitrogen has van der Waals constants a=0.137 Pa m6 mol−2a=0.137\,\mathrm{Pa\,m^6\,mol^{-2}} and b=3.87×10−5 m3 mol−1b=3.87\times10^{-5}\,\mathrm{m^3\,mol^{-1}}. Find its molar second virial coefficient at 300 K300\,\mathrm K and the fractional deviation of the pressure from ideal at 1 atm1\,\mathrm{atm}.

Step 1. Enumerate the two contributions. Repulsion (excluded volume): b=3.87×10−5 m3/mol=38.7 cm3/molb=3.87\times10^{-5}\,\mathrm{m^3/mol}=38.7\,\mathrm{cm^3/mol}. Attraction: a/RT=0.137/(8.314×300)=5.49×10−5 m3/mol=54.9 cm3/mola/RT=0.137/(8.314\times300)=5.49\times10^{-5}\,\mathrm{m^3/mol}=54.9\,\mathrm{cm^3/mol}.

Step 2. Apply B2=b−a/RT=38.7−54.9=−16.2 cm3/molB_2=b-a/RT=38.7-54.9=\mathbf{-16.2\,cm^3/mol}. It is negative: at 300 K300\,\mathrm K the attractive tail of nitrogen still outweighs the excluded-volume repulsion, so nitrogen is slightly easier to compress than an ideal gas.

Step 3. Boundary number. At 1 atm1\,\mathrm{atm} and 300 K300\,\mathrm K the molar density is n=P/RT=101325/(8.314×300)=40.6 mol/m3n=P/RT=101325/(8.314\times300)=40.6\,\mathrm{mol/m^3}, so the deviation is Z−1=B2 n=(−16.2×10−6)(40.6)=−6.6×10−4Z-1=B_2\,n=(-16.2\times10^{-6})(40.6)=-6.6\times10^{-4}, about −0.07%-0.07\% — nitrogen at room conditions is ideal to better than one part in a thousand. (The van der Waals estimate −16.2 cm3/mol-16.2\,\mathrm{cm^3/mol} overestimates the attraction; the measured value is about −4.5 cm3/mol-4.5\,\mathrm{cm^3/mol}, but both are negative and tiny at 1 atm1\,\mathrm{atm}.)

Example 2 — Excluded volume and Boyle temperature of a hard-core molecule. Model a small molecule as a hard sphere of diameter σ=0.30 nm\sigma=0.30\,\mathrm{nm}, then estimate its Boyle temperature using nitrogen's attraction.

Step 1. The molecular volume is v0=π6σ3=π6(0.30×10−9)3=1.41×10−29 m3v_0=\tfrac{\pi}6\sigma^3=\tfrac\pi6(0.30\times10^{-9})^3=1.41\times10^{-29}\,\mathrm{m^3}.

Step 2. The excluded-volume (repulsive) second virial coefficient is B2=4v0=2π3σ3=5.66×10−29 m3B_2=4v_0=\tfrac{2\pi}3\sigma^3=5.66\times10^{-29}\,\mathrm{m^3} per molecule, or per mole B2×NA=34.1 cm3/molB_2\times N_A=34.1\,\mathrm{cm^3/mol} — the same order as nitrogen's b=38.7 cm3/molb=38.7\,\mathrm{cm^3/mol}, confirming the model.

Step 3. Boundary number. Using nitrogen's a,ba,b, the Boyle temperature is TB=a/bkB=a/(bR)=0.137/(3.87×10−5×8.314)=426 KT_B=a/bk_B=a/(bR)=0.137/(3.87\times10^{-5}\times8.314)=\mathbf{426\,K}. Above 426 K426\,\mathrm K nitrogen is harder to compress than ideal (B2>0B_2>0); below it, easier (B2<0B_2<0). The measured Boyle temperature of nitrogen is about 327 K327\,\mathrm K — the van der Waals model gets the right scale and sign, overestimating by the same crude-attraction factor seen in Example 1.

Origins · 1 minvirial expansion and how this was discovered
VE
virial expansion
statistical-mechanics concept · van der Waals 1873, Kamerlingh Onnes 1901

The virial equation of state grew from two threads. Johannes Diderik van der Waals, in his 1873 doctoral thesis, wrote the first equation of state including molecular size (the constant bb) and attraction (the constant aa), for which he received the 1910 Nobel Prize. Heike Kamerlingh Onnes, the low-temperature pioneer who first liquefied helium, introduced the systematic power-series form and coined the term "virial coefficients" in 1901, organizing the deviations from ideality order by order in density. The microscopic foundation — expressing each coefficient as a cluster integral over the intermolecular potential — was completed by Joseph Mayer and Maria Goeppert Mayer in the 1930s. The name "virial" traces to Clausius's virial of mechanics, since the pressure correction is literally the configurational virial of the intermolecular forces.

History
1870
— Clausius introduces the virial of the forces, the mechanical root of the name.
1873
— van der Waals's thesis gives the first equation of state with molecular size and attraction.
1901
— Kamerlingh Onnes writes the density power series and coins "virial coefficients."
1908
— Kamerlingh Onnes liquefies helium, opening precision low-temperature equation-of-state measurements.
1937
— Mayer's cluster expansion expresses every virial coefficient as an integral over irreducible clusters.

Going further

References. Pathria & Beale, Statistical Mechanics, 3rd ed., Ch. 10 (cluster expansion and virial coefficients) · Kardar, Statistical Physics of Particles, Ch. 5 (interacting particles, cluster expansion) · Reif, Fundamentals of Statistical and Thermal Physics, Ch. 10 · Landau & Lifshitz, Statistical Physics Part 1, §74–76 · Hansen & McDonald, Theory of Simple Liquids, Ch. 3.

Provenance. The density expansion Z=1+B2n+⋯Z=1+B_2 n+\cdots, the Mayer form B2=−12∫(e−βu−1) d3rB_2=-\tfrac12\int(e^{-\beta u}-1)\,d^3r, and the model evaluations are standard (Pathria Ch. 10, Kardar Ch. 5). A verifier should confirm: (i) hard-sphere B2=2π3σ3B_2=\tfrac{2\pi}3\sigma^3 from f=−1f=-1 inside the core; (ii) the identity B2=4v0B_2=4v_0 with v0=πσ3/6v_0=\pi\sigma^3/6; (iii) the square-well closed form and its weak-attraction reduction to b−a/kBTb-a/k_BT; (iv) the Boyle temperature TB=a/bkBT_B=a/bk_B; (v) the sign limits B2→b>0B_2\to b>0 as T→∞T\to\infty and B2<0B_2<0 as T→0T\to0; (vi) numerics — hard-sphere B2(σ=0.3 nm)=34 cm3/molB_2(\sigma=0.3\,\mathrm{nm})=34\,\mathrm{cm^3/mol}, nitrogen vdW B2(300 K)=−16 cm3/molB_2(300\,\mathrm K)=-16\,\mathrm{cm^3/mol} (measured ≈−4.5\approx-4.5), TB(N2)=426 KT_B(\mathrm N_2)=426\,\mathrm K. All checks are in verify_aq-sm-virial-equation-of-state.py. Constants: kB=1.380649×10−23 J/Kk_B=1.380649\times10^{-23}\,\mathrm{J/K}, R=8.314 J mol−1K−1R=8.314\,\mathrm{J\,mol^{-1}K^{-1}}, NA=6.022×1023 mol−1N_A=6.022\times10^{23}\,\mathrm{mol^{-1}}.

Builds on: Classical Ideal Gas · Virial Theorem in Statistical Mechanics · Correct Boltzmann Counting · Thermal de Broglie Wavelength Leads to: van der Waals Equation · Mayer Cluster Expansion · Classical Limit of Quantum Statistics

Why does the second virial coefficient depend only on the pair potential?

Because at order n2n^2 in the density expansion, only diagrams with exactly two molecules joined by a single Mayer bond f12f_{12} contribute. Three-body correlations first appear at order n3n^3 in B3B_3, which contains the triple product f12f13f23f_{12}f_{13}f_{23}. So to leading order beyond ideal, the only encounters that matter are isolated pairs — one molecule meeting one other — and B2B_2 is a pure pair quantity, computable from the two-body potential u(r)u(r) alone without knowing anything about many-body structure.

Where does the factor of 4 in the hard-sphere excluded volume come from?

Two hard spheres of diameter σ\sigma cannot have their centers closer than σ\sigma. So around any one molecule there is a forbidden sphere of radius σ\sigma (not σ/2\sigma/2) that another center cannot enter — its volume is 43πσ3=8v0\tfrac43\pi\sigma^3=8v_0, where v0=43π(σ/2)3v_0=\tfrac43\pi(\sigma/2)^3 is one molecule's actual volume. Because this excluded region is shared between the two molecules of a pair, each is charged with half of it: B2=12⋅8v0=4v0=2π3σ3B_2=\tfrac12\cdot8v_0=4v_0=\tfrac{2\pi}3\sigma^3. The counterintuitive factor of four is a purely geometric consequence of "closest approach is σ\sigma, not σ/2\sigma/2."

Is the gas truly ideal at the Boyle temperature?

No — only to first order in density. At TBT_B the second virial coefficient vanishes, B2(TB)=0B_2(T_B)=0, so the leading n2n^2 correction to the pressure disappears and the gas obeys PV=NkBTPV=Nk_BT over an extended low-to-moderate pressure range. But the higher coefficients B3,B4,…B_3,B_4,\dots are generally nonzero, so at high enough density deviations reappear at order n3n^3. The Boyle temperature is therefore a very useful single-number characterization of a gas — the temperature where it best mimics ideality — but not a claim that intermolecular forces have somehow switched off.

How is B₂ measured experimentally?

From low-pressure PVTPVT data. You measure the compressibility factor Z=PV/NkBTZ=PV/Nk_BT at several densities and fit Z=1+B2n+B3n2+⋯Z=1+B_2 n+B_3 n^2+\cdots; the initial slope of ZZ versus nn (as n→0n\to0) is exactly B2(T)B_2(T). Repeating at several temperatures maps out B2(T)B_2(T), whose zero crossing gives the Boyle temperature and whose shape is fitted to model potentials (Lennard-Jones, square well) to extract the well depth ϵ\epsilon and range σ\sigma. Because B2B_2 is the initial density slope, it is one of the most direct experimental windows onto intermolecular forces.

Why can a quantum ideal gas have a nonzero B₂ with no forces at all?

Because quantum statistics act like an effective interaction. Even with u(r)=0u(r)=0, the requirement that the many-body wavefunction be symmetric (bosons) or antisymmetric (fermions) under exchange correlates the positions of identical particles: bosons are effectively drawn together (an attractive "statistical potential") and fermions kept apart (repulsive). Carrying this through the partition function gives a second virial coefficient B2=∓λ3/25/2B_2=\mp\lambda^3/2^{5/2}, with the thermal de Broglie wavelength λ\lambda setting the scale — negative for bosons, positive for fermions. It is measured directly in the equation of state of 3^3He and 4^4He and is a clean demonstration that statistics alone produce thermodynamic consequences.

Does the virial series converge, and what happens at condensation?

The virial series is asymptotic, not convergent across a phase transition. As density rises toward the gas-liquid transition, the cluster sum that generates the coefficients develops a singularity, and the successive partial sums stop improving — the radius of convergence shrinks to the condensation density. This is a deep point: a phase transition, being non-analytic, cannot be reached by any finite-order expansion in density. The breakdown of the virial series is itself the signal of condensation, connecting the expansion to the Mayer and Yang-Lee theories of the gas-liquid transition. In practice the series is trustworthy for dilute-to-moderate gases and is truncated at B2B_2 or B3B_3.

How does the virial equation relate to the virial theorem of mechanics?

The name and the physics both come from Clausius's virial. The virial theorem gives the pressure as PV=NkBT+13⟨∑pairsrij⋅Fij⟩PV=Nk_BT+\tfrac13\langle\sum_{\text{pairs}}\mathbf r_{ij}\cdot\mathbf F_{ij}\rangle, where the second term is the configurational virial of the intermolecular forces. Expanding that force average in powers of density reproduces exactly the virial equation of state, with B2B_2 arising as the two-body configurational virial. So the "virial coefficients" Bk(T)B_k(T) are literally the density expansion of the mechanical virial of the forces — the equation of state is the virial theorem, organized order by order in nn.

Before this

Where this leads