Cantera  2.5.1
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 
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 doublereal PDSS_ConstVol::intEnergy_mole() const
56 {
57  doublereal pV = (m_pres * m_Vss);
58  return m_h0_RT * GasConstant * m_temp - pV;
59 }
60 
61 doublereal PDSS_ConstVol::cv_mole() const
62 {
63  return (cp_mole() - m_V0);
64 }
65 
66 void PDSS_ConstVol::setPressure(doublereal p)
67 {
68  m_pres = p;
69  doublereal del_pRT = (m_pres - m_p0) / (GasConstant * m_temp);
70  m_hss_RT = m_h0_RT + del_pRT * m_Vss;
71  m_gss_RT = m_hss_RT - m_sss_R;
72 }
73 
74 void PDSS_ConstVol::setTemperature(doublereal temp)
75 {
76  m_temp = temp;
77  m_spthermo->updatePropertiesTemp(temp, &m_cp0_R, &m_h0_RT, &m_s0_R);
78  m_g0_RT = m_h0_RT - m_s0_R;
79 
80  doublereal del_pRT = (m_pres - m_p0) / (GasConstant * m_temp);
81 
82  m_hss_RT = m_h0_RT + del_pRT * m_Vss;
83  m_cpss_R = m_cp0_R;
84  m_sss_R = m_s0_R;
85  m_gss_RT = m_hss_RT - m_sss_R;
86 }
87 
88 void PDSS_ConstVol::setState_TP(doublereal temp, doublereal pres)
89 {
90  setTemperature(temp);
91  setPressure(pres);
92 }
93 
94 void PDSS_ConstVol::setState_TR(doublereal temp, doublereal rho)
95 {
96  doublereal rhoStored = m_mw / m_constMolarVolume;
97  if (fabs(rhoStored - rho) / (rhoStored + rho) > 1.0E-4) {
98  throw CanteraError("PDSS_ConstVol::setState_TR",
99  "Inconsistent supplied rho");
100  }
101  setTemperature(temp);
102 }
103 
104 doublereal PDSS_ConstVol::satPressure(doublereal t)
105 {
106  return 1.0E-200;
107 }
108 
109 }
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 ...
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:104
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
Definition: xml.cpp:492
std::string name() const
Returns the name of the XML node.
Definition: xml.h:372
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:679
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data.
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition: ct_defs.h:109
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264
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:164