Where Does the Ideal Gas Come From?

When you learn PV = nRT in high school, the equation is simply handed to you as “that’s just how it is.” Here we start from each individual molecule flying around in a box and build up, one step at a time, pressure, temperature, internal energy, enthalpy, entropy, and specific heat. All we will need along the way is mechanics and counting.

0. Setup

Suppose a box of volume V contains N molecules, each of mass m. When we call it an “ideal gas,” we have thrown away the following two things.

What we threw away can be put back later Putting back the first adds a term for the excluded volume (the b of van der Waals) to the equation of state, and putting back the second adds a term for the attraction (likewise the a). In the simulator the molecules are drawn large so that they are “visible,” and they collide at that size, so the measured pressure comes out about 1 % higher than nRT/V. That is exactly the effect of putting back the first one.
The dots on the screen are “representative particles” The simulator draws between 30 and 5000 dots, which is not the same as the number of molecules N shown in the readouts (2.4×1022 for 1 L, 1 atm, 300 K). However, the number of dots is made proportional to N, and the size of the box is made proportional to the cube root of the volume, so whichever of T, P, V, n you move, the crowding on the screen follows the true number density N/V. The measured pressure is likewise obtained by multiplying the impulse that the representative particles deliver to the wall by N/(number of dots), and then dividing by the area and the time. This proportionality breaks down only when the number of dots is stuck at its upper or lower limit, and a note to that effect appears next to the slider.

However, if we take “exert no forces on one another” literally, each molecule keeps its initial velocity forever and the gas can never reach an equilibrium state. The correct statement is that the molecules do collide very occasionally and exchange energy, but those collisions are so rare that they do not affect the equation of state.

1. The Conclusion First (the 30-Second Version)

What we will build from here ① Counting the impulse on the wall gives PV = NkBT.
② Temperature is a quantity proportional to the average translational kinetic energy per molecule.
③ Once the partition function z is written down, U, S, and P all come out mechanically.
④ Entropy has an absolute value (Sackur–Tetrode). For N₂, O₂, and CO₂ it agrees with the measured value to within 0.02 J/(mol·K) (§10).
⑤ CP − CV = R means that at constant pressure extra heat is needed, by exactly the work the gas does in pushing back its surroundings.

2. Pressure Is the “Impulse Delivered to the Wall” — Kinetic Theory

Consider a cube of side L and focus on the right-hand wall, which is perpendicular to the x axis. When a molecule whose x component of velocity is vx bounces off this wall, the x component of its momentum changes from mvx to −mvx. By the law of action and reaction, the impulse that the wall receives is

Δp=2mvx

Before this molecule can hit the same wall again, it has to make a round trip across the box, so it takes Δt=2L/vx to come back. Hence the average force that this one molecule exerts on the wall is

F‾= ΔpΔt = 2mvx 2L/vx = mvx2L

Adding up the contributions of N molecules and dividing by the wall area L² gives the pressure. Using ⟨…⟩ for the average, we can write

P= Nm⟨vx2⟩ L3 = Nm⟨vx2⟩V

A gas has no preferred direction (it is isotropic), so ⟨vx2⟩= ⟨vy2⟩= ⟨vz2⟩ and adding the three gives ⟨v2⟩ as the total. In other words, ⟨vx2⟩= ⟨v2⟩/3. Substituting this, we get

PV= 13Nm ⟨v2⟩ = 23N ⟨εtrans⟩ (2.1)

Here ⟨εtrans⟩= 12m⟨v2⟩ is the translational kinetic energy per molecule.

The assumptions used so far Only mechanics (conservation of momentum) and isotropy. We have not yet used quantum mechanics or statistical mechanics. Even so, we already have the skeleton of the equation of state: PV is proportional to “energy per molecule × number of molecules.”

3. What Temperature Really Is, and the Maxwell Distribution

If we compare the experimentally known PV = NkBT with Eq. (2.1), we can read off what temperature is.

⟨εtrans⟩ = 12m⟨v2⟩ = 32kBT (3.1)

What a thermometer measures is a quantity proportional to the average translational kinetic energy per molecule. The 3 comes from the three directions x, y, z, and each degree of freedom receives (1/2)kBT. This is the equipartition theorem.

