[Thermo] newSpeciesThermoInterpType argument is the 'thermo' XML node

No data from the outer 'species' node is needed to instantiate the
SpeciesThermoInterpType object, so this function can just take the 'thermo' node
directly.
This commit is contained in:
Ray Speth 2015-04-17 18:40:40 -04:00
parent 1b0970a494
commit 7d170a9989
6 changed files with 16 additions and 25 deletions

View file

@ -278,11 +278,12 @@ SpeciesThermoInterpType* newSpeciesThermoInterpType(const std::string& type,
//! Create a new SpeciesThermoInterpType object from XML_Node
/*!
* @param speciesNode XML_Node defining the species (with child 'thermo' node)
* @param thermo 'thermo' XML_Node (child of the 'species' node) with child
* nodes representing parameterizations for one or more temperature ranges
* @return Returns the pointer to the newly allocated
* SpeciesThermoInterpType object
*/
SpeciesThermoInterpType* newSpeciesThermoInterpType(const XML_Node& speciesNode);
SpeciesThermoInterpType* newSpeciesThermoInterpType(const XML_Node& thermoNode);
}

View file

@ -361,7 +361,8 @@ void LatticeSolidPhase::installSlavePhases(Cantera::XML_Node* phaseNode)
}
addUniqueSpecies(lp->speciesName(k), &ecomp[0], lp->charge(k),
lp->size(k));
shared_ptr<SpeciesThermoInterpType> stit(newSpeciesThermoInterpType(*spNode[k]));
shared_ptr<SpeciesThermoInterpType> stit(
newSpeciesThermoInterpType(spNode[k]->child("thermo")));
stit->validate(spNode[k]->attrib("name"));
m_spthermo->install_STIT(kk, stit);
m_speciesData.push_back(new XML_Node(*(spNode[k])));

View file

@ -570,7 +570,8 @@ void SpeciesThermoFactory::installThermoForSpecies
(size_t k, const XML_Node& speciesNode, ThermoPhase* th_ptr,
SpeciesThermo& spthermo, const XML_Node* phaseNode_ptr) const
{
shared_ptr<SpeciesThermoInterpType> stit(newSpeciesThermoInterpType(speciesNode));
shared_ptr<SpeciesThermoInterpType> stit(
newSpeciesThermoInterpType(speciesNode.child("thermo")));
stit->validate(speciesNode["name"]);
spthermo.install_STIT(k, stit);
}
@ -595,18 +596,8 @@ void SpeciesThermoFactory::installVPThermoForSpecies(size_t k,
vp_ptr->createInstallPDSS(k, speciesNode, phaseNode_ptr);
}
SpeciesThermoInterpType* newSpeciesThermoInterpType(const XML_Node& speciesNode)
SpeciesThermoInterpType* newSpeciesThermoInterpType(const XML_Node& thermo)
{
/*
* Check to see that the species block has a thermo block
* before processing. Throw an error if not there.
*/
if (!(speciesNode.hasChild("thermo"))) {
throw UnknownSpeciesThermoModel("installThermoForSpecies",
speciesNode["name"], "<nonexistent>");
}
const XML_Node& thermo = speciesNode.child("thermo");
// Get the children of the thermo XML node. In the next bit of code we take out the comments that
// may have been children of the thermo XML node by doing a selective copy.
// These shouldn't interfere with the algorithm at any point.
@ -619,13 +610,11 @@ SpeciesThermoInterpType* newSpeciesThermoInterpType(const XML_Node& speciesNode)
}
std::string thermoType = lowercase(tp[0]->name());
std::string specName = speciesNode["name"];
for (size_t i = 1; i < tp.size(); i++) {
if (lowercase(tp[i]->name()) != thermoType) {
throw CanteraError("newSpeciesThermoInterpType",
"Encounter unsupported mixed species thermo parameterizations "
"for species '" + specName + "'.");
"Encounterd unsupported mixed species thermo parameterizations");
}
}
if ((tp.size() > 2 && thermoType != "nasa9") ||
@ -633,8 +622,7 @@ SpeciesThermoInterpType* newSpeciesThermoInterpType(const XML_Node& speciesNode)
thermoType == "mu0" ||
thermoType == "adsorbate"))) {
throw CanteraError("newSpeciesThermoInterpType",
"Too many regions in thermo parameterization for species '" +
specName + "'.");
"Too many regions in thermo parameterization.");
}
if (thermo["model"] == "MineralEQ3") {
@ -658,8 +646,8 @@ SpeciesThermoInterpType* newSpeciesThermoInterpType(const XML_Node& speciesNode)
} else if (thermoType == "statmech") {
return newStatMechThermoFromXML(*tp[0]);
} else {
throw UnknownSpeciesThermoModel("installThermoForSpecies",
specName, thermoType);
throw CanteraError("newSpeciesThermoInterpType",
"Unknown species thermo model '" + thermoType + "'.");
}
}

View file

@ -621,7 +621,7 @@ bool installSpecies(size_t k, const XML_Node& s, thermo_t& th,
vp_ptr->createInstallPDSS(k, s, phaseNode_ptr);
} else {
shared_ptr<Species> sp(new Species(s["name"], comp_map, chrg, sz));
sp->thermo.reset(newSpeciesThermoInterpType(s));
sp->thermo.reset(newSpeciesThermoInterpType(s.child("thermo")));
// Read gas-phase transport data, if provided
if (s.hasChild("transport") &&

View file

@ -394,7 +394,7 @@ void VPSSMgr::initThermoXML(XML_Node& phaseNode, const std::string& id)
void VPSSMgr::installSTSpecies(size_t k, const XML_Node& s,
const XML_Node* phaseNode_ptr)
{
shared_ptr<SpeciesThermoInterpType> stit(newSpeciesThermoInterpType(s));
shared_ptr<SpeciesThermoInterpType> stit(newSpeciesThermoInterpType(s.child("thermo")));
stit->validate(s["name"]);
m_spthermo->install_STIT(k, stit);
if (m_p0 < 0.0) {

View file

@ -103,7 +103,8 @@ VPSSMgr_IdealGas::createInstallPDSS(size_t k, const XML_Node& speciesNode,
m_Vss.resize(k+1, 0.0);
}
shared_ptr<SpeciesThermoInterpType> stit(newSpeciesThermoInterpType(speciesNode));
shared_ptr<SpeciesThermoInterpType> stit(
newSpeciesThermoInterpType(speciesNode.child("thermo")));
stit->validate(speciesNode["name"]);
m_spthermo->install_STIT(k, stit);