Cantera  3.1.0a1
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 
15 #include "cantera/base/ct_defs.h"
17 #include "cantera/base/AnyMap.h"
18 
19 namespace Cantera
20 {
21 
22 class 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 {
114 public:
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, 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 double* tt, double* cp_R, double* h_RT,
189  double* s_R) const;
190 
191  //! Compute the reference-state property of one species
192  /*!
193  * Given temperature T in K, this method updates the values of the non-
194  * dimensional heat capacity at constant pressure, enthalpy, and entropy, at
195  * the reference pressure, of the species.
196  *
197  * @param temp Temperature (Kelvin)
198  * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
199  * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
200  * @param s_R Vector of Dimensionless entropies. (length m_kk).
201  */
202  virtual void updatePropertiesTemp(const double temp,
203  double* cp_R,
204  double* h_RT,
205  double* s_R) const;
206 
207  //! This utility function returns the number of coefficients
208  //! for a given type of species parameterization
209  virtual size_t nCoeffs() const;
210 
211  //! This utility function returns the type of parameterization and all
212  //! of the parameters for the species.
213  /*!
214  * All parameters are output variables
215  *
216  * @param index Species index
217  * @param type Integer type of the standard type
218  * @param minTemp output - Minimum temperature
219  * @param maxTemp output - Maximum temperature
220  * @param refPressure output - reference pressure (Pa).
221  * @param coeffs Vector of coefficients used to set the
222  * parameters for the standard state.
223  */
224  virtual void reportParameters(size_t& index, int& type, double& minTemp,
225  double& maxTemp, double& refPressure,
226  double* const coeffs) const;
227 
228  //! Return the parameters of the species thermo object such that an
229  //! identical species thermo object could be reconstructed using the
230  //! newSpeciesThermo() function. Behavior specific to derived classes is
231  //! handled by the getParameters() method.
232  //! @param withInput If true, include additional input data fields associated
233  //! with the object, such as user-defined fields from a YAML input file, as
234  //! returned by the input() method.
235  AnyMap parameters(bool withInput=true) const;
236 
237  //! Report the 298 K Heat of Formation of the standard state of one species
238  //! (J kmol-1)
239  /*!
240  * The 298K Heat of Formation is defined as the enthalpy change to create
241  * the standard state of the species from its constituent elements in their
242  * standard states at 298 K and 1 bar.
243  *
244  * @param h298 If this is nonnull, the current value of the Heat of
245  * Formation at 298K and 1 bar for species m_speciesIndex is
246  * returned in h298[m_speciesIndex].
247  * @return the current value of the Heat of Formation at 298K and 1 bar for
248  * species m_speciesIndex.
249  */
250  virtual double reportHf298(double* const h298 = 0) const;
251 
252  //! Modify the value of the 298 K Heat of Formation of one species in the
253  //! phase (J kmol-1)
254  /*!
255  * The 298K heat of formation is defined as the enthalpy change to create
256  * the standard state of the species from its constituent elements in their
257  * standard states at 298 K and 1 bar.
258  *
259  * @param k Species k
260  * @param Hf298New Specify the new value of the Heat of Formation at
261  * 298K and 1 bar
262  */
263  virtual void modifyOneHf298(const size_t k, const double Hf298New);
264 
265  //! Restore the original heat of formation for this species
266  /*!
267  * Resets changes made by modifyOneHf298().
268  */
269  virtual void resetHf298() {
270  throw NotImplementedError("SpeciesThermoInterpType::resetHf298");
271  }
272 
273  //! Access input data associated with the species thermo definition
274  const AnyMap& input() const;
275  AnyMap& input();
276 
277 protected:
278  //! Store the parameters of the species thermo object such that an identical
279  //! species thermo object could be reconstructed using the
280  //! newSpeciesThermo() function.
281  virtual void getParameters(AnyMap& thermo) const;
282 
283  //! lowest valid temperature
284  double m_lowT = 0.0;
285  //! Highest valid temperature
286  double m_highT = 0.0;
287  //! Reference state pressure
288  double m_Pref = 0.0;
289 
290  AnyMap m_input;
291 };
292 
293 }
294 
295 #endif
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:427
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:195
Abstract Base class for the thermodynamic manager for an individual species' reference state.
virtual void updateProperties(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 reportParameters(size_t &index, int &type, double &minTemp, double &maxTemp, double &refPressure, double *const coeffs) const
This utility function returns the type of parameterization and all of the parameters for the species.
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.
virtual double reportHf298(double *const h298=0) const
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1)
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 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 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 setMinTemp(double Tmin)
Set the minimum temperature at which the thermo parameterization is valid.
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 double refPressure() const
Returns the reference pressure (Pa)
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:564