diff --git a/include/cantera/thermo/Nasa9Poly1.h b/include/cantera/thermo/Nasa9Poly1.h index 19e8c013b..15f5f4e60 100644 --- a/include/cantera/thermo/Nasa9Poly1.h +++ b/include/cantera/thermo/Nasa9Poly1.h @@ -103,6 +103,9 @@ public: virtual int reportType() const; + virtual size_t temperaturePolySize() const { return 7; } + virtual void updateTemperaturePoly(double T, double* T_poly) const; + //! Update the properties for this species, given a temperature polynomial /*! * This method is called with a pointer to an array containing the diff --git a/include/cantera/thermo/Nasa9PolyMultiTempRegion.h b/include/cantera/thermo/Nasa9PolyMultiTempRegion.h index c8b9d05a1..21442d469 100644 --- a/include/cantera/thermo/Nasa9PolyMultiTempRegion.h +++ b/include/cantera/thermo/Nasa9PolyMultiTempRegion.h @@ -72,6 +72,9 @@ public: virtual int reportType() const; + virtual size_t temperaturePolySize() const { return 7; } + virtual void updateTemperaturePoly(double T, double* T_poly) const; + //! Update the properties for this species, given a temperature polynomial /*! * This method is called with a pointer to an array containing the diff --git a/include/cantera/thermo/NasaPoly1.h b/include/cantera/thermo/NasaPoly1.h index 82b7a6d72..849c7381e 100644 --- a/include/cantera/thermo/NasaPoly1.h +++ b/include/cantera/thermo/NasaPoly1.h @@ -97,6 +97,17 @@ public: return NASA1; } + virtual size_t temperaturePolySize() const { return 6; } + + virtual void updateTemperaturePoly(double T, double* T_poly) const { + T_poly[0] = T; + T_poly[1] = T * T; + T_poly[2] = T_poly[1] * T; + T_poly[3] = T_poly[2] * T; + T_poly[4] = 1.0 / T; + T_poly[5] = std::log(T); + } + //! Update the properties for this species, given a temperature polynomial /*! * This method is called with a pointer to an array containing the @@ -145,12 +156,7 @@ public: doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const { double tPoly[6]; - tPoly[0] = temp; - tPoly[1] = temp * temp; - tPoly[2] = tPoly[1] * temp; - tPoly[3] = tPoly[2] * temp; - tPoly[4] = 1.0 / temp; - tPoly[5] = std::log(temp); + updateTemperaturePoly(temp, tPoly); updateProperties(tPoly, cp_R, h_RT, s_R); } @@ -186,12 +192,7 @@ public: virtual doublereal reportHf298(doublereal* const h298 = 0) const { double tt[6]; double temp = 298.15; - tt[0] = temp; - tt[1] = temp * temp; - tt[2] = tt[1] * temp; - tt[3] = tt[2] * temp; - tt[4] = 1.0 / temp; - //tt[5] = std::log(temp); + updateTemperaturePoly(temp, tt); doublereal ct0 = m_coeff[2]; // a0 doublereal ct1 = m_coeff[3]*tt[0]; // a1 * T doublereal ct2 = m_coeff[4]*tt[1]; // a2 * T^2 diff --git a/include/cantera/thermo/NasaPoly2.h b/include/cantera/thermo/NasaPoly2.h index c6d517e76..0da6a885a 100644 --- a/include/cantera/thermo/NasaPoly2.h +++ b/include/cantera/thermo/NasaPoly2.h @@ -109,6 +109,12 @@ public: return NASA2; } + virtual size_t temperaturePolySize() const { return 6; } + + virtual void updateTemperaturePoly(double T, double* T_poly) const { + mnp_low.updateTemperaturePoly(T, T_poly); + } + //! Update the properties for this species, given a temperature polynomial /*! * This method is called with a pointer to an array containing the @@ -131,8 +137,7 @@ public: */ void updateProperties(const doublereal* tt, doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const { - double T = tt[0]; - if (T <= m_midT) { + if (tt[0] <= m_midT) { mnp_low.updateProperties(tt, cp_R, h_RT, s_R); } else { mnp_high.updateProperties(tt, cp_R, h_RT, s_R); diff --git a/include/cantera/thermo/ShomatePoly.h b/include/cantera/thermo/ShomatePoly.h index ff1aeda37..a7e5e5631 100644 --- a/include/cantera/thermo/ShomatePoly.h +++ b/include/cantera/thermo/ShomatePoly.h @@ -118,6 +118,19 @@ public: return SHOMATE; } + virtual size_t temperaturePolySize() const { return 7; } + + virtual void updateTemperaturePoly(double T, double* T_poly) const { + doublereal tt = 1.e-3*T; + T_poly[0] = tt; + T_poly[1] = tt * tt; + T_poly[2] = T_poly[1] * tt; + T_poly[3] = 1.0/T_poly[1]; + T_poly[4] = std::log(tt); + T_poly[5] = 1.0/GasConstant; + T_poly[6] = 1.0/(GasConstant * T); + } + //! Update the properties for this species, given a temperature polynomial /*! * This method is called with a pointer to an array containing the @@ -174,14 +187,7 @@ public: doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const { double tPoly[7]; - doublereal tt = 1.e-3*temp; - tPoly[0] = tt; - tPoly[1] = tt * tt; - tPoly[2] = tPoly[1] * tt; - tPoly[3] = 1.0/tPoly[1]; - tPoly[4] = std::log(tt); - tPoly[5] = 1.0/GasConstant; - tPoly[6] = 1.0/(GasConstant * temp); + updateTemperaturePoly(temp, tPoly); updateProperties(tPoly, cp_R, h_RT, s_R); } @@ -213,13 +219,8 @@ public: } virtual doublereal reportHf298(doublereal* const h298 = 0) const { - double tPoly[4]; - doublereal tt = 1.e-3*298.15; - tPoly[0] = tt; - tPoly[1] = tt * tt; - tPoly[2] = tPoly[1] * tt; - tPoly[3] = 1.0/tPoly[1]; - + double tPoly[7]; + updateTemperaturePoly(298.15, tPoly); doublereal A = m_coeff[0]; doublereal Bt = m_coeff[1]*tPoly[0]; doublereal Ct2 = m_coeff[2]*tPoly[1]; @@ -359,6 +360,12 @@ public: return SHOMATE2; } + virtual size_t temperaturePolySize() const { return 7; } + + virtual void updateTemperaturePoly(double T, double* T_poly) const { + msp_low.updateTemperaturePoly(T, T_poly); + } + //! Update the properties for this species, given a temperature polynomial /*! * This method is called with a pointer to an array containing the diff --git a/include/cantera/thermo/SpeciesThermoInterpType.h b/include/cantera/thermo/SpeciesThermoInterpType.h index 2112e2a50..3e65708af 100644 --- a/include/cantera/thermo/SpeciesThermoInterpType.h +++ b/include/cantera/thermo/SpeciesThermoInterpType.h @@ -195,6 +195,15 @@ public: return m_index; } + //! Number of terms in the temperature polynomial for this parameterization + virtual size_t temperaturePolySize() const { return 1; } + + //! Given the temperature *T*, compute the terms of the temperature + //! polynomial *T_poly*. + virtual void updateTemperaturePoly(double T, double* T_poly) const { + T_poly[0] = T; + } + //! Update the properties for this species, given a temperature polynomial /*! * This method is called with a pointer to an array containing the functions diff --git a/src/thermo/Nasa9Poly1.cpp b/src/thermo/Nasa9Poly1.cpp index bad612aad..b5be4f870 100644 --- a/src/thermo/Nasa9Poly1.cpp +++ b/src/thermo/Nasa9Poly1.cpp @@ -55,6 +55,17 @@ int Nasa9Poly1::reportType() const return NASA9; } +void Nasa9Poly1::updateTemperaturePoly(double T, double* T_poly) const +{ + T_poly[0] = T; + T_poly[1] = T * T; + T_poly[2] = T_poly[1] * T; + T_poly[3] = T_poly[2] * T; + T_poly[4] = 1.0 / T; + T_poly[5] = T_poly[4] / T; + T_poly[6] = std::log(T); +} + void Nasa9Poly1::updateProperties(const doublereal* tt, doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const @@ -87,13 +98,7 @@ void Nasa9Poly1::updatePropertiesTemp(const doublereal temp, doublereal* s_R) const { double tPoly[7]; - tPoly[0] = temp; - tPoly[1] = temp * temp; - tPoly[2] = tPoly[1] * temp; - tPoly[3] = tPoly[2] * temp; - tPoly[4] = 1.0 / temp; - tPoly[5] = tPoly[4] / temp; - tPoly[6] = std::log(temp); + updateTemperaturePoly(temp, tPoly); updateProperties(tPoly, cp_R, h_RT, s_R); } diff --git a/src/thermo/Nasa9PolyMultiTempRegion.cpp b/src/thermo/Nasa9PolyMultiTempRegion.cpp index 96e65bfe7..a5a809b04 100644 --- a/src/thermo/Nasa9PolyMultiTempRegion.cpp +++ b/src/thermo/Nasa9PolyMultiTempRegion.cpp @@ -113,6 +113,17 @@ int Nasa9PolyMultiTempRegion::reportType() const return NASA9MULTITEMP; } +void Nasa9PolyMultiTempRegion::updateTemperaturePoly(double T, double* T_poly) const +{ + T_poly[0] = T; + T_poly[1] = T * T; + T_poly[2] = T_poly[1] * T; + T_poly[3] = T_poly[2] * T; + T_poly[4] = 1.0 / T; + T_poly[5] = T_poly[4] / T; + T_poly[6] = std::log(T); +} + void Nasa9PolyMultiTempRegion::updateProperties(const doublereal* tt, doublereal* cp_R, doublereal* h_RT, @@ -143,13 +154,7 @@ void Nasa9PolyMultiTempRegion::updatePropertiesTemp(const doublereal temp, doublereal* s_R) const { double tPoly[7]; - tPoly[0] = temp; - tPoly[1] = temp * temp; - tPoly[2] = tPoly[1] * temp; - tPoly[3] = tPoly[2] * temp; - tPoly[4] = 1.0 / temp; - tPoly[5] = tPoly[4] / temp; - tPoly[6] = std::log(temp); + updateTemperaturePoly(temp, tPoly); // Now find the region m_currRegion = 0; for (size_t i = 1; i < m_numTempRegions; i++) {