Cantera  2.4.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 http://www.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::constructPDSSXML",
30  "no standardState Node for species " + speciesNode.name());
31  }
32  if (ss->attrib("model") != "constant_incompressible") {
33  throw CanteraError("PDSS_ConstVol::initThermoXML",
34  "standardState model for species isn't constant_incompressible: " + speciesNode.name());
35  }
36 
37  setMolarVolume(getFloat(*ss, "molarVolume", "toSI"));
38 }
39 
40 void PDSS_ConstVol::initThermo()
41 {
42  PDSS::initThermo();
43  m_minTemp = m_spthermo->minTemp();
44  m_maxTemp = m_spthermo->maxTemp();
45  m_p0 = m_spthermo->refPressure();
46  m_V0 = m_constMolarVolume;
47  m_Vss = m_constMolarVolume;
48 }
49 
50 doublereal PDSS_ConstVol::intEnergy_mole() const
51 {
52  doublereal pV = (m_pres * m_Vss);
53  return m_h0_RT * GasConstant * m_temp - pV;
54 }
55 
56 doublereal PDSS_ConstVol::cv_mole() const
57 {
58  return (cp_mole() - m_V0);
59 }
60 
61 void PDSS_ConstVol::setPressure(doublereal p)
62 {
63  m_pres = p;
64  doublereal del_pRT = (m_pres - m_p0) / (GasConstant * m_temp);
65  m_hss_RT = m_h0_RT + del_pRT * m_Vss;
66  m_gss_RT = m_hss_RT - m_sss_R;
67 }
68 
69 void PDSS_ConstVol::setTemperature(doublereal temp)
70 {
71  m_temp = temp;
72  m_spthermo->updatePropertiesTemp(temp, &m_cp0_R, &m_h0_RT, &m_s0_R);
73  m_g0_RT = m_h0_RT - m_s0_R;
74 
75  doublereal del_pRT = (m_pres - m_p0) / (GasConstant * m_temp);
76 
77  m_hss_RT = m_h0_RT + del_pRT * m_Vss;
78  m_cpss_R = m_cp0_R;
79  m_sss_R = m_s0_R;
80  m_gss_RT = m_hss_RT - m_sss_R;
81 }
82 
83 void PDSS_ConstVol::setState_TP(doublereal temp, doublereal pres)
84 {
85  setTemperature(temp);
86  setPressure(pres);
87 }
88 
89 void PDSS_ConstVol::setState_TR(doublereal temp, doublereal rho)
90 {
91  doublereal rhoStored = m_mw / m_constMolarVolume;
92  if (fabs(rhoStored - rho) / (rhoStored + rho) > 1.0E-4) {
93  throw CanteraError("PDSS_ConstVol::setState_TR",
94  "Inconsistent supplied rho");
95  }
96  setTemperature(temp);
97 }
98 
99 doublereal PDSS_ConstVol::satPressure(doublereal t)
100 {
101  return 1.0E-200;
102 }
103 
104 }
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
std::string name() const
Returns the name of the XML node.
Definition: xml.h:370
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:695
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
STL namespace.
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:65
Header file for a derived class of ThermoPhase that handles variable pressure standard state methods ...
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
Definition: xml.cpp:500
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:64
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
Declarations for the class PDSS_ConstVol (pressure dependent standard state) which handles calculatio...
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8