Is there a function in the python API library that can extract atom distance across the unit cell boundary?

I am interested in using the CCDC python API library to extract distance between two atoms. There are several structures that have been worked on are molecular anions with only 1 Te atom in the unit cell. Therefore, in the atom coordinates section of the CIF files, there is only one Tellurium atom index. I tried to use the function MolecularDescriptors.atom_distance(ab) to extract the atom distance across the unit cell, (i.e. MolecularDescriptors.atom_distance(Te1,Te1)). However, a distance of 0.0 gets printed out. That function in the library probably simply calls the distance of a specific atom index and subtract the two sets of coordinates values. 

I also check other functions containing the word "distance" in them, but none of them seem to allow extraction of atom distance across the unit cell boundary. 

Will highly appreciate it if people can tell me how to use the library to calculate atom distance across the unit cell boundary.

Hi Xiwen,

for this I think you will need to know the symmetry operators of the crystal, and to know which of the symmetry operators you are interested in using.  For example,

from ccdc import io, descriptors
csd = io.EntryReader('csd')
crystal = csd.crystal('AABHTZ')
base_mol = crystal.molecule
symm_mol = crystal.symmetric_molecule(crystal.symmetry_operators[1])
print descriptors.MolecularDescriptors.atom_distance(base_mol.atom('N2'), symm_mol.atom('N2')


Hope this is helpful; please let me know if you would like any more help.

Best wishes



Hi Richard,

Thanks for replying! 

I have considered using the symmetry operators of the crystals to calculate the distance between two atoms in the crystal before.  I think the symmetry operators only allow populating the atoms within the unit cells. However, I am interesting in calculating and finding the minimum distance between any two atoms in the crystal structure. This requires applying translational symmetry for the central unit cell and creating a supercell by expanding the central unit cell in 3D.

Therefore, I wonder whether CCDC python API library has methods that will allow interatomic distance calculation across the unit cell boundary. Thanks a lot!




 Hi Xiwen,

you can generate molecules outside the unit cell with the translate parameter of the symmetric_molecule() method if you want explicit control of the symmety operator, or you can generate expanded representations of the crystal through methods such as packing_shell() and molecular_shell().  So, for example, you could use the molecular shell:

mol = crystal.molecular_shell()
atoms_of_interest = [a for a in mol.atoms if a.label == 'Te1']
min_dist = min(MolecularDescriptors.atom_distance(a, b) for a in atoms_of_interest for b in atoms_of_interest if a != b)

or by hand you can calculate all translated symmetric molecules:

expansions = [
    crystal.symmetric_molecule(symmop, (i, j, k))
    for symmop in cry.symmetry_operators
    for i in range(-2, 3)
    for j in range(-2, 3)
    for k in range(-2, 3)

min_dist = min(
    MolecularDescriptors.atom_distance(expansions[i].atom('Te1'), expansions[j].atom('Te1'))
    for i in range(len(expansions)) for j in range(len(expansions))
    if i != j

Is either of these solutions what you are after?

Best wishes



Hi Richard:

The molecular_shell( ) definitely helps and I have extracted the right min_distance using that function. Thank you very much for your help!




You must be signed in to post in this forum.