Cantera  2.3.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  //! @deprecated To be removed after Cantera 2.3.
54  //! @deprecated To be removed after Cantera 2.3.
56  virtual ~MultiSpeciesThermo() {}
57 
58  //! Duplication routine for objects derived from MultiSpeciesThermo
59  /*!
60  * This function can be used to duplicate objects derived from
61  * MultiSpeciesThermo even if the application only has a pointer to
62  * MultiSpeciesThermo to work with.
63  * @deprecated To be removed after Cantera 2.3.
64  */
66 
67  //! Install a new species thermodynamic property parameterization for one
68  //! species.
69  /*!
70  * @param index Index of the species being installed
71  * @param stit Pointer to the SpeciesThermoInterpType object
72  * This will set up the thermo for one species
73  */
74  virtual void install_STIT(size_t index,
75  shared_ptr<SpeciesThermoInterpType> stit);
76 
77  //! Modify the species thermodynamic property parameterization for a species
78  /*!
79  * @param index Index of the species being installed
80  * @param spec Pointer to the SpeciesThermoInterpType object
81  */
82  virtual void modifySpecies(size_t index,
83  shared_ptr<SpeciesThermoInterpType> spec);
84 
85  //! Install a PDSS object to handle the reference state thermodynamics
86  //! calculation
87  /*!
88  * @param k species index
89  * @param PDSS_ptr Pressure dependent standard state (PDSS) object
90  * that will handle the reference state calc
91  * @param vpssmgr_ptr Pointer to the variable pressure standard state
92  * manager that handles the PDSS object.
93  */
94  void installPDSShandler(size_t k, PDSS* PDSS_ptr, VPSSMgr* vpssmgr_ptr);
95 
96  //! Like update(), but only updates the single species k.
97  /*!
98  * @param k species index
99  * @param T Temperature (Kelvin)
100  * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
101  * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
102  * @param s_R Vector of Dimensionless entropies. (length m_kk).
103  */
104  virtual void update_one(size_t k, doublereal T, doublereal* cp_R,
105  doublereal* h_RT,
106  doublereal* s_R) const;
107 
108  //! Compute the reference-state properties for all species.
109  /*!
110  * Given temperature T in K, this method updates the values of the non-
111  * dimensional heat capacity at constant pressure, enthalpy, and entropy,
112  * at the reference pressure, Pref of each of the standard states.
113  *
114  * @param T Temperature (Kelvin)
115  * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
116  * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
117  * @param s_R Vector of Dimensionless entropies. (length m_kk).
118  */
119  virtual void update(doublereal T, doublereal* cp_R,
120  doublereal* h_RT, doublereal* s_R) const;
121 
122  //! Minimum temperature.
123  /*!
124  * If no argument is supplied, this method returns the minimum temperature
125  * for which \e all parameterizations are valid. If an integer index k is
126  * supplied, then the value returned is the minimum temperature for
127  * species k in the phase.
128  *
129  * @param k Species index
130  */
131  virtual doublereal minTemp(size_t k=npos) const;
132 
133  //! Maximum temperature.
134  /*!
135  * If no argument is supplied, this method returns the maximum temperature
136  * for which \e all parameterizations are valid. If an integer index k is
137  * supplied, then the value returned is the maximum temperature for
138  * parameterization k.
139  *
140  * @param k Species Index
141  */
142  virtual doublereal maxTemp(size_t k=npos) const;
143 
144  //! The reference-state pressure for species k.
145  /*!
146  * Returns the reference state pressure in Pascals for species k. If k is
147  * left out of the argument list, it returns the reference state pressure
148  * for the first species.
149  *
150  * @param k Species Index
151  */
152  virtual doublereal refPressure(size_t k=npos) const;
153 
154  //! This utility function reports the type of parameterization used for the
155  //! species with index number *index*.
156  /*!
157  * @param index Species index
158  */
159  virtual int reportType(size_t index) const;
160 
161  //! This utility function reports back the type of parameterization and
162  //! all of the parameters for the species with index number *index*.
163  /*!
164  * @param index Species index
165  * @param type Integer type of the standard type
166  * @param c Vector of coefficients used to set the
167  * parameters for the standard state.
168  * @param minTemp output - Minimum temperature
169  * @param maxTemp output - Maximum temperature
170  * @param refPressure output - reference pressure (Pa).
171  */
172  virtual void reportParams(size_t index, int& type,
173  doublereal* const c,
174  doublereal& minTemp,
175  doublereal& maxTemp,
176  doublereal& refPressure) const;
177 
178  //! Report the 298 K Heat of Formation of the standard state of one species
179  //! (J kmol-1)
180  /*!
181  * The 298K Heat of Formation is defined as the enthalpy change to create
182  * the standard state of the species from its constituent elements in their
183  * standard states at 298 K and 1 bar.
184  *
185  * @param k species index
186  * @returns the current value of the Heat of Formation at 298K and 1 bar
187  */
188  virtual doublereal reportOneHf298(const size_t k) const;
189 
190  //! Modify the value of the 298 K Heat of Formation of the standard state of
191  //! one species in the phase (J kmol-1)
192  /*!
193  * The 298K heat of formation is defined as the enthalpy change to create
194  * the standard state of the species from its constituent elements in their
195  * standard states at 298 K and 1 bar.
196  *
197  * @param k Index of the species
198  * @param Hf298New Specify the new value of the Heat of Formation at
199  * 298K and 1 bar. units = J/kmol.
200  */
201  virtual void modifyOneHf298(const size_t k, const doublereal Hf298New);
202 
203  //! Restore the original heat of formation of one or more species
204  /*!
205  * Resets changes made by modifyOneHf298(). If the species index is not
206  * specified, the heats of formation for all species are restored.
207  */
208  virtual void resetHf298(const size_t k);
209 
210  //! Check if data for all species (0 through nSpecies-1) has been installed.
211  bool ready(size_t nSpecies);
212 
213 private:
214  //! Provide the SpeciesthermoInterpType object
215  /*!
216  * @param k species index
217  * @return pointer to the SpeciesThermoInterpType object.
218  */
220  const SpeciesThermoInterpType* provideSTIT(size_t k) const;
221 
222 protected:
223  //! Mark species *k* as having its thermodynamic data installed
224  void markInstalled(size_t k);
225 
226  typedef std::pair<size_t, shared_ptr<SpeciesThermoInterpType> > index_STIT;
227  typedef std::map<int, std::vector<index_STIT> > STIT_map;
228  typedef std::map<int, vector_fp> tpoly_map;
229 
230  //! This is the main data structure, which contains the
231  //! SpeciesThermoInterpType objects, sorted by the parameterization type.
232  //! `m_sp[i]` is the vector of [species index, STIT] pairs which use
233  //! parameterization `i`.
234  STIT_map m_sp;
235 
236  //! Temperature polynomials for each thermo parameterization
237  mutable tpoly_map m_tpoly;
238 
239  //! Map from species index to location within #m_sp, such that
240  //! `m_sp[m_speciesLoc[k].first][m_speciesLoc[k].second]` is the
241  //! SpeciesThermoInterpType object for species `k`.
242  std::map<size_t, std::pair<int, size_t> > m_speciesLoc;
243 
244  //! Maximum value of the lowest temperature
245  doublereal m_tlow_max;
246 
247  //! Minimum value of the highest temperature
248  doublereal m_thigh_min;
249 
250  //! reference pressure (Pa)
251  doublereal m_p0;
252 
253  //! indicates if data for species has been installed
254  std::vector<bool> m_installed;
255 
256  //! Make the class VPSSMgr a friend because we need to access the function
257  //! provideSTIT()
258  friend class VPSSMgr;
259 };
260 
261 }
262 
263 #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 base class for the classes that manage the calculation of standard state properties for all t...
Definition: VPSSMgr.h:228
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
void installPDSShandler(size_t k, PDSS *PDSS_ptr, VPSSMgr *vpssmgr_ptr)
Install a PDSS object to handle the reference state thermodynamics calculation.
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 MultiSpeciesThermo * duplMyselfAsSpeciesThermo() const
Duplication routine for objects derived from MultiSpeciesThermo.
virtual doublereal minTemp(size_t k=npos) const
Minimum temperature.
Virtual base class for a species with a pressure dependent standard state.
Definition: PDSS.h:176
MultiSpeciesThermo & operator=(const MultiSpeciesThermo &b)
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: application.cpp:29
tpoly_map m_tpoly
Temperature polynomials for each thermo parameterization.
std::vector< bool > m_installed
indicates if data for species has been installed