Cantera 2.6.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
20namespace 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{
50public:
51 NasaPoly2();
52
53 //! Constructor with all input data
54 /*!
55 * @param tlow output - Minimum temperature
56 * @param thigh output - Maximum temperature
57 * @param pref output - reference pressure (Pa).
58 * @param coeffs Vector of coefficients used to set the parameters for
59 * the standard state [Tmid, 7 high-T coeffs, 7 low-T
60 * coeffs]. This is the coefficient order used in the
61 * standard NASA format.
62 */
63 NasaPoly2(doublereal tlow, doublereal thigh, doublereal pref,
64 const doublereal* coeffs) :
65 SpeciesThermoInterpType(tlow, thigh, pref),
66 m_midT(coeffs[0]),
67 mnp_low(tlow, coeffs[0], pref, coeffs + 8),
68 mnp_high(coeffs[0], thigh, pref, coeffs + 1) {
69 }
70
71 virtual void setMinTemp(double Tmin) {
73 mnp_low.setMinTemp(Tmin);
74 }
75
76 virtual void setMaxTemp(double Tmax) {
78 mnp_high.setMaxTemp(Tmax);
79 }
80
81 virtual void setRefPressure(double Pref) {
85 }
86
87 /*!
88 * @param Tmid Temperature [K] at the boundary between the low and high
89 * temperature polynomials
90 * @param low Vector of 7 coefficients for the low temperature polynomial
91 * @param high Vector of 7 coefficients for the high temperature polynomial
92 */
93 void setParameters(double Tmid, const vector_fp& low, const vector_fp& high);
94
95 virtual int reportType() const {
96 return NASA2;
97 }
98
99 virtual size_t temperaturePolySize() const { return 6; }
100
101 virtual void updateTemperaturePoly(double T, double* T_poly) const {
103 }
104
105 //! @copydoc NasaPoly1::updateProperties
106 void updateProperties(const doublereal* tt,
107 doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const {
108 if (tt[0] <= m_midT) {
109 mnp_low.updateProperties(tt, cp_R, h_RT, s_R);
110 } else {
111 mnp_high.updateProperties(tt, cp_R, h_RT, s_R);
112 }
113 }
114
115 void updatePropertiesTemp(const doublereal temp,
116 doublereal* cp_R,
117 doublereal* h_RT,
118 doublereal* s_R) const {
119 if (temp <= m_midT) {
120 mnp_low.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
121 } else {
122 mnp_high.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
123 }
124 }
125
126 size_t nCoeffs() const { return 15; }
127
128 void reportParameters(size_t& n, int& type,
129 doublereal& tlow, doublereal& thigh,
130 doublereal& pref,
131 doublereal* const coeffs) const {
132 mnp_high.reportParameters(n, type, coeffs[0], thigh, pref, coeffs + 1);
133 mnp_low.reportParameters(n, type, tlow, coeffs[0], pref, coeffs + 8);
134 type = NASA2;
135 }
136
137 virtual void getParameters(AnyMap& thermo) const;
138
139 doublereal reportHf298(doublereal* const h298 = 0) const {
140 double h;
141 if (298.15 <= m_midT) {
142 h = mnp_low.reportHf298(0);
143 } else {
144 h = mnp_high.reportHf298(0);
145 }
146 if (h298) {
147 *h298 = h;
148 }
149 return h;
150 }
151
152 void resetHf298() {
155 }
156
157 void modifyOneHf298(const size_t k, const doublereal Hf298New) {
158 doublereal h298now = reportHf298(0);
159 doublereal delH = Hf298New - h298now;
160 double h = mnp_low.reportHf298(0);
161 double hnew = h + delH;
162 mnp_low.modifyOneHf298(k, hnew);
163 h = mnp_high.reportHf298(0);
164 hnew = h + delH;
165 mnp_high.modifyOneHf298(k, hnew);
166 }
167
168 void validate(const std::string& name);
169
170protected:
171 //! Midrange temperature
172 doublereal m_midT;
173 //! NasaPoly1 object for the low temperature region.
175 //! NasaPoly1 object for the high temperature region.
177};
178
179}
180#endif
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the N...
Pure Virtual Base class for individual species reference state thermodynamic managers and text for th...
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:399
The NASA polynomial parameterization for one temperature range.
Definition: NasaPoly1.h:48
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:124
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:83
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:103
virtual void resetHf298()
Restore the original heat of formation for this species.
Definition: NasaPoly1.h:176
virtual void reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal *const coeffs) const
This utility function returns the type of parameterization and all of the parameters for the species.
Definition: NasaPoly1.h:132
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:170
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:150
The NASA polynomial parameterization for two temperature ranges.
Definition: NasaPoly2.h:49
NasaPoly2(doublereal tlow, doublereal thigh, doublereal pref, const doublereal *coeffs)
Constructor with all input data.
Definition: NasaPoly2.h:63
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:101
void resetHf298()
Restore the original heat of formation for this species.
Definition: NasaPoly2.h:152
virtual void setRefPressure(double Pref)
Set the reference pressure [Pa].
Definition: NasaPoly2.h:81
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:157
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:139
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:36
virtual void getParameters(AnyMap &thermo) const
Store the parameters of the species thermo object such that an identical species thermo object could ...
Definition: NasaPoly2.cpp:25
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:115
size_t nCoeffs() const
This utility function returns the number of coefficients for a given type of species parameterization...
Definition: NasaPoly2.h:126
void reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal *const coeffs) const
This utility function returns the type of parameterization and all of the parameters for the species.
Definition: NasaPoly2.h:128
void setParameters(double Tmid, const vector_fp &low, const vector_fp &high)
Definition: NasaPoly2.cpp:16
virtual void setMinTemp(double Tmin)
Set the minimum temperature at which the thermo parameterization is valid.
Definition: NasaPoly2.h:71
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:106
doublereal m_midT
Midrange temperature.
Definition: NasaPoly2.h:172
virtual size_t temperaturePolySize() const
Number of terms in the temperature polynomial for this parameterization.
Definition: NasaPoly2.h:99
NasaPoly1 mnp_low
NasaPoly1 object for the low temperature region.
Definition: NasaPoly2.h:174
virtual void setMaxTemp(double Tmax)
Set the maximum temperature at which the thermo parameterization is valid.
Definition: NasaPoly2.h:76
virtual int reportType() const
Returns an integer representing the type of parameterization.
Definition: NasaPoly2.h:95
NasaPoly1 mnp_high
NasaPoly1 object for the high temperature region.
Definition: NasaPoly2.h:176
Abstract Base class for the thermodynamic manager for an individual species' reference state.
virtual void setRefPressure(double Pref)
Set the reference pressure [Pa].
virtual void setMinTemp(double Tmin)
Set the minimum temperature at which the thermo parameterization is valid.
virtual void setMaxTemp(double Tmax)
Set the maximum temperature at which the thermo parameterization is valid.
Namespace for the Cantera kernel.
Definition: AnyMap.h:29
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:184
#define NASA2
Two regions of 7 coefficient NASA Polynomials This is implemented in the class NasaPoly2 in NasaPoly2...