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"
13
14using namespace std;
15
16namespace Cantera
17{
18
20{
21}
22
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
43{
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();
53}
54
56{
57 PDSS::getParameters(eosNode);
58 eosNode["model"] = "constant-volume";
59 eosNode["molar-volume"].setQuantity(m_constMolarVolume, "m^3/kmol");
60}
61
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
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;
79}
80
81void PDSS_ConstVol::setTemperature(doublereal temp)
82{
83 m_temp = temp;
84 m_spthermo->updatePropertiesTemp(temp, &m_cp0_R, &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;
93}
94
95void PDSS_ConstVol::setState_TP(doublereal temp, doublereal pres)
96{
97 setTemperature(temp);
98 setPressure(pres);
99}
100
101void 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}
Declarations for the class PDSS_ConstVol (pressure dependent standard state) which handles calculatio...
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:399
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
bool hasKey(const std::string &key) const
Returns true if the map contains an item named key.
Definition: AnyMap.cpp:1406
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
PDSS_ConstVol()
Default Constructor.
virtual void getParameters(AnyMap &eosNode) const
Store the parameters needed to reconstruct a copy of this PDSS object.
virtual void setPressure(doublereal pres)
Sets the pressure in the object.
virtual void setState_TP(doublereal temp, doublereal pres)
Set the internal temperature and pressure.
virtual doublereal cv_mole() const
Return the molar const volume heat capacity in units of J kmol-1 K-1.
virtual void setTemperature(doublereal temp)
Set the internal temperature.
void setMolarVolume(double v)
Set the (constant) molar volume [m3/kmol] of the species.
Definition: PDSS_ConstVol.h:56
virtual void initThermo()
Initialization routine.
doublereal m_constMolarVolume
Value of the constant molar volume for the species.
Definition: PDSS_ConstVol.h:67
virtual void setParametersFromXML(const XML_Node &speciesNode)
Initialization routine for the PDSS object based on the speciesNode.
virtual void setState_TR(doublereal temp, doublereal rho)
Set the internal temperature and density.
virtual doublereal satPressure(doublereal t)
saturation pressure
virtual doublereal intEnergy_mole() const
Return the molar internal Energy in units of J kmol-1.
double m_sss_R
Standard state entropy divided by R.
Definition: PDSS.h:522
virtual doublereal cp_mole() const
Return the molar const pressure heat capacity in units of J kmol-1 K-1.
Definition: PDSS.cpp:262
double m_cpss_R
Standard state heat capacity divided by R.
Definition: PDSS.h:521
double m_h0_RT
Reference state enthalpy divided by RT.
Definition: PDSS.h:515
double m_g0_RT
Reference state Gibbs free energy divided by RT.
Definition: PDSS.h:518
double m_s0_R
Reference state entropy divided by R.
Definition: PDSS.h:517
double m_gss_RT
Standard state Gibbs free energy divided by RT.
Definition: PDSS.h:523
double m_cp0_R
Reference state heat capacity divided by R.
Definition: PDSS.h:516
double m_Vss
Standard State molar volume (m^3/kmol)
Definition: PDSS.h:524
double m_hss_RT
Standard state enthalpy divided by RT.
Definition: PDSS.h:520
double m_V0
Reference state molar volume (m^3/kmol)
Definition: PDSS.h:519
virtual void initThermo()
Initialization routine.
Definition: PDSS.h:415
virtual void setParametersFromXML(const XML_Node &speciesNode)
Initialization routine for the PDSS object based on the speciesNode.
Definition: PDSS.h:434
doublereal m_pres
State of the system - pressure.
Definition: PDSS.h:458
shared_ptr< SpeciesThermoInterpType > m_spthermo
Pointer to the species thermodynamic property manager.
Definition: PDSS.h:478
doublereal m_temp
Current temperature used by the PDSS object.
Definition: PDSS.h:455
doublereal m_maxTemp
Maximum temperature.
Definition: PDSS.h:467
doublereal m_p0
Reference state pressure of the species.
Definition: PDSS.h:461
doublereal m_mw
Molecular Weight of the species.
Definition: PDSS.h:470
AnyMap m_input
Input data supplied via setParameters.
Definition: PDSS.h:474
virtual void getParameters(AnyMap &eosNode) const
Store the parameters needed to reconstruct a copy of this PDSS object.
Definition: PDSS.h:424
doublereal m_minTemp
Minimum temperature.
Definition: PDSS.h:464
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:103
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
Definition: xml.cpp:493
std::string name() const
Returns the name of the XML node.
Definition: xml.h:371
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 ("Cantera Markup Language") is the variant of XML that Cantera uses to store data.
Namespace for the Cantera kernel.
Definition: AnyMap.h:29
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
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition: ct_defs.h:113