Cantera  3.0.0
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 for species k.
122 /*!
123 * Returns the reference state pressure in Pascals for species k. If k is
124 * left out of the argument list, it returns the reference state pressure
125 * for the first species.
126 *
127 * @param k Species Index
128 * @deprecated The species index parameter is deprecated and will be removed after
129 * %Cantera 3.0. All species in a phase must have the same reference pressure.
130 */
131 virtual double refPressure(size_t k=npos) const;
132
133 //! This utility function reports the type of parameterization used for the
134 //! species with index number *index*.
135 /*!
136 * @param index Species index
137 */
138 virtual int reportType(size_t index) const;
139
140 //! This utility function reports back the type of parameterization and
141 //! all of the parameters for the species with index number *index*.
142 /*!
143 * @param index Species index
144 * @param type Integer type of the standard type
145 * @param c Vector of coefficients used to set the
146 * parameters for the standard state.
147 * @param minTemp output - Minimum temperature
148 * @param maxTemp output - Maximum temperature
149 * @param refPressure output - reference pressure (Pa).
150 */
151 virtual void reportParams(size_t index, int& type, double* const c, double& minTemp,
152 double& maxTemp, double& refPressure) const;
153
154 //! Report the 298 K Heat of Formation of the standard state of one species
155 //! (J kmol-1)
156 /*!
157 * The 298K Heat of Formation is defined as the enthalpy change to create
158 * the standard state of the species from its constituent elements in their
159 * standard states at 298 K and 1 bar.
160 *
161 * @param k species index
162 * @returns the current value of the Heat of Formation at 298K and 1 bar
163 */
164 virtual double reportOneHf298(const size_t k) const;
165
166 //! Modify the value of the 298 K Heat of Formation of the standard state of
167 //! one species in the phase (J kmol-1)
168 /*!
169 * The 298K heat of formation is defined as the enthalpy change to create
170 * the standard state of the species from its constituent elements in their
171 * standard states at 298 K and 1 bar.
172 *
173 * @param k Index of the species
174 * @param Hf298New Specify the new value of the Heat of Formation at
175 * 298K and 1 bar. units = J/kmol.
176 */
177 virtual void modifyOneHf298(const size_t k, const double Hf298New);
178
179 //! Restore the original heat of formation of one or more species
180 /*!
181 * Resets changes made by modifyOneHf298(). If the species index is not
182 * specified, the heats of formation for all species are restored.
183 */
184 virtual void resetHf298(const size_t k);
185
186 //! Check if data for all species (0 through nSpecies-1) has been installed.
187 bool ready(size_t nSpecies);
188
189private:
190 //! Provide the SpeciesThermoInterpType object
191 /*!
192 * @param k species index
193 * @return pointer to the SpeciesThermoInterpType object.
194 */
196 const SpeciesThermoInterpType* provideSTIT(size_t k) const;
197
198protected:
199 //! Mark species *k* as having its thermodynamic data installed
200 void markInstalled(size_t k);
201
202 typedef pair<size_t, shared_ptr<SpeciesThermoInterpType>> index_STIT;
203 typedef map<int, vector<index_STIT>> STIT_map;
204 typedef map<int, vector<double>> tpoly_map;
205
206 //! This is the main data structure, which contains the
207 //! SpeciesThermoInterpType objects, sorted by the parameterization type.
208 //! `m_sp[i]` is the vector of [species index, STIT] pairs which use
209 //! parameterization `i`.
210 STIT_map m_sp;
211
212 //! Temperature polynomials for each thermo parameterization
213 mutable tpoly_map m_tpoly;
214
215 //! Map from species index to location within #m_sp, such that
216 //! `m_sp[m_speciesLoc[k].first][m_speciesLoc[k].second]` is the
217 //! SpeciesThermoInterpType object for species `k`.
218 map<size_t, pair<int, size_t>> m_speciesLoc;
219
220 //! Maximum value of the lowest temperature
221 double m_tlow_max = 0.0;
222
223 //! Minimum value of the highest temperature
224 double m_thigh_min = 1e+30;
225
226 //! reference pressure (Pa)
227 double m_p0 = 0.0;
228
229 //! indicates if data for species has been installed
230 vector<bool> m_installed;
231};
232
233}
234
235#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.
double m_tlow_max
Maximum value of the lowest temperature.
virtual double refPressure(size_t k=npos) const
The reference-state pressure for species k.
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:195