Skip to content

Commit

Permalink
[Thermo] replace remaining references to Phase::name by Phase::id
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Oct 7, 2019
1 parent 3c98504 commit 5bf6357
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion interfaces/cython/cantera/test/test_thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,14 @@ 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')

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)
Expand Down
4 changes: 2 additions & 2 deletions src/clib/ct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ extern "C" {
int thermo_getName(int n, size_t lennm, char* nm)
{
try {
return static_cast<int>(copyString(ThermoCabinet::item(n).name(), nm, lennm));
return static_cast<int>(copyString(ThermoCabinet::item(n).id(), nm, lennm));
} catch (...) {
return handleAllExceptions(-1, ERR);
}
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/thermo/BinarySolutionTabulatedThermo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<AnyMap>();
vector_fp x = table["mole-fractions"].asVector<double>();
Expand Down
2 changes: 1 addition & 1 deletion src/thermo/LatticeSolidPhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ void LatticeSolidPhase::addLattice(shared_ptr<ThermoPhase> 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++) {
Expand Down
4 changes: 2 additions & 2 deletions src/thermo/MolalityVPSSTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions src/thermo/PureFluidPhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
1 change: 1 addition & 0 deletions src/thermo/ThermoFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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__"];
}
Expand Down
4 changes: 2 additions & 2 deletions src/thermo/ThermoPhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions test/thermo/phaseConstructors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,14 +508,14 @@ TEST(MargulesVPSSTP, fromScratch)
TEST(LatticeSolidPhase, fromScratch)
{
auto base = make_shared<StoichSubstance>();
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<LatticePhase>();
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;
Expand Down

0 comments on commit 5bf6357

Please sign in to comment.