LCOV - code coverage report
Current view: top level - src/userobjects - GeochemistryKineticRate.C (source / functions) Hit Total Coverage
Test: idaholab/moose geochemistry: 419b9d Lines: 70 70 100.0 %
Date: 2025-08-08 20:01:54 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #include "GeochemistryKineticRate.h"
      11             : 
      12             : registerMooseObject("GeochemistryApp", GeochemistryKineticRate);
      13             : 
      14             : InputParameters
      15         162 : GeochemistryKineticRate::validParams()
      16             : {
      17         162 :   InputParameters params = GeneralUserObject::validParams();
      18         324 :   params.addRequiredParam<std::string>(
      19             :       "kinetic_species_name",
      20             :       "The name of the kinetic species that will be controlled by this rate");
      21         324 :   params.addRequiredRangeCheckedParam<Real>("intrinsic_rate_constant",
      22             :                                             "intrinsic_rate_constant >= 0.0",
      23             :                                             "The intrinsic rate constant for the reaction");
      24         486 :   params.addRangeCheckedParam<Real>(
      25             :       "area_quantity",
      26         324 :       1.0,
      27             :       "area_quantity > 0.0",
      28             :       "The surface area of the kinetic species in m^2 (if multiply_by_mass = false) or the "
      29             :       "specific surface area of the kinetic species in m^2/g (if multiply_by_mass = true)");
      30         324 :   params.addParam<bool>(
      31             :       "multiply_by_mass",
      32         324 :       false,
      33             :       "Whether the rate should be multiplied by the kinetic_species mass (in grams)");
      34         324 :   params.addParam<Real>("kinetic_molal_index",
      35         324 :                         0.0,
      36             :                         "The rate is multiplied by kinetic_species_molality^kinetic_molal_index / "
      37             :                         "(kinetic_species_molality^kinetic_molal_index + "
      38             :                         "kinetic_half_saturation^kinetic_molal_index)^kinetic_monod_index");
      39         324 :   params.addParam<Real>("kinetic_monod_index",
      40         324 :                         0.0,
      41             :                         "The rate is multiplied by kinetic_species_molality^kinetic_molal_index / "
      42             :                         "(kinetic_species_molality^kinetic_molal_index + "
      43             :                         "kinetic_half_saturation^kinetic_molal_index)^kinetic_monod_index");
      44         324 :   params.addParam<Real>("kinetic_half_saturation",
      45         324 :                         0.0,
      46             :                         "The rate is multiplied by kinetic_species_molality^kinetic_molal_index / "
      47             :                         "(kinetic_species_molality^kinetic_molal_index + "
      48             :                         "kinetic_half_saturation^kinetic_molal_index)^kinetic_monod_index");
      49         324 :   params.addParam<std::vector<std::string>>(
      50             :       "promoting_species_names", {}, "Names of any promoting species");
      51         324 :   params.addParam<std::vector<Real>>("promoting_indices", {}, "Indices of the promoting species");
      52         324 :   params.addParam<std::vector<Real>>(
      53             :       "promoting_monod_indices",
      54             :       "Indices of the monod denominators of the promoting species.  If not given, then the default "
      55             :       "is 0 for each promoting species, meaning that there is no monod form");
      56         324 :   params.addParam<std::vector<Real>>("promoting_half_saturation",
      57             :                                      "Half-saturation constants for the monod expression.  If not "
      58             :                                      "given, then the default is 0 for each promoting species");
      59         324 :   params.addParam<Real>("theta", 1.0, "Theta parameter, which appears in |1 - (Q/K)^theta|^eta");
      60         324 :   params.addParam<Real>("eta", 1.0, "Eta parameter, which appears in |1 - (Q/K)^theta|^eta");
      61         486 :   params.addRangeCheckedParam<Real>(
      62             :       "activation_energy",
      63         324 :       0.0,
      64             :       "activation_energy >= 0.0",
      65             :       "Activation energy, in J.mol^-1, which appears in exp(activation_energy / R * (1/T0 - 1/T))");
      66         324 :   params.addParam<Real>(
      67             :       "one_over_T0",
      68         324 :       0.0,
      69             :       "1/T0, in 1/Kelvin, which appears in exp(activation_energy / R * (1/T0 - 1/T))");
      70         324 :   MooseEnum direction("both dissolution precipitation raw death", "both");
      71         324 :   params.addParam<MooseEnum>(
      72             :       "direction",
      73             :       direction,
      74             :       "Direction of reaction.  Let Q = the activity product of the kinetic reaction, and K = the "
      75             :       "equilibrium constant of the reaction.  Then direction means the following.  both = "
      76             :       "dissolution and precipitation are allowed.  (Specifically, if Q < K then dissolution will "
      77             :       "occur, that is, the kinetic species mass will decrease with time.  If Q > K then "
      78             :       "precipitation will occur, that is, the kinetic species mass will increase with time.)  "
      79             :       "dissolution = if Q < K then dissolution will occur, and when Q > K then the rate will be "
      80             :       "set to zero so that precipitation will be prevented.  precipitation = if Q > K then "
      81             :       "precipitation will occur, and when Q < K then the rate will be set to zero so that "
      82             :       "dissolution will be prevented.  raw = the rate will not depend on sgn(1 - (Q/K)), which "
      83             :       "means dissolution will occur if intrinsic_rate_constant > 0, and precipitation will occur "
      84             :       "when intrinsic_rate_constant < 0.  death = the rate will not depend on sgn(1 - (Q/K)), "
      85             :       "which means dissolution will occur if intrinsic_rate_constant > 0, and precipitation will "
      86             :       "occur when intrinsic_rate_constant < 0, and, in addition, no reactants will be produced or "
      87             :       "consumed by this kinetic reaction (only the kinetic species mass will change).");
      88         324 :   params.addParam<std::string>(
      89             :       "non_kinetic_biological_catalyst",
      90             :       "H2O",
      91             :       "Name of the primary or equilibrium species that acts as a biological catalyst.");
      92         324 :   params.addParam<Real>(
      93             :       "non_kinetic_biological_efficiency",
      94         324 :       0.0,
      95             :       "When one mole of the kinetic species dissolves, non_kinetic_biological_efficiency moles of "
      96             :       "the non_kinetic_biological_catalyst is created");
      97         324 :   params.addParam<Real>(
      98             :       "kinetic_biological_efficiency",
      99         324 :       -1,
     100             :       "This is used when modelling biologically-catalysed reactions, when the biomass is treated "
     101             :       "as a kinetic species, and the reactants and reactant-products are in equilibrium in the "
     102             :       "aqueous solution.  When one mole of reaction is catalysed, the biomass increases by "
     103             :       "kinetic_biological_efficiency moles");
     104         324 :   params.addParam<Real>(
     105             :       "energy_captured",
     106         324 :       0.0,
     107             :       "In biologically-catalysed kinetic reactions, this is the energy captured by the cell, per "
     108             :       "mol of reaction turnover.  Specifically, for each mole of kinetic reaction, the microbe "
     109             :       "will produce m moles of ATP via a reaction such as ADP + PO4--- -> ATP + H2O, with "
     110             :       "free-energy change G (usually around 45 kJ/mol).  Then, energy_captured = m * G.  For "
     111             :       "non-biologically-catalysed reactions, this should be zero.  The impact of energy_captured "
     112             :       "is that the reaction's equilibrium constant is K_database * exp(-energy_captured / R / "
     113             :       "T_in_Kelvin)");
     114         162 :   params.addClassDescription(
     115             :       "User object that defines a kinetic rate.  Note that more than one rate can be prescribed to "
     116             :       "a single kinetic_species: the sum the individual rates defines the overall rate.  "
     117             :       "GeochemistryKineticRate simply specifies the algebraic form for a kinetic rate: to actually "
     118             :       "use it in a calculation, you must use it in the GeochemicalModelDefinition.  The rate is "
     119             :       "intrinsic_rate_constant * area_quantity * (optionally, mass of kinetic_species in "
     120             :       "grams) * kinetic_molality^kinetic_molal_index / (kinetic_molality^kinetic_molal_index + "
     121             :       "kinetic_half_saturation^kinetic_molal_index)^kinetic_monod_index * "
     122             :       "(product_over_promoting_species m^promoting_index / (m^promoting_index + "
     123             :       "promoting_half_saturation^promiting_index)^promoting_monod_index) * |1 - (Q/K)^theta|^eta * "
     124             :       "exp(activation_energy / R * (1/T0 - 1/T)) * Direction(1 - (Q/K)).  Please see the markdown "
     125             :       "documentation for examples");
     126             : 
     127         162 :   return params;
     128         162 : }
     129             : 
     130          81 : GeochemistryKineticRate::GeochemistryKineticRate(const InputParameters & parameters)
     131             :   : GeneralUserObject(parameters),
     132          81 :     _promoting_names(getParam<std::vector<std::string>>("promoting_species_names")),
     133         198 :     _monod_ind(isParamValid("promoting_monod_indices")
     134          81 :                    ? getParam<std::vector<Real>>("promoting_monod_indices")
     135          81 :                    : std::vector<Real>(_promoting_names.size(), 0.0)),
     136         198 :     _half_sat(isParamValid("promoting_half_saturation")
     137          81 :                   ? getParam<std::vector<Real>>("promoting_half_saturation")
     138          81 :                   : std::vector<Real>(_promoting_names.size(), 0.0)),
     139         567 :     _rate_description(getParam<std::string>("kinetic_species_name"),
     140         162 :                       getParam<Real>("intrinsic_rate_constant"),
     141          81 :                       getParam<Real>("area_quantity"),
     142         243 :                       getParam<bool>("multiply_by_mass"),
     143         162 :                       getParam<Real>("kinetic_molal_index"),
     144         162 :                       getParam<Real>("kinetic_monod_index"),
     145         162 :                       getParam<Real>("kinetic_half_saturation"),
     146             :                       _promoting_names,
     147             :                       getParam<std::vector<Real>>("promoting_indices"),
     148          81 :                       _monod_ind,
     149          81 :                       _half_sat,
     150         162 :                       getParam<Real>("theta"),
     151         162 :                       getParam<Real>("eta"),
     152         162 :                       getParam<Real>("activation_energy"),
     153         162 :                       getParam<Real>("one_over_T0"),
     154         162 :                       getParam<MooseEnum>("direction").getEnum<DirectionChoiceEnum>(),
     155             :                       getParam<std::string>("non_kinetic_biological_catalyst"),
     156         162 :                       getParam<Real>("non_kinetic_biological_efficiency"),
     157         162 :                       getParam<Real>("kinetic_biological_efficiency"),
     158         162 :                       getParam<Real>("energy_captured"))
     159             : {
     160          81 : }
     161             : 
     162             : void
     163        1539 : GeochemistryKineticRate::initialize()
     164             : {
     165        1539 : }
     166             : 
     167             : void
     168        1539 : GeochemistryKineticRate::execute()
     169             : {
     170        1539 : }
     171             : 
     172             : void
     173        1539 : GeochemistryKineticRate::finalize()
     174             : {
     175        1539 : }
     176             : 
     177             : const KineticRateUserDescription &
     178          81 : GeochemistryKineticRate::getRateDescription() const
     179             : {
     180          81 :   return _rate_description;
     181             : }

Generated by: LCOV version 1.14