librascal
librascal copied to clipboard
Finite-difference gradient test breaks with large(ish) displacements
This isn't a big issue (hence the new sparkly tag), but we want to keep track of it in case related problems pop up again. Several funny edge cases can happen when the finite displacement used in the gradient test (defined here: https://github.com/cosmo-epfl/librascal/blob/4feef3147c9784771602a6e893603def00df2525/tests/test_math.hh#L362) is too large. One of which is, if the unit cell is too close (shrinkwrapped) to the atoms, the finite displacement can kick them out and break the neighbourlist, but this was fixed in 6c7886c. This issue starts happening already with a displacement (dx) of 0.01 Å.
Another issue that just came up when I tried a gradient test of small_molecule.json
is that an environment might have only one atom of a certain species in it; if this atom leaves the environment, the size of the species set changes and causes a size mismatch in the current finite-difference implementation. This one is much more complex to fix, since it requires ensuring that f(center), f(center + dx), and f(center - dx) are all using the same species set. Since it can be fixed by not starting with such a large displacement (i.e. < 0.01 Å), I'd say this is a very low-priority bug.
In short: There are several reasons not to use too large a finite displacement in the gradient tests, but we should keep this issue in mind in case the edge cases become more important than we thought.
For this problem introducing the solution for #213 a proper error message is now thrown.
Another issue that just came up when I tried a gradient test of
small_molecule.json
is that an environment might have only one atom of a certain species in it; if this atom leaves the environment, the size of the species set changes and causes a size mismatch in the current finite-difference implementation. This one is much more complex to fix, since it requires ensuring that f(center), f(center + dx), and f(center - dx) are all using the same species set. Since it can be fixed by not starting with such a large displacement (i.e. < 0.01 Å), I'd say this is a very low-priority bug.