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