test: adapt tests to include MassH2O

This commit is contained in:
Max Lübke 2025-11-13 16:03:16 +01:00
parent fe1c8de0ec
commit 5cb1f7e77c
4 changed files with 27 additions and 32 deletions

View File

@ -79,6 +79,12 @@ double IPhreeqcReader::operator[](const std::string &name) const {
// if it ends with '_si', we need to find '-si'
pos = _m_raw_output.find("-si", pos);
}
} else if (name == "MassH2O") {
pos = _m_raw_output.find("mass_water");
if (pos == std::string::npos) {
throw std::runtime_error("Name not found in output: " + name);
}
} else {
// if not, we first need to find '-totals'
pos = _m_raw_output.find("-totals");

View File

@ -24,10 +24,10 @@ RUN_CELLS
END)";
const std::vector<std::string> expected_names = {
"ID", "H", "O", "Charge", "tc",
"patm", "SolVol", "pH", "pe", "C(-4)",
"C(4)", "Ca", "Cl", "Mg", "Na",
"Calcite_eq", "Calcite_si", "Dolomite_eq", "Dolomite_si"};
"ID", "H", "O", "Charge", "tc",
"patm", "SolVol", "pH", "pe", "MassH2O",
"C(-4)", "C(4)", "Ca", "Cl", "Mg",
"Na", "Calcite_eq", "Calcite_si", "Dolomite_eq", "Dolomite_si"};
const std::string phreeqc_database = R"database(@POET_PHREEQCDAT_DB@)database";
} // namespace base_test
@ -45,6 +45,7 @@ const std::vector<std::string> expected_names = {"ID",
"SolVol",
"pH",
"pe",
"MassH2O",
"Ba",
"Cl",
"S(-2)",
@ -57,28 +58,16 @@ const std::vector<std::string> expected_names = {"ID",
"Celestite_eq",
"Celestite_si"};
const std::vector<std::string> expected_names_erased = {"ID",
"H",
"O",
"Charge",
"tc",
"patm",
"SolVol",
"pH",
"pe",
"Ba",
"Cl",
"S(-2)",
"S(6)",
"Sr",
"Barite_kin",
"Barite_p1",
"Celestite_kin",
"Celestite_p1"};
const std::vector<std::string> expected_names_erased = {
"ID", "H", "O", "Charge", "tc", "patm",
"SolVol", "pH", "pe", "MassH2O", "Ba", "Cl",
"S(-2)", "S(6)", "Sr", "Barite_kin", "Barite_p1", "Celestite_kin",
"Celestite_p1"};
const std::vector<std::string> expected_names_subset = {
"ID", "H", "O", "Charge", "tc", "patm", "SolVol", "pH",
"pe", "Ba", "Cl", "S(-2)", "S(6)", "Sr", "Celestite_eq", "Celestite_si"};
"ID", "H", "O", "Charge", "tc", "patm",
"SolVol", "pH", "pe", "MassH2O", "Ba", "Cl",
"S(-2)", "S(6)", "Sr", "Celestite_eq", "Celestite_si"};
} // namespace barite_test
namespace test_engine {

View File

@ -39,7 +39,7 @@ POET_TEST(PhreeqcMatrixOneSolution) {
PhreeqcMatrix::STLExport exported_init = pqc_mat.get();
// ID + H,O,Charge + 6 Solutions + 4 Equil incl. params
EXPECT_EQ(exported_init.names.size(), 19);
EXPECT_EQ(exported_init.names.size(), 20);
IPhreeqcReader pqc_compare(base_db, base_test::script);
pqc_compare.setOutputID(1);
@ -102,7 +102,7 @@ POET_TEST(PhreeqcMatrixMultiSolution) {
pqc_compare.setOutputID(1);
for (std::size_t i = 1; i < exported.names.size(); i++) {
if (i > 13 && i < 18) {
if (i > 14 && i < 19) {
EXPECT_TRUE(std::isnan(exported.values[i]));
continue;
}
@ -159,7 +159,7 @@ POET_TEST(PhreeqcMatrixCtor) {
pqc_compare.setOutputID(1);
for (std::size_t i = 1; i < exported.names.size(); i++) {
if (i > 13 && i < 18) {
if (i > 14 && i < 19) {
EXPECT_TRUE(std::isnan(exported.values[i]));
continue;
}
@ -190,7 +190,7 @@ POET_TEST(PhreeqcMatrixOperator) {
pqc_compare.setOutputID(1);
for (std::size_t i = 1; i < exported.names.size(); i++) {
if (i > 13 && i < 18) {
if (i > 14 && i < 19) {
EXPECT_TRUE(std::isnan(exported.values[i]));
continue;
}
@ -255,8 +255,8 @@ POET_TEST(PhreeqcMatrixWithoutRedoxAndH0O0) {
PhreeqcMatrix pqc_mat(barite_db, barite_script, false, false);
const std::vector<std::string> expected_names_without_redox = {
"H", "O", "Charge", "tc", "patm", "SolVol",
"pH", "pe", "Ba", "Cl", "S", "Sr",
"H", "O", "Charge", "tc", "patm", "SolVol", "pH",
"pe", "MassH2O", "Ba", "Cl", "S", "Sr",
};
EXPECT_EQ(expected_names_without_redox, pqc_mat.getSolutionNames());

View File

@ -61,10 +61,10 @@ POET_TEST(PhreeqcRunnerSimulation) {
const bool is_first_half = cell_index < half_cells;
if (is_first_half) {
EXPECT_EQ(simulationInOut[cell_index][0], expected_value_first_half);
EXPECT_TRUE(std::isnan(simulationInOut[cell_index][14]));
EXPECT_TRUE(std::isnan(simulationInOut[cell_index][15]));
} else {
EXPECT_EQ(simulationInOut[cell_index][0], expected_value_second_half);
EXPECT_FALSE(std::isnan(simulationInOut[cell_index][14]));
EXPECT_FALSE(std::isnan(simulationInOut[cell_index][15]));
}
EXPECT_NEAR(simulationInOut[cell_index][1], 111, 1);