Cantera  2.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  * 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 
33 
35 {
36 }
37 
39  VPSSMgr(right.m_vptp_ptr, right.m_spthermo)
40 {
43  *this = right;
44 }
45 
46 
48 {
49  if (&b == this) {
50  return *this;
51  }
53  return *this;
54 }
55 
57 {
58  VPSSMgr_ConstVol* vpm = new VPSSMgr_ConstVol(*this);
59  return (VPSSMgr*) vpm;
60 }
61 
62 /*
63  * Get the nondimensional Entropies for the species
64  * standard states at the current T and P of the solution.
65  *
66  * Note, this is equal to the reference state entropies
67  * due to the zero volume expansivity:
68  * i.e., (dS/dp)_T = (dV/dT)_P = 0.0
69  */
71 {
72 
73  doublereal del_pRT = (m_plast - m_p0) / (GasConstant * m_tlast);
74 
75  for (size_t k = 0; k < m_kk; k++) {
76  m_hss_RT[k] = m_h0_RT[k] + del_pRT * m_Vss[k];
77  m_cpss_R[k] = m_cp0_R[k];
78  m_sss_R[k] = m_s0_R[k];
79  m_gss_RT[k] = m_hss_RT[k] - m_sss_R[k];
80  // m_Vss[k] constant
81  }
82 }
83 
84 /*
85  * Returns the vector of nondimensional
86  * Gibbs free energies of the reference state at the current temperature
87  * of the solution and the reference pressure for the species.
88  *
89  * @param grt Output vector contains the nondimensional Gibbs free energies
90  * of the reference state of the species
91  * length = m_kk, units = dimensionless.
92  */
93 void VPSSMgr_ConstVol::getGibbs_RT_ref(doublereal* grt) const
94 {
96  std::copy(m_g0_RT.begin(), m_g0_RT.end(), grt);
97  } else {
98  throw CanteraError("VPSSMgr_ConstVol::getGibbs_RT_ref",
99  "unimplemented without m_useTmpRefStateStorage");
100  }
101 }
102 
103 
104 // Get the molar volumes of the species reference states at the current
105 // <I>T</I> and <I>P_ref</I> of the solution.
106 /*
107  * units = m^3 / kmol
108  *
109  * @param vol Output vector containing the standard state volumes.
110  * Length: m_kk.
111  */
112 void VPSSMgr_ConstVol::getStandardVolumes_ref(doublereal* vol) const
113 {
115  std::copy(m_Vss.begin(), m_Vss.end(), vol);
116  } else {
117  throw CanteraError("VPSSMgr_ConstVol::getStandardVolumes_ref",
118  "unimplemented without m_useTmpRefStateStorage");
119  }
120 }
121 
123 {
125 }
126 
127 void
128 VPSSMgr_ConstVol::initThermoXML(XML_Node& phaseNode, std::string id)
129 {
130  VPSSMgr::initThermoXML(phaseNode, id);
131 
132  XML_Node& speciesList = phaseNode.child("speciesArray");
133  XML_Node* speciesDB = get_XML_NameID("speciesData", speciesList["datasrc"],
134  &phaseNode.root());
135  const vector<string>&sss = m_vptp_ptr->speciesNames();
136 
137  for (size_t k = 0; k < m_kk; k++) {
138  const XML_Node* s = speciesDB->findByAttr("name", sss[k]);
139  if (!s) {
140  throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
141  "no species Node for species " + sss[k]);
142  }
143  const XML_Node* ss = s->findByName("standardState");
144  if (!ss) {
145  throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
146  "no standardState Node for species " + s->name());
147  }
148  std::string model = (*ss)["model"];
149  if (model != "constant_incompressible" && model != "constantVolume") {
150  throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
151  "standardState model for species isn't constant_incompressible: " + s->name());
152  }
153  m_Vss[k] = ctml::getFloat(*ss, "molarVolume", "toSI");
154  }
155 }
156 
157 // void
158 // VPSSMgr_ConstVol::installSpecies(int k, const XML_Node& speciesNode,
159 // const XML_Node *phaseNode_ptr) {
160 //}
161 
162 PDSS*
163 VPSSMgr_ConstVol::createInstallPDSS(size_t k, const XML_Node& speciesNode,
164  const XML_Node* const phaseNode_ptr)
165 {
166  //VPSSMgr::installSpecies(k, speciesNode, phaseNode_ptr);
167  const XML_Node* ss = speciesNode.findByName("standardState");
168  if (!ss) {
169  throw CanteraError("VPSSMgr_ConstVol::installSpecies",
170  "no standardState Node for species " + speciesNode.name());
171  }
172  std::string model = (*ss)["model"];
173  if (model != "constant_incompressible" && model != "constantVolume") {
174  throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
175  "standardState model for species isn't "
176  "constant_incompressible: " + speciesNode.name());
177  }
178  if (m_Vss.size() < k+1) {
179  m_Vss.resize(k+1, 0.0);
180  }
181  m_Vss[k] = ctml::getFloat(*ss, "molarVolume", "toSI");
182 
183  installSTSpecies(k, speciesNode, phaseNode_ptr);
184 
185 
186  PDSS* kPDSS = new PDSS_ConstVol(m_vptp_ptr, k, speciesNode,
187  *phaseNode_ptr, true);
188  return kPDSS;
189 }
190 
192 {
193  return cPDSS_CONSTVOL;
194 }
195 
197 {
198  return cVPSSMGR_CONSTVOL;
199 }
200 }
201