A gas is just a swarm of tiny particles bouncing off the walls — and that picture is enough to explain PV = nRT. In this box the particles fly and rebound elastically; the tool reads their average kinetic energy as the temperature, measures the pressure from the momentum they hand to the walls, and takes the volume from a piston you can slide. Add particles, heat the gas or squeeze the box and watch the pressure respond — while the readouts show PV and NkT tracking each other and a live Maxwell–Boltzmann speed histogram broadens as it warms. The law is not built in; it emerges from the collisions. It all runs on your device.
Change T, slide the piston or add particles — watch P and the PV = NkT check
Particles N120
Temperature T300 K
RMS speed (arb.)—
Pressure P (arb.)—
Volume V (arb.)—
P·V—
N·k·T—
PV / NkT—
Speed distribution — bars are the live particles, the curve is Maxwell–Boltzmann
Change N, T or V — PV/NT does not budge. Temperature is the average kinetic energy of the particles; pressure is the force per unit area they deliver by hammering the walls; volume is the size of the box. Heat the gas and it strikes harder and more often, so pressure rises. Squeeze the box and each particle hits the walls sooner, so pressure rises again. But the ratio PV / (N·T) stays put — that constancy is the ideal gas law PV = NkT, and here it comes straight out of the bouncing, not from any formula written into the box.
Reading the simulation
What the flashing walls, the speed colours and the two matching readouts are telling you.
1
Pressure is the rate of wall collisions
Every time a particle strikes a wall it bounces back and hands the wall a kick of momentum — you see each kick as a white flash, and each wall glows brighter the harder the gas is hammering it. The Pressure P readout adds up all those kicks per second over the wall length. Add particles or heat the gas and the flashes come faster and the pressure climbs; there is no formula behind it, just the collisions being counted.
2
Raising T speeds the particles up
The particles are tinted by speed — blue for slow, magenta and warm red for fast — and the lower panel shows their full Maxwell–Boltzmann speed distribution as bars, with the theoretical curve drawn on top. Drag the Temperature up and the whole histogram broadens and slides to the right, and the RMS speed readout grows with the square root of T. Temperature simply is the average kinetic energy of this motion.
3
PV = NkT — squeeze V and P climbs
The P·V and N·k·T readouts sit side by side, and their ratio PV / NkT stays pinned near 1 no matter what you change. Slide the piston in to halve the Volume at fixed T and N and each particle reaches the walls twice as often, so the Pressure roughly doubles and the P·V product barely moves — that inverse trade is Boyle's law and a slice of the ideal gas law PV = NkT.
How It Works
Bouncing particles, three measured quantities, and a ratio that refuses to change.
1
Temperature is motion
The particles fly in straight lines and rebound elastically off the walls, never losing energy. The gas's temperature is nothing more than the average kinetic energy of that motion — hotter means faster. Drag the temperature slider and every particle is rescaled to match, so you can watch a cold, sluggish gas turn into a fast, hot one.
2
Pressure is collisions
Every time a particle strikes a wall it bounces back, handing the wall a kick of momentum. Add up all those kicks over a second and divide by the wall area and you have the pressure — measured here directly from the collisions, not assumed. More particles, faster particles, or a smaller box all mean more kicks per second and a higher pressure.
3
The law that emerges
Watch the P·V and N·k·T readouts as you change things. Double the temperature and the pressure doubles; add particles and it climbs; slide the piston in and it rises as the volume falls — yet P·V and N·k·T stay equal, so their ratio PV / NkT holds near 1. That constant is Boltzmann's constant in these units, and its steadiness is the ideal gas law PV = NkT appearing on its own from a box of bouncing balls.
What is the ideal gas law?
The ideal gas law is PV = nRT (equivalently PV = NkT), linking the pressure P, volume V, amount of gas n and absolute temperature T of a gas whose particles are treated as tiny, non-interacting, perfectly elastic balls. It says that for a fixed amount of gas the quantity PV/T is constant, so squeezing the gas raises its pressure and heating it raises the pressure too. This simulator lets you change the particle count, temperature and volume and watch PV/NT hold steady.
How does this simulator show PV = nRT?
Nothing here imposes the law — it emerges. The particles simply fly in straight lines and bounce elastically off the walls. Temperature is computed as their average kinetic energy, pressure is measured from the momentum they hand to the walls each second, and volume is the area of the box set by a piston. The readouts show PV and NkT side by side, and when you change the particle count, the temperature or the volume, the measured pressure adjusts so the two stay equal and PV / (NkT) holds at about 1 — which is exactly the ideal gas law.
How is temperature related to particle motion?
In the kinetic theory of gases, the absolute temperature is a measure of the average kinetic energy of the particles: the faster they move, the hotter the gas. Heating the gas speeds every particle up, so they hit the walls harder and more often, which raises the pressure, and the RMS speed grows in proportion to the square root of temperature. The second panel plots the live Maxwell–Boltzmann speed distribution: raise the temperature and the whole histogram broadens and shifts to higher speeds.
Why does compressing a gas raise its pressure?
Pressure comes from particles striking the walls. If you push the piston in to shrink the volume while keeping the temperature and number of particles the same, each particle has less distance to travel between walls, so it strikes them more often. More collisions per second means more force per unit area — higher pressure. That is why, at constant temperature, pressure and volume are inversely related, the relationship known as Boyle's law and a special case of the ideal gas law.
A ready-to-assign lab using the simulation above. Free to use — nothing to install or sign up for, and no student data leaves the browser.
High school, College10–20 minInteractive simulation
Learning objectives
Relate pressure, volume, temperature, and amount of gas.
Connect macroscopic gas behavior to molecular motion.
Apply the ideal gas law.
Variables to change
Temperature
Volume
Number of particles
Pressure
Procedure
Hold temperature fixed and reduce the volume; watch the pressure (Boyle’s law).
Hold volume fixed and raise the temperature; watch the pressure (Gay-Lussac’s law).
Add more particles at fixed volume and temperature; watch the pressure.
Observations
Record how pressure responds to each change, keeping the other quantities fixed.
Questions
At constant temperature, what happens to pressure when volume decreases?
At constant volume, what happens to pressure when temperature rises?
Write the ideal gas law.
Microscopically, why does raising temperature raise pressure at fixed volume?
Why must temperature be in kelvin for these relationships?
Explanation
The ideal gas law PV = nRT ties pressure, volume, temperature, and amount together. Microscopically, pressure comes from molecular collisions with the walls; hotter gas means faster molecules and more forceful, frequent collisions.
Answer key (for instructors)
1. Pressure increases — P and V are inversely proportional (Boyle’s law).
2. Pressure increases in proportion to absolute temperature (Gay-Lussac’s law).
3. PV = nRT (or PV = NkT).
4. Molecules move faster and strike the walls harder and more often, increasing force per area.
5. The gas laws are proportional to absolute temperature; kelvin starts at absolute zero, where ideal-gas pressure would be zero.
Put the Ideal Gas Law Simulator on your own page — free, no sign-up, no watermark. It runs entirely in your visitors' browsers. Copy the snippet and paste it into your page's HTML.
The credit line under the widget links back to LK Forge — please keep it so others can find it too.