Murray State University · Part four · Example projects

Ideal Gas Law Simulator

Murray State University
Demo 17 of 17 · Part four · Physics · Stage 1

Pressure is a tally of wall hits

Double the number of particles in the same box at the same temperature. What does the pressure do?

Before you start. The box holds tiny particles that fly in straight lines and bounce off the walls. Pressure is the push the walls feel: this page measures it by adding up the momentum every bounce hands to a wall, per second, per unit of wall. Nothing about the gas law is typed into the simulation — the gauge reads what the particles actually do.

Predict

Twice the particles, same box, same temperature: does the pressure double, stay put, or rise by less?

Try

Commit to a prediction, then press Run: double the particles and watch the pressure gauge before and after.

Takeaway

Pressure is the running tally of wall hits: twice the particles means twice the hits per second, and twice the pressure.

Scripted the guided experiment for this stage

Your prediction Commit before you run. The experiment stays locked until you do, and the list locks while it runs — the commitment is the point.

The experiment measures for a few seconds, makes one change, and measures again.

Live every number here is measured from the particles on this device

Gas in a box

2× time
Particles N–
Temperature T–
Area A–
Pressure, measured–from wall hits
Pressure, predicted N·T / A–ratio –
Wall hits / s–

The thermostat nudges every speed toward the target temperature, like a water bath. Switch it off and the gas keeps whatever energy it has — then push the piston in and watch T.

Live the bars are the particles now; the curve is the 2D Maxwell distribution at the measured T

How fast are they going?

Bars: how many particles are at each speed right now. Line: the shape a gas at this temperature settles into once the particles have collided enough. Press Start all at one speed to watch it get there.

Check yourself

You doubled the particles and the measured pressure roughly doubled. Why?

Guidehow to use this demo

One question across four stages: where does gas pressure come from, and how far does P·A = N·T get you?

Where this sits: an AI-built classroom tool from Part four. The gas law is never typed into the simulation — pressure is measured from the particles, and the law is a prediction the gauges test.

  1. Add particles. Commit to a prediction, press Run: double the particles, and read the pressure gauge before and after.
  2. Heat it. Same routine with Run: double the temperature; watch the speed histogram widen.
  3. Squeeze it. Run: halve the box with the thermostat on; then switch the Thermostat off and drag the Piston yourself.
  4. Test the law. Run: grow the particles, then plot the law with Sweep the box, Sweep temperature and Sweep particle count.

Getting around

The four tabs switch stages; the box and its controls come with you. Details opens the formula, assumptions and sources for the current stage. Guide reopens this card; Settings holds Open Presenter Notes, Presentation mode and Reset.

Time

About fifteen minutes for the four guided experiments: each one measures for a few seconds, changes one thing, and measures again. A sweep in stage 4 takes ten to fifteen seconds.

Settings

Presenter notes

The printable presenter guide, on screen: timings, the beats to hit, the numbers this model produces, and the misconceptions to name.

Presentation mode

Scales the whole page up one notch for projecting to a room and puts a Notes button in the header.

Reset

Back to the start: stage 1, a fresh gas of 240 small particles at 300 in a full-width box with the thermostat on, no predictions, no findings, the sweep chart cleared, and every disclosure closed. The page does not reload, so nothing flashes on a projector. Presentation mode stays as you set it.

DetailsAdd particles

What is live

The pressure gauge reads the walls, not a formula

Live particle motion, wall hits, pressure, temperature, the histogram

Every particle's position and velocity is advanced on this device many times per frame. When one reaches a wall it bounces, and the momentum it hands over is added to that wall's tally. The pressure gauge is that tally, per second, per unit of wall length. Temperature is computed from the particles' kinetic energy. Nothing is looked up and nothing about the gas law is built in.

Scripted the box, the starting gas and the guided experiment

A 100 × 60 box, 240 particles at a temperature of 300 and a particle radius of 0.35 are chosen teaching values. The guided experiment is a fixed routine: measure for four seconds of simulated time, double N, wait a moment, measure again.

Reasoned the ± band under the pressure reading

A gauge on a few hundred particles is noisy: the band is the reading divided by the square root of the number of wall hits counted, a rough rule of thumb for a random count, not a confidence interval. More particles, more time, or a smaller box all steady it.

