Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SpeciesThermoMgr.h
Go to the documentation of this file.
1 /**
2  * @file SpeciesThermoMgr.h
3  * This file contains descriptions of templated subclasses of
4  * the virtual base class, SpeciesThermo, which includes SpeciesThermoDuo
5  * (see \ref mgrsrefcalc and class
6  * \link Cantera::SpeciesThermoDuo SpeciesThermoDuo\endlink)
7  */
8 
9 // Copyright 2001 California Institute of Technology
10 
11 #ifndef CT_SPECIESTHERMO_MGR_H
12 #define CT_SPECIESTHERMO_MGR_H
13 
16 #include "SpeciesThermo.h"
17 #include "cantera/base/utilities.h"
18 
19 namespace Cantera
20 {
21 //! Unknown species thermo manager string error
22 /*!
23  * @ingroup mgrsrefcalc
24  */
26 {
27 public:
28  //! constructor
29  /*!
30  * @param proc name of the procecdure
31  * @param type unknown type
32  */
33  UnknownSpeciesThermo(const std::string& proc, int type) :
34  CanteraError(proc, "Specified species parameterization type (" + int2str(type)
35  + ") does not match any known type.") {}
36 
37  //! Alternate constructor
38  /*!
39  * @param proc name of the procecdure
40  * @param stype String name for the unknown type
41  */
42  UnknownSpeciesThermo(const std::string& proc, const std::string& stype) :
43  CanteraError(proc, "Specified species parameterization type (" + stype
44  + ") does not match any known type.") {}
45 };
46 
47 /**
48  * This species thermo manager requires that all species have one
49  * of two parameterizations.
50  *
51  * Note this seems to be a slow way to do things, and it may be on its way out.
52  *
53  * @deprecated To be removed after Cantera 2.2. Use GeneralSpeciesThermo instead.
54  * @ingroup mgrsrefcalc
55  */
56 template<class T1, class T2>
58 {
59 public:
60  //! Constructor
62  warn_deprecated("class SpeciesThermoDuo", "To be removed after "
63  "Cantera 2.2. Use GeneralSpeciesThermo instead.");
64  };
65 
66  //! copy constructor
67  /*!
68  * @param right Object to be copied
69  */
71  *this = right;
72  }
73 
74  //! Assignment operator
75  /*!
76  * @param right Object to be copied
77  */
79 
81 
82  virtual void install(const std::string& name, size_t sp, int type,
83  const doublereal* c,
84  doublereal minTemp, doublereal maxTemp,
85  doublereal refPressure);
86 
87  virtual void install_STIT(size_t index,
88  shared_ptr<SpeciesThermoInterpType> stit_ptr) {
89  throw CanteraError("install_STIT", "not implemented");
90  }
91 
92  virtual void update(doublereal t, doublereal* cp_R,
93  doublereal* h_RT, doublereal* s_R) const;
94 
95  virtual doublereal minTemp(size_t k = npos) const {
96  return std::max(m_thermo1.minTemp(),m_thermo2.minTemp());
97  }
98 
99  virtual doublereal maxTemp(size_t k = npos) const {
100  return std::min(m_thermo1.maxTemp(), m_thermo2.maxTemp());
101  }
102 
103  virtual doublereal refPressure(size_t k = npos) const {
104  return m_p0;
105  }
106 
107  virtual int reportType(size_t k) const;
108 
109  virtual void reportParams(size_t index, int& type,
110  doublereal* const c,
111  doublereal& minTemp,
112  doublereal& maxTemp,
113  doublereal& refPressure) const;
114 
115  virtual doublereal reportOneHf298(const size_t k) const {
116  throw CanteraError("reportHF298", "unimplemented");
117  }
118 
119  virtual void modifyOneHf298(const size_t k, const doublereal Hf298New) {
120  throw CanteraError("reportHF298", "unimplemented");
121  }
122 
123 private:
124 
125  //! Thermo Type 1
127  //! Thermo Type 2
129  //! Reference pressure
130  doublereal m_p0;
131  //! map from species to type
132  std::map<size_t, int> speciesToType;
133 };
134 
135 
136 // ------------------------- cpp part of file -------------------------------------
137 
138 // Definitions for the SpeciesThermoDuo<T1,T2> templated class
139 
140 template<class T1, class T2>
143 {
144  if (&right == this) {
145  return *this;
146  }
147 
148  SpeciesThermo::operator=(right);
149  m_thermo1 = right.m_thermo1;
150  m_thermo2 = right.m_thermo2;
151  m_p0 = right.m_p0;
152  speciesToType = right.speciesToType;
153 
154  return *this;
155 }
156 
157 template<class T1, class T2>
160 {
161  return new SpeciesThermoDuo<T1,T2>(*this);
162 }
163 
164 template<class T1, class T2>
165 void
166 SpeciesThermoDuo<T1, T2>::install(const std::string& name, size_t sp, int type,
167  const doublereal* c,
168  doublereal minTemp_,
169  doublereal maxTemp_,
170  doublereal refPressure_)
171 {
172  m_p0 = refPressure_;
173  if (type == m_thermo1.ID) {
174  m_thermo1.install(name, sp, type, c, minTemp_, maxTemp_,
175  refPressure_);
176  speciesToType[sp] = m_thermo1.ID;
177  } else if (type == m_thermo2.ID) {
178  m_thermo2.install(name, sp, type, c, minTemp_, maxTemp_,
179  refPressure_);
180  speciesToType[sp] = m_thermo2.ID;
181  } else {
182  throw UnknownSpeciesThermo("SpeciesThermoDuo:install",type);
183  }
184  markInstalled(sp);
185 }
186 
187 template<class T1, class T2>
188 void
189 SpeciesThermoDuo<T1, T2>::update(doublereal t, doublereal* cp_R,
190  doublereal* h_RT, doublereal* s_R) const
191 {
192  m_thermo1.update(t, cp_R, h_RT, s_R);
193  m_thermo2.update(t, cp_R, h_RT, s_R);
194 }
195 
196 template<class T1, class T2>
197 int
199 {
200  return getValue(speciesToType, k, -1);
201 }
202 
203 template<class T1, class T2>
204 void
206  doublereal* const c,
207  doublereal& minTemp_,
208  doublereal& maxTemp_,
209  doublereal& refPressure_) const
210 {
211  int ctype = reportType(index);
212  if (ctype == m_thermo1.ID) {
213  m_thermo1.reportParams(index, type, c, minTemp_, maxTemp_,
214  refPressure_);
215  } else if (ctype == m_thermo2.ID) {
216  m_thermo2.reportParams(index, type, c, minTemp_, maxTemp_,
217  refPressure_);
218  } else {
219  throw CanteraError("SpeciesThermoDuo", "mismatched SpeciesThermoInterpType");
220  }
221 }
222 
223 }
224 #endif
UnknownSpeciesThermo(const std::string &proc, const std::string &stype)
Alternate constructor.
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
Definition: stringUtils.cpp:39
virtual doublereal maxTemp(size_t k=npos) const
Maximum temperature.
T2 m_thermo2
Thermo Type 2.
Various templated functions that carry out common vector operations (see Templated Utility Functions)...
virtual doublereal minTemp(size_t k=npos) const
Minimum temperature.
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:78
Virtual base class for the calculation of multiple-species thermodynamic reference-state property man...
doublereal m_p0
Reference pressure.
Pure Virtual base class for the species thermo manager classes.
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...
SpeciesThermoDuo & operator=(const SpeciesThermoDuo &right)
Assignment operator.
UnknownSpeciesThermo(const std::string &proc, int type)
constructor
virtual void install_STIT(size_t index, shared_ptr< SpeciesThermoInterpType > stit_ptr)
Install a new species thermodynamic property parameterization for one species.
virtual void install(const std::string &name, size_t sp, int type, const doublereal *c, doublereal minTemp, doublereal maxTemp, doublereal refPressure)
Install a new species thermodynamic property parameterization for one species.
SpeciesThermoDuo(const SpeciesThermoDuo &right)
copy constructor
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:99
virtual doublereal refPressure(size_t k=npos) const
The reference-state pressure for species k.
const U & getValue(const std::map< T, U > &m, const T &key)
Const accessor for a value in a std::map.
Definition: utilities.h:714
SpeciesThermoDuo()
Constructor.
virtual SpeciesThermo * duplMyselfAsSpeciesThermo() const
Duplication routine for objects derived from SpeciesThermo.
This species thermo manager requires that all species have one of two parameterizations.
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) ...
Unknown species thermo manager string error.
Contains declarations for string manipulation functions within Cantera.
T1 m_thermo1
Thermo Type 1.
virtual void update(doublereal t, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Compute the reference-state properties for all species.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
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 ...
virtual int reportType(size_t k) const
This utility function reports the type of parameterization used for the species with index number ind...
std::map< size_t, int > speciesToType
map from species to type