IdealSolidSolnPhase.h

Go to the documentation of this file.
00001 /**
00002  * @file IdealSolidSolnPhase.h
00003  *      Header file for an ideal solid solution model
00004  *      with incompressible thermodynamics (see \ref thermoprops and
00005  *      \link Cantera::IdealSolidSolnPhase IdealSolidSolnPhase\endlink).
00006  *
00007  *      This class inherits from the Cantera class ThermoPhase
00008  *      and implements an ideal solid solution model with incompressible
00009  *      thermodynamics.
00010  */
00011 
00012 /* 
00013  * $Author: hkmoffa $
00014  *  $Date: 2009-12-05 14:08:43 -0500 (Sat, 05 Dec 2009) $
00015  *  $Revision: 279 $
00016  */
00017 /*
00018  * Copywrite 2006 Sandia Corporation. Under the terms of Contract
00019  * DE-AC04-94AL85000, with Sandia Corporation, the U.S. Government
00020  * retains certain rights in this software.
00021  */
00022 
00023 #ifndef CT_IDEALSOLIDSOLNPHASE_H
00024 #define CT_IDEALSOLIDSOLNPHASE_H
00025 
00026 #include "mix_defs.h"
00027 #include "ThermoPhase.h"
00028 #include "ThermoFactory.h"
00029 #include "SpeciesThermo.h"
00030 
00031 
00032 namespace Cantera {
00033 
00034   /*!
00035    * @name CONSTANTS - Models for the Standard State of IdealSolidSolnPhase's
00036    */
00037   //@{
00038   const int cIdealSolidSolnPhase0 = 5010;
00039   const int cIdealSolidSolnPhase1 = 5011;
00040   const int cIdealSolidSolnPhase2 = 5012;
00041   //@}
00042 
00043   /**
00044    * Class IdealSolidSolnPhase represents a condensed phase ideal 
00045    * solution compound. The phase and the pure species phases which
00046    * comprise the standard states of the species are assumed to have
00047    * zero volume expansivity and zero isothermal compressibility.
00048    * Each species does, however, have constant but distinct partial 
00049    * molar volumes equal to their pure species molar volumes.
00050    * The class derives from class ThermoPhase,
00051    * and overloads the virtual methods defined there with ones that
00052    * use expressions appropriate for ideal solution mixtures.
00053    * File name for the XML datafile containing information
00054    *               for this phase
00055    * The generalized concentrations can have three different forms 
00056    * depending on the value of the member attribute m_formGC, which
00057    * is supplied in the constructor and in the XML file.
00058    *                          <TABLE>
00059    *  <TR><TD> m_formGC </TD><TD> GeneralizedConc </TD><TD> StandardConc </TD></TR>
00060    *  <TR><TD> 0        </TD><TD> X_k             </TD><TD> 1.0          </TD></TR>
00061    *  <TR><TD> 1        </TD><TD> X_k / V_k       </TD><TD> 1.0 / V_k    </TD></TR>
00062    *  <TR><TD> 2        </TD><TD> X_k / V_N       </TD><TD> 1.0 / V_N    </TD></TR>
00063    *                         </TABLE>
00064    * The value and form of the generalized concentration will affect
00065    * reaction rate constants involving species in this phase.
00066    *
00067    * @ingroup thermoprops
00068    */
00069   class IdealSolidSolnPhase : public ThermoPhase  {
00070 
00071   public:
00072 
00073     /**
00074      * Constructor for IdealSolidSolnPhase.
00075      * The generalized concentrations can have three different forms 
00076      * depending on the value of the member attribute m_formGC, which
00077      * is supplied in the constructor or read from the xml data file.
00078      *                          <TABLE>
00079      *  <TR><TD> m_formGC </TD><TD> GeneralizedConc </TD><TD> StandardConc </TD></TR>
00080      *  <TR><TD> 0        </TD><TD> X_k             </TD><TD> 1.0          </TD></TR>
00081      *  <TR><TD> 1        </TD><TD> X_k / V_k       </TD><TD> 1.0 / V_k    </TD></TR>
00082      *  <TR><TD> 2        </TD><TD> X_k / V_N       </TD><TD> 1.0 / V_N    </TD></TR>
00083      *                         </TABLE>
00084      *
00085      * @param formCG This parameter initializes the m_formGC variable. The default
00086      *               is a value of 0.
00087      */
00088     IdealSolidSolnPhase(int formCG=0);
00089 
00090 
00091     //! Construct and initialize an IdealSolidSolnPhase ThermoPhase object 
00092     //! directly from an asci input file
00093     /*!
00094      *
00095      * This constructor will also fully initialize the object.
00096      * The generalized concentrations can have three different forms 
00097      * depending on the value of the member attribute m_formGC, which
00098      * is supplied in the constructor or read from the xml data file.
00099      *
00100      *                          <TABLE>
00101      *  <TR><TD> m_formGC </TD><TD> GeneralizedConc </TD><TD> StandardConc </TD></TR>
00102      *  <TR><TD> 0        </TD><TD> X_k             </TD><TD> 1.0          </TD></TR>
00103      *  <TR><TD> 1        </TD><TD> X_k / V_k       </TD><TD> 1.0 / V_k    </TD></TR>
00104      *  <TR><TD> 2        </TD><TD> X_k / V_N       </TD><TD> 1.0 / V_N    </TD></TR>
00105      *                         </TABLE>
00106      *
00107      * @param infile File name for the XML datafile containing information
00108      *               for this phase
00109      * @param id     The name of this phase. This is used to look up
00110      *               the phase in the XML datafile.
00111      * @param formCG This parameter initializes the m_formGC variable. The default
00112      *               is a value of 0.
00113      */
00114     IdealSolidSolnPhase(std::string infile, std::string id="", int formCG=0);
00115 
00116     //! Construct and initialize an IdealSolidSolnPhase ThermoPhase object 
00117     //! directly from an XML database
00118     /*!  
00119      * The generalized concentrations can have three different forms 
00120      * depending on the value of the member attribute m_formGC, which
00121      * is supplied in the constructor and/or read from the data file.
00122      *
00123      *                          <TABLE>
00124      *  <TR><TD> m_formGC </TD><TD> GeneralizedConc </TD><TD> StandardConc </TD></TR>
00125      *  <TR><TD> 0        </TD><TD> X_k             </TD><TD> 1.0          </TD></TR>
00126      *  <TR><TD> 1        </TD><TD> X_k / V_k       </TD><TD> 1.0 / V_k    </TD></TR>
00127      *  <TR><TD> 2        </TD><TD> X_k / V_N       </TD><TD> 1.0 / V_N    </TD></TR>
00128      *                         </TABLE>
00129      *
00130      * @param root   XML tree containing a description of the phase.
00131      *               The tree must be positioned at the XML element
00132      *               named phase with id, "id", on input to this routine.
00133      * @param id     The name of this phase. This is used to look up
00134      *               the phase in the XML datafile.
00135      * @param formCG This parameter initializes the m_formGC variable. The default
00136      *               is a value of 0.
00137      */
00138     IdealSolidSolnPhase(XML_Node& root, std::string id="", int formCG=0);
00139 
00140     /*!
00141      * Copy Constructor
00142      */
00143     IdealSolidSolnPhase(const IdealSolidSolnPhase &);
00144 
00145     /*!
00146      * Assignment operator
00147      */
00148     IdealSolidSolnPhase& operator=(const IdealSolidSolnPhase &);
00149 
00150     /*!
00151      * Base Class Duplication Function
00152      *  -> given a pointer to ThermoPhase, this function can
00153      *     duplicate the object. (note has to be a separate function
00154      *     not the copy constructor, because it has to be
00155      *     a virtual function)
00156      */
00157     virtual ThermoPhase* duplMyselfAsThermoPhase() const;
00158 
00159     //! Destructor
00160     virtual ~IdealSolidSolnPhase() {}
00161 
00162     /**
00163      * Equation of state flag. Returns a value depending upon the value of
00164      * m_formGC, which is defined at instantiation.
00165      */
00166     virtual int eosType() const;
00167 
00168     /**
00169      * @name Molar Thermodynamic Properties of the Solution ------------------------
00170      * @{
00171      */
00172 
00173     /**
00174      * Molar enthalpy of the solution. Units: J/kmol.
00175      * For an ideal, constant partial molar volume solution mixture with
00176      * pure species phases which exhibit zero volume expansivity and
00177      * zero isothermal compressibility:
00178      * \f[
00179      * \hat h(T,P) = \sum_k X_k \hat h^0_k(T) + (P - P_{ref}) (\sum_k X_k \hat V^0_k)
00180      * \f]
00181      * The reference-state pure-species enthalpies at the reference pressure Pref 
00182      * \f$ \hat h^0_k(T) \f$, are computed by the species thermodynamic 
00183      * property manager. They are polynomial functions of temperature.
00184      * @see SpeciesThermo
00185      */
00186     virtual doublereal enthalpy_mole() const;
00187 
00188     /**
00189      * Molar internal energy of the solution. Units: J/kmol.
00190      * For an ideal, constant partial molar volume solution mixture with
00191      * pure species phases which exhibit zero volume expansivity and
00192      * zero isothermal compressibility:
00193      * \f[
00194      * \hat u(T,X) = \hat h(T,P,X) - p \hat V 
00195      *         =  \sum_k X_k \hat h^0_k(T)  - P_{ref} (\sum_k{X_k \hat V^0_k})
00196      * \f]
00197      * and is a function only of temperature.
00198      * The reference-state pure-species enthalpies 
00199      * \f$ \hat h^0_k(T) \f$ are computed by the species thermodynamic 
00200      * property manager.
00201      * @see SpeciesThermo
00202      */
00203     virtual doublereal intEnergy_mole() const;
00204 
00205     /**
00206      * Molar entropy of the solution. Units: J/kmol/K.
00207      * For an ideal, constant partial molar volume solution mixture with
00208      * pure species phases which exhibit zero volume expansivity:
00209      * \f[
00210      * \hat s(T, P, X_k) = \sum_k X_k \hat s^0_k(T)  - \hat R \sum_k X_k log(X_k)
00211      * \f]
00212      * The reference-state pure-species entropies 
00213      * \f$ \hat s^0_k(T,p_{ref}) \f$ are computed by the species thermodynamic 
00214      * property manager. The pure species entropies are independent of 
00215      * pressure since the volume expansivities are equal to zero.
00216      * @see SpeciesThermo
00217      */
00218     virtual doublereal entropy_mole() const;
00219 
00220     /**
00221      * Molar gibbs free energy of the solution. Units: J/kmol.
00222      * For an ideal, constant partial molar volume solution mixture with
00223      * pure species phases which exhibit zero volume expansivity:
00224      * \f[
00225      * \hat g(T, P) = \sum_k X_k \hat g^0_k(T,P) + \hat R T \sum_k X_k log(X_k)
00226      * \f]
00227      * The reference-state pure-species gibbs free energies
00228      * \f$ \hat g^0_k(T) \f$ are computed by the species thermodynamic 
00229      * property manager, while the standard state gibbs free energies
00230      * \f$ \hat g^0_k(T,P) \f$ are computed by the member function, gibbs_RT().
00231      * @see SpeciesThermo
00232      */
00233     virtual doublereal gibbs_mole() const;
00234 
00235     /**
00236      * Molar heat capacity at constant pressure of the solution.
00237      * Units: J/kmol/K.
00238      * For an ideal, constant partial molar volume solution mixture with
00239      * pure species phases which exhibit zero volume expansivity:
00240      * \f[
00241      * \hat c_p(T,P) = \sum_k X_k \hat c^0_{p,k}(T) .
00242      * \f]
00243      * The heat capacity is independent of pressure. 
00244      * The reference-state pure-species heat capacities  
00245      * \f$ \hat c^0_{p,k}(T) \f$ are computed by the species thermodynamic 
00246      * property manager.
00247      * @see SpeciesThermo
00248      */
00249     virtual doublereal cp_mole() const;
00250 
00251     /**
00252      * Molar heat capacity at constant volume of the solution.
00253      * Units: J/kmol/K.
00254      * For an ideal, constant partial molar volume solution mixture with
00255      * pure species phases which exhibit zero volume expansivity:
00256      * \f[ \hat c_v(T,P) = \hat c_p(T,P) \f]
00257      * The two heat capacities are equal.
00258      */
00259     virtual doublereal cv_mole() const {
00260       return cp_mole();
00261     }
00262 
00263     //@}
00264     /** @name Mechanical Equation of State Properties ------------------------------------
00265      *
00266      *   In this equation of state implementation, the density is a 
00267      *   function only of the mole fractions. Therefore, it can't be 
00268      *   an independent variable. Instead, the pressure is used as the
00269      *   independent variable. Functions which try to set the thermodynamic
00270      *   state by calling setDensity() may cause an exception to be
00271      *   thrown.  
00272      */
00273     //@{
00274 
00275     /**
00276      * Pressure. Units: Pa.
00277      * For this incompressible system, we return the internally storred
00278      * independent value of the pressure.
00279      */ 
00280     virtual doublereal pressure() const {
00281       return m_Pcurrent;
00282     }
00283 
00284     /**
00285      * Set the pressure at constant temperature. Units: Pa.
00286      * This method sets a constant within the object.
00287      * The mass density is not a function of pressure.
00288      *
00289      * @param p   Input Pressure (Pa)
00290      */
00291     virtual void setPressure(doublereal p);
00292 
00293     /**
00294      * Calculate the density of the mixture using the partial 
00295      * molar volumes and mole fractions as input
00296      *
00297      * The formula for this is
00298      *
00299      * \f[ 
00300      * \rho = \frac{\sum_k{X_k W_k}}{\sum_k{X_k V_k}} 
00301      * \f]
00302      *
00303      * where \f$X_k\f$ are the mole fractions, \f$W_k\f$ are
00304      * the molecular weights, and \f$V_k\f$ are the pure species
00305      * molar volumes.
00306      *
00307      * Note, the basis behind this formula is that in an ideal
00308      * solution the partial molar volumes are equal to the pure
00309      * species molar volumes. We have additionally specified
00310      * in this class that the pure species molar volumes are
00311      * independent of temperature and pressure.
00312      *
00313      * NOTE: This is a non-virtual function, which is not a 
00314      *       member of the ThermoPhase base class. 
00315      */
00316     void calcDensity();
00317 
00318     /**
00319      * Overwritten setDensity() function is necessary because the
00320      * density is not an indendent variable.
00321      *
00322      * This function will now throw an error condition
00323      *
00324      * @internal May have to adjust the strategy here to make
00325      * the eos for these materials slightly compressible, in order
00326      * to create a condition where the density is a function of 
00327      * the pressure.
00328      *
00329      * This function will now throw an error condition.
00330      *
00331      *  NOTE: This is a virtual function that overwrites the State.h
00332      *        class
00333      *
00334      * @param rho  Input density
00335      */
00336     virtual void setDensity(const doublereal rho);
00337 
00338     /**
00339      * Overwritten setMolarDensity() function is necessary because the
00340      * density is not an independent variable.
00341      *
00342      * This function will now throw an error condition.
00343      *
00344      *  NOTE: This is virtual function that overwrites the State.h
00345      *        class
00346      *
00347      * @param rho   Input Density 
00348      */
00349     virtual void setMolarDensity(const doublereal rho);
00350 
00351     //! Set the mole fractions
00352     /*!
00353      * @param x  Input vector of mole fractions.
00354      *           Length: m_kk.
00355      */
00356     virtual void setMoleFractions(const doublereal * const x);
00357 
00358     //! Set the mole fractions, but don't normalize them to one.
00359     /*!
00360      * @param x  Input vector of mole fractions.
00361      *           Length: m_kk.
00362      */
00363     virtual void setMoleFractions_NoNorm(const doublereal * const x); 
00364 
00365     //! Set the mass fractions, and normalize them to one.
00366     /*!
00367      * @param y  Input vector of mass fractions.
00368      *           Length: m_kk.
00369      */
00370     virtual void setMassFractions(const doublereal * const y);
00371 
00372     //! Set the mass fractions, but don't normalize them to one
00373     /*!
00374      * @param y  Input vector of mass fractions.
00375      *           Length: m_kk.
00376      */
00377     virtual void setMassFractions_NoNorm(const doublereal * const y);
00378 
00379     //! Set the concentration, 
00380     /*!
00381      * @param c  Input vector of concentrations.
00382      *           Length: m_kk.
00383      */
00384     virtual void setConcentrations(const doublereal * const c);
00385     
00386 
00387     //@}
00388 
00389     /**
00390      * @name Chemical Potentials and Activities -----------------------------------------
00391      *
00392      * The activity \f$a_k\f$ of a species in solution is
00393      * related to the chemical potential by 
00394      * \f[
00395      *  \mu_k(T,P,X_k) = \mu_k^0(T,P)
00396      * + \hat R T \log a_k.
00397      *  \f] 
00398      * The quantity \f$\mu_k^0(T,P)\f$ is
00399      * the standard state chemical potential at unit activity.
00400      * It may depend on the pressure and the temperature. However,
00401      * it may not depend on the mole fractions of the species 
00402      * in the solid solution.
00403      *
00404      * The activities are related to the generalized 
00405      * concentrations, \f$\tilde C_k\f$, and standard 
00406      * concentrations, \f$C^0_k\f$, by the following formula:
00407      *
00408      *  \f[
00409      *  a_k = \frac{\tilde C_k}{C^0_k} 
00410      *  \f] 
00411      * The generalized concentrations are used in the kinetics classes
00412      * to describe the rates of progress of reactions involving the
00413      * species. Their formulation depends upons the specification
00414      * of the rate constants for reaction, especially the units used
00415      * in specifying the rate constants. The bridge between the
00416      * thermodynamic equilibrium expressions that use a_k and the
00417      * kinetics expressions which use the generalized concentrations
00418      * is provided by the multiplicative factor of the 
00419      * standard concentrations. 
00420      * @{
00421      */
00422 
00423     /**
00424      * This method returns the array of generalized
00425      * concentrations. The generalized concentrations are used
00426      * in the evaluation of the rates of progress for reactions
00427      * involving species in this phase. The generalized
00428      * concentration divided by the standard concentration is also
00429      * equal to the activity of species.
00430      *
00431      * For this implentation the activity is defined to be the
00432      * mole fraction of the species. The generalized concentration
00433      * is defined to be equal to the mole fraction divided by
00434      * the partial molar volume. The generalized concentrations
00435      * for species in this phase therefore have units of
00436      * kmol m<SUP>-3</SUP>. Rate constants must reflect this fact.
00437      *
00438      * On a general note, the following must be true.
00439      * For an ideal solution, the generalized concentration  must consist 
00440      * of the mole fraction multiplied by a constant. The constant may be
00441      * fairly arbitrarily chosen, with differences adsorbed into the
00442      * reaction rate expression. 1/V_N, 1/V_k, or 1 are equally good,
00443      * as long as the standard concentration is adjusted accordingly. 
00444      * However, it must be a constant (and not the concentration, btw,
00445      * which is a function of the mole fractions) in order for the
00446      * ideal solution properties to hold at the same time having the 
00447      * standard concentration to be independent of the mole fractions.
00448      *
00449      * In this implementation the form of the generalized concentrations
00450      * depend upon the member attribute, m_formGC:
00451      *
00452      *                          <TABLE>
00453      *  <TR><TD> m_formGC </TD><TD> GeneralizedConc </TD><TD> StandardConc </TD></TR>
00454      *  <TR><TD> 0        </TD><TD> X_k             </TD><TD> 1.0          </TD></TR>
00455      *  <TR><TD> 1        </TD><TD> X_k / V_k       </TD><TD> 1.0 / V_k    </TD></TR>
00456      *  <TR><TD> 2        </TD><TD> X_k / V_N       </TD><TD> 1.0 / V_N    </TD></TR>
00457      *                         </TABLE>
00458      *
00459      * HKM Note: We have absorbed the pressure dependence of the pures species
00460      *        state into the thermodynamics functions. Therefore the
00461      *        standard state on which the activities are based depend
00462      *        on both temperature and pressure. If we hadn't, it would have
00463      *        appeared in this function in a very awkwards exp[] format.
00464      *
00465      * @param c  Pointer to array of doubles of length m_kk, which on exit
00466      *           will contain the generalized concentrations.
00467      */
00468     virtual void getActivityConcentrations(doublereal* c) const;
00469 
00470     /**
00471      * The standard concentration \f$ C^0_k \f$ used to normalize
00472      * the generalized concentration.
00473      * In many cases, this quantity
00474      * will be the same for all species in a phase.
00475      * However, for this case, we will return a distinct concentration
00476      * for each species. This is the inverse of the species molar
00477      * volume. Units for the standard concentration are 
00478      * kmol m<SUP>-3</SUP>.
00479      *
00480      * @param k Species number: this is a require parameter,
00481      * a change from the ThermoPhase base class, where it was
00482      * an optional parameter.
00483      */ 
00484     virtual doublereal standardConcentration(int k) const;
00485 
00486     /**
00487      * The reference (ie standard) concentration \f$ C^0_k \f$ used to normalize
00488      * the generalized concentration. In many cases, this quantity
00489      * will be the same for all species in a phase.
00490      * However, for this case, we will return a distinct concentration
00491      * for each species. (clone of the standard concentration ->
00492      * suggest changing the name). This is the inverse of the species molar
00493      * volume.
00494      *
00495      * @param k  Species index.
00496      */ 
00497     virtual doublereal referenceConcentration(int k) const;
00498 
00499     /**
00500      * Returns the log of the standard concentration of the kth species
00501      *
00502      * @param k Species number: this is a require parameter,
00503      *          a change from the ThermoPhase base class, where it was
00504      *          an optional parameter.
00505      */ 
00506     virtual doublereal logStandardConc(int k) const;
00507 
00508     /**
00509      * Returns the units of the standard and general concentrations
00510      * Note they have the same units, as their divisor is 
00511      * defined to be equal to the activity of the kth species
00512      * in the solution, which is unitless.
00513      *
00514      * This routine is used in print out applications where the
00515      * units are needed. Usually, MKS units are assumed throughout
00516      * the program and in the XML input files.
00517      *
00518      * @param uA Output vector containing the units
00519      *  uA[0] = kmol units - default  = 1
00520      *  uA[1] = m    units - default  = -nDim(), the number of spatial
00521      *                                dimensions in the Phase class.
00522      *  uA[2] = kg   units - default  = 0;
00523      *  uA[3] = Pa(pressure) units - default = 0;
00524      *  uA[4] = Temperature units - default = 0;
00525      *  uA[5] = time units - default = 0
00526      * @param k species index. Defaults to 0.
00527      * @param sizeUA output int containing the size of the vector.
00528      *        Currently, this is equal to 6.
00529      *
00530      *  For EOS types other than cIdealSolidSolnPhase0, the default
00531      *  kmol/m3 holds for standard concentration units. For
00532      *  cIdealSolidSolnPhase0 type, the standard concentrtion is
00533      *  unitless.
00534      */
00535     virtual void getUnitsStandardConc(double *uA, int k = 0, 
00536                                       int sizeUA = 6) const;
00537 
00538     
00539     //! Get the array of species activity coefficients
00540     /*!
00541      * @param ac output vector of activity coefficients. Length: m_kk
00542      */
00543     virtual void getActivityCoefficients(doublereal * ac) const;
00544 
00545     /**
00546      * Get the species chemical potentials. Units: J/kmol.
00547      *
00548      * This function returns a vector of chemical potentials of the 
00549      * species in solution.
00550      * \f[
00551      *    \mu_k = \mu^{ref}_k(T) + V_k * (p - p_o) + R T ln(X_k)
00552      * \f]
00553      *  or another way to phrase this is
00554      * \f[
00555      *    \mu_k = \mu^o_k(T,p) + R T ln(X_k) 
00556      * \f]
00557      *  where \f$ \mu^o_k(T,p) = \mu^{ref}_k(T) + V_k * (p - p_o)\f$
00558      *
00559      * @param mu  Output vector of chemical potentials.
00560      */
00561     virtual void getChemPotentials(doublereal* mu) const;
00562 
00563     /** 
00564      * Get the array of non-dimensional species solution
00565      * chemical potentials at the current T and P
00566      * \f$\mu_k / \hat R T \f$.
00567      * \f[
00568      *  \mu^0_k(T,P) = \mu^{ref}_k(T) + (P - P_{ref}) * V_k + RT ln(X_k)
00569      * \f]
00570      * where \f$V_k\f$ is the molar volume of pure species <I>k</I>.
00571      * \f$ \mu^{ref}_k(T)\f$ is the chemical potential of pure
00572      * species <I>k</I> at the reference pressure, \f$P_{ref}\f$.
00573      *
00574      * @param mu   Output vector of dimensionless chemical potentials. Length = m_kk.
00575      */
00576     virtual void getChemPotentials_RT(doublereal* mu) const;
00577 
00578     //@}
00579     /// @name  Partial Molar Properties of the Solution -----------------------------
00580     //@{
00581 
00582     /**
00583      * Returns an array of partial molar enthalpies for the species
00584      * in the mixture.
00585      * Units (J/kmol)
00586      * For this phase, the partial molar enthalpies are equal to the
00587      * pure species enthalpies
00588      *  \f[
00589      * \bar h_k(T,P) = \hat h^{ref}_k(T) + (P - P_{ref}) \hat V^0_k
00590      * \f]
00591      * The reference-state pure-species enthalpies, \f$ \hat h^{ref}_k(T) \f$,
00592      * at the reference pressure,\f$ P_{ref} \f$,
00593      * are computed by the species thermodynamic 
00594      * property manager. They are polynomial functions of temperature.
00595      * @see SpeciesThermo
00596      *
00597      * @param hbar Output vector containing partial molar enthalpies.
00598      *             Length: m_kk.
00599      */
00600     virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
00601 
00602     /**
00603      * Returns an array of partial molar entropies of the species in the
00604      * solution. Units: J/kmol/K.
00605      * For this phase, the partial molar entropies are equal to the
00606      * pure species entropies plus the ideal solution contribution.
00607      *  \f[
00608      * \bar s_k(T,P) =  \hat s^0_k(T) - R log(X_k)
00609      * \f]
00610      * The reference-state pure-species entropies,\f$ \hat s^{ref}_k(T) \f$,
00611      * at the reference pressure, \f$ P_{ref} \f$,  are computed by the 
00612      * species thermodynamic 
00613      * property manager. They are polynomial functions of temperature.
00614      * @see SpeciesThermo
00615      *
00616      * @param sbar Output vector containing partial molar entropies.
00617      *             Length: m_kk.
00618      */
00619     virtual void getPartialMolarEntropies(doublereal* sbar) const;
00620 
00621     /**
00622      * Returns an array of partial molar Heat Capacities at constant
00623      * pressure of the species in the
00624      * solution. Units: J/kmol/K.
00625      * For this phase, the partial molar heat capacities are equal
00626      * to the standard state heat capacities.
00627      *
00628      * @param cpbar  Output vector of partial heat capacities. Length: m_kk.
00629      */
00630     virtual void getPartialMolarCp(doublereal* cpbar) const;
00631 
00632     /**
00633      * returns an array of partial molar volumes of the species
00634      * in the solution. Units: m^3 kmol-1.
00635      *
00636      * For this solution, thepartial molar volumes are equal to the
00637      * constant species molar volumes.
00638      *
00639      * @param vbar  Output vector of partial molar volumes. Length: m_kk.
00640      */
00641     virtual void getPartialMolarVolumes(doublereal* vbar) const;
00642 
00643     //@}
00644     /// @name  Properties of the Standard State of the Species in the Solution -------------------------------------
00645     //@{
00646 
00647 
00648     /**
00649      *  Get the standard state chemical potentials of the species.
00650      *  This is the array of chemical potentials at unit activity 
00651      *  \f$ \mu^0_k(T,P) \f$.
00652      *  We define these here as the chemical potentials of the pure
00653      *  species at the temperature and pressure of the solution.
00654      *  This function is used in the evaluation of the 
00655      *  equilibrium constant Kc. Therefore, Kc will also depend
00656      *  on T and P. This is the norm for liquid and solid systems.
00657      *
00658      *  units = J / kmol
00659      *
00660      * @param mu0   Output vector of standard state chemical potentials. 
00661      *              Length: m_kk.
00662      */
00663     virtual void getStandardChemPotentials(doublereal* mu0) const {
00664       getPureGibbs(mu0);
00665     }
00666 
00667     
00668     //! Get the array of nondimensional Enthalpy functions for the standard state species
00669     //! at the current <I>T</I> and <I>P</I> of the solution.
00670     /*!
00671      * We assume an incompressible constant partial molar
00672      * volume here:
00673      * \f[
00674      *  h^0_k(T,P) = h^{ref}_k(T) + (P - P_{ref}) * V_k
00675      * \f]
00676      * where \f$V_k\f$ is the molar volume of pure species <I>k</I>.
00677      * \f$ h^{ref}_k(T)\f$ is the enthalpy of the pure
00678      * species <I>k</I> at the reference pressure, \f$P_{ref}\f$.
00679      *
00680      * @param hrt Vector of length m_kk, which on return hrt[k]
00681      *            will contain the nondimensional 
00682      *            standard state enthalpy of species k. 
00683      */
00684     void getEnthalpy_RT(doublereal* hrt) const;
00685 
00686     
00687     //! Get the nondimensional Entropies for the species
00688     //! standard states at the current T and P of the solution.
00689     /*!
00690      * Note, this is equal to the reference state entropies
00691      * due to the zero volume expansivity: 
00692      * i.e., (dS/dP)_T = (dV/dT)_P = 0.0
00693      *
00694      * @param sr Vector of length m_kk, which on return sr[k]
00695      *           will contain the nondimensional 
00696      *           standard state entropy for species k. 
00697      */
00698     void getEntropy_R(doublereal* sr) const;
00699 
00700     /**
00701      * Get the nondimensional gibbs function for the species
00702      * standard states at the current T and P of the solution.
00703      *
00704      *  \f[
00705      *  \mu^0_k(T,P) = \mu^{ref}_k(T) + (P - P_{ref}) * V_k
00706      * \f]
00707      * where \f$V_k\f$ is the molar volume of pure species <I>k</I>.
00708      * \f$ \mu^{ref}_k(T)\f$ is the chemical potential of pure
00709      * species <I>k</I> at the reference pressure, \f$P_{ref}\f$.
00710      *
00711      * @param grt Vector of length m_kk, which on return sr[k]
00712      *           will contain the nondimensional 
00713      *           standard state gibbs function for species k. 
00714      */
00715     virtual void getGibbs_RT(doublereal* grt) const;
00716 
00717     /**
00718      * Get the Gibbs functions for the pure species
00719      * at the current <I>T</I> and <I>P</I> of the solution.
00720      * We assume an incompressible constant partial molar
00721      * volume here:
00722      * \f[
00723      *  \mu^0_k(T,P) = \mu^{ref}_k(T) + (P - P_{ref}) * V_k
00724      * \f]
00725      * where \f$V_k\f$ is the molar volume of pure species <I>k</I>.
00726      * \f$ \mu^{ref}_k(T)\f$ is the chemical potential of pure
00727      * species <I>k</I> at the reference pressure, \f$P_{ref}\f$.
00728      *
00729      * @param gpure  Output vector of Gibbs functions for species
00730      *               Length: m_kk.
00731      */
00732     virtual void getPureGibbs(doublereal* gpure) const;
00733 
00734     
00735     //! Returns the vector of nondimensional
00736     //!  internal Energies of the standard state at the current
00737     //! temperature and pressure of the solution for each species.
00738     /*!
00739      *
00740      * @param urt  Output vector of standard state nondimensional internal energies.
00741      *             Length: m_kk.
00742      */
00743     virtual void getIntEnergy_RT(doublereal *urt) const;
00744 
00745     /**
00746      * Get the nondimensional heat capacity at constant pressure
00747      * function for the species
00748      * standard states at the current T and P of the solution.
00749      * \f[
00750      *  Cp^0_k(T,P) = Cp^{ref}_k(T)
00751      * \f]
00752      * where \f$V_k\f$ is the molar volume of pure species <I>k</I>.
00753      * \f$ Cp^{ref}_k(T)\f$ is the constant pressure heat capacity
00754      * of species <I>k</I> at the reference pressure, \f$p_{ref}\f$.
00755      *
00756      * @param cpr Vector of length m_kk, which on return cpr[k]
00757      *           will contain the nondimensional 
00758      *           constant pressure heat capacity for species k. 
00759      */
00760     void getCp_R(doublereal* cpr) const;
00761 
00762     /**
00763      * Get the molar volumes of each species in their standard
00764      * states at the current
00765      * <I>T</I> and <I>P</I> of the solution.
00766      * units = m^3 / kmol
00767      *
00768      * @param vol  Output vector of standard state volumes.
00769      *             Length: m_kk.
00770      */
00771     virtual void getStandardVolumes(doublereal *vol) const;
00772 
00773 
00774     //@}
00775     /// @name Thermodynamic Values for the Species Reference States ------
00776     //@{
00777 
00778 
00779     /**
00780      *  Returns the vector of nondimensional
00781      *  enthalpies of the reference state at the current temperature
00782      *  of the solution and the reference pressure for the species.
00783      *
00784      * @param hrt  Output vector containing reference nondimensional enthalpies.
00785      *             Length: m_kk.
00786      */
00787     virtual void getEnthalpy_RT_ref(doublereal *hrt) const;
00788      
00789     /**
00790      *  Returns the vector of nondimensional
00791      *  enthalpies of the reference state at the current temperature
00792      *  of the solution and the reference pressure for the species.
00793      *
00794      * @param grt  Output vector containing reference nondimensional Gibbs free energies.
00795      *             Length: m_kk.
00796      */
00797     virtual void getGibbs_RT_ref(doublereal *grt) const;
00798                    
00799     /**
00800      *  Returns the vector of the
00801      *  gibbs function of the reference state at the current temperature
00802      *  of the solution and the reference pressure for the species.
00803      *  units = J/kmol
00804      *
00805      * @param g    Output vector containing reference Gibbs free energies.
00806      *             Length: m_kk.
00807      */
00808     virtual void getGibbs_ref(doublereal *g) const;
00809 
00810     /**
00811      *  Returns the vector of nondimensional
00812      *  entropies of the reference state at the current temperature
00813      *  of the solution and the reference pressure for the species.
00814      *
00815      * @param er  Output vector containing reference nondimensional entropies.
00816      *             Length: m_kk.
00817      */
00818     virtual void getEntropy_R_ref(doublereal *er) const;
00819 
00820     /**
00821      *  Returns the vector of nondimensional
00822      *  internal Energies of the reference state at the current temperature
00823      *  of the solution and the reference pressure for each species.
00824      *
00825      * @param urt  Output vector containing reference nondimensional internal energies.
00826      *             Length: m_kk.
00827      */
00828     virtual void getIntEnergy_RT_ref(doublereal *urt) const;
00829         
00830     /**
00831      *  Returns the vector of nondimensional
00832      *  constant pressure heat capacities of the reference state
00833      *  at the current temperature of the solution
00834      *  and reference pressure for the species.
00835      *
00836      * @param cprt  Output vector containing reference nondimensional heat capacities.
00837      *             Length: m_kk.
00838      */
00839     virtual void getCp_R_ref(doublereal *cprt) const;
00840 
00841     /**
00842      *  Returns a reference to the vector of nondimensional
00843      *  enthalpies of the reference state at the current temperature.
00844      *  Real reason for its existence is that it also checks
00845      *  to see if a recalculation of the reference thermodynamics
00846      *  functions needs to be done.
00847      */
00848     const array_fp& enthalpy_RT_ref() const;
00849 
00850     /**
00851      *  Returns a reference to the vector of nondimensional
00852      *  enthalpies of the reference state at the current temperature.
00853      *  Real reason for its existence is that it also checks
00854      *  to see if a recalculation of the reference thermodynamics
00855      *  functions needs to be done.
00856      */
00857     const array_fp& gibbs_RT_ref() const {
00858       _updateThermo();
00859       return m_g0_RT;
00860     }
00861 
00862     /**
00863      *  Returns a reference to the vector of nondimensional
00864      *  enthalpies of the reference state at the current temperature.
00865      *  Real reason for its existence is that it also checks
00866      *  to see if a recalculation of the reference thermodynamics
00867      *  functions needs to be done.
00868      */
00869     const array_fp& expGibbs_RT_ref() const;
00870 
00871     /**
00872      *  Returns a reference to the vector of nondimensional
00873      *  enthalpies of the reference state at the current temperature.
00874      *  Real reason for its existence is that it also checks
00875      *  to see if a recalculation of the reference thermodynamics
00876      *  functions needs to be done.
00877      */
00878     const array_fp& entropy_R_ref() const;
00879 
00880     /**
00881      *  Returns a reference to the vector of nondimensional
00882      *  enthalpies of the reference state at the current temperature.
00883      *  Real reason for its existence is that it also checks
00884      *  to see if a recalculation of the reference thermodynamics
00885      *  functions needs to be done.
00886      */
00887     const array_fp& cp_R_ref() const {
00888       _updateThermo();
00889       return m_cp0_R;
00890     }
00891 
00892     virtual void setPotentialEnergy(int k, doublereal pe) {
00893       m_pe[k] = pe;
00894       _updateThermo();
00895     }
00896 
00897     virtual doublereal potentialEnergy(int k) const {
00898       return m_pe[k];
00899     }
00900     //@}
00901     /// @name Utility Functions -----------------------------------------------
00902     //@{
00903 
00904  
00905 
00906     /**
00907      * Initialization of an IdealSolidSolnPhase phase using an
00908      * xml file 
00909      *
00910      * This routine is a precursor to constructPhaseXML(XML_Node*)
00911      * routine, which does most of the work.
00912      *
00913      * @param infile XML file containing the description of the
00914      *        phase
00915      *
00916      * @param id  Optional parameter identifying the name of the
00917      *            phase. If none is given, the first XML
00918      *            phase element will be used.
00919      */
00920     void constructPhaseFile(std::string infile, std::string id="");
00921 
00922     /**
00923      *   Import and initialize an IdealSolidSolnPhase phase 
00924      *   specification in an XML tree into the current object.
00925      *   Here we read an XML description of the phase.
00926      *   We import descriptions of the elements that make up the
00927      *   species in a phase.
00928      *   We import information about the species, including their
00929      *   reference state thermodynamic polynomials. We then freeze
00930      *   the state of the species.
00931      *   This routine calls importPhase() to do most of its work.
00932      *   Then, importPhase() calls initThermoXML() to finish
00933      *   off the work.
00934      *
00935  
00936      * @param phaseNode This object must be the phase node of a
00937      *             complete XML tree
00938      *             description of the phase, including all of the
00939      *             species data. In other words while "phase" must
00940      *             point to an XML phase object, it must have
00941      *             sibling nodes "speciesData" that describe
00942      *             the species in the phase.
00943      * @param id   ID of the phase. If nonnull, a check is done
00944      *             to see if phaseNode is pointing to the phase
00945      *             with the correct id. 
00946      */
00947     void constructPhaseXML(XML_Node& phaseNode, std::string id="");
00948 
00949     /**
00950      *  Initialization of an IdealSolidSolnPhase phase:
00951      *  Note this function is pretty much useless because it doesn't
00952      *  get the xml tree passed to it. Suggest a change.
00953      */
00954     virtual void initThermo();
00955      
00956     /**
00957       * @internal
00958       *   Import and initialize a ThermoPhase object
00959       *   using an XML tree.
00960       *   Here we read extra information about the XML description
00961       *   of a phase. Regular information about elements and species
00962       *   and their reference state thermodynamic information
00963       *   have already been read at this point.
00964       *   For example, we do not need to call this function for
00965       *   ideal gas equations of state.
00966       *   This function is called from importPhase()
00967       *   after the elements and the
00968       *   species are initialized with default ideal solution
00969       *   level data.
00970       *
00971       * @param phaseNode This object must be the phase node of a
00972       *             complete XML tree
00973       *             description of the phase, including all of the
00974       *             species data. In other words while "phase" must
00975       *             point to an XML phase object, it must have
00976       *             sibling nodes "speciesData" that describe
00977       *             the species in the phase.
00978       * @param id   ID of the phase. If nonnull, a check is done
00979       *             to see if phaseNode is pointing to the phase
00980       *             with the correct id.
00981       */
00982     virtual void initThermoXML(XML_Node& phaseNode, std::string id);
00983 
00984 
00985     /** 
00986      * Set mixture to an equilibrium state consistent with specified 
00987      * element potentials and the temperature.
00988      *
00989      * @param lambda_RT vector of non-dimensional element potentials
00990      * \f$ \lambda_m/RT \f$.
00991      *
00992      */
00993     virtual void setToEquilState(const doublereal* lambda_RT);
00994 
00995 
00996     /**
00997      * Report the molar volume of species k
00998      *
00999      * units - \f$ m^3 kmol^-1 \f$
01000      *
01001      * @param  k species index
01002      */
01003     double speciesMolarVolume(int k) const;
01004 
01005     /**
01006      * Fill in a return vector containing the species molar volumes.
01007      *
01008      * units - \f$ m^3 kmol^-1 \f$
01009      *
01010      * @param smv  output vector containing species molar volumes.
01011      *             Length: m_kk.
01012      */
01013     void getSpeciesMolarVolumes(doublereal *smv) const;
01014 
01015     //@}
01016 
01017   protected:
01018 
01019     /**
01020      *  Format for the generalized concentrations
01021      *  0 = C_k = X_k.      (default)
01022      *  1 = C_k = X_k / V_k
01023      *  2 = C_k = X_k / V_N
01024      */
01025     int m_formGC;
01026     /**
01027      * m_mm = Number of distinct elements defined in species in this
01028      *        phase 
01029      */
01030     int m_mm;
01031 
01032     /**
01033      * Maximum temperature that this phase can accurately describe
01034      * the thermodynamics.
01035      */
01036     doublereal m_tmin;
01037 
01038     /**
01039      * Minimum temperature that this phase can accurately describe
01040      * the thermodynamics.
01041      */
01042     doublereal m_tmax;
01043     /**
01044      * Value of the reference pressure for all species in this phase.
01045      * The T dependent polynomials are evaluated at the reference
01046      * pressure. Note, because this is a single value, all species
01047      * are required to have the same reference pressure.
01048      */
01049     doublereal m_Pref;
01050 
01051     /**
01052      * m_Pcurrent = The current pressure
01053      * Since the density isn't a function of pressure, but only of the
01054      * mole fractions, we need to independently specify the pressure.
01055      * The density variable which is inherited as part of the State class,
01056      * m_dens, is always kept current whenever T, P, or X[] change. 
01057      */
01058     doublereal m_Pcurrent;
01059 
01060     /**
01061      * Species molar volume \f$ m^3 kmol^-1 \f$
01062      */
01063     array_fp   m_speciesMolarVolume;
01064 
01065     /**
01066      *  Value of the temperature at which the thermodynamics functions
01067      * for the reference state of the species were last evaluated.
01068      */
01069     mutable doublereal   m_tlast;
01070 
01071     /**
01072      * Vector containing the species reference enthalpies at T = m_tlast
01073      */
01074     mutable array_fp      m_h0_RT;
01075 
01076     /**
01077      * Vector containing the species reference constant pressure
01078      * heat capacities at T = m_tlast
01079      */
01080     mutable array_fp      m_cp0_R;
01081 
01082     /**
01083      * Vector containing the species reference Gibbs functions
01084      * at T = m_tlast
01085      */
01086     mutable array_fp      m_g0_RT;
01087 
01088     /**
01089      * Vector containing the species reference entropies
01090      * at T = m_tlast
01091      */
01092     mutable array_fp      m_s0_R;
01093 
01094     /**
01095      * Vector containing the species reference exp(-G/RT) functions
01096      * at T = m_tlast
01097      */
01098     mutable array_fp      m_expg0_RT;
01099 
01100     /**
01101      * Vector of potential energies for the species.
01102      */
01103     mutable array_fp      m_pe;
01104 
01105     /**
01106      * Temporary array used in equilibrium calculations
01107      */
01108     mutable array_fp      m_pp;
01109 
01110   private:
01111     /// @name Utility Functions ------------------------------------------
01112     //@{
01113     /**
01114      * This function gets called for every call to functions in this
01115      * class. It checks to see whether the temperature has changed and
01116      * thus the reference thermodynamics functions for all of the species
01117      * must be recalculated.
01118      * If the temperature has changed, the species thermo manager is called
01119      * to recalculate G, Cp, H, and S at the current temperature.
01120      */
01121     void _updateThermo() const;
01122         
01123     /**
01124      * This internal function adjusts the lengths of arrays
01125      */
01126     void initLengths();
01127 
01128     //@}
01129   };
01130 }
01131         
01132 #endif
01133 
01134 
01135 
01136 
01137 
Generated by  doxygen 1.6.3