How it works

P = (momentum handed to the walls) ÷ (time × total wall length)

A particle of mass 1 moving at speed v⊥ toward a wall leaves with the same speed the other way, so the wall receives momentum 2v⊥. Add every such hit over a stretch of time, divide by that time and by the length of wall, and you have a pressure. Doubling the number of particles doubles the number of hits per second while leaving each hit the same, so the pressure doubles.

Assumptions and simplifications

  • Two dimensions. The box is flat, so "pressure" is force per unit length of wall and "volume" is area. Every relationship the stages find holds in 3D too; only the constants change.
  • Reduced units. Every particle has mass 1 and Boltzmann's constant is 1, so temperature is half the mean squared speed and the gas law reads P·A = N·T with no constant in it. The default temperature of 300 is chosen to look like room temperature in kelvin; it is not kelvin.
  • Perfectly elastic walls at rest (the piston aside), which hand back exactly the speed they receive.
  • A finite, noisy gauge. Real gases have ~1023 particles and a gauge that averages over all of them; this box has a few hundred, so the reading wanders. The running average smooths about one second of simulated time.
  • The animation runs at 2× simulated time by default, adjustable from the Speed switch, so that an experiment finishes in a few seconds.

Sources

Boundary: this is an idealized two-dimensional teaching model built to make one mechanism visible. It does not reproduce any real gas's numbers, and its temperature and pressure scales are the model's own.

Presenter Notesthe printable guide, on screen

Presenter guide · Kinetic-theory simulator: particles in a box

Ideal Gas Law Simulator

Demo 17 of 17 · Part four, Example projects · About 15 minutes for the four guided experiments, plus 5 for the sweeps

You need: index.html open in any modern browser, on a projector or on each student's phone. No network, no install, no accounts. Nothing is fetched at runtime, so it works with the wi-fi off.

Learning goals

One per stage, in the learner's own words — these are the four Takeaway cards on screen, verbatim. If a student can say these four things and point at the gauge reading that shows each, the demo has done its job.

  1. Pressure is the running tally of wall hits: twice the particles means twice the hits per second, and twice the pressure.
  2. Temperature is the particles' average kinetic energy, and pressure rises in step with it: hotter particles hit harder and more often.
  3. At fixed temperature, pressure × area stays constant: half the room means every wall is hit twice as often.
  4. The ideal gas law is what tiny, non-interacting particles do on average. It holds here to within the noise, and drifts as soon as the particles take up real room.

Where this sits on the path

An AI-built classroom tool from Part four. Its distinctive move is that the gas law is never typed into the simulation: pressure is measured by adding up the momentum the walls receive, temperature is computed from the particles' kinetic energy, and P·A = N·T is a prediction the gauges test. It does not depend on any earlier demo; the habit it shares with the rest of Part four is naming the boundary between what is measured and what is claimed.

One question for the session

Where does gas pressure come from, and how far does P·A = N·T get you?

"Every number on this screen is measured from those dots. Nobody told the box the gas law. We are going to change one thing at a time and see whether the gauge does what the law says it should — and then we are going to break the law on purpose."

Units students see

LabelMeaning in this activity
NNumber of particles in the box (10 to 600; 240 by default).
TTemperature: half the mean squared speed, in the model's units. 300 by default because it reads like room temperature in kelvin. It is not kelvin.
ABox area, width × 60. The box is two-dimensional, so "volume" is area.
PPressure: momentum handed to the walls, per second, per unit of wall length. Two-dimensional pressure is force per length.
ZThe ratio P·A / (N·T). Exactly 1 when the ideal gas law holds.
rParticle radius, 0.35 to 1.0. At 0.35 the particles cover about 1.5% of the box; at 1.0, about 13%.
P · A = N · T   (mass = 1, kB = 1, two dimensions)

Run of show

Every stage follows the same routine: read the question, commit to a prediction (the Run button stays locked until one is chosen), press Run, read the finding. The guided experiment measures for four seconds of simulated time, makes one change, settles, and measures again. At the default 2× speed that is about six real seconds. The numbers below are what the model produces at the defaults; a gauge on a few hundred particles wanders by a few percent run to run, and that is worth saying out loud.

