Coverage for gpaw/point_groups/group.py: 100%
26 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-14 00:18 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-14 00:18 +0000
1"""Point-group object."""
2from typing import Dict
3import numpy as np
4from gpaw.typing import Array2D
7class PointGroup:
8 def __init__(self, name: str):
9 """Point-group object.
11 Name must be one of: C2, C2v, C3v, D2d, D3h, D5, D5h,
12 Ico, Ih, Oh, Td or Th.
13 """
14 import gpaw.point_groups.groups as groups
15 self.name = name
16 group = getattr(groups, name)()
17 self.character_table = np.array(group.character_table)
18 self.operations: Dict[str, Array2D] = {}
19 for opname, op in group.operations:
20 assert opname not in self.operations, opname
21 if not isinstance(op, np.ndarray):
22 op = op(np.eye(3))
23 self.operations[opname] = op
24 self.symmetries = group.symmetries
25 self.nops = group.nof_operations
26 self.complex = getattr(group, 'complex', False)
27 self.translations = [self.symmetries[t]
28 for t in (group.Tx_i, group.Ty_i, group.Tz_i)]
30 def __str__(self) -> str:
31 lines = [[self.name] + list(self.operations)]
32 for sym, coefs in zip(self.symmetries, self.character_table):
33 lines.append([sym] + list(coefs))
34 return '\n'.join(f'{line[0]:5}' +
35 ''.join(f'{word:>10}' for word in line[1:])
36 for line in lines) + '\n'
38 def get_normalized_table(self) -> Array2D:
39 """Normalized character table."""
40 # Divide by degeneracies:
41 return self.character_table / self.character_table[:, :1]