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

Fixed double-counting of periopdic image pairs #260

Merged
merged 4 commits into from
Feb 16, 2024
Merged

Conversation

Luthaf
Copy link
Member

@Luthaf Luthaf commented Nov 9, 2023

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/

@rosecers
Copy link
Collaborator

rosecers commented Nov 9, 2023

Much appreciated on my end! Code looks great to this noob -- let me know if you want a formal review from me.

@Luthaf
Copy link
Member Author

Luthaf commented Nov 9, 2023

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.

Copy link

github-actions bot commented Nov 9, 2023

Here is a pre-built version of the code in this pull request: wheels.zip, you can install it locally by unzipping wheels.zip and using pip to install the file matching your system

@Luthaf Luthaf force-pushed the fix-neighbors-list branch from f8cedbe to a8e4ab0 Compare January 8, 2024 16:23
@Luthaf Luthaf force-pushed the fix-neighbors-list branch 4 times, most recently from e54d057 to 3b01782 Compare February 15, 2024 13:22
@Luthaf Luthaf requested a review from PicoCentauri February 15, 2024 13:52
Copy link
Contributor

@PicoCentauri PicoCentauri left a 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.

python/rascaline/rascaline/systems/ase.py Outdated Show resolved Hide resolved
python/rascaline/tests/systems/ase.py Show resolved Hide resolved


def test_same_spherical_expansion():
system = ase.Atoms(
Copy link
Contributor

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?

Copy link
Member Author

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

(shift[2] < 0 || (shift[2] == 0 && shift[1] < 0))
)
{
// When creating pairs between an atom
Copy link
Contributor

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.

Copy link
Contributor

@liam-o-marsh liam-o-marsh Feb 15, 2024

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
  ┼─────┼─────┼─────┼─────┼
 ╭╯   ╱╭╯    ╭╯    ╭╯    ╭╯
 │   × │   × │   × │   × │
 │     │     │     │     │
╭╯    ╭╯    ╭╯    ╭╯    ╭╯
┼─────┼─────┼─────┼─────┼

Copy link
Member Author

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

Copy link
Contributor

@liam-o-marsh liam-o-marsh Feb 15, 2024

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

Copy link
Member Author

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

@Luthaf Luthaf force-pushed the fix-neighbors-list branch from 3b01782 to 0fe681c Compare February 15, 2024 16:51
@Luthaf Luthaf force-pushed the fix-neighbors-list branch from 0fe681c to b2fa30b Compare February 15, 2024 17:02
@Luthaf Luthaf requested a review from PicoCentauri February 15, 2024 17:05
@Luthaf Luthaf merged commit f00d440 into master Feb 16, 2024
25 checks passed
@Luthaf Luthaf deleted the fix-neighbors-list branch February 16, 2024 13:24
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.

4 participants