Cantera  2.1.2
Nasa9Poly1.cpp
Go to the documentation of this file.
1 /**
2  * @file Nasa9Poly1.cpp
3  * Definitions for a single-species standard state object derived
4  * from
5  * \link Cantera::SpeciesThermoInterpType SpeciesThermoInterpType\endlink
6  * based
7  * on the NASA 9 coefficient temperature polynomial form applied to one temperature region
8  * (see \ref spthermo and class \link Cantera::Nasa9Poly1 Nasa9Poly1\endlink).
9  *
10  * This parameterization has one NASA temperature region.
11  */
12 // Copyright 2007 Sandia National Laboratories
13 
15 
16 namespace Cantera
17 {
19  : m_coeff(vector_fp(9))
20 {
21  m_Pref = 1.0e5;
22 }
23 
24 Nasa9Poly1::Nasa9Poly1(size_t n, doublereal tlow, doublereal thigh,
25  doublereal pref,
26  const doublereal* coeffs) :
27  SpeciesThermoInterpType(n, tlow, thigh, pref),
28  m_coeff(vector_fp(9))
29 {
30  std::copy(coeffs, coeffs + 9, m_coeff.begin());
31 }
32 
35  m_coeff(vector_fp(9))
36 {
37  std::copy(b.m_coeff.begin(),
38  b.m_coeff.begin() + 9,
39  m_coeff.begin());
40 }
41 
43 {
44  if (&b != this) {
45  SpeciesThermoInterpType::operator=(b);
46  std::copy(b.m_coeff.begin(),
47  b.m_coeff.begin() + 9,
48  m_coeff.begin());
49  }
50  return *this;
51 }
52 
55 {
56  return new Nasa9Poly1(*this);
57 }
58 
60 {
61  return NASA9;
62 }
63 
64 void Nasa9Poly1::updateProperties(const doublereal* tt,
65  doublereal* cp_R, doublereal* h_RT,
66  doublereal* s_R) const
67 {
68 
69  doublereal ct0 = m_coeff[0] * tt[5]; // a0 / (T^2)
70  doublereal ct1 = m_coeff[1] * tt[4]; // a1 / T
71  doublereal ct2 = m_coeff[2]; // a2
72  doublereal ct3 = m_coeff[3] * tt[0]; // a3 * T
73  doublereal ct4 = m_coeff[4] * tt[1]; // a4 * T^2
74  doublereal ct5 = m_coeff[5] * tt[2]; // a5 * T^3
75  doublereal ct6 = m_coeff[6] * tt[3]; // a6 * T^4
76 
77 
78  doublereal cpdivR = ct0 + ct1 + ct2 + ct3 + ct4 + ct5 + ct6;
79  doublereal hdivRT = -ct0 + tt[6]*ct1 + ct2 + 0.5*ct3 + OneThird*ct4
80  + 0.25*ct5 + 0.2*ct6 + m_coeff[7] * tt[4];
81  doublereal sdivR = -0.5*ct0 - ct1 + tt[6]*ct2 + ct3 + 0.5*ct4
82  + OneThird*ct5 + 0.25*ct6 + m_coeff[8];
83 
84  // return the computed properties in the location in the output
85  // arrays for this species
86  cp_R[m_index] = cpdivR;
87  h_RT[m_index] = hdivRT;
88  s_R[m_index] = sdivR;
89  //writelog("NASA9poly1: for species "+int2str(m_index)+", h_RT = "+
90  // fp2str(h)+"\n");
91 }
92 
93 void Nasa9Poly1::updatePropertiesTemp(const doublereal temp,
94  doublereal* cp_R, doublereal* h_RT,
95  doublereal* s_R) const
96 {
97  double tPoly[7];
98  tPoly[0] = temp;
99  tPoly[1] = temp * temp;
100  tPoly[2] = tPoly[1] * temp;
101  tPoly[3] = tPoly[2] * temp;
102  tPoly[4] = 1.0 / temp;
103  tPoly[5] = tPoly[4] / temp;
104  tPoly[6] = std::log(temp);
105  updateProperties(tPoly, cp_R, h_RT, s_R);
106 }
107 
108 void Nasa9Poly1::reportParameters(size_t& n, int& type,
109  doublereal& tlow, doublereal& thigh,
110  doublereal& pref,
111  doublereal* const coeffs) const
112 {
113  warn_deprecated("Nasa9Poly1::reportParameters");
114  n = m_index;
115  type = NASA9;
116  tlow = m_lowT;
117  thigh = m_highT;
118  pref = m_Pref;
119  coeffs[0] = 1;
120  coeffs[1] = m_lowT;
121  coeffs[2] = m_highT;
122  for (int i = 0; i < 9; i++) {
123  coeffs[i+3] = m_coeff[i];
124  }
125 }
126 
127 void Nasa9Poly1::modifyParameters(doublereal* coeffs)
128 {
129  warn_deprecated("Nasa9Poly1::modifyParameters");
130  for (int i = 0; i < 9; i++) {
131  m_coeff[i] = coeffs[i];
132  }
133 }
134 
135 }
Nasa9Poly1()
Empty constructor.
Definition: Nasa9Poly1.cpp:18
virtual void modifyParameters(doublereal *coeffs)
Modify parameters for the standard state.
Definition: Nasa9Poly1.cpp:127
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:108
Pure Virtual Base class for the thermodynamic manager for an individual species' reference state...
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the N...
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:76
virtual int reportType() const
Returns an integer representing the type of parameterization.
Definition: Nasa9Poly1.cpp:59
virtual SpeciesThermoInterpType * duplMyselfAsSpeciesThermoInterpType() const
duplicator
Definition: Nasa9Poly1.cpp:54
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:93
#define NASA9
9 coefficient NASA Polynomials This is implemented in the class Nasa9Poly1 in Nasa9Poly1.h
const doublereal OneThird
1/3
Definition: ct_defs.h:128
doublereal m_highT
Highest valid temperature.
doublereal m_lowT
lowest valid temperature
Nasa9Poly1 & operator=(const Nasa9Poly1 &b)
assignment operator
Definition: Nasa9Poly1.cpp:42
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:165
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:64
The NASA 9 polynomial parameterization for one temperature range.
Definition: Nasa9Poly1.h:69
doublereal m_Pref
Reference state pressure.
vector_fp m_coeff
array of polynomial coefficients
Definition: Nasa9Poly1.h:189