Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SpeciesThermoInterpType.h
Go to the documentation of this file.
1 /**
2  * @file SpeciesThermoInterpType.h
3  *
4  * Pure Virtual Base class for individual species reference state thermodynamic
5  * managers and text for the spthermo module (see \ref spthermo and class \link
6  * Cantera::SpeciesThermoInterpType SpeciesThermoInterpType \endlink).
7  */
8 
9 // Copyright 2001 California Institute of Technology
10 
11 #ifndef CT_SPECIESTHERMOINTERPTYPE_H
12 #define CT_SPECIESTHERMOINTERPTYPE_H
13 
14 #include "cantera/base/ct_defs.h"
15 #include "speciesThermoTypes.h"
16 
17 namespace Cantera
18 {
19 
20 class PDSS;
21 class VPSSMgr;
22 
23 /**
24  * @defgroup spthermo Species Reference-State Thermodynamic Properties
25  *
26  * The ThermoPhase object relies on classes to calculate the thermodynamic
27  * properties of the reference state for all of the species in the phase.
28  * This group describes the types and functionality of the classes that
29  * calculate the reference state thermodynamic functions within %Cantera.
30  *
31  * To compute the thermodynamic properties of multicomponent
32  * solutions, it is necessary to know something about the
33  * thermodynamic properties of the individual species present in
34  * the solution. Exactly what sort of species properties are
35  * required depends on the thermodynamic model for the
36  * solution. For a gaseous solution (i.e., a gas mixture), the
37  * species properties required are usually ideal gas properties at
38  * the mixture temperature and at a reference pressure (almost always at
39  * 1 bar). For other types of solutions, however, it may
40  * not be possible to isolate the species in a "pure" state. For
41  * example, the thermodynamic properties of, say, Na+ and Cl- in
42  * saltwater are not easily determined from data on the properties
43  * of solid NaCl, or solid Na metal, or chlorine gas. In this
44  * case, the solvation in water is fundamental to the identity of
45  * the species, and some other reference state must be used. One
46  * common convention for liquid solutions is to use thermodynamic
47  * data for the solutes in the limit of infinite dilution within the
48  * pure solvent; another convention is to reference all properties
49  * to unit molality.
50  *
51  * In defining these standard states for species in a phase, we make
52  * the following definition. A reference state is a standard state
53  * of a species in a phase limited to one particular pressure, the reference
54  * pressure. The reference state specifies the dependence of all
55  * thermodynamic functions as a function of the temperature, in
56  * between a minimum temperature and a maximum temperature. The
57  * reference state also specifies the molar volume of the species
58  * as a function of temperature. The molar volume is a thermodynamic
59  * function.
60  * A full standard state does the same thing as a reference state,
61  * but specifies the thermodynamics functions at all pressures.
62  *
63  * Whatever the conventions used by a particular solution model,
64  * means need to be provided to compute the species properties in
65  * the reference state. Class SpeciesThermo is the base class
66  * for a family of classes that compute properties of all
67  * species in a phase in their reference states, for a range of temperatures.
68  * Note, the pressure dependence of the species thermodynamic functions is not
69  * handled by this particular species thermodynamic model. SpeciesThermo
70  * calculates the reference-state thermodynamic values of all species in a single
71  * phase during each call.
72  *
73  * The class SpeciesThermoInterpType is a pure virtual base class for
74  * calculation of thermodynamic functions for a single species
75  * in its reference state.
76  * The following classes inherit from SpeciesThermoInterpType.
77  *
78  * - NasaPoly1 in file NasaPoly1.h
79  * - This is a one zone model, consisting of a 7
80  * coefficient NASA Polynomial format.
81  * .
82  * - NasaPoly2 in file NasaPoly2.h
83  * - This is a two zone model, with each zone consisting of a 7
84  * coefficient NASA Polynomial format.
85  * .
86  * - ShomatePoly in file ShomatePoly.h
87  * - This is a one zone model, consisting of a 7
88  * coefficient Shomate Polynomial format.
89  * .
90  * - ShomatePoly2 in file ShomatePoly.h
91  * - This is a two zone model, with each zone consisting of a 7
92  * coefficient Shomate Polynomial format.
93  * .
94  * - ConstCpPoly in file ConstCpPoly.h
95  * - This is a one-zone constant heat capacity model.
96  * .
97  * - Mu0Poly in file Mu0Poly.h
98  * - This is a multi-zone model. The chemical potential is given
99  * at a set number of temperatures. Between each temperature
100  * the heat capacity is treated as a constant.
101  * .
102  * - Nasa9Poly1 in file Nasa9Poly1.h
103  * - This is a one zone model, consisting of the 9
104  * coefficient NASA Polynomial format.
105  * .
106  * - Nasa9PolyMultiTempRegion in file Nasa9PolyMultiTempRegion.h
107  * - This is a multiple zone model, consisting of the 9
108  * coefficient NASA Polynomial format in each zone.
109  * .
110  * - STITbyPDSS in file SpeciesThermoInterpType.h
111  * - This is an object that calculates reference state thermodynamic
112  * functions by relying on a pressure dependent
113  * standard state object (i.e., a PDSS object) to calculate
114  * the thermodynamic functions.
115  * .
116  *
117  * The most important member function for the SpeciesThermoInterpType class
118  * is the member function
119  * \link SpeciesThermoInterpType::updatePropertiesTemp() updatePropertiesTemp()\endlink.
120  * The function calculates the values of Cp, H, and S for the specific
121  * species pertaining to this class. It takes as its arguments the
122  * base pointer for the vector of Cp, H, and S values for all species
123  * in the phase. The offset for the species is known within the
124  * object.
125  *
126  * A key concept for reference states is that there is a maximum and a minimum
127  * temperature beyond which the thermodynamic formulation isn't valid.
128  * Calls for temperatures outside this range will cause the
129  * object to throw a CanteraError.
130  *
131  * @ingroup thermoprops
132  */
133 
134 //! Pure Virtual Base class for the thermodynamic manager for
135 //! an individual species' reference state
136 /*!
137  * This differs from the SpeciesThermo virtual
138  * base class in the sense that this class is meant to handle only
139  * one species. The speciesThermo class is meant to handle the
140  * calculation of all the species (or a large subset) in a phase.
141  *
142  * One key feature is that the update routines use the same
143  * form as the update routines in the speciesThermo class. They update
144  * into a vector of cp_R, s_R, and H_R that spans all of the species in
145  * a phase. Therefore, this class must carry along a species index into that
146  * vector.
147  *
148  * These routine may be templated. A key requirement of the template is that
149  * there is a constructor with the following form:
150  *
151  * @code
152  * SpeciesThermoInterpType(int index, doublereal tlow, doublereal thigh,
153  * doublereal pref, const doublereal* coeffs)
154  * @endcode
155  *
156  * @ingroup spthermo
157  */
159 {
160 public:
162 
163  //! @deprecated Use the constructor without the species index. To be removed
164  //! after Cantera 2.2.
165  SpeciesThermoInterpType(size_t n, doublereal tlow,
166  doublereal thigh, doublereal pref);
167 
168  SpeciesThermoInterpType(double tlow, double thigh, double pref);
169 
171 
172  virtual ~SpeciesThermoInterpType() {}
173 
174  virtual SpeciesThermoInterpType*
175  duplMyselfAsSpeciesThermoInterpType() const = 0;
176 
177  //! Returns the minimum temperature that the thermo
178  //! parameterization is valid
179  virtual doublereal minTemp() const {
180  return m_lowT;
181  }
182 
183  //! Returns the maximum temperature that the thermo
184  //! parameterization is valid
185  virtual doublereal maxTemp() const {
186  return m_highT;
187  }
188 
189  //! Returns the reference pressure (Pa)
190  virtual doublereal refPressure() const {
191  return m_Pref;
192  }
193 
194  //! Check for problems with the parameterization, and generate warnings or
195  //! throw and exception if any are found.
196  virtual void validate(const std::string& name) {}
197 
198  //! Returns an integer representing the type of parameterization
199  virtual int reportType() const = 0;
200 
201  //! Returns an integer representing the species index
202  //! @deprecated
203  virtual size_t speciesIndex() const {
204  return m_index;
205  }
206 
207  //! @deprecated
208  virtual void setIndex(size_t index) {
209  m_index = index;
210  }
211 
212  //! Number of terms in the temperature polynomial for this parameterization
213  virtual size_t temperaturePolySize() const { return 1; }
214 
215  //! Given the temperature *T*, compute the terms of the temperature
216  //! polynomial *T_poly*.
217  virtual void updateTemperaturePoly(double T, double* T_poly) const {
218  T_poly[0] = T;
219  }
220 
221  //! Update the properties for this species, given a temperature polynomial
222  /*!
223  * This method is called with a pointer to an array containing the functions
224  * of temperature needed by this parameterization, and three pointers to
225  * arrays where the computed property values should be written. This method
226  * updates only one value in each array.
227  *
228  * The form and length of the Temperature Polynomial may vary depending on
229  * the parameterization.
230  *
231  * @param tempPoly vector of temperature polynomials
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 updateProperties(const doublereal* tempPoly,
237  doublereal* cp_R, doublereal* h_RT,
238  doublereal* s_R) const;
239 
240  //! Compute the reference-state property of one species
241  /*!
242  * Given temperature T in K, this method updates the values of
243  * the non-dimensional heat capacity at constant pressure,
244  * enthalpy, and entropy, at the reference pressure, Pref
245  * of one of the species. The species index is used
246  * to reference into the cp_R, h_RT, and s_R arrays.
247  *
248  * @param temp Temperature (Kelvin)
249  * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
250  * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
251  * @param s_R Vector of Dimensionless entropies. (length m_kk).
252  */
253  virtual void updatePropertiesTemp(const doublereal temp,
254  doublereal* cp_R,
255  doublereal* h_RT,
256  doublereal* s_R) const = 0;
257 
258  //!This utility function reports back the type of
259  //! parameterization and all of the parameters for the
260  //! species, index.
261  /*!
262  * All parameters are output variables
263  *
264  * @param index Species index
265  * @param type Integer type of the standard type
266  * @param minTemp output - Minimum temperature
267  * @param maxTemp output - Maximum temperature
268  * @param refPressure output - reference pressure (Pa).
269  * @param coeffs Vector of coefficients used to set the
270  * parameters for the standard state.
271  */
272  virtual void reportParameters(size_t& index, int& type,
273  doublereal& minTemp, doublereal& maxTemp,
274  doublereal& refPressure,
275  doublereal* const coeffs) const = 0;
276 
277  //! Modify parameters for the standard state
278  /*!
279  * @param coeffs Vector of coefficients used to set the
280  * parameters for the standard state.
281  */
282  virtual void modifyParameters(doublereal* coeffs) {}
283 
284  //! Report the 298 K Heat of Formation of the standard state of one species
285  //! (J kmol-1)
286  /*!
287  * The 298K Heat of Formation is defined as the enthalpy change to create
288  * the standard state of the species from its constituent elements in
289  * their standard states at 298 K and 1 bar.
290  *
291  * @param h298 If this is nonnull, the current value of the Heat of
292  * Formation at 298K and 1 bar for species m_speciesIndex is
293  * returned in h298[m_speciesIndex].
294  * @return Returns the current value of the Heat of Formation at 298K
295  * and 1 bar for species m_speciesIndex.
296  */
297  virtual doublereal reportHf298(doublereal* const h298 = 0) const;
298 
299  //! Modify the value of the 298 K Heat of Formation of one species in the
300  //! phase (J kmol-1)
301  /*!
302  * The 298K heat of formation is defined as the enthalpy change to create
303  * the standard state of the species from its constituent elements in
304  * their standard states at 298 K and 1 bar.
305  *
306  * @param k Species k
307  * @param Hf298New Specify the new value of the Heat of Formation at
308  * 298K and 1 bar
309  */
310  virtual void modifyOneHf298(const size_t k, const doublereal Hf298New);
311 
312 protected:
313  //! lowest valid temperature
314  doublereal m_lowT;
315  //! Highest valid temperature
316  doublereal m_highT;
317  //! Reference state pressure
318  doublereal m_Pref;
319  //! species index @deprecated
320  size_t m_index;
321 };
322 
323 //! Class for the thermodynamic manager for an individual species' reference
324 //! state which uses the PDSS base class to satisfy the requests.
325 /*!
326  * This class is a pass-through class for handling thermodynamics calls
327  * for reference state thermo to an pressure dependent standard state (PDSS)
328  * class. For some situations, it makes no sense to have a reference state
329  * at all. One example of this is the real water standard state.
330  *
331  * What this class does is just to pass through the calls for thermo at (T, p0)
332  * to the PDSS class, which evaluates the calls at (T, p0).
333  *
334  * @ingroup spthermo
335  */
337 {
338 public:
339  //! Constructor
340  STITbyPDSS();
341 
342  //! Main Constructor
343  /*!
344  * @param speciesIndex species index for this object. Note, this must
345  * agree with what was internally set before.
346  *
347  * @param vpssmgr_ptr Pointer to the Variable pressure standard state
348  * manager that owns the PDSS object that will handle calls for this
349  * object
350  *
351  * @param PDSS_ptr Pointer to the PDSS object that handles calls for
352  * this object
353  * @deprecated Use the constructor which does not require the species
354  * index. To be removed after Cantera 2.2.
355  */
356  STITbyPDSS(size_t speciesIndex, VPSSMgr* vpssmgr_ptr, PDSS* PDSS_ptr);
357 
358  //! Main Constructor
359  /*!
360  * @param vpssmgr_ptr Pointer to the Variable pressure standard state
361  * manager that owns the PDSS object that will handle calls for this
362  * object
363  *
364  * @param PDSS_ptr Pointer to the PDSS object that handles calls for
365  * this object
366  */
367  STITbyPDSS(VPSSMgr* vpssmgr_ptr, PDSS* PDSS_ptr);
368 
369  //! copy constructor
370  /*!
371  * @param b Object to be copied
372  */
373  STITbyPDSS(const STITbyPDSS& b);
374 
375  virtual SpeciesThermoInterpType* duplMyselfAsSpeciesThermoInterpType() const;
376 
377  //! Initialize and/or Reinitialize all the pointers for this object
378  /*!
379  * This routine is needed because the STITbyPDSS object doesn't own the
380  * underlying objects. Therefore, shallow copies during duplication
381  * operations may fail.
382  *
383  * @param speciesIndex species index for this object. Note, this must
384  * agree with what was internally set before.
385  *
386  * @param vpssmgr_ptr Pointer to the Variable pressure standard state
387  * manager that owns the PDSS object that will handle calls for this
388  * object
389  *
390  * @param PDSS_ptr Pointer to the PDSS object that handles calls for
391  * this object
392  */
393  void initAllPtrs(size_t speciesIndex, VPSSMgr* vpssmgr_ptr, PDSS* PDSS_ptr);
394 
395  //! Returns the minimum temperature that the thermo
396  //! parameterization is valid
397  virtual doublereal minTemp() const;
398 
399  //! Returns the maximum temperature that the thermo
400  //! parameterization is valid
401  virtual doublereal maxTemp() const;
402 
403  //! Returns the reference pressure (Pa)
404  virtual doublereal refPressure() const;
405 
406  //! Returns an integer representing the type of parameterization
407  virtual int reportType() const;
408 
409  virtual void updateProperties(const doublereal* tempPoly,
410  doublereal* cp_R, doublereal* h_RT,
411  doublereal* s_R) const;
412 
413  virtual void updatePropertiesTemp(const doublereal temp,
414  doublereal* cp_R,
415  doublereal* h_RT,
416  doublereal* s_R) const;
417 
418  virtual void reportParameters(size_t& index, int& type,
419  doublereal& minTemp, doublereal& maxTemp,
420  doublereal& refPressure,
421  doublereal* const coeffs) const;
422 
423  virtual void modifyParameters(doublereal* coeffs) {}
424 
425 private:
426  //! Pointer to the Variable pressure standard state manager
427  //! that owns the PDSS object that will handle calls for this object
429 
430  //! Pointer to the PDSS object that handles calls for this object
431  /*!
432  * This object is not owned by the current one.
433  */
435 };
436 
437 }
438 
439 #endif
virtual void modifyParameters(doublereal *coeffs)
Modify parameters for the standard state.
Pure Virtual Base class for the thermodynamic manager for an individual species' reference state...
virtual doublereal reportHf298(doublereal *const h298=0) const
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1) ...
Virtual base class for the classes that manage the calculation of standard state properties for all t...
Definition: VPSSMgr.h:235
virtual size_t speciesIndex() const
Returns an integer representing the species index.
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
virtual void validate(const std::string &name)
Check for problems with the parameterization, and generate warnings or throw and exception if any are...
void initAllPtrs(size_t speciesIndex, VPSSMgr *vpssmgr_ptr, PDSS *PDSS_ptr)
Initialize and/or Reinitialize all the pointers for this object.
virtual void reportParameters(size_t &index, int &type, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure, doublereal *const coeffs) const
This utility function reports back the type of parameterization and all of the parameters for the spe...
PDSS * m_PDSS_ptr
Pointer to the PDSS object that handles calls for this object.
virtual void modifyOneHf298(const size_t k, const doublereal Hf298New)
Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1) ...
virtual int reportType() const =0
Returns an integer representing the type of parameterization.
virtual doublereal refPressure() const
Returns the reference pressure (Pa)
Contains const definitions for types of species reference-state thermodynamics managers (see Species ...
virtual doublereal maxTemp() const
Returns the maximum temperature that the thermo parameterization is valid.
virtual void updateTemperaturePoly(double T, double *T_poly) const
Given the temperature T, compute the terms of the temperature polynomial T_poly.
virtual void reportParameters(size_t &index, int &type, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure, doublereal *const coeffs) const =0
This utility function reports back the type of parameterization and all of the parameters for the spe...
virtual size_t temperaturePolySize() const
Number of terms in the temperature polynomial for this parameterization.
Class for the thermodynamic manager for an individual species' reference state which uses the PDSS ba...
doublereal m_highT
Highest valid temperature.
virtual void updateProperties(const doublereal *tempPoly, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Update the properties for this species, given a temperature polynomial.
virtual void updateProperties(const doublereal *tempPoly, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Update the properties for this species, given a temperature polynomial.
doublereal m_lowT
lowest valid temperature
virtual int reportType() const
Returns an integer representing the type of parameterization.
virtual doublereal minTemp() const
Returns the minimum temperature that the thermo parameterization is valid.
virtual doublereal refPressure() const
Returns the reference pressure (Pa)
Virtual base class for a species with a pressure dependent standard state.
Definition: PDSS.h:193
virtual doublereal minTemp() const
Returns the minimum temperature that the thermo parameterization is valid.
virtual void updatePropertiesTemp(const doublereal temp, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const =0
Compute the reference-state property of one species.
virtual doublereal maxTemp() const
Returns the maximum temperature that the thermo parameterization is valid.
virtual void modifyParameters(doublereal *coeffs)
Modify parameters for the standard state.
doublereal m_Pref
Reference state pressure.
virtual void updatePropertiesTemp(const doublereal temp, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Compute the reference-state property of one species.
VPSSMgr * m_vpssmgr_ptr
Pointer to the Variable pressure standard state manager that owns the PDSS object that will handle ca...