Cantera  2.4.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 
11 // This file is part of Cantera. See License.txt in the top-level directory or
12 // at http://www.cantera.org/license.txt for license and copyright information.
13 
14 #ifndef CT_NASAPOLY2_H
15 #define CT_NASAPOLY2_H
16 
19 
20 namespace Cantera
21 {
22 /**
23  * The NASA polynomial parameterization for two temperature ranges. This
24  * parameterization expresses the heat capacity as a fourth-order polynomial.
25  * Note that this is the form used in the 1971 NASA equilibrium program and by
26  * the Chemkin software package, but differs from the form used in the more
27  * recent NASA equilibrium program.
28  *
29  * Seven coefficients \f$(a_0,\dots,a_6)\f$ are used to represent
30  * \f$ c_p^0(T)\f$, \f$ h^0(T)\f$, and \f$ s^0(T) \f$ as
31  * polynomials in \f$ T \f$ :
32  * \f[
33  * \frac{c_p(T)}{R} = a_0 + a_1 T + a_2 T^2 + a_3 T^3 + a_4 T^4
34  * \f]
35  * \f[
36  * \frac{h^0(T)}{RT} = a_0 + \frac{a_1}{2} T + \frac{a_2}{3} T^2
37  * + \frac{a_3}{4} T^3 + \frac{a_4}{5} T^4 + \frac{a_5}{T}.
38  * \f]
39  * \f[
40  * \frac{s^0(T)}{R} = a_0\ln T + a_1 T + \frac{a_2}{2} T^2
41  * + \frac{a_3}{3} T^3 + \frac{a_4}{4} T^4 + a_6.
42  * \f]
43  *
44  * This class is designed specifically for use by the class MultiSpeciesThermo.
45  *
46  * @ingroup spthermo
47  */
49 {
50 public:
51  //! Full Constructor
52  /*!
53  * @param tlow output - Minimum temperature
54  * @param thigh output - Maximum temperature
55  * @param pref output - reference pressure (Pa).
56  * @param coeffs Vector of coefficients used to set the parameters for
57  * the standard state [Tmid, 7 high-T coeffs, 7 low-T
58  * coeffs]. This is the coefficient order used in the
59  * standard NASA format.
60  */
61  NasaPoly2(doublereal tlow, doublereal thigh, doublereal pref,
62  const doublereal* coeffs) :
63  SpeciesThermoInterpType(tlow, thigh, pref),
64  m_midT(coeffs[0]),
65  mnp_low(tlow, coeffs[0], pref, coeffs + 8),
66  mnp_high(coeffs[0], thigh, pref, coeffs + 1),
67  m_coeff(coeffs, coeffs + 15) {
68  }
69 
70  virtual int reportType() const {
71  return NASA2;
72  }
73 
74  virtual size_t temperaturePolySize() const { return 6; }
75 
76  virtual void updateTemperaturePoly(double T, double* T_poly) const {
77  mnp_low.updateTemperaturePoly(T, T_poly);
78  }
79 
80  //! @copydoc NasaPoly1::updateProperties
81  void updateProperties(const doublereal* tt,
82  doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const {
83  if (tt[0] <= m_midT) {
84  mnp_low.updateProperties(tt, cp_R, h_RT, s_R);
85  } else {
86  mnp_high.updateProperties(tt, cp_R, h_RT, s_R);
87  }
88  }
89 
90  void updatePropertiesTemp(const doublereal temp,
91  doublereal* cp_R,
92  doublereal* h_RT,
93  doublereal* s_R) const {
94  if (temp <= m_midT) {
95  mnp_low.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
96  } else {
97  mnp_high.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
98  }
99  }
100 
101  void reportParameters(size_t& n, int& type,
102  doublereal& tlow, doublereal& thigh,
103  doublereal& pref,
104  doublereal* const coeffs) const {
105  n = 0;
106  type = NASA2;
107  tlow = m_lowT;
108  thigh = m_highT;
109  pref = m_Pref;
110  for (int i = 0; i < 15; i++) {
111  coeffs[i] = m_coeff[i];
112  }
113  }
114 
115  doublereal reportHf298(doublereal* const h298 = 0) const {
116  double h;
117  if (298.15 <= m_midT) {
118  h = mnp_low.reportHf298(0);
119  } else {
120  h = mnp_high.reportHf298(0);
121  }
122  if (h298) {
123  *h298 = h;
124  }
125  return h;
126  }
127 
128  void resetHf298() {
131  }
132 
133  void modifyOneHf298(const size_t k, const doublereal Hf298New) {
134  doublereal h298now = reportHf298(0);
135  doublereal delH = Hf298New - h298now;
136  double h = mnp_low.reportHf298(0);
137  double hnew = h + delH;
138  mnp_low.modifyOneHf298(k, hnew);
139  h = mnp_high.reportHf298(0);
140  hnew = h + delH;
141  mnp_high.modifyOneHf298(k, hnew);
142  }
143 
144  void validate(const std::string& name);
145 
146 protected:
147  //! Midrange temperature
148  doublereal m_midT;
149  //! NasaPoly1 object for the low temperature region.
151  //! NasaPoly1 object for the high temperature region.
153  //! array of polynomial coefficients
155 };
156 
157 }
158 #endif
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:101
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:133
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:150
Abstract Base class for the thermodynamic manager for an individual species&#39; 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:10
The NASA polynomial parameterization for two temperature ranges.
Definition: NasaPoly2.h:48
#define NASA2
Two regions of 7 coefficient NASA Polynomials This is implemented in the class NasaPoly2 in NasaPoly2...
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:69
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:76
Pure Virtual Base class for individual species reference state thermodynamic managers and text for th...
virtual void resetHf298()
Restore the original heat of formation for this species.
Definition: NasaPoly1.h:156
virtual int reportType() const
Returns an integer representing the type of parameterization.
Definition: NasaPoly2.h:70
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:110
vector_fp m_coeff
array of polynomial coefficients
Definition: NasaPoly2.h:154
NasaPoly1 mnp_high
NasaPoly1 object for the high temperature region.
Definition: NasaPoly2.h:152
NasaPoly2(doublereal tlow, doublereal thigh, doublereal pref, const doublereal *coeffs)
Full Constructor.
Definition: NasaPoly2.h:61
doublereal m_highT
Highest valid temperature.
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the N...
void resetHf298()
Restore the original heat of formation for this species.
Definition: NasaPoly2.h:128
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:130
doublereal m_lowT
lowest valid temperature
doublereal m_midT
Midrange temperature.
Definition: NasaPoly2.h:148
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: NasaPoly2.h:74
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:81
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:90
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:89
The NASA polynomial parameterization for one temperature range.
Definition: NasaPoly1.h:45
doublereal m_Pref
Reference state pressure.
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8
NasaPoly1 mnp_low
NasaPoly1 object for the low temperature region.
Definition: NasaPoly2.h:150
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:115