Cantera  3.1.0a2
Loading...
Searching...
No Matches
MultiSpeciesThermo.h
Go to the documentation of this file.
1/**
2 * @file MultiSpeciesThermo.h
3 * Header for a general species thermodynamic property manager for a phase (see
4 * @link Cantera::MultiSpeciesThermo MultiSpeciesThermo@endlink).
5 */
6
7// This file is part of Cantera. See License.txt in the top-level directory or
8// at https://cantera.org/license.txt for license and copyright information.
9
10#ifndef CT_MULTISPECIESTHERMO_H
11#define CT_MULTISPECIESTHERMO_H
12
14
15namespace Cantera
16{
17
18//! A species thermodynamic property manager for a phase.
19/*!
20 * This is a general manager that can handle a wide variety of species
21 * thermodynamic polynomials for individual species and compute their
22 * nondimensional, reference-state thermodynamic properties (that is, as a function
23 * of temperature only).
24 *
25 * The ThermoPhase object relies on MultiSpeciesThermo to calculate the
26 * thermodynamic properties of the reference state for all of the species in the
27 * phase, for a range of temperatures. Note, the pressure dependence of the
28 * species thermodynamic functions is not handled at this level. Species using
29 * the same parameterization are grouped together in order to minimize the
30 * operation count and achieve better efficiency.
31 *
32 * The most important member function for the MultiSpeciesThermo class is the
33 * member function MultiSpeciesThermo::update(). The function calculates the
34 * values of Cp/R, H/RT, and S/R for all of the species at once at the specified
35 * temperature.
36 *
37 * Usually, all of the species in a phase are installed into a
38 * MultiSpeciesThermo object. However, there is no requirement that a
39 * MultiSpeciesThermo object handles all of the species in a phase. The member
40 * function
41 * @link MultiSpeciesThermo::install_STIT() install_STIT()@endlink
42 * is called to install each species into the MultiSpeciesThermo object.
43 *
44 * @ingroup spthermo
45 */
47{
48public:
49 //! Constructor
50 MultiSpeciesThermo() = default;
51
52 // MultiSpeciesThermo objects are not copyable or assignable
53 MultiSpeciesThermo(const MultiSpeciesThermo& b) = delete;
54 MultiSpeciesThermo& operator=(const MultiSpeciesThermo& b) = delete;
55 virtual ~MultiSpeciesThermo() = default;
56
57 //! Install a new species thermodynamic property parameterization for one
58 //! species.
59 /*!
60 * @param index Index of the species being installed
61 * @param stit Pointer to the SpeciesThermoInterpType object
62 * This will set up the thermo for one species
63 */
64 virtual void install_STIT(size_t index,
65 shared_ptr<SpeciesThermoInterpType> stit);
66
67 //! Modify the species thermodynamic property parameterization for a species
68 /*!
69 * @param index Index of the species being installed
70 * @param spec Pointer to the SpeciesThermoInterpType object
71 */
72 virtual void modifySpecies(size_t index,
73 shared_ptr<SpeciesThermoInterpType> spec);
74
75 //! Get reference-state properties for a single species
76 /*!
77 * @param k species index
78 * @param T Temperature (Kelvin)
79 * @param cp_R Dimensionless heat capacity
80 * @param h_RT Dimensionless enthalpy
81 * @param s_R Dimensionless entropy
82 */
83 virtual void update_single(size_t k, double T, double* cp_R,
84 double* h_RT, double* s_R) const;
85
86 //! Compute the reference-state properties for all species.
87 /*!
88 * Given temperature T in K, this method updates the values of the non-
89 * dimensional heat capacity at constant pressure, enthalpy, and entropy,
90 * at the reference pressure, Pref of each of the standard states.
91 *
92 * @param T Temperature (Kelvin)
93 * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
94 * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
95 * @param s_R Vector of Dimensionless entropies. (length m_kk).
96 */
97 virtual void update(double T, double* cp_R, double* h_RT, double* s_R) const;
98
99 //! Minimum temperature.
100 /*!
101 * If no argument is supplied, this method returns the minimum temperature
102 * for which @e all parameterizations are valid. If an integer index k is
103 * supplied, then the value returned is the minimum temperature for
104 * species k in the phase.
105 *
106 * @param k Species index
107 */
108 virtual double minTemp(size_t k=npos) const;
109
110 //! Maximum temperature.
111 /*!
112 * If no argument is supplied, this method returns the maximum temperature
113 * for which @e all parameterizations are valid. If an integer index k is
114 * supplied, then the value returned is the maximum temperature for
115 * parameterization k.
116 *
117 * @param k Species Index
118 */
119 virtual double maxTemp(size_t k=npos) const;
120
121 //! The reference-state pressure (Pa) for all species
122 virtual double refPressure() const;
123
124 //! This utility function reports the type of parameterization used for the
125 //! species with index number *index*.
126 /*!
127 * @param index Species index
128 */
129 virtual int reportType(size_t index) const;
130
131 //! This utility function reports back the type of parameterization and
132 //! all of the parameters for the species with index number *index*.
133 /*!
134 * @param index Species index
135 * @param type Integer type of the standard type
136 * @param c Vector of coefficients used to set the
137 * parameters for the standard state.
138 * @param minTemp output - Minimum temperature
139 * @param maxTemp output - Maximum temperature
140 * @param refPressure output - reference pressure (Pa).
141 */
142 virtual void reportParams(size_t index, int& type, double* const c, double& minTemp,
143 double& maxTemp, double& refPressure) const;
144
145 //! Report the 298 K Heat of Formation of the standard state of one species
146 //! (J kmol-1)
147 /*!
148 * The 298K Heat of Formation is defined as the enthalpy change to create
149 * the standard state of the species from its constituent elements in their
150 * standard states at 298 K and 1 bar.
151 *
152 * @param k species index
153 * @returns the current value of the Heat of Formation at 298K and 1 bar
154 */
155 virtual double reportOneHf298(const size_t k) const;
156
157 //! Modify the value of the 298 K Heat of Formation of the standard state of
158 //! one species in the phase (J kmol-1)
159 /*!
160 * The 298K heat of formation is defined as the enthalpy change to create
161 * the standard state of the species from its constituent elements in their
162 * standard states at 298 K and 1 bar.
163 *
164 * @param k Index of the species
165 * @param Hf298New Specify the new value of the Heat of Formation at
166 * 298K and 1 bar. units = J/kmol.
167 */
168 virtual void modifyOneHf298(const size_t k, const double Hf298New);
169
170 //! Restore the original heat of formation of one or more species
171 /*!
172 * Resets changes made by modifyOneHf298(). If the species index is not
173 * specified, the heats of formation for all species are restored.
174 */
175 virtual void resetHf298(const size_t k);
176
177 //! Check if data for all species (0 through nSpecies-1) has been installed.
178 bool ready(size_t nSpecies);
179
180private:
181 //! Provide the SpeciesThermoInterpType object
182 /*!
183 * @param k species index
184 * @return pointer to the SpeciesThermoInterpType object.
185 */
187 const SpeciesThermoInterpType* provideSTIT(size_t k) const;
188
189protected:
190 //! Mark species *k* as having its thermodynamic data installed
191 void markInstalled(size_t k);
192
193 typedef pair<size_t, shared_ptr<SpeciesThermoInterpType>> index_STIT;
194 typedef map<int, vector<index_STIT>> STIT_map;
195 typedef map<int, vector<double>> tpoly_map;
196
197 //! This is the main data structure, which contains the
198 //! SpeciesThermoInterpType objects, sorted by the parameterization type.
199 //! `m_sp[i]` is the vector of [species index, STIT] pairs which use
200 //! parameterization `i`.
201 STIT_map m_sp;
202
203 //! Temperature polynomials for each thermo parameterization
204 mutable tpoly_map m_tpoly;
205
206 //! Map from species index to location within #m_sp, such that
207 //! `m_sp[m_speciesLoc[k].first][m_speciesLoc[k].second]` is the
208 //! SpeciesThermoInterpType object for species `k`.
209 map<size_t, pair<int, size_t>> m_speciesLoc;
210
211 //! Maximum value of the lowest temperature
212 double m_tlow_max = 0.0;
213
214 //! Minimum value of the highest temperature
215 double m_thigh_min = 1e+30;
216
217 //! reference pressure (Pa)
218 double m_p0 = 0.0;
219
220 //! indicates if data for species has been installed
221 vector<bool> m_installed;
222};
223
224}
225
226#endif
Pure Virtual Base class for individual species reference state thermodynamic managers and text for th...
A species thermodynamic property manager for a phase.
bool ready(size_t nSpecies)
Check if data for all species (0 through nSpecies-1) has been installed.
MultiSpeciesThermo()=default
Constructor.
STIT_map m_sp
This is the main data structure, which contains the SpeciesThermoInterpType objects,...
SpeciesThermoInterpType * provideSTIT(size_t k)
Provide the SpeciesThermoInterpType object.
virtual void update(double T, double *cp_R, double *h_RT, double *s_R) const
Compute the reference-state properties for all species.
double m_p0
reference pressure (Pa)
virtual void install_STIT(size_t index, shared_ptr< SpeciesThermoInterpType > stit)
Install a new species thermodynamic property parameterization for one species.
void markInstalled(size_t k)
Mark species k as having its thermodynamic data installed.
virtual double refPressure() const
The reference-state pressure (Pa) for all species.
double m_tlow_max
Maximum value of the lowest temperature.
virtual void modifySpecies(size_t index, shared_ptr< SpeciesThermoInterpType > spec)
Modify the species thermodynamic property parameterization for a species.
virtual int reportType(size_t index) const
This utility function reports the type of parameterization used for the species with index number ind...
virtual double minTemp(size_t k=npos) const
Minimum temperature.
tpoly_map m_tpoly
Temperature polynomials for each thermo parameterization.
double m_thigh_min
Minimum value of the highest temperature.
virtual double maxTemp(size_t k=npos) const
Maximum temperature.
virtual void update_single(size_t k, double T, double *cp_R, double *h_RT, double *s_R) const
Get reference-state properties for a single species.
map< size_t, pair< int, size_t > > m_speciesLoc
Map from species index to location within m_sp, such that m_sp[m_speciesLoc[k].first][m_speciesLoc[k]...
vector< bool > m_installed
indicates if data for species has been installed
virtual void modifyOneHf298(const size_t k, const double Hf298New)
Modify the value of the 298 K Heat of Formation of the standard state of one species in the phase (J ...
virtual void reportParams(size_t index, int &type, double *const c, double &minTemp, double &maxTemp, double &refPressure) const
This utility function reports back the type of parameterization and all of the parameters for the spe...
virtual void resetHf298(const size_t k)
Restore the original heat of formation of one or more species.
virtual double reportOneHf298(const size_t k) const
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1)
Abstract Base class for the thermodynamic manager for an individual species' reference state.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
const size_t npos
index returned by functions to indicate "no position"
Definition ct_defs.h:180