[Base] break out thermo/kinetics manager types to Python
This commit is contained in:
parent
f71954ac96
commit
b926a31faf
4 changed files with 39 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue