Neighbor search with ML-FF for certain lattice vector ranges bugged

Problems running VASP: crashes, internal errors, "wrong" results.


Moderators: Global Moderator, Moderator

Post Reply
Message
Author
akretschmer
Newbie
Newbie
Posts: 35
Joined: Wed Nov 13, 2019 8:14 am

Neighbor search with ML-FF for certain lattice vector ranges bugged

#1 Post by akretschmer » Mon Nov 23, 2026 2:18 pm

Dear VASP team,

I believe there is a bug in the neighbour search of the machine-learned force fields in VASP 6.5.1 (src/ml_ff_neighbor.F). It breaks energy conservation for cells with lattice vectors between 24 and 30 A for the default cutoff radius ML_RCUT1 = 8 A.

Problem:
The Verlet list (cutoff 1.5 * ML_RCUT1 = 12 A) is built with a cell list:
• In create_box_parameters, the boxes are at least cutoff/2 = 6 A long. So number_of_needed_neighbor_boxes returns n = 2, and the search loops over box shifts −n ... +n in each direction.
• These 2n+1 = 5 shifts are only distinct if there are at least 5 boxes along that direction.
• The fallback to the N² search, however, is only triggered for 2n > number_boxes, i.e. for at most 3 boxes.
• With exactly 4 boxes (lattice vectors of 24–30 A), the shifts −2 and +2 land on the same box, so its atoms enter the neighbour list twice. Duplicates within ML_RCUT1 are then counted twice in the descriptors.

Fix:
Fall back to the N² search whenever the 2n+1 box shifts are not all distinct. You'll find a suggested patch file attached.

Test:
The attached test runs the same 10 ps NVE simulation of 512 water molecules (cubic cell, a = 24.36 A) twice: once with VASP 6.5.1 and once with VASP 6.5.1 plus the patch. With 6.5.1 the total energy rises by >1 eV in discrete steps; with the patch it stays constant (+0.02 eV). The inputs (without ML_FF), a short analysis script and outputs are included. We also looked at the relevant code section in version 6.6.1 and the bug seems to persist there.

Credit for finding this bug goes to my colleague Nader Nour (TU Wien).

You do not have the required permissions to view the files attached to this post.

jonathan_lahnsteiner2
Global Moderator
Global Moderator
Posts: 316
Joined: Fri Jul 01, 2022 2:17 pm

Re: Neighbor search with ML-FF for certain lattice vector ranges bugged

#2 Post by jonathan_lahnsteiner2 » Mon Nov 23, 2026 2:44 pm

Dear akretschmer,

Thank you for reaching out to us. We are already aware of this bug in the neighbor list and fixed it already. With the next VASP release the neighbor list will work as expected for cases like this.

With many thanks and all the Best

Jonathan


Post Reply