Cantera  2.5.1
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"
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  * The most important member function for the SpeciesThermoInterpType class is
92  * the member function SpeciesThermoInterpType::updatePropertiesTemp(). The
93  * function calculates the values of Cp, H, and S for the specific species
94  * pertaining to this class.
95  *
96  * A key concept for reference states is that there is a maximum and a minimum
97  * temperature beyond which the thermodynamic formulation isn't valid. Calls
98  * for temperatures outside this range will cause the object to throw a
99  * CanteraError.
100  *
101  * @ingroup thermoprops
102  */
103 
104 //! Abstract Base class for the thermodynamic manager for an individual
105 //! species' reference state
106 /*!
107  * One key feature is that the update routines use the same form as the update
108  * routines in the MultiSpeciesThermo class. They update values of cp_R,
109  * s_R, and H_R.
110  *
111  * @ingroup spthermo
112  */
114 {
115 public:
117 
118  SpeciesThermoInterpType(double tlow, double thigh, double pref);
119 
120  // SpeciesThermoInterpType objects are not copyable or assignable
122  SpeciesThermoInterpType& operator=(const SpeciesThermoInterpType& b) = delete;
123 
124  virtual ~SpeciesThermoInterpType() {}
125 
126  //! Returns the minimum temperature that the thermo parameterization is
127  //! valid
128  virtual doublereal minTemp() const {
129  return m_lowT;
130  }
131 
132  //! Set the minimum temperature at which the thermo parameterization is valid
133  virtual void setMinTemp(double Tmin) {
134  m_lowT = Tmin;
135  }
136 
137  //! Returns the maximum temperature that the thermo parameterization is
138  //! valid
139  virtual doublereal maxTemp() const {
140  return m_highT;
141  }
142 
143  //! Set the maximum temperature at which the thermo parameterization is valid
144  virtual void setMaxTemp(double Tmax) {
145  m_highT = Tmax;
146  }
147 
148  //! Returns the reference pressure (Pa)
149  virtual doublereal refPressure() const {
150  return m_Pref;
151  }
152 
153  //! Set the reference pressure [Pa]
154  virtual void setRefPressure(double Pref) {
155  m_Pref = 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 { return 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;
208 
209  //! This utility function returns the number of coefficients
210  //! for a given type of species parameterization
211  virtual size_t nCoeffs() const;
212 
213  //! This utility function returns the type of parameterization and all
214  //! of the parameters for the species.
215  /*!
216  * All parameters are output variables
217  *
218  * @param index Species index
219  * @param type Integer type of the standard type
220  * @param minTemp output - Minimum temperature
221  * @param maxTemp output - Maximum temperature
222  * @param refPressure output - reference pressure (Pa).
223  * @param coeffs Vector of coefficients used to set the
224  * parameters for the standard state.
225  */
226  virtual void reportParameters(size_t& index, int& type,
227  doublereal& minTemp, doublereal& maxTemp,
228  doublereal& refPressure,
229  doublereal* const coeffs) const;
230 
231  //! Report the 298 K Heat of Formation of the standard state of one species
232  //! (J kmol-1)
233  /*!
234  * The 298K Heat of Formation is defined as the enthalpy change to create
235  * the standard state of the species from its constituent elements in their
236  * standard states at 298 K and 1 bar.
237  *
238  * @param h298 If this is nonnull, the current value of the Heat of
239  * Formation at 298K and 1 bar for species m_speciesIndex is
240  * returned in h298[m_speciesIndex].
241  * @return the current value of the Heat of Formation at 298K and 1 bar for
242  * species m_speciesIndex.
243  */
244  virtual doublereal reportHf298(doublereal* const h298 = 0) const;
245 
246  //! Modify the value of the 298 K Heat of Formation of one species in the
247  //! phase (J kmol-1)
248  /*!
249  * The 298K heat of formation is defined as the enthalpy change to create
250  * the standard state of the species from its constituent elements in their
251  * standard states at 298 K and 1 bar.
252  *
253  * @param k Species k
254  * @param Hf298New Specify the new value of the Heat of Formation at
255  * 298K and 1 bar
256  */
257  virtual void modifyOneHf298(const size_t k, const doublereal Hf298New);
258 
259  //! Restore the original heat of formation for this species
260  /*!
261  * Resets changes made by modifyOneHf298().
262  */
263  virtual void resetHf298() {
264  throw NotImplementedError("SpeciesThermoInterpType::resetHf298");
265  }
266 
267 protected:
268  //! lowest valid temperature
269  doublereal m_lowT;
270  //! Highest valid temperature
271  doublereal m_highT;
272  //! Reference state pressure
273  doublereal m_Pref;
274 };
275 
276 }
277 
278 #endif
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.
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 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.
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
This file contains definitions for utility functions and text for modules, inputfiles,...
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264
Contains const definitions for types of species reference-state thermodynamics managers (see Species ...