Skip to content

Commit

Permalink
finalize the fix of site symmetry #295
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhu2017 committed Nov 29, 2024
1 parent 80b88b5 commit e7d4810
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 5 additions & 3 deletions pyxtal/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,8 @@ def __init__(self, op, parse_trans=False, hexagonal=False):
self.axis = rotvec / self.angle
if self.hexagonal:
# print('convert hex', self.axis, np.dot(self.axis, hex_cell))
self.axis = np.dot(self.axis, hex_cell)
if np.linalg.norm(self.axis - np.array([1, 0, 0])) > 1e-4:
self.axis = np.dot(self.axis, hex_cell)
# parse symmetry direction
if self.parse_trans and not self.parse_axis():
self.axis *= -1
Expand Down Expand Up @@ -758,8 +759,9 @@ def __init__(self, op, parse_trans=False, hexagonal=False):
self.angle = np.linalg.norm(rotvec)
self.axis = rotvec / self.angle
if self.hexagonal:
# print('convert hex', self.axis, np.dot(self.axis, hex_cell))
self.axis = np.dot(self.axis, hex_cell)
if np.linalg.norm(self.axis - np.array([1, 0, 0])) > 1e-4:
# print('convert hex', self.axis, np.dot(self.axis, hex_cell))
self.axis = np.dot(self.axis, hex_cell)
if np.isclose(self.angle, 0):
self.symbol = "-1"
self.type = "inversion"
Expand Down
12 changes: 8 additions & 4 deletions pyxtal/symmetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2414,7 +2414,7 @@ def get_site_symm_wo_translation(self):
return [SymmOp.from_rotation_and_translation(op.rotation_matrix, [0, 0, 0]) for op in self.symmetry[0]]

def get_site_symmetry_object(self, idx=0):
ops = self.get_site_symm_ops(idx)
ops = self.get_site_symm_ops(idx)#; print(self.number, self.index, self.letter)
return site_symmetry(ops, self.lattice_type, self.symbol[0])

def get_site_symmetry(self, idx=0):
Expand Down Expand Up @@ -3835,9 +3835,13 @@ def get_highest_symmetry(self, row):
for i, ref_array in enumerate(ref_arrays):
if np.array_equal(row, ref_array[0]):
return ref_array[1], i
symbols = ["1", "-1", "2", "m", "3", "4", "-4", "-3", "6", "-6"]
strs = [symbols[i] for i, x in enumerate(row) if x == 1]
raise ValueError("Incompatible symmetry list", strs)

if self.lattice_type not in ["hexagonal", "trigonal"]:
symbols = ["1", "-1", "2", "m", "3", "4", "-4", "-3", "6", "-6"]
strs = [symbols[i] for i, x in enumerate(row) if x == 1]
print(row)
#raise ValueError("Incompatible symmetry list", strs)
return ref_arrays[0][1], 0


def organized_wyckoffs(group):
Expand Down

0 comments on commit e7d4810

Please sign in to comment.