10#include "gtest/gtest.h"
20 {
"H2O",
"H+",
"HCO3-",
"O2(aq)",
"Ca++",
">(s)FeOH",
"radius_neg1",
"radius_neg1.5"},
31TEST(GeochemistryActivityCoefficientsDebyeHuckelTest, notDH)
34 "database/faultydbs/notDH.json",
true,
true,
false);
39 FAIL() <<
"Missing expected exception.";
41 catch (
const std::exception & e)
43 std::string msg(e.what());
44 ASSERT_TRUE(msg.find(
"Attempted to get Debye-Huckel activity parameters but the activity model "
45 "is NOTdebye-huckel") != std::string::npos)
46 <<
"Failed with unexpected error message: " << msg;
51TEST(GeochemistryActivityCoefficientsDebyeHuckelTest, noNeutral)
54 "database/faultydbs/missing_DH.json",
true,
true,
false);
58 25.0,
mgd, std::vector<Real>(8, 1.0), std::vector<Real>(9), std::vector<Real>(3));
61 EXPECT_EQ(dh.
A, 0.5555);
62 EXPECT_EQ(dh.
B, 0.3333);
63 EXPECT_EQ(dh.
Bdot, 0.0444);
75TEST(GeochemistryActivityCoefficientsDebyeHuckelTest, ionicStrengthInterface)
80 is.setUseOnlyBasisMolality(
true);
81 is.setMaxStoichiometricIonicStrength(2.0E-8);
83 Real gold_ionic_str = 0.0;
84 std::vector<Real> basis_m(8);
87 gold_ionic_str += 2.0;
89 gold_ionic_str += 3.0;
92 gold_ionic_str += 4 * 5.0;
100 25.0,
mgd, basis_m, std::vector<Real>(9, 1.1), std::vector<Real>(3, 2.2));
107TEST(GeochemistryActivityCoefficientsDebyeHuckelTest, getDebyeHuckel)
112 25.0,
mgd, std::vector<Real>(8, 1.0), std::vector<Real>(9), std::vector<Real>(3));
115 EXPECT_EQ(dh.
A, 0.5092);
116 EXPECT_EQ(dh.
B, 0.3283);
117 EXPECT_EQ(dh.
Bdot, 0.041);
118 EXPECT_EQ(dh.
a_water, 1.45397);
119 EXPECT_EQ(dh.
b_water, 0.022357);
120 EXPECT_EQ(dh.
c_water, 0.0093804);
121 EXPECT_EQ(dh.
d_water, -0.0005362);
129TEST(GeochemistryActivityCoefficientsDebyeHuckelTest, buildActivityCoefficientsDebyeHuckel)
134 25.0,
mgd, std::vector<Real>(8, 1.0), std::vector<Real>(9), std::vector<Real>(3));
138 std::vector<Real> basis_ac;
139 std::vector<Real> eqm_ac;
142 EXPECT_EQ(basis_ac.size(), (std::size_t)8);
143 EXPECT_EQ(eqm_ac.size(), (std::size_t)9);
149 for (
unsigned i = 1; i < 8; ++i)
153 gold = std::pow(10.0,
169 std::sqrt(ionic_str),
173 ASSERT_NEAR(basis_ac[i], gold, 1.0E-8);
176 for (
unsigned j = 0; j < 9; ++j)
182 else if (nm ==
"CO2(aq)" || nm ==
"CaCO3" || nm ==
">(s)FeO-")
184 else if (nm ==
"seq_radius_neg1")
193 std::sqrt(ionic_str),
197 ASSERT_NEAR(eqm_ac[j], gold, 1.0E-8);
202TEST(GeochemistryActivityCoefficientsDebyeHuckelTest, waterActivity)
207 25.0,
mgd, std::vector<Real>(8, 1.0), std::vector<Real>(9), std::vector<Real>(3));
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-")
TEST(GeochemistryActivityCoefficientsDebyeHuckelTest, notDH)
Test errors when a non-DebyeHuckel database is read.
const GeochemicalDatabaseReader database("database/moose_testdb.json", true, true, false)
const ModelGeochemicalDatabase mgd
Class for reading geochemical reactions from a MOOSE geochemical database.
Computes activity coefficients for non-minerals and non-gases (since these species do not have activi...
const DebyeHuckelParameters & getDebyeHuckel() const
Real getStoichiometricIonicStrength() const
Return the current value of stoichiometric ionic strength.
void setInternalParameters(Real temperature, const ModelGeochemicalDatabase &mgd, const std::vector< Real > &basis_species_molality, const std::vector< Real > &eqm_species_molality, const std::vector< Real > &kin_species_molality) override
Sets internal parameters, such as the ionic strength and Debye-Huckel parameters, prior to computing ...
void buildActivityCoefficients(const ModelGeochemicalDatabase &mgd, std::vector< Real > &basis_activity_coef, std::vector< Real > &eqm_activity_coef) const override
Compute the activity coefficients and store them in basis_activity_coef and eqm_activity_coef Note:
Real getIonicStrength() const
Return the current value of ionic strength.
Real waterActivity() const override
Computes and returns the activity of water.
Calculators to compute ionic strength and stoichiometric ionic strength.
Constructs and stores a minimal amount of information that is pertinent to the user-defined geochemic...
const ModelGeochemicalDatabase & modelGeochemicalDatabase() const
Return a reference to the ModelGeochemicalDatabase structure.
Real log10ActCoeffDHBdot(Real charge, Real ion_size, Real sqrt_ionic_strength, Real A, Real B, Real Bdot)
log10(activity coefficient) according to the Debye-Huckel B-dot model
Real log10ActCoeffDHBdotAlternative(Real ionic_strength, Real Bdot)
log10(activity coefficient) alternative expression that is sometimes used in conjunction with the Deb...
Real log10ActCoeffDHBdotNeutral(Real ionic_strength, Real a, Real b, Real c, Real d)
log10(activity coefficient) for neutral species according to the Debye-Huckel B-dot model
Real lnActivityDHBdotWater(Real stoichiometric_ionic_strength, Real A, Real atilde, Real btilde, Real ctilde, Real dtilde)
ln(activity of water) according to the Debye-Huckel B-dot model
Data structure to hold all relevant information from the database file.
std::vector< Real > eqm_species_radius
all quantities have an ionic radius (Angstrom) for computing activity (mineral radius = 0,...
std::vector< Real > basis_species_radius
all quantities have an ionic radius (Angstrom) for computing activity (mineral radius = 0,...
std::vector< Real > basis_species_charge
all quantities have a charge (mineral charge = 0, gas charge = 0, oxide charge = 0)
std::unordered_map< std::string, unsigned > basis_species_index
basis_species_index[name] = index of the basis species, within all ModelGeochemicalDatabase internal ...
std::vector< std::string > eqm_species_name
eqm_species_name[i] = name of the i^th eqm species
std::vector< Real > eqm_species_charge
all quantities have a charge (mineral charge = 0, gas charge = 0, oxide charge = 0)