Skip to content

Custom filter criteria per reaction family#1577

Closed
ajocher wants to merge 16 commits into
masterfrom
FilterCritPerReactFamily
Closed

Custom filter criteria per reaction family#1577
ajocher wants to merge 16 commits into
masterfrom
FilterCritPerReactFamily

Conversation

@ajocher

@ajocher ajocher commented Apr 16, 2019

Copy link
Copy Markdown
Contributor

Motivation or Problem

By filtering reactions we add a pre-filtering step before the step of reacting species together (slow), which prevents species from reacting together when the reactions are expected to be negligible throughout the simulation. Currently, unimolecularThreshold, bimolecularThreshold, and trimolecularThreshold are binary arrays storing flags for whether a species or a pair of species are above a reaction threshold. For a unimolecular rate, this threshold is set to True if the unimolecular rate of reaction 𝑘 reaction k for a species A
image
at any given time 𝑡 t in the reaction system, where
image
For a bimolecular reaction occuring between species A and B, this threshold is set to True if the bimolecular rate
image
where 𝑘𝑡ℎ𝑟𝑒𝑠ℎ𝑜𝑙𝑑=filterThreshold is set by the user in the input file and its default value is
image.
Similarly, for a trimolecular reaction, the following expression is used:
image
where
image
The threshold values can be refined for each reaction family to speed reaction generation up.

Description of Changes

In this pull request we will refine the threshold values for uni-/bi- and trimolecular reactions by evaluating an Arrhenius fit for each reaction family at the user defined reactor temperature. The Arrhenius fits were obtained by extracting the highest reaction rates from all training reactions of one family for a discrete set of temperatures. The ipython notebook is RMG-Py/ipython/kinetics_training_analysis.ipynb.

Testing

Tested superminimal and minimal example with reaction filtering turned on. The latter one also with pdep.

Reviewer Tips

This pull request shouldn't dramatically change the core model of your own test case, but speed reaction generation up.

Modified Travis to simultaneously update RMG-Py and RMG-database. When merging, the code reviewer should remove the temporary commit on RMG-Py.

@ajocher
ajocher force-pushed the FilterCritPerReactFamily branch from 2015b68 to 84413cf Compare April 17, 2019 13:15
@ajocher ajocher changed the title Filter crit per react family Custom filter criteria per reaction family Apr 17, 2019
@ajocher
ajocher force-pushed the FilterCritPerReactFamily branch from b72dc72 to 5cf31b0 Compare April 18, 2019 18:49
@codecov

codecov Bot commented Apr 18, 2019

Copy link
Copy Markdown

Codecov Report

Merging #1577 into master will decrease coverage by 0.03%.
The diff coverage is 38.95%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1577      +/-   ##
=========================================
- Coverage   44.24%   44.2%   -0.04%     
=========================================
  Files          83      83              
  Lines       21551   21627      +76     
  Branches     5648    5668      +20     
=========================================
+ Hits         9535    9561      +26     
- Misses      10958   11010      +52     
+ Partials     1058    1056       -2
Impacted Files Coverage Δ
arkane/explorer.py 7.85% <0%> (-0.05%) ⬇️
rmgpy/rmg/settings.py 82.6% <100%> (+0.38%) ⬆️
rmgpy/rmg/input.py 42.57% <20%> (-0.07%) ⬇️
rmgpy/rmg/main.py 21.91% <4.93%> (-0.23%) ⬇️
rmgpy/rmg/react.py 81.96% <71.42%> (-4.58%) ⬇️
rmgpy/data/kinetics/database.py 50.44% <85.36%> (-0.17%) ⬇️
rmgpy/data/kinetics/common.py 68.02% <0%> (-1.02%) ⬇️

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 7b3ab69...e034790. Read the comment docs.

