Cantera  2.3.0
SurfPhase.h
Go to the documentation of this file.
1 /**
2  * @file SurfPhase.h
3  * Header for a simple thermodynamics model of a surface phase
4  * derived from ThermoPhase,
5  * assuming an ideal solution model
6  * (see \ref thermoprops and class \link Cantera::SurfPhase SurfPhase\endlink).
7  */
8 
9 // This file is part of Cantera. See License.txt in the top-level directory or
10 // at http://www.cantera.org/license.txt for license and copyright information.
11 
12 #ifndef CT_SURFPHASE_H
13 #define CT_SURFPHASE_H
14 
15 #include "mix_defs.h"
16 #include "ThermoPhase.h"
17 
18 namespace Cantera
19 {
20 
21 //! A simple thermodynamic model for a surface phase, assuming an ideal solution
22 //! model.
23 /*!
24  * The surface consists of a grid of equivalent sites. Surface species may be
25  * defined to occupy one or more sites. The surface species are assumed to be
26  * independent, and thus the species form an ideal solution.
27  *
28  * The density of surface sites is given by the variable \f$ n_0 \f$,
29  * which has SI units of kmol m-2.
30  *
31  * ## Specification of Species Standard State Properties
32  *
33  * It is assumed that the reference state thermodynamics may be obtained by a
34  * pointer to a populated species thermodynamic property manager class (see
35  * ThermoPhase::m_spthermo). How to relate pressure changes to the reference
36  * state thermodynamics is resolved at this level.
37  *
38  * Pressure is defined as an independent variable in this phase. However, it has
39  * no effect on any quantities, as the molar concentration is a constant.
40  *
41  * Therefore, The standard state internal energy for species *k* is equal to the
42  * enthalpy for species *k*.
43  *
44  * \f[
45  * u^o_k = h^o_k
46  * \f]
47  *
48  * Also, the standard state chemical potentials, entropy, and heat capacities
49  * are independent of pressure. The standard state Gibbs free energy is obtained
50  * from the enthalpy and entropy functions.
51  *
52  * ## Specification of Solution Thermodynamic Properties
53  *
54  * The activity of species defined in the phase is given by
55  * \f[
56  * a_k = \theta_k
57  * \f]
58  *
59  * The chemical potential for species *k* is equal to
60  * \f[
61  * \mu_k(T,P) = \mu^o_k(T) + R T \log(\theta_k)
62  * \f]
63  *
64  * Pressure is defined as an independent variable in this phase. However, it has
65  * no effect on any quantities, as the molar concentration is a constant.
66  *
67  * The internal energy for species k is equal to the enthalpy for species *k*
68  * \f[
69  * u_k = h_k
70  * \f]
71  *
72  * The entropy for the phase is given by the following relation, which is
73  * independent of the pressure:
74  *
75  * \f[
76  * s_k(T,P) = s^o_k(T) - R \log(\theta_k)
77  * \f]
78  *
79  * ## %Application within Kinetics Managers
80  *
81  * The activity concentration,\f$ C^a_k \f$, used by the kinetics manager, is equal to
82  * the actual concentration, \f$ C^s_k \f$, and is given by the following
83  * expression.
84  * \f[
85  * C^a_k = C^s_k = \frac{\theta_k n_0}{s_k}
86  * \f]
87  *
88  * The standard concentration for species *k* is:
89  * \f[
90  * C^0_k = \frac{n_0}{s_k}
91  * \f]
92  *
93  * ## Instantiation of the Class
94  *
95  * The constructor for this phase is located in the default ThermoFactory
96  * for %Cantera. A new SurfPhase may be created by the following code snippet:
97  *
98  * @code
99  * XML_Node *xc = get_XML_File("diamond.xml");
100  * XML_Node * const xs = xc->findNameID("phase", "diamond_100");
101  * ThermoPhase *diamond100TP_tp = newPhase(*xs);
102  * SurfPhase *diamond100TP = dynamic_cast <SurfPhase *>(diamond100TP_tp);
103  * @endcode
104  *
105  * or by the following constructor:
106  *
107  * @code
108  * XML_Node *xc = get_XML_File("diamond.xml");
109  * XML_Node * const xs = xc->findNameID("phase", "diamond_100");
110  * SurfPhase *diamond100TP = new SurfPhase(*xs);
111  * @endcode
112  *
113  * ## XML Example
114  *
115  * An example of an XML Element named phase setting up a SurfPhase object named
116  * diamond_100 is given below.
117  *
118  * @code
119  * <phase dim="2" id="diamond_100">
120  * <elementArray datasrc="elements.xml">H C</elementArray>
121  * <speciesArray datasrc="#species_data">c6HH c6H* c6*H c6** c6HM c6HM* c6*M c6B </speciesArray>
122  * <reactionArray datasrc="#reaction_data"/>
123  * <state>
124  * <temperature units="K">1200.0</temperature>
125  * <coverages>c6H*:0.1, c6HH:0.9</coverages>
126  * </state>
127  * <thermo model="Surface">
128  * <site_density units="mol/cm2">3e-09</site_density>
129  * </thermo>
130  * <kinetics model="Interface"/>
131  * <transport model="None"/>
132  * <phaseArray>
133  * gas_phase diamond_bulk
134  * </phaseArray>
135  * </phase>
136  * @endcode
137  *
138  * The model attribute, "Surface", on the thermo element identifies the phase as being
139  * a SurfPhase object.
140  *
141  * @ingroup thermoprops
142  */
143 class SurfPhase : public ThermoPhase
144 {
145 public:
146  //! Constructor.
147  /*!
148  * @param n0 Site Density of the Surface Phase
149  * Units: kmol m-2.
150  */
151  SurfPhase(doublereal n0 = 1.0);
152 
153  //! Construct and initialize a SurfPhase ThermoPhase object directly from an
154  //! ASCII input file
155  /*!
156  * @param infile name of the input file
157  * @param id name of the phase id in the file.
158  * If this is blank, the first phase in the file is used.
159  */
160  SurfPhase(const std::string& infile, const std::string& id);
161 
162  //! Construct and initialize a SurfPhase ThermoPhase object directly from an
163  //! XML database
164  /*!
165  * @param xmlphase XML node pointing to a SurfPhase description
166  */
167  SurfPhase(XML_Node& xmlphase);
168 
169  SurfPhase(const SurfPhase& right);
170  SurfPhase& operator=(const SurfPhase& right);
171  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
172 
173  //! Equation of state type flag.
174  /*!
175  * Redefine this to return cSurf, listed in mix_defs.h.
176  * @deprecated To be removed after Cantera 2.3.
177  */
178  virtual int eosType() const {
179  warn_deprecated("SurfPhase::eosType",
180  "To be removed after Cantera 2.3.");
181  return cSurf;
182  }
183  virtual std::string type() const {
184  return "Surf";
185  }
186 
187  //! Return the Molar Enthalpy. Units: J/kmol.
188  /*!
189  * For an ideal solution,
190  * \f[
191  * \hat h(T,P) = \sum_k X_k \hat h^0_k(T),
192  * \f]
193  * and is a function only of temperature. The standard-state pure-species
194  * Enthalpies \f$ \hat h^0_k(T) \f$ are computed by the species
195  * thermodynamic property manager.
196  *
197  * \see MultiSpeciesThermo
198  */
199  virtual doublereal enthalpy_mole() const;
200 
201  //! Return the Molar Internal Energy. Units: J/kmol
202  /**
203  * For a surface phase, the pressure is not a relevant thermodynamic
204  * variable, and so the Enthalpy is equal to the Internal Energy.
205  */
206  virtual doublereal intEnergy_mole() const;
207 
208  //! Return the Molar Entropy. Units: J/kmol-K
209  /**
210  * \f[
211  * \hat s(T,P) = \sum_k X_k (\hat s^0_k(T) - R \log(\theta_k))
212  * \f]
213  */
214  virtual doublereal entropy_mole() const;
215 
216  virtual doublereal cp_mole() const;
217  virtual doublereal cv_mole() const;
218 
219  virtual void getChemPotentials(doublereal* mu) const;
220  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
221  virtual void getPartialMolarEntropies(doublereal* sbar) const;
222  virtual void getPartialMolarCp(doublereal* cpbar) const;
223  virtual void getPartialMolarVolumes(doublereal* vbar) const;
224  virtual void getStandardChemPotentials(doublereal* mu0) const;
225 
226  //! Return a vector of activity concentrations for each species
227  /*!
228  * For this phase the activity concentrations,\f$ C^a_k \f$, are defined to
229  * be equal to the actual concentrations, \f$ C^s_k \f$. Activity
230  * concentrations are
231  *
232  * \f[
233  * C^a_k = C^s_k = \frac{\theta_k n_0}{s_k}
234  * \f]
235  *
236  * where \f$ \theta_k \f$ is the surface site fraction for species k,
237  * \f$ n_0 \f$ is the surface site density for the phase, and
238  * \f$ s_k \f$ is the surface size of species k.
239  *
240  * \f$ C^a_k\f$ that are defined such that \f$ a_k = C^a_k / C^0_k, \f$
241  * where \f$ C^0_k \f$ is a standard concentration defined below and \f$ a_k
242  * \f$ are activities used in the thermodynamic functions. These activity
243  * concentrations are used by kinetics manager classes to compute the
244  * forward and reverse rates of elementary reactions. Note that they may or
245  * may not have units of concentration --- they might be partial pressures,
246  * mole fractions, or surface coverages,
247  *
248  * @param c vector of activity concentration (kmol m-2).
249  */
250  virtual void getActivityConcentrations(doublereal* c) const;
251 
252  //! Return the standard concentration for the kth species
253  /*!
254  * The standard concentration \f$ C^0_k \f$ used to normalize the activity
255  * (i.e., generalized) concentration. For this phase, the standard
256  * concentration is species- specific
257  *
258  * \f[
259  * C^0_k = \frac{n_0}{s_k}
260  * \f]
261  *
262  * This definition implies that the activity is equal to \f$ \theta_k \f$.
263  *
264  * @param k Optional parameter indicating the species. The default
265  * is to assume this refers to species 0.
266  * @return
267  * Returns the standard Concentration in units of m3 kmol-1.
268  */
269  virtual doublereal standardConcentration(size_t k = 0) const;
270  virtual doublereal logStandardConc(size_t k=0) const;
271 
272  //! Set the equation of state parameters from the argument list
273  /*!
274  * @internal
275  * Set equation of state parameters.
276  *
277  * @param n number of parameters. Must be one
278  * @param c array of \a n coefficients
279  * c[0] = The site density (kmol m-2)
280  */
281  virtual void setParameters(int n, doublereal* const c);
282 
283  //! Set the Equation-of-State parameters by reading an XML Node Input
284  /*!
285  * The Equation-of-State data consists of one item, the site density.
286  *
287  * @param thermoData Reference to an XML_Node named thermo containing the
288  * equation-of-state data. The XML_Node is within the
289  * phase XML_Node describing the SurfPhase object.
290  *
291  * An example of the contents of the thermoData XML_Node is provided below.
292  * The units attribute is used to supply the units of the site density in
293  * any convenient form. Internally it is changed into MKS form.
294  *
295  * @code
296  * <thermo model="Surface">
297  * <site_density units="mol/cm2"> 3e-09 </site_density>
298  * </thermo>
299  * @endcode
300  */
301  virtual void setParametersFromXML(const XML_Node& thermoData);
302 
303  virtual bool addSpecies(shared_ptr<Species> spec);
304 
305  //! Set the initial state of the Surface Phase from an XML_Node
306  /*!
307  * State variables that can be set by this routine are the temperature and
308  * the surface site coverages.
309  *
310  * @param state XML_Node containing the state information
311  *
312  * An example of the XML code block is given below.
313  *
314  * @code
315  * <state>
316  * <temperature units="K">1200.0</temperature>
317  * <coverages>c6H*:0.1, c6HH:0.9</coverages>
318  * </state>
319  * @endcode
320  */
321  virtual void setStateFromXML(const XML_Node& state);
322 
323  //! Returns the site density
324  /*!
325  * Site density kmol m-2
326  */
327  doublereal siteDensity() {
328  return m_n0;
329  }
330 
331  //! Set the site density of the surface phase (kmol m-2)
332  /*!
333  * @param n0 Site density of the surface phase (kmol m-2)
334  */
335  void setSiteDensity(doublereal n0);
336 
337  virtual void getGibbs_RT(doublereal* grt) const;
338  virtual void getEnthalpy_RT(doublereal* hrt) const;
339  virtual void getEntropy_R(doublereal* sr) const;
340  virtual void getCp_R(doublereal* cpr) const;
341  virtual void getStandardVolumes(doublereal* vol) const;
342 
343  //! Return the thermodynamic pressure (Pa).
344  virtual doublereal pressure() const {
345  return m_press;
346  }
347 
348  //! Set the internally stored pressure (Pa) at constant temperature and
349  //! composition
350  /*!
351  * @param p input Pressure (Pa)
352  */
353  virtual void setPressure(doublereal p) {
354  m_press = p;
355  }
356 
357  virtual void getPureGibbs(doublereal* g) const;
358  virtual void getGibbs_RT_ref(doublereal* grt) const;
359  virtual void getEnthalpy_RT_ref(doublereal* hrt) const;
360  virtual void getEntropy_R_ref(doublereal* er) const;
361  virtual void getCp_R_ref(doublereal* cprt) const;
362 
363  //! Set the surface site fractions to a specified state.
364  /*!
365  * This routine converts to concentrations in kmol/m2, using m_n0, the
366  * surface site density, and size(k), which is defined to be the number of
367  * surface sites occupied by the kth molecule. It then calls
368  * Phase::setConcentrations to set the internal concentration in the object.
369  *
370  * @param theta This is the surface site fraction for the kth species in
371  * the surface phase. This is a dimensionless quantity.
372  *
373  * This routine normalizes the theta's to 1, before application
374  */
375  void setCoverages(const doublereal* theta);
376 
377  //! Set the surface site fractions to a specified state.
378  /*!
379  * This routine converts to concentrations in kmol/m2, using m_n0, the
380  * surface site density, and size(k), which is defined to be the number of
381  * surface sites occupied by the kth molecule. It then calls
382  * Phase::setConcentrations to set the internal concentration in the object.
383  *
384  * @param theta This is the surface site fraction for the kth species in
385  * the surface phase. This is a dimensionless quantity.
386  */
387  void setCoveragesNoNorm(const doublereal* theta);
388 
389  //! Set the coverages from a string of colon-separated name:value pairs.
390  /*!
391  * @param cov String containing colon-separated name:value pairs
392  */
393  void setCoveragesByName(const std::string& cov);
394 
395  //! Set the coverages from a map of name:value pairs
396  void setCoveragesByName(const compositionMap& cov);
397 
398  //! Return a vector of surface coverages
399  /*!
400  * Get the coverages.
401  *
402  * @param theta Array theta must be at least as long as the number of
403  * species.
404  */
405  void getCoverages(doublereal* theta) const;
406 
407 protected:
408  //! Surface site density (kmol m-2)
409  doublereal m_n0;
410 
411  //! log of the surface site density
412  doublereal m_logn0;
413 
414  //! Current value of the pressure (Pa)
415  doublereal m_press;
416 
417  //! Temporary storage for the reference state enthalpies
418  mutable vector_fp m_h0;
419 
420  //! Temporary storage for the reference state entropies
421  mutable vector_fp m_s0;
422 
423  //! Temporary storage for the reference state heat capacities
424  mutable vector_fp m_cp0;
425 
426  //! Temporary storage for the reference state Gibbs energies
427  mutable vector_fp m_mu0;
428 
429  //! Temporary work array
430  mutable vector_fp m_work;
431 
432  //! vector storing the log of the size of each species.
433  /*!
434  * The size of each species is defined as the number of surface sites each
435  * species occupies.
436  */
438 
439 private:
440  //! Update the species reference state thermodynamic functions
441  /*!
442  * The polynomials for the standard state functions are only reevaluated if
443  * the temperature has changed.
444  *
445  * @param force Boolean, which if true, forces a reevaluation of the thermo
446  * polynomials. default = false.
447  */
448  void _updateThermo(bool force=false) const;
449 };
450 }
451 
452 #endif
std::map< std::string, doublereal > compositionMap
Map connecting a string name with a double.
Definition: ct_defs.h:149
void setCoveragesNoNorm(const doublereal *theta)
Set the surface site fractions to a specified state.
Definition: SurfPhase.cpp:282
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
Definition: SurfPhase.cpp:134
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
Definition: SurfPhase.cpp:197
virtual void getGibbs_RT_ref(doublereal *grt) const
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
Definition: SurfPhase.cpp:217
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
Definition: SurfPhase.cpp:203
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
Definition: SurfPhase.cpp:191
void setCoveragesByName(const std::string &cov)
Set the coverages from a string of colon-separated name:value pairs.
Definition: SurfPhase.cpp:298
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
Definition: SurfPhase.cpp:160
doublereal m_press
Current value of the pressure (Pa)
Definition: SurfPhase.h:415
void setCoverages(const doublereal *theta)
Set the surface site fractions to a specified state.
Definition: SurfPhase.cpp:265
SurfPhase(doublereal n0=1.0)
Constructor.
Definition: SurfPhase.cpp:23
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
Definition: SurfPhase.cpp:67
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:54
virtual void getPureGibbs(doublereal *g) const
Get the Gibbs functions for the standard state of the species at the current T and P of the solution...
Definition: SurfPhase.cpp:179
virtual void getGibbs_RT(doublereal *grt) const
Get the nondimensional Gibbs functions for the species in their standard states at the current T and ...
Definition: SurfPhase.cpp:185
vector_fp m_work
Temporary work array.
Definition: SurfPhase.h:430
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:93
const int cSurf
A surface phase. Used by class SurfPhase.
Definition: mix_defs.h:41
doublereal m_n0
Surface site density (kmol m-2)
Definition: SurfPhase.h:409
virtual std::string type() const
String indicating the thermodynamic model implemented.
Definition: SurfPhase.h:183
virtual doublereal logStandardConc(size_t k=0) const
Natural logarithm of the standard concentration of the kth species.
Definition: SurfPhase.cpp:165
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
Definition: SurfPhase.h:143
doublereal m_logn0
log of the surface site density
Definition: SurfPhase.h:412
virtual doublereal enthalpy_mole() const
Return the Molar Enthalpy. Units: J/kmol.
Definition: SurfPhase.cpp:72
void getCoverages(doublereal *theta) const
Return a vector of surface coverages.
Definition: SurfPhase.cpp:290
virtual doublereal intEnergy_mole() const
Return the Molar Internal Energy. Units: J/kmol.
Definition: SurfPhase.cpp:81
virtual void setStateFromXML(const XML_Node &state)
Set the initial state of the Surface Phase from an XML_Node.
Definition: SurfPhase.cpp:344
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
Definition: SurfPhase.cpp:145
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
Definition: SurfPhase.cpp:97
vector_fp m_logsize
vector storing the log of the size of each species.
Definition: SurfPhase.h:437
vector_fp m_s0
Temporary storage for the reference state entropies.
Definition: SurfPhase.h:421
virtual void getEnthalpy_RT_ref(doublereal *hrt) const
Returns the vector of nondimensional enthalpies of the reference state at the current temperature of ...
Definition: SurfPhase.cpp:222
virtual void getActivityConcentrations(doublereal *c) const
Return a vector of activity concentrations for each species.
Definition: SurfPhase.cpp:155
void _updateThermo(bool force=false) const
Update the species reference state thermodynamic functions.
Definition: SurfPhase.cpp:321
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
Definition: SurfPhase.h:344
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
Definition: SurfPhase.h:353
vector_fp m_h0
Temporary storage for the reference state enthalpies.
Definition: SurfPhase.h:418
virtual void getStandardVolumes(doublereal *vol) const
Get the molar volumes of the species standard states at the current T and P of the solution...
Definition: SurfPhase.cpp:209
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
Definition: SurfPhase.cpp:116
virtual void getEntropy_R_ref(doublereal *er) const
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
Definition: SurfPhase.cpp:227
void setSiteDensity(doublereal n0)
Set the site density of the surface phase (kmol m-2)
Definition: SurfPhase.cpp:255
virtual doublereal entropy_mole() const
Return the Molar Entropy. Units: J/kmol-K.
Definition: SurfPhase.cpp:86
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:157
virtual bool addSpecies(shared_ptr< Species > spec)
Definition: SurfPhase.cpp:237
vector_fp m_mu0
Temporary storage for the reference state Gibbs energies.
Definition: SurfPhase.h:427
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
Definition: SurfPhase.cpp:108
virtual void getCp_R_ref(doublereal *cprt) const
Returns the vector of nondimensional constant pressure heat capacities of the reference state at the ...
Definition: SurfPhase.cpp:232
virtual void setParametersFromXML(const XML_Node &thermoData)
Set the Equation-of-State parameters by reading an XML Node Input.
Definition: SurfPhase.cpp:337
virtual void getPartialMolarCp(doublereal *cpbar) const
Return an array of partial molar heat capacities for the species in the mixture.
Definition: SurfPhase.cpp:124
Namespace for the Cantera kernel.
Definition: application.cpp:29
virtual void getStandardChemPotentials(doublereal *mu0) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
Definition: SurfPhase.cpp:139
virtual int eosType() const
Equation of state type flag.
Definition: SurfPhase.h:178
Header file for class ThermoPhase, the base class for phases with thermodynamic properties, and the text for the Module thermoprops (see Thermodynamic Properties and class ThermoPhase).
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
Definition: SurfPhase.cpp:103
vector_fp m_cp0
Temporary storage for the reference state heat capacities.
Definition: SurfPhase.h:424
doublereal siteDensity()
Returns the site density.
Definition: SurfPhase.h:327
virtual void setParameters(int n, doublereal *const c)
Set the equation of state parameters from the argument list.
Definition: SurfPhase.cpp:170