Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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(9, 0.0)
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(coeffs, coeffs + 9)
29 {
30 }
31 
32 Nasa9Poly1::Nasa9Poly1(double tlow, double thigh, double pref,
33  const double* coeffs) :
34  SpeciesThermoInterpType(tlow, thigh, pref),
35  m_coeff(coeffs, coeffs + 9)
36 {
37 }
38 
41  m_coeff(b.m_coeff)
42 {
43 }
44 
46 {
47  if (&b != this) {
48  SpeciesThermoInterpType::operator=(b);
49  m_coeff = b.m_coeff;
50  }
51  return *this;
52 }
53 
55 Nasa9Poly1::duplMyselfAsSpeciesThermoInterpType() const
56 {
57  return new Nasa9Poly1(*this);
58 }
59 
61 {
62  return NASA9;
63 }
64 
65 void Nasa9Poly1::updateTemperaturePoly(double T, double* T_poly) const
66 {
67  T_poly[0] = T;
68  T_poly[1] = T * T;
69  T_poly[2] = T_poly[1] * T;
70  T_poly[3] = T_poly[2] * T;
71  T_poly[4] = 1.0 / T;
72  T_poly[5] = T_poly[4] / T;
73  T_poly[6] = std::log(T);
74 }
75 
76 void Nasa9Poly1::updateProperties(const doublereal* tt,
77  doublereal* cp_R, doublereal* h_RT,
78  doublereal* s_R) const
79 {
80 
81  doublereal ct0 = m_coeff[0] * tt[5]; // a0 / (T^2)
82  doublereal ct1 = m_coeff[1] * tt[4]; // a1 / T
83  doublereal ct2 = m_coeff[2]; // a2
84  doublereal ct3 = m_coeff[3] * tt[0]; // a3 * T
85  doublereal ct4 = m_coeff[4] * tt[1]; // a4 * T^2
86  doublereal ct5 = m_coeff[5] * tt[2]; // a5 * T^3
87  doublereal ct6 = m_coeff[6] * tt[3]; // a6 * T^4
88 
89 
90  doublereal cpdivR = ct0 + ct1 + ct2 + ct3 + ct4 + ct5 + ct6;
91  doublereal hdivRT = -ct0 + tt[6]*ct1 + ct2 + 0.5*ct3 + 1.0/3.0*ct4
92  + 0.25*ct5 + 0.2*ct6 + m_coeff[7] * tt[4];
93  doublereal sdivR = -0.5*ct0 - ct1 + tt[6]*ct2 + ct3 + 0.5*ct4
94  + 1.0/3.0*ct5 + 0.25*ct6 + m_coeff[8];
95 
96  // return the computed properties in the location in the output
97  // arrays for this species
98  cp_R[m_index] = cpdivR;
99  h_RT[m_index] = hdivRT;
100  s_R[m_index] = sdivR;
101 }
102 
103 void Nasa9Poly1::updatePropertiesTemp(const doublereal temp,
104  doublereal* cp_R, doublereal* h_RT,
105  doublereal* s_R) const
106 {
107  double tPoly[7];
108  updateTemperaturePoly(temp, tPoly);
109  updateProperties(tPoly, cp_R, h_RT, s_R);
110 }
111 
112 void Nasa9Poly1::reportParameters(size_t& n, int& type,
113  doublereal& tlow, doublereal& thigh,
114  doublereal& pref,
115  doublereal* const coeffs) const
116 {
117  n = m_index;
118  type = NASA9;
119  tlow = m_lowT;
120  thigh = m_highT;
121  pref = m_Pref;
122  coeffs[0] = 1;
123  coeffs[1] = m_lowT;
124  coeffs[2] = m_highT;
125  for (int i = 0; i < 9; i++) {
126  coeffs[i+3] = m_coeff[i];
127  }
128 }
129 
130 void Nasa9Poly1::modifyParameters(doublereal* coeffs)
131 {
132  for (int i = 0; i < 9; i++) {
133  m_coeff[i] = coeffs[i];
134  }
135 }
136 
137 }
Nasa9Poly1()
Empty constructor.
Definition: Nasa9Poly1.cpp:18
virtual void modifyParameters(doublereal *coeffs)
Modify parameters for the standard state.
Definition: Nasa9Poly1.cpp:130
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:112
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...
virtual int reportType() const
Returns an integer representing the type of parameterization.
Definition: Nasa9Poly1.cpp:60
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:103
#define NASA9
9 coefficient NASA Polynomials This is implemented in the class Nasa9Poly1 in Nasa9Poly1.h
doublereal m_highT
Highest valid temperature.
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:65
doublereal m_lowT
lowest valid temperature
Nasa9Poly1 & operator=(const Nasa9Poly1 &b)
assignment operator
Definition: Nasa9Poly1.cpp:45
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:76
The NASA 9 polynomial parameterization for one temperature range.
Definition: Nasa9Poly1.h:71
doublereal m_Pref
Reference state pressure.
vector_fp m_coeff
array of polynomial coefficients
Definition: Nasa9Poly1.h:204