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