Thermodynamics
Ideal Gas Law
PV = nRT — the equation that links pressure, volume, and temperature for low-density gases
The ideal gas law PV = nRT is the equation of state for an idealized gas — describing how pressure (P), volume (V), and temperature (T) relate, given amount of gas (n moles) and the universal gas constant R. Excellent approximation for most gases at low density. Used to design engines, predict atmospheric phenomena, design HVAC, and analyze chemical reactions.
- Ideal gas lawP·V = n·R·T
- Universal gas constant R8.314 J/(mol·K) = 0.08206 L·atm/(mol·K)
- Avogadro's number6.022 × 10²³ molecules/mol
- Boltzmann formP·V = N·k_B·T (N = molecules, k_B = R/N_A)
- Standard conditions (STP)0°C (273.15 K), 1 atm — 1 mole = 22.4 L
- When it failsHigh pressure (small V), low T (near condensation)
Interactive visualization
Press play, or step through manually. The visualization is yours to drive — try it before reading on.
Watch the 60-second explainer
A condensed visual walkthrough — narrated, captioned, under a minute.
The equation
P · V = n · R · T
where:
- P = pressure (Pa or atm).
- V = volume (m³ or L).
- n = number of moles of gas.
- R = universal gas constant.
- T = absolute temperature (K).
R values:
- R = 8.314 J/(mol·K) — for SI units (P in Pa, V in m³).
- R = 0.08206 L·atm/(mol·K) — for chemistry (P in atm, V in L).
Or in molecular form:
P · V = N · k_B · T
where N is the number of molecules and k_B = R/N_A = 1.381 × 10⁻²³ J/K.
Historical sub-laws
| Law | Year | Statement |
|---|---|---|
| Boyle's law | 1662 | P·V = constant (at fixed T, n) |
| Charles' law | 1787 | V/T = constant (at fixed P, n) |
| Gay-Lussac's law | 1809 | P/T = constant (at fixed V, n) |
| Avogadro's law | 1811 | V/n = constant (at fixed P, T) |
| Combined gas law | 1834 (Clapeyron) | P·V/T = constant for fixed n |
| Ideal gas law | 1834 | P·V = n·R·T |
Standard temperature and pressure
Old IUPAC definition (used in most textbooks):
- T = 0°C = 273.15 K.
- P = 1 atm = 101,325 Pa.
- 1 mol of any ideal gas occupies 22.41 L.
New IUPAC (1982):
- T = 273.15 K, P = 100 kPa.
- V = 22.71 L per mole.
NIST:
- T = 20°C = 293.15 K, P = 1 atm.
- V = 24.06 L per mole.
Processes for ideal gases
| Process | Constraint | P-V-T relation |
|---|---|---|
| Isobaric (constant P) | P = const | V/T = const |
| Isochoric (constant V) | V = const | P/T = const |
| Isothermal (constant T) | T = const | P·V = const (Boyle) |
| Adiabatic (no heat) | Q = 0 | P·V^γ = const, T·V^(γ-1) = const |
| γ (adiabatic index) | — | = C_p/C_v; ~1.4 for diatomic gases (air); ~1.67 for monoatomic |
From kinetic theory
Consider a gas of N molecules of mass m in volume V at temperature T. Molecules bounce around with random velocities; their collisions with walls produce pressure.
Statistical analysis gives:
P · V = (1/3) · N · m · <v²> = (2/3) · N · <½ · m · v²>
The average translational kinetic energy is:
<KE> = (3/2) · k_B · T
(Equipartition theorem — ½k_B·T per degree of freedom.)
Substituting:
P · V = (2/3) · N · (3/2 · k_B · T) = N · k_B · T = n · R · T
Recovers the ideal gas law from microscopic mechanics. Beautiful unification.
JavaScript — ideal gas calculations
const R = 8.314; // J/(mol·K)
const k_B = 1.380649e-23;
const N_A = 6.02214e23;
// Solve PV = nRT for any unknown
function pressure(n, V, T) { return n * R * T / V; }
function volume(n, P, T) { return n * R * T / P; }
function temperature(P, V, n) { return P * V / (n * R); }
function moles(P, V, T) { return P * V / (R * T); }
// 1 mole at STP
console.log(`1 mole at STP: V = ${volume(1, 101325, 273.15).toFixed(4)} m³`); // 0.0224
// Inflate a balloon at room temp: 1 atm pressure, 1 L volume
const balloon = moles(101325, 0.001, 293); // 0.0416 mol
console.log(`1 L at 20°C, 1 atm: ${balloon.toFixed(4)} mol = ${(balloon * 6.022e23).toExponential(2)} molecules`);
// Air pressure at altitude (using PV=nRT with T variation, density variation)
// At constant T (rough approx), P ∝ density ∝ n/V
function densityAtAltitude(P_alt, T_alt, M = 0.029) { // M = 0.029 kg/mol for air
// PV = nRT → ρ = nM/V = PM/(RT)
return P_alt * M / (R * T_alt);
}
console.log(`Sea level air density: ${densityAtAltitude(101325, 293).toFixed(3)} kg/m³`); // ~1.20
// Charles' law: balloon expansion when heated
function newVolumeAtNewTemp(V_initial, T_initial, T_final) {
return V_initial * (T_final / T_initial); // at constant P
}
console.log(`1 L balloon, 25°C → 100°C: ${newVolumeAtNewTemp(1, 298, 373).toFixed(2)} L`); // 1.25 L
// Adiabatic process for diatomic gas
function adiabaticTemp(T_initial, V_initial, V_final, gamma = 1.4) {
// T·V^(γ-1) = constant
return T_initial * Math.pow(V_initial / V_final, gamma - 1);
}
console.log(`Adiabatic compression to half volume: T 300K → ${adiabaticTemp(300, 2, 1).toFixed(0)} K`);
// ~396 K (123°C — bike pump heats up!)
// Average molecular speed (rms)
function rmsSpeed(T, M_kg_per_mol) {
// KE_total = (3/2)RT, KE per molecule = (3/2)k_B·T
// ½ m v² = (3/2)k_B·T, so v = √(3k_B·T/m) = √(3RT/M)
return Math.sqrt(3 * R * T / M_kg_per_mol);
}
console.log(`Air at 20°C, rms speed: ${rmsSpeed(293, 0.029).toFixed(0)} m/s`); // ~503
console.log(`H₂ at 20°C, rms speed: ${rmsSpeed(293, 0.002).toFixed(0)} m/s`); // ~1900 (light molecules fast)
Where ideal gas law shows up
- Engineering. Engine cycles (Otto, Diesel, Brayton), HVAC design, gas turbines, compressors, refrigeration.
- Chemistry. Stoichiometry of gas-phase reactions, gas chromatography, vapor pressure calculations.
- Atmospheric science. Pressure variation with altitude, adiabatic lapse rates, weather modeling.
- Aviation. Cabin pressurization, jet engine cycles, atmospheric properties at altitude.
- Astrophysics. Stellar structure (interior pressures), exoplanet atmospheres, interstellar medium.
- Industrial gas. Storage, transport, scuba tanks, medical gas supply.
- Education. Foundational thermodynamics topic; introduces molar quantities, kinetic theory.
Common mistakes
- Using Celsius in PV=nRT. MUST use Kelvin. Celsius gives 0 = 0 nonsense at freezing.
- Mixing units of R. R = 8.314 J/(mol·K) requires P in Pa, V in m³. R = 0.08206 L·atm/(mol·K) for P in atm, V in L. Don't mix.
- Forgetting "ideal" assumptions. At high P, low T, near condensation, real gases deviate. Use van der Waals or other real-gas equation when accuracy matters.
- Treating PV=nRT as exact. It's an approximation. Within its valid range (low to moderate P, T well above boiling), it's very good (< 1% error). Outside, deviations grow.
- Confusing n (moles) with mass. n = mass / molar_mass. Plugging mass directly gives wrong answer. Always convert mass to moles first.
- Forgetting that 22.4 L/mol is at STP only. At room temp (~293 K), it's 24.06 L/mol. Always check conditions.
Frequently asked questions
What's "ideal" about an ideal gas?
Two assumptions — (1) molecules occupy negligible volume compared to container; (2) intermolecular forces are negligible. So molecules just bounce around as point particles. Real gases (especially at high pressure or low temperature) deviate — finite molecular size and attractive forces matter. For most everyday gases at moderate conditions, ideal-gas approximation is very accurate (< 1% error).
How does it combine Boyle's, Charles', and Avogadro's laws?
Boyle (1662) — P·V = constant at fixed T (P inversely with V). Charles (1787) — V/T = constant at fixed P (V proportional to T). Gay-Lussac (1809) — P/T = constant at fixed V. Avogadro (1811) — V proportional to n at fixed P, T. Combined: PV = nRT. R = 8.314 J/(mol·K) is the universal gas constant.
Why is R the same for all gases?
Because ideal gas behavior is universal — molecules of any kind, sufficiently dilute, follow PV = nRT with the same R. The molecular weight doesn't enter (only number of moles). In statistical-mechanical terms, R = N_A × k_B, where k_B (Boltzmann constant) is fundamental. So R is fixed by atomic-scale physics, not gas type.
What's STP and what volume does 1 mole occupy?
STP = Standard Temperature and Pressure. Old definition: 0°C (273.15 K) and 1 atm (101.325 kPa). At STP, 1 mole of any ideal gas occupies V = nRT/P = 1 × 0.08206 × 273.15 / 1 = 22.41 L. New IUPAC STP (1982): 0°C and 100 kPa, where V = 22.71 L. Either way, ~22 L for 1 mole at room T and atmospheric P.
When does the ideal gas law break down?
At high pressure or low temperature. Real gas equations (van der Waals: (P + a/V²)(V - b) = nRT) account for molecular volume (b) and attractions (a). For air at 1 atm and room T, ideal-gas error is < 0.1%. At 100 atm or near boiling point, errors grow to 5-20%.
How does it relate to kinetic theory?
Kinetic theory derives ideal gas law from molecular motion. For gas of N molecules in volume V at temperature T, pressure comes from molecular collisions with walls. Statistical analysis: P = (1/3)·n·m·<v²>, with average kinetic energy ½m<v²> = (3/2)k_B·T. Combine to get P·V = N·k_B·T = n·R·T. Connects macroscopic to microscopic.
How does the ideal gas law explain weather?
Air masses behave approximately as ideal gas. As air rises, it expands (lower P at altitude), cools (PV = nRT, V↑ at constant n requires T↓ at constant P, OR less work in adiabatic expansion). Adiabatic lapse rate ~10°C per km. As air cools, water vapor condenses → clouds, rain. Foundation of meteorology.