Skip to content

Commit

Permalink
Address requested changes
Browse files Browse the repository at this point in the history
Adjust tolerances, wrap long lines, and add document equations for isothermal compressibility and thermal expansion coefficient in PengRobinson and RedlichKwongMFTP
  • Loading branch information
corykinney committed Apr 26, 2023
1 parent 01123ce commit a9b5945
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
14 changes: 12 additions & 2 deletions include/cantera/thermo/PengRobinson.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,20 @@ class PengRobinson : public MixtureFugacityTP

public:

//! Returns the isothermal compressibility. Units: 1/Pa.
//! Returns the isothermal compressibility (\f$\beta_T\f$). Units: 1/Pa.
/*!
* \f[
* \beta_T = \frac{1}{v} \left(\frac{\partial v}{\partial p}\right)_T
* \f]
*/
virtual double isothermalCompressibility() const;

//! Return the volumetric thermal expansion coefficient. Units: 1/K.
//! Return the volumetric thermal expansion coefficient (\f$\alpha_V\f$). Units: 1/K.
/*!
* \f[
* \alpha_V = \frac{1}{v} \left(\frac{\partial v}{\partial T}\right)_p
* \f]
*/
virtual double thermalExpansionCoeff() const;

//! Calculate \f$dp/dV\f$ and \f$dp/dT\f$ at the current conditions
Expand Down
14 changes: 12 additions & 2 deletions include/cantera/thermo/RedlichKwongMFTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,20 @@ class RedlichKwongMFTP : public MixtureFugacityTP
virtual doublereal densSpinodalGas() const;
virtual doublereal dpdVCalc(doublereal TKelvin, doublereal molarVol, doublereal& presCalc) const;

//! Returns the isothermal compressibility. Units: 1/Pa.
//! Returns the isothermal compressibility (\f$\beta_T\f$). Units: 1/Pa.
/*!
* \f[
* \beta_T = \frac{1}{v} \left(\frac{\partial v}{\partial p}\right)_T
* \f]
*/
virtual double isothermalCompressibility() const;

//! Return the volumetric thermal expansion coefficient. Units: 1/K.
//! Return the volumetric thermal expansion coefficient (\f$\alpha_V\f$). Units: 1/K.
/*!
* \f[
* alpha_V = \frac{1}{v} \left(\frac{\partial v}{\partial T}\right)_p
* \f]
*/
virtual double thermalExpansionCoeff() const;

//! Calculate dpdV and dpdT at the current conditions
Expand Down
14 changes: 8 additions & 6 deletions test/thermo/consistency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ class TestConsistency : public testing::TestWithParam<std::tuple<AnyMap, AnyMap>
atol = setup.getDouble("atol", 1e-5);
rtol_fd = setup.getDouble("rtol_fd", 1e-6);
atol_v = setup.getDouble("atol_v", 1e-11);
atol_c = setup.getDouble("atol_c", 1e-8);
atol_e = setup.getDouble("atol_e", 1e-12);
atol_c = setup.getDouble("atol_c", 1e-14);
atol_e = setup.getDouble("atol_e", 1e-18);

phase = cache[key];
phase->setState(state);
Expand Down Expand Up @@ -362,7 +362,7 @@ TEST_P(TestConsistency, betaT_eq_minus_dmv_dP_const_T_div_mv)
double P1 = phase->pressure();
double mv1 = phase->molarVolume();

double P2 = P1 * (1 + 1e-7);
double P2 = P1 * (1 + 1e-6);
phase->setState_TP(T, P2);
double betaT2 = phase->isothermalCompressibility();
double mv2 = phase->molarVolume();
Expand All @@ -371,7 +371,8 @@ TEST_P(TestConsistency, betaT_eq_minus_dmv_dP_const_T_div_mv)
double mv_mid = 0.5 * (mv1 + mv2);
double betaT_fd = -1 / mv_mid * (mv2 - mv1) / (P2 - P1);

EXPECT_NEAR(betaT_fd, betaT_mid, max({rtol_fd * betaT_mid, rtol_fd * betaT_fd, atol_c}));
EXPECT_NEAR(betaT_fd, betaT_mid,
max({rtol_fd * betaT_mid, rtol_fd * betaT_fd, atol_c}));
}

TEST_P(TestConsistency, alphaV_eq_dmv_dT_const_P_div_mv)
Expand All @@ -387,7 +388,7 @@ TEST_P(TestConsistency, alphaV_eq_dmv_dT_const_P_div_mv)
double T1 = phase->temperature();
double mv1 = phase->molarVolume();

double T2 = T1 * (1 + 1e-7);
double T2 = T1 * (1 + 1e-6);
phase->setState_TP(T2, P);
double alphaV2 = phase->thermalExpansionCoeff();
double mv2 = phase->molarVolume();
Expand All @@ -396,7 +397,8 @@ TEST_P(TestConsistency, alphaV_eq_dmv_dT_const_P_div_mv)
double mv_mid = 0.5 * (mv1 + mv2);
double alphaV_fd = 1 / mv_mid * (mv2 - mv1) / (T2 - T1);

EXPECT_NEAR(alphaV_fd, alphaV_mid, max({rtol_fd * alphaV_mid, rtol_fd * alphaV_fd, atol_e}));
EXPECT_NEAR(alphaV_fd, alphaV_mid,
max({rtol_fd * alphaV_mid, rtol_fd * alphaV_fd, atol_e}));
}

// ---------- Tests for consistency of standard state properties ---------------
Expand Down

0 comments on commit a9b5945

Please sign in to comment.