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