diff --git a/scripts/convertKineticsLibraryToTrainingReactions.ipynb b/scripts/convertKineticsLibraryToTrainingReactions.ipynb index 2250dce58e..dc4656b60f 100644 --- a/scripts/convertKineticsLibraryToTrainingReactions.ipynb +++ b/scripts/convertKineticsLibraryToTrainingReactions.ipynb @@ -36,6 +36,7 @@ "from rmgpy.rmg.model import Species\n", "from rmgpy import settings\n", "from IPython.display import display, HTML, Image\n", + "import itertools\n", "from base64 import b64encode\n", "if compareKinetics:\n", " import numpy as np\n", @@ -106,21 +107,21 @@ " commentsDict[lib_rxn] = [entry.reference, entry.referenceType, entry.shortDesc, entry.longDesc] #save comments to add to training\n", " # Let's make RMG try to generate this reaction from the families!\n", " fam_rxn_list = []\n", - " rxt_mol_mutation_num = 1\n", - " pdt_mol_mutation_num = 1\n", - " for reactant in lib_rxn.reactants:\n", - " rxt_mol_mutation_num *= len(reactant.molecule)\n", - "\n", - " for product in lib_rxn.products:\n", - " pdt_mol_mutation_num *= len(product.molecule)\n", - "\n", - " for mutation_i in range(rxt_mol_mutation_num):\n", - " rxts_mol = [spc.molecule[mutation_i%(len(spc.molecule))] for spc in lib_rxn.reactants]\n", - " pdts_mol = [spc.molecule[0] for spc in lib_rxn.products]\n", + " \n", + " #get list of all possible resonance structures of reactant molecules\n", + " if len(lib_rxn.reactants) > 1:\n", + " rxt_resonances = [rxt.molecule for rxt in lib_rxn.reactants]\n", + " rxts_cross = list(itertools.product(*rxt_resonances))\n", + " rxts_cross = [list(cross) for cross in rxts_cross]\n", + " else:\n", + " rxts_cross = [[mol] for mol in lib_rxn.reactants[0].mol] #should have only one reactant\n", + " \n", + " #use families to try find reactions\n", + " for rxts_mol in rxts_cross:\n", + " pdts_mol = [spc.molecule[0] for spc in lib_rxn.products] #do we also need to cross through products.mol\n", " fam_rxn_list.extend(database.kinetics.generateReactionsFromFamilies(\n", " reactants=rxts_mol, products=pdts_mol))\n", "\n", - "\n", " if len(fam_rxn_list) == 1:\n", " fam_rxn = fam_rxn_list[0]\n", "\n",