Cantera  2.1.2
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  * Copyright (2005) Sandia Corporation. Under the terms of
11  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
12  * U.S. Government retains certain rights in this software.
13  */
14 
16 #include "cantera/base/xml.h"
20 
21 using namespace std;
22 
23 namespace Cantera
24 {
25 
26 VPSSMgr_ConstVol::VPSSMgr_ConstVol(VPStandardStateTP* vp_ptr, SpeciesThermo* spth) :
27  VPSSMgr(vp_ptr, spth)
28 {
31 }
32 
34  VPSSMgr(right.m_vptp_ptr, right.m_spthermo)
35 {
38  *this = right;
39 }
40 
41 
43 {
44  if (&b == this) {
45  return *this;
46  }
48  return *this;
49 }
50 
52 {
53  return new VPSSMgr_ConstVol(*this);
54 }
55 
56 /*
57  * Note, this is equal to the reference state entropies
58  * due to the zero volume expansivity:
59  * i.e., (dS/dp)_T = (dV/dT)_P = 0.0
60  */
62 {
63 
64  doublereal del_pRT = (m_plast - m_p0) / (GasConstant * m_tlast);
65 
66  for (size_t k = 0; k < m_kk; k++) {
67  m_hss_RT[k] = m_h0_RT[k] + del_pRT * m_Vss[k];
68  m_cpss_R[k] = m_cp0_R[k];
69  m_sss_R[k] = m_s0_R[k];
70  m_gss_RT[k] = m_hss_RT[k] - m_sss_R[k];
71  // m_Vss[k] constant
72  }
73 }
74 
75 void VPSSMgr_ConstVol::getGibbs_RT_ref(doublereal* grt) const
76 {
78  std::copy(m_g0_RT.begin(), m_g0_RT.end(), grt);
79  } else {
80  throw CanteraError("VPSSMgr_ConstVol::getGibbs_RT_ref",
81  "unimplemented without m_useTmpRefStateStorage");
82  }
83 }
84 
85 void VPSSMgr_ConstVol::getStandardVolumes_ref(doublereal* vol) const
86 {
88  std::copy(m_Vss.begin(), m_Vss.end(), vol);
89  } else {
90  throw CanteraError("VPSSMgr_ConstVol::getStandardVolumes_ref",
91  "unimplemented without m_useTmpRefStateStorage");
92  }
93 }
94 
96 {
98 }
99 
100 void
101 VPSSMgr_ConstVol::initThermoXML(XML_Node& phaseNode, const std::string& id)
102 {
103  VPSSMgr::initThermoXML(phaseNode, id);
104 
105  XML_Node& speciesList = phaseNode.child("speciesArray");
106  XML_Node* speciesDB = get_XML_NameID("speciesData", speciesList["datasrc"],
107  &phaseNode.root());
108  const vector<string>&sss = m_vptp_ptr->speciesNames();
109 
110  for (size_t k = 0; k < m_kk; k++) {
111  const XML_Node* s = speciesDB->findByAttr("name", sss[k]);
112  if (!s) {
113  throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
114  "no species Node for species " + sss[k]);
115  }
116  const XML_Node* ss = s->findByName("standardState");
117  if (!ss) {
118  throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
119  "no standardState Node for species " + s->name());
120  }
121  std::string model = (*ss)["model"];
122  if (model != "constant_incompressible" && model != "constantVolume") {
123  throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
124  "standardState model for species isn't constant_incompressible: " + s->name());
125  }
126  m_Vss[k] = ctml::getFloat(*ss, "molarVolume", "toSI");
127  }
128 }
129 
130 PDSS*
131 VPSSMgr_ConstVol::createInstallPDSS(size_t k, const XML_Node& speciesNode,
132  const XML_Node* const phaseNode_ptr)
133 {
134  //VPSSMgr::installSpecies(k, speciesNode, phaseNode_ptr);
135  const XML_Node* ss = speciesNode.findByName("standardState");
136  if (!ss) {
137  throw CanteraError("VPSSMgr_ConstVol::installSpecies",
138  "no standardState Node for species " + speciesNode.name());
139  }
140  std::string model = (*ss)["model"];
141  if (model != "constant_incompressible" && model != "constantVolume") {
142  throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
143  "standardState model for species isn't "
144  "constant_incompressible: " + speciesNode.name());
145  }
146  if (m_Vss.size() < k+1) {
147  m_Vss.resize(k+1, 0.0);
148  }
149  m_Vss[k] = ctml::getFloat(*ss, "molarVolume", "toSI");
150 
151  installSTSpecies(k, speciesNode, phaseNode_ptr);
152 
153 
154  PDSS* kPDSS = new PDSS_ConstVol(m_vptp_ptr, k, speciesNode,
155  *phaseNode_ptr, true);
156  return kPDSS;
157 }
158 
160 {
161  return cPDSS_CONSTVOL;
162 }
163 
165 {
166  return cVPSSMGR_CONSTVOL;
167 }
168 }
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:716
bool m_useTmpRefStateStorage
Definition: VPSSMgr.h:751
virtual PDSS_enumType reportPDSSType(int index=-1) const
This utility function reports the type of parameterization used for the species with index number ind...
vector_fp m_sss_R
Vector containing the species Standard State entropies at T = m_tlast and P = m_plast.
Definition: VPSSMgr.h:808
Virtual base class for the classes that manage the calculation of standard state properties for all t...
Definition: VPSSMgr.h:238
VPSSMgr & operator=(const VPSSMgr &right)
Assignment operator.
Definition: VPSSMgr.cpp:67
bool m_useTmpStandardStateStorage
Definition: VPSSMgr.h:784
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...
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Finalize the thermo after all species have been entered.
Definition: VPSSMgr.cpp:393
VPSSMgr_ConstVol & operator=(const VPSSMgr_ConstVol &right)
Assignment operator.
size_t m_kk
Number of species in the phase.
Definition: VPSSMgr.h:716
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
VPSSMgr_ConstVol(VPStandardStateTP *vp_ptr, SpeciesThermo *spth)
Constructor.
doublereal getFloat(const Cantera::XML_Node &parent, const std::string &name, const std::string &type)
Get a floating-point value from a child element.
Definition: ctml.cpp:267
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...
virtual void initThermo()
Definition: VPSSMgr.cpp:360
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.
Pure Virtual base class for the species thermo manager classes.
VPSSMgr_enumType
enum for VPSSMgr types that are responsible for calculating the species standard state and reference-...
Definition: mix_defs.h:133
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
Definition: xml.cpp:584
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:754
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:763
VPStandardStateTP * m_vptp_ptr
Variable pressure ThermoPhase object.
Definition: VPSSMgr.h:719
Class for pressure dependent standard states that use a constant volume model.
Definition: PDSS_ConstVol.h:26
virtual void getGibbs_RT_ref(doublereal *grt) const
doublereal m_plast
The last pressure at which the Standard State thermodynamic properties were calculated at...
Definition: VPSSMgr.h:733
PDSS_enumType
Types of PDSS's.
Definition: mix_defs.h:119
Variable pressure SS calculate for phases consisting all species having a constant molar volume prope...
Definition: mix_defs.h:139
std::string name() const
Returns the name of the XML node.
Definition: xml.h:390
Classes providing support for XML data files.
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:68
This is a filter class for ThermoPhase that implements some prepatory steps for efficiently handling ...
virtual VPSSMgr * duplMyselfAsVPSSMgr() const
Duplication routine for objects which derive from VPSSMgr.
vector_fp m_Vss
Vector containing the species standard state volumes at T = m_tlast and P = m_plast.
Definition: VPSSMgr.h:814
const std::vector< std::string > & speciesNames() const
Return a const reference to the vector of species names.
Definition: Phase.cpp:252
vector_fp m_hss_RT
Vector containing the species Standard State enthalpies at T = m_tlast and P = m_plast.
Definition: VPSSMgr.h:790
vector_fp m_cpss_R
Vector containing the species Standard State constant pressure heat capacities at T = m_tlast and P =...
Definition: VPSSMgr.h:796
vector_fp m_h0_RT
Definition: VPSSMgr.h:757
Header for factory to build instances of classes that manage the standard-state thermodynamic propert...
Header file for a derived class of ThermoPhase that handles variable pressure standard state methods ...
Virtual base class for a species with a pressure dependent standard state.
Definition: PDSS.h:195
vector_fp m_g0_RT
Vector containing the species reference Gibbs functions at T = m_tlast and P = p_ref.
Definition: VPSSMgr.h:769
virtual void _updateStandardStateThermo()
Updates the standard state thermodynamic functions at the current T and P of the solution.
doublereal m_p0
Definition: VPSSMgr.h:739
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:66
Declarations for a derived class for the calculation of multiple-species thermodynamic property manag...
Declarations for the class PDSS_ConstVol (pressure dependent standard state) which handles calculatio...
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:440
doublereal m_tlast
The last temperature at which the standard state thermodynamic properties were calculated at...
Definition: VPSSMgr.h:729
XML_Node & root() const
Return the root of the current XML_Node tree.
Definition: xml.cpp:1091
virtual VPSSMgr_enumType reportVPSSMgrType() const
This utility function reports the type of manager for the calculation of ss properties.
vector_fp m_gss_RT
Vector containing the species Standard State Gibbs functions at T = m_tlast and P = m_plast...
Definition: VPSSMgr.h:802
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:271
vector_fp m_s0_R
Vector containing the species reference entropies at T = m_tlast and P = p_ref.
Definition: VPSSMgr.h:775