Chemical Equilibrium

Chemical Equilibrium preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)


chemical reactions 

Tagged by Reuven M. Lerner over 9 years ago

chemistry and physics 

Tagged by Reuven M. Lerner over 9 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 459 times • Downloaded 38 times • Run 0 times
Download the 'Chemical Equilibrium' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


This model 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 atomic-level 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 =======> C + D


        C + D =======> A + B

This can also be written as a single, reversible reaction:

        A + B <=======> C + D

A classic real-life example of such a reaction occurs when carbon monoxide reacts with nitrogen dioxide to produce carbon dioxide and nitrogen monoxide (or, nitric oxide). The reverse reaction (where carbon dioxide and nitrogen monoxide react to form carbon monoxide and nitrogen dioxide) is also possible. While all substances in the reaction are gases, we could actually watch such a system reach equilibrium as nitrogen dioxide (NO2) is a visible reddish colored gas. When nitrogen dioxide (NO2) combines with carbon monoxide (CO), the resulting products -- nitrogen monoxide (NO) and carbon dioxide (CO2) -- are colorless, causing the system to lose some of its reddish color. Ultimately the system comes to a state of equilibrium with some of the "reactants" and some of the "products" present.

While how much of each "reactant" and "product" a system ends up with depends on a number of factors (including, for example, how much energy is released when substances react or the temperature of the system), this model focuses on the concentrations of the reactants.


In the model, blue and yellow molecules can react with one another as can green and brown molecules. At each tick, each molecule move randomly throughout the world encountering other molecules. If it meets a molecule with which it can react (for example a yellow molecule meeting a blue, or a brown meeting a green, a reaction occurs. Because blue and yellow molecules react to produce green and brown molecules, and green and brown molecules react to produce blue and yellow molecules, eventually a state of equilibrium is reached.

To keep molecules from immediately reacting twice in a row, each molecule has a "ready-timer." After a reaction, this timer is set to 2, and over two ticks, the timer is decremented back to zero, allowing the molecule to react again.


The YELLOW-MOLECULES and BLUE-MOLECULES sliders determine the starting number of yellow and blue molecules respectively. Once these sliders are set, pushing the SETUP button creates these molecules and distributes them throughout the world.

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. The plot MOLECULE AMOUNTS shows the number of each kind of molecule present over time.


You may notice that the number of product molecules is limited by the smallest amount of initial reactant molecules. Notice that there is always the same number of product molecules 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 YELLOW-MOLECULES slider to 400 and the BLUE-MOLECULES 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 happens when you start with the same number of YELLOW-MOLECULES and BLUE-MOLECULES? After running the model, what is the relationship between the count of these two types of molecules?


What if the forward and reverse reaction rates were determined by a variable 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?


The line if any? turtles-here with [ color = reactant-2-color ] uses a combination of the any? and turtles-here commands to check to see if there are any other turtles of a specific type occupying the same path. This is both a succinct and easily readable way to achieve this behavior.


Enzyme Kinetics Simple Kinetics 1


If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:


Copyright 1998 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, 2001.

Comments and Questions

Click to Run Model

turtles-own [
  ready-timer  ;; timer that keeps molecules from immediately entering a reverse reaction

;; Setup Procedures

to setup
  set-default-shape turtles "circle"  
  create-turtles blue-molecules [
    setup-molecules blue
  create-turtles yellow-molecules [
    setup-molecules yellow

;;  Sets a timer to indicate whether or not the molecule is ready 
;;  to react to zero, the color of the molecule, and the position of
;;  the molecule to random x & y coordinates.

to setup-molecules [c] ;; turtle procedure
  set ready-timer 0
  set color c
  setxy random-xcor random-ycor

;;  Runtime Procedures

;;  Turtles wiggle then check for a reaction. Turtles that have a ready-timer also reduce it by one tick.

to go
  ask turtles [
    if ready-timer > 0 [
      set ready-timer ready-timer - 1

    ;; If a blue molecule meets a yellow molecule, they 
    ;; respectively become green and brown molecules
    check-for-reaction blue yellow green brown

    ;; If a green molecule meets a brown molecule, they 
    ;; respectively become blue and yellow molecules
    check-for-reaction green brown blue yellow


;; turtles are given a slight random twist to their heading.

to wiggle ;; turtle procedure
  fd 1
  rt random-float 2
  lt random-float 2

;; A reaction is defined by four colors: the colors of the two molecules that can potentially 
;; react together (reactant-1-color and reactant-2-color) and the colors of the two molecules
;; that will be produced if such a reaction occurs (product-1-color and product-2-color.)

to check-for-reaction [ reactant-1-color reactant-2-color product-1-color product-2-color ] ;; turtle procedure
  ;; start by checking if we are ready to react and 
  ;; if we are the right color for this reaction
  if ready-timer = 0 and color = reactant-1-color [
    ;; try to find a partner of the appropriate color with whom to react
    if any? turtles-here with [ color = reactant-2-color ] [ 
      ;; there is a reactant here, so do the reaction
      react product-1-color
      ask one-of turtles-here with [ color = reactant-2-color ] [ react product-2-color ]

;; When a molecule reacts, it changes its color, sets a new heading, and
;; sets a timer that will give it enough time to move out of the way
;; before reacting again.

to react [ new-color ] ;; turtle procedure
  set color new-color
  rt random-float 360
  set ready-timer 2

; Copyright 1998 Uri Wilensky.
; See Info tab for full copyright and license.

There are 10 versions of this model.

Uploaded by When Description Download
Uri Wilensky over 9 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky about 10 years ago Updated version tag Download this version
Uri Wilensky over 10 years ago Updated to version from NetLogo 5.0.3 distribution Download this version
Uri Wilensky about 11 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky over 12 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 12 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 12 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 12 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 12 years ago Model from NetLogo distribution Download this version
Uri Wilensky over 12 years ago Chemical Equilibrium Download this version

Attached files

File Type Description Last updated
Chemical Equilibrium.png preview Preview for 'Chemical Equilibrium' almost 10 years ago, by Uri Wilensky Download
Chemical Equilibrium.png preview Preview for 'Chemical Equilibrium' over 9 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.