Cantera  2.1.2
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 // Copyright 2001 California Institute of Technology
11 
12 #ifndef CT_NASAPOLY2_H
13 #define CT_NASAPOLY2_H
14 
17 
18 namespace Cantera
19 {
20 /**
21  * The NASA polynomial parameterization for two temperature ranges.
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 the class
44  * GeneralSpeciesThermo.
45  *
46  * @ingroup spthermo
47  */
49 {
50 public:
51  //! Empty constructor
53  : m_midT(0.0),
54  m_coeff(15, 0.0) {
55  }
56 
57  //! Full Constructor
58  /*!
59  * @param n Species index
60  * @param tlow output - Minimum temperature
61  * @param thigh output - Maximum temperature
62  * @param pref output - reference pressure (Pa).
63  * @param coeffs Vector of coefficients used to set the
64  * parameters for the standard state.
65  */
66  NasaPoly2(size_t n, doublereal tlow, doublereal thigh, doublereal pref,
67  const doublereal* coeffs) :
68  SpeciesThermoInterpType(n, tlow, thigh, pref),
69  mnp_low(n, tlow, coeffs[0], pref, coeffs +1),
70  mnp_high(n, tlow, thigh, pref, coeffs + 8),
71  m_coeff(15, 0.0) {
72  std::copy(coeffs, coeffs + 15, m_coeff.begin());
73  m_midT = coeffs[0];
74  }
75 
76  //! Copy Constructor
77  /*!
78  * @param b object to be copied.
79  */
80  NasaPoly2(const NasaPoly2& b) :
82  m_midT(b.m_midT),
83  mnp_low(b.mnp_low),
84  mnp_high(b.mnp_high),
85  m_coeff(b.m_coeff) {
86  }
87 
88  //! Assignment operator
89  /*!
90  * @param b object to be copied.
91  */
93  if (&b != this) {
94  SpeciesThermoInterpType::operator=(b);
95  m_midT = b.m_midT;
96  m_coeff = b.m_coeff;
97  mnp_low = b.mnp_low;
98  mnp_high = b.mnp_high;
99  }
100  return *this;
101  }
102 
103  virtual SpeciesThermoInterpType*
105  NasaPoly2* np = new NasaPoly2(*this);
106  return (SpeciesThermoInterpType*) np;
107  }
108 
109  virtual int reportType() const {
110  return NASA2;
111  }
112 
113  //! Update the properties for this species, given a temperature polynomial
114  /*!
115  * This method is called with a pointer to an array containing the
116  * functions of temperature needed by this parameterization, and three
117  * pointers to arrays where the computed property values should be
118  * written. This method updates only one value in each array.
119  *
120  * Temperature Polynomial:
121  * tt[0] = t;
122  * tt[1] = t*t;
123  * tt[2] = m_t[1]*t;
124  * tt[3] = m_t[2]*t;
125  * tt[4] = 1.0/t;
126  * tt[5] = std::log(t);
127  *
128  * @param tt vector of temperature polynomials
129  * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
130  * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
131  * @param s_R Vector of Dimensionless entropies. (length m_kk).
132  */
133  void updateProperties(const doublereal* tt,
134  doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const {
135  double T = tt[0];
136  if (T <= m_midT) {
137  mnp_low.updateProperties(tt, cp_R, h_RT, s_R);
138  } else {
139  mnp_high.updateProperties(tt, cp_R, h_RT, s_R);
140  }
141  }
142 
143  void updatePropertiesTemp(const doublereal temp,
144  doublereal* cp_R,
145  doublereal* h_RT,
146  doublereal* s_R) const {
147  if (temp <= m_midT) {
148  mnp_low.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
149  } else {
150  mnp_high.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
151  }
152  }
153 
154  //! @deprecated
155  void reportParameters(size_t& n, int& type,
156  doublereal& tlow, doublereal& thigh,
157  doublereal& pref,
158  doublereal* const coeffs) const {
159  warn_deprecated("NasaPoly2::reportParameters");
160  n = m_index;
161  type = NASA2;
162  tlow = m_lowT;
163  thigh = m_highT;
164  pref = m_Pref;
165  for (int i = 0; i < 15; i++) {
166  coeffs[i] = m_coeff[i];
167  }
168  }
169 
170 #ifdef H298MODIFY_CAPABILITY
171 
172  doublereal reportHf298(doublereal* const h298 = 0) const {
173  double h;
174  if (298.15 <= m_midT) {
175  h = mnp_low.reportHf298(0);
176  } else {
177  h = mnp_high.reportHf298(0);
178  }
179  if (h298) {
180  h298[m_index] = h;
181  }
182  return h;
183  }
184 
185  void modifyOneHf298(const size_t& k, const doublereal Hf298New) {
186  if (k != m_index) {
187  return;
188  }
189 
190  doublereal h298now = reportHf298(0);
191  doublereal delH = Hf298New - h298now;
192  double h = mnp_low.reportHf298(0);
193  double hnew = h + delH;
194  mnp_low.modifyOneHf298(k, hnew);
195  h = mnp_high.reportHf298(0);
196  hnew = h + delH;
197  mnp_high.modifyOneHf298(k, hnew);
198  }
199 
200 #endif
201 
202 protected:
203  //! Midrange temperature
204  doublereal m_midT;
205  //! NasaPoly1 object for the low temperature region.
207  //! NasaPoly1 object for the high temperature region.
209  //! array of polynomial coefficients
211 };
212 
213 }
214 #endif
Pure Virtual Base class for the thermodynamic manager for an individual species' reference state...
The NASA polynomial parameterization for two temperature ranges.
Definition: NasaPoly2.h:48
void reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal *const coeffs) const
Definition: NasaPoly2.h:155
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:133
#define NASA2
Two regions of 7 coefficient NASA Polynomials This is implemented in the class NasaPoly2 in NasaPoly2...
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:76
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:143
Pure Virtual Base class for individual species reference state thermodynamic managers and text for th...
virtual SpeciesThermoInterpType * duplMyselfAsSpeciesThermoInterpType() const
duplicator
Definition: NasaPoly2.h:104
vector_fp m_coeff
array of polynomial coefficients
Definition: NasaPoly2.h:210
NasaPoly1 mnp_high
NasaPoly1 object for the high temperature region.
Definition: NasaPoly2.h:208
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
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the N...
doublereal m_lowT
lowest valid temperature
virtual int reportType() const
Returns an integer representing the type of parameterization.
Definition: NasaPoly2.h:109
doublereal m_midT
Midrange temperature.
Definition: NasaPoly2.h:204
NasaPoly2(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal *coeffs)
Full Constructor.
Definition: NasaPoly2.h:66
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
NasaPoly2()
Empty constructor.
Definition: NasaPoly2.h:52
NasaPoly2 & operator=(const NasaPoly2 &b)
Assignment operator.
Definition: NasaPoly2.h:92
The NASA polynomial parameterization for one temperature range.
Definition: NasaPoly1.h:48
doublereal m_Pref
Reference state pressure.
NasaPoly2(const NasaPoly2 &b)
Copy Constructor.
Definition: NasaPoly2.h:80
NasaPoly1 mnp_low
NasaPoly1 object for the low temperature region.
Definition: NasaPoly2.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:128