IdealSolnGasVPSS.h

Go to the documentation of this file.
00001 /**
00002  *  @file IdealSolnGasVPSS.h
00003  * Definition file for a derived class of ThermoPhase that assumes either
00004  * an ideal gas or ideal solution approximation and handles
00005  * variable pressure standard state methods for calculating
00006  * thermodynamic properties (see \ref thermoprops and
00007  * class \link Cantera::IdealSolnGasVPSS IdealSolnGasVPSS\endlink).
00008  */
00009 /*
00010  * Copywrite (2005) Sandia Corporation. Under the terms of 
00011  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
00012  * U.S. Government retains certain rights in this software.
00013  */
00014 /*
00015  *  $Author: hkmoffa $
00016  *  $Date: 2009-12-05 14:08:43 -0500 (Sat, 05 Dec 2009) $
00017  *  $Revision: 279 $
00018  */
00019 
00020 #ifndef CT_IDEALSOLNGASVPSS_H
00021 #define CT_IDEALSOLNGASVPSS_H
00022 
00023 #include "VPStandardStateTP.h"
00024 #include "VPSSMgr.h"
00025 
00026 namespace Cantera {
00027 
00028   class XML_Node;
00029   class PDSS;
00030 
00031  /*!
00032    * @name CONSTANTS - Models for the Standard State of IdealSolnPhase's
00033    */
00034   //@{
00035   const int cIdealSolnGasPhaseG = 6009;
00036   const int cIdealSolnGasPhase0 = 6010;
00037   const int cIdealSolnGasPhase1 = 6011;
00038   const int cIdealSolnGasPhase2 = 6012;
00039 
00040 
00041   /**
00042    * @ingroup thermoprops
00043    *
00044    *  This class can handle either an ideal solution or an ideal gas approximation
00045    *  of a phase.
00046    *
00047    *   
00048    *  @nosubgrouping
00049    */
00050   class IdealSolnGasVPSS : public VPStandardStateTP {
00051 
00052   public:
00053 
00054     /*!
00055      *   
00056      * @name Constructors and Duplicators for %IdealSolnGasVPSS 
00057      *
00058      */   
00059     /// Constructor. 
00060     IdealSolnGasVPSS();
00061 
00062     IdealSolnGasVPSS(std::string infile, std::string id="");
00063 
00064     /// Copy Constructor.
00065     IdealSolnGasVPSS(const IdealSolnGasVPSS &);
00066 
00067     /// Assignment operator
00068     IdealSolnGasVPSS& operator=(const IdealSolnGasVPSS &);
00069 
00070     /// Destructor. 
00071     virtual ~IdealSolnGasVPSS();
00072 
00073     /*
00074      * Duplication routine
00075      */
00076     virtual ThermoPhase *duplMyselfAsThermoPhase() const;
00077 
00078     //@}
00079 
00080     /**
00081      * @name  Utilities (IdealSolnGasVPSS)
00082      */
00083     //@{
00084     /** 
00085      * Equation of state type flag. The base class returns
00086      * zero. Subclasses should define this to return a unique
00087      * non-zero value. Constants defined for this purpose are
00088      * listed in mix_defs.h.
00089      */
00090     virtual int eosType() const;
00091 
00092     //@}
00093  
00094     /// Molar enthalpy. Units: J/kmol. 
00095     doublereal enthalpy_mole() const;
00096   
00097     /// Molar internal energy. Units: J/kmol. 
00098     doublereal intEnergy_mole() const;
00099 
00100     /// Molar entropy. Units: J/kmol/K. 
00101     doublereal entropy_mole() const;
00102 
00103     /// Molar Gibbs function. Units: J/kmol. 
00104     doublereal gibbs_mole() const;
00105 
00106     /// Molar heat capacity at constant pressure. Units: J/kmol/K. 
00107     doublereal cp_mole() const;
00108 
00109     /// Molar heat capacity at constant volume. Units: J/kmol/K. 
00110     doublereal cv_mole() const;
00111 
00112     /**
00113      * @}
00114      * @name Mechanical Properties
00115      * @{
00116      */
00117 
00118     //! Set the pressure in the fluid
00119     /*!
00120      * @param p pressure in pascals.
00121      */
00122     void setPressure(doublereal p);
00123 
00124     //! Returns  the isothermal compressibility. Units: 1/Pa.
00125     /*!
00126      * The isothermal compressibility is defined as
00127      * \f[
00128      * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T
00129      * \f]
00130      */
00131     virtual doublereal isothermalCompressibility() const;
00132 
00133   protected:
00134     /**
00135      * Calculate the density of the mixture using the partial
00136      * molar volumes and mole fractions as input
00137      *
00138      * The formula for this is
00139      *
00140      * \f[
00141      * \rho = \frac{\sum_k{X_k W_k}}{\sum_k{X_k V_k}}
00142      * \f]
00143      *
00144      * where \f$X_k\f$ are the mole fractions, \f$W_k\f$ are
00145      * the molecular weights, and \f$V_k\f$ are the pure species
00146      * molar volumes.
00147      *
00148      * Note, the basis behind this formula is that in an ideal
00149      * solution the partial molar volumes are equal to the
00150      * species standard state molar volumes.
00151      * The species molar volumes may be functions 
00152      * of temperature and pressure.
00153      *
00154      * NOTE: This is a non-virtual function, which is not a
00155      *       member of the ThermoPhase base class.
00156      */
00157     virtual void calcDensity();
00158 
00159   public:
00160 
00161     //! This method returns an array of generalized concentrations
00162     /*!
00163      * \f$ C^a_k\f$ are defined such that \f$ a_k = C^a_k /
00164      * C^0_k, \f$ where \f$ C^0_k \f$ is a standard concentration
00165      * defined below and \f$ a_k \f$ are activities used in the
00166      * thermodynamic functions.  These activity (or generalized)
00167      * concentrations are used
00168      * by kinetics manager classes to compute the forward and
00169      * reverse rates of elementary reactions. Note that they may
00170      * or may not have units of concentration --- they might be
00171      * partial pressures, mole fractions, or surface coverages,
00172      * for example.
00173      *
00174      * @param c Output array of generalized concentrations. The 
00175      *           units depend upon the implementation of the
00176      *           reaction rate expressions within the phase.
00177      */
00178     virtual void getActivityConcentrations(doublereal* c) const;
00179 
00180     //! Returns the standard concentration \f$ C^0_k \f$, which is used to normalize
00181     //! the generalized concentration.
00182     /*!
00183      * This is defined as the concentration  by which the generalized
00184      * concentration is normalized to produce the activity.
00185      * In many cases, this quantity will be the same for all species in a phase.
00186      * Since the activity for an ideal gas mixture is
00187      * simply the mole fraction, for an ideal gas \f$ C^0_k = P/\hat R T \f$.
00188      *
00189      * @param k Optional parameter indicating the species. The default
00190      *          is to assume this refers to species 0.
00191      * @return
00192      *   Returns the standard Concentration in units of m3 kmol-1.
00193      */
00194     virtual doublereal standardConcentration(int k=0) const;
00195 
00196     //! Returns the natural logarithm of the standard
00197     //! concentration of the kth species
00198     /*!
00199      * @param k    index of the species. (defaults to zero)
00200      */
00201     virtual doublereal logStandardConc(int k=0) const;
00202 
00203    //! Returns the units of the standard and generalized concentrations.
00204     /*!
00205      * Note they have the same units, as their
00206      * ratio is defined to be equal to the activity of the kth
00207      * species in the solution, which is unitless.
00208      *
00209      * This routine is used in print out applications where the
00210      * units are needed. Usually, MKS units are assumed throughout
00211      * the program and in the XML input files.
00212      *
00213      * The base %ThermoPhase class assigns the default quantities
00214      * of (kmol/m3) for all species.
00215      * Inherited classes are responsible for overriding the default 
00216      * values if necessary.
00217      *
00218      * @param uA Output vector containing the units
00219      *  uA[0] = kmol units - default  = 1
00220      *  uA[1] = m    units - default  = -nDim(), the number of spatial
00221      *                                dimensions in the Phase class.
00222      *  uA[2] = kg   units - default  = 0;
00223      *  uA[3] = Pa(pressure) units - default = 0;
00224      *  uA[4] = Temperature units - default = 0;
00225      *  uA[5] = time units - default = 0
00226      * @param k species index. Defaults to 0.
00227      * @param sizeUA output int containing the size of the vector.
00228      *        Currently, this is equal to 6.
00229      */
00230     virtual void getUnitsStandardConc(double *uA, int k = 0,
00231                                       int sizeUA = 6) const;
00232       
00233     //! Get the array of non-dimensional activity coefficients at
00234     //! the current solution temperature, pressure, and solution concentration.
00235     /*!
00236      *  For ideal gases, the activity coefficients are all equal to one.
00237      *
00238      * @param ac Output vector of activity coefficients. Length: m_kk.
00239      */
00240     virtual void getActivityCoefficients(doublereal* ac) const;
00241 
00242 
00243     /// @name  Partial Molar Properties of the Solution  (IdealSolnGasVPSS)
00244     //@{
00245 
00246     //! Get the array of non-dimensional species chemical potentials
00247     //! These are partial molar Gibbs free energies.
00248     /*!
00249      * \f$ \mu_k / \hat R T \f$.
00250      * Units: unitless
00251      *
00252      * We close the loop on this function, here, calling
00253      * getChemPotentials() and then dividing by RT. No need for child
00254      * classes to handle.
00255      *
00256      * @param mu    Output vector of  non-dimensional species chemical potentials
00257      *              Length: m_kk.
00258      */
00259     void getChemPotentials_RT(doublereal* mu) const;
00260 
00261     //! Get the species chemical potentials. Units: J/kmol.
00262     /*!
00263      * This function returns a vector of chemical potentials of the
00264      * species in solution at the current temperature, pressure
00265      * and mole fraction of the solution.
00266      *
00267      * @param mu  Output vector of species chemical
00268      *            potentials. Length: m_kk. Units: J/kmol
00269      */
00270     virtual void getChemPotentials(doublereal* mu) const;
00271 
00272     //!  Get the species partial molar enthalpies. Units: J/kmol.
00273     /*!
00274      * @param hbar    Output vector of species partial molar enthalpies.
00275      *                Length: m_kk. units are J/kmol.
00276      */
00277     virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
00278 
00279     //! Get the species partial molar entropies. Units: J/kmol/K.
00280     /*!
00281      * @param sbar    Output vector of species partial molar entropies.
00282      *                Length = m_kk. units are J/kmol/K.
00283      */
00284     virtual void getPartialMolarEntropies(doublereal* sbar) const;
00285 
00286     //! Get the species partial molar enthalpies. Units: J/kmol.
00287     /*!
00288      * @param ubar    Output vector of speciar partial molar internal energies.
00289      *                Length = m_kk. units are J/kmol.
00290      */
00291     virtual void getPartialMolarIntEnergies(doublereal* ubar) const;
00292 
00293     //! Get the partial molar heat capacities Units: J/kmol/K
00294     /*!
00295      * @param cpbar   Output vector of species partial molar heat capacities
00296      *                at constant pressure.
00297      *                Length = m_kk. units are J/kmol/K.
00298      */
00299     virtual void getPartialMolarCp(doublereal* cpbar) const;
00300 
00301     //! Get the species partial molar volumes. Units: m^3/kmol.
00302     /*!
00303      *  @param vbar   Output vector of speciar partial molar volumes.
00304      *                Length = m_kk. units are m^3/kmol.
00305      */
00306     virtual void getPartialMolarVolumes(doublereal* vbar) const;
00307   
00308     //@}
00309 
00310     /*!
00311      * @name  Properties of the Standard State of the Species in the Solution 
00312      *
00313      *  Properties of the standard states are delegated to the VPSSMgr object.
00314      *  The values are cached within this object, and are not recalculated unless
00315      *  the temperature or pressure changes.
00316      */
00317     //@{
00318     
00319     //@}
00320 
00321     /// @name Thermodynamic Values for the Species Reference States (IdealSolnGasVPSS)
00322     /*!
00323      *  Properties of the reference states are delegated to the VPSSMgr object.
00324      *  The values are cached within this object, and are not recalculated unless
00325      *  the temperature or pressure changes.
00326      */
00327     //@{
00328 
00329     //@}
00330 
00331         
00332   public:
00333  
00334     //! @name Initialization Methods - For Internal use (VPStandardState)
00335     /*!
00336      * The following methods are used in the process of constructing
00337      * the phase and setting its parameters from a specification in an 
00338      * input file. They are not normally used in application programs.
00339      * To see how they are used, see files importCTML.cpp and 
00340      * ThermoFactory.cpp.
00341      */
00342     //@{
00343 
00344     
00345     //! Set equation of state parameter values from XML
00346     //! entries. 
00347     /*!
00348      *  This method is called by function importPhase in
00349      *  file importCTML.cpp when processing a phase definition in
00350      *  an input file. It should be overloaded in subclasses to set
00351      *  any parameters that are specific to that particular phase
00352      *  model. 
00353      *   
00354      * @param thermoNode An XML_Node object corresponding to
00355      *                   the "thermo" entry for this phase in the input file.
00356      */
00357     virtual void setParametersFromXML(const XML_Node& thermoNode);
00358   
00359     //! @internal Initialize the object
00360     /*!
00361      * This method is provided to allow
00362      * subclasses to perform any initialization required after all
00363      * species have been added. For example, it might be used to
00364      * resize internal work arrays that must have an entry for
00365      * each species.  The base class implementation does nothing,
00366      * and subclasses that do not require initialization do not
00367      * need to overload this method.  When importing a CTML phase
00368      * description, this method is called just prior to returning
00369      * from function importPhase().
00370      *
00371      * @see importCTML.cpp
00372      */
00373     virtual void initThermo();
00374 
00375 
00376     //!This method is used by the ChemEquil equilibrium solver.
00377     /*!
00378      * It sets the state such that the chemical potentials satisfy
00379      * \f[ \frac{\mu_k}{\hat R T} = \sum_m A_{k,m}
00380      * \left(\frac{\lambda_m} {\hat R T}\right) \f] where 
00381      * \f$ \lambda_m \f$ is the element potential of element m. The
00382      * temperature is unchanged.  Any phase (ideal or not) that
00383      * implements this method can be equilibrated by ChemEquil.
00384      *
00385      * @param lambda_RT Input vector of dimensionless element potentials
00386      *                  The length is equal to nElements().
00387      */ 
00388     void setToEquilState(const doublereal* lambda_RT);
00389 
00390     //!   Initialize a ThermoPhase object, potentially reading activity
00391     //!   coefficient information from an XML database.
00392     /*!
00393      *
00394      * This routine initializes the lengths in the current object and
00395      * then calls the parent routine.
00396      * This method is provided to allow
00397      * subclasses to perform any initialization required after all
00398      * species have been added. For example, it might be used to
00399      * resize internal work arrays that must have an entry for
00400      * each species.  The base class implementation does nothing,
00401      * and subclasses that do not require initialization do not
00402      * need to overload this method.  When importing a CTML phase
00403      * description, this method is called just prior to returning
00404      * from function importPhase().
00405      *
00406      * @param phaseNode This object must be the phase node of a
00407      *             complete XML tree
00408      *             description of the phase, including all of the
00409      *             species data. In other words while "phase" must
00410      *             point to an XML phase object, it must have
00411      *             sibling nodes "speciesData" that describe
00412      *             the species in the phase.
00413      * @param id   ID of the phase. If nonnull, a check is done
00414      *             to see if phaseNode is pointing to the phase
00415      *             with the correct id. 
00416      */
00417     virtual void initThermoXML(XML_Node& phaseNode, std::string id);
00418 
00419   private:
00420     //!  @internal Initialize the internal lengths in this object.
00421     /*!
00422      * Note this is not a virtual function and only handles
00423      * this object
00424      */
00425     void initLengths();
00426 
00427    //@}
00428 
00429   protected:
00430 
00431     //! boolean indicating what ideal solution this is
00432     /*!
00433      *  - 1 = ideal gas
00434      *  - 0 = ideal soln
00435      */
00436     int m_idealGas;
00437 
00438     //! form of the generalized concentrations
00439     /*!
00440      *    - 0 unity
00441      *    - 1 1/V_k
00442      *    - 2 1/V_0
00443      */
00444     int m_formGC;
00445 
00446     //! Temporary storage - length = m_kk.
00447     vector_fp m_pp;
00448 
00449   };
00450 }
00451         
00452 #endif
Generated by  doxygen 1.6.3