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

improve performance of is_independent #1037

Merged
merged 2 commits into from
Jun 6, 2022

Conversation

daico007
Copy link
Member

@daico007 daico007 commented Jun 6, 2022

PR Summary:

The current Compound.is_independent() is not very performant and @CalCraven found out that changing the check from if neigh not in self to if neigh not in self.particles() will significantly speed thing up.

PR Checklist


  • Includes appropriate unit test(s)
  • Appropriate docstring(s) are added/updated
  • Code is (approximately) PEP8 compliant
  • Issue(s) raised/addressed?

@daico007 daico007 requested a review from CalCraven June 6, 2022 14:27
@daico007 daico007 changed the title improve performance of is_independence, suggested by Cal improve performance of is_independent Jun 6, 2022
@codecov
Copy link

codecov bot commented Jun 6, 2022

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.37%. Comparing base (f90c448) to head (aee6ec9).
Report is 160 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1037   +/-   ##
=======================================
  Coverage   90.37%   90.37%           
=======================================
  Files          64       64           
  Lines        9014     9014           
=======================================
  Hits         8146     8146           
  Misses        868      868           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

mbuild/compound.py Outdated Show resolved Hide resolved
Copy link
Contributor

@CalCraven CalCraven left a comment

Choose a reason for hiding this comment

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

Should be much more useful now.

CalCraven added a commit to CalCraven/mbuild that referenced this pull request Jun 6, 2022
This PR adds two methods to a compound,
`_recursive_id_molecules`
and
`group_by_molecules`.
These functions let a user reconfigure an mBuild
compound using the top down approach of iterating through
children. The is_independent() method is checked on each children
until False is returned, which identifies when the hierarchy is made
of a bonded together "molecule". This will be of use when converting to
GMSO `Topology`, the subtop information can be parsed from this
reconfigured mBuild compound in order to speed up atomtyping.

These methods use the compound.name attribute to group molecules
together. With a generic name like "Compound", the top level child
will be a single compound.

**Note that these tests won't pass until PR mosdef-hub#1037 is merged

* Add mbuild.compound.Compound._recursive_id_molecules method
* Add mbuild.compound.Compound.group_by_molecules method
@daico007 daico007 merged commit b0e0807 into mosdef-hub:main Jun 6, 2022
CalCraven added a commit to CalCraven/mbuild that referenced this pull request Jun 6, 2022
This PR adds two methods to a compound,
`_recursive_id_molecules`
and
`group_by_molecules`.
These functions let a user reconfigure an mBuild
compound using the top down approach of iterating through
children. The is_independent() method is checked on each children
until False is returned, which identifies when the hierarchy is made
of a bonded together "molecule". This will be of use when converting to
GMSO `Topology`, the subtop information can be parsed from this
reconfigured mBuild compound in order to speed up atomtyping.

These methods use the compound.name attribute to group molecules
together. With a generic name like "Compound", the top level child
will be a single compound.

**Note that these tests won't pass until PR mosdef-hub#1037 is merged

* Add mbuild.compound.Compound._recursive_id_molecules method
* Add mbuild.compound.Compound.group_by_molecules method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants