Cantera  2.0
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 
10 
11 #include "ConstCpPoly.h"
12 
13 #include <cmath>
14 
15 namespace Cantera
16 {
17 
19  : m_t0(0.0),
20  m_cp0_R(0.0),
21  m_h0_R(0.0),
22  m_s0_R(0.0),
23  m_logt0(0.0),
24  m_lowT(0.0),
25  m_highT(0.0),
26  m_Pref(0.0),
27  m_index(0)
28 {
29 }
30 
31 ConstCpPoly::ConstCpPoly(size_t n, doublereal tlow, doublereal thigh,
32  doublereal pref,
33  const doublereal* coeffs) :
34  m_lowT(tlow),
35  m_highT(thigh),
36  m_Pref(pref),
37  m_index(n)
38 {
39  m_t0 = coeffs[0];
40  m_h0_R = coeffs[1] / GasConstant;
41  m_s0_R = coeffs[2] / GasConstant;
42  m_cp0_R = coeffs[3] / GasConstant;
43  m_logt0 = log(m_t0);
44 }
45 
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  m_lowT(b.m_lowT),
53  m_highT(b.m_highT),
54  m_Pref(b.m_Pref),
55  m_index(b.m_index)
56 {
57 }
58 
60 {
61  if (&b != this) {
62  m_t0 = b.m_t0;
63  m_cp0_R = b.m_cp0_R;
64  m_h0_R = b.m_h0_R;
65  m_s0_R = b.m_s0_R;
66  m_logt0 = b.m_logt0;
67  m_lowT = b.m_lowT;
68  m_highT = b.m_highT;
69  m_Pref = b.m_Pref;
70  m_index = b.m_index;
71  }
72  return *this;
73 }
74 
76 
79 {
80  ConstCpPoly* newCCP = new ConstCpPoly(*this);
81  return (SpeciesThermoInterpType*) newCCP;
82 }
83 
84 doublereal ConstCpPoly::minTemp() const
85 {
86  return m_lowT;
87 }
88 doublereal ConstCpPoly::maxTemp() const
89 {
90  return m_highT;
91 }
92 doublereal ConstCpPoly::refPressure() const
93 {
94  return m_Pref;
95 }
96 
97 void ConstCpPoly::updateProperties(const doublereal* tt,
98  doublereal* cp_R,
99  doublereal* h_RT,
100  doublereal* s_R) const
101 {
102  double t = *tt;
103  doublereal logt = log(t);
104  doublereal rt = 1.0/t;
105  cp_R[m_index] = m_cp0_R;
106  h_RT[m_index] = rt*(m_h0_R + (t - m_t0) * m_cp0_R);
107  s_R[m_index] = m_s0_R + m_cp0_R * (logt - m_logt0);
108 }
109 
110 void ConstCpPoly::updatePropertiesTemp(const doublereal temp,
111  doublereal* cp_R,
112  doublereal* h_RT,
113  doublereal* s_R) const
114 {
115  doublereal logt = log(temp);
116  doublereal rt = 1.0/temp;
117  cp_R[m_index] = m_cp0_R;
118  h_RT[m_index] = rt*(m_h0_R + (temp - m_t0) * m_cp0_R);
119  s_R[m_index] = m_s0_R + m_cp0_R * (logt - m_logt0);
120 }
121 
122 void ConstCpPoly::reportParameters(size_t& n, int& type,
123  doublereal& tlow, doublereal& thigh,
124  doublereal& pref,
125  doublereal* const coeffs) const
126 {
127  n = m_index;
128  type = CONSTANT_CP;
129  tlow = m_lowT;
130  thigh = m_highT;
131  pref = m_Pref;
132  coeffs[0] = m_t0;
133  coeffs[1] = m_h0_R * GasConstant;
134  coeffs[2] = m_s0_R * GasConstant;
135  coeffs[3] = m_cp0_R * GasConstant;
136 }
137 
138 void ConstCpPoly::modifyParameters(doublereal* coeffs)
139 {
140  m_t0 = coeffs[0];
141  m_h0_R = coeffs[1] / GasConstant;
142  m_s0_R = coeffs[2] / GasConstant;
143  m_cp0_R = coeffs[3] / GasConstant;
144  m_logt0 = log(m_t0);
145 }
146 
147 #ifdef H298MODIFY_CAPABILITY
148 
149 doublereal ConstCpPoly::reportHf298(doublereal* const h298) const
150 {
151  double temp = 298.15;
152  doublereal h = GasConstant * (m_h0_R + (temp - m_t0) * m_cp0_R);
153  if (h298) {
154  h298[m_index] = h;
155  }
156  return h;
157 }
158 
159 void ConstCpPoly::modifyOneHf298(const int k, const doublereal Hf298New)
160 {
161  if (k != m_index) {
162  return;
163  }
164  doublereal hnow = reportHf298();
165  doublereal delH = Hf298New - hnow;
166  m_h0_R += delH / GasConstant;
167 }
168 
169 #endif
170 
171 }
172 
173