pymolsym 1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pymolsym/__init__.py +7 -0
- pymolsym/character_table.py +405 -0
- pymolsym/exact.py +310 -0
- pymolsym/linear.py +406 -0
- pymolsym/named_groups.py +148 -0
- pymolsym/pointgroup.py +1172 -0
- pymolsym/symmetry_operation.py +445 -0
- pymolsym-1.0.dist-info/METADATA +740 -0
- pymolsym-1.0.dist-info/RECORD +12 -0
- pymolsym-1.0.dist-info/WHEEL +5 -0
- pymolsym-1.0.dist-info/licenses/LICENSE +21 -0
- pymolsym-1.0.dist-info/top_level.txt +1 -0
pymolsym/__init__.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
from pymolsym.symmetry_operation import *
|
|
2
|
+
from pymolsym.pointgroup import *
|
|
3
|
+
from pymolsym.named_groups import *
|
|
4
|
+
from pymolsym.named_groups import T, O, I # not part of the * import, see named_groups
|
|
5
|
+
from pymolsym import symmetry_operation as _symmetry_operation, pointgroup as _pointgroup, named_groups as _named_groups
|
|
6
|
+
|
|
7
|
+
__all__ = _symmetry_operation.__all__ + _pointgroup.__all__ + _named_groups.__all__
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Character tables of finite groups, derived from their multiplication table.
|
|
3
|
+
|
|
4
|
+
The characters are computed with Dixon's method (J. D. Dixon, Numer. Math. 10, 446 (1967)),
|
|
5
|
+
Burnside's algorithm carried out exactly in modular arithmetic:
|
|
6
|
+
|
|
7
|
+
1. The class constants a_ijk (the number of ways an operation of class k is a product of an
|
|
8
|
+
operation of class i and one of class j) define commuting matrices M_j with
|
|
9
|
+
(M_j)_ik = a_ijk. For every irrep, the vector w_k = |C_k| χ(C_k) / χ(E) is a common
|
|
10
|
+
eigenvector of all M_j.
|
|
11
|
+
2. The common eigenvectors are found by splitting the space into eigenspaces of one M_j
|
|
12
|
+
after the other, modulo a prime p with p = 1 (mod e), e being the exponent of the group
|
|
13
|
+
(the lcm of the orders of its operations), so that all eigenvalues lie in GF(p).
|
|
14
|
+
3. Normalizing w with the orthogonality relation gives the characters modulo p. From the
|
|
15
|
+
characters of the powers of an operation g of order o, the multiplicities m_k of the
|
|
16
|
+
eigenvalues exp(2πik/o) of g in the irrep follow.
|
|
17
|
+
|
|
18
|
+
These multiplicities, the spectrum of g, are the exact form of a character:
|
|
19
|
+
χ(g) = Σ m_k exp(2πik/o). An irrep is a tuple of spectra, one per class. `character` turns
|
|
20
|
+
a spectrum into a number, `residue` into the character modulo p, with which multiplicities
|
|
21
|
+
of irreps in products and in representations of subgroups are computed exactly.
|
|
22
|
+
|
|
23
|
+
The Mulliken symbols follow R. S. Mulliken, J. Chem. Phys. 23, 1997 (1955), and the
|
|
24
|
+
axis convention of pymolsym: z is the principal axis, C2′ axes and σv planes contain x.
|
|
25
|
+
They are read from the spectra of the operations that decide them.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
from cmath import exp, pi
|
|
29
|
+
from fractions import Fraction
|
|
30
|
+
from math import gcd, isqrt, lcm
|
|
31
|
+
|
|
32
|
+
from pymolsym.exact import Axial, Polyhedral, axis_rank, unit_vector
|
|
33
|
+
|
|
34
|
+
__all__ = []
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# --- modular arithmetic -----------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
def _is_prime(n):
|
|
40
|
+
return n > 1 and all(n % q for q in range(2, isqrt(n) + 1))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _prime_factors(n):
|
|
44
|
+
return [q for q in range(2, n + 1) if n % q == 0 and _is_prime(q)]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _choose_prime(exponent, order):
|
|
48
|
+
"""Smallest prime p = 1 (mod exponent) with p > 2 sqrt(order)."""
|
|
49
|
+
p = exponent + 1
|
|
50
|
+
while not (_is_prime(p) and p * p > 4 * order):
|
|
51
|
+
p += exponent
|
|
52
|
+
return p
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _root_of_unity(e, p):
|
|
56
|
+
"""A primitive e-th root of unity modulo the prime p, where e divides p - 1."""
|
|
57
|
+
factors = _prime_factors(p - 1)
|
|
58
|
+
generator = next(g for g in range(2, p) if all(pow(g, (p - 1) // q, p) != 1 for q in factors))
|
|
59
|
+
return pow(generator, (p - 1) // e, p)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _nullspace(rows, ncols, p):
|
|
63
|
+
"""Basis of all x with row · x = 0 (mod p) for every row."""
|
|
64
|
+
rows = [list(row) for row in rows]
|
|
65
|
+
pivots = []
|
|
66
|
+
for c in range(ncols):
|
|
67
|
+
r = len(pivots)
|
|
68
|
+
pivot = next((i for i in range(r, len(rows)) if rows[i][c]), None)
|
|
69
|
+
if pivot is None:
|
|
70
|
+
continue
|
|
71
|
+
rows[r], rows[pivot] = rows[pivot], rows[r]
|
|
72
|
+
inverse = pow(rows[r][c], -1, p)
|
|
73
|
+
rows[r] = [x * inverse % p for x in rows[r]]
|
|
74
|
+
for i, row in enumerate(rows):
|
|
75
|
+
if i != r and row[c]:
|
|
76
|
+
rows[i] = [(x - row[c] * y) % p for x, y in zip(row, rows[r])]
|
|
77
|
+
pivots.append(c)
|
|
78
|
+
basis = []
|
|
79
|
+
for free in (c for c in range(ncols) if c not in pivots):
|
|
80
|
+
x = [0] * ncols
|
|
81
|
+
x[free] = 1
|
|
82
|
+
for i, c in enumerate(pivots):
|
|
83
|
+
x[c] = -rows[i][free] % p
|
|
84
|
+
basis.append(x)
|
|
85
|
+
return basis
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _eigenspaces(space, matrix, p):
|
|
89
|
+
"""Split the invariant subspace `space` (a list of basis vectors) into eigenspaces of matrix."""
|
|
90
|
+
images = [[sum(m * x for m, x in zip(row, v)) % p for row in matrix] for v in space]
|
|
91
|
+
parts, found = [], 0
|
|
92
|
+
for eigenvalue in range(p):
|
|
93
|
+
rows = [[(u[i] - eigenvalue * v[i]) % p for u, v in zip(images, space)]
|
|
94
|
+
for i in range(len(matrix))]
|
|
95
|
+
part = [[sum(c * v[i] for c, v in zip(coefficients, space)) % p for i in range(len(matrix))]
|
|
96
|
+
for coefficients in _nullspace(rows, len(space), p)]
|
|
97
|
+
if part:
|
|
98
|
+
parts.append(part)
|
|
99
|
+
found += len(part)
|
|
100
|
+
if found == len(space): # the space is the sum of its eigenspaces: there are no more
|
|
101
|
+
break
|
|
102
|
+
return parts
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
# --- characters -------------------------------------------------------------------------
|
|
106
|
+
|
|
107
|
+
def _number(z):
|
|
108
|
+
"""A character value as int if it is integral, as float if real, else as complex."""
|
|
109
|
+
if abs(z.imag) > 1e-9:
|
|
110
|
+
return complex(round(z.real, 12) + 0.0, round(z.imag, 12) + 0.0)
|
|
111
|
+
if abs(z.real - round(z.real)) < 1e-9:
|
|
112
|
+
return int(round(z.real))
|
|
113
|
+
return round(z.real, 12)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def character(spectrum):
|
|
117
|
+
"""
|
|
118
|
+
The character χ = Σ m_k exp(2πik/o) of a spectrum (m_0, ..., m_(o-1)): an int if it is
|
|
119
|
+
integral, a float rounded to 12 digits if it is real, else a complex number.
|
|
120
|
+
"""
|
|
121
|
+
o = len(spectrum)
|
|
122
|
+
return _number(sum(m * exp(2j * pi * k / o) for k, m in enumerate(spectrum) if m))
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def modulus(irreps, order):
|
|
126
|
+
"""
|
|
127
|
+
Exponent e of a group, the prime p and the primitive e-th root of unity modulo p that
|
|
128
|
+
its characters are computed with, from its irreps (tuples of spectra) and its order.
|
|
129
|
+
"""
|
|
130
|
+
exponent = lcm(*(len(spectrum) for spectrum in irreps[0]))
|
|
131
|
+
p = _choose_prime(exponent, order)
|
|
132
|
+
return exponent, p, _root_of_unity(exponent, p)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def residue(spectrum, exponent, p, root):
|
|
136
|
+
"""
|
|
137
|
+
The character of a spectrum modulo p, with exp(2πi/e) mapped to `root`. The order of
|
|
138
|
+
the operation, len(spectrum), must divide the exponent e.
|
|
139
|
+
"""
|
|
140
|
+
zeta = pow(root, exponent // len(spectrum), p)
|
|
141
|
+
return sum(m * pow(zeta, k, p) for k, m in enumerate(spectrum) if m) % p
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def characters(table, classes):
|
|
145
|
+
"""
|
|
146
|
+
Character table of a finite group.
|
|
147
|
+
|
|
148
|
+
Parameters
|
|
149
|
+
----------
|
|
150
|
+
table : sequence of sequences of int
|
|
151
|
+
Multiplication table: table[i][j] is the index of the product of the elements
|
|
152
|
+
i and j.
|
|
153
|
+
classes : sequence of sequences of int
|
|
154
|
+
The conjugacy classes of the group, as indices of their elements.
|
|
155
|
+
|
|
156
|
+
Returns
|
|
157
|
+
-------
|
|
158
|
+
list of tuple
|
|
159
|
+
The irreps in no particular order. Each is a tuple with one spectrum per class:
|
|
160
|
+
the multiplicities (m_0, ..., m_(o-1)) of the eigenvalues exp(2πik/o) of the
|
|
161
|
+
operations of the class, o being their order.
|
|
162
|
+
"""
|
|
163
|
+
order, k = len(table), len(classes)
|
|
164
|
+
sizes = [len(c) for c in classes]
|
|
165
|
+
class_of = [0] * order
|
|
166
|
+
for i, c in enumerate(classes):
|
|
167
|
+
for x in c:
|
|
168
|
+
class_of[x] = i
|
|
169
|
+
identity = next(i for i in range(order) if table[i][i] == i)
|
|
170
|
+
|
|
171
|
+
def powers(g):
|
|
172
|
+
"""The elements g^0, g^1, ..., g^(o-1)."""
|
|
173
|
+
chain, x = [identity], g
|
|
174
|
+
while x != identity:
|
|
175
|
+
chain.append(x)
|
|
176
|
+
x = table[g][x]
|
|
177
|
+
return chain
|
|
178
|
+
|
|
179
|
+
chains = [powers(c[0]) for c in classes]
|
|
180
|
+
exponent = lcm(*(len(chain) for chain in chains))
|
|
181
|
+
p = _choose_prime(exponent, order)
|
|
182
|
+
|
|
183
|
+
def class_matrix(j):
|
|
184
|
+
"""(M_j)_il = a_ijl: products x*y with x in class i, y in class j that are in class l."""
|
|
185
|
+
matrix = []
|
|
186
|
+
for c in classes:
|
|
187
|
+
counts = [0] * k
|
|
188
|
+
for x in c:
|
|
189
|
+
row = table[x]
|
|
190
|
+
for y in classes[j]:
|
|
191
|
+
counts[class_of[row[y]]] += 1
|
|
192
|
+
matrix.append([n // size for n, size in zip(counts, sizes)])
|
|
193
|
+
return matrix
|
|
194
|
+
|
|
195
|
+
spaces = [[[int(i == l) for l in range(k)] for i in range(k)]]
|
|
196
|
+
for j in range(k):
|
|
197
|
+
if all(len(space) == 1 for space in spaces):
|
|
198
|
+
break
|
|
199
|
+
if j == class_of[identity]:
|
|
200
|
+
continue # its matrix is the unit matrix
|
|
201
|
+
matrix = class_matrix(j)
|
|
202
|
+
spaces = [part for space in spaces
|
|
203
|
+
for part in (_eigenspaces(space, matrix, p) if len(space) > 1 else [space])]
|
|
204
|
+
|
|
205
|
+
inverse = [class_of[chain[-1]] for chain in chains]
|
|
206
|
+
size_inverses = [pow(size, -1, p) for size in sizes]
|
|
207
|
+
modular = []
|
|
208
|
+
for (w,) in spaces:
|
|
209
|
+
scale = pow(w[class_of[identity]], -1, p)
|
|
210
|
+
w = [x * scale % p for x in w]
|
|
211
|
+
norm = sum(w[i] * w[inverse[i]] * size_inverses[i] for i in range(k)) % p
|
|
212
|
+
square = order * pow(norm, -1, p) % p
|
|
213
|
+
dimension = next(d for d in range(1, isqrt(order) + 1) if d * d % p == square)
|
|
214
|
+
modular.append([dimension * x * s % p for x, s in zip(w, size_inverses)])
|
|
215
|
+
|
|
216
|
+
root = _root_of_unity(exponent, p)
|
|
217
|
+
spectra = [[None] * k for _ in modular]
|
|
218
|
+
for i in sorted(range(k), key=lambda i: -len(chains[i])): # operations of highest order first
|
|
219
|
+
if spectra[0][i] is not None:
|
|
220
|
+
continue
|
|
221
|
+
chain = chains[i]
|
|
222
|
+
n = len(chain)
|
|
223
|
+
indices = [class_of[x] for x in chain]
|
|
224
|
+
zeta, n_inverse = pow(root, exponent // n, p), pow(n, -1, p)
|
|
225
|
+
zeta_powers = [pow(zeta, l, p) for l in range(n)]
|
|
226
|
+
for theta, row in zip(modular, spectra):
|
|
227
|
+
values = [theta[c] for c in indices]
|
|
228
|
+
spectrum = [n_inverse * sum(values[l] * zeta_powers[-m * l % n] for l in range(n)) % p
|
|
229
|
+
for m in range(n)]
|
|
230
|
+
# g^l has the eigenvalues of g to the power l: this gives the spectra of all powers of g
|
|
231
|
+
for l in range(n):
|
|
232
|
+
if row[indices[l]] is None:
|
|
233
|
+
divisor = gcd(n, l)
|
|
234
|
+
power = [0] * (n // divisor)
|
|
235
|
+
for m, multiplicity in enumerate(spectrum):
|
|
236
|
+
power[m * (l // divisor) % len(power)] += multiplicity
|
|
237
|
+
row[indices[l]] = tuple(power)
|
|
238
|
+
return [tuple(row) for row in spectra]
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
# --- Mulliken symbols -------------------------------------------------------------------
|
|
242
|
+
|
|
243
|
+
_LETTERS = {1: 'a', 2: 'e', 3: 't', 4: 'g', 5: 'h'}
|
|
244
|
+
_LETTER_ORDER = 'abetgh'
|
|
245
|
+
_QUARTER = Fraction(1, 4)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def has_principal_axis(elements):
|
|
249
|
+
"""False for cubic and icosahedral groups, whose operations are `Polyhedral`."""
|
|
250
|
+
return all(isinstance(element, Axial) for element in elements)
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def mulliken_table(classes, irreps):
|
|
254
|
+
"""
|
|
255
|
+
Name the irreps of a point group by their Mulliken symbols and sort them.
|
|
256
|
+
|
|
257
|
+
Axial point groups (with principal axis z):
|
|
258
|
+
|
|
259
|
+
* The letter is A or B for one-dimensional irreps, symmetric or antisymmetric under
|
|
260
|
+
the principal operation P, and E for two-dimensional ones and for the pairs of complex
|
|
261
|
+
conjugate one-dimensional irreps (separably degenerate E). P is the rotation C_n
|
|
262
|
+
about z of highest order, or S_2n about z if the group contains it but not i
|
|
263
|
+
(eg. S4 in D2d; in D3d, S6 = i C3^2 gives the g/u labels instead).
|
|
264
|
+
* D2, D2h: A is symmetric under all C2, B1, B2, B3 are symmetric under C2(z), C2(y), C2(x).
|
|
265
|
+
* Subscript 1 or 2 for A and B: symmetric or antisymmetric under C2(x), or if there
|
|
266
|
+
is none, under the reflection in the xz plane. Subscript k for E if there are several
|
|
267
|
+
E with the same g/u or ′/″: P acts on E_k as a rotation by 2πk/m, m being its order.
|
|
268
|
+
* The two irreps of a separably degenerate E end in a and b: P acts on the a irrep as
|
|
269
|
+
multiplication by exp(+2πik/m), on the b irrep by exp(-2πik/m) (eg. e1a, e1b; ega, egb).
|
|
270
|
+
* g/u: symmetric or antisymmetric under i; else ′/″: under σh, the reflection in xy.
|
|
271
|
+
Primes are spelled p and pp (a1p for A1′, a1pp for A1″), so that symbols are valid
|
|
272
|
+
Python names.
|
|
273
|
+
|
|
274
|
+
Cubic and icosahedral point groups:
|
|
275
|
+
|
|
276
|
+
* The letter is A, E, T, G or H for dimension 1 to 5, and E also for the pair of complex
|
|
277
|
+
conjugate irreps in T and Th, which ends in a and b like in axial groups.
|
|
278
|
+
* The principal operation P is the proper rotation of highest order, or the improper
|
|
279
|
+
one if it has higher order and the group does not contain i: C3 about (1, 1, 1) in T
|
|
280
|
+
and Th, C4 about z in O and Oh, S4 about z in Td, C5 in I and Ih.
|
|
281
|
+
* Subscripts 1, 2 if there are two irreps of the same letter and g/u: 1 for the larger
|
|
282
|
+
character under P (eg. T1 and T2 in O, χ(C4) = 1 and -1).
|
|
283
|
+
* g/u: symmetric or antisymmetric under i.
|
|
284
|
+
|
|
285
|
+
The irreps are sorted by g/u (or ′/″), then by letter in the order A, B, E, T, G, H,
|
|
286
|
+
then by subscript, then a before b, which puts the totally symmetric irrep first.
|
|
287
|
+
|
|
288
|
+
Parameters
|
|
289
|
+
----------
|
|
290
|
+
classes : sequence of sequences of `Axial` or of `Polyhedral`
|
|
291
|
+
The operations of each class.
|
|
292
|
+
irreps : iterable of tuple
|
|
293
|
+
The spectra of the irreps, one per class, as `characters` gives them.
|
|
294
|
+
|
|
295
|
+
Returns
|
|
296
|
+
-------
|
|
297
|
+
tuple of (str, tuple)
|
|
298
|
+
Lowercase Mulliken symbol and spectra of each irrep, sorted.
|
|
299
|
+
|
|
300
|
+
Raises
|
|
301
|
+
------
|
|
302
|
+
ValueError
|
|
303
|
+
If two irreps get the same symbol.
|
|
304
|
+
"""
|
|
305
|
+
index = {element: i for i, c in enumerate(classes) for element in c}
|
|
306
|
+
irreps = [tuple(irrep) for irrep in irreps]
|
|
307
|
+
if has_principal_axis(index):
|
|
308
|
+
entries = _axial_entries(index, irreps)
|
|
309
|
+
else:
|
|
310
|
+
entries = _cubic_entries(index, irreps)
|
|
311
|
+
entries.sort(key=lambda e: (e[0], _LETTER_ORDER.index(e[1])) + tuple(e[2:4]))
|
|
312
|
+
table = tuple((letter + (str(subscript) if subscript else '') + mark + component, irrep)
|
|
313
|
+
for parity, letter, subscript, component, mark, irrep in entries)
|
|
314
|
+
symbols = [symbol for symbol, _ in table]
|
|
315
|
+
if len(set(symbols)) != len(symbols):
|
|
316
|
+
raise ValueError('irreps with the same Mulliken symbol: {}'.format(', '.join(symbols)))
|
|
317
|
+
return table
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
def _phase(spectrum):
|
|
321
|
+
"""The eigenvalue exp(2πi phase) of an operation in a one-dimensional irrep, as a fraction of a turn."""
|
|
322
|
+
return Fraction(spectrum.index(1), len(spectrum))
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
def _parity(index, irrep, kind):
|
|
326
|
+
"""Index (0 or 1) and mark of an irrep under i, else under σh, else ('', 0)."""
|
|
327
|
+
for operation, marks in ((kind.INVERSION, ('g', 'u')), (kind.SIGMA_H, ('p', 'pp'))):
|
|
328
|
+
if operation in index:
|
|
329
|
+
# i and σh commute with all operations: they act as 1 or as -1
|
|
330
|
+
parity = 0 if irrep[index[operation]][1] == 0 else 1
|
|
331
|
+
return parity, marks[parity]
|
|
332
|
+
return 0, ''
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
def _cubic_entries(index, irreps):
|
|
336
|
+
"""[parity, letter, subscript, component, mark, irrep] of the irreps of a cubic group."""
|
|
337
|
+
inversion = Polyhedral.INVERSION in index
|
|
338
|
+
identity = index[Polyhedral.IDENTITY]
|
|
339
|
+
|
|
340
|
+
def key(item):
|
|
341
|
+
element, description = item
|
|
342
|
+
order = len(irreps[0][index[element]])
|
|
343
|
+
return (-order, axis_rank(description.axis), description.k, unit_vector(description.axis))
|
|
344
|
+
described = [(element, element.describe()) for element in index]
|
|
345
|
+
principal = index[min(((element, description) for element, description in described
|
|
346
|
+
if description.kind == 'C' or (description.kind == 'S' and not inversion)), key=key)[0]]
|
|
347
|
+
entries = []
|
|
348
|
+
for irrep in irreps:
|
|
349
|
+
dimension = sum(irrep[identity])
|
|
350
|
+
parity, mark = _parity(index, irrep, Polyhedral)
|
|
351
|
+
if dimension == 1 and _phase(irrep[principal]) not in (0, Fraction(1, 2)):
|
|
352
|
+
entries.append([parity, 'e', 0, 'a' if _phase(irrep[principal]) < Fraction(1, 2) else 'b', mark, irrep])
|
|
353
|
+
else:
|
|
354
|
+
entries.append([parity, _LETTERS[dimension], 0, '', mark, irrep])
|
|
355
|
+
for parity, letter in {(e[0], e[1]) for e in entries if not e[3]}:
|
|
356
|
+
same = [e for e in entries if (e[0], e[1]) == (parity, letter)]
|
|
357
|
+
if len(same) > 1:
|
|
358
|
+
for subscript, entry in enumerate(sorted(same, key=lambda e: -character(e[5][principal])), 1):
|
|
359
|
+
entry[2] = subscript
|
|
360
|
+
return entries
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
def _axial_entries(index, irreps):
|
|
364
|
+
"""[parity, letter, subscript, component, mark, irrep] of the irreps of an axial group."""
|
|
365
|
+
identity = index[Axial.IDENTITY]
|
|
366
|
+
n = max(m for m in range(1, len(index) + 1) if Axial.rotation(m) in index)
|
|
367
|
+
principal = Axial.rotation(n) if n > 1 else None
|
|
368
|
+
if Axial.INVERSION not in index and Axial.improper_rotation(2 * n) in index: # σh and S_2n would give C_2n
|
|
369
|
+
principal = Axial.improper_rotation(2 * n)
|
|
370
|
+
d2_axes = [Axial.rotation(2), Axial.c2(_QUARTER), Axial.c2()] # C2(z), C2(y), C2(x)
|
|
371
|
+
is_d2 = principal == Axial.rotation(2) and all(element in index for element in d2_axes)
|
|
372
|
+
secondary = next((element for element in (Axial.c2(), Axial.reflection()) if element in index), None)
|
|
373
|
+
|
|
374
|
+
def symmetric(irrep, element):
|
|
375
|
+
return _phase(irrep[index[element]]) == 0
|
|
376
|
+
|
|
377
|
+
entries = []
|
|
378
|
+
for irrep in irreps:
|
|
379
|
+
dimension = sum(irrep[identity])
|
|
380
|
+
parity, mark = _parity(index, irrep, Axial)
|
|
381
|
+
component = ''
|
|
382
|
+
if dimension == 2:
|
|
383
|
+
# P has the eigenvalues exp(±2πik/m)
|
|
384
|
+
letter, spectrum = 'e', irrep[index[principal]]
|
|
385
|
+
subscript = next(k for k in range(1, len(spectrum)) if spectrum[k])
|
|
386
|
+
elif principal is not None and _phase(irrep[index[principal]]) not in (0, Fraction(1, 2)):
|
|
387
|
+
# one of a pair of complex conjugate irreps
|
|
388
|
+
letter, phase = 'e', _phase(irrep[index[principal]])
|
|
389
|
+
subscript = int(min(phase, 1 - phase) * len(irrep[index[principal]]))
|
|
390
|
+
component = 'a' if phase < Fraction(1, 2) else 'b'
|
|
391
|
+
elif is_d2:
|
|
392
|
+
symmetries = [symmetric(irrep, element) for element in d2_axes]
|
|
393
|
+
letter = 'a' if all(symmetries) else 'b'
|
|
394
|
+
subscript = 0 if all(symmetries) else symmetries.index(True) + 1
|
|
395
|
+
else:
|
|
396
|
+
letter = 'a' if principal is None or symmetric(irrep, principal) else 'b'
|
|
397
|
+
subscript = 0 if secondary is None else (1 if symmetric(irrep, secondary) else 2)
|
|
398
|
+
entries.append([parity, letter, subscript, component, mark, irrep])
|
|
399
|
+
|
|
400
|
+
# a single E (or E pair) with its g/u or ′/″ gets no subscript
|
|
401
|
+
single = [parity for parity in (0, 1) if len({e[2] for e in entries if e[:2] == [parity, 'e']}) == 1]
|
|
402
|
+
for entry in entries:
|
|
403
|
+
if entry[1] == 'e' and entry[0] in single:
|
|
404
|
+
entry[2] = 0
|
|
405
|
+
return entries
|