10 #include "gtest/gtest.h" 23 TEST(PertinentGeochemicalSystemTest, basisExceptions)
30 database, {
"H2O",
"Ca++",
"(O-phth)--",
"H2O",
"Na+"}, {}, {}, {}, {}, {},
"O2(aq)",
"e-");
31 FAIL() <<
"Missing expected exception.";
33 catch (
const std::exception & e)
35 std::string msg(e.what());
36 ASSERT_TRUE(msg.find(
"H2O exists more than once in the basis species list") !=
38 <<
"Failed with unexpected error message: " << msg;
44 {
"Ca++",
"H2O",
"H+",
"(O-phth)--",
"Am++++"},
52 FAIL() <<
"Missing expected exception.";
54 catch (
const std::exception & e)
56 std::string msg(e.what());
57 ASSERT_TRUE(msg.find(
"First member of basis species list must be H2O") != std::string::npos)
58 <<
"Failed with unexpected error message: " << msg;
65 {
"H2O",
"Ca++",
"H+",
"(O-phth)--",
"Am++++",
"does_not_exist"},
73 FAIL() <<
"Missing expected exception.";
75 catch (
const std::exception & e)
77 std::string msg(e.what());
78 ASSERT_TRUE(msg.find(
"does_not_exist does not exist in the basis species or redox species in " 79 "database/moose_testdb.json") != std::string::npos)
80 <<
"Failed with unexpected error message: " << msg;
93 TEST(PertinentGeochemicalSystemTest, mineralExceptions)
100 {
"H2O",
"Ca++",
"H+",
"(O-phth)--",
"HCO3-"},
101 {
"Calcite",
"Calcite_asdf",
"Calcite"},
108 FAIL() <<
"Missing expected exception.";
110 catch (
const std::exception & e)
112 std::string msg(e.what());
113 ASSERT_TRUE(msg.find(
"Calcite exists more than once in the minerals list") != std::string::npos)
114 <<
"Failed with unexpected error message: " << msg;
120 {
"H2O",
"Ca++",
"H+",
"Am++++",
"HCO3-"},
121 {
"Calcite",
"Calcite_asdf",
"does_not_exist"},
128 FAIL() <<
"Missing expected exception.";
130 catch (
const std::exception & e)
132 std::string msg(e.what());
133 ASSERT_TRUE(msg.find(
"does_not_exist does not exist in database database/moose_testdb.json") !=
135 <<
"Failed with unexpected error message: " << msg;
141 {
"H2O",
"H+",
"(O-phth)--",
"HCO3-"},
149 FAIL() <<
"Missing expected exception.";
151 catch (
const std::exception & e)
153 std::string msg(e.what());
154 ASSERT_TRUE(msg.find(
"The reaction for Calcite depends on Ca++ which is not reducable to a set " 155 "of basis species") != std::string::npos)
156 <<
"Failed with unexpected error message: " << msg;
162 database, {
"H2O",
"H+",
"O2(aq)"}, {
"Fe(OH)3(ppd)"}, {}, {}, {}, {},
"O2(aq)",
"e-");
163 FAIL() <<
"Missing expected exception.";
165 catch (
const std::exception & e)
167 std::string msg(e.what());
168 ASSERT_TRUE(msg.find(
"The reaction for Fe(OH)3(ppd) depends on Fe+++ which is not reducable to " 169 "a set of basis species") != std::string::npos)
170 <<
"Failed with unexpected error message: " << msg;
176 {
"H2O",
"H+",
"O2(aq)",
"Fe++",
">(s)FeOH"},
184 FAIL() <<
"Missing expected exception.";
186 catch (
const std::exception & e)
188 std::string msg(e.what());
189 ASSERT_TRUE(msg.find(
"The sorbing sites for Fe(OH)3(ppd) include >(w)FeOH which is not in the " 190 "basis_species list") != std::string::npos)
191 <<
"Failed with unexpected error message: " << msg;
197 {
"H2O",
"H+",
"O2(aq)",
"Fe++",
">(s)FeOH",
">(w)FeOH"},
214 TEST(PertinentGeochemicalSystemTest, gasExceptions)
221 {
"H2O",
"Ca++",
"H+",
"HCO3-",
"CH4(aq)"},
223 {
"CH4(g)",
"CH4(g)"},
229 FAIL() <<
"Missing expected exception.";
231 catch (
const std::exception & e)
233 std::string msg(e.what());
234 ASSERT_TRUE(msg.find(
"CH4(g) exists more than once in the gases list") != std::string::npos)
235 <<
"Failed with unexpected error message: " << msg;
241 {
"H2O",
"Ca++",
"H+",
"HCO3-",
"CH4(aq)"},
243 {
"CH4(g)",
"does_not_exist"},
249 FAIL() <<
"Missing expected exception.";
251 catch (
const std::exception & e)
253 std::string msg(e.what());
254 ASSERT_TRUE(msg.find(
"does_not_exist does not exist in database database/moose_testdb.json") !=
256 <<
"Failed with unexpected error message: " << msg;
262 {
"H2O",
"Ca++",
"H+",
"HCO3-"},
270 FAIL() <<
"Missing expected exception.";
272 catch (
const std::exception & e)
274 std::string msg(e.what());
275 ASSERT_TRUE(msg.find(
"The reaction for CH4(g) depends on CH4(aq) which is not reducable to a " 276 "set of basis species") != std::string::npos)
277 <<
"Failed with unexpected error message: " << msg;
283 {
"H2O",
"Ca++",
"H+",
"HCO3-",
"O2(aq)"},
303 TEST(PertinentGeochemicalSystemTest, kineticMineralExceptions)
310 database, {
"H2O"}, {}, {}, {
"Calcite",
"Calcite_asdf",
"Calcite"}, {}, {},
"O2(aq)",
"e-");
311 FAIL() <<
"Missing expected exception.";
313 catch (
const std::exception & e)
315 std::string msg(e.what());
316 ASSERT_TRUE(msg.find(
"Calcite exists more than once in the kinetic_minerals list") !=
318 <<
"Failed with unexpected error message: " << msg;
324 {
"H2O",
"Ca++",
"HCO3-",
"H+"},
327 {
"Calcite",
"Calcite_asdf"},
332 FAIL() <<
"Missing expected exception.";
334 catch (
const std::exception & e)
336 std::string msg(e.what());
337 ASSERT_TRUE(msg.find(
"Calcite_asdf exists in both the minerals and kinetic_minerals lists") !=
339 <<
"Failed with unexpected error message: " << msg;
345 {
"H2O",
"Ca++",
"HCO3-",
"H+"},
348 {
"Calcite",
"does_not_exist"},
353 FAIL() <<
"Missing expected exception.";
355 catch (
const std::exception & e)
357 std::string msg(e.what());
358 ASSERT_TRUE(msg.find(
"does_not_exist does not exist in database database/moose_testdb.json") !=
360 <<
"Failed with unexpected error message: " << msg;
366 database, {
"H2O",
"O2(aq)",
"H+"}, {}, {}, {
"Fe(OH)3(ppd)"}, {}, {},
"O2(aq)",
"e-");
367 FAIL() <<
"Missing expected exception.";
369 catch (
const std::exception & e)
371 std::string msg(e.what());
372 ASSERT_TRUE(msg.find(
"The reaction for Fe(OH)3(ppd) depends on Fe+++ which is not reducable to " 373 "a set of basis species") != std::string::npos)
374 <<
"Failed with unexpected error message: " << msg;
380 {
"H2O",
"H+",
"O2(aq)",
"Fe++",
">(s)FeOH"},
388 FAIL() <<
"Missing expected exception.";
390 catch (
const std::exception & e)
392 std::string msg(e.what());
393 ASSERT_TRUE(msg.find(
"The sorbing sites for Fe(OH)3(ppd) include >(w)FeOH which is not in the " 394 "basis_species list") != std::string::npos)
395 <<
"Failed with unexpected error message: " << msg;
401 {
"H2O",
"H+",
"O2(aq)",
"Fe++",
">(s)FeOH",
">(w)FeOH"},
419 TEST(PertinentGeochemicalSystemTest, kineticRedoxExceptions)
426 database, {
"H2O"}, {}, {}, {}, {
"(O-phth)--",
"Am++++",
"(O-phth)--"}, {},
"O2(aq)",
"e-");
427 FAIL() <<
"Missing expected exception.";
429 catch (
const std::exception & e)
431 std::string msg(e.what());
432 ASSERT_TRUE(msg.find(
"(O-phth)-- exists more than once in the kinetic_redox list") !=
434 <<
"Failed with unexpected error message: " << msg;
440 database, {
"H2O",
"(O-phth)--"}, {}, {}, {}, {
"Am++++",
"(O-phth)--"}, {},
"O2(aq)",
"e-");
441 FAIL() <<
"Missing expected exception.";
443 catch (
const std::exception & e)
445 std::string msg(e.what());
446 ASSERT_TRUE(msg.find(
"(O-phth)-- exists in both the basis_species and kinetic_redox lists") !=
448 <<
"Failed with unexpected error message: " << msg;
454 database, {
"H2O"}, {}, {}, {}, {
"(O-phth)--",
"does_not_exist"}, {},
"O2(aq)",
"e-");
455 FAIL() <<
"Missing expected exception.";
457 catch (
const std::exception & e)
459 std::string msg(e.what());
460 ASSERT_TRUE(msg.find(
"does_not_exist does not exist in database database/moose_testdb.json") !=
462 <<
"Failed with unexpected error message: " << msg;
468 database, {
"H2O",
"HCO3-",
"H+"}, {}, {}, {}, {
"(O-phth)--"}, {},
"O2(aq)",
"e-");
469 FAIL() <<
"Missing expected exception.";
471 catch (
const std::exception & e)
473 std::string msg(e.what());
474 ASSERT_TRUE(msg.find(
"The reaction for (O-phth)-- depends on O2(aq) which is not reducable to " 475 "a set of basis species") != std::string::npos)
476 <<
"Failed with unexpected error message: " << msg;
481 database, {
"H2O",
"HCO3-",
"H+",
"O2(aq)"}, {}, {}, {}, {
"(O-phth)--"}, {},
"O2(aq)",
"e-");
491 TEST(PertinentGeochemicalSystemTest, kineticSurfaceExceptions)
498 database, {
"H2O"}, {}, {}, {}, {}, {
">(s)FeO-",
">(s)FeOCa+",
">(s)FeO-"},
"O2(aq)",
"e-");
499 FAIL() <<
"Missing expected exception.";
501 catch (
const std::exception & e)
503 std::string msg(e.what());
504 ASSERT_TRUE(msg.find(
">(s)FeO- exists more than once in the kinetic_surface_species list") !=
506 <<
"Failed with unexpected error message: " << msg;
517 {
">(s)FeO-",
">(s)FeOCa+",
"does_not_exist"},
520 FAIL() <<
"Missing expected exception.";
522 catch (
const std::exception & e)
524 std::string msg(e.what());
525 ASSERT_TRUE(msg.find(
"does_not_exist does not exist in database database/moose_testdb.json") !=
527 <<
"Failed with unexpected error message: " << msg;
533 database, {
"H2O",
"H+"}, {}, {}, {}, {}, {
">(s)FeO-"},
"O2(aq)",
"e-");
534 FAIL() <<
"Missing expected exception.";
536 catch (
const std::exception & e)
538 std::string msg(e.what());
539 ASSERT_TRUE(msg.find(
"The reaction for >(s)FeO- depends on >(s)FeOH which is not reducable to " 540 "a set of basis species") != std::string::npos)
541 <<
"Failed with unexpected error message: " << msg;
546 database, {
"H2O",
"H+",
">(s)FeOH"}, {}, {}, {}, {}, {
">(s)FeO-"},
"O2(aq)",
"e-");
550 TEST(PertinentGeochemicalSystemTest, temperatures)
565 TEST(PertinentGeochemicalSystemTest, names1)
572 {
"H2O",
"H+",
"HCO3-",
"O2(aq)",
"Ca++",
">(s)FeOH"},
600 TEST(PertinentGeochemicalSystemTest, names2)
606 {
"H2O",
"H+",
"HCO3-",
"O2(aq)",
"Ca++",
">(s)FeOH"},
609 {
"Calcite_asdf",
"Calcite"},
611 {
">(s)FeOCa+",
">(s)FeO-"},
630 TEST(PertinentGeochemicalSystemTest, charge)
637 {
"H2O",
"H+",
"HCO3-",
"O2(aq)",
"Ca++",
">(s)FeOH"},
647 std::map<std::string, Real> charge_gold;
648 charge_gold[
"H2O"] = 0.0;
649 charge_gold[
"H+"] = 1.0;
650 charge_gold[
"HCO3-"] = -1.0;
651 charge_gold[
"O2(aq)"] = 0.0;
652 charge_gold[
"Ca++"] = 2.0;
653 charge_gold[
">(s)FeOH"] = 0.0;
654 charge_gold[
"CO2(aq)"] = 0.0;
655 charge_gold[
"CO3--"] = -2.0;
656 charge_gold[
"CaCO3"] = 0.0;
657 charge_gold[
"CaOH+"] = 1.0;
658 charge_gold[
"OH-"] = -1.0;
659 charge_gold[
"(O-phth)--"] = -2.0;
660 charge_gold[
">(s)FeO-"] = -1.0;
661 charge_gold[
">(s)FeOCa+"] = -1.0;
662 charge_gold[
"Calcite"] = 0.0;
663 charge_gold[
"e-"] = -1.0;
664 charge_gold[
"Calcite_asdf"] = 0.0;
665 charge_gold[
"CH4(aq)"] = 0.0;
675 TEST(PertinentGeochemicalSystemTest, radius)
682 {
"H2O",
"H+",
"HCO3-",
"O2(aq)",
"Ca++",
">(s)FeOH"},
692 std::map<std::string, Real> radius_gold;
693 radius_gold[
"H2O"] = 0.0;
694 radius_gold[
"H+"] = 9.0;
695 radius_gold[
"HCO3-"] = 4.5;
696 radius_gold[
"O2(aq)"] = -0.5;
697 radius_gold[
"Ca++"] = 6.0;
698 radius_gold[
">(s)FeOH"] = 0.0;
699 radius_gold[
"CO2(aq)"] = 4.0;
700 radius_gold[
"CO3--"] = 4.5;
701 radius_gold[
"CaCO3"] = 4.0;
702 radius_gold[
"CaOH+"] = 4.0;
703 radius_gold[
"OH-"] = 3.5;
704 radius_gold[
"(O-phth)--"] = 4.0;
705 radius_gold[
">(s)FeO-"] = -1.5;
706 radius_gold[
">(s)FeOCa+"] = -1.5;
707 radius_gold[
"Calcite"] = 0.0;
708 radius_gold[
"e-"] = 0.0;
716 TEST(PertinentGeochemicalSystemTest, molecular_weight)
723 {
"H2O",
"H+",
"HCO3-",
"O2(aq)",
"Ca++",
">(s)FeOH"},
733 std::map<std::string, Real> molecular_weight_gold;
734 molecular_weight_gold[
"H2O"] = 18.0152;
735 molecular_weight_gold[
"H+"] = 1.0079;
736 molecular_weight_gold[
"HCO3-"] = 61.0171;
737 molecular_weight_gold[
"O2(aq)"] = 31.9988;
738 molecular_weight_gold[
"Ca++"] = 40.0800;
739 molecular_weight_gold[
">(s)FeOH"] = 72.8543;
740 molecular_weight_gold[
"CO2(aq)"] = 44.0098;
741 molecular_weight_gold[
"CO3--"] = 60.0092;
742 molecular_weight_gold[
"CaCO3"] = 100.0892;
743 molecular_weight_gold[
"CaOH+"] = 57.0873;
744 molecular_weight_gold[
"OH-"] = 17.0073;
745 molecular_weight_gold[
"(O-phth)--"] = 164.1172;
746 molecular_weight_gold[
">(s)FeO-"] = 71.8464;
747 molecular_weight_gold[
">(s)FeOCa+"] = 279.7144;
748 molecular_weight_gold[
"Calcite"] = 100.0892;
749 molecular_weight_gold[
"e-"] = 0.0;
750 molecular_weight_gold[
"Calcite_asdf"] = 111.0892;
751 molecular_weight_gold[
"CH4(aq)"] = 16.0426;
752 molecular_weight_gold[
">(s)FeOCa+"] = 279.7144;
762 TEST(PertinentGeochemicalSystemTest, molecular_volume)
769 {
"H2O",
"H+",
"HCO3-",
"O2(aq)",
"Ca++",
">(s)FeOH"},
779 std::map<std::string, Real> molecular_volume_gold;
780 molecular_volume_gold[
"H2O"] = 0.0;
781 molecular_volume_gold[
"H+"] = 0.0;
782 molecular_volume_gold[
"HCO3-"] = 0.0;
783 molecular_volume_gold[
"O2(aq)"] = 0.0;
784 molecular_volume_gold[
"Ca++"] = 0.0;
785 molecular_volume_gold[
">(s)FeOH"] = 0.0;
786 molecular_volume_gold[
"CO2(aq)"] = 0.0;
787 molecular_volume_gold[
"CO3--"] = 0.0;
788 molecular_volume_gold[
"CaCO3"] = 0.0;
789 molecular_volume_gold[
"CaOH+"] = 0.0;
790 molecular_volume_gold[
"OH-"] = 0.0;
791 molecular_volume_gold[
"(O-phth)--"] = 0.0;
792 molecular_volume_gold[
">(s)FeO-"] = 0.0;
793 molecular_volume_gold[
">(s)FeOCa+"] = 0.0;
794 molecular_volume_gold[
"Calcite"] = 36.9340;
795 molecular_volume_gold[
"e-"] = 0.0;
796 molecular_volume_gold[
"Calcite_asdf"] = 136.9340;
797 molecular_volume_gold[
"CH4(aq)"] = 0.0;
798 molecular_volume_gold[
">(s)FeOCa+"] = 0.0;
808 TEST(PertinentGeochemicalSystemTest, surfaceComplexationInfo)
815 {
"H2O",
"H+",
"HCO3-",
"O2(aq)",
"Ca++",
">(s)FeOH"},
825 ASSERT_EQ(mgd1.surface_complexation_info.size(), (std::size_t)0);
830 {
"H2O",
"H+",
"O2(aq)",
"Fe++",
">(s)FeOH",
">(w)FeOH"},
840 ASSERT_EQ(mgd2.surface_complexation_info.count(
"Fe(OH)3(ppd)"), (std::size_t)1);
841 ASSERT_EQ(mgd2.surface_complexation_info[
"Fe(OH)3(ppd)"].surface_area, 600.0);
842 ASSERT_EQ(mgd2.surface_complexation_info[
"Fe(OH)3(ppd)"].sorption_sites[
">(s)FeOH"], 0.005);
843 ASSERT_EQ(mgd2.surface_complexation_info[
"Fe(OH)3(ppd)"].sorption_sites[
">(w)FeOH"], 0.2);
848 {
"H2O",
"H+",
"O2(aq)",
"Fe++",
">(s)FeOH",
">(w)FeOH"},
858 ASSERT_EQ(mgd3.surface_complexation_info.count(
"Goethite"), (std::size_t)1);
859 ASSERT_EQ(mgd3.surface_complexation_info[
"Goethite"].surface_area, 60.0);
860 ASSERT_EQ(mgd3.surface_complexation_info[
"Goethite"].sorption_sites[
">(s)FeOH"], 0.05);
861 ASSERT_EQ(mgd3.surface_complexation_info[
"Goethite"].sorption_sites[
">(w)FeOH"], 0.222);
865 TEST(PertinentGeochemicalSystemTest, surfaceComplexationRepeatedException)
872 {
"H2O",
"H+",
"O2(aq)",
"Fe++",
">(s)FeOH",
">(w)FeOH"},
873 {
"Goethite",
"Fe(OH)3(ppd)"},
880 FAIL() <<
"Missing expected exception.";
882 catch (
const std::exception & e)
884 std::string msg(e.what());
885 ASSERT_TRUE(msg.find(
"The sorbing site >(s)FeOH appears in more than one sorbing mineral") !=
887 <<
"Failed with unexpected error message: " << msg;
892 TEST(PertinentGeochemicalSystemTest, excessSorbingSitesException)
899 {
"H2O",
"H+",
"Fe+++",
"sorbsite1",
"sorbsite2"},
900 {
"problematic_sorber"},
907 FAIL() <<
"Missing expected exception.";
909 catch (
const std::exception & e)
911 std::string msg(e.what());
912 ASSERT_TRUE(msg.find(
"It is an error for any equilibrium species (such as problem_eqm) to have " 913 "a reaction involving more than one sorbing site") != std::string::npos)
914 <<
"Failed with unexpected error message: " << msg;
919 TEST(PertinentGeochemicalSystemTest, surfaceSorptionBuilding)
924 database, {
"H2O",
"H+",
"Ca++",
"HCO3-"}, {
"Calcite"}, {}, {}, {}, {},
"O2(aq)",
"e-");
927 EXPECT_EQ(mgdC.surface_sorption_name.size(), (std::size_t)0);
928 EXPECT_EQ(mgdC.surface_sorption_area.size(), (std::size_t)0);
929 for (
unsigned j = 0;
j < mgdC.eqm_species_name.size(); ++
j)
930 EXPECT_EQ(mgdC.surface_sorption_related[
j],
false);
933 {
"H2O",
"H+",
"Fe+++",
">(s)FeOH",
">(w)FeOH"},
934 {
"Fe(OH)3(ppd)fake",
"Goethite"},
942 EXPECT_EQ(mgd2.surface_complexation_info.count(
"Goethite"), (std::size_t)1);
943 EXPECT_EQ(mgd2.surface_sorption_name.size(), (std::size_t)1);
944 EXPECT_EQ(mgd2.surface_sorption_name[0],
"Goethite");
945 EXPECT_EQ(mgd2.surface_sorption_area.size(), (std::size_t)1);
946 EXPECT_EQ(mgd2.surface_sorption_area[0], 60.0);
947 EXPECT_EQ(mgd2.surface_sorption_related.size(), mgd2.eqm_species_name.size());
948 EXPECT_EQ(mgd2.surface_sorption_number.size(), mgd2.eqm_species_name.size());
950 EXPECT_EQ(mgd2.eqm_species_index.count(
">(s)FeO-"), (std::size_t)1);
951 const unsigned posn = mgd2.eqm_species_index.at(
">(s)FeO-");
952 for (
unsigned j = 0;
j < mgd2.eqm_species_name.size(); ++
j)
954 EXPECT_TRUE(mgd2.surface_sorption_related[
j]);
956 EXPECT_FALSE(mgd2.surface_sorption_related[
j]);
957 EXPECT_EQ(mgd2.surface_sorption_number[posn], (
unsigned int)0);
961 TEST(PertinentGeochemicalSystemTest, GasChi)
968 {
"H2O",
"H+",
"HCO3-",
"O2(aq)",
"Ca++",
">(s)FeOH"},
978 ASSERT_EQ(mgd1.gas_chi.size(), (std::size_t)0);
981 {
"H2O",
"Ca++",
"H+",
"HCO3-",
"O2(aq)"},
991 ASSERT_EQ(mgd2.gas_chi.count(
"CH4(g)"), (std::size_t)1);
992 ASSERT_EQ(mgd2.gas_chi[
"CH4(g)"][0], -537.779);
993 ASSERT_EQ(mgd2.gas_chi[
"CH4(g)"][1], 1.54946);
994 ASSERT_EQ(mgd2.gas_chi[
"CH4(g)"][2], -.000927827);
995 ASSERT_EQ(mgd2.gas_chi[
"CH4(g)"][3], 1.20861);
996 ASSERT_EQ(mgd2.gas_chi[
"CH4(g)"][4], -.00370814);
997 ASSERT_EQ(mgd2.gas_chi[
"CH4(g)"][5], 3.33804e-6);
1003 TEST(PertinentGeochemicalSystemTest, stoichiometry1)
1009 {
"H2O",
"H+",
"HCO3-",
"O2(aq)",
"Ca++",
">(s)FeOH"},
1014 {
">(s)FeO-",
">(s)FeOCa+"},
1020 for (
const auto & sp : {
"CO2(aq)",
"CO3--",
"CaCO3",
"CaOH+",
"OH-",
"(O-phth)--",
"Calcite"})
1023 std::map<std::string, DenseMatrix<Real>> stoi_gold;
1024 for (
const auto & sp : {
"CO2(aq)",
1037 stoi_gold[
"CO2(aq)"](0, 0) = -1;
1038 stoi_gold[
"CO2(aq)"](0, 1) = 1;
1039 stoi_gold[
"CO2(aq)"](0, 2) = 1;
1040 stoi_gold[
"CO3--"](0, 1) = -1;
1041 stoi_gold[
"CO3--"](0, 2) = 1;
1042 stoi_gold[
"CaCO3"](0, 4) = 1;
1043 stoi_gold[
"CaCO3"](0, 2) = 1;
1044 stoi_gold[
"CaCO3"](0, 1) = -1;
1045 stoi_gold[
"CaOH+"](0, 4) = 1;
1046 stoi_gold[
"CaOH+"](0, 0) = 1;
1047 stoi_gold[
"CaOH+"](0, 1) = -1;
1048 stoi_gold[
"OH-"](0, 0) = 1;
1049 stoi_gold[
"OH-"](0, 1) = -1;
1050 stoi_gold[
"(O-phth)--"](0, 0) = -5;
1051 stoi_gold[
"(O-phth)--"](0, 2) = 8;
1052 stoi_gold[
"(O-phth)--"](0, 1) = 6;
1053 stoi_gold[
"(O-phth)--"](0, 3) = -7.5;
1054 stoi_gold[
">(s)FeO-"](0, 5) = 1;
1055 stoi_gold[
">(s)FeO-"](0, 1) = -1;
1056 stoi_gold[
">(s)FeOCa+"](0, 5) = 1;
1057 stoi_gold[
">(s)FeOCa+"](0, 4) = 1;
1058 stoi_gold[
">(s)FeOCa+"](0, 1) = -1;
1059 stoi_gold[
"Calcite"](0, 4) = 1;
1060 stoi_gold[
"Calcite"](0, 2) = 1;
1061 stoi_gold[
"Calcite"](0, 1) = -1;
1062 stoi_gold[
"Calcite_asdf"](0, 4) = 2;
1063 stoi_gold[
"Calcite_asdf"](0, 2) = 1;
1064 stoi_gold[
"Calcite_asdf"](0, 1) = -1;
1066 stoi_gold[
"CH4(aq)"](0, 0) = 1;
1067 stoi_gold[
"CH4(aq)"](0, 1) = 1;
1068 stoi_gold[
"CH4(aq)"](0, 2) = 1;
1069 stoi_gold[
"CH4(aq)"](0, 3) = -2;
1071 for (
const auto & sp : {
"CO2(aq)",
"CO3--",
"CaCO3",
"CaOH+",
"OH-",
"(O-phth)--",
"Calcite"})
1076 for (
const auto & sp : {
"Calcite_asdf",
"CH4(aq)",
">(s)FeO-",
">(s)FeOCa+"})
1084 TEST(PertinentGeochemicalSystemTest, log10K1)
1091 {
"H2O",
"H+",
"HCO3-",
"O2(aq)",
"Ca++",
">(s)FeOH"},
1124 TEST(PertinentGeochemicalSystemTest, stoichiometry2)
1131 {
"H2O",
"H+",
">(s)FeOH",
">(w)FeOH",
"Fe++",
"HCO3-",
"O2(aq)"},
1132 {
"Fe(OH)3(ppd)fake"},
1142 for (
const auto & sp : {
"CO2(aq)",
1153 std::map<std::string, DenseMatrix<Real>> stoi_gold;
1154 for (
const auto & sp : {
"CO2(aq)",
1167 stoi_gold[
"CO2(aq)"](0, 0) = -1;
1168 stoi_gold[
"CO2(aq)"](0, 1) = 1;
1169 stoi_gold[
"CO2(aq)"](0, 5) = 1;
1170 stoi_gold[
"CO3--"](0, 5) = 1;
1171 stoi_gold[
"CO3--"](0, 1) = -1;
1172 stoi_gold[
"OH-"](0, 0) = 1;
1173 stoi_gold[
"OH-"](0, 1) = -1;
1174 stoi_gold[
"(O-phth)--"](0, 0) = -5;
1175 stoi_gold[
"(O-phth)--"](0, 5) = 8;
1176 stoi_gold[
"(O-phth)--"](0, 1) = 6;
1177 stoi_gold[
"(O-phth)--"](0, 6) = -7.5;
1178 stoi_gold[
"CH4(aq)"](0, 0) = 1;
1179 stoi_gold[
"CH4(aq)"](0, 1) = 1;
1180 stoi_gold[
"CH4(aq)"](0, 5) = 1;
1181 stoi_gold[
"CH4(aq)"](0, 6) = -2;
1182 stoi_gold[
"Fe+++"](0, 0) = -0.5;
1183 stoi_gold[
"Fe+++"](0, 4) = 1;
1184 stoi_gold[
"Fe+++"](0, 1) = 1;
1185 stoi_gold[
"Fe+++"](0, 6) = 0.25;
1186 stoi_gold[
">(s)FeO-"](0, 2) = 1;
1187 stoi_gold[
">(s)FeO-"](0, 1) = -1;
1188 stoi_gold[
"Fe(OH)3(ppd)fake"](0, 1) = -1;
1189 stoi_gold[
"Fe(OH)3(ppd)fake"](0, 0) = 2;
1190 stoi_gold[
"Fe(OH)3(ppd)fake"](0, 4) = 2;
1191 stoi_gold[
"Fe(OH)3(ppd)fake"](0, 6) = 0.5;
1192 stoi_gold[
"CH4(g)fake"](0, 0) = 3;
1193 stoi_gold[
"CH4(g)fake"](0, 4) = -2;
1194 stoi_gold[
"CH4(g)fake"](0, 5) = 3.5;
1195 stoi_gold[
"CH4(g)fake"](0, 6) = -4.5;
1196 stoi_gold[
"Fe(OH)3(ppd)"](0, 1) = -2;
1197 stoi_gold[
"Fe(OH)3(ppd)"](0, 4) = 1;
1198 stoi_gold[
"Fe(OH)3(ppd)"](0, 0) = 2.5;
1199 stoi_gold[
"Fe(OH)3(ppd)"](0, 6) = 0.25;
1201 for (
const auto & sp : {
"CO2(aq)",
1222 TEST(PertinentGeochemicalSystemTest, stoichiometry3)
1228 {
"H2O",
"H+",
">(s)FeOH",
">(w)FeOH",
"Fe++",
"HCO3-",
"O2(aq)"},
1231 {
"Fe(OH)3(ppd)",
"Fe(OH)3(ppd)fake"},
1239 for (
const auto & sp : {
"CO2(aq)",
"CO3--",
"OH-",
"CH4(aq)",
"Fe+++",
"CH4(g)fake"})
1242 std::map<std::string, DenseMatrix<Real>> stoi_gold;
1243 for (
const auto & sp : {
"CO2(aq)",
1256 stoi_gold[
"CO2(aq)"](0, 0) = -1;
1257 stoi_gold[
"CO2(aq)"](0, 1) = 1;
1258 stoi_gold[
"CO2(aq)"](0, 5) = 1;
1259 stoi_gold[
"CO3--"](0, 5) = 1;
1260 stoi_gold[
"CO3--"](0, 1) = -1;
1261 stoi_gold[
"OH-"](0, 0) = 1;
1262 stoi_gold[
"OH-"](0, 1) = -1;
1263 stoi_gold[
"(O-phth)--"](0, 0) = -5;
1264 stoi_gold[
"(O-phth)--"](0, 5) = 8;
1265 stoi_gold[
"(O-phth)--"](0, 1) = 6;
1266 stoi_gold[
"(O-phth)--"](0, 6) = -7.5;
1267 stoi_gold[
"CH4(aq)"](0, 0) = 1;
1268 stoi_gold[
"CH4(aq)"](0, 1) = 1;
1269 stoi_gold[
"CH4(aq)"](0, 5) = 1;
1270 stoi_gold[
"CH4(aq)"](0, 6) = -2;
1271 stoi_gold[
"Fe+++"](0, 0) = -0.5;
1272 stoi_gold[
"Fe+++"](0, 4) = 1;
1273 stoi_gold[
"Fe+++"](0, 1) = 1;
1274 stoi_gold[
"Fe+++"](0, 6) = 0.25;
1275 stoi_gold[
">(s)FeO-"](0, 2) = 1;
1276 stoi_gold[
">(s)FeO-"](0, 1) = -1;
1277 stoi_gold[
"Fe(OH)3(ppd)fake"](0, 1) = -1;
1278 stoi_gold[
"Fe(OH)3(ppd)fake"](0, 0) = 2;
1279 stoi_gold[
"Fe(OH)3(ppd)fake"](0, 4) = 2;
1280 stoi_gold[
"Fe(OH)3(ppd)fake"](0, 6) = 0.5;
1281 stoi_gold[
"CH4(g)fake"](0, 0) = 3;
1282 stoi_gold[
"CH4(g)fake"](0, 4) = -2;
1283 stoi_gold[
"CH4(g)fake"](0, 5) = 3.5;
1284 stoi_gold[
"CH4(g)fake"](0, 6) = -4.5;
1285 stoi_gold[
"Fe(OH)3(ppd)"](0, 1) = -2;
1286 stoi_gold[
"Fe(OH)3(ppd)"](0, 4) = 1;
1287 stoi_gold[
"Fe(OH)3(ppd)"](0, 0) = 2.5;
1288 stoi_gold[
"Fe(OH)3(ppd)"](0, 6) = 0.25;
1290 for (
const auto & sp : {
"CO2(aq)",
"CO3--",
"OH-",
"CH4(aq)",
"Fe+++",
"CH4(g)fake"})
1296 for (
const auto & sp : {
"Fe(OH)3(ppd)",
"Fe(OH)3(ppd)fake",
"(O-phth)--",
">(s)FeO-"})
1308 TEST(PertinentGeochemicalSystemTest, log10K2)
1315 {
"H2O",
"H+",
">(s)FeOH",
">(w)FeOH",
"Fe++",
"HCO3-",
"O2(aq)"},
1316 {
"Fe(OH)3(ppd)fake"},
1356 -2.6487 + 2 * 157.8920 - 2 * (-10.0553),
1359 -2.8202 + 2 * 144.1080 - 2 * (-8.4878),
1362 -2.9329 + 2 * 127.9360 - 2 * (-6.6954),
1365 -2.9446 + 2 * 112.8800 - 2 * (-5.0568),
1368 -2.9163 + 2 * 97.7060 - 2 * (-3.4154),
1371 -2.7253 + 2 * 85.2880 - 2 * (-2.0747),
1374 -2.4643 + 2 * 74.7500 - 2 * (-0.8908),
1377 -2.1569 + 2 * 65.6500 - 2 * (0.2679),
1385 TEST(PertinentGeochemicalSystemTest, secondarySpecies2)
1393 {
"H2O",
"H+",
"HCO3-",
"O2(aq)",
"Ca++",
">(s)FeOH",
"(O-phth)--"},
1404 for (
const auto & sp :
1405 {
"CO2(aq)",
"CO3--",
"CaCO3",
"CaOH+",
"OH-",
">(s)FeO-",
">(s)FeOCa+",
"Calcite"})
1410 TEST(PertinentGeochemicalSystemTest, isMineral)
1417 {
"H2O",
"H+",
">(s)FeOH",
">(w)FeOH",
"Fe++",
"HCO3-",
"O2(aq)"},
1418 {
"Fe(OH)3(ppd)fake"},
1430 if (species.first ==
"Fe(OH)3(ppd)fake")
1437 {
"H2O",
"H+",
">(s)FeOH",
">(w)FeOH",
"Fe++",
"HCO3-",
"O2(aq)"},
1440 {
"Fe(OH)3(ppd)fake"},
1447 for (
const auto & species : mgd2.basis_species_index)
1448 ASSERT_EQ(mgd2.basis_species_mineral[species.second],
false);
1449 for (
const auto & species : mgd2.eqm_species_index)
1450 ASSERT_EQ(mgd2.eqm_species_mineral[species.second],
false);
1451 for (
const auto & species : mgd2.kin_species_index)
1452 if (species.first ==
"Fe(OH)3(ppd)fake")
1453 ASSERT_EQ(mgd2.kin_species_mineral[species.second],
true);
1455 ASSERT_EQ(mgd2.kin_species_mineral[species.second],
false);
1459 TEST(PertinentGeochemicalSystemTest, isGas)
1466 {
"H2O",
"H+",
">(s)FeOH",
">(w)FeOH",
"Fe++",
"HCO3-",
"O2(aq)"},
1467 {
"Fe(OH)3(ppd)fake"},
1468 {
"CH4(g)fake",
"O2(g)"},
1479 if (species.first ==
"CH4(g)fake" || species.first ==
"O2(g)")
1486 TEST(PertinentGeochemicalSystemTest, isTransported)
1493 {
"H2O",
"H+",
">(s)FeOH",
">(w)FeOH",
"Fe++",
"HCO3-",
"O2(aq)"},
1504 if (species.first ==
">(s)FeOH" || species.first ==
">(w)FeOH")
1509 if (species.first ==
"Fe(OH)3(ppd)" || species.first ==
">(s)FeO-")
1516 {
"H2O",
"H+",
">(s)FeOH",
">(w)FeOH",
"Fe++",
"HCO3-",
"O2(aq)"},
1526 for (
const auto & species : mgd2.basis_species_index)
1527 if (species.first ==
">(s)FeOH" || species.first ==
">(w)FeOH")
1528 ASSERT_EQ(mgd2.basis_species_transported[species.second],
false);
1530 ASSERT_EQ(mgd2.basis_species_transported[species.second],
true);
1531 for (
const auto & species : mgd2.eqm_species_index)
1532 ASSERT_EQ(mgd2.eqm_species_transported[species.second],
true);
1533 for (
const auto & species : mgd2.kin_species_index)
1534 if (species.first ==
"Fe(OH)3(ppd)" || species.first ==
">(s)FeO-")
1535 ASSERT_EQ(mgd2.kin_species_transported[species.second],
false);
1537 ASSERT_EQ(mgd2.kin_species_transported[species.second],
true);
1541 TEST(PertinentGeochemicalSystemTest, redoxCapture)
1547 {
"H2O",
"H+",
">(s)FeOH",
">(w)FeOH",
"Fe++",
"HCO3-",
"O2(aq)"},
1548 {
"Fe(OH)3(ppd)fake"},
1549 {
"CH4(g)fake",
"O2(g)"},
1557 EXPECT_EQ(mgd_no_redox.redox_stoichiometry.m(), (unsigned)1);
1558 EXPECT_EQ(mgd_no_redox.redox_log10K.m(), (unsigned)1);
1562 {
"H2O",
"H+",
"HCO3-",
"O2(aq)",
"(O-phth)--",
"CH4(aq)",
"StoiCheckRedox",
"Fe+++"},
1563 {
"Fe(OH)3(ppd)fake"},
1564 {
"CH4(g)fake",
"O2(g)"},
1572 EXPECT_EQ(mgd_redox.redox_lhs,
"e-");
1576 EXPECT_EQ(mgd_redox.redox_stoichiometry.m(), (unsigned)3);
1577 EXPECT_EQ(mgd_redox.redox_log10K.m(), (unsigned)3);
1582 const bool ophth_is_slot_one = (mgd_redox.redox_stoichiometry(1, 4) > 1.0E-6);
1583 const unsigned ophth_slot = (ophth_is_slot_one ? 1 : 2);
1584 const unsigned ch4_slot = (ophth_is_slot_one ? 2 : 1);
1587 Real boa = 1.0 / 4.0 / 7.5;
1588 EXPECT_EQ(mgd_redox.redox_stoichiometry(ophth_slot, 0), 0.5 + 5.0 * boa);
1589 EXPECT_EQ(mgd_redox.redox_stoichiometry(ophth_slot, 1), -1 - 6.0 * boa);
1590 EXPECT_EQ(mgd_redox.redox_stoichiometry(ophth_slot, 2), -8.0 * boa);
1591 EXPECT_EQ(mgd_redox.redox_stoichiometry(ophth_slot, 3), 0.0);
1592 EXPECT_EQ(mgd_redox.redox_stoichiometry(ophth_slot, 4), boa);
1593 EXPECT_EQ(mgd_redox.redox_stoichiometry(ophth_slot, 5), 0.0);
1594 EXPECT_EQ(mgd_redox.redox_stoichiometry(ophth_slot, 6), 0.0);
1595 EXPECT_EQ(mgd_redox.redox_stoichiometry(ophth_slot, 7), 0.0);
1597 mgd_redox.redox_log10K(ophth_slot, 0), -boa * 594.3211 + 22.76135 - 0.25 * (-2.6610), 1E-8);
1599 mgd_redox.redox_log10K(ophth_slot, 1), -boa * 542.8292 + 20.7757 - 0.25 * (-2.8990), 1E-8);
1601 mgd_redox.redox_log10K(ophth_slot, 2), -boa * 482.3612 + 18.513025 - 0.25 * (-3.0580), 1E-8);
1603 mgd_redox.redox_log10K(ophth_slot, 3), -boa * 425.9738 + 16.4658 - 0.25 * (-3.1250), 1E-8);
1605 mgd_redox.redox_log10K(ophth_slot, 4), -boa * 368.7004 + 14.473225 - 0.25 * (-3.0630), 1E-8);
1607 mgd_redox.redox_log10K(ophth_slot, 5), -boa * 321.8658 + 12.92125 - 0.25 * (-2.9140), 1E-8);
1609 mgd_redox.redox_log10K(ophth_slot, 6), -boa * 281.8216 + 11.68165 - 0.25 * (-2.6600), 1E-8);
1611 mgd_redox.redox_log10K(ophth_slot, 7), -boa * 246.4849 + 10.67105 - 0.25 * (-2.4100), 1E-8);
1615 EXPECT_EQ(mgd_redox.redox_stoichiometry(ch4_slot, 0), 0.5 - boa);
1616 EXPECT_EQ(mgd_redox.redox_stoichiometry(ch4_slot, 1), -1 - boa);
1617 EXPECT_EQ(mgd_redox.redox_stoichiometry(ch4_slot, 2), -boa);
1618 EXPECT_EQ(mgd_redox.redox_stoichiometry(ch4_slot, 3), 0.0);
1619 EXPECT_EQ(mgd_redox.redox_stoichiometry(ch4_slot, 4), 0.0);
1620 EXPECT_EQ(mgd_redox.redox_stoichiometry(ch4_slot, 5), boa);
1621 EXPECT_EQ(mgd_redox.redox_stoichiometry(ch4_slot, 6), 0.0);
1622 EXPECT_EQ(mgd_redox.redox_stoichiometry(ch4_slot, 7), 0.0);
1624 mgd_redox.redox_log10K(ch4_slot, 0), -boa * 157.8920 + 22.76135 - 0.25 * (-2.6610), 1E-8);
1626 mgd_redox.redox_log10K(ch4_slot, 1), -boa * 144.1080 + 20.7757 - 0.25 * (-2.8990), 1E-8);
1628 mgd_redox.redox_log10K(ch4_slot, 2), -boa * 127.9360 + 18.513025 - 0.25 * (-3.0580), 1E-8);
1630 mgd_redox.redox_log10K(ch4_slot, 3), -boa * 112.8800 + 16.4658 - 0.25 * (-3.1250), 1E-8);
1632 mgd_redox.redox_log10K(ch4_slot, 4), -boa * 97.7060 + 14.473225 - 0.25 * (-3.0630), 1E-8);
1634 mgd_redox.redox_log10K(ch4_slot, 5), -boa * 85.2880 + 12.92125 - 0.25 * (-2.9140), 1E-8);
1636 mgd_redox.redox_log10K(ch4_slot, 6), -boa * 74.7500 + 11.68165 - 0.25 * (-2.6600), 1E-8);
1638 mgd_redox.redox_log10K(ch4_slot, 7), -boa * 65.6500 + 10.67105 - 0.25 * (-2.4100), 1E-8);
1642 TEST(PertinentGeochemicalSystemTest, redoxCapture_db_strange)
1647 database, {
"H2O",
"H+",
"HCO3-",
"O2(aq)",
"(O-phth)--"}, {}, {}, {}, {}, {},
"O2(aq)",
"e-");
1650 EXPECT_EQ(mgd_redox.redox_lhs,
"e-");
1652 EXPECT_EQ(mgd_redox.redox_stoichiometry.m(), (unsigned)1);
1653 EXPECT_EQ(mgd_redox.redox_log10K.m(), (unsigned)1);
1657 EXPECT_EQ(mgd_redox.redox_stoichiometry(0, 0), 2.0);
1658 EXPECT_EQ(mgd_redox.redox_stoichiometry(0, 1), -1.0);
1659 EXPECT_EQ(mgd_redox.redox_stoichiometry(0, 2), 0.0);
1660 EXPECT_EQ(mgd_redox.redox_stoichiometry(0, 3), 3.0);
1661 EXPECT_EQ(mgd_redox.redox_stoichiometry(0, 4), 0.0);
1662 EXPECT_NEAR(mgd_redox.redox_log10K(0, 0), 22.76135 + 14.9325, 1E-8);
1663 EXPECT_NEAR(mgd_redox.redox_log10K(0, 1), 20.7757 + 13.9868, 1E-8);
1664 EXPECT_NEAR(mgd_redox.redox_log10K(0, 2), 18.513025 + 13.0199, 1E-8);
1665 EXPECT_NEAR(mgd_redox.redox_log10K(0, 3), 16.4658 + 12.2403, 1E-8);
1666 EXPECT_NEAR(mgd_redox.redox_log10K(0, 4), 14.473225 + 11.5940, 1E-8);
1667 EXPECT_NEAR(mgd_redox.redox_log10K(0, 5), 12.92125 + 11.2191, 1E-8);
1668 EXPECT_NEAR(mgd_redox.redox_log10K(0, 6), 11.68165 + 11.0880, 1E-8);
1669 EXPECT_NEAR(mgd_redox.redox_log10K(0, 7), 10.67105 + 1001.2844, 1E-8);
1673 TEST(PertinentGeochemicalSystemTest, redoxCapture_redox_o_strange)
1678 database, {
"H2O",
"H+",
"HCO3-",
"O2(aq)",
"(O-phth)_0"}, {}, {}, {}, {}, {},
"O2(aq)",
"e-");
1681 EXPECT_EQ(mgd_redox.redox_lhs,
"e-");
1683 EXPECT_EQ(mgd_redox.redox_stoichiometry.m(), (unsigned)1);
1684 EXPECT_EQ(mgd_redox.redox_log10K.m(), (unsigned)1);
1688 EXPECT_EQ(mgd_redox.redox_stoichiometry(0, 0), 2.0);
1689 EXPECT_EQ(mgd_redox.redox_stoichiometry(0, 1), -1.0);
1690 EXPECT_EQ(mgd_redox.redox_stoichiometry(0, 2), 0.0);
1691 EXPECT_EQ(mgd_redox.redox_stoichiometry(0, 3), 3.0);
1692 EXPECT_EQ(mgd_redox.redox_stoichiometry(0, 4), 0.0);
1693 EXPECT_NEAR(mgd_redox.redox_log10K(0, 0), 22.76135 + 14.9325, 1E-8);
1694 EXPECT_NEAR(mgd_redox.redox_log10K(0, 1), 20.7757 + 13.9868, 1E-8);
1695 EXPECT_NEAR(mgd_redox.redox_log10K(0, 2), 18.513025 + 13.0199, 1E-8);
1696 EXPECT_NEAR(mgd_redox.redox_log10K(0, 3), 16.4658 + 12.2403, 1E-8);
1697 EXPECT_NEAR(mgd_redox.redox_log10K(0, 4), 14.473225 + 11.5940, 1E-8);
1698 EXPECT_NEAR(mgd_redox.redox_log10K(0, 5), 12.92125 + 11.2191, 1E-8);
1699 EXPECT_NEAR(mgd_redox.redox_log10K(0, 6), 11.68165 + 11.0880, 1E-8);
1700 EXPECT_NEAR(mgd_redox.redox_log10K(0, 7), 10.67105 + 1001.2844, 1E-8);
1704 TEST(PertinentGeochemicalSystemTest, addKineticRateExceptions)
1708 {
"H2O",
"H+",
"HCO3-",
"O2(aq)",
"Ca++"},
1740 FAIL() <<
"Missing expected exception.";
1742 catch (
const std::exception & e)
1744 std::string msg(e.what());
1747 "Cannot prescribe a kinetic rate to species Ca++ since it is not a kinetic species") !=
1749 <<
"Failed with unexpected error message: " << msg;
1775 FAIL() <<
"Missing expected exception.";
1777 catch (
const std::exception & e)
1779 std::string msg(e.what());
1780 ASSERT_TRUE(msg.find(
"Promoting species H++ must be a basis or a secondary species") !=
1782 <<
"Failed with unexpected error message: " << msg;
1808 FAIL() <<
"Missing expected exception.";
1810 catch (
const std::exception & e)
1812 std::string msg(e.what());
1813 ASSERT_TRUE(msg.find(
"Progeny CH4(aq) must be a basis or a secondary species") !=
1815 <<
"Failed with unexpected error message: " << msg;
1820 TEST(PertinentGeochemicalSystemTest, addKineticRate)
1824 {
"H2O",
"H+",
"HCO3-",
"O2(aq)",
"Ca++"},
1839 {
"H2O",
"OH-",
"O2(aq)",
"CO2(aq)",
"CaCO3"},
1840 {3.0, 3.1, 3.2, 3.3, 3.4},
1841 {1.0, 2.0, 3.0, 4.0, 5.0},
1842 {1.25, 1.5, 1.75, 2.25, 3.25},
1858 EXPECT_EQ(
mgd.
kin_rate[0].description.intrinsic_rate_constant, 1.0);
1859 EXPECT_EQ(
mgd.
kin_rate[0].description.area_quantity, 2.0);
1860 EXPECT_EQ(
mgd.
kin_rate[0].description.multiply_by_mass,
true);
1864 EXPECT_EQ(
mgd.
kin_rate[0].promoting_indices.size(), pi_gold.size());
1865 EXPECT_EQ(
mgd.
kin_rate[0].promoting_monod_indices.size(), pmi_gold.size());
1866 EXPECT_EQ(
mgd.
kin_rate[0].promoting_half_saturation.size(), pmk_gold.size());
1882 for (
unsigned i = 0; i < pi_gold.size(); ++i)
1884 EXPECT_EQ(
mgd.
kin_rate[0].promoting_indices[i], pi_gold[i]);
1885 EXPECT_EQ(
mgd.
kin_rate[0].promoting_monod_indices[i], pmi_gold[i]);
1886 EXPECT_EQ(
mgd.
kin_rate[0].promoting_half_saturation[i], pmk_gold[i]);
1888 EXPECT_EQ(
mgd.
kin_rate[0].description.theta, 4.0);
1890 EXPECT_EQ(
mgd.
kin_rate[0].description.activation_energy, 6.0);
1891 EXPECT_EQ(
mgd.
kin_rate[0].description.one_over_T0, 7.0);
1893 EXPECT_EQ(
mgd.
kin_rate[0].description.progeny,
"H+");
1894 EXPECT_EQ(
mgd.
kin_rate[0].description.progeny_efficiency, 2.0);
1920 EXPECT_EQ(
mgd.
kin_rate[1].description.intrinsic_rate_constant, 7.0);
1921 EXPECT_EQ(
mgd.
kin_rate[1].description.area_quantity, 6.0);
1922 EXPECT_EQ(
mgd.
kin_rate[1].description.multiply_by_mass,
false);
1923 EXPECT_EQ(
mgd.
kin_rate[1].promoting_indices.size(), pi_gold.size());
1924 std::fill(pi_gold.begin(), pi_gold.end(), 0.0);
1925 std::fill(pmi_gold.begin(), pmi_gold.end(), 0.0);
1926 std::fill(pmk_gold.begin(), pmk_gold.end(), 0.0);
1930 for (
unsigned i = 0; i < pi_gold.size(); ++i)
1932 EXPECT_EQ(
mgd.
kin_rate[1].promoting_indices[i], pi_gold[i]);
1933 EXPECT_EQ(
mgd.
kin_rate[1].promoting_monod_indices[i], pmi_gold[i]);
1934 EXPECT_EQ(
mgd.
kin_rate[1].promoting_half_saturation[i], pmk_gold[i]);
1936 EXPECT_EQ(
mgd.
kin_rate[1].description.theta, 5.0);
1938 EXPECT_EQ(
mgd.
kin_rate[1].description.activation_energy, 3.0);
1939 EXPECT_EQ(
mgd.
kin_rate[1].description.one_over_T0, 2.0);
1941 EXPECT_EQ(
mgd.
kin_rate[1].description.progeny,
"OH-");
1942 EXPECT_EQ(
mgd.
kin_rate[1].description.progeny_efficiency, 1.125);
1950 TEST(PertinentGeochemicalSystemTest, kin_log10K1)
1955 {
"H2O",
"H+",
">(s)FeOH",
">(w)FeOH",
"Fe++",
"HCO3-",
"O2(aq)"},
1958 {
"Fe(OH)3(ppd)fake"},
1966 6.1946 + 2 * (-10.0553),
1979 -0.5504 + 2 * (-0.8908),
2002 TEST(PertinentGeochemicalSystemTest, initSwapToOrigBasis)
2011 TEST(PertinentGeochemicalSystemTest, getIndexOfOriginalBasisSpecies)
2018 FAIL() <<
"Missing expected exception.";
2020 catch (
const std::exception & e)
2022 std::string msg(e.what());
2023 ASSERT_TRUE(msg.find(
"species OH- is not in the original basis") != std::string::npos)
2024 <<
"Failed with unexpected error message: " << msg;
2031 TEST(PertinentGeochemicalSystemTest, originalBasisNames)
2040 TEST(PertinentGeochemicalSystemTest, allMinerals)
2044 {
"H2O",
"H+",
">(s)FeOH",
">(w)FeOH",
"Fe++",
"HCO3-",
"O2(aq)"},
2047 {
"Fe(OH)3(ppd)fake"},
2054 for (
const auto & species : mgd2.basis_species_index)
2055 ASSERT_EQ(mgd2.basis_species_mineral[species.second],
false);
2056 EXPECT_EQ(mgd2.eqm_species_index.count(
"Calcite"), (std::size_t)0);
2057 EXPECT_EQ(mgd2.eqm_species_index.count(
"Calcite_asdf"), (std::size_t)0);
2058 EXPECT_EQ(mgd2.eqm_species_index.count(
"Fe(OH)3(ppd)fake"), (std::size_t)0);
2059 EXPECT_EQ(mgd2.eqm_species_index.count(
"Fe(OH)3(ppd)"), (std::size_t)1);
2060 EXPECT_EQ(mgd2.eqm_species_index.count(
"Goethite"), (std::size_t)1);
2061 EXPECT_EQ(mgd2.eqm_species_index.count(
"Something"), (std::size_t)1);
2062 for (
const auto & species : mgd2.kin_species_index)
2063 if (species.first ==
"Fe(OH)3(ppd)fake")
2064 ASSERT_EQ(mgd2.kin_species_mineral[species.second],
true);
2066 ASSERT_EQ(mgd2.kin_species_mineral[species.second],
false);
std::vector< Real > eqm_species_molecular_weight
all quantities have a molecular weight (g)
std::vector< bool > basis_species_transported
basis_species_transported[j] = true iff the j^th basis species is transported in reactive-transport s...
unsigned getIndexOfOriginalBasisSpecies(const std::string &name) const
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...
const std::vector< Real > & getTemperatures() const
Get the temperature points that the equilibrium constant is defined at.
std::vector< Real > basis_species_radius
all quantities have an ionic radius (Angstrom) for computing activity (mineral radius = 0...
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...
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...
DenseMatrix< Real > eqm_log10K
eqm_log10K(i, j) = log10(equilibrium constant) for i^th equilibrium species at the j^th temperature p...
TEST(PertinentGeochemicalSystemTest, basisExceptions)
Test that:
std::vector< Real > basis_species_molecular_weight
all quantities have a molecular weight (g)
const GeochemicalDatabaseReader * original_database
a pointer to the original database used to build this ModelGeochemicalDatabase
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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< std::string > originalBasisNames() const
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< 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< KineticRateDefinition > kin_rate
rates given to kinetic species.