NetLogo banner

 Contact Us

 Modeling Commons

 User Manuals:


NetLogo Models Library:
Curricular Models/Connected Chemistry

(back to the library)

Connected Chemistry 6 Volume and Pressure

[screen shot]

If you download the NetLogo application, this model is included. (You can also run this model in your browser, but we don't recommend it; details here.)


This model explores the relationship between the volume of a gas container and the pressure of a gas in that container. 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, the gas container has an adjustable volume. The number of particles can also be changed. Temperature is held constant throughout the model. In this model, students can also look at the relationship between the number of particles and pressure, as well as the volume of the gas container and pressure. Alternatively, they can change both the number of particles and the volume of the gas container, and see how these combined changes affect pressure. These models have been adapted from the model GasLab Pressure Box.


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," reflecting its direction but keeping its speed.


Buttons: SETUP - sets up the initial conditions set on the sliders. GO/STOP - runs and stops the model. MOVE WALL - allows the user to move the orange wall to the right of its current location (so as to permit adiabatic free expansion of the gas), by clicking with the mouse in the view. If the model is currently running (i.e., if GO/STOP is depressed), clicking on MOVE WALL will stop it. To continue running the model after moving the wall, press GO/STOP again.

Sliders: NUMBER - sets the number of gas particles in the box when the simulation starts. INITIAL-WALL-POSITION helps adjust the initial volume by setting the location of the orange box wall.

Switches: LABELS? turn particle id labels on or off

Choosers: SHOW-SPEED-AS-COLOR? allows you to visualize particle speed using a color palette. - The "blue-green-red" setting shows the lower half of the speeds of the starting population as blue, and the upper half as red. - The "violet shades" setting shows a gradient from dark violet (slow) to light violet (fast). - The "all green" setting shows all particles in green, regardless of speed. - The "custom color" setting, referenced in the Pedagogica version of this model, allows the user to modify the color of one or more particles, without having to worry that the particles will be recolored with each tick of the clock (as is the case for the other color options).

Monitors: CLOCK - number of clock cycles that GO has run. VOLUME - the volume of the box. Volume is computed based on what it would be using the 3D view. The can be visualized as the inner gas volume (yellow walls and orange wall) that is 1 patch width deep in the z direction.

PRESSURE - the total pressure in the box. WALL HITS PER PARTICLE - the average number of wall hits in one clock tick

Plots: - VOLUME VS. TIME: plots the volume of the gas container over time. Volume is computed based on what it would be using the 3D view. The can be visualized as the inner gas volume (yellow walls and orange wall) that is 1 patch width deep in the z direction. - PRESSURE VS. TIME: plots the average gas pressure inside of the box over time.

  1. Adjust the INITIAL-NUMBER and/or the INITIAL-WALL-POSITION slider.
  2. Press the SETUP button
  3. Press GO/STOP and observe what happens.
  4. Press MOVE WALL. The particle motion will pause momentarily.
  5. Then move your cursor to a spot inside the WORLD & VIEW, to the right of the current position of the orange wall. Click on this spot and the wall will move and the particle motion will resume.
  6. Observe the relationship between the Volume vs. Time graph and Pressure vs. Time graph.


When you move the wall, the faster particles move toward it first. Does this type of diffusion occur in reality?

There are combinations of NUMBER of particles and volumes for the container that yield the same pressure. What do you notice about the density of the gas particles in these situations: e.g. double the number of particles and double the volume?


Find a mathematical model that related volume to pressure by recording and graphing various volume and pressure values in the model.

What combination of volume and number of particles gives the highest pressure?


Add an external force on the orange wall and a mass for the wall. Allow it to move related to the forces that are on it from particle hits and the external force.

Model two gas chambers side both filled with gases side by side, with a movable wall in between.

Add a heated/cooled wall on the left side of the model. If you combine this with an external force on the orange wall, what happens to the motion of the wall if you alternatively heat and cool the left wall?


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 2005 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

(back to the NetLogo Models Library)