Cantera 2.6.0
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
5 * on the NASA 9 coefficient temperature polynomial form applied to one
6 * temperature region (see \ref spthermo and class \link Cantera::Nasa9Poly1
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
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 const double* coeffs) :
28 SpeciesThermoInterpType(tlow, thigh, pref),
29 m_coeff(coeffs, coeffs + 9)
30{
31}
32
34{
35 if (coeffs.size() != 9) {
36 throw CanteraError("Nasa9Poly1::setParameters", "Array must contain "
37 "9 coefficients, but {} were given.", coeffs.size());
38 }
39 m_coeff = coeffs;
40}
41
43{
44 return NASA9;
45}
46
47void Nasa9Poly1::updateTemperaturePoly(double T, double* T_poly) const
48{
49 T_poly[0] = T;
50 T_poly[1] = T * T;
51 T_poly[2] = T_poly[1] * T;
52 T_poly[3] = T_poly[2] * T;
53 T_poly[4] = 1.0 / T;
54 T_poly[5] = T_poly[4] / T;
55 T_poly[6] = std::log(T);
56}
57
58void Nasa9Poly1::updateProperties(const doublereal* tt,
59 doublereal* cp_R, doublereal* h_RT,
60 doublereal* s_R) const
61{
62
63 doublereal ct0 = m_coeff[0] * tt[5]; // a0 / (T^2)
64 doublereal ct1 = m_coeff[1] * tt[4]; // a1 / T
65 doublereal ct2 = m_coeff[2]; // a2
66 doublereal ct3 = m_coeff[3] * tt[0]; // a3 * T
67 doublereal ct4 = m_coeff[4] * tt[1]; // a4 * T^2
68 doublereal ct5 = m_coeff[5] * tt[2]; // a5 * T^3
69 doublereal ct6 = m_coeff[6] * tt[3]; // a6 * T^4
70
71 doublereal cpdivR = ct0 + ct1 + ct2 + ct3 + ct4 + ct5 + ct6;
72 doublereal hdivRT = -ct0 + tt[6]*ct1 + ct2 + 0.5*ct3 + 1.0/3.0*ct4
73 + 0.25*ct5 + 0.2*ct6 + m_coeff[7] * tt[4];
74 doublereal sdivR = -0.5*ct0 - ct1 + tt[6]*ct2 + ct3 + 0.5*ct4
75 + 1.0/3.0*ct5 + 0.25*ct6 + m_coeff[8];
76
77 // return the computed properties for this species
78 *cp_R = cpdivR;
79 *h_RT = hdivRT;
80 *s_R = sdivR;
81}
82
83void Nasa9Poly1::updatePropertiesTemp(const doublereal temp,
84 doublereal* cp_R, doublereal* h_RT,
85 doublereal* s_R) const
86{
87 double tPoly[7];
88 updateTemperaturePoly(temp, tPoly);
89 updateProperties(tPoly, cp_R, h_RT, s_R);
90}
91
92void Nasa9Poly1::reportParameters(size_t& n, int& type,
93 doublereal& tlow, doublereal& thigh,
94 doublereal& pref,
95 doublereal* const coeffs) const
96{
97 n = 0;
98 type = NASA9;
99 tlow = m_lowT;
100 thigh = m_highT;
101 pref = m_Pref;
102 coeffs[0] = 1;
103 coeffs[1] = m_lowT;
104 coeffs[2] = m_highT;
105 for (int i = 0; i < 9; i++) {
106 coeffs[i+3] = m_coeff[i];
107 }
108}
109
111 // Nasa9Poly1 is only used as an embedded model within
112 // Nasa9PolyMultiTempRegion, so all that needs to be added here are the
113 // polynomial coefficients
114 thermo["data"].asVector<vector_fp>().push_back(m_coeff);
115}
116
117}
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:399
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
virtual int reportType() const
Returns an integer representing the type of parameterization.
Definition: Nasa9Poly1.cpp:42
vector_fp m_coeff
array of polynomial coefficients
Definition: Nasa9Poly1.h:131
void setParameters(const vector_fp &coeffs)
Set the array of 9 polynomial coefficients.
Definition: Nasa9Poly1.cpp:33
virtual void getParameters(AnyMap &thermo) const
Store the parameters of the species thermo object such that an identical species thermo object could ...
Definition: Nasa9Poly1.cpp:110
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: Nasa9Poly1.cpp:83
virtual void reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal *const coeffs) const
This utility function reports back the type of parameterization and all of the parameters for the spe...
Definition: Nasa9Poly1.cpp:92
virtual void updateTemperaturePoly(double T, double *T_poly) const
Given the temperature T, compute the terms of the temperature polynomial T_poly.
Definition: Nasa9Poly1.cpp:47
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: Nasa9Poly1.cpp:58
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
#define NASA9
9 coefficient NASA Polynomials This is implemented in the class Nasa9Poly1 in Nasa9Poly1....