SpeciesThermoInterpType.h

Go to the documentation of this file.
00001 /**
00002  *  @file SpeciesThermoInterpType.h
00003  * Pure Virtual Base class for individual species reference state
00004  * themodynamic managers and text for the spthermo module 
00005  * (see \ref spthermo and class \link Cantera::SpeciesThermoInterpType SpeciesThermoInterpType \endlink).
00006  */
00007  /*
00008  * $Author: hkmoffa $
00009  * $Revision: 384 $
00010  * $Date: 2010-01-16 13:57:05 -0500 (Sat, 16 Jan 2010) $
00011  */
00012 
00013 // Copyright 2001  California Institute of Technology
00014 
00015 #include "speciesThermoTypes.h"
00016 
00017 #ifndef CT_SPECIESTHERMOINTERPTYPE_H
00018 #define CT_SPECIESTHERMOINTERPTYPE_H
00019 
00020 namespace Cantera {
00021 
00022   class PDSS;
00023   class VPSSMgr;
00024 
00025  /**
00026    * @defgroup spthermo Species Reference-State Thermodynamic Properties
00027    *
00028    *  The %ThermoPhase object relies on classes to calculate
00029    *  the thermodynamic properties of the reference state for all
00030    *  of the species in the phase.
00031    *  This group describes the types and functionality of the classes
00032    *  that calculate the reference state thermodynamic functions
00033    *  within %Cantera.
00034    *
00035    *
00036    * To compute the thermodynamic properties of multicomponent
00037    * solutions, it is necessary to know something about the
00038    * thermodynamic properties of the individual species present in
00039    * the solution. Exactly what sort of species properties are
00040    * required depends on the thermodynamic model for the
00041    * solution. For a gaseous solution (i.e., a gas mixture), the
00042    * species properties required are usually ideal gas properties at
00043    * the mixture temperature and at a reference pressure (almost always at
00044    * 1 bar). For other types of solutions, however, it may
00045    * not be possible to isolate the species in a "pure" state. For
00046    * example, the thermodynamic properties of, say, Na+ and Cl- in
00047    * saltwater are not easily determined from data on the properties
00048    * of solid NaCl, or solid Na metal, or chlorine gas. In this
00049    * case, the solvation in water is fundamental to the identity of
00050    * the species, and some other reference state must be used. One
00051    * common convention for liquid solutions is to use thermodynamic
00052    * data for the solutes in the limit of infinite dilution within the
00053    * pure solvent; another convention is to reference all properties
00054    * to unit molality.
00055    *
00056    * In defining these standard states for species in a phase, we make
00057    * the following definition. A reference state is a standard state
00058    * of a species in a phase limited to one particular pressure, the reference
00059    * pressure. The reference state specifies the dependence of all
00060    * thermodynamic functions as a function of the temperature, in
00061    * between a minimum temperature and a maximum temperature. The
00062    * reference state also specifies the molar volume of the species
00063    * as a function of temperature. The molar volume is a thermodynamic
00064    * function.
00065    * A full standard state does the same thing as a reference state,
00066    * but specifies the thermodynamics functions at all pressures.
00067    *
00068    * Whatever the conventions used by a particular solution model,
00069    * means need to be provided to compute the species properties in 
00070    * the reference state. Class SpeciesThermo is the base class
00071    * for a family of classes that compute properties of all
00072    * species in a phase in their reference states, for a range of temperatures.
00073    * Note, the pressure dependence of the species thermodynamic functions is not
00074    * handled by this particular species thermodynamic model. %SpeciesThermo
00075    * calculates the reference-state thermodynamic values of all species in a single
00076    * phase during each call.   
00077    *
00078    * The class SpeciesThermoInterpType is a pure virtual base class for
00079    * calculation of thermodynamic functions for a single species
00080    * in its reference state.
00081    * The following classes inherit from %SpeciesThermoInterpType.
00082    *
00083    *   - NasaPoly1          in file NasaPoly1.h
00084    *      - This is a one zone model,  consisting of a 7 
00085    *        coefficient Nasa Polynomial format.
00086    *      .
00087    *   - NasaPoly2          in file NasaPoly2.h
00088    *      - This is a two zone model, with each zone consisting of a 7 
00089    *        coefficient Nasa Polynomial format.
00090    *      .
00091    *   - ShomatePoly        in file ShomatePoly.h
00092    *      - This is a one zone model, consisting of a 7 
00093    *        coefficient Shomate Polynomial format.
00094    *      .
00095    *   - ShomatePoly2       in file ShomatePoly.h
00096    *      - This is a two zone model, with each zone consisting of a 7 
00097    *        coefficient Shomate Polynomial format.
00098    *      .
00099    *   - ConstCpPoly        in file ConstCpPoly.h
00100    *      - This is a one-zone constant heat capacity model.
00101    *      .
00102    *   - Mu0Poly            in file Mu0Poly.h
00103    *      - This is a multizoned model. The chemical potential is given
00104    *        at a set number of temperatures. Between each temperature
00105    *        the heat capacity is treated as a constant.
00106    *      .
00107    *   - Nasa9Poly1          in file Nasa9Poly1.h
00108    *      - This is a one zone model,  consisting of the 9
00109    *        coefficient Nasa Polynomial format.
00110    *      .
00111    *   - Nasa9PolyMultiTempRegion       in file Nasa9PolyMultiTempRegion.h
00112    *      - This is a multiple zone model, consisting of the 9
00113    *        coefficient Nasa Polynomial format in each zone.
00114    *      .
00115    *   - STITbyPDSS          in file SpeciesThermoInterpType.h
00116    *      - This is an object that calculates reference state thermodynamic
00117    *        functions by relying on a pressure dependent
00118    *        standard state object (i.e., a PDSS object) to calculate
00119    *        the thermodynamic functions.
00120    *      .
00121    *
00122    *  The most important member function for the %SpeciesThermoInterpType class
00123    *  is the member function
00124    *  \link SpeciesThermoInterpType::updatePropertiesTemp() updatePropertiesTemp()\endlink.
00125    *  The function calculates the values of Cp, H, and S for the specific
00126    *  species pertaining to this class. It takes as its arguments the
00127    *  base pointer for the vector of  Cp, H, and S values for all species
00128    *  in the phase. The offset for the species is known within the 
00129    *  object.
00130    *
00131    *  A key concept for reference states is that there is a maximum and a minimum
00132    *  temperature beyond which the thermodynamic formulation isn't valid.
00133    *  Calls for temperatures outside this range will cause the 
00134    *  object to throw a CanteraError.
00135    *
00136    * @ingroup thermoprops   
00137    */
00138 
00139   //!  Pure Virtual Base class for the thermoydnamic manager for 
00140   //!  an individual species' reference state
00141   /*!
00142    * This differs from the SpeciesThermo virtual
00143    * base class in the sense that this class is meant to handle only
00144    * one species. The speciesThermo class is meant to handle the 
00145    * calculation of all the species (or a large subset) in a phase.
00146    *
00147    * One key feature is that the update routines use the same
00148    * form as the update routines in the speciesThermo class. They update
00149    * into a vector of cp_R, s_R, and H_R that spans all of the species in 
00150    * a phase. Therefore, this class must carry along a species index into that
00151    * vector.
00152    *
00153    * These routine may be templated. A key requirement of the template is that
00154    * there is a constructor with the following form:
00155    *
00156    *  @code
00157    *   SpeciesThermoInterpType(int index, doublereal tlow, doublereal thigh, 
00158    *                           doublereal pref,  const doublereal* coeffs)
00159    *  @endcode
00160    *
00161    *  The constructor is used to instantiate the object.
00162    *
00163    * @ingroup spthermo
00164    */    
00165   class SpeciesThermoInterpType {
00166 
00167   public:
00168     
00169     //! Constructor
00170     SpeciesThermoInterpType();
00171 
00172     //! Destructor
00173     virtual ~SpeciesThermoInterpType();
00174 
00175     //! duplicator
00176     virtual SpeciesThermoInterpType * 
00177     duplMyselfAsSpeciesThermoInterpType() const = 0;
00178        
00179 
00180     //! Returns the minimum temperature that the thermo
00181     //! parameterization is valid
00182     virtual doublereal minTemp() const = 0;
00183 
00184     //! Returns the maximum temperature that the thermo
00185     //! parameterization is valid
00186     virtual doublereal maxTemp() const = 0;
00187 
00188     //! Returns the reference pressure (Pa)
00189     virtual doublereal refPressure() const = 0;
00190 
00191     //! Returns an integer representing the type of parameterization
00192     virtual int reportType() const = 0;
00193 
00194     //! Returns an integer representing the species index
00195     virtual int speciesIndex() const = 0;
00196   
00197     //! Update the properties for this species, given a temperature
00198     //! polynomial
00199     /*!
00200      * This method is called with a pointer to an array containing the functions of
00201      * temperature needed by this  parameterization, and three pointers to arrays where the
00202      * computed property values should be written. This method updates only one value in
00203      * each array.
00204      *
00205      * The form and length of the Temperature Polynomial may vary depending on the
00206      * parameterization.
00207      *
00208      * @param tempPoly  vector of temperature polynomials
00209      * @param cp_R    Vector of Dimensionless heat capacities.
00210      *                (length m_kk).
00211      * @param h_RT    Vector of Dimensionless enthalpies.
00212      *                (length m_kk).
00213      * @param s_R     Vector of Dimensionless entropies.
00214      *                (length m_kk).
00215      */
00216     virtual void updateProperties(const doublereal* tempPoly, 
00217                                   doublereal* cp_R, doublereal* h_RT,
00218                                   doublereal* s_R) const;
00219 
00220     //! Compute the reference-state property of one species
00221     /*!
00222      * Given temperature T in K, this method updates the values of
00223      * the non-dimensional heat capacity at constant pressure,
00224      * enthalpy, and entropy, at the reference pressure, Pref
00225      * of one of the species. The species index is used
00226      * to reference into the cp_R, h_RT, and s_R arrays.
00227      *
00228      * @param temp    Temperature (Kelvin)
00229      * @param cp_R    Vector of Dimensionless heat capacities.
00230      *                (length m_kk).
00231      * @param h_RT    Vector of Dimensionless enthalpies.
00232      *                (length m_kk).
00233      * @param s_R     Vector of Dimensionless entropies.
00234      *                (length m_kk).
00235      */
00236     virtual void updatePropertiesTemp(const doublereal temp, 
00237                                       doublereal* cp_R,
00238                                       doublereal* h_RT,
00239                                       doublereal* s_R) const = 0;
00240     
00241     //!This utility function reports back the type of 
00242     //! parameterization and all of the parameters for the 
00243     //! species, index.
00244     /*!
00245      * All parameters are output variables
00246      *
00247      * @param index     Species index
00248      * @param type      Integer type of the standard type
00249      * @param minTemp   output - Minimum temperature
00250      * @param maxTemp   output - Maximum temperature
00251      * @param refPressure output - reference pressure (Pa).
00252      * @param coeffs    Vector of coefficients used to set the
00253      *                  parameters for the standard state.
00254      */
00255     virtual void reportParameters(int &index, int &type,
00256                                   doublereal &minTemp, doublereal &maxTemp,
00257                                   doublereal &refPressure,
00258                                   doublereal* const coeffs) const = 0;
00259 
00260     //! Modify parameters for the standard state
00261     /*!
00262      * @param coeffs   Vector of coefficients used to set the
00263      *                 parameters for the standard state.
00264      */
00265     virtual void modifyParameters(doublereal* coeffs) {}
00266 
00267 #ifdef H298MODIFY_CAPABILITY
00268  
00269     //! Report the 298 K Heat of Formation of the standard state of one species (J kmol-1)
00270     /*!
00271      *   The 298K Heat of Formation is defined as the enthalpy change to create the standard state
00272      *   of the species from its constituent elements in their standard states at 298 K and 1 bar.
00273      *
00274      *   @param h298 If this is nonnull,  the current value of the Heat of Formation at 298K and 1 bar for
00275      *               species m_speciesIndex is returned in h298[m_speciesIndex].
00276      *   @return     Returns the current value of the Heat of Formation at 298K and 1 bar for 
00277      *               species m_speciesIndex.
00278      */
00279     virtual doublereal reportHf298(doublereal* const h298 = 0) const;
00280 
00281     //! Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1)
00282     /*!
00283      *   The 298K heat of formation is defined as the enthalpy change to create the standard state
00284      *   of the species from its constituent elements in their standard states at 298 K and 1 bar.
00285      *
00286      *   @param  k           Species k
00287      *   @param  Hf298New    Specify the new value of the Heat of Formation at 298K and 1 bar                      
00288      */
00289     virtual void modifyOneHf298(const int k, const doublereal Hf298New);
00290 
00291 #endif
00292   };
00293 
00294   //!  Class for the thermoydnamic manager for an individual species' reference state
00295   //!  which usess the PDSS base class to satisfy the requests.
00296   /*!
00297    * 
00298    *  This class is a pass-through class for handling thermodynamics calls
00299    *  for reference state thermo to an pressure dependent standard state (PDSS)
00300    *  class. For some situations, it makes no sense to have a reference state
00301    *  at all. One example of this is the real water standard state. 
00302    *
00303    *  What this class does is just to pass through the calls for thermo at (T , p0)
00304    *  to the PDSS class, which evaluates the calls at (T, p0).
00305    *
00306    * @ingroup spthermo
00307    */    
00308   class STITbyPDSS : public SpeciesThermoInterpType {
00309 
00310   public:
00311 
00312     //! Constructor
00313     STITbyPDSS();
00314 
00315     //! Main Constructor
00316     /*!
00317      * 
00318      *  @param speciesIndex species index for this object. Note, this must 
00319      *         agree with what was internally set before.
00320      *
00321      *  @param vpssmgr_ptr  Pointer to the Variable pressure standard state manager 
00322      *                      that owns the PDSS object that will handle calls for this object
00323      *
00324      *  @param PDSS_ptr     Pointer to the PDSS object that handles calls for this object
00325      */
00326     STITbyPDSS(int speciesIndex, VPSSMgr *vpssmgr_ptr, PDSS *PDSS_ptr);
00327 
00328     //! copy constructor
00329     /*!
00330      *  @param b Object to be copied
00331      */
00332     STITbyPDSS(const STITbyPDSS& b);
00333 
00334     //! Destructor
00335     virtual ~STITbyPDSS();
00336 
00337     //! duplicator
00338     virtual SpeciesThermoInterpType *duplMyselfAsSpeciesThermoInterpType() const;
00339 
00340     //! Initialize and/or Reinitialize all the pointers for this object
00341     /*!
00342      *  This routine is needed because the STITbyPDSS object doesn't own the
00343      *  underlying objects. Therefore, shallow copies during duplication operations
00344      *  may fail.
00345      *
00346      *  @param speciesIndex species index for this object. Note, this must 
00347      *         agree with what was internally set before.
00348      *
00349      *  @param vpssmgr_ptr  Pointer to the Variable pressure standard state manager 
00350      *                      that owns the PDSS object that will handle calls for this object
00351      *
00352      *  @param PDSS_ptr     Pointer to the PDSS object that handles calls for this object
00353      *
00354      */
00355     void initAllPtrs(int speciesIndex, VPSSMgr *vpssmgr_ptr, PDSS *PDSS_ptr);
00356 
00357     //! Returns the minimum temperature that the thermo
00358     //! parameterization is valid
00359     virtual doublereal minTemp() const;
00360 
00361     //! Returns the maximum temperature that the thermo
00362     //! parameterization is valid
00363     virtual doublereal maxTemp() const;
00364 
00365     //! Returns the reference pressure (Pa)
00366     virtual doublereal refPressure() const;
00367 
00368     //! Returns an integer representing the type of parameterization
00369     virtual int reportType() const;
00370 
00371     //! Returns an integer representing the species index
00372     virtual int speciesIndex() const;
00373   
00374     //! Update the properties for this species, given a temperature
00375     //! polynomial
00376     /*!
00377      * This method is called with a pointer to an array containing the functions of
00378      * temperature needed by this  parameterization, and three pointers to arrays where the
00379      * computed property values should be written. This method updates only one value in
00380      * each array.
00381      *
00382      * The form and length of the Temperature Polynomial may vary depending on the
00383      * parameterization.
00384      *
00385      * @param tempPoly  vector of temperature polynomials
00386      * @param cp_R    Vector of Dimensionless heat capacities.
00387      *                (length m_kk).
00388      * @param h_RT    Vector of Dimensionless enthalpies.
00389      *                (length m_kk).
00390      * @param s_R     Vector of Dimensionless entropies.
00391      *                (length m_kk).
00392      */
00393     virtual void updateProperties(const doublereal* tempPoly, 
00394                                   doublereal* cp_R, doublereal* h_RT,
00395                                   doublereal* s_R) const;
00396 
00397     //! Compute the reference-state property of one species
00398     /*!
00399      * Given temperature T in K, this method updates the values of
00400      * the non-dimensional heat capacity at constant pressure,
00401      * enthalpy, and entropy, at the reference pressure, Pref
00402      * of one of the species. The species index is used
00403      * to reference into the cp_R, h_RT, and s_R arrays.
00404      *
00405      * @param temp    Temperature (Kelvin)
00406      * @param cp_R    Vector of Dimensionless heat capacities.
00407      *                (length m_kk).
00408      * @param h_RT    Vector of Dimensionless enthalpies.
00409      *                (length m_kk).
00410      * @param s_R     Vector of Dimensionless entropies.
00411      *                (length m_kk).
00412      */
00413     virtual void updatePropertiesTemp(const doublereal temp, 
00414                                       doublereal* cp_R,
00415                                       doublereal* h_RT,
00416                                       doublereal* s_R) const;
00417     
00418     //!This utility function reports back the type of 
00419     //! parameterization and all of the parameters for the 
00420     //! species, index.
00421     /*!
00422      * All parameters are output variables
00423      *
00424      * @param index     Species index
00425      * @param type      Integer type of the standard type
00426      * @param minTemp   output - Minimum temperature
00427      * @param maxTemp   output - Maximum temperature
00428      * @param refPressure output - reference pressure (Pa).
00429      * @param coeffs    Vector of coefficients used to set the
00430      *                  parameters for the standard state.
00431      */
00432     virtual void reportParameters(int &index, int &type,
00433                                   doublereal &minTemp, doublereal &maxTemp,
00434                                   doublereal &refPressure,
00435                                   doublereal* const coeffs) const;
00436 
00437     //! Modify parameters for the standard state
00438     /*!
00439      *  This is a stub routine, without functionality
00440      * 
00441      * @param coeffs   Vector of coefficients used to set the
00442      *                 parameters for the standard state.
00443      */
00444     virtual void modifyParameters(doublereal* coeffs);
00445 
00446   private:
00447 
00448     //! Pointer to the Variable pressure standard state manager 
00449     //! that owns the PDSS object that will handle calls for this object
00450     VPSSMgr *m_vpssmgr_ptr;
00451 
00452     //! Pointer to the PDSS object that handles calls for this object
00453     /*!
00454      * This object is not owned by the current one.
00455      */
00456     PDSS *m_PDSS_ptr;
00457 
00458     //! Species index within the phase
00459     int m_speciesIndex;
00460   };
00461 
00462 }
00463 
00464 #endif
00465 
Generated by  doxygen 1.6.3