diff --git a/interfaces/cython/cantera/ck2cti.py b/interfaces/cython/cantera/ck2cti.py index 93323a737..4c40635a7 100644 --- a/interfaces/cython/cantera/ck2cti.py +++ b/interfaces/cython/cantera/ck2cti.py @@ -847,7 +847,12 @@ class TransportData(object): def __init__(self, label, geometry, wellDepth, collisionDiameter, dipoleMoment, polarizability, zRot, comment=None): - if int(geometry) not in (0,1,2): + try: + geometry = int(geometry) + except ValueError: + raise InputParseError("Bad geometry flag '{0}' for species '{1}', is the flag a float " + "or character? It should be an integer.".format(geometry, label)) + if geometry not in (0, 1, 2): raise InputParseError("Bad geometry flag '{0}' for species '{1}'".format(geometry, label)) self.label = label diff --git a/interfaces/cython/cantera/test/test_convert.py b/interfaces/cython/cantera/test/test_convert.py index 8c0a4f17e..fc5fbb579 100644 --- a/interfaces/cython/cantera/test/test_convert.py +++ b/interfaces/cython/cantera/test/test_convert.py @@ -348,6 +348,13 @@ class chemkinConverterTest(utilities.CanteraTest): outName=pjoin(self.test_work_dir, 'h2o2_transport_bad_geometry.cti'), quiet=True) + def test_transport_float_geometry(self): + with self.assertRaises(ck2cti.InputParseError): + convertMech(pjoin(self.test_data_dir, 'h2o2.inp'), + transportFile=pjoin(self.test_data_dir, 'h2o2-float-geometry-tran.dat'), + outName=pjoin(self.test_work_dir, 'h2o2_transport_float_geometry.cti'), + quiet=True) + def test_empty_reaction_section(self): convertMech(pjoin(self.test_data_dir, 'h2o2_emptyReactions.inp'), outName=pjoin(self.test_work_dir, 'h2o2_emptyReactions.cti'), diff --git a/test/data/h2o2-float-geometry-tran.dat b/test/data/h2o2-float-geometry-tran.dat new file mode 100644 index 000000000..dbfefc4cc --- /dev/null +++ b/test/data/h2o2-float-geometry-tran.dat @@ -0,0 +1,9 @@ +AR 0 136.500 3.330 0.000 0.000 0.000 +H 0.00 145.000 2.050 0.000 0.000 0.000 +H2 1.00 38.000 2.920 0.000 0.790 280.000 +H2O 2.00 572.400 2.605 1.844 0.000 4.000 +H2O2 2 107.400 3.458 0.000 0.000 3.800 +HO2 2 107.400 3.458 0.000 0.000 1.000 ! * +O 0 80.000 2.750 0.000 0.000 0.000 +O2 1 107.400 3.458 0.000 1.600 3.800 +OH 1 80.000 2.750 0.000 0.000 0.000