Cantera  2.1.2
ConstCpPoly.cpp
Go to the documentation of this file.
1 /**
2  * @file ConstCpPoly.cpp
3  * Declarations for the \link Cantera::SpeciesThermoInterpType SpeciesThermoInterpType \endlink object that
4  * employs a constant heat capacity assumption (see \ref spthermo and
5  * \link Cantera::ConstCpPoly ConstCpPoly \endlink).
6  */
7 // Copyright 2001 California Institute of Technology
8 
9 #include "ConstCpPoly.h"
10 
11 namespace Cantera
12 {
14  : m_t0(0.0),
15  m_cp0_R(0.0),
16  m_h0_R(0.0),
17  m_s0_R(0.0),
18  m_logt0(0.0)
19 {
20 }
21 
22 ConstCpPoly::ConstCpPoly(size_t n, doublereal tlow, doublereal thigh,
23  doublereal pref,
24  const doublereal* coeffs) :
25  SpeciesThermoInterpType(n, tlow, thigh, pref)
26 {
27  m_t0 = coeffs[0];
28  m_h0_R = coeffs[1] / GasConstant;
29  m_s0_R = coeffs[2] / GasConstant;
30  m_cp0_R = coeffs[3] / GasConstant;
31  m_logt0 = log(m_t0);
32 }
33 
36  m_t0(b.m_t0),
37  m_cp0_R(b.m_cp0_R),
38  m_h0_R(b.m_h0_R),
39  m_s0_R(b.m_s0_R),
40  m_logt0(b.m_logt0)
41 {
42 }
43 
45 {
46  if (&b != this) {
47  m_t0 = b.m_t0;
48  m_cp0_R = b.m_cp0_R;
49  m_h0_R = b.m_h0_R;
50  m_s0_R = b.m_s0_R;
51  m_logt0 = b.m_logt0;
52  SpeciesThermoInterpType::operator=(b);
53  }
54  return *this;
55 }
56 
59 {
60  return new ConstCpPoly(*this);
61 }
62 
63 void ConstCpPoly::updateProperties(const doublereal* tt,
64  doublereal* cp_R,
65  doublereal* h_RT,
66  doublereal* s_R) const
67 {
68  double t = *tt;
69  doublereal logt = log(t);
70  doublereal rt = 1.0/t;
71  cp_R[m_index] = m_cp0_R;
72  h_RT[m_index] = rt*(m_h0_R + (t - m_t0) * m_cp0_R);
73  s_R[m_index] = m_s0_R + m_cp0_R * (logt - m_logt0);
74 }
75 
76 void ConstCpPoly::updatePropertiesTemp(const doublereal temp,
77  doublereal* cp_R,
78  doublereal* h_RT,
79  doublereal* s_R) const
80 {
81  doublereal logt = log(temp);
82  doublereal rt = 1.0/temp;
83  cp_R[m_index] = m_cp0_R;
84  h_RT[m_index] = rt*(m_h0_R + (temp - m_t0) * m_cp0_R);
85  s_R[m_index] = m_s0_R + m_cp0_R * (logt - m_logt0);
86 }
87 
88 void ConstCpPoly::reportParameters(size_t& n, int& type,
89  doublereal& tlow, doublereal& thigh,
90  doublereal& pref,
91  doublereal* const coeffs) const
92 {
93  n = m_index;
94  type = CONSTANT_CP;
95  tlow = m_lowT;
96  thigh = m_highT;
97  pref = m_Pref;
98  coeffs[0] = m_t0;
99  coeffs[1] = m_h0_R * GasConstant;
100  coeffs[2] = m_s0_R * GasConstant;
101  coeffs[3] = m_cp0_R * GasConstant;
102 }
103 
104 void ConstCpPoly::modifyParameters(doublereal* coeffs)
105 {
106  m_t0 = coeffs[0];
107  m_h0_R = coeffs[1] / GasConstant;
108  m_s0_R = coeffs[2] / GasConstant;
109  m_cp0_R = coeffs[3] / GasConstant;
110  m_logt0 = log(m_t0);
111 }
112 
113 #ifdef H298MODIFY_CAPABILITY
114 
115 doublereal ConstCpPoly::reportHf298(doublereal* const h298) const
116 {
117  double temp = 298.15;
118  doublereal h = GasConstant * (m_h0_R + (temp - m_t0) * m_cp0_R);
119  if (h298) {
120  h298[m_index] = h;
121  }
122  return h;
123 }
124 
125 void ConstCpPoly::modifyOneHf298(const size_t& k, const doublereal Hf298New)
126 {
127  if (k != m_index) {
128  return;
129  }
130  doublereal hnow = reportHf298();
131  doublereal delH = Hf298New - hnow;
132  m_h0_R += delH / GasConstant;
133 }
134 
135 #endif
136 
137 }
Pure Virtual Base class for the thermodynamic manager for an individual species' reference state...
#define CONSTANT_CP
Constant Cp.
virtual SpeciesThermoInterpType * duplMyselfAsSpeciesThermoInterpType() const
duplicator
Definition: ConstCpPoly.cpp:58
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: ConstCpPoly.cpp:88
virtual void modifyParameters(doublereal *coeffs)
Modify parameters for the standard state.
ConstCpPoly & operator=(const ConstCpPoly &)
Assignment operator.
Definition: ConstCpPoly.cpp:44
doublereal m_s0_R
Dimensionless value of the entropy at t0.
Definition: ConstCpPoly.h:130
A constant-heat capacity species thermodynamic property manager class.
Definition: ConstCpPoly.h:47
doublereal m_highT
Highest valid temperature.
doublereal m_h0_R
dimensionless value of the enthaply at t0
Definition: ConstCpPoly.h:128
doublereal m_t0
Base temperature.
Definition: ConstCpPoly.h:124
doublereal m_lowT
lowest valid temperature
void updatePropertiesTemp(const doublereal temp, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Compute the reference-state property of one species.
Definition: ConstCpPoly.cpp:76
Headers for the SpeciesThermoInterpType object that employs a constant heat capacity assumption (see ...
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:66
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: ConstCpPoly.cpp:63
doublereal m_Pref
Reference state pressure.
ConstCpPoly()
empty constructor
Definition: ConstCpPoly.cpp:13
doublereal m_logt0
log of the t0 value
Definition: ConstCpPoly.h:132
doublereal m_cp0_R
Dimensionless value of the heat capacity.
Definition: ConstCpPoly.h:126