Cantera  2.3.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  //! Empty constructor
61  //! @deprecated Default constructor to be removed after Cantera 2.3.
63  warn_deprecated("ShomatePoly::ShomatePoly()",
64  "Default constructor to be removed after Cantera 2.3.");
65  }
66 
67  //! Normal constructor
68  /*!
69  * @param tlow Minimum temperature
70  * @param thigh Maximum temperature
71  * @param pref reference pressure (Pa).
72  * @param coeffs Vector of coefficients, [A,B,C,D,E,F,G], used to set
73  * the parameters for the species standard state.
74  *
75  * See the class description for the polynomial representation of the
76  * thermo functions in terms of \f$ A, \dots, G \f$.
77  */
78  ShomatePoly(double tlow, double thigh, double pref, const double* coeffs) :
79  SpeciesThermoInterpType(tlow, thigh, pref),
80  m_coeff(7)
81  {
82  for (size_t i = 0; i < 7; i++) {
83  m_coeff[i] = coeffs[i] * 1000 / GasConstant;
84  }
85  m_coeff5_orig = m_coeff[5];
86  }
87 
90  return new ShomatePoly(*this);
91  }
92 
93  virtual int reportType() const {
94  return SHOMATE;
95  }
96 
97  virtual size_t temperaturePolySize() const { return 6; }
98 
99  virtual void updateTemperaturePoly(double T, double* T_poly) const {
100  doublereal tt = 1.e-3*T;
101  T_poly[0] = tt;
102  T_poly[1] = tt * tt;
103  T_poly[2] = T_poly[1] * tt;
104  T_poly[3] = 1.0/T_poly[1];
105  T_poly[4] = std::log(tt);
106  T_poly[5] = 1.0/tt;
107  }
108 
109  /*!
110  * @copydoc SpeciesThermoInterpType::updateProperties
111  *
112  * Form of the temperature polynomial:
113  * - `t` is T/1000.
114  * - `t[0] = t`
115  * - `t[1] = t*t`
116  * - `t[2] = t[1]*t`
117  * - `t[3] = 1.0/t[1]`
118  * - `t[4] = log(t)`
119  * - `t[5] = 1.0/t;
120  */
121  virtual void updateProperties(const doublereal* tt,
122  doublereal* cp_R, doublereal* h_RT,
123  doublereal* s_R) const {
124  doublereal A = m_coeff[0];
125  doublereal Bt = m_coeff[1]*tt[0];
126  doublereal Ct2 = m_coeff[2]*tt[1];
127  doublereal Dt3 = m_coeff[3]*tt[2];
128  doublereal Etm2 = m_coeff[4]*tt[3];
129  doublereal Ftm1 = m_coeff[5]*tt[5];
130  doublereal G = m_coeff[6];
131 
132  *cp_R = A + Bt + Ct2 + Dt3 + Etm2;
133  *h_RT = A + 0.5*Bt + 1.0/3.0*Ct2 + 0.25*Dt3 - Etm2 + Ftm1;
134  *s_R = A*tt[4] + Bt + 0.5*Ct2 + 1.0/3.0*Dt3 - 0.5*Etm2 + G;
135  }
136 
137  virtual void updatePropertiesTemp(const doublereal temp,
138  doublereal* cp_R, doublereal* h_RT,
139  doublereal* s_R) const {
140  double tPoly[6];
141  updateTemperaturePoly(temp, tPoly);
142  updateProperties(tPoly, cp_R, h_RT, s_R);
143  }
144 
145  virtual void reportParameters(size_t& n, int& type,
146  doublereal& tlow, doublereal& thigh,
147  doublereal& pref,
148  doublereal* const coeffs) const {
149  n = 0;
150  type = SHOMATE;
151  tlow = m_lowT;
152  thigh = m_highT;
153  pref = m_Pref;
154  for (int i = 0; i < 7; i++) {
155  coeffs[i] = m_coeff[i] * GasConstant / 1000;
156  }
157  }
158 
159  //! @deprecated To be removed after Cantera 2.3. Use
160  //! MultiSpeciesThermo::modifySpecies instead.
161  virtual void modifyParameters(doublereal* coeffs) {
162  warn_deprecated("ShomatePoly::modifyParameters", "To be removed after "
163  "Cantera 2.3. Use MultiSpeciesThermo::modifySpecies instead.");
164  for (size_t i = 0; i < 7; i++) {
165  m_coeff[i] = coeffs[i] * 1000 / GasConstant;
166  }
167  }
168 
169  virtual doublereal reportHf298(doublereal* const h298 = 0) const {
170  double cp_R, h_RT, s_R;
171  updatePropertiesTemp(298.15, &cp_R, &h_RT, &s_R);
172  return h_RT * GasConstant * 298.15;
173  }
174 
175  virtual void modifyOneHf298(const size_t k, const doublereal Hf298New) {
176  doublereal hnow = reportHf298();
177  doublereal delH = Hf298New - hnow;
178  m_coeff[5] += delH / (1e3 * GasConstant);
179  }
180 
181  virtual void resetHf298() {
182  m_coeff[5] = m_coeff5_orig;
183  }
184 
185 protected:
186  //! Array of coefficients
188  double m_coeff5_orig;
189 };
190 
191 //! The Shomate polynomial parameterization for two temperature ranges for one
192 //! species
193 /*!
194  * Seven coefficients \f$(A,\dots,G)\f$ are used to represent
195  * \f$ c_p^0(T)\f$, \f$ h^0(T)\f$, and \f$ s^0(T) \f$ as
196  * polynomials in the temperature, \f$ T \f$, in one temperature region:
197  *
198  * \f[
199  * \tilde{c}_p^0(T) = A + B t + C t^2 + D t^3 + \frac{E}{t^2}
200  * \f]
201  * \f[
202  * \tilde{h}^0(T) = A t + \frac{B t^2}{2} + \frac{C t^3}{3}
203  * + \frac{D t^4}{4} - \frac{E}{t} + F.
204  * \f]
205  * \f[
206  * \tilde{s}^0(T) = A\ln t + B t + \frac{C t^2}{2}
207  * + \frac{D t^3}{3} - \frac{E}{2t^2} + G.
208  * \f]
209  *
210  * In the above expressions, the thermodynamic polynomials are expressed
211  * in dimensional units, but the temperature,\f$ t \f$, is divided by 1000. The
212  * following dimensions are assumed in the above expressions:
213  *
214  * - \f$ \tilde{c}_p^0(T)\f$ = Heat Capacity (J/gmol*K)
215  * - \f$ \tilde{h}^0(T) \f$ = standard Enthalpy (kJ/gmol)
216  * - \f$ \tilde{s}^0(T) \f$= standard Entropy (J/gmol*K)
217  * - \f$ t \f$= temperature (K) / 1000.
218  *
219  * For more information about Shomate polynomials, see the NIST website,
220  * http://webbook.nist.gov/
221  *
222  * Before being used within Cantera, the dimensions must be adjusted to those
223  * used by Cantera (i.e., Joules and kmol).
224  *
225  * This function uses two temperature regions, each with a Shomate polynomial
226  * representation to represent the thermo functions. There are 15 coefficients,
227  * therefore, in this representation. The first coefficient is the midrange
228  * temperature.
229  *
230  * @ingroup spthermo
231  */
233 {
234 public:
235  //! Empty constructor
236  //! @deprecated Default constructor to be removed after Cantera 2.3.
238  : m_midT(0.0)
239  {
240  warn_deprecated("ShomatePoly2::ShomatePoly2()",
241  "Default constructor to be removed after Cantera 2.3.");
242  m_coeff.resize(15);
243  }
244 
245  //! Normal constructor
246  /*!
247  * @param tlow Minimum temperature
248  * @param thigh Maximum temperature
249  * @param pref reference pressure (Pa).
250  * @param coeffs Vector of coefficients used to set the parameters for the
251  * standard state. [Tmid, 7 low-T coeffs, 7 high-T coeffs]
252  */
253  ShomatePoly2(double tlow, double thigh, double pref, const double* coeffs) :
254  SpeciesThermoInterpType(tlow, thigh, pref),
255  m_midT(coeffs[0]),
256  msp_low(tlow, coeffs[0], pref, coeffs+1),
257  msp_high(coeffs[0], thigh, pref, coeffs+8),
258  m_coeff(coeffs, coeffs + 15)
259  {
260  }
261 
262  virtual SpeciesThermoInterpType*
264  return new ShomatePoly2(*this);
265  }
266 
267  virtual int reportType() const {
268  return SHOMATE2;
269  }
270 
271  virtual size_t temperaturePolySize() const { return 7; }
272 
273  virtual void updateTemperaturePoly(double T, double* T_poly) const {
274  msp_low.updateTemperaturePoly(T, T_poly);
275  }
276 
277  //! @copydoc ShomatePoly::updateProperties
278  virtual void updateProperties(const doublereal* tt,
279  doublereal* cp_R, doublereal* h_RT,
280  doublereal* s_R) const {
281  double T = 1000 * tt[0];
282  if (T <= m_midT) {
283  msp_low.updateProperties(tt, cp_R, h_RT, s_R);
284  } else {
285  msp_high.updateProperties(tt, cp_R, h_RT, s_R);
286  }
287  }
288 
289  virtual void updatePropertiesTemp(const doublereal temp,
290  doublereal* cp_R,
291  doublereal* h_RT,
292  doublereal* s_R) const {
293  if (temp <= m_midT) {
294  msp_low.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
295  } else {
296  msp_high.updatePropertiesTemp(temp, cp_R, h_RT, s_R);
297  }
298  }
299 
300  virtual void reportParameters(size_t& n, int& type,
301  doublereal& tlow, doublereal& thigh,
302  doublereal& pref,
303  doublereal* const coeffs) const {
304  n = 0;
305  type = SHOMATE2;
306  tlow = m_lowT;
307  thigh = m_highT;
308  pref = m_Pref;
309  for (int i = 0; i < 15; i++) {
310  coeffs[i] = m_coeff[i];
311  }
312  }
313 
314  //! Modify parameters for the standard state
315  /*!
316  * Here, we take the tact that we will just regenerate the object.
317  *
318  * @param coeffs Vector of coefficients used to set the
319  * parameters for the standard state.
320  * @deprecated To be removed after Cantera 2.3. Use
321  * MultiSpeciesThermo::modifySpecies instead.
322  */
323  virtual void modifyParameters(doublereal* coeffs) {
324  warn_deprecated("ShomatePoly2::modifyParameters", "To be removed after "
325  "Cantera 2.3. Use MultiSpeciesThermo::modifySpecies instead.");
326  std::copy(coeffs, coeffs + 15, m_coeff.begin());
327  m_midT = coeffs[0];
328  msp_low = ShomatePoly(m_lowT, m_midT, m_Pref, coeffs+1);
329  msp_high = ShomatePoly(m_midT, m_highT, m_Pref, coeffs+8);
330  }
331 
332  virtual doublereal reportHf298(doublereal* const h298 = 0) const {
333  doublereal h;
334  if (298.15 <= m_midT) {
335  h = msp_low.reportHf298(h298);
336  } else {
337  h = msp_high.reportHf298(h298);
338  }
339  if (h298) {
340  *h298 = h;
341  }
342  return h;
343  }
344 
345  virtual void modifyOneHf298(const size_t k, const doublereal Hf298New) {
346  doublereal h298now = reportHf298(0);
347  doublereal delH = Hf298New - h298now;
348  double h = msp_low.reportHf298(0);
349  double hnew = h + delH;
350  msp_low.modifyOneHf298(k, hnew);
351  h = msp_high.reportHf298(0);
352  hnew = h + delH;
353  msp_high.modifyOneHf298(k, hnew);
354  }
355 
356  virtual void resetHf298() {
359  }
360 
361 protected:
362  //! Midrange temperature (kelvin)
363  doublereal m_midT;
364  //! Shomate polynomial for the low temperature region.
366  //! Shomate polynomial for the high temperature region.
368  //! Array of the original coefficients.
370 };
371 }
372 
373 #endif
doublereal m_midT
Midrange temperature (kelvin)
Definition: ShomatePoly.h:363
virtual size_t temperaturePolySize() const
Number of terms in the temperature polynomial for this parameterization.
Definition: ShomatePoly.h:271
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:99
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:273
virtual int reportType() const
Returns an integer representing the type of parameterization.
Definition: ShomatePoly.h:267
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:300
#define SHOMATE
Two regions of Shomate Polynomials.
virtual SpeciesThermoInterpType * duplMyselfAsSpeciesThermoInterpType() const
Definition: ShomatePoly.h:89
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:345
vector_fp m_coeff
Array of coefficients.
Definition: ShomatePoly.h:187
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:278
virtual void modifyParameters(doublereal *coeffs)
Definition: ShomatePoly.h:161
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:121
ShomatePoly()
Empty constructor.
Definition: ShomatePoly.h:62
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:54
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:289
vector_fp m_coeff
Array of the original coefficients.
Definition: ShomatePoly.h:369
ShomatePoly msp_high
Shomate polynomial for the high temperature region.
Definition: ShomatePoly.h:367
virtual void resetHf298()
Restore the original heat of formation for this species.
Definition: ShomatePoly.h:181
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:175
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:137
virtual SpeciesThermoInterpType * duplMyselfAsSpeciesThermoInterpType() const
Definition: ShomatePoly.h:263
virtual int reportType() const
Returns an integer representing the type of parameterization.
Definition: ShomatePoly.h:93
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:232
doublereal m_highT
Highest valid temperature.
virtual void modifyParameters(doublereal *coeffs)
Modify parameters for the standard state.
Definition: ShomatePoly.h:323
virtual void resetHf298()
Restore the original heat of formation for this species.
Definition: ShomatePoly.h:356
ShomatePoly msp_low
Shomate polynomial for the low temperature region.
Definition: ShomatePoly.h:365
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:145
#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:169
ShomatePoly2(double tlow, double thigh, double pref, const double *coeffs)
Normal constructor.
Definition: ShomatePoly.h:253
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:97
doublereal m_Pref
Reference state pressure.
Namespace for the Cantera kernel.
Definition: application.cpp:29
ShomatePoly2()
Empty constructor.
Definition: ShomatePoly.h:237
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:332
ShomatePoly(double tlow, double thigh, double pref, const double *coeffs)
Normal constructor.
Definition: ShomatePoly.h:78