NetLogo banner

NetLogo Publications
Contact Us

Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Farsi / Persian


NetLogo Models Library:
Curricular Models/Connected Chemistry

(back to the library)

Connected Chemistry 4 Number and Pressure

[screen shot]

If you download the NetLogo application, this model is included. You can also Try running it in NetLogo Web


This model explores the relationship between the number of gas particles and the pressure of the gas in a container with a fixed volume. This model is part of the "Connected Chemistry" curriculum which explore the behavior of gases.

Most of the models in the Connected Chemistry curriculum use the same basic rules for simulating the behavior of gases. Each model highlights different features of how gas behavior is related to gas particle behavior.

In all of the models, gas particles are assumed to move and to collide, both with each other and with objects such as walls.

In this model, gas container (a bike tire represented by a box) has a fixed volume. The number of particles can be varied initially (with the INITIAL-NUMBER slider) and by "pumping up the bike tire" by adding particles through a valve on the left wall of the box.

This model helps students study the representations of gas pressure in the model and the dynamics of the gas particles that lead to increases and decreases in pressure. In this model, students can also look at the relationship between number of particles and pressure. In addition, one can follow the average number of wall hits in one model clock tick. When the particles hit the walls the walls change their color temporarily. These models have been adapted from the model GasLab Pressure Box.

These pressure models are part of a suite of models that students use to gain deeper insight on Gas Laws and particle behavior. In all of the Connected Chemistry Curriculum models, the same basic rules are used for expressing what happens when gas particles collide. Each model has different features in order to show different aspects of the behavior of gases.


Particles are modeled as perfectly elastic with no energy except their kinetic energy, due to their motion. Collisions between particles are elastic. Particles can be color-coded by speed with the SHOW-SPEED-AS-COLOR? chooser. For example, selecting red-green-blue makes colors slow particles in blue, medium-speed particles in green, and fast particles in red.

The exact way two particles collide is as follows: 1. Two turtles "collide" when they find themselves on the same patch. 2. A random axis is chosen, as if they are two balls that hit each other and this axis is the line connecting their centers. 3. They exchange momentum and energy along that axis, according to the conservation of momentum and energy. This calculation is done in the center of mass system. 4. Each turtle is assigned its new velocity, energy, and heading. 5. If a turtle finds itself on or very close to a wall of the container, it "bounces" -- that is, reflects its direction and keeps its same speed.


Buttons: SETUP - sets up the initial conditions set on the sliders. GO/STOP - runs and stops the model. ADD-PARTICLES - when pressed, releases NUMBER-TO-ADD particles into the box while the simulation is running.

Sliders: INITIAL-NUMBER - sets the number of gas particles in the box when the simulation starts. NUMBER-TO-ADD - the number of gas particles released into the box when the ADD-PARTICLES button is pressed.

Monitors: CLOCK - number of clock cycles that GO has run. NUMBER - the number of particles in the box. PRESSURE - the total pressure in the box. AVERAGE WALL HITS PER PARTICLE - the average number of wall hits in one clock tick

Plots: PRESSURE VS TIME - plots the pressure in the box over time. NUMBER VS TIME - plots the number of particles in the box over time. AVG. WALL HITS PER PARTICLE - plots the average wall hits per particle over time.

Initially, the particles are not moving. Therefore the initial pressure is zero. When the particles start moving, they repeatedly collide, exchange energy and head off in new directions, and the speeds are dispersed -- some particles get faster, some get slower. When they hit the wall they change their heading, but not their speed.

  1. Adjust the INITIAL-NUMBER slider.
  2. Press the SETUP button
  3. Press GO/STOP and observe what happens.
  4. Adjust the NUMBER-TO-ADD slider.
  5. Press the ADD PARTICLES button.
  6. Observe the relationship between the Number vs. Time graph and Pressure vs. Time.


Can you relate what you can see happening to the particles in the box with changes in pressure?

Why does the pressure change over time, even when the number of particles is the same? How long does it take for the pressure to stabilize?

What happens to the wall hits per particle when particles are added to the box?

In what ways is this model an incorrect idealization of the real world?

What is the relationship between particle number and pressure? Is it reciprocal, linear, quadratic, exponential?

Why is the average number of wall hits per particle, relatively constant, even if you change the number of particles in the model?


Try different settings, especially the extremes. Are the particles behaving in a similar way? How does this affect the pressure?

You can pen-down a particle through the command center or by using the turtle menus. What do you notice about a particle's path when there more and less particles in the box?

Build a mathematical model of number of particle vs. pressure, by recording and graphing data for various number and pressure combinations.


Add a way to adjust the volume of the container or the speed (or temperature of the particles).


See GasLab Models See other Connected Chemistry models.


This model is part of the Connected Chemistry curriculum. See

We would like to thank Sharona Levy and Michael Novak for their substantial contributions to this model.


If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

Please cite the NetLogo software as:

To cite the Connected Chemistry curriculum as a whole, please use:


Copyright 2004 Uri Wilensky.


This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at

This model was created as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227.

(back to the NetLogo Models Library)