-
Notifications
You must be signed in to change notification settings - Fork 14
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
Fixed double-counting of periopdic image pairs #260
Conversation
Much appreciated on my end! Code looks great to this noob -- let me know if you want a formal review from me. |
I think the NeighborsList calculator is now wrong with these changes, around here: https://github.com/Luthaf/rascaline/blob/2851d47ab3471057f3794ac2b48b0417add2f748/rascaline/src/calculators/neighbor_list.rs#L568-L571 The condition should account for the cell shift as well. |
Here is a pre-built version of the code in this pull request: wheels.zip, you can install it locally by unzipping |
f8cedbe
to
a8e4ab0
Compare
e54d057
to
3b01782
Compare
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.
Good to have this fixed.
|
||
|
||
def test_same_spherical_expansion(): | ||
system = ase.Atoms( |
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.
I have the feeling that this cell is this to small to check for more then one unit cell?
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.
It's 3.6 in one direction, you should get pairs with a shift of 2 with a cutoff of 9
rascaline/src/systems/neighbors.rs
Outdated
(shift[2] < 0 || (shift[2] == 0 && shift[1] < 0)) | ||
) | ||
{ | ||
// When creating pairs between an atom |
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.
I understand what is going on here but maybe a picture would help. But I agree and accept, if this is too much work.
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.
does this work?
┼─────┼─────┼─────┼─────┼
╭╯ ╭╯ ╭╯ ╭╯ ╭╯
│ × │ × │ × │ × │
│ │ │ ╱ │ │
╭╯ ╭╯ ╭╯ ╱ <- first pair
┼─────┼─────┼─────┼─────┼
╭╯ ╭╯ ╱╭╯ ╭╯ ╭╯
│ × │ × │ × │ × │
│ │ ╱ │ │ │
╭╯ ╭╯ ╱ <- second pair, redundant
┼─────┼─────┼─────┼─────┼
╭╯ ╱╭╯ ╭╯ ╭╯ ╭╯
│ × │ × │ × │ × │
│ │ │ │ │
╭╯ ╭╯ ╭╯ ╭╯ ╭╯
┼─────┼─────┼─────┼─────┼
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.
We looked at the code very carefully again, and I think we both understand it now! I might do a diagram of the 2D version of it, but trying to represent the 3D version in ASCII is a bit clunky
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.
I think I understand what the hard part is in the understanding.
it's the condition that starts the block at https://github.com/Luthaf/rascaline/blob/3b0178213c13032e2f2d0b6c31f6ba5d8621ae84/rascaline/src/systems/neighbors.rs#L260, right?
to build this condition, my reasoning is:
- for two same-atom pairs characterised by (h,j,k) and (-h,-j,-k), one of them has to be ignored. how do you choose?
- first try to divide space along the h+j+k=0 plane.
- if it doesn't work, divide by the k=0 plane
- if it still doesn't work, divide by the j=0 plane.
- if the two pairs cannot be separated by any of those planes, then they are both at (h=0,j=0,k=0), which isn't possible
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.
Yes, that was the issue. I split the condition in two and added a small illustration of the 2D case
3b01782
to
0fe681c
Compare
0fe681c
to
b2fa30b
Compare
This was found by @liam-o-marsh in #240, and I cherry-picked it to merge the fix quicker.
Ping @rosecers who wants to use this!
📚 Documentation preview 📚: https://rascaline--260.org.readthedocs.build/en/260/