Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
GeochemicalDatabaseReader Class Reference

Class for reading geochemical reactions from a MOOSE geochemical database. More...

#include <GeochemicalDatabaseReader.h>

Public Member Functions

 GeochemicalDatabaseReader (const FileName filename, const bool reexpress_free_electron=true, const bool use_piecewise_interpolation=false, const bool remove_all_extrapolated_secondary_species=false)
 Parse the file. More...
 
void read (const FileName filename)
 Parse the thermodynamic database. More...
 
void validate (const FileName filename, const nlohmann::json &db)
 Validate the thermodynamic database. More...
 
void reexpressFreeElectron ()
 Sometimes the free electron's equilibrium reaction is defined in terms of O2(g) which is not a basis species. More...
 
std::string getActivityModel () const
 Get the activity model type. More...
 
std::string getFugacityModel () const
 Get the fugacity model type. More...
 
std::string getLogKModel () const
 Get the equilibrium constant model type. More...
 
std::vector< std::string > getBasisSpeciesNames () const
 Get the list of basis (primary) species read from database. More...
 
std::vector< std::string > getEquilibriumSpeciesNames () const
 Get the list of secondary equilibrium species read from database. More...
 
std::vector< std::string > getMineralSpeciesNames () const
 Get the list of secondary mineral species read from database. More...
 
const std::vector< Real > & getTemperatures () const
 Get the temperature points that the equilibrium constant is defined at. More...
 
std::vector< RealgetPressures ()
 Get the pressure points that the equilibrium constant is defined at. More...
 
const GeochemistryDebyeHuckelgetDebyeHuckel () const
 Get the Debye-Huckel activity coefficients. More...
 
std::map< std::string, GeochemistryBasisSpeciesgetBasisSpecies (const std::vector< std::string > &names)
 Get the basis (primary) species information. More...
 
std::map< std::string, GeochemistryEquilibriumSpeciesgetEquilibriumSpecies (const std::vector< std::string > &names)
 Get the secondary equilibrium species information. More...
 
std::map< std::string, GeochemistryMineralSpeciesgetMineralSpecies (const std::vector< std::string > &names)
 Get the mineral species information. More...
 
std::map< std::string, GeochemistryElementsgetElements ()
 Get all the elements. More...
 
std::map< std::string, GeochemistryGasSpeciesgetGasSpecies (const std::vector< std::string > &names)
 Get the gas species information. More...
 
std::map< std::string, GeochemistryRedoxSpeciesgetRedoxSpecies (const std::vector< std::string > &names)
 Get the redox species (couples) information. More...
 
std::map< std::string, GeochemistryOxideSpeciesgetOxideSpecies (const std::vector< std::string > &names)
 Get the oxide species information. More...
 
std::map< std::string, GeochemistrySurfaceSpeciesgetSurfaceSpecies (const std::vector< std::string > &names)
 Get the surface sorbing species information. More...
 
const std::map< std::string, GeochemistryNeutralSpeciesActivity > & getNeutralSpeciesActivity () const
 Get the neutral species activity coefficients. More...
 
std::vector< std::string > equilibriumReactions (const std::vector< std::string > &names) const
 Generates a formatted vector of strings representing all aqueous equilibrium reactions. More...
 
std::vector< std::string > mineralReactions (const std::vector< std::string > &names) const
 Generates a formatted vector of strings representing all mineral reactions. More...
 
std::vector< std::string > gasReactions (const std::vector< std::string > &names) const
 Generates a formatted vector of strings representing all gas reactions. More...
 
std::vector< std::string > redoxReactions (const std::vector< std::string > &names) const
 Generates a formatted vector of strings representing all redox reactions. More...
 
std::vector< std::string > oxideReactions (const std::vector< std::string > &names) const
 Generates a formatted vector of strings representing all oxide reactions. More...
 
std::string getSpeciesData (const std::string name) const
 String representation of JSON species object contents. More...
 
const FileName & filename () const
 Filename of database. More...
 
bool isSecondarySpecies (const std::string &name) const
 Returns true if name is a "secondary species" or "free electron" in the database. More...
 
bool isBasisSpecies (const std::string &name) const
 Checks if species is of given type. More...
 
bool isRedoxSpecies (const std::string &name) const
 
bool isGasSpecies (const std::string &name) const
 
bool isMineralSpecies (const std::string &name) const
 
bool isOxideSpecies (const std::string &name) const
 
bool isSurfaceSpecies (const std::string &name) const
 
bool isSorbingMineral (const std::string &name) const
 returns True iff name is the name of a sorbing mineral More...
 
std::vector< std::string > mineralSpeciesNames () const
 Returns a list of all the names of the "mineral species" in the database. More...
 
std::vector< std::string > secondarySpeciesNames () const
 Returns a list of all the names of the "secondary species" and "free electron" in the database. More...
 
std::vector< std::string > redoxCoupleNames () const
 Returns a list of all the names of the "redox couples" in the database. More...
 
std::vector< std::string > surfaceSpeciesNames () const
 Returns a list of all the names of the "surface species" in the database. More...
 

Protected Member Functions

void removeExtrapolatedSecondarySpecies ()
 After parsing the database file, remove any secondary species that have extrapolated equilibrium constants. More...
 
void setTemperatures ()
 Copy the temperature points (if any) found in the database into _temperature_points. More...
 
void setDebyeHuckel ()
 Copy the Debye-Huckel parameters (if any) found in the database into _debye_huckel. More...
 
void setNeutralSpeciesActivity ()
 Copy the Debye-Huckel parameters for computing neutral species activity (if any) found in the database into _neutral_species_activity. More...
 

Static Protected Member Functions

static Real getReal (const nlohmann::json &node)
 

Protected Attributes

const FileName _filename
 Database filename. More...
 
nlohmann::json _root
 JSON data. More...
 
std::vector< std::string > _bs_names
 List of basis (primary) species names read from database. More...
 
std::vector< std::string > _es_names
 List of secondary equilibrium species to read from database. More...
 
std::vector< std::string > _ms_names
 List of secondary mineral species to read from database. More...
 
std::vector< Real_temperature_points
 Temperature points in database. More...
 
std::vector< Real_pressure_points
 Pressure points in database. More...
 
std::map< std::string, GeochemistryElements_elements
 Elements and their molecular weight read from the database. More...
 
std::map< std::string, GeochemistryBasisSpecies_basis_species
 Basis species data read from the database. More...
 
std::map< std::string, GeochemistryEquilibriumSpecies_equilibrium_species
 Secondary equilibrium species and free electron data read from the database. More...
 
std::map< std::string, GeochemistryMineralSpecies_mineral_species
 Mineral species data read from the database. More...
 
std::map< std::string, GeochemistryGasSpecies_gas_species
 Gas species data read from the database. More...
 
std::map< std::string, GeochemistryRedoxSpecies_redox_species
 Redox species (couples) data read from the database. More...
 
std::map< std::string, GeochemistryOxideSpecies_oxide_species
 Oxide species data read from the database. More...
 
std::map< std::string, GeochemistrySurfaceSpecies_surface_species
 Surface sorbing species data read from the database. More...
 
GeochemistryDebyeHuckel _debye_huckel
 Debye-Huckel activity coefficients. More...
 
std::map< std::string, GeochemistryNeutralSpeciesActivity_neutral_species_activity
 Neutral species activity coefficients. More...
 

Private Member Functions

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. More...
 

Detailed Description

Class for reading geochemical reactions from a MOOSE geochemical database.

Definition at line 213 of file GeochemicalDatabaseReader.h.

Constructor & Destructor Documentation

◆ GeochemicalDatabaseReader()

GeochemicalDatabaseReader::GeochemicalDatabaseReader ( const FileName  filename,
const bool  reexpress_free_electron = true,
const bool  use_piecewise_interpolation = false,
const bool  remove_all_extrapolated_secondary_species = false 
)

Parse the file.

Parameters
filenameMoose geochemical database file
reexpress_free_electronIf true, and if the free electron in the database file has an equilibrium reaction expressed in terms of O2(g), and O2(g) exists as a gas in the database file, and O2(g)'s equilibrium reaction is O2(g)=O2(eq), and O2(aq) exists as a basis species in the database file, then reexpress the free electron's equilibrium reaction in terms of O2(aq)
use_piecewise_interpolationIf true then set the "logk model" to "piecewise-linear" regardless of the value found in the filename. This is designed to make testing easy (because logK and Debye-Huckel parameters will be exactly as set in the filename instead of from a 4-th order least-squares fit) but should rarely be used for real geochemical simulations

Definition at line 18 of file GeochemicalDatabaseReader.C.

24 {
25  read(_filename);
27 
28  if (reexpress_free_electron)
30 
31  if (use_piecewise_interpolation && _root["Header"].contains("logk model"))
32  _root["Header"]["logk model"] = "piecewise-linear";
33 
34  if (remove_all_extrapolated_secondary_species)
36 
40 }
void validate(const FileName filename, const nlohmann::json &db)
Validate the thermodynamic database.
const FileName & filename() const
Filename of database.
nlohmann::json _root
JSON data.
const FileName _filename
Database filename.
void removeExtrapolatedSecondarySpecies()
After parsing the database file, remove any secondary species that have extrapolated equilibrium cons...
void setDebyeHuckel()
Copy the Debye-Huckel parameters (if any) found in the database into _debye_huckel.
void read(const FileName filename)
Parse the thermodynamic database.
void setTemperatures()
Copy the temperature points (if any) found in the database into _temperature_points.
void reexpressFreeElectron()
Sometimes the free electron&#39;s equilibrium reaction is defined in terms of O2(g) which is not a basis ...
void setNeutralSpeciesActivity()
Copy the Debye-Huckel parameters for computing neutral species activity (if any) found in the databas...

Member Function Documentation

◆ equilibriumReactions()

std::vector< std::string > GeochemicalDatabaseReader::equilibriumReactions ( const std::vector< std::string > &  names) const

Generates a formatted vector of strings representing all aqueous equilibrium reactions.

Parameters
nameslist of equilibrium species return formatted equilibrium reactions

Definition at line 513 of file GeochemicalDatabaseReader.C.

Referenced by TEST().

514 {
515  std::vector<std::map<std::string, Real>> basis_species(names.size());
516 
517  for (unsigned int i = 0; i < names.size(); ++i)
518  {
519  auto species = names[i];
520 
521  if (_root["secondary species"].contains(species))
522  {
523  auto sec_species = _root["secondary species"][species];
524 
525  // The basis species in this reaction
526  std::map<std::string, Real> this_basis_species;
527  for (auto & bs : sec_species["species"].items())
528  this_basis_species[bs.key()] = getReal(bs.value());
529 
530  basis_species[i] = this_basis_species;
531  }
532  else
533  mooseError(species + " does not exist in database " + _filename);
534  }
535 
536  auto reactions = printReactions(names, basis_species);
537 
538  return reactions;
539 }
void mooseError(Args &&... args)
nlohmann::json _root
JSON data.
const FileName _filename
Database filename.
static Real getReal(const nlohmann::json &node)
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.

◆ filename()

const FileName & GeochemicalDatabaseReader::filename ( ) const

Filename of database.

Returns
filename

Definition at line 740 of file GeochemicalDatabaseReader.C.

Referenced by PertinentGeochemicalSystem::buildBasis(), read(), TEST(), and validate().

741 {
742  return _filename;
743 }
const FileName _filename
Database filename.

◆ gasReactions()

std::vector< std::string > GeochemicalDatabaseReader::gasReactions ( const std::vector< std::string > &  names) const

Generates a formatted vector of strings representing all gas reactions.

Parameters
nameslist of gas species formatted gas reactions

Definition at line 571 of file GeochemicalDatabaseReader.C.

Referenced by TEST().

572 {
573  std::vector<std::map<std::string, Real>> basis_species(names.size());
574 
575  for (unsigned int i = 0; i < names.size(); ++i)
576  {
577  const auto species = names[i];
578 
579  if (_root["gas species"].contains(species))
580  {
581  auto gas_species = _root["gas species"][species];
582 
583  // The basis species in this reaction
584  std::map<std::string, Real> this_basis_species;
585  for (auto & bs : gas_species["species"].items())
586  this_basis_species[bs.key()] = getReal(bs.value());
587 
588  basis_species[i] = this_basis_species;
589  }
590  else
591  mooseError(species + " does not exist in database " + _filename);
592  }
593 
594  auto reactions = printReactions(names, basis_species);
595 
596  return reactions;
597 }
void mooseError(Args &&... args)
nlohmann::json _root
JSON data.
const FileName _filename
Database filename.
static Real getReal(const nlohmann::json &node)
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.

◆ getActivityModel()

std::string GeochemicalDatabaseReader::getActivityModel ( ) const

Get the activity model type.

Returns
activity model

Definition at line 109 of file GeochemicalDatabaseReader.C.

Referenced by getDebyeHuckel(), setDebyeHuckel(), and TEST().

110 {
111  return _root["Header"]["activity model"];
112 }
nlohmann::json _root
JSON data.

◆ getBasisSpecies()

std::map< std::string, GeochemistryBasisSpecies > GeochemicalDatabaseReader::getBasisSpecies ( const std::vector< std::string > &  names)

Get the basis (primary) species information.

Parameters
nameslist of basis species
Returns
basis species structure

Definition at line 215 of file GeochemicalDatabaseReader.C.

Referenced by PertinentGeochemicalSystem::buildBasis(), and TEST().

216 {
217  // Parse the basis species specified in names
218  for (const auto & species : names)
219  if (_root["basis species"].contains(species))
220  {
222 
223  auto basis_species = _root["basis species"][species];
224  dbs.name = species;
225  dbs.radius = getReal(basis_species["radius"]);
226  dbs.charge = getReal(basis_species["charge"]);
227  dbs.molecular_weight = getReal(basis_species["molecular weight"]);
228 
229  std::map<std::string, Real> elements;
230  for (auto & el : basis_species["elements"].items())
231  elements[el.key()] = getReal(el.value());
232 
233  dbs.elements = elements;
234 
235  _basis_species[species] = dbs;
236  }
237  else
238  mooseError(species + " does not exist in database " + _filename);
239 
240  return _basis_species;
241 }
Data structure for basis (primary) species.
void mooseError(Args &&... args)
nlohmann::json _root
JSON data.
const FileName _filename
Database filename.
static Real getReal(const nlohmann::json &node)
std::map< std::string, Real > elements
std::map< std::string, GeochemistryBasisSpecies > _basis_species
Basis species data read from the database.

