PDSS_Water.h

Go to the documentation of this file.
00001 /**
00002  *  @file PDSS_Water.h
00003  * Implementation of a pressure dependent standard state 
00004  * virtual function for a Pure Water Phase
00005  * (see \ref pdssthermo and class \link Cantera::PDSS_Water PDSS_Water\endlink).
00006  */
00007 /*
00008  * Copywrite (2006) Sandia Corporation. Under the terms of
00009  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
00010  * U.S. Government retains certain rights in this software.
00011  */
00012 /*  $Author: hkmoffa $
00013  *  $Date: 2010-01-17 12:05:46 -0500 (Sun, 17 Jan 2010) $
00014  *  $Revision: 385 $
00015  */
00016 
00017 #ifndef CT_PDSS_WATER_H
00018 #define CT_PDSS_WATER_H
00019 
00020 #include "ct_defs.h"
00021 #include "PDSS.h"
00022 #include "VPStandardStateTP.h"
00023 
00024 
00025 
00026 
00027 namespace Cantera {
00028   class WaterPropsIAPWS;
00029   class WaterProps;
00030 
00031   //!  Class for the liquid water pressure dependent 
00032   //!  standard state
00033   /*!
00034    *
00035    * Notes:
00036    *   Base state for thermodynamic properties:
00037    * 
00038    *   The thermodynamic base state for water is set to the NIST basis here
00039    *   by specifying constants EW_Offset and SW_Offset. These offsets are
00040    *   specified so that the following properties hold:
00041    *
00042    *   Delta_Hfo_gas(298.15) = -241.826 kJ/gmol
00043    *   So_gas(298.15, 1bar)  = 188.835 J/gmolK
00044    *
00045    *           (http://webbook.nist.gov)
00046    *
00047    *   The "o" here refers to a hypothetical ideal gas state. The way
00048    *   we achieve this in practice is to evaluate at a very low pressure
00049    *   and then use the theoretical ideal gas results to scale up to
00050    *   higher pressures:
00051    *
00052    *   Ho(1bar) = H(P0)
00053    *
00054    *   So(1bar) = S(P0) + RT ln(1bar/P0)
00055    *
00056    *   The offsets used in the steam tables are different than NIST's. 
00057    *   They assume u_liq(TP) = 0.0, s_liq(TP) = 0.0, where TP is the
00058    *   triple point conditions.
00059    *
00060    * @ingroup pdssthermo
00061    */
00062   class PDSS_Water : public PDSS {
00063 
00064   public:
00065 
00066     /**
00067      * @name  Constructors
00068      * @{
00069      */
00070 
00071     //! Bare constructor
00072     /*!
00073      *  eliminate?
00074      */
00075     PDSS_Water(); 
00076 
00077     //! Constructor that initializes the object by examining the XML entries
00078     //! from the ThermoPhase object
00079     /*!
00080      *  This function calls the constructPDSS member function.
00081      *
00082      *  @param tp        Pointer to the ThermoPhase object pertaining to the phase
00083      *  @param spindex   Species index of the species in the phase
00084      */
00085     PDSS_Water(VPStandardStateTP *tp, int spindex);
00086 
00087     //! Copy Constructor
00088     /*!
00089      * @param b object to be copied
00090      */
00091     PDSS_Water(const PDSS_Water &b);
00092 
00093     //! Assignment operator
00094     /*!
00095      * @param b Object to be copied
00096      */
00097     PDSS_Water& operator=(const PDSS_Water& b);
00098 
00099     //! Constructor that initializes the object by examining the input file
00100     //! of the variable pressure ThermoPhase object
00101     /*!
00102      *  This function calls the constructPDSSFile member function.
00103      *
00104      *  @param tp        Pointer to the variable pressure ThermoPhase object pertaining to the phase
00105      *  @param spindex   Species index of the species in the phase
00106      *  @param inputFile String name of the input file
00107      *  @param id        String name of the phase in the input file. The default
00108      *                   is the empty string, in which case the first phase in the
00109      *                   file is used.
00110      */
00111     PDSS_Water(VPStandardStateTP *tp, int spindex,
00112               std::string inputFile, std::string id = "");
00113 
00114     //! Constructor that initializes the object by examining the input file
00115     //! of the variable pressure ThermoPhase object
00116     /*!
00117      *  This function calls the constructPDSSXML member function.
00118      *
00119      *  @param tp        Pointer to the ThermoPhase object pertaining to the phase
00120      *  @param spindex   Species index of the species in the phase
00121      *  @param speciesNode Reference to the species XML tree.
00122      *  @param phaseRef  Reference to the XML tree containing the phase information.
00123      *  @param spInstalled Is the species already installed.
00124      */
00125     PDSS_Water(VPStandardStateTP *tp, int spindex, const XML_Node& speciesNode, 
00126               const XML_Node& phaseRef, bool spInstalled);
00127 
00128     //! Destructor
00129     virtual ~PDSS_Water();
00130         
00131     //! Duplication routine for objects which inherit from %PDSS
00132     /*!
00133      *  This virtual routine can be used to duplicate %PDSS  objects
00134      *  inherited from %PDSS even if the application only has
00135      *  a pointer to %PDSS to work with.
00136      *
00137      * @return returns a pointer to the base %PDSS object type
00138      */
00139     virtual PDSS *duplMyselfAsPDSS() const;
00140 
00141     /**
00142      * @}
00143      * @name  Utilities  
00144      * @{
00145      */
00146     
00147     /**
00148      * @}
00149      * @name  Molar Thermodynamic Properties of the Species Standard State
00150      *        in the Solution
00151      * @{
00152      */
00153 
00154     //! Return the molar enthalpy in units of J kmol-1
00155     /*!
00156      * Returns the species standard state enthalpy in J kmol-1 at the
00157      * current temperature and pressure.
00158      *
00159      * @return returns the species standard state enthalpy in  J kmol-1
00160      */
00161     virtual doublereal enthalpy_mole() const;
00162 
00163     //! Return the molar internal Energy in units of J kmol-1
00164     /*!
00165      * Returns the species standard state internal Energy in J kmol-1 at the
00166      * current temperature and pressure.
00167      *
00168      * @return returns the species standard state internal Energy in  J kmol-1
00169      */
00170     virtual doublereal intEnergy_mole() const;
00171 
00172     //! Return the molar entropy in units of J kmol-1 K-1
00173     /*!
00174      * Returns the species standard state entropy in J kmol-1 K-1 at the
00175      * current temperature and pressure.
00176      *
00177      * @return returns the species standard state entropy in J kmol-1 K-1
00178      */
00179     virtual doublereal entropy_mole() const;
00180 
00181     //! Return the molar gibbs free energy in units of J kmol-1
00182     /*!
00183      * Returns the species standard state gibbs free energy in J kmol-1 at the
00184      * current temperature and pressure.
00185      *
00186      * @return returns the species standard state gibbs free energy in  J kmol-1
00187      */
00188     virtual doublereal gibbs_mole() const;
00189 
00190     //! Return the molar const pressure heat capacity in units of J kmol-1 K-1
00191     /*!
00192      * Returns the species standard state Cp in J kmol-1 K-1 at the
00193      * current temperature and pressure.
00194      *
00195      * @return returns the species standard state Cp in J kmol-1 K-1
00196      */
00197     virtual doublereal cp_mole() const;
00198 
00199     //! Return the molar const volume heat capacity in units of J kmol-1 K-1
00200     /*!
00201      * Returns the species standard state Cv in J kmol-1 K-1 at the
00202      * current temperature and pressure.
00203      *
00204      * @return returns the species standard state Cv in J kmol-1 K-1
00205      */
00206     virtual doublereal cv_mole() const;
00207 
00208    //! Return the molar volume at standard state
00209     /*!
00210      * Returns the species standard state molar volume at the
00211      * current temperature and pressure
00212      *
00213      * @return returns the standard state molar volume divided by R
00214      *             units are m**3 kmol-1.
00215      */
00216     virtual doublereal molarVolume() const;
00217 
00218     //! Return the standard state density at standard state
00219     /*!
00220      * Returns the species standard state density at the
00221      * current temperature and pressure
00222      *
00223      * @return returns the standard state density
00224      *             units are kg m-3
00225      */
00226     virtual doublereal density() const;
00227 
00228     /**
00229      * @} 
00230      * @name Properties of the Reference State of the Species
00231      *       in the Solution 
00232      * @{
00233      */
00234 
00235     //! Returns a reference pressure value that can be safely calculated by the
00236     //! underlying real equation of state for water
00237     /*!
00238      *  Note, this function is needed because trying to calculate a one atm
00239      *  value around the critical point will cause a crash
00240      *
00241      * @param temp  Temperature (Kelvin)
00242      */
00243     doublereal pref_safe(doublereal temp) const;
00244 
00245 
00246     //! Return the molar gibbs free energy divided by RT at reference pressure
00247     /*!
00248      * Returns the species reference state gibbs free energy divided by RT at the
00249      * current temperature.
00250      *
00251      * @return returns the reference state gibbs free energy divided by RT
00252      */
00253     virtual doublereal gibbs_RT_ref() const;
00254 
00255     //! Return the molar enthalpy divided by RT at reference pressure
00256     /*!
00257      * Returns the species reference state enthalpy divided by RT at the
00258      * current temperature.
00259      *
00260      * @return returns the reference state enthalpy divided by RT
00261      */
00262     virtual doublereal enthalpy_RT_ref() const;
00263 
00264     //! Return the molar entropy divided by R at reference pressure
00265     /*!
00266      * Returns the species reference state entropy divided by R at the
00267      * current temperature.
00268      *
00269      * @return returns the reference state entropy divided by R
00270      */
00271     virtual doublereal entropy_R_ref() const;
00272 
00273     //! Return the molar heat capacity divided by R at reference pressure
00274     /*!
00275      * Returns the species reference state heat capacity divided by R at the
00276      * current temperature.
00277      *
00278      * @return returns the reference state heat capacity divided by R
00279      */
00280     virtual doublereal cp_R_ref() const;
00281 
00282     //! Return the molar volume at reference pressure
00283     /*!
00284      * Returns the species reference state molar volume at the
00285      * current temperature.
00286      *
00287      * @return returns the reference state molar volume divided by R
00288      *             units are m**3 kmol-1.
00289      */
00290     virtual doublereal molarVolume_ref() const;\
00291 
00292     /**
00293      * @}
00294      *  @name Mechanical Equation of State Properties 
00295      * @{
00296      */
00297  
00298 
00299     //! Report the current pressure used in the object
00300     /*!
00301      * @return Returns the pressure (Pascal)
00302      */
00303     virtual doublereal pressure() const;
00304 
00305     //! Set the pressure internally
00306     /*!
00307      *  @param pres  Value of the pressure (Pascals)
00308      */
00309     virtual void setPressure(doublereal pres);
00310 
00311     //! Set the internal temperature
00312     /*!
00313      * @param temp Temperature (Kelvin)
00314      */
00315     virtual void setTemperature(doublereal temp);
00316 
00317     //! Set the temperature and pressure in the object
00318     /*!
00319      *  @param temp   Temperature (Kelvin)
00320      *  @param pres   Pressure    (Pascal)
00321      */
00322     virtual void setState_TP(doublereal temp, doublereal pres);
00323 
00324 
00325     //! Set the temperature and density in the object
00326     /*!
00327      *  @param temp   Temperature (Kelvin)
00328      *  @param rho    Density (kg/m3) 
00329      */
00330     virtual void setState_TR(doublereal temp, doublereal rho);
00331 
00332     //! Set the density of the water phase
00333     /*!
00334      *  This is a non-virtual function because it specific
00335      *  to this object.
00336      *
00337      * @param dens Density of the water (kg/m3)
00338      */
00339     void setDensity(doublereal dens);
00340 
00341 
00342     //! Return the volumetric thermal expansion coefficient. Units: 1/K.
00343     /*!
00344      * The thermal expansion coefficient is defined as
00345      * \f[
00346      * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P
00347      * \f]
00348      */
00349     virtual doublereal thermalExpansionCoeff() const;
00350       
00351     //! Return the derivative of the volumetric thermal expansion coefficient. Units: 1/K2.
00352     /*!
00353      * The thermal expansion coefficient is defined as
00354      * \f[
00355      * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P
00356      * \f]
00357      */
00358     virtual doublereal dthermalExpansionCoeffdT() const;
00359 
00360     //! Returns  the isothermal compressibility. Units: 1/Pa.
00361     /*!
00362      * The isothermal compressibility is defined as
00363      * \f[
00364      * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T
00365      * \f]
00366      *  or
00367      * \f[
00368      * \kappa_T = \frac{1}{\rho}\left(\frac{\partial \rho}{\partial P}\right)_T
00369      * \f]
00370      */
00371     virtual doublereal isothermalCompressibility() const;
00372 
00373     /**
00374      * @}
00375      *  @name  Miscellaneous properties of the standard state
00376      * @{
00377      */
00378 
00379     //! critical temperature 
00380     virtual doublereal critTemperature() const;
00381  
00382     //! critical pressure
00383     virtual doublereal critPressure() const;
00384         
00385     //! critical density
00386     virtual doublereal critDensity() const;
00387    
00388     //! Return the saturation pressure at a given temperature
00389     /*!
00390      *  @param t  Temperature (Kelvin)
00391      */
00392     virtual doublereal satPressure(doublereal t);
00393 
00394     //! Get a pointer to a changeable WaterPropsIAPWS object
00395     WaterPropsIAPWS *getWater() {
00396       return m_sub;
00397     }
00398 
00399     //! Get a pointer to a changeable WaterPropsIAPWS object
00400     WaterProps *getWaterProps() {
00401       return m_waterProps;
00402     }
00403 
00404     /**
00405      * @} 
00406      * @name Initialization of the Object
00407      * @{
00408      */
00409     
00410     //! Internal routine that initializes the underlying water model
00411     /*!
00412      *  This routine is not virtual
00413      */
00414     void constructSet();
00415 
00416     //! Initialization of a PDSS object using an
00417     //! input XML file.
00418     /*!
00419      * This routine is a precursor to constructPDSSXML(XML_Node*)
00420      * routine, which does most of the work.
00421      *
00422      * @param vptp_ptr    Pointer to the Variable pressure %ThermoPhase object
00423      *                    This object must have already been malloced.
00424      *
00425      * @param spindex     Species index within the phase
00426      *
00427      * @param inputFile   XML file containing the description of the
00428      *                    phase
00429      *
00430      * @param id          Optional parameter identifying the name of the
00431      *                    phase. If none is given, the first XML
00432      *                    phase element will be used.
00433      */
00434     void constructPDSSFile(VPStandardStateTP *vptp_ptr, int spindex,
00435                            std::string inputFile, std::string id);
00436 
00437     //!Initialization of a PDSS object using an xml tree
00438     /*!
00439      * This routine is a driver for the initialization of the
00440      * object.
00441      * 
00442      *   basic logic:
00443      *       initThermo()                 (cascade)
00444      *       getStuff from species Part of XML file
00445      *       initThermoXML(phaseNode)      (cascade)
00446      * 
00447      * @param vptp_ptr   Pointer to the Variable pressure %ThermoPhase object
00448      *                   This object must have already been malloced.
00449      *
00450      * @param spindex    Species index within the phase
00451      *
00452      * @param phaseNode  Reference to the phase Information for the phase
00453      *                   that owns this species.
00454      *
00455      * @param id         Optional parameter identifying the name of the
00456      *                   phase. If none is given, the first XML
00457      *                   phase element will be used.
00458      */
00459     void constructPDSSXML(VPStandardStateTP *vptp_ptr, int spindex,
00460                           const XML_Node& phaseNode, std::string id);
00461 
00462     //! Initialization routine for all of the shallow pointers
00463     /*!
00464      *  This is a cascading call, where each level should call the
00465      *  the parent level.
00466      *
00467      *  The initThermo() routines get called before the initThermoXML() routines
00468      *  from the constructPDSSXML() routine.
00469      *
00470      *
00471      *  Calls initPtrs();
00472      */
00473     virtual void initThermo();
00474 
00475     //! Initialization routine for the PDSS object based on the phaseNode
00476     /*!
00477      *  This is a cascading call, where each level should call the
00478      *  the parent level.
00479      *
00480      * @param phaseNode  Reference to the phase Information for the phase
00481      *                   that owns this species.
00482      *
00483      * @param id         Optional parameter identifying the name of the
00484      *                   phase. If none is given, the first XML
00485      *                   phase element will be used.
00486      */
00487     virtual void initThermoXML(const XML_Node& phaseNode, std::string& id);
00488 
00489     //@}
00490 
00491   protected:
00492   
00493 
00494   private:
00495 
00496     //! Pointer to the WaterPropsIAPWS object, which does the actual calculations
00497     //! for the real equation of state
00498     /*!
00499      * This object owns m_sub
00500      */
00501     mutable WaterPropsIAPWS *m_sub;
00502 
00503     //! Pointer to the WaterProps object
00504     /*!
00505      *   This class is used to house several approximation
00506      *   routines for properties of water.
00507      *
00508      * This object owns m_waterProps, and the WaterPropsIAPWS object used by
00509      * WaterProps is m_sub, which is defined above.
00510      */
00511     WaterProps *m_waterProps;
00512 
00513     //! State of the system - density
00514     /*!
00515      * Density is the independent variable here, but it's hidden behind the
00516      * object's interface.
00517      */
00518     doublereal m_dens;
00519 
00520     //! state of the fluid 
00521     /*!
00522      *    0  WATER_GAS       0
00523      *    1  WATER_LIQUID    1
00524      *    2  WATER_SUPERCRIT 2
00525      *    3  WATER_UNSTABLELIQUID  3
00526      *    4  WATER_UNSTABLEGAS  
00527      */
00528     int m_iState;
00529 
00530     /**
00531      *  Offset constants used to obtain consistency with the NIST database.
00532      *  This is added to all internal energy and enthalpy results.
00533      *  units = J kmol-1.
00534      */
00535     doublereal EW_Offset;
00536 
00537     /**
00538      *  Offset constant used to obtain consistency with NIST convention.
00539      *  This is added to all internal entropy results.
00540      *  units = J kmol-1 K-1.
00541      */
00542     doublereal SW_Offset;
00543 
00544     //! Verbose flag - used?
00545     bool m_verbose;
00546 
00547   public:
00548     /**
00549      *  Since this phase represents a liquid phase, it's an error to 
00550      *  return a gas-phase answer. However, if the below is true, then
00551      *  a gas-phase answer is allowed. This is used to check the thermodynamic
00552      *  consistency with ideal-gas thermo functions for example.
00553      */
00554     bool m_allowGasPhase;
00555   };
00556 
00557 }
00558 
00559 #endif
Generated by  doxygen 1.6.3