Skip to content

Commit

Permalink
Add consistency tests for BinarySolutionTabulatedThermo
Browse files Browse the repository at this point in the history
  • Loading branch information
speth authored and ischoegl committed Jun 10, 2022
1 parent 11407e4 commit 948ffed
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
22 changes: 22 additions & 0 deletions test/data/consistency-cases.yaml
Expand Up @@ -63,3 +63,25 @@ ideal-condensed-2:
- {T: 300, P: 0.1 atm, X: {sp1: 1.0}}
- {T: 400, P: 0.1 atm, X: {sp1: 0.01, sp2: 0.03, sp3: 0.94}}
- {T: 500, P: 2 bar, X: {sp1: 0.1, sp2: 0.89, sp3: 0.01}}

binary-solution-tabulated:
setup:
file: BinarySolutionTabulatedThermo.yaml
phase: anode
known-failures:
hk_eq_uk_plus_P_times_vk: getPartialMolarIntEnergies is not implemented
u_eq_sum_uk_Xk: getPartialMolarIntEnergies is not implemented
g_eq_h_minus_Ts: "Inconsistent results when P != 1 atm. See GitHub Issue #1301"
g_eq_sum_gk_Xk: "Inconsistent results when P != 1 atm. See GitHub Issue #1301"
v_eq_sum_vk_Xk: "Inconsistent results. See GitHub Issue #1302"
h_eq_sum_hk_Xk: "Inconsistent results. See GitHub Issue #1302"
s_eq_sum_sk_Xk: "Problems near composition limit. See GitHub Issue #1303"
gk_eq_hk_minus_T_times_sk: "Problems near composition limit. See GitHub Issue #1303"
states:
- {T: 300, P: 1 atm, X: {"Li[anode]": 0.3, "V[anode]": 0.7}}
- {T: 320, P: 1 atm, X: {"Li[anode]": 0.3, "V[anode]": 0.7}}
- {T: 340, P: 10 atm, X: {"Li[anode]": 0.6, "V[anode]": 0.4}}
- {T: 300, P: 5 atm, X: {"Li[anode]": 0.0, "V[anode]": 1.0}}
- {T: 300, P: 1 atm, X: {"Li[anode]": 1.0, "V[anode]": 0.0}}
- {T: 300, P: 5 atm, X: {"Li[anode]": 1.0e-10, "V[anode]": 1.0}}
- {T: 300, P: 1 atm, X: {"Li[anode]": 1.0, "V[anode]": 1.0e-10}}
11 changes: 9 additions & 2 deletions test/thermo/consistency.cpp
Expand Up @@ -44,6 +44,7 @@ class TestConsistency : public testing::TestWithParam<std::tuple<AnyMap, AnyMap>
cache[key].reset(newPhase(key.first, key.second));
}
atol = setup.getDouble("atol", 1e-5);
atol_v = setup.getDouble("atol_v", 1e-11);

phase = cache[key];
phase->setState(state);
Expand All @@ -70,7 +71,7 @@ class TestConsistency : public testing::TestWithParam<std::tuple<AnyMap, AnyMap>
shared_ptr<ThermoPhase> phase;
size_t nsp;
double T, p;
double atol;
double atol, atol_v;
};

map<pair<string, string>, shared_ptr<ThermoPhase>> TestConsistency::cache = {};
Expand Down Expand Up @@ -143,7 +144,7 @@ TEST_P(TestConsistency, v_eq_sum_vk_Xk)
{
vector_fp vk(nsp);
phase->getPartialMolarVolumes(vk.data());
EXPECT_NEAR(phase->molarVolume(), phase->mean_X(vk), atol);
EXPECT_NEAR(phase->molarVolume(), phase->mean_X(vk), atol_v);
}

INSTANTIATE_TEST_SUITE_P(IdealGas, TestConsistency,
Expand Down Expand Up @@ -182,4 +183,10 @@ INSTANTIATE_TEST_SUITE_P(IdealSolidSolnPhase2, TestConsistency,
testing::ValuesIn(getStates("ideal-condensed-2")))
);

INSTANTIATE_TEST_SUITE_P(BinarySolutionTabulated, TestConsistency,
testing::Combine(
testing::Values(getSetup("binary-solution-tabulated")),
testing::ValuesIn(getStates("binary-solution-tabulated")))
);

}

0 comments on commit 948ffed

Please sign in to comment.