Examples#
Sample code for each feature, in docs/examples. Run each file from anywhere after pip install -e ., e.g.
python docs/examples/group.py. The outputs below are made when the documentation is built.
cluster_basis.py#
Load the orthonormal (scalar) Oh/D6h cluster basis (cluster_scalar_basis.pkl), keyed by PGMultipoleType, expand a function on the cluster.
import numpy as np
from multipiegen.util.util_cluster_basis import load_cluster_basis, cluster_basis_matrix
# 1. load the cluster basis of Oh and D6h.
data = load_cluster_basis()
print("groups:", list(data.keys()))
oh = data["Oh"]
print("site0 :", oh["site0"])
print("number of cluster points:", len(oh["cluster"]))
print("first 3 cluster points (exact):")
for p in oh["cluster"][:3]:
print(" ", p)
groups: ['Oh', 'D6h']
site0 : [1 5 6]
number of cluster points: 48
first 3 cluster points (exact):
[1 5 6]
[-1 -5 6]
[-1 5 -6]
# 2. basis multiplets are keyed by PGMultipoleType(X="Q", l, Gamma, n, p=-1, s=0, k=0, x="q") (MultiPie Ver.2 site SAMB);
# the value has all components, (dim, N).
print("\nbasis keys of Oh:")
for key in oh["basis"].keys():
print(" ", key, oh["basis"][key].shape)
key = [k for k in oh["basis"] if k.l == 1 and k.Gamma == "T1u"][0]
print(f"\n{key}, x component, first 4 values (exact):", oh["basis"][key][0][:4])
# harmonics dropped by Gram-Schmidt (linearly dependent on lower ranks).
print("number of dropped harmonics:", len(oh["dropped"]), ", e.g.", oh["dropped"][:3])
basis keys of Oh:
PGMultipoleType(X='Q', l=0, Gamma='A1g', n=-1, p=-1, s=0, k=0, x='q') (1, 48)
PGMultipoleType(X='Q', l=1, Gamma='T1u', n=-1, p=-1, s=0, k=0, x='q') (3, 48)
PGMultipoleType(X='Q', l=2, Gamma='Eg', n=-1, p=-1, s=0, k=0, x='q') (2, 48)
PGMultipoleType(X='Q', l=2, Gamma='T2g', n=-1, p=-1, s=0, k=0, x='q') (3, 48)
PGMultipoleType(X='Q', l=3, Gamma='A2u', n=-1, p=-1, s=0, k=0, x='q') (1, 48)
PGMultipoleType(X='Q', l=3, Gamma='T1u', n=-1, p=-1, s=0, k=0, x='q') (3, 48)
PGMultipoleType(X='Q', l=3, Gamma='T2u', n=-1, p=-1, s=0, k=0, x='q') (3, 48)
PGMultipoleType(X='Q', l=4, Gamma='Eg', n=-1, p=-1, s=0, k=0, x='q') (2, 48)
PGMultipoleType(X='Q', l=4, Gamma='T1g', n=-1, p=-1, s=0, k=0, x='q') (3, 48)
PGMultipoleType(X='Q', l=4, Gamma='T2g', n=-1, p=-1, s=0, k=0, x='q') (3, 48)
PGMultipoleType(X='Q', l=5, Gamma='Eu', n=-1, p=-1, s=0, k=0, x='q') (2, 48)
PGMultipoleType(X='Q', l=5, Gamma='T1u', n=1, p=-1, s=0, k=0, x='q') (3, 48)
PGMultipoleType(X='Q', l=5, Gamma='T2u', n=-1, p=-1, s=0, k=0, x='q') (3, 48)
PGMultipoleType(X='Q', l=6, Gamma='A2g', n=-1, p=-1, s=0, k=0, x='q') (1, 48)
PGMultipoleType(X='Q', l=6, Gamma='T1g', n=-1, p=-1, s=0, k=0, x='q') (3, 48)
PGMultipoleType(X='Q', l=6, Gamma='T2g', n=1, p=-1, s=0, k=0, x='q') (3, 48)
PGMultipoleType(X='Q', l=7, Gamma='Eu', n=-1, p=-1, s=0, k=0, x='q') (2, 48)
PGMultipoleType(X='Q', l=7, Gamma='T2u', n=1, p=-1, s=0, k=0, x='q') (3, 48)
PGMultipoleType(X='Q', l=8, Gamma='T1g', n=1, p=-1, s=0, k=0, x='q') (3, 48)
PGMultipoleType(X='Q', l=9, Gamma='A1u', n=-1, p=-1, s=0, k=0, x='q') (1, 48)
PGMultipoleType(X='Q', l=1, Gamma='T1u', n=-1, p=-1, s=0, k=0, x='q'), x component, first 4 values (exact): [sqrt(62)/248 -sqrt(62)/248 -sqrt(62)/248 sqrt(62)/248]
number of dropped harmonics: 40 , e.g. [PGMultipoleType(X='Q', l=4, Gamma='A1g', n=-1, p=-1, s=0, k=0, x='q'), PGMultipoleType(X='Q', l=5, Gamma='T1u', n=2, p=-1, s=0, k=0, x='q'), PGMultipoleType(X='Q', l=6, Gamma='A1g', n=-1, p=-1, s=0, k=0, x='q')]
# 3. basis as a float matrix (each row is a component, columns follow oh["cluster"]); keys are (PGMultipoleType, comp).
m, keys = cluster_basis_matrix(oh)
print("\nbasis matrix shape:", m.shape)
print("orthonormal ?", np.allclose(m @ m.T, np.eye(len(keys))))
basis matrix shape: (48, 48)
orthonormal ? True
# 4. expand a function on the cluster in the basis.
# f is a weight on the cluster points, e.g. f(r) = x + 0.5 x y z at each point.
r = np.array(oh["cluster"], dtype=float)
f = r[:, 0] + 0.5 * r[:, 0] * r[:, 1] * r[:, 2]
c = m @ f # coefficients, f = sum_k c_k e_k.
print("\nexpansion of f = x + 0.5 xyz:")
for k, ck in zip(keys, c):
if abs(ck) > 1e-8:
print(f" {k}: {ck:.6f}")
print("reconstructed ?", np.allclose(c @ m, f))
# weight of each irrep (sum of |c_k|^2 over the irrep), total equals |f|^2.
weight = {}
for k, ck in zip(keys, c):
weight[k[0].Gamma] = weight.get(k[0].Gamma, 0.0) + ck**2
print("irrep weights:", {ir: round(float(w), 6) for ir, w in weight.items() if w > 1e-8})
print("|f|^2 =", round(float(f @ f), 6))
expansion of f = x + 0.5 xyz:
(PGMultipoleType(X='Q', l=1, Gamma='T1u', n=-1, p=-1, s=0, k=0, x='q'), 0): 31.496031
(PGMultipoleType(X='Q', l=3, Gamma='A2u', n=-1, p=-1, s=0, k=0, x='q'), 0): 103.923048
reconstructed ? True
irrep weights: {'T1u': 992.0, 'A2u': 10800.0}
|f|^2 = 11792.0
# 5. the same for D6h (24 points).
d6h = data["D6h"]
m6, keys6 = cluster_basis_matrix(d6h)
print("\nD6h basis matrix shape:", m6.shape, ", orthonormal ?", np.allclose(m6 @ m6.T, np.eye(len(keys6))))
print("D6h irreps:", sorted({k[0].Gamma for k in keys6}))
D6h basis matrix shape: (24, 24) , orthonormal ? True
D6h irreps: ['A1g', 'A1u', 'A2g', 'A2u', 'B1g', 'B1u', 'B2g', 'B2u', 'E1g', 'E1u', 'E2g', 'E2u']
cluster_vector_basis.py#
Load the orthonormal vector cluster basis (internal rank s=1, polar/axial internal basis) of the Oh/D6h clusters, keyed by PGMultipoleType, expand a vector field.
import numpy as np
from multipiegen.util.util_cluster_vector_basis import cluster_vector_basis_matrix, load_cluster_vector_basis
data = load_cluster_vector_basis()
for group in ["Oh", "D6h"]:
d = data[group]
print(f"{group}: {len(d['cluster'])} points, internal basis {d['internal_basis']}")
for x in ["q", "g"]:
m, keys = cluster_vector_basis_matrix(d, x)
n_mult = len([k for k in d["basis"] if k.x == x])
n_drop = len([k for k in d["dropped"] if k.x == x])
ok = np.allclose(m @ m.T, np.eye(len(m)))
print(f" x={x}: {len(keys)} vectors in {n_mult} multiplets, orthonormal: {ok}, dropped multiplets: {n_drop}")
Oh: 48 points, internal basis ['px', 'py', 'pz']
x=q: 144 vectors in 60 multiplets, orthonormal: True, dropped multiplets: 118
x=g: 144 vectors in 60 multiplets, orthonormal: True, dropped multiplets: 118
D6h: 24 points, internal basis ['px', 'py', 'pz']
x=q: 72 vectors in 48 multiplets, orthonormal: True, dropped multiplets: 238
x=g: 72 vectors in 48 multiplets, orthonormal: True, dropped multiplets: 238
# keys: PGMultipoleType(X, l, Gamma, n, p=-1, s=1, k, x) as MultiPie Ver.2 vector SAMB; value: (dim, N, 3) at the cluster points.
d = data["Oh"]
for key in list(d["basis"])[:4]:
print(key, "at the first point:", d["basis"][key][:, 0].tolist())
# a vector field on the cluster expanded in the basis: coefficients = <basis|field>.
P = np.array(d["cluster"], dtype=float)
field = np.cross(P, [0, 0, 1]) # rotation around z (axial dipole like).
m, keys = cluster_vector_basis_matrix(d, "q")
c = m @ field.ravel()
print("nonzero components of r x e_z:", [(keys[i], round(c[i], 6)) for i in range(len(c)) if abs(c[i]) > 1e-9])
PGMultipoleType(X='Q', l=0, Gamma='A1g', n=-1, p=-1, s=1, k=1, x='q') at the first point: [[sqrt(186)/744, 5*sqrt(186)/744, sqrt(186)/124]]
PGMultipoleType(X='Q', l=1, Gamma='T1u', n=-1, p=-1, s=1, k=-1, x='q') at the first point: [[sqrt(3)/12, 0, 0], [0, sqrt(3)/12, 0], [0, 0, sqrt(3)/12]]
PGMultipoleType(X='G', l=1, Gamma='T1g', n=-1, p=-1, s=1, k=0, x='q') at the first point: [[0, 3*sqrt(31)/124, -5*sqrt(31)/248], [-3*sqrt(31)/124, 0, sqrt(31)/248], [5*sqrt(31)/248, -sqrt(31)/248, 0]]
PGMultipoleType(X='Q', l=1, Gamma='T1u', n=-1, p=-1, s=1, k=1, x='q') at the first point: [[-59*sqrt(6)/1488, 5*sqrt(6)/496, 3*sqrt(6)/248], [5*sqrt(6)/496, 13*sqrt(6)/1488, 15*sqrt(6)/248], [3*sqrt(6)/248, 15*sqrt(6)/248, 23*sqrt(6)/744]]
nonzero components of r x e_z: [((PGMultipoleType(X='G', l=1, Gamma='T1g', n=-1, p=-1, s=1, k=0, x='q'), 2), np.float64(44.542115))]
bond_cluster_basis.py#
Load the orthonormal bond cluster basis of the Oh/D6h clusters (vector cluster basis contracted with the bond vectors and re-orthonormalized), keyed by PGMultipoleType as MultiPie Ver.2’s bond_a.
import numpy as np
from multipiegen.util.util_bond_cluster_basis import bond_cluster_basis_matrix, load_bond_cluster_basis
data = load_bond_cluster_basis()
for group in ["Oh", "D6h"]:
d = data[group]
print(f"{group}: {len(d['cluster'])} points, vector0 = {d['vector0']}, bond b_0 = {d['bond'][0]}")
for x in ["q", "g"]:
m, keys = bond_cluster_basis_matrix(d, x)
ok = np.allclose(m @ m.T, np.eye(len(m)))
n_mult = len([k for k in d["basis"] if k.x == x])
n_drop = len([k for k in d["dropped"] if k.x == x])
print(f" x={x}: {len(keys)} vectors in {n_mult} multiplets, orthonormal: {ok}, dropped vector multiplets: {n_drop}")
Oh: 48 points, vector0 = [3*sqrt(62)/31 sqrt(62)/62 5*sqrt(62)/62], bond b_0 = [3*sqrt(62)/31 sqrt(62)/62 5*sqrt(62)/62]
x=q: 48 vectors in 20 multiplets, orthonormal: True, dropped vector multiplets: 40
x=g: 48 vectors in 20 multiplets, orthonormal: True, dropped vector multiplets: 40
D6h: 24 points, vector0 = [-5*sqrt(31)/62 sqrt(93)/62 2*sqrt(186)/31], bond b_0 = [-5*sqrt(31)/62 sqrt(93)/62 2*sqrt(186)/31]
x=q: 24 vectors in 16 multiplets, orthonormal: True, dropped vector multiplets: 32
x=g: 24 vectors in 16 multiplets, orthonormal: True, dropped vector multiplets: 32
# keys: PGMultipoleType(X, l, Gamma, n, p, s=0, k=0, x) as MultiPie Ver.2 bond_a; value: (dim, N) values on the bonds.
# source: the multiplet of the vector cluster basis (PGMultipoleType with s=1).
d = data["Oh"]
for key in list(d["basis"])[:4]:
print(key, d["basis"][key].shape, "<-", d["source"][key])
print("with add_multiplicity:", [k for k in d["basis"] if k.p != -1][:2])
print("dropped vector cluster basis multiplets (first 2):", d["dropped"][:2])
PGMultipoleType(X='Q', l=0, Gamma='A1g', n=-1, p=-1, s=0, k=0, x='q') (1, 48) <- PGMultipoleType(X='Q', l=0, Gamma='A1g', n=-1, p=-1, s=1, k=1, x='q')
PGMultipoleType(X='Q', l=1, Gamma='T1u', n=-1, p=1, s=0, k=0, x='q') (3, 48) <- PGMultipoleType(X='Q', l=1, Gamma='T1u', n=-1, p=-1, s=1, k=-1, x='q')
PGMultipoleType(X='G', l=1, Gamma='T1g', n=-1, p=-1, s=0, k=0, x='q') (3, 48) <- PGMultipoleType(X='G', l=1, Gamma='T1g', n=-1, p=-1, s=1, k=0, x='q')
PGMultipoleType(X='Q', l=1, Gamma='T1u', n=-1, p=2, s=0, k=0, x='q') (3, 48) <- PGMultipoleType(X='Q', l=1, Gamma='T1u', n=-1, p=-1, s=1, k=1, x='q')
with add_multiplicity: [PGMultipoleType(X='Q', l=1, Gamma='T1u', n=-1, p=1, s=0, k=0, x='q'), PGMultipoleType(X='Q', l=1, Gamma='T1u', n=-1, p=2, s=0, k=0, x='q')]
dropped vector cluster basis multiplets (first 2): [PGMultipoleType(X='Q', l=3, Gamma='A2u', n=-1, p=-1, s=1, k=1, x='q'), PGMultipoleType(X='Q', l=3, Gamma='T1u', n=-1, p=-1, s=1, k=1, x='q')]
cluster_samb.py#
Cluster SAMB of each Wyckoff site and bond (site; bond = symmetric Q and anti-symmetric T/M) of the real point groups and the space groups (cluster_samb.pkl).
import numpy as np
from multipiegen.util.util_cluster_samb import load_cluster_samb
from multipiegen.util.util_harmonics import harmonics_expression
from multipiegen.util.util_info import load_info
info = load_info()
data = load_cluster_samb()
# {PG_id/SG_id: {"site"/"bond": {wyckoff: {PGMultipoleType: samb (dim, N)}}}}.
# "bond": symmetric bond (X = Q, real) and i times anti-symmetric bond (X = T/M, pure imaginary).
# the expression of the harmonics (X, l, Gamma, n) is looked up by the key in harmonics.pkl (T, M as Q, G).
d = data[info["id"]["D4h"]]
for kind in ["site", "bond"]:
w = list(d[kind].keys())[1]
print(f"* {kind} {w}")
for key, samb in d[kind][w].items():
print(" ", key, "ex =", list(harmonics_expression("D4h", key)))
print(" ", samb.tolist())
# orthonormality on the N sites (bonds) of each Wyckoff position, for Q and T/M separately (different time-reversal
# parity).
d = data["SG:225"]
for kind in ["site", "bond"]:
for X in ["Q", "TM"]:
parts = [[np.array(s, dtype=complex) for k, s in samb.items() if k.X in X] for samb in d[kind].values()]
parts = [np.vstack(p) for p in parts if p]
if not parts:
continue
ok = all(np.allclose(v.conj() @ v.T, np.eye(len(v))) for v in parts)
print(f"SG:225 {kind} {X}: {len(parts)} Wyckoff positions, orthonormal: {ok}")
* site 2a
PGMultipoleType(X='Q', l=0, Gamma='A1g', n=-1, p=-1, s=0, k=0, x='q') ex = [1]
[[sqrt(2)/2, sqrt(2)/2]]
PGMultipoleType(X='Q', l=1, Gamma='A2u', n=-1, p=-1, s=0, k=0, x='q') ex = [z]
[[sqrt(2)/2, -sqrt(2)/2]]
* bond 2b@1o
PGMultipoleType(X='Q', l=0, Gamma='A1g', n=-1, p=-1, s=0, k=0, x='q') ex = [1]
[[sqrt(2)/2, sqrt(2)/2]]
PGMultipoleType(X='Q', l=2, Gamma='B1g', n=-1, p=-1, s=0, k=0, x='q') ex = [sqrt(3)*x**2/2 - sqrt(3)*y**2/2]
[[-sqrt(2)/2, sqrt(2)/2]]
PGMultipoleType(X='T', l=1, Gamma='Eu', n=-1, p=1, s=0, k=0, x='q') ex = [x, y]
[[I, 0], [0, I]]
SG:225 site Q: 12 Wyckoff positions, orthonormal: True
SG:225 bond Q: 62 Wyckoff positions, orthonormal: True
SG:225 bond TM: 62 Wyckoff positions, orthonormal: True
group.py#
Data of each group (group.pkl): symmetry operations, product, mapping to Oh/D6h, character, Wyckoff site and bond, active multipoles.
from multipiegen.util.util_group import load_group
from multipiegen.util.util_info import load_info
info = load_info()
group = load_group()
print("number of groups:", len(group.keys()), "(PG, SG, MPG, MSG)\n")
number of groups: 2085 (PG, SG, MPG, MSG)
# 1. symmetry operations of a point group (D4h).
d4h = group[info["id"]["D4h"]]
so = d4h["symmetry_operation"]
print("D4h:", d4h["info"].international, ", SO:", so["tag"])
print(" matrix of 4+[001] (cartesian):", so["cartesian"][so["tag"].index("4+[001]")].tolist())
print(" product 4+[001] * 2[100] =", so["product"][("4+[001]", "2[100]")])
print(" dipole matrix of 4+[001], axial (G, s=1):", so["so_matrix"][("G", 1)][2].tolist())
D4h: 4/mmm , SO: ['1', '2[001]', '4+[001]', '4-[001]', '2[010]', '2[100]', '2[110]', '2[1-10]', '-1', 'm[001]', '-4+[001]', '-4-[001]', 'm[010]', 'm[100]', 'm[110]', 'm[1-10]']
matrix of 4+[001] (cartesian): [[0, -1, 0], [1, 0, 0], [0, 0, 1]]
product 4+[001] * 2[100] = 2[110]
dipole matrix of 4+[001], axial (G, s=1): [[0, -1, 0], [1, 0, 0], [0, 0, 1]]
# 2. mapping to the Oh cluster: mapping[0] is D4h itself, mapping[k] is a left coset in Oh.
top = so["mapping"]["top"]
oh_tag = group[info["id"][top]]["symmetry_operation"]["tag"]
print(f"\nmapping to {top}:")
for k, row in enumerate(so["mapping"]["mapping"]):
print(f" coset {k}:", [oh_tag[i - 1] for i in row][:6], "...")
mapping to Oh:
coset 0: ['1', '2[001]', '4+[001]', '4-[001]', '2[010]', '2[100]'] ...
coset 1: ['3+[111]', '3+[-11-1]', '2[101]', '4+[010]', '3+[1-1-1]', '3+[-1-11]'] ...
coset 2: ['3-[111]', '3-[1-1-1]', '4-[100]', '2[011]', '3-[-1-11]', '3-[-11-1]'] ...
# 3. character table (complex PG has its own table, other data are those of the real PG).
c3h = group[info["id"]["C3h-c"]]
print("\nC3h-c irreps:", list(c3h["character"]["table"]))
print(" character of Ea' for all SO:", c3h["character"]["table_full"]["Ea'"].tolist())
C3h-c irreps: ["A'", "Ea'", "Eb'", "A''", "Ea''", "Eb''"]
character of Ea' for all SO: [1, -1/2 - sqrt(3)*I/2, -1/2 + sqrt(3)*I/2, 1, -1/2 - sqrt(3)*I/2, -1/2 + sqrt(3)*I/2]
# 4. Wyckoff site and bond of a space group (P6_3/mmc).
sg = group["SG:194"]
site = sg["wyckoff"]["site"]["2a"]
print("\nSG:194", sg["info"].international, "Wyckoff 2a:", site["conventional"].tolist(), ", symmetry:", site["symmetry"])
print(" mapping:", site["mapping"])
print(" bonds at 2a:", site["bond"][:4])
bw = site["bond"][0]
bond = sg["wyckoff"]["bond"][bw]
print(f" bond {bw}: symmetry {bond['symmetry']}, (vector, center) =", bond["conventional"].tolist())
SG:194 P6_3/mmc Wyckoff 2a: [[0, 0, 0], [0, 0, 1/2]] , symmetry: -3m.
mapping: [[1, 2, 3, 7, 8, 9, 13, 14, 15, 19, 20, 21], [4, 5, 6, 10, 11, 12, 16, 17, 18, 22, 23, 24]]
bonds at 2a: ['2a@2a', '6b@2a', '6c@2a', '12d@2a']
bond 2a@2a: symmetry -3m., (vector, center) = [[0, 0, Z, 0, 0, 0], [0, 0, Z, 0, 0, 1/2]]
# 5. magnetic point group: active multipoles.
mpg = group["MPG:24.5.149"]
print("\nMPG", mpg["info"].international, "time-reversal sign:", mpg["symmetry_operation"]["tr_sign"].tolist())
print(" active multipoles:", mpg["active_multipole"])
MPG 6'22' time-reversal sign: [1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1]
active multipoles: ['Qs', 'Qdu', 'Qg0', 'Gs', 'Gdu', 'Gg0', 'Tfs', 'Tgc', 'Mfs', 'Mgc']
representation_matrix.py#
Representation matrices of a point group from the harmonics up to rank 11, and the check that all harmonics of an irrep give the same matrices.
from multipiegen.util.util_representation_matrix import (
check_representation_matrix,
harmonics_blocks,
representation_matrix,
)
pg = "D3h"
# 1. harmonics blocks (X, rank, irrep, multiplicity) -> [(coeff, top key)] of each component.
blocks = harmonics_blocks(pg)
print(f"{pg}: {len(blocks)} harmonics blocks up to rank 11, e.g.")
for b in list(blocks)[:4]:
print(" ", b, blocks[b])
D3h: 192 harmonics blocks up to rank 11, e.g.
('Q', 0, "A1'", -1) [(1, (0, 'A1g', -1, -1))]
('Q', 1, "A2''", -1) [(1, (1, 'A2u', -1, -1))]
('Q', 1, "E'", -1) [(1, (1, 'E1u', -1, 0)), (1, (1, 'E1u', -1, 1))]
('Q', 2, "A1'", -1) [(1, (2, 'A1g', -1, -1))]
# 2. all harmonics of the same irrep have the same representation matrices.
print("\nirrep: number of harmonics blocks, max deviation from the first one, max closure residual")
for irrep, d in check_representation_matrix(pg).items():
print(f" {irrep:4s}: {len(d['blocks']):3d}, {d['deviation']:.1e}, {d['closure']:.1e}")
irrep: number of harmonics blocks, max deviation from the first one, max closure residual
A1' : 24, 1.1e-15, 1.0e-15
A2'': 24, 6.7e-16, 1.3e-15
E' : 48, 1.2e-15, 1.4e-15
E'' : 48, 1.1e-15, 1.4e-15
A2' : 24, 1.3e-15, 1.3e-15
A1'': 24, 1.4e-15, 1.0e-15
# 3. exact representation matrices (in the order of symmetry operations).
rm = representation_matrix(pg)
D = rm["matrix"]["E'"]
for tag, d in list(zip(rm["tag"], D))[:3]:
print(f"\nE' {tag}:\n{d}")
E' 1:
[[1 0]
[0 1]]
E' 3+[001]:
[[-1/2 -sqrt(3)/2]
[sqrt(3)/2 -1/2]]
E' 3-[001]:
[[-1/2 sqrt(3)/2]
[-sqrt(3)/2 -1/2]]
response_tensor.py#
Response tensors (rank 0-4) of a magnetic point group in terms of active multipoles (response_tensor.pkl).
from multipiegen.util.util_group import load_group
from multipiegen.util.util_response_tensor import load_response_tensor
rt = load_response_tensor()
group = load_group()
mpg = "MPG:24.5.149"
print(mpg, group[mpg]["info"].international, ", active multipoles:", group[mpg]["active_multipole"])
MPG:24.5.149 6'22' , active multipoles: ['Qs', 'Qdu', 'Qg0', 'Gs', 'Gdu', 'Gg0', 'Tfs', 'Tgc', 'Mfs', 'Mgc']
# 1. keys: (X, rank, opt), X = Q (polar), G (axial), T (magnetic polar), M (magnetic axial).
d = rt[mpg]
print("number of tensors:", len(d), ", e.g.", list(d)[:4])
number of tensors: 64 , e.g. [('Q', 0, ''), ('Q', 1, ''), ('Q', 2, 's'), ('Q', 2, 'a')]
# 2. non-vanishing tensors and their expressions in terms of active multipoles.
for (X, rank, opt), (m, ex) in d.items():
if ex and rank <= 3:
print(f"\n{X} rank {rank} {opt}:\n{m}")
for c, e in ex.items():
print(f" {c} = {e}")
Q rank 0 :
[[Q]]
Q = \mathbb{Q}_{0}^{(1)}
Q rank 2 s:
[[Q_{xx} 0 0]
[0 Q_{xx} 0]
[0 0 Q_{zz}]]
Q_{xx} = \mathbb{Q}_{0}^{(1)} - \mathbb{Q}_{u}^{(1)}
Q_{zz} = \mathbb{Q}_{0}^{(1)} + 2*\mathbb{Q}_{u}^{(1)}
Q rank 3 sa:
[[0 0 0]
[0 0 0]
[0 0 0]
[Q_{yzx} 0 0]
[0 -Q_{yzx} 0]
[0 0 0]]
Q_{yzx} = 3*\mathbb{G}_{u}^{(1)}
Q rank 3 a:
[[Q_{yzx} 0 0]
[0 Q_{yzx} 0]
[0 0 Q_{xyz}]]
Q_{yzx} = \mathbb{G}_{0}^{(1)} - \mathbb{G}_{u}^{(2)}
Q_{xyz} = \mathbb{G}_{0}^{(1)} + 2*\mathbb{G}_{u}^{(2)}
G rank 0 :
[[G]]
G = \mathbb{G}_{0}^{(1)}
G rank 2 s:
[[G_{xx} 0 0]
[0 G_{xx} 0]
[0 0 G_{zz}]]
G_{xx} = \mathbb{G}_{0}^{(1)} - \mathbb{G}_{u}^{(1)}
G_{zz} = \mathbb{G}_{0}^{(1)} + 2*\mathbb{G}_{u}^{(1)}
G rank 3 sa:
[[0 0 0]
[0 0 0]
[0 0 0]
[G_{yzx} 0 0]
[0 -G_{yzx} 0]
[0 0 0]]
G_{yzx} = 3*\mathbb{Q}_{u}^{(1)}
G rank 3 a:
[[G_{yzx} 0 0]
[0 G_{yzx} 0]
[0 0 G_{xyz}]]
G_{yzx} = \mathbb{Q}_{0}^{(1)} - \mathbb{Q}_{u}^{(2)}
G_{xyz} = \mathbb{Q}_{0}^{(1)} + 2*\mathbb{Q}_{u}^{(2)}
T rank 3 ss:
[[0 T_{xxy} 0]
[0 -T_{xxy} 0]
[0 0 0]
[0 0 0]
[0 0 0]
[T_{xxy} 0 0]]
T_{xxy} = \mathbb{T}_{3s}^{(1)}
M rank 3 ss:
[[0 M_{xxy} 0]
[0 -M_{xxy} 0]
[0 0 0]
[0 0 0]
[0 0 0]
[M_{xxy} 0 0]]
M_{xxy} = \mathbb{M}_{3s}^{(1)}
harmonics.py#
Expression and u-matrix of the harmonics of a point group (harmonics.pkl), looked up by a multipole key of any binary.
from multipiegen.util.util_cluster_samb import load_cluster_samb
from multipiegen.util.util_harmonics import harmonics_expression, harmonics_u_matrix, load_harmonics
from multipiegen.util.util_info import load_info
info = load_info()
# 1. {PG_id: {PGMultipoleType(X, l, Gamma, n, -1, 0, 0, "q"): (expression (dim), u_matrix (2l+1, dim))}}.
d = load_harmonics()[info["id"]["D4h"]]
print("D4h:", len(d), "harmonics (rank <= 11)")
for key, (ex, U) in list(d.items())[:4]:
print(" ", key, list(ex), U.shape)
D4h: 216 harmonics (rank <= 11)
PGMultipoleType(X='Q', l=0, Gamma='A1g', n=-1, p=-1, s=0, k=0, x='q') [1] (1, 1)
PGMultipoleType(X='Q', l=2, Gamma='A1g', n=-1, p=-1, s=0, k=0, x='q') [-x**2/2 - y**2/2 + z**2] (5, 1)
PGMultipoleType(X='Q', l=4, Gamma='A1g', n=1, p=-1, s=0, k=0, x='q') [sqrt(21)*x**4/6 - sqrt(21)*x**2*y**2/2 - sqrt(21)*x**2*z**2/2 + sqrt(21)*y**4/6 - sqrt(21)*y**2*z**2/2 + sqrt(21)*z**4/6] (9, 1)
PGMultipoleType(X='Q', l=4, Gamma='A1g', n=2, p=-1, s=0, k=0, x='q') [-sqrt(15)*x**4/12 + sqrt(15)*x**2*y**2 - sqrt(15)*x**2*z**2/2 - sqrt(15)*y**4/12 - sqrt(15)*y**2*z**2/2 + sqrt(15)*z**4/6] (9, 1)
# 2. look up the harmonics of a key of another binary (only (X, l, Gamma, n) of the key is used).
samb = load_cluster_samb()[info["id"]["D4h"]]["site"]["4b"]
for key in list(samb)[:3]:
print(key, "->", list(harmonics_expression("D4h", key)))
key = list(samb)[1]
print("u-matrix of", key, ":\n", harmonics_u_matrix("PG:15", key))
PGMultipoleType(X='Q', l=0, Gamma='A1g', n=-1, p=-1, s=0, k=0, x='q') -> [1]
PGMultipoleType(X='Q', l=2, Gamma='B2g', n=-1, p=-1, s=0, k=0, x='q') -> [sqrt(3)*x*y]
PGMultipoleType(X='Q', l=1, Gamma='Eu', n=-1, p=-1, s=0, k=0, x='q') -> [x, y]
u-matrix of PGMultipoleType(X='Q', l=2, Gamma='B2g', n=-1, p=-1, s=0, k=0, x='q') :
[[-sqrt(2)*I/2]
[0]
[0]
[0]
[sqrt(2)*I/2]]
multipolar_harmonics.py#
Multipolar harmonics (internal rank s=1,2,3, rank l<=3) with polar/axial internal basis of the data_basis orbitals (multipolar_harmonics.pkl).
import collections
from multipiegen.util.util_harmonics import harmonics_expression
from multipiegen.util.util_harmonics_multipole import load_multipolar_harmonics
from multipiegen.util.util_info import load_info
info = load_info()
hm = load_multipolar_harmonics()
# 1. keys: PGMultipoleType(X, l, Gamma, n, p, s, k, x); value: (internal_coefficient, multipole_expression).
# the expression of the harmonics (X, l, Gamma, n) is looked up by the key in harmonics.pkl.
for pg in ["Oh", "D6h"]:
d = hm[info["id"][pg]]
print(pg, len(d), "multipolar harmonics:", dict(collections.Counter((k.x, k.s) for k in d)))
crystal = "cubic" if pg == "Oh" else "hexagonal"
print(" internal basis (s=3, q):", info["harmonics"]["internal_basis"][crystal][(3, "q")])
Oh 166 multipolar harmonics: {('q', 1): 19, ('q', 2): 29, ('q', 3): 35, ('g', 1): 19, ('g', 2): 29, ('g', 3): 35}
internal basis (s=3, q): [Q_{xyz}, Q_{x}^{\alpha}, Q_{y}^{\alpha}, Q_{z}^{\alpha}, Q_{x}^{\beta}, Q_{y}^{\beta}, Q_{z}^{\beta}]
D6h 270 multipolar harmonics: {('q', 1): 31, ('q', 2): 47, ('q', 3): 57, ('g', 1): 31, ('g', 2): 47, ('g', 3): 57}
internal basis (s=3, q): [Q_{z}^{\alpha}, Q_{3s}, Q_{3c}, Q_{3x}, Q_{3y}, Q_{xyz}, Q_{z}^{\beta}]
# 2. an example: a dipole-type (s=1) multipole of rank 2 in Oh.
d = hm[info["id"]["Oh"]]
key = [k for k in d if k.s == 1 and k.l == 2 and k.Gamma == "Eg" and k.k == 1][0]
coeff, expr = d[key]
print("\n", key)
print(" harmonics:", harmonics_expression("Oh", key).tolist())
print(" internal coefficient of [Q_x, Q_y, Q_z] (first component):", coeff[0].tolist())
print(" multipole expression (first component):", expr[0])
PGMultipoleType(X='Q', l=2, Gamma='Eg', n=-1, p=-1, s=1, k=1, x='q')
harmonics: [-x**2/2 - y**2/2 + z**2, sqrt(3)*x**2/2 - sqrt(3)*y**2/2]
internal coefficient of [Q_x, Q_y, Q_z] (first component): [-sqrt(21)*x*(x**2 + y**2 - 4*z**2)/14, -sqrt(21)*y*(x**2 + y**2 - 4*z**2)/14, -sqrt(21)*z*(3*x**2 + 3*y**2 - 2*z**2)/14]
multipole expression (first component): -sqrt(21)*Q_{x}*x*(x**2 + y**2 - 4*z**2)/14 - sqrt(21)*Q_{y}*y*(x**2 + y**2 - 4*z**2)/14 - sqrt(21)*Q_{z}*z*(3*x**2 + 3*y**2 - 2*z**2)/14
# 3. axial internal basis (g) of rank s=2 in D6h.
d = hm[info["id"]["D6h"]]
key = [k for k in d if k.x == "g" and k.s == 2][0]
print("\n", key, "\n ", d[key][1].tolist())
PGMultipoleType(X='Q', l=2, Gamma='A1g', n=-1, p=-1, s=2, k=-1, x='g')
[sqrt(2)*G_{xz}*y/2 - sqrt(2)*G_{yz}*x/2]
atomic_multipole.py#
Atomic multipole matrices (atomic_multipole.pkl) and atomic multipole SAMB of a point group in the jml/lgs/lg basis, keyed by PGMultipoleType (atomic_multipole_group.pkl).
import numpy as np
from multipiegen.data.data_basis import atomic_lgs_basis
from multipiegen.util.util_atomic_multipole import load_atomic_multipole, load_atomic_multipole_group
from multipiegen.util.util_harmonics import harmonics_expression
from multipiegen.util.util_info import load_info
# atomic multipole: {"lms"/"jml"/"lm": {(L1, L2): {SphericalMultipoleType(X, l, s, k, "q"): ndarray(2l+1, n1, n2)}}}.
am = load_atomic_multipole()
for key, mat in am["lms"][(1, 1)].items():
print(key, mat.shape)
SphericalMultipoleType(X='Q', l=0, s=0, k=0, x='q') (1, 6, 6)
SphericalMultipoleType(X='Q', l=2, s=0, k=0, x='q') (5, 6, 6)
SphericalMultipoleType(X='Q', l=2, s=1, k=-1, x='q') (5, 6, 6)
SphericalMultipoleType(X='Q', l=0, s=1, k=1, x='q') (1, 6, 6)
SphericalMultipoleType(X='G', l=1, s=1, k=0, x='q') (3, 6, 6)
SphericalMultipoleType(X='T', l=2, s=1, k=0, x='q') (5, 6, 6)
SphericalMultipoleType(X='M', l=1, s=0, k=0, x='q') (3, 6, 6)
SphericalMultipoleType(X='M', l=1, s=1, k=-1, x='q') (3, 6, 6)
SphericalMultipoleType(X='M', l=3, s=1, k=-1, x='q') (7, 6, 6)
SphericalMultipoleType(X='M', l=1, s=1, k=1, x='q') (3, 6, 6)
# atomic multipole SAMB of Oh: {"jml"/"lgs"/"lg": {(L1, L2): {PGMultipoleType: matrix (dim, n1, n2)}}}.
# the expression of the harmonics (X, l, Gamma, n) is looked up by the key in harmonics.pkl.
info = load_info()
pg = load_atomic_multipole_group()[info["id"]["Oh"]]
print("lgs basis of p:", atomic_lgs_basis[1])
for key, mat in list(pg["lgs"][(1, 1)].items())[:3]:
print(key, "symmetry:", list(harmonics_expression("Oh", key)))
print(mat[0])
# orthonormality: Re tr(A^dagger B) = delta (diagonal block) or delta/2 (off-diagonal block).
for block in [(1, 1), (1, 2)]:
v = np.array([np.asarray(c, dtype=complex).ravel() for m in pg["lgs"][block].values() for c in m])
g = (v.conj() @ v.T).real
print(block, len(v), "matrices, orthonormal:", np.allclose(g, np.eye(len(v)) * (1 if block[0] == block[1] else 0.5)))
lgs basis of p: ['(px,u)', '(px,d)', '(py,u)', '(py,d)', '(pz,u)', '(pz,d)']
PGMultipoleType(X='Q', l=0, Gamma='A1g', n=-1, p=-1, s=0, k=0, x='q') symmetry: [1]
[[sqrt(6)/6 0 0 0 0 0]
[0 sqrt(6)/6 0 0 0 0]
[0 0 sqrt(6)/6 0 0 0]
[0 0 0 sqrt(6)/6 0 0]
[0 0 0 0 sqrt(6)/6 0]
[0 0 0 0 0 sqrt(6)/6]]
PGMultipoleType(X='Q', l=2, Gamma='Eg', n=-1, p=-1, s=0, k=0, x='q') symmetry: [-x**2/2 - y**2/2 + z**2, sqrt(3)*x**2/2 - sqrt(3)*y**2/2]
[[-sqrt(3)/6 0 0 0 0 0]
[0 -sqrt(3)/6 0 0 0 0]
[0 0 -sqrt(3)/6 0 0 0]
[0 0 0 -sqrt(3)/6 0 0]
[0 0 0 0 sqrt(3)/3 0]
[0 0 0 0 0 sqrt(3)/3]]
PGMultipoleType(X='Q', l=2, Gamma='T2g', n=-1, p=-1, s=0, k=0, x='q') symmetry: [sqrt(3)*y*z, sqrt(3)*x*z, sqrt(3)*x*y]
[[0 0 0 0 0 0]
[0 0 0 0 0 0]
[0 0 0 0 1/2 0]
[0 0 0 0 0 1/2]
[0 0 1/2 0 0 0]
[0 0 0 1/2 0 0]]
(1, 1) 36 matrices, orthonormal: True
(1, 2) 120 matrices, orthonormal: True
harmonics_symbol.py#
Polar and axial symbols of harmonics side by side for all 47 point groups (as in the harmonics PDF).
from multipiegen.util.util_harmonics_symbol import harmonics_symbol_table, polar_to_axial, multipole_symbol
# 1. table of Oh harmonics: (key, polar symbol, axial symbol, expression in LaTeX).
tbl = harmonics_symbol_table("Oh")
print("number of Oh harmonics (rank 0-11):", len(tbl))
for key, p_sym, a_sym, expr in tbl[:9]:
print(f" {str(key):22s} {p_sym:28s} {a_sym:30s} {expr}")
number of Oh harmonics (rank 0-11): 144
(0, 'A1g', -1, -1) \mathbb{Q}_{0}(A_{1g}) \mathbb{G}_{0}(A_{1u}) 1
(1, 'T1u', -1, 0) \mathbb{Q}_{1,1}(T_{1u}) \mathbb{G}_{1,1}(T_{1g}) x
(1, 'T1u', -1, 1) \mathbb{Q}_{1,2}(T_{1u}) \mathbb{G}_{1,2}(T_{1g}) y
(1, 'T1u', -1, 2) \mathbb{Q}_{1,3}(T_{1u}) \mathbb{G}_{1,3}(T_{1g}) z
(2, 'Eg', -1, 0) \mathbb{Q}_{2,1}(E_{g}) \mathbb{G}_{2,1}(E_{u}) - \frac{x^{2}}{2} - \frac{y^{2}}{2} + z^{2}
(2, 'Eg', -1, 1) \mathbb{Q}_{2,2}(E_{g}) \mathbb{G}_{2,2}(E_{u}) \frac{\sqrt{3} \left(x - y\right) \left(x + y\right)}{2}
(2, 'T2g', -1, 0) \mathbb{Q}_{2,1}(T_{2g}) \mathbb{G}_{2,1}(T_{2u}) \sqrt{3} y z
(2, 'T2g', -1, 1) \mathbb{Q}_{2,2}(T_{2g}) \mathbb{G}_{2,2}(T_{2u}) \sqrt{3} x z
(2, 'T2g', -1, 2) \mathbb{Q}_{2,3}(T_{2g}) \mathbb{G}_{2,3}(T_{2u}) \sqrt{3} x y
# 2. for Oh and D6h, the axial irrep is obtained by g <-> u (same component, no sign).
for key, p_sym, a_sym, expr in harmonics_symbol_table("D6h"):
if key[0] == 3:
print(f" D6h: {p_sym:28s} -> {a_sym}")
D6h: \mathbb{Q}_{3}(A_{2u}) -> \mathbb{G}_{3}(A_{2g})
D6h: \mathbb{Q}_{3}(B_{1u}) -> \mathbb{G}_{3}(B_{1g})
D6h: \mathbb{Q}_{3}(B_{2u}) -> \mathbb{G}_{3}(B_{2g})
D6h: \mathbb{Q}_{3,1}(E_{1u}) -> \mathbb{G}_{3,1}(E_{1g})
D6h: \mathbb{Q}_{3,2}(E_{1u}) -> \mathbb{G}_{3,2}(E_{1g})
D6h: \mathbb{Q}_{3,1}(E_{2u}) -> \mathbb{G}_{3,1}(E_{2g})
D6h: \mathbb{Q}_{3,2}(E_{2u}) -> \mathbb{G}_{3,2}(E_{2g})
# 3. polar -> axial for a single key (any of the 47 point groups).
a_key, sign = polar_to_axial("Oh", (2, "Eg", -1, 1))
print("\nOh Q(Eg,2) ->", a_key, sign, multipole_symbol("G", a_key, sign))
# Td: components are interchanged and a sign appears.
for key, p_sym, a_sym, expr in harmonics_symbol_table("Td")[4:9]:
print(f" Td: {p_sym:24s} -> {a_sym:26s} {expr}")
# complex group: complex irreps E^(a), E^(b) and complex expressions.
for key, p_sym, a_sym, expr in harmonics_symbol_table("C3h-c")[1:4]:
print(f" C3h-c: {p_sym:30s} -> {a_sym:30s} {expr}")
Oh Q(Eg,2) -> (2, 'Eu', -1, 1) 1 \mathbb{G}_{2,2}(E_{u})
Td: \mathbb{Q}_{2,1}(E) -> \mathbb{G}_{2,2}(E) - \frac{x^{2}}{2} - \frac{y^{2}}{2} + z^{2}
Td: \mathbb{Q}_{2,2}(E) -> -\mathbb{G}_{2,1}(E) \frac{\sqrt{3} \left(x - y\right) \left(x + y\right)}{2}
Td: \mathbb{Q}_{2,1}(T_{2}) -> \mathbb{G}_{2,1}(T_{1}) \sqrt{3} y z
Td: \mathbb{Q}_{2,2}(T_{2}) -> \mathbb{G}_{2,2}(T_{1}) \sqrt{3} x z
Td: \mathbb{Q}_{2,3}(T_{2}) -> \mathbb{G}_{2,3}(T_{1}) \sqrt{3} x y
C3h-c: \mathbb{Q}_{1}(E^{\prime(a)}) -> \mathbb{G}_{1}(E^{\prime\prime(a)}) \frac{\sqrt{2} \left(x + i y\right)}{2}
C3h-c: \mathbb{Q}_{1}(E^{\prime(b)}) -> \mathbb{G}_{1}(E^{\prime\prime(b)}) \frac{\sqrt{2} \left(x - i y\right)}{2}
C3h-c: \mathbb{Q}_{1}(A^{\prime\prime}) -> \mathbb{G}_{1}(A^{\prime}) z
# 4. create the PDFs of all 47 point groups (needs ptex2pdf):
# python -m multipiegen.create_pdf.create_pdf_harmonics
info.py#
Overall information of groups (info.pkl): group id/tag/name, orbital basis and basis functions, root cluster.
from multipiegen.util.util_info import load_info
# 1. load info. str(info) is the description of the contents.
info = load_info()
print("keys:", list(info.keys()))
print(str(info)[:400], "...\n")
keys: ['id_set', 'tag', 'id', 'group_name', 'character', 'root_cluster', 'harmonics', 'response_tensor']
"""
* Information of all groups.
- "id_set" (str): (dict) info. of group's IDs.
- "PG/SG/MPG/MSG" (str): (dict) ID set.
- PG: all/crystal/complex/irrep.
- SG: all/crystal/PG.
- MPG: all/crystal/PG/type.
- MSG: all/crystal/PG/SG/MPG/type.
- "tag" (str): (dict) from id to tag.
- "id" (str): (dict) from tag to id.
- "group_name" (str): (dict) name list of groups (data_group_name_l ...
# 2. group id, tag and name.
print("PG:32 ->", info["tag"]["PG:32"], ", Oh ->", info["id"]["Oh"])
print("number of SG:", len(info["id_set"]["SG"]["all"]))
print("name of PG:32:", info["group_name"]["PG"]["PG:32"])
PG:32 -> Oh , Oh -> PG:32
number of SG: 230
name of PG:32: {'dir': '032-Oh', 'md': 'No_32.md', 'no': 32, 'tag': 'Oh', 'name': '$O_{\\rm h}$ ($m\\bar{3}m$)', 'PG': 'PG:32', 'SG': 'SG:221', 'MPG': 'MPG:32.2.119', 'MSG': 'MSG:221.93'}
# 3. orbital basis (renamed tags) and basis functions.
h = info["harmonics"]
print("\nvariables: site", h["variable_site"], ", vector", h["variable_vector"])
print("\nregular atomic orbitals (lg):", h["atomic_basis"]["spinless"]["lg"])
print("cubic orbitals:", h["atomic_basis"]["spinless"]["cubic"][3])
print("hexagonal orbitals:", h["atomic_basis"]["spinless"]["hexagonal"][3])
for name in ["fc", "fx", "gc4"]:
expr, u = h["basis_function"][name]
print(f" {name:4s}: key={h['harmonics_key'][name]}, expression={expr}, <m|gamma>={u}")
print("tesseral tag of fc:", h["tesseral"]["fc"], ", Wannier90 fxz2 ->", h["wannier90"]["fxz2"])
print("internal basis (cubic, s=3, polar):", h["internal_basis"]["cubic"][(3, "q")])
variables: site [x y z] , vector [X Y Z]
regular atomic orbitals (lg): {0: ['s'], 1: ['px', 'py', 'pz'], 2: ['dv', 'dxy', 'dxz', 'dyz', 'du'], 3: ['fc', 'fs', 'fbz', 'f3', 'fx', 'fy', 'faz']}
cubic orbitals: ['f3', 'fax', 'fay', 'faz', 'fbx', 'fby', 'fbz']
hexagonal orbitals: ['faz', 'fs', 'fc', 'fx', 'fy', 'f3', 'fbz']
fc : key=('D6h', (3, 'B2u', -1, -1)), expression=sqrt(10)*x*(x**2 - 3*y**2)/4, <m|gamma>=[-sqrt(2)/2 0 0 0 0 0 sqrt(2)/2]
fx : key=('D6h', (3, 'E1u', -1, 0)), expression=-sqrt(6)*x*(x**2 + y**2 - 4*z**2)/4, <m|gamma>=[0 0 -sqrt(2)/2 0 sqrt(2)/2 0 0]
gc4 : key=('D6h', (4, 'E2g', 1, 0)), expression=sqrt(35)*(x**2 - 2*x*y - y**2)*(x**2 + 2*x*y - y**2)/8, <m|gamma>=[sqrt(2)/2 0 0 0 0 0 0 0 sqrt(2)/2]
tesseral tag of fc: (3, 3, 'c') , Wannier90 fxz2 -> fx
internal basis (cubic, s=3, polar): [Q_{xyz}, Q_{x}^{\alpha}, Q_{y}^{\alpha}, Q_{z}^{\alpha}, Q_{x}^{\beta}, Q_{y}^{\beta}, Q_{z}^{\beta}]
# 4. root cluster and compatibility relation.
rc = info["root_cluster"]
print("\nroot cluster:", rc["point_group"], ", scale:", rc["scale"])
print(" Oh site0 (cart):", rc["oh_site0_cart"], ", vector0 (cart):", rc["oh_vector0_cart"])
print(" D6h site0 (cart):", rc["d6h_site0_cart"], ", site0 (hex. fractional):", rc["d6h_site0_frac"])
print("compatibility Oh -> Td (first 4):", info["character"]["compatibility_relation"][("Oh", "Td")][:4])
root cluster: ['Oh', 'D6h'] , scale: 5
Oh site0 (cart): [sqrt(62)/62 5*sqrt(62)/62 3*sqrt(62)/31] , vector0 (cart): [3*sqrt(62)/31 sqrt(62)/62 5*sqrt(62)/62]
D6h site0 (cart): [2*sqrt(31)/31 sqrt(93)/31 2*sqrt(186)/31] , site0 (hex. fractional): [3*sqrt(31)/31 2*sqrt(31)/31 2*sqrt(186)/31]
compatibility Oh -> Td (first 4): [('A1g', 'A1'), ('A2g', 'A2'), ('Eg(x)', 'E(x)'), ('Eg(y)', 'E(y)')]
binary_data.py#
Binary data for MultiPie (binary_data): info.pkl and one file for each group, read with BinaryManager alone, and the look-up of the harmonics of a SAMB key in the PG file.
from multipie.util.util_binary import BinaryManager
from multipiegen.util.util_binary_data import binary_data_dir, group_file
# 1. info.pkl: information of all groups (the same as binary/info.pkl).
info = BinaryManager("info", topdir=binary_data_dir)
print("info:", list(info.keys()))
print("PG:32 ->", info["tag"]["PG:32"], ", name:", info["group_name"]["PG"]["PG:32"]["name"])
info: ['id_set', 'tag', 'id', 'group_name', 'character', 'root_cluster', 'harmonics', 'response_tensor', 'parent', 'coset', 'supergroup']
PG:32 -> Oh , name: $O_{\rm h}$ ($m\bar{3}m$)
# 2. a PG file. str() shows the description of its keys.
pg = BinaryManager("PG/PG_32", topdir=binary_data_dir)
print("\nPG/PG_32:", list(pg.keys()))
print(str(pg)[:300], "...")
PG/PG_32: ['info', 'symmetry_operation', 'wyckoff', 'character', 'representation_matrix', 'harmonics', 'multipolar_harmonics', 'atomic_samb', 'cluster_samb']
"""
* Data of a PG.
- "info" (str): (namedtuple) info.
- tag: Schoenflies in text.
- international: international short symbol in LaTeX.
- schoenflies: Schoenflies symbol in LaTeX.
- crystal: triclinic, monoclinic, orthorhombic, tetragonal, trigonal, hexagonal, cubic.
- setting: setting.
...
# 3. the SAMB hold no expression: look up the harmonics by (X, l, Gamma, n) of the key, with T -> Q and M -> G.
harmonics_type = {"Q": "Q", "G": "G", "T": "Q", "M": "G"}
def expression(harmonics, key):
ex, _ = harmonics[(harmonics_type[key.X], key.l, key.Gamma, key.n, -1, 0, 0, "q")]
return list(ex)
for key, samb in list(pg["cluster_samb"]["bond"]["3a@1o"].items())[:3]:
print(" ", key, "ex =", expression(pg["harmonics"], key), "samb =", samb.tolist())
PGMultipoleType(X='Q', l=0, Gamma='A1g', n=-1, p=-1, s=0, k=0, x='q') ex = [1] samb = [[sqrt(3)/3, sqrt(3)/3, sqrt(3)/3]]
PGMultipoleType(X='Q', l=2, Gamma='Eg', n=-1, p=-1, s=0, k=0, x='q') ex = [-x**2/2 - y**2/2 + z**2, sqrt(3)*x**2/2 - sqrt(3)*y**2/2] samb = [[sqrt(6)/6, sqrt(6)/6, -sqrt(6)/3], [-sqrt(2)/2, sqrt(2)/2, 0]]
PGMultipoleType(X='T', l=1, Gamma='T1u', n=-1, p=1, s=0, k=0, x='q') ex = [x, y, z] samb = [[I, 0, 0], [0, I, 0], [0, 0, I]]
# 4. an SG file: its harmonics are those of its PG (info.PG).
sg = BinaryManager("SG/SG_221", topdir=binary_data_dir)
pg_of_sg = BinaryManager(group_file(sg["info"].PG), topdir=binary_data_dir)
print("\nSG/SG_221:", list(sg.keys()), ", PG:", sg["info"].PG)
w = list(sg["cluster_samb"]["site"].keys())[1]
for key, samb in list(sg["cluster_samb"]["site"][w].items())[:2]:
print(" ", w, key, "ex =", expression(pg_of_sg["harmonics"], key))
SG/SG_221: ['info', 'symmetry_operation', 'wyckoff', 'cluster_samb'] , PG: PG:32
1b PGMultipoleType(X='Q', l=0, Gamma='A1g', n=-1, p=-1, s=0, k=0, x='q') ex = [1]
# 5. an MPG file: active multipoles and response tensors.
mpg = BinaryManager("MPG/MPG_15.6.58", topdir=binary_data_dir)
print("\nMPG/MPG_15.6.58:", mpg["info"].international, list(mpg.keys()))
matrix, ex = mpg["response_tensor"][("T", 2, "a")]
print(" (T, 2, a):", matrix.tolist(), ex)
MPG/MPG_15.6.58: 4/mm'm' ['info', 'symmetry_operation', 'wyckoff', 'active_multipole', 'response_tensor']
(T, 2, a): [[0, T_{xy}, 0], [-T_{xy}, 0, 0], [0, 0, 0]] {T_{xy}: \mathbb{M}_{z}^{(1)}}
coset.py#
Cosets of a group in its parents (coset.pkl): the first coset in the direct parent (representative, order, rotation or inversion), the images of the sites, bonds, and cluster SAMB under the inversion (eps or U), the parent structures, and the cosets of all parents.
from multipiegen.util.util_coset import load_coset
from multipiegen.util.util_info import load_info
info = load_info()
coset = load_coset()
def show(gid):
d = coset[gid]
f = d["first"]
print(f"{gid} ({info['tag'][gid] if gid.startswith('PG') else gid}): parents {d['parent']}")
print(f" direct parent {f['parent']}, index {f['index']}, representative g = {f['rep']}, order {f['order']}, {f['kind']}")
print(f" g in the coordinates of H: {f['rep_matrix'].tolist()}")
if f["kind"] == "rotation":
print(f" frame of the image system: {f['frame'].tolist()}")
else:
inv = f["inversion"]
print(f" image {inv['image']}, map {inv['map'].tolist()}")
for kind in ["site", "bond"]:
for w, t in list(inv[kind].items())[:3]:
if t["diag"]:
eps = {f"{k.X}{k.l}({k.Gamma})": e for k, e in t["eps"].items()}
print(f" {kind} {w} -> {t['image'][1]}, perm {t['perm']}, eps {eps}")
else:
print(f" {kind} {w} -> {t['image'][1]}, U in blocks {list(t['U'])}")
for w, lims in f["parent_limit"].items():
print(f" parent structure of {w}: " + ", ".join(f"{l['param']} -> {l['parent_wyckoff']}" for l in lims))
for p, cos in d["coset"].items():
print(f" {len(cos)} cosets in {p}, first: {cos[0][:4]} ...")
print()
# Te (P3_121, No.152): the inversion coset of P-3m1 maps it onto P3_221 (No.154).
show("SG:152")
# D2h in D4h: g = 4+[001] (rotation); the image system is written in the frame rotated by g.
show(info["id"]["D2h"])
# SG 210 (F4_132): Wyckoff positions mapped onto themselves with the transport matrix U (first non-diagonal block).
import numpy as np
inv = coset["SG:210"]["first"]["inversion"]
for kind in ["site", "bond"]:
for w, t in inv[kind].items():
if t["diag"]:
continue
for blk, (rows, rows2, U) in t["U"].items():
if not np.allclose(np.abs(np.array(U, dtype=complex)), np.eye(len(rows))):
print(f"SG:210 {kind} {w} -> {t['image'][1]}, block {blk}, {len(rows)} rows: U =\n{U}")
break
break
SG:152 (SG:152): parents ['SG:164', 'SG:191']
direct parent SG:164, index 2, representative g = -1:[0,0,0], order 2, inversion
g in the coordinates of H: [[-1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]]
image SG:154, map [[-1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]]
site 3a -> 3a, perm [0, 1, 2], eps {'Q0(A1)': [1], 'Q1(E)': [1, 1]}
site 3b -> 3b, perm [0, 1, 2], eps {'Q0(A1)': [1], 'Q1(E)': [1, 1]}
site 6c -> 6c, perm [0, 1, 2, 3, 4, 5], eps {'Q0(A1)': [1], 'Q1(A2)': [1], 'Q1(E)': [1, 1], 'Q2(E)': [1, 1]}
bond 3a@3a -> 3a@3a, perm [0, 1, 2], eps {'Q0(A1)': [1], 'T1(A2)': [1], 'Q1(E)': [1, 1], 'T1(E)': [1, 1]}
bond 3b@3a -> 3b@3a, perm [0, 1, 2], eps {'Q0(A1)': [1], 'T0(A1)': [1], 'Q1(E)': [1, 1], 'T1(E)': [1, 1]}
bond 6c@3a -> 6c@3a, perm [0, 1, 2, 3, 4, 5], eps {'Q0(A1)': [1], 'T0(A1)': [1], 'Q1(A2)': [1], 'T1(A2)': [1], 'Q1(E)': [1, 1], 'Q2(E)': [1, 1], 'T1(E)': [1, 1], 'M1(E)': [1, 1]}
parent structure of 3a: {'x': '0'} -> 1a
parent structure of 3b: {'x': '0'} -> 1b
parent structure of 6c: {'x': '0', 'y': '0', 'z': 'z'} -> 2c, {'x': '1/3', 'y': '2/3', 'z': 'z'} -> 2d
3 cosets in SG:164, first: ['-1:[0,0,0]', '-3+[001]:[0,0,2/3]', '-3-[001]:[0,0,1/3]', 'm[110]:[0,0,0]'] ...
9 cosets in SG:191, first: ['2[001]:[0,0,0]', '6-[001]:[0,0,1/3]', '6+[001]:[0,0,2/3]', '2[1-10]:[0,0,0]'] ...
PG:8 (D2h): parents ['PG:15', 'PG:32']
direct parent PG:15, index 2, representative g = 4+[001], order 2, rotation
g in the coordinates of H: [[0, -1, 0], [1, 0, 0], [0, 0, 1]]
frame of the image system: [[0, -1, 0], [1, 0, 0], [0, 0, 1]]
parent structure of 4f: {'x': 'x', 'y': 'x'} -> 4b, {'x': 'x', 'y': '-x'} -> 4b
parent structure of 8g: {'x': 'x', 'y': '-x', 'z': 'z'} -> 8e, {'x': 'x', 'y': 'x', 'z': 'z'} -> 8e
1 cosets in PG:15, first: ['4+[001]', '4-[001]', '2[1-10]', '2[110]'] ...
5 cosets in PG:32, first: ['3+[111]', '3+[-11-1]', '3+[1-1-1]', '3+[-1-11]'] ...
SG:210 site 48f -> 48f, block E, 4 rows: U =
[[0.811134235171696 0 -0.5848600281541111 0]
[0 0.8111342351716962 0 -0.5848600281541111]
[-0.5848600281541111 0 -0.8111342351716962 0]
[0 -0.5848600281541111 0 -0.811134235171696]]
SG:210 bond 24a@8a -> 24a@8a, block E, 4 rows: U =
[[0.8111342351716961 0 -0.584860028154111 0]
[0 0.811134235171696 0 -0.584860028154111]
[-0.584860028154111 0 -0.811134235171696 0]
[0 -0.584860028154111 0 -0.8111342351716961]]
supergroup.py#
Direct (maximal) supergroups of a group with the embeddings x_P = A x_H (supergroup.pkl): t- and k-subgroups, the indices, and the chains of them up to the representative parents.
from multipiegen.util.util_supergroup import load_supergroup
data = load_supergroup()
def show(gid):
print(f"{gid}: {len(data[gid])} direct supergroups")
for d in data[gid]:
kind = "t" if d["index"] == d["index_parent"] else ("k" if d["index_parent"] == 1 else "t+k")
print(
f" {d['parent']:7s} index {d['index']} (modulo the lattice of P: {d['index_parent']}, {kind}), A = {d['A'].tolist()}"
)
# P3_121 (Te, No.152): R-3m (No.166) is not a direct supergroup, but a direct supergroup of R32 (No.155).
show("SG:152")
show("SG:155")
SG:152: 6 direct supergroups
SG:154 index 2 (modulo the lattice of P: 1, k), A = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 2, 0], [0, 0, 0, 1]]
SG:178 index 2 (modulo the lattice of P: 2, t), A = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1/6], [0, 0, 0, 1]]
SG:181 index 2 (modulo the lattice of P: 2, t), A = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1/6], [0, 0, 0, 1]]
SG:150 index 3 (modulo the lattice of P: 1, k), A = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 3, 0], [0, 0, 0, 1]]
SG:151 index 3 (modulo the lattice of P: 1, k), A = [[2, -1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1/6], [0, 0, 0, 1]]
SG:155 index 3 (modulo the lattice of P: 1, k), A = [[1, 0, 0, 0], [0, 1, 0, -1/3], [0, 0, 1, 1/3], [0, 0, 0, 1]]
SG:155: 11 direct supergroups
SG:166 index 2 (modulo the lattice of P: 2, t), A = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
SG:167 index 2 (modulo the lattice of P: 2, t), A = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 1/4], [0, 0, 0, 1]]
SG:149 index 3 (modulo the lattice of P: 1, k), A = [[2, -1, 0, 0], [1, 1, 0, 0], [0, 0, 3, 0], [0, 0, 0, 1]]
SG:207 index 4 (modulo the lattice of P: 4, t), A = [[1, 0, 1, 0], [-1, 1, 1, 0], [0, -1, 1, 0], [0, 0, 0, 1]]
SG:208 index 4 (modulo the lattice of P: 4, t), A = [[1, 0, 1, 1/4], [-1, 1, 1, 1/4], [0, -1, 1, 1/4], [0, 0, 0, 1]]
SG:209 index 4 (modulo the lattice of P: 4, t), A = [[1/2, -1/2, 1, 0], [0, 1/2, 1, 0], [-1/2, 0, 1, 0], [0, 0, 0, 1]]
SG:210 index 4 (modulo the lattice of P: 4, t), A = [[1/2, -1/2, 1, 1/8], [0, 1/2, 1, 1/8], [-1/2, 0, 1, 1/8], [0, 0, 0, 1]]
SG:211 index 4 (modulo the lattice of P: 4, t), A = [[1, -1, 1/2, 0], [0, 1, 1/2, 0], [-1, 0, 1/2, 0], [0, 0, 0, 1]]
SG:212 index 4 (modulo the lattice of P: 4, t), A = [[1, 0, 1, 1/8], [-1, 1, 1, 1/8], [0, -1, 1, 1/8], [0, 0, 0, 1]]
SG:213 index 4 (modulo the lattice of P: 4, t), A = [[1, -1, -1, 1/8], [0, 1, -1, 5/8], [1, 0, 1, 7/8], [0, 0, 0, 1]]
SG:214 index 4 (modulo the lattice of P: 4, t), A = [[1, -1, 1/2, 1/8], [0, 1, 1/2, 1/8], [-1, 0, 1/2, 1/8], [0, 0, 0, 1]]
# the chain of direct supergroups from SG 152 to SG 166, and to the representative parent P-3m1 (No.164).
def chains(h, p, path=None):
path = [h] if path is None else path
if h == p:
yield path
return
for d in data[h]:
if d["parent"] not in path:
yield from chains(d["parent"], p, path + [d["parent"]])
for p in ["SG:166", "SG:164"]:
print(p, "<-", min(chains("SG:152", p), key=len))
SG:166 <- ['SG:152', 'SG:155', 'SG:166']
SG:164 <- ['SG:152', 'SG:150', 'SG:164']
# point groups: D2h in D4h (4-fold axis along z) and in Th; no supergroup for the top groups.
show("PG:8")
print([g for g, v in data.items() if not v])
PG:8: 2 direct supergroups
PG:15 index 2 (modulo the lattice of P: 2, t), A = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
PG:29 index 3 (modulo the lattice of P: 3, t), A = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
['PG:27', 'PG:32', 'SG:191']