Monday, September 23, 2013

Active ocean acidification calculator.

I wrote a post a few weeks ago on ocean acidification. The message was that there is more to acidification than pH, and that it's basically an issue of equilibrium between carbonate species. Difficulties of measuring pH can be avoided.

In the course of discussion, I said I would try to develop an active calculator to display some of the principles.

It calculates equilibrium adjustments, and I expect that is a rather specialised interest. I'm putting it forward to demonstrate
  • that any two of the species are sufficient to determine the others - pH is not essential and can be treated as just a following variable
  • CO2 when dissolved is almost completely reacted (at usual pH)
The main process of interest is the addition of CO2, which causes carbonate to go down. This affects the solubility of CaCO3. I haven't shown that equilibrium, because it only makes sense where solid CaCO3 is present. The calculator has two modes. You can show the effect of adding a fixed amount of any reagent, or you can specify any two. Details and gadget below the jump.

The gadget

There are four species (H+,CO2,HCO3- and CO3--). For details of the chemistry, see my previous post. I also have two combinations, dissolved inorganic carbon (DIC) and total alkalinity (TA). These are conserved during the reaction as total C and nett charge. There are six bars, four in gold for the species, and two for the combinations. They are scaled on a negative log scale (like pH). You can click on each bar to vary each constituent. But first you need to set a constraint using the radio buttons at the top. The default setting is marked "Add". Here you can only vary the species (gold). Your click will indicate what the concentration would have been if the change (+ or -) happened without reaction. But in fact your addition is added appropriately to DIC and TA, and then the equilibrium adjusts with these held constant. Sometimes almost all what you have added reacts, and you see only a small change in that variable. If you click another radio button, you move to "set" mode. The column you have marked is held fixed, and the column you click (a different one) will move to the value you have set (if possible - see below). "Set" is a slight misnomer - it's better seen as the values the other components are known to have when the "set" values have been measured. The blue bars show the current state, with log values beside. The absolute values show in the table on the right, with the pK values. The intent, not yet implemented, is that you can vary these.

Update: You can now vary pK1 and pK2 (but see Notes below). Modify the text box and click the new "Accept Data". You can use this to look at totally different equilibria if you want. To make it monoprotic, just set pK2 to, say, 15.


I'm using a Newton-Raphson process to solve the equations. This is fast and accurate, but may not necessarily converge. On the right there is a purple box which tells you whether your request has converged or failed. If failed, for whatever reason, no change has been made and you can try again. Some requests are impossible. For example, no carbon species can exceed DIC. But sometimes the Newton process just had trouble with the size of change you asked for. Try getting there in two steps.


A Bjerrum plot is shown (from the previous post). It shows equilibrium concentrations normalised against DIC vs pH. A thin gold bar moves to show where you currently are on the plot.

Here it is:


The constants pK1 and pK2 come from Zeebe's review article referred to in my previous post. I do not distinguish between CO2 and H2CO3, and the constants reflect that. [CO2] means the combined value. A pK1 based on carbonic acid alone would be lower, but you would then need the equilibrium between CO2 and H2CO3.


  1. Nick, this looks to be a wonderful widget. I've just started playing with it and I'm hooked.

    I'll bet the Brer Eli wishes that he had one at the Run...

    Bernard J.

    1. Thanks, Bernard. I'll get the text boxes working so the pK's can be changed etc.

  2. The bars are working OK for me but the pK1, pK2 thing isn't working for me on safari (can't see "Accept data"). I'll try on windows when I get to work.

    1. SCM,
      My faukt - fixed - sorry about that. A bit hard to explain, but it got into my automatic update system, and the earlier version got uploaded. It wasn't Safari.

  3. Nick, solid CaC)3 is always present as shells, and indeed the decrease in CaCO3, otherwise known as the shells don't grow is the issue. Put it in man!!

    1. Eli,
      If CaCO3 is assumed always present, and since Ca++ is present in great excess, assuming solubility equilibrium would then fix CO3--. That leaves only 1 dof.

      Many results are reported from flask analysis of seawater, where CaCO3 is presumably absent.

      A further problem is that the solubility product is not adhered to. Much of surface seawater is supersaturated.