Cantera  2.2.1
NasaPoly2.h
Go to the documentation of this file.
1 /**
2  * @file NasaPoly2.h
3  * Header for a single-species standard state object derived
5  * on the NASA temperature polynomial form applied to two temperature regions
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 parameters for
64  * the standard state [Tmid, 7 low-T coeffs, 7 high-T coeffs]
65  * @deprecated Use constructor without species index. To be removed after
66  * Cantera 2.2.
67  */
68  NasaPoly2(size_t n, doublereal tlow, doublereal thigh, doublereal pref,
69  const doublereal* coeffs) :
70  SpeciesThermoInterpType(n, tlow, thigh, pref),
71  m_midT(coeffs),
72  mnp_low(n, tlow, coeffs, pref, coeffs +1),
73  mnp_high(n, tlow, thigh, pref, coeffs + 8),
74  m_coeff(coeffs, coeffs + 15) {
75  }
76
77  //! Full Constructor
78  /*!
79  * @param tlow output - Minimum temperature
80  * @param thigh output - Maximum temperature
81  * @param pref output - reference pressure (Pa).
82  * @param coeffs Vector of coefficients used to set the parameters for
83  * the standard state [Tmid, 7 high-T coeffs, 7 low-T
84  * coeffs]. This is the coefficient order used in the
85  * standard NASA format.
86  */
87  NasaPoly2(doublereal tlow, doublereal thigh, doublereal pref,
88  const doublereal* coeffs) :
89  SpeciesThermoInterpType(tlow, thigh, pref),
90  m_midT(coeffs),
91  mnp_low(tlow, coeffs, pref, coeffs + 8),
92  mnp_high(coeffs, thigh, pref, coeffs + 1),
93  m_coeff(coeffs, coeffs + 15) {
94  }
95
96  //! Copy Constructor
97  /*!
98  * @param b object to be copied.
99  */
100  NasaPoly2(const NasaPoly2& b) :
102  m_midT(b.m_midT),
103  mnp_low(b.mnp_low),
104  mnp_high(b.mnp_high),
105  m_coeff(b.m_coeff) {
106  }
107
108  //! Assignment operator
109  /*!
110  * @param b object to be copied.
111  */
113  if (&b != this) {
114  SpeciesThermoInterpType::operator=(b);
115  m_midT = b.m_midT;
116  m_coeff = b.m_coeff;
117  mnp_low = b.mnp_low;
118  mnp_high = b.mnp_high;
119  }
120  return *this;
121  }
122
123  virtual SpeciesThermoInterpType*
124  duplMyselfAsSpeciesThermoInterpType() const {
125  NasaPoly2* np = new NasaPoly2(*this);
126  return (SpeciesThermoInterpType*) np;
127  }
128
129  virtual int reportType() const {
130  return NASA2;
131  }
132
133  virtual void setIndex(size_t index) {
135  mnp_low.setIndex(index);
136  mnp_high.setIndex(index);
137  }
138
139  virtual size_t temperaturePolySize() const { return 6; }
140
141  virtual void updateTemperaturePoly(double T, double* T_poly) const {
142  mnp_low.updateTemperaturePoly(T, T_poly);
143  }
144
145  //! Update the properties for this species, given a temperature polynomial
146  /*!
147  * This method is called with a pointer to an array containing the
148  * functions of temperature needed by this parameterization, and three
149  * pointers to arrays where the computed property values should be
150  * written. This method updates only one value in each array.
151  *
152  * Temperature Polynomial:
153  * tt = t;
154  * tt = t*t;
155  * tt = m_t*t;
156  * tt = m_t*t;
157  * tt = 1.0/t;
158  * tt = std::log(t);
159  *
160  * @param tt vector of temperature polynomials
161  * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
162  * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
163  * @param s_R Vector of Dimensionless entropies. (length m_kk).
164  */
165  void updateProperties(const doublereal* tt,
166  doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const {
167  if (tt <= m_midT) {
168  mnp_low.updateProperties(tt, cp_R, h_RT, s_R);
169  } else {
170  mnp_high.updateProperties(tt, cp_R, h_RT, s_R);
171  }
172  }
173
174  void updatePropertiesTemp(const doublereal temp,
175  doublereal* cp_R,
176  doublereal* h_RT,
177  doublereal* s_R) const {
178  if (temp <= m_midT) {
179  mnp_low.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
180  } else {
181  mnp_high.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
182  }
183  }
184
185  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 = NASA2;
191  tlow = m_lowT;
192  thigh = m_highT;
193  pref = m_Pref;
194  for (int i = 0; i < 15; i++) {
195  coeffs[i] = m_coeff[i];
196  }
197  }
198
199  doublereal reportHf298(doublereal* const h298 = 0) const {
200  double h;
201  if (298.15 <= m_midT) {
202  h = mnp_low.reportHf298(0);
203  } else {
204  h = mnp_high.reportHf298(0);
205  }
206  if (h298) {
207  h298[m_index] = h;
208  }
209  return h;
210  }
211
212  void modifyOneHf298(const size_t k, const doublereal Hf298New) {
213  if (k != m_index) {
214  return;
215  }
216
217  doublereal h298now = reportHf298(0);
218  doublereal delH = Hf298New - h298now;
219  double h = mnp_low.reportHf298(0);
220  double hnew = h + delH;
221  mnp_low.modifyOneHf298(k, hnew);
222  h = mnp_high.reportHf298(0);
223  hnew = h + delH;
224  mnp_high.modifyOneHf298(k, hnew);
225  }
226
227  void validate(const std::string& name);
228
229 protected:
230  //! Midrange temperature
231  doublereal m_midT;
232  //! NasaPoly1 object for the low temperature region.
234  //! NasaPoly1 object for the high temperature region.
236  //! array of polynomial coefficients
238 };
239
240 }
241 #endif
virtual size_t temperaturePolySize() const
Number of terms in the temperature polynomial for this parameterization.
Definition: NasaPoly2.h:139
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: NasaPoly2.h:212
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...
void validate(const std::string &name)
Check for problems with the parameterization, and generate warnings or throw and exception if any are...
Definition: NasaPoly2.cpp:7
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
This utility function reports back the type of parameterization and all of the parameters for the spe...
Definition: NasaPoly2.h:185
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:165
#define NASA2
Two regions of 7 coefficient NASA Polynomials This is implemented in the class NasaPoly2 in NasaPoly2...
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:174
Pure Virtual Base class for individual species reference state thermodynamic managers and text for th...
virtual void updateTemperaturePoly(double T, double *T_poly) const
Given the temperature T, compute the terms of the temperature polynomial T_poly.
Definition: NasaPoly2.h:141
vector_fp m_coeff
array of polynomial coefficients
Definition: NasaPoly2.h:237
NasaPoly1 mnp_high
NasaPoly1 object for the high temperature region.
Definition: NasaPoly2.h:235
NasaPoly2(doublereal tlow, doublereal thigh, doublereal pref, const doublereal *coeffs)
Full Constructor.
Definition: NasaPoly2.h:87
doublereal m_highT
Highest valid temperature.
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: NasaPoly2.h:199
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
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:129
doublereal m_midT
Midrange temperature.
Definition: NasaPoly2.h:231
NasaPoly2(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal *coeffs)
Full Constructor.
Definition: NasaPoly2.h:68
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
NasaPoly2()
Empty constructor.
Definition: NasaPoly2.h:52
NasaPoly2 & operator=(const NasaPoly2 &b)
Assignment operator.
Definition: NasaPoly2.h:112
The NASA polynomial parameterization for one temperature range.
Definition: NasaPoly1.h:46
doublereal m_Pref
Reference state pressure.
NasaPoly2(const NasaPoly2 &b)
Copy Constructor.
Definition: NasaPoly2.h:100
NasaPoly1 mnp_low
NasaPoly1 object for the low temperature region.
Definition: NasaPoly2.h:233
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
virtual void setIndex(size_t index)
Definition: NasaPoly2.h:133