Eq. (3.1) speaks only of the average. How the speeds of individual molecules are scattered follows from the canonical distribution (a state of energy ε appears in proportion to e−ε/kBT). In velocity space, multiply e−mv2/2kBT by the area 4πv² of a spherical shell of radius v, and we get

f(v)= 4π (m2πkBT) 3/2 v2 e− mv2/2kBT (3.2)

Three representative speeds follow from this distribution. They are listed in increasing order.

NameDefinitionValueN₂ at 300 K
Most probable speed vpThe v at which f(v) is maximum 2kBT/m 422 m/s
Mean speed v̄∫v f(v)dv 8kBT/πm 476 m/s
Root-mean-square speed vrms√⟨v²⟩ (this is the one that matters for pressure) 3kBT/m 517 m/s
The distribution is not something “given from outside” If you press “Make all speeds equal” in ① of the simulator, at first all molecules have the same speed (a single bar). Yet through nothing but repeated elastic collisions between molecules, within the time it takes to cross the box a few times, the distribution settles into the shape of Eq. (3.2). Not even 1 J of energy has flowed in or out, and still fast and slow molecules are born. The equilibrium distribution is something the collisions create on their own, and that is the starting point of statistical mechanics.

4. The Partition Function — A Machine for Producing State Functions

From here on, just by writing down a single function, U, S, and P all come out mechanically. For the states i (energy εi) that one molecule can take, define

z=∑i e− εi/kBT (4.1)

as the molecular partition function. Since the molecules exert no forces on one another, the partition function of the whole system is a product of single-molecule ones. However, the molecules are indistinguishable, so we divide by N! to remove the overcounting of identical arrangements.

Z=zNN! (4.2)
A note on notation Lowercase z is the partition function for a single molecule, and uppercase Z is that for the whole system. The same convention is used in the derivation of entropy. The derivation of specific heat, on the other hand, has no need to separate the single-molecule and total cases, so it uses Z alone throughout.
What happens if we drop this N! The entropy ceases to be extensive. Just by placing two samples of the same gas side by side and removing the partition, the entropy would increase (the Gibbs paradox). The N! is not a mere correction factor. It is what the quantum-mechanical fact that identical particles are in principle indistinguishable looks like when it shows up in a classical formula.

The Helmholtz free energy is A = −kBT ln Z. Using Stirling’s approximation ln N! ≈ N ln N − N, we get

A= −NkBT [ln⁡ zN+1] (4.3)

The rest is just a matter of applying thermodynamic relations.

U= kBT2 (∂ln⁡Z∂T)V =NkBT2 ∂ln⁡z∂T S= − (∂A∂T)V =NkB [ln⁡zN+1] +UT P= − (∂A∂V)T (4.4)

5. Deriving PV = NkBT Again from Statistical Mechanics

We construct the partition function for translational motion. The energy levels of a particle confined in a box of side L are, from quantum mechanics (a square-well potential), given by εn= n2h2 /8mL2. The level spacing is extremely fine at room temperature, so the sum can be replaced by an integral. Multiplying the contributions of the three directions gives

ztrans= VΛ3 , Λ= h2πmkBT (5.1)

Λ is the thermal de Broglie wavelength, “the quantum-mechanical spread of a molecule moving about at that temperature.” For N₂ at 300 K it is about 19 pm. ztrans = V/Λ³ can be read as a count of how many “places” for a molecule there are in the box.

The only place where V enters is ztrans (neither rotation nor vibration has anything to do with the size of the box). So if we obtain the pressure from Eqs. (4.3) and (4.4), we get

P= − ∂A∂V = NkBT ∂ln⁡V∂V = NkBTV (5.2)
We arrived at the same equation by two routes In §2 we counted the impulse on the wall, and in §5 we differentiated the partition function; both led to PV = NkBT = nRT. Moreover, all that appeared in the course of Eq. (5.2) was the logarithmic derivative with respect to V, so neither the mass of the molecule nor whether it rotates had any effect at all. This is why the equation of state is the same for every ideal gas.

6. Internal Energy and Specific Heat — Where Equipartition Breaks Down

Molecules do not only move: they also rotate, and the atoms in them stretch and compress like springs. Since these motions are independent of one another, the partition function splits into a product.

z= ztrans zrot zvib zel (6.1)

Since ln z splits into a sum, both U in Eq. (4.4) and the specific heat become sums of the separate contributions. For the rotation of a linear molecule and the vibration of a single spring, we have

zrot= 1σ ∑J=0∞ (2J+1) e− J(J+1) θr/T (θr= ħ22IkB) zvib= 11− e− θv/T (θv= hνkB) (6.2)

θr and θv are called characteristic temperatures and represent “the temperature needed to awaken that motion.” σ is the symmetry number, the number of ways of rotating the molecule so that it coincides with itself (2 for a homonuclear diatomic molecule such as N₂ or O₂).

If the temperature is much higher than the characteristic temperature, the sum can be replaced by an integral, which gives zrot≈T /σθr and hence Urot = NkBT (for 2 degrees of freedom). Conversely, if the temperature is much lower than the characteristic temperature, only the first term of the sum survives, z becomes a constant, and it no longer contributes to U. This is called freezing out.

CV,vib =R (θvT)2 eθv/T (eθv/T−1)2 Einstein’s formula for the specific heat. It tends to R for T ≫ θv and to 0 for T ≪ θv
Here lay the limit of classical physics If we think with classical mechanics alone, equipartition should apply to both rotation and vibration, and CV of a diatomic molecule should be (7/2)R, independent of temperature. Yet the measured value at room temperature is (5/2)R. This discrepancy, which troubled 19th-century physicists, was resolved only when it was accepted that energy is discrete. If kBT is smaller than the level spacing, that motion cannot be excited and stays asleep.

Fig. 1. Temperature dependence of the molar heat capacity at constant volume, CV/R. From the bottom, the contributions of translation (always 3/2), rotation, and vibration are stacked up. The vertical dotted lines mark the characteristic temperatures θr and θv; check that the staircase rises by one step at each of them.

Gasθr [K]θv [K] CV/R at 298 KγMotions awake at room temperature
He, Ne, Ar——1.5001.667Translation only (3 degrees of freedom)
H₂85.459872.5021.400Translation + rotation
N₂2.8633522.5021.400Translation + rotation
O₂2.0722392.5311.395Translation + rotation (a little vibration)
CO₂0.56960 (×2), 1918, 33803.4671.288Translation + rotation + bending vibration

The columns of CV/R and γ are not measured values but calculated values, obtained by putting this page’s spectroscopic constants into Eqs. (6.1)–(6.2) and then using Eq. (4.4). For H₂ alone there is a slight discrepancy from the measured value, as described in §10; working back from the measured CP = 28.84 J/(mol·K) gives CV/R ≈ 2.469 and γ ≈ 1.405.

CO₂ ends up with an in-between value, neither (5/2)R nor (7/2)R, because the characteristic temperature of its bending vibration is as low as 960 K, so that it is already about half awake at room temperature. It is a good example of a case where the classical way of counting specific heat by “the number of degrees of freedom” does not work.

7. Entropy — The Sackur–Tetrode Equation

Put ztrans = V/Λ³ and U = (3/2)NkBT into Eq. (4.4). For a monatomic gas there is no rotation or vibration, so that is all there is to it.

S=NkB [ ln⁡ (VNΛ3) +52 ] (7.1)

This is the Sackur–Tetrode equation. What is inside is V/(NΛ³) — that is, the logarithm of how many times larger the volume available to one molecule is than that molecule’s quantum-mechanical spread. The more sparsely the molecules are placed in a large room, the more states there are and the larger the entropy.

This equation has not a single adjustable parameter It is determined only by the mass of the molecule and by V, N, and T. And yet for argon at 298.15 K and 1 bar it gives 154.85 J/(mol·K), which agrees with the 154.85 J/(mol·K) in the NIST-JANAF thermochemical tables. However, for monatomic gases the tabulated value itself is built from Eq. (7.1), so a match to the second decimal place is too good to count for much. It does agree with the calorimetric value, obtained by integrating the specific heat up from low temperature, within its experimental error (about 0.1 J/(mol·K)). The table in §10 compares seven kinds of gases.

When there is rotation or vibration, the remaining factors of Eq. (6.1) are simply added.

S=NkB [ln⁡ ztransN +1 +ln⁡ (zrot zvib zel) ] +UT (7.2)

The N! acts only on the N in ztrans/N. Rotation and vibration concern the inside of a molecule, so they receive no correction for “indistinguishability.”

From Eq. (7.1) the changes familiar from textbooks follow immediately as well. Holding T fixed and doubling only V gives

ΔS=nRln⁡2 =5.763n J/K

When only the temperature is changed, the temperature dependence of the quantity inside the logarithm, Λ³ ∝ T−3/2 (and, at constant pressure, additionally V ∝ T), gives first, for a monatomic gas, ΔS = n(3/2)R ln(T₂/T₁) (constant volume) and ΔS = n(5/2)R ln(T₂/T₁) (constant pressure). When there is rotation or vibration, the contribution from the internal-degree-of-freedom terms of Eq. (7.2) is added as well, and by using CV,m and CP,m that include that contribution we get the same form, ΔS = nCV,m ln(T₂/T₁) (constant volume) and ΔS = nCP,m ln(T₂/T₁) (constant pressure). The simulator’s ② calculates ΔS directly from Eq. (7.2), but in the range where CV,m does not depend on temperature, as for a monatomic gas, it agrees with these ln formulas to six decimal places. In the temperature range where rotation and vibration are awakening, however, CV,m itself varies with temperature, so the correct expressions are ΔS = n∫CV,mdT/T (constant volume) and ΔS = n∫CP,mdT/T (constant pressure). If a gas whose vibration is just beginning to awaken at room temperature, such as CO₂, is heated by a large amount, it deviates from the ln formulas, but the value obtained directly from Eq. (7.2) is always the correct one.

8. Enthalpy and CP − CV = R

When we heat a gas, the heat required differs depending on whether we hold the volume fixed or hold the pressure fixed. Let us write the first law with W for the work done by the gas.

ΔU=Q−W , W=∫PdV (8.1)

At constant volume, dV = 0, so W = 0. The heat added becomes internal energy as it is.

QV=ΔU , CV= (∂U∂T)V

At constant pressure, heating makes the piston move out, and the gas does work W = PΔV. That much extra heat has to be supplied. The quantity that builds this “extra amount” into the equations from the start is the enthalpy.

H≡U+PV ⟹ QP=ΔH , CP= (∂H∂T)P (8.2)

Enthalpy is not so much “a kind of energy” as a quantity constructed as a ledger from which the heat flowing in or out at constant pressure can be read directly. We express the heat of a chemical reaction by ΔH because experiments are usually carried out under atmospheric pressure.

For an ideal gas PV = nRT, so H = U + nRT. Differentiating both sides with respect to T gives

CP−CV=nR that is, CP,m− CV,m=R (8.3)
Where does R come from? The extra work when the gas is warmed by ΔT is PΔV = nRΔT. In other words, the R on the right-hand side of Eq. (8.3) is itself the work of pushing back the surroundings when 1 mol is warmed by 1 K. That it does not depend on the kind of molecule, nor on whether it rotates, is because, as we saw in §5, the equation of state knows nothing of the inside of the molecule. If you look at the four rows of “Comparing the heat needed for the same ΔT” in ② of the simulator, you will see QP − QV and nRΔT come out equal to the last digit.

9. When the Classical Approximation Holds

The argument so far has stepped into the classical approximation at the point in Eq. (5.1) where we “replaced the sum by an integral.” That is allowed when the quantum-mechanical spread Λ of a molecule is much smaller than the spacing between molecules.

Λ≪ (VN) 1/3 that is, NΛ3V≪1 (9.1)
Gas and state (1 atm)Λ [pm]Mean spacing [pm] Λ/spacingVerdict
N₂ 300 K (air at room temperature)19.034500.0055Classical approximation is sufficient
Ar 300 K15.934500.0046Classical approximation is sufficient
N₂ 77.4 K (boiling point)37.521900.017Still fine
H₂ 20.3 K (boiling point)27314000.19Doubtful
He 4.22 K (boiling point)4258320.51Classical approximation breaks down

At its boiling point, helium has a Λ that is as much as half the spacing between molecules. Here the molecules have to be counted afresh as “indistinguishable particles,” and indeed liquid helium shows superfluidity, a behavior that classical physics cannot explain.

Sackur–Tetrode cannot be used down to absolute zero If we let T → 0 in Eq. (7.1), then Λ → ∞, so S diverges to −∞. A negative entropy is clearly wrong (it violates the third law). This is not a mistake in the equation: it is the penalty for taking the equation into a region where Eq. (9.1) is not satisfied. In reality, before that happens the gas turns into a liquid or a solid. The simulator is set up to show a warning when you enter this region.

