Line data Source code
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 : 15 : /** 16 : * Class for validating MOOSE geochemical database 17 : */ 18 12 : class GeochemicalDatabaseValidator 19 : { 20 : public: 21 : GeochemicalDatabaseValidator(const FileName filename, const nlohmann::json & db); 22 : 23 : /** 24 : * Validate the thermodynamic database 25 : */ 26 : void validate(); 27 : 28 : protected: 29 : /** 30 : * Check Json::Value can be converted to a Real 31 : * @param array array of values 32 : * @return true/false if the value can/cannot be converted to a Real 33 : */ 34 : bool isValueReal(const nlohmann::json & value) const; 35 : 36 : /** 37 : * Check Json::Value array is comprised of Reals 38 : * @param array array of values 39 : * @param field database field name 40 : */ 41 : void checkArrayValues(const nlohmann::json & array, const std::string field) const; 42 : 43 : /** 44 : * Check array array values can be converted to Real 45 : * @param type species type (basis, secondary, etc) 46 : * @param species species name 47 : * @param field name of array values to check 48 : */ 49 : void checkArrayValues(const std::string type, 50 : const std::string species, 51 : const std::string field) const; 52 : 53 : /** 54 : * Check Json::Value array is the correct size 55 : * @param array array of values 56 : * @param field database field name 57 : */ 58 : void checkArraySize(const nlohmann::json & array, const std::string field) const; 59 : 60 : /** 61 : * Check array is the correct size 62 : * @param type species type (basis, secondary, etc) 63 : * @param species species name 64 : * @param field name of array values to check 65 : */ 66 : void 67 : checkArraySize(const std::string type, const std::string species, const std::string field) const; 68 : 69 : /** 70 : * Check fields are present in the Header section 71 : * @param field name of field to check 72 : */ 73 : void checkHeaderField(const std::string field) const; 74 : 75 : /** 76 : * Check arrays in field can be converted to Reals 77 : * @param field name of field to check 78 : */ 79 : void checkHeaderArray(const std::string field) const; 80 : 81 : /** 82 : * Check elements in the database 83 : * Each elemenent should have a real number as their molecular weights 84 : * @param element element name 85 : */ 86 : void checkElements(const std::string element) const; 87 : 88 : /** 89 : * Check basis species in the database 90 : * Each basis species should have a real number as their molecular weights, charge, radius 91 : * and weight for each element 92 : * @param species basis species name 93 : */ 94 : void checkBasisSpecies(const std::string species) const; 95 : 96 : /** 97 : * Check secondary species in the database 98 : * Each secondary species should have a real number as their molecular weights, charge, radius, 99 : * equilibrium constants and weight for each basis species 100 : * @param species secondary species name 101 : */ 102 : void checkSecondarySpecies(const std::string species) const; 103 : 104 : /** 105 : * Check mineral species in the database 106 : * Each mineral species should have a real number as their molecular weights, volume, 107 : * equilibrium constants and weight for each basis species 108 : * @param species mineral species name 109 : */ 110 : void checkMineralSpecies(const std::string species) const; 111 : 112 : /** 113 : * Check sorbing mineral species in the database 114 : * Each sorbing mineral species should have a real number as their surface area, 115 : * equilibrium constants and weight for each sorbing site 116 : * @param species sorbing mineral species name 117 : */ 118 : void checkSorbingMineralSpecies(const std::string species) const; 119 : 120 : /** 121 : * Check gas species in the database 122 : * Each gas species should have a real number as their molecular weights, 123 : * equilibrium constants, weight for each basis species, and fugacity values 124 : * @param species gas species name 125 : */ 126 : void checkGasSpecies(const std::string species) const; 127 : 128 : /** 129 : * Check redox couple species in the database 130 : * Each redox couple species should have a real number as their molecular weights, charge, radius, 131 : * equilibrium constants and weight for each basis species 132 : * @param species redox couple species name 133 : */ 134 : void checkRedoxSpecies(const std::string species) const; 135 : 136 : /** 137 : * Check oxide species in the database 138 : * Each oxide species should have a real number as their molecular weights 139 : * and weight for each basis species 140 : * @param species oxide species name 141 : */ 142 : void checkOxideSpecies(const std::string species) const; 143 : 144 : /** 145 : * Check surface species in the database 146 : * Each surface species should have a real number as their molecular weights, charge, 147 : * and equilibrium constants 148 : * @param species surface species name 149 : */ 150 : void checkSurfaceSpecies(const std::string species) const; 151 : 152 : /** 153 : * Check given species field value can be converted to a Real 154 : * @param type species type (basis, secondary, etc) 155 : * @param species species name 156 : * @param field value to check 157 : */ 158 : void checkSpeciesValue(const std::string type, 159 : const std::string species, 160 : const std::string field) const; 161 : 162 : /** 163 : * Check given species stoichiometric weigth values can be converted to a Real 164 : * @param type species type (basis, secondary, etc) 165 : * @param species species name 166 : * @param field name of values to check 167 : */ 168 : void checkSpeciesWeightValue(const std::string type, 169 : const std::string species, 170 : const std::string field) const; 171 : 172 : /// Database filename 173 : const FileName _filename; 174 : /// JSON database 175 : const nlohmann::json & _root; 176 : /// Number of temperature points 177 : unsigned int _temperature_size; 178 : };