Skip to content

Commit

Permalink
[unittest] Ensure yaml2ck handles notes correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Sep 9, 2023
1 parent 816d60d commit 475d855
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/data/species-names.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ species:
-1.02466476e+04, -4.64130376]
- [0.074851495, 0.0133909467, -5.73285809e-06, 1.22292535e-09, -1.0181523e-13,
-9468.34459, 18.437318]
note: 120521 # string incidentally serialized as integer
- name: plus
composition: {C: 1, H: 4}
thermo:
Expand All @@ -86,6 +87,7 @@ species:
-1.02466476e+04, -4.64130376]
- [0.074851495, 0.0133909467, -5.73285809e-06, 1.22292535e-09, -1.0181523e-13,
-9468.34459, 18.437318]
note: 12.05 # string incidentally serialized as float
- name: trans_butene
composition: {C: 1, H: 4}
thermo:
Expand Down
19 changes: 19 additions & 0 deletions test/python/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,25 @@ def test_write_chemkin(self):
self.check_kinetics(ck_phase, yaml_phase, [900, 1800], [2e5, 20e5], tol=2e-7)
self.check_transport(ck_phase, yaml_phase, [298, 1001, 2400])

def test_write_notes(self):
input_file = self.test_data_path / 'species-names.yaml'
yaml_phase = ct.Solution(input_file)
assert yaml_phase.species("eq=uals").input_data["thermo"]["note"] == 120521
assert yaml_phase.species("plus").input_data["thermo"]["note"] == 12.05

ck_file = self.test_work_path / 'species-names.ck'
ck_file.unlink(missing_ok=True)
yaml_phase.write_chemkin(ck_file, quiet=True)

yaml_file = self.test_work_path / 'species-names.yaml'
yaml_file.unlink(missing_ok=True)
ck2yaml.convert(ck_file, out_name=yaml_file, quiet=True)
assert yaml_file.exists()

ck_phase = ct.Solution(yaml_file)
assert ck_phase.species("eq=uals").input_data["thermo"]["note"] == "120521"
assert ck_phase.species("plus").input_data["thermo"]["note"] == "12.05"


class cti2yamlTest(utilities.CanteraTest):
def convert(self, basename, src_dir=None, encoding=None):
Expand Down

0 comments on commit 475d855

Please sign in to comment.