pymatgen
pymatgen copied to clipboard
CrystalNN bug with atom bonded to its own images
Python version
3.11.2
Pymatgen version
2024.6.10
Operating system version
macOS 14.5
Current behavior
Take a structure with only one atom per cell, which bonds to its own images in neighboring cells. Many simple metals do that, like mp-2647057.
Apply CrystalNN to get a bonded structure. The structure for mp-2647057 looks like this:
Structure Graph
Structure:
Structure Summary
Lattice
abc : 2.428889488469988 2.428889488469988 2.428889488469988
angles : 109.47122063449069 109.47122063449069 109.47122063449069
volume : 11.030656874268672
A : -1.40232 1.40232 1.40232
B : 1.40232 -1.40232 1.40232
C : 1.40232 1.40232 -1.40232
pbc : True True True
PeriodicSite: Co0 (Co) (0.0, 0.0, 0.0) [0.0, 0.0, 0.0]
Graph: bonds
from to to_image
---- ---- ------------
0 0 (1, 1, 1)
0 0 (1, 0, 0)
0 0 (0, 0, 1)
0 0 (0, 1, 0)
The bonds graph is incorrect. The Co atom should be 8-connected, and there should be bonds to atoms at positions (-1, -1, -1) (-1, 0, 0) (0, 0, -1) (0, -1, 0). These missing bonds have the exact same length and characteristics as the ones present, in fact they are equivalent by symmetry.
If you make a 2x2x2 supercell and apply CrystalNN, you get the correct coordination.
Expected Behavior
The Co atom should be 8-coordinated.
Minimal example
crystallnn = CrystalNN()
from pymatgen.analysis.local_env import CrystalNN
from pymatgen.ext.matproj import MPRester
with MPRester(apikey) as mpr:
mp_data = mpr.materials.summary.search(
material_ids=["mp-2647057"],
fields=["material_id", "formula", "formula_pretty", "nelements", "structure"]
)
structure = mp_data[0].structure
bonded_struct = crystallnn.get_bonded_structure(structure)
bonded_struct
### Relevant files to reproduce this bug
_No response_