https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PertinentGeochemicalSystem.h
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
10#pragma once
11
14#include <unordered_map>
15#include "DenseMatrix.h"
16#include <libmesh/dense_vector.h>
17
26{
28
29 bool operator==(const SurfaceComplexationInfo & rhs) const
30 {
32 };
33
35 std::map<std::string, Real> sorption_sites;
36};
37
91
102{
111
112 bool operator==(const ModelGeochemicalDatabase & rhs) const
113 {
114 return (original_database == rhs.original_database) &&
139 (redox_log10K == rhs.redox_log10K) &&
141 (gas_chi == rhs.gas_chi) && (kin_species_index == rhs.kin_species_index) &&
149 (kin_rate == rhs.kin_rate) &&
153 };
154
157
162 std::unordered_map<std::string, unsigned> basis_species_index;
163
165 std::vector<std::string> basis_species_name;
166
168 std::vector<bool> basis_species_mineral;
169
171 std::vector<bool> basis_species_gas;
172
174 std::vector<bool> basis_species_transported;
175
177 std::vector<Real> basis_species_charge;
178
180 std::vector<Real> basis_species_radius;
181
184
187
194 std::unordered_map<std::string, unsigned> eqm_species_index;
195
197 std::vector<std::string> eqm_species_name;
198
200 std::vector<bool> eqm_species_mineral;
201
203 std::vector<bool> eqm_species_gas;
204
206 std::vector<bool> eqm_species_transported;
207
209 std::vector<Real> eqm_species_charge;
210
212 std::vector<Real> eqm_species_radius;
213
216
219
224 DenseMatrix<Real> eqm_stoichiometry;
225
230 DenseMatrix<Real> eqm_log10K;
231
236 std::vector<std::string> surface_sorption_name;
237
243 std::vector<Real> surface_sorption_area;
244
246 std::vector<bool> surface_sorption_related;
247
255 std::vector<unsigned> surface_sorption_number;
256
261 std::string redox_lhs;
262
276 DenseMatrix<Real> redox_stoichiometry;
277
282 DenseMatrix<Real> redox_log10K;
283
289 std::unordered_map<std::string, SurfaceComplexationInfo> surface_complexation_info;
290
298 std::unordered_map<std::string, std::vector<Real>> gas_chi;
299
304 std::unordered_map<std::string, unsigned> kin_species_index;
305
307 std::vector<std::string> kin_species_name;
308
310 std::vector<bool> kin_species_mineral;
311
313 std::vector<bool> kin_species_transported;
314
316 std::vector<Real> kin_species_charge;
317
320
323
328 DenseMatrix<Real> kin_log10K;
329
334 DenseMatrix<Real> kin_stoichiometry;
335
341 std::vector<KineticRateDefinition> kin_rate;
342
348 std::vector<unsigned> have_swapped_out_of_basis;
349
355 std::vector<unsigned> have_swapped_into_basis;
356
371 DenseMatrix<Real> swap_to_original_basis;
372};
373
387{
388public:
455 const std::vector<std::string> & basis_species,
456 const std::vector<std::string> & minerals,
457 const std::vector<std::string> & gases,
458 const std::vector<std::string> & kinetic_minerals,
459 const std::vector<std::string> & kinetic_redox,
460 const std::vector<std::string> & kinetic_surface_species,
461 const std::string & redox_ox,
462 const std::string & redox_e);
463
466
472 void addKineticRate(const KineticRateUserDescription & description);
473
478 unsigned getIndexOfOriginalBasisSpecies(const std::string & name) const;
479
483 std::vector<std::string> originalBasisNames() const;
484
485private:
488
490 std::unordered_map<std::string, unsigned> _basis_index;
491
493 std::vector<GeochemistryBasisSpecies> _basis_info;
494
496 std::unordered_map<std::string, unsigned> _mineral_index;
497
499 std::vector<GeochemistryMineralSpecies> _mineral_info;
500
502 std::unordered_map<std::string, unsigned> _gas_index;
503
505 std::vector<GeochemistryGasSpecies> _gas_info;
506
508 std::unordered_map<std::string, unsigned> _kinetic_mineral_index;
509
511 std::vector<GeochemistryMineralSpecies> _kinetic_mineral_info;
512
514 std::unordered_map<std::string, unsigned> _kinetic_redox_index;
515
517 std::vector<GeochemistryRedoxSpecies> _kinetic_redox_info;
518
520 std::unordered_map<std::string, unsigned> _kinetic_surface_index;
521
523 std::vector<GeochemistrySurfaceSpecies> _kinetic_surface_info;
524
526 std::unordered_map<std::string, unsigned> _secondary_index;
527
529 std::vector<GeochemistryEquilibriumSpecies> _secondary_info;
530
535 const std::string _redox_ox;
536
538 const std::string _redox_e;
539
542
546 void buildBasis(const std::vector<std::string> & basis_species);
547
552 void buildMinerals(const std::vector<std::string> & minerals);
553
563 void buildAllMinerals(const std::vector<std::string> & minerals);
564
568 void buildGases(const std::vector<std::string> & gases);
569
574 void buildKineticMinerals(const std::vector<std::string> & kinetic_minerals);
575
580 void buildKineticRedox(const std::vector<std::string> & kinetic_redox);
581
586 void buildKineticSurface(const std::vector<std::string> & kinetic_surface);
587
594
599 bool checkRedoxe();
600
606 void checkMinerals(const std::vector<GeochemistryMineralSpecies> & mineral_info) const;
607
612 void checkGases() const;
613
618 void checkKineticRedox() const;
619
624 void checkKineticSurfaceSpecies() const;
625
629 void createModel();
630
637 void buildRedoxeInfo(std::vector<Real> & redox_e_stoichiometry,
638 std::vector<Real> & redox_e_log10K);
639};
const GeochemicalDatabaseReader db("database/moose_testdb.json", true, true, false)
const std::string name
Definition Setup.h:21
Class for reading geochemical reactions from a MOOSE geochemical database.
Constructs and stores a minimal amount of information that is pertinent to the user-defined geochemic...
std::vector< GeochemistryEquilibriumSpecies > _secondary_info
a vector of all relevant species
unsigned getIndexOfOriginalBasisSpecies(const std::string &name) const
void buildKineticRedox(const std::vector< std::string > &kinetic_redox)
using the kinetic_redox list, this method builds _kinetic_redox_index and _kinetic_redox_info
void buildGases(const std::vector< std::string > &gases)
using the gas list, this method builds _gas_index and _gas_info
const std::string _redox_ox
The name of the oxygen in all disequilibrium-redox equations, eg O2(aq), which must be a basis specie...
void buildMinerals(const std::vector< std::string > &minerals)
using the minerals list, this method builds _mineral_index and _mineral_info, unless minerals = {"*"}...
std::vector< GeochemistryMineralSpecies > _kinetic_mineral_info
a vector of all relevant species
const ModelGeochemicalDatabase & modelGeochemicalDatabase() const
Return a reference to the ModelGeochemicalDatabase structure.
void buildBasis(const std::vector< std::string > &basis_species)
using the basis_species list, this method builds _basis_index and _basis_info
std::vector< GeochemistryBasisSpecies > _basis_info
a vector of all relevant species
std::unordered_map< std::string, unsigned > _gas_index
given a species name, return its index in the corresponding "info" std::vector
std::unordered_map< std::string, unsigned > _basis_index
given a species name, return its index in the corresponding "info" std::vector
std::vector< GeochemistryRedoxSpecies > _kinetic_redox_info
a vector of all relevant species
ModelGeochemicalDatabase _model
The important datastructure built by this class.
void checkKineticSurfaceSpecies() const
Check that all kinetic surface species in the _kinetic_surface_species list have reactions that invol...
std::unordered_map< std::string, unsigned > _secondary_index
given a species name, return its index in the corresponding "info" std::vector
void buildRedoxeInfo(std::vector< Real > &redox_e_stoichiometry, std::vector< Real > &redox_e_log10K)
Extract the stoichiometry and log10K for the _redox_e species.
const std::string _redox_e
The name of the free electron involved in redox reactions.
std::vector< GeochemistryGasSpecies > _gas_info
a vector of all relevant species
void buildKineticMinerals(const std::vector< std::string > &kinetic_minerals)
using the kinetic_minerals list, this method builds _kinetic_mineral_index and _kinetic_mineral_info
void addKineticRate(const KineticRateUserDescription &description)
Adds a rate description for kinetic_species.
void checkGases() const
Check that all gases in the "gases" list have reactions that involve only the basis_species or second...
std::unordered_map< std::string, unsigned > _kinetic_surface_index
given a species name, return its index in the corresponding "info" std::vector
void createModel()
Fully populate the ModelGeochemicalDatabase.
void buildKineticSurface(const std::vector< std::string > &kinetic_surface)
using the kinetic_surface list, this method builds _kinetic_surface_index and _kinetic_surface_info
GeochemicalDatabaseReader _db
The database.
std::unordered_map< std::string, unsigned > _kinetic_redox_index
given a species name, return its index in the corresponding "info" std::vector
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 seconda...
void buildAllMinerals(const std::vector< std::string > &minerals)
If minerals = {"*"} then populate _mineral_index and _mineral_info with all relevant minerals This is...
std::unordered_map< std::string, unsigned > _kinetic_mineral_index
given a species name, return its index in the corresponding "info" std::vector
std::vector< GeochemistryMineralSpecies > _mineral_info
a vector of all relevant species
std::vector< std::string > originalBasisNames() const
std::vector< GeochemistrySurfaceSpecies > _kinetic_surface_info
a vector of all relevant species
void buildSecondarySpecies()
Extract all relevant "redox couples" and "secondary species" and "surface species" from the database.
std::unordered_map< std::string, unsigned > _mineral_index
given a species name, return its index in the corresponding "info" std::vector
void checkKineticRedox() const
Check that all kinetic redox species in the _kinetic_redox list have reactions that involve only the ...
A single rate expression for the kinetic species with index kinetic_species_index.
bool operator==(const KineticRateDefinition &rhs) const
std::vector< Real > promoting_half_saturation
std::vector< Real > promoting_indices
KineticRateUserDescription description
std::vector< Real > promoting_monod_indices
KineticRateDefinition(unsigned kinetic_species_index, const std::vector< Real > &promoting_indices, const std::vector< Real > &promoting_monod_indices, const std::vector< Real > &promoting_half_saturation, unsigned progeny_index, const KineticRateUserDescription &description)
Holds a user-specified description of a kinetic rate.
Data structure to hold all relevant information from the database file.
std::vector< bool > eqm_species_mineral
eqm_species_mineral[i] = true iff the i^th equilibrium species is a mineral
std::vector< Real > eqm_species_radius
all quantities have an ionic radius (Angstrom) for computing activity (mineral radius = 0,...
DenseMatrix< Real > eqm_stoichiometry
eqm_stoichiometry(i, j) = stoichiometric coefficient for equilibrium species "i" in terms of the basi...
std::vector< Real > basis_species_molecular_weight
all quantities have a molecular weight (g)
DenseMatrix< Real > kin_stoichiometry
kin_stoichiometry(i, j) = stoichiometric coefficient for kinetic species "i" in terms of the basis sp...
std::vector< Real > basis_species_radius
all quantities have an ionic radius (Angstrom) for computing activity (mineral radius = 0,...
std::vector< Real > basis_species_charge
all quantities have a charge (mineral charge = 0, gas charge = 0, oxide charge = 0)
std::vector< Real > eqm_species_molecular_volume
all quantities have a molecular volume (cm^3) (only nonzero for minerals, however)
std::string redox_lhs
the name of the species on the left-hand side of the redox equations.
std::vector< bool > kin_species_mineral
kin_species_mineral[j] = true iff the j^th kinetic species is a mineral
std::vector< Real > eqm_species_molecular_weight
all quantities have a molecular weight (g)
std::vector< unsigned > surface_sorption_number
surface_sorption_number[j] = the index of the surface potential that should be used to modify the equ...
std::vector< unsigned > have_swapped_into_basis
Species that have been swapped into the basis.
std::vector< bool > basis_species_transported
basis_species_transported[j] = true iff the j^th basis species is transported in reactive-transport s...
std::vector< std::string > kin_species_name
kin_species_name[j] = name of the j^th kinetic species
DenseMatrix< Real > redox_stoichiometry
redox_stoichiometry(i, j) = stoichiometric coefficients for i^th redox species that is in disequilibr...
DenseMatrix< Real > swap_to_original_basis
Swap matrix that allows expression in terms of the original basis.
std::vector< Real > surface_sorption_area
surface_sorption_area[k] = specific surface area [m^2/g] for the k^th mineral involved in surface sor...
std::vector< bool > basis_species_mineral
basis_species_mineral[j] = true iff the j^th basis species is a mineral
std::vector< KineticRateDefinition > kin_rate
rates given to kinetic species.
std::vector< Real > kin_species_molecular_volume
all quantities have a molecular volume (cm^3/mol) (only nonzero for minerals, however)
DenseMatrix< Real > redox_log10K
redox_log10K(i, j) = log10(equilibrium constant) for i^th redox species at the j^th temperature point
DenseMatrix< Real > kin_log10K
kin_log10K(i, j) = log10(equilibrium constant for the i^th kinetic species at the j^th temperature po...
std::unordered_map< std::string, SurfaceComplexationInfo > surface_complexation_info
Holds info on surface complexation, if any, in the model.
std::vector< bool > surface_sorption_related
surface_sorption_related[j] = true iff the j^th equilibrium species is involved in surface sorption
std::vector< unsigned > have_swapped_out_of_basis
Species that have been swapped out of the basis.
std::vector< Real > basis_species_molecular_volume
all quantities have a molecular volume (cm^3) (only nonzero for minerals, however)
std::unordered_map< std::string, unsigned > eqm_species_index
eqm_species_index[name] = index of the equilibrium species (secondary aqueous species,...
const GeochemicalDatabaseReader * original_database
a pointer to the original database used to build this ModelGeochemicalDatabase
std::vector< std::string > basis_species_name
basis_species_name[j] = name of the j^th basis species
ModelGeochemicalDatabase(const GeochemicalDatabaseReader &db)
Constructor sets original_database.
std::vector< bool > kin_species_transported
kin_species_transported[j] = true iff the j^th kinetic species is transported in reactive-transport s...
std::unordered_map< std::string, std::vector< Real > > gas_chi
Holds info on gas fugacity "chi" parameters.
std::vector< Real > kin_species_charge
all kinetic quantities have a charge (mineral charge = 0)
std::unordered_map< std::string, unsigned > basis_species_index
basis_species_index[name] = index of the basis species, within all ModelGeochemicalDatabase internal ...
std::vector< std::string > surface_sorption_name
surface_sorption_name[k] = name of the mineral involved in surface sorption.
DenseMatrix< Real > eqm_log10K
eqm_log10K(i, j) = log10(equilibrium constant) for i^th equilibrium species at the j^th temperature p...
std::vector< bool > basis_species_gas
basis_species_gas[j] = true iff the j^th basis species is a gas
std::unordered_map< std::string, unsigned > kin_species_index
kin_species_index[name] = index of the kinetic species, within all ModelGeochemicalDatabase internal ...
std::vector< std::string > eqm_species_name
eqm_species_name[i] = name of the i^th eqm species
std::vector< Real > eqm_species_charge
all quantities have a charge (mineral charge = 0, gas charge = 0, oxide charge = 0)
std::vector< bool > eqm_species_gas
eqm_species_gas[i] = true iff the i^th equilibrium species is a gas
std::vector< Real > kin_species_molecular_weight
all quantities have a molecular weight (g/mol)
bool operator==(const ModelGeochemicalDatabase &rhs) const
std::vector< bool > eqm_species_transported
eqm_species_transported[i] = true iff the i^th eqm species is transported in reactive-transport sims
Data structure designed to hold information related to sorption via surface complexation.
std::map< std::string, Real > sorption_sites
bool operator==(const SurfaceComplexationInfo &rhs) const