metatensor / featomic

Computing representations for atomistic machine learning
http://metatensor.github.io/featomic/
BSD 3-Clause "New" or "Revised" License
44 stars 13 forks source link

Untangle strain and cell gradients #301

Closed Luthaf closed 6 months ago

Luthaf commented 7 months ago

This partially undo #105: we where right to use gradient w.r.t. strain there, but these should be stored using "strain" as the gradient parameter.

Now, we can have three kinds of gradients:

The first two are then used when integrating with Torch's autograd system; and the last one can be useful when computing gradients in forward mode.

As a side effect, I fixed gradients of SOAP when the cell is smaller than the cutoff, we where doing some summations wrong in this case.


📚 Documentation preview 📚: https://rascaline--301.org.readthedocs.build/en/301/

github-actions[bot] commented 7 months 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

bananenpampe commented 5 months ago

Hello, is it possible that these changes are breaking changes with respect to older rascaline versions? I am seeing broken NPT simulations with the newest rascaline version

bananenpampe commented 5 months ago

Old rascaline:

Bildschirmfoto 2024-05-30 um 01 29 28

New rascaline:

Bildschirmfoto 2024-05-30 um 01 30 39

unwrapped

Luthaf commented 5 months ago

which simulation engine/driver are you using? The old i-PI driver used for the alchemical HEA project was cancelling the issue fixed here and producing the right gradients overall. But if you use it with the code from this PR then the correction will make it wrong.

bananenpampe commented 5 months ago

Okay, is it off by only a scaling factor with the cell-volume, or is it more that needs to be changed ?

Luthaf commented 5 months ago

Two things needs to change: the code needs to compute "strain" gradients instead of "cell" gradients (the old cell gradients where almost the same as the new strain gradients), and then scale by the volume.