So, using pymatgen, I have a structure object. What I want to do is get all of the bond angles within the structure. I could loop over every atom to get all bond angles, but this would include every atom, regardless of how far apart they are, which of course is a problem.
Now, I can find the neighbors of each central atom using the "get_neighbors" function, however, I'm not sure where to go from here, especially because the "get_angle" function takes integer values and not atomic site objects.
Below is the code I have thus far:
import pymatgen as mg
import numpy as np
s = mg.Structure.from_file('POSCAR')
atoms = s.atomic_numbers
van = [x for x in atoms if x == 23]
length = len(van)
nb = ['NONE']*length
x = 0
while x < length:
nb[x] = s.get_neighbors(s[x],2.4)
x += 1
So I have an array of the neighbors and I know which atom they correspond too, now I just need to get the angles for all neighboring atoms.
Any help would be greatly appreciated.
Update:
So, I've figured out a way of doing this. I actually converted each neighboring atom into their Cartesian coordinates. Then, I subtracted the coordinates of the central atom to which the neighboring atoms are attached. Lastly, I found the angles by calculating the dot product of each two vectors divided by the product of their magnitudes, then taking the arc cosine of these values. The code which I used is below. This may not be the most elegant way of doing things, but it does get the job done. If anyone has improvements, feel free to comment.