diff --git a/interfaces/cython/cantera/ck2yaml.py b/interfaces/cython/cantera/ck2yaml.py index 13ae27e81fd..a7cef641660 100644 --- a/interfaces/cython/cantera/ck2yaml.py +++ b/interfaces/cython/cantera/ck2yaml.py @@ -61,6 +61,9 @@ BlockMap = yaml.comments.CommentedMap +# url to cantera tutorial about Chemkin syntax instruction +url = "https://cantera.org/tutorials/ck2yaml-tutorial.html#debugging-common-errors-in-ck-files" + logger = logging.getLogger(__name__) loghandler = logging.StreamHandler(sys.stdout) logformatter = logging.Formatter('%(message)s') @@ -673,10 +676,12 @@ def __init__(self, label, geometry, well_depth, collision_diameter, except ValueError: raise InputError( "Bad geometry flag '{}' for species '{}', is the flag a float " - "or character? It should be an integer.", geometry, label) + "or character? It should be an integer. " + "Please check {} for correct Chemkin syntax", geometry, label, url) if geometry not in (0, 1, 2): - raise InputError("Bad geometry flag '{}' for species '{}'", - geometry, label) + raise InputError("Bad geometry flag '{}' for species '{}' " + "Please check {} for correct Chemkin syntax" + "", geometry, label, url) self.geometry = self.geometry_flags[int(geometry)] self.well_depth = float(well_depth) @@ -872,7 +877,8 @@ def read_NASA7_entry(self, lines, TintDefault, comments): if not composition: raise InputError("Error parsing elemental composition for " - "species '{}'", species) + "species '{}', Please check {} for correct Chemkin syntax" + "", species, url) for symbol in composition.keys(): # Some CHEMKIN input files may have quantities of elements with @@ -952,8 +958,9 @@ def read_NASA9_entry(self, entry, comments): fortFloat(C[64:80])] polys.append((Trange, coeffs)) except (IndexError, ValueError) as err: - raise InputError('Error while reading thermo entry for species {}:\n{}', - species, err) + raise InputError('Error while reading thermo entry for species {}:\n{}' + 'Please check {} about the correct Chemkin syntax.' + '',species, err, url) thermo = Nasa9(data=polys, note=note) @@ -1042,8 +1049,9 @@ def read_kinetics_entry(self, entry, surface): try: locs[j] = float(token), 'coeff' except ValueError: - raise InputError('Unexpected token "{}" in reaction expression "{}".', - token, original_reaction) + raise InputError('Unexpected token "{}" in reaction expression "{}"' + 'Please check {} about the correct Chemkin syntax' + '', token, original_reaction, url) reactants = [] products = [] @@ -1302,7 +1310,8 @@ def parse_expression(expression, dest): surface] if sum(bool(t) for t in tests) > 1: raise InputError('Reaction {} contains parameters for more than ' - 'one reaction type.', original_reaction) + 'one reaction type. Please check {} about the correct Chemkin syntax' + '', original_reaction, url) if cheb_coeffs: if Tmin is None or Tmax is None: diff --git a/interfaces/cython/cantera/test/test_convert.py b/interfaces/cython/cantera/test/test_convert.py index c25d4cc604b..bd1d45767b3 100644 --- a/interfaces/cython/cantera/test/test_convert.py +++ b/interfaces/cython/cantera/test/test_convert.py @@ -509,10 +509,9 @@ def test_duplicate_reactions(self): self.assertIn(token, message) def test_error_for_big_element_number(self): - with self.assertRaisesRegex(self.InputError, 'Element amounts'): + with self.assertRaisesRegex(self.InputError, 'Element amounts can have no more than 3 digits.'): self.convert('big_element_num_err.inp') - class CtmlConverterTest(utilities.CanteraTest): def test_sofc(self): gas_a, anode_bulk, oxide_a = ct.import_phases(