-
Notifications
You must be signed in to change notification settings - Fork 922
Description
Python version
Python 3.10.12
Pymatgen version
2024.10.22
Operating system version
Ubuntu 20.04.6 LTS
Current behavior
I noticed that CrystalNN
behaves differently depending on whether the input structure is defined using fractional or Cartesian coordinates.
For example, consider the following two structures, which are essentially equivalent (their RMSD from StructureMatcher
is 1.84e-07):
structure_cart = Structure(
coords=data['gt_coords'],
species=data['atom_types'],
lattice=data['cell'],
coords_are_cartesian=True,
)
structure_frac = Structure(
coords=cart2frac(data['gt_coords'], data['cell']) % 1.0,
species=data['atom_types'],
lattice=data['cell'],
coords_are_cartesian=False,
)
# Get subgraphs
crystnn = CrystalNN()
struct_graph_cart = StructureGraph.from_local_env_strategy(structure=structure_cart, strategy=crystnn)
molecules_cart = struct_graph_cart.get_subgraphs_as_molecules()
len(molecules_cart) # 2
struct_graph_frac = StructureGraph.from_local_env_strategy(structure=structure_frac, strategy=crystnn)
molecules_frac = struct_graph.get_subgraphs_as_molecules()
len(molecules_frac) # 0
Despite the two structures being identical, the number of molecules extracted differs.
This behavior is important since tools such as MOFChecker
rely on get_subgraphs_as_molecules
to determine whether a structure contains isolated molecules. In my case, the same structure passes the test when using fractional coordinates but fails when using Cartesian coordinates.
Could you kindly look into this issue? I have attached the relevant data file below for reproducibility.
Thank you very much for your time and support!
Expected Behavior
They should behave the same.
Minimal example
Please see above.