Test the swap works on kinetic species.
856 {
"H2O",
"H+",
">(s)FeOH",
">(w)FeOH",
"Fe++",
"HCO3-",
"O2(aq)"},
859 {
"Fe(OH)3(ppd)",
"Fe(OH)3(ppd)fake"},
871 {
"H+",
"O2(aq)",
"CO3--"},
892 {
"O2(aq)",
"Fe+++",
"H2O"},
913 {
"CO2(aq)",
"Fe+++",
"Fe++"},
951 if (species.first ==
"Fe(OH)3(ppd)" || species.first ==
"Fe(OH)3(ppd)fake")
959 if (species.first ==
"CH4(g)fake")
965 if (species.first ==
">(s)FeOH" || species.first ==
">(w)FeOH")
972 if (species.first ==
"Fe(OH)3(ppd)" || species.first ==
"Fe(OH)3(ppd)fake" ||
973 species.first ==
">(s)FeO-")
979 for (
const auto & sp : {
"CO2(aq)",
"CO3--",
"OH-",
"CH4(aq)",
"Fe+++",
"CH4(g)fake"})
983 for (
const auto & sp : {
"Fe(OH)3(ppd)",
"Fe(OH)3(ppd)fake",
"(O-phth)--",
">(s)FeO-"})
986 std::map<std::string, Real> charge_gold;
987 charge_gold[
"H2O"] = 0.0;
988 charge_gold[
"H+"] = 1.0;
989 charge_gold[
">(s)FeOH"] = 0.0;
990 charge_gold[
">(w)FeOH"] = 0.0;
991 charge_gold[
"Fe++"] = 2.0;
992 charge_gold[
"HCO3-"] = -1.0;
993 charge_gold[
"O2(aq)"] = 0.0;
994 charge_gold[
"CO2(aq)"] = 0.0;
995 charge_gold[
"CO3--"] = -2.0;
996 charge_gold[
"OH-"] = -1.0;
997 charge_gold[
"CH4(aq)"] = 0.0;
998 charge_gold[
"Fe+++"] = 3.0;
999 charge_gold[
"CH4(g)fake"] = 0.0;
1000 charge_gold[
"Fe(OH)3(ppd)"] = 0.0;
1001 charge_gold[
"Fe(OH)3(ppd)fake"] = 0.0;
1002 charge_gold[
"(O-phth)--"] = -2.0;
1003 charge_gold[
">(s)FeO-"] = -1.0;
1011 std::map<std::string, Real> radius_gold;
1012 radius_gold[
"H2O"] = 0.0;
1013 radius_gold[
"H+"] = 9.0;
1014 radius_gold[
">(s)FeOH"] = 0.0;
1015 radius_gold[
">(w)FeOH"] = 0.0;
1016 radius_gold[
"Fe++"] = 6.0;
1017 radius_gold[
"HCO3-"] = 4.5;
1018 radius_gold[
"O2(aq)"] = -0.5;
1019 radius_gold[
"CO2(aq)"] = 4.0;
1020 radius_gold[
"CO3--"] = 4.5;
1021 radius_gold[
"OH-"] = 3.5;
1022 radius_gold[
"CH4(aq)"] = -0.5;
1023 radius_gold[
"Fe+++"] = 9.0;
1024 radius_gold[
"CH4(g)fake"] = 0.0;
1030 std::map<std::string, Real> molecular_weight_gold;
1031 molecular_weight_gold[
"H2O"] = 18.0152;
1032 molecular_weight_gold[
"H+"] = 1.0079;
1033 molecular_weight_gold[
">(s)FeOH"] = 72.8543;
1034 molecular_weight_gold[
">(w)FeOH"] = 1234.567;
1035 molecular_weight_gold[
"Fe++"] = 55.8470;
1036 molecular_weight_gold[
"HCO3-"] = 61.0171;
1037 molecular_weight_gold[
"O2(aq)"] = 31.9988;
1038 molecular_weight_gold[
"CO2(aq)"] = 44.0098;
1039 molecular_weight_gold[
"CO3--"] = 60.0092;
1040 molecular_weight_gold[
"OH-"] = 17.0073;
1041 molecular_weight_gold[
"CH4(aq)"] = 16.0426;
1042 molecular_weight_gold[
"Fe+++"] = 55.8470;
1043 molecular_weight_gold[
"CH4(g)fake"] = 16.0426;
1044 molecular_weight_gold[
"Fe(OH)3(ppd)"] = 106.8689;
1045 molecular_weight_gold[
"Fe(OH)3(ppd)fake"] = 106.8689;
1046 molecular_weight_gold[
"(O-phth)--"] = 164.1172;
1047 molecular_weight_gold[
">(s)FeO-"] = 71.8464;
1055 std::map<std::string, Real> molecular_volume_gold;
1056 molecular_volume_gold[
"H2O"] = 0.0;
1057 molecular_volume_gold[
"H+"] = 0.0;
1058 molecular_volume_gold[
">(s)FeOH"] = 0.0;
1059 molecular_volume_gold[
">(w)FeOH"] = 0.0;
1060 molecular_volume_gold[
"Fe++"] = 0.0;
1061 molecular_volume_gold[
"HCO3-"] = 0.0;
1062 molecular_volume_gold[
"O2(aq)"] = 0.0;
1063 molecular_volume_gold[
"CO2(aq)"] = 0.0;
1064 molecular_volume_gold[
"CO3--"] = 0.0;
1065 molecular_volume_gold[
"OH-"] = 0.0;
1066 molecular_volume_gold[
"CH4(aq)"] = 0.0;
1067 molecular_volume_gold[
"Fe+++"] = 0.0;
1068 molecular_volume_gold[
"CH4(g)fake"] = 0.0;
1069 molecular_volume_gold[
"Fe(OH)3(ppd)"] = 34.3200;
1070 molecular_volume_gold[
"Fe(OH)3(ppd)fake"] = 34.3200;
1071 molecular_volume_gold[
"(O-phth)--"] = 0.0;
1072 molecular_volume_gold[
">(s)FeO-"] = 0.0;
1080 std::map<std::string, DenseMatrix<Real>> stoi_gold;
1081 for (
const auto & sp : {
"CO2(aq)",
1094 stoi_gold[
"CO2(aq)"](0, 0) = -1;
1095 stoi_gold[
"CO2(aq)"](0, 1) = 1;
1096 stoi_gold[
"CO2(aq)"](0, 5) = 1;
1097 stoi_gold[
"CO3--"](0, 5) = 1;
1098 stoi_gold[
"CO3--"](0, 1) = -1;
1099 stoi_gold[
"OH-"](0, 0) = 1;
1100 stoi_gold[
"OH-"](0, 1) = -1;
1101 stoi_gold[
"CH4(aq)"](0, 0) = 1;
1102 stoi_gold[
"CH4(aq)"](0, 1) = 1;
1103 stoi_gold[
"CH4(aq)"](0, 5) = 1;
1104 stoi_gold[
"CH4(aq)"](0, 6) = -2;
1105 stoi_gold[
"Fe+++"](0, 0) = -0.5;
1106 stoi_gold[
"Fe+++"](0, 4) = 1;
1107 stoi_gold[
"Fe+++"](0, 1) = 1;
1108 stoi_gold[
"Fe+++"](0, 6) = 0.25;
1109 stoi_gold[
"CH4(g)fake"](0, 0) = 3;
1110 stoi_gold[
"CH4(g)fake"](0, 4) = -2;
1111 stoi_gold[
"CH4(g)fake"](0, 5) = 3.5;
1112 stoi_gold[
"CH4(g)fake"](0, 6) = -4.5;
1113 stoi_gold[
"Fe(OH)3(ppd)"](0, 1) = -2;
1114 stoi_gold[
"Fe(OH)3(ppd)"](0, 4) = 1;
1115 stoi_gold[
"Fe(OH)3(ppd)"](0, 0) = 2.5;
1116 stoi_gold[
"Fe(OH)3(ppd)"](0, 6) = 0.25;
1117 stoi_gold[
"Fe(OH)3(ppd)fake"](0, 1) = -1;
1118 stoi_gold[
"Fe(OH)3(ppd)fake"](0, 0) = 2;
1119 stoi_gold[
"Fe(OH)3(ppd)fake"](0, 4) = 2;
1120 stoi_gold[
"Fe(OH)3(ppd)fake"](0, 6) = 0.5;
1121 stoi_gold[
"(O-phth)--"](0, 0) = -5;
1122 stoi_gold[
"(O-phth)--"](0, 5) = 8;
1123 stoi_gold[
"(O-phth)--"](0, 1) = 6;
1124 stoi_gold[
"(O-phth)--"](0, 6) = -7.5;
1125 stoi_gold[
">(s)FeO-"](0, 2) = 1;
1126 stoi_gold[
">(s)FeO-"](0, 1) = -1;
1128 for (
const auto & sp : {
"CO2(aq)",
"CO3--",
"OH-",
"CH4(aq)",
"Fe+++",
"CH4(g)fake"})
1134 for (
const auto & sp : {
"Fe(OH)3(ppd)",
"Fe(OH)3(ppd)fake",
"(O-phth)--",
">(s)FeO-"})
1140 const std::vector<Real> feoh3ppd = {
1141 6.1946, 4.8890, 3.4608, 2.2392, 1.1150, 0.2446, -0.5504, -1.5398};
1142 const std::vector<Real> fe3 = {10.0553, 8.4878, 6.6954, 5.0568, 3.4154, 2.0747, 0.8908, -0.2679};
1143 const std::vector<Real> ophth = {
1144 594.3211, 542.8292, 482.3612, 425.9738, 368.7004, 321.8658, 281.8216, 246.4849};
1145 const std::vector<Real> feom = {8.93,
1154 for (
unsigned t = 0; t < 8; ++t)
1159 feoh3ppd[t] - 2 * fe3[t],
1166 std::vector<std::vector<Real>> kin_rate_gold(3, std::vector<Real>(7 + 6, 0.0));
1167 std::vector<std::vector<Real>> kin_monod_gold(3, std::vector<Real>(7 + 6, 0.0));
1168 std::vector<std::vector<Real>> kin_k_gold(3, std::vector<Real>(7 + 6, 0.0));
1196 for (
unsigned i = 0; i < 3; ++i)
1197 for (
unsigned j = 0;
j < 7 + 6; ++
j)
1199 EXPECT_EQ(
mgd.
kin_rate[i].promoting_indices[
j], kin_rate_gold[i][
j]);
1200 EXPECT_EQ(
mgd.
kin_rate[i].promoting_monod_indices[
j], kin_monod_gold[i][
j]);
1201 EXPECT_EQ(
mgd.
kin_rate[i].promoting_half_saturation[
j], kin_k_gold[i][
j]);
1211 swapper.performSwap(
mgd,
"O2(aq)",
"Fe+++");
1215 for (
const auto & sp : {
"H2O",
"H+",
">(s)FeOH",
">(w)FeOH",
"Fe++",
"HCO3-",
"Fe+++"})
1223 for (
const auto & sp : {
"CO2(aq)",
"CO3--",
"OH-",
"CH4(aq)",
"O2(aq)",
"CH4(g)fake"})
1232 for (
const auto & sp : {
"Fe(OH)3(ppd)",
"Fe(OH)3(ppd)fake",
"(O-phth)--",
">(s)FeO-"})
1278 if (species.first ==
"Fe(OH)3(ppd)" || species.first ==
"Fe(OH)3(ppd)fake")
1287 if (species.first ==
"CH4(g)fake")
1294 if (species.first ==
">(s)FeOH" || species.first ==
">(w)FeOH")
1301 if (species.first ==
"Fe(OH)3(ppd)" || species.first ==
"Fe(OH)3(ppd)fake" ||
1302 species.first ==
">(s)FeO-")
1308 for (
const auto & sp : {
"CO2(aq)",
1321 stoi_gold[
"CO2(aq)"](0, 0) = -1;
1322 stoi_gold[
"CO2(aq)"](0, 1) = 1;
1323 stoi_gold[
"CO2(aq)"](0, 5) = 1;
1324 stoi_gold[
"CO3--"](0, 5) = 1;
1325 stoi_gold[
"CO3--"](0, 1) = -1;
1326 stoi_gold[
"OH-"](0, 0) = 1;
1327 stoi_gold[
"OH-"](0, 1) = -1;
1328 stoi_gold[
"CH4(aq)"](0, 0) = -3;
1329 stoi_gold[
"CH4(aq)"](0, 1) = 9;
1330 stoi_gold[
"CH4(aq)"](0, 4) = 8;
1331 stoi_gold[
"CH4(aq)"](0, 5) = 1;
1332 stoi_gold[
"CH4(aq)"](0, 6) = -8;
1333 stoi_gold[
"O2(aq)"](0, 0) = 2;
1334 stoi_gold[
"O2(aq)"](0, 1) = -4;
1335 stoi_gold[
"O2(aq)"](0, 4) = -4;
1336 stoi_gold[
"O2(aq)"](0, 6) = 4;
1337 stoi_gold[
"CH4(g)fake"](0, 0) = -6;
1338 stoi_gold[
"CH4(g)fake"](0, 1) = 18;
1339 stoi_gold[
"CH4(g)fake"](0, 4) = 16;
1340 stoi_gold[
"CH4(g)fake"](0, 5) = 3.5;
1341 stoi_gold[
"CH4(g)fake"](0, 6) = -18;
1342 stoi_gold[
"Fe(OH)3(ppd)"](0, 0) = 3;
1343 stoi_gold[
"Fe(OH)3(ppd)"](0, 1) = -3;
1344 stoi_gold[
"Fe(OH)3(ppd)"](0, 6) = 1;
1345 stoi_gold[
"Fe(OH)3(ppd)fake"](0, 0) = 3;
1346 stoi_gold[
"Fe(OH)3(ppd)fake"](0, 1) = -3;
1347 stoi_gold[
"Fe(OH)3(ppd)fake"](0, 6) = 2;
1348 stoi_gold[
"(O-phth)--"](0, 0) = -5 - 7.5 * 2;
1349 stoi_gold[
"(O-phth)--"](0, 1) = 6 + 7.5 * 4;
1350 stoi_gold[
"(O-phth)--"](0, 4) = 7.5 * 4;
1351 stoi_gold[
"(O-phth)--"](0, 5) = 8;
1352 stoi_gold[
"(O-phth)--"](0, 6) = -7.5 * 4;
1353 stoi_gold[
">(s)FeO-"](0, 2) = 1;
1354 stoi_gold[
">(s)FeO-"](0, 1) = -1;
1356 for (
const auto & sp : {
"CO2(aq)",
"CO3--",
"OH-",
"CH4(aq)",
"O2(aq)",
"CH4(g)fake"})
1359 for (
unsigned i = 0; i < 7; ++i)
1363 for (
const auto & sp : {
"Fe(OH)3(ppd)",
"Fe(OH)3(ppd)fake",
"(O-phth)--",
">(s)FeO-"})
1366 for (
unsigned i = 0; i < 7; ++i)
1370 for (
unsigned t = 0; t < 8; ++t)
1375 ophth[t] - (7.5 / 0.25) * fe3[t],
1381 std::vector<std::vector<Real>> new_kin_rate_gold(3, std::vector<Real>(7 + 6, 0.0));
1382 std::vector<std::vector<Real>> new_kin_monod_gold(3, std::vector<Real>(7 + 6, 0.0));
1383 std::vector<std::vector<Real>> new_kin_k_gold(3, std::vector<Real>(7 + 6, 0.0));
1411 for (
unsigned i = 0; i < 3; ++i)
1412 for (
unsigned j = 0;
j < 7 + 6; ++
j)
1414 EXPECT_EQ(
mgd.
kin_rate[i].promoting_indices[
j], new_kin_rate_gold[i][
j]);
1415 EXPECT_EQ(
mgd.
kin_rate[i].promoting_monod_indices[
j], new_kin_monod_gold[i][
j]);
1416 EXPECT_EQ(
mgd.
kin_rate[i].promoting_half_saturation[
j], new_kin_k_gold[i][
j]);
1420 EXPECT_EQ(
mgd.
kin_rate[0].progeny_index, 7 + fe3_posn);
1422 EXPECT_EQ(
mgd.
kin_rate[2].progeny_index, o2aq_posn);
std::vector< Real > eqm_species_molecular_weight
all quantities have a molecular weight (g)
std::vector< bool > kin_species_mineral
kin_species_mineral[j] = true iff the j^th kinetic species is a mineral
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< Real > kin_species_charge
all kinetic quantities have a charge (mineral charge = 0)
std::vector< bool > eqm_species_gas
eqm_species_gas[i] = true iff the i^th equilibrium species is a gas
std::unordered_map< std::string, unsigned > basis_species_index
basis_species_index[name] = index of the basis species, within all ModelGeochemicalDatabase internal ...
const ModelGeochemicalDatabase mgd
DenseMatrix< Real > kin_stoichiometry
kin_stoichiometry(i, j) = stoichiometric coefficient for kinetic species "i" in terms of the basis sp...
std::vector< Real > kin_species_molecular_weight
all quantities have a molecular weight (g/mol)
std::vector< Real > kin_species_molecular_volume
all quantities have a molecular volume (cm^3/mol) (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, redox couples in equilibrium with the aqueous solution, minerals in equilibrium with the aqueous solution, gases in equilibrium with the aqueous solution) within all ModelGeochemicalDatabase internal datastrcutres, with given name
DenseMatrix< Real > swap_to_original_basis
Swap matrix that allows expression in terms of the original basis.
const GeochemicalDatabaseReader database("database/moose_testdb.json", true, true, false)
std::unordered_map< std::string, unsigned > kin_species_index
kin_species_index[name] = index of the kinetic species, within all ModelGeochemicalDatabase internal ...
DenseMatrix< Real > eqm_stoichiometry
eqm_stoichiometry(i, j) = stoichiometric coefficient for equilibrium species "i" in terms of the basi...
std::vector< Real > basis_species_radius
all quantities have an ionic radius (Angstrom) for computing activity (mineral radius = 0...
Class to swap basis species with equilibrium species.
const ModelGeochemicalDatabase & modelGeochemicalDatabase() const
Return a reference to the ModelGeochemicalDatabase structure.
void addKineticRate(const KineticRateUserDescription &description)
Adds a rate description for kinetic_species.
Constructs and stores a minimal amount of information that is pertinent to the user-defined geochemic...
DenseMatrix< Real > kin_log10K
kin_log10K(i, j) = log10(equilibrium constant for the i^th kinetic species at the j^th temperature po...
std::vector< bool > kin_species_transported
kin_species_transported[j] = true iff the j^th kinetic species is transported in reactive-transport s...
const PertinentGeochemicalSystem model(database, {"H2O", "H+", "HCO3-", "O2(aq)", "Ca++", ">(s)FeOH", "radius_neg1", "radius_neg1.5"}, {"Calcite"}, {}, {"Calcite_asdf"}, {"CH4(aq)"}, {">(s)FeOCa+"}, "O2(aq)", "e-")
std::vector< Real > eqm_species_radius
all quantities have an ionic radius (Angstrom) for computing activity (mineral radius = 0...
std::vector< Real > basis_species_molecular_weight
all quantities have a molecular weight (g)
std::vector< bool > eqm_species_transported
eqm_species_transported[i] = true iff the i^th eqm species is transported in reactive-transport sims ...
std::vector< Real > eqm_species_molecular_volume
all quantities have a molecular volume (cm^3) (only nonzero for minerals, however) ...
std::vector< Real > basis_species_charge
all quantities have a charge (mineral charge = 0, gas charge = 0, oxide charge = 0) ...
Holds a user-specified description of a kinetic rate.
std::vector< unsigned > have_swapped_into_basis
Species that have been swapped into the basis.
std::vector< bool > basis_species_gas
basis_species_gas[j] = true iff the j^th basis species is a gas
std::vector< bool > basis_species_mineral
basis_species_mineral[j] = true iff the j^th basis species is a mineral
std::vector< Real > eqm_species_charge
all quantities have a charge (mineral charge = 0, gas charge = 0, oxide charge = 0) ...
std::vector< std::string > kin_species_name
kin_species_name[j] = name of the j^th kinetic species
Data structure to hold all relevant information from the database file.
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
std::vector< bool > eqm_species_mineral
eqm_species_mineral[i] = true iff the i^th equilibrium species is a mineral
std::vector< Real > basis_species_molecular_volume
all quantities have a molecular volume (cm^3) (only nonzero for minerals, however) ...
DenseMatrix sub_matrix(unsigned int row_id, unsigned int row_size, unsigned int col_id, unsigned int col_size) const
std::vector< std::string > eqm_species_name
eqm_species_name[i] = name of the i^th eqm species
std::vector< std::string > basis_species_name
basis_species_name[j] = name of the j^th basis species
Class for reading geochemical reactions from a MOOSE geochemical database.
std::vector< unsigned > have_swapped_out_of_basis
Species that have been swapped out of the basis.
std::vector< KineticRateDefinition > kin_rate
rates given to kinetic species.