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, KK, 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 ApA_{p}: AjνwjAw+iνijAi+kνkjAk+mνmjAm . A_{j} \rightleftharpoons \nu_{wj}A_{w} + \sum_{i}\nu_{ij}A_{i} + \sum_{k}\nu_{kj}A_{k} + \sum_{m}\nu_{mj}A_{m} \ .(1) Mass-action equilibrium for the reaction Eq. (1) with equilibrium constant KjK_{j}, may be rearranged for the molality of the secondary species mj=awνwji(γimi)νijkakνkjmfmνmjγjKj . m_{j} = \frac{a_{w}^{\nu_{wj}}\cdot \prod_{i}(\gamma_{i}m_{i})^{\nu_{ij}} \cdot \prod_{k}a_{k}^{\nu_{kj}} \cdot \prod_{m}f_{m}^{\nu_{mj}}}{\gamma_{j}K_{j}} \ .(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): AlνwlAw+iνilAi+kνklAk+mνmlAm . A_{l} \rightleftharpoons \nu_{wl}A_{w} + \sum_{i}\nu_{il}A_{i} + \sum_{k}\nu_{kl}A_{k} + \sum_{m}\nu_{ml}A_{m} \ .(3) Define the activity product for all minerals Ql=awνwli(γimi)νilkakνklmfmνmlal , Q_{l} = \frac{a_{w}^{\nu_{wl}}\cdot \prod_{i}(\gamma_{i}m_{i})^{\nu_{il}} \cdot \prod_{k}a_{k}^{\nu_{kl}} \cdot \prod_{m}f_{m}^{\nu_{ml}}}{a_{l}} \ ,(4) which may be compared with the expression for the reaction's equilibrium constant, KlK_{l}. Define the "saturation index": SIl=log10(Ql/Kl) . \mathrm{SI}_{l} = \log_{10}\left(Q_{l}/K_{l}\right) \ .(5) There are three possibilities:

  • SI=0\mathrm{SI}=0. The mineral is at equilibrium.

  • SI>0\mathrm{SI}>0. The mineral is supersaturated, which means the system will try to precipitate the mineral.

  • SI<0\mathrm{SI}<0. The mineral is undersaturated, which means the aqueous solution will dissolve more of the mineral.

Sorbed species

The reaction for sorbed species is: AqνwqAw+iνiqAi+kνkqAk+mνmqAm+νpqAp , A_{q} \rightleftharpoons \nu_{wq}A_{w} + \sum_{i}\nu_{iq}A_{i} + \sum_{k}\nu_{kq}A_{k} + \sum_{m}\nu_{mq}A_{m} + \nu_{pq}A_{p} \ ,(6) when using the Langmuir (Np=1N_{p}=1) or the surface-complexation approach (Np1N_{p}\geq 1). The single stoichiometric coefficient νpq\nu_{pq} determines the type of surface site that the surface complex AqA_{q} will adsorb onto (there is no sum over pp).

In the Langmuir approach, each sorption reaction is of the form Eq. (6) and has an equilibrium constant KqK_{q}, so that mass-action reads mq=1Kq(awνwqi(γimi)νiqkakνkqmfmνmqmpνpq) . m_{q} = \frac{1}{K_{q}} \left(a_{w}^{\nu_{wq}}\cdot \prod_{i}(\gamma_{i}m_{i})^{\nu_{iq}} \cdot \prod_{k}a_{k}^{\nu_{kq}} \cdot \prod_{m}f_{m}^{\nu_{mq}} \cdot m_{p}^{\nu_{pq}} \right) \ .(7) Here mpm_{p} is the molality of unoccupied sites and mqm_{q} 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 AqA_{q} is mq=1KqezaFΨp/RT(awνwqi(γimi)νiqkakνkqmfmνmqmpνpq) . m_{q} = \frac{1}{K_{q}e^{z_{a}F\Psi_{p}/RT}} \left(a_{w}^{\nu_{wq}}\cdot \prod_{i}(\gamma_{i}m_{i})^{\nu_{iq}} \cdot \prod_{k}a_{k}^{\nu_{kq}} \cdot \prod_{m}f_{m}^{\nu_{mq}} \cdot m_{p}^{\nu_{pq}} \right) \ .(8) which sets the molality of each surface complex. Here:

  • zqz_{q} [units: dimensionless] is the electronic charge of the surface complex AqA_{q}

  • Ψp\Psi_{p} [units: J.C1^{-1} = V] is the surface potential of the site, ApA_{p}, onto which the surface species AqA_{q} is adsorbing onto. The equation for Ψp\Psi_{p} is set below.

  • F=96485F = 96485\ldots \,C.mol1^{-1} is the Faraday constant

  • R=8.314R = 8.314\ldots\,J.K1^{-1}.mol1^{-1} is the gas constant

  • TT [units: K] is temperature