◆ getBasisSpeciesNames()

std::vector<std::string> GeochemicalDatabaseReader::getBasisSpeciesNames ( ) const
inline

Get the list of basis (primary) species read from database.

Returns
list of primary species names

Definition at line 275 of file GeochemicalDatabaseReader.h.

275 { return _bs_names; };
std::vector< std::string > _bs_names
List of basis (primary) species names read from database.

◆ getDebyeHuckel()

const GeochemistryDebyeHuckel & GeochemicalDatabaseReader::getDebyeHuckel ( ) const

Get the Debye-Huckel activity coefficients.

Returns
vectors of adh, bdh and bdot

Definition at line 191 of file GeochemicalDatabaseReader.C.

Referenced by TEST().

192 {
193  if (getActivityModel() != "debye-huckel")
194  mooseError("Attempted to get Debye-Huckel activity parameters but the activity model is ",
195  getActivityModel());
196  return _debye_huckel;
197 }
std::string getActivityModel() const
Get the activity model type.
void mooseError(Args &&... args)
GeochemistryDebyeHuckel _debye_huckel
Debye-Huckel activity coefficients.

◆ getElements()

std::map< std::string, GeochemistryElements > GeochemicalDatabaseReader::getElements ( )

Get all the elements.

Returns
elements species structure

Definition at line 200 of file GeochemicalDatabaseReader.C.

Referenced by TEST().

201 {
202  if (_root.contains("elements"))
203  {
204  for (auto & el : _root["elements"].items())
205  {
206  _elements[el.key()].name = el.value()["name"];
207  _elements[el.key()].molecular_weight = getReal(el.value()["molecular weight"]);
208  }
209  }
210 
211  return _elements;
212 }
nlohmann::json _root
JSON data.
static Real getReal(const nlohmann::json &node)
std::map< std::string, GeochemistryElements > _elements
Elements and their molecular weight read from the database.

◆ getEquilibriumSpecies()

std::map< std::string, GeochemistryEquilibriumSpecies > GeochemicalDatabaseReader::getEquilibriumSpecies ( const std::vector< std::string > &  names)

Get the secondary equilibrium species information.

Parameters
nameslist of equilibrium species
Returns
secondary species structure

Definition at line 244 of file GeochemicalDatabaseReader.C.

Referenced by PertinentGeochemicalSystem::buildRedoxeInfo(), PertinentGeochemicalSystem::buildSecondarySpecies(), PertinentGeochemicalSystem::checkRedoxe(), and TEST().

245 {
246  // Parse the secondary species specified in names
247  for (const auto & species : names)
248  if (_root["secondary species"].contains(species) or _root["free electron"].contains(species))
249  {
251 
252  auto sec_species = _root["secondary species"].contains(species)
253  ? _root["secondary species"][species]
254  : _root["free electron"][species];
255  dbs.name = species;
256  dbs.radius = getReal(sec_species["radius"]);
257  dbs.charge = getReal(sec_species["charge"]);
258  dbs.molecular_weight = getReal(sec_species["molecular weight"]);
259 
260  std::vector<Real> eq_const(sec_species["logk"].size());
261  for (unsigned int i = 0; i < sec_species["logk"].size(); ++i)
262  eq_const[i] = getReal(sec_species["logk"][i]);
263 
264  dbs.equilibrium_const = eq_const;
265 
266  std::map<std::string, Real> basis_species;
267  for (auto & bs : sec_species["species"].items())
268  basis_species[bs.key()] = getReal(bs.value());
269 
270  dbs.basis_species = basis_species;
271 
272  _equilibrium_species[species] = dbs;
273  }
274  else
275  mooseError(species + " does not exist in database " + _filename);
276 
277  return _equilibrium_species;
278 }
std::map< std::string, Real > basis_species
void mooseError(Args &&... args)
nlohmann::json _root
JSON data.
const FileName _filename
Database filename.
static Real getReal(const nlohmann::json &node)
std::map< std::string, GeochemistryEquilibriumSpecies > _equilibrium_species
Secondary equilibrium species and free electron data read from the database.
Data structure for secondary equilibrium species.

◆ getEquilibriumSpeciesNames()

std::vector<std::string> GeochemicalDatabaseReader::getEquilibriumSpeciesNames ( ) const
inline

Get the list of secondary equilibrium species read from database.

Returns
list of equilibrium species names

Definition at line 281 of file GeochemicalDatabaseReader.h.

281 { return _es_names; };
std::vector< std::string > _es_names
List of secondary equilibrium species to read from database.

◆ getFugacityModel()

std::string GeochemicalDatabaseReader::getFugacityModel ( ) const

Get the fugacity model type.

Returns
fugacity model

Definition at line 115 of file GeochemicalDatabaseReader.C.

Referenced by TEST().

116 {
117  return _root["Header"]["fugacity model"];
118 }
nlohmann::json _root
JSON data.

◆ getGasSpecies()

std::map< std::string, GeochemistryGasSpecies > GeochemicalDatabaseReader::getGasSpecies ( const std::vector< std::string > &  names)

Get the gas species information.

Parameters
nameslist of gs species
Returns
gas species structure

Definition at line 328 of file GeochemicalDatabaseReader.C.

Referenced by PertinentGeochemicalSystem::buildGases(), and TEST().

329 {
330  // Parse the gas species specified in names
331  for (const auto & species : names)
332  if (_root["gas species"].contains(species))
333  {
335 
336  auto gas_species = _root["gas species"][species];
337  dbs.name = species;
338  dbs.molecular_weight = getReal(gas_species["molecular weight"]);
339 
340  std::vector<Real> eq_const(gas_species["logk"].size());
341  for (unsigned int i = 0; i < gas_species["logk"].size(); ++i)
342  eq_const[i] = getReal(gas_species["logk"][i]);
343 
344  dbs.equilibrium_const = eq_const;
345 
346  std::map<std::string, Real> basis_species;
347  for (auto & bs : gas_species["species"].items())
348  basis_species[bs.key()] = getReal(bs.value());
349 
350  dbs.basis_species = basis_species;
351 
352  // Optional fugacity coefficients
353  if (gas_species.contains("chi"))
354  {
355  std::vector<Real> chi(gas_species["chi"].size());
356  for (unsigned int i = 0; i < gas_species["chi"].size(); ++i)
357  chi[i] = getReal(gas_species["chi"][i]);
358 
359  dbs.chi = chi;
360  }
361 
362  if (gas_species.contains("Pcrit"))
363  dbs.Pcrit = getReal(gas_species["Pcrit"]);
364 
365  if (gas_species.contains("Tcrit"))
366  dbs.Tcrit = getReal(gas_species["Tcrit"]);
367 
368  if (gas_species.contains("omega"))
369  dbs.omega = getReal(gas_species["omega"]);
370 
371  _gas_species[species] = dbs;
372  }
373  else
374  mooseError(species + " does not exist in database " + _filename);
375 
376  return _gas_species;
377 }
void mooseError(Args &&... args)
nlohmann::json _root
JSON data.
std::map< std::string, GeochemistryGasSpecies > _gas_species
Gas species data read from the database.
const FileName _filename
Database filename.
Data structure for mineral species.
static Real getReal(const nlohmann::json &node)
std::vector< Real > equilibrium_const
std::map< std::string, Real > basis_species

