Cantera 2.6.0

PDSS_ConstVol.cpp
Go to the documentation of this file.
1/**
2 * @file PDSS_ConstVol.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/base/ctml.h"
11#include "cantera/thermo/PDSS_ConstVol.h"
12#include "cantera/thermo/VPStandardStateTP.h"
13
14 using namespace std;
15
16 namespace Cantera
17{
18
19 PDSS_ConstVol::PDSS_ConstVol()
20{
21}
22
23 void PDSS_ConstVol::setParametersFromXML(const XML_Node& speciesNode)
24{
25 PDSS::setParametersFromXML(speciesNode);
26
27 const XML_Node* ss = speciesNode.findByName("standardState");
28 if (!ss) {
29 throw CanteraError("PDSS_ConstVol::setParametersFromXML",
30 "no standardState Node for species '{}'",
31 speciesNode.name());
32 }
33 if (ss->attrib("model") != "constant_incompressible") {
34 throw CanteraError("PDSS_ConstVol::setParametersFromXML",
35 "standardState model for species '{}' isn't "
36 "'constant_incompressible'", speciesNode.name());
37 }
38
39 setMolarVolume(getFloat(*ss, "molarVolume", "toSI"));
40}
41
42 void PDSS_ConstVol::initThermo()
43{
44 PDSS::initThermo();
45 if (m_input.hasKey("molar-volume")) {
46 setMolarVolume(m_input.convert("molar-volume", "m^3/kmol"));
47 }
48 m_minTemp = m_spthermo->minTemp();
49 m_maxTemp = m_spthermo->maxTemp();
50 m_p0 = m_spthermo->refPressure();
51 m_V0 = m_constMolarVolume;
52 m_Vss = m_constMolarVolume;
53}
54
55 void PDSS_ConstVol::getParameters(AnyMap &eosNode) const
56{
57 PDSS::getParameters(eosNode);
58 eosNode["model"] = "constant-volume";
59 eosNode["molar-volume"].setQuantity(m_constMolarVolume, "m^3/kmol");
60}
61
62doublereal PDSS_ConstVol::intEnergy_mole() const
63{
64 doublereal pV = (m_pres * m_Vss);
65 return m_h0_RT * GasConstant * m_temp - pV;
66}
67
68doublereal PDSS_ConstVol::cv_mole() const
69{
70 return (cp_mole() - m_V0);
71}
72
73 void PDSS_ConstVol::setPressure(doublereal p)
74{
75 m_pres = p;
76 doublereal del_pRT = (m_pres - m_p0) / (GasConstant * m_temp);
77 m_hss_RT = m_h0_RT + del_pRT * m_Vss;
78 m_gss_RT = m_hss_RT - m_sss_R;
79}
80
81 void PDSS_ConstVol::setTemperature(doublereal temp)
82{
83 m_temp = temp;
84 m_spthermo->updatePropertiesTemp(temp, &m_cp0_R, &m_h0_RT, &m_s0_R);
85 m_g0_RT = m_h0_RT - m_s0_R;
86
87 doublereal del_pRT = (m_pres - m_p0) / (GasConstant * m_temp);
88
89 m_hss_RT = m_h0_RT + del_pRT * m_Vss;
90 m_cpss_R = m_cp0_R;
91 m_sss_R = m_s0_R;
92 m_gss_RT = m_hss_RT - m_sss_R;
93}
94
95 void PDSS_ConstVol::setState_TP(doublereal temp, doublereal pres)
96{
97 setTemperature(temp);
98 setPressure(pres);
99}
100
101 void PDSS_ConstVol::setState_TR(doublereal temp, doublereal rho)
102{
103 doublereal rhoStored = m_mw / m_constMolarVolume;
104 if (fabs(rhoStored - rho) / (rhoStored + rho) > 1.0E-4) {
105 throw CanteraError("PDSS_ConstVol::setState_TR",
106 "Inconsistent supplied rho");
107 }
108 setTemperature(temp);
109}
110
111doublereal PDSS_ConstVol::satPressure(doublereal t)
112{
113 return 1.0E-200;
114}
115
116}
PDSS_ConstVol.h
Declarations for the class PDSS_ConstVol (pressure dependent standard state) which handles calculatio...
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:399
Cantera::AnyMap::convert
double convert(const std::string &key, const std::string &units) const
Convert the item stored by the given key to the units specified in units.
Definition: AnyMap.cpp:1508
Cantera::AnyMap::hasKey
bool hasKey(const std::string &key) const
Returns true if the map contains an item named key.
Definition: AnyMap.cpp:1406
Cantera::CanteraError
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
Cantera::PDSS_ConstVol::PDSS_ConstVol
PDSS_ConstVol()
Default Constructor.
Definition: PDSS_ConstVol.cpp:19
Cantera::PDSS_ConstVol::getParameters
virtual void getParameters(AnyMap &eosNode) const
Store the parameters needed to reconstruct a copy of this PDSS object.
Definition: PDSS_ConstVol.cpp:55
Cantera::PDSS_ConstVol::setPressure
virtual void setPressure(doublereal pres)
Sets the pressure in the object.
Definition: PDSS_ConstVol.cpp:73
Cantera::PDSS_ConstVol::setState_TP
virtual void setState_TP(doublereal temp, doublereal pres)
Set the internal temperature and pressure.
Definition: PDSS_ConstVol.cpp:95
Cantera::PDSS_ConstVol::cv_mole
virtual doublereal cv_mole() const
Return the molar const volume heat capacity in units of J kmol-1 K-1.
Definition: PDSS_ConstVol.cpp:68
Cantera::PDSS_ConstVol::setTemperature
virtual void setTemperature(doublereal temp)
Set the internal temperature.
Definition: PDSS_ConstVol.cpp:81
Cantera::PDSS_ConstVol::setMolarVolume
void setMolarVolume(double v)
Set the (constant) molar volume [m3/kmol] of the species.
Definition: PDSS_ConstVol.h:56
Cantera::PDSS_ConstVol::initThermo
virtual void initThermo()
Initialization routine.
Definition: PDSS_ConstVol.cpp:42
Cantera::PDSS_ConstVol::m_constMolarVolume
doublereal m_constMolarVolume
Value of the constant molar volume for the species.
Definition: PDSS_ConstVol.h:67
Cantera::PDSS_ConstVol::setParametersFromXML
virtual void setParametersFromXML(const XML_Node &speciesNode)
Initialization routine for the PDSS object based on the speciesNode.
Definition: PDSS_ConstVol.cpp:23
Cantera::PDSS_ConstVol::setState_TR
virtual void setState_TR(doublereal temp, doublereal rho)
Set the internal temperature and density.
Definition: PDSS_ConstVol.cpp:101
Cantera::PDSS_ConstVol::satPressure
virtual doublereal satPressure(doublereal t)
saturation pressure
Definition: PDSS_ConstVol.cpp:111
Cantera::PDSS_ConstVol::intEnergy_mole
virtual doublereal intEnergy_mole() const
Return the molar internal Energy in units of J kmol-1.
Definition: PDSS_ConstVol.cpp:62
Cantera::PDSS_Nondimensional::m_sss_R
double m_sss_R
Standard state entropy divided by R.
Definition: PDSS.h:522
Cantera::PDSS_Nondimensional::cp_mole
virtual doublereal cp_mole() const
Return the molar const pressure heat capacity in units of J kmol-1 K-1.
Definition: PDSS.cpp:262
Cantera::PDSS_Nondimensional::m_cpss_R
double m_cpss_R
Standard state heat capacity divided by R.
Definition: PDSS.h:521
Cantera::PDSS_Nondimensional::m_h0_RT
double m_h0_RT
Reference state enthalpy divided by RT.
Definition: PDSS.h:515
Cantera::PDSS_Nondimensional::m_g0_RT
double m_g0_RT
Reference state Gibbs free energy divided by RT.
Definition: PDSS.h:518
Cantera::PDSS_Nondimensional::m_s0_R
double m_s0_R
Reference state entropy divided by R.
Definition: PDSS.h:517
Cantera::PDSS_Nondimensional::m_gss_RT
double m_gss_RT
Standard state Gibbs free energy divided by RT.
Definition: PDSS.h:523
Cantera::PDSS_Nondimensional::m_cp0_R
double m_cp0_R
Reference state heat capacity divided by R.
Definition: PDSS.h:516
Cantera::PDSS_Nondimensional::m_Vss
double m_Vss
Standard State molar volume (m^3/kmol)
Definition: PDSS.h:524
Cantera::PDSS_Nondimensional::m_hss_RT
double m_hss_RT
Standard state enthalpy divided by RT.
Definition: PDSS.h:520
Cantera::PDSS_Nondimensional::m_V0
double m_V0
Reference state molar volume (m^3/kmol)
Definition: PDSS.h:519
Cantera::PDSS::initThermo
virtual void initThermo()
Initialization routine.
Definition: PDSS.h:415
Cantera::PDSS::setParametersFromXML
virtual void setParametersFromXML(const XML_Node &speciesNode)
Initialization routine for the PDSS object based on the speciesNode.
Definition: PDSS.h:434
Cantera::PDSS::m_pres
doublereal m_pres
State of the system - pressure.
Definition: PDSS.h:458
Cantera::PDSS::m_spthermo
shared_ptr< SpeciesThermoInterpType > m_spthermo
Pointer to the species thermodynamic property manager.
Definition: PDSS.h:478
Cantera::PDSS::m_temp
doublereal m_temp
Current temperature used by the PDSS object.
Definition: PDSS.h:455
Cantera::PDSS::m_maxTemp
doublereal m_maxTemp
Maximum temperature.
Definition: PDSS.h:467
Cantera::PDSS::m_p0
doublereal m_p0
Reference state pressure of the species.
Definition: PDSS.h:461
Cantera::PDSS::m_mw
doublereal m_mw
Molecular Weight of the species.
Definition: PDSS.h:470
Cantera::PDSS::m_input
AnyMap m_input
Input data supplied via setParameters.
Definition: PDSS.h:474
Cantera::PDSS::getParameters
virtual void getParameters(AnyMap &eosNode) const
Store the parameters needed to reconstruct a copy of this PDSS object.
Definition: PDSS.h:424
Cantera::PDSS::m_minTemp
doublereal m_minTemp
Minimum temperature.
Definition: PDSS.h:464
Cantera::XML_Node
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:103
Cantera::XML_Node::attrib
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
Definition: xml.cpp:493
Cantera::XML_Node::name
std::string name() const
Returns the name of the XML node.
Definition: xml.h:371
Cantera::XML_Node::findByName
const XML_Node * findByName(const std::string &nm, int depth=100000) const
This routine carries out a recursive search for an XML node based on the name of the node.
Definition: xml.cpp:680
ctml.h
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data.
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557
Cantera::getFloat
doublereal getFloat(const XML_Node &parent, const std::string &name, const std::string &type)
Get a floating-point value from a child element.
Definition: ctml.cpp:166
Cantera::GasConstant
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition: ct_defs.h:113