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

(back to the library)

GasLab Adiabatic Piston

[screen shot]

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


This model simulates the behavior of gas particles in a box with a movable piston. The piston has weight which pushes it down, and the gas particles push upward against the piston when they collide with it. "Adiabatic" means "without loss or gain of heat". In this model, no heat energy (such as heat loss through the walls of the box) is added to or removed from the system.

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 (see the model "GasLab Gas in a Box" for an introduction to the GasLab collection).


The basic principle of all GasLab models is the following algorithm (for more details, see the model "GasLab Gas in a Box":

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 (NetLogo's View is composed of a grid of small squares called patches). In this model, two particles 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 or the piston, it "bounces" --- that is, reflects its direction and keeps its same speed.

The piston has both potential energy (due to gravity) and kinetic energy (from its motion).

Each particle bounces off the sides and the bottom of the box without changing speed. When it hits the piston, however, its speed does change. If the piston is moving upward at that moment, the particle bounces off at a slightly smaller speed. If the piston is moving downward, it gives the particle a kick and the particle speeds up. This is the process by which the energy of the gas is changed by the motion of the piston.

The piston also changes speed with each collision. The change is not large, because the piston is much heavier than each particle; but the accumulated effect of many particle collisions is enough to hold the piston up.

Gravity is incorporated in this model as a constant downwards acceleration on the piston. In order to make the model simpler, this model doesn't include the effect of gravity on the particles. See the "GasLab Atmosphere" and "GasLab Gravity Box" models if you are interested in the effect of gravity on the particles.

Pressure is calculated by adding up the momentum transferred to the walls of the box and the piston by the particles when they bounce off. This is averaged over the surface area of the box to give the pressure.


Initial settings: - NUMBER-OF-PARTICLES: number of gas particles. - INIT-PARTICLE-SPEED: initial speed of the particles. - PARTICLE-MASS: mass of each particle. - BOX-HEIGHT: height of the container (percentage of the world-height). - BOX-WIDTH: width of the container (percentage of the world-width). - PISTON-MASS: mass of the piston, in the same "units" as the particle's mass.

The SETUP button will set the initial conditions. The GO button will run the simulation.

Other settings: - COLLIDE?: Turns collisions between particles on and off.

Monitors: - AVERAGE SPEED: average speed of the particles. - AVERAGE ENERGY: average kinetic energy per particle of the gas. - TOTAL ENERGY: total energy of the particles. - PISTON HEIGHT: piston's height above the bottom of the box. - PISTON VELOCITY: speed of the piston (up is positive). - PISTON POTENTIAL ENERGY: potential energy of the piston, due to gravity. - PISTON KINETIC ENERGY: kinetic energy of the piston, due to its motion. - PISTON TOTAL ENERGY: sum of potential and kinetic energy of the piston. - SYSTEM ENERGY: sum of particles' and the piston's total energy.

Plots: - PISTON HEIGHT VS. TIME: measured up from the bottom of the box. - PRESSURE VS. TIME: average pressure of the particles. - ENERGY OF PARTICLES, PISTON, AND TOTAL ENERGY: in terms of energy per particle. The piston's energy is both kinetic (motion) and potential (height).


Watch all the plots and notice how they change in relation to each other.

Does the piston reach an equilibrium position (as this might take a long time, so you could turn the display off to speed the process up)? What is the pattern of its motion before that? Why doesn't it keep oscillating, like a bouncing ball, if all of the collisions are elastic?

Would you expect that the pressure would settle at a stable value? What would determine it?

The energy of the gas changes as the piston moves up and down. How are the two related? Where does the energy come from and where does it go?

Can you infer what is happening to the temperature of the gas as the piston moves?

Explain in physical terms and in terms of the model's rules how the piston heats up the gas by pushing downward and cools it down when moving upward.

Gravity only affects the piston in this model. Does this make sense? If gravity were made to affect the particles as well would that significantly change the behavior of the model? What if you were to think of the downwards acceleration of the piston as the atmospheric pressure pushing down from above the piston. Would this make more sense? Would you need to make any changes to the behavior of the model to have the force be atmospheric pressure instead of gravity? Why or why not?

You can change the coloring of the particles while the model is running by moving the INIT-PARTICLE-SPEED slider. This will change the meaning of the colors, but not the relative meanings of the colors or the behavior of the model.


Change the initial particle mass and particle speed. How do these variables affect the piston's motion and its equilibrium position? Adjust the piston's mass to keep it inside the box.

Change the piston mass, leaving the gas alone. What happens to all of the volume, pressure, and energy? Note: if you do this while the model is running, the piston energy changes suddenly. Why is this?

In this simulation, the piston and the particles exchange energy on every collision. The model treats the wall collisions differently. Is this legitimate? How is a piston different from a wall?

In this adiabatic system, neither pressure, volume, nor temperature are constant, so pressure and volume are not simply inversely proportional. In fact it turns out that for two different states,

> (P'/P) = (V/V')^gamma,

where gamma depends on the number of degrees of freedom of the particles. In this two-dimensional case, gamma = 2. Confirm that this is roughly true by changing piston-mass (hence pressure) and noticing its effect on piston height (hence volume).


Add a heater in the box that changes the temperature of the gas. What would happen if the gas were heated and nothing else were changed?

Combine this with the "Two Gas" model such that there are gases pushing on both sides of a piston, instead of gravity against a single gas.

Give the piston the ability to store thermal energy, so that it heats up instead of moving when the particles hit it.


Look at the other GasLab models, especially "GasLab Isothermal Piston" and "GasLab Moving Piston".


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

Wilensky, U. (1999). GasLab--an Extensible Modeling Toolkit for Exploring Micro- and Macro- Views of Gases. In Roberts, N. , Feurzeig, W. & Hunter, B. (Eds.) Computer Modeling and Simulation in Science Education. Berlin: Springer Verlag. (this is the best and most detailed source)

Wilensky, U. & Resnick, M. (1999). Thinking in Levels: A Dynamic Systems Perspective to Making Sense of the World. Journal of Science Education and Technology. Vol. 8 No. 1

Wilensky, U., Hazzard, E. & Froemke, R. (1999). An Extensible Modeling Toolkit for Exploring Statistical Mechanics Proceedings of the Seventh European Logo Conference - EUROLOGO'99, Sofia, Bulgaria.


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 1997 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 project: CONNECTED MATHEMATICS: MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL MODELS (OBPML). The project gratefully acknowledges the support of the National Science Foundation (Applications of Advanced Technologies Program) -- grant numbers RED #9552950 and REC #9632612.

This model was developed at the MIT Media Lab using CM StarLogo. See Wilensky, U. (1993). Thesis - Connected Mathematics: Building Concrete Relationships with Mathematical Knowledge. Adapted to StarLogoT, 1997, as part of the Connected Mathematics Project. Adapted to NetLogo, 2002, as part of the Participatory Simulations Project.

This model was converted to NetLogo 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. Converted from StarLogoT to NetLogo, 2002.

(back to the NetLogo Models Library)