◆ getLogKModel()

std::string GeochemicalDatabaseReader::getLogKModel ( ) const

Get the equilibrium constant model type.

Returns
equilibrium constant model

Definition at line 121 of file GeochemicalDatabaseReader.C.

Referenced by GeochemicalSystem::buildTemperatureDependentQuantities(), GeochemicalModelInterrogator::outputActivity(), GeochemicalModelInterrogator::outputReaction(), GeochemicalModelInterrogator::solveForT(), and TEST().

122 {
123  return _root["Header"]["logk model"];
124 }
nlohmann::json _root
JSON data.

◆ getMineralSpecies()

std::map< std::string, GeochemistryMineralSpecies > GeochemicalDatabaseReader::getMineralSpecies ( const std::vector< std::string > &  names)

Get the mineral species information.

Parameters
nameslist of mineral species
Returns
mineral species structure

Definition at line 281 of file GeochemicalDatabaseReader.C.

Referenced by PertinentGeochemicalSystem::buildAllMinerals(), PertinentGeochemicalSystem::buildKineticMinerals(), PertinentGeochemicalSystem::buildMinerals(), and TEST().

282 {
283  // Parse the mineral species specified in names
284  for (const auto & species : names)
285  if (_root["mineral species"].contains(species))
286  {
288 
289  auto mineral_species = _root["mineral species"][species];
290  dbs.name = species;
291  dbs.molecular_weight = getReal(mineral_species["molecular weight"]);
292  dbs.molecular_volume = getReal(mineral_species["molar volume"]);
293 
294  std::vector<Real> eq_const(mineral_species["logk"].size());
295  for (unsigned int i = 0; i < mineral_species["logk"].size(); ++i)
296  eq_const[i] = getReal(mineral_species["logk"][i]);
297 
298  dbs.equilibrium_const = eq_const;
299 
300  std::map<std::string, Real> basis_species;
301  for (auto & bs : mineral_species["species"].items())
302  basis_species[bs.key()] = getReal(bs.value());
303 
304  dbs.basis_species = basis_species;
305 
306  // recover sorption information, if any
307  std::map<std::string, Real> species_and_sorbing_density;
308  dbs.surface_area = 0.0;
309  if (_root["sorbing minerals"].contains(species))
310  {
311  auto sorbing_mineral = _root["sorbing minerals"][species];
312  dbs.surface_area = getReal(sorbing_mineral["surface area"]);
313 
314  for (auto & site : sorbing_mineral["sorbing sites"].items())
315  species_and_sorbing_density[site.key()] = getReal(site.value());
316  }
317  dbs.sorption_sites = species_and_sorbing_density;
318 
319  _mineral_species[species] = dbs;
320  }
321  else
322  mooseError(species + " does not exist in database " + _filename);
323 
324  return _mineral_species;
325 }
void mooseError(Args &&... args)
Data structure for mineral species.
nlohmann::json _root
JSON data.
std::map< std::string, Real > basis_species
const FileName _filename
Database filename.
std::map< std::string, GeochemistryMineralSpecies > _mineral_species
Mineral species data read from the database.
static Real getReal(const nlohmann::json &node)
std::map< std::string, Real > sorption_sites

◆ getMineralSpeciesNames()

std::vector<std::string> GeochemicalDatabaseReader::getMineralSpeciesNames ( ) const
inline

Get the list of secondary mineral species read from database.

Returns
list of mineral species names

Definition at line 287 of file GeochemicalDatabaseReader.h.

287 { return _ms_names; };
std::vector< std::string > _ms_names
List of secondary mineral species to read from database.

◆ getNeutralSpeciesActivity()

const std::map< std::string, GeochemistryNeutralSpeciesActivity > & GeochemicalDatabaseReader::getNeutralSpeciesActivity ( ) const

Get the neutral species activity coefficients.

Returns
neutral species activity coefficients

Definition at line 505 of file GeochemicalDatabaseReader.C.

Referenced by TEST().

506 {
507  if (!_root["Header"].contains("neutral species"))
508  mooseError("No neutral species activity coefficients in database");
510 }
void mooseError(Args &&... args)
nlohmann::json _root
JSON data.
std::map< std::string, GeochemistryNeutralSpeciesActivity > _neutral_species_activity
Neutral species activity coefficients.

◆ getOxideSpecies()

std::map< std::string, GeochemistryOxideSpecies > GeochemicalDatabaseReader::getOxideSpecies ( const std::vector< std::string > &  names)

Get the oxide species information.

Parameters
nameslist of gs species
Returns
oxide species structure

Definition at line 415 of file GeochemicalDatabaseReader.C.

Referenced by TEST().

416 {
417  // Parse the oxide species specified in names
418  for (auto & species : names)
419  if (_root["oxides"].contains(species))
420  {
422 
423  auto oxide_species = _root["oxides"][species];
424  dbs.name = species;
425  dbs.molecular_weight = getReal(oxide_species["molecular weight"]);
426 
427  std::map<std::string, Real> basis_species;
428  for (auto & bs : oxide_species["species"].items())
429  basis_species[bs.key()] = getReal(bs.value());
430 
431  dbs.basis_species = basis_species;
432 
433  _oxide_species[species] = dbs;
434  }
435  else
436  mooseError(species + " does not exist in database " + _filename);
437 
438  return _oxide_species;
439 }
void mooseError(Args &&... args)
Data structure for oxide species.
nlohmann::json _root
JSON data.
const FileName _filename
Database filename.
std::map< std::string, Real > basis_species
std::map< std::string, GeochemistryOxideSpecies > _oxide_species
Oxide species data read from the database.
static Real getReal(const nlohmann::json &node)

◆ getPressures()

std::vector< Real > GeochemicalDatabaseReader::getPressures ( )

Get the pressure points that the equilibrium constant is defined at.

Returns
vector of pressure points (C)

Definition at line 145 of file GeochemicalDatabaseReader.C.

Referenced by TEST().

146 {
147  // Read pressure points
148  if (_root["Header"].contains("pressures"))
149  {
150  auto pressures = _root["Header"]["pressures"];
151  _pressure_points.resize(pressures.size());
152  for (unsigned int i = 0; i < pressures.size(); ++i)
153  _pressure_points[i] = getReal(pressures[i]);
154  }
155 
156  return _pressure_points;
157 }
nlohmann::json _root
JSON data.
static Real getReal(const nlohmann::json &node)
std::vector< Real > _pressure_points
Pressure points in database.

◆ getReal()

Real GeochemicalDatabaseReader::getReal ( const nlohmann::json &  node)
staticprotected

◆ getRedoxSpecies()

std::map< std::string, GeochemistryRedoxSpecies > GeochemicalDatabaseReader::getRedoxSpecies ( const std::vector< std::string > &  names)

Get the redox species (couples) information.

