Skip to content

Commit

Permalink
[Input] Preserve YAML note field for ThermoPhase
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Jun 27, 2020
1 parent d2085c0 commit a9f2065
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
13 changes: 13 additions & 0 deletions include/cantera/thermo/Phase.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@ class Phase
return "Phase";
}

//! Return the annotation string
std::string note() const {
return m_note;
}

//! Set the annotation string
void setNote(const std::string& note) {
m_note = note;
}

//!@} end group Name

//! @name Element and Species Information
Expand Down Expand Up @@ -1004,6 +1014,9 @@ class Phase
std::vector<std::string> m_elementNames; //!< element names
vector_int m_elem_type; //!< Vector of element types

//! Annotation string describing the phase
std::string m_note;

//! Entropy at 298.15 K and 1 bar of stable state pure elements (J kmol-1)
vector_fp m_entropy298;

Expand Down
1 change: 1 addition & 0 deletions interfaces/cython/cantera/_cantera.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ cdef extern from "cantera/thermo/ThermoPhase.h" namespace "Cantera":

# miscellaneous
string type()
string note()
string phaseOfMatter() except +translate_exception
string report(cbool, double) except +translate_exception
cbool hasPhaseTransition()
Expand Down
5 changes: 5 additions & 0 deletions interfaces/cython/cantera/thermo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@ cdef class ThermoPhase(_SolutionBase):
def __get__(self):
return pystr(self.thermo.type())

property note:
""" Annotation string describing the thermo phase. """
def __get__(self):
return pystr(self.thermo.note())

property phase_of_matter:
"""
Get the thermodynamic phase (gas, liquid, etc.) at the current conditions.
Expand Down
3 changes: 2 additions & 1 deletion src/thermo/Phase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ Phase::Phase() :
m_mmw(0.0),
m_stateNum(-1),
m_mm(0),
m_elem_type(0)
m_elem_type(0),
m_note("")
{
}

Expand Down
2 changes: 2 additions & 0 deletions src/thermo/ThermoFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,8 @@ void setupPhase(ThermoPhase& thermo, AnyMap& phaseNode, const AnyMap& rootNode)
warn_deprecated(method, msg);
}

thermo.setNote(phaseNode.getString("note", ""));

// Add elements
if (phaseNode.hasKey("elements")) {
if (phaseNode.getBool("skip-undeclared-elements", false)) {
Expand Down
1 change: 1 addition & 0 deletions test/thermo/thermoFromYaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ TEST(ThermoFromYaml, elementOverride)
EXPECT_DOUBLE_EQ(thermo->atomicWeight(0), getElementWeight("N"));
EXPECT_DOUBLE_EQ(thermo->atomicWeight(1), getElementWeight("O"));
EXPECT_DOUBLE_EQ(thermo->atomicWeight(2), 36);
EXPECT_EQ(thermo->note(), "replace Argon with custom element");
}

TEST(ThermoFromYaml, elementFromDifferentFile)
Expand Down

0 comments on commit a9f2065

Please sign in to comment.