From 3f488b284114de53e539d668031e5ac3f26018e7 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 8 Aug 2012 22:16:25 +0000 Subject: [PATCH] Removed constructPhaseFile and constructPhaseXML methods from LatticePhase --- include/cantera/thermo/LatticePhase.h | 23 -------- src/thermo/LatticePhase.cpp | 85 +++------------------------ 2 files changed, 9 insertions(+), 99 deletions(-) diff --git a/include/cantera/thermo/LatticePhase.h b/include/cantera/thermo/LatticePhase.h index f47011432..36918be3c 100644 --- a/include/cantera/thermo/LatticePhase.h +++ b/include/cantera/thermo/LatticePhase.h @@ -294,29 +294,6 @@ public: */ ThermoPhase* duplMyselfAsThermoPhase() const; - //! Import and initialize a %LatticePhase phase specification from an XML tree into the current object. - /*! - * @param phaseNode XML file containing the description of the phase - * - * @param idTarget Optional parameter identifying the name of the - * phase. If none is given, the first XML phase element is used. - */ - void constructPhaseXML(XML_Node& phaseNode, std::string idTarget); - - //! Initialization of a %LatticePhase phase using an xml file - /*! - * - * This routine is a precursor to constructPhaseXML(XML_Node*) - * routine, which does most of the work. - * - * @param inputFile XML file containing the description of the phase - * - * @param id Optional parameter identifying the name of the - * phase. If none is given, the first XML - * phase element will be used. - */ - void constructPhaseFile(std::string inputFile, std::string id); - //! Equation of state flag. Returns the value cLattice virtual int eosType() const { return cLattice; diff --git a/src/thermo/LatticePhase.cpp b/src/thermo/LatticePhase.cpp index 00cd965d9..1ea20ae4f 100644 --- a/src/thermo/LatticePhase.cpp +++ b/src/thermo/LatticePhase.cpp @@ -89,7 +89,7 @@ LatticePhase::~LatticePhase() */ LatticePhase::LatticePhase(std::string inputFile, std::string id) { - constructPhaseFile(inputFile, id); + initThermoFile(inputFile, id); } // Full constructor for a water phase @@ -99,7 +99,7 @@ LatticePhase::LatticePhase(std::string inputFile, std::string id) */ LatticePhase::LatticePhase(XML_Node& phaseRef, std::string id) { - constructPhaseXML(phaseRef, id); + importPhase(*findXMLPhase(&phaseRef, id), this); } @@ -117,80 +117,7 @@ ThermoPhase* LatticePhase::duplMyselfAsThermoPhase() const return (ThermoPhase*) igp; } -/* - * @param infile XML file containing the description of the - * phase - * - * @param id Optional parameter identifying the name of the - * phase. If none is given, the first XML - * phase element will be used. - */ -void LatticePhase::constructPhaseXML(XML_Node& phaseNode, std::string idTarget) -{ - std::string idattrib = phaseNode.id(); - if (idTarget != idattrib) { - throw CanteraError("LatticePhase::constructPhaseXML","ids don't match"); - } - - /* - * Call the Cantera importPhase() function. This will import - * all of the species into the phase. This will also handle - * all of the solvent and solute standard states. - */ - bool m_ok = importPhase(phaseNode, this); - if (!m_ok) { - throw CanteraError("LatticePhase::constructPhaseXML","importPhase failed "); - } -} - -/* - * constructPhaseFile - * - * - * This routine is a precursor to constructPhaseXML(XML_Node*) - * routine, which does most of the work. - * - * @param inputFile XML file containing the description of the - * phase - * - * @param id Optional parameter identifying the name of the - * phase. If none is given, the first XML - * phase element will be used. - */ -void LatticePhase::constructPhaseFile(std::string inputFile, std::string id) -{ - - if (inputFile.size() == 0) { - throw CanteraError("LatticePhase::constructPhaseFile", - "input file is null"); - } - std::string path = findInputFile(inputFile); - std::ifstream fin(path.c_str()); - if (!fin) { - throw CanteraError("LatticePhase::constructPhaseFile","could not open " - +path+" for reading."); - } - /* - * The phase object automatically constructs an XML object. - * Use this object to store information. - */ - XML_Node& phaseNode_XML = xml(); - XML_Node* fxml = new XML_Node(); - fxml->build(fin); - XML_Node* fxml_phase = findXMLPhase(fxml, id); - if (!fxml_phase) { - throw CanteraError("LatticePhase::constructPhaseFile", - "ERROR: Can not find phase named " + - id + " in file named " + inputFile); - } - fxml_phase->copy(&phaseNode_XML); - constructPhaseXML(*fxml_phase, id); - delete fxml; -} - - -doublereal LatticePhase:: -enthalpy_mole() const +doublereal LatticePhase::enthalpy_mole() const { doublereal p0 = m_spthermo->refPressure(); return GasConstant * temperature() * @@ -503,6 +430,12 @@ void LatticePhase::initThermo() //==================================================================================================================== void LatticePhase::initThermoXML(XML_Node& phaseNode, std::string id) { + std::string idattrib = phaseNode.id(); + if (!id.empty() && id != idattrib) { + throw CanteraError("LatticePhase::initThermoXML", + "ids don't match"); + } + std::string subname = "LatticePhase::initThermoXML"; /* * Check on the thermo field. Must have: