14#ifndef CT_SHOMATEPOLY1_H
15#define CT_SHOMATEPOLY1_H
58class ShomatePoly :
public SpeciesThermoInterpType
61 ShomatePoly() : m_coeff(7), m_coeff5_orig(0.0) {}
74 ShomatePoly(
double tlow,
double thigh,
double pref, span<const double> coeffs) :
75 SpeciesThermoInterpType(tlow, thigh, pref),
78 for (
size_t i = 0; i < 7; i++) {
81 m_coeff5_orig = m_coeff[5];
87 if (coeffs.size() != 7) {
88 throw CanteraError(
"ShomatePoly::setParameters",
"Array must "
89 "contain 7 coefficients, but {} were given.", coeffs.size());
91 for (
size_t i = 0; i < 7; i++) {
94 m_coeff5_orig = m_coeff[5];
107 T_poly[2] = T_poly[1] * tt;
108 T_poly[3] = 1.0/T_poly[1];
109 T_poly[4] = std::log(tt);
126 double& s_R)
const override {
127 double A = m_coeff[0];
128 double Bt = m_coeff[1]*tt[0];
129 double Ct2 = m_coeff[2]*tt[1];
130 double Dt3 = m_coeff[3]*tt[2];
131 double Etm2 = m_coeff[4]*tt[3];
132 double Ftm1 = m_coeff[5]*tt[5];
133 double G = m_coeff[6];
135 cp_R = A + Bt + Ct2 + Dt3 + Etm2;
136 h_RT = A + 0.5*Bt + 1.0/3.0*Ct2 + 0.25*Dt3 - Etm2 + Ftm1;
137 s_R = A*tt[4] + Bt + 0.5*Ct2 + 1.0/3.0*Dt3 - 0.5*Etm2 + G;
141 double& h_RT,
double& s_R)
const override {
148 double& pref, span<double> coeffs)
const override {
154 for (
int i = 0; i < 7; i++) {
162 vector<double> dimensioned_coeffs(m_coeff.size());
163 for (
size_t i = 0; i < m_coeff.size(); i++) {
164 dimensioned_coeffs[i] = m_coeff[i] *
GasConstant / 1000;
166 thermo[
"data"].asVector<vector<double>>().push_back(dimensioned_coeffs);
170 double cp_R, h_RT, s_R;
175 void modifyOneHf298(
const size_t k,
const double Hf298New)
override {
177 double delH = Hf298New - hnow;
182 m_coeff[5] = m_coeff5_orig;
187 vector<double> m_coeff;
188 double m_coeff5_orig;
232class ShomatePoly2 :
public SpeciesThermoInterpType
235 ShomatePoly2() :
m_midT(0.0) {}
245 ShomatePoly2(
double tlow,
double thigh,
double pref, span<const double> coeffs) :
246 SpeciesThermoInterpType(tlow, thigh, pref),
248 msp_low(tlow, coeffs[0], pref, coeffs.subspan(1, 7)),
249 msp_high(coeffs[0], thigh, pref, coeffs.subspan(8, 7))
275 void setParameters(
double Tmid, span<const double> low, span<const double> high) {
290 msp_low.updateTemperaturePoly(T, T_poly);
295 double& s_R)
const override {
296 double T = 1000 * tt[0];
298 msp_low.updateProperties(tt, cp_R, h_RT, s_R);
300 msp_high.updateProperties(tt, cp_R, h_RT, s_R);
305 double& h_RT,
double& s_R)
const override {
307 msp_low.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
309 msp_high.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
313 size_t nCoeffs()
const override {
return 15; }
316 double& pref, span<double> coeffs)
const override {
317 msp_low.reportParameters(n, type, tlow, coeffs[0], pref, coeffs.subspan(1));
318 msp_high.reportParameters(n, type, coeffs[0], thigh, pref, coeffs.subspan(8));
324 thermo[
"model"] =
"Shomate";
326 thermo[
"temperature-ranges"].setQuantity(Tranges,
"K");
327 thermo[
"data"] = vector<vector<double>>();
342 double delH = Hf298New - h298now;
343 double h =
msp_low.reportHf298();
344 double hnew = h + delH;
345 msp_low.modifyOneHf298(k, hnew);
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.
Base class for exceptions thrown by Cantera classes.
ShomatePoly2(double tlow, double thigh, double pref, span< const double > coeffs)
Constructor with all input data.
void setMinTemp(double Tmin) override
Set the minimum temperature at which the thermo parameterization is valid.
int reportType() const override
Returns an integer representing the type of parameterization.
void setParameters(double Tmid, span< const double > low, span< const double > high)
ShomatePoly msp_low
Shomate polynomial for the low temperature region.
void updatePropertiesTemp(const double temp, double &cp_R, double &h_RT, double &s_R) const override
Compute the reference-state property of one species.
size_t temperaturePolySize() const override
Number of terms in the temperature polynomial for this parameterization.
void getParameters(AnyMap &thermo) const override
Store the parameters of the species thermo object such that an identical species thermo object could ...
size_t nCoeffs() const override
This utility function returns the number of coefficients for a given type of species parameterization...
void reportParameters(size_t &n, int &type, double &tlow, double &thigh, double &pref, span< double > coeffs) const override
This utility function returns the type of parameterization and all of the parameters for the species.
void updateTemperaturePoly(double T, span< double > T_poly) const override
Given the temperature T, compute the terms of the temperature polynomial T_poly.
void setRefPressure(double Pref) override
Set the reference pressure [Pa].
double reportHf298() const override
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1).
ShomatePoly msp_high
Shomate polynomial for the high temperature region.
void resetHf298() override
Restore the original heat of formation for this species.
void setMaxTemp(double Tmax) override
Set the maximum temperature at which the thermo parameterization is valid.
double m_midT
Midrange temperature (kelvin).
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).
void updateProperties(span< const double > tt, double &cp_R, double &h_RT, double &s_R) const override
Update the properties for this species, given a temperature polynomial.
The Shomate polynomial parameterization for one temperature range for one species.
int reportType() const override
Returns an integer representing the type of parameterization.
size_t temperaturePolySize() const override
Number of terms in the temperature polynomial for this parameterization.
void updateTemperaturePoly(double T, span< double > T_poly) const override
Given the temperature T, compute the terms of the temperature polynomial T_poly.
ShomatePoly(double tlow, double thigh, double pref, span< const double > coeffs)
Constructor with all input data.
void setParameters(const span< const double > coeffs)
Set array of 7 polynomial coefficients.
double m_Pref
Reference state pressure.
virtual void setRefPressure(double Pref)
Set the reference pressure [Pa].
virtual void reportParameters(size_t &index, int &type, double &minTemp, double &maxTemp, double &refPressure, span< double > coeffs) const
This utility function returns the type of parameterization and all of the parameters for the species.
virtual void getParameters(AnyMap &thermo) const
Store the parameters of the species thermo object such that an identical species thermo object could ...
virtual void resetHf298()
Restore the original heat of formation for this species.
virtual void updatePropertiesTemp(const double temp, double &cp_R, double &h_RT, double &s_R) const
Compute the reference-state property of one species.
double m_lowT
lowest valid temperature
virtual void updateProperties(span< const double > tt, double &cp_R, double &h_RT, double &s_R) const
Update the properties for this species, given a temperature polynomial.
virtual void setMinTemp(double Tmin)
Set the minimum temperature at which the thermo parameterization is valid.
virtual double reportHf298() const
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1).
double m_highT
Highest valid temperature.
virtual void setMaxTemp(double Tmax)
Set the maximum temperature at which the thermo parameterization is valid.
virtual void modifyOneHf298(const size_t k, const double Hf298New)
Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1).
const double GasConstant
Universal Gas Constant [J/kmol/K].
Namespace for the Cantera kernel.
#define SHOMATE
Two regions of Shomate Polynomials.
#define SHOMATE2
Two regions of Shomate Polynomials.