NetLogo banner

NetLogo Publications
Contact Us

Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Farsi / Persian


NetLogo Models Library:
Sample Models/Chemistry & Physics/GasLab/Unverified

Note: This model is unverified. It has not yet been tested and polished as thoroughly as our other models.

(back to the library)

GasLab Heat Box

[screen shot]

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


This model is illustrates the relationship between temperature and pressure in a fixed volume gas container.

This model is one in a series of GasLab models. They use the same basic rules for simulating the behavior of gases. Each model integrates different features in order to highlight different aspects of gas behavior.

The basic principle of the models is that gas particles are assumed to have two elementary actions: they move and they collide --- either with other particles or with any other objects such as walls.

This model is part of the Connected Mathematics "Making Sense of Complex Phenomena" Modeling Project.


The particles are modeled as hard balls with no internal energy except that which is due to their motion. Collisions between particles are elastic.

  1. A particle moves in a straight line without changing its speed, unless it collides with another particle or bounces off the wall.
  2. Two particles "collide" if they find themselves on the same patch. In this model, two turtles are aimed so that they will collide at the origin.
  3. An angle of collision for the particles is chosen, as if they were two solid balls that hit, and this angle describes the direction of the line connecting their centers.
  4. The particles exchange momentum and energy only along this line, conforming to the conservation of momentum and energy for elastic collisions.
  5. Each particle is assigned its new speed, heading and energy.
  6. If a particle finds itself on or very close to a wall of the container, it "bounces" --- that is, reflects its direction and keeps its same speed.

As the walls of the box are heated, the sides of the walls will change color from a deep red (cool) to a bright red, to pink to a pale pink white (hot). The walls contain a constant heat value throughout the simulation. If ONE-SIDE? is set to ON, only the left wall will be heated, while the other three walls remain yellow.

The exact way particles gain energy from the walls of the box is as follows: 1. Particles check their state of energy. 2. They hit or bounce off the wall. 3. They find wall energy and recalculate their new energy. 4. They change their speed and direction after the wall hit.


Initial settings

  • NUMBER-OF-PARTICLES: number of particles within in the box


The SETUP button will set these initial conditions. The GO button will begin the simulation.

Other Settings

  • OUTSIDE TEMPERATURE: temperature of the outside of the box and the wall of the box.
  • ONE SIDE?: heats only the left wall if enabled. the other walls are colored yellow, and do not affect the energy of the particles that bounce into it.
  • COLLIDE?: Turns collisions between particles on and off.


  • PRESSURE: the pressure of the gas particles in the box
  • WALL HITS PER PARTICLE: number of times that each particle hit the walls
  • AVERAGE SPEED: average speed of the particles.
  • AVERAGE ENERGY: average kinetic energy of the particles.


  • SPEED COUNTS: plots the number of particles in each range of speed.
  • SPEED HISTOGRAM: speed distribution of all the particles. The gray line is the average value, and the black line is the initial average.
  • ENERGY HISTOGRAM: distribution of energies of all the particles, calculated as m*(v^2)/2.
  • PRESSURE VS. TIME: plots average pressure of the inside of the box over time.
  • TEMPERATURE VS. TIME: plots particle temperature inside the box over time and wall temperature over time.
  • WALL HITS PER PARTICLE: plots average wall hits per particle over time.


How does adding heat to the box walls affect the pressure?

How does adding heat to the wall affect the particle behavior?

How does the particle behavior or system response change with only one wall heated instead of all walls heated?

Does the system reach an equilibrium temperature faster when the wall is heated or cooled the same amount in comparison to the temperature of the particles?


Try to get the inside temperature to reach the outside temperature. Is this possible?

Try to increase the wall hits per particle.


Give the wall a mass and see how that affects the behavior of the model.

Close off the right side of the box. Create two valves on either side to the wall that allow the user to "spurt" particles into the chambers to see how number of particles affects pressure.

Vary the width and length of the box, does this effect how fast the particle temperature changes?


Notice how the collisions are detected by the turtles and how the code guarantees the same two particles do not collide twice. What happens if we let the patches detect them?


This model was developed as part of the GasLab curriculum ( and has also been incorporated into the Connected Chemistry curriculum (


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:


Copyright 2002 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 and associated activities and materials were created as part of the project: MODELING ACROSS THE CURRICULUM. The project gratefully acknowledges the support of the National Science Foundation, the National Institute of Health, and the Department of Education (IERI program) -- grant number REC #0115699. Additional support was provided through the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT -- NSF (REPP & ROLE programs) grant numbers REC #9814682 and REC-0126227.

(back to the NetLogo Models Library)