Constructs and stores a minimal amount of information that is pertinent to the user-defined geochemical system. More...
#include <PertinentGeochemicalSystem.h>
Public Member Functions | |
PertinentGeochemicalSystem (const GeochemicalDatabaseReader &db, const std::vector< std::string > &basis_species, const std::vector< std::string > &minerals, const std::vector< std::string > &gases, const std::vector< std::string > &kinetic_minerals, const std::vector< std::string > &kinetic_redox, const std::vector< std::string > &kinetic_surface_species, const std::string &redox_ox, const std::string &redox_e) | |
const ModelGeochemicalDatabase & | modelGeochemicalDatabase () const |
Return a reference to the ModelGeochemicalDatabase structure. More... | |
void | addKineticRate (const KineticRateUserDescription &description) |
Adds a rate description for kinetic_species. More... | |
unsigned | getIndexOfOriginalBasisSpecies (const std::string &name) const |
std::vector< std::string > | originalBasisNames () const |
Private Member Functions | |
void | buildBasis (const std::vector< std::string > &basis_species) |
using the basis_species list, this method builds _basis_index and _basis_info More... | |
void | buildMinerals (const std::vector< std::string > &minerals) |
using the minerals list, this method builds _mineral_index and _mineral_info, unless minerals = {"*"}, in which case buildAllMinerals is used instead More... | |
void | buildAllMinerals (const std::vector< std::string > &minerals) |
If minerals = {"*"} then populate _mineral_index and _mineral_info with all relevant minerals This is called in the constructor after buildSecondarySpecies and buildKineticMinerals because it adds to _mineral_index and _mineral_info all minerals that: More... | |
void | buildGases (const std::vector< std::string > &gases) |
using the gas list, this method builds _gas_index and _gas_info More... | |
void | buildKineticMinerals (const std::vector< std::string > &kinetic_minerals) |
using the kinetic_minerals list, this method builds _kinetic_mineral_index and _kinetic_mineral_info More... | |
void | buildKineticRedox (const std::vector< std::string > &kinetic_redox) |
using the kinetic_redox list, this method builds _kinetic_redox_index and _kinetic_redox_info More... | |
void | buildKineticSurface (const std::vector< std::string > &kinetic_surface) |
using the kinetic_surface list, this method builds _kinetic_surface_index and _kinetic_surface_info More... | |
void | buildSecondarySpecies () |
Extract all relevant "redox couples" and "secondary species" and "surface species" from the database. More... | |
bool | checkRedoxe () |
void | checkMinerals (const std::vector< GeochemistryMineralSpecies > &mineral_info) const |
Check that all minerals in mineral_info have reactions that involve only the basis_species or secondary_species. More... | |
void | checkGases () const |
Check that all gases in the "gases" list have reactions that involve only the basis_species or secondary_species. More... | |
void | checkKineticRedox () const |
Check that all kinetic redox species in the _kinetic_redox list have reactions that involve only the basis_species or secondary_species. More... | |
void | checkKineticSurfaceSpecies () const |
Check that all kinetic surface species in the _kinetic_surface_species list have reactions that involve only the basis_species or secondary_species. More... | |
void | createModel () |
Fully populate the ModelGeochemicalDatabase. More... | |
void | buildRedoxeInfo (std::vector< Real > &redox_e_stoichiometry, std::vector< Real > &redox_e_log10K) |
Extract the stoichiometry and log10K for the _redox_e species. More... | |
Private Attributes | |
GeochemicalDatabaseReader | _db |
The database. More... | |
std::unordered_map< std::string, unsigned > | _basis_index |
given a species name, return its index in the corresponding "info" std::vector More... | |
std::vector< GeochemistryBasisSpecies > | _basis_info |
a vector of all relevant species More... | |
std::unordered_map< std::string, unsigned > | _mineral_index |
given a species name, return its index in the corresponding "info" std::vector More... | |
std::vector< GeochemistryMineralSpecies > | _mineral_info |
a vector of all relevant species More... | |
std::unordered_map< std::string, unsigned > | _gas_index |
given a species name, return its index in the corresponding "info" std::vector More... | |
std::vector< GeochemistryGasSpecies > | _gas_info |
a vector of all relevant species More... | |
std::unordered_map< std::string, unsigned > | _kinetic_mineral_index |
given a species name, return its index in the corresponding "info" std::vector More... | |
std::vector< GeochemistryMineralSpecies > | _kinetic_mineral_info |
a vector of all relevant species More... | |
std::unordered_map< std::string, unsigned > | _kinetic_redox_index |
given a species name, return its index in the corresponding "info" std::vector More... | |
std::vector< GeochemistryRedoxSpecies > | _kinetic_redox_info |
a vector of all relevant species More... | |
std::unordered_map< std::string, unsigned > | _kinetic_surface_index |
given a species name, return its index in the corresponding "info" std::vector More... | |
std::vector< GeochemistrySurfaceSpecies > | _kinetic_surface_info |
a vector of all relevant species More... | |
std::unordered_map< std::string, unsigned > | _secondary_index |
given a species name, return its index in the corresponding "info" std::vector More... | |
std::vector< GeochemistryEquilibriumSpecies > | _secondary_info |
a vector of all relevant species More... | |
const std::string | _redox_ox |
The name of the oxygen in all disequilibrium-redox equations, eg O2(aq), which must be a basis species if disequilibrium redox reactions are to be recorded. More... | |
const std::string | _redox_e |
The name of the free electron involved in redox reactions. More... | |
ModelGeochemicalDatabase | _model |
The important datastructure built by this class. More... | |
Constructs and stores a minimal amount of information that is pertinent to the user-defined geochemical system.
Most importantly, all basis species, secondary species, mineral species, etc, that are defined in the geochemical database but are irrelevant to the user-defined system are eliminated from further consideration. This reduces the amount of information considerably. The final result is stored in a ModelGeochemicalDatabase structure. This structure is designed to be computationally efficient. A "getter" that copies this structure is provided as a public method. It is intended that a MOOSE simulation will construct one PertinentGeochemicalSystem object, and then copy the information to the nodes during the initial setup. If different nodes are allowed different swaps (likely to be the case) each node will need a different copy of the ModelGeochemicalDatabase structure.
Definition at line 382 of file PertinentGeochemicalSystem.h.
PertinentGeochemicalSystem::PertinentGeochemicalSystem | ( | const GeochemicalDatabaseReader & | db, |
const std::vector< std::string > & | basis_species, | ||
const std::vector< std::string > & | minerals, | ||
const std::vector< std::string > & | gases, | ||
const std::vector< std::string > & | kinetic_minerals, | ||
const std::vector< std::string > & | kinetic_redox, | ||
const std::vector< std::string > & | kinetic_surface_species, | ||
const std::string & | redox_ox, | ||
const std::string & | redox_e | ||
) |
db | the database reader, which will have parsed the database file |
basis_species | A list of basis components relevant to the aqueous-equilibrium problem. "H2O" must appear first in this list. No element must appear more than once in this list. These components must be chosen from the "basis species" in the database, the sorbing sites (if any) and the decoupled redox states that are in disequilibrium (if any). Any redox pair that is not in this list or the kinetic_redox list, will be assumed to be at equilibrium with the aqueous solution and will be considered a secondary species. All these species, except H2O, may be later swapped out of this list, either by a manual user-prescribed swap (and replaced by a mineral or a gas of fixed fugacity, for instance), or during the numerical solve. |
minerals | A list of minerals that are in equilibrium with the aqueous solution. This can only include the "minerals" in the database file. No element can appear more than once in this list. Their equilibrium reaction must consist of only the basis_species, and secondary species and non-kinetically-controlled redox couples that can be expressed in terms of the basis_species. If they are also "sorbing minerals" in the database then their sorption sites must consist of the basis_species only. During simulation, the user can compute the saturation index of these minerals, and these minerals can be "swapped" into the basis if desired (or required during the numerical solve). If the user performs a manual "swap" then an initial condition must be provided for the mineral. The user choose whether these minerals are allowed to precipitate or not - that is, they can be "supressed". This list, along with the kinetic_minerals list, comprises the entire list of minerals in the problem: all others are eliminated from consideration. |
gases | A list of gases that are in equilibrium with the aqueous solution and can have their fugacities fixed, at least at some time and spatial location. All members of this list must be a "gas" in the database file. No gas must appear more than once in this list. The equilibrium reaction of each gas must involve only the basis_species, or secondary species or non-kinetically-controlled redox couples that can be expressed in terms of the basis_species. |
kinetic_minerals | A list of minerals that whose dynamics are governed by a rate law. These are not in equilibrium with the aqueous solution. This can only include the "minerals" in the database file. No element can appear more than once in this list. Their equilibrium reaction must involve only the basis_species, or secondary species or non-kinetically-controlled redox couples that can be expressed in terms of the basis_species. If they are also "sorbing minerals" in the database then their sorption sites must consist of the basis_speices only. No members of this list must be in the minerals list. They can never be "swapped" into the basis, nor can they be "supressed". |
kinetic_redox | A list of redox pairs whose dynamics are governed by a rate law. These are not in equilibrium with the aqueous solution. Each element of this list must appear in the "redox couples" section of the database. No element can appear more than once in this list. Their reaction must involve only the basis_species, or secondary species or non-kinetically-controlled redox couples that can be expressed in terms of the basis_species. No members of this list must be in the basis_species list. They can never be "swapped" into the basis. |
kinetic_surface_species | A list of surface sorbing species whose dynamics are governed by a rate law. These are not in equilibrium with the aqueous solution. All elements of this list must appear as a "surface species" in the database. No member must appear more than twice in this list. Their reaction must involve only the basis_species, or secondary species or non-kinetically-controlled redox couples that can be expressed in terms of the basis_species. They can never be "swapped" into the basis. |
redox_ox | The name of the oxygen species, eg O2(aq), that appears in redox reactions. For redox pairs that are in disequilibrium to be correctly recorded, and hence their Nernst potentials to be computed easily, redox_ox must be a basis_species and it must appear in the reaction for each redox pair. |
redox_e | The name of the free electron, eg e-. For redox pairs that are in disequilibrium to be correctly recorded, and hence their Nernst potentials to be computed easily, the equilibrium reaction for redox_e must involve redox_ox, and the basis species must be chosen so that redox_e is an equilibrium species according to the database reader |
Definition at line 12 of file PertinentGeochemicalSystem.C.
void PertinentGeochemicalSystem::addKineticRate | ( | const KineticRateUserDescription & | description | ) |
Adds a rate description for kinetic_species.
Note that a single kinetic species can have multiple rates prescribed to it (by calling this method multiple times): they are added together to give an overall rate.
Definition at line 856 of file PertinentGeochemicalSystem.C.
Referenced by GeochemicalModelDefinition::GeochemicalModelDefinition(), and TEST().
|
private |
If minerals = {"*"} then populate _mineral_index and _mineral_info with all relevant minerals This is called in the constructor after buildSecondarySpecies and buildKineticMinerals because it adds to _mineral_index and _mineral_info all minerals that:
Definition at line 300 of file PertinentGeochemicalSystem.C.
Referenced by PertinentGeochemicalSystem().
|
private |
using the basis_species list, this method builds _basis_index and _basis_info
Definition at line 95 of file PertinentGeochemicalSystem.C.
Referenced by PertinentGeochemicalSystem().
|
private |
using the gas list, this method builds _gas_index and _gas_info
Definition at line 141 of file PertinentGeochemicalSystem.C.
Referenced by PertinentGeochemicalSystem().
|
private |
using the kinetic_minerals list, this method builds _kinetic_mineral_index and _kinetic_mineral_info
Definition at line 156 of file PertinentGeochemicalSystem.C.
Referenced by PertinentGeochemicalSystem().
|
private |
using the kinetic_redox list, this method builds _kinetic_redox_index and _kinetic_redox_info
Definition at line 172 of file PertinentGeochemicalSystem.C.
Referenced by PertinentGeochemicalSystem().
|
private |
using the kinetic_surface list, this method builds _kinetic_surface_index and _kinetic_surface_info
Definition at line 188 of file PertinentGeochemicalSystem.C.
Referenced by PertinentGeochemicalSystem().
|
private |
using the minerals list, this method builds _mineral_index and _mineral_info, unless minerals = {"*"}, in which case buildAllMinerals is used instead
Definition at line 125 of file PertinentGeochemicalSystem.C.
Referenced by PertinentGeochemicalSystem().
|
private |
Extract the stoichiometry and log10K for the _redox_e species.
This is called during createModel()
redox_e_stoichiometry | upon exit will contain the stoichiometry for the _redox_e species |
redox_e_log10K | upon exit will contain the log10K info for the _redox_e species |
Definition at line 345 of file PertinentGeochemicalSystem.C.
Referenced by createModel().
|
private |
Extract all relevant "redox couples" and "secondary species" and "surface species" from the database.
These are all species whose reaction involves only the basis_species and are not kinetically controlled or already in the basis_species list.
Definition at line 203 of file PertinentGeochemicalSystem.C.
Referenced by PertinentGeochemicalSystem().
|
private |
Check that all gases in the "gases" list have reactions that involve only the basis_species or secondary_species.
Definition at line 398 of file PertinentGeochemicalSystem.C.
Referenced by PertinentGeochemicalSystem().
|
private |
Check that all kinetic redox species in the _kinetic_redox list have reactions that involve only the basis_species or secondary_species.
Definition at line 408 of file PertinentGeochemicalSystem.C.
Referenced by PertinentGeochemicalSystem().
|
private |
Check that all kinetic surface species in the _kinetic_surface_species list have reactions that involve only the basis_species or secondary_species.
Definition at line 418 of file PertinentGeochemicalSystem.C.
Referenced by PertinentGeochemicalSystem().
|
private |
Check that all minerals in mineral_info have reactions that involve only the basis_species or secondary_species.
Check that if a mineral in this list is also a "sorbing mineral", its sorbing sites are present in the basis_species list
Definition at line 381 of file PertinentGeochemicalSystem.C.
Referenced by PertinentGeochemicalSystem().
|
private |
Definition at line 329 of file PertinentGeochemicalSystem.C.
Referenced by createModel().
|
private |
Fully populate the ModelGeochemicalDatabase.
Definition at line 428 of file PertinentGeochemicalSystem.C.
Referenced by PertinentGeochemicalSystem().
unsigned PertinentGeochemicalSystem::getIndexOfOriginalBasisSpecies | ( | const std::string & | name | ) | const |
name | species name |
Definition at line 69 of file PertinentGeochemicalSystem.C.
Referenced by GeochemistryQuantityAux::computeValue(), GeochemistryQuantityAux::GeochemistryQuantityAux(), and TEST().
const ModelGeochemicalDatabase & PertinentGeochemicalSystem::modelGeochemicalDatabase | ( | ) | const |
Return a reference to the ModelGeochemicalDatabase structure.
Definition at line 850 of file PertinentGeochemicalSystem.C.
Referenced by GeochemistryQuantityAux::GeochemistryQuantityAux(), GeochemicalModelDefinition::getDatabase(), TEST(), and TEST_F().
std::vector< std::string > PertinentGeochemicalSystem::originalBasisNames | ( | ) | const |
Definition at line 86 of file PertinentGeochemicalSystem.C.
Referenced by GeochemistryConsoleOutput::output(), TEST(), and TEST_F().
|
private |
given a species name, return its index in the corresponding "info" std::vector
Definition at line 486 of file PertinentGeochemicalSystem.h.
Referenced by buildAllMinerals(), buildBasis(), buildKineticRedox(), buildSecondarySpecies(), checkGases(), checkKineticRedox(), checkKineticSurfaceSpecies(), checkMinerals(), checkRedoxe(), createModel(), getIndexOfOriginalBasisSpecies(), and originalBasisNames().
|
private |
a vector of all relevant species
Definition at line 489 of file PertinentGeochemicalSystem.h.
Referenced by buildBasis(), buildRedoxeInfo(), createModel(), and originalBasisNames().
|
private |
The database.
Definition at line 483 of file PertinentGeochemicalSystem.h.
Referenced by buildAllMinerals(), buildBasis(), buildGases(), buildKineticMinerals(), buildKineticRedox(), buildKineticSurface(), buildMinerals(), buildRedoxeInfo(), buildSecondarySpecies(), checkRedoxe(), and createModel().
|
private |
given a species name, return its index in the corresponding "info" std::vector
Definition at line 498 of file PertinentGeochemicalSystem.h.
Referenced by buildGases().
|
private |
a vector of all relevant species
Definition at line 501 of file PertinentGeochemicalSystem.h.
Referenced by buildGases(), checkGases(), and createModel().
|
private |
given a species name, return its index in the corresponding "info" std::vector
Definition at line 504 of file PertinentGeochemicalSystem.h.
Referenced by buildAllMinerals(), and buildKineticMinerals().
|
private |
a vector of all relevant species
Definition at line 507 of file PertinentGeochemicalSystem.h.
Referenced by buildKineticMinerals(), createModel(), and PertinentGeochemicalSystem().
|
private |
given a species name, return its index in the corresponding "info" std::vector
Definition at line 510 of file PertinentGeochemicalSystem.h.
Referenced by buildKineticRedox(), and buildSecondarySpecies().
|
private |
a vector of all relevant species
Definition at line 513 of file PertinentGeochemicalSystem.h.
Referenced by buildKineticRedox(), checkKineticRedox(), and createModel().
|
private |
given a species name, return its index in the corresponding "info" std::vector
Definition at line 516 of file PertinentGeochemicalSystem.h.
Referenced by buildKineticSurface(), and buildSecondarySpecies().
|
private |
a vector of all relevant species
Definition at line 519 of file PertinentGeochemicalSystem.h.
Referenced by buildKineticSurface(), checkKineticSurfaceSpecies(), and createModel().
|
private |
given a species name, return its index in the corresponding "info" std::vector
Definition at line 492 of file PertinentGeochemicalSystem.h.
Referenced by buildAllMinerals(), buildKineticMinerals(), and buildMinerals().
|
private |
a vector of all relevant species
Definition at line 495 of file PertinentGeochemicalSystem.h.
Referenced by buildAllMinerals(), buildMinerals(), createModel(), and PertinentGeochemicalSystem().
|
private |
The important datastructure built by this class.
Definition at line 537 of file PertinentGeochemicalSystem.h.
Referenced by addKineticRate(), buildRedoxeInfo(), createModel(), and modelGeochemicalDatabase().
|
private |
The name of the free electron involved in redox reactions.
Definition at line 534 of file PertinentGeochemicalSystem.h.
Referenced by buildRedoxeInfo(), buildSecondarySpecies(), checkRedoxe(), and createModel().
|
private |
The name of the oxygen in all disequilibrium-redox equations, eg O2(aq), which must be a basis species if disequilibrium redox reactions are to be recorded.
Definition at line 531 of file PertinentGeochemicalSystem.h.
Referenced by createModel().
|
private |
given a species name, return its index in the corresponding "info" std::vector
Definition at line 522 of file PertinentGeochemicalSystem.h.
Referenced by buildAllMinerals(), buildRedoxeInfo(), buildSecondarySpecies(), checkGases(), checkKineticRedox(), checkKineticSurfaceSpecies(), checkMinerals(), checkRedoxe(), and createModel().
|
private |
a vector of all relevant species
Definition at line 525 of file PertinentGeochemicalSystem.h.
Referenced by buildSecondarySpecies(), and createModel().