SolveSAPHE-r2: a new versatile 4x4 engine for carbonate system pH calculations
Authors: Munhoven Guy 
Published: March 2021

&lt;p&gt;SolveSAPHE, the Solver Suite for Alkalinity-PH Equations (Munhoven, 2013, DOI:10.5194/gmd-6-1367-2013), hereafter SolveSAPHE v.1, was the first carbonate chemistry speciation package that was able to securely and reliably calculate pH for any physically meaningful pair of total alkalinity (Alk&lt;sub&gt;T&lt;/sub&gt;) and dissolved inorganic carbon (&lt;em&gt;C&lt;/em&gt;&lt;sub&gt;T&lt;/sub&gt;) values. We have now revised and extended the solution approach developed for SolveSAPHE v.1 so that Alk&lt;sub&gt;T&lt;/sub&gt; &amp; CO&lt;sub&gt;2&lt;/sub&gt;, Alk&lt;sub&gt;T&lt;/sub&gt; &amp; HCO&lt;sub&gt;3&lt;/sub&gt; and Alk&lt;sub&gt;T&lt;/sub&gt; &amp; CO&lt;sub&gt;3&lt;/sub&gt; problems can be processed as well.&lt;/p&gt;&lt;p&gt;The mathematical analysis of the modified alkalinity-pH equations reveals that the Alk&lt;sub&gt;T&lt;/sub&gt; &amp; CO&lt;sub&gt;2&lt;/sub&gt; and Alk&lt;sub&gt;T&lt;/sub&gt; &amp; HCO&lt;sub&gt;3&lt;/sub&gt; problems have one and only one positive root for any physically sensible pair of data (i.e., such that, resp., [CO&lt;sub&gt;2&lt;/sub&gt;] &gt; 0 and [HCO&lt;sub&gt;3&lt;/sub&gt;&lt;sup&gt;&amp;#8211;&lt;/sup&gt;] &gt; 0). For Alk&lt;sub&gt;T&lt;/sub&gt; &amp; CO&lt;sub&gt;3&lt;/sub&gt; the situation is completely different: there are pairs of data values for which there is no solution, others for which there is one and still others for which there are two. Similarly to its predecessor, the new SolveSAPHE-r2 offers automatic root bracketing and efficient initialisation schemes for the iterative solvers. The Alk&lt;sub&gt;T&lt;/sub&gt; &amp; CO&lt;sub&gt;3&lt;/sub&gt; problem is furthermore autonomously and completely characterised: for any given pair of data values, the number of solutions is determined and non-overlapping bracketing intervals are calculated.&lt;/p&gt;&lt;p&gt;The numerical solution of the alkalinity-pH equations for the three new pairs is far more difficult than for the Alk&lt;sub&gt;T&lt;/sub&gt; &amp; &lt;em&gt;C&lt;/em&gt;&lt;sub&gt;T&lt;/sub&gt; pair. The Newton-Raphson and the secant based solvers from SolveSAPHE v.1 had to be reworked in depth to reliably process the three additional data input pairs. The Alk&lt;sub&gt;T&lt;/sub&gt; &amp; CO&lt;sub&gt;2&lt;/sub&gt; pair is computationally the most demanding. With the Newton-Raphson based solver, it takes about five times as long to solve as the companion Alk&lt;sub&gt;T&lt;/sub&gt; &amp; &lt;em&gt;C&lt;/em&gt;&lt;sub&gt;T&lt;/sub&gt; pair, while Alk&lt;sub&gt;T&lt;/sub&gt; &amp; CO&lt;sub&gt;3&lt;/sub&gt;&lt;sup&gt;2&amp;#8211;&lt;/sup&gt; requires about four times as much time. All in all, the secant based solver offers the best performances. It outperforms the Newton-Raphson based one by up to a factor of four and leads to equation residuals that are up to seven orders of magnitude lower. For carbonate speciation problems posed by Alk&lt;sub&gt;T&lt;/sub&gt; and either one of [CO&lt;sub&gt;2&lt;/sub&gt;], [HCO&lt;sub&gt;3&lt;/sub&gt;&lt;sup&gt;&amp;#8211;&lt;/sup&gt;] or [CO&lt;sub&gt;3&lt;/sub&gt;&lt;sup&gt;2&amp;#8211;&lt;/sup&gt;] the secant based routine from SolveSAPHE-r2 is clearly the method of choice; for calculations with Alk&lt;sub&gt;T&lt;/sub&gt; &amp; &lt;em&gt;C&lt;/em&gt;&lt;sub&gt;T&lt;/sub&gt;, the SolveSAPHE v.1 solvers will perform better, due to the mathematically favourable characteristics of the alkalinity-pH equation for that pair.&lt;/p&gt;