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

infinite loop for cutoff=0.0 from python interface #122

Closed PicoCentauri closed 1 year ago

PicoCentauri commented 2 years ago

This piece of code leads to an infinite loop

import ase
from rascaline import SphericalExpansion

atoms = ase.Atoms("OO", positions=((0,0,0),(1,0,0)), pbc=True, cell=[2,2,2])

HYPER_PARAMETERS = {
    "cutoff": 0.0,
    "max_radial": 9,
    "max_angular": 6,
    "atomic_gaussian_width": 0.3,
    "center_atom_weight": 1.0,
    "radial_basis": {"Gto": {"spline_accuracy": 1e-6}},
    "cutoff_function": {"ShiftedCosine": {"width": 0.5}},
    "radial_scaling": {"Willatt2018": {"scale": 2.0, "rate": 1.0, "exponent": 4}},
}

calculator = SphericalExpansion(**HYPER_PARAMETERS)
descriptor0 = calculator.compute(atoms)

However a rust test

    #[test]
    fn cutoff_zero() {
        let soap_parameters = r#"{
            "cutoff": 0.0,
            "max_radial": 9,
            "max_angular": 6,
            "atomic_gaussian_width": 0.3,
            "center_atom_weight": 1.0,
            "radial_basis": {"Gto": {"spline_accuracy": 1e-6}},
            "cutoff_function": {"ShiftedCosine": {"width": 0.5}},
            "radial_scaling": {"Willatt2018": {"scale": 2.0, "rate": 1.0, "exponent": 4}}
        }"#;

        let mut calculator = Calculator::new(
            "spherical_expansion",
            soap_parameters.into(),
        ).unwrap();

        let mut systems = test_systems(&["water", "methane"]);
        calculator.compute(&mut systems, Default::default()).unwrap();
    }

leads to

thread 'calculators::soap::spherical_expansion::tests::cutoff_zero' panicked at 'assertion failed: `(left == right)`
  left: `NaN`,
 right: `NaN`: matrix is not symmetric', rascaline/src/math/eigen.rs:254:17
Luthaf commented 2 years ago

I guess these two checks should use <=: https://github.com/Luthaf/rascaline/blob/a4e46d550d1658f17f7a1f42bfe150d1a330d34b/rascaline/src/calculators/soap/radial_integral/gto.rs#L33-L39

What happens with cutoff=1e-16?