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