Given a cif file I want to obtain the graph representation (as a data structure) of a certain material. I am trying with this cif file which represents the unit cell of CrN.
I am trying to use pymatgen's StructureGraph class but I have had some problems. In this link they suggest to use the with_local_env_strategy()
method, however when I try to use it I get an error. Here my code:
from pymatgen.analysis.graphs import StructureGraph
from pymatgen.analysis.local_env import NearNeighbors
from pymatgen.core import Structure
filename = 'CrN.cif'
structure = Structure.from_file(filename)
nn = NearNeighbors()
strategy = nn.get_all_nn_info(structure)
strucGraph = StructureGraph.with_local_env_strategy(supercell, strategy, weights=False, edge_properties=False)
The error:
Since I am not an expert in the materials subject (I am only a systems engineer and a mathematician), I made these 2 possible solutions:
Using the
get_neighbors()
method which, given a spherical neighborhood of a given radius, obtains the nearest neighbors:The second method is a little more customizable, the code I put here takes into account Euclidean distance, however, for the criterion of connection of 2 atoms can be used other criteria, such as energy.