Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
18 #include "cantera/base/ctml.h"
19 
20 using namespace std;
21 
22 namespace Cantera
23 {
24 
25 VPSSMgr_ConstVol::VPSSMgr_ConstVol(VPStandardStateTP* vp_ptr, SpeciesThermo* spth) :
26  VPSSMgr(vp_ptr, spth)
27 {
30 }
31 
33  VPSSMgr(right.m_vptp_ptr, right.m_spthermo)
34 {
37  *this = right;
38 }
39 
40 
42 {
43  if (&b == this) {
44  return *this;
45  }
47  return *this;
48 }
49 
51 {
52  return new VPSSMgr_ConstVol(*this);
53 }
54 
55 /*
56  * Note, this is equal to the reference state entropies
57  * due to the zero volume expansivity:
58  * i.e., (dS/dp)_T = (dV/dT)_P = 0.0
59  */
61 {
62 
63  doublereal del_pRT = (m_plast - m_p0) / (GasConstant * m_tlast);
64 
65  for (size_t k = 0; k < m_kk; k++) {
66  m_hss_RT[k] = m_h0_RT[k] + del_pRT * m_Vss[k];
67  m_cpss_R[k] = m_cp0_R[k];
68  m_sss_R[k] = m_s0_R[k];
69  m_gss_RT[k] = m_hss_RT[k] - m_sss_R[k];
70  // m_Vss[k] constant
71  }
72 }
73 
74 void VPSSMgr_ConstVol::getGibbs_RT_ref(doublereal* grt) const
75 {
77  std::copy(m_g0_RT.begin(), m_g0_RT.end(), grt);
78  } else {
79  throw CanteraError("VPSSMgr_ConstVol::getGibbs_RT_ref",
80  "unimplemented without m_useTmpRefStateStorage");
81  }
82 }
83 
84 void VPSSMgr_ConstVol::getStandardVolumes_ref(doublereal* vol) const
85 {
87  std::copy(m_Vss.begin(), m_Vss.end(), vol);
88  } else {
89  throw CanteraError("VPSSMgr_ConstVol::getStandardVolumes_ref",
90  "unimplemented without m_useTmpRefStateStorage");
91  }
92 }
93 
95 {
97 }
98 
99 void
100 VPSSMgr_ConstVol::initThermoXML(XML_Node& phaseNode, const std::string& id)
101 {
102  VPSSMgr::initThermoXML(phaseNode, id);
103 
104  XML_Node& speciesList = phaseNode.child("speciesArray");
105  XML_Node* speciesDB = get_XML_NameID("speciesData", speciesList["datasrc"],
106  &phaseNode.root());
107 
108  for (size_t k = 0; k < m_kk; k++) {
109  const XML_Node* s = speciesDB->findByAttr("name", m_vptp_ptr->speciesName(k));
110  if (!s) {
111  throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
112  "no species Node for species " + m_vptp_ptr->speciesName(k));
113  }
114  const XML_Node* ss = s->findByName("standardState");
115  if (!ss) {
116  throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
117  "no standardState Node for species " + s->attrib("name"));
118  }
119  std::string model = ss->attrib("model");
120  if (model != "constant_incompressible" && model != "constantVolume") {
121  throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
122  "standardState model for species isn't constant_incompressible: " + s->attrib("name"));
123  }
124  m_Vss[k] = getFloat(*ss, "molarVolume", "toSI");
125  }
126 }
127 
128 PDSS*
129 VPSSMgr_ConstVol::createInstallPDSS(size_t k, const XML_Node& speciesNode,
130  const XML_Node* const phaseNode_ptr)
131 {
132  const XML_Node* ss = speciesNode.findByName("standardState");
133  if (!ss) {
134  throw CanteraError("VPSSMgr_ConstVol::createInstallPDSS",
135  "no standardState Node for species " + speciesNode["name"]);
136  }
137  std::string model = ss->attrib("model");
138  if (model != "constant_incompressible" && model != "constantVolume") {
139  throw CanteraError("VPSSMgr_ConstVol::createInstallPDSS",
140  "standardState model for species isn't "
141  "constant_incompressible: " + speciesNode["name"]);
142  }
143  if (m_Vss.size() < k+1) {
144  m_Vss.resize(k+1, 0.0);
145  }
146  m_Vss[k] = getFloat(*ss, "molarVolume", "toSI");
147 
148  installSTSpecies(k, speciesNode, phaseNode_ptr);
149  return new PDSS_ConstVol(m_vptp_ptr, k, speciesNode, *phaseNode_ptr, true);
150 }
151 
153 {
154  return cPDSS_CONSTVOL;
155 }
156 
158 {
159  return cVPSSMGR_CONSTVOL;
160 }
161 }
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:704
bool m_useTmpRefStateStorage
Definition: VPSSMgr.h:746
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
virtual PDSS_enumType reportPDSSType(int index=-1) const
This utility function reports the type of parameterization used for the species with index number ind...
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
Definition: xml.cpp:527
vector_fp m_sss_R
Vector containing the species Standard State entropies at T = m_tlast and P = m_plast.
Definition: VPSSMgr.h:803
Virtual base class for the classes that manage the calculation of standard state properties for all t...
Definition: VPSSMgr.h:235
VPSSMgr & operator=(const VPSSMgr &right)
Assignment operator.
Definition: VPSSMgr.cpp:61
bool m_useTmpStandardStateStorage
Definition: VPSSMgr.h:779
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:383
VPSSMgr_ConstVol & operator=(const VPSSMgr_ConstVol &right)
Assignment operator.
size_t m_kk
Number of species in the phase.
Definition: VPSSMgr.h:711
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.
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:350
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:135
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
Definition: xml.cpp:573
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:742
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:758
VPStandardStateTP * m_vptp_ptr
Variable pressure ThermoPhase object.
Definition: VPSSMgr.h:714
Class for pressure dependent standard states that use a constant volume model.
Definition: PDSS_ConstVol.h:23
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:728
PDSS_enumType
Types of PDSS's.
Definition: mix_defs.h:121
Variable pressure SS calculate for phases consisting all species having a constant molar volume prope...
Definition: mix_defs.h:141
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:99
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:809
vector_fp m_hss_RT
Vector containing the species Standard State enthalpies at T = m_tlast and P = m_plast.
Definition: VPSSMgr.h:785
vector_fp m_cpss_R
Vector containing the species Standard State constant pressure heat capacities at T = m_tlast and P =...
Definition: VPSSMgr.h:791
vector_fp m_h0_RT
Definition: VPSSMgr.h:752
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:193
vector_fp m_g0_RT
Vector containing the species reference Gibbs functions at T = m_tlast and P = p_ref.
Definition: VPSSMgr.h:764
virtual void _updateStandardStateThermo()
Updates the standard state thermodynamic functions at the current T and P of the solution.
doublereal m_p0
Definition: VPSSMgr.h:734
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:194
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:394
doublereal m_tlast
The last temperature at which the standard state thermodynamic properties were calculated at...
Definition: VPSSMgr.h:724
XML_Node & root() const
Return the root of the current XML_Node tree.
Definition: xml.cpp:1095
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:797
std::string speciesName(size_t k) const
Name of the species with index k.
Definition: Phase.cpp:272
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:770