From 6a51eb88dc9001c9f258f6aeac2529ebabd3dadc Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Sat, 8 Mar 2014 21:46:58 +0000 Subject: [PATCH] [Thermo] Move modifyOneHf298SS and m_tlast to ThermoPhase This eliminates many duplicate implementations of this function and declarations of this variable. --- include/cantera/thermo/ConstDensityThermo.h | 3 --- include/cantera/thermo/IdealGasPhase.h | 7 ------- include/cantera/thermo/IdealSolidSolnPhase.h | 6 ------ include/cantera/thermo/LatticePhase.h | 16 ---------------- include/cantera/thermo/LatticeSolidPhase.h | 3 --- include/cantera/thermo/MaskellSolidSolnPhase.h | 6 ------ include/cantera/thermo/SingleSpeciesTP.h | 16 ---------------- include/cantera/thermo/StoichSubstance.h | 6 ------ include/cantera/thermo/SurfPhase.h | 16 ---------------- include/cantera/thermo/ThermoPhase.h | 4 ++++ src/thermo/ConstDensityThermo.cpp | 4 +--- src/thermo/IdealGasPhase.cpp | 5 ----- src/thermo/IdealSolidSolnPhase.cpp | 10 +++------- src/thermo/LatticePhase.cpp | 3 --- src/thermo/LatticeSolidPhase.cpp | 2 -- src/thermo/MaskellSolidSolnPhase.cpp | 2 -- src/thermo/SingleSpeciesTP.cpp | 7 ++----- src/thermo/StoichSubstance.cpp | 7 ++----- src/thermo/SurfPhase.cpp | 13 ++++--------- src/thermo/ThermoPhase.cpp | 4 +++- 20 files changed, 19 insertions(+), 121 deletions(-) diff --git a/include/cantera/thermo/ConstDensityThermo.h b/include/cantera/thermo/ConstDensityThermo.h index b6971c60d..b1f81b246 100644 --- a/include/cantera/thermo/ConstDensityThermo.h +++ b/include/cantera/thermo/ConstDensityThermo.h @@ -324,9 +324,6 @@ public: virtual void setParametersFromXML(const XML_Node& eosdata); protected: - //! last value of the temperature processed by reference state - mutable doublereal m_tlast; - //! Temporary storage for dimensionless reference state enthalpies mutable vector_fp m_h0_RT; diff --git a/include/cantera/thermo/IdealGasPhase.h b/include/cantera/thermo/IdealGasPhase.h index c6b91b48a..62472c78c 100644 --- a/include/cantera/thermo/IdealGasPhase.h +++ b/include/cantera/thermo/IdealGasPhase.h @@ -768,10 +768,6 @@ public: */ virtual void getEnthalpy_RT_ref(doublereal* hrt) const; - virtual void modifyOneHf298SS(const size_t k, const doublereal Hf298New) { - m_spthermo->modifyOneHf298(k, Hf298New); - m_tlast += 0.0001234; - } //! Returns the vector of nondimensional //! Gibbs Free Energies of the reference state at the current temperature //! of the solution and the reference pressure for the species. @@ -920,9 +916,6 @@ protected: */ doublereal m_p0; - //! last value of the temperature processed by reference state - mutable doublereal m_tlast; - //! Temporary storage for log of p/RT mutable doublereal m_logc0; diff --git a/include/cantera/thermo/IdealSolidSolnPhase.h b/include/cantera/thermo/IdealSolidSolnPhase.h index b9487dc92..96cfa1420 100644 --- a/include/cantera/thermo/IdealSolidSolnPhase.h +++ b/include/cantera/thermo/IdealSolidSolnPhase.h @@ -907,12 +907,6 @@ protected: */ vector_fp m_speciesMolarVolume; - /** - * Value of the temperature at which the thermodynamics functions - * for the reference state of the species were last evaluated. - */ - mutable doublereal m_tlast; - //! Vector containing the species reference enthalpies at T = m_tlast mutable vector_fp m_h0_RT; diff --git a/include/cantera/thermo/LatticePhase.h b/include/cantera/thermo/LatticePhase.h index 0ef4a3d23..28426f803 100644 --- a/include/cantera/thermo/LatticePhase.h +++ b/include/cantera/thermo/LatticePhase.h @@ -733,19 +733,6 @@ public: /// @name Thermodynamic Values for the Species Reference States //@{ - //! Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1) - /*! - * The 298K heat of formation is defined as the enthalpy change to create the standard state - * of the species from its constituent elements in their standard states at 298 K and 1 bar. - * - * @param k Species k - * @param Hf298New Specify the new value of the Heat of Formation at 298K and 1 bar - */ - virtual void modifyOneHf298SS(const size_t k, const doublereal Hf298New) { - m_spthermo->modifyOneHf298(k, Hf298New); - m_tlast += 0.0001234; - } - //! Returns the vector of nondimensional //! Enthalpies of the reference state at the current temperature //! of the solution and the reference pressure for the phase. @@ -908,9 +895,6 @@ protected: */ doublereal m_Pcurrent; - //! Current value of the temperature (Kelvin) - mutable doublereal m_tlast; - //! Reference state enthalpies / RT mutable vector_fp m_h0_RT; diff --git a/include/cantera/thermo/LatticeSolidPhase.h b/include/cantera/thermo/LatticeSolidPhase.h index ce7dd21fd..de79d6a4d 100644 --- a/include/cantera/thermo/LatticeSolidPhase.h +++ b/include/cantera/thermo/LatticeSolidPhase.h @@ -644,9 +644,6 @@ private: doublereal err(const std::string& msg) const; protected: - //! Last temperature at which the reference thermo was calculated - mutable doublereal m_tlast; - //! Current value of the pressure doublereal m_press; diff --git a/include/cantera/thermo/MaskellSolidSolnPhase.h b/include/cantera/thermo/MaskellSolidSolnPhase.h index ee0ddf7f9..c59a21ce9 100644 --- a/include/cantera/thermo/MaskellSolidSolnPhase.h +++ b/include/cantera/thermo/MaskellSolidSolnPhase.h @@ -296,12 +296,6 @@ protected: */ void _updateThermo() const; - /** - * Value of the temperature at which the thermodynamics functions - * for the reference state of the species were last evaluated. - */ - mutable doublereal m_tlast; - //! Vector containing the species reference enthalpies at T = m_tlast mutable vector_fp m_h0_RT; diff --git a/include/cantera/thermo/SingleSpeciesTP.h b/include/cantera/thermo/SingleSpeciesTP.h index bd0c89aa3..c28655dea 100644 --- a/include/cantera/thermo/SingleSpeciesTP.h +++ b/include/cantera/thermo/SingleSpeciesTP.h @@ -326,19 +326,6 @@ public: /// equation of state. //@{ - //! Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1) - /*! - * The 298K heat of formation is defined as the enthalpy change to create the standard state - * of the species from its constituent elements in their standard states at 298 K and 1 bar. - * - * @param k Species k - * @param Hf298New Specify the new value of the Heat of Formation at 298K and 1 bar - */ - virtual void modifyOneHf298SS(const size_t k, const doublereal Hf298New) { - m_spthermo->modifyOneHf298(k, Hf298New); - m_tlast += 0.0001234; - } - /*! * Returns the vector of nondimensional * enthalpies of the reference state at the current temperature @@ -647,9 +634,6 @@ protected: */ doublereal m_p0; - //! Last temperature used to evaluate the thermodynamic polynomial. - mutable doublereal m_tlast; - //! Dimensionless enthalpy at the (mtlast, m_p0) mutable vector_fp m_h0_RT; //! Dimensionless heat capacity at the (mtlast, m_p0) diff --git a/include/cantera/thermo/StoichSubstance.h b/include/cantera/thermo/StoichSubstance.h index aa8a7ca29..116c93b3e 100644 --- a/include/cantera/thermo/StoichSubstance.h +++ b/include/cantera/thermo/StoichSubstance.h @@ -297,11 +297,6 @@ public: */ virtual void getEnthalpy_RT_ref(doublereal* hrt) const; - virtual void modifyOneHf298SS(const size_t k, const doublereal Hf298New) { - m_spthermo->modifyOneHf298(k, Hf298New); - m_tlast += 0.0001234; - } - /** * Returns the vector of nondimensional * enthalpies of the reference state at the current temperature @@ -362,7 +357,6 @@ protected: doublereal m_press; doublereal m_p0; - mutable doublereal m_tlast; mutable vector_fp m_h0_RT; mutable vector_fp m_cp0_R; mutable vector_fp m_s0_R; diff --git a/include/cantera/thermo/SurfPhase.h b/include/cantera/thermo/SurfPhase.h index 3894f791b..22b43a5f7 100644 --- a/include/cantera/thermo/SurfPhase.h +++ b/include/cantera/thermo/SurfPhase.h @@ -511,19 +511,6 @@ public: */ virtual void getEnthalpy_RT_ref(doublereal* hrt) const; - //! Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1) - /*! - * The 298K heat of formation is defined as the enthalpy change to create the standard state - * of the species from its constituent elements in their standard states at 298 K and 1 bar. - * - * @param k Species k - * @param Hf298New Specify the new value of the Heat of Formation at 298K and 1 bar - */ - virtual void modifyOneHf298SS(const size_t k, const doublereal Hf298New) { - m_spthermo->modifyOneHf298(k, Hf298New); - m_tlast += 0.0001234; - } - //! Returns the vector of nondimensional //! entropies of the reference state at the current temperature //! of the solution and the reference pressure for each species. @@ -600,9 +587,6 @@ protected: //! Current value of the pressure (Pa) doublereal m_press; - //! Current value of the temperature (Kelvin) - mutable doublereal m_tlast; - //! Temporary storage for the reference state enthalpies mutable vector_fp m_h0; diff --git a/include/cantera/thermo/ThermoPhase.h b/include/cantera/thermo/ThermoPhase.h index a163a682e..baa56d137 100644 --- a/include/cantera/thermo/ThermoPhase.h +++ b/include/cantera/thermo/ThermoPhase.h @@ -191,6 +191,7 @@ public: */ virtual void modifyOneHf298SS(const size_t k, const doublereal Hf298New) { m_spthermo->modifyOneHf298(k, Hf298New); + m_tlast += 0.0001234; } //! Maximum temperature for which the thermodynamic data for the species @@ -1610,6 +1611,9 @@ protected: */ std::vector xMol_Ref; + //! last value of the temperature processed by reference state + mutable doublereal m_tlast; + private: //! Error function that gets called for unhandled cases /*! diff --git a/src/thermo/ConstDensityThermo.cpp b/src/thermo/ConstDensityThermo.cpp index e4b0b5efb..26469e6e3 100644 --- a/src/thermo/ConstDensityThermo.cpp +++ b/src/thermo/ConstDensityThermo.cpp @@ -16,13 +16,12 @@ using namespace ctml; namespace Cantera { -ConstDensityThermo::ConstDensityThermo() : m_tlast(0.0) +ConstDensityThermo::ConstDensityThermo() { } ConstDensityThermo::ConstDensityThermo(const ConstDensityThermo& right) - : m_tlast(0.0) { *this = operator=(right); } @@ -33,7 +32,6 @@ ConstDensityThermo& ConstDensityThermo::operator=(const ConstDensityThermo& righ return *this; } - m_tlast = right.m_tlast; m_h0_RT = right.m_h0_RT; m_cp0_R = right.m_cp0_R; m_g0_RT = right.m_g0_RT; diff --git a/src/thermo/IdealGasPhase.cpp b/src/thermo/IdealGasPhase.cpp index 5fbde3100..2c1bfbfc3 100644 --- a/src/thermo/IdealGasPhase.cpp +++ b/src/thermo/IdealGasPhase.cpp @@ -17,14 +17,12 @@ namespace Cantera IdealGasPhase::IdealGasPhase() : m_p0(-1.0), - m_tlast(0.0), m_logc0(0.0) { } IdealGasPhase::IdealGasPhase(const std::string& inputFile, const std::string& id_) : m_p0(-1.0), - m_tlast(0.0), m_logc0(0.0) { initThermoFile(inputFile, id_); @@ -32,7 +30,6 @@ IdealGasPhase::IdealGasPhase(const std::string& inputFile, const std::string& id IdealGasPhase::IdealGasPhase(XML_Node& phaseRef, const std::string& id_) : m_p0(-1.0), - m_tlast(0.0), m_logc0(0.0) { initThermoXML(phaseRef, id_); @@ -40,7 +37,6 @@ IdealGasPhase::IdealGasPhase(XML_Node& phaseRef, const std::string& id_) : IdealGasPhase::IdealGasPhase(const IdealGasPhase& right) : m_p0(right.m_p0), - m_tlast(right.m_tlast), m_logc0(right.m_logc0) { /* @@ -55,7 +51,6 @@ IdealGasPhase& IdealGasPhase::operator=(const IdealGasPhase& right) if (&right != this) { ThermoPhase::operator=(right); m_p0 = right.m_p0; - m_tlast = right.m_tlast; m_logc0 = right.m_logc0; m_h0_RT = right.m_h0_RT; m_cp0_R = right.m_cp0_R; diff --git a/src/thermo/IdealSolidSolnPhase.cpp b/src/thermo/IdealSolidSolnPhase.cpp index f29c47a30..30e0ca58b 100644 --- a/src/thermo/IdealSolidSolnPhase.cpp +++ b/src/thermo/IdealSolidSolnPhase.cpp @@ -22,8 +22,7 @@ IdealSolidSolnPhase::IdealSolidSolnPhase(int formGC) : ThermoPhase(), m_formGC(formGC), m_Pref(OneAtm), - m_Pcurrent(OneAtm), - m_tlast(0.0) + m_Pcurrent(OneAtm) { if (formGC < 0 || formGC > 2) { throw CanteraError(" IdealSolidSolnPhase Constructor", @@ -36,8 +35,7 @@ IdealSolidSolnPhase::IdealSolidSolnPhase(const std::string& inputFile, ThermoPhase(), m_formGC(formGC), m_Pref(OneAtm), - m_Pcurrent(OneAtm), - m_tlast(0.0) + m_Pcurrent(OneAtm) { if (formGC < 0 || formGC > 2) { throw CanteraError(" IdealSolidSolnPhase Constructor", @@ -51,8 +49,7 @@ IdealSolidSolnPhase::IdealSolidSolnPhase(XML_Node& root, const std::string& id_, ThermoPhase(), m_formGC(formGC), m_Pref(OneAtm), - m_Pcurrent(OneAtm), - m_tlast(0.0) + m_Pcurrent(OneAtm) { if (formGC < 0 || formGC > 2) { throw CanteraError(" IdealSolidSolnPhase Constructor", @@ -76,7 +73,6 @@ operator=(const IdealSolidSolnPhase& b) m_Pref = b.m_Pref; m_Pcurrent = b.m_Pcurrent; m_speciesMolarVolume = b.m_speciesMolarVolume; - m_tlast = b.m_tlast; m_h0_RT = b.m_h0_RT; m_cp0_R = b.m_cp0_R; m_g0_RT = b.m_g0_RT; diff --git a/src/thermo/LatticePhase.cpp b/src/thermo/LatticePhase.cpp index ed8c986e5..a82319a0a 100644 --- a/src/thermo/LatticePhase.cpp +++ b/src/thermo/LatticePhase.cpp @@ -21,7 +21,6 @@ namespace Cantera LatticePhase::LatticePhase() : m_Pref(OneAtm), m_Pcurrent(OneAtm), - m_tlast(0.0), m_speciesMolarVolume(0), m_site_density(0.0) { @@ -30,7 +29,6 @@ LatticePhase::LatticePhase() : LatticePhase::LatticePhase(const LatticePhase& right) : m_Pref(OneAtm), m_Pcurrent(OneAtm), - m_tlast(0.0), m_speciesMolarVolume(0), m_site_density(0.0) { @@ -43,7 +41,6 @@ LatticePhase& LatticePhase::operator=(const LatticePhase& right) ThermoPhase::operator=(right); m_Pref = right.m_Pref; m_Pcurrent = right.m_Pcurrent; - m_tlast = right.m_tlast; m_h0_RT = right.m_h0_RT; m_cp0_R = right.m_cp0_R; m_g0_RT = right.m_g0_RT; diff --git a/src/thermo/LatticeSolidPhase.cpp b/src/thermo/LatticeSolidPhase.cpp index 29e9bd143..e716585ed 100644 --- a/src/thermo/LatticeSolidPhase.cpp +++ b/src/thermo/LatticeSolidPhase.cpp @@ -20,7 +20,6 @@ using namespace std; namespace Cantera { LatticeSolidPhase::LatticeSolidPhase() : - m_tlast(0.0), m_press(-1.0), m_molar_density(0.0), m_nlattice(0), @@ -32,7 +31,6 @@ LatticeSolidPhase::LatticeSolidPhase() : } LatticeSolidPhase::LatticeSolidPhase(const LatticeSolidPhase& right) : - m_tlast(0.0), m_press(-1.0), m_molar_density(0.0), m_nlattice(0), diff --git a/src/thermo/MaskellSolidSolnPhase.cpp b/src/thermo/MaskellSolidSolnPhase.cpp index 5a67b6e51..3aee9aba0 100644 --- a/src/thermo/MaskellSolidSolnPhase.cpp +++ b/src/thermo/MaskellSolidSolnPhase.cpp @@ -23,7 +23,6 @@ namespace Cantera MaskellSolidSolnPhase::MaskellSolidSolnPhase() : m_Pref(OneAtm), m_Pcurrent(OneAtm), - m_tlast(-1.0), m_h0_RT(2), m_cp0_R(2), m_g0_RT(2), @@ -37,7 +36,6 @@ MaskellSolidSolnPhase::MaskellSolidSolnPhase() : MaskellSolidSolnPhase::MaskellSolidSolnPhase(const MaskellSolidSolnPhase& b) : m_Pref(OneAtm), m_Pcurrent(OneAtm), - m_tlast(-1.0), m_h0_RT(2), m_cp0_R(2), m_g0_RT(2), diff --git a/src/thermo/SingleSpeciesTP.cpp b/src/thermo/SingleSpeciesTP.cpp index 3684ddf9e..4df26762d 100644 --- a/src/thermo/SingleSpeciesTP.cpp +++ b/src/thermo/SingleSpeciesTP.cpp @@ -20,16 +20,14 @@ namespace Cantera SingleSpeciesTP::SingleSpeciesTP() : ThermoPhase(), m_press(OneAtm), - m_p0(OneAtm), - m_tlast(-1.0) + m_p0(OneAtm) { } SingleSpeciesTP::SingleSpeciesTP(const SingleSpeciesTP& right): ThermoPhase(), m_press(OneAtm), - m_p0(OneAtm), - m_tlast(-1.0) + m_p0(OneAtm) { *this = operator=(right); } @@ -40,7 +38,6 @@ SingleSpeciesTP& SingleSpeciesTP::operator=(const SingleSpeciesTP& right) ThermoPhase::operator=(right); m_press = right.m_press; m_p0 = right.m_p0; - m_tlast = right.m_tlast; m_h0_RT = right.m_h0_RT; m_cp0_R = right.m_cp0_R; m_s0_R = right.m_s0_R; diff --git a/src/thermo/StoichSubstance.cpp b/src/thermo/StoichSubstance.cpp index e83f5b366..bb753a3c3 100644 --- a/src/thermo/StoichSubstance.cpp +++ b/src/thermo/StoichSubstance.cpp @@ -15,15 +15,13 @@ namespace Cantera { StoichSubstance::StoichSubstance() : m_press(OneAtm), - m_p0(OneAtm), - m_tlast(-1.0) + m_p0(OneAtm) { } StoichSubstance::StoichSubstance(const StoichSubstance& right) : m_press(OneAtm), - m_p0(OneAtm), - m_tlast(-1.0) + m_p0(OneAtm) { *this = operator=(right); } @@ -35,7 +33,6 @@ operator=(const StoichSubstance& right) ThermoPhase::operator=(right); m_press = right.m_press; m_p0 = right.m_p0; - m_tlast = right.m_tlast; m_h0_RT = right.m_h0_RT; m_cp0_R = right.m_cp0_R; m_s0_R = right.m_s0_R; diff --git a/src/thermo/SurfPhase.cpp b/src/thermo/SurfPhase.cpp index d080cd9d9..69f36f523 100644 --- a/src/thermo/SurfPhase.cpp +++ b/src/thermo/SurfPhase.cpp @@ -21,8 +21,7 @@ SurfPhase::SurfPhase(doublereal n0): ThermoPhase(), m_n0(n0), m_logn0(0.0), - m_press(OneAtm), - m_tlast(0.0) + m_press(OneAtm) { if (n0 > 0.0) { m_logn0 = log(n0); @@ -34,8 +33,7 @@ SurfPhase::SurfPhase(const std::string& infile, std::string id_) : ThermoPhase(), m_n0(0.0), m_logn0(0.0), - m_press(OneAtm), - m_tlast(0.0) + m_press(OneAtm) { XML_Node* root = get_XML_File(infile); if (id_ == "-") { @@ -60,8 +58,7 @@ SurfPhase::SurfPhase(XML_Node& xmlphase) : ThermoPhase(), m_n0(0.0), m_logn0(0.0), - m_press(OneAtm), - m_tlast(0.0) + m_press(OneAtm) { const XML_Node& th = xmlphase.child("thermo"); string model = th["model"]; @@ -75,8 +72,7 @@ SurfPhase::SurfPhase(XML_Node& xmlphase) : SurfPhase::SurfPhase(const SurfPhase& right) : m_n0(right.m_n0), m_logn0(right.m_logn0), - m_press(right.m_press), - m_tlast(right.m_tlast) + m_press(right.m_press) { *this = operator=(right); } @@ -89,7 +85,6 @@ operator=(const SurfPhase& right) m_n0 = right.m_n0; m_logn0 = right.m_logn0; m_press = right.m_press; - m_tlast = right.m_tlast; m_h0 = right.m_h0; m_s0 = right.m_s0; m_cp0 = right.m_cp0; diff --git a/src/thermo/ThermoPhase.cpp b/src/thermo/ThermoPhase.cpp index e1ad752ac..9082e2192 100644 --- a/src/thermo/ThermoPhase.cpp +++ b/src/thermo/ThermoPhase.cpp @@ -25,7 +25,8 @@ ThermoPhase::ThermoPhase() : m_phi(0.0), m_hasElementPotentials(false), m_chargeNeutralityNecessary(false), - m_ssConvention(cSS_CONVENTION_TEMPERATURE) + m_ssConvention(cSS_CONVENTION_TEMPERATURE), + m_tlast(0.0) { } @@ -92,6 +93,7 @@ ThermoPhase& ThermoPhase::operator=(const ThermoPhase& right) m_hasElementPotentials = right.m_hasElementPotentials; m_chargeNeutralityNecessary = right.m_chargeNeutralityNecessary; m_ssConvention = right.m_ssConvention; + m_tlast = right.m_tlast; return *this; }