NetLogo banner

 Contact Us

 Modeling Commons

 User Manuals:


NetLogo Models Library:
Sample Models/Chemistry & Physics/Chemical Reactions/Acids and Bases/Unverified

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

(back to the library)

Diprotic Acid

[screen shot]

If you download the NetLogo application, this model is included. (You can also run this model in your browser, but we don't recommend it; details here.)


This is the fourth model of the Acid-Base subsection of the Connected Chemistry models. It is best explored after the Strong Acid, Weak Acid, and Buffer models. In this model, we have yet another variant on determining the pH of a solution. This model depicts a diprotic acid, or an acid which can donate two atoms of hydrogen to a base.


The value of pH, like many other chemical measurements, emerges from the interactions and relative ratios of the composite molecules within a solution. Specifically, pH is a measurement of the amount of hydronium ions (H+ or H3O+) that are present in a solution. Hydronium ions are generated when an acid molecule donates a proton to a water molecule. Bases have the opposite effect on water -- they take a hydrogen atom from a water molecule and generate hydroxide ions (OH-). The chemical reaction is shown below (for more detailed explanations about pH and acid-base reactions, please check the three aforementioned models).

text Ka1 + - Ka2 + 2- H A + 2H O --> H O + H-A --> 2H O + A 2 2 3 3 We can see that the first proton is donated to water to make a hydronium ion. After the initial acid is consumed, the second proton is donated to form a second molecule of hydronium ion. It is important to note that the Ka of the first proton is much greater than the second Ka. This is because the loss of the first proton generates a negatively charged anion. It is very difficult for bases which have a negative charge or a high electron density to come in close proximity to this anion and pull off the second proton. Because of this, the first proton is most often consumed before the second proton can be donated. The pH for the reaction is determined using the Henderson-Hasselbach equation in two separate instances. While the original acid (H2A) is present, the pH is determined by:

> pH = pK1 + log ([H-A<sup>-</sup>] / [H<sub>2</sub>A])

Once the weak acid is depleted, the pH is then determined by:

> pH = pK2 + log ([A<sup>2-</sup>] / [H-A<sup>-</sup>])

The model uses a short-cut equation to approximate the pH of the solution. The equation, which can be used for each pK value of a polyprotic acid, transforms the above two equations into the following, respectively.

> pH = 0.5 * (pK1 + log [HA]) > pH = 0.5 * (pK2 + log [A])


Decide how much acid should be present at the start of the simulation with the STARTING-ACID slider and press SETUP. Turtles will distribute randomly across the view. BLUE turtles represent water molecules, GREEN turtles represent hydronium ions, YELLOW turtles are acid molecules, and finally MAGENTA turtles are conjugate base molecules. A set amount of water molecules is added each time to the solution. In this model we are using the Ka of acetic acid, which means that approximately 1% of the original acid turtles are dissociated into one conjugate base molecule and one hydronium molecule.

Press GO. The turtles will move randomly across the view and the pH of the solution will be plotted over time on the pH Curve and displayed in the pH monitor. Also, you will see the counts of all the molecules present in the solution in the Molecule Counts plot

Observe the effect of adding base to the solution by setting the volume of base with the BASE-ADDED slider and pressing ADD BASE.

When the pH remains at a steady value, press RECORD-PH, which will plot the pH versus the amount of bases added on the titration curve.


Run a titration and observe the curve. Is there anything unique about its shape?

Look for light blue (cyan) anions in the solution. How much base does it take before you start seeing them? Is this surprising?

Pay attention to how the molecules interact. Which molecules react with each other?


Compare the titration curve of the diprotic acid with that of a buffer. Do you see any similarities? How can you alter the code to test if this diprotic acid acts as a buffer?

Increase the dissociation percentage so that more hydronium ions are generated at setup. What does this do to the pH? Is the Henderson-Hasselbach equation still valid with a large Ka?

Notice that the code requires hydroxide molecules to first react with hydronium molecules on a patch before they react with acid molecules. Can you explain why this is? Reverse the code and observe the effect on the system.

Can you alter the pH of the solution without adding base to the solution?


Alter the code so that base turtles only react with hydronium molecules. What effect is observed? What additional changes do you need to make so that the pH continues to rise with the addition of base?

Substitute the short-cut equation for calculating pH with the full equation. Are the values similar?

Try substituting the various pKa values below into the Henderson-Hasselbach equation and observe their effect on the titration curve. What affect does this have on the pH?

<table border> <tr><th>weak acid<th>pK1<th>pK2 <tr><td>carbonic<td>6.5<td>10.2 <tr><td>oxalic<td>1.27<td>4.27 <tr><td>glycine<td>2.34<td>9.60 <tr><td>maleic<td>2.00<td>6.20 </table>


Strong Acid Weak Acid Buffer


Notice that in the calculate-pH procedure the model makes use of the count primitive to convert the number of turtles in the world into concentrations that are often used in the chemistry laboratory.


Thanks to Mike Stieff for his work on this model.


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

(back to the NetLogo Models Library)