Computing the surface potential, Ψp\Psi_{p}, requires an additional equation AsfFnw8RTϵϵ0ρwIsinh(z±ΨpF2RT)=qzqmq . \frac{A_{\mathrm{sf}}}{Fn_{w}}\sqrt{8RT\epsilon\epsilon_{0}\rho_{w} I}\sinh \left(\frac{z_{\pm}\Psi_{p} F}{2RT}\right) = \sum_{q}z_{q}m_{q} \ .(9) The sum on the right-hand side includes only the surface species that sorb onto surface site ApA_{p}, so the right-hand side of this equation depends on Ψp\Psi_{p} through equations such as Eq. (8). The additional notation introduced here is as follows.

  • AsfA_{\mathrm{sf}} [units: m2^{2}] is the surface area of precipitated mineral upon which the ApA_{p} resides. Most commonly, the user specifies a specific surface area in [m2^{2}/g(of mineral)]. Hence AsfA_{\mathrm{sf}} is proportional to the mole number of a mineral precipitate, nkn_{k}, with coefficient of proportionality being the mineral's density [units: g.mol1^{-1}] and the user-supplied specific surface area.

  • ϵ\epsilon [units: dimensionless] is the dielectric constant: ϵ=78.5\epsilon = 78.5 at 25^{\circ}C for water.

  • ϵ0=8.854×1012\epsilon_{0} = 8.854\times 10^{-12}\,F.m1^{-1} is the permittivity of free space.

  • ρw=1000\rho_{w}=1000\,kg.m3^{-3} is the density of water.

  • II [units: mol.kg1^{-1}] is the ionic strength.

  • z±z_{\pm} is the charge on the background solute, which is assumed to be z±=1z_{\pm}=1

  • zqz_{q} [units: dimensionless] is the charge of the surface complex AqA_{q}.

Kinetic reactions

The reactions for kinetically-controlled species — AjˉA_{\bar{j}} (decoupled redox reactions), AlˉA_{\bar{l}} (minerals that slowly dissolve or precipitate) and AqˉA_{\bar{q}} (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 AkˉA_{\bar{k}}, AkˉνwkˉAw+iνikˉAi+kνkkˉAk+mνmkˉAm+νpkˉAp , A_{\bar{k}} \rightleftharpoons \nu_{w\bar{k}}A_{w} + \sum_{i}\nu_{i\bar{k}}A_{i} + \sum_{k}\nu_{k\bar{k}}A_{k} + \sum_{m}\nu_{m\bar{k}}A_{m} + \nu_{p\bar{k}}A_{p} \ ,(10) with equilibrium constant KkˉK_{\bar{k}}. The activity product is Qkˉ=awνwkˉi(γimi)νikˉkakνkkˉmfmνmkˉapνpkˉakˉ , Q_{\bar{k}} = \frac{a_{w}^{\nu_{w\bar{k}}}\cdot \prod_{i}(\gamma_{i}m_{i})^{\nu_{i\bar{k}}} \cdot \prod_{k}a_{k}^{\nu_{k\bar{k}}} \cdot \prod_{m}f_{m}^{\nu_{m\bar{k}}} \cdot a_{p}^{\nu_{p\bar{k}}}}{a_{\bar{k}}} \ ,(11) which is of the same form as Eq. (4).

The mole number of AkˉA_{\bar{k}} is not governed by mass-action equations such as Eq. (8). Instead, denote the dissolution rate of AkˉA_{\bar{k}} by rkˉr_{\bar{k}} [units: mol.s1^{-1}]: dnkˉdt=rkˉ . \frac{\mathrm{d}n_{\bar{k}}}{\mathrm{d} t} = -r_{\bar{k}} \ .(12) Precipitation is assumed to follow the same rate as dissolution.

In the geochemistry module, the rate rkˉr_{\bar{k}} is a sum of an arbitrary number of terms of the form r=kA[M]m~P~(m~P~+K~P~)β~(αmαPα(mαPα+KαPα)βα)1(Q/K)θηexp(EaR(1T01T))D(Q/K) . r = kA[M] \frac{\tilde{m}^{\tilde{P}}}{(\tilde{m}^{\tilde{P}} + \tilde{K}^{\tilde{P}})^{\tilde{\beta}}}\left( \prod_{\alpha}\frac{m_{\alpha}^{P_{\alpha}}}{(m_{\alpha}^{P_{\alpha}} + K_{\alpha}^{P_{\alpha}})^{\beta_{\alpha}}} \right) \left|1 - \left(Q/K\right)^{\theta}\right|^{\eta} \exp\left( \frac{E_{a}}{R} \left(\frac{1}{T_{0}} - \frac{1}{T}\right)\right) D(Q/K) \ .(13) Each term in the sum may have different parameters kk, AA, PαP_{\alpha}, 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 AwA_{w}:

    • the mass of solvent water, nwn_{w}, 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 nw(55.51+jνwjmj+qνwqmq)n_{w}\left(55.51 + \sum_{j}\nu_{wj}m_{j} + \sum_{q}\nu_{wq}m_{q}\right) (and possible contributions from kinetic species: see below), where 55.5155.51 is the number of moles of H2_{2}O in a kg of water, or

    • the activity, awa_{w}, or its logarithm, log10aw\log_{10}a_{w}.

  • For aqueous basis species AiA_{i}:

    • the free concentration, mim_{i} (in molal, g/kgsolventwater_{\mathrm{solvent-water}}, etc, units), or

    • the total bulk composition (as moles or in mass units), so the total bulk mole number is nw(mi+jνijmj+qνiqmq)n_{w}(m_{i} + \sum_{j}\nu_{ij}m_{j} + \sum_{q}\nu_{iq}m_{q}) (and possible contributions from kinetic species: see below), or

    • the activity, ai=γimia_{i} = \gamma_{i}m_{i}, or its logarithm, log10ai\log_{10}a_{i} (so that the pH may be controlled, for example).

  • For precipitated minerals AkA_{k}:

    • the free (precipitated) mole number, nkn_{k}, or free mass or free volume, or

    • the total bulk mole number nk+nw(jνkjmj+qνkqmq)n_{k} + n_{w}(\sum_{j}\nu_{kj}m_{j} + \sum_{q}\nu_{kq}m_{q}) (and possible contributions from kinetic species: see below), or total bulk mass.

  • For gases with fixed fugacity, fmf_{m} or log10fm\log_{10}f_{m} must be provided.

  • For sorbing sites ApA_{p}:

    • the free concentration, mpm_{p}, (in molal, g/kgsolventwater_{\mathrm{solvent-water}}, etc, units), or

    • the total bulk composition (as moles or in mass units), so the total bulk mole number is nw(mp+qνpqmq)n_{w}(m_{p} + \sum_{q}\nu_{pq}m_{q}) (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, AkˉA_{\bar{k}}, 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 nkn_{k} very small) (called "flow-through" by Bethke (2007))

  • Adding pure H2_{2}O 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:

  1. the mass of solvent water, nwn_{w};

  2. the molality of all aqueous basis species, mim_{i};

  3. the molality of all unoccupied surface sites, mpm_{p};

  4. the surface potentials, Ψp\Psi_{p};

  5. the mole number of kinetic species, nkˉn_{\bar{k}};

  6. the mole number of precipitated minerals, nkn_{k};

  7. the fugacity of the gases, fmf_{m};

then an estimate of the ionic strength and stoichiometric ionic strength, may be performed to obtain:

  1. the activity of water, awa_{w};

  2. the activity all aqueous basis species, ai=γimia_{i} = \gamma_{i} m_{i} (recall that the mineral activities are all unity);

  3. the activity coefficient for all secondary species, γj\gamma_{j};

and the following can be calculated:

  1. the molality of all secondary species, mjm_{j}, using Eq. (2), as well as the molality of dissolved gases;

  2. the mineral activity products, QlQ_{l}, using Eq. (4), and the mineral saturation indices SIl\mathrm{SI}_{l} using Eq. (5);

  3. 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 mjm_{j}. 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, fmf_{m} 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 (nkn_{k} does not impact any other equation), so nk(t)n_{k}(t) may be determined once the other items are completed. This latter point is not true if AsfA_{\mathrm{sf}} in Ψp\Psi_{p} depends on nkn_{k}, and nkn_{k} is not fixed by the user through a constraint. This means the accuracy of the Ψp\Psi_{p} equation lags one step behind that of nwn_{w}, mim_{i}, mpm_{p} and nkˉn_{\bar{k}} 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 Mw=nw(55.51+jνwjmj+qνwqmq) . M_{w} = n_{w}\left(55.51 + \sum_{j}\nu_{wj}m_{j} + \sum_{q}\nu_{wq}m_{q}\right) \ .(14) Here 55.5155.51 is the number of moles of H2_{2}O in a kg of water, the second term is due to one mole of secondary species jj containing νwj\nu_{wj} moles of water "inside it", and similarly for the third term. Kinetic contributions from Eq. (12) provide the first ODE: ddt[nw(55.51+jνwjmj+qνwqmq)]=kˉνwkˉrkˉ+qw . \frac{\mathrm{d}}{\mathrm{d}t} \left[ n_{w}\left(55.51 + \sum_{j}\nu_{wj}m_{j} + \sum_{q}\nu_{wq}m_{q}\right) \right] = \sum_{\bar{k}}\nu_{w\bar{k}}r_{\bar{k}} + q_{w} \ .(15) Here qw(t)q_{w}(t) is an external source of H2_{2}O (defined by the user, as mentioned in the Reaction Paths section).

A similar set of NiN_{i} equations is provided by considering the total mole number of species AiA_{i}: ddt[nw(mi+jνijmj+qνiqmq)]=kˉνikˉrkˉ+qi . \frac{\mathrm{d}}{\mathrm{d}t} \left[ n_{w}\left(m_{i} + \sum_{j}\nu_{ij}m_{j} + \sum_{q}\nu_{iq}m_{q}\right) \right] = \sum_{\bar{k}}\nu_{i\bar{k}}r_{\bar{k}} + q_{i} \ .(16) Again, qi(t)q_{i}(t) is an external source of basis species AiA_{i}.

Similarly, a set of NpN_{p} equations expresses the change in the mole number of ApA_{p}: ddt[nw(mp+qνpqmq)]=kˉνpkˉrkˉ+qp , \frac{\mathrm{d}}{\mathrm{d}t} \left[ n_{w} \left(m_{p} + \sum_{q}\nu_{pq}m_{q} \right) \right] = \sum_{\bar{k}}\nu_{p\bar{k}}r_{\bar{k}} + q_{p} \ ,(17) where qp(t)q_{p}(t) is an external source of ApA_{p}.

Eq. (9) provides NpN_{p} additional algebraic (not ODEs) equations for Ψp\Psi_{p}.

Eq. (12) completes the description with NkˉN_{\bar{k}} further ODEs: dnkˉdt=rkˉ+qkˉ . \frac{\mathrm{d}n_{\bar{k}}}{\mathrm{d} t} = -r_{\bar{k}} + q_{\bar{k}} \ .(18)

The external sources, qq, are determined by the reaction path (see above).

Iterative solution scheme

The previous section defined 1+Ni+Np+Nkˉ1 + N_{i} + N_{p} + N_{\bar{k}} ODEs and, in the case of surface complexation, NpN_{p} 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:

  1. Temperature-dependent quantities such as the Debye-Huckel quantities are calculated.

  2. All quantities, such as nwn_{w}, mim_{i}, mpm_{p} and nkˉn_{\bar{k}} are initialised from their previous time-step values. At the first timestep, the initialization methods described in Bethke (2007) are used.

  3. Any known basis activities (such as pH) are prescribed and fixed.

  4. The ionic strength, stoichiometric ionic strength, water activity and activity coefficients are computed.

  5. The basis activities are computed, using ai=γimia_{i} = \gamma_{i}m_{i}.

  6. The equilibrium molalities are computed. Repeat from Step 4 a user-defined amount of times (default is no repetition).

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

0=Rw=nw(t)(55.51+jνwjmj(t)+qνwqmq(t))nw(tdt)(55.51+jνwjmj(tdt)+qνwqmq(tdt))dt(kˉνwkˉrkˉ(t)+qw(t)) , \begin{aligned} 0 = R_{w} = & n_{w}(t)\left(55.51 + \sum_{j}\nu_{wj}m_{j}(t) + \sum_{q}\nu_{wq}m_{q}(t)\right) \\ & - n_{w}(t - dt)\left(55.51 + \sum_{j}\nu_{wj}m_{j}(t - dt) + \sum_{q}\nu_{wq}m_{q}(t - dt)\right) \\ & - dt \left(\sum_{\bar{k}}\nu_{w\bar{k}}r_{\bar{k}}(t) + q_{w}(t) \right) \ , \end{aligned}(19) where mj(t)m_{j}(t) is defined in terms of mi(t)m_{i}(t), etc, by Eq. (2), and similarly for mq(t)m_{q}(t) and rkˉ(t)r_{\bar{k}}(t).

  1. Compute the mineral molalities, nkn_{k}, 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 10100010^{1000} or 10100010^{-1000}.

  • 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 qq, define

1δ=max(1,Δnwnw(q)/2,Δmimi(q)/2,Δmpmp(q)/2) ,\frac{1}{\delta} = \mathrm{max}\left(1, -\frac{\Delta n_{w}}{n_{w}^{(q)}/2}, -\frac{\Delta m_{i}}{m_{i}^{(q)}/2}, -\frac{\Delta m_{p}}{m_{p}^{(q)}/2} \right) \ , then the NR update takes the form nw(q+1)=nw(q)+δΔnwmi(q+1)=mi(q)+δΔmimp(q+1)=mp(q)+δΔmp\begin{aligned} n_{w}^{(q+1)} & = n_{w}^{(q)} + \delta\, \Delta n_{w} \\ m_{i}^{(q+1)} & = m_{i}^{(q)} + \delta\, \Delta m_{i} \\ m_{p}^{(q+1)} & = m_{p}^{(q)} + \delta\, \Delta m_{p} \end{aligned}

  • Charge-neutrality is enforced throughout the procedure.

  • After Newton-Raphson convergence, the molalities of minerals are checked. If some nk<0n_{k}<0 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 nkn_{k} 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 AjA_{j} that satisfies maxj(mjνkj)\mathrm{max}_{j}(m_{j}|\nu_{kj}|). The NR procedure is resolved.

    • The sauration index of each mineral, AlA_{l}, 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 maxi(νil/mi)\mathrm{max}_{i}(|\nu_{il}|/m_{i}); if no primary species appears in the reaction for AlA_{l} then the mineral in the reaction for AlA_{l} that satisfies mink(nk/νkl)\mathrm{min}_{k}(n_{k}/\nu_{kl}). 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, CC of a component (water, basis aqueous species, secondary aqueous species, etc) as C=MVsolution ,C = \frac{M}{V_{\mathrm{solution}}} \ , where VsolutionV_{\mathrm{solution}} [units: m3^{3}] is the total volume of the aqueous solution and MM is the total number of moles of the component. Hence the units of CC are mol.m3^{-3}.

Now introduce the porous skeleton, through which the aqueous solution flows. The aqueous solution inhabits its void space. Introduce the porosity [dimensionless], ϕ=VvoidVsolid+Vvoid=VvoidV .\phi = \frac{V_{\mathrm{void}}}{V_{\mathrm{solid}} + V_{\mathrm{void}}} = \frac{V_{\mathrm{void}}}{V} \ . Here, VsolidV_{\mathrm{solid}} [units: m3^{3}] 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. VV is a spatial volume containing the porous skeleton. Hence, the quantity VϕC ,\int_{V} \phi C \ , is the total number of moles of aqueous solution within a volume VV of porous material.

The dynamics of ϕ\phi, if any, are not provided by the geochemistry module (if ϕ\phi changes it is easiest to use the PorousFlow module).

The continuity equation (mass conservation) reads ddtVϕC=Vn.F+VϕQ\frac{\mathrm{d}}{\mathrm{d} t} \int_{V}\phi C = \int_{\partial V}n.F + \int_{V} \phi Q or t(ϕC)+F=ϕQ .\frac{\partial}{\partial t}(\phi C) + \nabla\cdot F = \phi Q \ . Here:

  • tt [units: s] is time

  • \nabla [units: m1^{-1}] is the vector spatial derivatives

  • FF [units: mol.s1^{-1}.m2^{-2}] is the fluid flux vector, so Vn.F\int_{\partial V}n.F is the flux [units: mol.s1^{-1}] into the volume VV through its boundary.

  • QQ [units: mol.s1^{-1}.m3^{-3}] is a source of fluid: it is the rate of production [units: mol.s1^{-1}] 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 (nkn_{k}), sorbed species (mqm_{q}) and sorption sites (mpm_{p}), are assumed to be immobile. Hence, the following concentrations of basis species are involved in transport (indicated by the subscript "T"): CT,w=cw(55.51+jνwjmj)CT,i=cw(mi+jνijmj)CT,k=cwjνkjmjCT,m=cwjνmjmj\begin{aligned} C_{T,w} & = c_{w} \left( 55.51 + \sum_{j}\nu_{wj}m_{j} \right) \\ C_{T,i} & = c_{w} \left( m_{i} + \sum_{j}\nu_{ij}m_{j} \right) \\ C_{T,k} & = c_{w} \sum_{j}\nu_{kj}m_{j} \\ C_{T,m} & = c_{w} \sum_{j}\nu_{mj}m_{j} \\ \end{aligned} Here cw=nw/Vsolutionc_{w} = n_{w}/V_{\mathrm{solution}}. 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 kˉνkˉnkˉ/Vsolution\sum_{\bar{k}}\nu_{\ast\bar{k}}n_{\bar{k}}/V_{\mathrm{solution}}.

  • the concentrations of these species, CT,kˉ=nkˉ/VsolutionC_{T,\bar{k}} = n_{\bar{k}}/V_{\mathrm{solution}}, 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 ddtϕCw+(qϕD)CT,w=kˉνwkˉϕRkˉ+ϕQw\frac{\mathrm{d}}{\mathrm{d}t}\phi C_{w} + \nabla \cdot(\mathbf{q} - \phi D\nabla) C_{T,w} = \sum_{\bar{k}}\nu_{w\bar{k}}\phi R_{\bar{k}} + \phi Q_{w} \\ Here:

  • CwC_{w} is the bulk composition of water, given in Eq. (14).

  • q\mathbf{q} [units: m.s1^{-1}] is the Darcy flux vector. It is computed by the PorousFlow module when employing that module to perform the transport. In the geochemistry module q\mathbf{q} 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 qi=jkijμ(jPρgj)q_{i} = -\sum_{j}\frac{k_{ij}}{\mu}(\nabla_{j}P - \rho g_{j}), where:

    • kijk_{ij} [units: m2^{2}] is the permeability;

    • μ\mu [units: Pa.s] is the fluid viscosity;

    • PP [units: Pa] is its porepressure;

    • ρ\rho [units: kg.m3^{-3}] is its density;

    • and gjg_{j} [units: m.s2^{-2}] is the acceleration due to gravity;

    • in this equation, ii and jj indicate spatial directions, not primary and secondary species.

  • DD [units: m2^{2}.s1^{-1}] is the hydrodynamic dispersion tensor. PorousFlow has more advanced concepts of dispersion than the geochemistry module: DD is assumed to be given to the geochemistry module by the user

  • RkˉR_{\bar{k}} [units: mol.s1^{-1}.m3^{-3}] is the kinetic rate per volume of aqueous solution, rkˉ/Vsolutionr_{\bar{k}}/V_{\mathrm{solution}}, for kinetic species AkˉA_{\bar{k}}.

  • QwQ_{w} [units: mol.s1^{-1}.m3^{-3}] is a source of H2_{2}O: it is the rate of production [units: mol.s1^{-1}] per unit volume of aqueous solution, qw/Vsolutionq_{w}/V_{\mathrm{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 ϕ/Vsolution\phi/V_{\mathrm{solution}} and the appropriate transport term of the form (qϕD)CT,\nabla\cdot(\mathbf{q} - \phi D \nabla) C_{T,\ast} is added.

commentnote

The above equation is dissimilar to Bethke (2007), who uses CTC_{T} 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 (Cw,Ci,Ck,Cm)(C_{w},C_{i}, C_{k}, C_{m}), 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:

  1. The PorousFlow module or geochemistry module transports the solutes in the aqueous phase (as well as the temperature distribution in the non-isothermal PorousFlow case). This provides the temperature and extra chemical source terms at each point in the spatial domain.

  2. 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

  1. Craig M. Bethke. Geochemical and Biogeochemical Reaction Modeling. Cambridge University Press, 2 edition, 2007. doi:10.1017/CBO9780511619670.[BibTeX]
  2. 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]
  3. John M. Prausnitz, Rudiger N. Lichtenthaler, and Edmundo Gomes de Azevedo. Molecular Thermodynamics of Fluid-Phase Equilibria. Pearson, 3 edition, 1998. ISBN 9780139777455.[BibTeX]
  4. 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]
  5. 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]
  6. 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]