MetalSHEelectrons.h

Go to the documentation of this file.
00001 /**
00002  * @file MetalSHEelectrons.h
00003  * Header file for the %MetalSHEElectrons class, which represents the
00004  * electrons in a metal that are consistent with the
00005  * SHE electrode (see \ref thermoprops and 
00006  * class \link Cantera::MetalSHEelectrons MetalSHEelectrons\endlink)
00007  */
00008 
00009 /*
00010  * Copywrite (2005) Sandia Corporation. Under the terms of
00011  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
00012  * U.S. Government retains certain rights in this software.
00013  */
00014 
00015 /*
00016  *  $Date: 2009-12-05 12:08:43 -0700 (Sat, 05 Dec 2009) $
00017  *  $Revision: 279 $
00018  */
00019 
00020 #ifndef CT_METALSHEELECTRONS_H
00021 #define CT_METALSHEELECTRONS_H
00022 
00023 #include "mix_defs.h"
00024 #include "SingleSpeciesTP.h"
00025 //#include "SpeciesThermo.h"
00026 
00027 namespace Cantera {
00028 
00029   //!  Class %MetalSHEelectrons represents electrons within 
00030   //!  a metal, adjacent to an aqueous electrolyte, that are consistent with the SHE reference electrode.
00031   /*!
00032    *  The class is based on the electron having a chemical potential
00033    *  equal to one-half of the entropy of the H<SUP>2</SUP> gas at the system pressure
00034    *
00035    *
00036    * <b> Specification of Species Standard %State Properties </b>
00037    *
00038    *  This class inherits from SingleSpeciesTP.
00039    *  It is assumed that the reference state thermodynamics may be
00040    *  obtained by a pointer to a populated species thermodynamic property
00041    *  manager class (see ThermoPhase::m_spthermo). How to relate pressure
00042    *  changes to the reference state thermodynamics is resolved at this level.
00043    *
00044    * The enthalpy function is given by the following relation.
00045    *
00046    *       \f[
00047    *            h^o_k(T,P) = h^{ref}_k(T) 
00048    *       \f]
00049    * 
00050    *  The standard state constant-pressure heat capacity is independent of pressure:
00051    *
00052    *       \f[
00053    *            Cp^o_k(T,P) = Cp^{ref}_k(T)
00054    *       \f]
00055    *
00056    *  The standard state entropy depends in the following fashion on pressure:
00057    *
00058    *       \f[
00059    *            S^o_k(T,P) = S^{ref}_k(T) -  R \ln(\frac{P}{P_{ref}})
00060    *       \f]
00061    *
00062    *  The standard state gibbs free energy is obtained from the enthalpy and entropy
00063    *  functions:
00064    *
00065    *       \f[
00066    *            \mu^o_k(T,P) =  h^o_k(T,P) - S^o_k(T,P) T
00067    *       \f]
00068    *
00069    *       \f[
00070    *            \mu^o_k(T,P) =  \mu^{ref}_k(T) + R T \ln( \frac{P}{P_{ref}})
00071    *       \f]
00072    *
00073    * where
00074    *       \f[
00075    *            \mu^{ref}_k(T) =   h^{ref}_k(T)   - T S^{ref}_k(T)
00076    *       \f]
00077    *
00078    *  The standard state internal energy is obtained from the enthalpy function also
00079    *
00080    *       \f[
00081    *            u^o_k(T,P) = h^o_k(T) - R T
00082    *       \f]
00083    *   
00084    *
00085    * <b> Specification of Solution Thermodynamic Properties </b>
00086    *
00087    *  All solution properties are obtained from the standard state
00088    *  species functions, since there is only one species in the phase.
00089    *
00090    * <b> %Application within %Kinetics Managers </b>
00091    *
00092    *  The standard concentration is equal to 1.0. This means that the
00093    *  kinetics operator works on an activities basis. Since this
00094    *  is a stoichiometric substance, this means that the concentration
00095    *  of this phase drops out of kinetics expressions since the activity is 
00096    *  always equal to one. 
00097    *
00098    *  This is what is expected of electrons. The only effect that this class will
00099    *  have on reactions is in terms of the standard state chemical potential, which
00100    *  is equal to 1/2 of the H2 gas chemical potential, and the voltage assigned
00101    *  to the electron, which is the voltage of the metal.
00102    *
00103    *
00104    * <b> Instanteation of the Class </b>
00105    *
00106    * The constructor for this phase is located in the default ThermoFactory
00107    * for %Cantera. A new %MetalSHEelectrons object may be created by 
00108    * the following code snippets, where the file metalSHEelectrons.xml exists
00109    * in a local directory:
00110    *
00111    * @code
00112    *    MetalSHEelectrons *eMetal = new MetalSHEelectrons("metalSHEelectrons.xml", "");
00113    * @endcode
00114    *
00115    * or by the following call to importPhase():
00116    *
00117    * @code
00118    *    sprintf(file_ID,"%s#MetalSHEelectrons", iFile);
00119    *    XML_Node *xm = get_XML_NameID("phase", file_ID, 0);
00120    *    MetalSHEelectrons eMetal;
00121    *    importPhase(*xm, &eMetal);
00122    * @endcode
00123    *
00124    *  @code
00125    *  ThermoPhase *eMetal = newPhase("  MetalSHEelectrons.xml", "MetalSHEelectrons");
00126    *  @endcode
00127    *
00128    *   Additionally, this phase may be created without including an xml file with
00129    *   the special command, where the default file is embedded into this object.
00130    *   
00131    * @code
00132    *    MetalSHEelectrons *eMetal = new MetalSHEelectrons("MetalSHEelectrons_default.xml", "");
00133    * @endcode
00134    *
00135    *
00136    *
00137    *   <b> XML Example </b>
00138    *
00139    * The phase model name for this is called %MetalSHEelectrons. It must be supplied
00140    * as the model attribute of the thermo XML element entry.
00141    * Within the phase XML block,
00142    * the density of the phase must be specified though it's not used. An example of an XML file
00143    * this phase is given below. 
00144    * 
00145    * @verbatim
00146 <?xml version="1.0"?>
00147 <ctml>
00148   <validate reactions="yes" species="yes"/>
00149 
00150   <phase dim="3" id="MetalSHEelectrons">
00151     <elementArray datasrc="elements.xml">
00152         E
00153     </elementArray>
00154     <speciesArray datasrc="#species_Metal_SHEelectrons"> she_electron </speciesArray>
00155     <thermo model="metalSHEelectrons">
00156       <density units="g/cm3">2.165</density>
00157     </thermo>
00158     <transport model="None"/>
00159     <kinetics model="none"/>
00160   </phase>
00161 
00162  <!-- species definitions     -->
00163   <speciesData id="species_Metal_SHEelectrons">
00164     <species name="she_electron">
00165       <atomArray> E:1  </atomArray>
00166       <charge> -1 </charge>
00167       <thermo>
00168         <NASA Tmax="1000.0" Tmin="200.0" P0="100000.0">
00169          <floatArray name="coeffs" size="7">
00170           1.172165560E+00,   3.990260375E-03,  -9.739075500E-06,  1.007860470E-08,
00171          -3.688058805E-12, -4.589675865E+02,  3.415051190E-01
00172          </floatArray>
00173         </NASA>
00174         <NASA Tmax="6000.0" Tmin="1000.0" P0="100000.0">
00175            <floatArray name="coeffs" size="7">
00176              1.466432895E+00,  4.133039835E-04, -7.320116750E-08, 7.705017950E-12,
00177             -3.444022160E-16, -4.065327985E+02, -5.121644350E-01
00178           </floatArray>
00179         </NASA>
00180       </thermo>
00181       <density units="g/cm3">2.165</density>
00182     </species>
00183   </speciesData>
00184 </ctml>
00185 @endverbatim
00186    *
00187    *  The model attribute, "MetalSHEelectrons", on the thermo element 
00188    *  identifies the phase as being a %MetalSHEelectrons object.
00189    *
00190    * @ingroup thermoprops
00191    */
00192   class MetalSHEelectrons : public SingleSpeciesTP {
00193 
00194   public:
00195     
00196     //! Default constructor for the MetalSHEelectrons class
00197     MetalSHEelectrons();
00198 
00199     //! Construct and initialize a %MetalSHEelectrons %ThermoPhase object 
00200     //! directly from an asci input file
00201     /*!
00202      * @param infile name of the input file
00203      * @param id     name of the phase id in the file.
00204      *               If this is blank, the first phase in the file is used.
00205      */
00206     MetalSHEelectrons(std::string infile, std::string id = "");
00207 
00208     //! Construct and initialize a MetalSHEelectrons ThermoPhase object 
00209     //! directly from an XML database
00210     /*!
00211      *  @param phaseRef XML node pointing to a MetalSHEelectrons description
00212      *  @param id       Id of the phase. 
00213      */
00214     MetalSHEelectrons(XML_Node& phaseRef, std::string id = "");
00215 
00216     //! Copy constructor
00217     /*!
00218      * @param right Object to be copied
00219      */
00220     MetalSHEelectrons(const MetalSHEelectrons  &right);
00221     
00222     //! Assignment operator
00223     /*!
00224      * @param right Object to be copied
00225      */
00226     MetalSHEelectrons & operator=(const MetalSHEelectrons & right);
00227    
00228     //! Destructor for the routine (virtual)
00229     virtual ~MetalSHEelectrons();
00230 
00231     //! Duplication function
00232     /*!
00233      * This virtual function is used to create a duplicate of the
00234      * current phase. It's used to duplicate the phase when given
00235      * a ThermoPhase pointer to the phase.
00236      *
00237      * @return It returns a ThermoPhase pointer.
00238      */
00239     ThermoPhase *duplMyselfAsThermoPhase() const;
00240    
00241     /**
00242      *   
00243      * @name  Utilities  
00244      * @{
00245      */
00246 
00247     /**
00248      * Equation of state flag.
00249      *
00250      * Returns the value cStoichSubstance, defined in mix_defs.h.
00251      */
00252     virtual int eosType() const;
00253 
00254     /**
00255      *  @}
00256      *  @name Molar Thermodynamic Properties of the Solution
00257      *  @{
00258      */
00259 
00260     /**
00261      * @}
00262      * @name Mechanical Equation of State
00263      * @{
00264      */
00265 
00266 
00267     //! Report the Pressure. Units: Pa.
00268     /*!
00269      * For an incompressible substance, the density is independent
00270      * of pressure. This method simply returns the storred
00271      * pressure value.
00272      */ 
00273     virtual doublereal pressure() const;
00274 
00275     //! Set the pressure at constant temperature. Units: Pa.
00276     /*!
00277      * For an incompressible substance, the density is 
00278      * independent of pressure. Therefore, this method only 
00279      * stores the specified pressure value. It does not 
00280      * modify the density.
00281      *
00282      * @param p Pressure (units - Pa)
00283      */
00284     virtual void setPressure(doublereal p);
00285 
00286     //! Returns  the isothermal compressibility. Units: 1/Pa.
00287     /*!
00288      * The isothermal compressibility is defined as
00289      * \f[
00290      * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T
00291      * \f]
00292      */
00293     virtual doublereal isothermalCompressibility() const; 
00294 
00295     //! Return the volumetric thermal expansion coefficient. Units: 1/K.
00296     /*!      
00297      * The thermal expansion coefficient is defined as
00298      * \f[
00299      * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P
00300      * \f]
00301      */
00302     virtual doublereal thermalExpansionCoeff() const ;
00303 
00304     /**
00305      * @}
00306      * @name Activities, Standard States, and Activity Concentrations
00307      *
00308      *  This section is largely handled by parent classes, since there
00309      *  is only one species. Therefore, the activity is equal to one.
00310      * @{
00311      */
00312 
00313     //! This method returns an array of generalized concentrations
00314     /*!
00315      * \f$ C^a_k\f$ are defined such that \f$ a_k = C^a_k /
00316      * C^0_k, \f$ where \f$ C^0_k \f$ is a standard concentration
00317      * defined below and \f$ a_k \f$ are activities used in the
00318      * thermodynamic functions.  These activity (or generalized)
00319      * concentrations are used
00320      * by kinetics manager classes to compute the forward and
00321      * reverse rates of elementary reactions.
00322      *
00323      *  For a stoichiomeetric substance, there is
00324      *  only one species, and the generalized concentration is 1.0.
00325      *
00326      * @param c Output array of generalized concentrations. The 
00327      *           units depend upon the implementation of the
00328      *           reaction rate expressions within the phase.
00329      */
00330     virtual void getActivityConcentrations(doublereal* c) const;
00331 
00332     //! Return the standard concentration for the kth species
00333     /*!
00334      * The standard concentration \f$ C^0_k \f$ used to normalize
00335      * the activity (i.e., generalized) concentration. 
00336      * This phase assumes that the kinetics operator works on an
00337      * dimensionless basis. Thus, the standard concentration is
00338      * equal to 1.0.
00339      *
00340      * @param k Optional parameter indicating the species. The default
00341      *         is to assume this refers to species 0.
00342      * @return 
00343      *   Returns The standard Concentration as 1.0
00344      */
00345     virtual doublereal standardConcentration(int k=0) const;
00346 
00347     //! Natural logarithm of the standard concentration of the kth species.
00348     /*!
00349      * @param k    index of the species (defaults to zero)
00350      */
00351     virtual doublereal logStandardConc(int k=0) const;
00352 
00353     //! Get the array of chemical potentials at unit activity for the species
00354     //! at their standard states at the current <I>T</I> and <I>P</I> of the solution.
00355     /*!
00356      * For a stoichiometric substance, there is no activity term in 
00357      * the chemical potential expression, and therefore the
00358      * standard chemical potential and the chemical potential
00359      * are both equal to the molar Gibbs function.
00360      *
00361      * These are the standard state chemical potentials \f$ \mu^0_k(T,P)
00362      * \f$. The values are evaluated at the current
00363      * temperature and pressure of the solution
00364      *
00365      * @param mu0     Output vector of chemical potentials. 
00366      *                Length: m_kk.
00367      */
00368     virtual void getStandardChemPotentials(doublereal* mu0) const;
00369 
00370     //! Returns the units of the standard and generalized concentrations.
00371     /*!
00372      * Note they have the same units, as their
00373      * ratio is defined to be equal to the activity of the kth
00374      * species in the solution, which is unitless.
00375      *
00376      * This routine is used in print out applications where the
00377      * units are needed. Usually, MKS units are assumed throughout
00378      * the program and in the XML input files.
00379      *
00380      * The base %ThermoPhase class assigns thedefault quantities
00381      * of (kmol/m3) for all species.
00382      * Inherited classes are responsible for overriding the default 
00383      * values if necessary.
00384      *
00385      * @param uA Output vector containing the units
00386      *  uA[0] = kmol units - default  = 1
00387      *  uA[1] = m    units - default  = -nDim(), the number of spatial
00388      *                                dimensions in the Phase class.
00389      *  uA[2] = kg   units - default  = 0;
00390      *  uA[3] = Pa(pressure) units - default = 0;
00391      *  uA[4] = Temperature units - default = 0;
00392      *  uA[5] = time units - default = 0
00393      * @param k species index. Defaults to 0.
00394      * @param sizeUA output int containing the size of the vector.
00395      *        Currently, this is equal to 6.
00396      */
00397     virtual void getUnitsStandardConc(doublereal *uA, int k = 0,
00398                                       int sizeUA = 6) const;
00399 
00400     //@}
00401     /// @name  Partial Molar Properties of the Solution
00402     ///
00403     ///        These properties are handled by the parent class,
00404     ///        SingleSpeciesTP
00405     //@{
00406 
00407 
00408     //@}
00409     /// @name  Properties of the Standard State of the Species in the Solution 
00410     //@{
00411 
00412     //! Get the nondimensional Enthalpy functions for the species
00413     //! at their standard states at the current <I>T</I> and <I>P</I> of the solution.
00414     /*!
00415      * @param hrt      Output vector of  nondimensional standard state enthalpies.
00416      *                 Length: m_kk.
00417      */
00418     virtual void getEnthalpy_RT(doublereal* hrt) const;
00419 
00420     //! Get the array of nondimensional Entropy functions for the
00421     //! standard state species at the current <I>T</I> and <I>P</I> of the solution.
00422     /*!
00423      * @param sr   Output vector of  nondimensional standard state entropies.
00424      *             Length: m_kk.
00425      */
00426     virtual void getEntropy_R(doublereal* sr) const;
00427 
00428     //! Get the nondimensional Gibbs functions for the species
00429     //! in their standard states at the current <I>T</I> and <I>P</I> of the solution.
00430     /*!
00431      * @param grt  Output vector of nondimensional standard state gibbs free energies
00432      *             Length: m_kk.
00433      */
00434     virtual void getGibbs_RT(doublereal* grt) const;
00435 
00436     //! Get the nondimensional Heat Capacities at constant
00437     //! pressure for the species standard states
00438     //! at the current <I>T</I> and <I>P</I> of the solution
00439     /*!
00440      * @param cpr   Output vector of nondimensional standard state heat capacities
00441      *              Length: m_kk.
00442      */
00443     virtual void getCp_R(doublereal* cpr) const;
00444     
00445     //!  Returns the vector of nondimensional Internal Energies  of the standard
00446     //!  state species at the current <I>T</I> and <I>P</I> of the solution
00447     /*!
00448      *  For an incompressible,
00449      * stoichiometric substance, the molar internal energy is
00450      * independent of pressure. Since the thermodynamic properties
00451      * are specified by giving the standard-state enthalpy, the
00452      * term \f$ P_{ref} \hat v\f$ is subtracted from the specified reference molar
00453      * enthalpy to compute the standard state molar internal energy.
00454      *
00455      * @param urt  output vector of nondimensional standard state 
00456      *             internal energies of the species. Length: m_kk. 
00457      */
00458     virtual void getIntEnergy_RT(doublereal* urt) const;
00459 
00460     //@}
00461     /// @name Thermodynamic Values for the Species Reference States
00462     //@{
00463 
00464     //! Returns the vector of nondimensional
00465     //!  internal Energies of the reference state at the current temperature
00466     //!  of the solution and the reference pressure for each species.
00467     /*!
00468      * @param urt    Output vector of nondimensional reference state
00469      *               internal energies of the species.
00470      *               Length: m_kk
00471      */
00472     virtual void getIntEnergy_RT_ref(doublereal *urt) const;
00473 
00474     /*
00475      * ---- Critical State Properties
00476      */
00477 
00478 
00479     /*
00480      * ---- Saturation Properties
00481      */
00482 
00483     /*
00484      * @internal Initialize. This method is provided to allow
00485      * subclasses to perform any initialization required after all
00486      * species have been added. For example, it might be used to
00487      * resize internal work arrays that must have an entry for
00488      * each species.  The base class implementation does nothing,
00489      * and subclasses that do not require initialization do not
00490      * need to overload this method.  When importing a CTML phase
00491      * description, this method is called just prior to returning
00492      * from function importPhase.
00493      *
00494      * @see importCTML.cpp
00495      */
00496     virtual void initThermo();
00497 
00498     
00499     virtual void initThermoXML(XML_Node& phaseNode, std::string id);
00500 
00501     //! Make the default XML tree
00502     /*!
00503      *   @return Returns a malloced XML tree containing the 
00504      *           default info.
00505      */
00506     static XML_Node *makeDefaultXMLTree();
00507  
00508     //! Set the equation of state parameters
00509     /*!
00510      * @internal
00511      *  The number and meaning of these depends on the subclass. 
00512      *
00513      * @param n number of parameters
00514      * @param c array of \a n coefficients
00515      *        c[0] = density of phase [ kg/m3 ]
00516      */
00517     virtual void setParameters(int n, doublereal * const c);
00518 
00519     //! Get the equation of state parameters in a vector
00520     /*!
00521      * @internal
00522      *
00523      * @param n number of parameters
00524      * @param c array of \a n coefficients
00525      *
00526      *  For this phase:
00527      *       -  n = 1
00528      *       -  c[0] = density of phase [ kg/m3 ]
00529      */
00530     virtual void getParameters(int &n, doublereal * const c) const;
00531 
00532     //! Set equation of state parameter values from XML entries.
00533     /*!
00534      * This method is called by function importPhase() in
00535      * file importCTML.cpp when processing a phase definition in
00536      * an input file. It should be overloaded in subclasses to set
00537      * any parameters that are specific to that particular phase
00538      * model. Note, this method is called before the phase is
00539      * initialzed with elements and/or species.
00540      *
00541      *  For this phase, the density of the phase is specified in this block.
00542      *   
00543      * @param eosdata An XML_Node object corresponding to
00544      *                the "thermo" entry for this phase in the input file.
00545      *
00546      * eosdata points to the thermo block, and looks like this:
00547      * 
00548      *   @verbatim
00549          <phase id="stoichsolid" >
00550            <thermo model="StoichSubstance">
00551                <density units="g/cm3">3.52</density>
00552            </thermo>
00553          </phase>    @endverbatim
00554      *
00555      */
00556     virtual void setParametersFromXML(const XML_Node& eosdata);
00557 
00558   protected:
00559 
00560     XML_Node *xdef_;
00561   };
00562      
00563  
00564 }  
00565 #endif
Generated by  doxygen 1.6.3