Skip to content

Commit

Permalink
Merge pull request #2057 from ReactionMechanismGenerator/debug_librar…
Browse files Browse the repository at this point in the history
…y_to_training

Debug library to training script
  • Loading branch information
mjohnson541 authored Jan 12, 2021
2 parents 43a1ee9 + 04f618f commit 1e21621
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
15 changes: 8 additions & 7 deletions ipython/kinetics_library_to_training.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"# Set libraries to load reactions from; set to None to load all libraries\n",
"libraries = ['vinylCPD_H']\n",
"\n",
"# Set families to add training reactions to; either 'all' or a list, e.g. ['R_Addition_MultipleBond']\n",
"# Set families to add training reactions to; either 'default' or a list, e.g. ['R_Addition_MultipleBond']\n",
"families = ['Intra_R_Add_Endocyclic']\n",
"\n",
"# Specify whether to plot kinetics comparisons\n",
Expand Down Expand Up @@ -73,8 +73,9 @@
"# If we want accurate kinetics comparison, add existing training reactions and fill tree by averaging\n",
"if compare_kinetics:\n",
" for family in database.kinetics.families.values():\n",
" family.add_rules_from_training(thermo_database=database.thermo)\n",
" family.fill_rules_by_averaging_up(verbose=verbose_comments)"
" if not family.auto_generated:\n",
" family.add_rules_from_training(thermo_database=database.thermo)\n",
" family.fill_rules_by_averaging_up(verbose=verbose_comments)"
]
},
{
Expand All @@ -94,7 +95,7 @@
"source": [
"master_dict, multiple_dict = process_reactions(database,\n",
" libraries,\n",
" families,\n",
" list(database.kinetics.families.keys()),\n",
" compare_kinetics=compare_kinetics,\n",
" show_all=show_all,\n",
" filter_aromatic=filter_aromatic)"
Expand Down Expand Up @@ -213,9 +214,9 @@
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python [conda env:rmg_env]",
"display_name": "Python 3",
"language": "python",
"name": "conda-env-rmg_env-py"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -227,7 +228,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.7.7"
}
},
"nbformat": 4,
Expand Down
10 changes: 10 additions & 0 deletions ipython/kinetics_library_to_training_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display, HTML
from rmgpy.quantity import ScalarQuantity


# HTML formatting for output
Expand Down Expand Up @@ -178,6 +179,15 @@ def process_reactions(database, libraries, families, compare_kinetics=True, show
lib_rxn.reactants = fam_rxn.products
lib_rxn.products = fam_rxn.reactants

if len(lib_rxn.reactants) == 1:
units = 's^-1'
elif len(lib_rxn.reactants) == 2:
units = 'cm^3/(mol*s)'
elif len(lib_rxn.reactants) == 3:
units = 'cm^6/(mol^2*s)'
A = lib_rxn.kinetics.A
lib_rxn.kinetics.A = ScalarQuantity(value=A.value_si*A.get_conversion_factor_from_si_to_cm_mol_s(),units=units,uncertainty_type=A.uncertainty_type,uncertainty=A.uncertainty_si*A.get_conversion_factor_from_si_to_cm_mol_s())

if fam_rxn.family in reaction_dict:
reaction_dict[fam_rxn.family].append(lib_rxn)
else:
Expand Down
2 changes: 2 additions & 0 deletions rmgpy/data/kinetics/family.py
Original file line number Diff line number Diff line change
Expand Up @@ -2770,6 +2770,7 @@ def add_atom_labels_for_reaction(self, reaction, output_with_resonance=True):
if species.is_isomorphic(labeled_molecule, save_order=self.save_order):
species.molecule = [labeled_molecule]
reaction.products[index] = species
labeled_products.remove(labeled_molecule)
break
else:
raise ActionError('Could not find isomorphic molecule to fit the original product {} from '
Expand All @@ -2779,6 +2780,7 @@ def add_atom_labels_for_reaction(self, reaction, output_with_resonance=True):
if species.is_isomorphic(labeled_molecule, save_order=self.save_order):
species.molecule = [labeled_molecule]
reaction.reactants[index] = species
labeled_reactants.remove(labeled_molecule)
break
else:
raise ActionError('Could not find isomorphic molecule to fit the original reactant {} from '
Expand Down

0 comments on commit 1e21621

Please sign in to comment.