Cantera  2.4.0
ShomatePoly.h
Go to the documentation of this file.
1 /**
2  * @file ShomatePoly.h
3  * Header for a single-species standard state object derived
4  * from \link Cantera::SpeciesThermoInterpType SpeciesThermoInterpType\endlink based
5  * on the Shomate temperature polynomial form applied to one temperature region
6  * (see \ref spthermo and class \link Cantera::ShomatePoly ShomatePoly\endlink and
7  * \link Cantera::ShomatePoly2 ShomatePoly2\endlink).
8  * Shomate polynomial expressions.
9  */
10 
11 // This file is part of Cantera. See License.txt in the top-level directory or
12 // at http://www.cantera.org/license.txt for license and copyright information.
13 
14 #ifndef CT_SHOMATEPOLY1_H
15 #define CT_SHOMATEPOLY1_H
16 
18 
19 namespace Cantera
20 {
21 //! The Shomate polynomial parameterization for one temperature range for one
22 //! species
23 /*!
24  * Seven coefficients \f$(A,\dots,G)\f$ are used to represent
25  * \f$ c_p^0(T)\f$, \f$ h^0(T)\f$, and \f$ s^0(T) \f$ as
26  * polynomials in the temperature, \f$ T \f$ :
27  *
28  * \f[
29  * \tilde{c}_p^0(T) = A + B t + C t^2 + D t^3 + \frac{E}{t^2}
30  * \f]
31  * \f[
32  * \tilde{h}^0(T) = A t + \frac{B t^2}{2} + \frac{C t^3}{3}
33  * + \frac{D t^4}{4} - \frac{E}{t} + F.
34  * \f]
35  * \f[
36  * \tilde{s}^0(T) = A\ln t + B t + \frac{C t^2}{2}
37  * + \frac{D t^3}{3} - \frac{E}{2t^2} + G.
38  * \f]
39  *
40  * In the above expressions, the thermodynamic polynomials are expressed in
41  * dimensional units, but the temperature,\f$ t \f$, is divided by 1000. The
42  * following dimensions are assumed in the above expressions:
43  *
44  * - \f$ \tilde{c}_p^0(T)\f$ = Heat Capacity (J/gmol*K)
45  * - \f$ \tilde{h}^0(T) \f$ = standard Enthalpy (kJ/gmol)
46  * - \f$ \tilde{s}^0(T) \f$= standard Entropy (J/gmol*K)
47  * - \f$ t \f$= temperature (K) / 1000.
48  *
49  * For more information about Shomate polynomials, see the NIST website,
50  * http://webbook.nist.gov/
51  *
52  * Before being used within Cantera, the dimensions must be adjusted to those
53  * used by Cantera (i.e., Joules and kmol).
54  *
55  * @ingroup spthermo
56  */
58 {
59 public:
60  //! Normal constructor
61  /*!
62  * @param tlow Minimum temperature
63  * @param thigh Maximum temperature
64  * @param pref reference pressure (Pa).
65  * @param coeffs Vector of coefficients, [A,B,C,D,E,F,G], used to set
66  * the parameters for the species standard state.
67  *
68  * See the class description for the polynomial representation of the
69  * thermo functions in terms of \f$ A, \dots, G \f$.
70  */
71  ShomatePoly(double tlow, double thigh, double pref, const double* coeffs) :
72  SpeciesThermoInterpType(tlow, thigh, pref),
73  m_coeff(7)
74  {
75  for (size_t i = 0; i < 7; i++) {
76  m_coeff[i] = coeffs[i] * 1000 / GasConstant;
77  }
78  m_coeff5_orig = m_coeff[5];
79  }
80 
81  virtual int reportType() const {
82  return SHOMATE;
83  }
84 
85  virtual size_t temperaturePolySize() const { return 6; }
86 
87  virtual void updateTemperaturePoly(double T, double* T_poly) const {
88  doublereal tt = 1.e-3*T;
89  T_poly[0] = tt;
90  T_poly[1] = tt * tt;
91  T_poly[2] = T_poly[1] * tt;
92  T_poly[3] = 1.0/T_poly[1];
93  T_poly[4] = std::log(tt);
94  T_poly[5] = 1.0/tt;
95  }
96 
97  /*!
98  * @copydoc SpeciesThermoInterpType::updateProperties
99  *
100  * Form of the temperature polynomial:
101  * - `t` is T/1000.
102  * - `t[0] = t`
103  * - `t[1] = t*t`
104  * - `t[2] = t[1]*t`
105  * - `t[3] = 1.0/t[1]`
106  * - `t[4] = log(t)`
107  * - `t[5] = 1.0/t;
108  */
109  virtual void updateProperties(const doublereal* tt,
110  doublereal* cp_R, doublereal* h_RT,
111  doublereal* s_R) const {
112  doublereal A = m_coeff[0];
113  doublereal Bt = m_coeff[1]*tt[0];
114  doublereal Ct2 = m_coeff[2]*tt[1];
115  doublereal Dt3 = m_coeff[3]*tt[2];
116  doublereal Etm2 = m_coeff[4]*tt[3];
117  doublereal Ftm1 = m_coeff[5]*tt[5];
118  doublereal G = m_coeff[6];
119 
120  *cp_R = A + Bt + Ct2 + Dt3 + Etm2;
121  *h_RT = A + 0.5*Bt + 1.0/3.0*Ct2 + 0.25*Dt3 - Etm2 + Ftm1;
122  *s_R = A*tt[4] + Bt + 0.5*Ct2 + 1.0/3.0*Dt3 - 0.5*Etm2 + G;
123  }
124 
125  virtual void updatePropertiesTemp(const doublereal temp,
126  doublereal* cp_R, doublereal* h_RT,
127  doublereal* s_R) const {
128  double tPoly[6];
129  updateTemperaturePoly(temp, tPoly);
130  updateProperties(tPoly, cp_R, h_RT, s_R);
131  }
132 
133  virtual void reportParameters(size_t& n, int& type,
134  doublereal& tlow, doublereal& thigh,
135  doublereal& pref,
136  doublereal* const coeffs) const {
137  n = 0;
138  type = SHOMATE;
139  tlow = m_lowT;
140  thigh = m_highT;
141  pref = m_Pref;
142  for (int i = 0; i < 7; i++) {
143  coeffs[i] = m_coeff[i] * GasConstant / 1000;
144  }
145  }
146 
147  virtual doublereal reportHf298(doublereal* const h298 = 0) const {
148  double cp_R, h_RT, s_R;
149  updatePropertiesTemp(298.15, &cp_R, &h_RT, &s_R);
150  return h_RT * GasConstant * 298.15;
151  }
152 
153  virtual void modifyOneHf298(const size_t k, const doublereal Hf298New) {
154  doublereal hnow = reportHf298();
155  doublereal delH = Hf298New - hnow;
156  m_coeff[5] += delH / (1e3 * GasConstant);
157  }
158 
159  virtual void resetHf298() {
160  m_coeff[5] = m_coeff5_orig;
161  }
162 
163 protected:
164  //! Array of coefficients
166  double m_coeff5_orig;
167 };
168 
169 //! The Shomate polynomial parameterization for two temperature ranges for one
170 //! species
171 /*!
172  * Seven coefficients \f$(A,\dots,G)\f$ are used to represent
173  * \f$ c_p^0(T)\f$, \f$ h^0(T)\f$, and \f$ s^0(T) \f$ as
174  * polynomials in the temperature, \f$ T \f$, in one temperature region:
175  *
176  * \f[
177  * \tilde{c}_p^0(T) = A + B t + C t^2 + D t^3 + \frac{E}{t^2}
178  * \f]
179  * \f[
180  * \tilde{h}^0(T) = A t + \frac{B t^2}{2} + \frac{C t^3}{3}
181  * + \frac{D t^4}{4} - \frac{E}{t} + F.
182  * \f]
183  * \f[
184  * \tilde{s}^0(T) = A\ln t + B t + \frac{C t^2}{2}
185  * + \frac{D t^3}{3} - \frac{E}{2t^2} + G.
186  * \f]
187  *
188  * In the above expressions, the thermodynamic polynomials are expressed
189  * in dimensional units, but the temperature,\f$ t \f$, is divided by 1000. The
190  * following dimensions are assumed in the above expressions:
191  *
192  * - \f$ \tilde{c}_p^0(T)\f$ = Heat Capacity (J/gmol*K)
193  * - \f$ \tilde{h}^0(T) \f$ = standard Enthalpy (kJ/gmol)
194  * - \f$ \tilde{s}^0(T) \f$= standard Entropy (J/gmol*K)
195  * - \f$ t \f$= temperature (K) / 1000.
196  *
197  * For more information about Shomate polynomials, see the NIST website,
198  * http://webbook.nist.gov/
199  *
200  * Before being used within Cantera, the dimensions must be adjusted to those
201  * used by Cantera (i.e., Joules and kmol).
202  *
203  * This function uses two temperature regions, each with a Shomate polynomial
204  * representation to represent the thermo functions. There are 15 coefficients,
205  * therefore, in this representation. The first coefficient is the midrange
206  * temperature.
207  *
208  * @ingroup spthermo
209  */
211 {
212 public:
213  //! Normal constructor
214  /*!
215  * @param tlow Minimum temperature
216  * @param thigh Maximum temperature
217  * @param pref reference pressure (Pa).
218  * @param coeffs Vector of coefficients used to set the parameters for the
219  * standard state. [Tmid, 7 low-T coeffs, 7 high-T coeffs]
220  */
221  ShomatePoly2(double tlow, double thigh, double pref, const double* coeffs) :
222  SpeciesThermoInterpType(tlow, thigh, pref),
223  m_midT(coeffs[0]),
224  msp_low(tlow, coeffs[0], pref, coeffs+1),
225  msp_high(coeffs[0], thigh, pref, coeffs+8),
226  m_coeff(coeffs, coeffs + 15)
227  {
228  }
229 
230  virtual int reportType() const {
231  return SHOMATE2;
232  }
233 
234  virtual size_t temperaturePolySize() const { return 7; }
235 
236  virtual void updateTemperaturePoly(double T, double* T_poly) const {
237  msp_low.updateTemperaturePoly(T, T_poly);
238  }
239 
240  //! @copydoc ShomatePoly::updateProperties
241  virtual void updateProperties(const doublereal* tt,
242  doublereal* cp_R, doublereal* h_RT,
243  doublereal* s_R) const {
244  double T = 1000 * tt[0];
245  if (T <= m_midT) {
246  msp_low.updateProperties(tt, cp_R, h_RT, s_R);
247  } else {
248  msp_high.updateProperties(tt, cp_R, h_RT, s_R);
249  }
250  }
251 
252  virtual void updatePropertiesTemp(const doublereal temp,
253  doublereal* cp_R,
254  doublereal* h_RT,
255  doublereal* s_R) const {
256  if (temp <= m_midT) {
257  msp_low.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
258  } else {
259  msp_high.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
260  }
261  }
262 
263  virtual void reportParameters(size_t& n, int& type,
264  doublereal& tlow, doublereal& thigh,
265  doublereal& pref,
266  doublereal* const coeffs) const {
267  n = 0;
268  type = SHOMATE2;
269  tlow = m_lowT;
270  thigh = m_highT;
271  pref = m_Pref;
272  for (int i = 0; i < 15; i++) {
273  coeffs[i] = m_coeff[i];
274  }
275  }
276 
277  virtual doublereal reportHf298(doublereal* const h298 = 0) const {
278  doublereal h;
279  if (298.15 <= m_midT) {
280  h = msp_low.reportHf298(h298);
281  } else {
282  h = msp_high.reportHf298(h298);
283  }
284  if (h298) {
285  *h298 = h;
286  }
287  return h;
288  }
289 
290  virtual void modifyOneHf298(const size_t k, const doublereal Hf298New) {
291  doublereal h298now = reportHf298(0);
292  doublereal delH = Hf298New - h298now;
293  double h = msp_low.reportHf298(0);
294  double hnew = h + delH;
295  msp_low.modifyOneHf298(k, hnew);
296  h = msp_high.reportHf298(0);
297  hnew = h + delH;
298  msp_high.modifyOneHf298(k, hnew);
299  }
300 
301  virtual void resetHf298() {
304  }
305 
306 protected:
307  //! Midrange temperature (kelvin)
308  doublereal m_midT;
309  //! Shomate polynomial for the low temperature region.
311  //! Shomate polynomial for the high temperature region.
313  //! Array of the original coefficients.
315 };
316 }
317 
318 #endif
doublereal m_midT
Midrange temperature (kelvin)
Definition: ShomatePoly.h:308
virtual size_t temperaturePolySize() const
Number of terms in the temperature polynomial for this parameterization.
Definition: ShomatePoly.h:234
virtual void updateTemperaturePoly(double T, double *T_poly) const
Given the temperature T, compute the terms of the temperature polynomial T_poly.
Definition: ShomatePoly.h:87
Abstract Base class for the thermodynamic manager for an individual species&#39; reference state...
virtual void updateTemperaturePoly(double T, double *T_poly) const
Given the temperature T, compute the terms of the temperature polynomial T_poly.
Definition: ShomatePoly.h:236
virtual int reportType() const
Returns an integer representing the type of parameterization.
Definition: ShomatePoly.h:230
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: ShomatePoly.h:263
#define SHOMATE
Two regions of Shomate Polynomials.
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) ...
Definition: ShomatePoly.h:290
vector_fp m_coeff
Array of coefficients.
Definition: ShomatePoly.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: ShomatePoly.h:241
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: ShomatePoly.h:109
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: ShomatePoly.h:252
vector_fp m_coeff
Array of the original coefficients.
Definition: ShomatePoly.h:314
ShomatePoly msp_high
Shomate polynomial for the high temperature region.
Definition: ShomatePoly.h:312
virtual void resetHf298()
Restore the original heat of formation for this species.
Definition: ShomatePoly.h:159
Pure Virtual Base class for individual species reference state thermodynamic managers and text for th...
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) ...
Definition: ShomatePoly.h:153
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: ShomatePoly.h:125
virtual int reportType() const
Returns an integer representing the type of parameterization.
Definition: ShomatePoly.h:81
The Shomate polynomial parameterization for one temperature range for one species.
Definition: ShomatePoly.h:57
The Shomate polynomial parameterization for two temperature ranges for one species.
Definition: ShomatePoly.h:210
doublereal m_highT
Highest valid temperature.
virtual void resetHf298()
Restore the original heat of formation for this species.
Definition: ShomatePoly.h:301
ShomatePoly msp_low
Shomate polynomial for the low temperature region.
Definition: ShomatePoly.h:310
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: ShomatePoly.h:133
#define SHOMATE2
Two regions of Shomate Polynomials.
doublereal m_lowT
lowest valid temperature
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) ...
Definition: ShomatePoly.h:147
ShomatePoly2(double tlow, double thigh, double pref, const double *coeffs)
Normal constructor.
Definition: ShomatePoly.h:221
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:157
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:64
virtual size_t temperaturePolySize() const
Number of terms in the temperature polynomial for this parameterization.
Definition: ShomatePoly.h:85
doublereal m_Pref
Reference state pressure.
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8
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) ...
Definition: ShomatePoly.h:277
ShomatePoly(double tlow, double thigh, double pref, const double *coeffs)
Normal constructor.
Definition: ShomatePoly.h:71