Cantera  4.0.0a1
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, span<double> cp_R, span<double> h_RT,
98 span<double> s_R) const;
99
100 //! Minimum temperature.
101 /*!
102 * If no argument is supplied, this method returns the minimum temperature
103 * for which @e all parameterizations are valid. If an integer index k is
104 * supplied, then the value returned is the minimum temperature for
105 * species k in the phase.
106 *
107 * @param k Species index
108 */
109 virtual double minTemp(size_t k=npos) const;
110
111 //! Maximum temperature.
112 /*!
113 * If no argument is supplied, this method returns the maximum temperature
114 * for which @e all parameterizations are valid. If an integer index k is
115 * supplied, then the value returned is the maximum temperature for
116 * parameterization k.
117 *
118 * @param k Species Index
119 */
120 virtual double maxTemp(size_t k=npos) const;
121
122 //! The reference-state pressure (Pa) for all species
123 virtual double refPressure() const;
124
125 //! This utility function reports the type of parameterization used for the
126 //! species with index number *index*.
127 /*!
128 * @param index Species index
129 */
130 virtual int reportType(size_t index) const;
131
132 //! This utility function reports back the type of parameterization and
133 //! all of the parameters for the species with index number *index*.
134 /*!
135 * @param index Species index
136 * @param type Integer type of the standard type
137 * @param c Vector of coefficients used to set the
138 * parameters for the standard state.
139 * @param minTemp output - Minimum temperature
140 * @param maxTemp output - Maximum temperature
141 * @param refPressure output - reference pressure (Pa).
142 */
143 virtual void reportParams(size_t index, int& type, span<double> c,
144 double& minTemp, double& maxTemp,
145 double& refPressure) const;
146
147 //! Report the 298 K Heat of Formation of the standard state of one species
148 //! (J kmol-1)
149 /*!
150 * The 298K Heat of Formation is defined as the enthalpy change to create
151 * the standard state of the species from its constituent elements in their
152 * standard states at 298 K and 1 bar.
153 *
154 * @param k species index
155 * @returns the current value of the Heat of Formation at 298K and 1 bar
156 */
157 virtual double reportOneHf298(const size_t k) const;
158
159 //! Modify the value of the 298 K Heat of Formation of the standard state of
160 //! one species in the phase (J kmol-1)
161 /*!
162 * The 298K heat of formation is defined as the enthalpy change to create
163 * the standard state of the species from its constituent elements in their
164 * standard states at 298 K and 1 bar.
165 *
166 * @param k Index of the species
167 * @param Hf298New Specify the new value of the Heat of Formation at
168 * 298K and 1 bar. units = J/kmol.
169 */
170 virtual void modifyOneHf298(const size_t k, const double Hf298New);
171
172 //! Restore the original heat of formation of one or more species
173 /*!
174 * Resets changes made by modifyOneHf298(). If the species index is not
175 * specified, the heats of formation for all species are restored.
176 */
177 virtual void resetHf298(const size_t k);
178
179 //! Check if data for all species (0 through nSpecies-1) has been installed.
180 bool ready(size_t nSpecies);
181
182private:
183 //! Provide the SpeciesThermoInterpType object
184 /*!
185 * @param k species index
186 * @return pointer to the SpeciesThermoInterpType object.
187 */
189 const SpeciesThermoInterpType* provideSTIT(size_t k) const;
190
191protected:
192 //! Mark species *k* as having its thermodynamic data installed
193 void markInstalled(size_t k);
194
195 typedef pair<size_t, shared_ptr<SpeciesThermoInterpType>> index_STIT;
196 typedef map<int, vector<index_STIT>> STIT_map;
197 typedef map<int, vector<double>> tpoly_map;
198
199 //! This is the main data structure, which contains the
200 //! SpeciesThermoInterpType objects, sorted by the parameterization type.
201 //! `m_sp[i]` is the vector of [species index, STIT] pairs which use
202 //! parameterization `i`.
203 STIT_map m_sp;
204
205 //! Temperature polynomials for each thermo parameterization
206 mutable tpoly_map m_tpoly;
207
208 //! Map from species index to location within #m_sp, such that
209 //! `m_sp[m_speciesLoc[k].first][m_speciesLoc[k].second]` is the
210 //! SpeciesThermoInterpType object for species `k`.
211 map<size_t, pair<int, size_t>> m_speciesLoc;
212
213 //! Maximum value of the lowest temperature
214 double m_tlow_max = 0.0;
215
216 //! Minimum value of the highest temperature
217 double m_thigh_min = 1e+30;
218
219 //! reference pressure (Pa)
220 double m_p0 = 0.0;
221
222 //! indicates if data for species has been installed
223 vector<bool> m_installed;
224};
225
226}
227
228#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.
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 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.
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 void update(double T, span< double > cp_R, span< double > h_RT, span< double > s_R) const
Compute the reference-state properties for all species.
virtual double minTemp(size_t k=npos) const
Minimum temperature.
virtual void reportParams(size_t index, int &type, span< double > 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...
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.
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 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:595
const size_t npos
index returned by functions to indicate "no position"
Definition ct_defs.h:183