Cantera  2.5.1
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 https://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  * @deprecated The XML input format is deprecated and will be removed in
167  * Cantera 3.0.
168  */
169  SurfPhase(XML_Node& xmlphase);
170 
171  virtual std::string type() const {
172  return "Surf";
173  }
174 
175  //! Return the Molar Enthalpy. Units: J/kmol.
176  /*!
177  * For an ideal solution,
178  * \f[
179  * \hat h(T,P) = \sum_k X_k \hat h^0_k(T),
180  * \f]
181  * and is a function only of temperature. The standard-state pure-species
182  * Enthalpies \f$ \hat h^0_k(T) \f$ are computed by the species
183  * thermodynamic property manager.
184  *
185  * \see MultiSpeciesThermo
186  */
187  virtual doublereal enthalpy_mole() const;
188 
189  //! Return the Molar Internal Energy. Units: J/kmol
190  /**
191  * For a surface phase, the pressure is not a relevant thermodynamic
192  * variable, and so the Enthalpy is equal to the Internal Energy.
193  */
194  virtual doublereal intEnergy_mole() const;
195 
196  //! Return the Molar Entropy. Units: J/kmol-K
197  /**
198  * \f[
199  * \hat s(T,P) = \sum_k X_k (\hat s^0_k(T) - R \log(\theta_k))
200  * \f]
201  */
202  virtual doublereal entropy_mole() const;
203 
204  virtual doublereal cp_mole() const;
205  virtual doublereal cv_mole() const;
206 
207  virtual void getChemPotentials(doublereal* mu) const;
208  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
209  virtual void getPartialMolarEntropies(doublereal* sbar) const;
210  virtual void getPartialMolarCp(doublereal* cpbar) const;
211  virtual void getPartialMolarVolumes(doublereal* vbar) const;
212  virtual void getStandardChemPotentials(doublereal* mu0) const;
213 
214  //! Return a vector of activity concentrations for each species
215  /*!
216  * For this phase the activity concentrations,\f$ C^a_k \f$, are defined to
217  * be equal to the actual concentrations, \f$ C^s_k \f$. Activity
218  * concentrations are
219  *
220  * \f[
221  * C^a_k = C^s_k = \frac{\theta_k n_0}{s_k}
222  * \f]
223  *
224  * where \f$ \theta_k \f$ is the surface site fraction for species k,
225  * \f$ n_0 \f$ is the surface site density for the phase, and
226  * \f$ s_k \f$ is the surface size of species k.
227  *
228  * \f$ C^a_k\f$ that are defined such that \f$ a_k = C^a_k / C^0_k, \f$
229  * where \f$ C^0_k \f$ is a standard concentration defined below and \f$ a_k
230  * \f$ are activities used in the thermodynamic functions. These activity
231  * concentrations are used by kinetics manager classes to compute the
232  * forward and reverse rates of elementary reactions. Note that they may or
233  * may not have units of concentration --- they might be partial pressures,
234  * mole fractions, or surface coverages,
235  *
236  * @param c vector of activity concentration (kmol m-2).
237  */
238  virtual void getActivityConcentrations(doublereal* c) const;
239 
240  //! Return the standard concentration for the kth species
241  /*!
242  * The standard concentration \f$ C^0_k \f$ used to normalize the activity
243  * (i.e., generalized) concentration. For this phase, the standard
244  * concentration is species- specific
245  *
246  * \f[
247  * C^0_k = \frac{n_0}{s_k}
248  * \f]
249  *
250  * This definition implies that the activity is equal to \f$ \theta_k \f$.
251  *
252  * @param k Optional parameter indicating the species. The default
253  * is to assume this refers to species 0.
254  * @return
255  * Returns the standard Concentration in units of m3 kmol-1.
256  */
257  virtual doublereal standardConcentration(size_t k = 0) const;
258  virtual doublereal logStandardConc(size_t k=0) const;
259 
260  //! Set the equation of state parameters from the argument list
261  /*!
262  * @internal
263  * Set equation of state parameters.
264  *
265  * @param n number of parameters. Must be one
266  * @param c array of \a n coefficients
267  * c[0] = The site density (kmol m-2)
268  */
269  virtual void setParameters(int n, doublereal* const c);
270 
271  //! Set the Equation-of-State parameters by reading an XML Node Input
272  /*!
273  * The Equation-of-State data consists of one item, the site density.
274  *
275  * @param thermoData Reference to an XML_Node named thermo containing the
276  * equation-of-state data. The XML_Node is within the
277  * phase XML_Node describing the SurfPhase object.
278  *
279  * An example of the contents of the thermoData XML_Node is provided below.
280  * The units attribute is used to supply the units of the site density in
281  * any convenient form. Internally it is changed into MKS form.
282  *
283  * @code
284  * <thermo model="Surface">
285  * <site_density units="mol/cm2"> 3e-09 </site_density>
286  * </thermo>
287  * @endcode
288  *
289  * @deprecated The XML input format is deprecated and will be removed in
290  * Cantera 3.0.
291  */
292  virtual void setParametersFromXML(const XML_Node& thermoData);
293  virtual void initThermo();
294 
295  virtual bool addSpecies(shared_ptr<Species> spec);
296 
297  //! Set the initial state of the Surface Phase from an XML_Node
298  /*!
299  * State variables that can be set by this routine are the temperature and
300  * the surface site coverages.
301  *
302  * @param state XML_Node containing the state information
303  *
304  * An example of the XML code block is given below.
305  *
306  * @code
307  * <state>
308  * <temperature units="K">1200.0</temperature>
309  * <coverages>c6H*:0.1, c6HH:0.9</coverages>
310  * </state>
311  * @endcode
312  *
313  * @deprecated The XML input format is deprecated and will be removed in
314  * Cantera 3.0.
315  */
316  virtual void setStateFromXML(const XML_Node& state);
317 
318  //! Returns the site density
319  /*!
320  * Site density kmol m-2
321  */
322  doublereal siteDensity() {
323  return m_n0;
324  }
325 
326  //! Returns the number of sites occupied by one molecule of species *k*.
327  virtual double size(size_t k) const {
328  return m_speciesSize[k];
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  //! @copydoc ThermoPhase::setState
408  /*!
409  * Additionally uses the key `coverages` to set the fractional coverages.
410  */
411  virtual void setState(const AnyMap& state);
412 
413 protected:
414  //! Surface site density (kmol m-2)
415  doublereal m_n0;
416 
417  //! Vector of species sizes (number of sites occupied). length m_kk.
419 
420  //! log of the surface site density
421  doublereal m_logn0;
422 
423  //! Current value of the pressure (Pa)
424  doublereal m_press;
425 
426  //! Temporary storage for the reference state enthalpies
427  mutable vector_fp m_h0;
428 
429  //! Temporary storage for the reference state entropies
430  mutable vector_fp m_s0;
431 
432  //! Temporary storage for the reference state heat capacities
433  mutable vector_fp m_cp0;
434 
435  //! Temporary storage for the reference state Gibbs energies
436  mutable vector_fp m_mu0;
437 
438  //! Temporary work array
439  mutable vector_fp m_work;
440 
441  //! vector storing the log of the size of each species.
442  /*!
443  * The size of each species is defined as the number of surface sites each
444  * species occupies.
445  */
447 
448 private:
449  //! Update the species reference state thermodynamic functions
450  /*!
451  * The polynomials for the standard state functions are only reevaluated if
452  * the temperature has changed.
453  *
454  * @param force Boolean, which if true, forces a reevaluation of the thermo
455  * polynomials. default = false.
456  */
457  void _updateThermo(bool force=false) const;
458 };
459 
460 }
461 
462 #endif
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:360
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
Definition: SurfPhase.h:143
virtual void setStateFromXML(const XML_Node &state)
Set the initial state of the Surface Phase from an XML_Node.
Definition: SurfPhase.cpp:335
void setCoveragesNoNorm(const doublereal *theta)
Set the surface site fractions to a specified state.
Definition: SurfPhase.cpp:253
void setCoveragesByName(const std::string &cov)
Set the coverages from a string of colon-separated name:value pairs.
Definition: SurfPhase.cpp:269
doublereal m_press
Current value of the pressure (Pa)
Definition: SurfPhase.h:424
virtual bool addSpecies(shared_ptr< Species > spec)
Definition: SurfPhase.cpp:207
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
vector_fp m_s0
Temporary storage for the reference state entropies.
Definition: SurfPhase.h:430
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
virtual void setState(const AnyMap &state)
Set the state using an AnyMap containing any combination of properties supported by the thermodynamic...
Definition: SurfPhase.cpp:292
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
Definition: SurfPhase.cpp:67
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
Definition: SurfPhase.cpp:78
vector_fp m_speciesSize
Vector of species sizes (number of sites occupied). length m_kk.
Definition: SurfPhase.h:418
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
Definition: SurfPhase.cpp:86
virtual doublereal enthalpy_mole() const
Return the Molar Enthalpy. Units: J/kmol.
Definition: SurfPhase.cpp:42
virtual doublereal logStandardConc(size_t k=0) const
Natural logarithm of the standard concentration of the kth species.
Definition: SurfPhase.cpp:135
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
Definition: SurfPhase.cpp:104
void getCoverages(doublereal *theta) const
Return a vector of surface coverages.
Definition: SurfPhase.cpp:261
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
void setSiteDensity(doublereal n0)
Set the site density of the surface phase (kmol m-2)
Definition: SurfPhase.cpp:226
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
Definition: SurfPhase.cpp:73
virtual void getActivityConcentrations(doublereal *c) const
Return a vector of activity concentrations for each species.
Definition: SurfPhase.cpp:125
virtual void setParametersFromXML(const XML_Node &thermoData)
Set the Equation-of-State parameters by reading an XML Node Input.
Definition: SurfPhase.cpp:319
doublereal m_n0
Surface site density (kmol m-2)
Definition: SurfPhase.h:415
doublereal m_logn0
log of the surface site density
Definition: SurfPhase.h:421
vector_fp m_h0
Temporary storage for the reference state enthalpies.
Definition: SurfPhase.h:427
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 getPartialMolarCp(doublereal *cpbar) const
Return an array of partial molar heat capacities for the species in the mixture.
Definition: SurfPhase.cpp:94
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
virtual double size(size_t k) const
Returns the number of sites occupied by one molecule of species k.
Definition: SurfPhase.h:327
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 doublereal entropy_mole() const
Return the Molar Entropy. Units: J/kmol-K.
Definition: SurfPhase.cpp:56
vector_fp m_work
Temporary work array.
Definition: SurfPhase.h:439
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
Definition: SurfPhase.cpp:326
vector_fp m_mu0
Temporary storage for the reference state Gibbs energies.
Definition: SurfPhase.h:436
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 _updateThermo(bool force=false) const
Update the species reference state thermodynamic functions.
Definition: SurfPhase.cpp:303
virtual std::string type() const
String indicating the thermodynamic model implemented.
Definition: SurfPhase.h:171
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
Definition: SurfPhase.h:344
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
doublereal siteDensity()
Returns the site density.
Definition: SurfPhase.h:322
vector_fp m_cp0
Temporary storage for the reference state heat capacities.
Definition: SurfPhase.h:433
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 setParameters(int n, doublereal *const c)
Set the equation of state parameters from the argument list.
Definition: SurfPhase.cpp:140
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
Definition: SurfPhase.cpp:115
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 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
virtual doublereal intEnergy_mole() const
Return the Molar Internal Energy. Units: J/kmol.
Definition: SurfPhase.cpp:51
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
Definition: SurfPhase.h:353
vector_fp m_logsize
vector storing the log of the size of each species.
Definition: SurfPhase.h:446
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 doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
Definition: SurfPhase.cpp:130
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:102
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:104
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:180
std::map< std::string, double > compositionMap
Map connecting a string name with a double.
Definition: ct_defs.h:172
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264