Cantera  3.1.0a1
Loading...
Searching...
No Matches
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 https://cantera.org/license.txt for license and copyright information.
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() = default;
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(double tlow, double thigh, double pref, const double* coeffs) :
64 SpeciesThermoInterpType(tlow, thigh, pref),
65 m_midT(coeffs[0]),
66 mnp_low(tlow, coeffs[0], pref, coeffs + 8),
67 mnp_high(coeffs[0], thigh, pref, coeffs + 1) {
68 }
69
70 void setMinTemp(double Tmin) override {
72 mnp_low.setMinTemp(Tmin);
73 }
74
75 void setMaxTemp(double Tmax) override {
77 mnp_high.setMaxTemp(Tmax);
78 }
79
80 void setRefPressure(double Pref) override {
84 }
85
86 /**
87 * @param Tmid Temperature [K] at the boundary between the low and high
88 * temperature polynomials
89 * @param low Vector of 7 coefficients for the low temperature polynomial
90 * @param high Vector of 7 coefficients for the high temperature polynomial
91 */
92 void setParameters(double Tmid, const vector<double>& low, const vector<double>& high);
93
94 int reportType() const override {
95 return NASA2;
96 }
97
98 size_t temperaturePolySize() const override { return 6; }
99
100 void updateTemperaturePoly(double T, double* T_poly) const override {
102 }
103
104 //! @copydoc NasaPoly1::updateProperties
105 void updateProperties(const double* tt,
106 double* cp_R, double* h_RT, double* s_R) const override {
107 if (tt[0] <= m_midT) {
108 mnp_low.updateProperties(tt, cp_R, h_RT, s_R);
109 } else {
110 mnp_high.updateProperties(tt, cp_R, h_RT, s_R);
111 }
112 }
113
114 void updatePropertiesTemp(const double temp,
115 double* cp_R, double* h_RT, double* s_R) const override {
116 if (temp <= m_midT) {
117 mnp_low.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
118 } else {
119 mnp_high.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
120 }
121 }
122
123 size_t nCoeffs() const override { return 15; }
124
125 void reportParameters(size_t& n, int& type, double& tlow, double& thigh,
126 double& pref, double* const coeffs) const override {
127 mnp_high.reportParameters(n, type, coeffs[0], thigh, pref, coeffs + 1);
128 mnp_low.reportParameters(n, type, tlow, coeffs[0], pref, coeffs + 8);
129 type = NASA2;
130 }
131
132 void getParameters(AnyMap& thermo) const override;
133
134 double reportHf298(double* const h298=nullptr) const override {
135 double h;
136 if (298.15 <= m_midT) {
137 h = mnp_low.reportHf298(0);
138 } else {
139 h = mnp_high.reportHf298(0);
140 }
141 if (h298) {
142 *h298 = h;
143 }
144 return h;
145 }
146
147 void resetHf298() override {
150 }
151
152 void modifyOneHf298(const size_t k, const double Hf298New) override {
153 double h298now = reportHf298(0);
154 double delH = Hf298New - h298now;
155 double h = mnp_low.reportHf298(0);
156 double hnew = h + delH;
157 mnp_low.modifyOneHf298(k, hnew);
158 h = mnp_high.reportHf298(0);
159 hnew = h + delH;
160 mnp_high.modifyOneHf298(k, hnew);
161 }
162
163 void validate(const string& name) override;
164
165protected:
166 //! Midrange temperature
167 double m_midT = 0.0;
168 //! NasaPoly1 object for the low temperature region.
170 //! NasaPoly1 object for the high temperature region.
172};
173
174}
175#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:427
The NASA polynomial parameterization for one temperature range.
Definition NasaPoly1.h:48
void updateTemperaturePoly(double T, double *T_poly) const override
Given the temperature T, compute the terms of the temperature polynomial T_poly.
Definition NasaPoly1.h:83
void reportParameters(size_t &n, int &type, double &tlow, double &thigh, double &pref, double *const coeffs) const override
This utility function returns the type of parameterization and all of the parameters for the species.
Definition NasaPoly1.h:131
void updateProperties(const double *tt, double *cp_R, double *h_RT, double *s_R) const override
Update the properties for this species, given a temperature polynomial.
Definition NasaPoly1.h:103
double reportHf298(double *const h298=nullptr) const override
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1)
Definition NasaPoly1.h:147
void resetHf298() override
Restore the original heat of formation for this species.
Definition NasaPoly1.h:173
void modifyOneHf298(const size_t k, const double Hf298New) override
Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1)
Definition NasaPoly1.h:167
void updatePropertiesTemp(const double temp, double *cp_R, double *h_RT, double *s_R) const override
Compute the reference-state property of one species.
Definition NasaPoly1.h:124
The NASA polynomial parameterization for two temperature ranges.
Definition NasaPoly2.h:49
void setMinTemp(double Tmin) override
Set the minimum temperature at which the thermo parameterization is valid.
Definition NasaPoly2.h:70
int reportType() const override
Returns an integer representing the type of parameterization.
Definition NasaPoly2.h:94
size_t temperaturePolySize() const override
Number of terms in the temperature polynomial for this parameterization.
Definition NasaPoly2.h:98
void getParameters(AnyMap &thermo) const override
Store the parameters of the species thermo object such that an identical species thermo object could ...
Definition NasaPoly2.cpp:20
size_t nCoeffs() const override
This utility function returns the number of coefficients for a given type of species parameterization...
Definition NasaPoly2.h:123
void validate(const string &name) override
Check for problems with the parameterization, and generate warnings or throw and exception if any are...
Definition NasaPoly2.cpp:31
void updateTemperaturePoly(double T, double *T_poly) const override
Given the temperature T, compute the terms of the temperature polynomial T_poly.
Definition NasaPoly2.h:100
void reportParameters(size_t &n, int &type, double &tlow, double &thigh, double &pref, double *const coeffs) const override
This utility function returns the type of parameterization and all of the parameters for the species.
Definition NasaPoly2.h:125
void setParameters(double Tmid, const vector< double > &low, const vector< double > &high)
Definition NasaPoly2.cpp:11
void setRefPressure(double Pref) override
Set the reference pressure [Pa].
Definition NasaPoly2.h:80
void updateProperties(const double *tt, double *cp_R, double *h_RT, double *s_R) const override
Update the properties for this species, given a temperature polynomial.
Definition NasaPoly2.h:105
double reportHf298(double *const h298=nullptr) const override
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1)
Definition NasaPoly2.h:134
void resetHf298() override
Restore the original heat of formation for this species.
Definition NasaPoly2.h:147
void setMaxTemp(double Tmax) override
Set the maximum temperature at which the thermo parameterization is valid.
Definition NasaPoly2.h:75
double m_midT
Midrange temperature.
Definition NasaPoly2.h:167
NasaPoly1 mnp_low
NasaPoly1 object for the low temperature region.
Definition NasaPoly2.h:169
void modifyOneHf298(const size_t k, const double Hf298New) override
Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1)
Definition NasaPoly2.h:152
NasaPoly1 mnp_high
NasaPoly1 object for the high temperature region.
Definition NasaPoly2.h:171
NasaPoly2(double tlow, double thigh, double pref, const double *coeffs)
Constructor with all input data.
Definition NasaPoly2.h:63
void updatePropertiesTemp(const double temp, double *cp_R, double *h_RT, double *s_R) const override
Compute the reference-state property of one species.
Definition NasaPoly2.h:114
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.cpp:564
#define NASA2
Two regions of 7 coefficient NASA Polynomials This is implemented in the class NasaPoly2 in NasaPoly2...