Skip to content

Commit

Permalink
Correctly compute rotational symmetry number for D*h point group (#4093)
Browse files Browse the repository at this point in the history
* 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 <fonari@schrodinger.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 22, 2024
1 parent f7d964c commit e67e0b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/pymatgen/symmetry/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tests/symmetry/test_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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 = [
Expand Down

0 comments on commit e67e0b5

Please sign in to comment.