mirror of https://github.com/phonopy/phono3py.git
Merge branch 'develop' into test-fortran-wrapper
This commit is contained in:
commit
a2d9850df1
|
@ -31,7 +31,7 @@ repos:
|
|||
- id: pydocstyle
|
||||
|
||||
- repo: https://github.com/pycqa/isort
|
||||
rev: 5.11.4
|
||||
rev: 5.12.0
|
||||
hooks:
|
||||
- id: isort
|
||||
name: isort (python)
|
||||
|
@ -58,7 +58,7 @@ repos:
|
|||
stages: [manual]
|
||||
|
||||
- repo: https://github.com/cheshirekow/cmake-format-precommit
|
||||
rev: v0.6.10
|
||||
rev: v0.6.13
|
||||
hooks:
|
||||
- id: cmake-format
|
||||
- id: cmake-lint
|
||||
|
|
|
@ -977,30 +977,119 @@ TEST(test_gridsys, test_gridsys_get_triplets_at_q_wurtzite_force_SNF) {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief gridsys_get_triplets_at_q by wurtzite rotations with and without
|
||||
* @brief gridsys_get_BZ_triplets_at_q by wurtzite rotations with and without
|
||||
* force_SNF (i.e., transformed or not transformed rotations)
|
||||
* @details Four patterns, is_time_reversal x swappable, are tested.
|
||||
* The lattices generated with and without force_SNF are the same.
|
||||
* Therefore numbers of unique triplets should agree, which is this test.
|
||||
*/
|
||||
TEST(test_gridsys, test_gridsys_get_bz_triplets_at_q_wurtzite_force_SNF) {
|
||||
long ref_triplets[8][45][3] = {
|
||||
{{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}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
|
||||
{{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}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
|
||||
{{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},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
|
||||
{{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}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
|
||||
{{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}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
|
||||
{{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},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
|
||||
{{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}}};
|
||||
long ref_ir_weights[8][45] = {
|
||||
{2, 2, 1, 8, 4, 8, 4, 8, 8, 4, 4, 2, 4, 4, 2, 4, 2, 4, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{2, 2, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 4, 2,
|
||||
4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{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, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{2, 2, 1, 4, 4, 2, 4, 2, 4, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{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}};
|
||||
long ref_num_triplets[8] = {18, 24, 30, 45, 18, 24, 30, 45};
|
||||
|
||||
long D_diag[2][3] = {{1, 5, 15}, {5, 5, 3}};
|
||||
long PS[3] = {0, 0, 0};
|
||||
long Q[2][3][3] = {{{-1, 0, -6}, {0, -1, 0}, {-1, 0, -5}},
|
||||
{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}};
|
||||
double rec_lattice[3][3] = {{0.3214400514304082, 0.0, 0.0},
|
||||
{0.1855835002216734, 0.3711670004433468, 0.0},
|
||||
{0.0, 0.0, 0.20088388911209323}};
|
||||
{0.18558350022167336, 0.37116700044334666, 0.0},
|
||||
{0.0, 0.0, 0.20088388911209318}};
|
||||
long grid_point = 1;
|
||||
long map_triplets[75], map_q[75];
|
||||
long i, j, k, ll, num_triplets_1, num_triplets_2, bz_size;
|
||||
long ref_unique_elems[4][2] = {{18, 30}, {24, 45}, {30, 30}, {45, 45}};
|
||||
long i, j, k, ll, count, num_triplets_1, num_triplets_2, bz_size;
|
||||
long is_time_reversal[2] = {1, 0};
|
||||
long swappable[2] = {1, 0};
|
||||
long rec_rotations[2][12][3][3];
|
||||
long triplets[75][3];
|
||||
long bz_grid_addresses[108][3];
|
||||
long bz_map[75];
|
||||
long bz_map[76];
|
||||
long bzg2grg[108];
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
|
@ -1021,10 +1110,16 @@ TEST(test_gridsys, test_gridsys_get_bz_triplets_at_q_wurtzite_force_SNF) {
|
|||
}
|
||||
}
|
||||
|
||||
count = 0;
|
||||
for (i = 0; i < 2; i++) { // force_SNF True or False
|
||||
bz_size =
|
||||
gridsys_get_bz_grid_addresses(bz_grid_addresses, bz_map, bzg2grg,
|
||||
D_diag[i], Q[i], PS, rec_lattice, 2);
|
||||
ASSERT_EQ(93, bz_size);
|
||||
// for (ll = 0; ll < 93; ll++) {
|
||||
// printf("[%ld, %ld, %ld]\n", bz_grid_addresses[ll][0],
|
||||
// bz_grid_addresses[ll][1], bz_grid_addresses[ll][2]);
|
||||
// }
|
||||
for (j = 0; j < 2; j++) { // swappable
|
||||
for (k = 0; k < 2; k++) { // is_time_reversal
|
||||
num_triplets_1 = gridsys_get_triplets_at_q(
|
||||
|
@ -1034,6 +1129,19 @@ TEST(test_gridsys, test_gridsys_get_bz_triplets_at_q_wurtzite_force_SNF) {
|
|||
triplets, grid_point, bz_grid_addresses, bz_map,
|
||||
map_triplets, 75, D_diag[i], Q[i], 2);
|
||||
ASSERT_EQ(num_triplets_1, num_triplets_2);
|
||||
ASSERT_EQ(num_triplets_1, ref_num_triplets[count]);
|
||||
for (ll = 0; ll < num_triplets_2; ll++) {
|
||||
// printf("%ld %ld %ld %ld [%ld %ld %ld] [%ld %ld %ld]\n",
|
||||
// i,
|
||||
// j, k, ll, ref_triplets[count][ll][0],
|
||||
// ref_triplets[count][ll][1],
|
||||
// ref_triplets[count][ll][2], triplets[ll][0],
|
||||
// triplets[ll][1], triplets[ll][2]);
|
||||
ASSERT_EQ(ref_triplets[count][ll][0], triplets[ll][0]);
|
||||
ASSERT_EQ(ref_triplets[count][ll][1], triplets[ll][1]);
|
||||
ASSERT_EQ(ref_triplets[count][ll][2], triplets[ll][2]);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -843,11 +843,11 @@ def test_get_triplets_reciprocal_mesh_at_q_wurtzite_force(
|
|||
is_time_reversal=False,
|
||||
)
|
||||
|
||||
for r in bzgrid.rotations:
|
||||
print("{")
|
||||
for v in r:
|
||||
print("{%d, %d, %d}," % tuple(v))
|
||||
print("},")
|
||||
# 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]]
|
||||
|
||||
|
@ -1315,6 +1315,8 @@ def test_get_BZ_triplets_at_q(aln_cell: PhonopyAtoms, params):
|
|||
force_SNF=params[0],
|
||||
is_time_reversal=False,
|
||||
)
|
||||
# print(bzgrid.D_diag)
|
||||
# print(bzgrid.addresses)
|
||||
map_triplets, map_q = _get_triplets_reciprocal_mesh_at_q(
|
||||
grid_point,
|
||||
bzgrid.D_diag,
|
||||
|
@ -1324,25 +1326,14 @@ def test_get_BZ_triplets_at_q(aln_cell: PhonopyAtoms, params):
|
|||
)
|
||||
triplets, ir_weights = _get_BZ_triplets_at_q(grid_point, bzgrid, map_triplets)
|
||||
|
||||
for tp in triplets:
|
||||
print("{%d, %d, %d}," % tuple(tp))
|
||||
# print(",".join(["%d" % x for x in ir_weights]))
|
||||
triplets_with_zeros = np.zeros((45, 3), dtype=int)
|
||||
triplets_with_zeros[: len(triplets)] = triplets
|
||||
ir_weights_with_zeros = np.zeros(45, dtype=int)
|
||||
ir_weights_with_zeros[: len(ir_weights)] = ir_weights
|
||||
# for tp in triplets_with_zeros:
|
||||
# print("{%d, %d, %d}," % tuple(tp))
|
||||
# print(",".join(["%d" % x for x in ir_weights_with_zeros]))
|
||||
# print(len(triplets))
|
||||
np.testing.assert_equal(ref_triplets[params[3]], triplets)
|
||||
np.testing.assert_equal(ref_ir_weights[params[3]], ir_weights)
|
||||
print(np.linalg.inv(ph.primitive.cell).tolist())
|
||||
|
||||
|
||||
def test_test(aln_cell: PhonopyAtoms):
|
||||
mesh = 13
|
||||
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=True,
|
||||
is_time_reversal=False,
|
||||
)
|
||||
print(np.linalg.inv(ph.primitive.cell))
|
||||
print(bzgrid.D_diag)
|
||||
print(bzgrid.Q)
|
||||
# print(bzgrid._reciprocal_lattice.tolist())
|
||||
|
|
Loading…
Reference in New Issue