NetLogo banner

 Contact Us

 Modeling Commons

 User Manuals:


NetLogo User Community Models

(back to the NetLogo User Community Models)

Chemical Equilibrium elaborated

by Russ Maurer (Submitted: 03/23/2005)

[screen shot]

Download Chemical Equilibrium elaborated
If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".

(You can also run this model in your browser, but we don't recommend it; details here.)


This is a modification to the "Netlogo chemical equilibrium model" by Uri Wilensky. New features that have been added to the basic model include the following:

1. The individual molecules have a property designated ke (kinetic energy). During setup, the ke is assigned as a random-normal variable as described below. The ke can change as the simulation runs.

2. The system as a whole has a property designated temperature, calculated as the mean of the kinetic energies. In real life, temperature (of an ideal gas) is proportional to mean kinetic energy. Since we are using a proportionality constant of one, the energy and temperature should not be interpreted in conventional units.

During setup, the user sets the initial temperature with a slider. The ke's are then assigned as random numbers from a normal distribution with mean = initial temperature and SD = .4 * initial temperature. (This approximates the Maxwell distribution, albeit imperfectly.) If, as usually happens, the random numbers do not have precisely the desired mean, all the ke's are adjusted up or down by the same amount to obtain the desired mean. A graph displays the distribution of kinetic energies as a histogram.

3. Both the forward and reverse reactions are assigned an activation energy (which may be, and usually are, different), set by the user with sliders. When molecules of the correct colors collide, they can react only if their combined ke exceeds the activation energy. By setting temperature low relative to the activation energy, the frequency of the reaction will be decreased because many collisions will have too little energy.

4. Both the forward and reverse reactions are assigned another characteristic, which I've labeled "difficulty". Chemists will recognize this as the more familiar orientation factor. Most collisions fail because the molecules are not oriented properly to break old bonds and form new ones. The difficulty factor is used by the simulation as an attenuator. If the factor is set to 10, for example, then every time you have a potential reaction (right colors, enough kinetic energy), a random drawing is held, with a 1 in 10 chance of success, to see whether the reaction will be allowed to take place. The higher the difficulty setting, the lower the chances.

5. The simulation has a toggle switch called hold-temp. If this switch is ON, it is similar to conducting a real reaction in a temperature-controlled environment. Any heat produced or absorbed by the reaction is transferred to/absorbed from the environment and the temperature of the system remains constant. If the switch is OFF, it is similar to running the reaction in an insulated environment. In this case, heat changes are retained within the system, causing the temperature to change. The simulation keeps track of the energy changes as reactions occur. At the end of each turn of the simulation, the new temperature is calculated and new kinetic energies are assigned to all molecules (whether they participated in a productive collision or not), using the same procedure as during initial ke assignment in setup.

6. I've created "new" commands to facilitate playing with disturbances to equilibrium. These are entered in the command center (while the simulation is running or paused, but I think paused is easier to digest because you can take time to predict the effect, then restart the simulation and see if you were right). These commands all take a number as an argument (100 just for illustration purposes):

newbl 100 changes the number of blue molecules to 100
newbr 100 changes the number of brown molecules to 100
newg 100 changes the number of green molecules to 100
newy 100 changes the number of yellow molecules to 100
newt 100 changes the temperature to 100 (can be used regardless of the hold-temp toggle)

7. Several additional graphs and monitors have been added to track new features.

The rate graph tracks the average number of forward reactions per cycle (blue line) and the average number of reverse reactions per cycle (red line). For the first twenty turns of the simulation, it averages the reactions from all the turns since the beginning of the simulation; after that it averages the most recent 20 turns.

The temperature graph shows the temperature (average ke) over time.

The reaction quotient graph shows the evaluation of the equilibrium constant expression [GR][BR]/([BL][YE]). At equilibrium, this value should be independent of the initial concentrations, but is sensitive to temperature, activation energies, and difficulty settings.

The ke distribution graph shows the initial distribution of kinetic energy (black line) as well as the current distribution (blue line). Note that as temperature increases, the distribution broadens; conversely, it narrows as temperature goes down.


Russ Maurer
Hawken School
PO Box 8002
Gates Mills, OH

Please send me your feedback or suggestions!

The following is the description of the original model by Uri Wilensky:


This project shows how a simple chemical system comes to different equilibrium states depending on the concentrations of the initial reactants. Equilibrium is the term we use to describe a system in which there are no macroscopic changes. This means that the system "looks" like nothing is happening. In fact, in all chemical systems microscopic processes continue but in a balance that yields no changes at the macroscopic level. This model simulates two simple reactions of four molecules.

The reactions can be written A + B yields C + D. And at the same time, of course, C + D yields A + B.

A classic real-life example that would illustrate such reactions is the reactions of carbon monoxide with nitrous dioxide to produce carbon dioxide and nitrous monoxide. The reverse is also possible. All the reactants are gases. We could watch such an equilibrium system because NO2 is a reddish colored gas which is visible. However, the combining of nitrous dioxide (NO2) with carbon monoxide (CO) results in the colorless products nitrous monoxide (NO) and carbon dioxide (CO2), and so the system loses its reddish color. And yet, not all the color is lost. Ultimately the system comes to equilibrium with some of the "reactants" and some of the "products" present.

How much "reactant" and "product" a system ends up with depends on a number of factors. The inherent kinetics of the reaction are of vital concern: For instance, some reactions tend to go in a particular direction because energy is released in that direction. A system's equilibrium is also affected by the concentrations of the reactants -- this is modeled here -- and by the system's temperature.


As stated above, this model simulates a chemical system of four different molecules. They are represented on the graphics screen as turtles of four different colors. In this simulation, yellow molecules react with blue molecules to produce brown molecules and green molecules.

The model is setup by first adjusting the YELLOWMOLS and BLUEMOLS sliders and pushing the SETUP button. YELLOWMOLS sets how many yellow molecules the simulation starts with, while BLUEMOLS sets how many blue molecules the simulation starts with.

The GO button sets the simulation in motion. Molecules move randomly and react with each other, changing color to represent rearrangement of atoms into different molecular structures. The system soon comes into equilibrium.

Four monitors show how many of each kind of molecule are present in the system. There is also a plot which plots the number of each kind of molecule present versus time.


Notice that the number of product molecules is limited by the smallest amount of reactant product. Notice that there are always the same number of reactant products since they are formed in a one-to-one correspondence with each other.


How do different amounts of the two reactants affect the final equilibrium. Are absolute amounts important, is it the difference between the amounts, or is it a ratio of the two reactants that matters?

Try setting the YELLOWMOLS slider to 400 and the BLUEMOLS slider to 20, 40, 100, 200, and 400 in five successive simulations. What sort of equilibrium state do you predict in each case? Are certain ratios predictable?


What if the forward and reverse reaction rates were the variables controlled instead of initial concentrations. You could compare such a simulation with the one in this model and see if concentration and reaction rates act independently of each other, as measured by the final equilibrium state.

You could also extend the program by allowing the user to introduce new molecules into the simulation while it is running. How would the addition of fifty blue molecules affect a system that was already at equilibrium?


To refer to this model in academic publications, please use: Wilensky, U. (2002). NetLogo Chemical Equilibrium model. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

In other publications, please use: Copyright 2002 by Uri Wilensky. All rights reserved. See for terms of use.

(back to the NetLogo User Community Models)