Cantera  2.1.2
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 
16 #include "cantera/base/global.h"
18 #include <iostream>
19 
20 namespace Cantera
21 {
22 /**
23  * The NASA polynomial parameterization for one temperature range.
24  * This parameterization expresses the heat capacity as a
25  * fourth-order polynomial. Note that this is the form used in the
26  * 1971 NASA equilibrium program and by the Chemkin software
27  * package, but differs from the form used in the more recent NASA
28  * equilibrium program.
29  *
30  * Seven coefficients \f$(a_0,\dots,a_6)\f$ are used to represent
31  * \f$ c_p^0(T)\f$, \f$ h^0(T)\f$, and \f$ s^0(T) \f$ as
32  * polynomials in \f$ T \f$ :
33  * \f[
34  * \frac{c_p(T)}{R} = a_0 + a_1 T + a_2 T^2 + a_3 T^3 + a_4 T^4
35  * \f]
36  * \f[
37  * \frac{h^0(T)}{RT} = a_0 + \frac{a_1}{2} T + \frac{a_2}{3} T^2
38  * + \frac{a_3}{4} T^3 + \frac{a_4}{5} T^4 + \frac{a_5}{T}.
39  * \f]
40  * \f[
41  * \frac{s^0(T)}{R} = a_0\ln T + a_1 T + \frac{a_2}{2} T^2
42  + \frac{a_3}{3} T^3 + \frac{a_4}{4} T^4 + a_6.
43  * \f]
44  *
45  * This class is designed specifically for use by class NasaThermo.
46  * @ingroup spthermo
47  */
49 {
50 public:
51  //! Empty constructor
53  : m_coeff(7, 0.0) {}
54 
55  //! constructor used in templated instantiations
56  /*!
57  * @param n Species index
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
62  * parameters for the standard state.
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(vector_fp(7)) {
68  std::copy(coeffs, coeffs + 7, m_coeff.begin());
69  }
70 
71  //! copy constructor
72  /*!
73  * @param b object to be copied
74  */
75  NasaPoly1(const NasaPoly1& b) :
77  m_coeff(vector_fp(7))
78  {
79  std::copy(b.m_coeff.begin(),
80  b.m_coeff.begin() + 7,
81  m_coeff.begin());
82  }
83 
84  //! assignment operator
85  /*!
86  * @param b object to be copied
87  */
89  if (&b != this) {
90  SpeciesThermoInterpType::operator=(b);
91  std::copy(b.m_coeff.begin(),
92  b.m_coeff.begin() + 7,
93  m_coeff.begin());
94  }
95  return *this;
96  }
97 
100  NasaPoly1* np = new NasaPoly1(*this);
101  return (SpeciesThermoInterpType*) np;
102  }
103 
104  virtual int reportType() const {
105  return NASA1;
106  }
107 
108  //! Update the properties for this species, given a temperature polynomial
109  /*!
110  * This method is called with a pointer to an array containing the
111  * functions of temperature needed by this parameterization, and three
112  * pointers to arrays where the computed property values should be
113  * written. This method updates only one value in each array.
114  *
115  * Temperature Polynomial:
116  * tt[0] = t;
117  * tt[1] = t*t;
118  * tt[2] = m_t[1]*t;
119  * tt[3] = m_t[2]*t;
120  * tt[4] = 1.0/t;
121  * tt[5] = std::log(t);
122  *
123  * @param tt vector of temperature polynomials
124  * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
125  * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
126  * @param s_R Vector of Dimensionless entropies. (length m_kk).
127  */
128  virtual void updateProperties(const doublereal* tt,
129  doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const {
130  doublereal ct0 = m_coeff[2]; // a0
131  doublereal ct1 = m_coeff[3]*tt[0]; // a1 * T
132  doublereal ct2 = m_coeff[4]*tt[1]; // a2 * T^2
133  doublereal ct3 = m_coeff[5]*tt[2]; // a3 * T^3
134  doublereal ct4 = m_coeff[6]*tt[3]; // a4 * T^4
135 
136  doublereal cp, h, s;
137  cp = ct0 + ct1 + ct2 + ct3 + ct4;
138  h = ct0 + 0.5*ct1 + OneThird*ct2 + 0.25*ct3 + 0.2*ct4
139  + m_coeff[0]*tt[4]; // last term is a5/T
140  s = ct0*tt[5] + ct1 + 0.5*ct2 + OneThird*ct3
141  +0.25*ct4 + m_coeff[1]; // last term is a6
142 
143  // return the computed properties in the location in the output
144  // arrays for this species
145  cp_R[m_index] = cp;
146  h_RT[m_index] = h;
147  s_R[m_index] = s;
148  //writelog("NASA1: for species "+int2str(m_index)+", h_RT = "+
149  // fp2str(h)+"\n");
150  }
151 
152  virtual void updatePropertiesTemp(const doublereal temp,
153  doublereal* cp_R, doublereal* h_RT,
154  doublereal* s_R) const {
155  double tPoly[6];
156  tPoly[0] = temp;
157  tPoly[1] = temp * temp;
158  tPoly[2] = tPoly[1] * temp;
159  tPoly[3] = tPoly[2] * temp;
160  tPoly[4] = 1.0 / temp;
161  tPoly[5] = std::log(temp);
162  updateProperties(tPoly, cp_R, h_RT, s_R);
163  }
164 
165  //! @deprecated
166  virtual void reportParameters(size_t& n, int& type,
167  doublereal& tlow, doublereal& thigh,
168  doublereal& pref,
169  doublereal* const coeffs) const {
170  warn_deprecated("NasaPoly1::reportParameters");
171  n = m_index;
172  type = NASA1;
173  tlow = m_lowT;
174  thigh = m_highT;
175  pref = m_Pref;
176  coeffs[5] = m_coeff[0];
177  coeffs[6] = m_coeff[1];
178  for (int i = 2; i < 7; i++) {
179  coeffs[i-2] = m_coeff[i];
180  }
181  }
182 
183  //! Modify parameters for the standard state
184  /*!
185  * @param coeffs Vector of coefficients used to set the
186  * parameters for the standard state.
187  * @deprecated
188  */
189  virtual void modifyParameters(doublereal* coeffs) {
190  warn_deprecated("NasaPoly1::modifyParameters");
191  m_coeff[0] = coeffs[5];
192  m_coeff[1] = coeffs[6];
193  for (int i = 0; i < 5; i++) {
194  m_coeff[i+2] = coeffs[i];
195  }
196  }
197 
198 #ifdef H298MODIFY_CAPABILITY
199 
200  virtual doublereal reportHf298(doublereal* const h298 = 0) const {
201  double tt[6];
202  double temp = 298.15;
203  tt[0] = temp;
204  tt[1] = temp * temp;
205  tt[2] = tt[1] * temp;
206  tt[3] = tt[2] * temp;
207  tt[4] = 1.0 / temp;
208  //tt[5] = std::log(temp);
209  doublereal ct0 = m_coeff[2]; // a0
210  doublereal ct1 = m_coeff[3]*tt[0]; // a1 * T
211  doublereal ct2 = m_coeff[4]*tt[1]; // a2 * T^2
212  doublereal ct3 = m_coeff[5]*tt[2]; // a3 * T^3
213  doublereal ct4 = m_coeff[6]*tt[3]; // a4 * T^4
214 
215  double h_RT = ct0 + 0.5*ct1 + OneThird*ct2 + 0.25*ct3 + 0.2*ct4
216  + m_coeff[0]*tt[4]; // last t
217 
218  double h = h_RT * GasConstant * temp;
219  if (h298) {
220  h298[m_index] = h;
221  }
222  return h;
223  }
224 
225  virtual void modifyOneHf298(const size_t& k, const doublereal Hf298New) {
226  if (k != m_index) {
227  return;
228  }
229  double hcurr = reportHf298(0);
230  double delH = Hf298New - hcurr;
231  m_coeff[0] += (delH) / GasConstant;
232  }
233 
234 #endif
235 
236 protected:
237  //! array of polynomial coefficients
239 };
240 
241 }
242 #endif
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:104
NasaPoly1(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal *coeffs)
constructor used in templated instantiations
Definition: NasaPoly1.h:64
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:76
This file contains definitions for utility functions and text for modules, inputfiles, logs, textlogs, HTML_logs (see Input File Handling, Diagnostic Output, Writing messages to the screen and Writing HTML Logfiles).
NasaPoly1 & operator=(const NasaPoly1 &b)
assignment operator
Definition: NasaPoly1.h:88
Pure Virtual Base class for individual species reference state thermodynamic managers and text for th...
NasaPoly1(const NasaPoly1 &b)
copy constructor
Definition: NasaPoly1.h:75
#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:189
const doublereal OneThird
1/3
Definition: ct_defs.h:128
virtual SpeciesThermoInterpType * duplMyselfAsSpeciesThermoInterpType() const
duplicator
Definition: NasaPoly1.h:99
vector_fp m_coeff
array of polynomial coefficients
Definition: NasaPoly1.h:238
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:152
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:165
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:66
virtual void reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal *const coeffs) const
Definition: NasaPoly1.h:166
The NASA polynomial parameterization for one temperature range.
Definition: NasaPoly1.h:48
doublereal m_Pref
Reference state pressure.
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:128
NasaPoly1()
Empty constructor.
Definition: NasaPoly1.h:52