Luthaf / rascaline

Computing representations for atomistic machine learning
https://luthaf.fr/rascaline/
BSD 3-Clause "New" or "Revised" License
44 stars 13 forks source link

Replace pair_id in neighbors list samples with the actual cell shift #221

Closed Luthaf closed 1 year ago

Luthaf commented 1 year ago

This is more informative, and not that much work overall.

@DivyaSuman14 and @HannaTuerk needed something like this for the hamiltonian learning. You can even compute only one of the translated cells at the time by using sample selection!


@felixmusil, this should solve https://github.com/Luthaf/rascaline/pull/131#issuecomment-1332201981, with all the data you want being in the samples:

calculator = rascaline.NeighborList(cutoff=3.4, full_neighbor_list=True)
descriptor = calculator.compute(frames)
descriptor.block(0).samples
# Labels(
#     structure  first_atom  second_atom  cell_shift_a  cell_shift_b  cell_shift_c
#         0          0           37            0             0             0
#         0          37           0            0             0             0
#         0          1            2            0             0             0
# ...
#         0          51          51            0             0             0
#         0          52          52            0             0             0
#         0          53          53            0             0             0
# )

# in ASE terms:
i = descriptor.block(0).samples["first_atom"]
j = descriptor.block(0).samples["second_atom"]
S = descriptor.block(0).samples.view(["cell_shift_a", "cell_shift_b", "cell_shift_c"]).values
D = descriptor.block(0).values

Ping @rosecers I think you are also using the neighbors list calculator so these changes might impact you (only if you are explicitly manipulating the old pair_id sample)


:books: Documentation preview :books:: https://rascaline--221.org.readthedocs.build/en/221/

felixmusil commented 1 year ago

Looks perfect, great work !

github-actions[bot] commented 1 year ago

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

arthur-lin1027 commented 1 year ago

Nice! @arthur-lin1027 can you check if this makes any problems with anisoap?

@rosecers I ran the code on dev424 (my locally installed version) and dev450 (this current version) and I got the same results! Makes sense since we aren't manipulating the pair_id sample, as Guillaume mentioned above.