Parameters
nameslist of gs species
Returns
redox species structure

Definition at line 380 of file GeochemicalDatabaseReader.C.

Referenced by PertinentGeochemicalSystem::buildBasis(), PertinentGeochemicalSystem::buildKineticRedox(), PertinentGeochemicalSystem::buildSecondarySpecies(), PertinentGeochemicalSystem::createModel(), and TEST().

381 {
382  // Parse the redox species specified in names
383  for (const auto & species : names)
384  if (_root["redox couples"].contains(species))
385  {
387 
388  auto redox_species = _root["redox couples"][species];
389  dbs.name = species;
390  dbs.radius = getReal(redox_species["radius"]);
391  dbs.charge = getReal(redox_species["charge"]);
392  dbs.molecular_weight = getReal(redox_species["molecular weight"]);
393 
394  std::vector<Real> eq_const(redox_species["logk"].size());
395  for (unsigned int i = 0; i < redox_species["logk"].size(); ++i)
396  eq_const[i] = getReal(redox_species["logk"][i]);
397 
398  dbs.equilibrium_const = eq_const;
399 
400  std::map<std::string, Real> basis_species;
401  for (auto & bs : redox_species["species"].items())
402  basis_species[bs.key()] = getReal(bs.value());
403 
404  dbs.basis_species = basis_species;
405 
406  _redox_species[species] = dbs;
407  }
408  else
409  mooseError(species + " does not exist in database " + _filename);
410 
411  return _redox_species;
412 }
void mooseError(Args &&... args)
std::map< std::string, GeochemistryRedoxSpecies > _redox_species
Redox species (couples) data read from the database.
Data structure for redox species.
nlohmann::json _root
JSON data.
const FileName _filename
Database filename.
static Real getReal(const nlohmann::json &node)
std::map< std::string, Real > basis_species

◆ getSpeciesData()

std::string GeochemicalDatabaseReader::getSpeciesData ( const std::string  name) const

String representation of JSON species object contents.

Parameters
namename of species
Returns
styled string of species information

Definition at line 794 of file GeochemicalDatabaseReader.C.

Referenced by TEST().

795 {
796  std::string output;
797  for (auto & item : _root.items())
798  if (_root[item.key()].contains(name))
799  {
800  std::ostringstream os;
801  os << item.value()[name].dump(4);
802  output = os.str();
803  }
804 
805  if (output.empty())
806  mooseError(name + " is not a species in the database");
807 
808  return name + ":\n" + output;
809 }
void mooseError(Args &&... args)
nlohmann::json _root
JSON data.
std::basic_ostream< charT, traits > * os
const std::string name
Definition: Setup.h:20

◆ getSurfaceSpecies()

std::map< std::string, GeochemistrySurfaceSpecies > GeochemicalDatabaseReader::getSurfaceSpecies ( const std::vector< std::string > &  names)

Get the surface sorbing species information.

Parameters
nameslist of surface sorbing species
Returns
surface sorbing species structure

Definition at line 442 of file GeochemicalDatabaseReader.C.

Referenced by PertinentGeochemicalSystem::buildKineticSurface(), PertinentGeochemicalSystem::buildSecondarySpecies(), and TEST().

443 {
444  // Parse the secondary species specified in names
445  for (const auto & species : names)
446  if (_root["surface species"].contains(species))
447  {
449 
450  auto surface_species = _root["surface species"][species];
451  dbs.name = species;
452  dbs.charge = getReal(surface_species["charge"]);
453  dbs.molecular_weight = getReal(surface_species["molecular weight"]);
454  dbs.log10K = getReal(surface_species["log K"]);
455  dbs.dlog10KdT = getReal(surface_species["dlogK/dT"]);
456 
457  std::map<std::string, Real> basis_species;
458  for (auto & bs : surface_species["species"].items())
459  basis_species[bs.key()] = getReal(bs.value());
460 
461  dbs.basis_species = basis_species;
462 
463  _surface_species[species] = dbs;
464  }
465  else
466  mooseError(species + " does not exist in database " + _filename);
467 
468  return _surface_species;
469 }
void mooseError(Args &&... args)
nlohmann::json _root
JSON data.
Data structure for sorbing surface species.
const FileName _filename
Database filename.
static Real getReal(const nlohmann::json &node)
std::map< std::string, GeochemistrySurfaceSpecies > _surface_species
Surface sorbing species data read from the database.
std::map< std::string, Real > basis_species

◆ getTemperatures()

const std::vector< Real > & GeochemicalDatabaseReader::getTemperatures ( ) const

◆ isBasisSpecies()

bool GeochemicalDatabaseReader::isBasisSpecies ( const std::string &  name) const

Checks if species is of given type.

Parameters
namespecies name
Returns
true iff species is of given type

Definition at line 746 of file GeochemicalDatabaseReader.C.

Referenced by PertinentGeochemicalSystem::buildBasis(), and TEST().

747 {
748  return _root["basis species"].contains(name);
749 }
nlohmann::json _root
JSON data.
const std::string name
Definition: Setup.h:20

◆ isGasSpecies()

bool GeochemicalDatabaseReader::isGasSpecies ( const std::string &  name) const

Definition at line 770 of file GeochemicalDatabaseReader.C.

Referenced by TEST().

771 {
772  return _root["gas species"].contains(name);
773 }
nlohmann::json _root
JSON data.
const std::string name
Definition: Setup.h:20

◆ isMineralSpecies()

bool GeochemicalDatabaseReader::isMineralSpecies ( const std::string &  name) const

Definition at line 776 of file GeochemicalDatabaseReader.C.

Referenced by TEST().

777 {
778  return _root["mineral species"].contains(name);
779 }
nlohmann::json _root
JSON data.
const std::string name
Definition: Setup.h:20

◆ isOxideSpecies()

bool GeochemicalDatabaseReader::isOxideSpecies ( const std::string &  name) const

Definition at line 782 of file GeochemicalDatabaseReader.C.

Referenced by TEST().

783 {
784  return _root["oxides"].contains(name);
785 }
nlohmann::json _root
JSON data.
const std::string name
Definition: Setup.h:20

◆ isRedoxSpecies()

bool GeochemicalDatabaseReader::isRedoxSpecies ( const std::string &  name) const

Definition at line 752 of file GeochemicalDatabaseReader.C.

Referenced by PertinentGeochemicalSystem::buildBasis(), PertinentGeochemicalSystem::createModel(), and TEST().

753 {
754  return _root["redox couples"].contains(name);
755 }
nlohmann::json _root
JSON data.
const std::string name
Definition: Setup.h:20

◆ isSecondarySpecies()

bool GeochemicalDatabaseReader::isSecondarySpecies ( const std::string &  name) const

Returns true if name is a "secondary species" or "free electron" in the database.

Definition at line 764 of file GeochemicalDatabaseReader.C.

Referenced by TEST().

765 {
766  return _root["secondary species"].contains(name) || _root["free electron"].contains(name);
767 }
nlohmann::json _root
JSON data.
const std::string name
Definition: Setup.h:20

◆ isSorbingMineral()

bool GeochemicalDatabaseReader::isSorbingMineral ( const std::string &  name) const

returns True iff name is the name of a sorbing mineral

