Cantera  2.4.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 http://www.cantera.org/license.txt for license and copyright information.
9 
10 #ifndef CT_MULTISPECIESTHERMO_H
11 #define CT_MULTISPECIESTHERMO_H
12 
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 (i.e. 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 {
48 public:
49  //! Constructor
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  //! Like update(), but only updates the single species k.
76  /*!
77  * @param k species index
78  * @param T Temperature (Kelvin)
79  * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
80  * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
81  * @param s_R Vector of Dimensionless entropies. (length m_kk).
82  * @deprecated Use update_single() instead.
83  * To be removed after Cantera 2.4.
84  */
85  virtual void update_one(size_t k, doublereal T, doublereal* cp_R,
86  doublereal* h_RT,
87  doublereal* s_R) const;
88 
89  //! Like update_one, but without applying offsets to the output pointers
90  /*!
91  * @param k species index
92  * @param T Temperature (Kelvin)
93  * @param cp_R Dimensionless heat capacity
94  * @param h_RT Dimensionless enthalpy
95  * @param s_R Dimensionless entropy
96  */
97  virtual void update_single(size_t k, double T, double* cp_R,
98  double* h_RT, double* s_R) const;
99 
100  //! Compute the reference-state properties for all species.
101  /*!
102  * Given temperature T in K, this method updates the values of the non-
103  * dimensional heat capacity at constant pressure, enthalpy, and entropy,
104  * at the reference pressure, Pref of each of the standard states.
105  *
106  * @param T Temperature (Kelvin)
107  * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
108  * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
109  * @param s_R Vector of Dimensionless entropies. (length m_kk).
110  */
111  virtual void update(doublereal T, doublereal* cp_R,
112  doublereal* h_RT, doublereal* s_R) const;
113 
114  //! Minimum temperature.
115  /*!
116  * If no argument is supplied, this method returns the minimum temperature
117  * for which \e all parameterizations are valid. If an integer index k is
118  * supplied, then the value returned is the minimum temperature for
119  * species k in the phase.
120  *
121  * @param k Species index
122  */
123  virtual doublereal minTemp(size_t k=npos) const;
124 
125  //! Maximum temperature.
126  /*!
127  * If no argument is supplied, this method returns the maximum temperature
128  * for which \e all parameterizations are valid. If an integer index k is
129  * supplied, then the value returned is the maximum temperature for
130  * parameterization k.
131  *
132  * @param k Species Index
133  */
134  virtual doublereal maxTemp(size_t k=npos) const;
135 
136  //! The reference-state pressure for species k.
137  /*!
138  * Returns the reference state pressure in Pascals for species k. If k is
139  * left out of the argument list, it returns the reference state pressure
140  * for the first species.
141  *
142  * @param k Species Index
143  */
144  virtual doublereal refPressure(size_t k=npos) const;
145 
146  //! This utility function reports the type of parameterization used for the
147  //! species with index number *index*.
148  /*!
149  * @param index Species index
150  */
151  virtual int reportType(size_t index) const;
152 
153  //! This utility function reports back the type of parameterization and
154  //! all of the parameters for the species with index number *index*.
155  /*!
156  * @param index Species index
157  * @param type Integer type of the standard type
158  * @param c Vector of coefficients used to set the
159  * parameters for the standard state.
160  * @param minTemp output - Minimum temperature
161  * @param maxTemp output - Maximum temperature
162  * @param refPressure output - reference pressure (Pa).
163  */
164  virtual void reportParams(size_t index, int& type,
165  doublereal* const c,
166  doublereal& minTemp,
167  doublereal& maxTemp,
168  doublereal& refPressure) const;
169 
170  //! Report the 298 K Heat of Formation of the standard state of one species
171  //! (J kmol-1)
172  /*!
173  * The 298K Heat of Formation is defined as the enthalpy change to create
174  * the standard state of the species from its constituent elements in their
175  * standard states at 298 K and 1 bar.
176  *
177  * @param k species index
178  * @returns the current value of the Heat of Formation at 298K and 1 bar
179  */
180  virtual doublereal reportOneHf298(const size_t k) const;
181 
182  //! Modify the value of the 298 K Heat of Formation of the standard state of
183  //! one species in the phase (J kmol-1)
184  /*!
185  * The 298K heat of formation is defined as the enthalpy change to create
186  * the standard state of the species from its constituent elements in their
187  * standard states at 298 K and 1 bar.
188  *
189  * @param k Index of the species
190  * @param Hf298New Specify the new value of the Heat of Formation at
191  * 298K and 1 bar. units = J/kmol.
192  */
193  virtual void modifyOneHf298(const size_t k, const doublereal Hf298New);
194 
195  //! Restore the original heat of formation of one or more species
196  /*!
197  * Resets changes made by modifyOneHf298(). If the species index is not
198  * specified, the heats of formation for all species are restored.
199  */
200  virtual void resetHf298(const size_t k);
201 
202  //! Check if data for all species (0 through nSpecies-1) has been installed.
203  bool ready(size_t nSpecies);
204 
205 private:
206  //! Provide the SpeciesthermoInterpType object
207  /*!
208  * @param k species index
209  * @return pointer to the SpeciesThermoInterpType object.
210  */
212  const SpeciesThermoInterpType* provideSTIT(size_t k) const;
213 
214 protected:
215  //! Mark species *k* as having its thermodynamic data installed
216  void markInstalled(size_t k);
217 
218  typedef std::pair<size_t, shared_ptr<SpeciesThermoInterpType> > index_STIT;
219  typedef std::map<int, std::vector<index_STIT> > STIT_map;
220  typedef std::map<int, vector_fp> tpoly_map;
221 
222  //! This is the main data structure, which contains the
223  //! SpeciesThermoInterpType objects, sorted by the parameterization type.
224  //! `m_sp[i]` is the vector of [species index, STIT] pairs which use
225  //! parameterization `i`.
226  STIT_map m_sp;
227 
228  //! Temperature polynomials for each thermo parameterization
229  mutable tpoly_map m_tpoly;
230 
231  //! Map from species index to location within #m_sp, such that
232  //! `m_sp[m_speciesLoc[k].first][m_speciesLoc[k].second]` is the
233  //! SpeciesThermoInterpType object for species `k`.
234  std::map<size_t, std::pair<int, size_t> > m_speciesLoc;
235 
236  //! Maximum value of the lowest temperature
237  doublereal m_tlow_max;
238 
239  //! Minimum value of the highest temperature
240  doublereal m_thigh_min;
241 
242  //! reference pressure (Pa)
243  doublereal m_p0;
244 
245  //! indicates if data for species has been installed
246  std::vector<bool> m_installed;
247 };
248 
249 }
250 
251 #endif
virtual doublereal maxTemp(size_t k=npos) const
Maximum temperature.
Abstract Base class for the thermodynamic manager for an individual species&#39; reference state...
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...
bool ready(size_t nSpecies)
Check if data for all species (0 through nSpecies-1) has been installed.
virtual void resetHf298(const size_t k)
Restore the original heat of formation of one or more species.
virtual void modifySpecies(size_t index, shared_ptr< SpeciesThermoInterpType > spec)
Modify the species thermodynamic property parameterization for a species.
virtual void update(doublereal T, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Compute the reference-state properties for all species.
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 ...
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
virtual doublereal refPressure(size_t k=npos) const
The reference-state pressure for species k.
doublereal m_p0
reference pressure (Pa)
Pure Virtual Base class for individual species reference state thermodynamic managers and text for th...
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]...
virtual int reportType(size_t index) const
This utility function reports the type of parameterization used for the species with index number ind...
doublereal m_tlow_max
Maximum value of the lowest temperature.
void markInstalled(size_t k)
Mark species k as having its thermodynamic data installed.
SpeciesThermoInterpType * provideSTIT(size_t k)
Provide the SpeciesthermoInterpType object.
STIT_map m_sp
This is the main data structure, which contains the SpeciesThermoInterpType objects, sorted by the parameterization type.
doublereal m_thigh_min
Minimum value of the highest temperature.
virtual doublereal minTemp(size_t k=npos) const
Minimum temperature.
virtual void update_one(size_t k, doublereal T, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Like update(), but only updates the single species k.
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) ...
A species thermodynamic property manager for a phase.
virtual void install_STIT(size_t index, shared_ptr< SpeciesThermoInterpType > stit)
Install a new species thermodynamic property parameterization for one species.
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8
virtual void update_single(size_t k, double T, double *cp_R, double *h_RT, double *s_R) const
Like update_one, but without applying offsets to the output pointers.
tpoly_map m_tpoly
Temperature polynomials for each thermo parameterization.
std::vector< bool > m_installed
indicates if data for species has been installed