Yes, there is! Pymatgen is ideally suited for this task. Specifically, I highly recommend the local environment module. Given a CIF, you can calculate the coordination environment around a given atom index using the following Python code. Here, the CrystalNN
algorithm is used, but you can find many other approaches here that you should consider. Simply swap out the nn_object
line.
import pymatgen as pm
from pymatgen.analysis.local_env import CrystalNN
p = '/path/to/cif' #path to CIF file
site_idx = 0 #index of atom to get coordination environment
structure = pm.Structure.from_file(p) #read in CIF as Pymatgen Structure
nn_object = CrystalNN() #initialize class
neighbors = nn_object.get_nn_info(structure,site_idx) #get NN info
An example output for neighbors
would look something like the following, which is a list containing all the coordinating atoms and their distances, the nearest image, and the site index. Other methods, such as VoronoiNN
, will provide additional information.
[{'site': PeriodicSite: O (3.2910, 2.0794, 0.9655) [0.4692, 0.2958, 0.2602], 'image': (0, 0, 0), 'weight': 1, 'site_index': 25}, {'site': PeriodicSite: C (4.9976, 0.0907, 2.7314) [0.7612, 0.0129, 0.5053], 'image': (0, 0, 0), 'weight': 1, 'site_index': 35}]
Of course, there are simpler approaches that are just based off a fixed cutoff distance (in Pymatgen, that could be done with pymatgen.core.structure.get_neighbors()
or in the Atomic Simulation Environment with the ase.neighborlist
tool).