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

Specifiable options for periodic neighbors calculations #318

Merged
merged 27 commits into from
Nov 18, 2024

Conversation

laserkelvin
Copy link
Collaborator

This PR closes #317 by allowing optional keyword arguments to the PeriodicPropertiesTransform workflow:

  • max_neighbors provides a hard cap on the destination nodes for any atom. A counter is updated within the per-site loop, and will break out if we exceed the max_neighbors value.
  • allow_self_loops, when set to False (which is now the default), will filter out self-loops as the last step, just before we return the updated data dictionary.

I also caught and fixed two bugs in the ase implementation:

  • Using the right variable check for adapative_cutoff
  • Missing cell reshape before passing it into the einsum

@laserkelvin laserkelvin added bug Something isn't working enhancement New feature or request labels Nov 15, 2024
Copy link
Collaborator

@melo-gonzo melo-gonzo left a comment

Choose a reason for hiding this comment

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

Look good overall, left two general comments

for site in dst_sites:
if site_count > max_neighbors:
Copy link
Collaborator

Choose a reason for hiding this comment

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

are neighbors sorted in any way? if not it might make sense to prune the lists after the loop.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I haven't fully verified it, but under the hood for ase.neighborlist, the code uses scipy.spatial.cKDTree which should be sorted based on nearest neighbors: i.e. I think if it's not sorted for the whole list of indices, it should be at least for the same level of the tree.

In other words with a max_neighbors of 50+ you're definitely going to be getting the nearest neighbors, but towards the end of the 50, those neighbors might not be necessarily sorted.

gamma = gamma * np.pi / 180.0

# this matrix is normally for fractional to cart
rotation = torch.tensor(
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe add a link to the wiki where this came from, for future reference.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added in 973a1b9

@laserkelvin laserkelvin merged commit 028f44e into IntelLabs:main Nov 18, 2024
2 of 3 checks passed
@laserkelvin laserkelvin deleted the 317-pbc-graph-wiring-options branch November 18, 2024 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature request]: Customization of periodic edge calculation
2 participants