Safeguard
Supply Chain Security•

The Ideal Gas Law Explained: PV = nRT With Worked Examples

PV = nRT ties a gas's pressure, volume, amount and absolute temperature together. Where it came from, when it fails, and worked examples with numbers.

Safeguard Security Team
52 min read

The ideal gas law, PV = nRT, says that for a gas at low enough pressure, pressure times volume equals the amount of gas in moles times the molar gas constant times the absolute temperature. Since 2019 the constant R is exact: 8.314 462 618... joules per mole per kelvin, the product of two fixed SI constants. Use kelvin and absolute pressure, and the law predicts tyre pressure, balloon size and air density to within a percent or so for everyday air.

This post goes one level below our tour of famous equations that changed the world and sits next to the laws of thermodynamics explained, which covers the energy bookkeeping that the gas law leaves out. If you liked the worked numbers in Ohm's law and Kirchhoff's laws with circuit examples or the force calculations in Newton's three laws of motion, this is the same treatment for gases.

A note on numbers. Constants come from NIST's CODATA pages (2022 recommended values) and the SI definitions from NIST Special Publication 330 (2019), the US edition of the SI brochure. Real gas data for nitrogen and carbon dioxide come from the NIST Chemistry WebBook's fluid property tables. Atmospheric temperature and pressure come from NASA Glenn Research Center's Earth atmosphere model. Data centre temperature ranges come from the US Department of Energy's data centre design guide, which reproduces the ASHRAE envelopes. Figures we chose ourselves, such as a tyre's placard pressure or a rack's heat load, are labelled as illustrative. Every calculation was rerun with the short Python script in the walkthrough, so you can check each one.

Key takeaways

  • PV = nRT relates pressure P (pascals), volume V (cubic metres), amount n (moles) and absolute temperature T (kelvin). R is the molar gas constant, 8.314 462 618... J mol⁻¹ K⁻¹.
  • R is exact since 20 May 2019. The revised SI fixed the Boltzmann constant k at 1.380 649 × 10⁻²³ J/K and the Avogadro constant at 6.022 140 76 × 10²³ mol⁻¹. R is their product, so it has no uncertainty either.
  • The law is a merger of four older laws: Boyle's pressure and volume law (published 1662), Amontons's pressure and temperature work (around 1700), the volume and temperature law that Charles found around 1787 and Gay-Lussac published in 1802, and Avogadro's 1811 hypothesis about equal volumes.
  • Kinetic theory explains it: pressure is momentum delivered by molecules hitting a wall, and temperature measures their average kinetic energy, 3/2 kT per molecule.
  • It fails when molecules are crowded (high pressure) or slow and sticky (low temperature, near condensation). The compressibility factor Z = PV/(nRT) measures the error. Nitrogen at 300 K and 301 bar has Z of about 1.14; carbon dioxide at 300 K and 61 bar has Z of about 0.57.
  • Van der Waals' 1873 equation adds a correction for molecular size (b) and attraction (a). It fixes most of the carbon dioxide error in our example but does little for nitrogen at scuba tank pressures.
  • Most real mistakes are unit mistakes: Celsius instead of kelvin, gauge instead of absolute pressure, litres mixed with pascals.
  • Air density falls 20 percent between a sea level data centre at 18 °C and one at 1,600 m at 27 °C, so the same rack needs about 25 percent more airflow by volume.

What does PV = nRT say, and what does each symbol mean?

The equation is a single statement about the state of a gas: fix any three of pressure, volume, amount and temperature, and the fourth is determined. NASA Glenn Research Center's Beginner's Guide puts it as an "equation of state", a relationship that defines the state of the gas from a small set of measurable properties.

SymbolQuantitySI unitCommon alternativesNotes
PPressurepascal (Pa) = N/m²kPa, bar (100 kPa), atm (101.325 kPa), psiMust be absolute pressure, not gauge
VVolumecubic metre (m³)litre (L) = 0.001 m³The volume the gas fills, not the volume of the molecules
nAmount of substancemole (mol)kmolOne mole is exactly 6.022 140 76 × 10²³ entities
RMolar gas constantJ mol⁻¹ K⁻¹0.082 057 L atm mol⁻¹ K⁻¹; 8.314 kPa L mol⁻¹ K⁻¹Exact since 2019
TThermodynamic temperaturekelvin (K)none for this equationK = °C + 273.15. Never use °C or °F directly
NNumber of moleculesdimensionlessUsed in the molecular form PV = NkT
kBoltzmann constantJ/KExactly 1.380 649 × 10⁻²³ J/K

Check the units once and you will trust the equation forever. A pascal is a newton per square metre and a joule is a newton metre, so pressure times volume is (N/m²)(m³) = N m = J. The right hand side is mol × J mol⁻¹ K⁻¹ × K = J. Both sides are energies. PV is, loosely, the energy a gas holds by virtue of pushing on its container, which is why it turns up in so much of thermodynamics.

The three other forms you will meet

Per molecule: PV = NkT. Divide n into molecules, N = n × N_A, and R splits into N_A × k. Physicists prefer this form because it talks about particles directly. It also gives the number density of a gas: N/V = P/(kT).

Per unit mass: P = ρRₛT. Engineers working with one gas, usually air, divide R by the molar mass M to get a specific gas constant Rₛ = R/M, and write the law with density ρ. NASA's equation of state page gives this form and quotes a value for air of about 0.286 kJ/kg/K; dividing R by the conventional molar mass of dry air, 28.964 g/mol, gives 0.287 kJ/kg/K. The difference is rounding in the molar mass, and it matters at the third significant figure only.

Combined gas law: P₁V₁/T₁ = P₂V₂/T₂. When the amount of gas does not change, nR cancels and you can compare two states without knowing n or R at all. Most everyday problems (tyres, balloons, syringes) use this form.

Standard conditions and the molar volume

The CODATA tables publish the molar volume of an ideal gas at 273.15 K and 101.325 kPa as 22.413 969 54... × 10⁻³ m³/mol, listed as exact because it follows from exact constants. That is the "22.4 litres per mole" every chemistry student memorises. OpenStax Chemistry 2e notes that IUPAC changed its standard pressure from 1 atm to 1 bar (100 kPa) in 1982, while many references still use 1 atm. At 298.15 K and 100 kPa the molar volume is 24.79 L. Always check which "standard" a table uses before you compare numbers.

How was the ideal gas law assembled from Boyle, Charles, Gay-Lussac and Avogadro?

Nobody discovered PV = nRT in one go. It was stitched together over about 170 years from separate observations, each holding two of the four variables fixed. Every date below was checked against the source in the right hand column.

