Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ck2yaml] Fixed #940 SRI parameter D,E cannot be written into yaml file when they equal to zero #941

Merged
merged 3 commits into from
Dec 5, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions interfaces/cython/cantera/ck2yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,9 +670,9 @@ def __init__(self, *, A, B, C, D=None, E=None):

def reduce(self, output):
sri = FlowMap([('A', self.A), ('B', self.B), ('C', self.C)])
if self.D:
if self.D != None:
12Chao marked this conversation as resolved.
Show resolved Hide resolved
sri['D'] = self.D
if self.E:
if self.E != None:
12Chao marked this conversation as resolved.
Show resolved Hide resolved
sri['E'] = self.E

output['SRI'] = sri
Expand Down
13 changes: 12 additions & 1 deletion interfaces/cython/cantera/test/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,18 @@ def test_extra(self):
self.assertEqual(desc, 'This is an alternative description.')
for key in ['foo', 'bar']:
self.assertIn(key, yml.keys())

# This test tests it can convert the SRI parameters when D or E equal to 0

def test_sri_zero(self):
self.convert('sri_convert_test.txt')
output = pjoin(self.test_work_dir, 'sri_convert_test' + self.ext)
with open(output, 'r') as f:
mech = yaml.safe_load(f)
D = mech['reactions'][0]['SRI']['D']
E = mech['reactions'][0]['SRI']['E']
self.assertEqual(D, 0)
self.assertEqual(E, 0)

def test_duplicate_reactions(self):
# Running a test this way instead of using the convertMech function
# tests the behavior of the ck2yaml.main function and the mechanism
Expand Down
29 changes: 29 additions & 0 deletions test/data/sri_convert_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ELEMENTS
H
C
END
SPECIES
H
CH3
CH4
END
THERMO ALL
300. 1000. 3500.
CH3 C 1H 3 G 300.00 3500.00 1270.00 1
2.57723974e+00 6.62601164e-03-2.54906392e-06 4.67320141e-10-3.34867663e-14 2
1.65488693e+04 6.94195966e+00 3.53327401e+00 3.61488008e-03 1.00739068e-06 3
-1.39958516e-09 3.34014277e-13 1.63060366e+04 2.10113860e+00 4
CH4 C 1H 4 G 300.00 3500.00 1070.00 1
-2.82321416e-01 1.42739336e-02-6.77628877e-06 1.55380951e-09-1.39473841e-13 2
-9.36383584e+03 2.03507024e+01 2.85765313e+00 2.53571100e-03 9.67916346e-06 3
-8.69880870e-09 2.25599770e-12-1.00357904e+04 4.98969392e+00 4
H H 1 G 300.00 3500.00 1490.00 1
2.50000000e+00 7.40336223e-15-5.56967416e-18 1.73924876e-21-1.92673709e-25 2
2.54716200e+04-4.60117600e-01 2.50000000e+00-4.07455160e-15 5.98527266e-18 3
-3.43074982e-21 6.74775716e-25 2.54716200e+04-4.60117600e-01 4
END
REACTIONS
H+CH3(+M)=CH4(+M) 1.2000e+15 -0.400 0.00
LOW/ 6.40e+23 -1.800 0.0/
SRI/ 0.4500 797.0000 979.0000 0.0000 0.0000/
END