4
$\begingroup$

I wish to calculate the distance of all the atoms from a particular atom(atom A) in my cell. But I also want to include the atoms that might lie just beyond the periodic unit cell boundary.( In figure, besides distance of A with 1,2,3 i also want distance with 4). I am using get_distance from ASE, but it will not include atom outside(atom 4) the boundary. I am printing the nearest atoms to A to confirm this. What can be done to consider this?Example structure

The code I am using is(Atom A is "Cu" and atom 1,2,3,4 is "O") :

import numpy as np
from ase.io import read,write
from ase.geometry import get_distances
from ase.neighborlist import NeighborList,natural_cutoffs,build_neighbor_list,first_neighbors,get_connectivity_matrix,neighbor_list

structure= read("1985check.cif")

atom_count=structure.get_chemical_symbols()
#atom_count=supercell.get_chemical_symbols()

for i in range(len(atom_count)):
        if(atom_count[i]=='Cu'):
            index=i
            break

neighbor_list=[]
j_list=[]
for j in range(len(atom_count)):
       
          if(j!=index):  
            neighbor_list.append(structure.get_distance(index,j,mic=True))
            j_list.append(j)
 
keys= sorted(range(len(neighbor_list)), key=lambda k: neighbor_list[k])    

check_list=[]
for c in range(len(keys)):
        #print(structure.get_chemical_symbols()[j_list[keys[c]]])
        check_list.append(structure.get_chemical_symbols()[j_list[keys[c]]])

The output of check_list is ['O','O','O', 'Cu'...] while I expect ['O','O','O', 'O'...]

The cif file is https://www.dropbox.com/s/ucro7otg8dn4doy/1985check.cif?dl=0

$\endgroup$
7
  • $\begingroup$ if mic=True, it should include it...can you give an output $\endgroup$ Nov 27, 2022 at 19:12
  • $\begingroup$ @TristanMaxson I have printed the names of the elements closest to atom A. It should give the names of the 4 red atoms , but it is giving three. Possibly it is skipping the one outside the cell? $\endgroup$
    – rik
    Nov 27, 2022 at 19:34
  • $\begingroup$ Would it be possible to include the part of your code that prints the atoms closest to atom A and its output? Does the neighbour_list variable in your present code change significantly if you set mic=False? $\endgroup$
    – CW Tan
    Nov 27, 2022 at 19:53
  • $\begingroup$ @CWTan The variable changes in the sense some distances are not present. I have edited and added the code for atoms closest to atom A to the main post. $\endgroup$
    – rik
    Nov 27, 2022 at 19:58
  • $\begingroup$ You are going to have to provide a minimum working example for us to know what's going wrong. This code looks okay at a glance. $\endgroup$ Nov 27, 2022 at 20:01

1 Answer 1

4
$\begingroup$

I think the answer to your problem lies in the CIF file. With reference to the figure below, two out of four of the O neighbors of Cu are actually "the same atom" (only one of them is present as an entry in the unit cell and the other is a periodic image of the one in the unit cell). ASE's .get_distance() and mic=True (Minimum Image Convention) works as expected, by only giving you the minimum distance from the Cu atom chosen to that O atom (considering the O atom in the simulation cell and its periodic image), or else it would be double counting to get the results you expect.

To get the results you were expecting, you could create a supercell with that structure and use your previous code, picking a Cu atom in the center of the cell so that it will definitely have all four nearest neighbor O atoms in the simulation cell.

enter image description here

$\endgroup$
1
  • $\begingroup$ Yes, i think I will have to consider a supercell to handle this boundary problem, because in the actual structure there should be 4 nearest neighbors. $\endgroup$
    – rik
    Nov 29, 2022 at 9:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .