MineralEQ3.h

Go to the documentation of this file.
00001 /**
00002  *  @file MineralEQ3.h
00003  * Header file for the MineralEQ3 class, which represents a fixed-composition
00004  * incompressible substance based on EQ3's parameterization (see \ref thermoprops and 
00005  * class \link Cantera::MineralEQ3 MineralEQ3\endlink)
00006  */
00007 
00008 /*
00009  * Copywrite (2006) Sandia Corporation. Under the terms of
00010  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
00011  * U.S. Government retains certain rights in this software.
00012  *
00013  * Copyright 2001 California Institute of Technology
00014  */
00015 
00016 /* 
00017  *  $Date: 2009-12-05 14:08:43 -0500 (Sat, 05 Dec 2009) $
00018  *  $Revision: 279 $
00019  */
00020 
00021 #ifndef CT_MINERALEQ3_H
00022 #define CT_MINERALEQ3_H
00023 
00024 #include "mix_defs.h"
00025 #include "SingleSpeciesTP.h"
00026 #include "SpeciesThermo.h"
00027 #include "StoichSubstanceSSTP.h"
00028 
00029 namespace Cantera {
00030 
00031   //!  Class %MineralEQ3 represents a stoichiometric (fixed
00032   //!   composition)  incompressible substance based on EQ3's parameterization
00033   /*!
00034    *  This class inherits from SingleSpeciesSSTP class.
00035    *  EQ's parameterization is mapped onto the Shomate polynomial class.
00036    *
00037    * <b> Specification of Species Standard %State Properties </b>
00038    *
00039    *  This class inherits from SingleSpeciesTP.
00040    *  It is assumed that the reference state thermodynamics may be
00041    *  obtained by a pointer to a populated species thermodynamic property
00042    *  manager class (see ThermoPhase::m_spthermo). How to relate pressure
00043    *  changes to the reference state thermodynamics is resolved at this level.
00044    *
00045    *  For an incompressible,
00046    * stoichiometric substance, the molar internal energy is
00047    * independent of pressure. Since the thermodynamic properties
00048    * are specified by giving the standard-state enthalpy, the
00049    * term \f$ P_0 \hat v\f$ is subtracted from the specified molar
00050    * enthalpy to compute the molar internal energy. The entropy is
00051    * assumed to be independent of the pressure.
00052    *
00053    * The enthalpy function is given by the following relation.
00054    *
00055    *       \f[
00056    *   \raggedright   h^o_k(T,P) =
00057    *                  h^{ref}_k(T) + \tilde v \left( P - P_{ref} \right) 
00058    *       \f]
00059    *
00060    * For an incompressible,
00061    * stoichiometric substance, the molar internal energy is
00062    * independent of pressure. Since the thermodynamic properties
00063    * are specified by giving the standard-state enthalpy, the
00064    * term \f$ P_{ref} \tilde v\f$ is subtracted from the specified reference molar
00065    * enthalpy to compute the molar internal energy.
00066    *
00067    *       \f[
00068    *            u^o_k(T,P) = h^{ref}_k(T) - P_{ref} \tilde v
00069    *       \f]
00070    *
00071    * The standard state heat capacity and entropy are independent
00072    * of pressure. The standard state gibbs free energy is obtained
00073    * from the enthalpy and entropy functions.
00074    *   
00075    *
00076    * <b> Specification of Solution Thermodynamic Properties </b>
00077    *
00078    *  All solution properties are obtained from the standard state
00079    *  species functions, since there is only one species in the phase.
00080    *
00081    * <b> Application within %Kinetics Managers </b>
00082    *
00083    * The standard concentration is equal to 1.0. This means that the
00084    * kinetics operator works on an (activities basis). Since this
00085    * is a stoichiometric substance, this means that the concentration
00086    * of this phase drops out of kinetics expressions. 
00087    *
00088    * An example of a reaction using this is a sticking coefficient
00089    * reaction of a substance in an ideal gas phase on a surface with a bulk phase
00090    * species in this phase. In this case, the rate of progress for this 
00091    * reaction, \f$ R_s \f$, may be expressed via the following equation:
00092    *   \f[
00093    *    R_s = k_s C_{gas}
00094    *   \f]
00095    * where the units for \f$ R_s \f$ are kmol m-2 s-1. \f$ C_{gas} \f$ has units
00096    * of kmol m-3. Therefore, the kinetic rate constant,  \f$ k_s \f$, has
00097    * units of m s-1. Nowhere does the concentration of the bulk phase
00098    * appear in the rate constant expression, since it's a stoichiometric
00099    * phase and the activity is always equal to 1.0.
00100    *
00101    * <b> Instanteation of the Class </b>
00102    *
00103    * The constructor for this phase is NOT located in the default ThermoFactory
00104    * for %Cantera. However, a new %StoichSubstanceSSTP may be created by 
00105    * the following code snippets:
00106    *
00107    * @code
00108    *    sprintf(file_ID,"%s#NaCl(S)", iFile);
00109    *    XML_Node *xm = get_XML_NameID("phase", file_ID, 0);
00110    *    StoichSubstanceSSTP *solid = new StoichSubstanceSSTP(*xm);
00111    * @endcode
00112    *
00113    * or by the following call to importPhase():
00114    *
00115    * @code
00116    *    sprintf(file_ID,"%s#NaCl(S)", iFile);
00117    *    XML_Node *xm = get_XML_NameID("phase", file_ID, 0);
00118    *    StoichSubstanceSSTP solid;
00119    *    importPhase(*xm, &solid);
00120    * @endcode
00121    *
00122    *   <b> XML Example </b>
00123    *
00124    * The phase model name for this is called StoichSubstance. It must be supplied
00125    * as the model attribute of the thermo XML element entry.
00126    * Within the phase XML block,
00127    * the density of the phase must be specified. An example of an XML file
00128    * this phase is given below. 
00129    * 
00130    * @verbatim
00131      <!-- phase NaCl(S)    -->
00132      <phase dim="3" id="NaCl(S)">
00133         <elementArray datasrc="elements.xml">
00134            Na Cl
00135         </elementArray>
00136         <speciesArray datasrc="#species_NaCl(S)"> NaCl(S) </speciesArray>
00137         <thermo model="StoichSubstanceSSTP">
00138            <density units="g/cm3">2.165</density>
00139         </thermo>
00140         <transport model="None"/>
00141         <kinetics model="none"/>
00142      </phase>
00143     
00144      <!-- species definitions     -->
00145      <speciesData id="species_NaCl(S)">
00146        <!-- species NaCl(S)   -->
00147        <species name="NaCl(S)">
00148           <atomArray> Na:1 Cl:1 </atomArray>
00149           <thermo>
00150              <Shomate Pref="1 bar" Tmax="1075.0" Tmin="250.0">
00151                 <floatArray size="7">
00152                     50.72389, 6.672267, -2.517167,
00153                     10.15934, -0.200675, -427.2115,
00154                     130.3973
00155                 </floatArray>
00156              </Shomate>
00157           </thermo>
00158           <density units="g/cm3">2.165</density>
00159         </species>
00160      </speciesData>  @endverbatim
00161    *
00162    *  The model attribute, "StoichSubstanceSSTP", on the thermo element identifies the phase as being
00163    * a StoichSubstanceSSTP object.
00164    *
00165    * @ingroup thermoprops
00166    */
00167   class MineralEQ3 : public StoichSubstanceSSTP {
00168 
00169   public:
00170     
00171     //! Default constructor for the StoichSubstanceSSTP class
00172     MineralEQ3();
00173 
00174     //! Construct and initialize a StoichSubstanceSSTP ThermoPhase object 
00175     //! directly from an asci input file
00176     /*!
00177      * @param infile name of the input file
00178      * @param id     name of the phase id in the file.
00179      *               If this is blank, the first phase in the file is used.
00180      */
00181     MineralEQ3(std::string infile, std::string id = "");
00182 
00183     //! Construct and initialize a StoichSubstanceSSTP ThermoPhase object 
00184     //! directly from an XML database
00185     /*!
00186      *  @param phaseRef XML node pointing to a StoichSubstanceSSTP description
00187      *  @param id       Id of the phase. 
00188      */
00189     MineralEQ3(XML_Node& phaseRef, std::string id = "");
00190 
00191     //! Copy constructor
00192     /*!
00193      * @param right Object to be copied
00194      */
00195     MineralEQ3(const MineralEQ3  &right);
00196     
00197     //! Assignment operator
00198     /*!
00199      * @param right Object to be copied
00200      */
00201     MineralEQ3 & operator=(const MineralEQ3 & right);
00202    
00203     //! Destructor for the routine (virtual)
00204     virtual ~MineralEQ3();
00205 
00206     //! Duplication function
00207     /*!
00208      * This virtual function is used to create a duplicate of the
00209      * current phase. It's used to duplicate the phase when given
00210      * a ThermoPhase pointer to the phase.
00211      *
00212      * @return It returns a ThermoPhase pointer.
00213      */
00214     ThermoPhase *duplMyselfAsThermoPhase() const;
00215    
00216     /**
00217      *   
00218      * @name  Utilities  
00219      * @{
00220      */
00221 
00222     /**
00223      * Equation of state flag.
00224      *
00225      * Returns the value cStoichSubstance, defined in mix_defs.h.
00226      */
00227     virtual int eosType() const;
00228 
00229     /**
00230      *  @}
00231      *  @name Molar Thermodynamic Properties of the Solution
00232      *  @{
00233      */
00234 
00235     /**
00236      * @}
00237      * @name Mechanical Equation of State
00238      * @{
00239      */
00240 
00241 
00242     //! Report the Pressure. Units: Pa.
00243     /*!
00244      * For an incompressible substance, the density is independent
00245      * of pressure. This method simply returns the storred
00246      * pressure value.
00247      */ 
00248     virtual doublereal pressure() const;
00249 
00250     //! Set the pressure at constant temperature. Units: Pa.
00251     /*!
00252      * For an incompressible substance, the density is 
00253      * independent of pressure. Therefore, this method only 
00254      * stores the specified pressure value. It does not 
00255      * modify the density.
00256      *
00257      * @param p Pressure (units - Pa)
00258      */
00259     virtual void setPressure(doublereal p);
00260 
00261     //! Returns  the isothermal compressibility. Units: 1/Pa.
00262     /*!
00263      * The isothermal compressibility is defined as
00264      * \f[
00265      * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T
00266      * \f]
00267      */
00268     virtual doublereal isothermalCompressibility() const; 
00269 
00270     //! Return the volumetric thermal expansion coefficient. Units: 1/K.
00271     /*!      
00272      * The thermal expansion coefficient is defined as
00273      * \f[
00274      * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P
00275      * \f]
00276      */
00277     virtual doublereal thermalExpansionCoeff() const ;
00278 
00279     /**
00280      * @}
00281      * @name Activities, Standard States, and Activity Concentrations
00282      *
00283      *  This section is largely handled by parent classes, since there
00284      *  is only one species. Therefore, the activity is equal to one.
00285      * @{
00286      */
00287 
00288     //! This method returns an array of generalized concentrations
00289     /*!
00290      * \f$ C^a_k\f$ are defined such that \f$ a_k = C^a_k /
00291      * C^0_k, \f$ where \f$ C^0_k \f$ is a standard concentration
00292      * defined below and \f$ a_k \f$ are activities used in the
00293      * thermodynamic functions.  These activity (or generalized)
00294      * concentrations are used
00295      * by kinetics manager classes to compute the forward and
00296      * reverse rates of elementary reactions.
00297      *
00298      *  For a stoichiomeetric substance, there is
00299      *  only one species, and the generalized concentration is 1.0.
00300      *
00301      * @param c Output array of generalized concentrations. The 
00302      *           units depend upon the implementation of the
00303      *           reaction rate expressions within the phase.
00304      */
00305     virtual void getActivityConcentrations(doublereal* c) const;
00306 
00307     //! Return the standard concentration for the kth species
00308     /*!
00309      * The standard concentration \f$ C^0_k \f$ used to normalize
00310      * the activity (i.e., generalized) concentration. 
00311      * This phase assumes that the kinetics operator works on an
00312      * dimensionless basis. Thus, the standard concentration is
00313      * equal to 1.0.
00314      *
00315      * @param k Optional parameter indicating the species. The default
00316      *         is to assume this refers to species 0.
00317      * @return 
00318      *   Returns The standard Concentration as 1.0
00319      */
00320     virtual doublereal standardConcentration(int k=0) const;
00321 
00322     //! Natural logarithm of the standard concentration of the kth species.
00323     /*!
00324      * @param k    index of the species (defaults to zero)
00325      */
00326     virtual doublereal logStandardConc(int k=0) const;
00327 
00328     //! Get the array of chemical potentials at unit activity for the species
00329     //! at their standard states at the current <I>T</I> and <I>P</I> of the solution.
00330     /*!
00331      * For a stoichiometric substance, there is no activity term in 
00332      * the chemical potential expression, and therefore the
00333      * standard chemical potential and the chemical potential
00334      * are both equal to the molar Gibbs function.
00335      *
00336      * These are the standard state chemical potentials \f$ \mu^0_k(T,P)
00337      * \f$. The values are evaluated at the current
00338      * temperature and pressure of the solution
00339      *
00340      * @param mu0     Output vector of chemical potentials. 
00341      *                Length: m_kk.
00342      */
00343     virtual void getStandardChemPotentials(doublereal* mu0) const;
00344 
00345     //! Returns the units of the standard and generalized concentrations.
00346     /*!
00347      * Note they have the same units, as their
00348      * ratio is defined to be equal to the activity of the kth
00349      * species in the solution, which is unitless.
00350      *
00351      * This routine is used in print out applications where the
00352      * units are needed. Usually, MKS units are assumed throughout
00353      * the program and in the XML input files.
00354      *
00355      * The base %ThermoPhase class assigns thedefault quantities
00356      * of (kmol/m3) for all species.
00357      * Inherited classes are responsible for overriding the default 
00358      * values if necessary.
00359      *
00360      * @param uA Output vector containing the units
00361      *  uA[0] = kmol units - default  = 1
00362      *  uA[1] = m    units - default  = -nDim(), the number of spatial
00363      *                                dimensions in the Phase class.
00364      *  uA[2] = kg   units - default  = 0;
00365      *  uA[3] = Pa(pressure) units - default = 0;
00366      *  uA[4] = Temperature units - default = 0;
00367      *  uA[5] = time units - default = 0
00368      * @param k species index. Defaults to 0.
00369      * @param sizeUA output int containing the size of the vector.
00370      *        Currently, this is equal to 6.
00371      */
00372     virtual void getUnitsStandardConc(doublereal *uA, int k = 0,
00373                                       int sizeUA = 6) const;
00374 
00375     //@}
00376     /// @name  Partial Molar Properties of the Solution
00377     ///
00378     ///        These properties are handled by the parent class,
00379     ///        SingleSpeciesTP
00380     //@{
00381 
00382 
00383     //@}
00384     /// @name  Properties of the Standard State of the Species in the Solution 
00385     //@{
00386 
00387     //! Get the nondimensional Enthalpy functions for the species
00388     //! at their standard states at the current <I>T</I> and <I>P</I> of the solution.
00389     /*!
00390      * @param hrt      Output vector of  nondimensional standard state enthalpies.
00391      *                 Length: m_kk.
00392      */
00393     virtual void getEnthalpy_RT(doublereal* hrt) const;
00394 
00395     //! Get the array of nondimensional Entropy functions for the
00396     //! standard state species at the current <I>T</I> and <I>P</I> of the solution.
00397     /*!
00398      * @param sr   Output vector of  nondimensional standard state entropies.
00399      *             Length: m_kk.
00400      */
00401     virtual void getEntropy_R(doublereal* sr) const;
00402 
00403     //! Get the nondimensional Gibbs functions for the species
00404     //! in their standard states at the current <I>T</I> and <I>P</I> of the solution.
00405     /*!
00406      * @param grt  Output vector of nondimensional standard state gibbs free energies
00407      *             Length: m_kk.
00408      */
00409     virtual void getGibbs_RT(doublereal* grt) const;
00410 
00411     //! Get the nondimensional Heat Capacities at constant
00412     //! pressure for the species standard states
00413     //! at the current <I>T</I> and <I>P</I> of the solution
00414     /*!
00415      * @param cpr   Output vector of nondimensional standard state heat capacities
00416      *              Length: m_kk.
00417      */
00418     virtual void getCp_R(doublereal* cpr) const;
00419     
00420     //!  Returns the vector of nondimensional Internal Energies  of the standard
00421     //!  state species at the current <I>T</I> and <I>P</I> of the solution
00422     /*!
00423      *  For an incompressible,
00424      * stoichiometric substance, the molar internal energy is
00425      * independent of pressure. Since the thermodynamic properties
00426      * are specified by giving the standard-state enthalpy, the
00427      * term \f$ P_{ref} \hat v\f$ is subtracted from the specified reference molar
00428      * enthalpy to compute the standard state molar internal energy.
00429      *
00430      * @param urt  output vector of nondimensional standard state 
00431      *             internal energies of the species. Length: m_kk. 
00432      */
00433     virtual void getIntEnergy_RT(doublereal* urt) const;
00434 
00435     //@}
00436     /// @name Thermodynamic Values for the Species Reference States
00437     //@{
00438 
00439     //! Returns the vector of nondimensional
00440     //!  internal Energies of the reference state at the current temperature
00441     //!  of the solution and the reference pressure for each species.
00442     /*!
00443      * @param urt    Output vector of nondimensional reference state
00444      *               internal energies of the species.
00445      *               Length: m_kk
00446      */
00447     virtual void getIntEnergy_RT_ref(doublereal *urt) const;
00448 
00449     /*
00450      * ---- Critical State Properties
00451      */
00452 
00453 
00454     /*
00455      * ---- Saturation Properties
00456      */
00457 
00458     //! Initialization of a HMWSoln phase using an xml file
00459     /*!
00460      * This routine is a precursor to initThermo(XML_Node*)
00461      * routine, which does most of the work.
00462      *
00463      * @param inputFile XML file containing the description of the
00464      *        phase
00465      *
00466      * @param id  Optional parameter identifying the name of the
00467      *            phase. If none is given, the first XML
00468      *            phase element will be used.
00469      */
00470     void constructPhaseFile(std::string inputFile, std::string id);
00471 
00472     //!   Import and initialize a HMWSoln phase 
00473     //!   specification in an XML tree into the current object.
00474     /*!
00475      *   Here we read an XML description of the phase.
00476      *   We import descriptions of the elements that make up the
00477      *   species in a phase.
00478      *   We import information about the species, including their
00479      *   reference state thermodynamic polynomials. We then freeze
00480      *   the state of the species.
00481      *
00482      *   Then, we read the species molar volumes from the xml 
00483      *   tree to finish the initialization.
00484      *
00485      * @param phaseNode This object must be the phase node of a
00486      *             complete XML tree
00487      *             description of the phase, including all of the
00488      *             species data. In other words while "phase" must
00489      *             point to an XML phase object, it must have
00490      *             sibling nodes "speciesData" that describe
00491      *             the species in the phase.
00492      *
00493      * @param id   ID of the phase. If nonnull, a check is done
00494      *             to see if phaseNode is pointing to the phase
00495      *             with the correct id. 
00496      */
00497     void constructPhaseXML(XML_Node& phaseNode, std::string id);
00498 
00499     //! Internal initialization required after all species have
00500     //! been added
00501     /*!
00502      * @internal Initialize. This method is provided to allow
00503      * subclasses to perform any initialization required after all
00504      * species have been added. For example, it might be used to
00505      * resize internal work arrays that must have an entry for
00506      * each species.  The base class implementation does nothing,
00507      * and subclasses that do not require initialization do not
00508      * need to overload this method.  When importing a CTML phase
00509      * description, this method is called just prior to returning
00510      * from function importPhase.
00511      *
00512      * @see importCTML.cpp
00513      */
00514     virtual void initThermo();
00515 
00516     //! Initialize the phase parameters from an XML file.
00517     /*!
00518      * initThermoXML()                 (virtual from ThermoPhase)
00519      *
00520      *  This gets called from importPhase(). It processes the XML file
00521      *  after the species are set up. This is the main routine for
00522      *  reading in activity coefficient parameters.
00523      *
00524      * @param phaseNode This object must be the phase node of a
00525      *             complete XML tree
00526      *             description of the phase, including all of the
00527      *             species data. In other words while "phase" must
00528      *             point to an XML phase object, it must have
00529      *             sibling nodes "speciesData" that describe
00530      *             the species in the phase.
00531      * @param id   ID of the phase. If nonnull, a check is done
00532      *             to see if phaseNode is pointing to the phase
00533      *             with the correct id.
00534      */
00535     virtual void initThermoXML(XML_Node& phaseNode, std::string id);
00536 
00537     //! Set the equation of state parameters
00538     /*!
00539      * @internal
00540      *  The number and meaning of these depends on the subclass. 
00541      *
00542      * @param n number of parameters
00543      * @param c array of \a n coefficients
00544      *        c[0] = density of phase [ kg/m3 ]
00545      */
00546     virtual void setParameters(int n, doublereal * const c);
00547 
00548     //! Get the equation of state parameters in a vector
00549     /*!
00550      * @internal
00551      *
00552      * @param n number of parameters
00553      * @param c array of \a n coefficients
00554      *
00555      *  For this phase:
00556      *       -  n = 1
00557      *       -  c[0] = density of phase [ kg/m3 ]
00558      */
00559     virtual void getParameters(int &n, doublereal * const c) const;
00560 
00561     //! Set equation of state parameter values from XML entries.
00562     /*!
00563      * This method is called by function importPhase() in
00564      * file importCTML.cpp when processing a phase definition in
00565      * an input file. It should be overloaded in subclasses to set
00566      * any parameters that are specific to that particular phase
00567      * model. Note, this method is called before the phase is
00568      * initialzed with elements and/or species.
00569      *
00570      *  For this phase, the density of the phase is specified in this block.
00571      *   
00572      * @param eosdata An XML_Node object corresponding to
00573      *                the "thermo" entry for this phase in the input file.
00574      *
00575      * eosdata points to the thermo block, and looks like this:
00576      * 
00577      *   @verbatim
00578          <phase id="stoichsolid" >
00579            <thermo model="StoichSubstance">
00580                <density units="g/cm3">3.52</density>
00581            </thermo>
00582          </phase>    @endverbatim
00583      *
00584      */
00585     virtual void setParametersFromXML(const XML_Node& eosdata);
00586     doublereal LookupGe(const std::string& elemName);
00587     void convertDGFormation();
00588 
00589   protected:
00590 
00591     //! Value of the Absolute Gibbs Free Energy NIST scale at T_r and P_r
00592     /*!
00593      *  This is the NIST scale value of Gibbs free energy at T_r = 298.15
00594      *  and P_r = 1 atm.
00595      *
00596      *  J kmol-1
00597      */
00598     doublereal m_Mu0_pr_tr;
00599 
00600 
00601     //! Input value of S_j at Tr and Pr    (cal gmol-1 K-1)
00602     /*!
00603      *  Tr = 298.15   Pr = 1 atm
00604      */
00605     doublereal m_Entrop_pr_tr;
00606 
00607     //! Input Value of deltaG of Formation at Tr and Pr    (cal gmol-1)
00608     /*!
00609      *  Tr = 298.15   Pr = 1 atm
00610      *
00611      *  This is the delta G for the formation reaction of the
00612      *  ion from elements in their stable state at Tr, Pr.
00613      */
00614     doublereal m_deltaG_formation_pr_tr;
00615 
00616     //! Input Value of deltaH of Formation at Tr and Pr    (cal gmol-1)
00617     /*!
00618      *  Tr = 298.15   Pr = 1 atm
00619      *
00620      *  This is the delta H for the formation reaction of the
00621      *  ion from elements in their stable state at Tr, Pr.
00622      */
00623     doublereal m_deltaH_formation_pr_tr;
00624 
00625     //! Input Value of the molar volume at T_r and P_r
00626     /*!
00627      *  cm^3 / gmol
00628      */
00629     doublereal m_V0_pr_tr;
00630 
00631     //! a coefficient (cal gmol-1 K-1)
00632     doublereal m_a;
00633 
00634     //! b coefficient (cal gmol-1 K-2) x 10^3
00635     doublereal m_b;
00636 
00637     //! c coefficient (cal K gmol-1 K) x 10^-5
00638     doublereal m_c;
00639 
00640   };
00641     
00642 }
00643         
00644 #endif
Generated by  doxygen 1.6.3