Re: [Spglib-users] Can not find atoms related by space group symmetry
Brought to you by:
atztogo
From: Đorđe D. <dan...@ho...> - 2022-03-29 06:44:17
|
Hello again, I apologize I accidently hit send. I apologize for the confusion. I was copy/paste-ing part from a larger code and I have not checked the script. I am attaching the script with the email. Test contains the python code. Let’s say the position of an atom in the primitive cell in crystal coordinates is x1, and it is a component of the vector of all atomic positions inside primitive cell X. If I act with the space group symmetry on x1 I would get, as you said x’: x' = (R|t) x1 = Rx1 + t Part of the code that does that should be: new_pos = np.einsum('ij,jk->ik', scaled_positions, rotations[irot]) + translations[irot] Now, I would expect that x’ is also a position of some atom in the primitive cell, maybe translated by the lattice vector. If I compare x’ with each component of X I should get a match for some x2. That would mean that my original x1 that I transformed transforms to some other atomic position x2 (which could be the same). Now I could say that space group symmetry (R|t) maps atom x1 to atom x2. Am I correct in saying this? Matching of transformed and original atomic positions should be done with this part of the code: for iat in range(natom): found = False for jat in range(natom): pos = new_pos[iat] - scaled_positions[jat] pos -= np.rint(pos) if(check_if_R(pos)): atom_image[irot, iat] = jat found = True break I hope now you can run the code and see that I do not match all of the transformed atoms. Can you help me fix this? Kind regards, Đorđe From: Atsushi Togo<mailto:atz...@gm...> Sent: Tuesday 29 March 2022 03:04 To: spglib-users<mailto:spg...@li...> Subject: Re: [Spglib-users] Can not find atoms related by space group symmetry Hi, Please define what you want to do more clearly. For example, Given a space group operation (R|t), and a point x in crystallographic coordinates x' = (R|t) x = Rx + t Then what do you want to do? In addition, your script doesn't work as it is. Togo On Mon, Mar 28, 2022 at 4:26 PM Dorde Dangic <Dan...@ho...> wrote: > > Dear all, > > I am having trouble finding atoms related by a spacegroup symmetry. I am not sure what I am doing wrong. I am sending a script that I am using to find symmetry-related atoms. > > POSCAR: > > H > 1.00000000 > 0.59175841 -0.59175841 1.52600353 > 0.59175841 0.59175841 1.52600353 > -0.59175841 -0.59175841 1.52600353 > H > 2 > Direct > 0.00000000 0.00000000 0.00000000 > 0.50000000 -0.25000000 0.25000000 > > test.py: > > import numpy as np > import spglib > from phonopy.interface.calculator import read_crystal_structure > > # Function to check if the vector is the translational lattice vector > def check_if_R(vec): > rvec = False > for i in range(-1,2): > if not rvec: > for j in range(-1,2): > if not rvec: > for k in range(-1,2): > vec1 = vec + np.array([float(i), float(j), float(k)]) > if(np.linalg.norm(vec1) < 1.0e-5): > rvec = True > break > return rvec > > unitcell, _ = read_crystal_structure("POSCAR", interface_mode='vasp') # read in structure > cell = (unitcell.cell, unitcell.scaled_positions, unitcell.numbers) > > dataset = spglib.get_symmetry_dataset(cell, symprec=1e-5, angle_tolerance=-1.0, hall_number=0) # get datasets > rotations = dataset['rotations'].copy() > translations = dataset['translations'].copy() > > print(scaled_positions) > > atom_image = np.zeros((len(rotations), len(numbers))) + len(numbers) # array to store to which atom we go with symmetry > for irot in range(len(rotations)): > new_pos = np.einsum('ij,jk->ik', scaled_positions, rotations[irot]) + translations[irot] # symmetry operation on the scaled positions > for iat in range(natom): # Try to match rotated atom with the original set > found = False > for jat in range(natom): > pos = new_pos[iat] - scaled_positions[jat] > pos -= np.rint(pos) > if(check_if_R(pos)): > atom_image[irot, iat] = jat > found = True > break > if(not found): # Print rotated atom if could not match > print(irot, iat) > print(new_pos[iat]) > # Print atom images > print(atom_image) > > Could you please tell me what am I missing? > > Thank you for your help. > _______________________________________________ > Spglib-users mailing list > Spg...@li... > https://lists.sourceforge.net/lists/listinfo/spglib-users -- Atsushi Togo _______________________________________________ Spglib-users mailing list Spg...@li... https://lists.sourceforge.net/lists/listinfo/spglib-users |