Cantera 2.6.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
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
11#include "cantera/thermo/ConstCpPoly.h"
12#include "cantera/base/AnyMap.h"
13
14 namespace Cantera
15{
16
17ConstCpPoly::ConstCpPoly()
18 : SpeciesThermoInterpType(0.0, std::numeric_limits<double>::infinity(), 0.0)
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_h0_R_orig(0.0)
25{
26}
27
28ConstCpPoly::ConstCpPoly(double tlow, double thigh, double pref,
29 const double* coeffs) :
30 SpeciesThermoInterpType(tlow, thigh, pref)
31{
32 setParameters(coeffs[0], coeffs[1], coeffs[2], coeffs[3]);
33}
34
35 void ConstCpPoly::setParameters(double t0, double h0, double s0, double cp0)
36{
37 m_t0 = t0;
38 m_logt0 = log(m_t0);
39 m_cp0_R = cp0 / GasConstant;
40 m_h0_R = h0 / GasConstant;
41 m_s0_R = s0 / GasConstant;
42}
43
44 void ConstCpPoly::updateProperties(const doublereal* tt,
45 doublereal* cp_R,
46 doublereal* h_RT,
47 doublereal* s_R) const
48{
49 double t = *tt;
50 doublereal logt = log(t);
51 doublereal rt = 1.0/t;
52 *cp_R = m_cp0_R;
53 *h_RT = rt*(m_h0_R + (t - m_t0) * m_cp0_R);
54 *s_R = m_s0_R + m_cp0_R * (logt - m_logt0);
55}
56
57 void ConstCpPoly::updatePropertiesTemp(const doublereal temp,
58 doublereal* cp_R,
59 doublereal* h_RT,
60 doublereal* s_R) const
61{
62 doublereal logt = log(temp);
63 doublereal rt = 1.0/temp;
64 *cp_R = m_cp0_R;
65 *h_RT = rt*(m_h0_R + (temp - m_t0) * m_cp0_R);
66 *s_R = m_s0_R + m_cp0_R * (logt - m_logt0);
67}
68
69 void ConstCpPoly::reportParameters(size_t& n, int& type,
70 doublereal& tlow, doublereal& thigh,
71 doublereal& pref,
72 doublereal* const coeffs) const
73{
74 n = 0;
75 type = CONSTANT_CP;
76 tlow = m_lowT;
77 thigh = m_highT;
78 pref = m_Pref;
79 coeffs[0] = m_t0;
80 coeffs[1] = m_h0_R * GasConstant;
81 coeffs[2] = m_s0_R * GasConstant;
82 coeffs[3] = m_cp0_R * GasConstant;
83}
84
85 void ConstCpPoly::getParameters(AnyMap& thermo) const
86{
87 thermo["model"] = "constant-cp";
88 SpeciesThermoInterpType::getParameters(thermo);
89 thermo["T0"].setQuantity(m_t0, "K");
90 thermo["h0"].setQuantity(m_h0_R * GasConstant, "J/kmol");
91 thermo["s0"].setQuantity(m_s0_R * GasConstant, "J/kmol/K");
92 thermo["cp0"].setQuantity(m_cp0_R * GasConstant, "J/kmol/K");
93}
94
95doublereal ConstCpPoly::reportHf298(doublereal* const h298) const
96{
97 double temp = 298.15;
98 doublereal h = GasConstant * (m_h0_R + (temp - m_t0) * m_cp0_R);
99 if (h298) {
100 *h298 = h;
101 }
102 return h;
103}
104
105 void ConstCpPoly::modifyOneHf298(const size_t k, const doublereal Hf298New)
106{
107 doublereal hnow = reportHf298();
108 doublereal delH = Hf298New - hnow;
109 m_h0_R += delH / GasConstant;
110}
111
112 void ConstCpPoly::resetHf298() {
113 m_h0_R = m_h0_R_orig;
114}
115
116}
AnyMap.h
ConstCpPoly.h
Headers for the SpeciesThermoInterpType object that employs a constant heat capacity assumption (see ...
Cantera::AnyMap
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:399
Cantera::ConstCpPoly::resetHf298
virtual void resetHf298()
Restore the original heat of formation for this species.
Definition: ConstCpPoly.cpp:112
Cantera::ConstCpPoly::setParameters
void setParameters(double t0, double h0, double s0, double cp0)
Definition: ConstCpPoly.cpp:35
Cantera::ConstCpPoly::m_s0_R
doublereal m_s0_R
Dimensionless value of the entropy at t0.
Definition: ConstCpPoly.h:112
Cantera::ConstCpPoly::modifyOneHf298
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:105
Cantera::ConstCpPoly::reportHf298
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:95
Cantera::ConstCpPoly::getParameters
virtual void getParameters(AnyMap &thermo) const
Store the parameters of the species thermo object such that an identical species thermo object could ...
Definition: ConstCpPoly.cpp:85
Cantera::ConstCpPoly::m_logt0
doublereal m_logt0
log of the t0 value
Definition: ConstCpPoly.h:114
Cantera::ConstCpPoly::updatePropertiesTemp
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:57
Cantera::ConstCpPoly::m_h0_R_orig
double m_h0_R_orig
Original value of h0_R, restored by calling resetHf298()
Definition: ConstCpPoly.h:116
Cantera::ConstCpPoly::m_cp0_R
doublereal m_cp0_R
Dimensionless value of the heat capacity.
Definition: ConstCpPoly.h:108
Cantera::ConstCpPoly::reportParameters
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:69
Cantera::ConstCpPoly::updateProperties
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:44
Cantera::ConstCpPoly::m_h0_R
doublereal m_h0_R
dimensionless value of the enthaply at t0
Definition: ConstCpPoly.h:110
Cantera::ConstCpPoly::m_t0
doublereal m_t0
Base temperature.
Definition: ConstCpPoly.h:106
Cantera::SpeciesThermoInterpType
Abstract Base class for the thermodynamic manager for an individual species' reference state.
Definition: SpeciesThermoInterpType.h:113
Cantera::SpeciesThermoInterpType::getParameters
virtual void getParameters(AnyMap &thermo) const
Store the parameters of the species thermo object such that an identical species thermo object could ...
Definition: SpeciesThermoInterpType.cpp:65
Cantera::SpeciesThermoInterpType::m_lowT
doublereal m_lowT
lowest valid temperature
Definition: SpeciesThermoInterpType.h:286
Cantera::SpeciesThermoInterpType::m_highT
doublereal m_highT
Highest valid temperature.
Definition: SpeciesThermoInterpType.h:288
Cantera::SpeciesThermoInterpType::m_Pref
doublereal m_Pref
Reference state pressure.
Definition: SpeciesThermoInterpType.h:290
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557
Cantera::GasConstant
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition: ct_defs.h:113
CONSTANT_CP
#define CONSTANT_CP
Constant Cp.
Definition: speciesThermoTypes.h:13