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