Cantera  2.3.0
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 // This file is part of Cantera. See License.txt in the top-level directory or
10 // at http://www.cantera.org/license.txt for license and copyright information.
11 
12 #ifndef CT_SPECIESTHERMOINTERPTYPE_H
13 #define CT_SPECIESTHERMOINTERPTYPE_H
14 
15 #include "cantera/base/ct_defs.h"
16 #include "speciesThermoTypes.h"
18 #include "cantera/base/global.h"
19 
20 namespace Cantera
21 {
22 
23 class PDSS;
24 class VPSSMgr;
25 
26 /**
27  * @defgroup spthermo Species Reference-State Thermodynamic Properties
28  *
29  * To compute the thermodynamic properties of multicomponent solutions, it is
30  * necessary to know something about the thermodynamic properties of the
31  * individual species present in the solution. Exactly what sort of species
32  * properties are required depends on the thermodynamic model for the solution.
33  * For a gaseous solution (i.e., a gas mixture), the species properties
34  * required are usually ideal gas properties at the mixture temperature and at
35  * a reference pressure (almost always at 1 bar). For other types of solutions,
36  * however, it may not be possible to isolate the species in a "pure" state.
37  * For example, the thermodynamic properties of, say, Na+ and Cl- in saltwater
38  * are not easily determined from data on the properties of solid NaCl, or
39  * solid Na metal, or chlorine gas. In this case, the solvation in water is
40  * fundamental to the identity of the species, and some other reference state
41  * must be used. One common convention for liquid solutions is to use
42  * thermodynamic data for the solutes in the limit of infinite dilution within
43  * the pure solvent; another convention is to reference all properties to unit
44  * molality.
45  *
46  * In defining these standard states for species in a phase, we make the
47  * following definition. A reference state is a standard state of a species in
48  * a phase limited to one particular pressure, the reference pressure. The
49  * reference state specifies the dependence of all thermodynamic functions as a
50  * function of the temperature, in between a minimum temperature and a maximum
51  * temperature. The reference state also specifies the molar volume of the
52  * species as a function of temperature. The molar volume is a thermodynamic
53  * function. A full standard state does the same thing as a reference state,
54  * but specifies the thermodynamics functions at all pressures.
55  *
56  * The class SpeciesThermoInterpType is an abstract base class for calculation
57  * of thermodynamic functions for a single species in its reference state. The
58  * following classes inherit from SpeciesThermoInterpType.
59  *
60  * - NasaPoly1 in file NasaPoly1.h
61  * - This is a one zone model, consisting of a 7
62  * coefficient NASA Polynomial format.
63  * .
64  * - NasaPoly2 in file NasaPoly2.h
65  * - This is a two zone model, with each zone consisting of a 7
66  * coefficient NASA Polynomial format.
67  * .
68  * - ShomatePoly in file ShomatePoly.h
69  * - This is a one zone model, consisting of a 7
70  * coefficient Shomate Polynomial format.
71  * .
72  * - ShomatePoly2 in file ShomatePoly.h
73  * - This is a two zone model, with each zone consisting of a 7
74  * coefficient Shomate Polynomial format.
75  * .
76  * - ConstCpPoly in file ConstCpPoly.h
77  * - This is a one-zone constant heat capacity model.
78  * .
79  * - Mu0Poly in file Mu0Poly.h
80  * - This is a multi-zone model. The chemical potential is given
81  * at a set number of temperatures. Between each temperature
82  * the heat capacity is treated as a constant.
83  * .
84  * - Nasa9Poly1 in file Nasa9Poly1.h
85  * - This is a one zone model, consisting of the 9
86  * coefficient NASA Polynomial format.
87  * .
88  * - Nasa9PolyMultiTempRegion in file Nasa9PolyMultiTempRegion.h
89  * - This is a multiple zone model, consisting of the 9
90  * coefficient NASA Polynomial format in each zone.
91  * .
92  * - STITbyPDSS in file SpeciesThermoInterpType.h
93  * - This is an object that calculates reference state thermodynamic
94  * functions by relying on a pressure dependent
95  * standard state object (i.e., a PDSS object) to calculate
96  * the thermodynamic functions.
97  *
98  * The most important member function for the SpeciesThermoInterpType class is
99  * the member function SpeciesThermoInterpType::updatePropertiesTemp(). The
100  * function calculates the values of Cp, H, and S for the specific species
101  * pertaining to this class.
102  *
103  * A key concept for reference states is that there is a maximum and a minimum
104  * temperature beyond which the thermodynamic formulation isn't valid. Calls
105  * for temperatures outside this range will cause the object to throw a
106  * CanteraError.
107  *
108  * @ingroup thermoprops
109  */
110 
111 //! Abstract Base class for the thermodynamic manager for an individual
112 //! species' reference state
113 /*!
114  * One key feature is that the update routines use the same form as the update
115  * routines in the MultiSpeciesThermo class. They update values of cp_R,
116  * s_R, and H_R.
117  *
118  * @ingroup spthermo
119  */
121 {
122 public:
124 
125  SpeciesThermoInterpType(double tlow, double thigh, double pref);
126 
127  //! @deprecated Copy constructor to be removed after Cantera 2.3 for all
128  //! classes derived from SpeciesThermoInterpType.
130  //! @deprecated Assignment operator to be removed after Cantera 2.3 for all
131  //! classes derived from SpeciesThermoInterpType.
133 
134  virtual ~SpeciesThermoInterpType() {}
135 
136  //! @deprecated To be removed after Cantera 2.3 for all classes derived
137  //! from SpeciesThermoInterpType.
138  virtual SpeciesThermoInterpType*
140 
141  //! Returns the minimum temperature that the thermo parameterization is
142  //! valid
143  virtual doublereal minTemp() const {
144  return m_lowT;
145  }
146 
147  //! Returns the maximum temperature that the thermo parameterization is
148  //! valid
149  virtual doublereal maxTemp() const {
150  return m_highT;
151  }
152 
153  //! Returns the reference pressure (Pa)
154  virtual doublereal refPressure() const {
155  return m_Pref;
156  }
157 
158  //! Check for problems with the parameterization, and generate warnings or
159  //! throw and exception if any are found.
160  virtual void validate(const std::string& name) {}
161 
162  //! Returns an integer representing the type of parameterization
163  virtual int reportType() const = 0;
164 
165  //! Number of terms in the temperature polynomial for this parameterization
166  virtual size_t temperaturePolySize() const { return 1; }
167 
168  //! Given the temperature *T*, compute the terms of the temperature
169  //! polynomial *T_poly*.
170  virtual void updateTemperaturePoly(double T, double* T_poly) const {
171  T_poly[0] = T;
172  }
173 
174  //! Update the properties for this species, given a temperature polynomial
175  /*!
176  * This method is called with a pointer to an array containing the functions
177  * of temperature needed by this parameterization, and three pointers to
178  * arrays where the computed property values should be written. This method
179  * updates only one value in each array.
180  *
181  * The form and length of the Temperature Polynomial may vary depending on
182  * the parameterization.
183  *
184  * @param tt vector of evaluated temperature functions
185  * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
186  * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
187  * @param s_R Vector of Dimensionless entropies. (length m_kk).
188  */
189  virtual void updateProperties(const doublereal* tt,
190  doublereal* cp_R, doublereal* h_RT,
191  doublereal* s_R) const;
192 
193  //! Compute the reference-state property of one species
194  /*!
195  * Given temperature T in K, this method updates the values of the non-
196  * dimensional heat capacity at constant pressure, enthalpy, and entropy, at
197  * the reference pressure, of the species.
198  *
199  * @param temp Temperature (Kelvin)
200  * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
201  * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
202  * @param s_R Vector of Dimensionless entropies. (length m_kk).
203  */
204  virtual void updatePropertiesTemp(const doublereal temp,
205  doublereal* cp_R,
206  doublereal* h_RT,
207  doublereal* s_R) const = 0;
208 
209  //! This utility function reports back the type of parameterization and all
210  //! of the parameters for the species.
211  /*!
212  * All parameters are output variables
213  *
214  * @param index Species index
215  * @param type Integer type of the standard type
216  * @param minTemp output - Minimum temperature
217  * @param maxTemp output - Maximum temperature
218  * @param refPressure output - reference pressure (Pa).
219  * @param coeffs Vector of coefficients used to set the
220  * parameters for the standard state.
221  */
222  virtual void reportParameters(size_t& index, int& type,
223  doublereal& minTemp, doublereal& maxTemp,
224  doublereal& refPressure,
225  doublereal* const coeffs) const = 0;
226 
227  //! Modify parameters for the standard state
228  /*!
229  * @param coeffs Vector of coefficients used to set the parameters for the
230  * standard state.
231  * @deprecated To be removed after Cantera 2.3. Use
232  * MultiSpeciesThermo::modifySpecies instead.
233  */
234  virtual void modifyParameters(doublereal* coeffs) {
235  warn_deprecated("SpeciesThermoInterpType::modifyParameters", "To be "
236  "removed after Cantera 2.3. Use MultiSpeciesThermo::modifySpecies "
237  "instead.");
238  }
239 
240  //! Report the 298 K Heat of Formation of the standard state of one species
241  //! (J kmol-1)
242  /*!
243  * The 298K Heat of Formation is defined as the enthalpy change to create
244  * the standard state of the species from its constituent elements in their
245  * standard states at 298 K and 1 bar.
246  *
247  * @param h298 If this is nonnull, the current value of the Heat of
248  * Formation at 298K and 1 bar for species m_speciesIndex is
249  * returned in h298[m_speciesIndex].
250  * @return the current value of the Heat of Formation at 298K and 1 bar for
251  * species m_speciesIndex.
252  */
253  virtual doublereal reportHf298(doublereal* const h298 = 0) const;
254 
255  //! Modify the value of the 298 K Heat of Formation of one species in the
256  //! phase (J kmol-1)
257  /*!
258  * The 298K heat of formation is defined as the enthalpy change to create
259  * the standard state of the species from its constituent elements in their
260  * standard states at 298 K and 1 bar.
261  *
262  * @param k Species k
263  * @param Hf298New Specify the new value of the Heat of Formation at
264  * 298K and 1 bar
265  */
266  virtual void modifyOneHf298(const size_t k, const doublereal Hf298New);
267 
268  //! Restore the original heat of formation for this species
269  /*!
270  * Resets changes made by modifyOneHf298().
271  */
272  virtual void resetHf298() {
273  throw CanteraError("SpeciesThermoInterpType::resetHf298",
274  "Not implemented");
275  }
276 
277 protected:
278  //! lowest valid temperature
279  doublereal m_lowT;
280  //! Highest valid temperature
281  doublereal m_highT;
282  //! Reference state pressure
283  doublereal m_Pref;
284 };
285 
286 //! Class for the thermodynamic manager for an individual species' reference
287 //! state which uses the PDSS base class to satisfy the requests.
288 /*!
289  * This class is a pass-through class for handling thermodynamics calls for
290  * reference state thermo to an pressure dependent standard state (PDSS) class.
291  * For some situations, it makes no sense to have a reference state at all. One
292  * example of this is the real water standard state.
293  *
294  * What this class does is just to pass through the calls for thermo at (T, p0)
295  * to the PDSS class, which evaluates the calls at (T, p0).
296  *
297  * @ingroup spthermo
298  */
300 {
301 public:
302  //! Constructor
303  //! @deprecated Default constructor to be removed after Cantera 2.3.
304  STITbyPDSS();
305 
306  //! Main Constructor
307  /*!
308  * @param vpssmgr_ptr Pointer to the Variable pressure standard state
309  * manager that owns the PDSS object that will handle calls for this
310  * object
311  * @param PDSS_ptr Pointer to the PDSS object that handles calls for
312  * this object
313  */
314  STITbyPDSS(VPSSMgr* vpssmgr_ptr, PDSS* PDSS_ptr);
315 
316  STITbyPDSS(const STITbyPDSS& b);
317 
319 
320  //! Initialize and/or Reinitialize all the pointers for this object
321  /*!
322  * This routine is needed because the STITbyPDSS object doesn't own the
323  * underlying objects. Therefore, shallow copies during duplication
324  * operations may fail.
325  *
326  * @param speciesIndex species index for this object. Note, this must agree
327  * with what was internally set before.
328  * @param vpssmgr_ptr Pointer to the Variable pressure standard state
329  * manager that owns the PDSS object that will handle calls for this
330  * object
331  * @param PDSS_ptr Pointer to the PDSS object that handles calls for
332  * this object
333  */
334  void initAllPtrs(size_t speciesIndex, VPSSMgr* vpssmgr_ptr, PDSS* PDSS_ptr);
335 
336  virtual doublereal minTemp() const;
337  virtual doublereal maxTemp() const;
338  virtual doublereal refPressure() const;
339  virtual int reportType() const;
340 
341  virtual void updateProperties(const doublereal* tempPoly,
342  doublereal* cp_R, doublereal* h_RT,
343  doublereal* s_R) const;
344 
345  virtual void updatePropertiesTemp(const doublereal temp,
346  doublereal* cp_R,
347  doublereal* h_RT,
348  doublereal* s_R) const;
349 
350  virtual void reportParameters(size_t& index, int& type,
351  doublereal& minTemp, doublereal& maxTemp,
352  doublereal& refPressure,
353  doublereal* const coeffs) const;
354 
355  //! @deprecated To be removed after Cantera 2.3. Use
356  //! MultiSpeciesThermo::modifySpecies instead.
357  virtual void modifyParameters(doublereal* coeffs) {
358  warn_deprecated("STITbyPDSS::modifyParameters", "To be removed after "
359  "Cantera 2.3. Use MultiSpeciesThermo::modifySpecies instead.");
360  }
361 
362 private:
363  //! Pointer to the Variable pressure standard state manager that owns the
364  //! PDSS object that will handle calls for this object
366 
367  //! Pointer to the PDSS object that handles calls for this object
368  /*!
369  * This object is not owned by the current one.
370  */
372 };
373 
374 }
375 
376 #endif
virtual void modifyParameters(doublereal *coeffs)
Modify parameters for the standard state.
Abstract 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 doublereal minTemp() const
Returns the minimum temperature that the thermo parameterization is valid.
Virtual base class for the classes that manage the calculation of standard state properties for all t...
Definition: VPSSMgr.h:228
virtual SpeciesThermoInterpType * duplMyselfAsSpeciesThermoInterpType() const
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 warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:54
virtual void updateTemperaturePoly(double T, double *T_poly) const
Given the temperature T, compute the terms of the temperature polynomial T_poly.
This file contains definitions for utility functions and text for modules, inputfiles, logs, textlogs, (see Input File Handling, Diagnostic Output, and Writing messages to the screen).
void initAllPtrs(size_t speciesIndex, VPSSMgr *vpssmgr_ptr, PDSS *PDSS_ptr)
Initialize and/or Reinitialize all the pointers for this object.
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 SpeciesThermoInterpType * duplMyselfAsSpeciesThermoInterpType() const =0
Contains const definitions for types of species reference-state thermodynamics managers (see Species ...
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...
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 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 updatePropertiesTemp(const doublereal temp, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Compute the reference-state property of one species.
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:65
doublereal m_lowT
lowest valid temperature
virtual doublereal refPressure() const
Returns the reference pressure (Pa)
virtual doublereal maxTemp() const
Returns the maximum temperature that the thermo parameterization is valid.
virtual int reportType() const
Returns an integer representing the type of parameterization.
virtual void updateProperties(const doublereal *tt, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Update the properties for this species, given a temperature polynomial.
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:176
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 void modifyParameters(doublereal *coeffs)
virtual doublereal maxTemp() const
Returns the maximum temperature that the thermo parameterization is valid.
virtual size_t temperaturePolySize() const
Number of terms in the temperature polynomial for this parameterization.
virtual void resetHf298()
Restore the original heat of formation for this species.
doublereal m_Pref
Reference state pressure.
Namespace for the Cantera kernel.
Definition: application.cpp:29
VPSSMgr * m_vpssmgr_ptr
Pointer to the Variable pressure standard state manager that owns the PDSS object that will handle ca...
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
SpeciesThermoInterpType & operator=(const SpeciesThermoInterpType &b)