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