[Python/1D] Allow setting Inlet mole fractions using a dict
This commit is contained in:
parent
c7e2f5fcbc
commit
27e2aa16b8
2 changed files with 6 additions and 6 deletions
|
|
@ -208,12 +208,9 @@ cdef class Boundary1D(Domain1D):
|
|||
return self.phase.X
|
||||
|
||||
def __set__(self, X):
|
||||
cdef np.ndarray[np.double_t, ndim=1] data
|
||||
if isinstance(X, (str, unicode)):
|
||||
self.boundary.setMoleFractions(stringify(X))
|
||||
else:
|
||||
data = np.ascontiguousarray(X, dtype=np.double)
|
||||
self.boundary.setMoleFractions(&data[0])
|
||||
self.phase.TPX = None, None, X
|
||||
cdef np.ndarray[np.double_t, ndim=1] data = self.phase.X
|
||||
self.boundary.setMoleFractions(&data[0])
|
||||
|
||||
property Y:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -47,6 +47,9 @@ class TestOnedim(utilities.CanteraTest):
|
|||
self.assertArrayNear(inlet.X, Xref)
|
||||
self.assertArrayNear(inlet.Y, Yref)
|
||||
|
||||
inlet.X = {'H2':0.3, 'O2':0.5, 'AR':0.2}
|
||||
self.assertNear(inlet.X[gas2.species_index('H2')], 0.3)
|
||||
|
||||
def test_unpicklable(self):
|
||||
import pickle
|
||||
gas = ct.Solution('h2o2.xml')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue