Skip to content

Commit 1561880

Browse files
authored
Merge pull request #341 from KenHino/fix/hexagonal-site-symmetry
support Z'=1/3, 1/6
2 parents 65d4872 + 2928d7b commit 1561880

3 files changed

Lines changed: 44 additions & 4 deletions

File tree

‎pyxtal/molecule.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,7 +2137,7 @@ def get_orientations_in_wp(self, wp, rtol=1e-2):
21372137
elif wp.index > 1 and self.pga.sch_symbol == "C1":
21382138
return []
21392139

2140-
symm_w = wp.get_site_symm_wo_translation() # symmetry without translation
2140+
symm_w = wp.get_site_symm_wo_translation(space="euclidean") # symmetry without translation
21412141
# molecule has fewer symops
21422142
if len(self.pg[0]) < len(symm_w):
21432143
return []
@@ -2637,7 +2637,7 @@ def is_compatible_symmetry(mol, wp):
26372637
if len(mol) == 1 or wp.index == 0:
26382638
return True
26392639
pga = PointGroupAnalyzer(mol)
2640-
return all(pga.is_valid_op(op) for op in wp.get_site_symm_wo_translation())
2640+
return all(pga.is_valid_op(op) for op in wp.get_site_symm_wo_translation(space="euclidean"))
26412641

26422642

26432643
def make_graph(mol, tol=0.2, ignore_HH=False, debug=False):

‎pyxtal/symmetry.py‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import re
1616
from copy import deepcopy
1717
from ast import literal_eval
18+
from typing import Literal
1819

1920
import numpy as np
2021
from monty.serialization import loadfn
@@ -2465,8 +2466,27 @@ def equivalent_set(self, index):
24652466
return self
24662467

24672468
# =============================Get functions===========================
2468-
def get_site_symm_wo_translation(self):
2469-
return [SymmOp.from_rotation_and_translation(op.rotation_matrix, [0, 0, 0]) for op in self.symmetry[0]]
2469+
def get_site_symm_wo_translation(self, space: Literal["fractional", "euclidean"] = "fractional"):
2470+
"""
2471+
Site symmetry operations of the first point, with translations removed.
2472+
2473+
Args:
2474+
space: "fractional" returns the rotations as stored (fractional
2475+
coordinates). "euclidean" returns them in Cartesian space, which
2476+
differs only for trigonal/hexagonal groups (``self.euclidean``),
2477+
where a 3-fold rotation such as (-y, x-y, z) is not orthogonal.
2478+
Use "euclidean" when comparing against a molecule's point group.
2479+
2480+
Returns:
2481+
list of pymatgen SymmOp objects
2482+
"""
2483+
if space == "fractional":
2484+
ops = self.symmetry[0]
2485+
elif space == "euclidean":
2486+
ops = self.get_site_symm_ops()
2487+
else:
2488+
raise ValueError(f"space must be 'fractional' or 'euclidean', got {space!r}")
2489+
return [SymmOp.from_rotation_and_translation(op.rotation_matrix, [0, 0, 0]) for op in ops]
24702490

24712491
def get_site_symmetry_object(self, idx=0):
24722492
ops = self.get_site_symm_ops(idx)#; print(self.number, self.index, self.letter)

‎tests/test_molecule.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,5 +307,25 @@ def test_special_sites(self):
307307
struc.from_random(3, 61, ["Benzene"], [4])
308308
assert struc.valid
309309

310+
def test_special_sites_in_hexagonal_setting(self):
311+
"""Benzene (D6h) on the special positions of R-3 (148, hexagonal axes)."""
312+
cases = [
313+
(9, [["9d"]]), # Z' = 1/2: inversion centre (-1)
314+
(9, None),
315+
(6, [["6c"]]), # Z' = 1/3: three-fold axis (3)
316+
(6, None),
317+
(3, [["3a"]]), # Z' = 1/6: rotoinversion axis (-3)
318+
(3, None),
319+
]
320+
for num_mols, site in cases:
321+
with self.subTest(site=site):
322+
struc = pyxtal(molecular=True)
323+
struc.from_random(3, 148, ["Benzene"], [num_mols], sites=site)
324+
assert struc.valid
325+
if site is not None:
326+
assert [[s.wp.get_label() for s in struc.mol_sites]] == site
327+
sga = SpacegroupAnalyzer(struc.to_pymatgen(), symprec=1e-2)
328+
assert sga.get_space_group_number() == 148
329+
310330
if __name__ == "__main__":
311331
unittest.main()

0 commit comments

Comments
 (0)