Definition at line 758 of file GeochemicalDatabaseReader.C.

Referenced by TEST().

759 {
760  return _root["sorbing minerals"].contains(name);
761 }
nlohmann::json _root
JSON data.
const std::string name
Definition: Setup.h:20

◆ isSurfaceSpecies()

bool GeochemicalDatabaseReader::isSurfaceSpecies ( const std::string &  name) const

Definition at line 788 of file GeochemicalDatabaseReader.C.

Referenced by TEST().

789 {
790  return _root["surface species"].contains(name);
791 }
nlohmann::json _root
JSON data.
const std::string name
Definition: Setup.h:20

◆ mineralReactions()

std::vector< std::string > GeochemicalDatabaseReader::mineralReactions ( const std::vector< std::string > &  names) const

Generates a formatted vector of strings representing all mineral reactions.

Parameters
nameslist of mineral species formatted mineral reactions

Definition at line 542 of file GeochemicalDatabaseReader.C.

Referenced by TEST().

543 {
544  std::vector<std::map<std::string, Real>> basis_species(names.size());
545 
546  for (unsigned int i = 0; i < names.size(); ++i)
547  {
548  const auto species = names[i];
549 
550  if (_root["mineral species"].contains(species))
551  {
552  auto min_species = _root["mineral species"][species];
553 
554  // The basis species in this reaction
555  std::map<std::string, Real> this_basis_species;
556  for (auto & bs : min_species["species"].items())
557  this_basis_species[bs.key()] = getReal(bs.value());
558 
559  basis_species[i] = this_basis_species;
560  }
561  else
562  mooseError(species + " does not exist in database " + _filename);
563  }
564 
565  auto reactions = printReactions(names, basis_species);
566 
567  return reactions;
568 }
void mooseError(Args &&... args)
nlohmann::json _root
JSON data.
const FileName _filename
Database filename.
static Real getReal(const nlohmann::json &node)
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.

◆ mineralSpeciesNames()

std::vector< std::string > GeochemicalDatabaseReader::mineralSpeciesNames ( ) const

Returns a list of all the names of the "mineral species" in the database.

Definition at line 696 of file GeochemicalDatabaseReader.C.

Referenced by PertinentGeochemicalSystem::buildAllMinerals(), and TEST().

697 {
698  std::vector<std::string> names;
699  if (_root.contains("mineral species"))
700  for (auto & item : _root["mineral species"].items())
701  names.push_back(item.key());
702  return names;
703 }
nlohmann::json _root
JSON data.

◆ oxideReactions()

std::vector< std::string > GeochemicalDatabaseReader::oxideReactions ( const std::vector< std::string > &  names) const

Generates a formatted vector of strings representing all oxide reactions.

Parameters
nameslist of oxide species formatted oxide reactions

Definition at line 629 of file GeochemicalDatabaseReader.C.

Referenced by TEST().

630 {
631  std::vector<std::map<std::string, Real>> basis_species(names.size());
632 
633  for (unsigned int i = 0; i < names.size(); ++i)
634  {
635  const auto species = names[i];
636 
637  if (_root["oxides"].contains(species))
638  {
639  auto oxide_species = _root["oxides"][species];
640 
641  // The basis species in this reaction
642  std::map<std::string, Real> this_basis_species;
643  for (auto & bs : oxide_species["species"].items())
644  this_basis_species[bs.key()] = getReal(bs.value());
645 
646  basis_species[i] = this_basis_species;
647  }
648  else
649  mooseError(species + " does not exist in database " + _filename);
650  }
651 
652  auto reactions = printReactions(names, basis_species);
653 
654  return reactions;
655 }
void mooseError(Args &&... args)
nlohmann::json _root
JSON data.
const FileName _filename
Database filename.
static Real getReal(const nlohmann::json &node)
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.

◆ printReactions()

std::vector< std::string > GeochemicalDatabaseReader::printReactions ( const std::vector< std::string > &  names,
const std::vector< std::map< std::string, Real >> &  basis_species 
) const
private

Generates a formatted vector of strings representing all reactions.

Parameters
nameslist of reaction species
basisspecies list of basis species for each reaction species (this vector must be of same size as names)
Returns
formatted reaction equations

Definition at line 658 of file GeochemicalDatabaseReader.C.

Referenced by equilibriumReactions(), gasReactions(), mineralReactions(), oxideReactions(), and redoxReactions().

661 {
662  std::vector<std::string> reactions;
663 
664  for (unsigned int i = 0; i < names.size(); ++i)
665  {
666  std::string reaction = "";
667  for (auto & bs : basis_species[i])
668  {
669  if (bs.second < 0.0)
670  {
671  if (bs.second == -1.0)
672  reaction += " - " + bs.first;
673  else
674  reaction += " " + Moose::stringify(bs.second) + bs.first;
675  }
676  else
677  {
678  if (bs.second == 1.0)
679  reaction += " + " + bs.first;
680  else
681  reaction += " + " + Moose::stringify(bs.second) + bs.first;
682  }
683  }
684 
685  // Trim off leading +
686  if (reaction.size() > 1 && reaction[1] == '+')
687  reaction.erase(1, 2);
688 
689  reactions.push_back(names[i] + " =" + reaction);
690  }
691 
692  return reactions;
693 }
std::string reaction(const DenseMatrix< Real > &stoi, unsigned row, const std::vector< std::string > &names, Real stoi_tol=1.0E-6, int precision=4)
Returns a nicely formatted string corresponding to the reaction defined by the given row of the stoic...
std::string stringify(const T &t)

◆ read()

void GeochemicalDatabaseReader::read ( const FileName  filename)

Parse the thermodynamic database.

Parameters
filenameName of thermodynamic database file

Definition at line 43 of file GeochemicalDatabaseReader.C.

Referenced by GeochemicalDatabaseReader().

44 {
46 
47  // Read the JSON database
48  std::ifstream jsondata(filename);
49  jsondata >> _root;
50 }
const FileName & filename() const
Filename of database.
nlohmann::json _root
JSON data.
bool checkFileReadable(const std::string &filename, bool check_line_endings=false, bool throw_on_unreadable=true, bool check_for_git_lfs_pointer=true)

◆ redoxCoupleNames()

std::vector< std::string > GeochemicalDatabaseReader::redoxCoupleNames ( ) const

Returns a list of all the names of the "redox couples" in the database.

Definition at line 720 of file GeochemicalDatabaseReader.C.

Referenced by PertinentGeochemicalSystem::buildSecondarySpecies(), and TEST().

721 {
722  std::vector<std::string> names;
723  if (_root.contains("redox couples"))
724  for (const auto & item : _root["redox couples"].items())
725  names.push_back(item.key());
726  return names;
727 }
nlohmann::json _root
JSON data.

◆ redoxReactions()

std::vector< std::string > GeochemicalDatabaseReader::redoxReactions ( const std::vector< std::string > &  names) const

Generates a formatted vector of strings representing all redox reactions.

Parameters
nameslist of redox species formatted redox reactions

Definition at line 600 of file GeochemicalDatabaseReader.C.

Referenced by TEST().

601 {
602  std::vector<std::map<std::string, Real>> basis_species(names.size());
603 
604  for (unsigned int i = 0; i < names.size(); ++i)
605  {
606  const auto species = names[i];
607 
608  if (_root["redox couples"].contains(species))
609  {
610  auto redox_species = _root["redox couples"][species];
611 
612  // The basis species in this reaction
613  std::map<std::string, Real> this_basis_species;
614  for (auto & bs : redox_species["species"].items())
615  this_basis_species[bs.key()] = getReal(bs.value());
616 
617  basis_species[i] = this_basis_species;
618  }
619  else
620  mooseError(species + " does not exist in database " + _filename);
621  }
622 
623  auto reactions = printReactions(names, basis_species);
624 
625  return reactions;
626 }
void mooseError(Args &&... args)
nlohmann::json _root
JSON data.
const FileName _filename
Database filename.
static Real getReal(const nlohmann::json &node)
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.

◆ reexpressFreeElectron()

void GeochemicalDatabaseReader::reexpressFreeElectron ( )

Sometimes the free electron's equilibrium reaction is defined in terms of O2(g) which is not a basis species.

If this is the case, re-express it in terms of O2(aq), if O2(g) is a gas and O2(aq) is a basis species.

Definition at line 62 of file GeochemicalDatabaseReader.C.

Referenced by GeochemicalDatabaseReader().

63 {
64  if (!_root.contains("free electron") || !_root["free electron"].contains("e-") ||
65  !_root["free electron"]["e-"]["species"].contains("O2(g)"))
66  return;
67  if (!_root.contains("basis species") || !_root["basis species"].contains("O2(aq)"))
68  return;
69  if (!_root.contains("gas species") || !_root["gas species"].contains("O2(g)") ||
70  !_root["gas species"]["O2(g)"]["species"].contains("O2(aq)") ||
71  (_root["gas species"]["O2(g)"]["species"].size() != 1))
72  return;
73 
74  // remove O2(g) in the "e-" and replace with O2(aq)
75  const std::string stoi_o2g =
76  nlohmann::to_string(_root["free electron"]["e-"]["species"]["O2(g)"]);
77  _root["free electron"]["e-"]["species"].erase("O2(g)");
78  _root["free electron"]["e-"]["species"]["O2(aq)"] = stoi_o2g;
79  const Real stoi = getReal(stoi_o2g);
80 
81  // alter equilibrium constants
82  if (!_root["Header"].contains("temperatures"))
83  return;
84  for (unsigned i = 0; i < _root["Header"]["temperatures"].size(); ++i)
85  {
86  const Real logk_e = getReal(_root["free electron"]["e-"]["logk"][i]);
87  const Real logk_o2 = getReal(_root["gas species"]["O2(g)"]["logk"][i]);
88  const Real newk = logk_e + stoi * logk_o2;
89  _root["free electron"]["e-"]["logk"][i] = std::to_string(newk);
90  }
91 }
nlohmann::json _root
JSON data.
static Real getReal(const nlohmann::json &node)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ removeExtrapolatedSecondarySpecies()

void GeochemicalDatabaseReader::removeExtrapolatedSecondarySpecies ( )
protected

After parsing the database file, remove any secondary species that have extrapolated equilibrium constants.

This is called in the constructor if the remove_all_extrapolated_secondary_species flag is true

Definition at line 94 of file GeochemicalDatabaseReader.C.

Referenced by GeochemicalDatabaseReader().

95 {
96  if (_root.contains("secondary species"))
97  {
98  std::set<std::string> remove; // items to remove
99  for (const auto & item : _root["secondary species"].items())
100  if (item.value().contains("note"))
101  remove.insert(item.key());
102 
103  for (const auto & name : remove)
104  _root["secondary species"].erase(name);
105  }
106 }
nlohmann::json _root
JSON data.
const std::string name
Definition: Setup.h:20

◆ secondarySpeciesNames()

std::vector< std::string > GeochemicalDatabaseReader::secondarySpeciesNames ( ) const

Returns a list of all the names of the "secondary species" and "free electron" in the database.

Definition at line 706 of file GeochemicalDatabaseReader.C.

Referenced by PertinentGeochemicalSystem::buildRedoxeInfo(), PertinentGeochemicalSystem::buildSecondarySpecies(), PertinentGeochemicalSystem::checkRedoxe(), and TEST().

707 {
708  std::vector<std::string> names;
709  if (_root.contains("secondary species"))
710  for (auto & item : _root["secondary species"].items())
711  names.push_back(item.key());
712 
713  if (_root.contains("free electron"))
714  for (const auto & nm : _root["free electron"].items())
715  names.push_back(nm.key());
716  return names;
717 }
nlohmann::json _root
JSON data.

◆ setDebyeHuckel()

void GeochemicalDatabaseReader::setDebyeHuckel ( )
protected

Copy the Debye-Huckel parameters (if any) found in the database into _debye_huckel.

This method is called in the constructor

Definition at line 160 of file GeochemicalDatabaseReader.C.

Referenced by GeochemicalDatabaseReader().

161 {
162  if (getActivityModel() == "debye-huckel")
163  {
164  if (_root["Header"].contains("adh"))
165  {
166  std::vector<Real> adhvals(_root["Header"]["adh"].size());
167  for (unsigned int i = 0; i < _root["Header"]["adh"].size(); ++i)
168  adhvals[i] = getReal(_root["Header"]["adh"][i]);
169  _debye_huckel.adh = adhvals;
170  }
171 
172  if (_root["Header"].contains("bdh"))
173  {
174  std::vector<Real> bdhvals(_root["Header"]["bdh"].size());
175  for (unsigned int i = 0; i < _root["Header"]["bdh"].size(); ++i)
176  bdhvals[i] = getReal(_root["Header"]["bdh"][i]);
177  _debye_huckel.bdh = bdhvals;
178  }
179 
180  if (_root["Header"].contains("bdot"))
181  {
182  std::vector<Real> bdotvals(_root["Header"]["bdot"].size());
183  for (unsigned int i = 0; i < _root["Header"]["bdot"].size(); ++i)
184  bdotvals[i] = getReal(_root["Header"]["bdot"][i]);
185  _debye_huckel.bdot = bdotvals;
186  }
187  }
188 }
std::string getActivityModel() const
Get the activity model type.
nlohmann::json _root
JSON data.
GeochemistryDebyeHuckel _debye_huckel
Debye-Huckel activity coefficients.
static Real getReal(const nlohmann::json &node)

◆ setNeutralSpeciesActivity()

void GeochemicalDatabaseReader::setNeutralSpeciesActivity ( )
protected

Copy the Debye-Huckel parameters for computing neutral species activity (if any) found in the database into _neutral_species_activity.

This method is called in the constructor

Definition at line 472 of file GeochemicalDatabaseReader.C.

Referenced by GeochemicalDatabaseReader().

