Cantera  2.5.1
NasaPoly2.h
Go to the documentation of this file.
1 /**
2  * @file NasaPoly2.h
3  * Header for a single-species standard state object derived
4  * from \link Cantera::SpeciesThermoInterpType SpeciesThermoInterpType\endlink based
5  * on the NASA temperature polynomial form applied to two temperature regions
6  * (see \ref spthermo and class \link Cantera::NasaPoly2 NasaPoly2\endlink).
7  *
8  * Two zoned NASA polynomial parameterization
9  */
10 
11 // This file is part of Cantera. See License.txt in the top-level directory or
12 // at https://cantera.org/license.txt for license and copyright information.
13 
14 #ifndef CT_NASAPOLY2_H
15 #define CT_NASAPOLY2_H
16 
19 
20 namespace Cantera
21 {
22 /**
23  * The NASA polynomial parameterization for two temperature ranges. This
24  * parameterization expresses the heat capacity as a fourth-order polynomial.
25  * Note that this is the form used in the 1971 NASA equilibrium program and by
26  * the Chemkin software package, but differs from the form used in the more
27  * recent NASA equilibrium program.
28  *
29  * Seven coefficients \f$(a_0,\dots,a_6)\f$ are used to represent
30  * \f$ c_p^0(T)\f$, \f$ h^0(T)\f$, and \f$ s^0(T) \f$ as
31  * polynomials in \f$ T \f$ :
32  * \f[
33  * \frac{c_p(T)}{R} = a_0 + a_1 T + a_2 T^2 + a_3 T^3 + a_4 T^4
34  * \f]
35  * \f[
36  * \frac{h^0(T)}{RT} = a_0 + \frac{a_1}{2} T + \frac{a_2}{3} T^2
37  * + \frac{a_3}{4} T^3 + \frac{a_4}{5} T^4 + \frac{a_5}{T}.
38  * \f]
39  * \f[
40  * \frac{s^0(T)}{R} = a_0\ln T + a_1 T + \frac{a_2}{2} T^2
41  * + \frac{a_3}{3} T^3 + \frac{a_4}{4} T^4 + a_6.
42  * \f]
43  *
44  * This class is designed specifically for use by the class MultiSpeciesThermo.
45  *
46  * @ingroup spthermo
47  */
49 {
50 public:
51  NasaPoly2();
52 
53  //! Constructor with all input data
54  /*!
55  * @param tlow output - Minimum temperature
56  * @param thigh output - Maximum temperature
57  * @param pref output - reference pressure (Pa).
58  * @param coeffs Vector of coefficients used to set the parameters for
59  * the standard state [Tmid, 7 high-T coeffs, 7 low-T
60  * coeffs]. This is the coefficient order used in the
61  * standard NASA format.
62  */
63  NasaPoly2(doublereal tlow, doublereal thigh, doublereal pref,
64  const doublereal* coeffs) :
65  SpeciesThermoInterpType(tlow, thigh, pref),
66  m_midT(coeffs[0]),
67  mnp_low(tlow, coeffs[0], pref, coeffs + 8),
68  mnp_high(coeffs[0], thigh, pref, coeffs + 1) {
69  }
70 
71  virtual void setMinTemp(double Tmin) {
73  mnp_low.setMinTemp(Tmin);
74  }
75 
76  virtual void setMaxTemp(double Tmax) {
78  mnp_high.setMaxTemp(Tmax);
79  }
80 
81  virtual void setRefPressure(double Pref) {
83  mnp_low.setRefPressure(Pref);
85  }
86 
87  /*!
88  * @param Tmid Temperature [K] at the boundary between the low and high
89  * temperature polynomials
90  * @param low Vector of 7 coefficients for the low temperature polynomial
91  * @param high Vector of 7 coefficients for the high temperature polynomial
92  */
93  void setParameters(double Tmid, const vector_fp& low, const vector_fp& high);
94 
95  virtual int reportType() const {
96  return NASA2;
97  }
98 
99  virtual size_t temperaturePolySize() const { return 6; }
100 
101  virtual void updateTemperaturePoly(double T, double* T_poly) const {
102  mnp_low.updateTemperaturePoly(T, T_poly);
103  }
104 
105  //! @copydoc NasaPoly1::updateProperties
106  void updateProperties(const doublereal* tt,
107  doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const {
108  if (tt[0] <= m_midT) {
109  mnp_low.updateProperties(tt, cp_R, h_RT, s_R);
110  } else {
111  mnp_high.updateProperties(tt, cp_R, h_RT, s_R);
112  }
113  }
114 
115  void updatePropertiesTemp(const doublereal temp,
116  doublereal* cp_R,
117  doublereal* h_RT,
118  doublereal* s_R) const {
119  if (temp <= m_midT) {
120  mnp_low.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
121  } else {
122  mnp_high.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
123  }
124  }
125 
126  size_t nCoeffs() const { return 15; }
127 
128  void reportParameters(size_t& n, int& type,
129  doublereal& tlow, doublereal& thigh,
130  doublereal& pref,
131  doublereal* const coeffs) const {
132  mnp_high.reportParameters(n, type, coeffs[0], thigh, pref, coeffs + 1);
133  mnp_low.reportParameters(n, type, tlow, coeffs[0], pref, coeffs + 8);
134  type = NASA2;
135  }
136 
137  doublereal reportHf298(doublereal* const h298 = 0) const {
138  double h;
139  if (298.15 <= m_midT) {
140  h = mnp_low.reportHf298(0);
141  } else {
142  h = mnp_high.reportHf298(0);
143  }
144  if (h298) {
145  *h298 = h;
146  }
147  return h;
148  }
149 
150  void resetHf298() {
153  }
154 
155  void modifyOneHf298(const size_t k, const doublereal Hf298New) {
156  doublereal h298now = reportHf298(0);
157  doublereal delH = Hf298New - h298now;
158  double h = mnp_low.reportHf298(0);
159  double hnew = h + delH;
160  mnp_low.modifyOneHf298(k, hnew);
161  h = mnp_high.reportHf298(0);
162  hnew = h + delH;
163  mnp_high.modifyOneHf298(k, hnew);
164  }
165 
166  void validate(const std::string& name);
167 
168 protected:
169  //! Midrange temperature
170  doublereal m_midT;
171  //! NasaPoly1 object for the low temperature region.
173  //! NasaPoly1 object for the high temperature region.
175 };
176 
177 }
178 #endif
Cantera::NasaPoly1::reportHf298
virtual doublereal reportHf298(doublereal *const h298=0) const
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1)
Definition: NasaPoly1.h:142
Cantera::NasaPoly2::updatePropertiesTemp
void updatePropertiesTemp(const doublereal temp, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Compute the reference-state property of one species.
Definition: NasaPoly2.h:115
Cantera::NasaPoly2::reportType
virtual int reportType() const
Returns an integer representing the type of parameterization.
Definition: NasaPoly2.h:95
Cantera::NasaPoly1::modifyOneHf298
virtual void modifyOneHf298(const size_t k, const doublereal Hf298New)
Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1)
Definition: NasaPoly1.h:162
Cantera::NasaPoly1::reportParameters
virtual void reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal *const coeffs) const
This utility function returns the type of parameterization and all of the parameters for the species.
Definition: NasaPoly1.h:130
Cantera::NasaPoly2::m_midT
doublereal m_midT
Midrange temperature.
Definition: NasaPoly2.h:170
Cantera::SpeciesThermoInterpType
Abstract Base class for the thermodynamic manager for an individual species' reference state.
Definition: SpeciesThermoInterpType.h:113
Cantera::NasaPoly2::reportParameters
void reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal *const coeffs) const
This utility function returns the type of parameterization and all of the parameters for the species.
Definition: NasaPoly2.h:128
Cantera::vector_fp
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:180
Cantera::NasaPoly2::setRefPressure
virtual void setRefPressure(double Pref)
Set the reference pressure [Pa].
Definition: NasaPoly2.h:81
Cantera::NasaPoly1
The NASA polynomial parameterization for one temperature range.
Definition: NasaPoly1.h:45
Cantera::NasaPoly2::validate
void validate(const std::string &name)
Check for problems with the parameterization, and generate warnings or throw and exception if any are...
Definition: NasaPoly2.cpp:24
Cantera::NasaPoly2::setMinTemp
virtual void setMinTemp(double Tmin)
Set the minimum temperature at which the thermo parameterization is valid.
Definition: NasaPoly2.h:71
Cantera::NasaPoly2::reportHf298
doublereal reportHf298(doublereal *const h298=0) const
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1)
Definition: NasaPoly2.h:137
Cantera::NasaPoly2::mnp_high
NasaPoly1 mnp_high
NasaPoly1 object for the high temperature region.
Definition: NasaPoly2.h:174
Cantera::SpeciesThermoInterpType::setMaxTemp
virtual void setMaxTemp(double Tmax)
Set the maximum temperature at which the thermo parameterization is valid.
Definition: SpeciesThermoInterpType.h:144
NasaPoly1.h
Cantera::NasaPoly2
The NASA polynomial parameterization for two temperature ranges.
Definition: NasaPoly2.h:48
NASA2
#define NASA2
Two regions of 7 coefficient NASA Polynomials This is implemented in the class NasaPoly2 in NasaPoly2...
Definition: speciesThermoTypes.h:24
SpeciesThermoInterpType.h
Cantera::NasaPoly2::mnp_low
NasaPoly1 mnp_low
NasaPoly1 object for the low temperature region.
Definition: NasaPoly2.h:172
Cantera::SpeciesThermoInterpType::setMinTemp
virtual void setMinTemp(double Tmin)
Set the minimum temperature at which the thermo parameterization is valid.
Definition: SpeciesThermoInterpType.h:133
Cantera::NasaPoly2::nCoeffs
size_t nCoeffs() const
This utility function returns the number of coefficients for a given type of species parameterization...
Definition: NasaPoly2.h:126
Cantera::NasaPoly1::updateProperties
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.
Definition: NasaPoly1.h:101
Cantera::NasaPoly2::resetHf298
void resetHf298()
Restore the original heat of formation for this species.
Definition: NasaPoly2.h:150
Cantera::NasaPoly1::updateTemperaturePoly
virtual void updateTemperaturePoly(double T, double *T_poly) const
Given the temperature T, compute the terms of the temperature polynomial T_poly.
Definition: NasaPoly1.h:81
Cantera::NasaPoly2::setParameters
void setParameters(double Tmid, const vector_fp &low, const vector_fp &high)
Definition: NasaPoly2.cpp:15
Cantera::NasaPoly1::resetHf298
virtual void resetHf298()
Restore the original heat of formation for this species.
Definition: NasaPoly1.h:168
Cantera::NasaPoly2::setMaxTemp
virtual void setMaxTemp(double Tmax)
Set the maximum temperature at which the thermo parameterization is valid.
Definition: NasaPoly2.h:76
Cantera::NasaPoly1::updatePropertiesTemp
virtual void updatePropertiesTemp(const doublereal temp, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Compute the reference-state property of one species.
Definition: NasaPoly1.h:122
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:263
Cantera::NasaPoly2::temperaturePolySize
virtual size_t temperaturePolySize() const
Number of terms in the temperature polynomial for this parameterization.
Definition: NasaPoly2.h:99
Cantera::NasaPoly2::updateProperties
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.
Definition: NasaPoly2.h:106
Cantera::NasaPoly2::updateTemperaturePoly
virtual void updateTemperaturePoly(double T, double *T_poly) const
Given the temperature T, compute the terms of the temperature polynomial T_poly.
Definition: NasaPoly2.h:101
Cantera::SpeciesThermoInterpType::setRefPressure
virtual void setRefPressure(double Pref)
Set the reference pressure [Pa].
Definition: SpeciesThermoInterpType.h:154
Cantera::NasaPoly2::NasaPoly2
NasaPoly2(doublereal tlow, doublereal thigh, doublereal pref, const doublereal *coeffs)
Constructor with all input data.
Definition: NasaPoly2.h:63
Cantera::NasaPoly2::modifyOneHf298
void modifyOneHf298(const size_t k, const doublereal Hf298New)
Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1)
Definition: NasaPoly2.h:155