DateEventSource
1660Robert Boyle publishes New Experiments Physico-Mechanicall, Touching the Spring of the Air, built on air pump experimentsScience History Institute
1662The second edition sets out the inverse relation between gas volume and pressure, later called Boyle's lawScience History Institute; Le Moyne College Classic Chemistry
about 1700Guillaume Amontons establishes empirically that gas pressure rises with temperature at fixed volumeOpenStax Chemistry 2e, section 9.2
about 1787Jacques Charles notices that several gases expand equally when heated, but does not publishGay-Lussac (1802), as reprinted by Le Moyne College
1802Joseph Louis Gay-Lussac publishes "The Expansion of Gases by Heat" in Annales de Chimie 43, crediting Charles's unpublished workLe Moyne College Classic Chemistry
1811Amedeo Avogadro proposes that equal volumes of gases at the same temperature and pressure contain equal numbers of molecules (Journal de Physique 73, 58 to 76)Le Moyne College Classic Chemistry; OpenStax 9.2
1873Johannes Diderik van der Waals publishes his treatise on the continuity of the gas and liquid states, with the equation of state that bears his nameVan der Waals, Nobel Lecture (1910)
1873James Clerk Maxwell's lecture "Molecules" appears in Nature 8, 437 to 441, a popular account of the kinetic theoryLe Moyne College Classic Chemistry
1910Van der Waals receives the Nobel Prize in Physics "for his work on the equation of state for gases and liquids"NobelPrize.org
1954The kelvin is defined as 1/273.16 of the thermodynamic temperature of the triple point of waterNIST, SI redefinition: kelvin
Nov 2018The 26th CGPM approves the revised SI, fixing k and N_ANIST SP 330 (2019); NIST kelvin page
20 May 2019The revised SI enters into force; R becomes exactNIST SP 330 (2019)

Boyle's law: PV is constant at fixed temperature

Boyle used an air pump and a J shaped tube of mercury to squeeze trapped air and measure how its volume shrank as the pressure on it rose. The Science History Institute's biography says the first edition of his book appeared in 1660 and the second edition, in 1662, "delineated the quantitative relationship". NASA's Glenn pages give 1660 as the year Boyle first observed it, so you will see both dates; the published quantitative statement is 1662. The law: at constant temperature and amount, P₁V₁ = P₂V₂. Halve the volume, double the pressure.

OpenStax gives two everyday cases. Breathing is a Boyle's law cycle: your diaphragm enlarges the chest cavity, lung pressure drops below the outside air, and air flows in. A scuba diver's buoyancy compensator expands on the way up because the surrounding water pressure falls.

Amontons, Charles and Gay-Lussac: temperature enters

Gay-Lussac's 1802 memoir, read in translation on Le Moyne College's Classic Chemistry site, measured how much oxygen, nitrogen, hydrogen, carbon dioxide and air expanded between melting ice and boiling water. He found they all expanded by the same fraction, which he gave as 100/266.66 of the starting volume for the centigrade scale. He also wrote that "citizen Charles" had noticed the same property 15 years earlier but never published it. That is why the volume and temperature law carries Charles's name in English textbooks and Gay-Lussac's in French ones, and why NASA's page calls it "Charles and Gay-Lussac's Law".

Gay-Lussac's fraction is worth a second look. 100/266.66 is 0.375, so a gas heated from 0 °C to 100 °C grows by 37.5 percent by his measurement. The modern ideal gas value is 100/273.15, or 36.6 percent. Run the line backwards and the volume reaches zero at about minus 267 °C by his numbers and minus 273.15 °C by modern ones. That extrapolated zero is absolute zero, and it is the reason the gas law only works in kelvin. OpenStax shows the same extrapolation with methane, whose line stops at 111 K because the gas liquefies, but points straight at the origin.

At constant volume the same logic gives Amontons's law, P/T constant. OpenStax credits Guillaume Amontons with establishing the pressure and temperature relationship around 1700 and Gay-Lussac with measuring it more precisely around 1800. Many textbooks call this one "Gay-Lussac's law", which adds to the naming muddle.

Avogadro: amount enters

In 1811 Amedeo Avogadro proposed, in an essay in the Journal de Physique, that equal volumes of all gases at the same temperature and pressure contain the same number of molecules. It explained Gay-Lussac's other discovery, that gases combine in simple whole number ratios by volume. NIST's account of the mole notes that Avogadro was not very good at convincing other people, and the idea was not widely accepted until decades after his death in 1856. In gas law terms it says V/n is constant at fixed P and T.

Putting the pieces together

OpenStax lists the four laws side by side: PV constant at fixed T and n; P/T constant at fixed V and n; V/T constant at fixed P and n; V/n constant at fixed P and T. The only function that satisfies all four at once is PV proportional to nT, and the constant of proportionality is R. Textbooks usually credit Émile Clapeyron with first writing the combined equation in the 1830s; we could not retrieve his memoir to confirm the date, so it is left out of the table.

Where does the gas constant R come from, and how did the 2019 SI redefinition make it exact?

For most of its history R was a measured number. You filled a vessel of known volume with a known mass of gas at a known temperature, measured the pressure, extrapolated to zero pressure where every gas behaves ideally, and divided. Its uncertainty fed into the Boltzmann constant through k = R/N_A, and into the kelvin itself through the way temperature was realised.

The old kelvin and the new one

NIST's history of the kelvin explains that from 1954 the kelvin was defined as 1/273.16 of the thermodynamic temperature of the triple point of water, the unique condition where ice, liquid water and vapour coexist. That tied every temperature measurement in the world to a property of one substance, and to the isotopic makeup and purity of the water in the triple point cell.

The revised SI, approved in November 2018 and in force from 20 May 2019, changed the anchor. NIST SP 330 now defines the kelvin by fixing the numerical value of the Boltzmann constant k at exactly 1.380 649 × 10⁻²³ when expressed in J/K. The size of the kelvin did not change noticeably. What changed is that temperature is now defined through energy per degree of freedom, which is exactly what kinetic theory says it is.

The new mole

SP 330 also redefined the mole: one mole contains exactly 6.022 140 76 × 10²³ specified elementary entities. Before 2019 the mole was the amount of substance in 12 grams of carbon 12, which tied it to the kilogram and left the Avogadro constant as a measured value. NIST's account describes how silicon sphere measurements, counting atoms in an almost perfect crystal, pinned the value down well enough to fix it.

Why R became exact

R = N_A × k. With both factors fixed exactly, their product is fixed too:

