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