Skip to content

Commit

Permalink
Fix bug that didn't properly check all resonances structures when cre…
Browse files Browse the repository at this point in the history
…ating training reactions
  • Loading branch information
nyee committed Jun 1, 2017
1 parent 0381ce9 commit 23dfe63
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions scripts/convertKineticsLibraryToTrainingReactions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 23dfe63

Please sign in to comment.