NasaPoly2.h

Go to the documentation of this file.
00001 /**
00002  *  @file NasaPoly2.h
00003  *  Header for a single-species standard state object derived
00004  *  from \link Cantera::SpeciesThermoInterpType SpeciesThermoInterpType\endlink  based 
00005  *  on the NASA temperature polynomial form applied to two temperature regions
00006  *  (see \ref spthermo and class \link Cantera::NasaPoly2 NasaPoly2\endlink).
00007  *
00008  *  Two zoned Nasa polynomial parameterization
00009  */
00010 
00011 /* $Author: hkmoffa $
00012  * $Revision: 279 $
00013  * $Date: 2009-12-05 14:08:43 -0500 (Sat, 05 Dec 2009) $
00014  */
00015 
00016 // Copyright 2001  California Institute of Technology
00017 
00018 
00019 #ifndef CT_NASAPOLY2_H
00020 #define CT_NASAPOLY2_H
00021 
00022 #include "SpeciesThermoInterpType.h"
00023 
00024 namespace Cantera {
00025 
00026   /**
00027    *
00028    * 
00029    * The NASA polynomial parameterization for two temperature ranges.
00030    * This parameterization expresses the heat capacity as a
00031    * fourth-order polynomial. Note that this is the form used in the
00032    * 1971 NASA equilibrium program and by the Chemkin software
00033    * package, but differs from the form used in the more recent NASA
00034    * equilibrium program.
00035    *
00036    * Seven coefficients \f$(a_0,\dots,a_6)\f$ are used to represent
00037    * \f$ c_p^0(T)\f$, \f$ h^0(T)\f$, and \f$ s^0(T) \f$ as 
00038    * polynomials in \f$ T \f$ :  
00039    * \f[
00040    * \frac{c_p(T)}{R} = a_0 + a_1 T + a_2 T^2 + a_3 T^3 + a_4 T^4
00041    * \f]
00042    * \f[
00043    * \frac{h^0(T)}{RT} = a_0 + \frac{a_1}{2} T + \frac{a_2}{3} T^2 
00044    * + \frac{a_3}{4} T^3 + \frac{a_4}{5} T^4  + \frac{a_5}{T}.
00045    * \f]
00046    * \f[
00047    * \frac{s^0(T)}{R} = a_0\ln T + a_1 T + \frac{a_2}{2} T^2 
00048    + \frac{a_3}{3} T^3 + \frac{a_4}{4} T^4  + a_6.
00049    * \f]
00050    * 
00051    * This class is designed specifically for use by the class 
00052    * GeneralSpeciesThermo.
00053    *
00054    * @ingroup spthermo
00055    */
00056   class NasaPoly2 : public SpeciesThermoInterpType {
00057 
00058   public:
00059 
00060     //! Empty constructor
00061     NasaPoly2() 
00062       : m_lowT(0.0),
00063         m_midT(0.0), 
00064         m_highT (0.0),
00065         m_Pref(0.0),
00066         mnp_low(0),
00067         mnp_high(0), 
00068         m_index(0),
00069         m_coeff(array_fp(15)) {
00070     }
00071 
00072     //! Full Constructor
00073     /*!
00074      * @param n         Species index
00075      * @param tlow      output - Minimum temperature
00076      * @param thigh     output - Maximum temperature
00077      * @param pref      output - reference pressure (Pa).
00078      * @param coeffs    Vector of coefficients used to set the
00079      *                  parameters for the standard state.
00080      */
00081     NasaPoly2(int n, doublereal tlow, doublereal thigh, doublereal pref,
00082               const doublereal* coeffs) :
00083       m_lowT(tlow),
00084       m_highT(thigh),
00085       m_Pref(pref),
00086       mnp_low(0),
00087       mnp_high(0),
00088       m_index(n),
00089       m_coeff(array_fp(15)) {
00090 
00091       std::copy(coeffs, coeffs + 15, m_coeff.begin());
00092       m_midT = coeffs[0];
00093       mnp_low  = new NasaPoly1(m_index, m_lowT, m_midT,
00094                                m_Pref, &m_coeff[1]);
00095       mnp_high = new NasaPoly1(m_index, m_midT, m_highT,
00096                                m_Pref, &m_coeff[8]);
00097     }
00098 
00099     //! Copy Constructor
00100     /*!
00101      * @param b objecto to be copied.
00102      */
00103     NasaPoly2(const NasaPoly2& b) :
00104       m_lowT(b.m_lowT),
00105       m_midT(b.m_midT),
00106       m_highT(b.m_highT),
00107       m_Pref(b.m_Pref),
00108       mnp_low(0),
00109       mnp_high(0),
00110       m_index(b.m_index),
00111       m_coeff(array_fp(15)) {
00112 
00113       std::copy(b.m_coeff.begin(),
00114                 b.m_coeff.begin() + 15,
00115                 m_coeff.begin());
00116       mnp_low  = new NasaPoly1(m_index, m_lowT, m_midT,
00117                                m_Pref, &m_coeff[1]);
00118       mnp_high = new NasaPoly1(m_index, m_midT, m_highT,
00119                                m_Pref, &m_coeff[8]);
00120     }
00121 
00122     //! Assignment operator
00123     /*!
00124      * @param b objecto to be copied.
00125      */
00126     NasaPoly2& operator=(const NasaPoly2& b) {
00127       if (&b != this) {
00128         m_lowT   = b.m_lowT;
00129         m_midT   = b.m_midT;
00130         m_highT  = b.m_highT;
00131         m_Pref   = b.m_Pref;
00132         m_index  = b.m_index;
00133         std::copy(b.m_coeff.begin(),
00134                   b.m_coeff.begin() + 15,
00135                   m_coeff.begin());
00136         if (mnp_low) delete mnp_low;
00137         if (mnp_high) delete mnp_high;
00138         mnp_low  = new NasaPoly1(m_index, m_lowT, m_midT, 
00139                                  m_Pref, &m_coeff[1]);
00140         mnp_high = new NasaPoly1(m_index, m_midT, m_highT, 
00141                                  m_Pref, &m_coeff[8]);
00142       }
00143       return *this;
00144     }
00145 
00146     //! destructor
00147     virtual ~NasaPoly2(){
00148       delete mnp_low;
00149       delete mnp_high;
00150     }
00151 
00152     //! duplicator
00153     virtual SpeciesThermoInterpType *
00154     duplMyselfAsSpeciesThermoInterpType() const {
00155       NasaPoly2* np = new NasaPoly2(*this);
00156       return (SpeciesThermoInterpType *) np;
00157     }
00158 
00159     //! Returns the minimum temperature that the thermo
00160     //! parameterization is valid
00161     doublereal minTemp() const     { return m_lowT;}
00162 
00163     //! Returns the maximum temperature that the thermo
00164     //! parameterization is valid
00165     doublereal maxTemp() const     { return m_highT;}
00166 
00167     //! Returns the reference pressure (Pa)
00168     doublereal refPressure() const { return m_Pref; }
00169 
00170     //! Returns an integer representing the type of parameterization
00171     virtual int reportType() const { return NASA2; }
00172 
00173     //! Returns an integer representing the species index
00174     virtual int speciesIndex() const { return m_index; }
00175   
00176 
00177     //! Update the properties for this species, given a temperature polynomial
00178     /*!
00179      * This method is called with a pointer to an array containing the functions of
00180      * temperature needed by this  parameterization, and three pointers to arrays where the
00181      * computed property values should be written. This method updates only one value in
00182      * each array.
00183      *
00184      * Temperature Polynomial:
00185      *  tt[0] = t;
00186      *  tt[1] = t*t;
00187      *  tt[2] = m_t[1]*t;
00188      *  tt[3] = m_t[2]*t;
00189      *  tt[4] = 1.0/t;
00190      *  tt[5] = std::log(t);
00191      *
00192      * @param tt  vector of temperature polynomials
00193      * @param cp_R    Vector of Dimensionless heat capacities.
00194      *                (length m_kk).
00195      * @param h_RT    Vector of Dimensionless enthalpies.
00196      *                (length m_kk).
00197      * @param s_R     Vector of Dimensionless entropies.
00198      *                (length m_kk).
00199      */
00200     void updateProperties(const doublereal* tt, 
00201                           doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const {
00202           
00203       double T = tt[0];
00204       if (T <= m_midT) {
00205         mnp_low->updateProperties(tt, cp_R, h_RT, s_R);
00206       } else {
00207         mnp_high->updateProperties(tt, cp_R, h_RT, s_R);
00208       }
00209     }
00210 
00211     //! Compute the reference-state property of one species
00212     /*!
00213      * Given temperature T in K, this method updates the values of
00214      * the non-dimensional heat capacity at constant pressure,
00215      * enthalpy, and entropy, at the reference pressure, Pref
00216      * of one of the species. The species index is used
00217      * to reference into the cp_R, h_RT, and s_R arrays.
00218      *
00219      * @param temp    Temperature (Kelvin)
00220      * @param cp_R    Vector of Dimensionless heat capacities.
00221      *                (length m_kk).
00222      * @param h_RT    Vector of Dimensionless enthalpies.
00223      *                (length m_kk).
00224      * @param s_R     Vector of Dimensionless entropies.
00225      *                (length m_kk).
00226      */
00227     void updatePropertiesTemp(const doublereal temp, 
00228                               doublereal* cp_R,
00229                               doublereal* h_RT, 
00230                               doublereal* s_R) const {
00231       if (temp <= m_midT) {
00232         mnp_low->updatePropertiesTemp(temp, cp_R, h_RT, s_R);
00233       } else {
00234         mnp_high->updatePropertiesTemp(temp, cp_R, h_RT, s_R);
00235       }
00236     }
00237 
00238     //!This utility function reports back the type of 
00239     //! parameterization and all of the parameters for the 
00240     //! species, index.
00241     /*!
00242      * All parameters are output variables
00243      *
00244      * @param n         Species index
00245      * @param type      Integer type of the standard type
00246      * @param tlow      output - Minimum temperature
00247      * @param thigh     output - Maximum temperature
00248      * @param pref      output - reference pressure (Pa).
00249      * @param coeffs    Vector of coefficients used to set the
00250      *                  parameters for the standard state.
00251      */
00252     void reportParameters(int &n, int &type,
00253                           doublereal &tlow, doublereal &thigh,
00254                           doublereal &pref,
00255                           doublereal* const coeffs) const {
00256       n = m_index;
00257       type = NASA2;
00258       tlow = m_lowT;
00259       thigh = m_highT;
00260       pref = m_Pref;
00261       for (int i = 0; i < 15; i++) {
00262         coeffs[i] = m_coeff[i];
00263       }
00264     }
00265 
00266 #ifdef H298MODIFY_CAPABILITY
00267 
00268     doublereal reportHf298(doublereal* const h298 = 0) const {
00269       double h;
00270       if (298.15 <= m_midT) {
00271         h = mnp_low->reportHf298(0);
00272       } else {
00273         h = mnp_high->reportHf298(0);
00274       }
00275       if (h298) {
00276         h298[m_index] = h;
00277       }
00278       return h;
00279     }
00280 
00281     void modifyOneHf298(const int k, const doublereal Hf298New) {
00282       if (k != m_index) return;
00283  
00284       doublereal h298now = reportHf298(0);
00285       doublereal delH = Hf298New - h298now;
00286       double h = mnp_low->reportHf298(0);
00287       double hnew = h + delH;
00288       mnp_low->modifyOneHf298(k, hnew);
00289       h  = mnp_high->reportHf298(0);
00290       hnew = h + delH;
00291       mnp_high->modifyOneHf298(k, hnew);
00292     }
00293 
00294 #endif
00295 
00296   protected:
00297     //!  lowest valid temperature
00298     doublereal m_lowT;   
00299     //! Midrange temperature
00300     doublereal m_midT;
00301     //! Highest valid temperatre
00302     doublereal m_highT;  
00303     //! Reference state pressure
00304     doublereal m_Pref;
00305     //! pointer to the NasaPoly1 object for the low temperature region.
00306     NasaPoly1 *mnp_low;
00307     //! pointer to the NasaPoly1 object for the high temperature region.
00308     NasaPoly1 *mnp_high;
00309     //! species index
00310     int m_index;           
00311     //! array of polynomial coefficients
00312     array_fp m_coeff;    
00313 
00314   };
00315 
00316 }
00317 #endif
00318 
00319 
00320 
00321 
Generated by  doxygen 1.6.3