diff --git a/include/cantera/thermo/AdsorbateThermo.h b/include/cantera/thermo/AdsorbateThermo.h index 7b72e64b6..d5fbea263 100644 --- a/include/cantera/thermo/AdsorbateThermo.h +++ b/include/cantera/thermo/AdsorbateThermo.h @@ -32,11 +32,8 @@ class Adsorbate : public SpeciesThermoInterpType public: //! Empty constructor - Adsorbate() - : m_lowT(0.0), - m_highT(0.0), - m_index(0), - m_nFreqs(0) { + Adsorbate() : + m_nFreqs(0) { } //! Full Constructor @@ -47,9 +44,9 @@ public: * @param pref output - reference pressure (Pa). */ Adsorbate(size_t n, doublereal tlow, doublereal thigh, doublereal pref, - const doublereal* coeffs) : m_lowT(tlow), - m_highT(thigh), - m_index(n) { + const doublereal* coeffs) + : SpeciesThermoInterpType(n, tlow, thigh, pref) + { m_nFreqs = int(coeffs[0]); m_be = coeffs[1]; m_freq.resize(m_nFreqs); @@ -58,10 +55,6 @@ public: /// Copy Constructor Adsorbate(const Adsorbate& b) : - m_lowT(b.m_lowT), - m_highT(b.m_highT), - m_Pref(b.m_Pref), - m_index(b.m_index), m_be(b.m_be) { m_nFreqs = b.m_nFreqs; std::copy(b.m_freq.begin(), b.m_freq.begin() + m_nFreqs, @@ -89,26 +82,10 @@ public: m_Pref = refPressure_; } - virtual doublereal minTemp() const { - return m_lowT; - } - - virtual doublereal maxTemp() const { - return m_highT; - } - - virtual doublereal refPressure() const { - return OneAtm; - } - virtual int reportType() const { return ADSORBATE; } - virtual size_t speciesIndex() const { - return m_index; - } - void updatePropertiesTemp(const doublereal temp, doublereal* cp_R, doublereal* h_RT, @@ -138,14 +115,6 @@ public: } protected: - //! lowest valid temperature - doublereal m_lowT; - //! Highest valid temperature - doublereal m_highT; - //! Reference state pressure - doublereal m_Pref; - //! species index - size_t m_index; size_t m_nFreqs; //! array of vib frequencies vector_fp m_freq; diff --git a/include/cantera/thermo/Mu0Poly.h b/include/cantera/thermo/Mu0Poly.h index 2e258c397..d308b6aa9 100644 --- a/include/cantera/thermo/Mu0Poly.h +++ b/include/cantera/thermo/Mu0Poly.h @@ -112,18 +112,10 @@ public: virtual SpeciesThermoInterpType* duplMyselfAsSpeciesThermoInterpType() const; - virtual doublereal minTemp() const; - virtual doublereal maxTemp() const; - virtual doublereal refPressure() const; - virtual int reportType() const { return MU0_INTERP; } - virtual size_t speciesIndex() const { - return m_index; - } - //! Update the properties for this species, given a temperature polynomial /*! * This method is called with a pointer to an array containing the functions of @@ -191,16 +183,6 @@ protected: //! Heat capacity at the points vector_fp m_cp0_R_int; - //! Limiting low temperature - doublereal m_lowT; - //! Limiting high temperature - doublereal m_highT; - - //! Reference pressure - doublereal m_Pref; - - //! Species index - size_t m_index; private: //! process the coefficients diff --git a/include/cantera/thermo/Nasa9Poly1.h b/include/cantera/thermo/Nasa9Poly1.h index 6158cf0dd..366f70053 100644 --- a/include/cantera/thermo/Nasa9Poly1.h +++ b/include/cantera/thermo/Nasa9Poly1.h @@ -99,11 +99,7 @@ public: virtual SpeciesThermoInterpType* duplMyselfAsSpeciesThermoInterpType() const; - virtual doublereal minTemp() const; - virtual doublereal maxTemp() const; - virtual doublereal refPressure() const; virtual int reportType() const; - virtual size_t speciesIndex() const; //! Update the properties for this species, given a temperature polynomial /*! @@ -189,14 +185,6 @@ public: virtual void modifyParameters(doublereal* coeffs); protected: - //! lowest valid temperature - doublereal m_lowT; - //! highest valid temperature - doublereal m_highT; - //! standard-state pressure - doublereal m_Pref; - //! species index - size_t m_index; //! array of polynomial coefficients vector_fp m_coeff; }; diff --git a/include/cantera/thermo/NasaPoly1.h b/include/cantera/thermo/NasaPoly1.h index 776952283..bd36679d2 100644 --- a/include/cantera/thermo/NasaPoly1.h +++ b/include/cantera/thermo/NasaPoly1.h @@ -15,6 +15,7 @@ #include "cantera/base/global.h" #include "SpeciesThermoInterpType.h" +#include namespace Cantera { @@ -49,8 +50,7 @@ class NasaPoly1 : public SpeciesThermoInterpType public: //! Empty constructor NasaPoly1() - : m_lowT(0.0), m_highT(0.0), - m_Pref(0.0), m_index(0), m_coeff(7, 0.0) {} + : m_coeff(7, 0.0) {} //! constructor used in templated instantiations /*! @@ -63,10 +63,7 @@ public: */ NasaPoly1(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs) : - m_lowT(tlow), - m_highT(thigh), - m_Pref(pref), - m_index(n), + SpeciesThermoInterpType(n, tlow, thigh, pref), m_coeff(vector_fp(7)) { std::copy(coeffs, coeffs + 7, m_coeff.begin()); } @@ -76,11 +73,9 @@ public: * @param b object to be copied */ NasaPoly1(const NasaPoly1& b) : - m_lowT(b.m_lowT), - m_highT(b.m_highT), - m_Pref(b.m_Pref), - m_index(b.m_index), - m_coeff(vector_fp(7)) { + SpeciesThermoInterpType(b), + m_coeff(vector_fp(7)) + { std::copy(b.m_coeff.begin(), b.m_coeff.begin() + 7, m_coeff.begin()); @@ -92,10 +87,7 @@ public: */ NasaPoly1& operator=(const NasaPoly1& b) { if (&b != this) { - m_lowT = b.m_lowT; - m_highT = b.m_highT; - m_Pref = b.m_Pref; - m_index = b.m_index; + SpeciesThermoInterpType::operator=(b); std::copy(b.m_coeff.begin(), b.m_coeff.begin() + 7, m_coeff.begin()); @@ -109,26 +101,10 @@ public: return (SpeciesThermoInterpType*) np; } - virtual doublereal minTemp() const { - return m_lowT; - } - - virtual doublereal maxTemp() const { - return m_highT; - } - - virtual doublereal refPressure() const { - return m_Pref; - } - virtual int reportType() const { return NASA1; } - virtual size_t speciesIndex() const { - return m_index; - } - //! Update the properties for this species, given a temperature polynomial /*! * This method is called with a pointer to an array containing the @@ -258,14 +234,6 @@ public: #endif protected: - //! lowest valid temperature - doublereal m_lowT; - //! highest valid temperature - doublereal m_highT; - //! standard-state pressure - doublereal m_Pref; - //! species index - size_t m_index; //! array of polynomial coefficients vector_fp m_coeff; }; diff --git a/include/cantera/thermo/SpeciesThermoInterpType.h b/include/cantera/thermo/SpeciesThermoInterpType.h index 07ed21c24..ab0d3b53c 100644 --- a/include/cantera/thermo/SpeciesThermoInterpType.h +++ b/include/cantera/thermo/SpeciesThermoInterpType.h @@ -161,6 +161,14 @@ public: //! Constructor SpeciesThermoInterpType(); + //! Constructor + SpeciesThermoInterpType(size_t n, doublereal tlow, + doublereal thigh, doublereal pref) : + m_lowT(tlow), + m_highT(thigh), + m_Pref(pref), + m_index(n) {} + //! Destructor virtual ~SpeciesThermoInterpType(); @@ -170,20 +178,28 @@ public: //! Returns the minimum temperature that the thermo //! parameterization is valid - virtual doublereal minTemp() const = 0; + virtual doublereal minTemp() const { + return m_lowT; + } //! Returns the maximum temperature that the thermo //! parameterization is valid - virtual doublereal maxTemp() const = 0; + virtual doublereal maxTemp() const { + return m_highT; + } //! Returns the reference pressure (Pa) - virtual doublereal refPressure() const = 0; + virtual doublereal refPressure() const { + return m_Pref; + } //! Returns an integer representing the type of parameterization virtual int reportType() const = 0; //! Returns an integer representing the species index - virtual size_t speciesIndex() const = 0; + virtual size_t speciesIndex() const { + return m_index; + } //! Update the properties for this species, given a temperature polynomial /*! @@ -275,6 +291,16 @@ public: virtual void modifyOneHf298(const int k, const doublereal Hf298New); #endif + +protected: + //! lowest valid temperature + doublereal m_lowT; + //! Highest valid temperature + doublereal m_highT; + //! Reference state pressure + doublereal m_Pref; + //! species index + size_t m_index; }; //! Class for the thermodynamic manager for an individual species' reference state @@ -346,9 +372,6 @@ public: //! Returns an integer representing the type of parameterization virtual int reportType() const; - //! Returns an integer representing the species index - virtual size_t speciesIndex() const; - virtual void updateProperties(const doublereal* tempPoly, doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const; @@ -377,9 +400,6 @@ private: * This object is not owned by the current one. */ PDSS* m_PDSS_ptr; - - //! Species index within the phase - size_t m_speciesIndex; }; } diff --git a/include/cantera/thermo/StatMech.h b/include/cantera/thermo/StatMech.h index 094d6f1f8..91f54bede 100644 --- a/include/cantera/thermo/StatMech.h +++ b/include/cantera/thermo/StatMech.h @@ -19,7 +19,7 @@ namespace Cantera { -// Statistical mechanics +//! Statistical mechanics /*! * @ingroup spthermo */ @@ -60,23 +60,8 @@ public: virtual SpeciesThermoInterpType* duplMyselfAsSpeciesThermoInterpType() const; - //! Returns the minimum temperature that the thermo - //! parameterization is valid - virtual doublereal minTemp() const; - - //! Returns the maximum temperature that the thermo - //! parameterization is valid - virtual doublereal maxTemp() const; - - //! Returns the reference pressure (Pa) - virtual doublereal refPressure() const; - //! Returns an integer representing the type of parameterization virtual int reportType() const; - - //! Returns an integer representing the species index - virtual size_t speciesIndex() const; - //! Build a series of maps for the properties needed for species int buildmap(); @@ -156,14 +141,6 @@ public: virtual void modifyParameters(doublereal* coeffs); protected: - //! lowest valid temperature - doublereal m_lowT; - //! highest valid temperature - doublereal m_highT; - //! standard-state pressure - doublereal m_Pref; - //! species index - int m_index; //! array of polynomial coefficients vector_fp m_coeff; diff --git a/src/thermo/ConstCpPoly.cpp b/src/thermo/ConstCpPoly.cpp index 16c4bef2e..9a8117bc9 100644 --- a/src/thermo/ConstCpPoly.cpp +++ b/src/thermo/ConstCpPoly.cpp @@ -15,21 +15,14 @@ ConstCpPoly::ConstCpPoly() m_cp0_R(0.0), m_h0_R(0.0), m_s0_R(0.0), - m_logt0(0.0), - m_lowT(0.0), - m_highT(0.0), - m_Pref(0.0), - m_index(0) + m_logt0(0.0) { } ConstCpPoly::ConstCpPoly(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs) : - m_lowT(tlow), - m_highT(thigh), - m_Pref(pref), - m_index(n) + SpeciesThermoInterpType(n, tlow, thigh, pref) { m_t0 = coeffs[0]; m_h0_R = coeffs[1] / GasConstant; @@ -39,15 +32,12 @@ ConstCpPoly::ConstCpPoly(size_t n, doublereal tlow, doublereal thigh, } ConstCpPoly::ConstCpPoly(const ConstCpPoly& b) : + SpeciesThermoInterpType(b), m_t0(b.m_t0), m_cp0_R(b.m_cp0_R), m_h0_R(b.m_h0_R), m_s0_R(b.m_s0_R), - m_logt0(b.m_logt0), - m_lowT(b.m_lowT), - m_highT(b.m_highT), - m_Pref(b.m_Pref), - m_index(b.m_index) + m_logt0(b.m_logt0) { } @@ -59,10 +49,7 @@ ConstCpPoly& ConstCpPoly::operator=(const ConstCpPoly& b) m_h0_R = b.m_h0_R; m_s0_R = b.m_s0_R; m_logt0 = b.m_logt0; - m_lowT = b.m_lowT; - m_highT = b.m_highT; - m_Pref = b.m_Pref; - m_index = b.m_index; + SpeciesThermoInterpType::operator=(b); } return *this; } @@ -73,19 +60,6 @@ ConstCpPoly::duplMyselfAsSpeciesThermoInterpType() const return new ConstCpPoly(*this); } -doublereal ConstCpPoly::minTemp() const -{ - return m_lowT; -} -doublereal ConstCpPoly::maxTemp() const -{ - return m_highT; -} -doublereal ConstCpPoly::refPressure() const -{ - return m_Pref; -} - void ConstCpPoly::updateProperties(const doublereal* tt, doublereal* cp_R, doublereal* h_RT, diff --git a/src/thermo/ConstCpPoly.h b/src/thermo/ConstCpPoly.h index 4e6bbe540..0691882ee 100644 --- a/src/thermo/ConstCpPoly.h +++ b/src/thermo/ConstCpPoly.h @@ -77,18 +77,10 @@ public: virtual SpeciesThermoInterpType* duplMyselfAsSpeciesThermoInterpType() const; - doublereal minTemp() const; - doublereal maxTemp() const; - doublereal refPressure() const; - virtual int reportType() const { return CONSTANT_CP; } - virtual size_t speciesIndex() const { - return m_index; - } - //! Update the properties for this species, given a temperature polynomial /*! * This method is called with a pointer to an array containing the functions of @@ -138,14 +130,6 @@ protected: doublereal m_s0_R; //! log of the t0 value doublereal m_logt0; - //! Minimum temperature for which the parameterization is valid (Kelvin) - doublereal m_lowT; - //! Maximum temperature for which the parameterization is valid (Kelvin) - doublereal m_highT; - //! Reference pressure (Pa) - doublereal m_Pref; - //! Species Index - size_t m_index; }; } diff --git a/src/thermo/Mu0Poly.cpp b/src/thermo/Mu0Poly.cpp index af3d14246..430f8cd45 100644 --- a/src/thermo/Mu0Poly.cpp +++ b/src/thermo/Mu0Poly.cpp @@ -19,45 +19,36 @@ using namespace ctml; namespace Cantera { Mu0Poly::Mu0Poly() : m_numIntervals(0), - m_H298(0.0), - m_lowT(0.0), - m_highT(0.0), - m_Pref(0.0), - m_index(0) + m_H298(0.0) { } Mu0Poly::Mu0Poly(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs) : + SpeciesThermoInterpType(n, tlow, thigh, pref), m_numIntervals(0), - m_H298(0.0), - m_lowT(tlow), - m_highT(thigh), - m_Pref(pref), - m_index(n) + m_H298(0.0) { processCoeffs(coeffs); } Mu0Poly::Mu0Poly(const Mu0Poly& b) - : m_numIntervals(b.m_numIntervals), + : SpeciesThermoInterpType(b), + m_numIntervals(b.m_numIntervals), m_H298(b.m_H298), m_t0_int(b.m_t0_int), m_mu0_R_int(b.m_mu0_R_int), m_h0_R_int(b.m_h0_R_int), m_s0_R_int(b.m_s0_R_int), - m_cp0_R_int(b.m_cp0_R_int), - m_lowT(b.m_lowT), - m_highT(b.m_highT), - m_Pref(b.m_Pref), - m_index(b.m_index) + m_cp0_R_int(b.m_cp0_R_int) { } Mu0Poly& Mu0Poly::operator=(const Mu0Poly& b) { if (&b != this) { + SpeciesThermoInterpType::operator=(b); m_numIntervals = b.m_numIntervals; m_H298 = b.m_H298; m_t0_int = b.m_t0_int; @@ -65,10 +56,6 @@ Mu0Poly& Mu0Poly::operator=(const Mu0Poly& b) m_h0_R_int = b.m_h0_R_int; m_s0_R_int = b.m_s0_R_int; m_cp0_R_int = b.m_cp0_R_int; - m_lowT = b.m_lowT; - m_highT = b.m_highT; - m_Pref = b.m_Pref; - m_index = b.m_index; } return *this; } @@ -79,19 +66,6 @@ Mu0Poly::duplMyselfAsSpeciesThermoInterpType() const return new Mu0Poly(*this); } -doublereal Mu0Poly::minTemp() const -{ - return m_lowT; -} -doublereal Mu0Poly::maxTemp() const -{ - return m_highT; -} -doublereal Mu0Poly::refPressure() const -{ - return m_Pref; -} - void Mu0Poly:: updateProperties(const doublereal* tt, doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const diff --git a/src/thermo/Nasa9Poly1.cpp b/src/thermo/Nasa9Poly1.cpp index 74cf33d38..44d9e9868 100644 --- a/src/thermo/Nasa9Poly1.cpp +++ b/src/thermo/Nasa9Poly1.cpp @@ -16,26 +16,22 @@ namespace Cantera { Nasa9Poly1::Nasa9Poly1() - : m_lowT(0.0), m_highT(0.0), - m_Pref(1.0E5), m_index(0), m_coeff(vector_fp(9)) {} + : m_coeff(vector_fp(9)) +{ + m_Pref = 1.0e5; +} Nasa9Poly1::Nasa9Poly1(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs) : - m_lowT(tlow), - m_highT(thigh), - m_Pref(pref), - m_index(n), + SpeciesThermoInterpType(n, tlow, thigh, pref), m_coeff(vector_fp(9)) { std::copy(coeffs, coeffs + 9, m_coeff.begin()); } Nasa9Poly1::Nasa9Poly1(const Nasa9Poly1& b) : - m_lowT(b.m_lowT), - m_highT(b.m_highT), - m_Pref(b.m_Pref), - m_index(b.m_index), + SpeciesThermoInterpType(b), m_coeff(vector_fp(9)) { std::copy(b.m_coeff.begin(), @@ -46,10 +42,7 @@ Nasa9Poly1::Nasa9Poly1(const Nasa9Poly1& b) : Nasa9Poly1& Nasa9Poly1::operator=(const Nasa9Poly1& b) { if (&b != this) { - m_lowT = b.m_lowT; - m_highT = b.m_highT; - m_Pref = b.m_Pref; - m_index = b.m_index; + SpeciesThermoInterpType::operator=(b); std::copy(b.m_coeff.begin(), b.m_coeff.begin() + 9, m_coeff.begin()); @@ -63,31 +56,11 @@ Nasa9Poly1::duplMyselfAsSpeciesThermoInterpType() const return new Nasa9Poly1(*this); } -doublereal Nasa9Poly1::minTemp() const -{ - return m_lowT; -} - -doublereal Nasa9Poly1::maxTemp() const -{ - return m_highT; -} - -doublereal Nasa9Poly1::refPressure() const -{ - return m_Pref; -} - int Nasa9Poly1::reportType() const { return NASA9; } -size_t Nasa9Poly1::speciesIndex() const -{ - return m_index; -} - void Nasa9Poly1::updateProperties(const doublereal* tt, doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const diff --git a/src/thermo/Nasa9PolyMultiTempRegion.cpp b/src/thermo/Nasa9PolyMultiTempRegion.cpp index 396ffded5..f0b79d33c 100644 --- a/src/thermo/Nasa9PolyMultiTempRegion.cpp +++ b/src/thermo/Nasa9PolyMultiTempRegion.cpp @@ -21,10 +21,6 @@ using namespace std; namespace Cantera { Nasa9PolyMultiTempRegion::Nasa9PolyMultiTempRegion() : - m_lowT(0.0), - m_highT(0.0), - m_Pref(0.0), - m_index(0), m_numTempRegions(0), m_currRegion(0) { @@ -32,10 +28,6 @@ Nasa9PolyMultiTempRegion::Nasa9PolyMultiTempRegion() : Nasa9PolyMultiTempRegion:: Nasa9PolyMultiTempRegion(std::vector ®ionPts) : - m_lowT(0.0), - m_highT(0.0), - m_Pref(0.0), - m_index(0), m_numTempRegions(0), m_currRegion(0) { @@ -73,10 +65,7 @@ Nasa9PolyMultiTempRegion(std::vector ®ionPts) : Nasa9PolyMultiTempRegion:: Nasa9PolyMultiTempRegion(const Nasa9PolyMultiTempRegion& b) : - m_lowT(b.m_lowT), - m_highT(b.m_highT), - m_Pref(b.m_Pref), - m_index(b.m_index), + SpeciesThermoInterpType(b), m_numTempRegions(b.m_numTempRegions), m_lowerTempBounds(b.m_lowerTempBounds), m_currRegion(b.m_currRegion) @@ -92,14 +81,11 @@ Nasa9PolyMultiTempRegion& Nasa9PolyMultiTempRegion::operator=(const Nasa9PolyMultiTempRegion& b) { if (&b != this) { + SpeciesThermoInterpType::operator=(b); for (size_t i = 0; i < m_numTempRegions; i++) { delete m_regionPts[i]; m_regionPts[i] = 0; } - m_lowT = b.m_lowT; - m_highT = b.m_highT; - m_Pref = b.m_Pref; - m_index = b.m_index; m_numTempRegions = b.m_numTempRegions; m_lowerTempBounds = b.m_lowerTempBounds; m_currRegion = b.m_currRegion; @@ -125,31 +111,11 @@ Nasa9PolyMultiTempRegion::duplMyselfAsSpeciesThermoInterpType() const return new Nasa9PolyMultiTempRegion(*this); } -doublereal Nasa9PolyMultiTempRegion::minTemp() const -{ - return m_lowT; -} - -doublereal Nasa9PolyMultiTempRegion::maxTemp() const -{ - return m_highT; -} - -doublereal Nasa9PolyMultiTempRegion::refPressure() const -{ - return m_Pref; -} - int Nasa9PolyMultiTempRegion::reportType() const { return NASA9MULTITEMP; } -size_t Nasa9PolyMultiTempRegion::speciesIndex() const -{ - return m_index; -} - void Nasa9PolyMultiTempRegion::updateProperties(const doublereal* tt, doublereal* cp_R, doublereal* h_RT, diff --git a/src/thermo/Nasa9PolyMultiTempRegion.h b/src/thermo/Nasa9PolyMultiTempRegion.h index 386c7e8f1..171999390 100644 --- a/src/thermo/Nasa9PolyMultiTempRegion.h +++ b/src/thermo/Nasa9PolyMultiTempRegion.h @@ -102,11 +102,7 @@ public: virtual SpeciesThermoInterpType* duplMyselfAsSpeciesThermoInterpType() const; - virtual doublereal minTemp() const; - virtual doublereal maxTemp() const; - virtual doublereal refPressure() const; virtual int reportType() const; - virtual size_t speciesIndex() const; //! Update the properties for this species, given a temperature polynomial /*! @@ -195,14 +191,6 @@ public: virtual void modifyParameters(doublereal* coeffs); protected: - //! lowest valid temperature - doublereal m_lowT; - //! highest valid temperature - doublereal m_highT; - //! standard-state pressure - doublereal m_Pref; - //! species index - size_t m_index; //! Number of temperature regions size_t m_numTempRegions; diff --git a/src/thermo/NasaPoly2.h b/src/thermo/NasaPoly2.h index 18746571c..50ddeb978 100644 --- a/src/thermo/NasaPoly2.h +++ b/src/thermo/NasaPoly2.h @@ -13,6 +13,7 @@ #define CT_NASAPOLY2_H #include "cantera/thermo/SpeciesThermoInterpType.h" +#include "cantera/thermo/NasaPoly1.h" namespace Cantera { @@ -49,11 +50,7 @@ class NasaPoly2 : public SpeciesThermoInterpType public: //! Empty constructor NasaPoly2() - : m_lowT(0.0), - m_midT(0.0), - m_highT(0.0), - m_Pref(0.0), - m_index(0), + : m_midT(0.0), m_coeff(15, 0.0) { } @@ -68,14 +65,10 @@ public: */ NasaPoly2(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs) : - m_lowT(tlow), - m_highT(thigh), - m_Pref(pref), + SpeciesThermoInterpType(n, tlow, thigh, pref), mnp_low(n, tlow, coeffs[0], pref, coeffs +1), mnp_high(n, tlow, thigh, pref, coeffs + 8), - m_index(n), m_coeff(15, 0.0) { - std::copy(coeffs, coeffs + 15, m_coeff.begin()); m_midT = coeffs[0]; } @@ -85,13 +78,10 @@ public: * @param b object to be copied. */ NasaPoly2(const NasaPoly2& b) : - m_lowT(b.m_lowT), + SpeciesThermoInterpType(b), m_midT(b.m_midT), - m_highT(b.m_highT), - m_Pref(b.m_Pref), mnp_low(b.mnp_low), mnp_high(b.mnp_high), - m_index(b.m_index), m_coeff(b.m_coeff) { } @@ -101,11 +91,8 @@ public: */ NasaPoly2& operator=(const NasaPoly2& b) { if (&b != this) { - m_lowT = b.m_lowT; + SpeciesThermoInterpType::operator=(b); m_midT = b.m_midT; - m_highT = b.m_highT; - m_Pref = b.m_Pref; - m_index = b.m_index; m_coeff = b.m_coeff; mnp_low = b.mnp_low; mnp_high = b.mnp_high; @@ -119,26 +106,10 @@ public: return (SpeciesThermoInterpType*) np; } - doublereal minTemp() const { - return m_lowT; - } - - doublereal maxTemp() const { - return m_highT; - } - - doublereal refPressure() const { - return m_Pref; - } - virtual int reportType() const { return NASA2; } - virtual size_t speciesIndex() const { - return m_index; - } - //! Update the properties for this species, given a temperature polynomial /*! * This method is called with a pointer to an array containing the @@ -229,20 +200,12 @@ public: #endif protected: - //! lowest valid temperature - doublereal m_lowT; //! Midrange temperature doublereal m_midT; - //! Highest valid temperature - doublereal m_highT; - //! Reference state pressure - doublereal m_Pref; //! NasaPoly1 object for the low temperature region. NasaPoly1 mnp_low; //! NasaPoly1 object for the high temperature region. NasaPoly1 mnp_high; - //! species index - size_t m_index; //! array of polynomial coefficients vector_fp m_coeff; }; diff --git a/src/thermo/ShomatePoly.h b/src/thermo/ShomatePoly.h index 10f9d0c2e..56e117150 100644 --- a/src/thermo/ShomatePoly.h +++ b/src/thermo/ShomatePoly.h @@ -57,9 +57,7 @@ class ShomatePoly : public SpeciesThermoInterpType { public: //! Empty constructor - ShomatePoly() - : m_lowT(0.0), m_highT(0.0), - m_Pref(0.0), m_index(0) {} + ShomatePoly() {} //! Constructor used in templated instantiations /*! @@ -83,10 +81,8 @@ public: */ ShomatePoly(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs) : - m_lowT(tlow), - m_highT(thigh), - m_Pref(pref), - m_index(n) { + SpeciesThermoInterpType(n, tlow, thigh, pref) + { m_coeff.resize(7); std::copy(coeffs, coeffs + 7, m_coeff.begin()); } @@ -96,11 +92,9 @@ public: * @param b object to be copied */ ShomatePoly(const ShomatePoly& b) : - m_lowT(b.m_lowT), - m_highT(b.m_highT), - m_Pref(b.m_Pref), - m_coeff(vector_fp(7)), - m_index(b.m_index) { + SpeciesThermoInterpType(b), + m_coeff(vector_fp(7)) + { std::copy(b.m_coeff.begin(), b.m_coeff.begin() + 7, m_coeff.begin()); @@ -112,10 +106,7 @@ public: */ ShomatePoly& operator=(const ShomatePoly& b) { if (&b != this) { - m_lowT = b.m_lowT; - m_highT = b.m_highT; - m_Pref = b.m_Pref; - m_index = b.m_index; + SpeciesThermoInterpType::operator=(b); m_coeff.resize(7); std::copy(b.m_coeff.begin(), b.m_coeff.begin() + 7, @@ -130,26 +121,10 @@ public: return (SpeciesThermoInterpType*) sp; } - virtual doublereal minTemp() const { - return m_lowT; - } - - virtual doublereal maxTemp() const { - return m_highT; - } - - virtual doublereal refPressure() const { - return m_Pref; - } - virtual int reportType() const { return SHOMATE; } - virtual size_t speciesIndex() const { - return m_index; - } - //! Update the properties for this species, given a temperature polynomial /*! * This method is called with a pointer to an array containing the @@ -282,16 +257,8 @@ public: #endif protected: - //! Minimum temperature for which the parameterization is valid (Kelvin) - doublereal m_lowT; - //! Maximum temperature for which the parameterization is valid (Kelvin) - doublereal m_highT; - //! Reference pressure (Pa) - doublereal m_Pref; //! Array of coeffcients vector_fp m_coeff; - //! Species Index - size_t m_index; }; //! The Shomate polynomial parameterization for two temperature ranges @@ -340,13 +307,10 @@ class ShomatePoly2 : public SpeciesThermoInterpType public: //! Empty constructor ShomatePoly2() - : m_lowT(0.0), - m_midT(0.0), - m_highT(0.0), - m_Pref(0.0), + : m_midT(0.0), msp_low(0), - msp_high(0), - m_index(0) { + msp_high(0) + { m_coeff.resize(15); } @@ -365,13 +329,11 @@ public: */ ShomatePoly2(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs) : - m_lowT(tlow), + SpeciesThermoInterpType(n, tlow, thigh, pref), m_midT(0.0), - m_highT(thigh), - m_Pref(pref), msp_low(0), - msp_high(0), - m_index(n) { + msp_high(0) + { m_coeff.resize(15); std::copy(coeffs, coeffs + 15, m_coeff.begin()); m_midT = coeffs[0]; @@ -384,14 +346,12 @@ public: * @param b object to be copied. */ ShomatePoly2(const ShomatePoly2& b) : - m_lowT(b.m_lowT), + SpeciesThermoInterpType(b), m_midT(b.m_midT), - m_highT(b.m_highT), - m_Pref(b.m_Pref), msp_low(0), msp_high(0), - m_coeff(vector_fp(15)), - m_index(b.m_index) { + m_coeff(vector_fp(15)) + { std::copy(b.m_coeff.begin(), b.m_coeff.begin() + 15, m_coeff.begin()); @@ -407,11 +367,8 @@ public: */ ShomatePoly2& operator=(const ShomatePoly2& b) { if (&b != this) { - m_lowT = b.m_lowT; + SpeciesThermoInterpType::operator=(b); m_midT = b.m_midT; - m_highT = b.m_highT; - m_Pref = b.m_Pref; - m_index = b.m_index; std::copy(b.m_coeff.begin(), b.m_coeff.begin() + 15, m_coeff.begin()); @@ -437,26 +394,10 @@ public: return (SpeciesThermoInterpType*) sp; } - virtual doublereal minTemp() const { - return m_lowT; - } - - virtual doublereal maxTemp() const { - return m_highT; - } - - virtual doublereal refPressure() const { - return m_Pref; - } - virtual int reportType() const { return SHOMATE2; } - virtual size_t speciesIndex() const { - return m_index; - } - //! Update the properties for this species, given a temperature polynomial /*! * This method is called with a pointer to an array containing the @@ -565,22 +506,14 @@ public: #endif protected: - //! Minimum temperature the representation is valid(kelvin) - doublereal m_lowT; //! Midrange temperature (kelvin) doublereal m_midT; - //! Maximum temperature the representation is valid (kelvin) - doublereal m_highT; - //! Reference pressure (Pascal) - doublereal m_Pref; //! Pointer to the Shomate polynomial for the low temperature region. ShomatePoly* msp_low; //! Pointer to the Shomate polynomial for the high temperature region. ShomatePoly* msp_high; //! Array of the original coefficients. vector_fp m_coeff; - //! Species index - size_t m_index; }; } diff --git a/src/thermo/SpeciesThermoInterpType.cpp b/src/thermo/SpeciesThermoInterpType.cpp index aca1119c4..bd92f06a2 100644 --- a/src/thermo/SpeciesThermoInterpType.cpp +++ b/src/thermo/SpeciesThermoInterpType.cpp @@ -13,7 +13,11 @@ namespace Cantera { -SpeciesThermoInterpType::SpeciesThermoInterpType() +SpeciesThermoInterpType::SpeciesThermoInterpType() : + m_lowT(0.0), + m_highT(0.0), + m_Pref(0.0), + m_index(0) { } @@ -45,22 +49,21 @@ void SpeciesThermoInterpType::modifyOneHf298(const int k, const doublereal Hf298 #endif -STITbyPDSS::STITbyPDSS() : - m_speciesIndex(npos) +STITbyPDSS::STITbyPDSS() { + m_index = npos; } STITbyPDSS::STITbyPDSS(size_t k, VPSSMgr* vpssmgr_ptr, PDSS* PDSS_ptr) : m_vpssmgr_ptr(vpssmgr_ptr), - m_PDSS_ptr(PDSS_ptr), - m_speciesIndex(k) + m_PDSS_ptr(PDSS_ptr) { + m_index = k; } STITbyPDSS::STITbyPDSS(const STITbyPDSS& b) : m_vpssmgr_ptr(b.m_vpssmgr_ptr), - m_PDSS_ptr(b.m_PDSS_ptr), - m_speciesIndex(b.m_speciesIndex) + m_PDSS_ptr(b.m_PDSS_ptr) { } @@ -72,7 +75,7 @@ STITbyPDSS::duplMyselfAsSpeciesThermoInterpType() const void STITbyPDSS::initAllPtrs(size_t speciesIndex, VPSSMgr* vpssmgr_ptr, PDSS* PDSS_ptr) { - AssertThrow(speciesIndex == m_speciesIndex, "STITbyPDSS::initAllPtrs internal confusion"); + AssertThrow(speciesIndex == m_index, "STITbyPDSS::initAllPtrs internal confusion"); m_vpssmgr_ptr = vpssmgr_ptr; m_PDSS_ptr = PDSS_ptr; } @@ -97,11 +100,6 @@ int STITbyPDSS::reportType() const return PDSS_TYPE; } -size_t STITbyPDSS::speciesIndex() const -{ - return m_speciesIndex; -} - void STITbyPDSS::updateProperties(const doublereal* tempPoly, doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const @@ -117,11 +115,11 @@ void STITbyPDSS::updatePropertiesTemp(const doublereal temp, { //m_vpssmgr_ptr->setState_T(temp); m_PDSS_ptr->setTemperature(temp); - AssertThrowMsg(m_speciesIndex != npos, "STITbyPDSS::updatePropertiesTemp", + AssertThrowMsg(m_index != npos, "STITbyPDSS::updatePropertiesTemp", "object was probably not installed correctly"); - h_RT[m_speciesIndex] = m_PDSS_ptr->enthalpy_RT_ref(); - cp_R[m_speciesIndex] = m_PDSS_ptr->cp_R_ref(); - s_R[m_speciesIndex] = m_PDSS_ptr->entropy_R_ref(); + h_RT[m_index] = m_PDSS_ptr->enthalpy_RT_ref(); + cp_R[m_index] = m_PDSS_ptr->cp_R_ref(); + s_R[m_index] = m_PDSS_ptr->entropy_R_ref(); } void STITbyPDSS::reportParameters(size_t& index, int& type, @@ -130,10 +128,10 @@ void STITbyPDSS::reportParameters(size_t& index, int& type, doublereal* const coeffs) const { warn_deprecated("STITbyPDSS::reportParameters"); - index = m_speciesIndex; + index = m_index; type = PDSS_TYPE; - minTemp = m_vpssmgr_ptr->minTemp(m_speciesIndex); - maxTemp = m_vpssmgr_ptr->maxTemp(m_speciesIndex); + minTemp = m_vpssmgr_ptr->minTemp(m_index); + maxTemp = m_vpssmgr_ptr->maxTemp(m_index); refPressure = m_PDSS_ptr->refPressure(); } diff --git a/src/thermo/StatMech.cpp b/src/thermo/StatMech.cpp index 5300c7f38..b626ef2df 100644 --- a/src/thermo/StatMech.cpp +++ b/src/thermo/StatMech.cpp @@ -10,18 +10,13 @@ namespace Cantera { -StatMech::StatMech() - : m_lowT(0.1), m_highT(1.0), - m_Pref(1.0E5), m_index(0) {} +StatMech::StatMech() {} StatMech::StatMech(int n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs, const std::string& my_name) : - m_lowT(tlow), - m_highT(thigh), - m_Pref(pref), - m_index(n), + SpeciesThermoInterpType(n, tlow, thigh, pref), sp_name(my_name) { // should error on zero -- cannot take ln(0) @@ -33,21 +28,14 @@ StatMech::StatMech(int n, doublereal tlow, doublereal thigh, } StatMech::StatMech(const StatMech& b) : - m_lowT(b.m_lowT), - m_highT(b.m_highT), - m_Pref(b.m_Pref), - m_index(b.m_index) + SpeciesThermoInterpType(b) { - } StatMech& StatMech::operator=(const StatMech& b) { if (&b != this) { - m_lowT = b.m_lowT; - m_highT = b.m_highT; - m_Pref = b.m_Pref; - m_index = b.m_index; + SpeciesThermoInterpType::operator=(b); } return *this; } @@ -58,31 +46,11 @@ StatMech::duplMyselfAsSpeciesThermoInterpType() const return new StatMech(*this); } -doublereal StatMech::minTemp() const -{ - return m_lowT; -} - -doublereal StatMech::maxTemp() const -{ - return m_highT; -} - -doublereal StatMech::refPressure() const -{ - return m_Pref; -} - int StatMech::reportType() const { return STAT; } -size_t StatMech::speciesIndex() const -{ - return m_index; -} - int StatMech::buildmap() {