Cantera  2.4.0
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 
14 // This file is part of Cantera. See License.txt in the top-level directory or
15 // at http://www.cantera.org/license.txt for license and copyright information.
16 
19 
20 using namespace std;
21 
22 namespace Cantera
23 {
24 
25 Nasa9PolyMultiTempRegion::Nasa9PolyMultiTempRegion(vector<Nasa9Poly1*>& regionPts) :
26  m_currRegion(0)
27 {
28  // From now on, we own these pointers
29  for (Nasa9Poly1* region : regionPts) {
30  m_regionPts.emplace_back(region);
31  }
32  m_lowerTempBounds.resize(regionPts.size());
33  m_lowT = m_regionPts[0]->minTemp();
34  m_highT = m_regionPts[m_regionPts.size()-1]->maxTemp();
35  m_Pref = m_regionPts[0]->refPressure();
36  for (size_t i = 0; i < m_regionPts.size(); i++) {
37  m_lowerTempBounds[i] = m_regionPts[i]->minTemp();
38  if (fabs(m_regionPts[i]->refPressure() - m_Pref) > 0.0001) {
39  throw CanteraError("Nasa9PolyMultiTempRegion::Nasa9PolyMultiTempRegion",
40  "refPressure inconsistency");
41  }
42  if (i > 0) {
43  if (m_lowerTempBounds[i-1] >= m_lowerTempBounds[i]) {
44  throw CanteraError("Nasa9PolyMultiTempRegion::Nasa9PolyMultiTempRegion",
45  "minTemp bounds inconsistency");
46  }
47  if (fabs(m_regionPts[i-1]->maxTemp() - m_lowerTempBounds[i]) > 0.0001) {
48  throw CanteraError("Nasa9PolyMultiTempRegion::Nasa9PolyMultiTempRegion",
49  "Temp bounds inconsistency");
50  }
51  }
52  }
53 }
54 
55 Nasa9PolyMultiTempRegion::~Nasa9PolyMultiTempRegion()
56 {
57 }
58 
60 {
61  return NASA9MULTITEMP;
62 }
63 
64 void Nasa9PolyMultiTempRegion::updateTemperaturePoly(double T, double* T_poly) const
65 {
66  T_poly[0] = T;
67  T_poly[1] = T * T;
68  T_poly[2] = T_poly[1] * T;
69  T_poly[3] = T_poly[2] * T;
70  T_poly[4] = 1.0 / T;
71  T_poly[5] = T_poly[4] / T;
72  T_poly[6] = std::log(T);
73 }
74 
76  doublereal* cp_R,
77  doublereal* h_RT,
78  doublereal* s_R) const
79 {
80  m_currRegion = 0;
81  for (size_t i = 1; i < m_regionPts.size(); i++) {
82  if (tt[0] < m_lowerTempBounds[i]) {
83  break;
84  }
85  m_currRegion++;
86  }
87 
88  m_regionPts[m_currRegion]->updateProperties(tt, cp_R, h_RT, s_R);
89 }
90 
92  doublereal* cp_R, doublereal* h_RT,
93  doublereal* s_R) const
94 {
95  // Now find the region
96  m_currRegion = 0;
97  for (size_t i = 1; i < m_regionPts.size(); i++) {
98  if (temp < m_lowerTempBounds[i]) {
99  break;
100  }
101  m_currRegion++;
102  }
103 
104  m_regionPts[m_currRegion]->updatePropertiesTemp(temp, cp_R, h_RT, s_R);
105 }
106 
108  doublereal& tlow, doublereal& thigh,
109  doublereal& pref,
110  doublereal* const coeffs) const
111 {
112  n = 0;
113  type = NASA9MULTITEMP;
114  tlow = m_lowT;
115  thigh = m_highT;
116  pref = m_Pref;
117  double ctmp[12];
118  coeffs[0] = double(m_regionPts.size());
119  int index = 1;
120  size_t n_tmp = 0;
121  int type_tmp = 0;
122  double pref_tmp = 0.0;
123  for (size_t iReg = 0; iReg < m_regionPts.size(); iReg++) {
124  m_regionPts[iReg]->reportParameters(n_tmp, type_tmp,
125  coeffs[index], coeffs[index+1],
126  pref_tmp, ctmp);
127  for (int i = 0; i < 9; i++) {
128  coeffs[index+2+i] = ctmp[3+i];
129  }
130  index += 11;
131  }
132 }
133 
134 }
virtual void updatePropertiesTemp(const doublereal temp, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Compute the reference-state property of one species.
virtual int reportType() const
Returns an integer representing the type of parameterization.
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.
STL namespace.
#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.
doublereal m_highT
Highest valid temperature.
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:65
doublereal m_lowT
lowest valid temperature
virtual doublereal refPressure() const
Returns the reference pressure (Pa)
virtual void updateTemperaturePoly(double T, double *T_poly) const
Given the temperature T, compute the terms of the temperature polynomial T_poly.
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...
The NASA 9 polynomial parameterization for one temperature range.
Definition: Nasa9Poly1.h:61
virtual doublereal maxTemp() const
Returns the maximum temperature that the thermo parameterization is valid.
doublereal m_Pref
Reference state pressure.
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
std::vector< std::unique_ptr< Nasa9Poly1 > > m_regionPts
Individual temperature region objects.