@ajocher
ajocher force-pushed the FilterCritPerReactFamily branch 2 times, most recently from b649749 to c131602 Compare April 19, 2019 15:36
@ajocher
ajocher force-pushed the FilterCritPerReactFamily branch 2 times, most recently from 04e3f8d to 054faeb Compare April 26, 2019 14:46
@ajocher
ajocher force-pushed the FilterCritPerReactFamily branch 2 times, most recently from 1d37c15 to 0461ca4 Compare June 14, 2019 21:39
@ajocher
ajocher force-pushed the FilterCritPerReactFamily branch 3 times, most recently from f326ccd to 9105935 Compare June 25, 2019 13:41
@ajocher
ajocher force-pushed the FilterCritPerReactFamily branch 3 times, most recently from c184e87 to f336ff1 Compare June 28, 2019 15:48
@amarkpayne
amarkpayne force-pushed the FilterCritPerReactFamily branch from 229fcf1 to e75dd51 Compare July 11, 2019 17:08
Comment thread rmgpy/data/kinetics/family.py Outdated
Comment thread rmgpy/data/kinetics/family.py Outdated
Comment thread rmgpy/data/kinetics/family.py Outdated
Comment thread rmgpy/data/kinetics/family.py Outdated
Comment thread rmgpy/data/kinetics/family.py Outdated
Comment thread rmgpy/data/kinetics/family.py Outdated
Comment thread rmgpy/rmg/main.py Outdated
Comment thread rmgpy/rmg/react.py Outdated
Comment thread rmgpy/solver/base.pyx Outdated
Comment thread rmgpy/solver/base.pyx Outdated
Comment thread rmgpy/solver/base.pyx Outdated
Comment thread arkane/explorer.py Outdated
Comment thread arkane/explorer.py Outdated
Comment thread arkane/explorer.py Outdated
Comment thread arkane/explorer.py Outdated
Comment thread arkane/explorer.py Outdated
Comment thread rmgpy/solver/liquidTest.py Outdated
Comment thread rmgpy/solver/simpleTest.py Outdated
Comment thread rmgpy/solver/simpleTest.py Outdated
Comment thread rmgpy/solver/surfaceTest.py Outdated
Comment thread rmgpy/solver/surfaceTest.py Outdated
Comment thread rmgpy/rmg/settings.py Outdated
Comment thread rmgpy/data/kinetics/familyTest.py Outdated
Comment thread rmgpy/data/kinetics/familyTest.py Outdated
Comment thread rmgpy/data/kinetics/familyTest.py Outdated
Comment thread rmgpy/data/kinetics/familyTest.py Outdated
Comment thread rmgpy/rmg/react.py Outdated
@amarkpayne
amarkpayne force-pushed the FilterCritPerReactFamily branch from 3804be0 to 1da5304 Compare July 18, 2019 15:19
@ajocher
ajocher force-pushed the FilterCritPerReactFamily branch from 8b1f75f to d125ce2 Compare July 22, 2019 22:37

@amarkpayne amarkpayne left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Quick comments to help fix your codacy issues

Comment thread testing/checkFilterFits.py Outdated
Comment thread testing/checkFilterFits.py Outdated
@ajocher
ajocher force-pushed the FilterCritPerReactFamily branch 2 times, most recently from 6143b5d to 04398f9 Compare July 24, 2019 18:02
@mliu49

mliu49 commented Aug 8, 2019

Copy link
Copy Markdown
Contributor

I skimmed through the reaction generation code again, and I'm fairly sure that it's safe to not copy species before reacting. I added a unit test to confirm that a couple notable Species and Molecule attributes are not affected by the reaction generation process. Let me know if you think there are other attributes we should check.

Based on that, I removed species copying from react_species. I also removed a redundant resonance structure generation step in ensure_independent_atom_ids. Finally, I restored the prior behavior where family splitting is only employed when running in parallel, which reduces the number species tuples created for reaction generation.

To summarize the runtime differences:

stage runtime change
master 442 s --
custom filter criteria v1 1270 s +828
optimize filter threshold 780 s -490
remove species copy 509 s -271
remove res gen 442 s -67
change family splitting 339 s -103

Two of the changes I added make custom filter criteria more efficient, while two are unrelated and could also be applied on master. That means that for this particular example, custom filtering still hurts performance. I think that additional profiling would be a good idea, probably with longer jobs.

@ajocher

ajocher commented Aug 8, 2019

Copy link
Copy Markdown
Contributor Author

Thanks for helping, I really appreciate it. My untested suspicion is that some of the Numpy vectorization operations we have added, especially in the .pyx files might not be as fast as the for loops that were there before.

@amarkpayne

Copy link
Copy Markdown
Member

Thanks for helping, I really appreciate it. My untested suspicion is that some of the Numpy vectorization operations we have added, especially in the .pyx files might not be as fast as the for loops that were there before.

I agree with @ajocher . Specifically, I think my recommendations here were bad and should be reverted back to for loops

@mliu49 mliu49 added After Py3 To be addressed after Python 3 transition and removed Before Py3 Should be merged before Python 3 transition labels Aug 9, 2019
@ajocher
ajocher force-pushed the FilterCritPerReactFamily branch 2 times, most recently from 41e71f1 to 3587fdb Compare January 23, 2020 19:47
@ajocher
ajocher requested a review from amarkpayne January 27, 2020 10:29
@ajocher
ajocher force-pushed the FilterCritPerReactFamily branch from 0fe372e to e034790 Compare January 27, 2020 10:30
@JacksonBurns

Copy link
Copy Markdown
Contributor

This PR is attempting to merge into master, which is abandoned. Closing this PR as stale and deleting the branch.

If there are commits on this branch that should be merged into main, please restore the branch, cherry pick them, and open a new PR.

@JacksonBurns
JacksonBurns deleted the FilterCritPerReactFamily branch May 12, 2023 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants