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