| Cantera 3.0.0

Loading...
Searching...
No Matches
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{
20}
21
22ConstCpPoly::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
77 void ConstCpPoly::getParameters(AnyMap& thermo) const
78{
79 thermo["model"] = "constant-cp";
80 SpeciesThermoInterpType::getParameters(thermo);
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
104 void ConstCpPoly::resetHf298() {
105 m_h0_R = m_h0_R_orig;
106}
107
108}
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:427
Cantera::ConstCpPoly::m_t0
double m_t0
Base temperature.
Definition ConstCpPoly.h:99
Cantera::ConstCpPoly::m_h0_R
double m_h0_R
dimensionless value of the enthalpy at t0
Definition ConstCpPoly.h:103
Cantera::ConstCpPoly::getParameters
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
Cantera::ConstCpPoly::setParameters
void setParameters(double t0, double h0, double s0, double cp0)
Set ConstCpPoly parameters.
Definition ConstCpPoly.cpp:29
Cantera::ConstCpPoly::reportParameters
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
Cantera::ConstCpPoly::m_s0_R
double m_s0_R
Dimensionless value of the entropy at t0.
Definition ConstCpPoly.h:105
Cantera::ConstCpPoly::m_h0_R_orig
double m_h0_R_orig
Original value of h0_R, restored by calling resetHf298()
Definition ConstCpPoly.h:109
Cantera::ConstCpPoly::m_cp0_R
double m_cp0_R
Dimensionless value of the heat capacity.
Definition ConstCpPoly.h:101
Cantera::ConstCpPoly::updateProperties
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
Cantera::ConstCpPoly::reportHf298
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
Cantera::ConstCpPoly::resetHf298
void resetHf298() override
Restore the original heat of formation for this species.
Definition ConstCpPoly.cpp:104
Cantera::ConstCpPoly::m_logt0
double m_logt0
log of the t0 value
Definition ConstCpPoly.h:107
Cantera::ConstCpPoly::modifyOneHf298
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
Cantera::ConstCpPoly::updatePropertiesTemp
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
Cantera::SpeciesThermoInterpType
Abstract Base class for the thermodynamic manager for an individual species' reference state.
Definition SpeciesThermoInterpType.h:113
Cantera::SpeciesThermoInterpType::m_Pref
double m_Pref
Reference state pressure.
Definition SpeciesThermoInterpType.h:288
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:58
Cantera::SpeciesThermoInterpType::m_lowT
double m_lowT
lowest valid temperature
Definition SpeciesThermoInterpType.h:284
Cantera::SpeciesThermoInterpType::m_highT
double m_highT
Highest valid temperature.
Definition SpeciesThermoInterpType.h:286
Cantera::GasConstant
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition ct_defs.h:120
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
CONSTANT_CP
#define CONSTANT_CP
Constant Cp.
Definition speciesThermoTypes.h:13