Cantera  2.3.0
NasaPoly1.h
Go to the documentation of this file.
1 /**
2  * @file NasaPoly1.h
3  * Header for a single-species standard state object derived
5  * on the NASA temperature polynomial form applied to one temperature region
7  *
8  * This parameterization has one NASA temperature region.
9  */
10
11 // This file is part of Cantera. See License.txt in the top-level directory or
13
14 #ifndef CT_NASAPOLY1_H
15 #define CT_NASAPOLY1_H
16
18
19 namespace Cantera
20 {
21 /**
22  * The NASA polynomial parameterization for one temperature range. This
23  * parameterization expresses the heat capacity as a fourth-order polynomial.
24  * Note that this is the form used in the 1971 NASA equilibrium program and by
25  * the Chemkin software package, but differs from the form used in the more
26  * recent NASA equilibrium program.
27  *
28  * Seven coefficients \f$(a_0,\dots,a_6)\f$ are used to represent
29  * \f$c_p^0(T)\f$, \f$h^0(T)\f$, and \f$s^0(T) \f$ as
30  * polynomials in \f$T \f$ :
31  * \f[
32  * \frac{c_p(T)}{R} = a_0 + a_1 T + a_2 T^2 + a_3 T^3 + a_4 T^4
33  * \f]
34  * \f[
35  * \frac{h^0(T)}{RT} = a_0 + \frac{a_1}{2} T + \frac{a_2}{3} T^2
36  * + \frac{a_3}{4} T^3 + \frac{a_4}{5} T^4 + \frac{a_5}{T}.
37  * \f]
38  * \f[
39  * \frac{s^0(T)}{R} = a_0\ln T + a_1 T + \frac{a_2}{2} T^2
40  * + \frac{a_3}{3} T^3 + \frac{a_4}{4} T^4 + a_6.
41  * \f]
42  *
43  * @ingroup spthermo
44  */
46 {
47 public:
48  //! Empty constructor
49  //! @deprecated Default constructor to be removed after Cantera 2.3.
51  : m_coeff(7, 0.0) {
52  warn_deprecated("NasaPoly1::NasaPoly1()",
53  "Default constructor to be removed after Cantera 2.3.");
54  }
55
56  //! Normal constructor
57  /*!
58  * @param tlow Minimum temperature
59  * @param thigh Maximum temperature
60  * @param pref reference pressure (Pa).
61  * @param coeffs Vector of coefficients used to set the parameters for the
62  * standard state, in the order [a0,a1,a2,a3,a4,a5,a6]
63  */
64  NasaPoly1(double tlow, double thigh, double pref, const double* coeffs)
65  : SpeciesThermoInterpType(tlow, thigh, pref)
66  , m_coeff(coeffs, coeffs+7)
67  {
68  m_coeff5_orig = m_coeff[5];
69  }
70
73  return new NasaPoly1(*this);
74  }
75
76  virtual int reportType() const {
77  return NASA1;
78  }
79
80  virtual size_t temperaturePolySize() const { return 6; }
81
82  virtual void updateTemperaturePoly(double T, double* T_poly) const {
83  T_poly[0] = T;
84  T_poly[1] = T * T;
85  T_poly[2] = T_poly[1] * T;
86  T_poly[3] = T_poly[2] * T;
87  T_poly[4] = 1.0 / T;
88  T_poly[5] = std::log(T);
89  }
90
91  /*!
92  * @copydoc SpeciesThermoInterpType::updateProperties
93  *
94  * Temperature Polynomial:
95  * tt[0] = t;
96  * tt[1] = t*t;
97  * tt[2] = m_t[1]*t;
98  * tt[3] = m_t[2]*t;
99  * tt[4] = 1.0/t;
100  * tt[5] = std::log(t);
101  */
102  virtual void updateProperties(const doublereal* tt,
103  doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const {
104  doublereal ct0 = m_coeff[0]; // a0
105  doublereal ct1 = m_coeff[1]*tt[0]; // a1 * T
106  doublereal ct2 = m_coeff[2]*tt[1]; // a2 * T^2
107  doublereal ct3 = m_coeff[3]*tt[2]; // a3 * T^3
108  doublereal ct4 = m_coeff[4]*tt[3]; // a4 * T^4
109
110  doublereal cp, h, s;
111  cp = ct0 + ct1 + ct2 + ct3 + ct4;
112  h = ct0 + 0.5*ct1 + 1.0/3.0*ct2 + 0.25*ct3 + 0.2*ct4
113  + m_coeff[5]*tt[4]; // last term is a5/T
114  s = ct0*tt[5] + ct1 + 0.5*ct2 + 1.0/3.0*ct3
115  +0.25*ct4 + m_coeff[6]; // last term is a6
116
117  // return the computed properties for this species
118  *cp_R = cp;
119  *h_RT = h;
120  *s_R = s;
121  }
122
123  virtual void updatePropertiesTemp(const doublereal temp,
124  doublereal* cp_R, doublereal* h_RT,
125  doublereal* s_R) const {
126  double tPoly[6];
127  updateTemperaturePoly(temp, tPoly);
128  updateProperties(tPoly, cp_R, h_RT, s_R);
129  }
130
131  virtual void reportParameters(size_t& n, int& type,
132  doublereal& tlow, doublereal& thigh,
133  doublereal& pref,
134  doublereal* const coeffs) const {
135  n = 0;
136  type = NASA1;
137  tlow = m_lowT;
138  thigh = m_highT;
139  pref = m_Pref;
140  std::copy(m_coeff.begin(), m_coeff.end(), coeffs);
141  }
142
143  //! @deprecated To be removed after Cantera 2.3. Use
145  virtual void modifyParameters(doublereal* coeffs) {
146  warn_deprecated("NasaPoly1::modifyParameters", "To be removed after "
147  "Cantera 2.3. Use MultiSpeciesThermo::modifySpecies instead.");
148  std::copy(coeffs, coeffs+7, m_coeff.begin());
149  }
150
151  virtual doublereal reportHf298(doublereal* const h298 = 0) const {
152  double tt[6];
153  double temp = 298.15;
154  updateTemperaturePoly(temp, tt);
155  doublereal ct0 = m_coeff[0]; // a0
156  doublereal ct1 = m_coeff[1]*tt[0]; // a1 * T
157  doublereal ct2 = m_coeff[2]*tt[1]; // a2 * T^2
158  doublereal ct3 = m_coeff[3]*tt[2]; // a3 * T^3
159  doublereal ct4 = m_coeff[4]*tt[3]; // a4 * T^4
160
161  double h_RT = ct0 + 0.5*ct1 + 1.0/3.0*ct2 + 0.25*ct3 + 0.2*ct4
162  + m_coeff[5]*tt[4]; // last t
163
164  double h = h_RT * GasConstant * temp;
165  if (h298) {
166  *h298 = h;
167  }
168  return h;
169  }
170
171  virtual void modifyOneHf298(const size_t k, const doublereal Hf298New) {
172  double hcurr = reportHf298(0);
173  double delH = Hf298New - hcurr;
174  m_coeff[5] += (delH) / GasConstant;
175  }
176
177  virtual void resetHf298() {
178  m_coeff[5] = m_coeff5_orig;
179  }
180
181 protected:
182  //! array of polynomial coefficients, stored in the order [a0, ..., a6]
184
185  double m_coeff5_orig;
186 };
187
188 }
189 #endif
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:171
Abstract Base class for the thermodynamic manager for an individual species&#39; reference state...
virtual size_t temperaturePolySize() const
Number of terms in the temperature polynomial for this parameterization.
Definition: NasaPoly1.h:80
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:54
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:82
Pure Virtual Base class for individual species reference state thermodynamic managers and text for th...
virtual int reportType() const
Returns an integer representing the type of parameterization.
Definition: NasaPoly1.h:76
virtual void resetHf298()
Restore the original heat of formation for this species.
Definition: NasaPoly1.h:177
#define NASA1
7 coefficient NASA Polynomials This is implemented in the class NasaPoly1 in NasaPoly1.h
virtual void modifyParameters(doublereal *coeffs)
Definition: NasaPoly1.h:145
virtual SpeciesThermoInterpType * duplMyselfAsSpeciesThermoInterpType() const
Definition: NasaPoly1.h:72
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:123
vector_fp m_coeff
array of polynomial coefficients, stored in the order [a0, ..., a6]
Definition: NasaPoly1.h:183
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...
Definition: NasaPoly1.h:131
doublereal m_highT
Highest valid temperature.
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:151
doublereal m_lowT
lowest valid temperature
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
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:102
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:64
NasaPoly1(double tlow, double thigh, double pref, const double *coeffs)
Normal constructor.
Definition: NasaPoly1.h:64
The NASA polynomial parameterization for one temperature range.
Definition: NasaPoly1.h:45
doublereal m_Pref
Reference state pressure.
Namespace for the Cantera kernel.
Definition: application.cpp:29
NasaPoly1()
Empty constructor.
Definition: NasaPoly1.h:50