Ideal Gas Law Simulator
See the ideal gas law come alive. Set the temperature, volume, and amount and watch the pressure and the gas particles respond through PV = nRT.
Offline ● Works without internet after loading After the first page load, no network connection is needed.Drag the piston to change the volume
This simulation needs a modern browser with canvas support. The measurements and formula below still describe the physics.
Controls
Live measurements
Graph
Formula
P = n R T / V
Type your own values to solve the formula. The simulation follows along.
- P Pressure
- —
Observations
What's happening
Real-world examples
Bike pump
Push the piston in and the same gas in a smaller volume climbs in pressure, and the air warms up.
Sealed can in the sun
Heat a fixed volume of gas and the pressure rises, which is why aerosol cans warn against heat.
Hot air balloon
Warming the gas lowers its density at fixed pressure, so the balloon floats upward.
Boyle isotherm
At fixed temperature, halving the volume doubles the pressure, tracing the P-V hyperbola on the graph.
Common Questions
What is the ideal gas law?
The ideal gas law states that PV = nRT: pressure times volume equals the amount of gas in moles times the gas constant R times the absolute temperature. Rearranged, the pressure is P = nRT / V. It ties together the four things that describe a gas, and it holds well for real gases at everyday pressures. The simulator runs it live, so changing any slider updates the pressure instantly.
Why does compressing a gas raise its pressure?
Squeezing the same amount of gas into a smaller volume packs the particles closer, so they strike the walls more often. Because P = nRT / V, halving the volume at fixed temperature doubles the pressure. This inverse link between pressure and volume is Boyle's law, and you can trace it as the P-V hyperbola on the graph while dragging the piston.
Why does heating a sealed gas raise its pressure?
Heating the gas makes the particles move faster, so they hit the walls harder and more often. At fixed volume and amount, pressure is proportional to the absolute temperature, so doubling the kelvin temperature doubles the pressure. That is why a sealed can left in the sun can burst. The simulator shows the particles speeding up as you raise the temperature.
Do I use celsius or kelvin in the ideal gas law?
Always kelvin. The ideal gas law needs an absolute temperature, where zero means no thermal motion, so you must convert celsius to kelvin by adding 273.15 first. Using celsius gives nonsense, including negative or zero pressures. The simulator works in kelvin throughout to keep the relationship correct.
What causes gas pressure?
Pressure comes from countless particle collisions with the container walls, not from the weight of the gas. Each impact gives the wall a tiny push, and the collective effect over the whole surface is the pressure. More particles, faster particles, or a smaller box all increase the collision rate and therefore the pressure, exactly as PV = nRT predicts.
Does the simulator send my data anywhere?
No. Everything runs in your browser with a canvas and simple arithmetic. Nothing is uploaded or stored remotely, and the simulator keeps working offline after the page loads.