Mu0Poly.h

Go to the documentation of this file.
00001 /**
00002  *  @file Mu0Poly.h 
00003  *  Header for a single-species standard state object derived
00004  *  from \link Cantera::SpeciesThermoInterpType SpeciesThermoInterpType\endlink  based 
00005  *  on a piecewise constant mu0 interpolation
00006  *  (see \ref spthermo and class \link Cantera::Mu0Poly Mu0Poly\endlink).
00007  */
00008 
00009 /* $Author: hkmoffa $
00010  * $Revision: 279 $
00011  * $Date: 2009-12-05 14:08:43 -0500 (Sat, 05 Dec 2009) $
00012  */
00013 
00014 
00015 
00016 #ifndef CT_MU0POLY_H
00017 #define CT_MU0POLY_H
00018 
00019 #include "SpeciesThermoInterpType.h"
00020 
00021 namespace Cantera {
00022   class SpeciesThermo;
00023   class XML_Node;
00024 
00025   //!  The %Mu0Poly class implements an interpolation of the Gibbs free energy based on a
00026   //!  piecewise constant heat capacity approximation.
00027   /*!
00028    *   The %Mu0Poly class implements a piecewise constant heat capacity approximation.
00029    *   of the standard state chemical potential of one
00030    *   species at a single reference pressure.
00031    *   The chemical potential is input as a series of (\f$T\f$, \f$ \mu^o(T)\f$)
00032    *   values. The first temperature is assumed to be equal
00033    *   to 298.15 K; however, this may be relaxed in the future. 
00034    *   This information, and an assumption of a constant
00035    *   heat capacity within each interval is enough to 
00036    *   calculate all thermodynamic functions.
00037    *   
00038    *  The piece-wise constant heat capacity is calculated from the change in the chemical potential over each interval.
00039    *  Once the heat capacity is known, the other thermodynamic functions may be determined.
00040    *  The basic equation for going from temperature point 1 to temperature point 2
00041    *  are as follows for \f$ T \f$,  \f$ T_1 <= T <= T_2 \f$
00042    *
00043    * \f[
00044    *      \mu^o(T_1) = h^o(T_1) - T_1 * s^o(T_1)
00045    * \f]
00046    * \f[
00047    *      \mu^o(T_2) - \mu^o(T_1) = Cp^o(T_1)(T_2 - T_1) - Cp^o(T_1)(T_2)ln(\frac{T_2}{T_1}) - s^o(T_1)(T_2 - T_1)
00048    * \f]
00049    * \f[
00050    *      s^o(T_2) = s^o(T_1) + Cp^o(T_1)ln(\frac{T_2}{T_1})
00051    * \f]
00052    * \f[
00053    *      h^o(T_2) = h^o(T_1) + Cp^o(T_1)(T_2 - T_1)
00054    * \f]
00055    *
00056    *  Within each interval the following relations are used. For \f$ T \f$,  \f$ T_1 <= T <= T_2 \f$
00057    *
00058    * \f[
00059    *      \mu^o(T) = \mu^o(T_1) + Cp^o(T_1)(T - T_1) - Cp^o(T_1)(T_2)ln(\frac{T}{T_1}) - s^o(T_1)(T - T_1)
00060    * \f]
00061    * \f[
00062    *      s^o(T) = s^o(T_1) + Cp^o(T_1)ln(\frac{T}{T_1})
00063    * \f]
00064    * \f[
00065    *      h^o(T) = h^o(T_1) + Cp^o(T_1)(T - T_1)
00066    * \f]
00067    *
00068    *   Notes about temperature interpolation for \f$ T < T_1 \f$ and \f$ T > T_{npoints} \f$.
00069    *     These are achieved by assuming a constant heat capacity
00070    *     equal to the value in the closest temperature interval.
00071    *     No error is thrown.
00072    *
00073    *   @note In the future, a better assumption about the heat
00074    *         capacity may be employed, so that it can be continuous.
00075    *
00076    * @ingroup spthermo
00077    */
00078   class Mu0Poly: public SpeciesThermoInterpType {
00079 
00080   public:
00081 
00082     //! Constructor
00083     Mu0Poly();
00084 
00085     //! Constructor used in templated instantiations
00086     /*!
00087      *
00088      * In the constructor, we calculate and store the
00089      * piecewise linear approximation to the thermodynamic
00090      * functions.
00091      *
00092      * @param n            Species index
00093      * @param tlow         Minimum temperature
00094      * @param thigh        Maximum temperature
00095      * @param pref         reference pressure (Pa).
00096      * @param coeffs       Vector of coefficients used to set the
00097      *                     parameters for the standard state for species n.
00098      *                     There are \f$ 2+npoints*2 \f$ coefficients, where
00099      *                     \f$ npoints \f$ are the number of temperature points.
00100      *                     Their identity is further broken down:
00101      *            - coeffs[0] = number of points (integer)
00102      *            - coeffs[1]  = \f$ h^o(298.15 K) \f$ (J/kmol)
00103      *            - coeffs[2]  = \f$ T_1 \f$  (Kelvin)
00104      *            - coeffs[3]  = \f$ \mu^o(T_1) \f$ (J/kmol) 
00105      *            - coeffs[4]  = \f$ T_2 \f$  (Kelvin)
00106      *            - coeffs[5]  = \f$ \mu^o(T_2) \f$ (J/kmol) 
00107      *            - coeffs[6]  = \f$ T_3 \f$  (Kelvin)
00108      *            - coeffs[7]  = \f$ \mu^o(T_3) \f$ (J/kmol)
00109      *            - ........
00110      *            .
00111      */
00112     Mu0Poly(int n, doublereal tlow, doublereal thigh, 
00113             doublereal pref, const doublereal* coeffs);
00114 
00115     //! Copy constructor
00116     Mu0Poly(const Mu0Poly &);
00117 
00118     //! Assignment operator
00119     Mu0Poly& operator=(const Mu0Poly&);
00120 
00121     //! Destructor
00122     virtual ~Mu0Poly();
00123 
00124     //! Duplicator
00125     virtual SpeciesThermoInterpType *
00126     duplMyselfAsSpeciesThermoInterpType() const;
00127 
00128     //! Returns the minimum temperature that the thermo
00129     //! parameterization is valid       
00130     virtual doublereal minTemp() const;
00131 
00132     //! Returns the maximum temperature that the thermo
00133     //! parameterization is valid
00134     virtual doublereal maxTemp() const;
00135 
00136     //! Returns the reference pressure (Pa)
00137     virtual doublereal refPressure() const;
00138 
00139     //! Returns an integer representing the type of parameterization
00140     virtual int reportType() const { return MU0_INTERP; }
00141 
00142     //! Returns an integer representing the species index
00143     virtual int speciesIndex() const { return m_index; }
00144   
00145     //! Update the properties for this species, given a temperature polynomial
00146     /*!
00147      * This method is called with a pointer to an array containing the functions of
00148      * temperature needed by this  parameterization, and three pointers to arrays where the
00149      * computed property values should be written. This method updates only one value in
00150      * each array.
00151      *
00152      * Temperature Polynomial:
00153      *
00154      * tPoly[0] = temp (Kelvin)
00155      *
00156      * @param tPoly  vector of temperature polynomials. Length = 1
00157      * @param cp_R    Vector of Dimensionless heat capacities.
00158      *                (length m_kk).
00159      * @param h_RT    Vector of Dimensionless enthalpies.
00160      *                (length m_kk).
00161      * @param s_R     Vector of Dimensionless entropies.
00162      *                (length m_kk).
00163      */
00164     virtual void updateProperties(const doublereal* tPoly, 
00165                           doublereal* cp_R, doublereal* h_RT, 
00166                           doublereal* s_R) const ;
00167 
00168     //! Compute the reference-state property of one species
00169     /*!
00170      * Given temperature T in K, this method updates the values of
00171      * the non-dimensional heat capacity at constant pressure,
00172      * enthalpy, and entropy, at the reference pressure, Pref
00173      * of one of the species. The species index is used
00174      * to reference into the cp_R, h_RT, and s_R arrays.
00175      *
00176      * @param temp    Temperature (Kelvin)
00177      * @param cp_R    Vector of Dimensionless heat capacities.
00178      *                (length m_kk).
00179      * @param h_RT    Vector of Dimensionless enthalpies.
00180      *                (length m_kk).
00181      * @param s_R     Vector of Dimensionless entropies.
00182      *                (length m_kk).
00183      */
00184     virtual void updatePropertiesTemp(const doublereal temp, 
00185                               doublereal* cp_R,
00186                               doublereal* h_RT, 
00187                               doublereal* s_R) const ;
00188 
00189     //!This utility function reports back the type of 
00190     //! parameterization and all of the parameters for the 
00191     //! species, index.
00192     /*!
00193      * All parameters are output variables
00194      *
00195      * @param n         Species index
00196      * @param type      Integer type of the standard type
00197      * @param tlow      output - Minimum temperature
00198      * @param thigh     output - Maximum temperature
00199      * @param pref      output - reference pressure (Pa).
00200      * @param coeffs    Vector of coefficients used to set the
00201      *                  parameters for the standard state.
00202      */
00203     virtual void reportParameters(int &n, int &type,
00204                           doublereal &tlow, doublereal &thigh,
00205                           doublereal &pref,
00206                           doublereal* const coeffs) const;
00207 
00208     //! Modify parameters for the standard state
00209     /*!
00210      * @param coeffs   Vector of coefficients used to set the
00211      *                 parameters for the standard state.
00212      */
00213     virtual void modifyParameters(doublereal* coeffs);
00214 
00215   protected:
00216 
00217     /**
00218      * Number of intervals in the interpolating linear
00219      * approximation. Number of points is one more than the
00220      * number of intervals.
00221      */
00222     int m_numIntervals;
00223 
00224     /**
00225      * Value of the enthalpy at T = 298.15.
00226      *  This value is tied to the Heat of formation of 
00227      *  the species at 298.15.
00228      */
00229     doublereal m_H298;
00230 
00231     /**
00232      * Points at which the standard state chemical potential
00233      * are given. 
00234      */
00235     vector_fp m_t0_int;
00236 
00237     /**
00238      * Mu0's are primary input data. They aren't strictly
00239      * needed, but are kept here for convenience. 
00240      */
00241     vector_fp m_mu0_R_int;
00242 
00243     //! Dimensionless Enthalpies at the temperature points
00244     vector_fp m_h0_R_int;
00245 
00246     //! Entropy at the points
00247     vector_fp m_s0_R_int;
00248 
00249     //! Heat capacity at the points
00250     vector_fp m_cp0_R_int;
00251     //! Limiting low temperature
00252     doublereal m_lowT;
00253     //! Limiting high temperature
00254     doublereal m_highT;
00255     
00256     //! Reference pressure
00257     doublereal m_Pref;
00258 
00259     //! Species index
00260     int m_index;
00261     
00262   private:
00263 
00264     //! process the coefficients
00265     /*!
00266      * Mu0Poly():
00267      *
00268      * In the constructor, we calculate and store the
00269      * piecewise linear approximation to the thermodynamic
00270      * functions.
00271      *
00272      * @param coeffs coefficients. These are defined as follows:
00273      *
00274      *  coeffs[0] = number of points (integer)
00275      *         1  = H298(J/kmol)
00276      *         2  = T1  (Kelvin)
00277      *         3  = mu1 (J/kmol) 
00278      *         4  = T2  (Kelvin)
00279      *         5  = mu2 (J/kmol) 
00280      *         6  = T3  (Kelvin)
00281      *         7  = mu3 (J/kmol)
00282      *         ........
00283      */
00284     void processCoeffs(const doublereal * coeffs);
00285 
00286   };
00287 
00288   //!  Install a Mu0 polynomial thermodynamic reference state
00289   /*!
00290    * Install a Mu0 polynomial thermodynamic reference state property
00291    * parameterization for species k into a SpeciesThermo instance,
00292    * getting the information from an XML database.
00293    *
00294    * @param speciesName  Name of the species
00295    * @param sp           Owning SpeciesThermo object
00296    * @param k            Species index
00297    * @param Mu0Node_ptr  Pointer to the XML element containing the
00298    *                     Mu0 information.
00299    *
00300    *  @ingroup spthermo 
00301    */
00302   void installMu0ThermoFromXML(std::string speciesName,
00303                                SpeciesThermo& sp, int k, 
00304                                const XML_Node* Mu0Node_ptr);
00305 }
00306 
00307 #endif
00308 
00309 
Generated by  doxygen 1.6.3