mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[Input] Add option of setting units to YamlWriter
This commit is contained in:
committed by
Ingmar Schoegl
parent
685168ce9b
commit
f6bd2c0954
@@ -64,6 +64,7 @@ cdef extern from "cantera/base/AnyMap.h" namespace "Cantera":
|
||||
CxxAnyValue& operator[](string) except +translate_exception
|
||||
cbool hasKey(string)
|
||||
string keys_str()
|
||||
void applyUnits()
|
||||
|
||||
cdef cppclass CxxAnyValue "Cantera::AnyValue":
|
||||
CxxAnyValue()
|
||||
|
||||
@@ -854,8 +854,9 @@ class TestReaction(utilities.CanteraTest):
|
||||
r = ct.ElementaryReaction({'O':1, 'H2':1}, {'H':1, 'OH':1})
|
||||
r.rate = ct.Arrhenius(3.87e1, 2.7, 2.6e7)
|
||||
data = r.input_data
|
||||
self.assertEqual(data['rate-constant'],
|
||||
{'A': 3.87e1, 'b': 2.7, 'Ea': 2.6e7})
|
||||
self.assertNear(data['rate-constant']['A'], 3.87e1)
|
||||
self.assertNear(data['rate-constant']['b'], 2.7)
|
||||
self.assertNear(data['rate-constant']['Ea'], 2.6e7)
|
||||
terms = data['equation'].split()
|
||||
self.assertIn('O', terms)
|
||||
self.assertIn('OH', terms)
|
||||
|
||||
@@ -117,6 +117,7 @@ cdef anyvalueToPython(string name, CxxAnyValue& v):
|
||||
|
||||
cdef anymapToPython(CxxAnyMap& m):
|
||||
py_items = []
|
||||
m.applyUnits()
|
||||
for item in m:
|
||||
py_items.append((item.second.order(),
|
||||
pystr(item.first),
|
||||
|
||||
Reference in New Issue
Block a user