https://mooseframework.inl.gov
Loading...
Searching...
No Matches
GeochemicalDatabaseReader.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
12#include "nlohmann/json.h"
13#include "MooseTypes.h"
14
25{
27
28 std::string name;
29 std::map<std::string, Real> elements;
30 Real radius;
31 Real charge;
33};
34
46{
48
49 std::string name;
50 std::map<std::string, Real> basis_species;
51 std::vector<Real> equilibrium_const;
52 Real radius;
53 Real charge;
55};
56
69{
71
72 std::string name;
74 std::map<std::string, Real> basis_species;
75 std::vector<Real> equilibrium_const;
78 std::map<std::string, Real> sorption_sites;
79};
80
92{
94
95 std::string name;
96 std::map<std::string, Real> basis_species;
97 std::vector<Real> equilibrium_const;
99 std::vector<Real> chi;
100 Real Pcrit;
101 Real Tcrit;
102 Real omega;
103};
104
116{
118
119 std::string name;
120 std::map<std::string, Real> basis_species;
121 std::vector<Real> equilibrium_const;
122 Real radius;
123 Real charge;
125};
126
135{
137
138 std::string name;
139 std::map<std::string, Real> basis_species;
141};
142
152{
154
155 std::string name;
156 std::map<std::string, Real> basis_species;
157 Real charge;
159 Real log10K;
161};
162
171{
173
174 std::vector<Real> adh;
175 std::vector<Real> bdh;
176 std::vector<Real> bdot;
177};
178
192
199{
201 GeochemistryNeutralSpeciesActivity(std::vector<std::vector<Real>> coeffs)
202 : a(coeffs[0]), b(coeffs[1]), c(coeffs[2]), d(coeffs[3])
203 {
204 }
205
206 std::vector<Real> a;
207 std::vector<Real> b;
208 std::vector<Real> c;
209 std::vector<Real> d;
210};
211
216{
217public:
230 GeochemicalDatabaseReader(const FileName filename,
231 const bool reexpress_free_electron = true,
232 const bool use_piecewise_interpolation = false,
233 const bool remove_all_extrapolated_secondary_species = false);
234
239 void read(const FileName filename);
240
246 void validate(const FileName filename, const nlohmann::json & db);
247
254
259 std::string getActivityModel() const;
260
265 std::string getFugacityModel() const;
266
271 std::string getLogKModel() const;
272
277 std::vector<std::string> getBasisSpeciesNames() const { return _bs_names; };
278
283 std::vector<std::string> getEquilibriumSpeciesNames() const { return _es_names; };
284
289 std::vector<std::string> getMineralSpeciesNames() const { return _ms_names; };
290
295 const std::vector<Real> & getTemperatures() const;
296
301 std::vector<Real> getPressures();
302
308
314 std::map<std::string, GeochemistryBasisSpecies>
315 getBasisSpecies(const std::vector<std::string> & names);
316
322 std::map<std::string, GeochemistryEquilibriumSpecies>
323 getEquilibriumSpecies(const std::vector<std::string> & names);
324
330 std::map<std::string, GeochemistryMineralSpecies>
331 getMineralSpecies(const std::vector<std::string> & names);
332
337 std::map<std::string, GeochemistryElements> getElements();
338
344 std::map<std::string, GeochemistryGasSpecies>
345 getGasSpecies(const std::vector<std::string> & names);
346
352 std::map<std::string, GeochemistryRedoxSpecies>
353 getRedoxSpecies(const std::vector<std::string> & names);
354
360 std::map<std::string, GeochemistryOxideSpecies>
361 getOxideSpecies(const std::vector<std::string> & names);
362
368 std::map<std::string, GeochemistrySurfaceSpecies>
369 getSurfaceSpecies(const std::vector<std::string> & names);
370
375 const std::map<std::string, GeochemistryNeutralSpeciesActivity> &
377
384 std::vector<std::string> equilibriumReactions(const std::vector<std::string> & names) const;
385
391 std::vector<std::string> mineralReactions(const std::vector<std::string> & names) const;
392
398 std::vector<std::string> gasReactions(const std::vector<std::string> & names) const;
399
405 std::vector<std::string> redoxReactions(const std::vector<std::string> & names) const;
406
412 std::vector<std::string> oxideReactions(const std::vector<std::string> & names) const;
413
419 std::string getSpeciesData(const std::string name) const;
420
425 const FileName & filename() const;
426
428 bool isSecondarySpecies(const std::string & name) const;
429
435 bool isBasisSpecies(const std::string & name) const;
436 bool isRedoxSpecies(const std::string & name) const;
437 bool isGasSpecies(const std::string & name) const;
438 bool isMineralSpecies(const std::string & name) const;
439 bool isOxideSpecies(const std::string & name) const;
440 bool isSurfaceSpecies(const std::string & name) const;
441
443 bool isSorbingMineral(const std::string & name) const;
444
446 std::vector<std::string> mineralSpeciesNames() const;
447
449 std::vector<std::string> secondarySpeciesNames() const;
450
452 std::vector<std::string> redoxCoupleNames() const;
453
455 std::vector<std::string> surfaceSpeciesNames() const;
456
457protected:
464
469 void setTemperatures();
470
475 void setDebyeHuckel();
476
482
484 const FileName _filename;
486 nlohmann::json _root;
488 std::vector<std::string> _bs_names;
490 std::vector<std::string> _es_names;
492 std::vector<std::string> _ms_names;
494 std::vector<Real> _temperature_points;
496 std::vector<Real> _pressure_points;
498 std::map<std::string, GeochemistryElements> _elements;
500 std::map<std::string, GeochemistryBasisSpecies> _basis_species;
502 std::map<std::string, GeochemistryEquilibriumSpecies> _equilibrium_species;
504 std::map<std::string, GeochemistryMineralSpecies> _mineral_species;
506 std::map<std::string, GeochemistryGasSpecies> _gas_species;
508 std::map<std::string, GeochemistryRedoxSpecies> _redox_species;
510 std::map<std::string, GeochemistryOxideSpecies> _oxide_species;
512 std::map<std::string, GeochemistrySurfaceSpecies> _surface_species;
516 std::map<std::string, GeochemistryNeutralSpeciesActivity> _neutral_species_activity;
517 // Helper for converting json node to Real from string
518 static Real getReal(const nlohmann::json & node);
519
520private:
528 std::vector<std::string>
529 printReactions(const std::vector<std::string> & names,
530 const std::vector<std::map<std::string, Real>> & basis_species) const;
531};
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.
GeochemistryDebyeHuckel _debye_huckel
Debye-Huckel activity coefficients.
std::map< std::string, GeochemistryNeutralSpeciesActivity > _neutral_species_activity
Neutral species activity coefficients.
bool isBasisSpecies(const std::string &name) const
Checks if species is of given type.
std::vector< std::string > oxideReactions(const std::vector< std::string > &names) const
Generates a formatted vector of strings representing all oxide reactions.
void validate(const FileName filename, const nlohmann::json &db)
Validate the thermodynamic database.
std::vector< std::string > getEquilibriumSpeciesNames() const
Get the list of secondary equilibrium species read from database.
std::vector< std::string > printReactions(const std::vector< std::string > &names, const std::vector< std::map< std::string, Real > > &basis_species) const
Generates a formatted vector of strings representing all reactions.
void setNeutralSpeciesActivity()
Copy the Debye-Huckel parameters for computing neutral species activity (if any) found in the databas...
std::map< std::string, GeochemistryEquilibriumSpecies > _equilibrium_species
Secondary equilibrium species and free electron data read from the database.
const GeochemistryDebyeHuckel & getDebyeHuckel() const
Get the Debye-Huckel activity coefficients.
bool isSurfaceSpecies(const std::string &name) const
std::vector< std::string > _ms_names
List of secondary mineral species to read from database.
bool isOxideSpecies(const std::string &name) const
std::vector< std::string > getMineralSpeciesNames() const
Get the list of secondary mineral species read from database.
std::map< std::string, GeochemistryMineralSpecies > _mineral_species
Mineral species data read from the database.
std::map< std::string, GeochemistryRedoxSpecies > _redox_species
Redox species (couples) data read from the database.
void removeExtrapolatedSecondarySpecies()
After parsing the database file, remove any secondary species that have extrapolated equilibrium cons...
bool isSorbingMineral(const std::string &name) const
returns True iff name is the name of a sorbing mineral
std::map< std::string, GeochemistryGasSpecies > getGasSpecies(const std::vector< std::string > &names)
Get the gas species information.
const FileName _filename
Database filename.
std::vector< std::string > gasReactions(const std::vector< std::string > &names) const
Generates a formatted vector of strings representing all gas reactions.
std::map< std::string, GeochemistryOxideSpecies > _oxide_species
Oxide species data read from the database.
std::map< std::string, GeochemistryElements > _elements
Elements and their molecular weight read from the database.
std::vector< std::string > mineralReactions(const std::vector< std::string > &names) const
Generates a formatted vector of strings representing all mineral reactions.
std::vector< std::string > secondarySpeciesNames() const
Returns a list of all the names of the "secondary species" and "free electron" in the database.
std::map< std::string, GeochemistryEquilibriumSpecies > getEquilibriumSpecies(const std::vector< std::string > &names)
Get the secondary equilibrium species information.
std::vector< std::string > getBasisSpeciesNames() const
Get the list of basis (primary) species read from database.
bool isMineralSpecies(const std::string &name) const
std::vector< Real > _pressure_points
Pressure points in database.
void setTemperatures()
Copy the temperature points (if any) found in the database into _temperature_points.
std::map< std::string, GeochemistryBasisSpecies > _basis_species
Basis species data read from the database.
std::map< std::string, GeochemistrySurfaceSpecies > _surface_species
Surface sorbing species data read from the database.
std::vector< std::string > _es_names
List of secondary equilibrium species to read from database.
std::map< std::string, GeochemistryRedoxSpecies > getRedoxSpecies(const std::vector< std::string > &names)
Get the redox species (couples) information.
std::vector< std::string > equilibriumReactions(const std::vector< std::string > &names) const
Generates a formatted vector of strings representing all aqueous equilibrium reactions.
void read(const FileName filename)
Parse the thermodynamic database.
std::string getFugacityModel() const
Get the fugacity model type.
std::vector< std::string > mineralSpeciesNames() const
Returns a list of all the names of the "mineral species" in the database.
bool isSecondarySpecies(const std::string &name) const
Returns true if name is a "secondary species" or "free electron" in the database.
std::map< std::string, GeochemistryBasisSpecies > getBasisSpecies(const std::vector< std::string > &names)
Get the basis (primary) species information.
std::vector< Real > _temperature_points
Temperature points in database.
std::vector< std::string > redoxReactions(const std::vector< std::string > &names) const
Generates a formatted vector of strings representing all redox reactions.
bool isRedoxSpecies(const std::string &name) const
std::map< std::string, GeochemistryOxideSpecies > getOxideSpecies(const std::vector< std::string > &names)
Get the oxide species information.
const FileName & filename() const
Filename of database.
void setDebyeHuckel()
Copy the Debye-Huckel parameters (if any) found in the database into _debye_huckel.
std::vector< std::string > surfaceSpeciesNames() const
Returns a list of all the names of the "surface species" in the database.
std::map< std::string, GeochemistryElements > getElements()
Get all the elements.
const std::vector< Real > & getTemperatures() const
Get the temperature points that the equilibrium constant is defined at.
void reexpressFreeElectron()
Sometimes the free electron's equilibrium reaction is defined in terms of O2(g) which is not a basis ...
std::string getSpeciesData(const std::string name) const
String representation of JSON species object contents.
std::map< std::string, GeochemistryGasSpecies > _gas_species
Gas species data read from the database.
const std::map< std::string, GeochemistryNeutralSpeciesActivity > & getNeutralSpeciesActivity() const
Get the neutral species activity coefficients.
std::vector< Real > getPressures()
Get the pressure points that the equilibrium constant is defined at.
std::vector< std::string > _bs_names
List of basis (primary) species names read from database.
std::string getActivityModel() const
Get the activity model type.
std::string getLogKModel() const
Get the equilibrium constant model type.
std::map< std::string, GeochemistrySurfaceSpecies > getSurfaceSpecies(const std::vector< std::string > &names)
Get the surface sorbing species information.
std::vector< std::string > redoxCoupleNames() const
Returns a list of all the names of the "redox couples" in the database.
bool isGasSpecies(const std::string &name) const
std::map< std::string, GeochemistryMineralSpecies > getMineralSpecies(const std::vector< std::string > &names)
Get the mineral species information.
static Real getReal(const nlohmann::json &node)
Data structure for basis (primary) species.
std::map< std::string, Real > elements
Data structure for Debye-Huckel activity coefficients.
Data structure for elements.
Data structure for secondary equilibrium species.
std::map< std::string, Real > basis_species
Data structure for mineral species.
std::vector< Real > equilibrium_const
std::map< std::string, Real > basis_species
Data structure for mineral species.
std::map< std::string, Real > basis_species
std::map< std::string, Real > sorption_sites
Data structure for neutral species activity coefficients.
GeochemistryNeutralSpeciesActivity(std::vector< std::vector< Real > > coeffs)
Data structure for oxide species.
std::map< std::string, Real > basis_species
Data structure for redox species.
std::map< std::string, Real > basis_species
Data structure for sorbing surface species.
std::map< std::string, Real > basis_species