10 #include "gtest/gtest.h" 20 {
"H2O",
"H+",
"HCO3-",
"O2(aq)",
"Ca++",
">(s)FeOH",
"radius_neg1",
"radius_neg1.5"},
31 TEST(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;
51 TEST(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);
75 TEST(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));
107 TEST(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);
129 TEST(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)
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);
202 TEST(GeochemistryActivityCoefficientsDebyeHuckelTest, waterActivity)
207 25.0,
mgd, std::vector<Real>(8, 1.0), std::vector<Real>(9), std::vector<Real>(3));
TEST(GeochemistryActivityCoefficientsDebyeHuckelTest, notDH)
Test errors when a non-DebyeHuckel database is read.
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 getIonicStrength() const
Return the current value of ionic strength.
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
Real getStoichiometricIonicStrength() const
Return the current value of stoichiometric ionic strength.
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: ...
const GeochemicalDatabaseReader database("database/moose_testdb.json", true, true, false)
Real waterActivity() const override
Computes and returns the activity of water.
Real log10ActCoeffDHBdotAlternative(Real ionic_strength, Real Bdot)
log10(activity coefficient) alternative expression that is sometimes used in conjunction with the Deb...
std::vector< Real > basis_species_radius
all quantities have an ionic radius (Angstrom) for computing activity (mineral radius = 0...
Computes activity coefficients for non-minerals and non-gases (since these species do not have activi...
const ModelGeochemicalDatabase & modelGeochemicalDatabase() const
Return a reference to the ModelGeochemicalDatabase structure.
Constructs and stores a minimal amount of information that is pertinent to the user-defined geochemic...
Calculators to compute ionic strength and stoichiometric ionic strength.
PetscErrorCode PetscInt const PetscInt IS * is
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...
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
const DebyeHuckelParameters & getDebyeHuckel() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< Real > basis_species_charge
all quantities have a charge (mineral charge = 0, gas charge = 0, oxide charge = 0) ...
std::vector< Real > eqm_species_charge
all quantities have a charge (mineral charge = 0, gas charge = 0, oxide charge = 0) ...
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")
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
MooseUnits pow(const MooseUnits &, int)
std::vector< std::string > eqm_species_name
eqm_species_name[i] = name of the i^th eqm species
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 ...
Class for reading geochemical reactions from a MOOSE geochemical database.