diff --git a/Cantera/src/thermo/LatticeSolidPhase.cpp b/Cantera/src/thermo/LatticeSolidPhase.cpp index 64da30a24..f4f2a911e 100644 --- a/Cantera/src/thermo/LatticeSolidPhase.cpp +++ b/Cantera/src/thermo/LatticeSolidPhase.cpp @@ -249,6 +249,38 @@ namespace Cantera { } } //==================================================================================================================== + void LatticeSolidPhase::installSlavePhases(Cantera::XML_Node* phaseNode) + { + int m, k; + for (int n = 0; n < m_nlattice; n++) { + LatticePhase *lp = m_lattice[n]; + int nsp = lp->nSpecies(); + vector constArr(lp->nElements()); + for (k = 0; k < nsp; k++) { + std::string sname = lp->speciesName(k); + std::map comp; + lp->getAtoms(k, DATA_PTR(constArr)); + for (m = 0; m < lp->nElements(); m++) { + if (constArr[m] != 0.0) { + std::string ename = lp->elementName(m); + comp[ename] = constArr[m]; + } + } + int nel = nElements(); + vector_fp ecomp(nel, 0.0); + for (m = 0; m < nel; m++) { + double anum = comp[elementName(m)]; + if (anum != 0.0) { + ecomp[m] = anum; + } + } + double chrg = lp->charge(k); + double sz = lp->size(k); + addUniqueSpecies(sname, &ecomp[0], chrg, sz); + } + } + } + //==================================================================================================================== void LatticeSolidPhase::initThermo() { m_kk = nSpecies(); m_mm = nElements(); diff --git a/Cantera/src/thermo/LatticeSolidPhase.h b/Cantera/src/thermo/LatticeSolidPhase.h index c605ae119..e8ee4d510 100644 --- a/Cantera/src/thermo/LatticeSolidPhase.h +++ b/Cantera/src/thermo/LatticeSolidPhase.h @@ -274,6 +274,12 @@ namespace Cantera { virtual void initThermo(); + //! Add in species from Slave phases + /*! + * This hook is used for cSS_CONVENTION_SLAVE phases + */ + virtual void installSlavePhases(Cantera::XML_Node* phaseNode); + virtual void setParametersFromXML(const XML_Node& eosdata); void setLatticeMoleFractions(int n, std::string x); diff --git a/Cantera/src/thermo/ThermoFactory.cpp b/Cantera/src/thermo/ThermoFactory.cpp index 8e3f52035..11741b193 100644 --- a/Cantera/src/thermo/ThermoFactory.cpp +++ b/Cantera/src/thermo/ThermoFactory.cpp @@ -561,7 +561,7 @@ namespace Cantera { // file. db = get_XML_Node(speciesArray["datasrc"], &phase.root()); if (db == 0) { - throw CanteraError("importPhase", + throw CanteraError("importPhase()", " Can not find XML node for species database: " + speciesArray["datasrc"]); } @@ -597,17 +597,29 @@ namespace Cantera { // install it in the phase object th->setSpeciesThermo(spth); - } else { + } else if (ssConvention == cSS_CONVENTION_SLAVE) { + /* + * No species thermo manager for this type + */ + } else if (ssConvention == cSS_CONVENTION_VPSS) { vp_spth = newVPSSMgr(vpss_ptr, &phase, spDataNodeList); vpss_ptr->setVPSSMgr(vp_spth); spth = vp_spth->SpeciesThermoMgr(); th->setSpeciesThermo(spth); + } else { + throw CanteraError("importPhase()", "unknown convention"); } int k = 0; int nsp = spDataNodeList.size(); + if (ssConvention == cSS_CONVENTION_SLAVE) { + if (nsp > 0) { + throw CanteraError("importPhase()", "For Slave standard states, number of species must be zero: " + + int2str(nsp)); + } + } for (int i = 0; i < nsp; i++) { XML_Node *s = spDataNodeList[i]; AssertTrace(s != 0); @@ -619,6 +631,10 @@ namespace Cantera { } } + if (ssConvention == cSS_CONVENTION_SLAVE) { + th->installSlavePhases(&phase); + } + // done adding species. th->freezeSpecies(); diff --git a/Cantera/src/thermo/ThermoPhase.cpp b/Cantera/src/thermo/ThermoPhase.cpp index afc819617..c1d1034a5 100644 --- a/Cantera/src/thermo/ThermoPhase.cpp +++ b/Cantera/src/thermo/ThermoPhase.cpp @@ -941,16 +941,20 @@ namespace Cantera { } xMol_Ref.resize(m_kk, 0.0); } + //==================================================================================================================== + void ThermoPhase::installSlavePhases(Cantera::XML_Node* phaseNode) { + } + //==================================================================================================================== void ThermoPhase::saveSpeciesData(const int k, const XML_Node* const data) { if ((int) m_speciesData.size() < (k + 1)) { m_speciesData.resize(k+1, 0); } m_speciesData[k] = new XML_Node(*data); } - - //! Return a pointer to the XML tree containing the species - /// data for this phase. + //==================================================================================================================== + // Return a pointer to the XML tree containing the species + // data for this phase. const std::vector & ThermoPhase::speciesData() const { if ((int) m_speciesData.size() != m_kk) { throw CanteraError("ThermoPhase::speciesData", diff --git a/Cantera/src/thermo/ThermoPhase.h b/Cantera/src/thermo/ThermoPhase.h index 19887fa1f..1d3f82443 100644 --- a/Cantera/src/thermo/ThermoPhase.h +++ b/Cantera/src/thermo/ThermoPhase.h @@ -2016,6 +2016,12 @@ namespace Cantera { */ virtual void initThermo(); + //! Add in species from Slave phases + /*! + * This hook is used for cSS_CONVENTION_SLAVE phases + */ + virtual void installSlavePhases(Cantera::XML_Node* phaseNode); + // The following methods are used by the clib interface // library, and should not be used by application programs.