diff --git a/interfaces/cython/cantera/base.pyx b/interfaces/cython/cantera/base.pyx index de5ef9cd9..7ef88c8d6 100644 --- a/interfaces/cython/cantera/base.pyx +++ b/interfaces/cython/cantera/base.pyx @@ -101,6 +101,21 @@ cdef class _SolutionBase: def __set__(self, name): self.base.setName(stringify(name)) + property composite: + """ + Returns tuple of thermo/kinetics/transport models associated with + this SolutionBase object. + """ + def __get__(self): + thermo = None if self.thermo == NULL \ + else pystr(self.thermo.type()) + kinetics = None if self.kinetics == NULL \ + else pystr(self.kinetics.kineticsType()) + transport = None if self.transport == NULL \ + else pystr(self.transport.transportType()) + + return thermo, kinetics, transport + def _init_yaml(self, infile, phaseid, phases, source): """ Instantiate a set of new Cantera C++ objects from a YAML diff --git a/interfaces/cython/cantera/kinetics.pyx b/interfaces/cython/cantera/kinetics.pyx index 89e7544c9..f3c71bb8c 100644 --- a/interfaces/cython/cantera/kinetics.pyx +++ b/interfaces/cython/cantera/kinetics.pyx @@ -31,6 +31,13 @@ cdef class Kinetics(_SolutionBase): kwargs['base_type'] = base_type super().__init__(*args, **kwargs) + property kinetics_model: + """ + Return type of kinetics. + """ + def __get__(self): + return pystr(self.kinetics.kineticsType()) + property n_total_species: """ Total number of species in all phases participating in the kinetics diff --git a/interfaces/cython/cantera/test/test_thermo.py b/interfaces/cython/cantera/test/test_thermo.py index 3c319ab5d..ddce98b28 100644 --- a/interfaces/cython/cantera/test/test_thermo.py +++ b/interfaces/cython/cantera/test/test_thermo.py @@ -13,10 +13,19 @@ class TestThermoPhase(utilities.CanteraTest): def setUp(self): self.phase = ct.Solution('h2o2.xml') - def test_cpp_attributes(self): + def test_base_attributes(self): self.assertTrue(isinstance(self.phase.type, str)) self.assertTrue(self.phase.type=='Solution') self.assertTrue(isinstance(self.phase.name, str)) + self.assertTrue(isinstance(self.phase.thermo_model, str)) + self.assertTrue(isinstance(self.phase.kinetics_model, str)) + self.assertTrue(isinstance(self.phase.transport_model, str)) + self.assertTrue(isinstance(self.phase.composite, tuple)) + self.assertTrue(len(self.phase.composite)==3) + self.assertTrue( + self.phase.composite == (self.phase.thermo_model, + self.phase.kinetics_model, + self.phase.transport_model)) self.phase.name = 'spam' self.assertTrue(self.phase.name=='spam') with self.assertRaises(AttributeError): diff --git a/interfaces/cython/cantera/thermo.pyx b/interfaces/cython/cantera/thermo.pyx index 20088b6e4..fa143b0e1 100644 --- a/interfaces/cython/cantera/thermo.pyx +++ b/interfaces/cython/cantera/thermo.pyx @@ -271,6 +271,13 @@ cdef class ThermoPhase(_SolutionBase): self.thermo_basis = mass_basis self._references = weakref.WeakKeyDictionary() + property thermo_model: + """ + Return thermodynamic model describing phase. + """ + def __get__(self): + return pystr(self.thermo.type()) + def report(self, show_thermo=True, float threshold=1e-14): """ Generate a report describing the thermodynamic state of this phase. To