Cantera  4.0.0a1
Loading...
Searching...
No Matches
Nasa9Poly1.cpp
Go to the documentation of this file.
1/**
2 * @file Nasa9Poly1.cpp Definitions for a single-species standard state object
3 * derived from
4 * @link Cantera::SpeciesThermoInterpType SpeciesThermoInterpType@endlink based
5 * on the NASA 9 coefficient temperature polynomial form applied to one
6 * temperature region (see @ref spthermo and class @link Cantera::Nasa9Poly1
7 * Nasa9Poly1@endlink).
8 *
9 * This parameterization has one NASA temperature region.
10 */
11
12// This file is part of Cantera. See License.txt in the top-level directory or
13// at https://cantera.org/license.txt for license and copyright information.
14
16#include "cantera/base/AnyMap.h"
17
18namespace Cantera
19{
20
21Nasa9Poly1::Nasa9Poly1()
22 : m_coeff(9)
23{
24}
25
26Nasa9Poly1::Nasa9Poly1(double tlow, double thigh, double pref,
27 span<const double> coeffs) :
28 SpeciesThermoInterpType(tlow, thigh, pref),
29 m_coeff(coeffs.begin(), coeffs.end())
30{
31}
32
33void Nasa9Poly1::setParameters(span<const double> coeffs)
34{
35 checkArraySize("Nasa9Poly1::setParameters", coeffs.size(), 9);
36 m_coeff.assign(coeffs.begin(), coeffs.end());
37}
38
40{
41 return NASA9;
42}
43
44void Nasa9Poly1::updateTemperaturePoly(double T, span<double> T_poly) const
45{
46 T_poly[0] = T;
47 T_poly[1] = T * T;
48 T_poly[2] = T_poly[1] * T;
49 T_poly[3] = T_poly[2] * T;
50 T_poly[4] = 1.0 / T;
51 T_poly[5] = T_poly[4] / T;
52 T_poly[6] = std::log(T);
53}
54
55void Nasa9Poly1::updateProperties(span<const double> tt, double& cp_R,
56 double& h_RT, double& s_R) const
57{
58
59 double ct0 = m_coeff[0] * tt[5]; // a0 / (T^2)
60 double ct1 = m_coeff[1] * tt[4]; // a1 / T
61 double ct2 = m_coeff[2]; // a2
62 double ct3 = m_coeff[3] * tt[0]; // a3 * T
63 double ct4 = m_coeff[4] * tt[1]; // a4 * T^2
64 double ct5 = m_coeff[5] * tt[2]; // a5 * T^3
65 double ct6 = m_coeff[6] * tt[3]; // a6 * T^4
66
67 double cpdivR = ct0 + ct1 + ct2 + ct3 + ct4 + ct5 + ct6;
68 double hdivRT = -ct0 + tt[6]*ct1 + ct2 + 0.5*ct3 + 1.0/3.0*ct4
69 + 0.25*ct5 + 0.2*ct6 + m_coeff[7] * tt[4];
70 double sdivR = -0.5*ct0 - ct1 + tt[6]*ct2 + ct3 + 0.5*ct4
71 + 1.0/3.0*ct5 + 0.25*ct6 + m_coeff[8];
72
73 // return the computed properties for this species
74 cp_R = cpdivR;
75 h_RT = hdivRT;
76 s_R = sdivR;
77}
78
79void Nasa9Poly1::updatePropertiesTemp(const double temp, double& cp_R, double& h_RT,
80 double& s_R) const
81{
82 double tPoly[7];
83 updateTemperaturePoly(temp, tPoly);
84 updateProperties(tPoly, cp_R, h_RT, s_R);
85}
86
87void Nasa9Poly1::reportParameters(size_t& n, int& type, double& tlow, double& thigh,
88 double& pref, span<double> coeffs) const
89{
90 checkArraySize("Nasa9Poly1::reportParameters", coeffs.size(), 12);
91 n = 0;
92 type = NASA9;
93 tlow = m_lowT;
94 thigh = m_highT;
95 pref = m_Pref;
96 coeffs[0] = 1;
97 coeffs[1] = m_lowT;
98 coeffs[2] = m_highT;
99 for (int i = 0; i < 9; i++) {
100 coeffs[i+3] = m_coeff[i];
101 }
102}
103
105 // Nasa9Poly1 is only used as an embedded model within
106 // Nasa9PolyMultiTempRegion, so all that needs to be added here are the
107 // polynomial coefficients
108 thermo["data"].asVector<vector<double>>().push_back(m_coeff);
109}
110
111}
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the N...
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:431
vector< double > m_coeff
array of polynomial coefficients
Definition Nasa9Poly1.h:125
int reportType() const override
Returns an integer representing the type of parameterization.
void setParameters(span< const double > coeffs)
Set the array of 9 polynomial coefficients.
void updatePropertiesTemp(const double temp, double &cp_R, double &h_RT, double &s_R) const override
Compute the reference-state property of one species.
void getParameters(AnyMap &thermo) const override
Store the parameters of the species thermo object such that an identical species thermo object could ...
void reportParameters(size_t &n, int &type, double &tlow, double &thigh, double &pref, span< double > coeffs) const override
This utility function reports back the type of parameterization and all of the parameters for the spe...
void updateTemperaturePoly(double T, span< double > T_poly) const override
Given the temperature T, compute the terms of the temperature polynomial T_poly.
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.
Abstract Base class for the thermodynamic manager for an individual species' reference state.
double m_Pref
Reference state pressure.
double m_lowT
lowest valid temperature
double m_highT
Highest valid temperature.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
void checkArraySize(const char *procedure, size_t available, size_t required)
Wrapper for throwing ArraySizeError.
#define NASA9
9 coefficient NASA Polynomials This is implemented in the class Nasa9Poly1 in Nasa9Poly1....