Skip to content

Commit

Permalink
Add consistency test for cv = du/dT at constant V
Browse files Browse the repository at this point in the history
  • Loading branch information
speth authored and ischoegl committed Jun 10, 2022
1 parent bfb11e6 commit ad00983
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/data/consistency-cases.yaml
Expand Up @@ -32,6 +32,7 @@ ideal-molal-solution:
"Implementations of g and s are inconsistent. See GitHub Issue #1300"
gk_eq_hk_minus_T_times_sk:
"Implementations of g and s are inconsistent. See GitHub Issue #1300"
cv_eq_dudT: cv not implemented
states:
- {T: 300, P: 101325, molalities: {CH4(aq): 0.01, H2S(aq): 0.03, CO2(aq): 0.1}}
- {T: 300, P: 2 atm, molalities: {CH4(aq): 0.1, H2S(aq): 0.01, CO2(aq): 0.1}}
Expand Down Expand Up @@ -109,6 +110,8 @@ nitrogen-purefluid:
file: liquidvapor.yaml
phase: nitrogen
rtol_fd: 1e-5
known-failures:
cv_eq_dudT/3: cv not defined in two-phase region
states:
- {T: 300, P: 1 atm}
- {T: 70, P: 1 atm}
Expand All @@ -121,6 +124,7 @@ plasma:
phase: discretized-electron-energy-plasma
known-failures:
cp_eq_dhdT/1: Test does not account for distinct electron temperature
cv_eq_dudT/1: Test does not account for distinct electron temperature
states:
- {T: 300, P: 1 atm, X: {O2: 1.0, O2-: 1e-5, E: 1e-5}}
- {T: 300, P: 1 atm, X: {E: 1.0}}
Expand Down
18 changes: 18 additions & 0 deletions test/thermo/consistency.cpp
Expand Up @@ -163,6 +163,24 @@ TEST_P(TestConsistency, cp_eq_dhdT)
EXPECT_NEAR(cp_fd, cp_mid, max({rtol_fd * cp_mid, rtol_fd * cp_fd, atol}));
}

TEST_P(TestConsistency, cv_eq_dudT)
{
double u1 = phase->intEnergy_mole();
double cv1 = phase->cv_mole();
double T1 = phase->temperature();
double dT = 1e-5 * phase->temperature();
if (phase->isCompressible()) {
phase->setState_TR(T1 + dT, phase->density());
} else {
phase->setTemperature(T1 + dT);
}
double u2 = phase->intEnergy_mole();
double cv2 = phase->cv_mole();
double cv_mid = 0.5 * (cv1 + cv2);
double cv_fd = (u2 - u1)/dT;
EXPECT_NEAR(cv_fd, cv_mid, max({rtol_fd * cv_mid, rtol_fd * cv_fd, atol}));
}

INSTANTIATE_TEST_SUITE_P(IdealGas, TestConsistency,
testing::Combine(
testing::Values(getSetup("ideal-gas-h2o2")),
Expand Down

0 comments on commit ad00983

Please sign in to comment.