Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MetalSHEelectrons.h
Go to the documentation of this file.
1 /**
2  * @file MetalSHEelectrons.h
3  * Header file for the MetalSHEElectrons class, which represents the
4  * electrons in a metal that are consistent with the
5  * SHE electrode (see \ref thermoprops and
6  * class \link Cantera::MetalSHEelectrons MetalSHEelectrons\endlink)
7  */
8 
9 /*
10  * Copyright (2005) Sandia Corporation. Under the terms of
11  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
12  * U.S. Government retains certain rights in this software.
13  */
14 #ifndef CT_METALSHEELECTRONS_H
15 #define CT_METALSHEELECTRONS_H
16 
17 #include "SingleSpeciesTP.h"
18 
19 namespace Cantera
20 {
21 
22 //! Class MetalSHEelectrons represents electrons within
23 //! a metal, adjacent to an aqueous electrolyte, that are consistent with the SHE reference electrode.
24 /*!
25  * The class is based on the electron having a chemical potential
26  * equal to one-half of the entropy of the H<SUP>2</SUP> gas at the system pressure
27  *
28  * <b> Specification of Species Standard State Properties </b>
29  *
30  * This class inherits from SingleSpeciesTP.
31  * It is assumed that the reference state thermodynamics may be
32  * obtained by a pointer to a populated species thermodynamic property
33  * manager class (see ThermoPhase::m_spthermo). How to relate pressure
34  * changes to the reference state thermodynamics is resolved at this level.
35  *
36  * The enthalpy function is given by the following relation.
37  *
38  * \f[
39  * h^o_k(T,P) = h^{ref}_k(T)
40  * \f]
41  *
42  * The standard state constant-pressure heat capacity is independent of pressure:
43  *
44  * \f[
45  * Cp^o_k(T,P) = Cp^{ref}_k(T)
46  * \f]
47  *
48  * The standard state entropy depends in the following fashion on pressure:
49  *
50  * \f[
51  * S^o_k(T,P) = S^{ref}_k(T) - R \ln(\frac{P}{P_{ref}})
52  * \f]
53  *
54  * The standard state Gibbs free energy is obtained from the enthalpy and entropy
55  * functions:
56  *
57  * \f[
58  * \mu^o_k(T,P) = h^o_k(T,P) - S^o_k(T,P) T
59  * \f]
60  *
61  * \f[
62  * \mu^o_k(T,P) = \mu^{ref}_k(T) + R T \ln( \frac{P}{P_{ref}})
63  * \f]
64  *
65  * where
66  * \f[
67  * \mu^{ref}_k(T) = h^{ref}_k(T) - T S^{ref}_k(T)
68  * \f]
69  *
70  * The standard state internal energy is obtained from the enthalpy function also
71  *
72  * \f[
73  * u^o_k(T,P) = h^o_k(T) - R T
74  * \f]
75  *
76  * <b> Specification of Solution Thermodynamic Properties </b>
77  *
78  * All solution properties are obtained from the standard state
79  * species functions, since there is only one species in the phase.
80  *
81  * <b> %Application within Kinetics Managers </b>
82  *
83  * The standard concentration is equal to 1.0. This means that the
84  * kinetics operator works on an activities basis. Since this
85  * is a stoichiometric substance, this means that the concentration
86  * of this phase drops out of kinetics expressions since the activity is
87  * always equal to one.
88  *
89  * This is what is expected of electrons. The only effect that this class will
90  * have on reactions is in terms of the standard state chemical potential, which
91  * is equal to 1/2 of the H2 gas chemical potential, and the voltage assigned
92  * to the electron, which is the voltage of the metal.
93  *
94  * <b> Instantiation of the Class </b>
95  *
96  * The constructor for this phase is located in the default ThermoFactory
97  * for %Cantera. A new MetalSHEelectrons object may be created by
98  * the following code snippets, where the file metalSHEelectrons.xml exists
99  * in a local directory:
100  *
101  * @code
102  * MetalSHEelectrons *eMetal = new MetalSHEelectrons("metalSHEelectrons.xml", "");
103  * @endcode
104  *
105  * or by the following call to importPhase():
106  *
107  * @code
108  * sprintf(file_ID,"%s#MetalSHEelectrons", iFile);
109  * XML_Node *xm = get_XML_NameID("phase", file_ID, 0);
110  * MetalSHEelectrons eMetal;
111  * importPhase(*xm, &eMetal);
112  * @endcode
113  *
114  * @code
115  * ThermoPhase *eMetal = newPhase("MetalSHEelectrons.xml", "MetalSHEelectrons");
116  * @endcode
117  *
118  * Additionally, this phase may be created without including an XML file with
119  * the special command, where the default file is embedded into this object.
120  *
121  * @code
122  * MetalSHEelectrons *eMetal = new MetalSHEelectrons("MetalSHEelectrons_default.xml", "");
123  * @endcode
124  *
125  * <b> XML Example </b>
126  *
127  * The phase model name for this is called MetalSHEelectrons. It must be supplied
128  * as the model attribute of the thermo XML element entry.
129  * Within the phase XML block,
130  * the density of the phase must be specified though it's not used. An example of an XML file
131  * this phase is given below.
132  *
133  * @code
134  * <?xml version="1.0"?>
135  * <ctml>
136  * <validate reactions="yes" species="yes"/>
137  *
138  * <phase dim="3" id="MetalSHEelectrons">
139  * <elementArray datasrc="elements.xml">
140  * E
141  * </elementArray>
142  * <speciesArray datasrc="#species_Metal_SHEelectrons"> she_electron </speciesArray>
143  * <thermo model="metalSHEelectrons">
144  * <density units="g/cm3">2.165</density>
145  * </thermo>
146  * <transport model="None"/>
147  * <kinetics model="none"/>
148  * </phase>
149  *
150  * <!-- species definitions -->
151  * <speciesData id="species_Metal_SHEelectrons">
152  * <species name="she_electron">
153  * <atomArray> E:1 </atomArray>
154  * <charge> -1 </charge>
155  * <thermo>
156  * <NASA Tmax="1000.0" Tmin="200.0" P0="100000.0">
157  * <floatArray name="coeffs" size="7">
158  * 1.172165560E+00, 3.990260375E-03, -9.739075500E-06, 1.007860470E-08,
159  * -3.688058805E-12, -4.589675865E+02, 3.415051190E-01
160  * </floatArray>
161  * </NASA>
162  * <NASA Tmax="6000.0" Tmin="1000.0" P0="100000.0">
163  * <floatArray name="coeffs" size="7">
164  * 1.466432895E+00, 4.133039835E-04, -7.320116750E-08, 7.705017950E-12,
165  * -3.444022160E-16, -4.065327985E+02, -5.121644350E-01
166  * </floatArray>
167  * </NASA>
168  * </thermo>
169  * <density units="g/cm3">2.165</density>
170  * </species>
171  * </speciesData>
172  * </ctml>
173  * @endcode
174  *
175  * The model attribute, "MetalSHEelectrons", on the thermo element
176  * identifies the phase as being a MetalSHEelectrons object.
177  *
178  * @ingroup thermoprops
179  */
181 {
182 public:
183  //! Default constructor for the MetalSHEelectrons class
185 
186  //! Construct and initialize a MetalSHEelectrons ThermoPhase object
187  //! directly from an ASCII input file
188  /*!
189  * @param infile name of the input file
190  * @param id name of the phase id in the file.
191  * If this is blank, the first phase in the file is used.
192  */
193  MetalSHEelectrons(const std::string& infile, std::string id = "");
194 
195  //! Construct and initialize a MetalSHEelectrons ThermoPhase object
196  //! directly from an XML database
197  /*!
198  * @param phaseRef XML node pointing to a MetalSHEelectrons description
199  * @param id Id of the phase.
200  */
201  MetalSHEelectrons(XML_Node& phaseRef, const std::string& id = "");
202 
203  //! Copy constructor
204  /*!
205  * @param right Object to be copied
206  */
207  MetalSHEelectrons(const MetalSHEelectrons& right);
208 
209  //! Assignment operator
210  /*!
211  * @param right Object to be copied
212  */
214 
215  //! Destructor for the routine
216  virtual ~MetalSHEelectrons();
217 
218  //! Duplication function
219  /*!
220  * This virtual function is used to create a duplicate of the
221  * current phase. It's used to duplicate the phase when given
222  * a ThermoPhase pointer to the phase.
223  *
224  * @return It returns a ThermoPhase pointer.
225  */
227 
228  /**
229  * Equation of state flag.
230  *
231  * Returns the value cMetalSHEelectrons, defined in mix_defs.h.
232  */
233  virtual int eosType() const;
234 
235  //! @name Mechanical Equation of State
236  //! @{
237 
238  //! Report the Pressure. Units: Pa.
239  /*!
240  * For an incompressible substance, the density is independent of
241  * pressure. This method simply returns the stored pressure value.
242  */
243  virtual doublereal pressure() const;
244 
245  //! Set the pressure at constant temperature. Units: Pa.
246  /*!
247  * For an incompressible substance, the density is
248  * independent of pressure. Therefore, this method only
249  * stores the specified pressure value. It does not
250  * modify the density.
251  *
252  * @param p Pressure (units - Pa)
253  */
254  virtual void setPressure(doublereal p);
255 
256  //! Returns the isothermal compressibility. Units: 1/Pa.
257  /*!
258  * The isothermal compressibility is defined as
259  * \f[
260  * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T
261  * \f]
262  */
263  virtual doublereal isothermalCompressibility() const;
264 
265  //! Return the volumetric thermal expansion coefficient. Units: 1/K.
266  /*!
267  * The thermal expansion coefficient is defined as
268  * \f[
269  * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P
270  * \f]
271  */
272  virtual doublereal thermalExpansionCoeff() const ;
273 
274  //! @}
275  //! @name Activities, Standard States, and Activity Concentrations
276  //!
277  //! This section is largely handled by parent classes, since there
278  //! is only one species. Therefore, the activity is equal to one.
279  //! @{
280 
281  //! This method returns an array of generalized concentrations
282  /*!
283  * \f$ C^a_k\f$ are defined such that \f$ a_k = C^a_k /
284  * C^0_k, \f$ where \f$ C^0_k \f$ is a standard concentration
285  * defined below and \f$ a_k \f$ are activities used in the
286  * thermodynamic functions. These activity (or generalized)
287  * concentrations are used
288  * by kinetics manager classes to compute the forward and
289  * reverse rates of elementary reactions.
290  *
291  * For a stoichiometric substance, there is
292  * only one species, and the generalized concentration is 1.0.
293  *
294  * @param c Output array of generalized concentrations. The
295  * units depend upon the implementation of the
296  * reaction rate expressions within the phase.
297  */
298  virtual void getActivityConcentrations(doublereal* c) const;
299 
300  //! Return the standard concentration for the kth species
301  /*!
302  * The standard concentration \f$ C^0_k \f$ used to normalize
303  * the activity (i.e., generalized) concentration.
304  * This phase assumes that the kinetics operator works on an
305  * dimensionless basis. Thus, the standard concentration is
306  * equal to 1.0.
307  *
308  * @param k Optional parameter indicating the species. The default
309  * is to assume this refers to species 0.
310  * @return
311  * Returns The standard Concentration as 1.0
312  */
313  virtual doublereal standardConcentration(size_t k=0) const;
314 
315  //! Natural logarithm of the standard concentration of the kth species.
316  /*!
317  * @param k index of the species (defaults to zero)
318  */
319  virtual doublereal logStandardConc(size_t k=0) const;
320 
321  //! Get the array of chemical potentials at unit activity for the species
322  //! at their standard states at the current <I>T</I> and <I>P</I> of the solution.
323  /*!
324  * For a stoichiometric substance, there is no activity term in
325  * the chemical potential expression, and therefore the
326  * standard chemical potential and the chemical potential
327  * are both equal to the molar Gibbs function.
328  *
329  * These are the standard state chemical potentials \f$ \mu^0_k(T,P)
330  * \f$. The values are evaluated at the current
331  * temperature and pressure of the solution
332  *
333  * @param mu0 Output vector of chemical potentials.
334  * Length: m_kk.
335  */
336  virtual void getStandardChemPotentials(doublereal* mu0) const;
337 
338  //! Returns the units of the standard and generalized concentrations.
339  /*!
340  * Note they have the same units, as their
341  * ratio is defined to be equal to the activity of the kth
342  * species in the solution, which is unitless.
343  *
344  * This routine is used in print out applications where the
345  * units are needed. Usually, MKS units are assumed throughout
346  * the program and in the XML input files.
347  *
348  * The base ThermoPhase class assigns the default quantities
349  * of (kmol/m3) for all species.
350  * Inherited classes are responsible for overriding the default
351  * values if necessary.
352  *
353  * @param uA Output vector containing the units
354  * uA[0] = kmol units - default = 1
355  * uA[1] = m units - default = -nDim(), the number of spatial
356  * dimensions in the Phase class.
357  * uA[2] = kg units - default = 0;
358  * uA[3] = Pa(pressure) units - default = 0;
359  * uA[4] = Temperature units - default = 0;
360  * uA[5] = time units - default = 0
361  * @param k species index. Defaults to 0.
362  * @param sizeUA output int containing the size of the vector.
363  * Currently, this is equal to 6.
364  * @deprecated To be removed after Cantera 2.2.
365  */
366  virtual void getUnitsStandardConc(doublereal* uA, int k = 0,
367  int sizeUA = 6) const;
368 
369  //@}
370  /// @name Properties of the Standard State of the Species in the Solution
371  //@{
372 
373  //! Get the nondimensional Enthalpy functions for the species
374  //! at their standard states at the current <I>T</I> and <I>P</I> of the solution.
375  /*!
376  * @param hrt Output vector of nondimensional standard state enthalpies.
377  * Length: m_kk.
378  */
379  virtual void getEnthalpy_RT(doublereal* hrt) const;
380 
381  //! Get the array of nondimensional Entropy functions for the
382  //! standard state species at the current <I>T</I> and <I>P</I> of the solution.
383  /*!
384  * @param sr Output vector of nondimensional standard state entropies.
385  * Length: m_kk.
386  */
387  virtual void getEntropy_R(doublereal* sr) const;
388 
389  //! Get the nondimensional Gibbs functions for the species
390  //! in their standard states at the current <I>T</I> and <I>P</I> of the solution.
391  /*!
392  * @param grt Output vector of nondimensional standard state Gibbs free energies
393  * Length: m_kk.
394  */
395  virtual void getGibbs_RT(doublereal* grt) const;
396 
397  //! Get the nondimensional Heat Capacities at constant
398  //! pressure for the species standard states
399  //! at the current <I>T</I> and <I>P</I> of the solution
400  /*!
401  * @param cpr Output vector of nondimensional standard state heat capacities
402  * Length: m_kk.
403  */
404  virtual void getCp_R(doublereal* cpr) const;
405 
406  //! Returns the vector of nondimensional Internal Energies of the standard
407  //! state species at the current <I>T</I> and <I>P</I> of the solution
408  /*!
409  * For an incompressible,
410  * stoichiometric substance, the molar internal energy is
411  * independent of pressure. Since the thermodynamic properties
412  * are specified by giving the standard-state enthalpy, the
413  * term \f$ P_{ref} \hat v\f$ is subtracted from the specified reference molar
414  * enthalpy to compute the standard state molar internal energy.
415  *
416  * @param urt output vector of nondimensional standard state
417  * internal energies of the species. Length: m_kk.
418  */
419  virtual void getIntEnergy_RT(doublereal* urt) const;
420 
421  //@}
422  /// @name Thermodynamic Values for the Species Reference States
423  //@{
424 
425  //! Returns the vector of nondimensional
426  //! internal Energies of the reference state at the current temperature
427  //! of the solution and the reference pressure for each species.
428  /*!
429  * @param urt Output vector of nondimensional reference state
430  * internal energies of the species.
431  * Length: m_kk
432  */
433  virtual void getIntEnergy_RT_ref(doublereal* urt) const;
434  // @}
435 
436  virtual void initThermoXML(XML_Node& phaseNode, const std::string& id);
437 
438  //! Make the default XML tree
439  /*!
440  * @return Returns a malloced XML tree containing the
441  * default info.
442  */
443  static XML_Node* makeDefaultXMLTree();
444 
445  //! Set the equation of state parameters
446  /*!
447  * @internal
448  *
449  * @param n number of parameters
450  * @param c array of \a n coefficients
451  * c[0] = density of phase [ kg/m3 ]
452  */
453  virtual void setParameters(int n, doublereal* const c);
454 
455  //! Get the equation of state parameters in a vector
456  /*!
457  * @internal
458  *
459  * @param n number of parameters
460  * @param c array of \a n coefficients
461  *
462  * For this phase:
463  * - n = 1
464  * - c[0] = density of phase [ kg/m3 ]
465  */
466  virtual void getParameters(int& n, doublereal* const c) const;
467 
468  //! Set equation of state parameter values from XML entries.
469  /*!
470  * This method is called by function importPhase() when processing a phase
471  * definition in an input file. It should be overloaded in subclasses to set
472  * any parameters that are specific to that particular phase
473  * model. Note, this method is called before the phase is
474  * initialized with elements and/or species.
475  *
476  * For this phase, the density of the phase is specified in this block.
477  *
478  * @param eosdata An XML_Node object corresponding to
479  * the "thermo" entry for this phase in the input file.
480  *
481  * eosdata points to the thermo block, and looks like this:
482  *
483  * @code
484  * <phase id="stoichsolid" >
485  * <thermo model="StoichSubstance">
486  * <density units="g/cm3">3.52</density>
487  * </thermo>
488  * </phase>
489  * @endcode
490  */
491  virtual void setParametersFromXML(const XML_Node& eosdata);
492 
493 protected:
494  XML_Node* xdef_;
495 };
496 
497 }
498 #endif
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
virtual void setParameters(int n, doublereal *const c)
Set the equation of state parameters.
MetalSHEelectrons()
Default constructor for the MetalSHEelectrons class.
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
virtual doublereal pressure() const
Report the Pressure. Units: Pa.
ThermoPhase * duplMyselfAsThermoPhase() const
Duplication function.
MetalSHEelectrons & operator=(const MetalSHEelectrons &right)
Assignment operator.
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
virtual void getIntEnergy_RT_ref(doublereal *urt) const
Returns the vector of nondimensional internal Energies of the reference state at the current temperat...
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:97
virtual ~MetalSHEelectrons()
Destructor for the routine.
virtual void setPressure(doublereal p)
Set the pressure at constant temperature. Units: Pa.
virtual int eosType() const
Equation of state flag.
Class MetalSHEelectrons represents electrons within a metal, adjacent to an aqueous electrolyte...
Header for the SingleSpeciesTP class, which is a filter class for ThermoPhase, that eases the constru...
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
virtual void getStandardChemPotentials(doublereal *mu0) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
static XML_Node * makeDefaultXMLTree()
Make the default XML tree.
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
virtual void getGibbs_RT(doublereal *grt) const
Get the nondimensional Gibbs functions for the species in their standard states at the current T and ...
virtual void getUnitsStandardConc(doublereal *uA, int k=0, int sizeUA=6) const
Returns the units of the standard and generalized concentrations.
virtual void getIntEnergy_RT(doublereal *urt) const
Returns the vector of nondimensional Internal Energies of the standard state species at the current T...
virtual doublereal logStandardConc(size_t k=0) const
Natural logarithm of the standard concentration of the kth species.
virtual void getParameters(int &n, doublereal *const c) const
Get the equation of state parameters in a vector.
The SingleSpeciesTP class is a filter class for ThermoPhase.
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.