Cantera  2.3.0
VPSSMgr_ConstVol.cpp
Go to the documentation of this file.
1 /**
2  * @file VPSSMgr_ConstVol.cpp
3  * Definition file for a derived class that handles the calculation
4  * of standard state thermo properties for
5  * a set of species which have a constant molar volume pressure
6  * dependence (see \ref thermoprops and
7  * class \link Cantera::VPSSMgr_ConstVol VPSSMgr_ConstVol\endlink).
8  */
9 
10 // This file is part of Cantera. See License.txt in the top-level directory or
11 // at http://www.cantera.org/license.txt for license and copyright information.
12 
16 #include "cantera/base/ctml.h"
17 
18 using namespace std;
19 
20 namespace Cantera
21 {
22 
23 VPSSMgr_ConstVol::VPSSMgr_ConstVol(VPStandardStateTP* vp_ptr, MultiSpeciesThermo* spth) :
24  VPSSMgr(vp_ptr, spth)
25 {
28 }
29 
31  VPSSMgr(right.m_vptp_ptr, right.m_spthermo)
32 {
35  *this = right;
36 }
37 
38 VPSSMgr_ConstVol& VPSSMgr_ConstVol::operator=(const VPSSMgr_ConstVol& b)
39 {
40  if (&b == this) {
41  return *this;
42  }
44  return *this;
45 }
46 
48 {
49  return new VPSSMgr_ConstVol(*this);
50 }
51 
52 /*
53  * Note, this is equal to the reference state entropies
54  * due to the zero volume expansivity:
55  * i.e., (dS/dp)_T = (dV/dT)_P = 0.0
56  */
58 {
59  doublereal del_pRT = (m_plast - m_p0) / (GasConstant * m_tlast);
60 
61  for (size_t k = 0; k < m_kk; k++) {
62  m_hss_RT[k] = m_h0_RT[k] + del_pRT * m_Vss[k];
63  m_cpss_R[k] = m_cp0_R[k];
64  m_sss_R[k] = m_s0_R[k];
65  m_gss_RT[k] = m_hss_RT[k] - m_sss_R[k];
66  // m_Vss[k] constant
67  }
68 }
69 
70 void VPSSMgr_ConstVol::getGibbs_RT_ref(doublereal* grt) const
71 {
73  std::copy(m_g0_RT.begin(), m_g0_RT.end(), grt);
74  } else {
75  throw CanteraError("VPSSMgr_ConstVol::getGibbs_RT_ref",
76  "unimplemented without m_useTmpRefStateStorage");
77  }
78 }
79 
80 void VPSSMgr_ConstVol::getStandardVolumes_ref(doublereal* vol) const
81 {
83  std::copy(m_Vss.begin(), m_Vss.end(), vol);
84  } else {
85  throw CanteraError("VPSSMgr_ConstVol::getStandardVolumes_ref",
86  "unimplemented without m_useTmpRefStateStorage");
87  }
88 }
89 
90 void VPSSMgr_ConstVol::initThermoXML(XML_Node& phaseNode, const std::string& id)
91 {
92  VPSSMgr::initThermoXML(phaseNode, id);
93  XML_Node& speciesList = phaseNode.child("speciesArray");
94  XML_Node* speciesDB = get_XML_NameID("speciesData", speciesList["datasrc"],
95  &phaseNode.root());
96 
97  for (size_t k = 0; k < m_kk; k++) {
98  const XML_Node* s = speciesDB->findByAttr("name", m_vptp_ptr->speciesName(k));
99  if (!s) {
100  throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
101  "no species Node for species " + m_vptp_ptr->speciesName(k));
102  }
103  const XML_Node* ss = s->findByName("standardState");
104  if (!ss) {
105  throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
106  "no standardState Node for species " + s->attrib("name"));
107  }
108  std::string model = ss->attrib("model");
109  if (model != "constant_incompressible" && model != "constantVolume") {
110  throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
111  "standardState model for species isn't constant_incompressible: " + s->attrib("name"));
112  }
113  m_Vss[k] = getFloat(*ss, "molarVolume", "toSI");
114  }
115 }
116 
117 PDSS* VPSSMgr_ConstVol::createInstallPDSS(size_t k, const XML_Node& speciesNode,
118  const XML_Node* const phaseNode_ptr)
119 {
120  const XML_Node* ss = speciesNode.findByName("standardState");
121  if (!ss) {
122  throw CanteraError("VPSSMgr_ConstVol::createInstallPDSS",
123  "no standardState Node for species " + speciesNode["name"]);
124  }
125  std::string model = ss->attrib("model");
126  if (model != "constant_incompressible" && model != "constantVolume") {
127  throw CanteraError("VPSSMgr_ConstVol::createInstallPDSS",
128  "standardState model for species isn't "
129  "constant_incompressible: " + speciesNode["name"]);
130  }
131  if (m_Vss.size() < k+1) {
132  m_Vss.resize(k+1, 0.0);
133  }
134  m_Vss[k] = getFloat(*ss, "molarVolume", "toSI");
135 
136  installSTSpecies(k, speciesNode, phaseNode_ptr);
137  return new PDSS_ConstVol(m_vptp_ptr, k, speciesNode, *phaseNode_ptr, true);
138 }
139 
141 {
142  warn_deprecated("VPSSMgr_ConstVol::reportPDSSType",
143  "To be removed after Cantera 2.3.");
144  return cPDSS_CONSTVOL;
145 }
146 
148 {
149  warn_deprecated("VPSSMgr_ConstVol::reportVPSSMgrType",
150  "To be removed after Cantera 2.3.");
151  return cVPSSMGR_CONSTVOL;
152 }
153 }
bool m_useTmpRefStateStorage
boolean indicating whether temporary reference state storage is used -> default is false ...
Definition: VPSSMgr.h:734
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
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
vector_fp m_sss_R
Vector containing the species Standard State entropies at T = m_tlast and P = m_plast.
Definition: VPSSMgr.h:773
Virtual base class for the classes that manage the calculation of standard state properties for all t...
Definition: VPSSMgr.h:228
VPSSMgr & operator=(const VPSSMgr &right)
Definition: VPSSMgr.cpp:60
bool m_useTmpStandardStateStorage
boolean indicating whether temporary standard state storage is used -> default is false ...
Definition: VPSSMgr.h:757
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Finalize the thermo after all species have been entered.
Definition: VPSSMgr.cpp:364
size_t m_kk
Number of species in the phase.
Definition: VPSSMgr.h:704
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:54
STL namespace.
virtual void getGibbs_RT_ref(doublereal *grt) const
virtual PDSS * createInstallPDSS(size_t k, const XML_Node &speciesNode, const XML_Node *const phaseNode_ptr)
Create and install a constant volume pressure dependent standard state for one species within this ob...
Constant Molar Volume e VPSS species thermo manager class.
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Finalize the thermo after all species have been entered.
VPSSMgr_enumType
enum for VPSSMgr types that are responsible for calculating the species standard state and reference-...
Definition: mix_defs.h:119
virtual void getStandardVolumes_ref(doublereal *vol) const
Get the molar volumes of the species reference states at the current T and P_ref of the solution...
vector_fp m_cp0_R
Vector containing the species reference constant pressure heat capacities at T = m_tlast and P = p_re...
Definition: VPSSMgr.h:742
VPStandardStateTP * m_vptp_ptr
Variable pressure ThermoPhase object.
Definition: VPSSMgr.h:707
virtual VPSSMgr * duplMyselfAsVPSSMgr() const
Duplication routine for objects which derive from VPSSMgr.
Class for pressure dependent standard states that use a constant volume model.
Definition: PDSS_ConstVol.h:22
std::string speciesName(size_t k) const
Name of the species with index k.
Definition: Phase.cpp:267
doublereal m_plast
The last pressure at which the Standard State thermodynamic properties were calculated at...
Definition: VPSSMgr.h:721
PDSS_enumType
Types of PDSS&#39;s.
Definition: mix_defs.h:105
Variable pressure SS calculate for phases consisting all species having a constant molar volume prope...
Definition: mix_defs.h:125
virtual PDSS_enumType reportPDSSType(int index=-1) const
This utility function reports the type of parameterization used for the species with index number ind...
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:65
This is a filter class for ThermoPhase that implements some prepatory steps for efficiently handling ...
VPSSMgr_ConstVol(VPStandardStateTP *vp_ptr, MultiSpeciesThermo *spth)
Constructor.
vector_fp m_Vss
Vector containing the species standard state volumes at T = m_tlast and P = m_plast.
Definition: VPSSMgr.h:777
XML_Node & child(const size_t n) const
Return a changeable reference to the n&#39;th child of the current node.
Definition: xml.cpp:546
XML_Node & root() const
Return the root of the current XML_Node tree.
Definition: xml.cpp:1025
vector_fp m_hss_RT
Vector containing the species Standard State enthalpies at T = m_tlast and P = m_plast.
Definition: VPSSMgr.h:761
vector_fp m_cpss_R
Vector containing the species Standard State constant pressure heat capacities at T = m_tlast and P =...
Definition: VPSSMgr.h:765
vector_fp m_h0_RT
Vector containing the species reference enthalpies at T = m_tlast and P = p_ref.
Definition: VPSSMgr.h:738
virtual VPSSMgr_enumType reportVPSSMgrType() const
This utility function reports the type of manager for the calculation of ss properties.
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
Virtual base class for a species with a pressure dependent standard state.
Definition: PDSS.h:176
vector_fp m_g0_RT
Vector containing the species reference Gibbs functions at T = m_tlast and P = p_ref.
Definition: VPSSMgr.h:746
virtual void _updateStandardStateThermo()
Updates the standard state thermodynamic functions at the current T and P of the solution.
doublereal m_p0
Reference pressure (Pa) must be the same for all species - defaults to 1 atm.
Definition: VPSSMgr.h:724
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:64
Declarations for a derived class for the calculation of multiple-species thermodynamic property manag...
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:178
Declarations for the class PDSS_ConstVol (pressure dependent standard state) which handles calculatio...
XML_Node * findByAttr(const std::string &attr, const std::string &val, int depth=100000) const
This routine carries out a recursive search for an XML node based on an attribute of each XML node...
Definition: xml.cpp:661
A species thermodynamic property manager for a phase.
void installSTSpecies(size_t k, const XML_Node &speciesNode, const XML_Node *phaseNode_ptr)
Install specific content for species k in the reference-state thermodynamic SpeciesManager object...
Definition: VPSSMgr.cpp:375
doublereal m_tlast
The last temperature at which the standard state thermodynamic properties were calculated at...
Definition: VPSSMgr.h:717
Namespace for the Cantera kernel.
Definition: application.cpp:29
vector_fp m_gss_RT
Vector containing the species Standard State Gibbs functions at T = m_tlast and P = m_plast...
Definition: VPSSMgr.h:769
XML_Node * get_XML_NameID(const std::string &nameTarget, const std::string &file_ID, XML_Node *root)
This routine will locate an XML node in either the input XML tree or in another input file specified ...
Definition: global.cpp:252
vector_fp m_s0_R
Vector containing the species reference entropies at T = m_tlast and P = p_ref.
Definition: VPSSMgr.h:750