Cantera  2.0
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 
13 #ifndef CT_NASAPOLY2_H
14 #define CT_NASAPOLY2_H
15 
17 
18 namespace Cantera
19 {
20 
21 /**
22  *
23  *
24  * The NASA polynomial parameterization for two temperature ranges.
25  * This parameterization expresses the heat capacity as a
26  * fourth-order polynomial. Note that this is the form used in the
27  * 1971 NASA equilibrium program and by the Chemkin software
28  * package, but differs from the form used in the more recent NASA
29  * equilibrium program.
30  *
31  * Seven coefficients \f$(a_0,\dots,a_6)\f$ are used to represent
32  * \f$ c_p^0(T)\f$, \f$ h^0(T)\f$, and \f$ s^0(T) \f$ as
33  * polynomials in \f$ T \f$ :
34  * \f[
35  * \frac{c_p(T)}{R} = a_0 + a_1 T + a_2 T^2 + a_3 T^3 + a_4 T^4
36  * \f]
37  * \f[
38  * \frac{h^0(T)}{RT} = a_0 + \frac{a_1}{2} T + \frac{a_2}{3} T^2
39  * + \frac{a_3}{4} T^3 + \frac{a_4}{5} T^4 + \frac{a_5}{T}.
40  * \f]
41  * \f[
42  * \frac{s^0(T)}{R} = a_0\ln T + a_1 T + \frac{a_2}{2} T^2
43  + \frac{a_3}{3} T^3 + \frac{a_4}{4} T^4 + a_6.
44  * \f]
45  *
46  * This class is designed specifically for use by the class
47  * GeneralSpeciesThermo.
48  *
49  * @ingroup spthermo
50  */
52 {
53 
54 public:
55 
56  //! Empty constructor
58  : m_lowT(0.0),
59  m_midT(0.0),
60  m_highT(0.0),
61  m_Pref(0.0),
62  m_index(0),
63  m_coeff(15, 0.0) {
64  }
65 
66  //! Full Constructor
67  /*!
68  * @param n Species index
69  * @param tlow output - Minimum temperature
70  * @param thigh output - Maximum temperature
71  * @param pref output - reference pressure (Pa).
72  * @param coeffs Vector of coefficients used to set the
73  * parameters for the standard state.
74  */
75  NasaPoly2(size_t n, doublereal tlow, doublereal thigh, doublereal pref,
76  const doublereal* coeffs) :
77  m_lowT(tlow),
78  m_highT(thigh),
79  m_Pref(pref),
80  mnp_low(n, tlow, coeffs[0], pref, coeffs +1),
81  mnp_high(n, tlow, thigh, pref, coeffs + 8),
82  m_index(n),
83  m_coeff(15, 0.0) {
84 
85  std::copy(coeffs, coeffs + 15, m_coeff.begin());
86  m_midT = coeffs[0];
87  }
88 
89  //! Copy Constructor
90  /*!
91  * @param b object to be copied.
92  */
93  NasaPoly2(const NasaPoly2& b) :
94  m_lowT(b.m_lowT),
95  m_midT(b.m_midT),
96  m_highT(b.m_highT),
97  m_Pref(b.m_Pref),
98  mnp_low(b.mnp_low),
99  mnp_high(b.mnp_high),
100  m_index(b.m_index),
101  m_coeff(b.m_coeff) {
102  }
103 
104  //! Assignment operator
105  /*!
106  * @param b object to be copied.
107  */
109  if (&b != this) {
110  m_lowT = b.m_lowT;
111  m_midT = b.m_midT;
112  m_highT = b.m_highT;
113  m_Pref = b.m_Pref;
114  m_index = b.m_index;
115  m_coeff = b.m_coeff;
116  mnp_low = b.mnp_low;
117  mnp_high = b.mnp_high;
118  }
119  return *this;
120  }
121 
122  //! destructor
123  virtual ~NasaPoly2() { }
124 
125  //! duplicator
126  virtual SpeciesThermoInterpType*
128  NasaPoly2* np = new NasaPoly2(*this);
129  return (SpeciesThermoInterpType*) np;
130  }
131 
132  //! Returns the minimum temperature that the thermo
133  //! parameterization is valid
134  doublereal minTemp() const {
135  return m_lowT;
136  }
137 
138  //! Returns the maximum temperature that the thermo
139  //! parameterization is valid
140  doublereal maxTemp() const {
141  return m_highT;
142  }
143 
144  //! Returns the reference pressure (Pa)
145  doublereal refPressure() const {
146  return m_Pref;
147  }
148 
149  //! Returns an integer representing the type of parameterization
150  virtual int reportType() const {
151  return NASA2;
152  }
153 
154  //! Returns an integer representing the species index
155  virtual size_t speciesIndex() const {
156  return m_index;
157  }
158 
159 
160  //! Update the properties for this species, given a temperature polynomial
161  /*!
162  * This method is called with a pointer to an array containing the functions of
163  * temperature needed by this parameterization, and three pointers to arrays where the
164  * computed property values should be written. This method updates only one value in
165  * each array.
166  *
167  * Temperature Polynomial:
168  * tt[0] = t;
169  * tt[1] = t*t;
170  * tt[2] = m_t[1]*t;
171  * tt[3] = m_t[2]*t;
172  * tt[4] = 1.0/t;
173  * tt[5] = std::log(t);
174  *
175  * @param tt vector of temperature polynomials
176  * @param cp_R Vector of Dimensionless heat capacities.
177  * (length m_kk).
178  * @param h_RT Vector of Dimensionless enthalpies.
179  * (length m_kk).
180  * @param s_R Vector of Dimensionless entropies.
181  * (length m_kk).
182  */
183  void updateProperties(const doublereal* tt,
184  doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const {
185 
186  double T = tt[0];
187  if (T <= m_midT) {
188  mnp_low.updateProperties(tt, cp_R, h_RT, s_R);
189  } else {
190  mnp_high.updateProperties(tt, cp_R, h_RT, s_R);
191  }
192  }
193 
194  //! Compute the reference-state property of one species
195  /*!
196  * Given temperature T in K, this method updates the values of
197  * the non-dimensional heat capacity at constant pressure,
198  * enthalpy, and entropy, at the reference pressure, Pref
199  * of one of the species. The species index is used
200  * to reference into the cp_R, h_RT, and s_R arrays.
201  *
202  * @param temp Temperature (Kelvin)
203  * @param cp_R Vector of Dimensionless heat capacities.
204  * (length m_kk).
205  * @param h_RT Vector of Dimensionless enthalpies.
206  * (length m_kk).
207  * @param s_R Vector of Dimensionless entropies.
208  * (length m_kk).
209  */
210  void updatePropertiesTemp(const doublereal temp,
211  doublereal* cp_R,
212  doublereal* h_RT,
213  doublereal* s_R) const {
214  if (temp <= m_midT) {
215  mnp_low.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
216  } else {
217  mnp_high.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
218  }
219  }
220 
221  //!This utility function reports back the type of
222  //! parameterization and all of the parameters for the
223  //! species, index.
224  /*!
225  * All parameters are output variables
226  *
227  * @param n Species index
228  * @param type Integer type of the standard type
229  * @param tlow output - Minimum temperature
230  * @param thigh output - Maximum temperature
231  * @param pref output - reference pressure (Pa).
232  * @param coeffs Vector of coefficients used to set the
233  * parameters for the standard state.
234  */
235  void reportParameters(size_t& n, int& type,
236  doublereal& tlow, doublereal& thigh,
237  doublereal& pref,
238  doublereal* const coeffs) const {
239  n = m_index;
240  type = NASA2;
241  tlow = m_lowT;
242  thigh = m_highT;
243  pref = m_Pref;
244  for (int i = 0; i < 15; i++) {
245  coeffs[i] = m_coeff[i];
246  }
247  }
248 
249 #ifdef H298MODIFY_CAPABILITY
250 
251  doublereal reportHf298(doublereal* const h298 = 0) const {
252  double h;
253  if (298.15 <= m_midT) {
254  h = mnp_low.reportHf298(0);
255  } else {
256  h = mnp_high.reportHf298(0);
257  }
258  if (h298) {
259  h298[m_index] = h;
260  }
261  return h;
262  }
263 
264  void modifyOneHf298(const int k, const doublereal Hf298New) {
265  if (k != m_index) {
266  return;
267  }
268 
269  doublereal h298now = reportHf298(0);
270  doublereal delH = Hf298New - h298now;
271  double h = mnp_low.reportHf298(0);
272  double hnew = h + delH;
273  mnp_low.modifyOneHf298(k, hnew);
274  h = mnp_high.reportHf298(0);
275  hnew = h + delH;
276  mnp_high.modifyOneHf298(k, hnew);
277  }
278 
279 #endif
280 
281 protected:
282  //! lowest valid temperature
283  doublereal m_lowT;
284  //! Midrange temperature
285  doublereal m_midT;
286  //! Highest valid temperature
287  doublereal m_highT;
288  //! Reference state pressure
289  doublereal m_Pref;
290  //! NasaPoly1 object for the low temperature region.
292  //! NasaPoly1 object for the high temperature region.
294  //! species index
295  size_t m_index;
296  //! array of polynomial coefficients
298 
299 };
300 
301 }
302 #endif
303 
304 
305 
306