Skip to content

Commit 2773a63

Browse files
rwestclaude
andcommitted
Fix species rename from thermo library for reaction-generated species
7318b37 introduced a `rename` flag to `generate_thermo` to prevent user-labelled initial species from being silently renamed by a library match. However, it called `generate_thermo(spec)` (rename=False) inside `make_new_species`, caching `spec.thermo` before the rename-enabled call in `apply_thermo_to_species` could run — so the `if not spc.thermo` guard in `generate_thermo` always short-circuited the rename for reaction products, leaving them with SMILES labels (e.g. "O=O") instead of their library names (e.g. "O2(S)"). Fix: pass `rename=not bool(spec.label)` so that reaction-generated species (no label yet) are renamed from the library entry, while user-labelled initial species are left unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1ad3d07 commit 2773a63

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

rmgpy/rmg/model.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,11 @@ def make_new_species(self, object, label="", reactive=True, check_existing=True,
365365
spec.molecular_weight = Quantity(spec.molecule[0].get_molecular_weight() * 1000.0, "amu")
366366

367367
if generate_thermo:
368-
self.generate_thermo(spec)
368+
# Rename from thermo library label only if no user-provided label exists yet.
369+
self.generate_thermo(spec, rename=not bool(spec.label))
369370

370371
# If the species still does not have a label, set initial label as the SMILES
371-
# This may change later after getting thermo in self.generate_thermo()
372+
# (applies when generate_thermo is False, or when no library match was found)
372373
if not spec.label:
373374
spec.label = spec.smiles
374375

0 commit comments

Comments
 (0)