10. Checking Against Numbers

Let us check whether the equations so far are really correct by comparing them with measured values. The “Calculated” columns below were obtained with exactly the same code that this page and the simulator use, from nothing but the mass of the molecule and the spectroscopic constants (the rotational constant B₀ and the normal-mode frequencies). The “Measured” values are those of the NIST-JANAF thermochemical tables. However, as noted in §7, the three monatomic rows are a circular comparison, and the rows of molecular species are the ones that amount to a real test.

GasS°(298.15 K, 1 bar) [J/(mol·K)] CP°(298.15 K) [J/(mol·K)]
CalculatedMeasuredDifference CalculatedMeasuredDifference
He126.15126.150.00 20.7920.790.00
Ne146.33146.330.00 20.7920.790.00
Ar154.85154.850.00 20.7920.790.00
N₂191.60191.61−0.01 29.1129.12−0.01
O₂205.13205.15−0.02 29.3629.38−0.02
CO₂213.78213.780.00 37.1437.13+0.01
H₂130.54130.68−0.14 29.1228.84+0.28
Only H₂ is slightly off The θr of hydrogen is as large as 85 K, so we cannot say that 298 K satisfies “T ≫ θr.” Moreover, in hydrogen, depending on the orientation of the nuclear spins, the rotational quantum number J splits into even values (para-hydrogen) and odd values (ortho-hydrogen), so the molecules cannot be treated all together with the symmetry number σ = 2. The main origin of the 0.14 J/(mol·K) discrepancy is this treatment, in which the nuclear-spin statistics is lumped together with σ = 2; it is not an error of the numerical calculation (a little of the rest comes from non-rigid rotation and the anharmonicity of vibration). That the other three molecular species, for which the comparison is not circular (N₂, O₂, and CO₂), agree to within 0.02 is the flip side of this, and serves as evidence for it.

Let us also check the equation of state itself. The standard molar volume is

StateCalculated Vm = RT/PLiterature value
273.15 K, 101325 Pa (old STP)22.4140 L/mol22.4140 L/mol
273.15 K, 100000 Pa (current STP)22.7110 L/mol22.7110 L/mol

And in ① of the simulator, without using nRT/V at all, the pressure is obtained by counting only the impulse on the wall. If the molecules are treated as points (collisions switched off), the two approach the same value as the time average proceeds (since only a finite number of collisions is averaged, the displayed value keeps fluctuating by a few percent), and if the molecules are given a size, the center of that fluctuation shifts to about 1 % higher. The latter shift is well explained by the correction coming from the second virial coefficient of hard spheres. The compressibility factor is Z≈1+4η (η is the packing fraction), so even a packing fraction of just 0.25 % or so produces a 1 % excess. Here Z is the compressibility factor PV/NkBT, a different quantity from the partition function Z of Section 4 (both are conventional symbols, so they overlap only here).

11. Summary

QuantityForm in statistical mechanicsMeaning
T2⟨εtrans⟩/(3kB)A quantity proportional to the average translational kinetic energy per molecule
P−(∂A/∂V)TImpulse the wall receives per unit time and unit area
UkBT²(∂lnZ/∂T)V(1/2)kBT for each degree of freedom that is awake
SNkB[ln(z/N) + 1] + U/TLogarithm of the number of ways the state can be realized
HU + PVA ledger for reading directly the heat that flows in or out at constant pressure
CV(∂U/∂T)VA tool for measuring the number of degrees of freedom that are awake
CPCV + nRThat plus the work nR of pushing back the surroundings per 1 K
In three lines ① Pressure is the average of the impulse delivered by molecules striking the wall.
② Temperature is a quantity proportional to the average translational kinetic energy per molecule.
③ Write down one partition function, and all the other state functions follow by differentiation.

The physical constants used are the defined values of the 2019 SI (kB = 1.380649×10−23 J/K, h = 6.62607015×10−34 J·s, NA = 6.02214076×1023 mol−1), and the spectroscopic constants are the ground-vibrational-state values (B₀ and the fundamental frequency ν₀). The measured values used for comparison are from the NIST-JANAF thermochemical tables.