Cantera  2.5.1
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 
8 // This file is part of Cantera. See License.txt in the top-level directory or
9 // at https://cantera.org/license.txt for license and copyright information.
10 
12 
13 namespace Cantera
14 {
15 
16 ConstCpPoly::ConstCpPoly()
17  : SpeciesThermoInterpType(0.0, std::numeric_limits<double>::infinity(), 0.0)
18  , m_t0(0.0)
19  , m_cp0_R(0.0)
20  , m_h0_R(0.0)
21  , m_s0_R(0.0)
22  , m_logt0(0.0)
23  , m_h0_R_orig(0.0)
24 {
25 }
26 
27 ConstCpPoly::ConstCpPoly(double tlow, double thigh, double pref,
28  const double* coeffs) :
29  SpeciesThermoInterpType(tlow, thigh, pref)
30 {
31  setParameters(coeffs[0], coeffs[1], coeffs[2], coeffs[3]);
32 }
33 
34 void ConstCpPoly::setParameters(double t0, double h0, double s0, double cp0)
35 {
36  m_t0 = t0;
37  m_logt0 = log(m_t0);
38  m_cp0_R = cp0 / GasConstant;
39  m_h0_R = h0 / GasConstant;
40  m_s0_R = s0 / GasConstant;
41 }
42 
43 void ConstCpPoly::updateProperties(const doublereal* tt,
44  doublereal* cp_R,
45  doublereal* h_RT,
46  doublereal* s_R) const
47 {
48  double t = *tt;
49  doublereal logt = log(t);
50  doublereal rt = 1.0/t;
51  *cp_R = m_cp0_R;
52  *h_RT = rt*(m_h0_R + (t - m_t0) * m_cp0_R);
53  *s_R = m_s0_R + m_cp0_R * (logt - m_logt0);
54 }
55 
56 void ConstCpPoly::updatePropertiesTemp(const doublereal temp,
57  doublereal* cp_R,
58  doublereal* h_RT,
59  doublereal* s_R) const
60 {
61  doublereal logt = log(temp);
62  doublereal rt = 1.0/temp;
63  *cp_R = m_cp0_R;
64  *h_RT = rt*(m_h0_R + (temp - m_t0) * m_cp0_R);
65  *s_R = m_s0_R + m_cp0_R * (logt - m_logt0);
66 }
67 
68 void ConstCpPoly::reportParameters(size_t& n, int& type,
69  doublereal& tlow, doublereal& thigh,
70  doublereal& pref,
71  doublereal* const coeffs) const
72 {
73  n = 0;
74  type = CONSTANT_CP;
75  tlow = m_lowT;
76  thigh = m_highT;
77  pref = m_Pref;
78  coeffs[0] = m_t0;
79  coeffs[1] = m_h0_R * GasConstant;
80  coeffs[2] = m_s0_R * GasConstant;
81  coeffs[3] = m_cp0_R * GasConstant;
82 }
83 
84 doublereal ConstCpPoly::reportHf298(doublereal* const h298) const
85 {
86  double temp = 298.15;
87  doublereal h = GasConstant * (m_h0_R + (temp - m_t0) * m_cp0_R);
88  if (h298) {
89  *h298 = h;
90  }
91  return h;
92 }
93 
94 void ConstCpPoly::modifyOneHf298(const size_t k, const doublereal Hf298New)
95 {
96  doublereal hnow = reportHf298();
97  doublereal delH = Hf298New - hnow;
98  m_h0_R += delH / GasConstant;
99 }
100 
103 }
104 
105 }
Headers for the SpeciesThermoInterpType object that employs a constant heat capacity assumption (see ...
virtual void resetHf298()
Restore the original heat of formation for this species.
void setParameters(double t0, double h0, double s0, double cp0)
Definition: ConstCpPoly.cpp:34
doublereal m_s0_R
Dimensionless value of the entropy at t0.
Definition: ConstCpPoly.h:109
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: ConstCpPoly.cpp:94
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: ConstCpPoly.cpp:84
doublereal m_logt0
log of the t0 value
Definition: ConstCpPoly.h:111
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:56
double m_h0_R_orig
Original value of h0_R, restored by calling resetHf298()
Definition: ConstCpPoly.h:113
doublereal m_cp0_R
Dimensionless value of the heat capacity.
Definition: ConstCpPoly.h:105
void reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal *const coeffs) const
This utility function returns the type of parameterization and all of the parameters for the species.
Definition: ConstCpPoly.cpp:68
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:43
doublereal m_h0_R
dimensionless value of the enthaply at t0
Definition: ConstCpPoly.h:107
doublereal m_t0
Base temperature.
Definition: ConstCpPoly.h:103
Abstract Base class for the thermodynamic manager for an individual species' reference state.
doublereal m_lowT
lowest valid temperature
doublereal m_highT
Highest valid temperature.
doublereal m_Pref
Reference state pressure.
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition: ct_defs.h:109
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264
#define CONSTANT_CP
Constant Cp.