R = 6.022 140 76e23 mol⁻¹ × 1.380 649e-23 J/K
  = 8.314 462 618 153 24... J mol⁻¹ K⁻¹   (exact; the digits never end)

NIST's CODATA page for the molar gas constant lists 8.314 462 618... J mol⁻¹ K⁻¹ with "(exact)" in the uncertainty field. The trailing dots mean the decimal does not terminate, not that the value is uncertain. For day to day work 8.314 J mol⁻¹ K⁻¹ is good to four significant figures, and 0.082 06 L atm mol⁻¹ K⁻¹ when you work in litres and atmospheres.

ConstantSymbolValueStatus since 2019Source
Boltzmann constantk1.380 649 × 10⁻²³ J/KExact (defining)NIST CODATA; SP 330
Avogadro constantN_A6.022 140 76 × 10²³ mol⁻¹Exact (defining)NIST CODATA; SP 330
Molar gas constantR8.314 462 618... J mol⁻¹ K⁻¹Exact (derived)NIST CODATA
Molar volume, ideal gas, 273.15 K and 101.325 kPaV_m22.413 969 54... × 10⁻³ m³/molExact (derived)NIST CODATA

So where does the measurement go now? It moved into realising temperature. Laboratories that once measured k by acoustic gas thermometry now use the same apparatus to measure temperature against a fixed k. The physics did not change; the bookkeeping did.

How does kinetic theory explain the law from molecules in motion?

The gas law was empirical for nearly two centuries. Kinetic theory explains why it holds, using a small set of assumptions that NASA's Glenn pages and OpenStax both state in plain terms.

  1. A gas is made of a very large number of molecules in constant random motion.
  2. The molecules are tiny compared with the distances between them, so their own volume is negligible.
  3. They collide elastically with each other and with the walls: kinetic energy is conserved.
  4. They exert no forces on each other except during collisions.
  5. Their average kinetic energy depends only on the absolute temperature.

Pressure is momentum delivered to the wall

NASA's kinetic theory page puts the key idea in one line: pressure is a measure of the linear momentum of the molecules. A molecule of mass m moving at speed vₓ toward a wall bounces back at minus vₓ, so each hit delivers momentum 2mvₓ. In a cube of side L, it returns to the same wall every 2L/vₓ seconds, so its average force is mvₓ²/L. Add up N molecules, note that random motion splits the squared speed equally among three directions (the average of vₓ² is one third of the average of v²), and divide by the wall area L²:

P = (1/3) × (N/V) × m × ⟨v²⟩
PV = (2/3) × N × ( (1/2) m ⟨v²⟩ )

The bracket is the average translational kinetic energy of one molecule. Compare with PV = NkT and the two match only if:

(1/2) m ⟨v²⟩ = (3/2) k T

That is the microscopic meaning of temperature. At 300 K every gas molecule, light or heavy, carries on average 6.21 × 10⁻²¹ joules of translational kinetic energy. OpenStax states the same result per mole: the average kinetic energy is proportional to the kelvin temperature.

How fast are the molecules?

Rearranging gives the root mean square speed, u_rms = √(3RT/M), where M is the molar mass in kg/mol. For nitrogen (M = 0.028 013 4 kg/mol) at 300 K:

u_rms = √(3 × 8.314 462 618 × 300 / 0.028 013 4) = 517 m/s

OpenStax's speed distribution figure for nitrogen shows a most probable speed a little under 400 m/s and a root mean square speed close to 500 m/s, consistent with this. Helium at 15 °C comes out at 1,340 m/s, which is why it leaks through balloon skins and why the speed of sound in helium is so much higher.

How empty is a gas?

At 101.325 kPa and 15 °C the number density is P/(kT) = 2.55 × 10²⁵ molecules per cubic metre. The cube root of the volume per molecule gives an average spacing of about 3.4 nanometres. Nitrogen and oxygen molecules are a few tenths of a nanometre across, so at ordinary conditions the spacing is roughly ten times the size. The gas is mostly empty space, which is exactly assumption 2. Squeeze it to 300 bar and the spacing falls to about half a nanometre, comparable with the molecules themselves. That is where the theory starts to break, which the next section quantifies.

What kinetic theory adds that the empirical law did not

