| Cantera 3.0.0

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
10#include "cantera/thermo/PDSS_SSVol.h"
11#include "cantera/thermo/VPStandardStateTP.h"
12
13 namespace Cantera
14{
15
16 PDSS_SSVol::PDSS_SSVol()
17 : TCoeff_(4, 0.0)
18{
19}
20
21 void PDSS_SSVol::setVolumePolynomial(double* coeffs) {
22 for (size_t i = 0; i < 4; i++) {
23 TCoeff_[i] = coeffs[i];
24 }
25 volumeModel_ = SSVolume_Model::tpoly;
26}
27
28 void PDSS_SSVol::setDensityPolynomial(double* coeffs) {
29 for (size_t i = 0; i < 4; i++) {
30 TCoeff_[i] = coeffs[i];
31 }
32 volumeModel_ = SSVolume_Model::density_tpoly;
33}
34
35 void PDSS_SSVol::getParameters(AnyMap& eosNode) const
36{
37 PDSS::getParameters(eosNode);
38 vector<AnyValue> data(4);
39 if (volumeModel_ == SSVolume_Model::density_tpoly) {
40 eosNode["model"] = "density-temperature-polynomial";
41 data[0].setQuantity(TCoeff_[0], "kg/m^3");
42 data[1].setQuantity(TCoeff_[1], "kg/m^3/K");
43 data[2].setQuantity(TCoeff_[2], "kg/m^3/K^2");
44 data[3].setQuantity(TCoeff_[3], "kg/m^3/K^3");
45 } else {
46 eosNode["model"] = "molar-volume-temperature-polynomial";
47 data[0].setQuantity(TCoeff_[0], "m^3/kmol");
48 data[1].setQuantity(TCoeff_[1], "m^3/kmol/K");
49 data[2].setQuantity(TCoeff_[2], "m^3/kmol/K^2");
50 data[3].setQuantity(TCoeff_[3], "m^3/kmol/K^3");
51 }
52 eosNode["data"] = std::move(data);
53}
54
55 void PDSS_SSVol::initThermo()
56{
57 PDSS::initThermo();
58 if (m_input.hasKey("model")) {
59 const string& model = m_input["model"].asString();
60 auto& data = m_input["data"].asVector<AnyValue>(4);
61 if (model == "density-temperature-polynomial") {
62 double coeffs[] {
63 m_input.units().convert(data[0], "kg/m^3"),
64 m_input.units().convert(data[1], "kg/m^3/K"),
65 m_input.units().convert(data[2], "kg/m^3/K^2"),
66 m_input.units().convert(data[3], "kg/m^3/K^3"),
67 };
68 setDensityPolynomial(coeffs);
69 } else if (model == "molar-volume-temperature-polynomial") {
70 double coeffs[] {
71 m_input.units().convert(data[0], "m^3/kmol"),
72 m_input.units().convert(data[1], "m^3/kmol/K"),
73 m_input.units().convert(data[2], "m^3/kmol/K^2"),
74 m_input.units().convert(data[3], "m^3/kmol/K^3"),
75 };
76 setVolumePolynomial(coeffs);
77 }
78 }
79 m_minTemp = m_spthermo->minTemp();
80 m_maxTemp = m_spthermo->maxTemp();
81 m_p0 = m_spthermo->refPressure();
82}
83
84 double PDSS_SSVol::intEnergy_mole() const
85{
86 double pV = m_pres * m_Vss;
87 return m_h0_RT * GasConstant * m_temp - pV;
88}
89
90 double PDSS_SSVol::cv_mole() const
91{
92 return (cp_mole() - m_V0);
93}
94
95 void PDSS_SSVol::calcMolarVolume()
96{
97 if (volumeModel_ == SSVolume_Model::tpoly) {
98 m_Vss = TCoeff_[0] + m_temp * (TCoeff_[1] + m_temp * (TCoeff_[2] + m_temp * TCoeff_[3]));
99 m_V0 = m_Vss;
100 dVdT_ = TCoeff_[1] + 2.0 * m_temp * TCoeff_[2] + 3.0 * m_temp * m_temp * TCoeff_[3];
101 d2VdT2_ = 2.0 * TCoeff_[2] + 6.0 * m_temp * TCoeff_[3];
102 } else if (volumeModel_ == SSVolume_Model::density_tpoly) {
103 double dens = TCoeff_[0] + m_temp * (TCoeff_[1] + m_temp * (TCoeff_[2] + m_temp * TCoeff_[3]));
104 m_Vss = m_mw / dens;
105 m_V0 = m_Vss;
106 double dens2 = dens * dens;
107 double ddensdT = TCoeff_[1] + 2.0 * m_temp * TCoeff_[2] + 3.0 * m_temp * m_temp * TCoeff_[3];
108 double d2densdT2 = 2.0 * TCoeff_[2] + 6.0 * m_temp * TCoeff_[3];
109 dVdT_ = - m_mw / dens2 * ddensdT;
110 d2VdT2_ = 2.0 * m_mw / (dens2 * dens) * ddensdT * ddensdT - m_mw / dens2 * d2densdT2;
111 } else {
112 throw NotImplementedError("PDSS_SSVol::calcMolarVolume");
113 }
114}
115
116 void PDSS_SSVol::setPressure(double p)
117{
118 m_pres = p;
119 double deltaP = m_pres - m_p0;
120 if (fabs(deltaP) < 1.0E-10) {
121 m_hss_RT = m_h0_RT;
122 m_sss_R = m_s0_R;
123 m_gss_RT = m_hss_RT - m_sss_R;
124 m_cpss_R = m_cp0_R;
125 } else {
126 double del_pRT = deltaP / (GasConstant * m_temp);
127 double sV_term = - deltaP / GasConstant * dVdT_;
128 m_hss_RT = m_h0_RT + sV_term + del_pRT * m_Vss;
129 m_sss_R = m_s0_R + sV_term;
130 m_gss_RT = m_hss_RT - m_sss_R;
131 m_cpss_R = m_cp0_R - m_temp * deltaP * d2VdT2_;
132 }
133}
134
135 void PDSS_SSVol::setTemperature(double temp)
136{
137 m_temp = temp;
138 m_spthermo->updatePropertiesTemp(temp, &m_cp0_R, &m_h0_RT, &m_s0_R);
139 calcMolarVolume();
140 m_g0_RT = m_h0_RT - m_s0_R;
141 double deltaP = m_pres - m_p0;
142 if (fabs(deltaP) < 1.0E-10) {
143 m_hss_RT = m_h0_RT;
144 m_sss_R = m_s0_R;
145 m_gss_RT = m_hss_RT - m_sss_R;
146 m_cpss_R = m_cp0_R;
147 } else {
148 double del_pRT = deltaP / (GasConstant * m_temp);
149 double sV_term = - deltaP / GasConstant * dVdT_;
150 m_hss_RT = m_h0_RT + sV_term + del_pRT * m_Vss;
151 m_sss_R = m_s0_R + sV_term;
152 m_gss_RT = m_hss_RT - m_sss_R;
153 m_cpss_R = m_cp0_R - m_temp * deltaP * d2VdT2_;
154 }
155}
156
157 void PDSS_SSVol::setState_TP(double temp, double pres)
158{
159 m_pres = pres;
160 setTemperature(temp);
161}
162
163 double PDSS_SSVol::satPressure(double t)
164{
165 return 1.0E-200;
166}
167
168}
PDSS_SSVol.h
Declarations for the class PDSS_SSVol (pressure dependent standard state) which handles calculations ...
VPStandardStateTP.h
Header file for a derived class of ThermoPhase that handles variable pressure standard state methods ...
Cantera::AnyMap
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:427
Cantera::AnyMap::hasKey
bool hasKey(const string &key) const
Returns true if the map contains an item named key.
Definition AnyMap.cpp:1423
Cantera::AnyMap::units
const UnitSystem & units() const
Return the default units that should be used to convert stored values.
Definition AnyMap.h:630
Cantera::AnyValue
A wrapper for a variable whose type is determined at runtime.
Definition AnyMap.h:86
Cantera::NotImplementedError
An error indicating that an unimplemented function has been called.
Definition ctexceptions.h:195
Cantera::PDSS_Nondimensional::m_sss_R
double m_sss_R
Standard state entropy divided by R.
Definition PDSS.h:516
Cantera::PDSS_Nondimensional::m_cpss_R
double m_cpss_R
Standard state heat capacity divided by R.
Definition PDSS.h:515
Cantera::PDSS_Nondimensional::m_h0_RT
double m_h0_RT
Reference state enthalpy divided by RT.
Definition PDSS.h:509
Cantera::PDSS_Nondimensional::m_g0_RT
double m_g0_RT
Reference state Gibbs free energy divided by RT.
Definition PDSS.h:512
Cantera::PDSS_Nondimensional::m_s0_R
double m_s0_R
Reference state entropy divided by R.
Definition PDSS.h:511
Cantera::PDSS_Nondimensional::m_gss_RT
double m_gss_RT
Standard state Gibbs free energy divided by RT.
Definition PDSS.h:517
Cantera::PDSS_Nondimensional::m_cp0_R
double m_cp0_R
Reference state heat capacity divided by R.
Definition PDSS.h:510
Cantera::PDSS_Nondimensional::cp_mole
double cp_mole() const override
Return the molar const pressure heat capacity in units of J kmol-1 K-1.
Definition PDSS.cpp:256
Cantera::PDSS_Nondimensional::m_Vss
double m_Vss
Standard State molar volume (m^3/kmol)
Definition PDSS.h:518
Cantera::PDSS_Nondimensional::m_hss_RT
double m_hss_RT
Standard state enthalpy divided by RT.
Definition PDSS.h:514
Cantera::PDSS_Nondimensional::m_V0
double m_V0
Reference state molar volume (m^3/kmol)
Definition PDSS.h:513
Cantera::PDSS_SSVol::setPressure
void setPressure(double pres) override
Sets the pressure in the object.
Definition PDSS_SSVol.cpp:116
Cantera::PDSS_SSVol::setTemperature
void setTemperature(double temp) override
Set the internal temperature.
Definition PDSS_SSVol.cpp:135
Cantera::PDSS_SSVol::dVdT_
double dVdT_
Derivative of the volume wrt temperature.
Definition PDSS_SSVol.h:189
Cantera::PDSS_SSVol::setDensityPolynomial
void setDensityPolynomial(double *coeffs)
Set polynomial coefficients for the standard state density as a function of temperature.
Definition PDSS_SSVol.cpp:28
Cantera::PDSS_SSVol::setVolumePolynomial
void setVolumePolynomial(double *coeffs)
Set polynomial coefficients for the standard state molar volume as a function of temperature.
Definition PDSS_SSVol.cpp:21
Cantera::PDSS_SSVol::initThermo
void initThermo() override
Initialization routine.
Definition PDSS_SSVol.cpp:55
Cantera::PDSS_SSVol::cv_mole
double cv_mole() const override
Return the molar const volume heat capacity in units of J kmol-1 K-1.
Definition PDSS_SSVol.cpp:90
Cantera::PDSS_SSVol::PDSS_SSVol
PDSS_SSVol()
Default Constructor.
Definition PDSS_SSVol.cpp:16
Cantera::PDSS_SSVol::getParameters
void getParameters(AnyMap &eosNode) const override
Store the parameters needed to reconstruct a copy of this PDSS object.
Definition PDSS_SSVol.cpp:35
Cantera::PDSS_SSVol::TCoeff_
vector< double > TCoeff_
coefficients for the temperature representation
Definition PDSS_SSVol.h:186
Cantera::PDSS_SSVol::intEnergy_mole
double intEnergy_mole() const override
Return the molar internal Energy in units of J kmol-1.
Definition PDSS_SSVol.cpp:84
Cantera::PDSS_SSVol::setState_TP
void setState_TP(double temp, double pres) override
Set the internal temperature and pressure.
Definition PDSS_SSVol.cpp:157
Cantera::PDSS_SSVol::SSVolume_Model::tpoly
@ tpoly
This approximation is for a species with a cubic polynomial in temperature.
Cantera::PDSS_SSVol::SSVolume_Model::density_tpoly
@ density_tpoly
This approximation is for a species where the density is expressed as a cubic polynomial in temperatu...
Cantera::PDSS_SSVol::calcMolarVolume
void calcMolarVolume()
Does the internal calculation of the volume.
Definition PDSS_SSVol.cpp:95
Cantera::PDSS_SSVol::d2VdT2_
double d2VdT2_
2nd derivative of the volume wrt temperature
Definition PDSS_SSVol.h:192
Cantera::PDSS_SSVol::volumeModel_
SSVolume_Model volumeModel_
Enumerated data type describing the type of volume model used to calculate the standard state volume ...
Definition PDSS_SSVol.h:183
Cantera::PDSS_SSVol::satPressure
double satPressure(double t) override
saturation pressure
Definition PDSS_SSVol.cpp:163
Cantera::PDSS::initThermo
virtual void initThermo()
Initialization routine.
Definition PDSS.h:418
Cantera::PDSS::m_p0
double m_p0
Reference state pressure of the species.
Definition PDSS.h:455
Cantera::PDSS::m_temp
double m_temp
Current temperature used by the PDSS object.
Definition PDSS.h:449
Cantera::PDSS::m_spthermo
shared_ptr< SpeciesThermoInterpType > m_spthermo
Pointer to the species thermodynamic property manager.
Definition PDSS.h:472
Cantera::PDSS::m_pres
double m_pres
State of the system - pressure.
Definition PDSS.h:452
Cantera::PDSS::m_maxTemp
double m_maxTemp
Maximum temperature.
Definition PDSS.h:461
Cantera::PDSS::m_minTemp
double m_minTemp
Minimum temperature.
Definition PDSS.h:458
Cantera::PDSS::m_mw
double m_mw
Molecular Weight of the species.
Definition PDSS.h:464
Cantera::PDSS::m_input
AnyMap m_input
Input data supplied via setParameters.
Definition PDSS.h:468
Cantera::PDSS::getParameters
virtual void getParameters(AnyMap &eosNode) const
Store the parameters needed to reconstruct a copy of this PDSS object.
Definition PDSS.h:427
Cantera::UnitSystem::convert
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:538
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