StageBeatWhat the gauge showsSay
1 · Add particles
~4 min
Point at the walls flashing gold where they are hit. Ask for the prediction. Press Run: double the particles. P ≈ 12.4 → ≈ 24.8 (2.0×). T stays at 300. Wall hits/s roughly doubles, about 90 → 180. "Same speeds, same walls, twice the bodies. The walls are hit twice as often. That is all pressure is."
2 · Heat it
~4 min
Ask for the prediction; most rooms split between 2× and 4×. Press Run: double the temperature. Point at the histogram widening. P ≈ 12.4 → ≈ 24.8 (2.0×). Hits/s rise by about 1.4×, not 2×. T reads 600. "Doubling the temperature only made them √2 faster. √2 harder, √2 more often. √2 × √2 is 2."
3 · Squeeze it
~4 min
Press Run: halve the box with the thermostat on; watch the piston slide. Then switch the Thermostat off and drag the Piston in by hand. P ≈ 12.4 → ≈ 25 (2.0×) with T held at 300; P × A ≈ 74,000 both times. Thermostat off: T climbs past 500 as the piston moves. "Half the distance between walls, twice the hits. Now turn off the water bath and push: the moving wall kicks every particle it meets. That is why a bicycle pump gets warm."
4 · Test the law
~5 min + sweeps
Press Run: grow the particles. Then run Sweep the box small, grow the particles with the size slider, and run it again. Z ≈ 1.03 at r = 0.35 → Z ≈ 1.3 at r = 1.0. Sweep points sit on the diagonal when small, above it when big. "The law assumed the particles took up no room. Give them room and the space they fly through shrinks. This is the 'b' in van der Waals."
If a run comes out 1.9× or 2.1×: that is the finding, not a bug. Point at the ± band under the pressure reading and the hit count in the finding. Ask what would steady it (more particles, more time, a smaller box) and try one. A gauge on 240 particles is exactly as noisy as it looks.

Misconceptions to name

"Crowded particles push harder." Stage 1 and stage 3 both show T unchanged while P doubles. Each hit carries the same momentum; only the count changed. The temperature gauge is the evidence.
"Double the temperature, four times the pressure." Temperature is speed squared, so speeds rise by √2. The hits/s readout rising by about 1.4× while P rises by 2× separates the two factors on screen.
"Collisions between particles make pressure." Switch Collisions off in stage 1: the reading does not change. Particle–particle collisions swap momentum between particles and never touch a wall. (In stage 4 they matter for a different reason: they are what keeps big particles out of each other's space.)
"The law fails, so the simulation is wrong." Stage 4's drift is the point. The ideal gas law is an approximation with a stated assumption, and the gauge shows where the assumption stops holding.

What this model is, and is not

  • Two-dimensional, reduced units. Mass 1, kB = 1, temperature = half the mean squared speed. Every relationship the stages find holds in three dimensions too; only the constants change. The temperature and pressure scales are the model's own.
  • Hard discs with no attraction. The model shows one of the two real-gas corrections (excluded volume, the van der Waals b). The other, attraction pulling Z below 1 at low temperature, is not in it.
  • An idealized thermostat that rescales every speed toward the target, like a water bath with no lag.
  • A piston at one fixed speed, a sizeable fraction of the particles' speeds, so compression with the thermostat off heats more than a slow one would. The direction is right; the size depends on the piston speed.
  • The ± band under the pressure reading is a rule of thumb (reading ÷ √hits), not a confidence interval.
  • The excluded-area estimate in stage 4's Details is the authors' first-order derivation from the disc geometry, labelled as such. It gives direction and rough size, not a fitted equation of state.

Sources and attribution

These sources support the underlying physics; they do not endorse this activity. The 2D speed distribution, the moving-wall reflection rule and the excluded-area estimate are computed in the page's own model and checked by its node test suite, not quoted.

Ideal Gas Law Simulator · Bryant Harrison · Murray State University · Offline teaching model. Open index.html to run it. src/demo-guide.html is the canonical source of this document; the shipped presenter-guide.html, the PDF beside it, and the in-app presenter notes are all generated from it at build time.

Open the printable copy (presenter-guide.html) — the same document, laid out for Letter; the PDF beside it is a render of that file.

Bryant Harrison · Murray State University