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