The ideal gas law, PV = nRT, ties a gas's pressure, volume, amount and absolute temperature together. Drag the sliders below to change the moles, temperature (in kelvin) and volume, and watch the pressure respond — with Boyle's, Charles's and Gay-Lussac's laws falling out when you hold one fixed.

The Ideal Gas Law

One equation, PV = nRT, ties pressure, volume, temperature and amount of gas together. Drag a slider and watch the molecules respond — hotter gas moves faster, a smaller volume packs more collisions, and the pressure readout tracks it all. The preset buttons freeze one quantity so Boyle's, Charles's and Gay-Lussac's laws fall out on their own.

Pressure  P = nRT ÷ V
100.00 kPa
0.987 atm
Molecules  N = n·NA
6.02 × 1023
at n = 1.00 mol
Molar volume  Vm = V ÷ n
22.71 L/mol
rms speed 493 m/s
Amount 1.00 mol
Temperature 273.15 K
Volume 22.711 L
Gas: nitrogen (N2) · molar mass M = 0.02802 kg/mol · R = 8.314 J/(mol·K)
Tip: press Charles, then raise the temperature — the piston lifts so the pressure stays put. That is V ∝ T at constant P.

What Is the Ideal Gas Law Simulator?

The Ideal gas law simulator is a free interactive physics lab that runs in your browser — nothing to install and no sign-up. Change the moles, temperature and volume and watch the pressure respond through PV = nRT. It reports pressure, Molecules and Molar volume Vm as you drag the sliders.

What you can change in the Ideal gas law simulator
ControlRangeStep
Amount of gas0.10 – 5.00 mol0.01
Temperature100 – 800 K0.05
Volume1.0 – 50.0 L0.001

Three gas laws hiding inside PV = nRT

The single line PV = nRT quietly holds Boyle's, Charles's and Gay-Lussac's laws inside it; each one surfaces the moment you freeze a quantity in place. This simulation seals a fixed sample of nitrogen and hands you three sliders — Amount of gas n in moles, Temperature T in kelvin, and Volume V in litres — then solves P = nRT/V live, printing the pressure P and the molar volume (V/n) beside a fixed constant R = 8.314 J/(mol·K).

Watch how P responds: it climbs as you add moles or raise temperature, and sinks as the volume opens up. The preset buttons lock one variable so a named law stands alone. Hold n and T and you get Boyle's law, with P proportional to 1/V — halve the volume, double the pressure. Hold n and P for Charles's law, V proportional to T; hold n and V for Gay-Lussac's law, P proportional to T.

One trap catches everyone: T is absolute temperature. Doubling it truly doubles the pressure only in kelvin — 200 K to 400 K works, but 20°C to 40°C does not, because those are really 293 K and 313 K, a rise of under ten percent. Remember this is the ideal model — point molecules with no forces — so real gases drift off at high pressure or low temperature. Put numbers to it in the ideal gas law calculator, or bend other equations by hand across our collection of physics playgrounds.

Where the ideal gas law breaks down

Two assumptions are buried in PV = nRT: that the molecules take up no space, and that they do not attract one another. Both are wrong, and usefully they are wrong in opposite directions. Attraction pulls a molecule back as it approaches the wall, so a real gas pushes a little less hard than the law says. Its own bulk does the reverse, stealing room from the container so the pressure runs high. Squeeze hard and the volume term wins; cool toward condensation and attraction wins.

The sliders will take you well outside where any of this holds. Put 5.00 mol into 1.0 L and the readout gives 33,258 kPa, some 328 atmospheres, with the molar volume collapsed from 22.71 to 0.20 L/mol — a spacing at which "point molecules with no forces" is simply a false description. The temperature slider bottoms out at 100 K, and this cylinder holds nitrogen, whose critical temperature is about 126 K. Below that, enough pressure liquefies it. Run 5.00 mol at 100 K in 1.0 L and the sim prints 4,157 kPa for something that would long since have condensed.

