Cantera  4.0.0a1
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
12#include "cantera/base/AnyMap.h"
13
14namespace 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 span<const double> coeffs) :
24 SpeciesThermoInterpType(tlow, thigh, pref)
25{
26 checkArraySize("ConstCpPoly::ConstCpPoly", coeffs.size(), 4);
27 setParameters(coeffs[0], coeffs[1], coeffs[2], coeffs[3]);
28}
29
30void ConstCpPoly::setParameters(double t0, double h0, double s0, double cp0)
31{
32 m_t0 = t0;
33 m_logt0 = log(m_t0);
34 m_cp0_R = cp0 / GasConstant;
35 m_h0_R = h0 / GasConstant;
36 m_s0_R = s0 / GasConstant;
37}
38
39void ConstCpPoly::updateProperties(span<const double> tt, double& cp_R,
40 double& h_RT, double& s_R) const
41{
42 double t = tt[0];
43 double logt = log(t);
44 double rt = 1.0/t;
45 cp_R = m_cp0_R;
46 h_RT = rt*(m_h0_R + (t - m_t0) * m_cp0_R);
47 s_R = m_s0_R + m_cp0_R * (logt - m_logt0);
48}
49
50void ConstCpPoly::updatePropertiesTemp(const double temp, double& cp_R,
51 double& h_RT, double& s_R) const
52{
53 double logt = log(temp);
54 double rt = 1.0/temp;
55 cp_R = m_cp0_R;
56 h_RT = rt*(m_h0_R + (temp - m_t0) * m_cp0_R);
57 s_R = m_s0_R + m_cp0_R * (logt - m_logt0);
58}
59
60void ConstCpPoly::reportParameters(size_t& n, int& type, double& tlow, double& thigh,
61 double& pref, span<double> coeffs) const
62{
63 checkArraySize("ConstCpPoly::reportParameters", coeffs.size(), 4);
64 n = 0;
65 type = CONSTANT_CP;
66 tlow = m_lowT;
67 thigh = m_highT;
68 pref = m_Pref;
69 coeffs[0] = m_t0;
70 coeffs[1] = m_h0_R * GasConstant;
71 coeffs[2] = m_s0_R * GasConstant;
72 coeffs[3] = m_cp0_R * GasConstant;
73}
74
76{
77 thermo["model"] = "constant-cp";
79 thermo["T0"].setQuantity(m_t0, "K");
80 thermo["h0"].setQuantity(m_h0_R * GasConstant, "J/kmol");
81 thermo["s0"].setQuantity(m_s0_R * GasConstant, "J/kmol/K");
82 thermo["cp0"].setQuantity(m_cp0_R * GasConstant, "J/kmol/K");
83}
84
86{
87 double temp = 298.15;
88 return GasConstant * (m_h0_R + (temp - m_t0) * m_cp0_R);
89}
90
91void ConstCpPoly::modifyOneHf298(const size_t k, const double Hf298New)
92{
93 double hnow = reportHf298();
94 double delH = Hf298New - hnow;
95 m_h0_R += delH / GasConstant;
96}
97
100}
101
102}
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:431
double m_t0
Base temperature.
Definition ConstCpPoly.h:99
double m_h0_R
dimensionless value of the enthalpy at t0
void updatePropertiesTemp(const double temp, double &cp_R, double &h_RT, double &s_R) const override
Compute the reference-state property of one species.
void getParameters(AnyMap &thermo) const override
Store the parameters of the species thermo object such that an identical species thermo object could ...
void setParameters(double t0, double h0, double s0, double cp0)
Set ConstCpPoly parameters.
void reportParameters(size_t &n, int &type, double &tlow, double &thigh, double &pref, span< double > coeffs) const override
This utility function returns the type of parameterization and all of the parameters for the species.
double m_s0_R
Dimensionless value of the entropy at t0.
double m_h0_R_orig
Original value of h0_R, restored by calling resetHf298()
double reportHf298() const override
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1)
double m_cp0_R
Dimensionless value of the heat capacity.
void resetHf298() override
Restore the original heat of formation for this species.
double m_logt0
log of the t0 value
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)
void updateProperties(span< const double > tt, double &cp_R, double &h_RT, double &s_R) const override
Update the properties for this species, given a temperature polynomial.
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:123
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
void checkArraySize(const char *procedure, size_t available, size_t required)
Wrapper for throwing ArraySizeError.
#define CONSTANT_CP
Constant Cp.