# How to determine the lattice vector direction and magnitude in ASE

I am using the ASE library to compute the distance matrix with minimum image convention. In that, I have got the positions of all atoms in the cell.

Now I wish to calculate the distance between each of them by considering the translation vector on the three Bravais lattice vectors. For example the position of atom is pos1 = [0.11 , 0.23 , 0.156] now I have to translate this using the combinations of the three lattice vectors (t1,t2,t3) with cell size (a,b,c) respectively. That will be, like

pos1_1 = [0.11+a*t1 , 0.23 , 0.156]
pos1_2 =...


And so on.

How can this be done with ASE?

• How does what you are looking to do differ from the get_distance(), get_distances(), and get_all_distances() methods of ase.Atoms ? All of those allow a bool flag for the use of MIC as input. Feb 11 at 15:11
• Actually, I wish to not use the existing library functions and develop my own function for my understanding. I tried looking up the source code, but I couldn't relate it with my code. Feb 11 at 15:42
• @AndreyPoletayev , how to use get_all_distances() with only data of positions of atoms, cell length and cell angles? Feb 11 at 16:53
• What you have is enough information to construct an ase.Atoms object. Then calling its get_all_distances() returns the full all-to-all distances matrix. Feb 12 at 1:39

Offsets in positions is straightforwardly done in ASE:

# just a test system
from ase.build import bulk
ni = bulk('Ni', 'hcp', a=2.5, c=4.0)

# now to process for an offset
t1 = 1
t2 = 2
t3 = 3
print("cell = ")
print(ni.cell)
print("before translation = ")
print(ni.positions)
ni.positions += (t1, t2, t3) @ ni.cell
print("after translation = ")
print(ni.positions)


However, I think you should look into https://wiki.fysik.dtu.dk/ase/ase/neighborlist.html for details on getting actual neighbours in a faster fashion :)

• Also can you suggest on how to compute the lattice vectors; given the information about unit cell edge length = [a,b,c] and the dihededral angles (in degrees) = [ alpha, beta,gamma]. Feb 11 at 6:49
• But actually, I only wish to know the directions of the unit cell. I will calculate the new positions myself. So, the [t1,t2,t3] unit vectors of the cell are required. Feb 11 at 7:26
• Hey, btw I don't know about the structure 'hcp' , how to use this? Feb 11 at 16:22
• As for length + angles, see this method: wiki.fysik.dtu.dk/ase/ase/cell.html#ase.cell.Cell.new. Search the documentation for hcp, and it should come Feb 11 at 19:25