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