[Python] Convert both dicts and strings to compositionMap
This commit is contained in:
parent
f4715c671f
commit
9e4e73da90
3 changed files with 12 additions and 5 deletions
|
|
@ -31,6 +31,9 @@ cdef extern from "cantera/base/xml.h" namespace "Cantera":
|
|||
XML_Node* findID(string)
|
||||
int nChildren()
|
||||
|
||||
cdef extern from "cantera/base/stringUtils.h" namespace "Cantera":
|
||||
cdef Composition parseCompString(string) except +
|
||||
|
||||
cdef extern from "cantera/base/global.h" namespace "Cantera":
|
||||
cdef void CxxAddDirectory "Cantera::addDirectory" (string)
|
||||
cdef size_t CxxNpos "Cantera::npos"
|
||||
|
|
|
|||
|
|
@ -677,8 +677,8 @@ class TestReaction(utilities.CanteraTest):
|
|||
|
||||
def test_falloff(self):
|
||||
r = ct.FalloffReaction()
|
||||
r.reactants = {'OH':2}
|
||||
r.products = {'H2O2':1}
|
||||
r.reactants = 'OH:2'
|
||||
r.products = 'H2O2:1'
|
||||
r.high_rate = ct.Arrhenius(7.4e10, -0.37, 0.0)
|
||||
r.low_rate = ct.Arrhenius(2.3e12, -0.9, -1700*1000*4.184)
|
||||
r.falloff = ct.TroeFalloff((0.7346, 94, 1756, 5182))
|
||||
|
|
@ -724,8 +724,8 @@ class TestReaction(utilities.CanteraTest):
|
|||
species = ct.Species.listFromFile('pdep-test.cti')
|
||||
|
||||
r = ct.ChebyshevReaction()
|
||||
r.reactants = {'R5': 1, 'H': 1}
|
||||
r.products = {'P5A': 1, 'P5B': 1}
|
||||
r.reactants = 'R5:1, H:1'
|
||||
r.products = 'P5A:1, P5B:1'
|
||||
r.set_parameters(Tmin=300.0, Tmax=2000.0, Pmin=1000, Pmax=10000000,
|
||||
coeffs=[[ 5.28830e+00, -1.13970e+00, -1.20590e-01, 1.60340e-02],
|
||||
[ 1.97640e+00, 1.00370e+00, 7.28650e-03, -3.04320e-02],
|
||||
|
|
|
|||
|
|
@ -35,7 +35,11 @@ def appdelete():
|
|||
""" Delete all global Cantera C++ objects """
|
||||
CxxAppdelete()
|
||||
|
||||
cdef Composition comp_map(dict X) except *:
|
||||
cdef Composition comp_map(X) except *:
|
||||
if isinstance(X, (str, unicode, bytes)):
|
||||
return parseCompString(stringify(X))
|
||||
|
||||
# assume X is dict-like
|
||||
cdef Composition m
|
||||
for species,value in X.items():
|
||||
m[stringify(species)] = value
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue