Cantera  4.0.0a1
Loading...
Searching...
No Matches
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:
115 SpeciesThermoInterpType() = default;
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() = default;
124
125 //! Returns the minimum temperature that the thermo parameterization is
126 //! valid
127 virtual double 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 double 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 double 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 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, span<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 an array view containing the functions of
176 * temperature needed by this parameterization, and three references where the
177 * computed property values should be written.
178 *
179 * The form and length of the Temperature Polynomial may vary depending on
180 * the parameterization.
181 *
182 * @param[in] tt vector of evaluated temperature functions
183 * @param[out] cp_R Dimensionless heat capacity
184 * @param[out] h_RT Dimensionless enthalpy
185 * @param[out] s_R Dimensionless entropy
186 */
187 virtual void updateProperties(span<const double> tt, double& cp_R,
188 double& h_RT, double& s_R) const;
189
190 //! Compute the reference-state property of one species
191 /*!
192 * Given temperature T in K, this method updates the values of the non-
193 * dimensional heat capacity at constant pressure, enthalpy, and entropy, at
194 * the reference pressure, of the species.
195 *
196 * @param[in] temp Temperature (Kelvin)
197 * @param[out] cp_R Dimensionless heat capacity
198 * @param[out] h_RT Dimensionless enthalpy
199 * @param[out] s_R Dimensionless entropy
200 */
201 virtual void updatePropertiesTemp(const double temp, double& cp_R,
202 double& h_RT, double& s_R) const;
203
204 //! This utility function returns the number of coefficients
205 //! for a given type of species parameterization
206 virtual size_t nCoeffs() const;
207
208 //! This utility function returns the type of parameterization and all
209 //! of the parameters for the species.
210 /*!
211 * All parameters are output variables
212 *
213 * @param index Species index
214 * @param type Integer type of the standard type
215 * @param minTemp output - Minimum temperature
216 * @param maxTemp output - Maximum temperature
217 * @param refPressure output - reference pressure (Pa).
218 * @param coeffs Vector of coefficients used to set the
219 * parameters for the standard state.
220 */
221 virtual void reportParameters(size_t& index, int& type, double& minTemp,
222 double& maxTemp, double& refPressure,
223 span<double> coeffs) const;
224
225 //! Return the parameters of the species thermo object such that an
226 //! identical species thermo object could be reconstructed using the
227 //! newSpeciesThermo() function. Behavior specific to derived classes is
228 //! handled by the getParameters() method.
229 //! @param withInput If true, include additional input data fields associated
230 //! with the object, such as user-defined fields from a YAML input file, as
231 //! returned by the input() method.
232 AnyMap parameters(bool withInput=true) const;
233
234 //! Report the 298 K Heat of Formation of the standard state of one species
235 //! (J kmol-1)
236 /*!
237 * The 298K Heat of Formation is defined as the enthalpy change to create
238 * the standard state of the species from its constituent elements in their
239 * standard states at 298 K and 1 bar.
240 *
241 * @since Removed redundant output argument in %Cantera 4.0.
242 */
243 virtual double reportHf298() const;
244
245 //! Modify the value of the 298 K Heat of Formation of one species in the
246 //! phase (J kmol-1)
247 /*!
248 * The 298K heat of formation is defined as the enthalpy change to create
249 * the standard state of the species from its constituent elements in their
250 * standard states at 298 K and 1 bar.
251 *
252 * @param k Species k
253 * @param Hf298New Specify the new value of the Heat of Formation at
254 * 298K and 1 bar
255 */
256 virtual void modifyOneHf298(const size_t k, const double Hf298New);
257
258 //! Restore the original heat of formation for this species
259 /*!
260 * Resets changes made by modifyOneHf298().
261 */
262 virtual void resetHf298() {
263 throw NotImplementedError("SpeciesThermoInterpType::resetHf298");
264 }
265
266 //! Access input data associated with the species thermo definition
267 const AnyMap& input() const;
268 AnyMap& input();
269
270protected:
271 //! Store the parameters of the species thermo object such that an identical
272 //! species thermo object could be reconstructed using the
273 //! newSpeciesThermo() function.
274 virtual void getParameters(AnyMap& thermo) const;
275
276 //! lowest valid temperature
277 double m_lowT = 0.0;
278 //! Highest valid temperature
279 double m_highT = 0.0;
280 //! Reference state pressure
281 double m_Pref = 0.0;
282
283 AnyMap m_input;
284};
285
286}
287
288#endif
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:431
An error indicating that an unimplemented function has been called.
Abstract Base class for the thermodynamic manager for an individual species' reference state.
virtual double minTemp() const
Returns the minimum temperature that the thermo parameterization is valid.
virtual double maxTemp() const
Returns the maximum temperature that the thermo parameterization is valid.
double m_Pref
Reference state pressure.
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 void reportParameters(size_t &index, int &type, double &minTemp, double &maxTemp, double &refPressure, span< double > coeffs) const
This utility function returns the type of parameterization and all of the parameters for the species.
virtual void updateTemperaturePoly(double T, span< double > T_poly) const
Given the temperature T, compute the terms of the temperature polynomial T_poly.
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.
virtual void validate(const string &name)
Check for problems with the parameterization, and generate warnings or throw and exception if any are...
virtual void updatePropertiesTemp(const double temp, double &cp_R, double &h_RT, double &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...
double m_lowT
lowest valid temperature
virtual void updateProperties(span< const double > tt, double &cp_R, double &h_RT, double &s_R) const
Update the properties for this species, given a temperature polynomial.
virtual void setMinTemp(double Tmin)
Set the minimum temperature at which the thermo parameterization is valid.
virtual double refPressure() const
Returns the reference pressure (Pa)
virtual double reportHf298() const
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1)
double m_highT
Highest valid temperature.
virtual size_t temperaturePolySize() const
Number of terms in the temperature polynomial for this parameterization.
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.
const AnyMap & input() const
Access input data associated with the species thermo definition.
virtual void modifyOneHf298(const size_t k, const double Hf298New)
Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1)
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.cpp:595