Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perform a comprehensive set of thermodynamic consistency tests for all thermo models #1299

Merged
merged 40 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f11d463
[Test] Add extensible test suite for thermo consistency
speth May 30, 2022
4631d39
[Test] Add tests for partial molar properties
speth May 30, 2022
a50564e
Show more info about failing consistency tests
speth May 30, 2022
62b824a
[Thermo] Fix calculation of IdealMolalSoln::intEnergy_mole
speth May 31, 2022
a522e96
Handle known failures in thermo consistency tests
speth May 31, 2022
262c55f
Fix typo in binary-solution-tabulated YAML docs
speth May 31, 2022
6ce95df
Add consistency tests for IdealSolidSolnPhase
speth May 31, 2022
3f2b491
Add consistency tests for BinarySolutionTabulatedThermo
speth May 31, 2022
c7728b8
Make MetalPhase::intEnergy_mole thermodynamically consistent
speth Jun 1, 2022
10bc5f9
Add consistency tests for MetalPhase
speth Jun 1, 2022
e2acbf4
Add consistency tests for PureFluidPhase
speth Jun 1, 2022
3cc2f11
Add consistency tests for PlasmaPhase
speth Jun 1, 2022
1aa81d4
Add consistency test for cp = dh/dT at constant P
speth Jun 2, 2022
3619153
Add consistency test for cv = du/dT at constant V
speth Jun 2, 2022
72a0b51
Add consistency test for partial molar cp
speth Jun 2, 2022
d16f35a
Add consistency tests comparing dS/dT to cp and cv
speth Jun 3, 2022
802a925
Add consistency tests for DebyeHuckel
speth Jun 3, 2022
b830b81
[CI] Set Visual Studio 2019 as minimum tested version
speth Jun 3, 2022
0ac735d
Update submodule to Googletest 1.11.0
speth May 31, 2022
695b16e
Make error output from consistency tests more compact
speth Jun 3, 2022
cd8e132
Add consistency tests for Margules
speth Jun 3, 2022
36eae91
Add consistency tests for standard state properties
speth Jun 3, 2022
56896b4
Add consistency tests for LatticePhase and LatticeSolidPhase
speth Jun 3, 2022
4bec445
Add accessor for method raising CanteraError
speth Jun 3, 2022
d644f01
Automatically skip consistency tests of unimplemented array methods
speth Jun 3, 2022
0d3504a
Add consistency tests for activities and activity coeffs
speth Jun 4, 2022
e788862
Add consistency tests for StoichSubstance
speth Jun 4, 2022
a8d9f0f
Add consistency tests for SurfPhase and EdgePhase
speth Jun 4, 2022
b8a3bfc
Add consistency tests for WaterSSTP
speth Jun 4, 2022
e3f4fdf
Add consistency tests for Maxwell relations
speth Jun 5, 2022
9b8853e
Add consistency test for ideal-solution-VPSS model
speth Jun 6, 2022
7347866
Update naming/formatting in thermo consistency tests
speth Jun 6, 2022
632c1ce
Fix reference thermo in two-phase region for PureFluidPhase
speth Jun 6, 2022
20ca696
Add consistency tests for reference state properties
speth Jun 6, 2022
634da39
Add consistency tests for Redlich-Kister phase
speth Jun 6, 2022
ef17e1f
Add consistency tests for Maskell phase
speth Jun 6, 2022
d9b2ef4
Add consistency tests for IonsFromNeutralMolecule
speth Jun 7, 2022
7390d3b
Add consistency tests for HMW electrolyte phase
speth Jun 7, 2022
9d090ab
Document consistency testing infrastructure
speth Jun 7, 2022
107bd1e
Remove redundant thermo consistency tests
speth Jun 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ jobs:
BOOST_URL: https://boostorg.jfrog.io/artifactory/main/release/1.78.0/source/boost_1_78_0.7z
strategy:
matrix:
vs-toolset: ['14.0', '14.2']
vs-toolset: ['14.2']
python-version: [ "3.7", "3.9", "3.10" ]
fail-fast: false
steps:
Expand Down
3 changes: 1 addition & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ windows_options = [
Option(
"msvc_version",
"""Version of Visual Studio to use. The default is the newest
installed version. Specify '12.0' for Visual Studio 2013, '14.0' for
Visual Studio 2015, '14.1' ('14.1x') Visual Studio 2017, '14.2'
installed version. Specify '14.1' ('14.1x') Visual Studio 2017, '14.2'
('14.2x') for Visual Studio 2019, or '14.3' ('14.3x') for
Visual Studio 2022. For version numbers in parentheses,
'x' is a placeholder for a minor version number. Windows MSVC only.""",
Expand Down
2 changes: 1 addition & 1 deletion doc/sphinx/yaml/phases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ Phase thermodynamic models
A phase implementing tabulated standard state thermodynamics for one species in
a binary solution, as `described here <https://cantera.org/documentation/dev/doxygen/html/de/ddf/classCantera_1_1BinarySolutionTabulatedThermo.html#details>`__.

Includes the fields of :ref:`sec-yaml-ideal-molal-solution`, plus:
Includes the fields of :ref:`sec-yaml-ideal-condensed`, plus:

``tabulated-species``
The name of the species to which the tabulated enthalpy and entropy is
Expand Down
2 changes: 1 addition & 1 deletion ext/googletest
Submodule googletest updated 200 files
3 changes: 3 additions & 0 deletions include/cantera/base/ctexceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ class CanteraError : public std::exception
//! Method overridden by derived classes to format the error message
virtual std::string getMessage() const;

//! Get the name of the method that threw the exception
virtual std::string getMethod() const;

//! Method overridden by derived classes to indicate their type
virtual std::string getClass() const {
return "CanteraError";
Expand Down
13 changes: 13 additions & 0 deletions include/cantera/thermo/IdealMolalSoln.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,19 @@ class IdealMolalSoln : public MolalityVPSSTP
*/
virtual void getPartialMolarEnthalpies(doublereal* hbar) const;

//! Returns an array of partial molar internal energies for the species in the
//! mixture.
/*!
* Units (J/kmol). For this phase, the partial molar internal energies are equal to
* the species standard state internal energies (which are equal to the reference
* state internal energies)
* \f[
* \bar u_k(T,P) = \hat u^{ref}_k(T)
* \f]
* @param hbar Output vector of partial molar internal energies, length #m_kk
*/
virtual void getPartialMolarIntEnergies(doublereal* hbar) const;

//! Returns an array of partial molar entropies of the species in the
//! solution. Units: J/kmol.
/*!
Expand Down
2 changes: 1 addition & 1 deletion include/cantera/thermo/MetalPhase.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class MetalPhase : public ThermoPhase
return 0.0;
}
virtual doublereal intEnergy_mole() const {
return 0.0;
return - pressure() * molarVolume();
}
virtual doublereal entropy_mole() const {
return 0.0;
Expand Down
5 changes: 5 additions & 0 deletions src/base/ctexceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ std::string CanteraError::getMessage() const
return msg_;
}

std::string CanteraError::getMethod() const
{
return procedure_;
}

std::string ArraySizeError::getMessage() const
{
return fmt::format("Array size ({}) too small. Must be at least {}.",
Expand Down
10 changes: 9 additions & 1 deletion src/thermo/IdealMolalSoln.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ doublereal IdealMolalSoln::enthalpy_mole() const

doublereal IdealMolalSoln::intEnergy_mole() const
{
getPartialMolarEnthalpies(m_tmpV.data());
getPartialMolarIntEnergies(m_tmpV.data());
return mean_X(m_tmpV);
}

Expand Down Expand Up @@ -248,6 +248,14 @@ void IdealMolalSoln::getPartialMolarEnthalpies(doublereal* hbar) const
}
}

void IdealMolalSoln::getPartialMolarIntEnergies(double* ubar) const
{
getIntEnergy_RT(ubar);
for (size_t k = 0; k < m_kk; k++) {
ubar[k] *= RT();
}
}

void IdealMolalSoln::getPartialMolarEntropies(doublereal* sbar) const
{
getEntropy_R(sbar);
Expand Down
12 changes: 6 additions & 6 deletions src/thermo/PureFluidPhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,25 +241,25 @@ void PureFluidPhase::getGibbs_RT(doublereal* grt) const

void PureFluidPhase::getEnthalpy_RT_ref(doublereal* hrt) const
{
double psave = pressure();
double rhoSave = density();
double t = temperature();
double plow = 1.0E-8;
Set(tpx::PropertyPair::TP, t, plow);
getEnthalpy_RT(hrt);
Set(tpx::PropertyPair::TP, t, psave);
Set(tpx::PropertyPair::TV, t, 1 / rhoSave);

}

void PureFluidPhase::getGibbs_RT_ref(doublereal* grt) const
{
double psave = pressure();
double rhoSave = density();
double t = temperature();
double pref = refPressure();
double plow = 1.0E-8;
Set(tpx::PropertyPair::TP, t, plow);
getGibbs_RT(grt);
grt[0] += log(pref/plow);
Set(tpx::PropertyPair::TP, t, psave);
Set(tpx::PropertyPair::TV, t, 1 / rhoSave);
}

void PureFluidPhase::getGibbs_ref(doublereal* g) const
Expand All @@ -270,14 +270,14 @@ void PureFluidPhase::getGibbs_ref(doublereal* g) const

void PureFluidPhase::getEntropy_R_ref(doublereal* er) const
{
double psave = pressure();
double rhoSave = density();
double t = temperature();
double pref = refPressure();
double plow = 1.0E-8;
Set(tpx::PropertyPair::TP, t, plow);
getEntropy_R(er);
er[0] -= log(pref/plow);
Set(tpx::PropertyPair::TP, t, psave);
Set(tpx::PropertyPair::TV, t, 1 / rhoSave);
}

doublereal PureFluidPhase::critTemperature() const
Expand Down
Loading