diff --git a/Cantera/src/NasaPoly1.h b/Cantera/src/NasaPoly1.h index 6d4eec7aa..110c0d5c8 100755 --- a/Cantera/src/NasaPoly1.h +++ b/Cantera/src/NasaPoly1.h @@ -18,191 +18,256 @@ namespace Cantera { - /** - * The NASA polynomial parameterization for one temperature range. - * This parameterization expresses the heat capacity as a - * fourth-order polynomial. Note that this is the form used in the - * 1971 NASA equilibrium program and by the Chemkin software - * package, but differs from the form used in the more recent NASA - * equilibrium program. - * - * Seven coefficients \f$(a_0,\dots,a_6)\f$ are used to represent - * \f$ c_p^0(T)\f$, \f$ h^0(T)\f$, and \f$ s^0(T) \f$ as - * polynomials in \f$ T \f$ : - * \f[ - * \frac{c_p(T)}{R} = a_0 + a_1 T + a_2 T^2 + a_3 T^3 + a_4 T^4 - * \f] - * \f[ - * \frac{h^0(T)}{RT} = a_0 + \frac{a_1}{2} T + \frac{a_2}{3} T^2 - * + \frac{a_3}{4} T^3 + \frac{a_4}{5} T^4 + \frac{a_5}{T}. - * \f] - * \f[ - * \frac{s^0(T)}{R} = a_0\ln T + a_1 T + \frac{a_2}{2} T^2 - + \frac{a_3}{3} T^3 + \frac{a_4}{4} T^4 + a_6. - * \f] - * - * This class is designed specifically for use by class NasaThermo. - * @ingroup spthermo + /** + * The NASA polynomial parameterization for one temperature range. + * This parameterization expresses the heat capacity as a + * fourth-order polynomial. Note that this is the form used in the + * 1971 NASA equilibrium program and by the Chemkin software + * package, but differs from the form used in the more recent NASA + * equilibrium program. + * + * Seven coefficients \f$(a_0,\dots,a_6)\f$ are used to represent + * \f$ c_p^0(T)\f$, \f$ h^0(T)\f$, and \f$ s^0(T) \f$ as + * polynomials in \f$ T \f$ : + * \f[ + * \frac{c_p(T)}{R} = a_0 + a_1 T + a_2 T^2 + a_3 T^3 + a_4 T^4 + * \f] + * \f[ + * \frac{h^0(T)}{RT} = a_0 + \frac{a_1}{2} T + \frac{a_2}{3} T^2 + * + \frac{a_3}{4} T^3 + \frac{a_4}{5} T^4 + \frac{a_5}{T}. + * \f] + * \f[ + * \frac{s^0(T)}{R} = a_0\ln T + a_1 T + \frac{a_2}{2} T^2 + + \frac{a_3}{3} T^3 + \frac{a_4}{4} T^4 + a_6. + * \f] + * + * This class is designed specifically for use by class NasaThermo. + * @ingroup spthermo + */ + 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(array_fp(7)) {} + + + //! full constructor + /*! + * @param n Species index + * @param tlow Minimum temperature + * @param thigh Maximum temperature + * @param pref reference pressure (Pa). + * @param coeffs Vector of coefficients used to set the + * parameters for the standard state. */ - class NasaPoly1 : public SpeciesThermoInterpType { + NasaPoly1(int n, doublereal tlow, doublereal thigh, doublereal pref, + const doublereal* coeffs) : + m_lowT (tlow), + m_highT (thigh), + m_Pref (pref), + m_index (n), + m_coeff (array_fp(7)) { + std::copy(coeffs, coeffs + 7, m_coeff.begin()); + } - public: + //! copy constructor + /*! + * @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 (array_fp(7)) { + std::copy(b.m_coeff.begin(), + b.m_coeff.begin() + 7, + m_coeff.begin()); + } - NasaPoly1() - : m_lowT(0.0), m_highT (0.0), - m_Pref(0.0), m_index (0), m_coeff(array_fp(7)) {} + //! assignment operator + /*! + * @param b object to be copied + */ + 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; + std::copy(b.m_coeff.begin(), + b.m_coeff.begin() + 7, + m_coeff.begin()); + } + return *this; + } - NasaPoly1(int n, doublereal tlow, doublereal thigh, doublereal pref, - const doublereal* coeffs) : - m_lowT (tlow), - m_highT (thigh), - m_Pref (pref), - m_index (n), - m_coeff (array_fp(7)) { - std::copy(coeffs, coeffs + 7, m_coeff.begin()); - } + //! Destructor + virtual ~NasaPoly1(){} - 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 (array_fp(7)) { - std::copy(b.m_coeff.begin(), - b.m_coeff.begin() + 7, - m_coeff.begin()); - } + //! duplicator + virtual SpeciesThermoInterpType * + duplMyselfAsSpeciesThermoInterpType() const { + NasaPoly1* np = new NasaPoly1(*this); + return (SpeciesThermoInterpType *) np; + } - 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; - std::copy(b.m_coeff.begin(), - b.m_coeff.begin() + 7, - m_coeff.begin()); - } - return *this; - } + //! Returns the minimum temperature that the thermo + //! parameterization is valid + virtual doublereal minTemp() const { return m_lowT;} - virtual ~NasaPoly1(){} + //! Returns the maximum temperature that the thermo + //! parameterization is valid + virtual doublereal maxTemp() const { return m_highT;} - virtual SpeciesThermoInterpType * - duplMyselfAsSpeciesThermoInterpType() const { - NasaPoly1* np = new NasaPoly1(*this); - return (SpeciesThermoInterpType *) np; - } + //! Returns the reference pressure (Pa) + virtual doublereal refPressure() const { return m_Pref; } + + //! Returns an integer representing the type of parameterization + virtual int reportType() const { return NASA1; } - 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; } - - /** - * Update the properties for this species. This method is called - * with a pointer to an array containing the functions of - * temperature needed by this - * parameterization, and three pointers to arrays where the - * computed property values - * should be written. This method updates only one value in - * each array. - * - * Temperature Polynomial: - * tt[0] = t; - * tt[1] = t*t; - * tt[2] = m_t[1]*t; - * tt[3] = m_t[2]*t; - * tt[4] = 1.0/t; - * tt[5] = std::log(t); - */ - virtual void updateProperties(const doublereal* tt, - doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const { - - 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 - doublereal ct3 = m_coeff[5]*tt[2]; // a3 * T^3 - doublereal ct4 = m_coeff[6]*tt[3]; // a4 * T^4 - doublereal cp, h, s; - cp = ct0 + ct1 + ct2 + ct3 + ct4; - h = ct0 + 0.5*ct1 + OneThird*ct2 + 0.25*ct3 + 0.2*ct4 - + m_coeff[0]*tt[4]; // last term is a5/T - s = ct0*tt[5] + ct1 + 0.5*ct2 + OneThird*ct3 - +0.25*ct4 + m_coeff[1]; // last term is a6 + //! Update the properties for this species, given a temperature polynomial + /*! + * This method is called with a pointer to an array containing the functions of + * temperature needed by this parameterization, and three pointers to arrays where the + * computed property values should be written. This method updates only one value in + * each array. + * + * Temperature Polynomial: + * tt[0] = t; + * tt[1] = t*t; + * tt[2] = m_t[1]*t; + * tt[3] = m_t[2]*t; + * tt[4] = 1.0/t; + * tt[5] = std::log(t); + * + * @param tt vector of temperature polynomials + * @param cp_R Vector of Dimensionless heat capacities. + * (length m_kk). + * @param h_RT Vector of Dimensionless enthalpies. + * (length m_kk). + * @param s_R Vector of Dimensionless entropies. + * (length m_kk). + */ + virtual void updateProperties(const doublereal* tt, + doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const { + + 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 + doublereal ct3 = m_coeff[5]*tt[2]; // a3 * T^3 + doublereal ct4 = m_coeff[6]*tt[3]; // a4 * T^4 + + doublereal cp, h, s; + cp = ct0 + ct1 + ct2 + ct3 + ct4; + h = ct0 + 0.5*ct1 + OneThird*ct2 + 0.25*ct3 + 0.2*ct4 + + m_coeff[0]*tt[4]; // last term is a5/T + s = ct0*tt[5] + ct1 + 0.5*ct2 + OneThird*ct3 + +0.25*ct4 + m_coeff[1]; // last term is a6 - // return the computed properties in the location in the output - // arrays for this species - cp_R[m_index] = cp; - h_RT[m_index] = h; - s_R[m_index] = s; - //writelog("NASA1: for species "+int2str(m_index)+", h_RT = "+ - // fp2str(h)+"\n"); - } + // return the computed properties in the location in the output + // arrays for this species + cp_R[m_index] = cp; + h_RT[m_index] = h; + s_R[m_index] = s; + //writelog("NASA1: for species "+int2str(m_index)+", h_RT = "+ + // fp2str(h)+"\n"); + } - /** - * updatePropertiesTemp(): - * This formulation creates its own temperature - * polynomial. Then, it calls updateProperties(); - * - * (note: this is slow, but it is general) - */ - virtual void updatePropertiesTemp(const doublereal temp, - 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); - updateProperties(tPoly, cp_R, h_RT, s_R); - } + + //! Compute the reference-state property of one species + /*! + * Given temperature T in K, this method updates the values of + * the non-dimensional heat capacity at constant pressure, + * enthalpy, and entropy, at the reference pressure, Pref + * of one of the species. The species index is used + * to reference into the cp_R, h_RT, and s_R arrays. + * + * @param temp Temperature (Kelvin) + * @param cp_R Vector of Dimensionless heat capacities. + * (length m_kk). + * @param h_RT Vector of Dimensionless enthalpies. + * (length m_kk). + * @param s_R Vector of Dimensionless entropies. + * (length m_kk). + */ + virtual void updatePropertiesTemp(const doublereal temp, + 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); + updateProperties(tPoly, cp_R, h_RT, s_R); + } - virtual void reportParameters(int &n, int &type, - doublereal &tlow, doublereal &thigh, - doublereal &pref, - doublereal* const coeffs) const { - n = m_index; - type = NASA1; - tlow = m_lowT; - thigh = m_highT; - pref = m_Pref; - coeffs[5] = m_coeff[0]; - coeffs[6] = m_coeff[1]; - for (int i = 2; i < 7; i++) { - coeffs[i-2] = m_coeff[i]; - } + //!This utility function reports back the type of + //! parameterization and all of the parameters for the + //! species, index. + /*! + * All parameters are output variables + * + * @param n Species index + * @param type Integer type of the standard type + * @param tlow output - Minimum temperature + * @param thigh output - Maximum temperature + * @param pref output - reference pressure (Pa). + * @param coeffs Vector of coefficients used to set the + * parameters for the standard state. + * + * @todo should be a const function. + */ + virtual void reportParameters(int &n, int &type, + doublereal &tlow, doublereal &thigh, + doublereal &pref, + doublereal* const coeffs) const { + n = m_index; + type = NASA1; + tlow = m_lowT; + thigh = m_highT; + pref = m_Pref; + coeffs[5] = m_coeff[0]; + coeffs[6] = m_coeff[1]; + for (int i = 2; i < 7; i++) { + coeffs[i-2] = m_coeff[i]; + } #ifdef WARN_ABOUT_CHANGES_FROM_VERSION_1_6 - cout << "************************************************\n" - cout << "Warning: NasaPoly1::reportParameters now returns \n" - << "the coefficient array in the same order as in\n" - << "the input file. See file NasaPoly1.h" << endl; - cout << "************************************************\n" + cout << "************************************************\n" + cout << "Warning: NasaPoly1::reportParameters now returns \n" + << "the coefficient array in the same order as in\n" + << "the input file. See file NasaPoly1.h" << endl; + cout << "************************************************\n" #endif } - virtual void modifyParameters(doublereal* coeffs) { - m_coeff[0] = coeffs[5]; - m_coeff[1] = coeffs[6]; - for (int i = 0; i < 5; i++) { - m_coeff[i+2] = coeffs[i]; - } - } + virtual void modifyParameters(doublereal* coeffs) { + m_coeff[0] = coeffs[5]; + m_coeff[1] = coeffs[6]; + for (int i = 0; i < 5; i++) { + m_coeff[i+2] = coeffs[i]; + } + } - protected: - - doublereal m_lowT; // lowest valid temperature - doublereal m_highT; // highest valid temperature - doublereal m_Pref; // standard-state pressure - int m_index; // species index - array_fp m_coeff; // array of polynomial coefficients - - private: + 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 + array_fp m_coeff; - }; + }; } #endif diff --git a/Cantera/src/NasaPoly2.h b/Cantera/src/NasaPoly2.h index 58e6ea977..44eaf6b91 100644 --- a/Cantera/src/NasaPoly2.h +++ b/Cantera/src/NasaPoly2.h @@ -1,5 +1,7 @@ /** - * @file NasaPoly1.h + * @file NasaPoly2.h + * + * Two zoned Nasa polynomial parameterization */ /* $Author$ @@ -17,197 +19,264 @@ namespace Cantera { - /** - * - * - * The NASA polynomial parameterization for one temperature range. - * This parameterization expresses the heat capacity as a - * fourth-order polynomial. Note that this is the form used in the - * 1971 NASA equilibrium program and by the Chemkin software - * package, but differs from the form used in the more recent NASA - * equilibrium program. - * - * Seven coefficients \f$(a_0,\dots,a_6)\f$ are used to represent - * \f$ c_p^0(T)\f$, \f$ h^0(T)\f$, and \f$ s^0(T) \f$ as - * polynomials in \f$ T \f$ : - * \f[ - * \frac{c_p(T)}{R} = a_0 + a_1 T + a_2 T^2 + a_3 T^3 + a_4 T^4 - * \f] - * \f[ - * \frac{h^0(T)}{RT} = a_0 + \frac{a_1}{2} T + \frac{a_2}{3} T^2 - * + \frac{a_3}{4} T^3 + \frac{a_4}{5} T^4 + \frac{a_5}{T}. - * \f] - * \f[ - * \frac{s^0(T)}{R} = a_0\ln T + a_1 T + \frac{a_2}{2} T^2 - + \frac{a_3}{3} T^3 + \frac{a_4}{4} T^4 + a_6. - * \f] - * - * This class is designed specifically for use by class - * GeneralSpeciesThermo. - * @ingroup spthermo + /** + * + * + * The NASA polynomial parameterization for two temperature ranges. + * This parameterization expresses the heat capacity as a + * fourth-order polynomial. Note that this is the form used in the + * 1971 NASA equilibrium program and by the Chemkin software + * package, but differs from the form used in the more recent NASA + * equilibrium program. + * + * Seven coefficients \f$(a_0,\dots,a_6)\f$ are used to represent + * \f$ c_p^0(T)\f$, \f$ h^0(T)\f$, and \f$ s^0(T) \f$ as + * polynomials in \f$ T \f$ : + * \f[ + * \frac{c_p(T)}{R} = a_0 + a_1 T + a_2 T^2 + a_3 T^3 + a_4 T^4 + * \f] + * \f[ + * \frac{h^0(T)}{RT} = a_0 + \frac{a_1}{2} T + \frac{a_2}{3} T^2 + * + \frac{a_3}{4} T^3 + \frac{a_4}{5} T^4 + \frac{a_5}{T}. + * \f] + * \f[ + * \frac{s^0(T)}{R} = a_0\ln T + a_1 T + \frac{a_2}{2} T^2 + + \frac{a_3}{3} T^3 + \frac{a_4}{4} T^4 + a_6. + * \f] + * + * This class is designed specifically for use by the class + * GeneralSpeciesThermo. + * + * @ingroup spthermo + */ + class NasaPoly2 : public SpeciesThermoInterpType { + + public: + + //! Empty constructor + NasaPoly2() + : m_lowT(0.0), + m_midT(0.0), + m_highT (0.0), + m_Pref(0.0), + mnp_low(0), + mnp_high(0), + m_index(0), + m_coeff(array_fp(15)) { + } + + //! Full Constructor + /*! + * @param n Species index + * @param tlow output - Minimum temperature + * @param thigh output - Maximum temperature + * @param pref output - reference pressure (Pa). + * @param coeffs Vector of coefficients used to set the + * parameters for the standard state. */ - class NasaPoly2 : public SpeciesThermoInterpType { + NasaPoly2(int n, doublereal tlow, doublereal thigh, doublereal pref, + const doublereal* coeffs) : + m_lowT(tlow), + m_highT(thigh), + m_Pref(pref), + mnp_low(0), + mnp_high(0), + m_index(n), + m_coeff(array_fp(15)) { - public: + std::copy(coeffs, coeffs + 15, m_coeff.begin()); + m_midT = coeffs[0]; + mnp_low = new NasaPoly1(m_index, m_lowT, m_midT, + m_Pref, &m_coeff[1]); + mnp_high = new NasaPoly1(m_index, m_midT, m_highT, + m_Pref, &m_coeff[8]); + } - NasaPoly2() - : m_lowT(0.0), - m_midT(0.0), - m_highT (0.0), - m_Pref(0.0), - mnp_low(0), - mnp_high(0), - m_index(0), - m_coeff(array_fp(15)) { - } + //! Copy Constructor + /*! + * @param b objecto to be copied. + */ + NasaPoly2(const NasaPoly2& b) : + m_lowT(b.m_lowT), + m_midT(b.m_midT), + m_highT(b.m_highT), + m_Pref(b.m_Pref), + mnp_low(0), + mnp_high(0), + m_index(b.m_index), + m_coeff(array_fp(15)) { - NasaPoly2(int n, doublereal tlow, doublereal thigh, doublereal pref, - const doublereal* coeffs) : - m_lowT(tlow), - m_highT(thigh), - m_Pref(pref), - mnp_low(0), - mnp_high(0), - m_index(n), - m_coeff(array_fp(15)) { + std::copy(b.m_coeff.begin(), + b.m_coeff.begin() + 15, + m_coeff.begin()); + mnp_low = new NasaPoly1(m_index, m_lowT, m_midT, + m_Pref, &m_coeff[1]); + mnp_high = new NasaPoly1(m_index, m_midT, m_highT, + m_Pref, &m_coeff[8]); + } - std::copy(coeffs, coeffs + 15, m_coeff.begin()); - m_midT = coeffs[0]; - mnp_low = new NasaPoly1(m_index, m_lowT, m_midT, - m_Pref, &m_coeff[1]); - mnp_high = new NasaPoly1(m_index, m_midT, m_highT, - m_Pref, &m_coeff[8]); - } + //! Assignment operator + /*! + * @param b objecto to be copied. + */ + NasaPoly2& operator=(const NasaPoly2& b) { + if (&b != this) { + m_lowT = b.m_lowT; + 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()); + if (mnp_low) delete mnp_low; + if (mnp_high) delete mnp_high; + mnp_low = new NasaPoly1(m_index, m_lowT, m_midT, + m_Pref, &m_coeff[1]); + mnp_high = new NasaPoly1(m_index, m_midT, m_highT, + m_Pref, &m_coeff[8]); + } + return *this; + } - NasaPoly2(const NasaPoly2& b) : - m_lowT(b.m_lowT), - m_midT(b.m_midT), - m_highT(b.m_highT), - m_Pref(b.m_Pref), - mnp_low(0), - mnp_high(0), - m_index(b.m_index), - m_coeff(array_fp(15)) { + //! destructor + virtual ~NasaPoly2(){ + delete mnp_low; + delete mnp_high; + } - std::copy(b.m_coeff.begin(), - b.m_coeff.begin() + 15, - m_coeff.begin()); - mnp_low = new NasaPoly1(m_index, m_lowT, m_midT, - m_Pref, &m_coeff[1]); - mnp_high = new NasaPoly1(m_index, m_midT, m_highT, - m_Pref, &m_coeff[8]); - } + //! duplicator + virtual SpeciesThermoInterpType * + duplMyselfAsSpeciesThermoInterpType() const { + NasaPoly2* np = new NasaPoly2(*this); + return (SpeciesThermoInterpType *) np; + } - NasaPoly2& operator=(const NasaPoly2& b) { - if (&b != this) { - m_lowT = b.m_lowT; - 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()); - if (mnp_low) delete mnp_low; - if (mnp_high) delete mnp_high; - mnp_low = new NasaPoly1(m_index, m_lowT, m_midT, - m_Pref, &m_coeff[1]); - mnp_high = new NasaPoly1(m_index, m_midT, m_highT, - m_Pref, &m_coeff[8]); - } - return *this; - } + //! Returns the minimum temperature that the thermo + //! parameterization is valid + doublereal minTemp() const { return m_lowT;} - virtual ~NasaPoly2(){ - delete mnp_low; - delete mnp_high; - } + //! Returns the maximum temperature that the thermo + //! parameterization is valid + doublereal maxTemp() const { return m_highT;} - virtual SpeciesThermoInterpType * - duplMyselfAsSpeciesThermoInterpType() const { - NasaPoly2* np = new NasaPoly2(*this); - 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; } - - /** - * Update the properties for this species. This method is called - * with a pointer to an array containing the functions of - * temperature needed by this - * parameterization, and three pointers to arrays where the - * computed property values - * should be written. This method updates only one value in - * each array. - * - * Temperature Polynomial: - * tt[0] = t; - * tt[1] = t*t; - * tt[2] = m_t[1]*t; - * tt[3] = m_t[2]*t; - * tt[4] = 1.0/t; - * tt[5] = log(t); - */ - void updateProperties(const doublereal* tt, - doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const { + //! Returns the reference pressure (Pa) + doublereal refPressure() const { return m_Pref; } + + //! Returns an integer representing the type of parameterization + virtual int reportType() const { return NASA2; } + + + //! Update the properties for this species, given a temperature polynomial + /*! + * This method is called with a pointer to an array containing the functions of + * temperature needed by this parameterization, and three pointers to arrays where the + * computed property values should be written. This method updates only one value in + * each array. + * + * Temperature Polynomial: + * tt[0] = t; + * tt[1] = t*t; + * tt[2] = m_t[1]*t; + * tt[3] = m_t[2]*t; + * tt[4] = 1.0/t; + * tt[5] = std::log(t); + * + * @param tt vector of temperature polynomials + * @param cp_R Vector of Dimensionless heat capacities. + * (length m_kk). + * @param h_RT Vector of Dimensionless enthalpies. + * (length m_kk). + * @param s_R Vector of Dimensionless entropies. + * (length m_kk). + */ + void updateProperties(const doublereal* tt, + doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const { - double T = tt[0]; - if (T <= m_midT) { - mnp_low->updateProperties(tt, cp_R, h_RT, s_R); - } else { - mnp_high->updateProperties(tt, cp_R, h_RT, s_R); - } - } + double T = tt[0]; + if (T <= m_midT) { + mnp_low->updateProperties(tt, cp_R, h_RT, s_R); + } else { + mnp_high->updateProperties(tt, cp_R, h_RT, s_R); + } + } - /** - * updatePropertiesTemp(): - * This formulation creates its own temperature - * polynomial. Then, it calls updateProperties(); - * - * (note: this is slow, but it is general) - */ - void updatePropertiesTemp(const doublereal temp, - doublereal* cp_R, - doublereal* h_RT, - doublereal* s_R) const { - if (temp <= m_midT) { - mnp_low->updatePropertiesTemp(temp, cp_R, h_RT, s_R); - } else { - mnp_high->updatePropertiesTemp(temp, cp_R, h_RT, s_R); - } - } + //! Compute the reference-state property of one species + /*! + * Given temperature T in K, this method updates the values of + * the non-dimensional heat capacity at constant pressure, + * enthalpy, and entropy, at the reference pressure, Pref + * of one of the species. The species index is used + * to reference into the cp_R, h_RT, and s_R arrays. + * + * @param temp Temperature (Kelvin) + * @param cp_R Vector of Dimensionless heat capacities. + * (length m_kk). + * @param h_RT Vector of Dimensionless enthalpies. + * (length m_kk). + * @param s_R Vector of Dimensionless entropies. + * (length m_kk). + */ + void updatePropertiesTemp(const doublereal temp, + doublereal* cp_R, + doublereal* h_RT, + doublereal* s_R) const { + if (temp <= m_midT) { + mnp_low->updatePropertiesTemp(temp, cp_R, h_RT, s_R); + } else { + mnp_high->updatePropertiesTemp(temp, cp_R, h_RT, s_R); + } + } - void reportParameters(int &n, int &type, - doublereal &tlow, doublereal &thigh, - doublereal &pref, - doublereal* const coeffs) const { - n = m_index; - type = NASA2; - tlow = m_lowT; - thigh = m_highT; - pref = m_Pref; - for (int i = 0; i < 15; i++) { - coeffs[i] = m_coeff[i]; - } - } + //!This utility function reports back the type of + //! parameterization and all of the parameters for the + //! species, index. + /*! + * All parameters are output variables + * + * @param n Species index + * @param type Integer type of the standard type + * @param tlow output - Minimum temperature + * @param thigh output - Maximum temperature + * @param pref output - reference pressure (Pa). + * @param coeffs Vector of coefficients used to set the + * parameters for the standard state. + * + * @todo should be a const function. + */ + void reportParameters(int &n, int &type, + doublereal &tlow, doublereal &thigh, + doublereal &pref, + doublereal* const coeffs) const { + n = m_index; + type = NASA2; + tlow = m_lowT; + thigh = m_highT; + pref = m_Pref; + for (int i = 0; i < 15; i++) { + coeffs[i] = m_coeff[i]; + } + } - protected: - - doublereal m_lowT; // lowest valid temperature - doublereal m_midT; - doublereal m_highT; // highest valid temperature - doublereal m_Pref; // standard-state pressure - NasaPoly1 *mnp_low; - NasaPoly1 *mnp_high; - int m_index; // species index - array_fp m_coeff; // array of polynomial coefficients - - private: + protected: + //! lowest valid temperature + doublereal m_lowT; + //! Midrange temperature + doublereal m_midT; + //! Highest valid temperatre + doublereal m_highT; + //! Reference state pressure + doublereal m_Pref; + //! pointer to the NasaPoly1 object for the low temperature region. + NasaPoly1 *mnp_low; + //! pointer to the NasaPoly1 object for the high temperature region. + NasaPoly1 *mnp_high; + //! species index + int m_index; + //! array of polynomial coefficients + array_fp m_coeff; - }; + }; } #endif diff --git a/Cantera/src/NasaThermo.h b/Cantera/src/NasaThermo.h index de6899a66..bbd24ca0d 100755 --- a/Cantera/src/NasaThermo.h +++ b/Cantera/src/NasaThermo.h @@ -1,5 +1,8 @@ /** * @file NasaThermo.h + * + * Definitions for the 2 regime 7 coefficient Nasa thermodynamic + * polynomials. */ /* @@ -21,320 +24,468 @@ namespace Cantera { - /** - * A species thermodynamic property manager for the NASA - * polynomial parameterization with two temperature ranges. - * - * This class is designed to efficiently evaluate the properties - * of a large number of species with the NASA parameterization. - * - * The original NASA polynomial parameterization expressed the - * heat capacity as a fourth-order polynomial in temperature, with - * separate coefficients for each of two temperature ranges. (The - * newer NASA format adds coefficients for 1/T and 1/T^2, and - * allows multiple temperature ranges.) This class is designed for - * use with the original parameterization, which is used, for - * example, by the Chemkin software package. - * - * In many cases, the midpoint temperature is the same for many - * species. To take advantage of this, class NasaThermo groups - * species with a common midpoint temperature, so that checking - * which range the desired temperature is in need be done only - * once for each group. - * - * @note There is a special CTML element for entering the - * coefficients of this parameterization. - * @see importCTML - */ - class NasaThermo : public SpeciesThermo { + /** + * A species thermodynamic property manager for the NASA + * polynomial parameterization with two temperature ranges. + * + * This class is designed to efficiently evaluate the properties + * of a large number of species with the NASA parameterization. + * + * The original NASA polynomial parameterization expressed the + * heat capacity as a fourth-order polynomial in temperature, with + * separate coefficients for each of two temperature ranges. (The + * newer NASA format adds coefficients for 1/T and 1/T^2, and + * allows multiple temperature ranges.) This class is designed for + * use with the original parameterization, which is used, for + * example, by the Chemkin software package. + * + * In many cases, the midpoint temperature is the same for many + * species. To take advantage of this, class NasaThermo groups + * species with a common midpoint temperature, so that checking + * which range the desired temperature is in need be done only + * once for each group. + * + * @note There is a special CTML element for entering the + * coefficients of this parameterization. + * @see importCTML + * + * @ingroup spthermo + */ + class NasaThermo : public SpeciesThermo { - public: + public: - const int ID; + //! Initialized to the type of parameterization + /*! + * Note, this value is used in some template functions + */ + const int ID; - NasaThermo() : - ID(NASA), - m_tlow_max(0.0), - m_thigh_min(1.e30), - m_ngroups(0) { m_t.resize(6); } + //! constructor + NasaThermo() : + ID(NASA), + m_tlow_max(0.0), + m_thigh_min(1.e30), + m_p0(-1.0), + m_ngroups(0) + { + m_t.resize(6); + } - virtual ~NasaThermo() {} + //! destructor + virtual ~NasaThermo() {} - /** - * Install parameterization for a species. - * @param index Species index - * @param type ignored, since only NASA type is supported - * @param c coefficients. These are - * - c[0] midpoint temperature - * - c[1] - c[7] coefficients for low T range - * - c[8] - c[14] coefficients for high T range - */ - virtual void install(string name, int index, int type, - const doublereal* c, - doublereal minTemp, doublereal maxTemp, - doublereal refPressure) { + //! install a new species thermodynamic property + //! parameterization for one species. + /*! + * + * @param name Name of the species + * @param index The 'update' method will update the property + * values for this species + * at position i index in the property arrays. + * @param type int flag specifying the type of parameterization to be + * installed. + * @param c vector of coefficients for the parameterization. + * - c[0] midpoint temperature + * - c[1] - c[7] coefficients for low T range + * - c[8] - c[14] coefficients for high T range + * @param minTemp minimum temperature for which this parameterization + * is valid. + * @param maxTemp maximum temperature for which this parameterization + * is valid. + * @param refPressure standard-state pressure for this + * parameterization. + * @see speciesThermoTypes.h + */ + virtual void install(string name, int index, int type, + const doublereal* c, + doublereal minTemp, doublereal maxTemp, + doublereal refPressure) { - m_name[index] = name; - int imid = int(c[0]); // midpoint temp converted to integer - int igrp = m_index[imid]; // has this value been seen before? - if (igrp == 0) { // if not, prepare new group - vector v; - m_high.push_back(v); - m_low.push_back(v); - m_tmid.push_back(c[0]); - m_index[imid] = igrp = static_cast(m_high.size()); - m_ngroups++; - } + m_name[index] = name; + int imid = int(c[0]); // midpoint temp converted to integer + int igrp = m_index[imid]; // has this value been seen before? + if (igrp == 0) { // if not, prepare new group + vector v; + m_high.push_back(v); + m_low.push_back(v); + m_tmid.push_back(c[0]); + m_index[imid] = igrp = static_cast(m_high.size()); + m_ngroups++; + } - m_group_map[index] = igrp; - m_posInGroup_map[index] = (int) m_low[igrp-1].size(); + m_group_map[index] = igrp; + m_posInGroup_map[index] = (int) m_low[igrp-1].size(); - doublereal tlow = minTemp; - doublereal tmid = c[0]; - doublereal thigh = maxTemp; - doublereal pref = refPressure; - const doublereal* clow = c + 1; + doublereal tlow = minTemp; + doublereal tmid = c[0]; + doublereal thigh = maxTemp; + const doublereal* clow = c + 1; - vector_fp chigh(7); - copy(c + 8, c + 15, chigh.begin()); + vector_fp chigh(7); + copy(c + 8, c + 15, chigh.begin()); - m_high[igrp-1].push_back(NasaPoly1(index, tmid, thigh, - pref, &chigh[0])); - m_low[igrp-1].push_back(NasaPoly1(index, tlow, tmid, - pref, clow)); + m_high[igrp-1].push_back(NasaPoly1(index, tmid, thigh, + refPressure, &chigh[0])); + m_low[igrp-1].push_back(NasaPoly1(index, tlow, tmid, + refPressure, clow)); - vector_fp clu(7), chu(7); - clu[5] = clow[0]; - clu[6] = clow[1]; - copy(clow+2, clow+7, clu.begin()); - chu[5] = chigh[0]; - chu[6] = chigh[1]; - copy(chigh.begin()+2, chigh.begin()+7, chu.begin()); + vector_fp clu(7), chu(7); + clu[5] = clow[0]; + clu[6] = clow[1]; + copy(clow+2, clow+7, clu.begin()); + chu[5] = chigh[0]; + chu[6] = chigh[1]; + copy(chigh.begin()+2, chigh.begin()+7, chu.begin()); - checkContinuity(name, tmid, &clu[0], &chu[0]); + checkContinuity(name, tmid, &clu[0], &chu[0]); - if (tlow > m_tlow_max) m_tlow_max = tlow; - if (thigh < m_thigh_min) m_thigh_min = thigh; - m_tlow.push_back(tlow); - m_thigh.push_back(thigh); - m_p0 = pref; - } + if (tlow > m_tlow_max) m_tlow_max = tlow; + if (thigh < m_thigh_min) m_thigh_min = thigh; + if ((int) m_tlow.size() < index + 1) { + m_tlow.resize(index + 1, tlow); + m_thigh.resize(index + 1, thigh); + } + m_tlow[index] = tlow; + m_thigh[index] = thigh; + if (m_p0 < 0.0) { + m_p0 = refPressure; + } else if (fabs(m_p0 - refPressure) > 0.1) { + string logmsg = " WARNING NasaThermo: New Species, " + name + ", has a different reference pressure, " + + fp2str(refPressure) + ", than existing reference pressure, " + fp2str(m_p0) + "\n"; + writelog(logmsg); + logmsg = " This may become a fatal error in the future \n"; + writelog(logmsg); + } + m_p0 = refPressure; + } - /** - * update the properties for only one species. - */ - virtual void update_one(int k, doublereal t, doublereal* cp_R, - doublereal* h_RT, doublereal* s_R) const { + //! Like update(), but only updates the single species k. + /*! + * @param k species index + * @param t Temperature (Kelvin) + * @param cp_R Vector of Dimensionless heat capacities. + * (length m_kk). + * @param h_RT Vector of Dimensionless enthalpies. + * (length m_kk). + * @param s_R Vector of Dimensionless entropies. + * (length m_kk). + * + */ + virtual void update_one(int k, doublereal t, doublereal* cp_R, + doublereal* h_RT, doublereal* s_R) const { - m_t[0] = t; - m_t[1] = t*t; - m_t[2] = m_t[1]*t; - m_t[3] = m_t[2]*t; - m_t[4] = 1.0/t; - m_t[5] = log(t); + m_t[0] = t; + m_t[1] = t*t; + m_t[2] = m_t[1]*t; + m_t[3] = m_t[2]*t; + m_t[4] = 1.0/t; + m_t[5] = log(t); - int grp = m_group_map[k]; - int pos = m_posInGroup_map[k]; - const vector &mlg = m_low[grp-1]; - const NasaPoly1 *nlow = &(mlg[pos]); + int grp = m_group_map[k]; + int pos = m_posInGroup_map[k]; + const vector &mlg = m_low[grp-1]; + const NasaPoly1 *nlow = &(mlg[pos]); - doublereal tmid = nlow->maxTemp(); - if (t < tmid) { - nlow->updateProperties(&m_t[0], cp_R, h_RT, s_R); - } else { - const vector &mhg = m_high[grp-1]; - const NasaPoly1 *nhigh = &(mhg[pos]); - nhigh->updateProperties(&m_t[0], cp_R, h_RT, s_R); - } - } + doublereal tmid = nlow->maxTemp(); + if (t < tmid) { + nlow->updateProperties(&m_t[0], cp_R, h_RT, s_R); + } else { + const vector &mhg = m_high[grp-1]; + const NasaPoly1 *nhigh = &(mhg[pos]); + nhigh->updateProperties(&m_t[0], cp_R, h_RT, s_R); + } + } + //! Compute the reference-state properties for all species. + /*! + * Given temperature T in K, this method updates the values of + * the non-dimensional heat capacity at constant pressure, + * enthalpy, and entropy, at the reference pressure, Pref + * of each of the standard states. + * + * @param t Temperature (Kelvin) + * @param cp_R Vector of Dimensionless heat capacities. + * (length m_kk). + * @param h_RT Vector of Dimensionless enthalpies. + * (length m_kk). + * @param s_R Vector of Dimensionless entropies. + * (length m_kk). + */ + virtual void update(doublereal t, doublereal* cp_R, + doublereal* h_RT, doublereal* s_R) const { + int i; - virtual void update(doublereal t, doublereal* cp_R, - doublereal* h_RT, doublereal* s_R) const { - int i; + // load functions of temperature into m_t vector + m_t[0] = t; + m_t[1] = t*t; + m_t[2] = m_t[1]*t; + m_t[3] = m_t[2]*t; + m_t[4] = 1.0/t; + m_t[5] = log(t); - // load functions of temperature into m_t vector - m_t[0] = t; - m_t[1] = t*t; - m_t[2] = m_t[1]*t; - m_t[3] = m_t[2]*t; - m_t[4] = 1.0/t; - m_t[5] = log(t); - - // iterate over the groups - vector::const_iterator _begin, _end; - for (i = 0; i != m_ngroups; i++) { - if (t > m_tmid[i]) { - _begin = m_high[i].begin(); - _end = m_high[i].end(); - } - else { - _begin = m_low[i].begin(); - _end = m_low[i].end(); - } - for (; _begin != _end; ++_begin) - _begin->updateProperties(&m_t[0], cp_R, h_RT, s_R); - } - } + // iterate over the groups + vector::const_iterator _begin, _end; + for (i = 0; i != m_ngroups; i++) { + if (t > m_tmid[i]) { + _begin = m_high[i].begin(); + _end = m_high[i].end(); + } + else { + _begin = m_low[i].begin(); + _end = m_low[i].end(); + } + for (; _begin != _end; ++_begin) + _begin->updateProperties(&m_t[0], cp_R, h_RT, s_R); + } + } - /** - * Return the lowest temperature at which the thermodynamic - * parameterization is valid. If no argument is supplied, the - * value is the one for which all species parameterizations - * are valid. Otherwise, if an integer argument is given, the - * value applies only to the species with that index. - */ - virtual doublereal minTemp(int k=-1) const { - if (k < 0) - return m_tlow_max; - else - return m_tlow[k]; - } + //! Minimum temperature. + /*! + * If no argument is supplied, this + * method returns the minimum temperature for which \e all + * parameterizations are valid. If an integer index k is + * supplied, then the value returned is the minimum + * temperature for species k in the phase. + * + * @param k Species index + */ + virtual doublereal minTemp(int k=-1) const { + if (k < 0) + return m_tlow_max; + else + return m_tlow[k]; + } - virtual doublereal maxTemp(int k=-1) const { - if (k < 0) - return m_thigh_min; - else - return m_thigh[k]; - } + //! Maximum temperature. + /*! + * If no argument is supplied, this + * method returns the maximum temperature for which \e all + * parameterizations are valid. If an integer index k is + * supplied, then the value returned is the maximum + * temperature for parameterization k. + * + * @param k index for parameterization k + */ + virtual doublereal maxTemp(int k=-1) const { + if (k < 0) + return m_thigh_min; + else + return m_thigh[k]; + } + + //! The reference-state pressure for species k. + /*! + * + * returns the reference state pressure in Pascals for + * species k. If k is left out of the argument list, + * it returns the reference state pressure for the first + * species. + * Note that some SpeciesThermo implementations, such + * as those for ideal gases, require that all species + * in the same phase have the same reference state pressures. + * + * @param k index for parameterization k + */ + virtual doublereal refPressure(int k = -1) const { + return m_p0; + } - virtual doublereal refPressure(int k = -1) const { - return m_p0; - } + //! This utility function reports the type of parameterization + //! used for the species with index number index. + /*! + * + * @param index Species index + */ + virtual int reportType(int index) const { return NASA; } - /** - * This utility function reports the type of parameterization - * used for the species, index. - */ - virtual int reportType(int index) const { return NASA; } - - /** - * This utility function reports back the type of - * parameterization and all of the parameters for the - * species, index. - * For the NASA object, there are 15 coefficients. - */ - virtual void reportParams(int index, int &type, - doublereal * const c, - doublereal &minTemp, - doublereal &maxTemp, - doublereal &refPressure) { - type = reportType(index); - if (type == NASA) { - int grp = m_group_map[index]; - int pos = m_posInGroup_map[index]; - const vector &mlg = m_low[grp-1]; - const vector &mhg = m_high[grp-1]; - const NasaPoly1 *lowPoly = &(mlg[pos]); - const NasaPoly1 *highPoly = &(mhg[pos]); - int itype = NASA; - doublereal tmid = lowPoly->maxTemp(); - c[0] = tmid; - int n; - double ttemp; - lowPoly->reportParameters(n, itype, minTemp, ttemp, refPressure, - c + 1); - if (n != index) { - throw CanteraError(" ", "confused"); - } - if (itype != NASA1) { - throw CanteraError(" ", "confused"); - } - highPoly->reportParameters(n, itype, ttemp, maxTemp, refPressure, - c + 8); - if (n != index) { - throw CanteraError(" ", "confused"); - } - if (itype != NASA1) { - throw CanteraError(" ", "confused"); - } - } else { - throw CanteraError(" ", "confused"); - } + /*! + * This utility function reports back the type of + * parameterization and all of the parameters for the + * species, index. + * + * @param index Species index + * @param type Integer type of the standard type + * @param c Vector of coefficients used to set the + * parameters for the standard state. + * For the NASA object, there are 15 coefficients. + * @param minTemp output - Minimum temperature + * @param maxTemp output - Maximum temperature + * @param refPressure output - reference pressure (Pa). + */ + virtual void reportParams(int index, int &type, + doublereal * const c, + doublereal &minTemp, + doublereal &maxTemp, + doublereal &refPressure) { + type = reportType(index); + if (type == NASA) { + int grp = m_group_map[index]; + int pos = m_posInGroup_map[index]; + const vector &mlg = m_low[grp-1]; + const vector &mhg = m_high[grp-1]; + const NasaPoly1 *lowPoly = &(mlg[pos]); + const NasaPoly1 *highPoly = &(mhg[pos]); + int itype = NASA; + doublereal tmid = lowPoly->maxTemp(); + c[0] = tmid; + int n; + double ttemp; + lowPoly->reportParameters(n, itype, minTemp, ttemp, refPressure, + c + 1); + if (n != index) { + throw CanteraError(" ", "confused"); } - - - /** - * This utility function modifies the array of coefficients. - * The array is the same as that returned by reportParams, so - * a call can first be made to reportParams to populate the - * array, and then modifyParams can be called to alter - * selected values. For the NASA object, there are 15 - * coefficients. - */ - virtual void modifyParams(int index, doublereal *c) { - int type = reportType(index); - if (type == NASA) { - int grp = m_group_map[index]; - int pos = m_posInGroup_map[index]; - vector &mlg = m_low[grp-1]; - vector &mhg = m_high[grp-1]; - NasaPoly1 *lowPoly = &(mlg[pos]); - NasaPoly1 *highPoly = &(mhg[pos]); - doublereal tmid = lowPoly->maxTemp(); - if (c[0] != tmid) { - throw CanteraError(" ", "Tmid cannot be changed"); - } - lowPoly->modifyParameters(c + 1); - highPoly->modifyParameters(c + 8); - checkContinuity(m_name[index], c[0], c + 1, c + 8); - } else { - throw CanteraError(" ", "confused"); - } + if (itype != NASA1) { + throw CanteraError(" ", "confused"); } + highPoly->reportParameters(n, itype, ttemp, maxTemp, refPressure, + c + 8); + if (n != index) { + throw CanteraError(" ", "confused"); + } + if (itype != NASA1) { + throw CanteraError(" ", "confused"); + } + } else { + throw CanteraError(" ", "confused"); + } + } + //! Modify parameters for the standard state + /*! + * This utility function modifies the array of coefficients. + * The array is the same as that returned by reportParams, so + * a call can first be made to reportParams to populate the + * array, and then modifyParams can be called to alter + * selected values. For the NASA object, there are 15 + * coefficients. - protected: + * @param index Species index + * @param c Vector of coefficients used to set the + * parameters for the standard state. + */ + virtual void modifyParams(int index, doublereal *c) { + int type = reportType(index); + if (type == NASA) { + int grp = m_group_map[index]; + int pos = m_posInGroup_map[index]; + vector &mlg = m_low[grp-1]; + vector &mhg = m_high[grp-1]; + NasaPoly1 *lowPoly = &(mlg[pos]); + NasaPoly1 *highPoly = &(mhg[pos]); + doublereal tmid = lowPoly->maxTemp(); + if (c[0] != tmid) { + throw CanteraError(" ", "Tmid cannot be changed"); + } + lowPoly->modifyParameters(c + 1); + highPoly->modifyParameters(c + 8); + checkContinuity(m_name[index], c[0], c + 1, c + 8); + } else { + throw CanteraError(" ", "confused"); + } + } - vector > m_high; - vector > m_low; - map m_index; - vector_fp m_tmid; - doublereal m_tlow_max; - doublereal m_thigh_min; - vector_fp m_tlow; - vector_fp m_thigh; - doublereal m_p0; - int m_ngroups; - mutable vector_fp m_t; + protected: + //! Vector of vector of NasaPoly1's for the high temp region. + /*! + * This is the high temp region representation. + * The first Length is equal to the number of groups. + * The second vector is equal to the number of species + * in that particular group. + */ + vector > m_high; + + //! Vector of vector of NasaPoly1's for the low temp region. + /*! + * This is the low temp region representation. + * The first Length is equal to the number of groups. + * The second vector is equal to the number of species + * in that particular group. + */ + vector > m_low; - /*! - * This map takes as its index, the species index in the phase. - * It returns the group index, where the temperature polynomials - * for that species are stored. group indecises start at 1, - * so a decrement is always performed to access vectors. - */ - mutable map m_group_map; + //! Map between the midpoint temperature, as an int, to the group number + /*! + * Length is equal to the number of groups. Only used in the setup. + */ + map m_index; - /*! - * This map takes as its index, the species index in the phase. - * It returns the position index within the group, where the - * temperature polynomials for that species are storred. - */ - mutable map m_posInGroup_map; - mutable map m_name; + //! Vector of log temperature limits + /*! + * Length is equal to the number of groups. + */ + vector_fp m_tmid; - private: + //! Maximum value of the low temperature limit + + doublereal m_tlow_max; - // see SpeciesThermoFactory.cpp for the definition - void checkContinuity(string name, double tmid, const doublereal* clow, - doublereal* chigh); + //! Minimum value of the high temperature limit + doublereal m_thigh_min; + //! Vector of low temperature limits (species index) + /*! + * Length is equal to number of species + */ + vector_fp m_tlow; - /// for internal use by checkContinuity - doublereal enthalpy_RT(double t, const doublereal* c) { - return c[0] + 0.5*c[1]*t + OneThird*c[2]*t*t - + 0.25*c[3]*t*t*t + 0.2*c[4]*t*t*t*t - + c[5]/t; - } + //! Vector of low temperature limits (species index) + /*! + * Length is equal to number of species + */ + vector_fp m_thigh; - /// for internal use by checkContinuity - doublereal entropy_R(double t, const doublereal* c) { - return c[0]*log(t) + c[1]*t + 0.5*c[2]*t*t - + OneThird*c[3]*t*t*t + 0.25*c[4]*t*t*t*t - + c[6]; - } + //! Reference pressure (Pa) + /*! + * all species must have the same reference pressure. + */ + doublereal m_p0; - }; + //! number of groups + int m_ngroups; + + //! Vector of temperature polynomials + mutable vector_fp m_t; + + /*! + * This map takes as its index, the species index in the phase. + * It returns the group index, where the temperature polynomials + * for that species are stored. group indecises start at 1, + * so a decrement is always performed to access vectors. + */ + mutable map m_group_map; + + /*! + * This map takes as its index, the species index in the phase. + * It returns the position index within the group, where the + * temperature polynomials for that species are storred. + */ + mutable map m_posInGroup_map; + + //! Species name as a function of the species index + mutable map m_name; + + private: + + //! see SpeciesThermoFactory.cpp for the definition + void checkContinuity(std::string name, double tmid, const doublereal* clow, + doublereal* chigh); + + //! for internal use by checkContinuity + doublereal enthalpy_RT(double t, const doublereal* c) { + return c[0] + 0.5*c[1]*t + OneThird*c[2]*t*t + + 0.25*c[3]*t*t*t + 0.2*c[4]*t*t*t*t + + c[5]/t; + } + + //! for internal use by checkContinuity + doublereal entropy_R(double t, const doublereal* c) { + return c[0]*log(t) + c[1]*t + 0.5*c[2]*t*t + + OneThird*c[3]*t*t*t + 0.25*c[4]*t*t*t*t + + c[6]; + } + + }; } diff --git a/Cantera/src/SpeciesThermo.h b/Cantera/src/SpeciesThermo.h index d082fa927..18e646a66 100755 --- a/Cantera/src/SpeciesThermo.h +++ b/Cantera/src/SpeciesThermo.h @@ -73,11 +73,14 @@ namespace Cantera { * The following classes inherit from %SpeciesThermo * * - NasaThermo in file NasaThermo.h - * - This is a two zone model, with each zone consisting of a 7 coefficient Nasa Polynomial format. + * - This is a two zone model, with each zone consisting of a 7 + * coefficient Nasa Polynomial format. * . * - ShomateThermo in file ShomateThermo.h * - SimpleThermo in file SimpleThermo.h * - GeneralSpeciesThermo in file GeneralSpeciesThermo.h + * - SpeciesThermo1 in file SpeciesThermoMgr.h + * - SpeciesThermoDuo in file SpeciesThermoMgr.h * . * The class SpeciesThermoInterpType is a virtual base class for * calculation of thermodynamic functions for a single species @@ -117,9 +120,10 @@ namespace Cantera { //! Destructor virtual ~SpeciesThermo() {} - /** - * install a new species thermodynamic property - * parameterization for one species. + + //! install a new species thermodynamic property + //! parameterization for one species. + /*! * * @param name Name of the species * @param index The 'update' method will update the property @@ -208,9 +212,9 @@ namespace Cantera { * @param k index for parameterization k */ virtual doublereal maxTemp(int k=-1) const =0; - - /** - * The reference-state pressure for species k. + + //! The reference-state pressure for species k. + /*! * * returns the reference state pressure in Pascals for * species k. If k is left out of the argument list, diff --git a/Cantera/src/SpeciesThermoInterpType.h b/Cantera/src/SpeciesThermoInterpType.h index 0a33e89ca..04e8ba4e9 100644 --- a/Cantera/src/SpeciesThermoInterpType.h +++ b/Cantera/src/SpeciesThermoInterpType.h @@ -61,7 +61,7 @@ namespace Cantera { //! Update the properties for this species, given a temperature polynomial /*! - * This method is calledwith a pointer to an array containing the functions of + * This method is called with a pointer to an array containing the functions of * temperature needed by this parameterization, and three pointers to arrays where the * computed property values should be written. This method updates only one value in * each array.