Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
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 
34 ConstCpPoly::ConstCpPoly(double tlow, double thigh, double pref,
35  const double* coeffs) :
36  SpeciesThermoInterpType(tlow, thigh, pref)
37 {
38  m_t0 = coeffs[0];
39  m_h0_R = coeffs[1] / GasConstant;
40  m_s0_R = coeffs[2] / GasConstant;
41  m_cp0_R = coeffs[3] / GasConstant;
42  m_logt0 = log(m_t0);
43 }
44 
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 {
53 }
54 
56 {
57  if (&b != this) {
58  m_t0 = b.m_t0;
59  m_cp0_R = b.m_cp0_R;
60  m_h0_R = b.m_h0_R;
61  m_s0_R = b.m_s0_R;
62  m_logt0 = b.m_logt0;
63  SpeciesThermoInterpType::operator=(b);
64  }
65  return *this;
66 }
67 
69 ConstCpPoly::duplMyselfAsSpeciesThermoInterpType() const
70 {
71  return new ConstCpPoly(*this);
72 }
73 
74 void ConstCpPoly::updateProperties(const doublereal* tt,
75  doublereal* cp_R,
76  doublereal* h_RT,
77  doublereal* s_R) const
78 {
79  double t = *tt;
80  doublereal logt = log(t);
81  doublereal rt = 1.0/t;
82  cp_R[m_index] = m_cp0_R;
83  h_RT[m_index] = rt*(m_h0_R + (t - m_t0) * m_cp0_R);
84  s_R[m_index] = m_s0_R + m_cp0_R * (logt - m_logt0);
85 }
86 
87 void ConstCpPoly::updatePropertiesTemp(const doublereal temp,
88  doublereal* cp_R,
89  doublereal* h_RT,
90  doublereal* s_R) const
91 {
92  doublereal logt = log(temp);
93  doublereal rt = 1.0/temp;
94  cp_R[m_index] = m_cp0_R;
95  h_RT[m_index] = rt*(m_h0_R + (temp - m_t0) * m_cp0_R);
96  s_R[m_index] = m_s0_R + m_cp0_R * (logt - m_logt0);
97 }
98 
99 void ConstCpPoly::reportParameters(size_t& n, int& type,
100  doublereal& tlow, doublereal& thigh,
101  doublereal& pref,
102  doublereal* const coeffs) const
103 {
104  n = m_index;
105  type = CONSTANT_CP;
106  tlow = m_lowT;
107  thigh = m_highT;
108  pref = m_Pref;
109  coeffs[0] = m_t0;
110  coeffs[1] = m_h0_R * GasConstant;
111  coeffs[2] = m_s0_R * GasConstant;
112  coeffs[3] = m_cp0_R * GasConstant;
113 }
114 
115 void ConstCpPoly::modifyParameters(doublereal* coeffs)
116 {
117  m_t0 = coeffs[0];
118  m_h0_R = coeffs[1] / GasConstant;
119  m_s0_R = coeffs[2] / GasConstant;
120  m_cp0_R = coeffs[3] / GasConstant;
121  m_logt0 = log(m_t0);
122 }
123 
124 doublereal ConstCpPoly::reportHf298(doublereal* const h298) const
125 {
126  double temp = 298.15;
127  doublereal h = GasConstant * (m_h0_R + (temp - m_t0) * m_cp0_R);
128  if (h298) {
129  h298[m_index] = h;
130  }
131  return h;
132 }
133 
134 void ConstCpPoly::modifyOneHf298(const size_t k, const doublereal Hf298New)
135 {
136  if (k != m_index) {
137  return;
138  }
139  doublereal hnow = reportHf298();
140  doublereal delH = Hf298New - hnow;
141  m_h0_R += delH / GasConstant;
142 }
143 
144 }
Pure Virtual Base class for the thermodynamic manager for an individual species' reference state...
#define CONSTANT_CP
Constant Cp.
virtual void modifyOneHf298(const size_t k, const doublereal Hf298New)
Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1) ...
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:99
virtual void modifyParameters(doublereal *coeffs)
Modify parameters for the standard state.
virtual doublereal reportHf298(doublereal *const h298=0) const
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1) ...
ConstCpPoly & operator=(const ConstCpPoly &)
Assignment operator.
Definition: ConstCpPoly.cpp:55
doublereal m_s0_R
Dimensionless value of the entropy at t0.
Definition: ConstCpPoly.h:145
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:143
doublereal m_t0
Base temperature.
Definition: ConstCpPoly.h:139
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:87
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:64
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:74
doublereal m_Pref
Reference state pressure.
ConstCpPoly()
empty constructor
Definition: ConstCpPoly.cpp:13
doublereal m_logt0
log of the t0 value
Definition: ConstCpPoly.h:147
doublereal m_cp0_R
Dimensionless value of the heat capacity.
Definition: ConstCpPoly.h:141