Hi,
I want to calculate angles between sites 1, 2 and 3, so I write the following:

angle=struct.get_angle(site1,site2,site3)

In site1, site2 and site3 I have to write integrers which are the number of each atom.
Is there any method to write xyz coordinates intead of integrers?

My problem comes because I have an atom A in the (0.9,0.9,0.9) position and I want to calculate the angle with its nearest atoms. So the program, instead of taking the (1.1,1.1,1.1) position of atom B (which is the closest distance), it takes the (0.1,0.1,0.1) position (which is farther), so the angle is different (of course, there is a third atom in the equation but for simplifying I just wrote 2).

So I think that if I write the xyz coordinates of the site, instead of the atom number, this problem could be solved. However, I cannot do it

However, this will not help your original scenario as this will still be the coordinates of the original site and not the coordinates of the site in the closest image.

I’ve made a function that works like the original struct.get_angle but this time it will find the angle between the sites in the closest periodic image.

from pymatgen import Structure
from pymatgen.util.coord import pbc_diff, get_angle
def get_angle_between_closest_sites(
structure: Structure,
i: int,
j: int,
k: int
) -> float:
"""
Returns angle specified by three sites where the closest image
of the sites i and k to the central site, j, is used.
Args:
structure: A structure object.
i: Index of first site.
j: Index of second site.
k: Index of third site.
Returns:
Angle in degrees.
"""
v1 = pbc_diff(structure[i].frac_coords, structure[j].frac_coords)
v2 = pbc_diff(structure[k].frac_coords, structure[j].frac_coords)
cart_v1 = structure.lattice.get_cartesian_coords(v1)
cart_v2 = structure.lattice.get_cartesian_coords(v2)
return get_angle(cart_v1, cart_v2, units="degrees")
get_angle_between_closest_sites(structure, 0, 1, 2)