4
$\begingroup$

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?

$\endgroup$
4
  • 1
    $\begingroup$ 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. $\endgroup$ Feb 11, 2023 at 15:11
  • $\begingroup$ 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. $\endgroup$ Feb 11, 2023 at 15:42
  • $\begingroup$ @AndreyPoletayev , how to use get_all_distances() with only data of positions of atoms, cell length and cell angles? $\endgroup$ Feb 11, 2023 at 16:53
  • $\begingroup$ 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. $\endgroup$ Feb 12, 2023 at 1:39

1 Answer 1

2
$\begingroup$

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 :)

$\endgroup$
4
  • $\begingroup$ 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]. $\endgroup$ Feb 11, 2023 at 6:49
  • $\begingroup$ 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. $\endgroup$ Feb 11, 2023 at 7:26
  • $\begingroup$ Hey, btw I don't know about the structure 'hcp' , how to use this? $\endgroup$ Feb 11, 2023 at 16:22
  • 1
    $\begingroup$ 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 $\endgroup$
    – nickpapior
    Feb 11, 2023 at 19:25

You must log in to answer this question.

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