Cantera  2.4.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  virtual std::string type() const {
173  return "StoichSubstance";
174  }
175 
176  //! @name Mechanical Equation of State
177  //! @{
178 
179  //! Report the Pressure. Units: Pa.
180  /*!
181  * For an incompressible substance, the density is independent of pressure.
182  * This method simply returns the stored pressure value.
183  */
184  virtual doublereal pressure() const;
185 
186  //! Set the pressure at constant temperature. Units: Pa.
187  /*!
188  * For an incompressible substance, the density is independent of pressure.
189  * Therefore, this method only stores the specified pressure value. It does
190  * not modify the density.
191  *
192  * @param p Pressure (units - Pa)
193  */
194  virtual void setPressure(doublereal p);
195 
196  virtual doublereal isothermalCompressibility() const;
197  virtual doublereal thermalExpansionCoeff() const;
198 
199  /**
200  * @}
201  * @name Activities, Standard States, and Activity Concentrations
202  *
203  * This section is largely handled by parent classes, since there
204  * is only one species. Therefore, the activity is equal to one.
205  * @{
206  */
207 
208  //! This method returns an array of generalized concentrations
209  /*!
210  * \f$ C^a_k\f$ are defined such that \f$ a_k = C^a_k / C^0_k, \f$ where
211  * \f$ C^0_k \f$ is a standard concentration defined below and \f$ a_k \f$
212  * are activities used in the thermodynamic functions. These activity (or
213  * generalized) concentrations are used by kinetics manager classes to
214  * compute the forward and reverse rates of elementary reactions.
215  *
216  * For a stoichiometric substance, there is only one species, and the
217  * generalized concentration is 1.0.
218  *
219  * @param c Output array of generalized concentrations. The
220  * units depend upon the implementation of the
221  * reaction rate expressions within the phase.
222  */
223  virtual void getActivityConcentrations(doublereal* c) const;
224 
225  //! Return the standard concentration for the kth species
226  /*!
227  * The standard concentration \f$ C^0_k \f$ used to normalize the activity
228  * (i.e., generalized) concentration. This phase assumes that the kinetics
229  * operator works on an dimensionless basis. Thus, the standard
230  * concentration is equal to 1.0.
231  *
232  * @param k Optional parameter indicating the species. The default
233  * is to assume this refers to species 0.
234  * @return
235  * Returns The standard Concentration as 1.0
236  */
237  virtual doublereal standardConcentration(size_t k=0) const;
238  virtual doublereal logStandardConc(size_t k=0) const;
239 
240  //! Get the array of chemical potentials at unit activity for the species at
241  //! their standard states at the current *T* and *P* of the solution.
242  /*!
243  * For a stoichiometric substance, there is no activity term in the chemical
244  * potential expression, and therefore the standard chemical potential and
245  * the chemical potential are both equal to the molar Gibbs function.
246  *
247  * These are the standard state chemical potentials \f$ \mu^0_k(T,P) \f$.
248  * The values are evaluated at the current temperature and pressure of the
249  * solution
250  *
251  * @param mu0 Output vector of chemical potentials.
252  * Length: m_kk.
253  */
254  virtual void getStandardChemPotentials(doublereal* mu0) const;
255 
256  //@}
257  /// @name Properties of the Standard State of the Species in the Solution
258  //@{
259 
260  virtual void getEnthalpy_RT(doublereal* hrt) const;
261  virtual void getEntropy_R(doublereal* sr) const;
262  virtual void getGibbs_RT(doublereal* grt) const;
263  virtual void getCp_R(doublereal* cpr) const;
264 
265  //! Returns the vector of nondimensional Internal Energies of the standard
266  //! state species at the current *T* and *P* of the solution
267  /*!
268  * For an incompressible, stoichiometric substance, the molar internal
269  * energy is independent of pressure. Since the thermodynamic properties
270  * are specified by giving the standard-state enthalpy, the term
271  * \f$ P_{ref} \hat v\f$ is subtracted from the specified reference molar
272  * enthalpy to compute the standard state molar internal energy.
273  *
274  * @param urt output vector of nondimensional standard state
275  * internal energies of the species. Length: m_kk.
276  */
277  virtual void getIntEnergy_RT(doublereal* urt) const;
278 
279  //@}
280  /// @name Thermodynamic Values for the Species Reference States
281  //@{
282 
283  //! Returns the vector of nondimensional internal Energies of the reference
284  //! state at the current temperature of the solution and the reference
285  //! pressure for each species.
286  /*!
287  * @param urt Output vector of nondimensional reference state internal
288  * energies of the species. Length: m_kk
289  */
290  virtual void getIntEnergy_RT_ref(doublereal* urt) const;
291  // @}
292 
293  virtual void initThermo();
294  virtual void initThermoXML(XML_Node& phaseNode, const std::string& id);
295 
296  //! Set the equation of state parameters
297  /*!
298  * @internal
299  *
300  * @param n number of parameters
301  * @param c array of \a n coefficients
302  * c[0] = density of phase [ kg/m3 ]
303  */
304  virtual void setParameters(int n, doublereal* const c);
305 
306  //! Get the equation of state parameters in a vector
307  /*!
308  * @internal
309  *
310  * @param n number of parameters
311  * @param c array of \a n coefficients
312  *
313  * For this phase:
314  * - n = 1
315  * - c[0] = density of phase [ kg/m3 ]
316  */
317  virtual void getParameters(int& n, doublereal* const c) const;
318 
319  //! Set equation of state parameter values from XML entries.
320  /*!
321  * For this phase, the density of the phase is specified in this block.
322  *
323  * @param eosdata An XML_Node object corresponding to
324  * the "thermo" entry for this phase in the input file.
325  *
326  * eosdata points to the thermo block, and looks like this:
327  *
328  * @code
329  * <phase id="stoichsolid" >
330  * <thermo model="StoichSubstance">
331  * <density units="g/cm3">3.52</density>
332  * </thermo>
333  * </phase>
334  * @endcode
335  */
336  virtual void setParametersFromXML(const XML_Node& eosdata);
337 };
338 
339 }
340 
341 #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 void setPressure(doublereal p)
Set the pressure at constant temperature. Units: Pa.
Class StoichSubstance represents a stoichiometric (fixed composition) incompressible substance...
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 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: AnyMap.cpp:8
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.