Edit save_training_reactions in family.py to allow use for R_Recombination family#2922
Open
Nora-Khalil wants to merge 1 commit intomainfrom
Open
Edit save_training_reactions in family.py to allow use for R_Recombination family#2922Nora-Khalil wants to merge 1 commit intomainfrom
Nora-Khalil wants to merge 1 commit intomainfrom
Conversation
…ing reactions to be added to families that have multiple atoms with the same atom label. Only implemented for R_Recombination as of right now, where multiple atoms in the products are labeled as '*'.
Contributor
Author
|
Related to 8a057a4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
save_training_reactionsin family.py, this commit allows for training reactions to be added to families that have multiple atoms with the same atom label. Only implemented for R_Recombination as of right now, where two atoms in the product are both labeled as '*' since it is the simple recombination of two radicals and we don't need them individually numbered. I'm not sure if there are other families that do this too. If so, the assert statement in the new code introduced here would just have to be edited.Motivation or Problem
It's easy to use the
ipython/kinetics_library_to_training.ipynbscript to add new training reactions to a pre-existing kinetic family. However, if the family has a top-level group definition/recipe that labels multiple atoms in a reactant or product with the same label (i.e. R_Recombination), an error is encountered when we runfamily.save_training_reactions()to save new training reactions to this family's existing depository.To see if a new training reaction involves a species that already exists in the training dictionary.txt, the
save_training_datafunction will 1) see if the formula of the species in the new reaction matches any already in the dictionary and 2) if it finds a match, then retrieves the atom labeling for both the matched existing species and the species in the new reaction. However, in the python dict() that is returned from get_all_labeled_atoms, we will get something like this : {'*', [Atom F, Atom C]} in the case of the R_Recomb family (if we're getting the labeling of the product generated from the recombination). For the function to work properly, it's instead expecting something like this {'*': Atom F} or {'*1': Atom H}, so we get an error when the value of the dict() is a list.Description of Changes
Testing
To test, I added my new training reactions to R_Recombination via the ipython/kinetics_library_to_training.ipynb notebook (which successfully ran with out errors after these changes were introduced).
To confirm that everything looked good, I loaded the database in a separate script and ran something like:
To get a bunch of outputs like this:

I then visually confirmed that the atom labeling of the species involved in the new training reactions looks how it should.
Reviewer Tips
just do your best