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 Atmosphere

[screen shot]

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


In this model, a gaseous atmosphere is placed above the surface of a "planet", represented by a yellow line at the bottom of the world.

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.


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 the surface of the planet, it "bounces" --- that is, reflects its direction and keeps its same speed.

In this model, the effect of gravity is calculated as follows: every particle is given additional velocity downward during each clock tick, as it would get in a gravitational field. The particles bounce off the "ground". They disappear if they reach the top of the world, as if they had escaped the planet's gravitational field. The percentage of lost particles is shown in the PERCENT LOST PARTICLES monitor.


Initial settings: - NUMBER-OF-PARTICLES: number of gas particles - INIT-PARTICLE-SPEED: initial speed of each particle - PARTICLE-MASS: mass of each particle - GRAVITY-ACCELERATION: value of the gravitational acceleration

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. - TRACE?: Traces the path of one of the particles.

Monitors: - AVERAGE SPEED: average speed of the particles. - PERCENT FAST, PERCENT MEDIUM, PERCENT SLOW: percentage of particles with different speeds - fast (red), medium (green), and slow (blue). - PERCENT LOST PARTICLES: percentage of particles that have disappeared at the top edge of the world. - CLOCK (inside the View): number of ticks that have run.

Plots: - 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, using m*(v^2)/2. - DENSITY HISTOGRAM: shows the number of particles at each 'layer' of the atmosphere, i.e. its local density. - ENERGY VS. HEIGHT: shows the mean energy of the particles at each "layer" of the atmosphere.


Try to predict what the view will look like after a while, and why.

Watch the gray path of one particle. What can you say about its motion? Turn COLLIDE? off and see if there are any differences.

Watch the change in density distribution as the model runs.

As the model runs, what happens to the average speed and kinetic energy of the particles? If they gain energy, where does it come from? What happens to the speed and energy distributions?


What happens when gravity is increased or decreased?

Change the initial number, speed and mass. What happens to the density distribution?

What factors affect how many particles escape this planet?

Does this model come to some sort of equilibrium? How can you tell when it has been reached?

Try and find out if the distribution of the particles in this model is the same as what is predicted by conventional physical laws. Is this consistent, for instance, with the fact that high-altitude places have lower pressure ( and thus lower density of air)? Why are they colder?

Try making gravity negative.


Find a way to plot the relative "temperature" of the gas as a function of distance from the planet.

Try this model with particles of different masses. You could color each mass differently to be able to see where they go. Are their distributions different? Which ones escape most easily? What does this suggest about the composition of an atmosphere?

The fact that particles escape when they reach a certain height isn't completely realistic, especially in the case when the particle was about to turn back towards the planet. Improve the model by allowing particles that have "escaped" to re-enter the atmosphere once gravity pulls them back down. How does this change the behavior of the model? Keeping track of actual losses (particles which reached the escape velocity of the planet) would be interesting. Under what conditions will particles reach escape velocity at all?

Make the "planet" into a central point instead of a flat plane.

This basic model could be used to explore other situations where freely moving particles have forces on them --- e.g. a centrifuge or charged particles (ions) in an electrical field.


Because of the influence of gravity, the particles follow curved paths. Since NetLogo models time in discrete steps, these curved paths must be approximated with a series of short straight lines. This is the source of a slight inaccuracy where the particles gradually lose energy if the model runs for a long time. The effect is as though the collisions with the ground were slightly inelastic. The inaccuracy can be reduced by increasing vsplit, but the model will run slower.


This model is part of the GasLab suite and curriculum. See, in particular, the models "Gas in a Box" and "Gravity Box", which is a modified version of the "Atmosphere" model, with a ceiling on the atmosphere.


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