The law alone says PV = nRT. Kinetic theory explains why R is the same for every gas (the energy per molecule depends on T only, not on mass), predicts diffusion and effusion rates (Graham's law follows from u_rms ∝ 1/√M, as OpenStax derives), and tells you exactly which assumptions to relax when the law fails. Relax assumption 2 and you get van der Waals' b term. Relax assumption 4 and you get his a term.

When does the ideal gas law fail, and what do van der Waals and the compressibility factor add?

Real molecules take up space and attract each other weakly. At low pressure and high temperature neither effect matters. Raise the pressure, or cool the gas toward the point where it condenses, and both start to show.

The compressibility factor Z

The simplest way to measure the error is the compressibility factor, which OpenStax defines as the measured molar volume divided by the ideal molar volume at the same T and P:

Z = P V_m / (R T)

Z = 1 is ideal. Z below 1 means the gas is easier to compress than ideal, because attractions pull molecules together. Z above 1 means it is harder to compress, because the molecules' own volume is starting to crowd the space.

We pulled real data from the NIST Chemistry WebBook's thermophysical property tables for nitrogen and carbon dioxide along the 300 K isotherm, and computed Z from the listed molar volumes:

Gas at 300 KPressure (bar)NIST molar volume (L/mol)Z = PV/(RT)Ideal gas error
Nitrogen124.9390.99980.02 percent
Nitrogen510.487 460.99670.3 percent
Nitrogen1010.248 331.00550.6 percent
Nitrogen2010.131 241.05765.8 percent
Nitrogen3010.094 7971.143914 percent
Carbon dioxide124.8220.99510.5 percent
Carbon dioxide211.05650.889511 percent
Carbon dioxide410.462 400.760124 percent
Carbon dioxide610.231 880.567143 percent

Two patterns stand out. Nitrogen at 300 K is far above its critical temperature (126.19 K in the WebBook's phase data), so attractions barely matter and Z stays near 1 until molecular volume pushes it up past 100 bar. Carbon dioxide at 300 K is just below its critical temperature (304.18 K in the WebBook), so attractions dominate and Z falls steeply. By 61 bar the gas is close to condensing and the ideal gas law overestimates its pressure by nearly a factor of two.

The rule of thumb that falls out: the ideal gas law is good to better than 1 percent for permanent gases such as nitrogen, oxygen, argon, helium and air at pressures up to tens of bar and temperatures well above their critical points. It is poor for vapours near condensation (steam, refrigerants, carbon dioxide near room temperature) and for any gas at hundreds of bar.

The van der Waals equation

Van der Waals' equation kept the simplicity of the ideal gas law but added two corrections. OpenStax dates it to 1879, but his own Nobel lecture refers repeatedly to "my treatise of 1873", so we use that year:

(P + a n²/V²) × (V − n b) = n R T

The b term subtracts the volume the molecules themselves occupy, so the free volume they move in is smaller than the container. The a term adds back the pressure lost because molecules near a wall are pulled inward by their neighbours, so they hit the wall a little more softly. When V is large and n small, both corrections vanish and the ideal gas law returns, a point OpenStax makes explicitly.

OpenStax's Table 9.3 lists experimental constants:

Gasa (L² atm/mol²)b (L/mol)
N₂1.390.0391
O₂1.360.0318
CO₂3.590.0427
H₂O5.460.0305
He0.03420.0237
CCl₄20.40.1383

Notice how a tracks how easily the gas condenses. Helium, which liquefies only a few kelvin above absolute zero, has a tiny a. Water and carbon tetrachloride, liquids at room temperature, have large ones.

Van der Waals' larger idea was continuity: the same equation describes both gas and liquid, and below a critical temperature its curves have the S shaped wiggles that signal a phase change. He said in his Nobel lecture that "the idea of continuity occurred to me" while thinking about why the liquid and gas states should be treated by one law. That insight, more than the exact equation, is why he won the prize.

How good is van der Waals in practice?

Two of our worked examples below test it against the NIST data. The short answer: it removes most of the error for carbon dioxide near condensation, and it does almost nothing for nitrogen at 200 bar. Engineers who need precision use multi parameter reference equations of state, such as the ones behind the NIST WebBook tables and the open source CoolProp library, or the principle of corresponding states, which plots Z against pressure and temperature scaled by each gas's critical values.

Which equation should you use?

SituationTypical error of PV = nRTWhat to use
Air, nitrogen, oxygen, helium below about 10 bar and above about minus 50 °CWell under 1 percentIdeal gas law
Same gases at 10 to 100 bar, room temperatureUnder about 1 percent for nitrogenIdeal gas law with a check, or Z from tables
Compressed gas cylinders, 150 to 300 bar5 to 15 percent for nitrogenReference data (NIST WebBook) or a property library
Vapours near condensation (steam, refrigerants, CO₂ near 300 K)10 to 50 percent or moreReference equation of state or property tables; van der Waals for a rough estimate
Teaching or a quick estimate of non-ideal effectsVan der Waals
LiquidsMeaninglessNot a gas law problem

Worked examples with numbers

Each example states its assumptions, works in SI units with absolute temperature and pressure, and gives the answer to a sensible number of figures. The script in the walkthrough reproduces every number.

Example 1: why your tyre warning light comes on in the first cold morning

Setup (illustrative). You set your tyres to 240 kPa gauge (about 35 psi) on a warm afternoon at 25 °C. A cold front arrives and the next morning, before driving, the air is 0 °C. What does the gauge read?

Assumptions. The tyre volume stays almost constant (true to within a percent or two for a car tyre), no air leaks, and the tyre air reaches the outside temperature overnight. Atmospheric pressure is 101.325 kPa.

Step 1: convert to absolute pressure and kelvin.

P₁ = 240 + 101.325 = 341.325 kPa (absolute)
T₁ = 25 + 273.15 = 298.15 K
T₂ = 0 + 273.15 = 273.15 K

Step 2: constant volume and amount, so P/T is constant.

P₂ = P₁ × T₂ / T₁ = 341.325 × 273.15 / 298.15 = 312.70 kPa (absolute)

Step 3: convert back to gauge.

P₂ gauge = 312.70 − 101.325 = 211.4 kPa  (about 30.7 psi)

The tyre has lost 28.6 kPa, about 4.2 psi or 12 percent of its gauge pressure, without losing any air. That is roughly 1 kPa per degree, or the familiar "about 1 psi per 10 °F" rule of thumb.

Why it matters. US federal motor vehicle safety standard 571.138 requires a tyre pressure monitoring system to light its warning within 20 minutes once a tyre is 25 percent or more below the manufacturer's recommended cold inflation pressure (or a minimum in the standard's table, whichever is higher). For a 240 kPa placard that threshold is 180 kPa. A 25 degree drop alone does not trigger it; a tyre that was already 10 percent low before the cold snap gets close. That is why tyre placards specify a cold inflation pressure: measure before driving, not after.

The wrong ways. Use Celsius and you get P₂ = 341.325 × 0 / 25 = 0, a flat tyre from a cold front. Use gauge pressure in the ratio and you get 240 × 273.15/298.15 = 219.9 kPa, an error of 8.5 kPa that hides a third of the real drop. After a motorway drive that warms the air to 40 °C, the same tyre reads 257 kPa gauge; letting air out to "correct" it leaves the tyre underinflated once it cools.

Example 2: how big does a weather balloon get before it bursts?

Setup. The US National Weather Service's radiosonde fact sheet says a weather balloon is about 1.5 m in diameter at release, rises at about 300 m per minute, expands as air pressure falls, bursts when it reaches 6 to 8 m in diameter, and can climb above 35 km. Can the ideal gas law predict the burst altitude?

Assumptions. The balloon gas stays at ambient pressure (we ignore the small extra pressure from the stretched rubber) and at ambient temperature (the sun warms it in reality), and no helium leaks. Atmospheric pressure and temperature come from NASA Glenn's Earth atmosphere model, a set of curve fits for three zones: the troposphere to 11 km, the lower stratosphere to 25 km at a constant minus 56.46 °C, and the upper stratosphere above that.

Step 1: how much helium is in the balloon? At release, V₁ = (4/3)π(0.75)³ = 1.767 m³. The NASA model gives 15.04 °C and 101.40 kPa at sea level.

n = PV / (RT) = 101 400 × 1.767 / (8.314 × 288.19) = 74.8 mol
mass of helium = 74.8 × 4.0026 g/mol = 0.30 kg

Step 2: lift at release. Air density at those conditions is PM/(RT) with M = 0.028 964 kg/mol, giving 1.226 kg/m³. Helium's density is 0.169 kg/m³. The balloon displaces 1.767 × (1.226 − 0.169) = 1.87 kg more air than the helium weighs. That gross lift has to carry the balloon envelope, the parachute and the radiosonde, which the fact sheet says weighs 60 to 80 grams.

Step 3: volume ratio at altitude. With n constant, V₂/V₁ = (P₁/P₂) × (T₂/T₁). Diameter scales as the cube root of volume.

AltitudeTemperature (°C)Pressure (kPa)V₂/V₁Diameter (m)
0 km15.0101.41.01.50
5 kmminus 17.454.11.71.78
10 kmminus 49.926.53.02.15
20 kmminus 56.55.5313.83.60
25 kmminus 56.52.4830.74.70
30 kmminus 41.51.16706.19
35 kmminus 26.60.5701528.01

Answer. The model reaches 6 m at about 29.5 km and 8 m at about 35 km, which lines up with the Weather Service's 6 to 8 m burst diameter and "in excess of 35 km" ceiling. Most of the growth happens high up: the balloon only doubles in diameter (eight times the volume) by about 17 km, then grows almost twentyfold more in volume over the next 18 km as pressure keeps halving every 5 km or so. Notice too that temperature helps a little above 25 km, where the stratosphere warms with height.

What the assumptions hide. Rubber stretching adds overpressure, solar heating raises the gas temperature, and helium diffuses through the skin. Each moves the burst point, which is one reason real flights vary. The ideal gas law itself is not the weak link here: at 1 kPa and minus 40 °C helium is about as ideal as a gas gets.

Example 3: air density and airflow in a data centre cold aisle

Setup. The US Department of Energy's Best Practices Guide for Energy-Efficient Data Center Design (revised July 2024) reproduces the ASHRAE recommended envelope for IT equipment inlet air: 18 to 27 °C (64.4 to 80.6 °F). The guide advises designing to the recommended range and notes that server fans speed up when inlets run hotter. How does air density change across that range, and with altitude, and what does that do to the airflow a rack needs?

Assumptions (illustrative). A 10 kW rack, a 12 K rise in air temperature from inlet to exhaust, dry air with M = 0.028 964 kg/mol and a specific heat of about 1.006 kJ/(kg K), a standard textbook value near room temperature. Site pressures come from the NASA atmosphere model: 101.4 kPa at sea level and 83.6 kPa at 1,600 m.

Step 1: density from the ideal gas law. ρ = PM/(RT).

Sea level, 18 °C:  ρ = 101 400 × 0.028 964 / (8.314 × 291.15) = 1.213 kg/m³
Sea level, 27 °C:  ρ = 101 400 × 0.028 964 / (8.314 × 300.15) = 1.177 kg/m³
1,600 m, 18 °C:    ρ =  83 610 × 0.028 964 / (8.314 × 291.15) = 1.000 kg/m³
1,600 m, 27 °C:    ρ =  83 610 × 0.028 964 / (8.314 × 300.15) = 0.970 kg/m³

Step 2: mass flow to carry the heat. Heat removed equals mass flow times specific heat times temperature rise, so the mass flow does not depend on density at all:

ṁ = Q / (c_p × ΔT) = 10 / (1.006 × 12) = 0.828 kg/s

Step 3: volume flow, which is what fans move. Fans are roughly constant volume machines, so what they must deliver is ṁ/ρ.

Site and inletDensity (kg/m³)Volume flow (m³/s)Volume flow (CFM)
Sea level, 18 °C1.2130.6831,447
Sea level, 27 °C1.1770.7041,491
1,600 m, 18 °C1.0000.8281,755
1,600 m, 27 °C0.9700.8541,809

Answer. Moving from the cool end to the warm end of the recommended range costs about 3 percent in volume flow at sea level. Moving the same rack to a site at 1,600 m costs about 21 percent, and the two together about 25 percent. Because fan power rises roughly with the cube of fan speed (the fan affinity law the DOE guide cites), a 25 percent increase in airflow can mean nearly double the fan power if the fans have to deliver it alone. This is why cooling designs for high altitude sites derate air cooled equipment, and why rack airflow figures quoted at sea level need correcting with the ideal gas law before you trust them.

Check. At the international standard sea level condition of 101.325 kPa and 15 °C (288.15 K), the same formula gives 1.2250 kg/m³, the textbook standard air density. That agreement is a good sign the molar mass and units are right.

Example 4: how much air is really in a scuba cylinder?

Setup (illustrative). A cylinder with a 12 litre internal volume is filled to 201 bar at 300 K. How many moles of gas does it hold, and how many litres of free gas at 1 bar is that? We use nitrogen as a stand in for air because the NIST WebBook gives it directly; air at these conditions behaves similarly but not identically.

Ideal gas answer.

n_ideal = PV / (RT) = 201 × 10⁵ × 0.012 / (8.314 × 300) = 96.7 mol

Real gas answer from NIST data. The WebBook lists nitrogen's molar volume at 300 K and 201 bar as 0.131 24 L/mol.

n_real = 12 / 0.131 24 = 91.4 mol
Z = 1.0576

Answer. The ideal gas law overestimates the contents by 5.8 percent, about 5.3 mol or 150 grams of nitrogen. In free gas terms (24.94 L/mol at 1 bar and 300 K from the same table), the cylinder holds about 2,280 litres, not the 2,410 litres the ideal calculation suggests. At 301 bar the overestimate grows to 14 percent. Gas planning tables used for diving and industrial cylinders account for this; a hand calculation with PV = nRT will flatter the supply at high fill pressures.

Van der Waals check. Plugging the real molar volume into van der Waals with OpenStax's nitrogen constants gives 188.9 bar, against an ideal prediction of 190.1 bar and a true value of 201 bar. For nitrogen at room temperature and high pressure, van der Waals is no better than the ideal gas law. Its two constants were fitted for a different job.

Example 5: carbon dioxide near condensation

Setup. The NIST WebBook lists carbon dioxide at 300 K and 61 bar with a molar volume of 0.231 88 L/mol. What pressure do the ideal gas law and van der Waals predict for that molar volume?

Ideal:        P = RT / V_m = 0.082 057 × 300 / 0.231 88 = 106.2 atm = 107.6 bar
Van der Waals: P = RT/(V_m − b) − a/V_m²
             = 0.082 057 × 300 / (0.231 88 − 0.0427) − 3.59 / 0.231 88²
             = 130.1 − 66.8 = 63.4 atm = 64.2 bar
Measured (NIST): 61 bar

Answer. The ideal gas law is off by 76 percent. Van der Waals is off by 5 percent, a dramatic improvement, almost entirely from the a term. Near condensation, attractions are the story, and that is exactly the correction van der Waals designed.

Example 6: an airbag, as an order of magnitude check

Setup (illustrative). Suppose an airbag holds 60 litres when deployed, at an absolute pressure of 150 kPa. How much gas must the inflator produce?

At 300 K: n = 150 000 × 0.060 / (8.314 × 300) = 3.6 mol
At 600 K: n = 150 000 × 0.060 / (8.314 × 600) = 1.8 mol

Answer. A few moles of gas, produced in a few tens of milliseconds. The ideal gas law also shows why gas temperature matters to inflator design: hot gas fills the bag with half the moles, but the bag softens as the gas cools. Real inflator chemistry and bag volumes vary by vehicle and position, so treat these numbers as an illustration of the method, not a specification.

Where does the ideal gas law show up in everyday engineering?

HVAC and building controls

Every airflow calculation in heating, ventilation and air conditioning starts with air density, and air density is P M / (RT). Supply fans are sized in volume flow, heat loads in mass flow, and the conversion between them changes with altitude and season as Example 3 showed. Psychrometrics, the study of moist air, treats dry air and water vapour as two ideal gases sharing the same volume, each with its own partial pressure (Dalton's law). Building automation controllers do this arithmetic continuously: a variable air volume box converts a differential pressure reading into airflow using a density it either assumes or computes from temperature. Our post on BACnet and building automation covers how those controllers talk to each other.

Data centres

Beyond airflow, the gas law governs pressurised containment, gaseous fire suppression (the agent concentration in a sealed room depends on room volume and temperature) and the cooling capacity of air at altitude. Teams building a small data centre at home run into a homely version: a closed cabinet heats up, the air inside expands, and fans have to push a larger volume to carry the same heat.

Scuba and compressed gas

Boyle's law sets a diver's air consumption: at 20 m depth the ambient pressure is about 3 bar absolute, so each breath takes three times as many moles from the cylinder as at the surface. Cylinder contents follow PV = nRT until high fill pressures, where Example 4 showed it overestimates by 5 to 15 percent. A cylinder filled hot and left to cool loses pressure the same way the tyre in Example 1 did, which is why fill stations often fill slowly or top up after cooling.

Engines and compressors

Inside an engine cylinder the gas law links pressure, volume and temperature at every crank angle. When compression is fast enough that little heat escapes, the process is close to adiabatic and follows PV^γ = constant, with γ about 1.4 for air. Combined with PV = nRT, a 10 to 1 compression of air starting at 300 K would reach about 754 K and 25 times its starting pressure in the ideal limit. Diesel engines rely on that temperature rise to ignite fuel without a spark. Air compressors follow the same physics, which is why compressed air needs an aftercooler and why its moisture condenses out.

Airbags and other rapid inflation

Example 6 showed the scale: a few moles of gas fill a bag.

Weather, aviation and altitude

Weather balloons (Example 2), aircraft performance and altimeters all rest on the ideal gas law applied to the atmosphere. NASA's atmosphere model derives density from its temperature and pressure fits through the equation of state, and aerodynamic forces scale directly with that density. A hot day at a high altitude airport has thinner air, so aircraft need longer take off runs.

Walkthrough: check the worked examples in Python

You can reproduce every number in this post with a short script. The constants module in SciPy publishes the 2022 CODATA values, according to its documentation, so you do not have to type R by hand. For real gas checks, the open source CoolProp library exposes a PropsSI function whose documented outputs include Z, the compressibility factor.

Step 1: create a clean, pinned environment

Scientific scripts rot when dependencies drift. Pin versions and record hashes so the same script gives the same answer next year.

python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install scipy pint CoolProp
python -m pip freeze > requirements.txt

On the next machine, install exactly those versions:

python -m pip install -r requirements.txt

For stronger guarantees, generate a lock file that records a hash for every artifact (the pip-tools project's pip-compile can do this) and install in hash checking mode, so a changed artifact fails the install instead of silently replacing the one you tested:

pip-compile --generate-hashes requirements.in -o requirements.txt
python -m pip install --require-hashes -r requirements.txt

Step 2: the ideal gas calculations

Save this as idealgas.py:

import math
from scipy.constants import R, k, N_A  # CODATA values, exact since 2019

print(f"R = {R} J/(mol K);  N_A * k = {N_A * k}")

# Example 1: tyre, constant volume
P_atm = 101.325                      # kPa
p1_gauge, t1_c, t2_c = 240.0, 25.0, 0.0
P1 = p1_gauge + P_atm                # absolute
T1, T2 = t1_c + 273.15, t2_c + 273.15
P2 = P1 * T2 / T1
print(f"Tyre: {P2 - P_atm:.1f} kPa gauge (was {p1_gauge})")

# NASA Glenn Earth atmosphere model (metric curve fits)
def atmosphere(h):
    if h < 11000:
        T = 15.04 - 0.00649 * h
        p = 101.29 * ((T + 273.1) / 288.08) ** 5.256
    elif h < 25000:
        T = -56.46
        p = 22.65 * math.exp(1.73 - 0.000157 * h)
    else:
        T = -131.21 + 0.00299 * h
        p = 2.488 * ((T + 273.1) / 216.6) ** -11.388
    return T, p  # deg C, kPa

# Example 2: weather balloon
T0, p0 = atmosphere(0)
V0 = 4 / 3 * math.pi * 0.75 ** 3
n_he = p0 * 1000 * V0 / (R * (T0 + 273.15))
print(f"Balloon: {n_he:.1f} mol He, {n_he * 4.0026:.0f} g")
for h in (0, 10000, 20000, 30000, 35000):
    T, p = atmosphere(h)
    ratio = (p0 / p) * ((T + 273.15) / (T0 + 273.15))
    print(f"  {h/1000:4.0f} km: diameter {1.5 * ratio ** (1/3):.2f} m")

# Example 3: data centre air density and airflow
M_air, cp, load_kw, dT = 0.028964, 1.006, 10.0, 12.0
mdot = load_kw / (cp * dT)
for site, h in (("sea level", 0), ("1,600 m", 1600)):
    _, p = atmosphere(h)
    for t_in in (18, 27):
        rho = p * 1000 * M_air / (R * (t_in + 273.15))
        q = mdot / rho
        print(f"  {site}, {t_in} C: rho {rho:.3f} kg/m3, {q:.3f} m3/s, {q * 2118.88:.0f} CFM")

# Examples 4 and 5: compressibility from NIST WebBook molar volumes at 300 K
for gas, p_bar, vm_l in (("N2", 201, 0.13124), ("N2", 301, 0.094797), ("CO2", 61, 0.23188)):
    Z = p_bar * 1e5 * vm_l * 1e-3 / (R * 300)
    print(f"  {gas} at {p_bar} bar: Z = {Z:.4f}")

Run it:

python idealgas.py

The output should match the tables above: a tyre at 211.4 kPa gauge, 74.8 mol of helium, a balloon passing 8 m near 35 km, densities of 1.213 to 0.970 kg/m³, and Z values of 1.0576, 1.1439 and 0.5671.

Step 3: let a units library catch your mistakes

The pint package attaches units to numbers and refuses to add kelvin to degrees Celsius without an explicit conversion, which is precisely the mistake that sinks most gas law homework:

import pint
ureg = pint.UnitRegistry()
Q_ = ureg.Quantity

P = Q_(341.325, "kPa")
V = Q_(30, "L")              # illustrative tyre volume
T = Q_(25, "degC").to("K")   # explicit conversion
n = (P * V / (ureg.molar_gas_constant * T)).to("mol")
print(n)                     # about 4.13 mole

Step 4: compare with a real gas equation of state

from CoolProp.CoolProp import PropsSI
Z = PropsSI("Z", "T", 300, "P", 201e5, "Nitrogen")
print(f"CoolProp Z for N2 at 300 K, 201 bar: {Z:.4f}")

Expect a value close to the 1.058 we computed from the NIST WebBook table. Small differences come from the equation of state version each source uses.

Step 5: keep the environment healthy

The script has four third party dependencies with their own transitive trees. Before you hand it to a colleague or run it in CI, scan the folder for known vulnerable components:

safeguard scan --dir .

Results are written as JSON under ./output. The same check applies to the much larger dependency trees behind building management dashboards and telemetry services, which the bridge section below comes back to.

Common mistakes

Celsius or Fahrenheit instead of kelvin. The gas law is proportional to absolute temperature. Ratios in Celsius are meaningless: 20 °C is not "twice as hot" as 10 °C, and 0 °C would imply zero pressure. Add 273.15 every time. In US customary units use Rankine (°F + 459.67), as NASA's equation of state page reminds readers.

Gauge pressure instead of absolute. Tyre gauges, cylinder gauges and most industrial transmitters read pressure above atmospheric. The gas law needs absolute pressure. Add local atmospheric pressure (about 101 kPa at sea level, about 84 kPa at 1,600 m) before you compute, and subtract it afterwards if you want a gauge reading.

Mixing units. R = 8.314 J mol⁻¹ K⁻¹ needs pascals and cubic metres. R = 0.082 06 L atm mol⁻¹ K⁻¹ needs litres and atmospheres. R = 8.314 kPa L mol⁻¹ K⁻¹ needs kilopascals and litres. Mixing kPa with m³ or bar with litres gives answers off by factors of 1,000 or 100.

Using the wrong "standard". STP has meant 0 °C and 1 atm in older texts and 0 °C and 1 bar in IUPAC usage since 1982; engineering "standard" conditions often use 15 °C or 20 °C. A molar volume of 22.414 L, 22.711 L or 24.79 L can each be correct for its own conditions.

Ignoring that the gas changed. The combined gas law assumes n is constant. A leaking tyre, a balloon losing helium or a reaction that consumes gas breaks that assumption.

Assuming the volume is fixed when it is not, or vice versa. A tyre is nearly rigid; a balloon is not; a piston may or may not be held. Decide which variable is constant before choosing a law.

Using the ideal gas law for a vapour. Steam near 100 °C, refrigerants in a heat pump and carbon dioxide near room temperature are close to condensation. Example 5 showed a 76 percent error. Use property tables.

Using it at high pressure without checking Z. Above roughly 100 bar even nitrogen deviates by more than a percent, and by 300 bar by 14 percent.

Using molar mass in grams per mole with SI R. In ρ = PM/(RT) and u_rms = √(3RT/M), M must be in kilograms per mole when R is in J mol⁻¹ K⁻¹. Using 28.96 instead of 0.028 96 gives densities 1,000 times too large.

Forgetting humidity. Moist air is less dense than dry air at the same temperature and pressure, because water (18 g/mol) is lighter than the nitrogen and oxygen it displaces. For precise airflow work, use psychrometric methods.

FAQ

What is the ideal gas law in simple terms?

It says that pressure times volume equals the number of moles times a constant times the absolute temperature: PV = nRT. Squeeze a gas and its pressure rises; heat it and either its pressure or its volume rises; add more gas and the same happens. It holds well for most gases at everyday pressures and temperatures.

What is the value of R in the ideal gas law?

R = 8.314 462 618... J mol⁻¹ K⁻¹, exact since 20 May 2019 because it is the product of two exact constants, the Avogadro constant and the Boltzmann constant. In other units it is 0.082 057 L atm mol⁻¹ K⁻¹ or 8.314 kPa L mol⁻¹ K⁻¹.

Why must temperature be in kelvin?

Because the law depends on absolute temperature, measured from absolute zero. Gas volume extrapolates to zero at minus 273.15 °C, which is 0 K. A ratio of kelvin temperatures is physically meaningful; a ratio of Celsius temperatures is not.

Who discovered the ideal gas law?

No single person. Boyle published the pressure and volume relationship in 1662, Charles found the volume and temperature relationship around 1787 without publishing, Gay-Lussac published it in 1802, Amontons worked on pressure and temperature around 1700, and Avogadro added the amount of gas in 1811. The combined equation followed in the nineteenth century.

What is an ideal gas?

A model gas whose molecules have no volume of their own and exert no forces on each other except in perfectly elastic collisions. No real gas is ideal, but nitrogen, oxygen, helium and air come very close at ordinary conditions.

When is the ideal gas law not accurate?

At high pressure, where molecular volume matters, and at low temperature or near condensation, where molecular attractions matter. Nitrogen at 300 K is within about 1 percent up to around 100 bar but off by 14 percent at 301 bar. Carbon dioxide at 300 K is off by more than 40 percent at 61 bar.

What is the difference between the ideal gas law and van der Waals equation?

Van der Waals adds two constants per gas. The b term subtracts the volume the molecules occupy; the a term accounts for attractions that reduce the pressure on the walls. It improves on PV = nRT near condensation, but for precise work at high pressure engineers use reference equations of state and property tables.

What is the compressibility factor Z?

Z = PV/(nRT). It is 1 for an ideal gas, below 1 when attractions dominate and above 1 when molecular volume dominates. Multiplying the ideal gas law by Z, PV = ZnRT, makes it exact for a real gas if you know Z.

How does temperature affect tyre pressure?

At fixed volume, absolute pressure is proportional to absolute temperature. A tyre set to 240 kPa gauge at 25 °C reads about 211 kPa gauge at 0 °C, roughly 1 kPa lost per degree. Always set tyres cold, to the pressure on the vehicle placard.

What is 22.4 litres per mole?

The volume of one mole of an ideal gas at 0 °C and 1 atm (101.325 kPa). NIST CODATA lists it as 22.413 969 54... L/mol, exact because it follows from exact constants. At 0 °C and 1 bar it is 22.711 L/mol, and at 25 °C and 1 bar it is 24.79 L/mol.

The software that runs the machines: an honest bridge

The ideal gas law is physics, and Safeguard does not do physics. Its models are single purpose security models for software; they do not calculate gas properties, size HVAC systems or analyse hardware, and nothing in this post was computed by them. The connection is narrower and real. The building management systems, cooling controllers and data centre infrastructure dashboards that apply PV = nRT thousands of times a day are software, and much of that software is ordinary web applications, Python services and container images built from open source dependencies. A facility telemetry service, a CRAC unit integration written in Python, or the property calculation script in the walkthrough above all carry dependency trees that can include known vulnerable versions. Where Safeguard helps is there: scanning those repositories, images and SBOM files for known vulnerable open source components, showing which projects carry a given version, and, when a fixed version exists, opening an upgrade pull request for review.

Cooling and building controls run on software now: the dashboards, protocol gateways and analysis scripts around them all ship open source components, and every rebuild pulls those dependencies again. The fit is indirect for the physics itself, but for the code your team builds and ships around these systems, the same dependency hygiene applies, and the section below shows how to close the gap whether or not upstream has a fix yet.

Fix it without waiting for upstream

Whatever the vulnerability, most of the risk sits in two gaps. The first is the time between a fix being published and that fix actually running in your production builds. The second, and worse, is the time before any fix exists at all, while a maintainer works out a patch and a release schedule. Waiting through both gaps is a habit, not a requirement. Safeguard gives teams three ways to close them.

1. Autonomous remediation: pull requests, not tickets

When a fixed version exists, Safeguard's Griffin models open a tested, policy gated pull request that moves the affected dependency to the safe version. You can run it on one repository or in bulk across every project that carries the vulnerable version. Remediation covers eight categories, including dependencies, licenses, security posture and findings. Reachability analysis ranks the vulnerable code paths your application actually calls first, so the first pull requests you merge are the ones that matter most. Autonomous remediation ships switched off, with every category set to Manual, so your team decides how much runs on its own and what still needs a human approval.

2. Gold Open Source: the safe version in seconds, free

gold.safeguard.sh is free and needs no login. Search any CVE or package to see affected and fixed versions, CVSS, EPSS, CISA KEV status and a recommended safe version, or use the "Am I affected?" checker. The same data is available through a free read API, README status badges and RSS threat feeds. The safeguard-sh/gold-scan-action GitHub Action can fail a build on a known exploited vulnerability, on any known vulnerability, or never, so a version you have just removed cannot quietly come back in next week's merge.

3. Gold Registry: start from components that are already fixed

registry.safeguard.sh provides hardened, drop in replacements for upstream packages and container images. Every Gold artifact is held continuously to zero exploitable critical or high CVEs, zero malware and a completed license check, with SLSA L3 or higher provenance, a Sigstore signature and a public evidence page you can hand to an auditor. An artifact loses its Gold badge if it regresses. Teams can point their own package directory at the registry so hardened equivalents resolve without changing how developers install anything.

When upstream has no fix yet, or will not ship one, Safeguard first works to get the fix accepted upstream. If the issue is severe or upstream will not move, Safeguard builds a fork, fixes the vulnerability there and publishes a hardened Gold build, so you are not stuck on a maintainer's release schedule. You can also request a hardened, compatibility tested build of a specific package. This fork and patch flow is in early access today, so ask which packages it covers before you plan around it.

Your situationWhat to use
A fixed version existsAutonomous remediation opens the upgrade pull request; Gold Open Source confirms the safe version
You need to know today whether you are affectedGold Open Source lookup and "Am I affected?" checker, free and without login
You want vulnerable versions to stop shippingThe Gold scan GitHub Action in CI, plus Safeguard policies and gates
Upstream has no fix yet, or will not ship oneA custom Gold request; fork and patch (early access)
You want to start clean on new projectsPull hardened components and images from Gold Registry

One honest limit: when the vulnerable code lives in a vendor appliance, a hosted service or an operating system runtime you do not build yourself, the fix still has to come from that vendor or distribution. The steps above apply to the open source dependencies and container images you build and ship, which is where most teams carry the largest and least tracked share of their exposure.

See how Safeguard would help

None of these demos involve gas calculations; they show the software side described in the bridge above.

The first demo is a real Safeguard CLI session: it installs the CLI, opens the interactive terminal and asks it to fix a lodash CVE in a repository. It reads the finding and advisory, asks before each command, edits package.json to lodash 4.17.21, runs npm install and npm test with approval, prints a summary and pushes nothing. The same flow applies to a building telemetry dashboard or a cooling analytics service your team maintains: scan the repository, then let the assistant propose the dependency upgrade under your approval.

Click through it at your own pace, or open it full screen.

The second demo sets up the Safeguard runner on your own machine, approves it with its device code and then scans from the terminal. That suits engineering teams who keep calculation scripts, controller integration code or lab tooling on their own hardware and want the scan to run where the code lives.

Click through it at your own pace, or open it full screen.

The third demo connects Claude to the Safeguard MCP server with OAuth and lets you choose which tools Claude can use. For an engineer who already works with Claude while writing a facility monitoring service, it brings dependency findings into the same conversation, limited to the tools you allow.

Click through it at your own pace, or open it full screen.

To try it on your own repositories, download Safeguard and follow the CLI documentation.

Quick check

A sealed rigid container holds gas at 200 kPa absolute and 27 °C. What is the pressure at 127 °C?

At constant volume, P₂ = P₁ × T₂/T₁ = 200 × 400.15/300.15 = 266.6 kPa absolute. Using Celsius would wrongly give 200 × 127/27 = 941 kPa.

How many moles of an ideal gas fill 1 m³ at 101.325 kPa and 0 °C?

n = PV/(RT) = 101 325 × 1 / (8.314 462 618 × 273.15) = 44.6 mol, which matches 1,000 L divided by 22.414 L/mol.

Nitrogen at 300 K and 301 bar has Z of about 1.14. Does the ideal gas law overestimate or underestimate how much gas is in a cylinder at that pressure?

It overestimates. Z above 1 means the real molar volume is larger than ideal, so fewer moles fit in the same volume: about 14 percent fewer than PV = nRT predicts.

Sources

Last reviewed: 23 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.