Cantera 2.6.0

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
13#include "SpeciesThermoInterpType.h"
14
15 namespace 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 */
46 class MultiSpeciesThermo
47{
48 public:
49 //! Constructor
50 MultiSpeciesThermo();
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() {}
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(doublereal T, doublereal* cp_R,
98 doublereal* h_RT, doublereal* 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 doublereal 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 doublereal maxTemp(size_t k=npos) const;
121
122 //! The reference-state pressure for species k.
123 /*!
124 * Returns the reference state pressure in Pascals for species k. If k is
125 * left out of the argument list, it returns the reference state pressure
126 * for the first species.
127 *
128 * @param k Species Index
129 */
130 virtual doublereal refPressure(size_t k=npos) const;
131
132 //! This utility function reports the type of parameterization used for the
133 //! species with index number *index*.
134 /*!
135 * @param index Species index
136 */
137 virtual int reportType(size_t index) const;
138
139 //! This utility function reports back the type of parameterization and
140 //! all of the parameters for the species with index number *index*.
141 /*!
142 * @param index Species index
143 * @param type Integer type of the standard type
144 * @param c Vector of coefficients used to set the
145 * parameters for the standard state.
146 * @param minTemp output - Minimum temperature
147 * @param maxTemp output - Maximum temperature
148 * @param refPressure output - reference pressure (Pa).
149 */
150 virtual void reportParams(size_t index, int& type,
151 doublereal* const c,
152 doublereal& minTemp,
153 doublereal& maxTemp,
154 doublereal& refPressure) const;
155
156 //! Report the 298 K Heat of Formation of the standard state of one species
157 //! (J kmol-1)
158 /*!
159 * The 298K Heat of Formation is defined as the enthalpy change to create
160 * the standard state of the species from its constituent elements in their
161 * standard states at 298 K and 1 bar.
162 *
163 * @param k species index
164 * @returns the current value of the Heat of Formation at 298K and 1 bar
165 */
166 virtual doublereal reportOneHf298(const size_t k) const;
167
168 //! Modify the value of the 298 K Heat of Formation of the standard state of
169 //! one species in the phase (J kmol-1)
170 /*!
171 * The 298K heat of formation is defined as the enthalpy change to create
172 * the standard state of the species from its constituent elements in their
173 * standard states at 298 K and 1 bar.
174 *
175 * @param k Index of the species
176 * @param Hf298New Specify the new value of the Heat of Formation at
177 * 298K and 1 bar. units = J/kmol.
178 */
179 virtual void modifyOneHf298(const size_t k, const doublereal Hf298New);
180
181 //! Restore the original heat of formation of one or more species
182 /*!
183 * Resets changes made by modifyOneHf298(). If the species index is not
184 * specified, the heats of formation for all species are restored.
185 */
186 virtual void resetHf298(const size_t k);
187
188 //! Check if data for all species (0 through nSpecies-1) has been installed.
189 bool ready(size_t nSpecies);
190
191 private:
192 //! Provide the SpeciesThermoInterpType object
193 /*!
194 * @param k species index
195 * @return pointer to the SpeciesThermoInterpType object.
196 */
197 SpeciesThermoInterpType* provideSTIT(size_t k);
198 const SpeciesThermoInterpType* provideSTIT(size_t k) const;
199
200 protected:
201 //! Mark species *k* as having its thermodynamic data installed
202 void markInstalled(size_t k);
203
204 typedef std::pair<size_t, shared_ptr<SpeciesThermoInterpType> > index_STIT;
205 typedef std::map<int, std::vector<index_STIT> > STIT_map;
206 typedef std::map<int, vector_fp> tpoly_map;
207
208 //! This is the main data structure, which contains the
209 //! SpeciesThermoInterpType objects, sorted by the parameterization type.
210 //! `m_sp[i]` is the vector of [species index, STIT] pairs which use
211 //! parameterization `i`.
212 STIT_map m_sp;
213
214 //! Temperature polynomials for each thermo parameterization
215 mutable tpoly_map m_tpoly;
216
217 //! Map from species index to location within #m_sp, such that
218 //! `m_sp[m_speciesLoc[k].first][m_speciesLoc[k].second]` is the
219 //! SpeciesThermoInterpType object for species `k`.
220 std::map<size_t, std::pair<int, size_t> > m_speciesLoc;
221
222 //! Maximum value of the lowest temperature
223 doublereal m_tlow_max;
224
225 //! Minimum value of the highest temperature
226 doublereal m_thigh_min;
227
228 //! reference pressure (Pa)
229 doublereal m_p0;
230
231 //! indicates if data for species has been installed
232 std::vector<bool> m_installed;
233};
234
235}
236
237#endif
SpeciesThermoInterpType.h
Pure Virtual Base class for individual species reference state thermodynamic managers and text for th...
Cantera::MultiSpeciesThermo
A species thermodynamic property manager for a phase.
Definition: MultiSpeciesThermo.h:47
Cantera::MultiSpeciesThermo::ready
bool ready(size_t nSpecies)
Check if data for all species (0 through nSpecies-1) has been installed.
Definition: MultiSpeciesThermo.cpp:208
Cantera::MultiSpeciesThermo::minTemp
virtual doublereal minTemp(size_t k=npos) const
Minimum temperature.
Definition: MultiSpeciesThermo.cpp:129
Cantera::MultiSpeciesThermo::m_sp
STIT_map m_sp
This is the main data structure, which contains the SpeciesThermoInterpType objects,...
Definition: MultiSpeciesThermo.h:212
Cantera::MultiSpeciesThermo::MultiSpeciesThermo
MultiSpeciesThermo()
Constructor.
Definition: MultiSpeciesThermo.cpp:19
Cantera::MultiSpeciesThermo::provideSTIT
SpeciesThermoInterpType * provideSTIT(size_t k)
Provide the SpeciesThermoInterpType object.
Definition: MultiSpeciesThermo.cpp:162
Cantera::MultiSpeciesThermo::install_STIT
virtual void install_STIT(size_t index, shared_ptr< SpeciesThermoInterpType > stit)
Install a new species thermodynamic property parameterization for one species.
Definition: MultiSpeciesThermo.cpp:26
Cantera::MultiSpeciesThermo::refPressure
virtual doublereal refPressure(size_t k=npos) const
The reference-state pressure for species k.
Definition: MultiSpeciesThermo.cpp:151
Cantera::MultiSpeciesThermo::markInstalled
void markInstalled(size_t k)
Mark species k as having its thermodynamic data installed.
Definition: MultiSpeciesThermo.cpp:220
Cantera::MultiSpeciesThermo::m_installed
std::vector< bool > m_installed
indicates if data for species has been installed
Definition: MultiSpeciesThermo.h:232
Cantera::MultiSpeciesThermo::modifyOneHf298
virtual void modifyOneHf298(const size_t k, const doublereal Hf298New)
Modify the value of the 298 K Heat of Formation of the standard state of one species in the phase (J ...
Definition: MultiSpeciesThermo.cpp:192
Cantera::MultiSpeciesThermo::modifySpecies
virtual void modifySpecies(size_t index, shared_ptr< SpeciesThermoInterpType > spec)
Modify the species thermodynamic property parameterization for a species.
Definition: MultiSpeciesThermo.cpp:49
Cantera::MultiSpeciesThermo::reportType
virtual int reportType(size_t index) const
This utility function reports the type of parameterization used for the species with index number ind...
Definition: MultiSpeciesThermo.cpp:106
Cantera::MultiSpeciesThermo::reportOneHf298
virtual doublereal reportOneHf298(const size_t k) const
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1)
Definition: MultiSpeciesThermo.cpp:182
Cantera::MultiSpeciesThermo::m_thigh_min
doublereal m_thigh_min
Minimum value of the highest temperature.
Definition: MultiSpeciesThermo.h:226
Cantera::MultiSpeciesThermo::update
virtual void update(doublereal T, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Compute the reference-state properties for all species.
Definition: MultiSpeciesThermo.cpp:90
Cantera::MultiSpeciesThermo::reportParams
virtual void reportParams(size_t index, int &type, doublereal *const c, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure) const
This utility function reports back the type of parameterization and all of the parameters for the spe...
Definition: MultiSpeciesThermo.cpp:115
Cantera::MultiSpeciesThermo::m_tpoly
tpoly_map m_tpoly
Temperature polynomials for each thermo parameterization.
Definition: MultiSpeciesThermo.h:215
Cantera::MultiSpeciesThermo::m_speciesLoc
std::map< size_t, std::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]...
Definition: MultiSpeciesThermo.h:220
Cantera::MultiSpeciesThermo::m_p0
doublereal m_p0
reference pressure (Pa)
Definition: MultiSpeciesThermo.h:229
Cantera::MultiSpeciesThermo::update_single
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.
Definition: MultiSpeciesThermo.cpp:81
Cantera::MultiSpeciesThermo::maxTemp
virtual doublereal maxTemp(size_t k=npos) const
Maximum temperature.
Definition: MultiSpeciesThermo.cpp:140
Cantera::MultiSpeciesThermo::m_tlow_max
doublereal m_tlow_max
Maximum value of the lowest temperature.
Definition: MultiSpeciesThermo.h:223
Cantera::MultiSpeciesThermo::resetHf298
virtual void resetHf298(const size_t k)
Restore the original heat of formation of one or more species.
Definition: MultiSpeciesThermo.cpp:200
Cantera::SpeciesThermoInterpType
Abstract Base class for the thermodynamic manager for an individual species' reference state.
Definition: SpeciesThermoInterpType.h:113
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557
Cantera::npos
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:192