From 62dfdcfb01518ae0bb195f4f219a0a4977210f25 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 29 May 2013 00:10:58 +0000 Subject: [PATCH] [Cython] Added access to the "id" property of ThermoPhase objects --- interfaces/cython/cantera/_cantera.pxd | 2 ++ interfaces/cython/cantera/test/test_thermo.py | 7 +++++++ interfaces/cython/cantera/thermo.pyx | 10 ++++++++++ 3 files changed, 19 insertions(+) diff --git a/interfaces/cython/cantera/_cantera.pxd b/interfaces/cython/cantera/_cantera.pxd index e2cb6afa4..9f68a379b 100644 --- a/interfaces/cython/cantera/_cantera.pxd +++ b/interfaces/cython/cantera/_cantera.pxd @@ -47,6 +47,8 @@ cdef extern from "cantera/thermo/ThermoPhase.h" namespace "Cantera": string report(cbool) except + string name() void setName(string) + string id() + void setID(string) double minTemp() except + double maxTemp() except + double refPressure() except + diff --git a/interfaces/cython/cantera/test/test_thermo.py b/interfaces/cython/cantera/test/test_thermo.py index 2ab1bf724..b02c523e6 100644 --- a/interfaces/cython/cantera/test/test_thermo.py +++ b/interfaces/cython/cantera/test/test_thermo.py @@ -64,6 +64,13 @@ class TestThermoPhase(utilities.CanteraTest): self.assertEqual(self.phase.name, 'something') self.assertTrue('something' in 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') + def test_badLength(self): X = np.zeros(5) def set_X(): diff --git a/interfaces/cython/cantera/thermo.pyx b/interfaces/cython/cantera/thermo.pyx index 08c7949c2..7754a520d 100644 --- a/interfaces/cython/cantera/thermo.pyx +++ b/interfaces/cython/cantera/thermo.pyx @@ -43,6 +43,16 @@ cdef class ThermoPhase(_SolutionBase): def __set__(self, name): self.thermo.setName(stringify(name)) + property ID: + """ + The ID of the phase. The default is taken from the CTI/XML input file. + """ + def __get__(self): + return pystr(self.thermo.id()) + def __set__(self, id_): + self.thermo.setID(stringify(id_)) + + property basis: """ Determines whether intensive thermodynamic properties are treated on a