PureFluidPhase.h

Go to the documentation of this file.
00001 /**
00002  *  @file PureFluidPhase.h
00003  *
00004  *   Header for a ThermoPhase class for a pure fluid phase consisting of 
00005  *   gas, liquid, mixed-gas-liquid and supercrit fluid (see \ref thermoprops 
00006  *   and class \link Cantera::PureFluidPhase PureFluidPhase\endlink).
00007  *
00008  * This class is only available if the WITH_PURE_FLUIDS optional compile
00009  * capability has been turned on in Cantera's makefile system. 
00010  * It inherits from ThermoPhase, but is built on top of the tpx package.
00011  */
00012 
00013 /*  $Author: hkmoffa $
00014  *  $Date: 2009-12-05 14:08:43 -0500 (Sat, 05 Dec 2009) $
00015  *  $Revision: 279 $
00016  *
00017  *  Copyright 2003 California Institute of Technology
00018  */
00019 
00020 #ifndef CT_EOS_TPX_H
00021 #define CT_EOS_TPX_H
00022 
00023 #include "ThermoPhase.h"
00024 /*
00025  * For doxygen to recognize the ifdef below, it seems necessary to 
00026  * include a specific include reference.
00027  */
00028 /**
00029  * This object is only available if the WITH_PURE_FLUIDS optional compile
00030  * capability has been turned on in Cantera's makefile system.  
00031  */
00032 #ifdef WITH_PURE_FLUIDS
00033 
00034 #include "mix_defs.h"
00035 
00036 namespace tpx {
00037     class Substance;
00038 }
00039 
00040 namespace Cantera {
00041 
00042   //!   This phase object consists of a single component that can be a
00043   //!   gas, a liquid, a mixed gas-liquid fluid, or a fluid beyond its
00044   //!   critical point
00045   /*!
00046    *  The object inherits from ThermoPhase. However, its build on top
00047    *  of the tpx package.
00048    *
00049    *
00050    * <H2> Specification of Species Standard State Properties </H2>
00051    *
00052    *
00053    * <H2> Application within %Kinetics Managers </H2>
00054    *
00055    *
00056    * <H2> XML Example </H2>
00057    *
00058    *
00059    * <H2> Instantiation of the Class </H2>
00060    *
00061    * @ingroup thermoprops
00062    */
00063   class PureFluidPhase  : public ThermoPhase {
00064 
00065   public:
00066 
00067     //! Empty Base Constructor
00068     PureFluidPhase();
00069 
00070     //! Copy Constructor
00071     /*!
00072      * @param right Object to be copied
00073      */
00074     PureFluidPhase(const PureFluidPhase &right);
00075 
00076     //! Assignment operator
00077     /*!
00078      * @param right Object to be copied
00079      */
00080     PureFluidPhase& operator=(const PureFluidPhase& right);
00081 
00082     //! Destructor
00083     virtual ~PureFluidPhase();
00084 
00085     //! Duplication function
00086     /*!
00087      * This virtual function is used to create a duplicate of the
00088      * current phase. It's used to duplicate the phase when given
00089      * a ThermoPhase pointer to the phase.
00090      *
00091      * @return It returns a ThermoPhase pointer.
00092      */
00093     ThermoPhase *duplMyselfAsThermoPhase() const;
00094 
00095     //! Equation of state type
00096     virtual int eosType() const { return cPureFluid; }
00097 
00098     /// Molar enthalpy. Units: J/kmol. 
00099     virtual doublereal enthalpy_mole() const;
00100 
00101     /// Molar internal energy. Units: J/kmol. 
00102     virtual doublereal intEnergy_mole() const;
00103 
00104     /// Molar entropy. Units: J/kmol/K. 
00105     virtual doublereal entropy_mole() const;
00106 
00107     /// Molar Gibbs function. Units: J/kmol. 
00108     virtual doublereal gibbs_mole() const;
00109 
00110       /// Molar heat capacity at constant pressure. Units: J/kmol/K. 
00111     virtual doublereal cp_mole() const;
00112 
00113     /// Molar heat capacity at constant volume. Units: J/kmol/K. 
00114     virtual doublereal cv_mole() const;
00115 
00116     //! Return the thermodynamic pressure (Pa).
00117     /*!
00118      * This method calculates the current pressure consistent with the
00119      * independent variables, T, rho.
00120      */
00121     virtual doublereal pressure() const;
00122 
00123     //! sets the thermodynamic pressure (Pa).
00124     /*!
00125      * This method calculates the density that is consistent with the
00126      * desired pressure, given the temperature.
00127      *
00128      * @param p  Pressure (Pa)
00129      */
00130     virtual void setPressure(doublereal p);
00131 
00132     //! Get the species chemical potentials. Units: J/kmol.
00133     /*!
00134      * This function returns a vector of chemical potentials of the 
00135      * species in solution at the current temperature, pressure
00136      * and mole fraction of the solution.
00137      *
00138      * @param mu  Output vector of species chemical 
00139      *            potentials. Length: m_kk. Units: J/kmol
00140      */
00141     virtual void getChemPotentials(doublereal* mu) const {
00142       mu[0] = gibbs_mole();
00143     }
00144 
00145     //! Returns  the isothermal compressibility. Units: 1/Pa.
00146     /*!
00147      * The isothermal compressibility is defined as
00148      * \f[
00149      * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T
00150      * \f]
00151      */
00152     virtual doublereal isothermalCompressibility() const;
00153     
00154     //! Return the volumetric thermal expansion coefficient. Units: 1/K.
00155     /*!      
00156      * The thermal expansion coefficient is defined as
00157      * \f[
00158      * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P
00159      * \f]
00160      */
00161     virtual doublereal thermalExpansionCoeff() const;
00162 
00163     //! Returns a reference to the substance object
00164     tpx::Substance& TPX_Substance();
00165 
00166     /// critical temperature 
00167     virtual doublereal critTemperature() const;
00168  
00169     /// critical pressure
00170     virtual doublereal critPressure() const;
00171         
00172     /// critical density
00173     virtual doublereal critDensity() const;
00174         
00175     /// saturation temperature
00176     /*!
00177      * @param p  Pressure (Pa)
00178      */
00179     virtual doublereal satTemperature(doublereal p) const;
00180 
00181     //! Set the internally storred specific enthalpy (J/kg) and pressure (Pa) of the phase.
00182     /*!
00183      * @param h     Specific enthalpy (J/kg)
00184      * @param p     Pressure (Pa)
00185      * @param tol  Optional parameter setting the tolerance of the
00186      *             calculation.
00187      */
00188     virtual void setState_HP(doublereal h, doublereal p, 
00189                              doublereal tol = 1.e-8);
00190 
00191     //! Set the specific internal energy (J/kg) and specific volume (m^3/kg).
00192     /*!
00193      * This function fixes the internal state of the phase so that
00194      * the specific internal energy and specific volume have the value of the input parameters.
00195      *
00196      * @param u    specific internal energy (J/kg)
00197      * @param v    specific volume (m^3/kg).
00198      * @param tol  Optional parameter setting the tolerance of the
00199      *             calculation.
00200      */
00201     virtual void setState_UV(doublereal u, doublereal v, 
00202                              doublereal tol = 1.e-8);
00203 
00204     //! Set the specific entropy (J/kg/K) and specific volume (m^3/kg).
00205     /*!
00206      * This function fixes the internal state of the phase so that
00207      * the specific entropy and specific volume have the value of the input parameters.
00208      *
00209      * @param s    specific entropy (J/kg/K)
00210      * @param v    specific volume (m^3/kg).
00211      * @param tol  Optional parameter setting the tolerance of the
00212      *             calculation.
00213      */
00214     virtual void setState_SV(doublereal s, doublereal v, 
00215                              doublereal tol = 1.e-8);
00216 
00217     //! Set the specific entropy (J/kg/K) and pressure (Pa).
00218     /*!
00219      * This function fixes the internal state of the phase so that
00220      * the specific entropy and the pressure have the value of the input parameters.
00221      *
00222      * @param s    specific entropy (J/kg/K)
00223      * @param p    specific pressure (Pa).
00224      * @param tol  Optional parameter setting the tolerance of the
00225      *             calculation.
00226      */
00227     virtual void setState_SP(doublereal s, doublereal p, 
00228                              doublereal tol = 1.e-8);
00229 
00230 
00231       
00232     //! @name Saturation properties.
00233     /*!
00234      * These methods are only implemented by subclasses that 
00235      * implement full liquid-vapor equations of state. They may be
00236      * moved out of ThermoPhase at a later date.
00237      */
00238     //@{
00239 
00240     //! Return the saturation pressure given the temperatur
00241     /*!
00242      * @param t Temperature (Kelvin)
00243      */
00244     virtual doublereal satPressure(doublereal t) const;
00245 
00246     //! Return the fraction of vapor at the current conditions
00247     virtual doublereal vaporFraction() const;
00248 
00249     //! Set the state to a saturated system at a particular temperature
00250     /*!
00251      * @param t  Temperature (kelvin)
00252      * @param x  Fraction of vapor
00253      */
00254     virtual void setState_Tsat(doublereal t, doublereal x);
00255 
00256     //! Set the state to a saturated system at a particular pressure
00257     /*!
00258      * @param p  Pressure (Pa)
00259      * @param x  Fraction of vapor
00260      */
00261     virtual void setState_Psat(doublereal p, doublereal x);
00262     //@}
00263 
00264     //! Initialize the ThermoPhase object after all species have been set up
00265     /*!
00266      * @internal Initialize.
00267      *
00268      * This method is provided to allow
00269      * subclasses to perform any initialization required after all
00270      * species have been added. For example, it might be used to
00271      * resize internal work arrays that must have an entry for
00272      * each species.  The base class implementation does nothing,
00273      * and subclasses that do not require initialization do not
00274      * need to overload this method.  When importing a CTML phase
00275      * description, this method is called from ThermoPhase::initThermoXML(),
00276      * which is called from importPhase(),
00277      * just prior to returning from function importPhase().
00278      *
00279      * @see importCTML.cpp
00280      */
00281     virtual void initThermo();
00282 
00283     //! Set equation of state parameter values from XML entries.
00284     /*!
00285      *
00286      * This method is called by function importPhase() in
00287      * file importCTML.cpp when processing a phase definition in
00288      * an input file. It should be overloaded in subclasses to set
00289      * any parameters that are specific to that particular phase
00290      * model. Note, this method is called before the phase is
00291      * initialzed with elements and/or species.
00292      *   
00293      * @param eosdata An XML_Node object corresponding to
00294      *                the "thermo" entry for this phase in the input file.
00295      */
00296     virtual void setParametersFromXML(const XML_Node& eosdata);
00297 
00298 
00299     //! returns a summary of the state of the phase as a string
00300     /*!
00301      * @param show_thermo If true, extra information is printed out
00302      *                    about the thermodynamic state of the system.
00303      */
00304     virtual std::string report(bool show_thermo = true) const;
00305 
00306   protected:
00307 
00308     //! Main call to the tpx level to set the state of the system
00309     /*!
00310      * @param n  Integer indicating which 2 thermo components are held constant
00311      * @param x  Value of the first component
00312      * @param y  Value of the second component
00313      */
00314     void Set(int n, double x, double y) const;
00315 
00316     //! Sets the state using a TPX::TV call
00317     void setTPXState() const;
00318 
00319     //! Carry out a internal check on tpx, it may have thrown an error.
00320     /*!
00321      * @param v Defaults to zero
00322      */
00323     void check(doublereal v = 0.0) const;
00324 
00325     //! Report errors in the TPX level
00326     void reportTPXError() const;
00327 
00328   private:
00329 
00330     //! Pointer to the underlying tpx object Substance that does the work
00331     mutable tpx::Substance* m_sub;
00332 
00333     //! Int indicating the type of the fluid
00334     /*!
00335      * The tpx package uses an int to indicate what fluid is being sought.
00336      */
00337     int m_subflag;
00338 
00339     //! Molecular weight of the substance (kg kmol-1)
00340     doublereal m_mw;
00341 
00342     //! flag to turn on some printing.
00343     bool m_verbose;
00344   };
00345 
00346 }
00347 
00348 #endif
00349 #endif
00350 
Generated by  doxygen 1.6.3