From 27c64b76f80d5368767a0c1d4a74800279e90c52 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Fri, 11 Jan 2019 16:14:29 -0500 Subject: [PATCH] [Thermo] VPStandardStateTP does not use reference thermo objects Since VPStandardStateTP and derived classes do not use the reference state thermodynamic properties in the m_spthermo object, we can just install placeholder objects there, and eliminate the wrapper clas STITbyPDSS. --- include/cantera/thermo/PDSS.h | 12 +--- include/cantera/thermo/PDSS_HKFT.h | 1 - include/cantera/thermo/PDSS_IonsFromNeutral.h | 2 - include/cantera/thermo/PDSS_Water.h | 2 - .../cantera/thermo/SpeciesThermoInterpType.h | 56 ------------------ include/cantera/thermo/VPStandardStateTP.h | 9 +++ include/cantera/thermo/speciesThermoTypes.h | 5 -- src/thermo/SpeciesThermoInterpType.cpp | 58 ------------------- src/thermo/VPStandardStateTP.cpp | 36 +++++++++--- .../LatticeSolid_LiSi/verbose_blessed.txt | 4 +- 10 files changed, 41 insertions(+), 144 deletions(-) diff --git a/include/cantera/thermo/PDSS.h b/include/cantera/thermo/PDSS.h index f5e7e7448..70c024ba3 100644 --- a/include/cantera/thermo/PDSS.h +++ b/include/cantera/thermo/PDSS.h @@ -117,10 +117,7 @@ namespace Cantera * * For cases where the PDSS object doesn't use the MultiSpeciesThermo object, a * dummy SpeciesThermoInterpType object is actually installed into the - * MultiSpeciesThermo object for that species. This dummy - * SpeciesThermoInterpType object is called a STITbyPDSS object. This object - * satisfies calls to MultiSpeciesThermo member functions by actually calling - * the PDSS object at the reference pressure. + * MultiSpeciesThermo object for that species. * * @ingroup thermoprops */ @@ -429,13 +426,6 @@ public: m_spthermo = stit; } - //! Returns 'true' if this object should be used in an STITbyPDSS object - //! in the phase's reference thermo manager, or 'false' if a separate - //! SpeciesThermoInterpType should be constructed - virtual bool useSTITbyPDSS() const { - return false; - } - //! Set the parent VPStandardStateTP object of this PDSS object /*! * This information is only used by certain PDSS subclasses diff --git a/include/cantera/thermo/PDSS_HKFT.h b/include/cantera/thermo/PDSS_HKFT.h index 91decd014..9bc4cadf1 100644 --- a/include/cantera/thermo/PDSS_HKFT.h +++ b/include/cantera/thermo/PDSS_HKFT.h @@ -84,7 +84,6 @@ public: m_spindex = k; } - virtual bool useSTITbyPDSS() const { return true; } virtual void initThermo(); //! Set enthalpy of formation at Pr, Tr [J/kmol] diff --git a/include/cantera/thermo/PDSS_IonsFromNeutral.h b/include/cantera/thermo/PDSS_IonsFromNeutral.h index e60b8636f..9fd2188fc 100644 --- a/include/cantera/thermo/PDSS_IonsFromNeutral.h +++ b/include/cantera/thermo/PDSS_IonsFromNeutral.h @@ -88,8 +88,6 @@ public: void setParent(VPStandardStateTP* phase, size_t k); - virtual bool useSTITbyPDSS() const { return true; } - void setNeutralSpeciesMultiplier(const std::string& species, double mult); void setSpecialSpecies(bool special=true); void setParametersFromXML(const XML_Node& speciesNode); diff --git a/include/cantera/thermo/PDSS_Water.h b/include/cantera/thermo/PDSS_Water.h index 9c79f04b0..3ce2ae051 100644 --- a/include/cantera/thermo/PDSS_Water.h +++ b/include/cantera/thermo/PDSS_Water.h @@ -150,8 +150,6 @@ public: //! @} - virtual bool useSTITbyPDSS() const { return true; } - private: //! Pointer to the WaterPropsIAPWS object, which does the actual calculations //! for the real equation of state diff --git a/include/cantera/thermo/SpeciesThermoInterpType.h b/include/cantera/thermo/SpeciesThermoInterpType.h index 0eb6cdcd9..329675c73 100644 --- a/include/cantera/thermo/SpeciesThermoInterpType.h +++ b/include/cantera/thermo/SpeciesThermoInterpType.h @@ -88,12 +88,6 @@ class PDSS; * - This is a multiple zone model, consisting of the 9 * coefficient NASA Polynomial format in each zone. * . - * - STITbyPDSS in file SpeciesThermoInterpType.h - * - This is an object that calculates reference state thermodynamic - * functions by relying on a pressure dependent - * standard state object (i.e., a PDSS object) to calculate - * the thermodynamic functions. - * * The most important member function for the SpeciesThermoInterpType class is * the member function SpeciesThermoInterpType::updatePropertiesTemp(). The * function calculates the values of Cp, H, and S for the specific species @@ -261,56 +255,6 @@ protected: doublereal m_Pref; }; -//! Class for the thermodynamic manager for an individual species' reference -//! state which uses the PDSS base class to satisfy the requests. -/*! - * This class is a pass-through class for handling thermodynamics calls for - * reference state thermo to an pressure dependent standard state (PDSS) class. - * For some situations, it makes no sense to have a reference state at all. One - * example of this is the real water standard state. - * - * What this class does is just to pass through the calls for thermo at (T, p0) - * to the PDSS class, which evaluates the calls at (T, p0). - * - * @ingroup spthermo - */ -class STITbyPDSS : public SpeciesThermoInterpType -{ -public: - //! Main Constructor - /*! - * @param PDSS_ptr Pointer to the PDSS object that handles calls for - * this object - */ - explicit STITbyPDSS(PDSS* PDSS_ptr); - - virtual doublereal minTemp() const; - virtual doublereal maxTemp() const; - virtual doublereal refPressure() const; - virtual int reportType() const; - - virtual void updateProperties(const doublereal* tempPoly, - doublereal* cp_R, doublereal* h_RT, - doublereal* s_R) const; - - virtual void updatePropertiesTemp(const doublereal temp, - doublereal* cp_R, - doublereal* h_RT, - doublereal* s_R) const; - - virtual void reportParameters(size_t& index, int& type, - doublereal& minTemp, doublereal& maxTemp, - doublereal& refPressure, - doublereal* const coeffs) const; - -private: - //! Pointer to the PDSS object that handles calls for this object - /*! - * This object is not owned by the current one. - */ - PDSS* m_PDSS_ptr; -}; - } #endif diff --git a/include/cantera/thermo/VPStandardStateTP.h b/include/cantera/thermo/VPStandardStateTP.h index 0ae037783..3dc5683c5 100644 --- a/include/cantera/thermo/VPStandardStateTP.h +++ b/include/cantera/thermo/VPStandardStateTP.h @@ -160,6 +160,9 @@ public: */ virtual void updateStandardStateThermo() const; + virtual double minTemp(size_t k=npos) const; + virtual double maxTemp(size_t k=npos) const; + //@} protected: @@ -265,6 +268,12 @@ protected: */ doublereal m_Pcurrent; + //! The minimum temperature at which data for all species is valid + double m_minTemp; + + //! The maximum temperature at which data for all species is valid + double m_maxTemp; + //! The last temperature at which the standard statethermodynamic properties //! were calculated at. mutable doublereal m_Tlast_ss; diff --git a/include/cantera/thermo/speciesThermoTypes.h b/include/cantera/thermo/speciesThermoTypes.h index f55b6b659..288dbd70e 100644 --- a/include/cantera/thermo/speciesThermoTypes.h +++ b/include/cantera/thermo/speciesThermoTypes.h @@ -59,9 +59,4 @@ //! This is implemented in the class Nasa9PolyMultiTempRegion in Nasa9Poly1MultiTempRegion #define NASA9MULTITEMP 513 -//! Type of reference state thermo which is a wrapper around a pressure dependent -//! standard state object. Basically, the reference state pressure isn't special. -//! A general object is called with the pressure set at the reference state. -#define PDSS_TYPE 37 - #endif diff --git a/src/thermo/SpeciesThermoInterpType.cpp b/src/thermo/SpeciesThermoInterpType.cpp index e1f15a984..c7407e9f0 100644 --- a/src/thermo/SpeciesThermoInterpType.cpp +++ b/src/thermo/SpeciesThermoInterpType.cpp @@ -62,62 +62,4 @@ void SpeciesThermoInterpType::modifyOneHf298(const size_t k, "Not implemented"); } -//============================================================================= - -STITbyPDSS::STITbyPDSS(PDSS* PDSS_ptr) : - m_PDSS_ptr(PDSS_ptr) -{ -} - -doublereal STITbyPDSS::minTemp() const -{ - return m_PDSS_ptr->minTemp(); -} - -doublereal STITbyPDSS::maxTemp() const -{ - return m_PDSS_ptr->maxTemp(); -} - -doublereal STITbyPDSS::refPressure() const -{ - return m_PDSS_ptr->refPressure(); -} - -int STITbyPDSS::reportType() const -{ - return PDSS_TYPE; -} - -void STITbyPDSS::updateProperties(const doublereal* tempPoly, - doublereal* cp_R, doublereal* h_RT, - doublereal* s_R) const -{ - doublereal T = tempPoly[0]; - updatePropertiesTemp(T, cp_R, h_RT, s_R); -} - -void STITbyPDSS::updatePropertiesTemp(const doublereal temp, - doublereal* cp_R, - doublereal* h_RT, - doublereal* s_R) const -{ - m_PDSS_ptr->setTemperature(temp); - *h_RT = m_PDSS_ptr->enthalpy_RT_ref(); - *cp_R = m_PDSS_ptr->cp_R_ref(); - *s_R = m_PDSS_ptr->entropy_R_ref(); -} - -void STITbyPDSS::reportParameters(size_t& index, int& type, - doublereal& minTemp, doublereal& maxTemp, - doublereal& refPressure, - doublereal* const coeffs) const -{ - index = 0; - type = PDSS_TYPE; - minTemp = m_PDSS_ptr->minTemp(); - maxTemp = m_PDSS_ptr->maxTemp(); - refPressure = m_PDSS_ptr->refPressure(); -} - } diff --git a/src/thermo/VPStandardStateTP.cpp b/src/thermo/VPStandardStateTP.cpp index ba630b8aa..d6bfa61dd 100644 --- a/src/thermo/VPStandardStateTP.cpp +++ b/src/thermo/VPStandardStateTP.cpp @@ -25,6 +25,8 @@ namespace Cantera VPStandardStateTP::VPStandardStateTP() : m_Pcurrent(OneAtm), + m_minTemp(0.0), + m_maxTemp(BigNumber), m_Tlast_ss(-1.0), m_Plast_ss(-1.0) { @@ -170,6 +172,9 @@ bool VPStandardStateTP::addSpecies(shared_ptr spec) if (!added) { return false; } + + // VPStandardState does not use m_spthermo - install a dummy object + m_spthermo.install_STIT(m_kk-1, make_shared()); m_h0_RT.push_back(0.0); m_cp0_R.push_back(0.0); m_g0_RT.push_back(0.0); @@ -225,14 +230,12 @@ void VPStandardStateTP::installPDSS(size_t k, unique_ptr&& pdss) { pdss->setParent(this, k); pdss->setMolecularWeight(molecularWeight(k)); - if (pdss->useSTITbyPDSS()) { - m_spthermo.install_STIT(k, make_shared(pdss.get())); - } else { - auto stit = species(k)->thermo; - stit->validate(speciesName(k)); - pdss->setReferenceThermo(stit); - m_spthermo.install_STIT(k, stit); + if (species(k)->thermo) { + pdss->setReferenceThermo(species(k)->thermo); + species(k)->thermo->validate(speciesName(k)); } + m_minTemp = std::max(m_minTemp, pdss->minTemp()); + m_maxTemp = std::min(m_maxTemp, pdss->maxTemp()); if (m_PDSS_storage.size() < k+1) { m_PDSS_storage.resize(k+1); @@ -289,4 +292,23 @@ void VPStandardStateTP::updateStandardStateThermo() const _updateStandardStateThermo(); } } + +double VPStandardStateTP::minTemp(size_t k) const +{ + if (k == npos) { + return m_minTemp; + } else { + return m_PDSS_storage.at(k)->minTemp(); + } +} + +double VPStandardStateTP::maxTemp(size_t k) const +{ + if (k == npos) { + return m_maxTemp; + } else { + return m_PDSS_storage.at(k)->maxTemp(); + } +} + } diff --git a/test_problems/VCSnonideal/LatticeSolid_LiSi/verbose_blessed.txt b/test_problems/VCSnonideal/LatticeSolid_LiSi/verbose_blessed.txt index a640bb11b..2fa5bf2d1 100644 --- a/test_problems/VCSnonideal/LatticeSolid_LiSi/verbose_blessed.txt +++ b/test_problems/VCSnonideal/LatticeSolid_LiSi/verbose_blessed.txt @@ -4,8 +4,8 @@ dg_corr = -1.57754e+08 um_li_chempot = -1.65555e+08 Trying VCS equilibrium solver Unknown Cantera EOS to VCSnonideal: 'Margules' -vcs_Cantera_convert: Species Type 8 not known -vcs_Cantera_convert: Species Type 8 not known +vcs_Cantera_convert: Species Type 0 not known +vcs_Cantera_convert: Species Type 0 not known Unknown Cantera EOS to VCSnonideal: 'LatticeSolid' vcs_Cantera_convert: Species Type 8 not known vcs_Cantera_convert: Species Type 1 not known