https://mooseframework.inl.gov
GeochemicalModelDefinition.C
Go to the documentation of this file.
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 
12 
14 
17 {
19  params.addRequiredParam<FileName>("database_file", "The name of the geochemical database file");
20  params.addParam<bool>(
21  "reexpress_free_electron",
22  true,
23  "If true then if: (1) the 'free electron' appears in the database file; and (2) its "
24  "equilibrium reaction includes O2(g); and (3) O2(g) is a gas; and (4) O2(g)'s equilibrium "
25  "reaction is O2(g)=O2(eq); and (5) O2(aq) exists as a basis species in the database file; "
26  "then reexpress the free electron's equilibrium reaction in terms of O2(aq). Note that if "
27  "you choose 'reexpress_free_electron=false' and these other 5 conditions are true, then the "
28  "'free electron' will not be available as a secondary species");
29  params.addParam<bool>(
30  "piecewise_linear_interpolation",
31  false,
32  "If true then use a piecewise-linear interpolation of logK and Debye-Huckel parameters, "
33  "regardless of the interpolation type specified in the database file. This can be useful "
34  "for comparing with results using other geochemistry software");
35  params.addRequiredParam<std::vector<std::string>>(
36  "basis_species",
37  "A list of basis components relevant to the aqueous-equilibrium problem. H2O must appear "
38  "first in this list. These components must be chosen from the 'basis species' in the "
39  "database, the sorbing sites (if any) and the decoupled redox states that are in "
40  "disequilibrium (if any).");
41  params.addParam<std::vector<std::string>>(
42  "equilibrium_minerals",
43  {},
44  "A list of minerals that are in equilibrium with the aqueous solution. All members of this "
45  "list must be in the 'minerals' section of the database file");
46  params.addParam<std::vector<std::string>>(
47  "equilibrium_gases",
48  {},
49  "A list of gases that are in equilibrium with the aqueous solution and can have their "
50  "fugacities fixed, at least for some time and spatial location. All members of this list "
51  "must be in the 'gas' section of the database file");
52  params.addParam<std::vector<std::string>>(
53  "kinetic_minerals",
54  {},
55  "A list of minerals whose dynamics are governed by a rate law. These are not in equilibrium "
56  "with the aqueous solution. All members of this list must be in the 'minerals' section of "
57  "the database "
58  "file.");
59  params.addParam<std::vector<std::string>>(
60  "kinetic_redox",
61  {},
62  "A list alternative oxidation states (eg Fe+++) whose dynamics are governed by a rate law. "
63  "These are not in equilibrium with the aqueous solution. All members of this list must be "
64  "in the "
65  "'redox couples' section of the database file.");
66  params.addParam<std::vector<std::string>>(
67  "kinetic_surface_species",
68  {},
69  "A list surface sorbing species whose dynamics are governed by a rate law. These are not in "
70  "equilibrium with the aqueous solution. All members of this list must be in the 'surface "
71  "species' section of the database file.");
72  params.addParam<std::string>(
73  "redox_oxygen",
74  "O2(aq)",
75  "The name of the oxygen species that appears in redox reactions. For redox pairs that are "
76  "in disequilibrium to be correctly recorded, and hence their Nernst potentials to be "
77  "computed easily, redox_oxygen must be a basis species and it must appear in the reaction "
78  "for each redox pair");
79  params.addParam<std::string>(
80  "redox_electron",
81  "e-",
82  "The name of the free electron. For redox pairs that are in disequilibrium to be correctly "
83  "recorded, and hence their Nernst potentials to be computed eqsily, the equilibrium reaction "
84  "for redox_electron must involve redox_oxygen, and the basis species must be chosen to that "
85  "redox_electron is an equilibrium species");
86  params.addParam<std::vector<UserObjectName>>(
87  "kinetic_rate_descriptions",
88  {},
89  "A list of GeochemistryKineticRate UserObject names that define the kinetic rates. If a "
90  "kinetic species has no rate prescribed to it, its reaction rate will be zero");
91  params.addParam<bool>(
92  "remove_all_extrapolated_secondary_species",
93  false,
94  "After reading the database file, immediately remove all secondary species that have "
95  "extrapolated equilibrium constants. Sometimes these extrapolations are completely crazy "
96  "and those secondary species greatly impact the results");
97 
98  params.addClassDescription("User object that parses a geochemical database file, and only "
99  "retains information relevant to the current geochemical model");
100 
101  return params;
102 }
103 
105  : GeneralUserObject(parameters),
106  _db(getParam<FileName>("database_file"),
107  getParam<bool>("reexpress_free_electron"),
108  getParam<bool>("piecewise_linear_interpolation"),
109  getParam<bool>("remove_all_extrapolated_secondary_species")),
110  _model(_db,
111  getParam<std::vector<std::string>>("basis_species"),
112  getParam<std::vector<std::string>>("equilibrium_minerals"),
113  getParam<std::vector<std::string>>("equilibrium_gases"),
114  getParam<std::vector<std::string>>("kinetic_minerals"),
115  getParam<std::vector<std::string>>("kinetic_redox"),
116  getParam<std::vector<std::string>>("kinetic_surface_species"),
117  getParam<std::string>("redox_oxygen"),
118  getParam<std::string>("redox_electron"))
119 {
120  for (const auto & kr : getParam<std::vector<UserObjectName>>("kinetic_rate_descriptions"))
121  _model.addKineticRate(getUserObjectByName<GeochemistryKineticRate>(kr).getRateDescription());
122 }
123 
124 void
126 {
127 }
128 
129 void
131 {
132 }
133 
134 void
136 {
137 }
138 
141 {
143 }
144 
147 {
148  return _model;
149 }
150 
153 {
154  return _db;
155 }
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const GeochemicalDatabaseReader & getOriginalFullDatabase() const
provides a reference to the full database file used by this object
const PertinentGeochemicalSystem & getPertinentGeochemicalSystem() const
provides a reference to the PertinentGeochemicalSystem of this object
registerMooseObject("GeochemistryApp", GeochemicalModelDefinition)
void addRequiredParam(const std::string &name, const std::string &doc_string)
User object that parses a geochemical database file, and only retains information relevant to the cur...
const ModelGeochemicalDatabase & modelGeochemicalDatabase() const
Return a reference to the ModelGeochemicalDatabase structure.
virtual void initialize() override final
void addKineticRate(const KineticRateUserDescription &description)
Adds a rate description for kinetic_species.
const ModelGeochemicalDatabase & getDatabase() const
provides a reference to the pertinent geochemical database held by this object
Constructs and stores a minimal amount of information that is pertinent to the user-defined geochemic...
const T & getParam(const std::string &name) const
virtual void finalize() override final
void addClassDescription(const std::string &doc_string)
Data structure to hold all relevant information from the database file.
const GeochemicalDatabaseReader _db
virtual void execute() override final
GeochemicalModelDefinition(const InputParameters &parameters)
PertinentGeochemicalSystem _model
static InputParameters validParams()
Class for reading geochemical reactions from a MOOSE geochemical database.