Notice what the pressure does not depend on. P = nRT/V contains no property of the molecule at all, so it returns the same answer whatever the gas is. The substance appears in one readout only: rms speed, 493 m/s at 273.15 K because nitrogen's molar mass is 28 g/mol. Reality is not so even-handed — carbon dioxide, whose molecules attract strongly, strays from ideal behaviour far sooner than helium does at the same pressure and temperature.

Finally, there is no clock. Move the volume slider and the pressure jumps straight to the value for whatever temperature you have set, quietly assuming the change is slow enough for the gas to shed the heat of compression. Compress a real gas fast and it has nowhere to put that energy, so it warms and the pressure overshoots the isothermal figure. That is why a bicycle pump gets hot near the end of the stroke — a correction quite separate from molecular size or attraction.

Where this is actually used

Press Reset and the sim loads 1.00 mol at 273.15 K in 22.711 L, giving exactly 100.00 kPa and a molar volume of 22.71 L/mol. That is not a tidy coincidence: 22.711 L/mol is the standard molar volume, the space one mole of any ideal gas occupies at 0 °C and 100 kPa. It is the number that lets a chemist collect a gas over water, measure nothing but its volume, and convert straight to moles.

Tyre pressures are quoted cold for a reason you can watch here. Hold 1.00 mol at 22.711 L and take the temperature from 273.15 K to 313.15 K, a cold morning to hot motorway rubber: the pressure goes from 100.00 to 114.64 kPa, close to fifteen per cent from a 40 K change. A tyre at 220 kPa on the gauge is about 320 kPa in absolute terms, which is the pressure the law cares about, so the same fraction adds nearly 50 kPa. Top a warm tyre up to the sticker figure and it is soft by morning.

A hot-air balloon is Charles's law carrying passengers. Click Charles, which pins the pressure at 100.00 kPa and lets volume follow temperature, then take T from 273.15 K to 546.30 K: the volume goes from 22.711 to 45.422 L, exactly doubled, so each cubic metre now holds half the mass. Real balloons work over a much smaller range, roughly 293 K outside against 373 K inside, which thins the air by about a fifth — some 0.26 kg of lift per cubic metre. A 2,500 m3 envelope therefore lifts around 640 kg: envelope, basket, burner and three people.

Frequently asked questions

What is the ideal gas law?

The ideal gas law, PV = nRT, links the pressure, volume, amount (in moles) and absolute temperature of a gas, with the gas constant R = 8.314 J/(mol·K). It rearranges to P = nRT/V.

Why must the temperature be in kelvin?

Because the law uses absolute temperature. Doubling the temperature doubles the pressure only in kelvin (200 K to 400 K); it does not work in Celsius, since 20 °C to 40 °C is really 293 K to 313 K — a rise of under ten percent.

What are Boyle's, Charles's and Gay-Lussac's laws?

They are special cases of PV = nRT. Holding n and T gives Boyle's law (P inversely proportional to V); holding n and P gives Charles's law (V proportional to T); holding n and V gives Gay-Lussac's law (P proportional to T).

When does a real gas stop obeying the ideal gas law?

At high pressure or low temperature, near where it condenses to a liquid, because real molecules take up space and attract one another — effects the ideal model ignores.

What is the rms speed the simulator shows?

It is the root-mean-square molecular speed, sqrt(3RT/M) — the typical speed of a molecule at that temperature. It depends only on the temperature and the gas's molar mass, which is why moving the volume slider leaves it unchanged at 844 m/s while the pressure swings from 665.16 kPa to 33,258 kPa.

References & formula source

  • Halliday, Resnick & Walker — Fundamentals of Physics, Chapter 19 (The Kinetic Theory of Gases).
  • Young & Freedman — University Physics with Modern Physics, §18.1 (Equations of State; the Ideal-Gas Equation).
  • R. Nave — HyperPhysics, Georgia State University, "Ideal Gas Law" section.
  • Further reading: Ideal gas law — Wikipedia