phono3py/test/phonon3/test_triplets.py

1819 lines
40 KiB
Python

"""Test for triplets.py."""
import numpy as np
import pytest
from phonopy import Phonopy
from phonopy.structure.atoms import PhonopyAtoms
from phonopy.structure.symmetry import Symmetry
from phono3py import Phono3py
from phono3py.phonon.grid import BZGrid, get_grid_point_from_address
from phono3py.phonon3.triplets import (
_get_BZ_triplets_at_q,
_get_triplets_reciprocal_mesh_at_q,
get_triplets_at_q,
)
def test_get_triplets_at_q_type1(si_pbesol_111):
"""Test triplets under type1 grid."""
pcell = si_pbesol_111.primitive
psym = si_pbesol_111.primitive_symmetry
grid_point = 1
mesh = [4, 4, 4]
bz_grid = BZGrid(
mesh,
lattice=pcell.cell,
symmetry_dataset=psym.dataset,
store_dense_gp_map=False,
)
triplets, weights = get_triplets_at_q(grid_point, bz_grid)[:2]
triplets_ref = [
1,
0,
3,
1,
1,
2,
1,
4,
15,
1,
5,
14,
1,
6,
13,
1,
7,
12,
1,
65,
11,
1,
9,
10,
1,
24,
59,
1,
26,
88,
]
weights_ref = [2, 2, 6, 6, 6, 6, 6, 6, 12, 12]
# print("".join(["%d, " % i for i in triplets.ravel()]))
# print("".join(["%d, " % i for i in weights]))
_show_triplets_info(mesh, bz_grid, triplets, np.linalg.inv(pcell.cell))
np.testing.assert_equal(triplets.ravel(), triplets_ref)
np.testing.assert_equal(weights, weights_ref)
def test_get_triplets_at_q_type2(si_pbesol_111: Phono3py):
"""Test triplets under type2 grid."""
pcell = si_pbesol_111.primitive
psym = si_pbesol_111.primitive_symmetry
grid_point = 1
mesh = [4, 4, 4]
bz_grid = BZGrid(
mesh, lattice=pcell.cell, symmetry_dataset=psym.dataset, store_dense_gp_map=True
)
triplets, weights = get_triplets_at_q(grid_point, bz_grid)[:2]
triplets_ref = [
1,
0,
4,
1,
1,
2,
1,
5,
18,
1,
6,
17,
1,
7,
16,
1,
8,
15,
1,
10,
14,
1,
11,
12,
1,
27,
84,
1,
29,
82,
]
weights_ref = [2, 2, 6, 6, 6, 6, 6, 6, 12, 12]
_show_triplets_info(mesh, bz_grid, triplets, np.linalg.inv(pcell.cell))
# print("".join(["%d, " % i for i in triplets.ravel()]))
# print("".join(["%d, " % i for i in weights]))
np.testing.assert_equal(triplets.ravel(), triplets_ref)
np.testing.assert_equal(weights, weights_ref)
def _show_triplets_info(
mesh: list, bz_grid: BZGrid, triplets: np.ndarray, reclat: np.ndarray
) -> None:
"""Show triplets details in grid type-1 and 2."""
shift = np.prod(mesh)
double_shift = np.prod(mesh) * 8
for i in np.arange(np.prod(mesh)):
adrs = []
if bz_grid.store_dense_gp_map:
bzgp = bz_grid.gp_map[i]
multi = bz_grid.gp_map[i + 1] - bz_grid.gp_map[i]
for j in range(multi):
adrs.append(bz_grid.addresses[bzgp + j].tolist())
else:
bzgp = i
multi = (
bz_grid.gp_map[double_shift + i + 1]
- bz_grid.gp_map[double_shift + i]
+ 1
)
adrs.append(bz_grid.addresses[bzgp].tolist())
for j in range(multi - 1):
adrs.append(
bz_grid.addresses[
shift + bz_grid.gp_map[double_shift + i] + j
].tolist()
)
print(bzgp, adrs, multi)
for tp in triplets:
multis = []
for tp_adrs in bz_grid.addresses[tp]:
gp = get_grid_point_from_address(tp_adrs, mesh)
if bz_grid.store_dense_gp_map:
multis.append(bz_grid.gp_map[gp + 1] - bz_grid.gp_map[gp])
else:
shift = np.prod(mesh) * 8
multis.append(
bz_grid.gp_map[shift + gp + 1] - bz_grid.gp_map[shift + gp] + 1
)
bztp = bz_grid.addresses[tp]
gadrs = bz_grid.addresses[tp].sum(axis=0) / mesh
d = np.sqrt(np.linalg.norm(np.dot(reclat, gadrs)))
print(tp, "[", bztp[0], bztp[1], bztp[2], "]", multis, bztp.sum(axis=0), d)
@pytest.mark.parametrize(
"params",
[(True, True, 0), (False, True, 1), (True, False, 2), (False, False, 3)],
)
def test_get_triplets_reciprocal_mesh_at_q(aln_cell: PhonopyAtoms, params):
"""Test _get_triplets_reciprocal_mesh_at_q using AlN."""
symmetry = Symmetry(aln_cell)
grid_point = 1
D_diag = [3, 3, 4]
ref_map_triplets = [
[
0,
1,
0,
3,
3,
5,
5,
3,
3,
9,
10,
9,
12,
12,
14,
14,
12,
12,
18,
19,
18,
21,
21,
23,
23,
21,
21,
9,
10,
9,
12,
12,
14,
14,
12,
12,
],
[
0,
1,
2,
3,
4,
5,
5,
3,
4,
9,
10,
11,
12,
13,
14,
14,
12,
13,
18,
19,
20,
21,
22,
23,
23,
21,
22,
9,
10,
11,
12,
13,
14,
14,
12,
13,
],
[
0,
1,
0,
3,
3,
5,
5,
3,
3,
9,
10,
11,
12,
13,
14,
14,
12,
13,
18,
19,
18,
21,
21,
23,
23,
21,
21,
11,
10,
9,
13,
12,
14,
14,
13,
12,
],
[
0,
1,
2,
3,
4,
5,
5,
3,
4,
9,
10,
11,
12,
13,
14,
14,
12,
13,
18,
19,
20,
21,
22,
23,
23,
21,
22,
27,
28,
29,
30,
31,
32,
32,
30,
31,
],
]
ref_map_q = [
[
0,
1,
2,
3,
4,
5,
5,
3,
4,
9,
10,
11,
12,
13,
14,
14,
12,
13,
18,
19,
20,
21,
22,
23,
23,
21,
22,
9,
10,
11,
12,
13,
14,
14,
12,
13,
],
[
0,
1,
2,
3,
4,
5,
5,
3,
4,
9,
10,
11,
12,
13,
14,
14,
12,
13,
18,
19,
20,
21,
22,
23,
23,
21,
22,
9,
10,
11,
12,
13,
14,
14,
12,
13,
],
[
0,
1,
2,
3,
4,
5,
5,
3,
4,
9,
10,
11,
12,
13,
14,
14,
12,
13,
18,
19,
20,
21,
22,
23,
23,
21,
22,
27,
28,
29,
30,
31,
32,
32,
30,
31,
],
[
0,
1,
2,
3,
4,
5,
5,
3,
4,
9,
10,
11,
12,
13,
14,
14,
12,
13,
18,
19,
20,
21,
22,
23,
23,
21,
22,
27,
28,
29,
30,
31,
32,
32,
30,
31,
],
]
rec_rotations = [r.T for r in symmetry.pointgroup_operations]
map_triplets, map_q = _get_triplets_reciprocal_mesh_at_q(
grid_point,
D_diag,
rec_rotations,
is_time_reversal=params[1],
swappable=params[0],
)
# print(",".join(["%d" % x for x in map_triplets]))
# print(",".join(["%d" % x for x in map_q]))
# print(len(np.unique(map_triplets)))
np.testing.assert_equal(ref_map_triplets[params[2]], map_triplets)
np.testing.assert_equal(ref_map_q[params[2]], map_q)
@pytest.mark.parametrize(
"params",
[(True, True, 0), (False, True, 1), (True, False, 2), (False, False, 3)],
)
def test_get_triplets_reciprocal_mesh_at_q_agno2(agno2_cell: PhonopyAtoms, params):
"""Test BZGrid with shift using AgNO2."""
ref_map_triplets = [
[
0,
0,
2,
2,
4,
4,
6,
6,
8,
8,
10,
10,
12,
12,
6,
6,
16,
16,
2,
2,
12,
12,
6,
6,
8,
8,
10,
10,
4,
4,
6,
6,
],
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
6,
7,
16,
17,
2,
3,
12,
13,
6,
7,
8,
9,
10,
11,
4,
5,
6,
7,
],
[
0,
0,
2,
2,
4,
5,
6,
7,
8,
9,
10,
10,
12,
13,
7,
6,
16,
16,
2,
2,
13,
12,
6,
7,
9,
8,
10,
10,
5,
4,
7,
6,
],
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
2,
3,
20,
21,
6,
7,
24,
25,
10,
11,
28,
29,
14,
15,
],
]
ref_map_q = [
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
6,
7,
16,
17,
2,
3,
12,
13,
6,
7,
8,
9,
10,
11,
4,
5,
6,
7,
],
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
6,
7,
16,
17,
2,
3,
12,
13,
6,
7,
8,
9,
10,
11,
4,
5,
6,
7,
],
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
2,
3,
20,
21,
6,
7,
24,
25,
10,
11,
28,
29,
14,
15,
],
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
2,
3,
20,
21,
6,
7,
24,
25,
10,
11,
28,
29,
14,
15,
],
]
grid_point = 1
mesh = 12
ph = Phonopy(agno2_cell, supercell_matrix=[1, 1, 1], primitive_matrix="auto")
bzgrid = BZGrid(
mesh,
lattice=ph.primitive.cell,
symmetry_dataset=ph.primitive_symmetry.dataset,
use_grg=True,
is_time_reversal=False,
)
np.testing.assert_equal([2, 2, 8], bzgrid.D_diag)
np.testing.assert_equal([[0, 0, 1], [1, 0, -1], [0, 1, -1]], bzgrid.Q)
map_triplets, map_q = _get_triplets_reciprocal_mesh_at_q(
grid_point,
bzgrid.D_diag,
bzgrid.rotations,
is_time_reversal=params[1],
swappable=params[0],
)
# print(",".join(["%d" % x for x in map_triplets]))
# print(",".join(["%d" % x for x in map_q]))
np.testing.assert_equal(ref_map_triplets[params[2]], map_triplets)
np.testing.assert_equal(ref_map_q[params[2]], map_q)
@pytest.mark.parametrize(
"params",
[ # force_SNF, swappable, is_time_reversal
(True, True, True, 0),
(True, True, False, 1),
(True, False, True, 2),
(True, False, False, 3),
(False, True, True, 4),
(False, True, False, 5),
(False, False, True, 6),
(False, False, False, 7),
],
)
def test_get_triplets_reciprocal_mesh_at_q_wurtzite_force(
aln_cell: PhonopyAtoms, params
):
"""Test _get_triplets_reciprocal_mesh_at_q using wurtzite.
The lattices generated with and without force_SNF are the same.
Therefore numbers of unique triplets should agree, which is this test.
"""
grid_point = 1
mesh = 14
ph = Phonopy(aln_cell, supercell_matrix=[1, 1, 1], primitive_matrix="auto")
bzgrid = BZGrid(
mesh,
lattice=ph.primitive.cell,
symmetry_dataset=ph.primitive_symmetry.dataset,
use_grg=True,
force_SNF=params[0],
is_time_reversal=False,
)
# for r in bzgrid.rotations:
# print("{")
# for v in r:
# print("{%d, %d, %d}," % tuple(v))
# print("},")
ref_unique_elems = [[18, 30], [24, 45], [30, 30], [45, 45]]
if params[0]:
np.testing.assert_equal([1, 5, 15], bzgrid.D_diag)
np.testing.assert_equal([[-1, 0, -6], [0, -1, 0], [-1, 0, -5]], bzgrid.Q)
else:
np.testing.assert_equal([5, 5, 3], bzgrid.D_diag)
np.testing.assert_equal(np.eye(3, dtype=int), bzgrid.Q)
map_triplets, map_q = _get_triplets_reciprocal_mesh_at_q(
grid_point,
bzgrid.D_diag,
bzgrid.rotations,
is_time_reversal=params[2],
swappable=params[1],
)
# "% 4" means that expectation of the same values with and without force_SNF.
np.testing.assert_equal(
ref_unique_elems[params[3] % 4],
[len(np.unique(map_triplets)), len(np.unique(map_q))],
)
@pytest.mark.parametrize(
"params",
[ # force_SNF, swappable, is_time_reversal
(True, True, True, 0),
(True, True, False, 1),
(True, False, True, 2),
(True, False, False, 3),
(False, True, True, 4),
(False, True, False, 5),
(False, False, True, 6),
(False, False, False, 7),
],
)
def test_get_BZ_triplets_at_q(aln_cell: PhonopyAtoms, params):
"""Test _get_BZ_triplets_at_q."""
ref_triplets = [
[
[
[1, 0, 4],
[1, 1, 3],
[1, 2, 2],
[1, 5, 91],
[1, 7, 90],
[1, 10, 87],
[1, 12, 85],
[1, 13, 84],
[1, 14, 83],
[1, 18, 79],
[1, 19, 77],
[1, 23, 74],
[1, 31, 66],
[1, 32, 65],
[1, 33, 64],
[1, 36, 60],
[1, 38, 59],
[1, 41, 56],
],
[
[1, 0, 4],
[1, 1, 3],
[1, 2, 2],
[1, 5, 91],
[1, 7, 90],
[1, 8, 88],
[1, 10, 87],
[1, 11, 86],
[1, 12, 85],
[1, 13, 84],
[1, 14, 83],
[1, 15, 81],
[1, 17, 80],
[1, 18, 79],
[1, 19, 77],
[1, 23, 74],
[1, 31, 66],
[1, 32, 65],
[1, 33, 64],
[1, 34, 63],
[1, 35, 62],
[1, 36, 60],
[1, 38, 59],
[1, 41, 56],
],
[
[1, 0, 4],
[1, 1, 3],
[1, 2, 2],
[1, 3, 1],
[1, 4, 0],
[1, 5, 91],
[1, 7, 90],
[1, 8, 88],
[1, 10, 87],
[1, 11, 86],
[1, 12, 85],
[1, 13, 84],
[1, 14, 83],
[1, 15, 81],
[1, 17, 80],
[1, 18, 79],
[1, 19, 77],
[1, 21, 76],
[1, 22, 75],
[1, 23, 74],
[1, 31, 66],
[1, 32, 65],
[1, 33, 64],
[1, 34, 63],
[1, 35, 62],
[1, 36, 60],
[1, 38, 59],
[1, 39, 57],
[1, 41, 56],
[1, 42, 55],
],
[
[1, 0, 4],
[1, 1, 3],
[1, 2, 2],
[1, 3, 1],
[1, 4, 0],
[1, 5, 91],
[1, 7, 90],
[1, 8, 88],
[1, 10, 87],
[1, 11, 86],
[1, 12, 85],
[1, 13, 84],
[1, 14, 83],
[1, 15, 81],
[1, 17, 80],
[1, 18, 79],
[1, 19, 77],
[1, 21, 76],
[1, 22, 75],
[1, 23, 74],
[1, 31, 66],
[1, 32, 65],
[1, 33, 64],
[1, 34, 63],
[1, 35, 62],
[1, 36, 60],
[1, 38, 59],
[1, 39, 57],
[1, 41, 56],
[1, 42, 55],
[1, 43, 54],
[1, 44, 53],
[1, 45, 52],
[1, 46, 50],
[1, 48, 49],
[1, 62, 35],
[1, 63, 34],
[1, 64, 33],
[1, 65, 32],
[1, 66, 31],
[1, 67, 29],
[1, 69, 28],
[1, 70, 26],
[1, 72, 25],
[1, 73, 24],
],
[
[1, 0, 4],
[1, 1, 3],
[1, 2, 2],
[1, 5, 30],
[1, 6, 28],
[1, 10, 25],
[1, 11, 23],
[1, 13, 21],
[1, 16, 19],
[1, 31, 66],
[1, 32, 65],
[1, 33, 64],
[1, 36, 92],
[1, 37, 90],
[1, 41, 87],
[1, 42, 85],
[1, 44, 83],
[1, 47, 81],
],
[
[1, 0, 4],
[1, 1, 3],
[1, 2, 2],
[1, 5, 30],
[1, 6, 28],
[1, 10, 25],
[1, 11, 23],
[1, 13, 21],
[1, 16, 19],
[1, 31, 66],
[1, 32, 65],
[1, 33, 64],
[1, 34, 63],
[1, 35, 62],
[1, 36, 92],
[1, 37, 90],
[1, 39, 89],
[1, 40, 88],
[1, 41, 87],
[1, 42, 85],
[1, 44, 83],
[1, 46, 82],
[1, 47, 81],
[1, 48, 80],
],
[
[1, 0, 4],
[1, 1, 3],
[1, 2, 2],
[1, 3, 1],
[1, 4, 0],
[1, 5, 30],
[1, 6, 28],
[1, 8, 27],
[1, 9, 26],
[1, 10, 25],
[1, 11, 23],
[1, 13, 21],
[1, 15, 20],
[1, 16, 19],
[1, 17, 18],
[1, 31, 66],
[1, 32, 65],
[1, 33, 64],
[1, 34, 63],
[1, 35, 62],
[1, 36, 92],
[1, 37, 90],
[1, 39, 89],
[1, 40, 88],
[1, 41, 87],
[1, 42, 85],
[1, 44, 83],
[1, 46, 82],
[1, 47, 81],
[1, 48, 80],
],
[
[1, 0, 4],
[1, 1, 3],
[1, 2, 2],
[1, 3, 1],
[1, 4, 0],
[1, 5, 30],
[1, 6, 28],
[1, 8, 27],
[1, 9, 26],
[1, 10, 25],
[1, 11, 23],
[1, 13, 21],
[1, 15, 20],
[1, 16, 19],
[1, 17, 18],
[1, 31, 66],
[1, 32, 65],
[1, 33, 64],
[1, 34, 63],
[1, 35, 62],
[1, 36, 92],
[1, 37, 90],
[1, 39, 89],
[1, 40, 88],
[1, 41, 87],
[1, 42, 85],
[1, 44, 83],
[1, 46, 82],
[1, 47, 81],
[1, 48, 80],
[1, 62, 35],
[1, 63, 34],
[1, 64, 33],
[1, 65, 32],
[1, 66, 31],
[1, 67, 61],
[1, 68, 59],
[1, 70, 58],
[1, 71, 57],
[1, 72, 56],
[1, 73, 54],
[1, 75, 52],
[1, 77, 51],
[1, 78, 50],
[1, 79, 49],
],
],
[
[
[8, 0, 89],
[8, 1, 88],
[8, 2, 87],
[8, 3, 86],
[9, 4, 92],
[8, 5, 84],
[8, 6, 82],
[8, 8, 81],
[8, 10, 80],
[8, 11, 85],
[8, 12, 78],
[8, 13, 76],
[8, 14, 75],
[8, 17, 79],
[8, 19, 71],
[8, 20, 69],
[9, 22, 67],
[8, 24, 65],
[8, 27, 62],
[8, 29, 66],
[8, 31, 58],
[8, 32, 57],
[8, 40, 50],
[8, 48, 48],
],
[
[8, 0, 89],
[8, 1, 88],
[8, 2, 87],
[8, 3, 86],
[9, 4, 92],
[8, 5, 84],
[8, 6, 82],
[8, 8, 81],
[8, 10, 80],
[8, 11, 85],
[8, 12, 78],
[8, 13, 76],
[8, 14, 75],
[8, 17, 79],
[8, 19, 71],
[8, 20, 69],
[9, 22, 67],
[8, 24, 65],
[8, 27, 62],
[8, 29, 66],
[8, 31, 58],
[8, 32, 57],
[8, 40, 50],
[8, 48, 48],
],
[
[8, 0, 89],
[8, 1, 88],
[8, 2, 87],
[8, 3, 86],
[9, 4, 92],
[8, 5, 84],
[8, 6, 82],
[8, 8, 81],
[8, 10, 80],
[8, 11, 85],
[8, 12, 78],
[8, 13, 76],
[8, 14, 75],
[8, 16, 74],
[8, 17, 79],
[8, 19, 71],
[8, 20, 69],
[9, 22, 67],
[9, 23, 73],
[8, 24, 65],
[8, 25, 64],
[8, 27, 62],
[8, 29, 66],
[8, 31, 58],
[8, 32, 57],
[8, 33, 56],
[8, 34, 55],
[8, 40, 50],
[9, 41, 49],
[9, 42, 54],
[8, 43, 46],
[8, 44, 45],
[8, 48, 48],
[8, 50, 40],
[8, 51, 38],
[9, 53, 36],
[8, 58, 31],
[9, 61, 35],
[8, 62, 27],
[8, 63, 26],
[8, 71, 19],
[9, 72, 18],
[8, 79, 17],
[8, 81, 8],
[8, 89, 0],
],
[
[8, 0, 89],
[8, 1, 88],
[8, 2, 87],
[8, 3, 86],
[9, 4, 92],
[8, 5, 84],
[8, 6, 82],
[8, 8, 81],
[8, 10, 80],
[8, 11, 85],
[8, 12, 78],
[8, 13, 76],
[8, 14, 75],
[8, 16, 74],
[8, 17, 79],
[8, 19, 71],
[8, 20, 69],
[9, 22, 67],
[9, 23, 73],
[8, 24, 65],
[8, 25, 64],
[8, 27, 62],
[8, 29, 66],
[8, 31, 58],
[8, 32, 57],
[8, 33, 56],
[8, 34, 55],
[8, 40, 50],
[9, 41, 49],
[9, 42, 54],
[8, 43, 46],
[8, 44, 45],
[8, 48, 48],
[8, 50, 40],
[8, 51, 38],
[9, 53, 36],
[8, 58, 31],
[9, 61, 35],
[8, 62, 27],
[8, 63, 26],
[8, 71, 19],
[9, 72, 18],
[8, 79, 17],
[8, 81, 8],
[8, 89, 0],
],
[
[7, 0, 28],
[8, 1, 27],
[8, 2, 26],
[8, 5, 22],
[8, 6, 20],
[7, 8, 19],
[7, 11, 16],
[7, 13, 15],
[7, 17, 17],
[7, 31, 90],
[8, 32, 89],
[8, 33, 88],
[8, 36, 84],
[8, 37, 82],
[7, 39, 81],
[7, 42, 78],
[7, 44, 77],
[7, 48, 79],
],
[
[7, 0, 28],
[8, 1, 27],
[8, 2, 26],
[8, 5, 22],
[8, 6, 20],
[7, 8, 19],
[7, 11, 16],
[7, 13, 15],
[7, 17, 17],
[7, 31, 90],
[8, 32, 89],
[8, 33, 88],
[8, 36, 84],
[8, 37, 82],
[7, 39, 81],
[7, 42, 78],
[7, 44, 77],
[7, 48, 79],
[7, 49, 71],
[7, 50, 70],
[8, 53, 67],
[7, 56, 65],
[8, 58, 63],
[7, 59, 62],
],
[
[7, 0, 28],
[8, 1, 27],
[8, 2, 26],
[8, 5, 22],
[8, 6, 20],
[7, 8, 19],
[7, 11, 16],
[7, 13, 15],
[7, 17, 17],
[7, 18, 9],
[7, 19, 8],
[8, 22, 5],
[7, 25, 3],
[8, 27, 1],
[7, 28, 0],
[7, 31, 90],
[8, 32, 89],
[8, 33, 88],
[8, 36, 84],
[8, 37, 82],
[7, 39, 81],
[7, 42, 78],
[7, 44, 77],
[7, 48, 79],
[7, 49, 71],
[7, 50, 70],
[8, 53, 67],
[7, 56, 65],
[8, 58, 63],
[7, 59, 62],
],
[
[7, 0, 28],
[8, 1, 27],
[8, 2, 26],
[8, 5, 22],
[8, 6, 20],
[7, 8, 19],
[7, 11, 16],
[7, 13, 15],
[7, 17, 17],
[7, 18, 9],
[7, 19, 8],
[8, 22, 5],
[7, 25, 3],
[8, 27, 1],
[7, 28, 0],
[7, 31, 90],
[8, 32, 89],
[8, 33, 88],
[8, 36, 84],
[8, 37, 82],
[7, 39, 81],
[7, 42, 78],
[7, 44, 77],
[7, 48, 79],
[7, 49, 71],
[7, 50, 70],
[8, 53, 67],
[7, 56, 65],
[8, 58, 63],
[7, 59, 62],
[7, 62, 59],
[8, 63, 58],
[8, 64, 57],
[8, 67, 53],
[8, 68, 51],
[7, 70, 50],
[7, 73, 47],
[7, 75, 46],
[7, 79, 48],
[7, 80, 40],
[7, 81, 39],
[8, 84, 36],
[7, 87, 34],
[8, 89, 32],
[7, 90, 31],
],
],
]
ref_ir_weights = [
[
[2, 2, 1, 8, 4, 8, 4, 8, 8, 4, 4, 2, 4, 4, 2, 4, 2, 4],
[2, 2, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 4, 2, 4],
[
1,
1,
1,
1,
1,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
],
[
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
],
[2, 2, 1, 4, 4, 2, 4, 2, 4, 4, 4, 2, 8, 8, 4, 8, 4, 8],
[2, 2, 1, 4, 4, 2, 4, 2, 4, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
[
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
],
[
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
],
],
[
[2, 4, 4, 4, 4, 4, 2, 2, 4, 4, 4, 4, 4, 2, 2, 4, 4, 2, 2, 4, 2, 4, 2, 1],
[2, 4, 4, 4, 4, 4, 2, 2, 4, 4, 4, 4, 4, 2, 2, 4, 4, 2, 2, 4, 2, 4, 2, 1],
[
1,
2,
2,
2,
2,
2,
2,
1,
2,
2,
2,
2,
2,
2,
1,
1,
2,
2,
2,
2,
2,
1,
2,
1,
2,
2,
2,
1,
2,
2,
2,
2,
1,
1,
2,
2,
1,
2,
1,
2,
1,
2,
1,
1,
1,
],
[
1,
2,
2,
2,
2,
2,
2,
1,
2,
2,
2,
2,
2,
2,
1,
1,
2,
2,
2,
2,
2,
1,
2,
1,
2,
2,
2,
1,
2,
2,
2,
2,
1,
1,
2,
2,
1,
2,
1,
2,
1,
2,
1,
1,
1,
],
[2, 4, 4, 4, 4, 2, 2, 2, 1, 4, 8, 8, 8, 8, 4, 4, 4, 2],
[2, 4, 4, 4, 4, 2, 2, 2, 1, 2, 4, 4, 4, 4, 2, 4, 4, 2, 4, 2, 4, 4, 4, 2],
[
1,
2,
2,
2,
2,
1,
2,
2,
1,
2,
1,
2,
2,
2,
1,
2,
4,
4,
4,
4,
2,
4,
4,
2,
4,
2,
4,
4,
4,
2,
],
[
1,
2,
2,
2,
2,
1,
2,
2,
1,
2,
1,
2,
2,
2,
1,
1,
2,
2,
2,
2,
1,
2,
2,
1,
2,
1,
2,
2,
2,
1,
1,
2,
2,
2,
2,
1,
2,
2,
1,
2,
1,
2,
2,
2,
1,
],
],
]
mesh = 14
ph = Phonopy(aln_cell, supercell_matrix=[1, 1, 1], primitive_matrix="auto")
bzgrid = BZGrid(
mesh,
lattice=ph.primitive.cell,
symmetry_dataset=ph.primitive_symmetry.dataset,
use_grg=True,
force_SNF=params[0],
is_time_reversal=False,
)
# print(bzgrid.D_diag)
# print(bzgrid.addresses)
# bzg2grg[1] = 1, bzg2grg[8] = 7
for i, grid_index in enumerate((1, 7)):
map_triplets, map_q = _get_triplets_reciprocal_mesh_at_q(
grid_index,
bzgrid.D_diag,
bzgrid.rotations,
is_time_reversal=params[2],
swappable=params[1],
)
ir_triplets, ir_weights = _get_BZ_triplets_at_q(
bzgrid.grg2bzg[grid_index], bzgrid, map_triplets
)
triplets_with_zeros = np.zeros((45, 3), dtype=int)
triplets_with_zeros[: len(ir_triplets)] = ir_triplets
ir_weights_with_zeros = np.zeros(45, dtype=int)
ir_weights_with_zeros[: len(ir_weights)] = ir_weights
np.testing.assert_equal(ref_triplets[i][params[3]], ir_triplets)
np.testing.assert_equal(ref_ir_weights[i][params[3]], ir_weights)
if i == 1 and params[0]:
# print("{")
# for j, tp in enumerate(triplets_with_zeros):
# print("%d, %d, %d, " % tuple(tp), end="")
# if (j + 1) % 5 == 0:
# print("&")
print(", ".join(["%d" % x for x in ir_weights_with_zeros]))
# print("},")
# print(len(ir_triplets))
# print("[")
# print("[")
# for tp in ir_triplets:
# print("[%d, %d, %d]," % tuple(tp))
# print("],")
# print("]")
# print("[")
# print(",".join(["%d" % x for x in ir_weights]))
# print("],")
# print(len(ir_triplets))
# print(bzgrid._reciprocal_lattice.tolist())