[Cython] Add 'atomic_weight' method and 'atomic_weights' property

Resolves Issue 185.
This commit is contained in:
Ray Speth 2013-11-12 23:44:46 +00:00
parent bbaf0ff7a0
commit 81a8274e99
2 changed files with 10 additions and 0 deletions

View file

@ -69,6 +69,7 @@ cdef extern from "cantera/thermo/ThermoPhase.h" namespace "Cantera":
size_t nElements()
size_t elementIndex(string) except +
string elementName(size_t) except +
double atomicWeight(size_t) except +
# species properties
size_t nSpecies()

View file

@ -175,6 +175,15 @@ cdef class ThermoPhase(_SolutionBase):
def __get__(self):
return [self.element_name(m) for m in range(self.n_elements)]
def atomic_weight(self, m):
"""Atomic weight [kg/kmol] of element *m*"""
return self.thermo.atomicWeight(self.element_index(m))
property atomic_weights:
"""Array of atomic weight [kg/kmol] for each element in the mixture."""
def __get__(self):
return np.array([self.thermo.atomicWeight(m) for m in range(self.n_elements)])
property n_species:
"""Number of species."""
def __get__(self):