473 {
474  if (_root["Header"].contains("neutral species"))
475  {
476  auto neutral_species = _root["Header"]["neutral species"];
477  for (auto & ns : neutral_species.items())
478  {
479  std::vector<std::vector<Real>> coeffs;
480 
481  for (auto & nsac : ns.value().items())
482  {
483  if (nsac.key() == "note")
484  continue;
485  std::vector<Real> coeffvec(nsac.value().size());
486 
487  for (unsigned int i = 0; i < coeffvec.size(); ++i)
488  coeffvec[i] = getReal(nsac.value()[i]);
489 
490  coeffs.push_back(coeffvec);
491  }
492 
493  // GeochemistryNeutralSpeciesActivity expects four vectos, so
494  // add empty vectors if coeffs.size() != 4
495  coeffs.resize(4, {});
496 
498 
499  _neutral_species_activity[ns.key()] = nsa;
500  }
501  }
502 }
nlohmann::json _root
JSON data.
std::map< std::string, GeochemistryNeutralSpeciesActivity > _neutral_species_activity
Neutral species activity coefficients.
Data structure for neutral species activity coefficients.
static Real getReal(const nlohmann::json &node)

◆ setTemperatures()

void GeochemicalDatabaseReader::setTemperatures ( )
protected

Copy the temperature points (if any) found in the database into _temperature_points.

This method is called in the constructor

Definition at line 127 of file GeochemicalDatabaseReader.C.

Referenced by GeochemicalDatabaseReader().

128 {
129  if (_root["Header"].contains("temperatures"))
130  {
131  auto temperatures = _root["Header"]["temperatures"];
132  _temperature_points.resize(temperatures.size());
133  for (unsigned int i = 0; i < temperatures.size(); ++i)
134  _temperature_points[i] = getReal(temperatures[i]);
135  }
136 }
nlohmann::json _root
JSON data.
static Real getReal(const nlohmann::json &node)
std::vector< Real > _temperature_points
Temperature points in database.

◆ surfaceSpeciesNames()

std::vector< std::string > GeochemicalDatabaseReader::surfaceSpeciesNames ( ) const

Returns a list of all the names of the "surface species" in the database.

Definition at line 730 of file GeochemicalDatabaseReader.C.

Referenced by PertinentGeochemicalSystem::buildSecondarySpecies(), and TEST().

731 {
732  std::vector<std::string> names;
733  if (_root.contains("surface species"))
734  for (const auto & item : _root["surface species"].items())
735  names.push_back(item.key());
736  return names;
737 }
nlohmann::json _root
JSON data.

◆ validate()

void GeochemicalDatabaseReader::validate ( const FileName  filename,
const nlohmann::json &  db 
)

Validate the thermodynamic database.

Parameters
filenameName of thermodynamic database file
dbJSON database read from filename

Definition at line 53 of file GeochemicalDatabaseReader.C.

Referenced by GeochemicalDatabaseReader(), TEST(), and testExceptionMessage().

54 {
55  // Validate the JSON database so that we don't have to check array sizes,
56  // check for conversion issues, etc when extracting data using get methods
58  dbv.validate();
59 }
const FileName & filename() const
Filename of database.
const GeochemicalDatabaseReader db("database/moose_testdb.json", true, true, false)
Class for validating MOOSE geochemical database.

Member Data Documentation

◆ _basis_species

std::map<std::string, GeochemistryBasisSpecies> GeochemicalDatabaseReader::_basis_species
protected

Basis species data read from the database.

Definition at line 498 of file GeochemicalDatabaseReader.h.

Referenced by getBasisSpecies().

◆ _bs_names

std::vector<std::string> GeochemicalDatabaseReader::_bs_names
protected

List of basis (primary) species names read from database.

Definition at line 486 of file GeochemicalDatabaseReader.h.

Referenced by getBasisSpeciesNames().

◆ _debye_huckel

GeochemistryDebyeHuckel GeochemicalDatabaseReader::_debye_huckel
protected

Debye-Huckel activity coefficients.

Definition at line 512 of file GeochemicalDatabaseReader.h.

Referenced by getDebyeHuckel(), and setDebyeHuckel().

◆ _elements

std::map<std::string, GeochemistryElements> GeochemicalDatabaseReader::_elements
protected

Elements and their molecular weight read from the database.

Definition at line 496 of file GeochemicalDatabaseReader.h.

Referenced by getElements().

◆ _equilibrium_species

std::map<std::string, GeochemistryEquilibriumSpecies> GeochemicalDatabaseReader::_equilibrium_species
protected

Secondary equilibrium species and free electron data read from the database.

Definition at line 500 of file GeochemicalDatabaseReader.h.

Referenced by getEquilibriumSpecies().

◆ _es_names

std::vector<std::string> GeochemicalDatabaseReader::_es_names
protected

List of secondary equilibrium species to read from database.

Definition at line 488 of file GeochemicalDatabaseReader.h.

Referenced by getEquilibriumSpeciesNames().

◆ _filename

const FileName GeochemicalDatabaseReader::_filename
protected

◆ _gas_species

std::map<std::string, GeochemistryGasSpecies> GeochemicalDatabaseReader::_gas_species
protected

Gas species data read from the database.

Definition at line 504 of file GeochemicalDatabaseReader.h.

Referenced by getGasSpecies().

◆ _mineral_species

std::map<std::string, GeochemistryMineralSpecies> GeochemicalDatabaseReader::_mineral_species
protected

Mineral species data read from the database.

Definition at line 502 of file GeochemicalDatabaseReader.h.

Referenced by getMineralSpecies().

◆ _ms_names

std::vector<std::string> GeochemicalDatabaseReader::_ms_names
protected

List of secondary mineral species to read from database.

Definition at line 490 of file GeochemicalDatabaseReader.h.

Referenced by getMineralSpeciesNames().

◆ _neutral_species_activity

std::map<std::string, GeochemistryNeutralSpeciesActivity> GeochemicalDatabaseReader::_neutral_species_activity
protected

Neutral species activity coefficients.

Definition at line 514 of file GeochemicalDatabaseReader.h.

Referenced by getNeutralSpeciesActivity(), and setNeutralSpeciesActivity().

◆ _oxide_species

std::map<std::string, GeochemistryOxideSpecies> GeochemicalDatabaseReader::_oxide_species
protected

Oxide species data read from the database.

Definition at line 508 of file GeochemicalDatabaseReader.h.

Referenced by getOxideSpecies().

◆ _pressure_points

std::vector<Real> GeochemicalDatabaseReader::_pressure_points
protected

Pressure points in database.

Definition at line 494 of file GeochemicalDatabaseReader.h.

Referenced by getPressures().

◆ _redox_species

std::map<std::string, GeochemistryRedoxSpecies> GeochemicalDatabaseReader::_redox_species
protected

Redox species (couples) data read from the database.

Definition at line 506 of file GeochemicalDatabaseReader.h.

Referenced by getRedoxSpecies().

◆ _root

nlohmann::json GeochemicalDatabaseReader::_root
protected

◆ _surface_species

std::map<std::string, GeochemistrySurfaceSpecies> GeochemicalDatabaseReader::_surface_species
protected

Surface sorbing species data read from the database.

Definition at line 510 of file GeochemicalDatabaseReader.h.

Referenced by getSurfaceSpecies().

◆ _temperature_points

std::vector<Real> GeochemicalDatabaseReader::_temperature_points
protected

Temperature points in database.

Definition at line 492 of file GeochemicalDatabaseReader.h.

Referenced by getTemperatures(), and setTemperatures().


The documentation for this class was generated from the following files: