From 5bf6357d9c744a64e1a132c7323587ae8fb2f19f Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Mon, 7 Oct 2019 12:34:57 -0500 Subject: [PATCH] [Thermo] replace remaining references to Phase::name by Phase::id --- interfaces/cython/cantera/test/test_thermo.py | 2 +- src/clib/ct.cpp | 4 ++-- src/thermo/BinarySolutionTabulatedThermo.cpp | 2 +- src/thermo/LatticeSolidPhase.cpp | 2 +- src/thermo/MolalityVPSSTP.cpp | 4 ++-- src/thermo/PureFluidPhase.cpp | 4 ++-- src/thermo/ThermoFactory.cpp | 1 + src/thermo/ThermoPhase.cpp | 4 ++-- test/thermo/phaseConstructors.cpp | 4 ++-- 9 files changed, 14 insertions(+), 13 deletions(-) diff --git a/interfaces/cython/cantera/test/test_thermo.py b/interfaces/cython/cantera/test/test_thermo.py index 19621a73e2..4a57f2ca1e 100644 --- a/interfaces/cython/cantera/test/test_thermo.py +++ b/interfaces/cython/cantera/test/test_thermo.py @@ -304,7 +304,6 @@ def test_name(self): self.phase.name = 'something' self.assertEqual(self.phase.name, 'something') - self.assertIn('something', self.phase.report()) def test_ID(self): self.assertEqual(self.phase.ID, 'ohmech') @@ -312,6 +311,7 @@ def test_ID(self): self.phase.ID = 'something' self.assertEqual(self.phase.ID, 'something') self.assertEqual(self.phase.name, 'ohmech') + self.assertIn('something', self.phase.report()) def test_badLength(self): X = np.zeros(5) diff --git a/src/clib/ct.cpp b/src/clib/ct.cpp index bc3e0631d8..2d0796b407 100644 --- a/src/clib/ct.cpp +++ b/src/clib/ct.cpp @@ -287,7 +287,7 @@ extern "C" { int thermo_getName(int n, size_t lennm, char* nm) { try { - return static_cast(copyString(ThermoCabinet::item(n).name(), nm, lennm)); + return static_cast(copyString(ThermoCabinet::item(n).id(), nm, lennm)); } catch (...) { return handleAllExceptions(-1, ERR); } @@ -296,7 +296,7 @@ extern "C" { int thermo_setName(int n, const char* nm) { try { - ThermoCabinet::item(n).setName(nm); + ThermoCabinet::item(n).setID(nm); return 0; } catch (...) { return handleAllExceptions(-1, ERR); diff --git a/src/thermo/BinarySolutionTabulatedThermo.cpp b/src/thermo/BinarySolutionTabulatedThermo.cpp index c43a17b67d..1061e9bbc9 100644 --- a/src/thermo/BinarySolutionTabulatedThermo.cpp +++ b/src/thermo/BinarySolutionTabulatedThermo.cpp @@ -91,7 +91,7 @@ void BinarySolutionTabulatedThermo::initThermo() throw InputFileError("BinarySolutionTabulatedThermo::initThermo", m_input["tabulated-species"], "Species '{}' is not in phase '{}'", - m_input["tabulated-species"].asString(), name()); + m_input["tabulated-species"].asString(), id()); } const AnyMap& table = m_input["tabulated-thermo"].as(); vector_fp x = table["mole-fractions"].asVector(); diff --git a/src/thermo/LatticeSolidPhase.cpp b/src/thermo/LatticeSolidPhase.cpp index 02293b85ba..484c1e3762 100644 --- a/src/thermo/LatticeSolidPhase.cpp +++ b/src/thermo/LatticeSolidPhase.cpp @@ -343,7 +343,7 @@ void LatticeSolidPhase::addLattice(shared_ptr lattice) void LatticeSolidPhase::setLatticeStoichiometry(const compositionMap& comp) { for (size_t i = 0; i < m_lattice.size(); i++) { - theta_[i] = getValue(comp, m_lattice[i]->name(), 0.0); + theta_[i] = getValue(comp, m_lattice[i]->id(), 0.0); } // Add in the lattice stoichiometry constraint for (size_t i = 1; i < m_lattice.size(); i++) { diff --git a/src/thermo/MolalityVPSSTP.cpp b/src/thermo/MolalityVPSSTP.cpp index 1571f1a5bf..d59af29470 100644 --- a/src/thermo/MolalityVPSSTP.cpp +++ b/src/thermo/MolalityVPSSTP.cpp @@ -380,8 +380,8 @@ std::string MolalityVPSSTP::report(bool show_thermo, doublereal threshold) const { fmt::memory_buffer b; try { - if (name() != "") { - format_to(b, "\n {}:\n", name()); + if (id() != "") { + format_to(b, "\n {}:\n", id()); } format_to(b, "\n"); format_to(b, " temperature {:12.6g} K\n", temperature()); diff --git a/src/thermo/PureFluidPhase.cpp b/src/thermo/PureFluidPhase.cpp index 2382ac5119..71fafe3a91 100644 --- a/src/thermo/PureFluidPhase.cpp +++ b/src/thermo/PureFluidPhase.cpp @@ -385,8 +385,8 @@ void PureFluidPhase::setState_Psat(doublereal p, doublereal x) std::string PureFluidPhase::report(bool show_thermo, doublereal threshold) const { fmt::memory_buffer b; - if (name() != "") { - format_to(b, "\n {}:\n", name()); + if (id() != "") { + format_to(b, "\n {}:\n", id()); } format_to(b, "\n"); format_to(b, " temperature {:12.6g} K\n", temperature()); diff --git a/src/thermo/ThermoFactory.cpp b/src/thermo/ThermoFactory.cpp index 387b47ccbe..239c4af6a3 100644 --- a/src/thermo/ThermoFactory.cpp +++ b/src/thermo/ThermoFactory.cpp @@ -448,6 +448,7 @@ void addSpecies(ThermoPhase& thermo, const AnyValue& names, const AnyValue& spec void setupPhase(ThermoPhase& thermo, AnyMap& phaseNode, const AnyMap& rootNode) { thermo.setName(phaseNode["name"].asString()); + thermo.setID(phaseNode["name"].asString()); if (rootNode.hasKey("__file__")) { phaseNode["__file__"] = rootNode["__file__"]; } diff --git a/src/thermo/ThermoPhase.cpp b/src/thermo/ThermoPhase.cpp index 8ebbee16eb..044a520493 100644 --- a/src/thermo/ThermoPhase.cpp +++ b/src/thermo/ThermoPhase.cpp @@ -926,8 +926,8 @@ std::string ThermoPhase::report(bool show_thermo, doublereal threshold) const { fmt::memory_buffer b; try { - if (name() != "") { - format_to(b, "\n {}:\n", name()); + if (id() != "") { + format_to(b, "\n {}:\n", id()); } format_to(b, "\n"); format_to(b, " temperature {:12.6g} K\n", temperature()); diff --git a/test/thermo/phaseConstructors.cpp b/test/thermo/phaseConstructors.cpp index f9808be6ea..00f8dc2a34 100644 --- a/test/thermo/phaseConstructors.cpp +++ b/test/thermo/phaseConstructors.cpp @@ -508,14 +508,14 @@ TEST(MargulesVPSSTP, fromScratch) TEST(LatticeSolidPhase, fromScratch) { auto base = make_shared(); - base->setName("Li7Si3(S)"); + base->setID("Li7Si3(S)"); base->setDensity(1390.0); auto sLi7Si3 = make_shomate2_species("Li7Si3(S)", "Li:7 Si:3", li7si3_shomate_coeffs); base->addSpecies(sLi7Si3); base->initThermo(); auto interstital = make_shared(); - interstital->setName("Li7Si3_Interstitial"); + interstital->setID("Li7Si3_Interstitial"); auto sLii = make_const_cp_species("Li(i)", "Li:1", 298.15, 0, 2e4, 2e4); auto sVac = make_const_cp_species("V(i)", "", 298.15, 8.98e4, 0, 0); sLii->extra["molar_volume"] = 0.2;