ARC icon indicating copy to clipboard operation
ARC copied to clipboard

Fix duplicate degeneracy multiplication and add training rules to kinetics families

Open Copilot opened this issue 4 months ago • 0 comments

Problem

The rmg_kinetics.py script had two issues affecting the accuracy of kinetic rate coefficient calculations:

  1. Double multiplication of the A factor by degeneracy: The code was multiplying the rate coefficient by degeneracy twice - once internally in family.get_kinetics() (which accepts a degeneracy parameter) and again explicitly via kinetics.change_rate(deg_rxn.degeneracy). This resulted in incorrect rate coefficients.

  2. Missing training rules incorporation: When loading the RMG database, training rules were not being added to kinetics families, which could result in incomplete kinetic data.

Changes

1. Removed duplicate degeneracy multiplication (line 101)

# Before
kinetics_list = family.get_kinetics(reaction=deg_rxn, template_labels=deg_rxn.template, degeneracy=deg_rxn.degeneracy)
for kinetics_detailes in kinetics_list:
    kinetics = kinetics_detailes[0]
    kinetics.change_rate(deg_rxn.degeneracy)  # ❌ Double multiplication!
    if hasattr(kinetics, 'to_arrhenius'):
        ...

# After
kinetics_list = family.get_kinetics(reaction=deg_rxn, template_labels=deg_rxn.template, degeneracy=deg_rxn.degeneracy)
for kinetics_detailes in kinetics_list:
    kinetics = kinetics_detailes[0]
    if hasattr(kinetics, 'to_arrhenius'):  # ✅ Degeneracy already applied
        ...

2. Added training rules to kinetics families

def load_rmg_database() -> RMGDatabase:
    rmgdb = RMGDatabase()
    ...
    rmgdb.load_kinetics(path=os.path.join(DB_PATH, 'kinetics'),
                        reaction_libraries=kinetics_libraries,
                        kinetics_families='default',
                        kinetics_depositories=['training'])
    # Add training rules to each family
    for family in rmgdb.kinetics.families.values():
        family.add_rules_from_training(rmgdb)
    return rmgdb

Impact

  • Kinetic rate coefficients will now have the correct A factor values (not multiplied by degeneracy twice)
  • Kinetics families will include rules derived from training data, providing more complete and accurate kinetic estimates
Original prompt

In the rmg_kinetics.py file, we need to make changes. We need to remove the line 'kin.change_rate(cand.degeneracy)' because that just multiplies the A twice before output. In the load RMG database section we need to call on 'for family in rmgdb.kinetics.families.values(): family.add_rules_from_training(rmgdb) I think we need to loop, I am not sure.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Oct 16 '25 06:10 Copilot