mirror of https://github.com/phonopy/phono3py.git
Two tests for C gridsys library were added
test_gridsys_get_ir_grid_map_rutile test_gridsys_get_ir_grid_map_wurtzite
This commit is contained in:
parent
12e2238e8f
commit
60c84bd579
31
c/gridsys.c
31
c/gridsys.c
|
@ -64,7 +64,6 @@ long gridsys_get_double_grid_index(const long address_double[3],
|
|||
return grg_get_double_grid_index(address_double, D_diag, PS);
|
||||
}
|
||||
|
||||
/* From single address to grid index */
|
||||
long gridsys_get_grid_index_from_address(const long address[3],
|
||||
const long D_diag[3]) {
|
||||
return grg_get_grid_index(address, D_diag);
|
||||
|
@ -88,9 +87,6 @@ long gridsys_get_snf3x3(long D_diag[3], long P[3][3], long Q[3][3],
|
|||
return grg_get_snf3x3(D_diag, P, Q, A);
|
||||
}
|
||||
|
||||
/* Rotation matrices with respect to reciprocal basis vectors are
|
||||
* transformed to those for GRGrid. This set of the rotations are
|
||||
* used always in GRGrid handling. */
|
||||
long gridsys_transform_rotations(long (*transformed_rots)[3][3],
|
||||
const long (*rotations)[3][3],
|
||||
const long num_rot, const long D_diag[3],
|
||||
|
@ -112,44 +108,17 @@ void gridsys_get_thm_all_relative_grid_address(
|
|||
thm_get_all_relative_grid_address(relative_grid_address);
|
||||
}
|
||||
|
||||
/* Get one dataset of relative grid address used for tetrahedron */
|
||||
/* method. rec_lattice is used to choose the one. */
|
||||
/* rec_lattice : microzone basis vectors in column vectors */
|
||||
long gridsys_get_thm_relative_grid_address(
|
||||
long relative_grid_addresses[24][4][3], const double rec_lattice[3][3]) {
|
||||
return thm_get_relative_grid_address(relative_grid_addresses, rec_lattice);
|
||||
}
|
||||
|
||||
/* The rotations are those after proper transformation in GRGrid. */
|
||||
void gridsys_get_ir_grid_map(long *ir_grid_map, const long (*rotations)[3][3],
|
||||
const long num_rot, const long D_diag[3],
|
||||
const long PS[3]) {
|
||||
grg_get_ir_grid_map(ir_grid_map, rotations, num_rot, D_diag, PS);
|
||||
}
|
||||
|
||||
/* Find shortest grid points from Gamma considering periodicity of */
|
||||
/* reciprocal lattice. See the details in docstring of BZGrid. */
|
||||
/* */
|
||||
/* Parameters */
|
||||
/* ---------- */
|
||||
/* type : Data structure type of bz_map. type=2 is always */
|
||||
/* recommended.*/
|
||||
/* Returns */
|
||||
/* ------- */
|
||||
/* bz_grid_addresses : */
|
||||
/* Grid point addresses of shortest grid points. */
|
||||
/* len(bz_grid_addresses) <= product(D_diag + 1) */
|
||||
/* for full gr_grid_addresses. */
|
||||
/* bz_map : */
|
||||
/* List of accumulated numbers of BZ grid points from the first GR */
|
||||
/* grid point to the last grid point. */
|
||||
/* [0, 1, 3, 4, ...] means multiplicities of [1, 2, 1, ...] */
|
||||
/* With type=2, len(bz_map)=product(D_diag) + 1. */
|
||||
/* bzg2grg : */
|
||||
/* Mapping table of bz_grid_addresses to gr_grid_addresses. */
|
||||
/* len(bzg2grg) == len(bz_grid_addresses) <= product(D_diag + 1). */
|
||||
/* (function return) size : */
|
||||
/* Number of bz_grid_addresses stored. */
|
||||
long gridsys_get_bz_grid_addresses(long (*bz_grid_addresses)[3], long *bz_map,
|
||||
long *bzg2grg, const long D_diag[3],
|
||||
const long Q[3][3], const long PS[3],
|
||||
|
|
36
c/gridsys.h
36
c/gridsys.h
|
@ -109,7 +109,7 @@ long gridsys_get_grid_index_from_address(const long address[3],
|
|||
* @brief Return grid point index of rotated address of given grid point index.
|
||||
*
|
||||
* @param grid_index Grid point index in GR-grid
|
||||
* @param rotation Rotation in reciprocal space R^T
|
||||
* @param rotation Transformed rotation in reciprocal space tilde-R^T
|
||||
* @param D_diag Numbers of divisions along a, b, c directions of GR-grid
|
||||
* @param PS Shift in GR-grid
|
||||
* @return * long
|
||||
|
@ -149,7 +149,8 @@ long gridsys_get_snf3x3(long D_diag[3], long P[3][3], long Q[3][3],
|
|||
* vectors in GR-grid
|
||||
*
|
||||
* @param transformed_rots Transformed rotation matrices in reciprocal space
|
||||
* @param rotations Original rotations matrices in reciprocal space
|
||||
* {tilde-R^T}
|
||||
* @param rotations Original rotations matrices in reciprocal space {R^T}
|
||||
* @param num_rot Number of rotation matrices
|
||||
* @param D_diag Diagonal elements of diagnoal matrix D of Smith normal form
|
||||
* @param Q Unimodular matrix Q of Smith normal form
|
||||
|
@ -193,9 +194,40 @@ void gridsys_get_thm_all_relative_grid_address(
|
|||
*/
|
||||
long gridsys_get_thm_relative_grid_address(
|
||||
long relative_grid_addresses[24][4][3], const double rec_lattice[3][3]);
|
||||
|
||||
/**
|
||||
* @brief Return mapping table from GR-grid points to GR-ir-grid points
|
||||
*
|
||||
* @param ir_grid_map Grid point index mapping to ir-grid point indices with
|
||||
* array size of prod(D_diag)
|
||||
* @param rotations Transformed rotation matrices in reciprocal space
|
||||
* @param num_rot Number of rotation matrices
|
||||
* @param D_diag Diagonal elements of diagnoal matrix D of Smith normal form
|
||||
* @param PS Shift in GR-grid
|
||||
*/
|
||||
void gridsys_get_ir_grid_map(long *ir_grid_map, const long (*rotations)[3][3],
|
||||
const long num_rot, const long D_diag[3],
|
||||
const long PS[3]);
|
||||
|
||||
/**
|
||||
* @brief Find shortest grid points from Gamma considering periodicity of
|
||||
* reciprocal lattice. See the details in docstring of BZGrid
|
||||
*
|
||||
* @param bz_grid_addresses Grid point addresses of shortest grid points
|
||||
* @param bz_map List of accumulated numbers of BZ grid points from the
|
||||
* first GR grid point to the last grid point. In type-II, [0, 1, 3, 4, ...]
|
||||
* means multiplicities of [1, 2, 1, ...], with len(bz_map)=product(D_diag) + 1.
|
||||
* @param bzg2grg Mapping table of bz_grid_addresses to gr_grid_addresses. In
|
||||
* type-II, len(bzg2grg) == len(bz_grid_addresses) <= (D_diag[0] + 1) *
|
||||
* (D_diag[1] + 1) * (D_diag[2] + 1).
|
||||
* @param D_diag Diagonal elements of diagnoal matrix D of Smith normal form
|
||||
* @param Q Unimodular matrix Q of Smith normal form
|
||||
* @param PS Shift in GR-grid
|
||||
* @param rec_lattice Reduced reciprocal basis vectors in column vectors
|
||||
* @param type Data structure type I (old and sparse) or II (new and dense,
|
||||
* recommended) of bz_map
|
||||
* @return long Number of bz_grid_addresses stored.
|
||||
*/
|
||||
long gridsys_get_bz_grid_addresses(long (*bz_grid_addresses)[3], long *bz_map,
|
||||
long *bzg2grg, const long D_diag[3],
|
||||
const long Q[3][3], const long PS[3],
|
||||
|
|
|
@ -513,3 +513,94 @@ TEST(test_gridsys, test_gridsys_get_thm_relative_grid_address) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief gridsys_get_ir_grid_map tested by rutile rotations
|
||||
* Return grid point mapping table to ir-grid points
|
||||
*/
|
||||
TEST(test_gridsys, test_gridsys_get_ir_grid_map_rutile) {
|
||||
long *ir_grid_map;
|
||||
long n, i, j;
|
||||
long D_diag[3] = {4, 4, 6};
|
||||
long PS[4][3] = {{0, 0, 0}, {1, 1, 0}, {0, 0, 1}, {1, 1, 1}};
|
||||
|
||||
long ref_ir_grid_maps[4][96] = {
|
||||
{0, 1, 2, 1, 1, 5, 6, 5, 2, 6, 10, 6, 1, 5, 6, 5,
|
||||
16, 17, 18, 17, 17, 21, 22, 21, 18, 22, 26, 22, 17, 21, 22, 21,
|
||||
32, 33, 34, 33, 33, 37, 38, 37, 34, 38, 42, 38, 33, 37, 38, 37,
|
||||
48, 49, 50, 49, 49, 53, 54, 53, 50, 54, 58, 54, 49, 53, 54, 53,
|
||||
32, 33, 34, 33, 33, 37, 38, 37, 34, 38, 42, 38, 33, 37, 38, 37,
|
||||
16, 17, 18, 17, 17, 21, 22, 21, 18, 22, 26, 22, 17, 21, 22, 21},
|
||||
{0, 1, 1, 0, 1, 5, 5, 1, 1, 5, 5, 1, 0, 1, 1, 0,
|
||||
16, 17, 17, 16, 17, 21, 21, 17, 17, 21, 21, 17, 16, 17, 17, 16,
|
||||
32, 33, 33, 32, 33, 37, 37, 33, 33, 37, 37, 33, 32, 33, 33, 32,
|
||||
48, 49, 49, 48, 49, 53, 53, 49, 49, 53, 53, 49, 48, 49, 49, 48,
|
||||
32, 33, 33, 32, 33, 37, 37, 33, 33, 37, 37, 33, 32, 33, 33, 32,
|
||||
16, 17, 17, 16, 17, 21, 21, 17, 17, 21, 21, 17, 16, 17, 17, 16},
|
||||
{0, 1, 2, 1, 1, 5, 6, 5, 2, 6, 10, 6, 1, 5, 6, 5,
|
||||
16, 17, 18, 17, 17, 21, 22, 21, 18, 22, 26, 22, 17, 21, 22, 21,
|
||||
32, 33, 34, 33, 33, 37, 38, 37, 34, 38, 42, 38, 33, 37, 38, 37,
|
||||
32, 33, 34, 33, 33, 37, 38, 37, 34, 38, 42, 38, 33, 37, 38, 37,
|
||||
16, 17, 18, 17, 17, 21, 22, 21, 18, 22, 26, 22, 17, 21, 22, 21,
|
||||
0, 1, 2, 1, 1, 5, 6, 5, 2, 6, 10, 6, 1, 5, 6, 5},
|
||||
{0, 1, 1, 0, 1, 5, 5, 1, 1, 5, 5, 1, 0, 1, 1, 0,
|
||||
16, 17, 17, 16, 17, 21, 21, 17, 17, 21, 21, 17, 16, 17, 17, 16,
|
||||
32, 33, 33, 32, 33, 37, 37, 33, 33, 37, 37, 33, 32, 33, 33, 32,
|
||||
32, 33, 33, 32, 33, 37, 37, 33, 33, 37, 37, 33, 32, 33, 33, 32,
|
||||
16, 17, 17, 16, 17, 21, 21, 17, 17, 21, 21, 17, 16, 17, 17, 16,
|
||||
0, 1, 1, 0, 1, 5, 5, 1, 1, 5, 5, 1, 0, 1, 1, 0}};
|
||||
|
||||
n = D_diag[0] * D_diag[1] * D_diag[2];
|
||||
ir_grid_map = (long *)malloc(sizeof(long) * n);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
gridsys_get_ir_grid_map(ir_grid_map, rutile_rec_rotations, 16, D_diag,
|
||||
PS[i]);
|
||||
for (j = 0; j < n; j++) {
|
||||
ASSERT_EQ(ref_ir_grid_maps[i][j], ir_grid_map[j]);
|
||||
}
|
||||
}
|
||||
|
||||
free(ir_grid_map);
|
||||
ir_grid_map = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief gridsys_get_ir_grid_map tested by wurtzite rotations
|
||||
* Return grid point mapping table to ir-grid points
|
||||
*/
|
||||
TEST(test_gridsys, test_gridsys_get_ir_grid_map_wurtzite) {
|
||||
long *ir_grid_map;
|
||||
long n, i, j;
|
||||
long D_diag[3] = {5, 5, 4};
|
||||
long PS[2][3] = {{0, 0, 0}, {0, 0, 1}};
|
||||
|
||||
long ref_ir_grid_maps[2][100] = {
|
||||
{0, 1, 2, 2, 1, 1, 6, 7, 6, 1, 2, 7, 7, 2, 6, 2, 6,
|
||||
2, 7, 7, 1, 1, 6, 7, 6, 25, 26, 27, 27, 26, 26, 31, 32, 31,
|
||||
26, 27, 32, 32, 27, 31, 27, 31, 27, 32, 32, 26, 26, 31, 32, 31, 50,
|
||||
51, 52, 52, 51, 51, 56, 57, 56, 51, 52, 57, 57, 52, 56, 52, 56, 52,
|
||||
57, 57, 51, 51, 56, 57, 56, 25, 26, 27, 27, 26, 26, 31, 32, 31, 26,
|
||||
27, 32, 32, 27, 31, 27, 31, 27, 32, 32, 26, 26, 31, 32, 31},
|
||||
{0, 1, 2, 2, 1, 1, 6, 7, 6, 1, 2, 7, 7, 2, 6, 2, 6,
|
||||
2, 7, 7, 1, 1, 6, 7, 6, 25, 26, 27, 27, 26, 26, 31, 32, 31,
|
||||
26, 27, 32, 32, 27, 31, 27, 31, 27, 32, 32, 26, 26, 31, 32, 31, 25,
|
||||
26, 27, 27, 26, 26, 31, 32, 31, 26, 27, 32, 32, 27, 31, 27, 31, 27,
|
||||
32, 32, 26, 26, 31, 32, 31, 0, 1, 2, 2, 1, 1, 6, 7, 6, 1,
|
||||
2, 7, 7, 2, 6, 2, 6, 2, 7, 7, 1, 1, 6, 7, 6}};
|
||||
|
||||
n = D_diag[0] * D_diag[1] * D_diag[2];
|
||||
ir_grid_map = (long *)malloc(sizeof(long) * n);
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
gridsys_get_ir_grid_map(ir_grid_map,
|
||||
zincblende_rec_rotations_with_time_reversal, 24,
|
||||
D_diag, PS[i]);
|
||||
for (j = 0; j < n; j++) {
|
||||
ASSERT_EQ(ref_ir_grid_maps[i][j], ir_grid_map[j]);
|
||||
}
|
||||
}
|
||||
|
||||
free(ir_grid_map);
|
||||
ir_grid_map = NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue