Theory behind the geochemistry module
The geochemistry
module is designed to solve reactive transport in geochemical systems. The geochemistry
module's functionality is a subset of that described in the authoritative, pedagogical textbook Bethke (2007). In order of help users understand the concepts of geochemical modelling, the geochemistry
theory documentation uses notation and ideas drawn from this textbook, so readers will undoubtably find the textbook invaluable.
Reactions in the geochemistry module
Notation and definitions are described in Nomenclature.
This section describes the type of geochemical reactions that the geochemistry module can solve. This section does not consider transport: in this section, the geochemical system is conceptualised as a well-mixed "test tube" containing an aqueous solution, possibly in equilibrium with gases in the atmosphere, and possibly containing some precipitated minerals. Both equilibrium and kinetic reactions may be used in models solved by the geochemistry module.
Readers who are just starting to explore the world of geochemistry might find an introduction to equilibrium reactions, equilibrium constants, etc useful.
Database
All geochemical databases contain a list of chemical components along with their properties such as molar weight and charge, and reactions between those species, along with temperature-dependent equilibrium constants for those reactions. Hence, the geochemical database defines the possible scope of geochemical models built using the database (if the chemical component or reaction is not in the database it cannot possibly appear in a model).
The geochemistry module assumes the database is in a specific JSON format. The default database used in all geochemistry-module examples and tests is JSON version of the Geochemist's Workbench gwb_llnl.dat
January 2019 database. A python script is provided to convert the popular Geochemist's Workbench and EQ3/6 Wolery (2010) databases to the JSON format.
More discussion concerning the database is found here.
Chemical components in a model
The database defines the possible chemical components, and from this large set, the user selects the components that appear in the model, by defining the basis, minerals to exclude or include, gases to include and kinetic reactions (see below).
Equilibrium reactions and mass action
All equilibrium reactions are specified in the database. The database also contains temperature-dependent equilibrium constants, , for all these reactions. By definition, all non-basis chemical species can be expressed in terms of the basis components.
Secondary species
Since secondary species are not sorbing, their reaction does not involve : (1) Mass-action equilibrium for the reaction Eq. (1) with equilibrium constant , may be rearranged for the molality of the secondary species (2) Geochemists typically ignore the dimensional inconsistencies in this equation. Instead, it is conventional to omit dimension-full factors of "1", and simply use consistent units of moles, kg, bars and Kelvin throughout all calculations.
Mineral species
For any mineral in equilibrium (including those in the basis, but the equation is trivial for them): (3) Define the activity product for all minerals (4) which may be compared with the expression for the reaction's equilibrium constant, . Define the "saturation index": (5) There are three possibilities:
. The mineral is at equilibrium.
. The mineral is supersaturated, which means the system will try to precipitate the mineral.
. The mineral is undersaturated, which means the aqueous solution will dissolve more of the mineral.
Sorbed species
The reaction for sorbed species is: (6) when using the Langmuir () or the surface-complexation approach (). The single stoichiometric coefficient determines the type of surface site that the surface complex will adsorb onto (there is no sum over ).
In the Langmuir approach, each sorption reaction is of the form Eq. (6) and has an equilibrium constant , so that mass-action reads (7) Here is the molality of unoccupied sites and is the molality of the sorbed species.
The surface-complexation accounts for the electrical state of the porous-skeleton surface, which can vary sharply with pH, ionic strength and solution composition. The mass action for each surface complex is (8) which sets the molality of each surface complex. Here:
[units: dimensionless] is the electronic charge of the surface complex
[units: J.C = V] is the surface potential of the site, , onto which the surface species is adsorbing onto. The equation for is set below.
C.mol is the Faraday constant
J.K.mol is the gas constant
[units: K] is temperature
Computing the surface potential, , requires an additional equation (9) The sum on the right-hand side includes only the surface species that sorb onto surface site , so the right-hand side of this equation depends on through equations such as Eq. (8). The additional notation introduced here is as follows.
[units: m] is the surface area of precipitated mineral upon which the resides. Most commonly, the user specifies a specific surface area in [m/g(of mineral)]. Hence is proportional to the mole number of a mineral precipitate, , with coefficient of proportionality being the mineral's density [units: g.mol] and the user-supplied specific surface area.
[units: dimensionless] is the dielectric constant: at 25C for water.
F.m is the permittivity of free space.
kg.m is the density of water.
[units: mol.kg] is the ionic strength.
is the charge on the background solute, which is assumed to be
[units: dimensionless] is the charge of the surface complex .
Kinetic reactions
The reactions for kinetically-controlled species — (decoupled redox reactions), (minerals that slowly dissolve or precipitate) and (kinetically-controlled surface complexation) — are similar in form to Eq. (1), Eq. (3) and Eq. (6), and the database specifies the equilibrium constants for these reactions. All the material below holds for kinetically-controlled biogeochemical reactions too, but such cases contain additional complications, and details are found on the biogeochemistry page. Using the collective notation , (10) with equilibrium constant . The activity product is (11) which is of the same form as Eq. (4).
The mole number of is not governed by mass-action equations such as Eq. (8). Instead, denote the dissolution rate of by [units: mol.s]: (12) Precipitation is assumed to follow the same rate as dissolution.
In the geochemistry module, the rate is a sum of an arbitrary number of terms of the form (13) Each term in the sum may have different parameters , , , etc. This is a rather complicated equation, and a full explanation and examples are given in the GeochemistryKineticRate documentation.
Because the overall kinetic rate is a sum of terms of the form Eq. (13), acid-neutral-alkali promotion as listed in the correlations prepared by Palandri and Kharaka (2004) may be used in geochemistry
models.
Activity and fugacity
Only the Debye-Huckel B-dot model along with relevant formulae for neutral species and water are coded into the geochemistry
module. The virial Pitzer/HMW models have not yet been included. Details may be found here. Computations of gas fugacity use the Spycher-Reed (Spycher and Reed, 1988) fugacity formula (Xu et al., 2014; Prausnitz et al., 1998). Details may be found here.
Constraints
A constraint must be supplied by the user for each member of the basis in order that the geochemical system has a unique mathematical solution. The following types of constraints are possible in the geochemistry module:
For water :
the mass of solvent water, , or
the total bulk composition (as moles or in mass units): this includes the solvent water, as well as water "inside" secondary species and sorbed species, so the total bulk mole number is (and possible contributions from kinetic species: see below), where is the number of moles of HO in a kg of water, or
the activity, , or its logarithm, .
For aqueous basis species :
the free concentration, (in molal, g/kg, etc, units), or
the total bulk composition (as moles or in mass units), so the total bulk mole number is (and possible contributions from kinetic species: see below), or
the activity, , or its logarithm, (so that the pH may be controlled, for example).
For precipitated minerals :
the free (precipitated) mole number, , or free mass or free volume, or
the total bulk mole number (and possible contributions from kinetic species: see below), or total bulk mass.
For gases with fixed fugacity, or must be provided.
For sorbing sites :
the free concentration, , (in molal, g/kg, etc, units), or
the total bulk composition (as moles or in mass units), so the total bulk mole number is (and possible contributions from kinetic species: see below).
Using the species' molar volume and molar mass, all masses or volumes are converted to mole and molal units, which are used internally within the geochemistry code.
These constraints must ensure charge-neutrality. In geochemistry
models, a charge-balance species must be nominated, and its molality will be adjusted by the geochemistry
module to ensure charge neutrality.
In addition, all kinetic species, , must be provided with an initial mole number or mass, or, for minerals, an initial volume. If the constraint_meaning
for a basis species is set to bulk_composition_with_kinetic
, then the above sums for total bulk composition will also include contributions from kinetic species. See the kinetic_albite page for an example.
During any geochemistry-module simulation, the basis may change (in response to precipitation or dissolution, for example), however, the constraints provided by the user are always respected (except for the charge-balance species, as noted above). For instance, if the total bulk number of H is constrained and H is swapped out of the basis, the total mole number of H is conserved by the new basis.
Reaction paths
The following reaction paths are available in the geochemistry module:
Adding reactants at user-defined rates. These reactants may be basis species, secondary species, minerals, etc.
Controlling temperature with a user-defined function.
Changing temperature and altering the composition by adding cooler/hotter reactants at user-defined rates.
Removing one or more species activity constraints or gas fugacity constraints at user-supplied times.
Controlling species activity (such as the pH) or gas fugacity with user-supplied functions.
Discarding masses of any minerals present in the equilibrium solution (called a "dump" by Bethke (2007)).
Removing mineral masses at the end of each time-step (setting very small) (called "flow-through" by Bethke (2007))
Adding pure HO and removing an equal mass of water components and solutes it contains (called "flush" by Bethke (2007))
Combinations of these may be used. For instance, changing temperature while controlling species activity. Worked examples are provided.
Differences between the Geochemist's Workbench and the geochemistry
module
There are various differences between Geochemist's Workbench and geochemistry
. This means that a translation of input files and results can involve some subtleties.
Equations and solution method without transport
The geochemical system is fully defined when the mole numbers of all species, gas fugacities and surface potentials (if any) are known. Without transport, these quantities are time-dependent but not spatially-dependent. If all the following are known at any time:
the mass of solvent water, ;
the molality of all aqueous basis species, ;
the molality of all unoccupied surface sites, ;
the surface potentials, ;
the mole number of kinetic species, ;
the mole number of precipitated minerals, ;
the fugacity of the gases, ;
then an estimate of the ionic strength and stoichiometric ionic strength, may be performed to obtain:
the activity of water, ;
the activity all aqueous basis species, (recall that the mineral activities are all unity);
the activity coefficient for all secondary species, ;
and the following can be calculated:
the molality of all secondary species, , using Eq. (2), as well as the molality of dissolved gases;
the mineral activity products, , using Eq. (4), and the mineral saturation indices using Eq. (5);
the molality of the sorbed species using Eq. (7) or Eq. (8).
Calculating the molality of the secondary species in this way allows further refinement of the estimations of (stoichiometric) ionic strength, a re-calculation of the activity coefficients, and further refinement of . Hence, if items 1–7 were completed, items 8–13 could be iterated to fully define the geochemical system. (A slightly more sophisticated iterative scheme is used in the geochemistry module, as outlined below.) Most of the focus in geochemical solvers is therefore spent on items 1–7.
In fact, items 1–7 may be further reduced by noting that: the fugacity of gases, is known by definition (it is potentially time-dependent, but is fixed by the user); all minerals decouple from the system since the mineral activity is unity ( does not impact any other equation), so may be determined once the other items are completed. This latter point is not true if in depends on , and is not fixed by the user through a constraint. This means the accuracy of the equation lags one step behind that of , , and in the iterative scheme outlined below.
Equations relating molality and mole numbers of the basis
During the mathematical solve procedure, the geochemistry
module forms equations to relate the molality and mole number of the basis species to each other and the molality of the secondary species. These are listed in a separate page.
ODEs
In the setting without transport, a system of ODEs provides items 1–5. The total number of moles of water in the equilibrium system is (14) Here is the number of moles of HO in a kg of water, the second term is due to one mole of secondary species containing moles of water "inside it", and similarly for the third term. Kinetic contributions from Eq. (12) provide the first ODE: (15) Here is an external source of HO (defined by the user, as mentioned in the Reaction Paths section).
A similar set of equations is provided by considering the total mole number of species : (16) Again, is an external source of basis species .
Similarly, a set of equations expresses the change in the mole number of : (17) where is an external source of .
Eq. (9) provides additional algebraic (not ODEs) equations for .
Eq. (12) completes the description with further ODEs: (18)
The external sources, , are determined by the reaction path (see above).
Iterative solution scheme
The previous section defined ODEs and, in the case of surface complexation, algebraic equations to solve. In contrast to Bethke (2007), in the geochemistry module these are solved in a fully-implicit fashion using a Newton-Raphson procedure to ensure unconditional stability. Within each time-step the following iterative scheme is used:
Temperature-dependent quantities such as the Debye-Huckel quantities are calculated.
All quantities, such as , , and are initialised from their previous time-step values. At the first timestep, the initialization methods described in Bethke (2007) are used.
Any known basis activities (such as pH) are prescribed and fixed.
The ionic strength, stoichiometric ionic strength, water activity and activity coefficients are computed.
The basis activities are computed, using .
The equilibrium molalities are computed. Repeat from Step 4 a user-defined amount of times (default is no repetition).
Perform 1 step in a Newton-Raphson iteration to solve the implicit system given by Eq. (15), Eq. (16), Eq. (17), Eq. (9) and Eq. (18). For instance, Eq. (15) reads
(19) where is defined in terms of , etc, by Eq. (2), and similarly for and .
Compute the mineral molalities, , and repeat from Step 3 until the Newton-Raphson procedure has converged.
After convergence, or before the time-step commences, various actions such as "dump" or "flow-through", may be performed (see the above section concerning reaction paths).
This is an overview of the solution scheme and there are many subtleties, some of them mentioned in Bethke (2007):
Care must be taken to avoid overflows or underflows with numbers such as or .
If the Newton-Raphson procedure fails to converge (after a user-specified number of steps), the time-step size may be halved and the procedure re-attempted.
If the initial residual, such as Eq. (19), for a species is too large, then the initial-guess molalities may be repeatedly halved or doubled to reduce the residual.
When solving the equations such as Eq. (19), derivatives of the activity-coefficients are not included in the Jacobian.
The Newton-Raphson method is under-relaxed to avoid negative molalities. At iteration number , define
then the NR update takes the form
Charge-neutrality is enforced throughout the procedure.
After Newton-Raphson convergence, the molalities of minerals are checked. If some then the mineral was completed consumed (and more). Similarly, computing the saturation index of minerals not in the basis may reveal a supersaturated mineral that should be allowed to precipitate. Therefore, after NR convergence, the following procedure involving basis swaps is used.
All are computed. If one or more a negative, then the one that is the most negative is removed from the basis. It is replaced by secondary species that satisfies . The NR procedure is resolved.
The sauration index of each mineral, , that can form in a reaction model is checked for supersaturation. If one or more are supersaturated, the one with the largest saturation index is added into the basis, and something removed from the basis. This "something" is: preferably, a primary species satisfying ; if no primary species appears in the reaction for then the mineral in the reaction for that satisfies . The NR procedure is re-solved (and checked for undersaturation and supersaturation, etc).
During the whole procedure, if a basis molality becomes very small then numerical instability can result, because making small corrections to its molality can lead to large deviations in the molalities of the secondary species. In this case, it may be swapped for an abundant secondary species.
Transport
To perform reactive-transport simulations, coupling with the PorousFlow
module is recommended. This enables advanced features such as:
pressure and temperature that tightly couple with fluid flows, instead of being specified by uncoupled dynamics
densities, viscosities, etc, that depend on solute concentrations, temperature and pressure, instead of being constant
porosity and permeability that change with precipitation and dissolution
multiphase flow
coupling with geomechanics
sophisticated numerical stabilization
Nevertheless, rudimentary transport is available as part of the geochemistry
module. The relevant Kernels are GeochemistryTimeDerivative, ConservativeAdvection (preferably with upwinding_type = full
) and GeochemistryDispersion. The following material describes reactive transport in MOOSE, independently of whether the PorousFlow
or geochemistry
module is being used to facilitate the transport.
Volumes, concentrations and mass conservation
Define the concentration, of a component (water, basis aqueous species, secondary aqueous species, etc) as where [units: m] is the total volume of the aqueous solution and is the total number of moles of the component. Hence the units of are mol.m.
Now introduce the porous skeleton, through which the aqueous solution flows. The aqueous solution inhabits its void space. Introduce the porosity [dimensionless], Here, [units: m] is the volume of the rock grains of the porous skeleton: it is the volume of the porous skeleton if it were crushed so that it contained no voids. is a spatial volume containing the porous skeleton. Hence, the quantity is the total number of moles of aqueous solution within a volume of porous material.
The dynamics of , if any, are not provided by the geochemistry
module (if changes it is easiest to use the PorousFlow
module).
The continuity equation (mass conservation) reads or Here:
[units: s] is time
[units: m] is the vector spatial derivatives
[units: mol.s.m] is the fluid flux vector, so is the flux [units: mol.s] into the volume through its boundary.
[units: mol.s.m] is a source of fluid: it is the rate of production [units: mol.s] per unit volume of fluid (not per unit volume of porous material).
Reactive-transport equations
Only the water, the primary aqueous species, the minerals that are mobile and the dissolved gases, are transported. Precipitated minerals (), sorbed species () and sorption sites (), are assumed to be immobile. Hence, the following concentrations of basis species are involved in transport (indicated by the subscript "T"): Here . In addition, if there are mobile kinetic species (not minerals or sorbed species):
there are contributions on the right-hand side of the above equations of the form .
the concentrations of these species, , also transport.
Fluid density is assumed to be constant in the geochemistry
module. Therefore, transport acts on the basis species' total concentrations, which are now spatially and temporally varying functions. The continuity equation for the water component is therefore of the form Here:
is the bulk composition of water, given in Eq. (14).
[units: m.s] is the Darcy flux vector. It is computed by the
PorousFlow
module when employing that module to perform the transport. In thegeochemistry
module is assumed to be given by the user: it could be a user-defined set of functions, or a field that varies spatially and temporally by solving Darcy's equation. Usually , where:[units: m] is the permeability;
[units: Pa.s] is the fluid viscosity;
[units: Pa] is its porepressure;
[units: kg.m] is its density;
and [units: m.s] is the acceleration due to gravity;
in this equation, and indicate spatial directions, not primary and secondary species.
[units: m.s] is the hydrodynamic dispersion tensor.
PorousFlow
has more advanced concepts of dispersion than thegeochemistry
module: is assumed to be given to thegeochemistry
module by the user[units: mol.s.m] is the kinetic rate per volume of aqueous solution, , for kinetic species .
[units: mol.s.m] is a source of HO: it is the rate of production [units: mol.s] per unit volume of aqueous solution, .
Similar equations hold for the other basis species and transported kinetic species. For example, Eq. (16), Eq. (17) and Eq. (18) are all multiplied by and the appropriate transport term of the form is added.
The above equation is dissimilar to Bethke (2007), who uses in the time-derivatives. It is only because he uses operator splitting, where the contributions from the transport are added as source terms to the ODEs for , that his formulae (which I think is incorrect) actually gives the correct result.
Solution method
An operator-splitting solution method is strongly recommended since it is used in all other reactive-transport codes. This is a two-step method:
The
PorousFlow
module orgeochemistry
module transports the solutes in the aqueous phase (as well as the temperature distribution in the non-isothermalPorousFlow
case). This provides the temperature and extra chemical source terms at each point in the spatial domain.With these extra sources, the
geochemistry
module solves for the mole numbers of each species at each point in the spatial domain, using the Newton-Raphson method outlined in the sections above.
This type of model is more complicated to construct than usual MOOSE models, and users are encouraged to consult the examples
Computational aspects
Geochemistry
simulations use a large amount of memory since they store information about a complete geochemical system at each finite-element node, and, optionally, populate a huge number of AuxVariables with useful information. On the other hand, ignoring transport, they are almost embarrassingly parallel, so may be solved efficiently using a large number of processors. Solver choice can significantly impact compute time. A separate page describes
memory usage for pure geochemistry simulations
compute time for pure geochemistry simulations, and scaling with number of processors
relative compute time spent in transport and reactions
solver choices for simulations coupled with PorousFlow
reactive transport with multiple processors
References
- Craig M. Bethke.
Geochemical and Biogeochemical Reaction Modeling.
Cambridge University Press, 2 edition, 2007.
doi:10.1017/CBO9780511619670.[BibTeX]
- J. L. Palandri and Y. K. Kharaka.
A compilation of rate parameters of water-mineral interaction kinetics for application to geochemical modelling.
Technical Report OF 2004-1068, U.S. Geological Survey, 2004.
URL: https://pubs.usgs.gov/of/2004/1068/.[BibTeX]
- John M. Prausnitz, Rudiger N. Lichtenthaler, and Edmundo Gomes de Azevedo.
Molecular Thermodynamics of Fluid-Phase Equilibria.
Pearson, 3 edition, 1998.
ISBN 9780139777455.[BibTeX]
- Nicolas F. Spycher and Mark H. Reed.
Fugacity coefficients of H2, CO2, CH4, H2 and of H2–CO2–CH4 mixutres: A virial equation treatment for moderate pressures and temperatures applicable to calculations of hydrothermal boiling.
Geochemica et Cosmochimica Acta, 52:739–749, 1988.
URL: http://www.sciencedirect.com/science/article/pii/0016703788903341, doi:10.1016/0016-7037(88)90334-1.[BibTeX]
- T. J. Wolery.
Eq3/6 a software package for geochemical modeling, version 05.
12 2010.
URL: https://www.osti.gov//servlets/purl/1231666, doi:.[BibTeX]
- Tianfu Xu, Eric Sonnenthal, Nicolas Spycher, Liang Zhen, Norman Millar, and Karsten Pruess.
TOUGHREACT V3.0-OMP Reference Manual: A Parallel Simulation Program for Non-Isothermal Multiphase Geochemical Reactive Transport.
Technical Report, Lawrence Berkeley National Laboratory, 2014.
URL: https://tough.lbl.gov/assets/docs/TOUGHREACT_V3-OMP_RefManual.pdf.[BibTeX]