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