Skip to content

chemkin newline destroys group in thermo comments #2926

@sevyharris

Description

@sevyharris

Bug Description

When read in species from chem_annotated.inp, if the newline comes in the middle of a group, the group gets lost when I run extract_source_from_comments.

Here's an example comment for the example species smiles='[O]OC(C#N)(C)C'

Thermo group additivity estimation: group(O2s-OsCs) + group(O2s-OsH) + group(N3t-(Cs)Ct) + group(Cs-(Cds-Cds)CsCsOs) + group(Cs-CsHHH) + group(Cs-
CsHHH) + group(Ct-N3tCs) + radical(C3COOJ)

Before writing to chemkin, there are 8 groups:

{'GAV': {'group': [(<Entry index=2335 label="O2s-OsCs">, 1),
   (<Entry index=2317 label="O2s-OsH">, 1),
   (<Entry index=2673 label="N3t-(Cs)Ct">, 1),
   (<Entry index=1703 label="Cs-(Cds-Cds)CsCsOs">, 1),
   (<Entry index=921 label="Cs-CsHHH">, 2),
   (<Entry index=112 label="Ct-N3tCs">, 1)],
  'radical': [(<Entry index=1874 label="C3COOJ">, 1)]}}

After reading from chemkin, there are 7 groups

{'GAV': {'group': [(<Entry index=2335 label="O2s-OsCs">, 1),
   (<Entry index=2317 label="O2s-OsH">, 1),
   (<Entry index=2673 label="N3t-(Cs)Ct">, 1),
   (<Entry index=1703 label="Cs-(Cds-Cds)CsCsOs">, 1),
   (<Entry index=921 label="Cs-CsHHH">, 1),
   (<Entry index=112 label="Ct-N3tCs">, 1)],
  'radical': [(<Entry index=1874 label="C3COOJ">, 1)]}}

How To Reproduce

Here's a script to test the effect:

import rmgpy.chemkin
import rmgpy.data.rmg

# load database
database = rmgpy.data.rmg.RMGDatabase()
database.load(
    path=rmgpy.settings['database.directory'],
    thermo_libraries=[],
    transport_libraries=[],
    reaction_libraries=[],
    seed_mechanisms=[],
    kinetics_families='none',
    kinetics_depositories=[],
    depository=False,
)

# make a species - it has 8 groups
sp = rmgpy.species.Species(smiles='[O]OC(C#N)(C)C')
sp.thermo = database.thermo.get_thermo_data(sp).to_nasa(300, 3000, 1000)
display(database.thermo.extract_source_from_comments(sp))

# write the chemkin and read back in and you'll only count 7
rmgpy.chemkin.save_chemkin_file('test.inp', [sp], [])
rmgpy.chemkin.save_species_dictionary('test.txt', [sp], [])
species_list, _ = rmgpy.chemkin.load_chemkin_file('test.inp', 'test.txt')
display(database.thermo.extract_source_from_comments(species_list[0]))

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions