Cantera  2.4.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
4  * from \link Cantera::SpeciesThermoInterpType SpeciesThermoInterpType\endlink based
5  * on the NASA temperature polynomial form applied to one temperature region
6  * (see \ref spthermo and class \link Cantera::NasaPoly1 NasaPoly1\endlink).
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
12 // at http://www.cantera.org/license.txt for license and copyright information.
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  //! Normal constructor
49  /*!
50  * @param tlow Minimum temperature
51  * @param thigh Maximum temperature
52  * @param pref reference pressure (Pa).
53  * @param coeffs Vector of coefficients used to set the parameters for the
54  * standard state, in the order [a0,a1,a2,a3,a4,a5,a6]
55  */
56  NasaPoly1(double tlow, double thigh, double pref, const double* coeffs)
57  : SpeciesThermoInterpType(tlow, thigh, pref)
58  , m_coeff(coeffs, coeffs+7)
59  {
60  m_coeff5_orig = m_coeff[5];
61  }
62 
63  virtual int reportType() const {
64  return NASA1;
65  }
66 
67  virtual size_t temperaturePolySize() const { return 6; }
68 
69  virtual void updateTemperaturePoly(double T, double* T_poly) const {
70  T_poly[0] = T;
71  T_poly[1] = T * T;
72  T_poly[2] = T_poly[1] * T;
73  T_poly[3] = T_poly[2] * T;
74  T_poly[4] = 1.0 / T;
75  T_poly[5] = std::log(T);
76  }
77 
78  /*!
79  * @copydoc SpeciesThermoInterpType::updateProperties
80  *
81  * Temperature Polynomial:
82  * tt[0] = t;
83  * tt[1] = t*t;
84  * tt[2] = m_t[1]*t;
85  * tt[3] = m_t[2]*t;
86  * tt[4] = 1.0/t;
87  * tt[5] = std::log(t);
88  */
89  virtual void updateProperties(const doublereal* tt,
90  doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const {
91  doublereal ct0 = m_coeff[0]; // a0
92  doublereal ct1 = m_coeff[1]*tt[0]; // a1 * T
93  doublereal ct2 = m_coeff[2]*tt[1]; // a2 * T^2
94  doublereal ct3 = m_coeff[3]*tt[2]; // a3 * T^3
95  doublereal ct4 = m_coeff[4]*tt[3]; // a4 * T^4
96 
97  doublereal cp, h, s;
98  cp = ct0 + ct1 + ct2 + ct3 + ct4;
99  h = ct0 + 0.5*ct1 + 1.0/3.0*ct2 + 0.25*ct3 + 0.2*ct4
100  + m_coeff[5]*tt[4]; // last term is a5/T
101  s = ct0*tt[5] + ct1 + 0.5*ct2 + 1.0/3.0*ct3
102  +0.25*ct4 + m_coeff[6]; // last term is a6
103 
104  // return the computed properties for this species
105  *cp_R = cp;
106  *h_RT = h;
107  *s_R = s;
108  }
109 
110  virtual void updatePropertiesTemp(const doublereal temp,
111  doublereal* cp_R, doublereal* h_RT,
112  doublereal* s_R) const {
113  double tPoly[6];
114  updateTemperaturePoly(temp, tPoly);
115  updateProperties(tPoly, cp_R, h_RT, s_R);
116  }
117 
118  virtual void reportParameters(size_t& n, int& type,
119  doublereal& tlow, doublereal& thigh,
120  doublereal& pref,
121  doublereal* const coeffs) const {
122  n = 0;
123  type = NASA1;
124  tlow = m_lowT;
125  thigh = m_highT;
126  pref = m_Pref;
127  std::copy(m_coeff.begin(), m_coeff.end(), coeffs);
128  }
129 
130  virtual doublereal reportHf298(doublereal* const h298 = 0) const {
131  double tt[6];
132  double temp = 298.15;
133  updateTemperaturePoly(temp, tt);
134  doublereal ct0 = m_coeff[0]; // a0
135  doublereal ct1 = m_coeff[1]*tt[0]; // a1 * T
136  doublereal ct2 = m_coeff[2]*tt[1]; // a2 * T^2
137  doublereal ct3 = m_coeff[3]*tt[2]; // a3 * T^3
138  doublereal ct4 = m_coeff[4]*tt[3]; // a4 * T^4
139 
140  double h_RT = ct0 + 0.5*ct1 + 1.0/3.0*ct2 + 0.25*ct3 + 0.2*ct4
141  + m_coeff[5]*tt[4]; // last t
142 
143  double h = h_RT * GasConstant * temp;
144  if (h298) {
145  *h298 = h;
146  }
147  return h;
148  }
149 
150  virtual void modifyOneHf298(const size_t k, const doublereal Hf298New) {
151  double hcurr = reportHf298(0);
152  double delH = Hf298New - hcurr;
153  m_coeff[5] += (delH) / GasConstant;
154  }
155 
156  virtual void resetHf298() {
157  m_coeff[5] = m_coeff5_orig;
158  }
159 
160 protected:
161  //! array of polynomial coefficients, stored in the order [a0, ..., a6]
163 
164  double m_coeff5_orig;
165 };
166 
167 }
168 #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:150
Abstract Base class for the thermodynamic manager for an individual species' reference state...
virtual size_t temperaturePolySize() const
Number of terms in the temperature polynomial for this parameterization.
Definition: NasaPoly1.h:67
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:69
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:63
virtual void resetHf298()
Restore the original heat of formation for this species.
Definition: NasaPoly1.h:156
#define NASA1
7 coefficient NASA Polynomials This is implemented in the class NasaPoly1 in NasaPoly1.h
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:110
vector_fp m_coeff
array of polynomial coefficients, stored in the order [a0, ..., a6]
Definition: NasaPoly1.h:162
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:118
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:130
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:89
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:56
The NASA polynomial parameterization for one temperature range.
Definition: NasaPoly1.h:45
doublereal m_Pref
Reference state pressure.
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8