Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce species copying and resonance structure generation when reacting #1677

Merged
merged 3 commits into from
Aug 9, 2019

Conversation

mliu49
Copy link
Contributor

@mliu49 mliu49 commented Aug 8, 2019

Motivation or Problem

Two performance related changes, cherry-picked from #1577.

Description of Changes

  1. Do not make deep copies of species in react_species (reasoning)
  2. Remove a redundant resonance structure generation step

Testing

Tested with the liquid oxidation test from RMG-tests, but on the FilterCritPerReactFamily branch.

Should confirm that RMG-tests show no differences in models except for runtime.

@codecov
Copy link

codecov bot commented Aug 8, 2019

Codecov Report

Merging #1677 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1677      +/-   ##
==========================================
+ Coverage   41.78%   41.79%   +0.01%     
==========================================
  Files         177      177              
  Lines       30207    30206       -1     
  Branches     6252     6252              
==========================================
+ Hits        12622    12625       +3     
+ Misses      16661    16658       -3     
+ Partials      924      923       -1
Impacted Files Coverage Δ
rmgpy/rmg/react.py 86.53% <ø> (-0.26%) ⬇️
rmgpy/data/kinetics/common.py 70.14% <100%> (+0.94%) ⬆️
rmgpy/data/kinetics/family.py 48.71% <0%> (-0.21%) ⬇️
rmgpy/data/kinetics/database.py 51.11% <0%> (+1.73%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fabc165...6d110a3. Read the comment docs.

@codecov
Copy link

codecov bot commented Aug 8, 2019

Codecov Report

Merging #1677 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1677      +/-   ##
==========================================
+ Coverage   41.78%   41.79%   +0.01%     
==========================================
  Files         177      177              
  Lines       30207    30206       -1     
  Branches     6252     6252              
==========================================
+ Hits        12622    12625       +3     
+ Misses      16661    16658       -3     
+ Partials      924      923       -1
Impacted Files Coverage Δ
rmgpy/rmg/react.py 86.53% <ø> (-0.26%) ⬇️
rmgpy/data/kinetics/common.py 70.14% <100%> (+0.94%) ⬆️
rmgpy/data/kinetics/family.py 48.71% <0%> (-0.21%) ⬇️
rmgpy/data/kinetics/database.py 51.11% <0%> (+1.73%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fabc165...cc3ed41. Read the comment docs.

Copy link
Contributor

@mjohnson541 mjohnson541 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes all make sense as far as I've tracked them through RMG. Just some comments on the new tests.

@@ -1091,3 +1091,97 @@ def test_add_atom_labels_for_reaction_3(self):
self.assertIn('*2',found_labels)
self.assertIn('*3',found_labels)

def test_species_preserved_after_generate_reactions(self):
"""Test that Species objects do not retain changes after generating reactions"""
r1 = Species(index=1, label='ethyl', SMILES='C[CH2]')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use something more descriptive than r1? We more commonly use r for reaction than reactant, which can result in some confusion here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like it should be clear from context, but I changed them anyway.

self.assertIsNot(r1, r2_out)

# The molecule objects should be the same references for the first output species
self.assertIsNot(r1.molecule[0], r1_out.molecule[0])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is one of them the molecule objects the same reference and the other isn't? Why can't all identical molecule objects be the same reference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they were the same object then you couldn't assign different labels to the atoms.

mliu49 added 3 commits August 8, 2019 23:07
Test that Species objects passed to generate_reactions_from_families
do not retain any modifications after reaction generation
@mjohnson541 mjohnson541 merged commit e9a650d into master Aug 9, 2019
@mjohnson541 mjohnson541 deleted the speedups branch August 9, 2019 04:46
@mliu49 mliu49 mentioned this pull request Dec 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants