diff --git a/include/cantera/thermo/SpeciesThermoFactory.h b/include/cantera/thermo/SpeciesThermoFactory.h index 9583691ba..57abe14e1 100644 --- a/include/cantera/thermo/SpeciesThermoFactory.h +++ b/include/cantera/thermo/SpeciesThermoFactory.h @@ -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); } diff --git a/src/thermo/LatticeSolidPhase.cpp b/src/thermo/LatticeSolidPhase.cpp index 321565a4f..478c026a9 100644 --- a/src/thermo/LatticeSolidPhase.cpp +++ b/src/thermo/LatticeSolidPhase.cpp @@ -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 stit(newSpeciesThermoInterpType(*spNode[k])); + shared_ptr 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]))); diff --git a/src/thermo/SpeciesThermoFactory.cpp b/src/thermo/SpeciesThermoFactory.cpp index 1ae25c048..aac531370 100644 --- a/src/thermo/SpeciesThermoFactory.cpp +++ b/src/thermo/SpeciesThermoFactory.cpp @@ -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 stit(newSpeciesThermoInterpType(speciesNode)); + shared_ptr 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"], ""); - } - 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 + "'."); } } diff --git a/src/thermo/ThermoFactory.cpp b/src/thermo/ThermoFactory.cpp index 850b2c1c7..56f4bef22 100644 --- a/src/thermo/ThermoFactory.cpp +++ b/src/thermo/ThermoFactory.cpp @@ -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 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") && diff --git a/src/thermo/VPSSMgr.cpp b/src/thermo/VPSSMgr.cpp index 21300d3a1..e62752b82 100644 --- a/src/thermo/VPSSMgr.cpp +++ b/src/thermo/VPSSMgr.cpp @@ -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 stit(newSpeciesThermoInterpType(s)); + shared_ptr stit(newSpeciesThermoInterpType(s.child("thermo"))); stit->validate(s["name"]); m_spthermo->install_STIT(k, stit); if (m_p0 < 0.0) { diff --git a/src/thermo/VPSSMgr_IdealGas.cpp b/src/thermo/VPSSMgr_IdealGas.cpp index dbe2206d4..3e3c322df 100644 --- a/src/thermo/VPSSMgr_IdealGas.cpp +++ b/src/thermo/VPSSMgr_IdealGas.cpp @@ -103,7 +103,8 @@ VPSSMgr_IdealGas::createInstallPDSS(size_t k, const XML_Node& speciesNode, m_Vss.resize(k+1, 0.0); } - shared_ptr stit(newSpeciesThermoInterpType(speciesNode)); + shared_ptr stit( + newSpeciesThermoInterpType(speciesNode.child("thermo"))); stit->validate(speciesNode["name"]); m_spthermo->install_STIT(k, stit);