Cantera  2.3.0
StoichSubstance.h
Go to the documentation of this file.
1 /**
2  * @file StoichSubstance.h
3  * Header file for the StoichSubstance class, which represents a fixed-composition
4  * incompressible substance (see \ref thermoprops and
5  * class \link Cantera::StoichSubstance StoichSubstance\endlink)
6  */
7 
8 // This file is part of Cantera. See License.txt in the top-level directory or
9 // at http://www.cantera.org/license.txt for license and copyright information.
10 
11 #ifndef CT_STOICHSUBSTANCE_H
12 #define CT_STOICHSUBSTANCE_H
13 
14 #include "SingleSpeciesTP.h"
15 
16 namespace Cantera
17 {
18 
19 //! Class StoichSubstance represents a stoichiometric (fixed composition)
20 //! incompressible substance.
21 /*!
22  * This class internally changes the independent degree of freedom from density
23  * to pressure. This is necessary because the phase is incompressible. It uses a
24  * constant volume approximation.
25  *
26  * ## Specification of Species Standard State Properties
27  *
28  * This class inherits from SingleSpeciesTP. It is assumed that the reference
29  * state thermodynamics may be obtained by a pointer to a populated species
30  * thermodynamic property manager class (see ThermoPhase::m_spthermo). How to
31  * relate pressure changes to the reference state thermodynamics is resolved at
32  * this level.
33  *
34  * For an incompressible, stoichiometric substance, the molar internal energy is
35  * independent of pressure. Since the thermodynamic properties are specified by
36  * giving the standard-state enthalpy, the term \f$ P_0 \hat v\f$ is subtracted
37  * from the specified molar enthalpy to compute the molar internal energy. The
38  * entropy is assumed to be independent of the pressure.
39  *
40  * The enthalpy function is given by the following relation.
41  *
42  * \f[
43  * h^o_k(T,P) =
44  * h^{ref}_k(T) + \tilde v \left( P - P_{ref} \right)
45  * \f]
46  *
47  * For an incompressible, stoichiometric substance, the molar internal energy is
48  * independent of pressure. Since the thermodynamic properties are specified by
49  * giving the standard-state enthalpy, the term \f$ P_{ref} \tilde v\f$ is
50  * subtracted from the specified reference molar enthalpy to compute the molar
51  * internal energy.
52  *
53  * \f[
54  * u^o_k(T,P) = h^{ref}_k(T) - P_{ref} \tilde v
55  * \f]
56  *
57  * The standard state heat capacity and entropy are independent of pressure. The
58  * standard state Gibbs free energy is obtained from the enthalpy and entropy
59  * functions.
60  *
61  * ## Specification of Solution Thermodynamic Properties
62  *
63  * All solution properties are obtained from the standard state species
64  * functions, since there is only one species in the phase.
65  *
66  * ## Application within Kinetics Managers
67  *
68  * The standard concentration is equal to 1.0. This means that the kinetics
69  * operator works on an (activities basis). Since this is a stoichiometric
70  * substance, this means that the concentration of this phase drops out of
71  * kinetics expressions.
72  *
73  * An example of a reaction using this is a sticking coefficient reaction of a
74  * substance in an ideal gas phase on a surface with a bulk phase species in
75  * this phase. In this case, the rate of progress for this reaction,
76  * \f$ R_s \f$, may be expressed via the following equation:
77  * \f[
78  * R_s = k_s C_{gas}
79  * \f]
80  * where the units for \f$ R_s \f$ are kmol m-2 s-1. \f$ C_{gas} \f$ has units
81  * of kmol m-3. Therefore, the kinetic rate constant, \f$ k_s \f$, has units of
82  * m s-1. Nowhere does the concentration of the bulk phase appear in the rate
83  * constant expression, since it's a stoichiometric phase and the activity is
84  * always equal to 1.0.
85  *
86  * ## Instantiation of the Class
87  *
88  * The constructor for this phase is NOT located in the default ThermoFactory
89  * for %Cantera. However, a new StoichSubstance may be created by
90  * the following code snippets:
91  *
92  * @code
93  * XML_Node *xm = get_XML_NameID("phase", iFile + "#NaCl(S)", 0);
94  * StoichSubstance *solid = new StoichSubstance(*xm);
95  * @endcode
96  *
97  * or by the following call to importPhase():
98  *
99  * @code
100  * XML_Node *xm = get_XML_NameID("phase", iFile + "#NaCl(S)", 0);
101  * StoichSubstance solid;
102  * importPhase(*xm, &solid);
103  * @endcode
104  *
105  * ## XML Example
106  *
107  * The phase model name for this is called StoichSubstance. It must be supplied
108  * as the model attribute of the thermo XML element entry. Within the phase XML
109  * block, the density of the phase must be specified. An example of an XML file
110  * this phase is given below.
111  *
112  * @code
113  * <!-- phase NaCl(S) -->
114  * <phase dim="3" id="NaCl(S)">
115  * <elementArray datasrc="elements.xml">
116  * Na Cl
117  * </elementArray>
118  * <speciesArray datasrc="#species_NaCl(S)"> NaCl(S) </speciesArray>
119  * <thermo model="StoichSubstance">
120  * <density units="g/cm3">2.165</density>
121  * </thermo>
122  * <transport model="None"/>
123  * <kinetics model="none"/>
124  * </phase>
125  *
126  * <!-- species definitions -->
127  * <speciesData id="species_NaCl(S)">
128  * <!-- species NaCl(S) -->
129  * <species name="NaCl(S)">
130  * <atomArray> Na:1 Cl:1 </atomArray>
131  * <thermo>
132  * <Shomate Pref="1 bar" Tmax="1075.0" Tmin="250.0">
133  * <floatArray size="7">
134  * 50.72389, 6.672267, -2.517167,
135  * 10.15934, -0.200675, -427.2115,
136  * 130.3973
137  * </floatArray>
138  * </Shomate>
139  * </thermo>
140  * <density units="g/cm3">2.165</density>
141  * </species>
142  * </speciesData> @endcode
143  *
144  * The model attribute, "StoichSubstance", on the thermo element
145  * identifies the phase as being a StoichSubstance object.
146  *
147  * @ingroup thermoprops
148  */
150 {
151 public:
152  //! Default constructor for the StoichSubstance class
154 
155  //! Construct and initialize a StoichSubstance ThermoPhase object directly
156  //! from an ASCII input file
157  /*!
158  * @param infile name of the input file
159  * @param id name of the phase id in the file.
160  * If this is blank, the first phase in the file is used.
161  */
162  StoichSubstance(const std::string& infile, const std::string& id = "");
163 
164  //! Construct and initialize a StoichSubstance ThermoPhase object directly
165  //! from an XML database
166  /*!
167  * @param phaseRef XML node pointing to a StoichSubstance description
168  * @param id Id of the phase.
169  */
170  StoichSubstance(XML_Node& phaseRef, const std::string& id = "");
171 
172  StoichSubstance(const StoichSubstance& right);
173  StoichSubstance& operator=(const StoichSubstance& right);
174  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
175 
176  /**
177  * Equation of state flag.
178  *
179  * Returns the value cStoichSubstance, defined in mix_defs.h.
180  * @deprecated To be removed after Cantera 2.3.
181  */
182  virtual int eosType() const;
183  virtual std::string type() const {
184  return "StoichSubstance";
185  }
186 
187  //! @name Mechanical Equation of State
188  //! @{
189 
190  //! Report the Pressure. Units: Pa.
191  /*!
192  * For an incompressible substance, the density is independent of pressure.
193  * This method simply returns the stored pressure value.
194  */
195  virtual doublereal pressure() const;
196 
197  //! Set the pressure at constant temperature. Units: Pa.
198  /*!
199  * For an incompressible substance, the density is independent of pressure.
200  * Therefore, this method only stores the specified pressure value. It does
201  * not modify the density.
202  *
203  * @param p Pressure (units - Pa)
204  */
205  virtual void setPressure(doublereal p);
206 
207  virtual doublereal isothermalCompressibility() const;
208  virtual doublereal thermalExpansionCoeff() const;
209 
210  /**
211  * @}
212  * @name Activities, Standard States, and Activity Concentrations
213  *
214  * This section is largely handled by parent classes, since there
215  * is only one species. Therefore, the activity is equal to one.
216  * @{
217  */
218 
219  //! This method returns an array of generalized concentrations
220  /*!
221  * \f$ C^a_k\f$ are defined such that \f$ a_k = C^a_k / C^0_k, \f$ where
222  * \f$ C^0_k \f$ is a standard concentration defined below and \f$ a_k \f$
223  * are activities used in the thermodynamic functions. These activity (or
224  * generalized) concentrations are used by kinetics manager classes to
225  * compute the forward and reverse rates of elementary reactions.
226  *
227  * For a stoichiometric substance, there is only one species, and the
228  * generalized concentration is 1.0.
229  *
230  * @param c Output array of generalized concentrations. The
231  * units depend upon the implementation of the
232  * reaction rate expressions within the phase.
233  */
234  virtual void getActivityConcentrations(doublereal* c) const;
235 
236  //! Return the standard concentration for the kth species
237  /*!
238  * The standard concentration \f$ C^0_k \f$ used to normalize the activity
239  * (i.e., generalized) concentration. This phase assumes that the kinetics
240  * operator works on an dimensionless basis. Thus, the standard
241  * concentration is equal to 1.0.
242  *
243  * @param k Optional parameter indicating the species. The default
244  * is to assume this refers to species 0.
245  * @return
246  * Returns The standard Concentration as 1.0
247  */
248  virtual doublereal standardConcentration(size_t k=0) const;
249  virtual doublereal logStandardConc(size_t k=0) const;
250 
251  //! Get the array of chemical potentials at unit activity for the species at
252  //! their standard states at the current *T* and *P* of the solution.
253  /*!
254  * For a stoichiometric substance, there is no activity term in the chemical
255  * potential expression, and therefore the standard chemical potential and
256  * the chemical potential are both equal to the molar Gibbs function.
257  *
258  * These are the standard state chemical potentials \f$ \mu^0_k(T,P) \f$.
259  * The values are evaluated at the current temperature and pressure of the
260  * solution
261  *
262  * @param mu0 Output vector of chemical potentials.
263  * Length: m_kk.
264  */
265  virtual void getStandardChemPotentials(doublereal* mu0) const;
266 
267  //@}
268  /// @name Properties of the Standard State of the Species in the Solution
269  //@{
270 
271  virtual void getEnthalpy_RT(doublereal* hrt) const;
272  virtual void getEntropy_R(doublereal* sr) const;
273  virtual void getGibbs_RT(doublereal* grt) const;
274  virtual void getCp_R(doublereal* cpr) const;
275 
276  //! Returns the vector of nondimensional Internal Energies of the standard
277  //! state species at the current *T* and *P* of the solution
278  /*!
279  * For an incompressible, stoichiometric substance, the molar internal
280  * energy is independent of pressure. Since the thermodynamic properties
281  * are specified by giving the standard-state enthalpy, the term
282  * \f$ P_{ref} \hat v\f$ is subtracted from the specified reference molar
283  * enthalpy to compute the standard state molar internal energy.
284  *
285  * @param urt output vector of nondimensional standard state
286  * internal energies of the species. Length: m_kk.
287  */
288  virtual void getIntEnergy_RT(doublereal* urt) const;
289 
290  //@}
291  /// @name Thermodynamic Values for the Species Reference States
292  //@{
293 
294  //! Returns the vector of nondimensional internal Energies of the reference
295  //! state at the current temperature of the solution and the reference
296  //! pressure for each species.
297  /*!
298  * @param urt Output vector of nondimensional reference state internal
299  * energies of the species. Length: m_kk
300  */
301  virtual void getIntEnergy_RT_ref(doublereal* urt) const;
302  // @}
303 
304  virtual void initThermo();
305  virtual void initThermoXML(XML_Node& phaseNode, const std::string& id);
306 
307  //! Set the equation of state parameters
308  /*!
309  * @internal
310  *
311  * @param n number of parameters
312  * @param c array of \a n coefficients
313  * c[0] = density of phase [ kg/m3 ]
314  */
315  virtual void setParameters(int n, doublereal* const c);
316 
317  //! Get the equation of state parameters in a vector
318  /*!
319  * @internal
320  *
321  * @param n number of parameters
322  * @param c array of \a n coefficients
323  *
324  * For this phase:
325  * - n = 1
326  * - c[0] = density of phase [ kg/m3 ]
327  */
328  virtual void getParameters(int& n, doublereal* const c) const;
329 
330  //! Set equation of state parameter values from XML entries.
331  /*!
332  * For this phase, the density of the phase is specified in this block.
333  *
334  * @param eosdata An XML_Node object corresponding to
335  * the "thermo" entry for this phase in the input file.
336  *
337  * eosdata points to the thermo block, and looks like this:
338  *
339  * @code
340  * <phase id="stoichsolid" >
341  * <thermo model="StoichSubstance">
342  * <density units="g/cm3">3.52</density>
343  * </thermo>
344  * </phase>
345  * @endcode
346  */
347  virtual void setParametersFromXML(const XML_Node& eosdata);
348 };
349 
350 }
351 
352 #endif
virtual void getGibbs_RT(doublereal *grt) const
Get the nondimensional Gibbs functions for the species in their standard states at the current T and ...
virtual void getParameters(int &n, doublereal *const c) const
Get the equation of state parameters in a vector.
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
virtual int eosType() const
Equation of state flag.
virtual void setPressure(doublereal p)
Set the pressure at constant temperature. Units: Pa.
Class StoichSubstance represents a stoichiometric (fixed composition) incompressible substance...
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:93
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
virtual void getIntEnergy_RT_ref(doublereal *urt) const
Returns the vector of nondimensional internal Energies of the reference state at the current temperat...
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
virtual doublereal pressure() const
Report the Pressure. Units: Pa.
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
Header for the SingleSpeciesTP class, which is a filter class for ThermoPhase, that eases the constru...
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
StoichSubstance()
Default constructor for the StoichSubstance class.
virtual void getIntEnergy_RT(doublereal *urt) const
Returns the vector of nondimensional Internal Energies of the standard state species at the current T...
virtual void setParameters(int n, doublereal *const c)
Set the equation of state parameters.
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
virtual void getStandardChemPotentials(doublereal *mu0) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
Namespace for the Cantera kernel.
Definition: application.cpp:29
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
virtual std::string type() const
String indicating the thermodynamic model implemented.
virtual doublereal logStandardConc(size_t k=0) const
Natural logarithm of the standard concentration of the kth species.
The SingleSpeciesTP class is a filter class for ThermoPhase.
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.