From e67e0b56b3710565c99c8e54e75f9695d90ecf24 Mon Sep 17 00:00:00 2001 From: Alexandr Fonari Date: Mon, 21 Oct 2024 22:43:20 -0400 Subject: [PATCH] Correctly compute rotational symmetry number for D*h point group (#4093) * Correctly compute rotational symmetry number for D*h point group Correct value is 2 * pre-commit auto-fixes * Add docs * pre-commit auto-fixes --------- Co-authored-by: Sasha Fonari Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/pymatgen/symmetry/analyzer.py | 9 +++++++++ tests/symmetry/test_analyzer.py | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/src/pymatgen/symmetry/analyzer.py b/src/pymatgen/symmetry/analyzer.py index 3bce0e81af2..a4228794924 100644 --- a/src/pymatgen/symmetry/analyzer.py +++ b/src/pymatgen/symmetry/analyzer.py @@ -1329,6 +1329,15 @@ def get_symmetry_operations(self) -> Sequence[SymmOp]: return generate_full_symmops(self.symmops, self.tol) def get_rotational_symmetry_number(self) -> int: + """Get rotational symmetry number. + + Returns: + int: Rotational symmetry number. + """ + if self.sch_symbol == "D*h": + # Special case. H2 for example has rotational symmetry number 2 + return 2 + """Get the rotational symmetry number.""" symm_ops = self.get_symmetry_operations() symm_number = 0 diff --git a/tests/symmetry/test_analyzer.py b/tests/symmetry/test_analyzer.py index ac100ba5450..5a94b85a3ca 100644 --- a/tests/symmetry/test_analyzer.py +++ b/tests/symmetry/test_analyzer.py @@ -530,6 +530,7 @@ def test_tricky(self): mol = Molecule.from_file(f"{TEST_DIR}/dh.xyz") pg_analyzer = PointGroupAnalyzer(mol, 0.1) assert pg_analyzer.sch_symbol == "D*h" + assert pg_analyzer.get_rotational_symmetry_number() == 2 def test_linear(self): coords = [ @@ -540,9 +541,12 @@ def test_linear(self): mol = Molecule(["C", "H", "H"], coords) pg_analyzer = PointGroupAnalyzer(mol) assert pg_analyzer.sch_symbol == "D*h" + assert pg_analyzer.get_rotational_symmetry_number() == 2 + mol = Molecule(["C", "H", "N"], coords) pg_analyzer = PointGroupAnalyzer(mol) assert pg_analyzer.sch_symbol == "C*v" + assert pg_analyzer.get_rotational_symmetry_number() == 1 def test_asym_top(self): coords = [