Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NasaThermo.h
Go to the documentation of this file.
1 /**
2  * @file NasaThermo.h
3  * Header for the 2 regime 7 coefficient NASA thermodynamic
4  * polynomials for multiple species in a phase, derived from the
5  * \link Cantera::SpeciesThermo SpeciesThermo\endlink base class (see \ref mgrsrefcalc and
6  * \link Cantera::NasaThermo NasaThermo\endlink).
7  */
8 // Copyright 2003 California Institute of Technology
9 
10 #ifndef CT_NASATHERMO_H
11 #define CT_NASATHERMO_H
12 
15 
16 namespace Cantera
17 {
18 /**
19  * A species thermodynamic property manager for the NASA
20  * polynomial parameterization with two temperature ranges.
21  *
22  * This class is designed to efficiently evaluate the properties
23  * of a large number of species with the NASA parameterization.
24  *
25  * The original NASA polynomial parameterization expressed the
26  * heat capacity as a fourth-order polynomial in temperature, with
27  * separate coefficients for each of two temperature ranges. (The
28  * newer NASA format adds coefficients for 1/T and 1/T^2, and
29  * allows multiple temperature ranges.) This class is designed for
30  * use with the original parameterization, which is used, for
31  * example, by the Chemkin software package.
32  *
33  * In many cases, the midpoint temperature is the same for many
34  * species. To take advantage of this, class NasaThermo groups
35  * species with a common midpoint temperature, so that checking
36  * which range the desired temperature is in need be done only
37  * once for each group.
38  *
39  * @note There is a special CTML element for entering the
40  * coefficients of this parameterization.
41  * @see importCTML
42  *
43  * @ingroup mgrsrefcalc
44  * @deprecated To be removed after Cantera 2.2. Use GeneralSpeciesThermo instead.
45  */
46 class NasaThermo : public SpeciesThermo
47 {
48 public:
49  NasaThermo();
50 
51  NasaThermo(const NasaThermo& right);
52 
53  NasaThermo& operator=(const NasaThermo& right);
54 
56  NasaThermo* nt = new NasaThermo(*this);
57  return (SpeciesThermo*) nt;
58  }
59 
60  //! install a new species thermodynamic property
61  //! parameterization for one species.
62  /*!
63  * @param name Name of the species
64  * @param index The 'update' method will update the property values for
65  * this species at position i index in the property
66  * arrays.
67  * @param type int flag specifying the type of parameterization to be
68  * installed.
69  * @param c vector of coefficients for the parameterization.
70  * - c[0] midpoint temperature
71  * - c[1] - c[7] coefficients for low T range
72  * - c[8] - c[14] coefficients for high T range
73  * @param min_temp minimum temperature for which this parameterization
74  * is valid.
75  * @param max_temp maximum temperature for which this parameterization
76  * is valid.
77  * @param ref_pressure standard-state pressure for this parameterization.
78  * @see speciesThermoTypes.h
79  */
80  virtual void install(const std::string& name, size_t index, int type,
81  const doublereal* c,
82  doublereal min_temp, doublereal max_temp,
83  doublereal ref_pressure);
84 
85  virtual void install_STIT(size_t index, shared_ptr<SpeciesThermoInterpType> stit_ptr) {
86  throw CanteraError("install_STIT", "not implemented");
87  }
88 
89  //! Like update(), but only updates the single species k.
90  /*!
91  * @param k species index
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_one(size_t k, doublereal t, doublereal* cp_R,
98  doublereal* h_RT, doublereal* s_R) const;
99 
100  virtual void update(doublereal t, doublereal* cp_R,
101  doublereal* h_RT, doublereal* s_R) const;
102 
103  virtual doublereal minTemp(size_t k=npos) const {
104  if (k == npos) {
105  return m_tlow_max;
106  } else {
107  return m_tlow[k];
108  }
109  }
110 
111  virtual doublereal maxTemp(size_t k=npos) const {
112  if (k == npos) {
113  return m_thigh_min;
114  } else {
115  return m_thigh[k];
116  }
117  }
118 
119  virtual doublereal refPressure(size_t k=npos) const {
120  return m_p0;
121  }
122 
123  virtual int reportType(size_t index) const {
124  return NASA;
125  }
126 
127  /*!
128  * This utility function reports back the type of
129  * parameterization and all of the parameters for the
130  * species, index.
131  *
132  * @param index Species index
133  * @param type Integer type of the standard type
134  * @param c Vector of coefficients used to set the
135  * parameters for the standard state.
136  * For the NASA object, there are 15 coefficients.
137  * @param minTemp output - Minimum temperature
138  * @param maxTemp output - Maximum temperature
139  * @param refPressure output - reference pressure (Pa).
140  */
141  virtual void reportParams(size_t index, int& type,
142  doublereal* const c,
143  doublereal& minTemp,
144  doublereal& maxTemp,
145  doublereal& refPressure) const;
146 
147  virtual doublereal reportOneHf298(const size_t k) const;
148  virtual void modifyOneHf298(const size_t k, const doublereal Hf298New);
149 
150  //! Initialized to the type of parameterization
151  /*!
152  * Note, this value is used in some template functions
153  */
154  const int ID;
155 
156 protected:
157  //! Vector of vector of NasaPoly1's for the high temp region.
158  /*!
159  * This is the high temp region representation.
160  * The first Length is equal to the number of groups.
161  * The second vector is equal to the number of species
162  * in that particular group.
163  */
164  std::vector<std::vector<NasaPoly1> > m_high;
165 
166  //! Vector of vector of NasaPoly1's for the low temp region.
167  /*!
168  * This is the low temp region representation.
169  * The first Length is equal to the number of groups.
170  * The second vector is equal to the number of species
171  * in that particular group.
172  */
173  std::vector<std::vector<NasaPoly1> > m_low;
174 
175  //! Map between the midpoint temperature, as an int, to the group number
176  /*!
177  * Length is equal to the number of groups. Only used in the setup.
178  */
179  std::map<int, int> m_index;
180 
181  //! Vector of log temperature limits
182  /*!
183  * Length is equal to the number of groups.
184  */
186 
187  //! Maximum value of the low temperature limit
188  doublereal m_tlow_max;
189 
190  //! Minimum value of the high temperature limit
191  doublereal m_thigh_min;
192 
193  //! Vector of low temperature limits (species index)
194  /*!
195  * Length is equal to number of species
196  */
198 
199  //! Vector of low temperature limits (species index)
200  /*!
201  * Length is equal to number of species
202  */
204 
205  //! Reference pressure (Pa)
206  /*!
207  * all species must have the same reference pressure.
208  */
209  doublereal m_p0;
210 
211  //! number of groups
213 
214  //! Vector of temperature polynomials
215  mutable vector_fp m_t;
216 
217  /*!
218  * This map takes as its index, the species index in the phase.
219  * It returns the group index, where the temperature polynomials
220  * for that species are stored. group indices start at 1,
221  * so a decrement is always performed to access vectors.
222  */
223  std::map<size_t, size_t> m_group_map;
224 
225  /*!
226  * This map takes as its index, the species index in the phase.
227  * It returns the position index within the group, where the
228  * temperature polynomials for that species are stored.
229  */
230  std::map<size_t, size_t> m_posInGroup_map;
231 
232  //! Species name as a function of the species index
233  std::map<size_t, std::string> m_name;
234 
235 protected:
236  //! Compute the nondimensional heat capacity using the given NASA polynomial
237  /*!
238  * @param t temperature
239  * @param c coefficient array
240  */
241  doublereal cp_R(double t, const doublereal* c);
242 
243  //! Compute the nondimensional enthalpy using the given NASA polynomial
244  /*!
245  * @param t temperature
246  * @param c coefficient array
247  */
248  doublereal enthalpy_RT(double t, const doublereal* c);
249 
250  //! Compute the nondimensional entropy using the given NASA polynomial
251  /*!
252  * @param t temperature
253  * @param c coefficient array
254  */
255  doublereal entropy_R(double t, const doublereal* c);
256 
257  //! Adjust polynomials to be continuous at the midpoint temperature.
258  /*!
259  * Check to see if the provided coefficients are nearly continuous. Adjust
260  * the values to get more precise continuity to avoid convergence
261  * issues with algorithms that expect these quantities to be continuous.
262  *
263  * @param name string name of species
264  * @param tmid Mid temperature, between the two temperature regions
265  * @param clow coefficients for lower temperature region
266  * @param chigh coefficients for higher temperature region
267  */
268  double checkContinuity(const std::string& name, double tmid,
269  doublereal* clow, doublereal* chigh);
270 
271  //! Adjust polynomials to be continuous at the midpoint temperature.
272  /*!
273  * We seek a set of coefficients for the low- and high-temperature
274  * polynomials which are continuous in Cp, H, and S at the midpoint while
275  * minimizing the difference between the values in Cp, H, and S over the
276  * entire valid temperature range. To do this, we formulate a linear
277  * least-squares problem to be solved for 11 of the 14 coefficients, with
278  * the remaining 3 coefficients eliminated in the process of satisfying
279  * the continuity constraints.
280  *
281  * @param Tlow Minimum temperature at which the low-T polynomial is valid
282  * @param Tmid Mid temperature, between the two temperature regions
283  * @param Thigh Maximum temperature at which the high-T polynomial is valid
284  * @param clow coefficients for lower temperature region
285  * @param chigh coefficients for higher temperature region
286  */
287  void fixDiscontinuities(doublereal Tlow, doublereal Tmid, doublereal Thigh,
288  doublereal* clow, doublereal* chigh);
289 };
290 
291 }
292 
293 #endif
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: NasaThermo.cpp:218
doublereal m_thigh_min
Minimum value of the high temperature limit.
Definition: NasaThermo.h:191
#define NASA
Two regions of 7 coefficient NASA Polynomials This is implemented in the class NasaPoly2 in NasaPoly2...
virtual doublereal minTemp(size_t k=npos) const
Minimum temperature.
Definition: NasaThermo.h:103
std::vector< std::vector< NasaPoly1 > > m_high
Vector of vector of NasaPoly1's for the high temp region.
Definition: NasaThermo.h:164
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
virtual void update(doublereal t, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Compute the reference-state properties for all species.
Definition: NasaThermo.cpp:149
virtual int reportType(size_t index) const
This utility function reports the type of parameterization used for the species with index number ind...
Definition: NasaThermo.h:123
virtual doublereal refPressure(size_t k=npos) const
The reference-state pressure for species k.
Definition: NasaThermo.h:119
virtual void reportParams(size_t index, int &type, doublereal *const c, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure) const
Definition: NasaThermo.cpp:176
A species thermodynamic property manager for the NASA polynomial parameterization with two temperatur...
Definition: NasaThermo.h:46
doublereal m_tlow_max
Maximum value of the low temperature limit.
Definition: NasaThermo.h:188
const int ID
Initialized to the type of parameterization.
Definition: NasaThermo.h:154
Pure Virtual base class for the species thermo manager classes.
doublereal entropy_R(double t, const doublereal *c)
Compute the nondimensional entropy using the given NASA polynomial.
Definition: NasaThermo.cpp:270
virtual void install_STIT(size_t index, shared_ptr< SpeciesThermoInterpType > stit_ptr)
Install a new species thermodynamic property parameterization for one species.
Definition: NasaThermo.h:85
double checkContinuity(const std::string &name, double tmid, doublereal *clow, doublereal *chigh)
Adjust polynomials to be continuous at the midpoint temperature.
Definition: NasaThermo.cpp:276
doublereal m_p0
Reference pressure (Pa)
Definition: NasaThermo.h:209
virtual SpeciesThermo * duplMyselfAsSpeciesThermo() const
Duplication routine for objects derived from SpeciesThermo.
Definition: NasaThermo.h:55
doublereal cp_R(double t, const doublereal *c)
Compute the nondimensional heat capacity using the given NASA polynomial.
Definition: NasaThermo.cpp:259
std::map< int, int > m_index
Map between the midpoint temperature, as an int, to the group number.
Definition: NasaThermo.h:179
virtual void install(const std::string &name, size_t index, int type, const doublereal *c, doublereal min_temp, doublereal max_temp, doublereal ref_pressure)
install a new species thermodynamic property parameterization for one species.
Definition: NasaThermo.cpp:61
vector_fp m_tmid
Vector of log temperature limits.
Definition: NasaThermo.h:185
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:99
int m_ngroups
number of groups
Definition: NasaThermo.h:212
vector_fp m_t
Vector of temperature polynomials.
Definition: NasaThermo.h:215
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the N...
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: NasaThermo.cpp:234
This file contains descriptions of templated subclasses of the virtual base class, SpeciesThermo, which includes SpeciesThermoDuo (see Managers for Calculating Reference-State Thermodynamics and class SpeciesThermoDuo)
doublereal enthalpy_RT(double t, const doublereal *c)
Compute the nondimensional enthalpy using the given NASA polynomial.
Definition: NasaThermo.cpp:264
std::map< size_t, size_t > m_posInGroup_map
Definition: NasaThermo.h:230
std::map< size_t, std::string > m_name
Species name as a function of the species index.
Definition: NasaThermo.h:233
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:157
std::map< size_t, size_t > m_group_map
Definition: NasaThermo.h:223
void fixDiscontinuities(doublereal Tlow, doublereal Tmid, doublereal Thigh, doublereal *clow, doublereal *chigh)
Adjust polynomials to be continuous at the midpoint temperature.
Definition: NasaThermo.cpp:327
vector_fp m_thigh
Vector of low temperature limits (species index)
Definition: NasaThermo.h:203
vector_fp m_tlow
Vector of low temperature limits (species index)
Definition: NasaThermo.h:197
virtual doublereal maxTemp(size_t k=npos) const
Maximum temperature.
Definition: NasaThermo.h:111
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.
Definition: NasaThermo.cpp:124
std::vector< std::vector< NasaPoly1 > > m_low
Vector of vector of NasaPoly1's for the low temp region.
Definition: NasaThermo.h:173