diff --git a/rmgpy/chemkin.pyx b/rmgpy/chemkin.pyx index 0210f4d5404..f4f90385a1b 100644 --- a/rmgpy/chemkin.pyx +++ b/rmgpy/chemkin.pyx @@ -1533,8 +1533,11 @@ def write_thermo_entry(species, element_counts=None, verbose=True): # Line 1 string += '{0:<16} '.format(get_species_identifier(species)) - if len(element_counts) <= 5: + if len(element_counts) <= 4: # Use the original Chemkin syntax for the element counts + # Up to the first 4 elements only + # (don't use the space in columns 74-78 for the 5th element + # because nobody else does and Cantera can't read it) elements = [] for key, count in element_counts.items(): if isinstance(key, tuple): @@ -1543,23 +1546,22 @@ def write_thermo_entry(species, element_counts=None, verbose=True): else: chemkin_name = key elements.append('{0!s:<2}{1:>3d}'.format(chemkin_name, count)) - elements.extend([' '] * (5 - len(element_counts))) + elements.extend([' '] * (4 - len(element_counts))) string += ''.join(elements[0:4]) - string += 'G{0:>10.3f}{1:>10.3f}{2:>8.2f}{3} 1'.format( + string += 'G{0:>10.3f}{1:>10.3f}{2:>8.2f} 1'.format( thermo.polynomials[0].Tmin.value_si, thermo.polynomials[1].Tmax.value_si, thermo.polynomials[0].Tmax.value_si, - elements[4] ) else: + # Use the new-style Chemkin syntax for the element counts + # This will only be recognized by Chemkin 4 or later string += ' G{0:>10.3f}{1:>10.3f}{2:>8.2f} 1'.format( thermo.polynomials[0].Tmin.value_si, thermo.polynomials[1].Tmax.value_si, thermo.polynomials[0].Tmax.value_si, ) string += '&\n' - # Use the new-style Chemkin syntax for the element counts - # This will only be recognized by Chemkin 4 or later elements = [] for key, count in element_counts.items(): if isinstance(key, tuple): diff --git a/rmgpy/chemkinTest.py b/rmgpy/chemkinTest.py index 70e20b1f3b8..a0db0973e04 100644 --- a/rmgpy/chemkinTest.py +++ b/rmgpy/chemkinTest.py @@ -458,7 +458,8 @@ def setUp(self): -5.99027000E-08 2.38945000E-11-1.12576000E+04 3.56130000E+00 4 """ - self.entry2 = """CH3NO2X C 1H 3N 1O 2G 300.000 3000.000 650.73X 1 1 + self.entry2 = """CH3NO2X G 300.000 3000.000 650.73 1& +C 1 H 3 N 1 O 2 X 1 -3.07954000E-01 2.45269000E-02-1.24130000E-05 3.07724000E-09-3.01467000E-13 2 -1.06930000E+04 2.26280000E+01 4.03055000E+00-2.14171000E-03 4.90611000E-05 3 -5.99027000E-08 2.38945000E-11-1.12576000E+04 3.56130000E+00 4