Cantera  2.2.1
SpeciesThermo.h
Go to the documentation of this file.
1 /**
2  * @file SpeciesThermo.h
3  * Virtual base class for the calculation of multiple-species thermodynamic
4  * reference-state property managers and text for the mgrsrefcalc module (see \ref mgrsrefcalc
6  */
7 // Copyright 2001 California Institute of Technology
8
9 #ifndef CT_SPECIESTHERMO_H
10 #define CT_SPECIESTHERMO_H
11
12 #include "cantera/base/ct_defs.h"
13 #include "cantera/base/smart_ptr.h"
14
15 namespace Cantera
16 {
17 class SpeciesThermoInterpType;
18
19 /**
20  * @defgroup mgrsrefcalc Managers for Calculating Reference-State Thermodynamics
21  *
22  * The ThermoPhase object relies on a set of manager classes to calculate
23  * the thermodynamic properties of the reference state for all
24  * of the species in the phase. This may be a computationally
25  * significant cost, so efficiency is important.
26  * This group describes how this is done efficiently within Cantera.
27  *
28  * To compute the thermodynamic properties of multicomponent
29  * solutions, it is necessary to know something about the
30  * thermodynamic properties of the individual species present in
31  * the solution. Exactly what sort of species properties are
32  * required depends on the thermodynamic model for the
33  * solution. For a gaseous solution (i.e., a gas mixture), the
34  * species properties required are usually ideal gas properties at
35  * the mixture temperature and at a reference pressure (almost always at
36  * 1 bar).
37  *
38  * In defining these standard states for species in a phase, we make
39  * the following definition. A reference state is a standard state
40  * of a species in a phase limited to one particular pressure, the reference
41  * pressure. The reference state specifies the dependence of all
42  * thermodynamic functions as a function of the temperature, in
43  * between a minimum temperature and a maximum temperature. The
44  * reference state also specifies the molar volume of the species
45  * as a function of temperature. The molar volume is a thermodynamic
46  * function. By contrast, a full standard state does the same thing
47  * as a reference state, but specifies the thermodynamics functions
48  * at all pressures.
49  *
50  * Whatever the conventions used by a particular solution model,
51  * means need to be provided to compute the species properties in
52  * the reference state. Class SpeciesThermo is the base class
53  * for a family of classes that compute properties of all
54  * species in a phase in their reference states, for a range of temperatures.
55  * Note, the pressure dependence of the species thermodynamic functions is not
56  * handled by this particular species thermodynamic model. SpeciesThermo
57  * calculates the reference-state thermodynamic values of all species in a single
58  * phase during each call. The vector nature of the operation leads to
59  * a lower operation count and better efficiency, especially if the
60  * individual reference state classes are known to the reference-state
61  * manager class so that common operations may be grouped together.
62  *
63  * The most important member function for the SpeciesThermo class
65  * The function calculates the values of Cp, H, and S for all of the
66  * species at once at the specified temperature.
67  *
68  * Usually, all of the species in a phase are installed into a SpeciesThermo
69  * class. However, there is no requirement that a SpeciesThermo
70  * object handles all of the species in a phase. There are
71  * two member functions that are called to install each species into
72  * the SpeciesThermo.
74  * It is called with the index of the species in the phase,
75  * an integer type delineating
76  * the SpeciesThermoInterpType object, and a listing of the
77  * parameters for that parameterization. A factory routine is called based
78  * on the integer type. The other routine is called
80  * It accepts as an argument a pointer to an already formed
81  * SpeciesThermoInterpType object.
82  *
83  * The following classes inherit from SpeciesThermo. Each of these classes
84  * handle multiple species, usually all of the species in a phase. However,
85  * there is no requirement that a SpeciesThermo object handles all of the
86  * species in a phase.
87  *
88  * - NasaThermo in file NasaThermo.h
89  * - This is a two zone model, with each zone consisting of a 7
90  * coefficient NASA Polynomial format.
91  * - ShomateThermo in file ShomateThermo.h
92  * - This is a two zone model, with each zone consisting of a 7
93  * coefficient Shomate Polynomial format.
94  * - SimpleThermo in file SimpleThermo.h
95  * - This is a one-zone constant heat capacity model.
96  * - GeneralSpeciesThermo in file GeneralSpeciesThermo.h
97  * - This is a general model. Each species is handled separately
98  * via a vector over SpeciesThermoInterpType classes.
99  * - SpeciesThermoDuo in file SpeciesThermoMgr.h
100  * - This is a combination of two SpeciesThermo types.
101  *
102  * The class SpeciesThermoInterpType is a pure virtual base class for
103  * calculation of thermodynamic functions for a single species
104  * in its reference state.
105  * The following classes inherit from SpeciesThermoInterpType.
106  *
107  * - NasaPoly1 in file NasaPoly1.h
108  * - This is a one zone model, consisting of a 7
109  * coefficient NASA Polynomial format.
110  * - NasaPoly2 in file NasaPoly2.h
111  * - This is a two zone model, with each zone consisting of a 7
112  * coefficient NASA Polynomial format.
113  * - ShomatePoly in file ShomatePoly.h
114  * - This is a one zone model, consisting of a 7
115  * coefficient Shomate Polynomial format.
116  * - ShomatePoly2 in file ShomatePoly.h
117  * - This is a two zone model, with each zone consisting of a 7
118  * coefficient Shomate Polynomial format.
119  * - ConstCpPoly in file ConstCpPoly.h
120  * - This is a one-zone constant heat capacity model.
121  * - Mu0Poly in file Mu0Poly.h
122  * - This is a multi-zone model. The chemical potential is given
123  * at a set number of temperatures. Between each temperature
124  * the heat capacity is treated as a constant.
125  * - Nasa9Poly1 in file Nasa9Poly1.h
126  * - This is a one zone model, consisting of the 9
127  * coefficient NASA Polynomial format.
128  * - Nasa9PolyMultiTempRegion in file Nasa9PolyMultiTempRegion.h
129  * - This is a multiple zone model, consisting of the 9
130  * coefficient NASA Polynomial format in each zone.
131  *
132  * In particular the NasaThermo SpeciesThermo-derived model has been
133  * optimized for execution speed. It's the main-stay of gas phase computations
134  * involving large numbers of species in a phase. It combines the calculation
135  * of each species, which individually have NasaPoly2 representations, to
136  * minimize the computational time.
137  *
138  * The GeneralSpeciesThermo SpeciesThermo object is completely general. It
139  * does not try to coordinate the individual species calculations at all and
140  * therefore is the slowest but most general implementation.
141  *
142  * @ingroup thermoprops
143  */
144 //@{
145
146 //! Pure Virtual base class for the species thermo manager classes.
147 /*!
148  * This class defines the interface which all subclasses must implement.
149  *
150  * Class SpeciesThermo is the base class for a family of classes that compute
151  * properties of a set of species in their reference state at a range of
152  * temperatures. Note, the pressure dependence of the reference state is not
153  * handled by this particular species standard state model.
154  */
156 {
157 public:
158
159  //! Constructor
161
162  //! Destructor
163  virtual ~SpeciesThermo() {}
164
165  //! Duplication routine for objects derived from SpeciesThermo
166  /*!
167  * This function can be used to duplicate objects derived from
168  * SpeciesThermo even if the application only has a pointer to
169  * SpeciesThermo to work with.
170  */
171  virtual SpeciesThermo* duplMyselfAsSpeciesThermo() const = 0;
172
173  //! Install a new species thermodynamic property
174  //! parameterization for one species.
175  /*!
176  * @see speciesThermoTypes.h
177  *
178  * @param name Name of the species
179  * @param index The 'update' method will update the property
180  * values for this species
181  * at position i index in the property arrays.
182  * @param type int flag specifying the type of parameterization to be
183  * installed.
184  * @param c vector of coefficients for the parameterization.
185  * This vector is simply passed through to the
186  * parameterization constructor.
187  * @param minTemp minimum temperature for which this parameterization
188  * is valid.
189  * @param maxTemp maximum temperature for which this parameterization
190  * is valid.
191  * @param refPressure standard-state pressure for this
192  * parameterization.
193  * @deprecated Use newSpeciesThermoInterpType and
194  * GeneralSpeciesThermo::install_STIT. To be removed after Cantera 2.2.
195  */
196  virtual void install(const std::string& name, size_t index, int type,
197  const doublereal* c,
198  doublereal minTemp, doublereal maxTemp,
199  doublereal refPressure)=0;
200
201  //! Install a new species thermodynamic property
202  //! parameterization for one species.
203  /*!
204  * @param index Index of the species being installed
205  * @param stit Pointer to the SpeciesThermoInterpType object
206  * This will set up the thermo for one species
207  */
208  virtual void install_STIT(size_t index,
209  shared_ptr<SpeciesThermoInterpType> stit) = 0;
210
211  //! Compute the reference-state properties for all species.
212  /*!
213  * Given temperature T in K, this method updates the values of the non-
214  * dimensional heat capacity at constant pressure, enthalpy, and entropy,
215  * at the reference pressure, Pref of each of the standard states.
216  *
217  * @param T Temperature (Kelvin)
218  * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
219  * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
220  * @param s_R Vector of Dimensionless entropies. (length m_kk).
221  */
222  virtual void update(doublereal T, doublereal* cp_R,
223  doublereal* h_RT, doublereal* s_R) const=0;
224
225  //! Like update(), but only updates the single species k.
226  /*!
227  * The default treatment is to just call update() which means that
228  * potentially the operation takes a m_kk*m_kk hit.
229  *
230  * @param k species index
231  * @param T Temperature (Kelvin)
232  * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
233  * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
234  * @param s_R Vector of Dimensionless entropies. (length m_kk).
235  */
236  virtual void update_one(size_t k, doublereal T,
237  doublereal* cp_R,
238  doublereal* h_RT,
239  doublereal* s_R) const {
240  update(T, cp_R, h_RT, s_R);
241  }
242
243  //! Minimum temperature.
244  /*!
245  * If no argument is supplied, this method returns the minimum temperature
246  * for which \e all parameterizations are valid. If an integer index k is
247  * supplied, then the value returned is the minimum temperature for
248  * species k in the phase.
249  *
250  * @param k Species index
251  */
252  virtual doublereal minTemp(size_t k=npos) const =0;
253
254  //! Maximum temperature.
255  /*!
256  * If no argument is supplied, this method returns the maximum temperature
257  * for which \e all parameterizations are valid. If an integer index k is
258  * supplied, then the value returned is the maximum temperature for
259  * parameterization k.
260  *
261  * @param k Species Index
262  */
263  virtual doublereal maxTemp(size_t k=npos) const =0;
264
265  //! The reference-state pressure for species k.
266  /*!
267  * Returns the reference state pressure in Pascals for species k. If k is
268  * left out of the argument list, it returns the reference state pressure
269  * for the first species. Note that some SpeciesThermo implementations,
270  * such as those for ideal gases, require that all species in the same
271  * phase have the same reference state pressures.
272  *
273  * @param k Species Index
274  */
275  virtual doublereal refPressure(size_t k=npos) const =0;
276
277  //! This utility function reports the type of parameterization
278  //! used for the species with index number *index*.
279  /*!
280  * @param index Species index
281  */
282  virtual int reportType(size_t index=npos) const = 0;
283
284  //! This utility function reports back the type of parameterization and
285  //! all of the parameters for the species with index number *index*.
286  /*!
287  * @param index Species index
288  * @param type Integer type of the standard type
289  * @param c Vector of coefficients used to set the
290  * parameters for the standard state.
291  * @param minTemp output - Minimum temperature
292  * @param maxTemp output - Maximum temperature
293  * @param refPressure output - reference pressure (Pa).
294  */
295  virtual void reportParams(size_t index, int& type,
296  doublereal* const c,
297  doublereal& minTemp,
298  doublereal& maxTemp,
299  doublereal& refPressure) const =0;
300
301  //! Report the 298 K Heat of Formation of the standard state of one species (J kmol-1)
302  /*!
303  * The 298K Heat of Formation is defined as the enthalpy change to create the standard state
304  * of the species from its constituent elements in their standard states at 298 K and 1 bar.
305  *
306  * @param k species index
307  * @return Returns the current value of the Heat of Formation at 298K and 1 bar
308  */
309  virtual doublereal reportOneHf298(const size_t k) const = 0;
310
311  //! Modify the value of the 298 K Heat of Formation of the standard state of
312  //! one species in the phase (J kmol-1)
313  /*!
314  * The 298K heat of formation is defined as the enthalpy change to create the standard state
315  * of the species from its constituent elements in their standard states at 298 K and 1 bar.
316  *
317  * @param k Index of the species
318  * @param Hf298New Specify the new value of the Heat of Formation at 298K and 1 bar.
319  * units = J/kmol.
320  */
321  virtual void modifyOneHf298(const size_t k, const doublereal Hf298New) = 0;
322
323  //! Check if data for all species (0 through nSpecies-1) has been installed.
325
326 protected:
327  //! Mark species *k* as having its thermodynamic data installed
328  void markInstalled(size_t k);
329
330 private:
331  std::vector<bool> m_installed; // indicates if data for species has been installed
332 };
333 //@}
334 }
335
336 #endif
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
virtual doublereal maxTemp(size_t k=npos) const =0
Maximum temperature.
virtual void update_one(size_t k, doublereal T, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Like update(), but only updates the single species k.
virtual void install(const std::string &name, size_t index, int type, const doublereal *c, doublereal minTemp, doublereal maxTemp, doublereal refPressure)=0
Install a new species thermodynamic property parameterization for one species.
virtual void install_STIT(size_t index, shared_ptr< SpeciesThermoInterpType > stit)=0
Install a new species thermodynamic property parameterization for one species.
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
Pure Virtual base class for the species thermo manager classes.
virtual int reportType(size_t index=npos) const =0
This utility function reports the type of parameterization used for the species with index number ind...
Check if data for all species (0 through nSpecies-1) has been installed.
virtual SpeciesThermo * duplMyselfAsSpeciesThermo() const =0
Duplication routine for objects derived from SpeciesThermo.
void markInstalled(size_t k)
Mark species k as having its thermodynamic data installed.
virtual ~SpeciesThermo()
Destructor.
virtual doublereal refPressure(size_t k=npos) const =0
The reference-state pressure for species k.
virtual doublereal minTemp(size_t k=npos) const =0
Minimum temperature.
virtual void modifyOneHf298(const size_t k, const doublereal Hf298New)=0
Modify the value of the 298 K Heat of Formation of the standard state of one species in the phase (J ...
SpeciesThermo()
Constructor.
virtual void reportParams(size_t index, int &type, doublereal *const c, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure) const =0
This utility function reports back the type of parameterization and all of the parameters for the spe...
virtual void update(doublereal T, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const =0
Compute the reference-state properties for all species.
virtual doublereal reportOneHf298(const size_t k) const =0
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1) ...