Cantera  4.0.0a1
Loading...
Searching...
No Matches
PDSS_SSVol.cpp
Go to the documentation of this file.
1/**
2 * @file PDSS_SSVol.cpp
3 * Implementation of a pressure dependent standard state
4 * virtual function.
5 */
6
7// This file is part of Cantera. See License.txt in the top-level directory or
8// at https://cantera.org/license.txt for license and copyright information.
9
12
13namespace Cantera
14{
15
17 : TCoeff_(4, 0.0)
18{
19}
20
21void PDSS_SSVol::setVolumePolynomial(span<const double> coeffs) {
22 checkArraySize("PDSS_SSVol::setVolumePolynomial", coeffs.size(), 4);
23 for (size_t i = 0; i < 4; i++) {
24 TCoeff_[i] = coeffs[i];
25 }
27}
28
29void PDSS_SSVol::setDensityPolynomial(span<const double> coeffs) {
30 checkArraySize("PDSS_SSVol::setDensityPolynomial", coeffs.size(), 4);
31 for (size_t i = 0; i < 4; i++) {
32 TCoeff_[i] = coeffs[i];
33 }
35}
36
38{
39 PDSS::getParameters(eosNode);
40 vector<AnyValue> data(4);
42 eosNode["model"] = "density-temperature-polynomial";
43 data[0].setQuantity(TCoeff_[0], "kg/m^3");
44 data[1].setQuantity(TCoeff_[1], "kg/m^3/K");
45 data[2].setQuantity(TCoeff_[2], "kg/m^3/K^2");
46 data[3].setQuantity(TCoeff_[3], "kg/m^3/K^3");
47 } else {
48 eosNode["model"] = "molar-volume-temperature-polynomial";
49 data[0].setQuantity(TCoeff_[0], "m^3/kmol");
50 data[1].setQuantity(TCoeff_[1], "m^3/kmol/K");
51 data[2].setQuantity(TCoeff_[2], "m^3/kmol/K^2");
52 data[3].setQuantity(TCoeff_[3], "m^3/kmol/K^3");
53 }
54 eosNode["data"] = std::move(data);
55}
56
58{
60 if (m_input.hasKey("model")) {
61 const string& model = m_input["model"].asString();
62 auto& data = m_input["data"].asVector<AnyValue>(4);
63 if (model == "density-temperature-polynomial") {
64 std::array coeffs{
65 m_input.units().convert(data[0], "kg/m^3"),
66 m_input.units().convert(data[1], "kg/m^3/K"),
67 m_input.units().convert(data[2], "kg/m^3/K^2"),
68 m_input.units().convert(data[3], "kg/m^3/K^3"),
69 };
71 } else if (model == "molar-volume-temperature-polynomial") {
72 std::array coeffs{
73 m_input.units().convert(data[0], "m^3/kmol"),
74 m_input.units().convert(data[1], "m^3/kmol/K"),
75 m_input.units().convert(data[2], "m^3/kmol/K^2"),
76 m_input.units().convert(data[3], "m^3/kmol/K^3"),
77 };
78 setVolumePolynomial(coeffs);
79 }
80 }
81 m_minTemp = m_spthermo->minTemp();
82 m_maxTemp = m_spthermo->maxTemp();
83 m_p0 = m_spthermo->refPressure();
84}
85
87{
88 double pV = m_pres * m_Vss;
89 return m_h0_RT * GasConstant * m_temp - pV;
90}
91
92double PDSS_SSVol::cv_mole() const
93{
94 return (cp_mole() - m_V0);
95}
96
98{
100 m_Vss = TCoeff_[0] + m_temp * (TCoeff_[1] + m_temp * (TCoeff_[2] + m_temp * TCoeff_[3]));
101 m_V0 = m_Vss;
102 dVdT_ = TCoeff_[1] + 2.0 * m_temp * TCoeff_[2] + 3.0 * m_temp * m_temp * TCoeff_[3];
103 d2VdT2_ = 2.0 * TCoeff_[2] + 6.0 * m_temp * TCoeff_[3];
105 double dens = TCoeff_[0] + m_temp * (TCoeff_[1] + m_temp * (TCoeff_[2] + m_temp * TCoeff_[3]));
106 m_Vss = m_mw / dens;
107 m_V0 = m_Vss;
108 double dens2 = dens * dens;
109 double ddensdT = TCoeff_[1] + 2.0 * m_temp * TCoeff_[2] + 3.0 * m_temp * m_temp * TCoeff_[3];
110 double d2densdT2 = 2.0 * TCoeff_[2] + 6.0 * m_temp * TCoeff_[3];
111 dVdT_ = - m_mw / dens2 * ddensdT;
112 d2VdT2_ = 2.0 * m_mw / (dens2 * dens) * ddensdT * ddensdT - m_mw / dens2 * d2densdT2;
113 } else {
114 throw NotImplementedError("PDSS_SSVol::calcMolarVolume");
115 }
116}
117
119{
120 m_pres = p;
121 double deltaP = m_pres - m_p0;
122 if (fabs(deltaP) < 1.0E-10) {
124 m_sss_R = m_s0_R;
127 } else {
128 double del_pRT = deltaP / (GasConstant * m_temp);
129 double sV_term = - deltaP / GasConstant * dVdT_;
130 m_hss_RT = m_h0_RT + sV_term + del_pRT * m_Vss;
131 m_sss_R = m_s0_R + sV_term;
133 m_cpss_R = m_cp0_R - m_temp * deltaP * d2VdT2_;
134 }
135}
136
138{
139 m_temp = temp;
140 m_spthermo->updatePropertiesTemp(temp, m_cp0_R, m_h0_RT, m_s0_R);
143 double deltaP = m_pres - m_p0;
144 if (fabs(deltaP) < 1.0E-10) {
146 m_sss_R = m_s0_R;
149 } else {
150 double del_pRT = deltaP / (GasConstant * m_temp);
151 double sV_term = - deltaP / GasConstant * dVdT_;
152 m_hss_RT = m_h0_RT + sV_term + del_pRT * m_Vss;
153 m_sss_R = m_s0_R + sV_term;
155 m_cpss_R = m_cp0_R - m_temp * deltaP * d2VdT2_;
156 }
157}
158
159void PDSS_SSVol::setState_TP(double temp, double pres)
160{
161 m_pres = pres;
162 setTemperature(temp);
163}
164
166{
167 return 1.0E-200;
168}
169
170}
Declarations for the class PDSS_SSVol (pressure dependent standard state) which handles calculations ...
Header file for a derived class of ThermoPhase that handles variable pressure standard state methods ...
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:431
bool hasKey(const string &key) const
Returns true if the map contains an item named key.
Definition AnyMap.cpp:1477
const UnitSystem & units() const
Return the default units that should be used to convert stored values.
Definition AnyMap.h:640
A wrapper for a variable whose type is determined at runtime.
Definition AnyMap.h:88
An error indicating that an unimplemented function has been called.
double m_sss_R
Standard state entropy divided by R.
Definition PDSS.h:465
double m_cpss_R
Standard state heat capacity divided by R.
Definition PDSS.h:464
double m_h0_RT
Reference state enthalpy divided by RT.
Definition PDSS.h:458
double m_g0_RT
Reference state Gibbs free energy divided by RT.
Definition PDSS.h:461
double m_s0_R
Reference state entropy divided by R.
Definition PDSS.h:460
double m_gss_RT
Standard state Gibbs free energy divided by RT.
Definition PDSS.h:466
double m_cp0_R
Reference state heat capacity divided by R.
Definition PDSS.h:459
double cp_mole() const override
Return the molar const pressure heat capacity in units of J kmol-1 K-1.
Definition PDSS.cpp:215
double m_Vss
Standard State molar volume (m^3/kmol)
Definition PDSS.h:467
double m_hss_RT
Standard state enthalpy divided by RT.
Definition PDSS.h:463
double m_V0
Reference state molar volume (m^3/kmol)
Definition PDSS.h:462
void setPressure(double pres) override
Sets the pressure in the object.
void setTemperature(double temp) override
Set the internal temperature.
double dVdT_
Derivative of the volume wrt temperature.
Definition PDSS_SSVol.h:188
void initThermo() override
Initialization routine.
double cv_mole() const override
Return the molar const volume heat capacity in units of J kmol-1 K-1.
PDSS_SSVol()
Default Constructor.
void getParameters(AnyMap &eosNode) const override
Store the parameters needed to reconstruct a copy of this PDSS object.
vector< double > TCoeff_
coefficients for the temperature representation
Definition PDSS_SSVol.h:185
double intEnergy_mole() const override
Return the molar internal Energy in units of J kmol-1.
void setState_TP(double temp, double pres) override
Set the internal temperature and pressure.
@ tpoly
This approximation is for a species with a cubic polynomial in temperature.
@ density_tpoly
This approximation is for a species where the density is expressed as a cubic polynomial in temperatu...
void calcMolarVolume()
Does the internal calculation of the volume.
void setDensityPolynomial(span< const double > coeffs)
Set polynomial coefficients for the standard state density as a function of temperature.
void setVolumePolynomial(span< const double > coeffs)
Set polynomial coefficients for the standard state molar volume as a function of temperature.
double d2VdT2_
2nd derivative of the volume wrt temperature
Definition PDSS_SSVol.h:191
SSVolume_Model volumeModel_
Enumerated data type describing the type of volume model used to calculate the standard state volume ...
Definition PDSS_SSVol.h:182
double satPressure(double t) override
saturation pressure
virtual void initThermo()
Initialization routine.
Definition PDSS.h:383
double m_p0
Reference state pressure of the species.
Definition PDSS.h:404
double m_temp
Current temperature used by the PDSS object.
Definition PDSS.h:398
shared_ptr< SpeciesThermoInterpType > m_spthermo
Pointer to the species thermodynamic property manager.
Definition PDSS.h:421
double m_pres
State of the system - pressure.
Definition PDSS.h:401
double m_maxTemp
Maximum temperature.
Definition PDSS.h:410
double m_minTemp
Minimum temperature.
Definition PDSS.h:407
double m_mw
Molecular Weight of the species.
Definition PDSS.h:413
AnyMap m_input
Input data supplied via setParameters.
Definition PDSS.h:417
virtual void getParameters(AnyMap &eosNode) const
Store the parameters needed to reconstruct a copy of this PDSS object.
Definition PDSS.h:392
double convert(double value, const string &src, const string &dest) const
Convert value from the units of src to the units of dest.
Definition Units.cpp:539
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.