Cantera  2.0
StoichSubstanceSSTP.h
Go to the documentation of this file.
1 /**
2  * @file StoichSubstanceSSTP.h
3  * Header file for the StoichSubstanceSSTP class, which represents a fixed-composition
4  * incompressible substance (see \ref thermoprops and
5  * class \link Cantera::StoichSubstanceSSTP StoichSubstanceSSTP\endlink)
6  */
7 
8 /*
9  * Copyright (2005) Sandia Corporation. Under the terms of
10  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
11  * U.S. Government retains certain rights in this software.
12  */
13 #ifndef CT_STOICHSUBSTANCESSTP_H
14 #define CT_STOICHSUBSTANCESSTP_H
15 
16 #include "mix_defs.h"
17 #include "SingleSpeciesTP.h"
18 #include "SpeciesThermo.h"
19 
20 namespace Cantera
21 {
22 
23 //! Class %StoichSubstanceSSTP represents a stoichiometric (fixed
24 //! composition) incompressible substance.
25 /*!
26  * This class internally changes the independent degree of freedom from
27  * density to pressure. This is necessary because the phase is
28  * incompressible. It uses a constant volume approximation.
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  * For an incompressible,
40  * stoichiometric substance, the molar internal energy is
41  * independent of pressure. Since the thermodynamic properties
42  * are specified by giving the standard-state enthalpy, the
43  * term \f$ P_0 \hat v\f$ is subtracted from the specified molar
44  * enthalpy to compute the molar internal energy. The entropy is
45  * assumed to be independent of the pressure.
46  *
47  * The enthalpy function is given by the following relation.
48  *
49  * \f[
50  * \raggedright h^o_k(T,P) =
51  * h^{ref}_k(T) + \tilde v \left( P - P_{ref} \right)
52  * \f]
53  *
54  * For an incompressible,
55  * stoichiometric substance, the molar internal energy is
56  * independent of pressure. Since the thermodynamic properties
57  * are specified by giving the standard-state enthalpy, the
58  * term \f$ P_{ref} \tilde v\f$ is subtracted from the specified reference molar
59  * enthalpy to compute the molar internal energy.
60  *
61  * \f[
62  * u^o_k(T,P) = h^{ref}_k(T) - P_{ref} \tilde v
63  * \f]
64  *
65  * The standard state heat capacity and entropy are independent
66  * of pressure. The standard state gibbs free energy is obtained
67  * from the enthalpy and entropy functions.
68  *
69  *
70  * <b> Specification of Solution Thermodynamic Properties </b>
71  *
72  * All solution properties are obtained from the standard state
73  * species functions, since there is only one species in the phase.
74  *
75  * <b> Application within %Kinetics Managers </b>
76  *
77  * The standard concentration is equal to 1.0. This means that the
78  * kinetics operator works on an (activities basis). Since this
79  * is a stoichiometric substance, this means that the concentration
80  * of this phase drops out of kinetics expressions.
81  *
82  * An example of a reaction using this is a sticking coefficient
83  * reaction of a substance in an ideal gas phase on a surface with a bulk phase
84  * species in this phase. In this case, the rate of progress for this
85  * reaction, \f$ R_s \f$, may be expressed via the following equation:
86  * \f[
87  * R_s = k_s C_{gas}
88  * \f]
89  * where the units for \f$ R_s \f$ are kmol m-2 s-1. \f$ C_{gas} \f$ has units
90  * of kmol m-3. Therefore, the kinetic rate constant, \f$ k_s \f$, has
91  * units of m s-1. Nowhere does the concentration of the bulk phase
92  * appear in the rate constant expression, since it's a stoichiometric
93  * phase and the activity is always equal to 1.0.
94  *
95  * <b> Instantiation of the Class </b>
96  *
97  * The constructor for this phase is NOT located in the default ThermoFactory
98  * for %Cantera. However, a new %StoichSubstanceSSTP may be created by
99  * the following code snippets:
100  *
101  * @code
102  * sprintf(file_ID,"%s#NaCl(S)", iFile);
103  * XML_Node *xm = get_XML_NameID("phase", file_ID, 0);
104  * StoichSubstanceSSTP *solid = new StoichSubstanceSSTP(*xm);
105  * @endcode
106  *
107  * or by the following call to importPhase():
108  *
109  * @code
110  * sprintf(file_ID,"%s#NaCl(S)", iFile);
111  * XML_Node *xm = get_XML_NameID("phase", file_ID, 0);
112  * StoichSubstanceSSTP solid;
113  * importPhase(*xm, &solid);
114  * @endcode
115  *
116  * <b> XML Example </b>
117  *
118  * The phase model name for this is called StoichSubstance. It must be supplied
119  * as the model attribute of the thermo XML element entry.
120  * Within the phase XML block,
121  * the density of the phase must be specified. An example of an XML file
122  * this phase is given below.
123  *
124  * @verbatim
125  <!-- phase NaCl(S) -->
126  <phase dim="3" id="NaCl(S)">
127  <elementArray datasrc="elements.xml">
128  Na Cl
129  </elementArray>
130  <speciesArray datasrc="#species_NaCl(S)"> NaCl(S) </speciesArray>
131  <thermo model="StoichSubstanceSSTP">
132  <density units="g/cm3">2.165</density>
133  </thermo>
134  <transport model="None"/>
135  <kinetics model="none"/>
136  </phase>
137 
138  <!-- species definitions -->
139  <speciesData id="species_NaCl(S)">
140  <!-- species NaCl(S) -->
141  <species name="NaCl(S)">
142  <atomArray> Na:1 Cl:1 </atomArray>
143  <thermo>
144  <Shomate Pref="1 bar" Tmax="1075.0" Tmin="250.0">
145  <floatArray size="7">
146  50.72389, 6.672267, -2.517167,
147  10.15934, -0.200675, -427.2115,
148  130.3973
149  </floatArray>
150  </Shomate>
151  </thermo>
152  <density units="g/cm3">2.165</density>
153  </species>
154  </speciesData> @endverbatim
155  *
156  * The model attribute, "StoichSubstanceSSTP", on the thermo element
157  * identifies the phase as being a StoichSubstanceSSTP object.
158  *
159  * @ingroup thermoprops
160  */
162 {
163 
164 public:
165 
166  //! Default constructor for the StoichSubstanceSSTP class
168 
169  //! Construct and initialize a StoichSubstanceSSTP ThermoPhase object
170  //! directly from an ASCII input file
171  /*!
172  * @param infile name of the input file
173  * @param id name of the phase id in the file.
174  * If this is blank, the first phase in the file is used.
175  */
176  StoichSubstanceSSTP(std::string infile, std::string id = "");
177 
178  //! Construct and initialize a StoichSubstanceSSTP ThermoPhase object
179  //! directly from an XML database
180  /*!
181  * @param phaseRef XML node pointing to a StoichSubstanceSSTP description
182  * @param id Id of the phase.
183  */
184  StoichSubstanceSSTP(XML_Node& phaseRef, std::string id = "");
185 
186  //! Copy constructor
187  /*!
188  * @param right Object to be copied
189  */
191 
192  //! Assignment operator
193  /*!
194  * @param right Object to be copied
195  */
197 
198  //! Destructor for the routine (virtual)
199  virtual ~StoichSubstanceSSTP();
200 
201  //! Duplication function
202  /*!
203  * This virtual function is used to create a duplicate of the
204  * current phase. It's used to duplicate the phase when given
205  * a ThermoPhase pointer to the phase.
206  *
207  * @return It returns a ThermoPhase pointer.
208  */
210 
211  /**
212  *
213  * @name Utilities
214  * @{
215  */
216 
217  /**
218  * Equation of state flag.
219  *
220  * Returns the value cStoichSubstance, defined in mix_defs.h.
221  */
222  virtual int eosType() const;
223 
224  /**
225  * @}
226  * @name Molar Thermodynamic Properties of the Solution
227  * @{
228  */
229 
230  /**
231  * @}
232  * @name Mechanical Equation of State
233  * @{
234  */
235 
236 
237  //! Report the Pressure. Units: Pa.
238  /*!
239  * For an incompressible substance, the density is independent
240  * of pressure. This method simply returns the stored
241  * 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  * @}
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 
283  //! This method returns an array of generalized concentrations
284  /*!
285  * \f$ C^a_k\f$ are defined such that \f$ a_k = C^a_k /
286  * C^0_k, \f$ where \f$ C^0_k \f$ is a standard concentration
287  * defined below and \f$ a_k \f$ are activities used in the
288  * thermodynamic functions. These activity (or generalized)
289  * concentrations are used
290  * by kinetics manager classes to compute the forward and
291  * reverse rates of elementary reactions.
292  *
293  * For a stoichiometric substance, there is
294  * only one species, and the generalized concentration is 1.0.
295  *
296  * @param c Output array of generalized concentrations. The
297  * units depend upon the implementation of the
298  * reaction rate expressions within the phase.
299  */
300  virtual void getActivityConcentrations(doublereal* c) const;
301 
302  //! Return the standard concentration for the kth species
303  /*!
304  * The standard concentration \f$ C^0_k \f$ used to normalize
305  * the activity (i.e., generalized) concentration.
306  * This phase assumes that the kinetics operator works on an
307  * dimensionless basis. Thus, the standard concentration is
308  * equal to 1.0.
309  *
310  * @param k Optional parameter indicating the species. The default
311  * is to assume this refers to species 0.
312  * @return
313  * Returns The standard Concentration as 1.0
314  */
315  virtual doublereal standardConcentration(size_t k=0) const;
316 
317  //! Natural logarithm of the standard concentration of the kth species.
318  /*!
319  * @param k index of the species (defaults to zero)
320  */
321  virtual doublereal logStandardConc(size_t k=0) const;
322 
323  //! Get the array of chemical potentials at unit activity for the species
324  //! at their standard states at the current <I>T</I> and <I>P</I> of the solution.
325  /*!
326  * For a stoichiometric substance, there is no activity term in
327  * the chemical potential expression, and therefore the
328  * standard chemical potential and the chemical potential
329  * are both equal to the molar Gibbs function.
330  *
331  * These are the standard state chemical potentials \f$ \mu^0_k(T,P)
332  * \f$. The values are evaluated at the current
333  * temperature and pressure of the solution
334  *
335  * @param mu0 Output vector of chemical potentials.
336  * Length: m_kk.
337  */
338  virtual void getStandardChemPotentials(doublereal* mu0) const;
339 
340  //! Returns the units of the standard and generalized concentrations.
341  /*!
342  * Note they have the same units, as their
343  * ratio is defined to be equal to the activity of the kth
344  * species in the solution, which is unitless.
345  *
346  * This routine is used in print out applications where the
347  * units are needed. Usually, MKS units are assumed throughout
348  * the program and in the XML input files.
349  *
350  * The base %ThermoPhase class assigns the default quantities
351  * of (kmol/m3) for all species.
352  * Inherited classes are responsible for overriding the default
353  * values if necessary.
354  *
355  * @param uA Output vector containing the units
356  * uA[0] = kmol units - default = 1
357  * uA[1] = m units - default = -nDim(), the number of spatial
358  * dimensions in the Phase class.
359  * uA[2] = kg units - default = 0;
360  * uA[3] = Pa(pressure) units - default = 0;
361  * uA[4] = Temperature units - default = 0;
362  * uA[5] = time units - default = 0
363  * @param k species index. Defaults to 0.
364  * @param sizeUA output int containing the size of the vector.
365  * Currently, this is equal to 6.
366  */
367  virtual void getUnitsStandardConc(doublereal* uA, int k = 0,
368  int sizeUA = 6) const;
369 
370  //@}
371  /// @name Partial Molar Properties of the Solution
372  ///
373  /// These properties are handled by the parent class,
374  /// SingleSpeciesTP
375  //@{
376 
377 
378  //@}
379  /// @name Properties of the Standard State of the Species in the Solution
380  //@{
381 
382  //! Get the nondimensional Enthalpy functions for the species
383  //! at their standard states at the current <I>T</I> and <I>P</I> of the solution.
384  /*!
385  * @param hrt Output vector of nondimensional standard state enthalpies.
386  * Length: m_kk.
387  */
388  virtual void getEnthalpy_RT(doublereal* hrt) const;
389 
390  //! Get the array of nondimensional Entropy functions for the
391  //! standard state species at the current <I>T</I> and <I>P</I> of the solution.
392  /*!
393  * @param sr Output vector of nondimensional standard state entropies.
394  * Length: m_kk.
395  */
396  virtual void getEntropy_R(doublereal* sr) const;
397 
398  //! Get the nondimensional Gibbs functions for the species
399  //! in their standard states at the current <I>T</I> and <I>P</I> of the solution.
400  /*!
401  * @param grt Output vector of nondimensional standard state gibbs free energies
402  * Length: m_kk.
403  */
404  virtual void getGibbs_RT(doublereal* grt) const;
405 
406  //! Get the nondimensional Heat Capacities at constant
407  //! pressure for the species standard states
408  //! at the current <I>T</I> and <I>P</I> of the solution
409  /*!
410  * @param cpr Output vector of nondimensional standard state heat capacities
411  * Length: m_kk.
412  */
413  virtual void getCp_R(doublereal* cpr) const;
414 
415  //! Returns the vector of nondimensional Internal Energies of the standard
416  //! state species at the current <I>T</I> and <I>P</I> of the solution
417  /*!
418  * For an incompressible,
419  * stoichiometric substance, the molar internal energy is
420  * independent of pressure. Since the thermodynamic properties
421  * are specified by giving the standard-state enthalpy, the
422  * term \f$ P_{ref} \hat v\f$ is subtracted from the specified reference molar
423  * enthalpy to compute the standard state molar internal energy.
424  *
425  * @param urt output vector of nondimensional standard state
426  * internal energies of the species. Length: m_kk.
427  */
428  virtual void getIntEnergy_RT(doublereal* urt) const;
429 
430  //@}
431  /// @name Thermodynamic Values for the Species Reference States
432  //@{
433 
434  //! Returns the vector of nondimensional
435  //! internal Energies of the reference state at the current temperature
436  //! of the solution and the reference pressure for each species.
437  /*!
438  * @param urt Output vector of nondimensional reference state
439  * internal energies of the species.
440  * Length: m_kk
441  */
442  virtual void getIntEnergy_RT_ref(doublereal* urt) const;
443 
444  /*
445  * ---- Critical State Properties
446  */
447 
448 
449  /*
450  * ---- Saturation Properties
451  */
452 
453  /*
454  * @internal Initialize. This method is provided to allow
455  * subclasses to perform any initialization required after all
456  * species have been added. For example, it might be used to
457  * resize internal work arrays that must have an entry for
458  * each species. The base class implementation does nothing,
459  * and subclasses that do not require initialization do not
460  * need to overload this method. When importing a CTML phase
461  * description, this method is called just prior to returning
462  * from function importPhase.
463  *
464  * @see importCTML.cpp
465  */
466  virtual void initThermo();
467 
468 
469  virtual void initThermoXML(XML_Node& phaseNode, std::string id);
470 
471  //! Set the equation of state parameters
472  /*!
473  * @internal
474  * The number and meaning of these depends on the subclass.
475  *
476  * @param n number of parameters
477  * @param c array of \a n coefficients
478  * c[0] = density of phase [ kg/m3 ]
479  */
480  virtual void setParameters(int n, doublereal* const c);
481 
482  //! Get the equation of state parameters in a vector
483  /*!
484  * @internal
485  *
486  * @param n number of parameters
487  * @param c array of \a n coefficients
488  *
489  * For this phase:
490  * - n = 1
491  * - c[0] = density of phase [ kg/m3 ]
492  */
493  virtual void getParameters(int& n, doublereal* const c) const;
494 
495  //! Set equation of state parameter values from XML entries.
496  /*!
497  * This method is called by function importPhase() in
498  * file importCTML.cpp when processing a phase definition in
499  * an input file. It should be overloaded in subclasses to set
500  * any parameters that are specific to that particular phase
501  * model. Note, this method is called before the phase is
502  * initialized with elements and/or species.
503  *
504  * For this phase, the density of the phase is specified in this block.
505  *
506  * @param eosdata An XML_Node object corresponding to
507  * the "thermo" entry for this phase in the input file.
508  *
509  * eosdata points to the thermo block, and looks like this:
510  *
511  * @verbatim
512  <phase id="stoichsolid" >
513  <thermo model="StoichSubstance">
514  <density units="g/cm3">3.52</density>
515  </thermo>
516  </phase> @endverbatim
517  *
518  */
519  virtual void setParametersFromXML(const XML_Node& eosdata);
520 
521 protected:
522 
523 };
524 
525 //! Class %electrodeElectron represents an electron in a
526 //! metal using the Standard hydrogen reference electrode
527 /*!
528  *
529  * The class is based on the electron have a chemical potential
530  * equal to one-half of the entropy of the H2 gas at 1 bar.
531  *
532  */
534 {
535 public:
536 
537  //! Default constructor for the electrodeElectron class
539 
540  //! Construct and initialize a electrodeElectron ThermoPhase object
541  //! directly from an ASCII input file
542  /*!
543  * @param infile name of the input file
544  * @param id name of the phase id in the file.
545  * If this is blank, the first phase in the file is used.
546  */
547  electrodeElectron(std::string infile, std::string id = "");
548 
549  //! Construct and initialize a electrodeElectron ThermoPhase object
550  //! directly from an XML database
551  /*!
552  * @param phaseRef XML node pointing to a electrodeElectron description
553  * @param id Id of the phase.
554  */
555  electrodeElectron(XML_Node& phaseRef, std::string id = "");
556 
557  //! Copy constructor
558  /*!
559  * @param right Object to be copied
560  */
561  electrodeElectron(const electrodeElectron& right);
562 
563  //! Assignment operator
564  /*!
565  * @param right Object to be copied
566  */
568 
569  //! Destructor for the routine (virtual)
570  virtual ~electrodeElectron();
571 
572  void setParametersFromXML(const XML_Node& eosdata);
573 
574  virtual void initThermoXML(XML_Node& phaseNode, std::string id);
575 
576  void setParameters(int n, doublereal* const c);
577 };
578 
579 }
580 
581 #endif