Cantera  2.4.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 
25 /**
26  * @defgroup spthermo Species Reference-State Thermodynamic Properties
27  *
28  * To compute the thermodynamic properties of multicomponent solutions, it is
29  * necessary to know something about the thermodynamic properties of the
30  * individual species present in the solution. Exactly what sort of species
31  * properties are required depends on the thermodynamic model for the solution.
32  * For a gaseous solution (i.e., a gas mixture), the species properties
33  * required are usually ideal gas properties at the mixture temperature and at
34  * a reference pressure (almost always at 1 bar). For other types of solutions,
35  * however, it may not be possible to isolate the species in a "pure" state.
36  * For example, the thermodynamic properties of, say, Na+ and Cl- in saltwater
37  * are not easily determined from data on the properties of solid NaCl, or
38  * solid Na metal, or chlorine gas. In this case, the solvation in water is
39  * fundamental to the identity of the species, and some other reference state
40  * must be used. One common convention for liquid solutions is to use
41  * thermodynamic data for the solutes in the limit of infinite dilution within
42  * the pure solvent; another convention is to reference all properties to unit
43  * molality.
44  *
45  * In defining these standard states for species in a phase, we make the
46  * following definition. A reference state is a standard state of a species in
47  * a phase limited to one particular pressure, the reference pressure. The
48  * reference state specifies the dependence of all thermodynamic functions as a
49  * function of the temperature, in between a minimum temperature and a maximum
50  * temperature. The reference state also specifies the molar volume of the
51  * species as a function of temperature. The molar volume is a thermodynamic
52  * function. A full standard state does the same thing as a reference state,
53  * but specifies the thermodynamics functions at all pressures.
54  *
55  * The class SpeciesThermoInterpType is an abstract base class for calculation
56  * of thermodynamic functions for a single species in its reference state. The
57  * following classes inherit from SpeciesThermoInterpType.
58  *
59  * - NasaPoly1 in file NasaPoly1.h
60  * - This is a one zone model, consisting of a 7
61  * coefficient NASA Polynomial format.
62  * .
63  * - NasaPoly2 in file NasaPoly2.h
64  * - This is a two zone model, with each zone consisting of a 7
65  * coefficient NASA Polynomial format.
66  * .
67  * - ShomatePoly in file ShomatePoly.h
68  * - This is a one zone model, consisting of a 7
69  * coefficient Shomate Polynomial format.
70  * .
71  * - ShomatePoly2 in file ShomatePoly.h
72  * - This is a two zone model, with each zone consisting of a 7
73  * coefficient Shomate Polynomial format.
74  * .
75  * - ConstCpPoly in file ConstCpPoly.h
76  * - This is a one-zone constant heat capacity model.
77  * .
78  * - Mu0Poly in file Mu0Poly.h
79  * - This is a multi-zone model. The chemical potential is given
80  * at a set number of temperatures. Between each temperature
81  * the heat capacity is treated as a constant.
82  * .
83  * - Nasa9Poly1 in file Nasa9Poly1.h
84  * - This is a one zone model, consisting of the 9
85  * coefficient NASA Polynomial format.
86  * .
87  * - Nasa9PolyMultiTempRegion in file Nasa9PolyMultiTempRegion.h
88  * - This is a multiple zone model, consisting of the 9
89  * coefficient NASA Polynomial format in each zone.
90  * .
91  * - STITbyPDSS in file SpeciesThermoInterpType.h
92  * - This is an object that calculates reference state thermodynamic
93  * functions by relying on a pressure dependent
94  * standard state object (i.e., a PDSS object) to calculate
95  * the thermodynamic functions.
96  *
97  * The most important member function for the SpeciesThermoInterpType class is
98  * the member function SpeciesThermoInterpType::updatePropertiesTemp(). The
99  * function calculates the values of Cp, H, and S for the specific species
100  * pertaining to this class.
101  *
102  * A key concept for reference states is that there is a maximum and a minimum
103  * temperature beyond which the thermodynamic formulation isn't valid. Calls
104  * for temperatures outside this range will cause the object to throw a
105  * CanteraError.
106  *
107  * @ingroup thermoprops
108  */
109 
110 //! Abstract Base class for the thermodynamic manager for an individual
111 //! species' reference state
112 /*!
113  * One key feature is that the update routines use the same form as the update
114  * routines in the MultiSpeciesThermo class. They update values of cp_R,
115  * s_R, and H_R.
116  *
117  * @ingroup spthermo
118  */
120 {
121 public:
123 
124  SpeciesThermoInterpType(double tlow, double thigh, double pref);
125 
126  // SpeciesThermoInterpType objects are not copyable or assignable
128  SpeciesThermoInterpType& operator=(const SpeciesThermoInterpType& b) = delete;
129 
130  virtual ~SpeciesThermoInterpType() {}
131 
132  //! Returns the minimum temperature that the thermo parameterization is
133  //! valid
134  virtual doublereal minTemp() const {
135  return m_lowT;
136  }
137 
138  //! Returns the maximum temperature that the thermo parameterization is
139  //! valid
140  virtual doublereal maxTemp() const {
141  return m_highT;
142  }
143 
144  //! Returns the reference pressure (Pa)
145  virtual doublereal refPressure() const {
146  return m_Pref;
147  }
148 
149  //! Check for problems with the parameterization, and generate warnings or
150  //! throw and exception if any are found.
151  virtual void validate(const std::string& name) {}
152 
153  //! Returns an integer representing the type of parameterization
154  virtual int reportType() const = 0;
155 
156  //! Number of terms in the temperature polynomial for this parameterization
157  virtual size_t temperaturePolySize() const { return 1; }
158 
159  //! Given the temperature *T*, compute the terms of the temperature
160  //! polynomial *T_poly*.
161  virtual void updateTemperaturePoly(double T, double* T_poly) const {
162  T_poly[0] = T;
163  }
164 
165  //! Update the properties for this species, given a temperature polynomial
166  /*!
167  * This method is called with a pointer to an array containing the functions
168  * of temperature needed by this parameterization, and three pointers to
169  * arrays where the computed property values should be written. This method
170  * updates only one value in each array.
171  *
172  * The form and length of the Temperature Polynomial may vary depending on
173  * the parameterization.
174  *
175  * @param tt vector of evaluated temperature functions
176  * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
177  * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
178  * @param s_R Vector of Dimensionless entropies. (length m_kk).
179  */
180  virtual void updateProperties(const doublereal* tt,
181  doublereal* cp_R, doublereal* h_RT,
182  doublereal* s_R) const;
183 
184  //! Compute the reference-state property of one species
185  /*!
186  * Given temperature T in K, this method updates the values of the non-
187  * dimensional heat capacity at constant pressure, enthalpy, and entropy, at
188  * the reference pressure, of the species.
189  *
190  * @param temp Temperature (Kelvin)
191  * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
192  * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
193  * @param s_R Vector of Dimensionless entropies. (length m_kk).
194  */
195  virtual void updatePropertiesTemp(const doublereal temp,
196  doublereal* cp_R,
197  doublereal* h_RT,
198  doublereal* s_R) const = 0;
199 
200  //! This utility function reports back the type of parameterization and all
201  //! of the parameters for the species.
202  /*!
203  * All parameters are output variables
204  *
205  * @param index Species index
206  * @param type Integer type of the standard type
207  * @param minTemp output - Minimum temperature
208  * @param maxTemp output - Maximum temperature
209  * @param refPressure output - reference pressure (Pa).
210  * @param coeffs Vector of coefficients used to set the
211  * parameters for the standard state.
212  */
213  virtual void reportParameters(size_t& index, int& type,
214  doublereal& minTemp, doublereal& maxTemp,
215  doublereal& refPressure,
216  doublereal* const coeffs) const = 0;
217 
218  //! Report the 298 K Heat of Formation of the standard state of one species
219  //! (J kmol-1)
220  /*!
221  * The 298K Heat of Formation is defined as the enthalpy change to create
222  * the standard state of the species from its constituent elements in their
223  * standard states at 298 K and 1 bar.
224  *
225  * @param h298 If this is nonnull, the current value of the Heat of
226  * Formation at 298K and 1 bar for species m_speciesIndex is
227  * returned in h298[m_speciesIndex].
228  * @return the current value of the Heat of Formation at 298K and 1 bar for
229  * species m_speciesIndex.
230  */
231  virtual doublereal reportHf298(doublereal* const h298 = 0) const;
232 
233  //! Modify the value of the 298 K Heat of Formation of one species in the
234  //! phase (J kmol-1)
235  /*!
236  * The 298K heat of formation is defined as the enthalpy change to create
237  * the standard state of the species from its constituent elements in their
238  * standard states at 298 K and 1 bar.
239  *
240  * @param k Species k
241  * @param Hf298New Specify the new value of the Heat of Formation at
242  * 298K and 1 bar
243  */
244  virtual void modifyOneHf298(const size_t k, const doublereal Hf298New);
245 
246  //! Restore the original heat of formation for this species
247  /*!
248  * Resets changes made by modifyOneHf298().
249  */
250  virtual void resetHf298() {
251  throw CanteraError("SpeciesThermoInterpType::resetHf298",
252  "Not implemented");
253  }
254 
255 protected:
256  //! lowest valid temperature
257  doublereal m_lowT;
258  //! Highest valid temperature
259  doublereal m_highT;
260  //! Reference state pressure
261  doublereal m_Pref;
262 };
263 
264 //! Class for the thermodynamic manager for an individual species' reference
265 //! state which uses the PDSS base class to satisfy the requests.
266 /*!
267  * This class is a pass-through class for handling thermodynamics calls for
268  * reference state thermo to an pressure dependent standard state (PDSS) class.
269  * For some situations, it makes no sense to have a reference state at all. One
270  * example of this is the real water standard state.
271  *
272  * What this class does is just to pass through the calls for thermo at (T, p0)
273  * to the PDSS class, which evaluates the calls at (T, p0).
274  *
275  * @ingroup spthermo
276  */
278 {
279 public:
280  //! Main Constructor
281  /*!
282  * @param PDSS_ptr Pointer to the PDSS object that handles calls for
283  * this object
284  */
285  explicit STITbyPDSS(PDSS* PDSS_ptr);
286 
287  virtual doublereal minTemp() const;
288  virtual doublereal maxTemp() const;
289  virtual doublereal refPressure() const;
290  virtual int reportType() const;
291 
292  virtual void updateProperties(const doublereal* tempPoly,
293  doublereal* cp_R, doublereal* h_RT,
294  doublereal* s_R) const;
295 
296  virtual void updatePropertiesTemp(const doublereal temp,
297  doublereal* cp_R,
298  doublereal* h_RT,
299  doublereal* s_R) const;
300 
301  virtual void reportParameters(size_t& index, int& type,
302  doublereal& minTemp, doublereal& maxTemp,
303  doublereal& refPressure,
304  doublereal* const coeffs) const;
305 
306 private:
307  //! Pointer to the PDSS object that handles calls for this object
308  /*!
309  * This object is not owned by the current one.
310  */
312 };
313 
314 }
315 
316 #endif
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.
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...
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).
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.
STITbyPDSS(PDSS *PDSS_ptr)
Main Constructor.
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:165
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 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: AnyMap.cpp:8
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...