Cantera  3.3.0a1
Loading...
Searching...
No Matches
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
17namespace 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 * While the site coverage fractions @f$ \theta_k @f$ are generally used to describe the
31 * composition of surface phases, %Cantera represents the state internally in terms of
32 * mass fractions for consistency with other phase models. Mole fractions are computed
33 * from coverages as:
34 * @f[
35 * X_k = \frac{ \theta_k / s_k }{ \sum_i \theta_i / s_i }
36 * @f]
37 * where @f$ s_k @f$ is the number of sites occupied by species @f$ k @f$. Mass
38 * fractions and the mean molecular weight are then computed in the typical manner.
39 *
40 * The mass density of a surface phase is defined to have units of kg/m². It is computed
41 * as:
42 * @f[
43 * \rho = \frac{ n_0 \overline{W} }{ \sum X_k s_k }
44 * @f]
45 *
46 * ## Specification of Species Standard State Properties
47 *
48 * It is assumed that the reference state thermodynamics may be obtained by a
49 * pointer to a populated species thermodynamic property manager class (see
50 * ThermoPhase::m_spthermo). How to relate pressure changes to the reference
51 * state thermodynamics is resolved at this level.
52 *
53 * Pressure is defined as an independent variable in this phase. However, it has
54 * no effect on any quantities, as the molar concentration is a constant.
55 *
56 * Therefore, The standard state internal energy for species *k* is equal to the
57 * enthalpy for species *k*.
58 *
59 * @f[
60 * u^o_k = h^o_k
61 * @f]
62 *
63 * Also, the standard state chemical potentials, entropy, and heat capacities
64 * are independent of pressure. The standard state Gibbs free energy is obtained
65 * from the enthalpy and entropy functions.
66 *
67 * ## Specification of Solution Thermodynamic Properties
68 *
69 * The activity of species defined in the phase is given by
70 * @f[
71 * a_k = \theta_k
72 * @f]
73 *
74 * The chemical potential for species *k* is equal to
75 * @f[
76 * \mu_k(T,P) = \mu^o_k(T) + R T \ln \theta_k
77 * @f]
78 *
79 * Pressure is defined as an independent variable in this phase. However, it has
80 * no effect on any quantities, as the molar concentration is a constant.
81 *
82 * The internal energy for species k is equal to the enthalpy for species *k*
83 * @f[
84 * u_k = h_k
85 * @f]
86 *
87 * The entropy for the phase is given by the following relation, which is
88 * independent of the pressure:
89 *
90 * @f[
91 * s_k(T,P) = s^o_k(T) - R \ln \theta_k
92 * @f]
93 *
94 * ## Application within Kinetics Managers
95 *
96 * The activity concentration,@f$ C^a_k @f$, used by the kinetics manager, is equal to
97 * the actual concentration, @f$ C^s_k @f$, and is given as:
98 * @f[
99 * C^a_k = C^s_k = \frac{\theta_k n_0}{s_k}
100 * = \frac{\rho X_k}{\overline{W}} = \rho \frac{Y_k}{W_k}
101 * @f]
102 *
103 * The standard concentration for species *k* is:
104 * @f[
105 * C^0_k = \frac{n_0}{s_k}
106 * @f]
107 *
108 * An example phase definition is given in the
109 * [YAML API Reference](../yaml/phases.html#ideal-surface").
110 *
111 * @ingroup thermoprops
112 */
113class SurfPhase : public ThermoPhase
114{
115public:
116 //! Construct and initialize a SurfPhase ThermoPhase object directly from an
117 //! input file
118 /*!
119 * @param infile name of the input file. If blank, an empty phase will be created.
120 * @param id name of the phase id in the file.
121 * If this is blank, the first phase in the file is used.
122 */
123 explicit SurfPhase(const string& infile="", const string& id="");
124
125 string type() const override {
126 return "ideal-surface";
127 }
128
129 bool isCompressible() const override {
130 return false;
131 }
132
133 //! Return the Molar Enthalpy. Units: J/kmol.
134 /*!
135 * For an ideal solution,
136 * @f[
137 * \hat h(T,P) = \sum_k X_k \hat h^0_k(T),
138 * @f]
139 * and is a function only of temperature. The standard-state pure-species
140 * Enthalpies @f$ \hat h^0_k(T) @f$ are computed by the species
141 * thermodynamic property manager.
142 *
143 * @see MultiSpeciesThermo
144 */
145 double enthalpy_mole() const override;
146
147 //! Return the Molar Internal Energy. Units: J/kmol
148 /**
149 * For a surface phase, the pressure is not a relevant thermodynamic
150 * variable, and so the Enthalpy is equal to the Internal Energy.
151 */
152 double intEnergy_mole() const override;
153
154 //! Return the Molar Entropy. Units: J/kmol-K
155 /**
156 * @f[
157 * \hat s(T,P) = \sum_k X_k (\hat s^0_k(T) - R \ln \theta_k)
158 * @f]
159 */
160 double entropy_mole() const override;
161
162 double cp_mole() const override;
163 double cv_mole() const override;
164
165 void getChemPotentials(double* mu) const override;
166 void getPartialMolarEnthalpies(double* hbar) const override;
167 void getPartialMolarEntropies(double* sbar) const override;
168 void getPartialMolarCp(double* cpbar) const override;
169 void getPartialMolarVolumes(double* vbar) const override;
170 void getStandardChemPotentials(double* mu0) const override;
171
172 //! Return a vector of activity concentrations for each species
173 /*!
174 * For this phase the activity concentrations,@f$ C^a_k @f$, are defined to
175 * be equal to the actual concentrations, @f$ C^s_k @f$. Activity
176 * concentrations are
177 *
178 * @f[
179 * C^a_k = C^s_k = \frac{\theta_k n_0}{s_k}
180 * @f]
181 *
182 * where @f$ \theta_k @f$ is the surface site fraction for species k,
183 * @f$ n_0 @f$ is the surface site density for the phase, and
184 * @f$ s_k @f$ is the surface size of species k.
185 *
186 * @f$ C^a_k @f$ that are defined such that @f$ a_k = C^a_k / C^0_k, @f$
187 * where @f$ C^0_k @f$ is a standard concentration defined below and @f$ a_k
188 * @f$ are activities used in the thermodynamic functions. These activity
189 * concentrations are used by kinetics manager classes to compute the
190 * forward and reverse rates of elementary reactions. Note that they may or
191 * may not have units of concentration --- they might be partial pressures,
192 * mole fractions, or surface coverages,
193 *
194 * @param c vector of activity concentration (kmol m-2).
195 */
196 void getActivityConcentrations(double* c) const override;
197
198 //! Return the standard concentration for the kth species
199 /*!
200 * The standard concentration @f$ C^0_k @f$ used to normalize the activity
201 * (that is, generalized) concentration. For this phase, the standard
202 * concentration is species- specific
203 *
204 * @f[
205 * C^0_k = \frac{n_0}{s_k}
206 * @f]
207 *
208 * This definition implies that the activity is equal to @f$ \theta_k @f$.
209 *
210 * @param k Optional parameter indicating the species. The default
211 * is to assume this refers to species 0.
212 * @return the standard concentration in units of kmol/m^2 for surface phases or
213 * kmol/m for edge phases.
214 */
215 double standardConcentration(size_t k=0) const override;
216 double logStandardConc(size_t k=0) const override;
217
218 void initThermo() override;
219 void getParameters(AnyMap& phaseNode) const override;
220
221 bool addSpecies(shared_ptr<Species> spec) override;
222
223 //! Since interface phases have no volume, this returns 0.0.
224 double molarVolume() const override {
225 return 0.0;
226 }
227
228 //! Returns the site density
229 /*!
230 * Site density kmol m-2
231 */
232 double siteDensity() const {
233 return m_n0;
234 }
235
236 //! Returns the number of sites occupied by one molecule of species *k*.
237 double size(size_t k) const {
238 return m_speciesSize[k];
239 }
240
241 //! Set the site density of the surface phase (kmol m-2)
242 /*!
243 * @param n0 Site density of the surface phase (kmol m-2)
244 */
245 void setSiteDensity(double n0);
246
247 void getGibbs_RT(double* grt) const override;
248 void getEnthalpy_RT(double* hrt) const override;
249 void getEntropy_R(double* sr) const override;
250 void getCp_R(double* cpr) const override;
251 void getStandardVolumes(double* vol) const override;
252
253 //! Return the thermodynamic pressure (Pa).
254 double pressure() const override {
255 return m_press;
256 }
257
258 //! Set the internally stored pressure (Pa) at constant temperature and
259 //! composition
260 /*!
261 * @param p input Pressure (Pa)
262 */
263 void setPressure(double p) override {
264 m_press = p;
265 }
266
267 void getGibbs_RT_ref(double* grt) const override;
268 void getEnthalpy_RT_ref(double* hrt) const override;
269 void getEntropy_R_ref(double* er) const override;
270 void getCp_R_ref(double* cprt) const override;
271
272 //! Set the surface site fractions to a specified state.
273 /*!
274 * This routine converts to concentrations in kmol/m2, using m_n0, the
275 * surface site density, and size(k), which is defined to be the number of
276 * surface sites occupied by the kth molecule. It then calls
277 * Phase::setConcentrations to set the internal concentration in the object.
278 *
279 * @param theta This is the surface site fraction for the kth species in
280 * the surface phase. This is a dimensionless quantity.
281 *
282 * This routine normalizes the theta's to 1, before application
283 */
284 void setCoverages(const double* theta);
285
286 //! Set the surface site fractions to a specified state.
287 /*!
288 * This routine converts to concentrations in kmol/m2, using m_n0, the
289 * surface site density, and size(k), which is defined to be the number of
290 * surface sites occupied by the kth molecule. It then calls
291 * Phase::setConcentrations to set the internal concentration in the object.
292 *
293 * @param theta This is the surface site fraction for the kth species in
294 * the surface phase. This is a dimensionless quantity.
295 */
296 void setCoveragesNoNorm(const double* theta);
297
298 //! Set the coverages from a string of colon-separated name:value pairs.
299 /*!
300 * @param cov String containing colon-separated name:value pairs
301 */
302 void setCoveragesByName(const string& cov);
303
304 //! Set the coverages from a map of name:value pairs
305 void setCoveragesByName(const Composition& cov);
306
307 //! Return a vector of surface coverages
308 /*!
309 * Get the coverages. These are calculated from the mole fractions as
310 * @f[
311 * \theta_k = \frac{ X_k s_k }{ \sum X_j s_j }
312 * @f]
313 *
314 * @param theta Array theta must be at least as long as the number of
315 * species.
316 */
317 void getCoverages(double* theta) const;
318
319 //! @copydoc ThermoPhase::setState
320 /*!
321 * Additionally uses the key `coverages` to set the fractional coverages.
322 */
323 void setState(const AnyMap& state) override;
324
325protected:
326 void compositionChanged() override;
327
328 //! Surface site density (kmol m-2)
329 double m_n0 = 1.0;
330
331 //! Vector of species sizes (number of sites occupied). length m_kk.
332 vector<double> m_speciesSize;
333
334 //! log of the surface site density
335 double m_logn0;
336
337 //! Current value of the pressure (Pa)
338 double m_press = OneAtm;
339
340 //! Temporary storage for the reference state enthalpies
341 mutable vector<double> m_h0;
342
343 //! Temporary storage for the reference state entropies
344 mutable vector<double> m_s0;
345
346 //! Temporary storage for the reference state heat capacities
347 mutable vector<double> m_cp0;
348
349 //! Temporary storage for the reference state Gibbs energies
350 mutable vector<double> m_mu0;
351
352 //! Temporary work array
353 mutable vector<double> m_work;
354
355 //! vector storing the log of the size of each species.
356 /*!
357 * The size of each species is defined as the number of surface sites each
358 * species occupies.
359 */
360 mutable vector<double> m_logsize;
361
362 //! Update the species reference state thermodynamic functions
363 /*!
364 * The polynomials for the standard state functions are only reevaluated if
365 * the temperature has changed.
366 *
367 * @param force Boolean, which if true, forces a reevaluation of the thermo
368 * polynomials. default = false.
369 */
370 void _updateThermo(bool force=false) const;
371};
372
373}
374
375#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:431
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
Definition SurfPhase.h:114
double molarVolume() const override
Since interface phases have no volume, this returns 0.0.
Definition SurfPhase.h:224
void getStandardChemPotentials(double *mu0) const override
Get the array of chemical potentials at unit activity for the species at their standard states at the...
Definition SurfPhase.cpp:97
double enthalpy_mole() const override
Return the Molar Enthalpy. Units: J/kmol.
Definition SurfPhase.cpp:28
void setSiteDensity(double n0)
Set the site density of the surface phase (kmol m-2)
double logStandardConc(size_t k=0) const override
Natural logarithm of the standard concentration of the kth species.
void setState(const AnyMap &state) override
Set the state using an AnyMap containing any combination of properties supported by the thermodynamic...
void getPartialMolarEnthalpies(double *hbar) const override
Returns an array of partial molar enthalpies for the species in the mixture.
Definition SurfPhase.cpp:64
void getChemPotentials(double *mu) const override
Get the species chemical potentials. Units: J/kmol.
double pressure() const override
Return the thermodynamic pressure (Pa).
Definition SurfPhase.h:254
bool isCompressible() const override
Return whether phase represents a compressible substance.
Definition SurfPhase.h:129
void getEntropy_R(double *sr) const override
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
vector< double > m_logsize
vector storing the log of the size of each species.
Definition SurfPhase.h:360
vector< double > m_work
Temporary work array.
Definition SurfPhase.h:353
void getCp_R(double *cpr) const override
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
void getParameters(AnyMap &phaseNode) const override
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using ...
string type() const override
String indicating the thermodynamic model implemented.
Definition SurfPhase.h:125
void initThermo() override
Initialize the ThermoPhase object after all species have been set up.
void getActivityConcentrations(double *c) const override
Return a vector of activity concentrations for each species.
double m_n0
Surface site density (kmol m-2)
Definition SurfPhase.h:329
double size(size_t k) const
Returns the number of sites occupied by one molecule of species k.
Definition SurfPhase.h:237
void setPressure(double p) override
Set the internally stored pressure (Pa) at constant temperature and composition.
Definition SurfPhase.h:263
vector< double > m_h0
Temporary storage for the reference state enthalpies.
Definition SurfPhase.h:341
void getPartialMolarVolumes(double *vbar) const override
Return an array of partial molar volumes for the species in the mixture.
Definition SurfPhase.cpp:92
double cv_mole() const override
Molar heat capacity at constant volume and composition [J/kmol/K].
Definition SurfPhase.cpp:59
vector< double > m_s0
Temporary storage for the reference state entropies.
Definition SurfPhase.h:344
void setCoverages(const double *theta)
Set the surface site fractions to a specified state.
vector< double > m_cp0
Temporary storage for the reference state heat capacities.
Definition SurfPhase.h:347
vector< double > m_speciesSize
Vector of species sizes (number of sites occupied). length m_kk.
Definition SurfPhase.h:332
double m_press
Current value of the pressure (Pa)
Definition SurfPhase.h:338
double siteDensity() const
Returns the site density.
Definition SurfPhase.h:232
void getEnthalpy_RT(double *hrt) const override
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
void getEntropy_R_ref(double *er) const override
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
void getGibbs_RT(double *grt) const override
Get the nondimensional Gibbs functions for the species in their standard states at the current T and ...
double intEnergy_mole() const override
Return the Molar Internal Energy. Units: J/kmol.
Definition SurfPhase.cpp:37
double entropy_mole() const override
Return the Molar Entropy. Units: J/kmol-K.
Definition SurfPhase.cpp:42
void _updateThermo(bool force=false) const
Update the species reference state thermodynamic functions.
void getCp_R_ref(double *cprt) const override
Returns the vector of nondimensional constant pressure heat capacities of the reference state at the ...
void getStandardVolumes(double *vol) const override
Get the molar volumes of the species standard states at the current T and P of the solution.
void setCoveragesNoNorm(const double *theta)
Set the surface site fractions to a specified state.
void getCoverages(double *theta) const
Return a vector of surface coverages.
double cp_mole() const override
Molar heat capacity at constant pressure and composition [J/kmol/K].
Definition SurfPhase.cpp:53
void getPartialMolarCp(double *cpbar) const override
Return an array of partial molar heat capacities for the species in the mixture.
Definition SurfPhase.cpp:82
void compositionChanged() override
Apply changes to the state which are needed after the composition changes.
double standardConcentration(size_t k=0) const override
Return the standard concentration for the kth species.
vector< double > m_mu0
Temporary storage for the reference state Gibbs energies.
Definition SurfPhase.h:350
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
void setCoveragesByName(const string &cov)
Set the coverages from a string of colon-separated name:value pairs.
void getGibbs_RT_ref(double *grt) const override
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
double m_logn0
log of the surface site density
Definition SurfPhase.h:335
void getPartialMolarEntropies(double *sbar) const override
Returns an array of partial molar entropies of the species in the solution.
Definition SurfPhase.cpp:72
void getEnthalpy_RT_ref(double *hrt) const override
Returns the vector of nondimensional enthalpies of the reference state at the current temperature of ...
Base class for a phase with thermodynamic properties.
const double OneAtm
One atmosphere [Pa].
Definition ct_defs.h:96
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
map< string, double > Composition
Map from string names to doubles.
Definition ct_defs.h:177