Cantera 2.6.0
NasaPoly1.h
Go to the documentation of this file.
1/**
2 * @file NasaPoly1.h
3 * Header for a single-species standard state object derived
5 * on the NASA temperature polynomial form applied to one temperature region
7 *
8 * This parameterization has one NASA temperature region.
9 */
10
11// This file is part of Cantera. See License.txt in the top-level directory or
13
14#ifndef CT_NASAPOLY1_H
15#define CT_NASAPOLY1_H
16
19#include "cantera/base/AnyMap.h"
20
21namespace Cantera
22{
23/**
24 * The NASA polynomial parameterization for one temperature range. This
25 * parameterization expresses the heat capacity as a fourth-order polynomial.
26 * Note that this is the form used in the 1971 NASA equilibrium program and by
27 * the Chemkin software package, but differs from the form used in the more
28 * recent NASA equilibrium program.
29 *
30 * Seven coefficients \f$(a_0,\dots,a_6)\f$ are used to represent
31 * \f$c_p^0(T)\f$, \f$h^0(T)\f$, and \f$s^0(T) \f$ as
32 * polynomials in \f$T \f$ :
33 * \f[
34 * \frac{c_p(T)}{R} = a_0 + a_1 T + a_2 T^2 + a_3 T^3 + a_4 T^4
35 * \f]
36 * \f[
37 * \frac{h^0(T)}{RT} = a_0 + \frac{a_1}{2} T + \frac{a_2}{3} T^2
38 * + \frac{a_3}{4} T^3 + \frac{a_4}{5} T^4 + \frac{a_5}{T}.
39 * \f]
40 * \f[
41 * \frac{s^0(T)}{R} = a_0\ln T + a_1 T + \frac{a_2}{2} T^2
42 * + \frac{a_3}{3} T^3 + \frac{a_4}{4} T^4 + a_6.
43 * \f]
44 *
45 * @ingroup spthermo
46 */
48{
49public:
50 NasaPoly1() : m_coeff(7), m_coeff5_orig(0.0) {}
51
52 //! Constructor with all input data
53 /*!
54 * @param tlow Minimum temperature
55 * @param thigh Maximum temperature
56 * @param pref reference pressure (Pa).
57 * @param coeffs Vector of coefficients used to set the parameters for the
58 * standard state, in the order [a0,a1,a2,a3,a4,a5,a6]
59 */
60 NasaPoly1(double tlow, double thigh, double pref, const double* coeffs)
61 : SpeciesThermoInterpType(tlow, thigh, pref)
62 , m_coeff(coeffs, coeffs+7)
63 {
64 m_coeff5_orig = m_coeff[5];
65 }
66
67 //! Set array of 7 polynomial coefficients
68 void setParameters(const vector_fp& coeffs) {
69 if (coeffs.size() != 7) {
70 throw CanteraError("NasaPoly1::setParameters", "Array must contain "
71 "7 coefficients, but {} were given.", coeffs.size());
72 }
73 m_coeff = coeffs;
74 m_coeff5_orig = m_coeff[5];
75 }
76
77 virtual int reportType() const {
78 return NASA1;
79 }
80
81 virtual size_t temperaturePolySize() const { return 6; }
82
83 virtual void updateTemperaturePoly(double T, double* T_poly) const {
84 T_poly[0] = T;
85 T_poly[1] = T * T;
86 T_poly[2] = T_poly[1] * T;
87 T_poly[3] = T_poly[2] * T;
88 T_poly[4] = 1.0 / T;
89 T_poly[5] = std::log(T);
90 }
91
92 /*!
93 * @copydoc SpeciesThermoInterpType::updateProperties
94 *
95 * Temperature Polynomial:
96 * tt[0] = t;
97 * tt[1] = t*t;
98 * tt[2] = m_t[1]*t;
99 * tt[3] = m_t[2]*t;
100 * tt[4] = 1.0/t;
101 * tt[5] = std::log(t);
102 */
103 virtual void updateProperties(const doublereal* tt,
104 doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const {
105 doublereal ct0 = m_coeff[0]; // a0
106 doublereal ct1 = m_coeff[1]*tt[0]; // a1 * T
107 doublereal ct2 = m_coeff[2]*tt[1]; // a2 * T^2
108 doublereal ct3 = m_coeff[3]*tt[2]; // a3 * T^3
109 doublereal ct4 = m_coeff[4]*tt[3]; // a4 * T^4
110
111 doublereal cp, h, s;
112 cp = ct0 + ct1 + ct2 + ct3 + ct4;
113 h = ct0 + 0.5*ct1 + 1.0/3.0*ct2 + 0.25*ct3 + 0.2*ct4
114 + m_coeff[5]*tt[4]; // last term is a5/T
115 s = ct0*tt[5] + ct1 + 0.5*ct2 + 1.0/3.0*ct3
116 +0.25*ct4 + m_coeff[6]; // last term is a6
117
118 // return the computed properties for this species
119 *cp_R = cp;
120 *h_RT = h;
121 *s_R = s;
122 }
123
124 virtual void updatePropertiesTemp(const doublereal temp,
125 doublereal* cp_R, doublereal* h_RT,
126 doublereal* s_R) const {
127 double tPoly[6];
128 updateTemperaturePoly(temp, tPoly);
129 updateProperties(tPoly, cp_R, h_RT, s_R);
130 }
131
132 virtual void reportParameters(size_t& n, int& type,
133 doublereal& tlow, doublereal& thigh,
134 doublereal& pref,
135 doublereal* const coeffs) const {
136 n = 0;
137 type = NASA1;
138 tlow = m_lowT;
139 thigh = m_highT;
140 pref = m_Pref;
141 std::copy(m_coeff.begin(), m_coeff.end(), coeffs);
142 }
143
144 virtual void getParameters(AnyMap& thermo) const {
145 // NasaPoly1 is only used as an embedded model within NasaPoly2, so all
146 // that needs to be added here are the polynomial coefficients
147 thermo["data"].asVector<vector_fp>().push_back(m_coeff);
148 }
149
150 virtual doublereal reportHf298(doublereal* const h298 = 0) const {
151 double tt[6];
152 double temp = 298.15;
153 updateTemperaturePoly(temp, tt);
154 doublereal ct0 = m_coeff[0]; // a0
155 doublereal ct1 = m_coeff[1]*tt[0]; // a1 * T
156 doublereal ct2 = m_coeff[2]*tt[1]; // a2 * T^2
157 doublereal ct3 = m_coeff[3]*tt[2]; // a3 * T^3
158 doublereal ct4 = m_coeff[4]*tt[3]; // a4 * T^4
159
160 double h_RT = ct0 + 0.5*ct1 + 1.0/3.0*ct2 + 0.25*ct3 + 0.2*ct4
161 + m_coeff[5]*tt[4]; // last t
162
163 double h = h_RT * GasConstant * temp;
164 if (h298) {
165 *h298 = h;
166 }
167 return h;
168 }
169
170 virtual void modifyOneHf298(const size_t k, const doublereal Hf298New) {
171 double hcurr = reportHf298(0);
172 double delH = Hf298New - hcurr;
173 m_coeff[5] += (delH) / GasConstant;
174 }
175
176 virtual void resetHf298() {
177 m_coeff[5] = m_coeff5_orig;
178 }
179
180protected:
181 //! array of polynomial coefficients, stored in the order [a0, ..., a6]
183
184 double m_coeff5_orig;
185};
186
187}
188#endif
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
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
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
vector_fp m_coeff
array of polynomial coefficients, stored in the order [a0, ..., a6]
Definition: NasaPoly1.h:182
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 getParameters(AnyMap &thermo) const
Store the parameters of the species thermo object such that an identical species thermo object could ...
Definition: NasaPoly1.h:144
void setParameters(const vector_fp &coeffs)
Set array of 7 polynomial coefficients.
Definition: NasaPoly1.h:68
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
NasaPoly1(double tlow, double thigh, double pref, const double *coeffs)
Constructor with all input data.
Definition: NasaPoly1.h:60
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 size_t temperaturePolySize() const
Number of terms in the temperature polynomial for this parameterization.
Definition: NasaPoly1.h:81
virtual int reportType() const
Returns an integer representing the type of parameterization.
Definition: NasaPoly1.h:77
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
Abstract Base class for the thermodynamic manager for an individual species' reference state.
doublereal m_lowT
lowest valid temperature
doublereal m_highT
Highest valid temperature.
doublereal m_Pref
Reference state pressure.
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
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition: ct_defs.h:113
Contains const definitions for types of species reference-state thermodynamics managers (see Species ...
#define NASA1
7 coefficient NASA Polynomials This is implemented in the class NasaPoly1 in NasaPoly1....