IdealMolalSoln.h

Go to the documentation of this file.
00001 /**
00002  *  @file IdealMolalSoln.h
00003  *   ThermoPhase object for the ideal molal equation of
00004  * state (see \ref thermoprops 
00005  * and class \link Cantera::IdealMolalSoln IdealMolalSoln\endlink).
00006  *
00007  * Header file for a derived class of ThermoPhase that handles
00008  * variable pressure standard state methods for calculating
00009  * thermodynamic properties that are further based upon 
00010  * activities on the molality scale. The Ideal molal
00011  * solution assumes that all molality-based activity
00012  * coefficients are equal to one. This turns out to be highly
00013  * nonlinear in the limit of the solvent mole fraction going
00014  * to zero.
00015  */
00016 /*
00017  * Copywrite (2006) Sandia Corporation. Under the terms of 
00018  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
00019  * U.S. Government retains certain rights in this software.
00020  */
00021 /*
00022  *  $Author: hkmoffa $
00023  *  $Date: 2009-12-05 14:08:43 -0500 (Sat, 05 Dec 2009) $
00024  *  $Revision: 279 $
00025  */
00026 
00027 #ifndef CT_IDEALMOLALSOLN_H
00028 #define CT_IDEALMOLALSOLN_H
00029 
00030 #include "MolalityVPSSTP.h"
00031 
00032 namespace Cantera {
00033 
00034   /**  \addtogroup thermoprops */
00035   /* @{ 
00036    */
00037  
00038 
00039   /**
00040    * This phase is based upon the mixing-rule assumption that 
00041    * all molality-based activity coefficients are equal
00042    * to one.
00043    *
00044    * This is a full instanteation of a ThermoPhase object.
00045    * The assumption is that the molality-based activity
00046    * coefficient is equal to one. This also implies that
00047    * the osmotic coefficient is equal to one.
00048    *
00049    * Note, this does not mean that the solution is an
00050    * ideal solution. In fact, there is a singularity in
00051    * the formulation as
00052    * the solvent concentration goes to zero.
00053    *
00054    * The mechanical equation of state is currently assumed to
00055    * be that of an incompressible solution. This may change
00056    * in the future. Each species has its own molar volume.
00057    * The molar volume is a constant. 
00058    *
00059    * Class IdealMolalSoln represents a condensed phase.
00060    * The phase and the pure species phases which
00061    * comprise the standard states of the species are assumed to have
00062    * zero volume expansivity and zero isothermal compressibility.
00063    * Each species does, however, have constant but distinct partial
00064    * molar volumes equal to their pure species molar volumes.
00065    * The class derives from class ThermoPhase,
00066    * and overloads the virtual methods defined there with ones that
00067    * use expressions appropriate for incompressible mixtures.
00068    *
00069    * The standard concentrations can have three different forms
00070    * depending on the value of the member attribute m_formGC, which
00071    * is supplied in the XML file.
00072    *
00073    *                          <TABLE>
00074    *  <TR><TD> m_formGC </TD><TD> ActivityConc </TD><TD> StandardConc </TD></TR>
00075    *  <TR><TD> 0        </TD><TD> \f$ {m_k}/ { m^{\Delta}}\f$     </TD><TD> \f$ 1.0        \f$ </TD></TR>
00076    *  <TR><TD> 1        </TD><TD> \f$  m_k / (m^{\Delta} V_k)\f$  </TD><TD> \f$ 1.0 / V_k  \f$ </TD></TR>
00077    *  <TR><TD> 2        </TD><TD> \f$  m_k / (m^{\Delta} V^0_0)\f$</TD><TD> \f$ 1.0 / V^0_0\f$ </TD></TR>
00078    *                         </TABLE>
00079    *
00080    * \f$ V^0_0 \f$ is the solvent standard molar volume. \f$ m^{\Delta} \f$ is a constant equal to a 
00081    * molality of \f$ 1.0 \quad\mbox{gm kmol}^{-1} \f$.
00082    *
00083    * The current default is to have mformGC = 2.
00084    * 
00085    * The value and form of the activity concentration will affect
00086    * reaction rate constants involving species in this phase.
00087    *
00088    * @verbatim
00089       <thermo model="IdealMolalSoln">
00090          <standardConc model="solvent_volume" />
00091          <solvent> H2O(l) </solvent>
00092 
00093          <activityCoefficients model="IdealMolalSoln" >
00094            <idealMolalSolnCutoff model="polyExp">
00095               <gamma_O_limit> 1.0E-5  <gammaOlimit>
00096               <gamma_k_limit> 1.0E-5  <gammaklimit>
00097               <X_o_cutoff>    0.20    </X_o_cutoff>
00098               <C_0_param>     0.05    </C_0_param>
00099               <slope_f_limit> 0.6     </slopefLimit>
00100               <slope_g_limit> 0.0     </slopegLimit>
00101            </idealMolalSolnCutoff>
00102          </activityCoefficients>
00103 
00104 
00105 
00106       </thermo>
00107 
00108 
00109 
00110    @endverbatim
00111    *
00112    */
00113   class IdealMolalSoln : public MolalityVPSSTP {
00114 
00115   public:
00116         
00117     /// Constructors 
00118     IdealMolalSoln();
00119 
00120     //! Copy Constructor
00121     IdealMolalSoln(const IdealMolalSoln &);
00122 
00123     //! Assignment operator
00124     IdealMolalSoln& operator=(const     IdealMolalSoln&);
00125 
00126     //! Constructor for phase initialization
00127     /*!
00128      * This constructor will initialize a phase, by reading the required
00129      * information from an input file.
00130      *
00131      *  @param inputFile   Name of the Input file that contains information about the phase
00132      *  @param id          id of the phase within the input file 
00133      */
00134     IdealMolalSoln(std::string inputFile, std::string id = "");
00135 
00136     //! Constructor for phase initialization
00137     /*!
00138      * This constructor will initialize a phase, by reading the required
00139      * information from XML_Node tree.
00140      *
00141      *  @param phaseRef    reference for an XML_Node tree that contains
00142      *                     the information necessary to initialize the phase.
00143      *  @param id          id of the phase within the input file 
00144      */
00145     IdealMolalSoln(XML_Node& phaseRef, std::string id = "");
00146 
00147     /// Destructor. 
00148     virtual ~IdealMolalSoln();
00149 
00150     //! Duplication function
00151     /*!
00152      * This virtual function is used to create a duplicate of the
00153      * current phase. It's used to duplicate the phase when given
00154      * a ThermoPhase pointer to the phase.
00155      *
00156      * @return It returns a ThermoPhase pointer.
00157      */
00158     ThermoPhase *duplMyselfAsThermoPhase() const;
00159 
00160     /**
00161      *   
00162      * @name  Utilities  
00163      * @{
00164      */
00165 
00166     /** 
00167      * Equation of state type flag. The base class returns
00168      * zero. Subclasses should define this to return a unique
00169      * non-zero value. Constants defined for this purpose are
00170      * listed in mix_defs.h.
00171      */
00172     virtual int eosType() const { return 0; }
00173 
00174     /**
00175      * @} 
00176      * @name  Molar Thermodynamic Properties of the Solution --------------- 
00177      * @{
00178      */
00179 
00180     //! Molar enthalpy of the solution. Units: J/kmol. 
00181     /*!
00182      *
00183      * Returns the amount of enthalpy per mole of solution.
00184      * For an ideal molal solution,
00185      * \f[
00186      * \bar{h}(T, P, X_k) = \sum_k X_k \bar{h}_k(T)  
00187      * \f]
00188      * The formula is written in terms of the partial molar enthalpies.
00189      * \f$ \bar{h}_k(T, p, m_k) \f$.
00190      * See the partial molar enthalpy function, getPartialMolarEnthalpies(),
00191      * for details.
00192      *
00193      * Units: J/kmol
00194      */
00195     virtual doublereal enthalpy_mole() const;
00196 
00197     //! Molar internal energy of the solution: Units: J/kmol.
00198     /*!
00199      *
00200      * Returns the amount of internal energy per mole of solution.
00201      * For an ideal molal solution,
00202      * \f[
00203      * \bar{u}(T, P, X_k) = \sum_k X_k \bar{u}_k(T)  
00204      * \f]
00205      * The formula is written in terms of the partial molar internal energy.
00206      * \f$ \bar{u}_k(T, p, m_k) \f$.
00207      */
00208     virtual doublereal intEnergy_mole() const;
00209 
00210     //! Molar entropy of the solution. Units: J/kmol/K. 
00211     /*!
00212      * Returns the amount of entropy per mole of solution.
00213      * For an ideal molal solution,
00214      * \f[
00215      * \bar{s}(T, P, X_k) = \sum_k X_k \bar{s}_k(T)  
00216      * \f]
00217      * The formula is written in terms of the partial molar entropies.
00218      * \f$ \bar{s}_k(T, p, m_k) \f$.
00219      * See the partial molar entropies function, getPartialMolarEntropies(),
00220      * for details.
00221      *
00222      * Units: J/kmol/K.
00223      */
00224     virtual doublereal entropy_mole() const;
00225 
00226     //! Molar Gibbs function for the solution: Units J/kmol. 
00227     /*!
00228      *
00229      * Returns the gibbs free energy of the solution per mole
00230      * of the solution.
00231      *
00232      * \f[
00233      * \bar{g}(T, P, X_k) = \sum_k X_k \mu_k(T)  
00234      * \f]
00235      *
00236      * Units: J/kmol
00237      */
00238     virtual doublereal gibbs_mole() const;
00239 
00240     //! Molar heat capacity of the solution at constant pressure. Units: J/kmol/K. 
00241     /*!
00242      *   \f[
00243      * \bar{c}_p(T, P, X_k) = \sum_k X_k \bar{c}_{p,k}(T)  
00244      * \f]
00245      *
00246      * Units: J/kmol/K
00247      */
00248     virtual doublereal cp_mole() const;
00249 
00250     //! Molar heat capacity of the solution at constant volume. Units: J/kmol/K. 
00251     /*!
00252      * Molar heat capacity at constant volume: Units: J/kmol/K. 
00253      * NOT IMPLEMENTED.
00254      * Units: J/kmol/K
00255      */
00256     virtual doublereal cv_mole() const;
00257 
00258     //@}
00259     /** @name Mechanical Equation of State Properties -------------------------
00260      //@{
00261      *
00262      *   In this equation of state implementation, the density is a 
00263      *   function only of the mole fractions. Therefore, it can't be 
00264      *   an independent variable. Instead, the pressure is used as the
00265      *   independent variable. Functions which try to set the thermodynamic
00266      *   state by calling setDensity() may cause an exception to be
00267      *   thrown.  
00268      */
00269 
00270 
00271 
00272     /**
00273      * Set the pressure at constant temperature. Units: Pa.
00274      * This method sets a constant within the object.
00275      * The mass density is not a function of pressure.
00276      *
00277      * @param p   Input Pressure
00278      */
00279     virtual void setPressure(doublereal p);
00280 
00281   protected:
00282     /**
00283      * Calculate the density of the mixture using the partial 
00284      * molar volumes and mole fractions as input
00285      *
00286      * The formula for this is
00287      *
00288      * \f[ 
00289      * \rho = \frac{\sum_k{X_k W_k}}{\sum_k{X_k V_k}} 
00290      * \f]
00291      *
00292      * where \f$X_k\f$ are the mole fractions, \f$W_k\f$ are
00293      * the molecular weights, and \f$V_k\f$ are the pure species
00294      * molar volumes.
00295      *
00296      * Note, the basis behind this formula is that in an ideal
00297      * solution the partial molar volumes are equal to the pure
00298      * species molar volumes. We have additionally specified
00299      * in this class that the pure species molar volumes are
00300      * independent of temperature and pressure.
00301      *
00302      * NOTE: This is a non-virtual function, which is not a 
00303      *       member of the ThermoPhase base class. 
00304      */
00305     void calcDensity();
00306 
00307   public:
00308     /**
00309      * Overwritten setDensity() function is necessary because the
00310      * density is not an indendent variable.
00311      *
00312      * This function will now throw an error condition
00313      *
00314      * @internal May have to adjust the strategy here to make
00315      * the eos for these materials slightly compressible, in order
00316      * to create a condition where the density is a function of 
00317      * the pressure.
00318      *
00319      * This function will now throw an error condition.
00320      *
00321      *  NOTE: This is an overwritten function from the State.h
00322      *        class
00323      *
00324      * @param rho   Input Density
00325      */
00326     void setDensity(const doublereal rho);
00327 
00328     /**
00329      * Overwritten setMolarDensity() function is necessary because the
00330      * density is not an indendent variable.
00331      *
00332      * This function will now throw an error condition.
00333      *
00334      *  NOTE: This is an overwritten function from the State.h
00335      *        class
00336      *
00337      * @param rho   Input Density
00338      */
00339     void setMolarDensity(const doublereal rho);
00340 
00341     //! Set the temperature (K) and pressure (Pa)
00342     /*!
00343      *  Set the temperature and pressure.
00344      *
00345      * @param t    Temperature (K)
00346      * @param p    Pressure (Pa)
00347      */
00348     virtual void setState_TP(doublereal t, doublereal p);
00349 
00350     //! The isothermal compressibility. Units: 1/Pa.
00351     /*!
00352      * The isothermal compressibility is defined as
00353      * \f[
00354      * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T
00355      * \f]
00356      *
00357      *  It's equal to zero for this model, since the molar volume
00358      *  doesn't change with pressure or temperature.
00359      */
00360     virtual doublereal isothermalCompressibility() const;
00361 
00362     //!  The thermal expansion coefficient. Units: 1/K.
00363     /*!
00364      * The thermal expansion coefficient is defined as
00365      *
00366      * \f[
00367      * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P
00368      * \f]
00369      *
00370      *  It's equal to zero for this model, since the molar volume
00371      *  doesn't change with pressure or temperature.
00372      */
00373     virtual doublereal thermalExpansionCoeff() const;
00374 
00375     /**
00376      * @} 
00377      * @name Potential Energy
00378      * 
00379      * Species may have an additional potential energy due to the
00380      * presence of external gravitation or electric fields. These
00381      * methods allow specifying a potential energy for individual
00382      * species.
00383      * @{
00384      */
00385 
00386     
00387      //!Set the potential energy of species k to pe.
00388     /*!
00389      * Units: J/kmol.
00390      * This function must be reimplemented in inherited classes
00391      * of ThermoPhase.
00392      *
00393      * @param k    Species index
00394      * @param pe   Input potential energy.
00395      */
00396     virtual void setPotentialEnergy(int k, doublereal pe) {
00397       err("setPotentialEnergy");
00398     }
00399     
00400     /*
00401      * Get the potential energy of species k.
00402      * Units: J/kmol.
00403      * This function must be reimplemented in inherited classes
00404      * of ThermoPhase.
00405      *
00406      * @param k Species index
00407      */
00408     virtual doublereal potentialEnergy(int k) const {
00409       return err("potentialEnergy");
00410     }
00411 
00412     /*
00413      * Set the electric potential of this phase (V).
00414      * This is used by classes InterfaceKinetics and EdgeKinetics to
00415      * compute the rates of charge-transfer reactions, and in computing
00416      * the electrochemical potentials of the species.
00417      *
00418      * @param v       input Electric Potential (volts).
00419      */
00420     void setElectricPotential(doublereal v) {
00421       m_phi = v;
00422     }
00423 
00424     //! Returns the electric potential of this phase (V).
00425     doublereal electricPotential() const { return m_phi; }
00426 
00427 
00428     /**
00429      * @}
00430      * @name Activities and Activity Concentrations
00431      *
00432      * The activity \f$a_k\f$ of a species in solution is
00433      * related to the chemical potential by \f[ \mu_k = \mu_k^0(T)
00434      * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T)\f$ is
00435      * the chemical potential at unit activity, which depends only
00436      * on temperature and the pressure.
00437      * @{
00438      */
00439 
00440     /*!
00441      * This method returns an array of generalized concentrations
00442      * \f$ C_k\f$ that are defined such that 
00443      * \f$ a_k = C_k / C^0_k, \f$ where \f$ C^0_k \f$ 
00444      * is a standard concentration
00445      * defined below.  These generalized concentrations are used
00446      * by kinetics manager classes to compute the forward and
00447      * reverse rates of elementary reactions. 
00448      *
00449      * @param c Array of generalized concentrations. The 
00450      *          units depend upon the implementation of the
00451      *          reaction rate expressions within the phase.
00452      */
00453     virtual void getActivityConcentrations(doublereal* c) const;
00454 
00455     /**
00456      * The standard concentration \f$ C^0_k \f$ used to normalize
00457      * the generalized concentration. In many cases, this quantity
00458      * will be the same for all species in a phase - for example,
00459      * for an ideal gas \f$ C^0_k = P/\hat R T \f$. For this
00460      * reason, this method returns a single value, instead of an
00461      * array.  However, for phases in which the standard
00462      * concentration is species-specific (e.g. surface species of
00463      * different sizes), this method may be called with an
00464      * optional parameter indicating the species.
00465      *
00466      * @param k  Species index 
00467      */
00468     virtual doublereal standardConcentration(int k=0) const;
00469 
00470     /*!
00471      * Returns the natural logarithm of the standard 
00472      * concentration of the kth species
00473      *
00474      * @param k  Species index 
00475      */
00476     virtual doublereal logStandardConc(int k=0) const;
00477 
00478     /*!
00479      * Returns the units of the standard and generalized
00480      * concentrations Note they have the same units, as their
00481      * ratio is defined to be equal to the activity of the kth
00482      * species in the solution, which is unitless.
00483      *
00484      * This routine is used in print out applications where the
00485      * units are needed. Usually, MKS units are assumed throughout
00486      * the program and in the XML input files.
00487      *
00488      * @param uA Output vector containing the units
00489      *  uA[0] = kmol units - default  = 1
00490      *  uA[1] = m    units - default  = -nDim(), the number of spatial
00491      *                                dimensions in the Phase class.
00492      *  uA[2] = kg   units - default  = 0;
00493      *  uA[3] = Pa(pressure) units - default = 0;
00494      *  uA[4] = Temperature units - default = 0;
00495      *  uA[5] = time units - default = 0
00496      * @param k species index. Defaults to 0.
00497      * @param sizeUA output int containing the size of the vector.
00498      *        Currently, this is equal to 6.
00499      */
00500     virtual void getUnitsStandardConc(double *uA, int k = 0,
00501                                       int sizeUA = 6) const;
00502 
00503     /*!
00504      * Get the array of non-dimensional activities at
00505      * the current solution temperature, pressure, and
00506      * solution concentration.
00507      *
00508      * (note solvent is on molar scale)
00509      *
00510      * @param ac      Output activity coefficients.
00511      *                Length: m_kk.
00512      */
00513     virtual void getActivities(doublereal* ac) const;
00514 
00515     /*!
00516      * Get the array of non-dimensional molality-based
00517      * activity coefficients at the current solution temperature, 
00518      * pressure, and solution concentration.
00519      * 
00520      * 
00521      * (note solvent is on molar scale. The solvent molar
00522      *  based activity coefficient is returned).
00523      *
00524      * @param acMolality      Output Molality-based activity coefficients.
00525      *                        Length: m_kk.
00526      */
00527     virtual void 
00528     getMolalityActivityCoefficients(doublereal* acMolality) const;
00529 
00530     //@}
00531     /// @name  Partial Molar Properties of the Solution -----------------
00532     //@{
00533 
00534  
00535     //!Get the species chemical potentials: Units: J/kmol.
00536     /*!
00537      *
00538      * This function returns a vector of chemical potentials of the 
00539      * species in solution.
00540      *
00541      * \f[
00542      *    \mu_k = \mu^{o}_k(T,P) + R T \ln(\frac{m_k}{m^\Delta})
00543      * \f]
00544      * \f[
00545      *    \mu_w = \mu^{o}_w(T,P) +
00546      *            R T ((X_w - 1.0) / X_w)
00547      * \f]
00548      *
00549      * \f$ w \f$ refers to the solvent species. 
00550      * \f$ X_w \f$ is the mole fraction of the solvent.
00551      * \f$ m_k \f$ is the molality of the kth solute.
00552      * \f$ m^\Delta is 1 gmol solute per kg solvent. \f$
00553      *
00554      * Units: J/kmol.
00555      *
00556      * @param mu     Output vector of species chemical potentials.
00557      *               Length: m_kk.
00558      */
00559     virtual void getChemPotentials(doublereal* mu) const;
00560 
00561     //! Returns an array of partial molar enthalpies for the species in the mixture.
00562     /*!
00563      * Units (J/kmol)
00564      * For this phase, the partial molar enthalpies are equal to the
00565      * species standard state enthalpies.
00566      *  \f[
00567      * \bar h_k(T,P) = \hat h^{ref}_k(T) + (P - P_{ref}) \hat V^0_k
00568      * \f]
00569      * The reference-state pure-species enthalpies, \f$ \hat h^{ref}_k(T) \f$,
00570      * at the reference pressure,\f$ P_{ref} \f$,
00571      * are computed by the species thermodynamic 
00572      * property manager. They are polynomial functions of temperature.
00573      * @see SpeciesThermo
00574      *
00575      * @param hbar   Output vector of partial molar enthalpies.
00576      *               Length: m_kk.
00577      */
00578     virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
00579 
00580  
00581     //! Returns an array of partial molar entropies of the species in the solution. Units: J/kmol.
00582     /*!
00583      *
00584      * Maxwell's equations provide an insight in how to calculate this
00585      * (p.215 Smith and Van Ness)
00586      * \f[
00587      *      \frac{d(\mu_k)}{dT} = -\bar{s}_i
00588      * \f]
00589      * For this phase, the partial molar entropies are equal to the
00590      * standard state species entropies plus the ideal molal solution contribution.
00591      * 
00592      * \f[
00593      *   \bar{s}_k(T,P) =  s^0_k(T) - R \ln( \frac{m_k}{m^{\triangle}} )
00594      * \f]
00595      * \f[
00596      *   \bar{s}_w(T,P) =  s^0_w(T) - R ((X_w - 1.0) / X_w)
00597      * \f]
00598      *
00599      * The subscript, w, refers to the solvent species. \f$ X_w \f$ is
00600      * the mole fraction of solvent.
00601      * The reference-state pure-species entropies,\f$ s^0_k(T) \f$,
00602      * at the reference pressure, \f$ P_{ref} \f$, are computed by the
00603      * species thermodynamic
00604      * property manager. They are polynomial functions of temperature.
00605      * @see SpeciesThermo
00606      *
00607      * @param sbar Output vector of partial molar entropies.
00608      *             Length: m_kk.
00609      */
00610     virtual void getPartialMolarEntropies(doublereal* sbar) const;
00611      
00612     // partial molar volumes of the species Units: m^3 kmol-1.
00613     /*!
00614      * For this solution, the partial molar volumes are equal to the
00615      * constant species molar volumes.
00616      *
00617      * Units: m^3 kmol-1.
00618      *  @param vbar Output vector of partial molar volumes.
00619      */
00620     virtual void getPartialMolarVolumes(doublereal* vbar) const;
00621 
00622     
00623     //! Partial molar heat capacity of the solution:. UnitsL J/kmol/K
00624     /*!
00625      *   The kth partial molar heat capacity is  equal to 
00626      *   the temperature derivative of the partial molar
00627      *   enthalpy of the kth species in the solution at constant
00628      *   P and composition (p. 220 Smith and Van Ness).
00629      *    \f[
00630      *    \bar{Cp}_k(T,P) =  {Cp}^0_k(T) 
00631      *    \f]
00632      *
00633      *   For this solution, this is equal to the reference state
00634      *   heat capacities.
00635      *
00636      *  Units: J/kmol/K
00637      *
00638      * @param cpbar  Output vector of partial molar heat capacities.
00639      *               Length: m_kk.
00640      */
00641     virtual void getPartialMolarCp(doublereal* cpbar) const;
00642 
00643     //@}
00644     /// @name  Properties of the Standard State of the Species
00645     //          in the Solution --
00646     //@{
00647      
00648  
00649 
00650  
00651     //@}
00652     /// @name Thermodynamic Values for the Species Reference States ---
00653     //@{
00654 
00655 
00656     ///////////////////////////////////////////////////////
00657     //
00658     //  The methods below are not virtual, and should not
00659     //  be overloaded.
00660     //
00661     //////////////////////////////////////////////////////
00662 
00663     /**
00664      * @name Specific Properties
00665      * @{
00666      */
00667 
00668 
00669     /**
00670      * @name Setting the State
00671      *
00672      * These methods set all or part of the thermodynamic
00673      * state.
00674      * @{
00675      */
00676 
00677     //@}
00678 
00679     /**
00680      * @name Chemical Equilibrium
00681      * Chemical equilibrium.
00682      * @{
00683      */
00684 
00685     /**
00686      * This method is used by the ChemEquil equilibrium solver.
00687      * It sets the state such that the chemical potentials satisfy
00688      * \f[ \frac{\mu_k}{\hat R T} = \sum_m A_{k,m}
00689      * \left(\frac{\lambda_m} {\hat R T}\right) \f] where 
00690      * \f$ \lambda_m \f$ is the element potential of element m. The
00691      * temperature is unchanged.  Any phase (ideal or not) that
00692      * implements this method can be equilibrated by ChemEquil.
00693      * 
00694      * Not implemented.
00695      *
00696      * @param lambda_RT vector of Nondimensional element potentials.
00697      */ 
00698     virtual void setToEquilState(const doublereal* lambda_RT) {
00699       err("setToEquilState");
00700     }
00701 
00702     //@}
00703 
00704     /**
00705      * @internal
00706      * Set equation of state parameters. The number and meaning of
00707      * these depends on the subclass. 
00708      * @param n number of parameters
00709      * @param c array of <I>n</I> coefficients
00710      * 
00711      */
00712     virtual void setParameters(int n, doublereal* const c);
00713 
00714     /*!
00715      * @internal
00716      *  Get the parameters used to initialize the phase.
00717      *
00718      * @param n  number of parameters (output)
00719      * @param c array of <I>n</I> coefficients
00720      */
00721     virtual void getParameters(int &n, doublereal * const c) const;
00722 
00723     /*!
00724      * Set equation of state parameter values from XML
00725      * entries. This method is called by function importPhase in
00726      * file importCTML.cpp when processing a phase definition in
00727      * an input file. It should be overloaded in subclasses to set
00728      * any parameters that are specific to that particular phase
00729      * model. 
00730      *   
00731      * @param eosdata An XML_Node object corresponding to
00732      * the "thermo" entry for this phase in the input file.
00733      */
00734     virtual void setParametersFromXML(const XML_Node& eosdata);
00735 
00736     //---------------------------------------------------------
00737     /// @name Critical state properties.
00738     /// These methods are only implemented by some subclasses.
00739         
00740     //@{
00741         
00742     /**
00743      *   Critical temperature (K).
00744      *   Not implemented for this phase type.
00745      */
00746     virtual doublereal critTemperature() const {
00747       err("critTemperature"); return -1.0;
00748     }
00749         
00750     /**
00751      *  Critical pressure (Pa).
00752      *
00753      * Not implemented for this phase type.
00754      */
00755     virtual doublereal critPressure() const {
00756       err("critPressure"); return -1.0;
00757     }
00758         
00759     /**
00760      *  Critical density (kg/m3).
00761      *  Not implemented for this phase type.
00762      */
00763     virtual doublereal critDensity() const {
00764       err("critDensity"); return -1.0;
00765     }                
00766         
00767     //@}
00768         
00769     /// @name Saturation properties.
00770     /// These methods are only implemented by subclasses that 
00771     /// implement full liquid-vapor equations of state.
00772     ///
00773  
00774     //@}
00775 
00776 
00777     /*
00778      *  -------------- Utilities -------------------------------
00779      */
00780 
00781     /*!
00782      * Return a reference to the species thermodynamic property
00783      * manager.  @todo This method will fail if no species thermo
00784      * manager has been installed.
00785      */
00786     SpeciesThermo& speciesThermo() { return *m_spthermo; }
00787 
00788   
00789     //! Initialization routine for an IdealMolalSoln phase.
00790     /*!
00791      *  This internal routine is responsible for setting up
00792      *  the internal storage. This is reimplemented from the ThermoPhase 
00793      *  class.
00794      */
00795     virtual void initThermo();
00796 
00797     //!   Import and initialize an IdealMolalSoln phase 
00798     //!   specification in an XML tree into the current object.
00799     /*!
00800      *   Here we read an XML description of the phase.
00801      *   We import descriptions of the elements that make up the
00802      *   species in a phase.
00803      *   We import information about the species, including their
00804      *   reference state thermodynamic polynomials. We then freeze
00805      *   the state of the species.
00806      *
00807      *   Then, we read the species molar volumes from the xml 
00808      *   tree to finish the initialization.
00809      *
00810      *   This routine is a precursor to constructPhaseXML(XML_Node*)
00811      *   routine, which does most of the work.
00812      *
00813      *   This is a virtual routine, first used here.
00814      *
00815      * @param infile XML file containing the description of the
00816      *        phase
00817      *
00818      * @param id  Optional parameter identifying the name of the
00819      *            phase. If none is given, the first XML
00820      *            phase element will be used.
00821      */
00822     void constructPhaseFile(std::string infile, std::string id="");
00823 
00824     //!   Import and initialize an IdealMolalSoln phase 
00825     //!  specification in an XML tree into the current object.
00826     /*!
00827      * This is the main routine for constructing the phase.
00828      * It processes the XML file, and then it calls importPhase().
00829      * Then, initThermoXML() is called after importPhase().
00830      *
00831      *   Here we read an XML description of the phase.
00832      *   We import descriptions of the elements that make up the
00833      *   species in a phase.
00834      *   We import information about the species, including their
00835      *   reference state thermodynamic polynomials. We then freeze
00836      *   the state of the species.
00837      *
00838      *   Then, we read the species molar volumes from the xml 
00839      *   tree to finish the initialization.
00840      *
00841      * This is a virtual routine, first used in this class.
00842      *
00843      * @param phaseNode This object must be the phase node of a
00844      *             complete XML tree
00845      *             description of the phase, including all of the
00846      *             species data. In other words while "phase" must
00847      *             point to an XML phase object, it must have
00848      *             sibling nodes "speciesData" that describe
00849      *             the species in the phase.
00850      * @param id   ID of the phase. If nonnull, a check is done
00851      *             to see if phaseNode is pointing to the phase
00852      *             with the correct id. 
00853      */
00854     void constructPhaseXML(XML_Node& phaseNode, std::string id);
00855 
00856     //!  Import and initialize an IdealMolalSoln phase 
00857     //!  specification in an XML tree into the current object.
00858     /*!  
00859      *   This routine is called from importPhase() to finish
00860      *   up the initialization of the thermo object. It reads in the
00861      *   species molar volumes.
00862      *
00863      * @param phaseNode This object must be the phase node of a
00864      *             complete XML tree
00865      *             description of the phase, including all of the
00866      *             species data. In other words while "phase" must
00867      *             point to an XML phase object, it must have
00868      *             sibling nodes "speciesData" that describe
00869      *             the species in the phase.
00870      * @param id   ID of the phase. If nonnull, a check is done
00871      *             to see if phaseNode is pointing to the phase
00872      *             with the correct id. 
00873      */
00874     virtual void initThermoXML(XML_Node& phaseNode, std::string id="");
00875 
00876     //! Report the molar volume of species k
00877     /*!
00878      *
00879      * units - \f$ m^3 kmol^-1 \f$
00880      *
00881      * @param k Species index.
00882      */
00883     double speciesMolarVolume(int k) const;
00884 
00885     /*!
00886      * Fill in a return vector containing the species molar volumes
00887      * units - \f$ m^3 kmol^-1 \f$
00888      *
00889      * @param smv Output vector of species molar volumes.
00890      */
00891     void   getSpeciesMolarVolumes(double *smv) const;
00892     //@}
00893 
00894   protected:
00895     /**
00896      * Species molar volume \f$ m^3 kmol^-1 \f$
00897      */
00898     array_fp   m_speciesMolarVolume;
00899 
00900     /**
00901      * The standard concentrations can have three different forms
00902      * depending on the value of the member attribute m_formGC, which
00903      * is supplied in the XML file.
00904      *
00905      *                          <TABLE>
00906      *  <TR><TD> m_formGC </TD><TD> ActivityConc </TD><TD> StandardConc </TD></TR>
00907      *  <TR><TD> 0        </TD><TD> \f$ {m_k}/ { m^{\Delta}}\f$     </TD><TD> \f$ 1.0        \f$ </TD></TR>
00908      *  <TR><TD> 1        </TD><TD> \f$  m_k / (m^{\Delta} V_k)\f$  </TD><TD> \f$ 1.0 / V_k  \f$ </TD></TR>
00909      *  <TR><TD> 2        </TD><TD> \f$  m_k / (m^{\Delta} V^0_0)\f$</TD><TD> \f$ 1.0 / V^0_0\f$ </TD></TR>
00910      *                         </TABLE>
00911      */
00912     int m_formGC;
00913 
00914   public:
00915     //! Cutoff type
00916     int IMS_typeCutoff_;
00917 
00918   private:
00919 
00920     /**
00921      * Vector containing the species reference exp(-G/RT) functions
00922      * at T = m_tlast
00923      */
00924     mutable vector_fp      m_expg0_RT;
00925 
00926     /**
00927      * Vector of potential energies for the species.
00928      */
00929     mutable vector_fp      m_pe;
00930 
00931     /**
00932      * Temporary array used in equilibrium calculations
00933      */
00934     mutable vector_fp      m_pp;
00935 
00936     /**
00937      * vector of size m_kk, used as a temporary holding area.
00938      */
00939     mutable vector_fp      m_tmpV;
00940 
00941     //! Logarithm of the molal activity coefficients
00942     /*!
00943      *   Normally these are all one. However, stability schemes will change that
00944      */
00945     mutable vector_fp      IMS_lnActCoeffMolal_;
00946   public:
00947     //! value of the solute mole fraction that centers the cutoff polynomials
00948     //! for the cutoff =1 process;
00949     doublereal IMS_X_o_cutoff_;
00950   
00951     //! gamma_o value for the cutoff process at the zero solvent point
00952     doublereal IMS_gamma_o_min_;
00953 
00954     //! gamma_k minimun for the cutoff process at the zero solvent point
00955     doublereal IMS_gamma_k_min_;
00956 
00957     //! Parameter in the polyExp cutoff treatment having to do with rate of exp decay
00958     doublereal IMS_cCut_;
00959 
00960     //! Parameter in the polyExp cutoff treatment 
00961     /*!
00962      *  This is the slope of the f function at the zero solvent point
00963      *  Default value is 0.6
00964      */
00965     doublereal IMS_slopefCut_;
00966 
00967     //! Parameter in the polyExp cutoff treatment having to do with rate of exp decay
00968     doublereal IMS_dfCut_;
00969 
00970     //! Parameter in the polyExp cutoff treatment having to do with rate of exp decay
00971     doublereal IMS_efCut_;
00972 
00973     //! Parameter in the polyExp cutoff treatment having to do with rate of exp decay
00974     doublereal IMS_afCut_;
00975 
00976     //! Parameter in the polyExp cutoff treatment having to do with rate of exp decay
00977     doublereal IMS_bfCut_;
00978 
00979     //! Parameter in the polyExp cutoff treatment 
00980     /*!
00981      *  This is the slope of the g function at the zero solvent point
00982      *  Default value is 0.0
00983      */
00984     doublereal IMS_slopegCut_;
00985 
00986     //! Parameter in the polyExp cutoff treatment having to do with rate of exp decay
00987     doublereal IMS_dgCut_;
00988 
00989     //! Parameter in the polyExp cutoff treatment having to do with rate of exp decay
00990     doublereal IMS_egCut_;
00991 
00992     //! Parameter in the polyExp cutoff treatment having to do with rate of exp decay
00993     doublereal IMS_agCut_;
00994 
00995     //! Parameter in the polyExp cutoff treatment having to do with rate of exp decay
00996     doublereal IMS_bgCut_;
00997 
00998   private:
00999 
01000     //! Internal error message
01001     /*!
01002      *  @param          msg message to be printed
01003      */
01004     doublereal err(std::string msg) const;
01005 
01006     //! This function will be called to update the internally storred
01007     //! natural logarithm of the molality activity coefficients
01008     /*!
01009      * Normally the solutes are all zero. However, sometimes they are not,
01010      * due to stability schemes
01011      */
01012     void s_updateIMS_lnMolalityActCoeff() const;
01013 
01014     //! This internal function adjusts the lengths of arrays.
01015     /*!
01016      * This function is not virtual nor is it inherited
01017      */
01018     void initLengths();
01019 
01020     //! Calculate parameters for cutoff treatments of activity coefficients
01021     /*!
01022      * Some cutoff treatments for the activity coefficients
01023      * actually require some calculations to create a consistent treatment.
01024      *
01025      * This routine is called during the setup to calculate these parameters
01026      */
01027     void calcIMSCutoffParams_();
01028   };
01029 
01030   /* @} */
01031 }
01032         
01033 #endif
01034 
01035 
01036 
01037 
01038 
Generated by  doxygen 1.6.3