-
Notifications
You must be signed in to change notification settings - Fork 81
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
There was a problem hiding this 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.
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
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
PR Summary:
The current
Compound.is_independent()
is not very performant and @CalCraven found out that changing the check fromif neigh not in self
to ifneigh not in self.particles()
will significantly speed thing up.PR Checklist