Abstract
During reactive transport modeling, the computing cost associated with chemical equilibrium calculations can be 10 to 10,000 times higher than that of fluid flow, heat transfer, and species transport computations. These calculations are performed at least once per mesh cell and once per time step, amounting to billions of them throughout the simulation employing high-resolution meshes. To radically reduce the computing cost of chemical equilibrium calculations (each requiring an iterative solution of a system of nonlinear equations), we consider an on-demand machine learning algorithm that enables quick and accurate prediction of new chemical equilibrium states using the results of previously solved chemical equilibrium problems within the same reactive transport simulation. The training operations occur on-demand, rather than before the start of the simulation when it is not clear how many training points are needed to accurately and reliably predict all possible chemical conditions that may occur during the simulation. Each on-demand training operation consists of fully solving the equilibrium problem and storing some key information about the just computed chemical equilibrium state (which is used subsequently to rapidly predict similar states whenever possible). We study the performance of the on-demand learning algorithm, which is mass conservative by construction, by applying it to a reactive transport modeling example and achieve a speed-up of one or two orders of magnitude (depending on the activity model used). The implementation and numerical tests are carried out in Reaktoro (reaktoro.org), a unified open-source framework for modeling chemically reactive systems.
Similar content being viewed by others
Change history
05 June 2020
In the original publication of the article, Table 2 was published incorrectly.
Notes
The reason for this choice of notation is that we aim to formulate chemical systems in a more general form, instead of one that presumes the existence of certain types of species (e.g., molalities for aqueous solutes, mole fractions for gases, moles for minerals, etc.). We acknowledge that notations used by Lichtner (1985), Steefel and Cappellen (1990), Bethke (2007) are more common in the geochemical community. However, we believe that our choice for dependent and independent variables (molar amounts for all species, no matter their type, and considering elements as the building blocks of species, instead of primary/basic species) should not be difficult to understand.
When A is full rank, the number of primary species and elements (i.e., chemical elements and electric charge) are equal.
References
Alberty, R.A.: Equilibrium calculations on systems of biochemical reactions at specified pH and pMg. Biophys. Chem. 42(2), 117–131 (1992). https://doi.org/10.1016/0301-4622(92)85002-L
Bellman, R.E.: Dynamic Programming. Dover Publications Inc, New York (2003)
Bethke, C.M.: Geochemical and Biogeochemical Reaction Modeling, 2nd edn. Cambridge University Press, New York (2007)
Crerar, D.A.: A method for computing multicomponent chemical equilibria based on equilibrium constants. Geochim. Cosmochim. Acta 39(10), 1375–1384 (1975). https://doi.org/10.1016/0016-7037(75)90116-7
de Capitani, C., Brown, T.H.: The computation of chemical equilibrium in complex systems containing non-ideal solutions. Geochim. Cosmochim. Acta 51(10), 2639–2652 (1987). https://doi.org/10.1016/0016-7037(87)90145-1
Debye, P., Hückel, E.: The theory of electrolytes. 1. Lowering of freezing point and related phenomena. Phys. Z. 24, 85–206 (1923)
Dong, G., Fan, B.: Chemistry acceleration modeling of detonation based on the dynamical storage/deletion algorithm. Combust. Sci. Technol. 181(9), 1207–1216 (2009). https://doi.org/10.1080/00102200903181744
Dong, G., Fan, B.C., Chen, Y.L.: Acceleration of chemistry computations in two-dimensional detonation induced by shock focusing using reduced ISAT. Combust. Theory Model. 11(5), 823–837 (2007). https://doi.org/10.1080/13647830701316657
Drummond, S.: Boiling and Mixing of Hydrothermal Fluids: Chemical Effects on Mineral Precipitation. , Ph.D., Pennsylvania State University (1981)
Eriksson, G., Thompson, W.: A procedure to estimate equilibrium concentrations in multicomponent systems and related applications. Calphad 13(4), 389–400 (1989). https://doi.org/10.1016/0364-5916(89)90027-8
Fletcher, R.: Dense factors of sparse matrices. In: Approximation Theory and Optimization—Tributes to M. J. D. Powell, chapter 8. Cambridge University Press, Cambridge, pp 145–166 (1997)
Fletcher, R.: Practical Methods of Optimization, 2nd edn. Wiley, Hoboken (2000)
Garrels, R.M., Thompson, M.E.: A chemical model for sea water at 25 degrees C and one atmosphere total pressure. Am. J. Sci. 260(1), 57–66 (1962). https://doi.org/10.2475/ajs.260.1.57
Ghiorso, M.S.: Algorithms for the estimation of phase stability in heterogeneous thermodynamic systems. Geochim. Cosmochim. Acta 58(24), 5489–5501 (1994). https://doi.org/10.1016/0016-7037(94)90245-3
Guérillot, D., Bruyelle, J.: Geochemical equilibrium determination using an artificial neural network in compositional reservoir flow simulation. Comput. Geosci. (2019). https://doi.org/10.1007/s10596-019-09861-4
Harvey, J.P., Eriksson, G., Orban, D., Chartrand, P.: Global minimization of the gibbs energy of multicomponent systems involving the presence of order/disorder phase transitions. Am. J. Sci. 313(3), 199–241 (2013). https://doi.org/10.2475/03.2013.02
Harvie, C.E., Møller, N., Weare, J.H.: The prediction of mineral solubilities in natural waters: The Na–K–Mg–Ca–H–Cl–SO4–OH–HCO3–CO3–CO2–H2O system to high ionic strengths at \(25^{\circ }\text{ C }\). Geochim. Cosmochim. Acta 48(4), 723–751 (1984). https://doi.org/10.1016/0016-7037(84)90098-X
Harvie, C.E., Greenberg, J.P., Weare, J.H.: A chemical equilibrium algorithm for highly non-ideal multiphase systems: free energy minimization. Geochim. Cosmochim. Acta 51(5), 1045–1057 (1987). https://doi.org/10.1016/0016-7037(87)90199-2
Hastie, T., Tibshirani, R., Friedman, J.: The Elements of Statistical Learning—Data Mining, Inference, and Prediction, 2nd edn. Springer Series in Statistics. Springer, New York (2009). https://doi.org/10.1007/978-0-387-84858-7
Hedengren, J.D., Edgar, T.F.: Approximate nonlinear model predictive control with in situ adaptive tabulation. Comput. Chem. Eng. 32(4–5), 706–714 (2008). https://doi.org/10.1016/j.compchemeng.2007.02.010
Helgeson, H.C., Kirkham, D.H.: Theoretical prediction of the thermodynamic behavior of aqueous electrolytes at high pressures and temperatures. I: Summary of the thermodynamic/electrostatic properties of the solvent. Am. J. Sci. 274(10), 1089–1198 (1974a). https://doi.org/10.2475/ajs.274.10.1089
Helgeson, H.C., Kirkham, D.H.: Theoretical prediction of the thermodynamic behavior of aqueous electrolytes at high pressures and temperatures: II. Debye–Hückel parameters for activity coefficients and relative partial molal properties. Am. J. Sci. 274(10), 1199–1261 (1974b). https://doi.org/10.2475/ajs.274.10.1199
Helgeson, H.C., Kirkham, D.H.: Theoretical prediction of the thermodynamic properties of aqueous electrolytes at high pressures and temperatures: III. Equation of state for aqueous species at infinite dilution. Am. J. Sci. 276(2), 97–240 (1976). https://doi.org/10.2475/ajs.276.2.97
Helgeson, H.C., Delany, J.M., Nesbitt, H.W., Bird, D.K.: Summary and critique of the thermodynamic properties of rock-forming minerals. Am. J. Sci. 278A(1), 229 (1978)
Helgeson, H.C., Kirkham, D.H., Flowers, G.C.: Theoretical prediction of the thermodynamic behavior of aqueous electrolytes at high pressures and temperatures: IV. Calculation of activity coefficients, osmotic coefficients, and apparent molal and standard and relative partial molal properties to 600 C. Am. J. Sci. 281(10), 1249–1516 (1981). https://doi.org/10.2475/ajs.281.10.1249
Jatnieks, J., De Lucia, M., Dransch, D., Sips, M.: Data-driven Surrogate Model Approach for Improving the Performance of Reactive Transport Simulations. Energy Procedia 97, 447–453 (2016). https://doi.org/10.1016/j.egypro.2016.10.047
Johnson, J.W., Oelkers, E.H., Helgeson, H.C.: SUPCRT92: a software package for calculating the standard molal thermodynamic properties of minerals, gases, aqueous species, and reactions from 1 to 5000 bar and 0 to 1000 C. Comput. Geosci. 18(7), 899–947 (1992). https://doi.org/10.1016/0098-3004(92)90029-Q
Karpov, I.K., Chudnenko, K.V., Kulik, D.A.: Modeling chemical mass transfer in geochemical processes: thermodynamic relations, conditions of equilibria, and numerical algorithms. Am. J. Sci. 297(8), 767–806 (1997). https://doi.org/10.2475/ajs.297.8.767
Karpov, I.K., Chudnenko, K.V., Kulik, D.A., Avchenko, O.V., Bychinski, V.A.: Minimization of Gibbs free energy in geochemical systems by convex programming. Geochem. Int. 39(11), 1108–1119 (2001)
Karpov, I.K., Chudnenko, K.V., Kulik, D.A., Bychinskii, V.A.: The convex programming minimization of five thermodynamic potentials other than Gibbs energy in geochemical modeling. Am. J. Sci. 302(4), 281–311 (2002). https://doi.org/10.2475/ajs.302.4.281
Koukkari, P., Pajarre, R.: A Gibbs energy minimization method for constrained and partial equilibria. Pure Appl. Chem. 83(6), 1243–1254 (2011). https://doi.org/10.1351/PAC-CON-10-09-36
Kulik, D.A., Wagner, T., Dmytrieva, S.V., Kosakowski, G., Hingerl, F.F., Chudnenko, K.V., Berner, U.R.: GEM-Selektor geochemical modeling package: revised algorithm and GEMS3K numerical kernel for coupled simulation codes. Comput. Geosci. 17(1), 1–24 (2013). https://doi.org/10.1007/s10596-012-9310-6
Laloy, E., Jacques, D.: Emulation of CPU-demanding reactive transport models: a comparison of Gaussian processes, polynomial chaos expansion, and deep neural networks. Comput. Geosci. (2019). https://doi.org/10.1007/s10596-019-09875-y
Leal, A.M., Blunt, M.J., LaForce, T.C.: Efficient chemical equilibrium calculations for geochemical speciation and reactive transport modelling. Geochim. Cosmochim. Acta 131, 301–322 (2014). https://doi.org/10.1016/j.gca.2014.01.038
Leal, A.M., Blunt, M.J., LaForce, T.C.: A chemical kinetics algorithm for geochemical modelling. Appl. Geochem. 55, 46–61 (2015). https://doi.org/10.1016/j.apgeochem.2014.09.020
Leal, A.M., Kulik, D.A., Kosakowski, G.: Computational methods for reactive transport modeling: a Gibbs energy minimization approach for multiphase equilibrium calculations. Adv. Water Resour. 88, 231–240 (2016a). https://doi.org/10.1016/j.advwatres.2015.11.021
Leal, A.M., Kulik, D.A., Kosakowski, G., Saar, M.O.: Computational methods for reactive transport modeling: an extended law of mass-action, xLMA, method for multiphase equilibrium calculations. Adv. Water Resour. 96, 405–422 (2016b). https://doi.org/10.1016/j.advwatres.2016.08.008
Leal, A.M., Kulik, D.A., Saar, M.O.: Enabling Gibbs energy minimization algorithms to use equilibrium constants of reactions in multiphase equilibrium calculations. Chem. Geol. 437, 170–181 (2016c). https://doi.org/10.1016/j.chemgeo.2016.05.029
Leal, A.M.M., Blunt, M.J., LaForce, T.C.: A robust and efficient numerical method for multiphase equilibrium calculations: application to CO2-brine-rock systems at high temperatures, pressures and salinities. Adv. Water Resour. 62(Part C), 409–430 (2013). https://doi.org/10.1016/j.advwatres.2013.02.006
Leal, A.M.M., Kulik, D.A., Smith, W.R., Saar, M.O.: An overview of computational methods for chemical equilibrium and kinetic calculations for geochemical and reactive transport modeling. Pure Appl. Chem. 89(5), 597–643 (2017). https://doi.org/10.1515/pac-2016-1107
Leal, A.M.M., et al.: autodiff, a modern, fast and expressive C++ library for automatic differentiation (2018). https://autodiff.github.io. Accessed 1 Mar 2020
Lichtner, P.C.: Continuum model for simultaneous chemical reactions and mass transport in hydrothermal systems. Geochim. Cosmochim. Acta 49(3), 779–800 (1985). https://doi.org/10.1016/0016-7037(85)90172-3
Lu, L., Pope, S.B.: An improved algorithm for in situ adaptive tabulation. J. Comput. Phys. 228(2), 361–386 (2009). https://doi.org/10.1016/j.jcp.2008.09.015
Lu, L., Lantz, S.R., Ren, Z., Pope, S.B.: Computationally efficient implementation of combustion chemistry in parallel pdf calculations. FDA 07-02 (2007)
McBride, B.J., Gordon, S.: Computer program for calculation of complex chemical equilibrium compositions rocket performance incident and reflected shocks, and Chapman–Jouguet detonations. Technical report, NASA (1971)
McBride, B.J., Gordon, S.: Computer program for calculation of complex chemical equilibrium compositions and applications: I. Analysis. Technical report, NASA, NASA RP-1311 (1994)
McBride, B.J., Gordon, S.: Computer program for calculation of complex chemical equilibrium compositions and applications: II-user manual and program description. Technical report, NASA, NASA RP-1311 (1996)
Morel, F., Morgan, J.: Numerical method for computing equilibriums in aqueous chemical systems. Environ. Sci. Technol. 6(1), 58–67 (1972). https://doi.org/10.1021/es60060a006
Néron, A., Lantagne, G., Marcos, B.: Computation of complex and constrained equilibria by minimization of the Gibbs free energy. Chem. Eng. Sci. 82, 260–271 (2012). https://doi.org/10.1016/j.ces.2012.07.041
Nocedal, J., Wright, S.J.: Numerical Optimization, 2nd edn. Springer, Berlin (1999)
Nordstrom, D., Plummer, L.N., Wigley, T., Wolery, T., Ball, J., Jenne, E., Bassett, R., Crerar, D., Florence, T., Fritz, B., Hoffman, M., Holdren Jr., G.L.G., Mattigod, S., McDuff, R., Morel, F., Reddy, M., Sposito, G.: A comparison of computerized chemical models for equilibrium calculations in aqueous systems. Am. Chem. Soc. Symp. Ser. 93, 857–892 (1979)
Parkhurst, D., Appelo, C.: Description of input and examples for PHREEQC version 3—A computer program for speciation, batch-reaction, one-dimensional transport, and inverse geochemical calculations. In: Groundwater Book 6, Modeling Techniques, U.S. Geological Survey Techniques and Methods, Chapter A43, p. 497 (2013) http://pubs.usgs.gov/tm/06/a43. Accessed 1 Mar 2020
Peng, D.Y., Robinson, D.B.: A new two-constant equation of state. Ind. Eng. Chem. Fundam. 15(1), 59–64 (1976). https://doi.org/10.1021/i160057a011
KS, Pitzer: Thermodynamics of electrolytes. I. Theoretical basis and general equations. J. Phys. Chem. 77(2), 268–277 (1973). https://doi.org/10.1021/j100621a026
Pope, S.B.: Computationally efficient implementation of combustion chemistry using in situ adaptive tabulation. Combust. Theory Model. 1(1), 41–63 (1997). https://doi.org/10.1088/1364-7830/1/1/006
Pope, S.B., Ren, Z.: Efficient implementation of chemistry in computational combustion. Flow Turbul. Combust. 82(4), 437–453 (2009). https://doi.org/10.1007/s10494-008-9145-3
Ramshaw, J., Chang, C.: Iteration scheme for implicit calculations of kinetic and equilibrium chemical reactions in fluid dynamics. J. Comput. Phys. 116(2), 359–364 (1995). https://doi.org/10.1006/jcph.1995.1033
Ramshaw, J.D.: Partial chemical equilibrium in fluid dynamics. Phys. Fluids 23(4), 675–680 (1980)
Ramshaw, J.D., Amsden, A.A.: Improved iteration scheme for partial equilibrium flow. J. Comput. Phys. 59(3), 484–489 (1985). https://doi.org/10.1016/0021-9991(85)90124-X
Ramshaw, J.D., Cloutman, L.D.: Numerical method for partial equilibrium flow. J. Comput. Phys. 39(2), 405–417 (1981). https://doi.org/10.1016/0021-9991(81)90160-1
Shock, E., Helgeson, H.C.: Calculation of the thermodynamic and transport properties of aqueous species at high pressures and temperatures: correlation algorithms for ionic species and equation of state predictions to 5 kb and \(1000^{\circ }\text{ C }\). Geochim. Cosmochim. Acta 52(8), 2009–2036 (1988). https://doi.org/10.1016/0016-7037(88)90181-0
Shock, E.L., Oelkers, E.H., Johnson, J.W., Sverjensky, D.A., Helgeson, H.C.: Calculation of the thermodynamic properties of aqueous species at high pressures and temperatures. Effective electrostatic radii, dissociation constants and standard partial molal properties to \(1000^{\circ }\text{ C }\) and 5 kbar. J. Chem. Soc. Faraday Trans. 88(6), 803 (1992). https://doi.org/10.1039/ft9928800803
Singer, M., Pope, S., Najm, H.: Operator-splitting with ISAT to model reacting flow with detailed chemistry. Combust. Theory Model. 10(2), 199–217 (2006). https://doi.org/10.1080/13647830500307501
Singer, M.A., Pope, S.B.: Exploiting ISAT to solve the reaction–diffusion equation. Combust. Theory Model. 8(2), 361–383 (2004). https://doi.org/10.1088/1364-7830/8/2/009
Smith, W., Missen, R.: Chemical Reaction Equilibrium Analysis: Theory and Algorithms. Wiley, New York (1982)
Smith, W.R.: The computation of chemical equilibria in complex systems. Ind. Eng. Chem. Fundam. 19(1), 1–10 (1980). https://doi.org/10.1021/i160073a001
Steefel, C., Depaolo, D., Lichtner, P.: Reactive transport modeling: an essential tool and a new research approach for the Earth sciences. Earth Planet. Sci. Lett. 240(3–4), 539–558 (2005). https://doi.org/10.1016/j.epsl.2005.09.017
Steefel, C.I.: Reactive transport at the crossroads. Rev. Mineral. Geochem. 85(1), 1–26 (2019). https://doi.org/10.2138/rmg.2019.85.1
Steefel, C.I., Cappellen, P.V.: A new kinetic approach to modeling water-rock interaction: the role of nucleation, precursors, and Ostwald ripening. Geochim. Cosmochim. Acta 54(10), 2657–2677 (1990). https://doi.org/10.1016/0016-7037(90)90003-4
Steefel, C.I., Lasaga, A.C.: A coupled model for transport of multiple chemical species and kinetic precipitation/dissolution reactions with applications to reactive flow in single phase hydrothermal systems. Am. J. Sci. 294(5), 529–592 (1994)
Steefel, C.I., MacQuarrie, K.T.B.: Approaches to modeling of reactive transport in porous media. Rev. Mineral. Geochem. 34(1), 83–129 (1996)
Stockmann, M., Schikora, J., Becker, D.A., Flügge, J., Noseck, U., Brendler, V.: Smart Kd-values, their uncertainties and sensitivities—applying a new approach for realistic distribution coefficients in geochemical modeling of complex systems. Chemosphere 187, 277–285 (2017). https://doi.org/10.1016/j.chemosphere.2017.08.115
Tanger, J.C., Helgeson, H.C.: Calculation of the thermodynamic and transport properties of aqueous species at high pressures and temperatures; revised equations of state for the standard partial molal properties of ions and electrolytes. Am. J. Sci. 288(1), 19–98 (1988). https://doi.org/10.2475/ajs.288.1.19
Trangenstein, J.A.: Customized minimization techniques for phase equilibrium computations in reservoir simulation. Chem. Eng. Sci. 42(12), 2847–2863 (1987). https://doi.org/10.1016/0009-2509(87)87051-3
Vonka, P., Leitner, J.: Calculation of chemical equilibria in heterogeneous multicomponent systems. Calphad 19(1), 25–36 (1995). https://doi.org/10.1016/0364-5916(95)00004-X
Wagner, W., Pruss, A.: The IAPWS formulation 1995 for the thermodynamic properties of ordinary water substance for general and scientific use. J. Phys. Chem. Ref. Data 31(2), 387 (2002). https://doi.org/10.1063/1.1461829
White, W.B., Johnson, S.M., Dantzig, G.B.: Chemical equilibrium in complex mixtures. J. Chem. Phys. 28, 751 (1958). https://doi.org/10.1063/1.1744264
Wolery, T.J.: EQ3/6, a software package for geochemical modeling of aqueous systems: package overview and installation guide. Technical report, Lawrence Livermore National Laboratory, Livermore, California (1992a)
Wolery, T.J. EQ3NR, a computer program for geochemical aqueous speciation-solubility calculations: theoretical manual, user’s guide, and related documentation (Version 7.0). Technical report, UCRL-MA-110662 PT III, Lawrence Livermore National Laboratory, Livermore, California (1992)
Wolery, T.J., Walters, L.J.: Calculation of equilibrium distributions of chemical species in aqueous solutions by means of monotone sequences. J. Int. Assoc. Math. Geol. 7(2), 99–115 (1975). https://doi.org/10.1007/BF02080487
Wu, J., Dong, G., Li, B.: Parallel chemistry acceleration algorithms based on ISAT method in gaseous detonation computations. Comput. Fluids 167, 265–284 (2018). https://doi.org/10.1016/j.compfluid.2018.03.036
van Zeggeren, F., Storey, S.H.: The Computation of Chemical Equilibria. Cambridge University Press, London (1970)
Zeleznik, F.J., Gordon, S.: An analytical investigation of the general methods of calculating chemical equilibrium compositions. Technical report NASA-TN-D-473, NASA (1960)
Acknowledgements
This research project is funded by the Swiss National Science Foundation (Ambizione Grant PZ00P2-179967) and Shell Global Solutions International BV (Netherlands). We thank the Werner Siemens Foundation (Werner Siemens-Stiftung) for its support of the Geothermal Energy and Geofluids group at ETH Zurich, Switzerland. We also thank the associate editor and four anonymous reviewers whose critical comments and suggestions contributed immensely to the final version of this manuscript.
Author information
Authors and Affiliations
Corresponding author
Additional information
Publisher's Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
The original version of this article was revised: Table 2 and some sentences in the texts have been published incorrectly. The sentence “they are reliable and our benchmark” in the section “1.1.1 Advantages of the Smart Chemical Equilibrium Algorithm” under the heading “Reliability.” should read as “they are reliable and serve as a benchmark”. Also, the sentence “’N secondary species” below the equation 24 should read as “N-E secondary species”. The corrected version of table 2 and the sentences are updated in the article.
Appendices
Appendix 1: Chemical Equilibrium Equations
The solution of the Gibbs energy minimization problem in (9) needs to satisfy the following first-order optimality conditions, also known as Karush–Kuhn–Tucker (KKT) conditions, for a local minimum of the Gibbs energy function G (Nocedal and Wright 1999; Fletcher 2000):
where \(y\in{\mathbb{R}}^{\text{E}}\) and \(z\in{\mathbb{R}}^{\text{N}}\) are introduced Lagrange multipliers and slack variables, respectively, that need to be solved along with the vector of species amounts \({n\in{\mathbb{R}}^{\text{N}}}\). For more details about these Lagrange multipliers and slack variables, their interpretation, as well as instructions on how to efficiently solve these equations, see Leal et al. (2016a), Leal et al. (2017).
The previous chemical equilibrium equations can be written in an extended law of mass action (xLMA) formulation as:
following the use of the extended law of mass action equations
This is associated with the M linearly independent chemical reactions among the N chemical species in equilibrium:
where \({K\in{\mathbb{R}}^{\text{M}}}\) is the vector of equilibrium constants of the reactions, with \({K_{m}=K_{m}(T,P)}\) denoting the equilibrium constant of the mth reaction, and \(\nu \in{\mathbb{R}}^{\text{M}\times \text{N}}\) the stoichiometric matrix of these chemical reactions, with \(\nu _{mi}\) corresponding to the stoichiometric coefficient of the ith species in the mth reaction. Conventionally, \(\nu _{mi}\) is positive if the ith species is a product in the mth reaction (on its right-hand side), and negative if it is a reactant (on the left-hand side). Moreover, \({w\in{\mathbb{R}}^{\text{N}}}\) is the vector of species stability factors that need to be solved along with the species amounts \({n\in{\mathbb{R}}^{\text{N}}}\). These factors are introduced to ensure that the extended law of mass action equations (44) is valid even when some species in their corresponding reactions are unstable at equilibrium (i.e., when a species belongs to a phase that is absent from equilibrium). When all species are stable at equilibrium, it follows that \({w_{i}=1}\) and the xLMA equations reduce to the conventional lma equations
The number of linearly independent chemical reactions among the N species in equilibrium is \({\text{M}=\text{N}-\text{C}}\), where \({\text{C}=\text{rank}(A)}\), and thus whenever the formula matrix A is full rank, \(\text{C}=\text{E}\) and \(\text{M}=\text{N}-\text{E}\). For more information on how to solve these equations and how they are related to the conventional law of mass action equations, see Leal et al. (2016b), Leal et al. (2017).
Appendix 2: Sensitivity Derivatives
After computing the species amounts \(n=(n_{1},\ldots ,n_{\mathrm{N}})\) at a chemical equilibrium state corresponding to constrained temperature T, pressure P, and element amounts \(b=(b_{1},\ldots ,b_{\mathrm{E}})\), we are interested in computing the following sensitivity derivatives:
This can be achieved by applying the respective derivative operators d/dT, d/dP, and d/db on the governing equations used to compute the equilibrium state. To simplify the discussion, we consider the simpler conventional law of mass action (lma) formulation instead of the more advanced extended form (xLMA). Thus, the demonstration considers the system of equations
Sensitivity derivatives with respect to temperatureT:
$$\begin{aligned} \begin{aligned}\nu \frac{\partial (\ln a)}{\partial n} \frac{\partial n}{\partial T}&=\frac{\partial (\ln K)}{\partial T} -\nu \frac{\partial (\ln a)}{\partial T},\\ A\frac{\partial n}{\partial T}&=0. \end{aligned} \end{aligned}$$(49)Sensitivity derivatives with respect to pressureP:
$$\begin{aligned} \begin{aligned}\nu \frac{\partial (\ln a)}{\partial n}\frac{\partial n}{\partial P}&=\frac{\partial (\ln K)}{\partial P}-\nu \frac{\partial (\ln a)}{\partial P},\\ A\frac{\partial n}{\partial P}&=0. \end{aligned} \end{aligned}$$(50)Sensitivity derivatives with respect to element amounts\(b=(b_{1},\ldots ,b_{\mathrm{E}})\):
$$\begin{aligned} \begin{aligned} \nu \frac{\partial (\ln a)}{\partial n}\frac{\partial n}{\partial b}&=0,\\ A\frac{\partial n}{\partial b}&=I. \end{aligned} \end{aligned}$$(51)
Note that all these equations are linear and share the same coefficient matrix M:
Let S be the sensitivity matrix of the equilibrium state defined as
and introduce a matrix B that concatenate, along its columns, the right-hand side vectors in Eqs. (49), (50) and (51):
We can then compute S (the sensitivity matrix corresponding to the previously calculated equilibrium state) using
which can be performed by decomposing the M matrix once (e.g., in LU factors) and then solving for each column of S.
Note: We compute the derivatives \(\partial (\ln a)/\partial T\), \(\partial (\ln a)/\partial P\), \(\partial (\ln a)/\partial n\), \(\partial (\ln K)/\partial T\) and \(\partial (\ln K)/\partial P\) using automatic differentiation (Leal et al. 2018). In this way, we do not need to be concerned about the specific details and complexity of each thermodynamic model (or equation of state) used to compute the necessary thermodynamic properties of the phases, species, and reactions in the chemical system.
Appendix 3: Mass Conservative Predictions
We demonstrate here that the first-order Taylor prediction (used in the algorithm presented in Sect. 3)
is intrinsically mass conservative. Thus, we want to show that for a given (T, P, b), the corresponding Taylor estimate \({\tilde{n}}\) satisfies
where A is the formula matrix of the chemical system (see Sect. 2).
We start by multiplying equation (56) by A:
Observe from Eqs. (49), (50), and (51) that the following conditions are imposed for the sensitivity derivatives:
Moreover, since \(\mathring{n}\) was computed using a conventional and exact equilibrium algorithm, we have that
Combining all these observations, we determine, as desired, that
Appendix 4: Reactive Transport Equations
The fundamental mass conservation equations for both fluid and solid species are:
where \(n_{i}^{\text{f}}\) and \(n_{i}^{\text{s}}\) are the bulk concentration of the ith fluid and solid species (in mol/\(\hbox{m}^{3}\)), respectively; \({\varvec{v}}\) is the fluid pore velocity (in m/s); D is the diffusion coefficient of the fluid species (in \(\hbox{m}^{2}\)/s); \(r_{i}^{\text{f}}\) and \(r_{i}^{\text{s}}\) are the rates of production/consumption of the ith fluid and solid species (in mol/s), respectively, due to chemical reactions; and \(\text{N}^{\text{f}}\) and \(\text{N}^{\text{s}}\) are the numbers of fluid and solid species, respectively. Note that the above equations assume a single fluid phase and common diffusion coefficients for all fluid species.
By partitioning the species as fluid and solid species, the formula matrix A can be conveniently represented as:
where \(A^{\text{f}}\) and \(A^{\text{s}}\) are the formula matrices of the fluid and solid partitions (i.e., the matrices constructed from the columns of A corresponding to fluid and solid species).
The concentrations of elements in both fluid and solid partitions \(b_{j}^{\text{f}}\) and \(b_{j}^{\text{s}}\) can then be calculated from the species concentrations in the same partition using
and
Let \(r_{i}\) denote the rate of production/consumption of the ith species in the system (i.e., using the global index, and not a local index within the fluid or solid partition). From the mass conservation condition for the elements (chemical elements and electrical charge), it follows that
which is the mathematical statement for the fact that elements are neither created nor destroyed during chemical reactions. We can combine this result with Eqs. (62) and (63) to derive the following conservation equations for the elements:
Assume that all species, fluid and solid, are in local chemical equilibrium everywhere, at all times. One can then perform operator splitting steps to solve the fundamental mass conservation Eqs. (62) and (63) to calculate the concentrations of the species, \(n_{i}\), over time. Let k denote the current time step and \(\Delta t\) the time step length used in the discretization of the time derivative terms. The operator splitting steps at the kth time step are:
Step 1. We consider Eq. (68) without the \({\partial b_{j}^{\text{s}}}/{\partial t}\) term and compute an intermediate approximation of element concentrations in the fluid partition \({\tilde{b}}^{\text{f}}=({\tilde{b}}_{1}^{\text{f}},\ldots ,{\tilde{b}}_{\mathrm{E}}^{\text{f}})\) at time \(t_{k+1}\) using
with the following flux boundary condition at \(x=x_{L}\) (on the left boundary inlet face, where we inject the \(\hbox{CO}_{{2}}\)-saturated brine):
where subscript L denotes the left boundary at \(x=x_{L}\), \(\mathbf{n }_{L}\) is the normal vector on the inflow face, \(\phi _{L}\) is the current porosity at \(x=x_{L}\) (which changes with time), and \({\hat{b}}_{j,L}\) (in \(\mathrm{mol}/\mathrm{m}_{\mathrm{fluid}}^{3}\)) is the imposed concentration of the jth element in the injected brine. To match the units of concentrations of the elements in the fluid \([b_{j}]=\mathrm{mol}/\mathrm{m}_{\mathrm{bulk}}^{3}\) and the imposed concentration \([{\hat{b}}_{j,L}]=\mathrm{mol}/\mathrm{m}_{\mathrm{fluid}}^{3}\) , we need to multiply it by \(\phi _{L}\) (\(\mathrm{m}_{\mathrm{fluid}}^{3}/\mathrm{m}_{\mathrm{bulk}}^{3}\)). To discretize the above partial differential equations in space, a finite volume method is applied. The time integration uses an implicit scheme for both advection and diffusion.
Step 2. Update the total concentrations of each element \(b_{j}\) using the previously computed intermediate concentrations of each element in the fluid \({\tilde{b}}_{j}^{\mathrm{f}}\):
Note that each element concentration in the solid partition \(b_{j}^{\mathrm{s}}\) remains constant during the transport calculations in the previous step.
Step 3. Calculate the concentrations of the species, \(n_{i}^{k+1}\), in each mesh cell. For this, use as input the temperature and pressure values of the cell together with the updated local concentrations of elements, \(b_{j}^{k+1}\), from the previous step. Let the on-demand learning algorithm determine, in each cell, if it needs to fully solve the current equilibrium problem or if it can quickly estimate the species amounts \(n=(n_{1},\ldots ,n_{\mathrm{N}})\) using a previously learned problem with similar inputs.
Appendix 5: Normalization in the Smart Chemical Equilibrium Algorithm
The definition of x, y, f, and \(f_{x}\) in Sect. 4 ignores the fact of different dimensions across the entries in x and y. For example, \(x=(T,P,b)\) and \(y=(n,\mu )\). Because the on-demand machine learning algorithm requires a search procedure, which may or may not rely on searching of the nearest neighbor, it can help if the entries in these vectors are dimensionless. Therefore, we introduce below normalized and dimensionless variables
where \({T^{\circ }=298.15\hbox{K}}\), \({P^{\circ }=1\hbox{bar}}\), and \({b_{\Sigma }=\mathrm{sum}(b)}\). We then use (72) in more proper and preferred definitions of x, y, f , and \(f_{x}\) below, so that these mathematical entities are deprived of dimensions
Finally, the following observations can be made:
- 1.
The evaluation of f(x) can be done as follows: compute \({T={\bar{T}}T^{\circ }}\) and \({P={\bar{P}}P^{\circ }}\), then \({{\bar{n}}=\varphi (T,P,{\bar{b}})}\), using gem or lma, and finally, evaluate the non-ideal thermodynamic model of each phase in the chemical system to compute \(\mu =\mu (T,P,{\bar{n}})\), and then its normalization \({\bar{\mu }}=\mu /RT\).
- 2.
The sensitivity derivatives with and without normalization are related as follows:
$$\begin{aligned} \frac{\partial n}{\partial T}\equiv \frac{b_{\Sigma }}{T^{\circ }}\frac{\partial{\bar{n}}}{\partial{\bar{T}}},\quad \frac{\partial n}{\partial P}\equiv \frac{b_{\Sigma }}{P^{\circ }}\frac{\partial{\bar{n}}}{\partial{\bar{P}}},\quad \frac{\partial n}{\partial b}\equiv \frac{\partial{\bar{n}}}{\partial{\bar{b}}}. \end{aligned}$$(74)
Rights and permissions
About this article
Cite this article
Leal, A.M.M., Kyas, S., Kulik, D.A. et al. Accelerating Reactive Transport Modeling: On-Demand Machine Learning Algorithm for Chemical Equilibrium Calculations. Transp Porous Med 133, 161–204 (2020). https://doi.org/10.1007/s11242-020-01412-1
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s11242-020-01412-1