Ideal Gas Law (PV = nRT)
Solve PV = nRT for any one of P, V, n, or T given the other three. Computes density, molar volume, mass, and useful intermediates. Engineering unit systems supported. Compressibility factor Z input for non-ideal gases.
Defaults: 1 m³ of air at sea level (101.325 kPa, 25°C, MW = 29) → 40.9 mol. Ideal gas law is good to ~5% for air, water vapor, and most diatomic gases up to 1 atm. Above 10 atm, use Z-factor or equation of state (Soave, PR, etc.).
- SI: 8.314 J/(mol·K)
- US: 10.731 ft³·psia/(lbmol·°R)
- Common eng: 0.08206 L·atm/(mol·K), 8.205×10⁻⁵ m³·atm/(mol·K)
When ideal gas applies
Ideal gas assumptions: molecules are points, no intermolecular forces, perfectly elastic collisions. The law works well at low to moderate P and high T compared to critical conditions. Limits:
- Air at room conditions: error < 0.1%
- Steam at 1 atm, 100°C: error ~3% (use steam tables)
- Methane at 100 bar, 25°C: Z = 0.85, ideal gas overpredicts density 18%
- CO₂ at near-critical (75 bar, 35°C): highly non-ideal, Z varies 0.3 to 0.7
For natural gas at pipeline pressures, use the Soave-Redlich-Kwong (SRK) or Peng-Robinson equation of state. For steam, use IAPWS-IF97 tables. For air at high pressure, NIST REFPROP.
Z-factor — when to bother
If P/P_c > 0.5 (where P_c is critical pressure of the gas), Z deviates significantly from 1.0. Z is read from generalized compressibility charts (Nelson-Obert) using reduced T (T/T_c) and P (P/P_c). Approximation:
Z ≈ 1 − P_r × ω(T_r) where ω is an empirical function. Or use SRK/PR for accuracy.
For natural gas (mostly methane): Z = 0.95 at 60 psig (typical residential gas main), 0.85 at 1000 psig (pipeline), 0.7 at 5000 psig (compressor outlet).
Common gas reference data
| Gas | MW | R (J/kg·K) | T_c (K) | P_c (bar) |
| Air (mixture) | 28.97 | 287 | 132.6 | 37.7 |
| Hydrogen (H₂) | 2.02 | 4124 | 33.2 | 13.0 |
| Methane (CH₄) | 16.04 | 518 | 190.6 | 46.0 |
| CO₂ | 44.01 | 189 | 304.2 | 73.8 |
| Steam (H₂O) | 18.02 | 461 | 647.3 | 220.5 |
| Nitrogen (N₂) | 28.01 | 297 | 126.2 | 33.9 |
| Oxygen (O₂) | 32.00 | 260 | 154.6 | 50.4 |
R_specific = R_universal / MW. So for air, R = 8314 / 28.97 = 287 J/(kg·K).
Watch the absolute units
P and T must be absolute. Pressure: gauge + atmospheric (psia = psig + 14.7, kPa(a) = kPa(g) + 101.325). Temperature: K = °C + 273.15, °R = °F + 459.67. Using gauge or Celsius/Fahrenheit gives wrong results.
Reference: Smith, J.M., Van Ness, H.C., Abbott, M.M. (2018). Introduction to Chemical Engineering Thermodynamics, 9th ed., McGraw-Hill, ch. 3. NIST Chemistry WebBook for accurate gas properties.