Cantera  2.1.2
Nasa9PolyMultiTempRegion.cpp
Go to the documentation of this file.
1 /**
2  * @file Nasa9PolyMultiTempRegion.cpp
3  * Definitions for a single-species standard state object derived
4  * from \link Cantera::SpeciesThermoInterpType
5  * SpeciesThermoInterpType\endlink based
6  * on the NASA 9 coefficient temperature polynomial form
7  * applied to one temperature region
8  * (see \ref spthermo and class
9  * \link Cantera::Nasa9Poly1 Nasa9Poly1\endlink).
10  *
11  * This parameterization has one NASA temperature region.
12  */
13 // Copyright 2007 Sandia National Laboratories
14 
15 #include "cantera/base/global.h"
18 
19 using namespace std;
20 
21 namespace Cantera
22 {
23 Nasa9PolyMultiTempRegion::Nasa9PolyMultiTempRegion() :
24  m_numTempRegions(0),
25  m_currRegion(0)
26 {
27 }
28 
30 Nasa9PolyMultiTempRegion(std::vector<Cantera::Nasa9Poly1*> &regionPts) :
31  m_numTempRegions(0),
32  m_currRegion(0)
33 {
34  m_numTempRegions = regionPts.size();
35  // Do a shallow copy of the pointers. From now on, we will
36  // own these pointers and be responsible for deleting them.
37  m_regionPts = regionPts;
39  m_lowT = m_regionPts[0]->minTemp();
40  m_highT = m_regionPts[m_numTempRegions-1]->maxTemp();
41  m_Pref = m_regionPts[0]->refPressure();
42  m_index = m_regionPts[0]->speciesIndex();
43  for (size_t i = 0; i < m_numTempRegions; i++) {
44  m_lowerTempBounds[i] = m_regionPts[i]->minTemp();
45  if (m_regionPts[i]->speciesIndex() != m_index) {
46  throw CanteraError("Nasa9PolyMultiTempRegion::Nasa9PolyMultiTempRegion",
47  "m_index inconsistency");
48  }
49  if (fabs(m_regionPts[i]->refPressure() - m_Pref) > 0.0001) {
50  throw CanteraError("Nasa9PolyMultiTempRegion::Nasa9PolyMultiTempRegion",
51  "refPressure inconsistency");
52  }
53  if (i > 0) {
54  if (m_lowerTempBounds[i-1] >= m_lowerTempBounds[i]) {
55  throw CanteraError("Nasa9PolyMultiTempRegion::Nasa9PolyMultiTempRegion",
56  "minTemp bounds inconsistency");
57  }
58  if (fabs(m_regionPts[i-1]->maxTemp() - m_lowerTempBounds[i]) > 0.0001) {
59  throw CanteraError("Nasa9PolyMultiTempRegion::Nasa9PolyMultiTempRegion",
60  "Temp bounds inconsistency");
61  }
62  }
63  }
64 }
65 
69  m_numTempRegions(b.m_numTempRegions),
70  m_lowerTempBounds(b.m_lowerTempBounds),
71  m_currRegion(b.m_currRegion)
72 {
74  for (size_t i = 0; i < m_numTempRegions; i++) {
75  Nasa9Poly1* dptr = b.m_regionPts[i];
76  m_regionPts[i] = new Nasa9Poly1(*dptr);
77  }
78 }
79 
82 {
83  if (&b != this) {
84  SpeciesThermoInterpType::operator=(b);
85  for (size_t i = 0; i < m_numTempRegions; i++) {
86  delete m_regionPts[i];
87  m_regionPts[i] = 0;
88  }
89  m_numTempRegions = b.m_numTempRegions;
92  m_regionPts.resize(m_numTempRegions);
93  for (size_t i = 0; i < m_numTempRegions; i++) {
94  m_regionPts[i] = new Nasa9Poly1(*(b.m_regionPts[i]));
95  }
96  }
97  return *this;
98 }
99 
101 {
102  for (size_t i = 0; i < m_numTempRegions; i++) {
103  delete m_regionPts[i];
104  m_regionPts[i] = 0;
105  }
106 }
107 
110 {
111  return new Nasa9PolyMultiTempRegion(*this);
112 }
113 
115 {
116  return NASA9MULTITEMP;
117 }
118 
120  doublereal* cp_R,
121  doublereal* h_RT,
122  doublereal* s_R) const
123 {
124  // Let's put some additional debugging here.
125  // This is an external routine
126 #ifdef DEBUG_HKM
127  double temp = tt[0];
128  if (temp < m_regionPts[m_currRegion]->minTemp()) {
129  if (m_currRegion != 0) {
130  throw CanteraError("Nasa9PolyMultiTempRegion::updateProperties",
131  "region problem");
132  }
133  }
134  if (temp > m_regionPts[m_currRegion]->maxTemp()) {
135  if (m_currRegion != m_numTempRegions - 1) {
136  throw CanteraError("Nasa9PolyMultiTempRegion::updateProperties",
137  "region problem");
138  }
139  }
140 #endif
141  (m_regionPts[m_currRegion])->updateProperties(tt, cp_R, h_RT, s_R);
142 }
143 
145  doublereal* cp_R, doublereal* h_RT,
146  doublereal* s_R) const
147 {
148  double tPoly[7];
149  tPoly[0] = temp;
150  tPoly[1] = temp * temp;
151  tPoly[2] = tPoly[1] * temp;
152  tPoly[3] = tPoly[2] * temp;
153  tPoly[4] = 1.0 / temp;
154  tPoly[5] = tPoly[4] / temp;
155  tPoly[6] = std::log(temp);
156  // Now find the region
157  m_currRegion = 0;
158  for (size_t i = 1; i < m_numTempRegions; i++) {
159  if (temp < m_lowerTempBounds[i]) {
160  break;
161  }
162  m_currRegion++;
163  }
164 
165  updateProperties(tPoly, cp_R, h_RT, s_R);
166 }
167 
169  doublereal& tlow, doublereal& thigh,
170  doublereal& pref,
171  doublereal* const coeffs) const
172 {
173  warn_deprecated("Nasa9PolyMultiTempRegion::reportParameters");
174  n = m_index;
175  type = NASA9MULTITEMP;
176  tlow = m_lowT;
177  thigh = m_highT;
178  pref = m_Pref;
179  double ctmp[12];
180  coeffs[0] = double(m_numTempRegions);
181  int index = 1;
182  size_t n_tmp = 0;
183  int type_tmp = 0;
184  double pref_tmp = 0.0;
185  for (size_t iReg = 0; iReg < m_numTempRegions; iReg++) {
186  m_regionPts[iReg]->reportParameters(n_tmp, type_tmp,
187  coeffs[index], coeffs[index+1],
188  pref_tmp, ctmp);
189  for (int i = 0; i < 9; i++) {
190  coeffs[index+2+i] = ctmp[3+i];
191  }
192  index += 11;
193  }
194 
195 }
196 
198 {
199  warn_deprecated("Nasa9PolyMultiTempRegion::modifyParameters");
200  int index = 3;
201  for (size_t iReg = 0; iReg < m_numTempRegions; iReg++) {
202  m_regionPts[iReg]->modifyParameters(coeffs + index);
203  index += 11;
204  }
205 }
206 
207 }
size_t m_numTempRegions
Number of temperature regions.
Pure Virtual Base class for the thermodynamic manager for an individual species' reference state...
virtual size_t speciesIndex() const
Returns an integer representing the species index.
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the N...
vector_fp m_lowerTempBounds
Lower boundaries of each temperature regions.
virtual int reportType() const
Returns an integer representing the type of parameterization.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:76
This file contains definitions for utility functions and text for modules, inputfiles, logs, textlogs, HTML_logs (see Input File Handling, Diagnostic Output, Writing messages to the screen and Writing HTML Logfiles).
virtual doublereal refPressure() const
Returns the reference pressure (Pa)
virtual doublereal maxTemp() const
Returns the maximum temperature that the thermo parameterization is valid.
#define NASA9MULTITEMP
9 coefficient NASA Polynomials in multiple temperature regions This is implemented in the class Nasa9...
virtual void updateProperties(const doublereal *tt, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Update the properties for this species, given a temperature polynomial.
virtual SpeciesThermoInterpType * duplMyselfAsSpeciesThermoInterpType() const
duplicator
doublereal m_highT
Highest valid temperature.
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:68
doublereal m_lowT
lowest valid temperature
virtual doublereal minTemp() const
Returns the minimum temperature that the thermo parameterization is valid.
The NASA 9 polynomial parameterization for one temperature range.
Definition: Nasa9Poly1.h:69
Nasa9PolyMultiTempRegion & operator=(const Nasa9PolyMultiTempRegion &b)
Assignment operator.
doublereal m_Pref
Reference state pressure.
The NASA 9 polynomial parameterization for a single species encompassing multiple temperature regions...
virtual void modifyParameters(doublereal *coeffs)
Modify parameters for the standard state.
virtual void updatePropertiesTemp(const doublereal temp, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Compute the reference-state property of one species.
std::vector< Nasa9Poly1 * > m_regionPts
pointers to the objects
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
virtual void reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal *const coeffs) const
This utility function reports back the type of parameterization and all of the parameters for the spe...