Cantera  2.3.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
5  * on the NASA temperature polynomial form applied to two temperature regions
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
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  //! Empty constructor
52  //! @deprecated Default constructor to be removed after Cantera 2.3.
54  : m_midT(0.0),
55  m_coeff(15, 0.0) {
56  warn_deprecated("NasaPoly2::NasaPoly2()",
57  "Default constructor to be removed after Cantera 2.3.");
58  }
59
60  //! Full Constructor
61  /*!
62  * @param tlow output - Minimum temperature
63  * @param thigh output - Maximum temperature
64  * @param pref output - reference pressure (Pa).
65  * @param coeffs Vector of coefficients used to set the parameters for
66  * the standard state [Tmid, 7 high-T coeffs, 7 low-T
67  * coeffs]. This is the coefficient order used in the
68  * standard NASA format.
69  */
70  NasaPoly2(doublereal tlow, doublereal thigh, doublereal pref,
71  const doublereal* coeffs) :
72  SpeciesThermoInterpType(tlow, thigh, pref),
73  m_midT(coeffs),
74  mnp_low(tlow, coeffs, pref, coeffs + 8),
75  mnp_high(coeffs, thigh, pref, coeffs + 1),
76  m_coeff(coeffs, coeffs + 15) {
77  }
78
81  NasaPoly2* np = new NasaPoly2(*this);
82  return (SpeciesThermoInterpType*) np;
83  }
84
85  virtual int reportType() const {
86  return NASA2;
87  }
88
89  virtual size_t temperaturePolySize() const { return 6; }
90
91  virtual void updateTemperaturePoly(double T, double* T_poly) const {
92  mnp_low.updateTemperaturePoly(T, T_poly);
93  }
94
95  //! @copydoc NasaPoly1::updateProperties
96  void updateProperties(const doublereal* tt,
97  doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const {
98  if (tt <= m_midT) {
99  mnp_low.updateProperties(tt, cp_R, h_RT, s_R);
100  } else {
101  mnp_high.updateProperties(tt, cp_R, h_RT, s_R);
102  }
103  }
104
105  void updatePropertiesTemp(const doublereal temp,
106  doublereal* cp_R,
107  doublereal* h_RT,
108  doublereal* s_R) const {
109  if (temp <= m_midT) {
110  mnp_low.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
111  } else {
112  mnp_high.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
113  }
114  }
115
116  void reportParameters(size_t& n, int& type,
117  doublereal& tlow, doublereal& thigh,
118  doublereal& pref,
119  doublereal* const coeffs) const {
120  n = 0;
121  type = NASA2;
122  tlow = m_lowT;
123  thigh = m_highT;
124  pref = m_Pref;
125  for (int i = 0; i < 15; i++) {
126  coeffs[i] = m_coeff[i];
127  }
128  }
129
130  doublereal reportHf298(doublereal* const h298 = 0) const {
131  double h;
132  if (298.15 <= m_midT) {
133  h = mnp_low.reportHf298(0);
134  } else {
135  h = mnp_high.reportHf298(0);
136  }
137  if (h298) {
138  *h298 = h;
139  }
140  return h;
141  }
142
143  void resetHf298() {
146  }
147
148  void modifyOneHf298(const size_t k, const doublereal Hf298New) {
149  doublereal h298now = reportHf298(0);
150  doublereal delH = Hf298New - h298now;
151  double h = mnp_low.reportHf298(0);
152  double hnew = h + delH;
153  mnp_low.modifyOneHf298(k, hnew);
154  h = mnp_high.reportHf298(0);
155  hnew = h + delH;
156  mnp_high.modifyOneHf298(k, hnew);
157  }
158
159  void validate(const std::string& name);
160
161 protected:
162  //! Midrange temperature
163  doublereal m_midT;
164  //! NasaPoly1 object for the low temperature region.
166  //! NasaPoly1 object for the high temperature region.
168  //! array of polynomial coefficients
170 };
171
172 }
173 #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:116
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:148
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:171
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...
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:54
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:82
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:91
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:177
virtual int reportType() const
Returns an integer representing the type of parameterization.
Definition: NasaPoly2.h:85
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:123
virtual SpeciesThermoInterpType * duplMyselfAsSpeciesThermoInterpType() const
Definition: NasaPoly2.h:80
vector_fp m_coeff
array of polynomial coefficients
Definition: NasaPoly2.h:169
NasaPoly1 mnp_high
NasaPoly1 object for the high temperature region.
Definition: NasaPoly2.h:167
NasaPoly2(doublereal tlow, doublereal thigh, doublereal pref, const doublereal *coeffs)
Full Constructor.
Definition: NasaPoly2.h:70
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:143
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:151
doublereal m_lowT
lowest valid temperature
doublereal m_midT
Midrange temperature.
Definition: NasaPoly2.h:163
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:89
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:96
NasaPoly2()
Empty constructor.
Definition: NasaPoly2.h:53
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:105
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:102
The NASA polynomial parameterization for one temperature range.
Definition: NasaPoly1.h:45
doublereal m_Pref
Reference state pressure.
Namespace for the Cantera kernel.
Definition: application.cpp:29
NasaPoly1 mnp_low
NasaPoly1 object for the low temperature region.
Definition: NasaPoly2.h:165
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:130