Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NasaPoly1.h
Go to the documentation of this file.
1 
2 /**
3  * @file NasaPoly1.h
4  * Header for a single-species standard state object derived
5  * from \link Cantera::SpeciesThermoInterpType SpeciesThermoInterpType\endlink based
6  * on the NASA temperature polynomial form applied to one temperature region
7  * (see \ref spthermo and class \link Cantera::NasaPoly1 NasaPoly1\endlink).
8  *
9  * This parameterization has one NASA temperature region.
10  */
11 
12 #ifndef CT_NASAPOLY1_H
13 #define CT_NASAPOLY1_H
14 // Copyright 2001 California Institute of Technology
15 
17 
18 namespace Cantera
19 {
20 /**
21  * The NASA polynomial parameterization for one temperature range.
22  * This parameterization expresses the heat capacity as a
23  * fourth-order polynomial. Note that this is the form used in the
24  * 1971 NASA equilibrium program and by the Chemkin software
25  * package, but differs from the form used in the more recent NASA
26  * 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  * This class is designed specifically for use by class NasaThermo.
44  * @ingroup spthermo
45  */
47 {
48 public:
49  //! Empty constructor
51  : m_coeff(7, 0.0) {}
52 
53  //! constructor used in templated instantiations
54  /*!
55  * @param n Species index
56  * @param tlow Minimum temperature
57  * @param thigh Maximum temperature
58  * @param pref reference pressure (Pa).
59  * @param coeffs Vector of coefficients used to set the parameters for the
60  * standard state, in the order [a5,a6,a0,a1,a2,a3,a4]
61  * @deprecated Use the constructor which does not take species index. To be
62  * removed after Cantera 2.2.
63  */
64  NasaPoly1(size_t n, doublereal tlow, doublereal thigh, doublereal pref,
65  const doublereal* coeffs) :
66  SpeciesThermoInterpType(n, tlow, thigh, pref),
67  m_coeff(7)
68  {
69  for (size_t i = 0; i < 5; i++) {
70  m_coeff[i] = coeffs[i+2];
71  }
72  m_coeff[5] = coeffs[0];
73  m_coeff[6] = coeffs[1];
74  }
75 
76  //! Normal constructor
77  /*!
78  * @param tlow Minimum temperature
79  * @param thigh Maximum temperature
80  * @param pref reference pressure (Pa).
81  * @param coeffs Vector of coefficients used to set the parameters for the
82  * standard state, in the order [a0,a1,a2,a3,a4,a5,a6]
83  */
84  NasaPoly1(double tlow, double thigh, double pref, const double* coeffs)
85  : SpeciesThermoInterpType(tlow, thigh, pref)
86  , m_coeff(coeffs, coeffs+7)
87  {
88  }
89 
90  //! copy constructor
91  /*!
92  * @param b object to be copied
93  */
94  NasaPoly1(const NasaPoly1& b) :
96  m_coeff(b.m_coeff)
97  {
98  }
99 
100  //! assignment operator
101  /*!
102  * @param b object to be copied
103  */
105  if (&b != this) {
106  SpeciesThermoInterpType::operator=(b);
107  m_coeff = b.m_coeff;
108  }
109  return *this;
110  }
111 
112  virtual SpeciesThermoInterpType*
113  duplMyselfAsSpeciesThermoInterpType() const {
114  NasaPoly1* np = new NasaPoly1(*this);
115  return (SpeciesThermoInterpType*) np;
116  }
117 
118  virtual int reportType() const {
119  return NASA1;
120  }
121 
122  virtual size_t temperaturePolySize() const { return 6; }
123 
124  virtual void updateTemperaturePoly(double T, double* T_poly) const {
125  T_poly[0] = T;
126  T_poly[1] = T * T;
127  T_poly[2] = T_poly[1] * T;
128  T_poly[3] = T_poly[2] * T;
129  T_poly[4] = 1.0 / T;
130  T_poly[5] = std::log(T);
131  }
132 
133  //! Update the properties for this species, given a temperature polynomial
134  /*!
135  * This method is called with a pointer to an array containing the
136  * functions of temperature needed by this parameterization, and three
137  * pointers to arrays where the computed property values should be
138  * written. This method updates only one value in each array.
139  *
140  * Temperature Polynomial:
141  * tt[0] = t;
142  * tt[1] = t*t;
143  * tt[2] = m_t[1]*t;
144  * tt[3] = m_t[2]*t;
145  * tt[4] = 1.0/t;
146  * tt[5] = std::log(t);
147  *
148  * @param tt vector of temperature polynomials
149  * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
150  * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
151  * @param s_R Vector of Dimensionless entropies. (length m_kk).
152  */
153  virtual void updateProperties(const doublereal* tt,
154  doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const {
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  doublereal cp, h, s;
162  cp = ct0 + ct1 + ct2 + ct3 + ct4;
163  h = ct0 + 0.5*ct1 + 1.0/3.0*ct2 + 0.25*ct3 + 0.2*ct4
164  + m_coeff[5]*tt[4]; // last term is a5/T
165  s = ct0*tt[5] + ct1 + 0.5*ct2 + 1.0/3.0*ct3
166  +0.25*ct4 + m_coeff[6]; // last term is a6
167 
168  // return the computed properties in the location in the output
169  // arrays for this species
170  cp_R[m_index] = cp;
171  h_RT[m_index] = h;
172  s_R[m_index] = s;
173  //writelog("NASA1: for species "+int2str(m_index)+", h_RT = "+
174  // fp2str(h)+"\n");
175  }
176 
177  virtual void updatePropertiesTemp(const doublereal temp,
178  doublereal* cp_R, doublereal* h_RT,
179  doublereal* s_R) const {
180  double tPoly[6];
181  updateTemperaturePoly(temp, tPoly);
182  updateProperties(tPoly, cp_R, h_RT, s_R);
183  }
184 
185  virtual void reportParameters(size_t& n, int& type,
186  doublereal& tlow, doublereal& thigh,
187  doublereal& pref,
188  doublereal* const coeffs) const {
189  n = m_index;
190  type = NASA1;
191  tlow = m_lowT;
192  thigh = m_highT;
193  pref = m_Pref;
194  std::copy(m_coeff.begin(), m_coeff.end(), coeffs);
195  }
196 
197  //! Modify parameters for the standard state
198  /*!
199  * @param coeffs Vector of coefficients used to set the
200  * parameters for the standard state.
201  */
202  virtual void modifyParameters(doublereal* coeffs) {
203  std::copy(coeffs, coeffs+7, m_coeff.begin());
204  }
205 
206  virtual doublereal reportHf298(doublereal* const h298 = 0) const {
207  double tt[6];
208  double temp = 298.15;
209  updateTemperaturePoly(temp, tt);
210  doublereal ct0 = m_coeff[0]; // a0
211  doublereal ct1 = m_coeff[1]*tt[0]; // a1 * T
212  doublereal ct2 = m_coeff[2]*tt[1]; // a2 * T^2
213  doublereal ct3 = m_coeff[3]*tt[2]; // a3 * T^3
214  doublereal ct4 = m_coeff[4]*tt[3]; // a4 * T^4
215 
216  double h_RT = ct0 + 0.5*ct1 + 1.0/3.0*ct2 + 0.25*ct3 + 0.2*ct4
217  + m_coeff[5]*tt[4]; // last t
218 
219  double h = h_RT * GasConstant * temp;
220  if (h298) {
221  h298[m_index] = h;
222  }
223  return h;
224  }
225 
226  virtual void modifyOneHf298(const size_t k, const doublereal Hf298New) {
227  if (k != m_index) {
228  return;
229  }
230  double hcurr = reportHf298(0);
231  double delH = Hf298New - hcurr;
232  m_coeff[5] += (delH) / GasConstant;
233  }
234 
235 protected:
236  //! array of polynomial coefficients, stored in the order [a0, ..., a6]
238 };
239 
240 }
241 #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:226
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:124
Pure Virtual Base class for the thermodynamic manager for an individual species' reference state...
virtual int reportType() const
Returns an integer representing the type of parameterization.
Definition: NasaPoly1.h:118
NasaPoly1(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal *coeffs)
constructor used in templated instantiations
Definition: NasaPoly1.h:64
NasaPoly1 & operator=(const NasaPoly1 &b)
assignment operator
Definition: NasaPoly1.h:104
Pure Virtual Base class for individual species reference state thermodynamic managers and text for th...
NasaPoly1(const NasaPoly1 &b)
copy constructor
Definition: NasaPoly1.h:94
#define NASA1
7 coefficient NASA Polynomials This is implemented in the class NasaPoly1 in NasaPoly1.h
virtual void modifyParameters(doublereal *coeffs)
Modify parameters for the standard state.
Definition: NasaPoly1.h:202
vector_fp m_coeff
array of polynomial coefficients, stored in the order [a0, ..., a6]
Definition: NasaPoly1.h:237
doublereal m_highT
Highest valid temperature.
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:177
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 size_t temperaturePolySize() const
Number of terms in the temperature polynomial for this parameterization.
Definition: NasaPoly1.h:122
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:84
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:185
The NASA polynomial parameterization for one temperature range.
Definition: NasaPoly1.h:46
doublereal m_Pref
Reference state pressure.
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:206
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:153
NasaPoly1()
Empty constructor.
Definition: NasaPoly1.h:50