17 const nlohmann::json &
db)
18 : _filename(filename), _root(
db)
26 if (!
_root.contains(
"Header"))
48 if (
_root[
"Header"][
"activity model"] ==
"debye-huckel")
64 if (
_root[
"Header"].contains(
"neutral species"))
65 for (
auto & ns :
_root[
"Header"][
"neutral species"].items())
66 for (
auto & coeffs : ns.value().items())
68 if (coeffs.key() ==
"note")
72 auto values = coeffs.value();
73 checkArraySize(values,
"Header:neutral species:" + ns.key() +
":" + coeffs.key());
74 checkArrayValues(values,
"Header:neutral species:" + ns.key() +
":" + coeffs.key());
78 for (
auto & el :
_root[
"elements"].items())
82 for (
auto & species :
_root[
"basis species"].items())
86 if (
_root.contains(
"secondary species"))
87 for (
auto & species :
_root[
"secondary species"].items())
91 if (
_root.contains(
"mineral species"))
92 for (
auto & species :
_root[
"mineral species"].items())
96 if (
_root.contains(
"sorbing minerals"))
97 for (
auto & species :
_root[
"sorbing minerals"].items())
101 if (
_root.contains(
"gas species"))
102 for (
auto & species :
_root[
"gas species"].items())
106 if (
_root.contains(
"redox couples"))
107 for (
auto & species :
_root[
"redox couples"].items())
111 if (
_root.contains(
"oxides"))
112 for (
auto & species :
_root[
"oxides"].items())
116 if (
_root.contains(
"surface species"))
117 for (
auto & species :
_root[
"surface species"].items())
124 if (
value.is_number())
128 MooseUtils::convert<Real>(
value,
true);
130 catch (
const std::invalid_argument &
err)
140 const std::string field)
const 143 for (
auto & item : array.items())
146 nlohmann::to_string(item.value()),
151 " cannot be converted to Real");
156 const std::string species,
157 const std::string field)
const 160 for (
auto & item :
_root[type][species][field].items())
163 nlohmann::to_string(item.value()),
172 " cannot be converted to Real");
177 const std::string field)
const 184 " is not equal to the number of temperature values");
189 const std::string species,
190 const std::string field)
const 201 " is not equal to the number of temperature values");
207 if (!
_root[
"Header"].contains(field))
209 "The MOOSE database ",
_filename,
" does not have a required \"Header:", field,
"\" field");
222 const std::string species,
223 const std::string field)
const 225 if (!
_root[type].contains(species) || !
_root[type][species].contains(field))
232 nlohmann::to_string(
_root[type][species][field]),
239 " cannot be converted to Real");
244 const std::string species,
245 const std::string field)
const 247 if (!
_root[type].contains(species) || !
_root[type][species].contains(field))
251 for (
auto & item :
_root[type][species][field].items())
254 nlohmann::to_string(item.value()),
263 " cannot be converted to Real");
350 if (
_root[
"gas species"][species].contains(
"chi"))
353 if (
_root[
"gas species"][species].contains(
"Pcrit"))
356 if (
_root[
"gas species"][species].contains(
"Tcrit"))
359 if (
_root[
"gas species"][species].contains(
"omega"))
void checkHeaderArray(const std::string field) const
Check arrays in field can be converted to Reals.
void validate()
Validate the thermodynamic database.
void mooseError(Args &&... args)
GeochemicalDatabaseValidator(const FileName filename, const nlohmann::json &db)
void checkMineralSpecies(const std::string species) const
Check mineral species in the database Each mineral species should have a real number as their molecul...
void checkOxideSpecies(const std::string species) const
Check oxide species in the database Each oxide species should have a real number as their molecular w...
void checkElements(const std::string element) const
Check elements in the database Each elemenent should have a real number as their molecular weights...
const GeochemicalDatabaseReader db("database/moose_testdb.json", true, true, false)
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
void checkSecondarySpecies(const std::string species) const
Check secondary species in the database Each secondary species should have a real number as their mol...
unsigned int _temperature_size
Number of temperature points.
void checkSpeciesWeightValue(const std::string type, const std::string species, const std::string field) const
Check given species stoichiometric weigth values can be converted to a Real.
const FileName _filename
Database filename.
void checkSorbingMineralSpecies(const std::string species) const
Check sorbing mineral species in the database Each sorbing mineral species should have a real number ...
void checkSpeciesValue(const std::string type, const std::string species, const std::string field) const
Check given species field value can be converted to a Real.
bool isValueReal(const nlohmann::json &value) const
Check Json::Value can be converted to a Real.
const nlohmann::json & _root
JSON database.
void checkArrayValues(const nlohmann::json &array, const std::string field) const
Check Json::Value array is comprised of Reals.
void checkSurfaceSpecies(const std::string species) const
Check surface species in the database Each surface species should have a real number as their molecul...
void checkGasSpecies(const std::string species) const
Check gas species in the database Each gas species should have a real number as their molecular weigh...
void checkBasisSpecies(const std::string species) const
Check basis species in the database Each basis species should have a real number as their molecular w...
void checkArraySize(const nlohmann::json &array, const std::string field) const
Check Json::Value array is the correct size.
void checkHeaderField(const std::string field) const
Check fields are present in the Header section.
void checkRedoxSpecies(const std::string species) const
Check redox couple species in the database Each redox couple species should have a real number as the...