c-long was changed to int64_t.

This commit is contained in:
Atsushi Togo 2025-01-26 21:29:32 +09:00
parent d024ecb4c0
commit 942b1f5e01
72 changed files with 2592 additions and 2362 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
#include <math.h>
#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
#include <stdint.h>
#include "phononcalc.h"
@ -16,46 +17,46 @@ void py_get_phonons_at_gridpoints(
double unit_conversion_factor, nb::ndarray<> py_born_effective_charge,
nb::ndarray<> py_dielectric_constant, nb::ndarray<> py_reciprocal_lattice,
nb::ndarray<> py_q_direction, double nac_factor, nb::ndarray<> py_dd_q0,
nb::ndarray<> py_G_list, double lambda, long is_nac, long is_nac_q_zero,
long use_GL_NAC, const char *uplo) {
nb::ndarray<> py_G_list, double lambda, int64_t is_nac,
int64_t is_nac_q_zero, int64_t use_GL_NAC, const char *uplo) {
double(*born)[3][3];
double(*dielectric)[3];
double *q_dir;
double *freqs;
_lapack_complex_double *eigvecs;
char *phonon_done;
long *grid_points;
long(*grid_address)[3];
int64_t *grid_points;
int64_t(*grid_address)[3];
double(*QDinv)[3];
double *fc2;
double(*svecs_fc2)[3];
long(*multi_fc2)[2];
int64_t(*multi_fc2)[2];
double(*positions_fc2)[3];
double *masses_fc2;
long *p2s_fc2;
long *s2p_fc2;
int64_t *p2s_fc2;
int64_t *s2p_fc2;
double(*rec_lat)[3];
double(*dd_q0)[2];
double(*G_list)[3];
long num_patom, num_satom, num_phonons, num_grid_points, num_G_points;
int64_t num_patom, num_satom, num_phonons, num_grid_points, num_G_points;
freqs = (double *)py_frequencies.data();
eigvecs = (_lapack_complex_double *)py_eigenvectors.data();
phonon_done = (char *)py_phonon_done.data();
grid_points = (long *)py_grid_points.data();
grid_address = (long(*)[3])py_grid_address.data();
grid_points = (int64_t *)py_grid_points.data();
grid_address = (int64_t(*)[3])py_grid_address.data();
QDinv = (double(*)[3])py_QDinv.data();
fc2 = (double *)py_fc2.data();
svecs_fc2 = (double(*)[3])py_shortest_vectors_fc2.data();
multi_fc2 = (long(*)[2])py_multiplicity_fc2.data();
multi_fc2 = (int64_t(*)[2])py_multiplicity_fc2.data();
masses_fc2 = (double *)py_masses_fc2.data();
p2s_fc2 = (long *)py_p2s_map_fc2.data();
s2p_fc2 = (long *)py_s2p_map_fc2.data();
p2s_fc2 = (int64_t *)py_p2s_map_fc2.data();
s2p_fc2 = (int64_t *)py_s2p_map_fc2.data();
rec_lat = (double(*)[3])py_reciprocal_lattice.data();
num_patom = (long)py_multiplicity_fc2.shape(1);
num_satom = (long)py_multiplicity_fc2.shape(0);
num_phonons = (long)py_frequencies.shape(0);
num_grid_points = (long)py_grid_points.shape(0);
num_patom = (int64_t)py_multiplicity_fc2.shape(1);
num_satom = (int64_t)py_multiplicity_fc2.shape(0);
num_phonons = (int64_t)py_frequencies.shape(0);
num_grid_points = (int64_t)py_grid_points.shape(0);
if (is_nac) {
born = (double(*)[3][3])py_born_effective_charge.data();
@ -78,7 +79,7 @@ void py_get_phonons_at_gridpoints(
if (use_GL_NAC) {
dd_q0 = (double(*)[2])py_dd_q0.data();
G_list = (double(*)[3])py_G_list.data();
num_G_points = (long)py_G_list.shape(0);
num_G_points = (int64_t)py_G_list.shape(0);
positions_fc2 = (double(*)[3])py_positions_fc2.data();
} else {
dd_q0 = NULL;

View File

@ -1,40 +1,41 @@
#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
#include <stdint.h>
#include "recgrid.h"
namespace nb = nanobind;
long py_get_grid_index_from_address(nb::ndarray<> py_address,
nb::ndarray<> py_D_diag) {
long *address;
long *D_diag;
long gp;
int64_t py_get_grid_index_from_address(nb::ndarray<> py_address,
nb::ndarray<> py_D_diag) {
int64_t *address;
int64_t *D_diag;
int64_t gp;
address = (long *)py_address.data();
D_diag = (long *)py_D_diag.data();
address = (int64_t *)py_address.data();
D_diag = (int64_t *)py_D_diag.data();
gp = recgrid_get_grid_index_from_address(address, D_diag);
return gp;
}
long py_get_ir_grid_map(nb::ndarray<> py_grid_mapping_table,
nb::ndarray<> py_D_diag, nb::ndarray<> py_is_shift,
nb::ndarray<> py_rotations) {
long *D_diag;
long *is_shift;
long(*rot)[3][3];
long num_rot;
int64_t py_get_ir_grid_map(nb::ndarray<> py_grid_mapping_table,
nb::ndarray<> py_D_diag, nb::ndarray<> py_is_shift,
nb::ndarray<> py_rotations) {
int64_t *D_diag;
int64_t *is_shift;
int64_t(*rot)[3][3];
int64_t num_rot;
long *grid_mapping_table;
long num_ir;
int64_t *grid_mapping_table;
int64_t num_ir;
D_diag = (long *)py_D_diag.data();
is_shift = (long *)py_is_shift.data();
rot = (long(*)[3][3])py_rotations.data();
num_rot = (long)py_rotations.shape(0);
grid_mapping_table = (long *)py_grid_mapping_table.data();
D_diag = (int64_t *)py_D_diag.data();
is_shift = (int64_t *)py_is_shift.data();
rot = (int64_t(*)[3][3])py_rotations.data();
num_rot = (int64_t)py_rotations.shape(0);
grid_mapping_table = (int64_t *)py_grid_mapping_table.data();
num_ir = recgrid_get_ir_grid_map(grid_mapping_table, rot, num_rot, D_diag,
is_shift);
@ -43,25 +44,25 @@ long py_get_ir_grid_map(nb::ndarray<> py_grid_mapping_table,
void py_get_gr_grid_addresses(nb::ndarray<> py_gr_grid_addresses,
nb::ndarray<> py_D_diag) {
long(*gr_grid_addresses)[3];
long *D_diag;
int64_t(*gr_grid_addresses)[3];
int64_t *D_diag;
gr_grid_addresses = (long(*)[3])py_gr_grid_addresses.data();
D_diag = (long *)py_D_diag.data();
gr_grid_addresses = (int64_t(*)[3])py_gr_grid_addresses.data();
D_diag = (int64_t *)py_D_diag.data();
recgrid_get_all_grid_addresses(gr_grid_addresses, D_diag);
}
long py_get_reciprocal_rotations(nb::ndarray<> py_rec_rotations,
nb::ndarray<> py_rotations,
long is_time_reversal) {
long(*rec_rotations)[3][3];
long(*rotations)[3][3];
long num_rot, num_rec_rot;
int64_t py_get_reciprocal_rotations(nb::ndarray<> py_rec_rotations,
nb::ndarray<> py_rotations,
int64_t is_time_reversal) {
int64_t(*rec_rotations)[3][3];
int64_t(*rotations)[3][3];
int64_t num_rot, num_rec_rot;
rec_rotations = (long(*)[3][3])py_rec_rotations.data();
rotations = (long(*)[3][3])py_rotations.data();
num_rot = (long)py_rotations.shape(0);
rec_rotations = (int64_t(*)[3][3])py_rec_rotations.data();
rotations = (int64_t(*)[3][3])py_rotations.data();
num_rot = (int64_t)py_rotations.shape(0);
num_rec_rot = recgrid_get_reciprocal_point_group(
rec_rotations, rotations, num_rot, is_time_reversal, 1);
@ -72,17 +73,17 @@ long py_get_reciprocal_rotations(nb::ndarray<> py_rec_rotations,
bool py_transform_rotations(nb::ndarray<> py_transformed_rotations,
nb::ndarray<> py_rotations, nb::ndarray<> py_D_diag,
nb::ndarray<> py_Q) {
long(*transformed_rotations)[3][3];
long(*rotations)[3][3];
long *D_diag;
long(*Q)[3];
long num_rot, succeeded;
int64_t(*transformed_rotations)[3][3];
int64_t(*rotations)[3][3];
int64_t *D_diag;
int64_t(*Q)[3];
int64_t num_rot, succeeded;
transformed_rotations = (long(*)[3][3])py_transformed_rotations.data();
rotations = (long(*)[3][3])py_rotations.data();
D_diag = (long *)py_D_diag.data();
Q = (long(*)[3])py_Q.data();
num_rot = (long)py_transformed_rotations.shape(0);
transformed_rotations = (int64_t(*)[3][3])py_transformed_rotations.data();
rotations = (int64_t(*)[3][3])py_rotations.data();
D_diag = (int64_t *)py_D_diag.data();
Q = (int64_t(*)[3])py_Q.data();
num_rot = (int64_t)py_transformed_rotations.shape(0);
succeeded = recgrid_transform_rotations(transformed_rotations, rotations,
num_rot, D_diag, Q);
@ -95,16 +96,16 @@ bool py_transform_rotations(nb::ndarray<> py_transformed_rotations,
bool py_get_snf3x3(nb::ndarray<> py_D_diag, nb::ndarray<> py_P,
nb::ndarray<> py_Q, nb::ndarray<> py_A) {
long *D_diag;
long(*P)[3];
long(*Q)[3];
long(*A)[3];
long succeeded;
int64_t *D_diag;
int64_t(*P)[3];
int64_t(*Q)[3];
int64_t(*A)[3];
int64_t succeeded;
D_diag = (long *)py_D_diag.data();
P = (long(*)[3])py_P.data();
Q = (long(*)[3])py_Q.data();
A = (long(*)[3])py_A.data();
D_diag = (int64_t *)py_D_diag.data();
P = (int64_t(*)[3])py_P.data();
Q = (int64_t(*)[3])py_Q.data();
A = (int64_t(*)[3])py_A.data();
succeeded = recgrid_get_snf3x3(D_diag, P, Q, A);
if (succeeded) {
@ -114,26 +115,25 @@ bool py_get_snf3x3(nb::ndarray<> py_D_diag, nb::ndarray<> py_P,
}
}
long py_get_bz_grid_addresses(nb::ndarray<> py_bz_grid_addresses,
nb::ndarray<> py_bz_map, nb::ndarray<> py_bzg2grg,
nb::ndarray<> py_D_diag, nb::ndarray<> py_Q,
nb::ndarray<> py_PS,
nb::ndarray<> py_reciprocal_lattice, long type) {
long(*bz_grid_addresses)[3];
long *bz_map;
long *bzg2grg;
long *D_diag;
long(*Q)[3];
long *PS;
int64_t py_get_bz_grid_addresses(
nb::ndarray<> py_bz_grid_addresses, nb::ndarray<> py_bz_map,
nb::ndarray<> py_bzg2grg, nb::ndarray<> py_D_diag, nb::ndarray<> py_Q,
nb::ndarray<> py_PS, nb::ndarray<> py_reciprocal_lattice, int64_t type) {
int64_t(*bz_grid_addresses)[3];
int64_t *bz_map;
int64_t *bzg2grg;
int64_t *D_diag;
int64_t(*Q)[3];
int64_t *PS;
double(*reciprocal_lattice)[3];
long num_total_gp;
int64_t num_total_gp;
bz_grid_addresses = (long(*)[3])py_bz_grid_addresses.data();
bz_map = (long *)py_bz_map.data();
bzg2grg = (long *)py_bzg2grg.data();
D_diag = (long *)py_D_diag.data();
Q = (long(*)[3])py_Q.data();
PS = (long *)py_PS.data();
bz_grid_addresses = (int64_t(*)[3])py_bz_grid_addresses.data();
bz_map = (int64_t *)py_bz_map.data();
bzg2grg = (int64_t *)py_bzg2grg.data();
D_diag = (int64_t *)py_D_diag.data();
Q = (int64_t(*)[3])py_Q.data();
PS = (int64_t *)py_PS.data();
reciprocal_lattice = (double(*)[3])py_reciprocal_lattice.data();
num_total_gp =
@ -143,23 +143,24 @@ long py_get_bz_grid_addresses(nb::ndarray<> py_bz_grid_addresses,
return num_total_gp;
}
long py_rotate_bz_grid_addresses(long bz_grid_index, nb::ndarray<> py_rotation,
nb::ndarray<> py_bz_grid_addresses,
nb::ndarray<> py_bz_map,
nb::ndarray<> py_D_diag, nb::ndarray<> py_PS,
long type) {
long(*bz_grid_addresses)[3];
long(*rotation)[3];
long *bz_map;
long *D_diag;
long *PS;
long ret_bz_gp;
int64_t py_rotate_bz_grid_addresses(int64_t bz_grid_index,
nb::ndarray<> py_rotation,
nb::ndarray<> py_bz_grid_addresses,
nb::ndarray<> py_bz_map,
nb::ndarray<> py_D_diag,
nb::ndarray<> py_PS, int64_t type) {
int64_t(*bz_grid_addresses)[3];
int64_t(*rotation)[3];
int64_t *bz_map;
int64_t *D_diag;
int64_t *PS;
int64_t ret_bz_gp;
bz_grid_addresses = (long(*)[3])py_bz_grid_addresses.data();
rotation = (long(*)[3])py_rotation.data();
bz_map = (long *)py_bz_map.data();
D_diag = (long *)py_D_diag.data();
PS = (long *)py_PS.data();
bz_grid_addresses = (int64_t(*)[3])py_bz_grid_addresses.data();
rotation = (int64_t(*)[3])py_rotation.data();
bz_map = (int64_t *)py_bz_map.data();
D_diag = (int64_t *)py_D_diag.data();
PS = (int64_t *)py_PS.data();
ret_bz_gp = recgrid_rotate_bz_grid_index(
bz_grid_index, rotation, bz_grid_addresses, bz_map, D_diag, PS, type);

View File

@ -35,6 +35,7 @@
#include "bzgrid.h"
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@ -43,7 +44,7 @@
#include "recgrid.h"
#define BZG_NUM_BZ_SEARCH_SPACE 125
static long bz_search_space[BZG_NUM_BZ_SEARCH_SPACE][3] = {
static int64_t bz_search_space[BZG_NUM_BZ_SEARCH_SPACE][3] = {
{0, 0, 0}, {0, 0, 1}, {0, 0, 2}, {0, 0, -2}, {0, 0, -1},
{0, 1, 0}, {0, 1, 1}, {0, 1, 2}, {0, 1, -2}, {0, 1, -1},
{0, 2, 0}, {0, 2, 1}, {0, 2, 2}, {0, 2, -2}, {0, 2, -1},
@ -71,27 +72,30 @@ static long bz_search_space[BZG_NUM_BZ_SEARCH_SPACE][3] = {
{-1, -1, 0}, {-1, -1, 1}, {-1, -1, 2}, {-1, -1, -2}, {-1, -1, -1}};
static void get_bz_grid_addresses_type1(RecgridBZGrid *bzgrid,
const long Qinv[3][3]);
const int64_t Qinv[3][3]);
static void get_bz_grid_addresses_type2(RecgridBZGrid *bzgrid,
const long Qinv[3][3]);
static void set_bz_address(long address[3], const long bz_index,
const long grid_address[3], const long D_diag[3],
const long nint[3], const long Qinv[3][3]);
static double get_bz_distances(long nint[3], double distances[],
const int64_t Qinv[3][3]);
static void set_bz_address(int64_t address[3], const int64_t bz_index,
const int64_t grid_address[3],
const int64_t D_diag[3], const int64_t nint[3],
const int64_t Qinv[3][3]);
static double get_bz_distances(int64_t nint[3], double distances[],
const RecgridBZGrid *bzgrid,
const long grid_address[3],
const int64_t grid_address[3],
const double tolerance);
static void multiply_matrix_vector_d3(double v[3], const double a[3][3],
const double b[3]);
static void multiply_matrix_vector_ld3(double v[3], const long a[3][3],
static void multiply_matrix_vector_ld3(double v[3], const int64_t a[3][3],
const double b[3]);
static long get_inverse_unimodular_matrix_l3(long m[3][3], const long a[3][3]);
static int64_t get_inverse_unimodular_matrix_l3(int64_t m[3][3],
const int64_t a[3][3]);
static double norm_squared_d3(const double a[3]);
long bzg_rotate_grid_index(const long bz_grid_index, const long rotation[3][3],
const RecgridConstBZGrid *bzgrid) {
long i, gp, num_bzgp, num_grgp;
long dadrs[3], dadrs_rot[3], adrs_rot[3];
int64_t bzg_rotate_grid_index(const int64_t bz_grid_index,
const int64_t rotation[3][3],
const RecgridConstBZGrid *bzgrid) {
int64_t i, gp, num_bzgp, num_grgp;
int64_t dadrs[3], dadrs_rot[3], adrs_rot[3];
grg_get_double_grid_address(dadrs, bzgrid->addresses[bz_grid_index],
bzgrid->PS);
@ -129,9 +133,9 @@ long bzg_rotate_grid_index(const long bz_grid_index, const long rotation[3][3],
return bzgrid->gp_map[gp];
}
long bzg_get_bz_grid_addresses(RecgridBZGrid *bzgrid) {
long det;
long Qinv[3][3];
int64_t bzg_get_bz_grid_addresses(RecgridBZGrid *bzgrid) {
int64_t det;
int64_t Qinv[3][3];
det = get_inverse_unimodular_matrix_l3(Qinv, bzgrid->Q);
if (det == 0) {
@ -148,12 +152,12 @@ long bzg_get_bz_grid_addresses(RecgridBZGrid *bzgrid) {
}
static void get_bz_grid_addresses_type1(RecgridBZGrid *bzgrid,
const long Qinv[3][3]) {
const int64_t Qinv[3][3]) {
double tolerance, min_distance;
double distances[BZG_NUM_BZ_SEARCH_SPACE];
long bzmesh[3], bz_address_double[3], nint[3], gr_adrs[3];
long i, j, k, boundary_num_gp, total_num_gp, bzgp, gp, num_bzmesh;
long count, id_shift;
int64_t bzmesh[3], bz_address_double[3], nint[3], gr_adrs[3];
int64_t i, j, k, boundary_num_gp, total_num_gp, bzgp, gp, num_bzmesh;
int64_t count, id_shift;
tolerance = recgrid_get_tolerance_for_BZ_reduction(bzgrid);
for (j = 0; j < 3; j++) {
@ -208,11 +212,11 @@ static void get_bz_grid_addresses_type1(RecgridBZGrid *bzgrid,
}
static void get_bz_grid_addresses_type2(RecgridBZGrid *bzgrid,
const long Qinv[3][3]) {
const int64_t Qinv[3][3]) {
double tolerance, min_distance;
double distances[BZG_NUM_BZ_SEARCH_SPACE];
long nint[3], gr_adrs[3];
long i, j, num_gp;
int64_t nint[3], gr_adrs[3];
int64_t i, j, num_gp;
tolerance = recgrid_get_tolerance_for_BZ_reduction(bzgrid);
num_gp = 0;
@ -238,11 +242,12 @@ static void get_bz_grid_addresses_type2(RecgridBZGrid *bzgrid,
bzgrid->size = num_gp;
}
static void set_bz_address(long address[3], const long bz_index,
const long grid_address[3], const long D_diag[3],
const long nint[3], const long Qinv[3][3]) {
long i;
long deltaG[3];
static void set_bz_address(int64_t address[3], const int64_t bz_index,
const int64_t grid_address[3],
const int64_t D_diag[3], const int64_t nint[3],
const int64_t Qinv[3][3]) {
int64_t i;
int64_t deltaG[3];
for (i = 0; i < 3; i++) {
deltaG[i] = bz_search_space[bz_index][i] - nint[i];
@ -253,12 +258,12 @@ static void set_bz_address(long address[3], const long bz_index,
}
}
static double get_bz_distances(long nint[3], double distances[],
static double get_bz_distances(int64_t nint[3], double distances[],
const RecgridBZGrid *bzgrid,
const long grid_address[3],
const int64_t grid_address[3],
const double tolerance) {
long i, j;
long dadrs[3];
int64_t i, j;
int64_t dadrs[3];
double min_distance;
double q_vec[3], q_red[3];
@ -297,7 +302,7 @@ static double get_bz_distances(long nint[3], double distances[],
static void multiply_matrix_vector_d3(double v[3], const double a[3][3],
const double b[3]) {
long i;
int64_t i;
double c[3];
for (i = 0; i < 3; i++) {
c[i] = a[i][0] * b[0] + a[i][1] * b[1] + a[i][2] * b[2];
@ -307,9 +312,9 @@ static void multiply_matrix_vector_d3(double v[3], const double a[3][3],
}
}
static void multiply_matrix_vector_ld3(double v[3], const long a[3][3],
static void multiply_matrix_vector_ld3(double v[3], const int64_t a[3][3],
const double b[3]) {
long i;
int64_t i;
double c[3];
for (i = 0; i < 3; i++) {
c[i] = a[i][0] * b[0] + a[i][1] * b[1] + a[i][2] * b[2];
@ -319,9 +324,10 @@ static void multiply_matrix_vector_ld3(double v[3], const long a[3][3],
}
}
static long get_inverse_unimodular_matrix_l3(long m[3][3], const long a[3][3]) {
long det;
long c[3][3];
static int64_t get_inverse_unimodular_matrix_l3(int64_t m[3][3],
const int64_t a[3][3]) {
int64_t det;
int64_t c[3][3];
det = lagmat_get_determinant_l3(a);
if (labs(det) != 1) {

View File

@ -35,10 +35,13 @@
#ifndef __bzgrid_H__
#define __bzgrid_H__
#include <stdint.h>
#include "recgrid.h"
long bzg_rotate_grid_index(const long grid_index, const long rotation[3][3],
const RecgridConstBZGrid *bzgrid);
long bzg_get_bz_grid_addresses(RecgridBZGrid *bzgrid);
int64_t bzg_rotate_grid_index(const int64_t grid_index,
const int64_t rotation[3][3],
const RecgridConstBZGrid *bzgrid);
int64_t bzg_get_bz_grid_addresses(RecgridBZGrid *bzgrid);
#endif

View File

@ -35,6 +35,7 @@
#include "collision_matrix.h"
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@ -43,33 +44,38 @@
static void get_collision_matrix(
double *collision_matrix, const double *fc3_normal_squared,
const long num_band0, const long num_band, const double *frequencies,
const long (*triplets)[3], const long *triplets_map, const long num_gp,
const long *map_q, const long *rot_grid_points, const long num_ir_gp,
const long num_rot, const double *rotations_cartesian, const double *g,
const int64_t num_band0, const int64_t num_band, const double *frequencies,
const int64_t (*triplets)[3], const int64_t *triplets_map,
const int64_t num_gp, const int64_t *map_q, const int64_t *rot_grid_points,
const int64_t num_ir_gp, const int64_t num_rot,
const double *rotations_cartesian, const double *g,
const double temperature, const double unit_conversion_factor,
const double cutoff_frequency);
static void get_reducible_collision_matrix(
double *collision_matrix, const double *fc3_normal_squared,
const long num_band0, const long num_band, const double *frequencies,
const long (*triplets)[3], const long *triplets_map, const long num_gp,
const long *map_q, const double *g, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency);
static long get_inv_sinh(double *inv_sinh, const long gp,
const double temperature, const double *frequencies,
const long triplet[3], const long *triplets_map,
const long *map_q, const long num_band,
const double cutoff_frequency);
static long *create_gp2tp_map(const long *triplets_map, const long num_gp);
const int64_t num_band0, const int64_t num_band, const double *frequencies,
const int64_t (*triplets)[3], const int64_t *triplets_map,
const int64_t num_gp, const int64_t *map_q, const double *g,
const double temperature, const double unit_conversion_factor,
const double cutoff_frequency);
static int64_t get_inv_sinh(double *inv_sinh, const int64_t gp,
const double temperature, const double *frequencies,
const int64_t triplet[3],
const int64_t *triplets_map, const int64_t *map_q,
const int64_t num_band,
const double cutoff_frequency);
static int64_t *create_gp2tp_map(const int64_t *triplets_map,
const int64_t num_gp);
void col_get_collision_matrix(
double *collision_matrix, const Darray *fc3_normal_squared,
const double *frequencies, const long (*triplets)[3],
const long *triplets_map, const long *map_q, const long *rot_grid_points,
const double *rotations_cartesian, const double *g, const long num_ir_gp,
const long num_gp, const long num_rot, const double temperature,
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplets_map, const int64_t *map_q,
const int64_t *rot_grid_points, const double *rotations_cartesian,
const double *g, const int64_t num_ir_gp, const int64_t num_gp,
const int64_t num_rot, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency) {
long num_triplets, num_band0, num_band;
int64_t num_triplets, num_band0, num_band;
num_triplets = fc3_normal_squared->dims[0];
num_band0 = fc3_normal_squared->dims[1];
@ -85,11 +91,11 @@ void col_get_collision_matrix(
void col_get_reducible_collision_matrix(
double *collision_matrix, const Darray *fc3_normal_squared,
const double *frequencies, const long (*triplets)[3],
const long *triplets_map, const long *map_q, const double *g,
const long num_gp, const double temperature,
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplets_map, const int64_t *map_q, const double *g,
const int64_t num_gp, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency) {
long num_triplets, num_band, num_band0;
int64_t num_triplets, num_band, num_band0;
num_triplets = fc3_normal_squared->dims[0];
num_band0 = fc3_normal_squared->dims[1];
@ -104,14 +110,15 @@ void col_get_reducible_collision_matrix(
static void get_collision_matrix(
double *collision_matrix, const double *fc3_normal_squared,
const long num_band0, const long num_band, const double *frequencies,
const long (*triplets)[3], const long *triplets_map, const long num_gp,
const long *map_q, const long *rot_grid_points, const long num_ir_gp,
const long num_rot, const double *rotations_cartesian, const double *g,
const int64_t num_band0, const int64_t num_band, const double *frequencies,
const int64_t (*triplets)[3], const int64_t *triplets_map,
const int64_t num_gp, const int64_t *map_q, const int64_t *rot_grid_points,
const int64_t num_ir_gp, const int64_t num_rot,
const double *rotations_cartesian, const double *g,
const double temperature, const double unit_conversion_factor,
const double cutoff_frequency) {
long i, j, k, l, m, n, ti, r_gp, swapped;
long *gp2tp_map;
int64_t i, j, k, l, m, n, ti, r_gp, swapped;
int64_t *gp2tp_map;
double collision;
double *inv_sinh;
@ -175,12 +182,13 @@ static void get_collision_matrix(
static void get_reducible_collision_matrix(
double *collision_matrix, const double *fc3_normal_squared,
const long num_band0, const long num_band, const double *frequencies,
const long (*triplets)[3], const long *triplets_map, const long num_gp,
const long *map_q, const double *g, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency) {
long i, j, k, l, ti, swapped;
long *gp2tp_map;
const int64_t num_band0, const int64_t num_band, const double *frequencies,
const int64_t (*triplets)[3], const int64_t *triplets_map,
const int64_t num_gp, const int64_t *map_q, const double *g,
const double temperature, const double unit_conversion_factor,
const double cutoff_frequency) {
int64_t i, j, k, l, ti, swapped;
int64_t *gp2tp_map;
double collision;
double *inv_sinh;
@ -233,12 +241,13 @@ static void get_reducible_collision_matrix(
gp2tp_map = NULL;
}
static long get_inv_sinh(double *inv_sinh, const long gp,
const double temperature, const double *frequencies,
const long triplet[3], const long *triplets_map,
const long *map_q, const long num_band,
const double cutoff_frequency) {
long i, gp2, swapped;
static int64_t get_inv_sinh(double *inv_sinh, const int64_t gp,
const double temperature, const double *frequencies,
const int64_t triplet[3],
const int64_t *triplets_map, const int64_t *map_q,
const int64_t num_band,
const double cutoff_frequency) {
int64_t i, gp2, swapped;
double f;
/* This assumes the algorithm of get_ir_triplets_at_q_perm_q1q2, */
@ -267,11 +276,12 @@ static long get_inv_sinh(double *inv_sinh, const long gp,
/* Symmetrically independent triplets are indexed. */
/* Inverse definition of ir_grid_points in get_BZ_triplets_at_q */
/* in triplet_grid.c. */
static long *create_gp2tp_map(const long *triplets_map, const long num_gp) {
long i, num_ir;
long *gp2tp_map;
static int64_t *create_gp2tp_map(const int64_t *triplets_map,
const int64_t num_gp) {
int64_t i, num_ir;
int64_t *gp2tp_map;
gp2tp_map = (long *)malloc(sizeof(long) * num_gp);
gp2tp_map = (int64_t *)malloc(sizeof(int64_t) * num_gp);
num_ir = 0;
for (i = 0; i < num_gp; i++) {
if (triplets_map[i] == i) {

View File

@ -35,20 +35,23 @@
#ifndef __collision_matrix_H__
#define __collision_matrix_H__
#include <stdint.h>
#include "phonoc_array.h"
void col_get_collision_matrix(
double *collision_matrix, const Darray *fc3_normal_squared,
const double *frequencies, const long (*triplets)[3],
const long *triplets_map, const long *map_q, const long *rot_grid_points,
const double *rotations_cartesian, const double *g, const long num_ir_gp,
const long num_gp, const long num_rot, const double temperature,
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplets_map, const int64_t *map_q,
const int64_t *rot_grid_points, const double *rotations_cartesian,
const double *g, const int64_t num_ir_gp, const int64_t num_gp,
const int64_t num_rot, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency);
void col_get_reducible_collision_matrix(
double *collision_matrix, const Darray *fc3_normal_squared,
const double *frequencies, const long (*triplets)[3],
const long *triplets_map, const long *map_q, const double *g,
const long num_gp, const double temperature,
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplets_map, const int64_t *map_q, const double *g,
const int64_t num_gp, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency);
#endif

View File

@ -35,56 +35,61 @@
#include "dynmat.h"
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#define PI 3.14159265358979323846
static void add_dynmat_dd_at_q(
double (*dynamical_matrices)[2], const double q[3], const double *fc,
const double (*positions)[3], const long num_patom, const double *masses,
const double (*positions)[3], const int64_t num_patom, const double *masses,
const double (*born)[3][3], const double dielectric[3][3],
const double reciprocal_lattice[3][3], const double *q_dir_cart,
const double nac_factor, const double (*dd_q0)[2],
const double (*G_list)[3], const long num_G_points, const double lambda,
const double (*G_list)[3], const int64_t num_G_points, const double lambda,
const double tolerance);
static void get_dynmat_ij(double (*dynamical_matrix)[2], const long num_patom,
const long num_satom, const double *fc,
const double q[3], const double (*svecs)[3],
const long (*multi)[2], const double *mass,
const long *s2p_map, const long *p2s_map,
const double (*charge_sum)[3][3], const long i,
const long j);
static void get_dm(double dm[3][3][2], const long num_patom,
const long num_satom, const double *fc, const double q[3],
const double (*svecs)[3], const long (*multi)[2],
const long *p2s_map, const double (*charge_sum)[3][3],
const long i, const long j, const long k);
static void get_dynmat_ij(double (*dynamical_matrix)[2],
const int64_t num_patom, const int64_t num_satom,
const double *fc, const double q[3],
const double (*svecs)[3], const int64_t (*multi)[2],
const double *mass, const int64_t *s2p_map,
const int64_t *p2s_map,
const double (*charge_sum)[3][3], const int64_t i,
const int64_t j);
static void get_dm(double dm[3][3][2], const int64_t num_patom,
const int64_t num_satom, const double *fc, const double q[3],
const double (*svecs)[3], const int64_t (*multi)[2],
const int64_t *p2s_map, const double (*charge_sum)[3][3],
const int64_t i, const int64_t j, const int64_t k);
static double get_dielectric_part(const double q_cart[3],
const double dielectric[3][3]);
static void get_dd(double (*dd_part)[2], /* [natom, 3, natom, 3, (real,imag)] */
const double (*G_list)[3], /* [num_G, 3] */
const long num_G, const long num_patom,
const int64_t num_G, const int64_t num_patom,
const double q_cart[3], const double *q_direction_cart,
const double dielectric[3][3],
const double (*pos)[3], /* [num_patom, 3] */
const double lambda, const double tolerance,
const long use_openmp);
const int64_t use_openmp);
static void get_dd_at_g(
double (*dd_part)[2], /* [natom, 3, natom, 3, (real,imag)] */
const long i, const long j, const double G[3], const long num_patom,
const double (*pos)[3], /* [num_patom, 3] */
const int64_t i, const int64_t j, const double G[3],
const int64_t num_patom, const double (*pos)[3], /* [num_patom, 3] */
const double KK[3][3]);
static void make_Hermitian(double (*mat)[2], const long num_band);
static void make_Hermitian(double (*mat)[2], const int64_t num_band);
static void multiply_borns(double (*dd)[2], const double (*dd_in)[2],
const long num_patom, const double (*born)[3][3],
const long use_openmp);
static void multiply_borns_at_ij(double (*dd)[2], const long i, const long j,
const double (*dd_in)[2], const long num_patom,
const int64_t num_patom, const double (*born)[3][3],
const int64_t use_openmp);
static void multiply_borns_at_ij(double (*dd)[2], const int64_t i,
const int64_t j, const double (*dd_in)[2],
const int64_t num_patom,
const double (*born)[3][3]);
static void transform_dynmat_to_fc_ij(
double *fc, const double (*dm)[2], const long i, const long j,
double *fc, const double (*dm)[2], const int64_t i, const int64_t j,
const double (*comm_points)[3], const double (*svecs)[3],
const long (*multi)[2], const double *masses, const long *s2pp_map,
const long *fc_index_map, const long num_patom, const long num_satom);
const int64_t (*multi)[2], const double *masses, const int64_t *s2pp_map,
const int64_t *fc_index_map, const int64_t num_patom,
const int64_t num_satom);
static void get_q_cart(double q_cart[3], const double q[3],
const double reciprocal_lattice[3][3]);
@ -94,17 +99,18 @@ static void get_q_cart(double q_cart[3], const double q[3],
/// !use_Wang_NAC and dd_0 is not NULL: NAC by Gonze and Lee.
/// @param reciprocal_lattice in column vectors
/// @param q_direction in Crystallographic coordinates.
long dym_dynamical_matrices_with_dd_openmp_over_qpoints(
int64_t dym_dynamical_matrices_with_dd_openmp_over_qpoints(
double (*dynamical_matrices)[2], const double (*qpoints)[3],
const long n_qpoints, const double *fc, const double (*svecs)[3],
const long (*multi)[2], const double (*positions)[3], const long num_patom,
const long num_satom, const double *masses, const long *p2s_map,
const long *s2p_map, const double (*born)[3][3],
const int64_t n_qpoints, const double *fc, const double (*svecs)[3],
const int64_t (*multi)[2], const double (*positions)[3],
const int64_t num_patom, const int64_t num_satom, const double *masses,
const int64_t *p2s_map, const int64_t *s2p_map, const double (*born)[3][3],
const double dielectric[3][3], const double (*reciprocal_lattice)[3],
const double *q_direction, const double nac_factor,
const double (*dd_q0)[2], const double (*G_list)[3],
const long num_G_points, const double lambda, const long use_Wang_NAC) {
long i, n, adrs_shift;
const int64_t num_G_points, const double lambda,
const int64_t use_Wang_NAC) {
int64_t i, n, adrs_shift;
double(*charge_sum)[3][3];
double q_cart[3];
double *q_dir_cart;
@ -182,13 +188,13 @@ long dym_dynamical_matrices_with_dd_openmp_over_qpoints(
static void add_dynmat_dd_at_q(
double (*dynamical_matrices)[2], const double q[3], const double *fc,
const double (*positions)[3], const long num_patom, const double *masses,
const double (*positions)[3], const int64_t num_patom, const double *masses,
const double (*born)[3][3], const double dielectric[3][3],
const double reciprocal_lattice[3][3], const double *q_dir_cart,
const double nac_factor, const double (*dd_q0)[2],
const double (*G_list)[3], const long num_G_points, const double lambda,
const double (*G_list)[3], const int64_t num_G_points, const double lambda,
const double tolerance) {
long i, j, k, l, adrs;
int64_t i, j, k, l, adrs;
double(*dd)[2];
double q_cart[3];
double mm;
@ -217,15 +223,13 @@ static void add_dynmat_dd_at_q(
}
/// @brief charge_sum is NULL if G-L NAC or no-NAC.
long dym_get_dynamical_matrix_at_q(double (*dynamical_matrix)[2],
const long num_patom, const long num_satom,
const double *fc, const double q[3],
const double (*svecs)[3],
const long (*multi)[2], const double *mass,
const long *s2p_map, const long *p2s_map,
const double (*charge_sum)[3][3],
const long use_openmp) {
long i, j, ij;
int64_t dym_get_dynamical_matrix_at_q(
double (*dynamical_matrix)[2], const int64_t num_patom,
const int64_t num_satom, const double *fc, const double q[3],
const double (*svecs)[3], const int64_t (*multi)[2], const double *mass,
const int64_t *s2p_map, const int64_t *p2s_map,
const double (*charge_sum)[3][3], const int64_t use_openmp) {
int64_t i, j, ij;
if (use_openmp) {
#ifdef _OPENMP
@ -256,13 +260,13 @@ void dym_get_recip_dipole_dipole(
double (*dd)[2], /* [natom, 3, natom, 3, (real,imag)] */
const double (*dd_q0)[2], /* [natom, 3, 3, (real,imag)] */
const double (*G_list)[3], /* [num_G, 3] */
const long num_G, const long num_patom, const double q_cart[3],
const int64_t num_G, const int64_t num_patom, const double q_cart[3],
const double *q_direction_cart, /* must be pointer */
const double (*born)[3][3], const double dielectric[3][3],
const double (*pos)[3], /* [num_patom, 3] */
const double factor, /* 4pi/V*unit-conv */
const double lambda, const double tolerance, const long use_openmp) {
long i, k, l, adrs, adrs_sum;
const double lambda, const double tolerance, const int64_t use_openmp) {
int64_t i, k, l, adrs, adrs_sum;
double(*dd_tmp)[2];
dd_tmp =
@ -306,10 +310,10 @@ void dym_get_recip_dipole_dipole(
void dym_get_recip_dipole_dipole_q0(
double (*dd_q0)[2], /* [natom, 3, 3, (real,imag)] */
const double (*G_list)[3], /* [num_G, 3] */
const long num_G, const long num_patom, const double (*born)[3][3],
const int64_t num_G, const int64_t num_patom, const double (*born)[3][3],
const double dielectric[3][3], const double (*pos)[3], /* [num_patom, 3] */
const double lambda, const double tolerance, const long use_openmp) {
long i, j, k, l, adrs_tmp, adrs, adrsT;
const double lambda, const double tolerance, const int64_t use_openmp) {
int64_t i, j, k, l, adrs_tmp, adrs, adrsT;
double zero_vec[3];
double(*dd_tmp1)[2], (*dd_tmp2)[2];
@ -390,10 +394,10 @@ void dym_get_recip_dipole_dipole_q0(
}
void dym_get_charge_sum(
double (*charge_sum)[3][3], const long num_patom,
double (*charge_sum)[3][3], const int64_t num_patom,
const double factor, /* 4pi/V*unit-conv and denominator */
const double q_cart[3], const double (*born)[3][3]) {
long i, j, k, a, b;
int64_t i, j, k, a, b;
double(*q_born)[3];
q_born = (double(*)[3])malloc(sizeof(double[3]) * num_patom);
@ -431,14 +435,13 @@ void dym_get_charge_sum(
/* comm_points[num_satom / num_patom, 3] */
/* shortest_vectors[:, 3] */
/* multiplicities[num_satom, num_patom, 2] */
void dym_transform_dynmat_to_fc(double *fc, const double (*dm)[2],
const double (*comm_points)[3],
const double (*svecs)[3],
const long (*multi)[2], const double *masses,
const long *s2pp_map, const long *fc_index_map,
const long num_patom, const long num_satom,
const long use_openmp) {
long i, j, ij;
void dym_transform_dynmat_to_fc(
double *fc, const double (*dm)[2], const double (*comm_points)[3],
const double (*svecs)[3], const int64_t (*multi)[2], const double *masses,
const int64_t *s2pp_map, const int64_t *fc_index_map,
const int64_t num_patom, const int64_t num_satom,
const int64_t use_openmp) {
int64_t i, j, ij;
for (i = 0; i < num_patom * num_satom * 9; i++) {
fc[i] = 0;
@ -465,14 +468,15 @@ void dym_transform_dynmat_to_fc(double *fc, const double (*dm)[2],
}
/// @brief charge_sum is NULL if G-L NAC or no-NAC.
static void get_dynmat_ij(double (*dynamical_matrix)[2], const long num_patom,
const long num_satom, const double *fc,
const double q[3], const double (*svecs)[3],
const long (*multi)[2], const double *mass,
const long *s2p_map, const long *p2s_map,
const double (*charge_sum)[3][3], const long i,
const long j) {
long k, l, adrs;
static void get_dynmat_ij(double (*dynamical_matrix)[2],
const int64_t num_patom, const int64_t num_satom,
const double *fc, const double q[3],
const double (*svecs)[3], const int64_t (*multi)[2],
const double *mass, const int64_t *s2p_map,
const int64_t *p2s_map,
const double (*charge_sum)[3][3], const int64_t i,
const int64_t j) {
int64_t k, l, adrs;
double mass_sqrt;
double dm[3][3][2]; // [3][3][(real, imag)]
@ -502,12 +506,12 @@ static void get_dynmat_ij(double (*dynamical_matrix)[2], const long num_patom,
}
}
static void get_dm(double dm[3][3][2], const long num_patom,
const long num_satom, const double *fc, const double q[3],
const double (*svecs)[3], const long (*multi)[2],
const long *p2s_map, const double (*charge_sum)[3][3],
const long i, const long j, const long k) {
long l, m, i_pair, m_pair, adrs;
static void get_dm(double dm[3][3][2], const int64_t num_patom,
const int64_t num_satom, const double *fc, const double q[3],
const double (*svecs)[3], const int64_t (*multi)[2],
const int64_t *p2s_map, const double (*charge_sum)[3][3],
const int64_t i, const int64_t j, const int64_t k) {
int64_t l, m, i_pair, m_pair, adrs;
double phase, cos_phase, sin_phase, fc_elem;
cos_phase = 0;
@ -542,7 +546,7 @@ static void get_dm(double dm[3][3][2], const long num_patom,
static double get_dielectric_part(const double q_cart[3],
const double dielectric[3][3]) {
long i, j;
int64_t i, j;
double sum;
sum = 0;
@ -556,13 +560,13 @@ static double get_dielectric_part(const double q_cart[3],
static void get_dd(double (*dd_part)[2], /* [natom, 3, natom, 3, (real,imag)] */
const double (*G_list)[3], /* [num_G, 3] */
const long num_G, const long num_patom,
const int64_t num_G, const int64_t num_patom,
const double q_cart[3], const double *q_direction_cart,
const double dielectric[3][3],
const double (*pos)[3], /* [num_patom, 3] */
const double lambda, const double tolerance,
const long use_openmp) {
long i, j, g;
const int64_t use_openmp) {
int64_t i, j, g;
double q_K[3];
double norm, dielectric_part, L2;
double(*KK)[3][3];
@ -629,10 +633,10 @@ static void get_dd(double (*dd_part)[2], /* [natom, 3, natom, 3, (real,imag)] */
static void get_dd_at_g(
double (*dd_part)[2], /* [natom, 3, natom, 3, (real,imag)] */
const long i, const long j, const double G[3], const long num_patom,
const double (*pos)[3], /* [num_patom, 3] */
const int64_t i, const int64_t j, const double G[3],
const int64_t num_patom, const double (*pos)[3], /* [num_patom, 3] */
const double KK[3][3]) {
long k, l, adrs;
int64_t k, l, adrs;
double cos_phase, sin_phase, phase;
phase = 0;
@ -654,8 +658,8 @@ static void get_dd_at_g(
}
}
static void make_Hermitian(double (*mat)[2], const long num_band) {
long i, j, adrs, adrsT;
static void make_Hermitian(double (*mat)[2], const int64_t num_band) {
int64_t i, j, adrs, adrsT;
for (i = 0; i < num_band; i++) {
for (j = i; j < num_band; j++) {
@ -675,9 +679,9 @@ static void make_Hermitian(double (*mat)[2], const long num_band) {
}
static void multiply_borns(double (*dd)[2], const double (*dd_in)[2],
const long num_patom, const double (*born)[3][3],
const long use_openmp) {
long i, j, ij;
const int64_t num_patom, const double (*born)[3][3],
const int64_t use_openmp) {
int64_t i, j, ij;
if (use_openmp) {
#ifdef _OPENMP
@ -696,10 +700,11 @@ static void multiply_borns(double (*dd)[2], const double (*dd_in)[2],
}
}
static void multiply_borns_at_ij(double (*dd)[2], const long i, const long j,
const double (*dd_in)[2], const long num_patom,
static void multiply_borns_at_ij(double (*dd)[2], const int64_t i,
const int64_t j, const double (*dd_in)[2],
const int64_t num_patom,
const double (*born)[3][3]) {
long k, l, m, n, adrs, adrs_in;
int64_t k, l, m, n, adrs, adrs_in;
double zz;
for (k = 0; k < 3; k++) { /* alpha */
@ -718,11 +723,12 @@ static void multiply_borns_at_ij(double (*dd)[2], const long i, const long j,
}
static void transform_dynmat_to_fc_ij(
double *fc, const double (*dm)[2], const long i, const long j,
double *fc, const double (*dm)[2], const int64_t i, const int64_t j,
const double (*comm_points)[3], const double (*svecs)[3],
const long (*multi)[2], const double *masses, const long *s2pp_map,
const long *fc_index_map, const long num_patom, const long num_satom) {
long k, l, m, N, adrs, m_pair, i_pair, svecs_adrs;
const int64_t (*multi)[2], const double *masses, const int64_t *s2pp_map,
const int64_t *fc_index_map, const int64_t num_patom,
const int64_t num_satom) {
int64_t k, l, m, N, adrs, m_pair, i_pair, svecs_adrs;
double coef, phase, cos_phase, sin_phase;
N = num_satom / num_patom;
@ -760,7 +766,7 @@ static void transform_dynmat_to_fc_ij(
/// @param reciprocal_lattice in column vectors
static void get_q_cart(double q_cart[3], const double q[3],
const double reciprocal_lattice[3][3]) {
long i, j;
int64_t i, j;
for (i = 0; i < 3; i++) {
q_cart[i] = 0;

View File

@ -34,42 +34,42 @@
#ifndef __dynmat_H__
#define __dynmat_H__
#include <stdint.h>
long dym_dynamical_matrices_with_dd_openmp_over_qpoints(
int64_t dym_dynamical_matrices_with_dd_openmp_over_qpoints(
double (*dynamical_matrices)[2], const double (*qpoints)[3],
const long n_qpoints, const double *fc, const double (*svecs)[3],
const long (*multi)[2], const double (*positions)[3], const long num_patom,
const long num_satom, const double *masses, const long *p2s_map,
const long *s2p_map, const double (*born)[3][3],
const int64_t n_qpoints, const double *fc, const double (*svecs)[3],
const int64_t (*multi)[2], const double (*positions)[3],
const int64_t num_patom, const int64_t num_satom, const double *masses,
const int64_t *p2s_map, const int64_t *s2p_map, const double (*born)[3][3],
const double dielectric[3][3], const double (*reciprocal_lattice)[3],
const double *q_direction, const double nac_factor,
const double (*dd_q0)[2], const double (*G_list)[3],
const long num_G_points, const double lambda, const long use_Wang_NAC);
long dym_get_dynamical_matrix_at_q(double (*dynamical_matrix)[2],
const long num_patom, const long num_satom,
const double *fc, const double q[3],
const double (*svecs)[3],
const long (*multi)[2], const double *mass,
const long *s2p_map, const long *p2s_map,
const double (*charge_sum)[3][3],
const long use_openmp);
const int64_t num_G_points, const double lambda,
const int64_t use_Wang_NAC);
int64_t dym_get_dynamical_matrix_at_q(
double (*dynamical_matrix)[2], const int64_t num_patom,
const int64_t num_satom, const double *fc, const double q[3],
const double (*svecs)[3], const int64_t (*multi)[2], const double *mass,
const int64_t *s2p_map, const int64_t *p2s_map,
const double (*charge_sum)[3][3], const int64_t use_openmp);
void dym_get_recip_dipole_dipole(
double (*dd)[2], /* [natom, 3, natom, 3, (real,imag)] */
const double (*dd_q0)[2], /* [natom, 3, 3, (real,imag)] */
const double (*G_list)[3], /* [num_G, 3] */
const long num_G, const long num_patom, const double q_cart[3],
const int64_t num_G, const int64_t num_patom, const double q_cart[3],
const double *q_direction_cart, /* must be pointer */
const double (*born)[3][3], const double dielectric[3][3],
const double (*pos)[3], /* [num_patom, 3] */
const double factor, /* 4pi/V*unit-conv */
const double lambda, const double tolerance, const long use_openmp);
const double lambda, const double tolerance, const int64_t use_openmp);
void dym_get_recip_dipole_dipole_q0(
double (*dd_q0)[2], /* [natom, 3, 3, (real,imag)] */
const double (*G_list)[3], /* [num_G, 3] */
const long num_G, const long num_patom, const double (*born)[3][3],
const int64_t num_G, const int64_t num_patom, const double (*born)[3][3],
const double dielectric[3][3], const double (*pos)[3], /* [natom, 3] */
const double lambda, const double tolerance, const long use_openmp);
void dym_get_charge_sum(double (*charge_sum)[3][3], const long num_patom,
const double lambda, const double tolerance, const int64_t use_openmp);
void dym_get_charge_sum(double (*charge_sum)[3][3], const int64_t num_patom,
const double factor, const double q_cart[3],
const double (*born)[3][3]);
/* fc[num_patom, num_satom, 3, 3] */
@ -77,12 +77,10 @@ void dym_get_charge_sum(double (*charge_sum)[3][3], const long num_patom,
/* comm_points[num_satom / num_patom, 3] */
/* shortest_vectors[:, 3] */
/* multiplicities[num_satom, num_patom, 2] */
void dym_transform_dynmat_to_fc(double *fc, const double (*dm)[2],
const double (*comm_points)[3],
const double (*svecs)[3],
const long (*multi)[2], const double *masses,
const long *s2pp_map, const long *fc_index_map,
const long num_patom, const long num_satom,
const long use_openmp);
void dym_transform_dynmat_to_fc(
double *fc, const double (*dm)[2], const double (*comm_points)[3],
const double (*svecs)[3], const int64_t (*multi)[2], const double *masses,
const int64_t *s2pp_map, const int64_t *fc_index_map,
const int64_t num_patom, const int64_t num_satom, const int64_t use_openmp);
#endif

165
c/fc3.c
View File

@ -34,47 +34,49 @@
#include "fc3.h"
#include <stdint.h>
#include <stdlib.h>
static void rotate_delta_fc2s(double (*rot_delta_fc2s)[3][3], const long i_atom,
const long j_atom,
const double (*delta_fc2s)[3][3],
const double (*site_sym_cart)[3][3],
const long *rot_map_sym, const long num_atom,
const long num_site_sym, const long num_disp);
static void rotate_delta_fc2s(
double (*rot_delta_fc2s)[3][3], const int64_t i_atom, const int64_t j_atom,
const double (*delta_fc2s)[3][3], const double (*site_sym_cart)[3][3],
const int64_t *rot_map_sym, const int64_t num_atom,
const int64_t num_site_sym, const int64_t num_disp);
static void tensor2_rotation(double rot_tensor[3][3], const double tensor[3][3],
const double r[3][3]);
static void tensor3_rotation(double *rot_tensor, const double *tensor,
const double *rot_cartesian);
static double tensor3_rotation_elem(const double *tensor, const double *r,
const long pos);
const int64_t pos);
static void copy_permutation_symmetry_fc3_elem(double *fc3,
const double fc3_elem[27],
const long a, const long b,
const long c,
const long num_atom);
const int64_t a, const int64_t b,
const int64_t c,
const int64_t num_atom);
static void set_permutation_symmetry_fc3_elem(double *fc3_elem,
const double *fc3, const long a,
const long b, const long c,
const long num_atom);
const double *fc3,
const int64_t a, const int64_t b,
const int64_t c,
const int64_t num_atom);
static void set_permutation_symmetry_compact_fc3(
double *fc3, const long p2s[], const long s2pp[], const long nsym_list[],
const long perms[], const long n_satom, const long n_patom);
static void transpose_compact_fc3_type01(double *fc3, const long p2s[],
const long s2pp[],
const long nsym_list[],
const long perms[], const long n_satom,
const long n_patom, const long t_type);
static void transpose_compact_fc3_type2(double *fc3, const long p2s[],
const long s2pp[],
const long nsym_list[],
const long perms[], const long n_satom,
const long n_patom);
double *fc3, const int64_t p2s[], const int64_t s2pp[],
const int64_t nsym_list[], const int64_t perms[], const int64_t n_satom,
const int64_t n_patom);
static void transpose_compact_fc3_type01(
double *fc3, const int64_t p2s[], const int64_t s2pp[],
const int64_t nsym_list[], const int64_t perms[], const int64_t n_satom,
const int64_t n_patom, const int64_t t_type);
static void transpose_compact_fc3_type2(double *fc3, const int64_t p2s[],
const int64_t s2pp[],
const int64_t nsym_list[],
const int64_t perms[],
const int64_t n_satom,
const int64_t n_patom);
void fc3_distribute_fc3(double *fc3, const long target, const long source,
const long *atom_mapping, const long num_atom,
void fc3_distribute_fc3(double *fc3, const int64_t target, const int64_t source,
const int64_t *atom_mapping, const int64_t num_atom,
const double *rot_cart) {
long i, j, adrs_out, adrs_in;
int64_t i, j, adrs_out, adrs_in;
for (i = 0; i < num_atom; i++) {
for (j = 0; j < num_atom; j++) {
@ -90,9 +92,9 @@ void fc3_distribute_fc3(double *fc3, const long target, const long source,
void fc3_rotate_delta_fc2(double (*fc3)[3][3][3],
const double (*delta_fc2s)[3][3], const double *inv_U,
const double (*site_sym_cart)[3][3],
const long *rot_map_syms, const long num_atom,
const long num_site_sym, const long num_disp) {
long i_atoms, i, j, k, l, m, n;
const int64_t *rot_map_syms, const int64_t num_atom,
const int64_t num_site_sym, const int64_t num_disp) {
int64_t i_atoms, i, j, k, l, m, n;
double(*rot_delta_fc2s)[3][3];
rot_delta_fc2s =
@ -120,9 +122,9 @@ void fc3_rotate_delta_fc2(double (*fc3)[3][3][3],
rot_delta_fc2s = NULL;
}
void fc3_set_permutation_symmetry_fc3(double *fc3, const long num_atom) {
void fc3_set_permutation_symmetry_fc3(double *fc3, const int64_t num_atom) {
double fc3_elem[27];
long i, j, k;
int64_t i, j, k;
#ifdef _OPENMP
#pragma omp parallel for private(j, k, fc3_elem)
@ -139,17 +141,20 @@ void fc3_set_permutation_symmetry_fc3(double *fc3, const long num_atom) {
}
}
void fc3_set_permutation_symmetry_compact_fc3(
double *fc3, const long p2s[], const long s2pp[], const long nsym_list[],
const long perms[], const long n_satom, const long n_patom) {
void fc3_set_permutation_symmetry_compact_fc3(double *fc3, const int64_t p2s[],
const int64_t s2pp[],
const int64_t nsym_list[],
const int64_t perms[],
const int64_t n_satom,
const int64_t n_patom) {
set_permutation_symmetry_compact_fc3(fc3, p2s, s2pp, nsym_list, perms,
n_satom, n_patom);
}
void fc3_transpose_compact_fc3(double *fc3, const long p2s[], const long s2pp[],
const long nsym_list[], const long perms[],
const long n_satom, const long n_patom,
const long t_type) {
void fc3_transpose_compact_fc3(double *fc3, const int64_t p2s[],
const int64_t s2pp[], const int64_t nsym_list[],
const int64_t perms[], const int64_t n_satom,
const int64_t n_patom, const int64_t t_type) {
/* Three types of index permutations */
/* t_type=0: dim[0] <-> dim[1] */
/* t_type=1: dim[0] <-> dim[2] */
@ -165,13 +170,12 @@ void fc3_transpose_compact_fc3(double *fc3, const long p2s[], const long s2pp[],
}
}
static void rotate_delta_fc2s(double (*rot_delta_fc2s)[3][3], const long i_atom,
const long j_atom,
const double (*delta_fc2s)[3][3],
const double (*site_sym_cart)[3][3],
const long *rot_map_sym, const long num_atom,
const long num_site_sym, const long num_disp) {
long i, j;
static void rotate_delta_fc2s(
double (*rot_delta_fc2s)[3][3], const int64_t i_atom, const int64_t j_atom,
const double (*delta_fc2s)[3][3], const double (*site_sym_cart)[3][3],
const int64_t *rot_map_sym, const int64_t num_atom,
const int64_t num_site_sym, const int64_t num_disp) {
int64_t i, j;
for (i = 0; i < num_disp; i++) {
for (j = 0; j < num_site_sym; j++) {
@ -187,7 +191,7 @@ static void rotate_delta_fc2s(double (*rot_delta_fc2s)[3][3], const long i_atom,
static void tensor2_rotation(double rot_tensor[3][3], const double tensor[3][3],
const double r[3][3]) {
long i, j, k, l;
int64_t i, j, k, l;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
@ -208,7 +212,7 @@ static void tensor2_rotation(double rot_tensor[3][3], const double tensor[3][3],
static void tensor3_rotation(double *rot_tensor, const double *tensor,
const double *rot_cartesian) {
long l;
int64_t l;
for (l = 0; l < 27; l++) {
rot_tensor[l] = tensor3_rotation_elem(tensor, rot_cartesian, l);
@ -216,8 +220,8 @@ static void tensor3_rotation(double *rot_tensor, const double *tensor,
}
static double tensor3_rotation_elem(const double *tensor, const double *r,
const long pos) {
long i, j, k, l, m, n;
const int64_t pos) {
int64_t i, j, k, l, m, n;
double sum;
l = pos / 9;
@ -238,10 +242,10 @@ static double tensor3_rotation_elem(const double *tensor, const double *r,
static void copy_permutation_symmetry_fc3_elem(double *fc3,
const double fc3_elem[27],
const long a, const long b,
const long c,
const long num_atom) {
long i, j, k;
const int64_t a, const int64_t b,
const int64_t c,
const int64_t num_atom) {
int64_t i, j, k;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
@ -264,10 +268,11 @@ static void copy_permutation_symmetry_fc3_elem(double *fc3,
}
static void set_permutation_symmetry_fc3_elem(double *fc3_elem,
const double *fc3, const long a,
const long b, const long c,
const long num_atom) {
long i, j, k;
const double *fc3,
const int64_t a, const int64_t b,
const int64_t c,
const int64_t num_atom) {
int64_t i, j, k;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
@ -292,16 +297,17 @@ static void set_permutation_symmetry_fc3_elem(double *fc3_elem,
}
static void set_permutation_symmetry_compact_fc3(
double *fc3, const long p2s[], const long s2pp[], const long nsym_list[],
const long perms[], const long n_satom, const long n_patom) {
double *fc3, const int64_t p2s[], const int64_t s2pp[],
const int64_t nsym_list[], const int64_t perms[], const int64_t n_satom,
const int64_t n_patom) {
/* fc3 shape=(n_patom, n_satom, n_satom, 3, 3, 3) */
/* 1D indexing: */
/* i * n_satom * n_satom * 27 + j * n_satom * 27 + */
/* k * 27 + l * 9 + m * 3 + n */
long i, j, k, l, m, n, i_p, j_p, k_p;
long done_any;
long i_trans_j, k_trans_j, i_trans_k, j_trans_k;
long adrs[6];
int64_t i, j, k, l, m, n, i_p, j_p, k_p;
int64_t done_any;
int64_t i_trans_j, k_trans_j, i_trans_k, j_trans_k;
int64_t adrs[6];
double fc3_elem[3][3][3];
char *done;
@ -395,18 +401,16 @@ static void set_permutation_symmetry_compact_fc3(
done = NULL;
}
static void transpose_compact_fc3_type01(double *fc3, const long p2s[],
const long s2pp[],
const long nsym_list[],
const long perms[], const long n_satom,
const long n_patom,
const long t_type) {
static void transpose_compact_fc3_type01(
double *fc3, const int64_t p2s[], const int64_t s2pp[],
const int64_t nsym_list[], const int64_t perms[], const int64_t n_satom,
const int64_t n_patom, const int64_t t_type) {
/* Three types of index permutations */
/* t_type=0: dim[0] <-> dim[1] */
/* t_type=1: dim[0] <-> dim[2] */
/* t_type=2: dim[1] <-> dim[2] */
long i, j, k, l, m, n, i_p, j_p, i_trans, k_trans;
long adrs, adrs_t;
int64_t i, j, k, l, m, n, i_p, j_p, i_trans, k_trans;
int64_t adrs, adrs_t;
double fc3_elem[3][3][3];
char *done;
@ -509,13 +513,14 @@ static void transpose_compact_fc3_type01(double *fc3, const long p2s[],
done = NULL;
}
static void transpose_compact_fc3_type2(double *fc3, const long p2s[],
const long s2pp[],
const long nsym_list[],
const long perms[], const long n_satom,
const long n_patom) {
long j, k, l, m, n, i_p;
long adrs, adrs_t;
static void transpose_compact_fc3_type2(double *fc3, const int64_t p2s[],
const int64_t s2pp[],
const int64_t nsym_list[],
const int64_t perms[],
const int64_t n_satom,
const int64_t n_patom) {
int64_t j, k, l, m, n, i_p;
int64_t adrs, adrs_t;
double fc3_elem[3][3][3];
for (i_p = 0; i_p < n_patom; i_p++) {

28
c/fc3.h
View File

@ -34,22 +34,26 @@
#ifndef __fc3_H__
#define __fc3_H__
#include <stdint.h>
void fc3_distribute_fc3(double *fc3, const long target, const long source,
const long *atom_mapping, const long num_atom,
void fc3_distribute_fc3(double *fc3, const int64_t target, const int64_t source,
const int64_t *atom_mapping, const int64_t num_atom,
const double *rot_cart);
void fc3_rotate_delta_fc2(double (*fc3)[3][3][3],
const double (*delta_fc2s)[3][3], const double *inv_U,
const double (*site_sym_cart)[3][3],
const long *rot_map_syms, const long num_atom,
const long num_site_sym, const long num_disp);
void fc3_set_permutation_symmetry_fc3(double *fc3, const long num_atom);
void fc3_set_permutation_symmetry_compact_fc3(
double *fc3, const long p2s[], const long s2pp[], const long nsym_list[],
const long perms[], const long n_satom, const long n_patom);
void fc3_transpose_compact_fc3(double *fc3, const long p2s[], const long s2pp[],
const long nsym_list[], const long perms[],
const long n_satom, const long n_patom,
const long t_type);
const int64_t *rot_map_syms, const int64_t num_atom,
const int64_t num_site_sym, const int64_t num_disp);
void fc3_set_permutation_symmetry_fc3(double *fc3, const int64_t num_atom);
void fc3_set_permutation_symmetry_compact_fc3(double *fc3, const int64_t p2s[],
const int64_t s2pp[],
const int64_t nsym_list[],
const int64_t perms[],
const int64_t n_satom,
const int64_t n_patom);
void fc3_transpose_compact_fc3(double *fc3, const int64_t p2s[],
const int64_t s2pp[], const int64_t nsym_list[],
const int64_t perms[], const int64_t n_satom,
const int64_t n_patom, const int64_t t_type);
#endif

View File

@ -36,6 +36,7 @@
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include "lagrid.h"
@ -43,29 +44,35 @@
#define IDENTITY_TOL 1e-5
static void reduce_grid_address(long address[3], const long D_diag[3]);
static long get_double_grid_index(const long address_double[3],
const long D_diag[3], const long PS[3]);
static long get_grid_index_from_address(const long address[3],
const long D_diag[3]);
static void get_all_grid_addresses(long grid_address[][3],
const long D_diag[3]);
static void get_grid_address_from_index(long address[3], const long grid_index,
const long D_diag[3]);
static void get_grid_address(long address[3], const long address_double[3],
const long PS[3]);
static void get_double_grid_address(long address_double[3],
const long address[3], const long PS[3]);
static long rotate_grid_index(const long grid_index, const long rotation[3][3],
const long D_diag[3], const long PS[3]);
static void 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]);
static void reduce_grid_address(int64_t address[3], const int64_t D_diag[3]);
static int64_t get_double_grid_index(const int64_t address_double[3],
const int64_t D_diag[3],
const int64_t PS[3]);
static int64_t get_grid_index_from_address(const int64_t address[3],
const int64_t D_diag[3]);
static void get_all_grid_addresses(int64_t grid_address[][3],
const int64_t D_diag[3]);
static void get_grid_address_from_index(int64_t address[3],
const int64_t grid_index,
const int64_t D_diag[3]);
static void get_grid_address(int64_t address[3],
const int64_t address_double[3],
const int64_t PS[3]);
static void get_double_grid_address(int64_t address_double[3],
const int64_t address[3],
const int64_t PS[3]);
static int64_t rotate_grid_index(const int64_t grid_index,
const int64_t rotation[3][3],
const int64_t D_diag[3], const int64_t PS[3]);
static void get_ir_grid_map(int64_t *ir_grid_map,
const int64_t (*rotations)[3][3],
const int64_t num_rot, const int64_t D_diag[3],
const int64_t PS[3]);
long grg_get_snf3x3(long D_diag[3], long P[3][3], long Q[3][3],
const long A[3][3]) {
long i, j, succeeded;
long D[3][3];
int64_t grg_get_snf3x3(int64_t D_diag[3], int64_t P[3][3], int64_t Q[3][3],
const int64_t A[3][3]) {
int64_t i, j, succeeded;
int64_t D[3][3];
succeeded = 0;
@ -96,10 +103,11 @@ err:
/* Defined as q' = Rq where q is in the reciprocal primitive basis */
/* vectors. */
/* num_rot : Number of rotations */
long grg_transform_rotations(long (*transformed_rots)[3][3],
const long (*rotations)[3][3], const long num_rot,
const long D_diag[3], const long Q[3][3]) {
long i, j, k;
int64_t grg_transform_rotations(int64_t (*transformed_rots)[3][3],
const int64_t (*rotations)[3][3],
const int64_t num_rot, const int64_t D_diag[3],
const int64_t Q[3][3]) {
int64_t i, j, k;
double r[3][3], Q_double[3][3];
/* Compute D(Q^-1)RQ(D^-1) by three steps */
@ -132,7 +140,8 @@ long grg_transform_rotations(long (*transformed_rots)[3][3],
/* -------------------------------*/
/* address : Single grid address. */
/* D_diag : Diagnal elements of D. */
void grg_get_all_grid_addresses(long (*grid_address)[3], const long D_diag[3]) {
void grg_get_all_grid_addresses(int64_t (*grid_address)[3],
const int64_t D_diag[3]) {
get_all_grid_addresses(grid_address, D_diag);
}
@ -144,8 +153,9 @@ void grg_get_all_grid_addresses(long (*grid_address)[3], const long D_diag[3]) {
/* address_double : Double grid address. */
/* address : Single grid address. */
/* PS : Shifts transformed by P. s_i is 0 or 1. */
void grg_get_double_grid_address(long address_double[3], const long address[3],
const long PS[3]) {
void grg_get_double_grid_address(int64_t address_double[3],
const int64_t address[3],
const int64_t PS[3]) {
get_double_grid_address(address_double, address, PS);
}
@ -157,8 +167,8 @@ void grg_get_double_grid_address(long address_double[3], const long address[3],
/* address : Single grid address. */
/* address_double : Double grid address. */
/* PS : Shifts transformed by P. s_i is 0 or 1. */
void grg_get_grid_address(long address[3], const long address_double[3],
const long PS[3]) {
void grg_get_grid_address(int64_t address[3], const int64_t address_double[3],
const int64_t PS[3]) {
get_grid_address(address, address_double, PS);
}
@ -168,8 +178,9 @@ void grg_get_grid_address(long address[3], const long address_double[3],
/* address_double : Double grid address. */
/* D_diag : Diagnal elements of D. */
/* PS : Shifts transformed by P. s_i is 0 or 1. */
long grg_get_double_grid_index(const long address_double[3],
const long D_diag[3], const long PS[3]) {
int64_t grg_get_double_grid_index(const int64_t address_double[3],
const int64_t D_diag[3],
const int64_t PS[3]) {
return get_double_grid_index(address_double, D_diag, PS);
}
@ -178,8 +189,8 @@ long grg_get_double_grid_index(const long address_double[3],
/* -------------------------------------------------*/
/* address : Single grid address. */
/* D_diag : Diagnal elements of D. */
long grg_get_grid_index(const long address[3], const long D_diag[3]) {
long red_adrs[3];
int64_t grg_get_grid_index(const int64_t address[3], const int64_t D_diag[3]) {
int64_t red_adrs[3];
lagmat_copy_vector_l3(red_adrs, address);
reduce_grid_address(red_adrs, D_diag);
@ -191,25 +202,27 @@ long grg_get_grid_index(const long address[3], const long D_diag[3]) {
/* ---------------------------------------*/
/* address : Single grid address. */
/* D_diag : Diagnal elements of D. */
void grg_get_grid_address_from_index(long address[3], const long grid_index,
const long D_diag[3]) {
void grg_get_grid_address_from_index(int64_t address[3],
const int64_t grid_index,
const int64_t D_diag[3]) {
get_grid_address_from_index(address, grid_index, D_diag);
}
/* ---------------------------*/
/* Rotate grid point by index */
/* ---------------------------*/
long grg_rotate_grid_index(const long grid_index, const long rotation[3][3],
const long D_diag[3], const long PS[3]) {
int64_t grg_rotate_grid_index(const int64_t grid_index,
const int64_t rotation[3][3],
const int64_t D_diag[3], const int64_t PS[3]) {
return rotate_grid_index(grid_index, rotation, D_diag, PS);
}
/* -----------------------------*/
/* Find irreducible grid points */
/* -----------------------------*/
void grg_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]) {
void grg_get_ir_grid_map(int64_t *ir_grid_map, const int64_t (*rotations)[3][3],
const int64_t num_rot, const int64_t D_diag[3],
const int64_t PS[3]) {
get_ir_grid_map(ir_grid_map, rotations, num_rot, D_diag, PS);
}
@ -221,15 +234,15 @@ void grg_get_ir_grid_map(long *ir_grid_map, const long (*rotations)[3][3],
/* is_time_reversal controls if inversion is added in the group of */
/* reciprocal space rotations. */
/* Return 0 if failed */
long grg_get_reciprocal_point_group(long rec_rotations[48][3][3],
const long (*rotations)[3][3],
const long num_rot,
const long is_time_reversal,
const long is_transpose)
int64_t grg_get_reciprocal_point_group(int64_t rec_rotations[48][3][3],
const int64_t (*rotations)[3][3],
const int64_t num_rot,
const int64_t is_time_reversal,
const int64_t is_transpose)
{
long i, j, num_rot_ret, inv_exist;
const long inversion[3][3] = {{-1, 0, 0}, {0, -1, 0}, {0, 0, -1}};
int64_t i, j, num_rot_ret, inv_exist;
const int64_t inversion[3][3] = {{-1, 0, 0}, {0, -1, 0}, {0, 0, -1}};
/* Collect unique rotations */
num_rot_ret = 0;
@ -281,17 +294,18 @@ err:
return 0;
}
static void reduce_grid_address(long address[3], const long D_diag[3]) {
long i;
static void reduce_grid_address(int64_t address[3], const int64_t D_diag[3]) {
int64_t i;
for (i = 0; i < 3; i++) {
address[i] = lagmat_modulo_l(address[i], D_diag[i]);
}
}
static long get_double_grid_index(const long address_double[3],
const long D_diag[3], const long PS[3]) {
long address[3];
static int64_t get_double_grid_index(const int64_t address_double[3],
const int64_t D_diag[3],
const int64_t PS[3]) {
int64_t address[3];
get_grid_address(address, address_double, PS);
reduce_grid_address(address, D_diag);
@ -302,8 +316,8 @@ static long get_double_grid_index(const long address_double[3],
/* Therefore reduction to interval [0, D_diag[i]) has to be */
/* done outside of this function. */
/* See kgrid.h about GRID_ORDER_XYZ information. */
static long get_grid_index_from_address(const long address[3],
const long D_diag[3]) {
static int64_t get_grid_index_from_address(const int64_t address[3],
const int64_t D_diag[3]) {
#ifndef GRID_ORDER_XYZ
return (address[2] * D_diag[0] * D_diag[1] + address[1] * D_diag[0] +
address[0]);
@ -313,10 +327,10 @@ static long get_grid_index_from_address(const long address[3],
#endif
}
static void get_all_grid_addresses(long grid_address[][3],
const long D_diag[3]) {
long i, j, k, grid_index;
long address[3];
static void get_all_grid_addresses(int64_t grid_address[][3],
const int64_t D_diag[3]) {
int64_t i, j, k, grid_index;
int64_t address[3];
for (i = 0; i < D_diag[0]; i++) {
address[0] = i;
@ -332,9 +346,10 @@ static void get_all_grid_addresses(long grid_address[][3],
}
/* See grg_get_grid_address_from_index */
static void get_grid_address_from_index(long address[3], const long grid_index,
const long D_diag[3]) {
long nn;
static void get_grid_address_from_index(int64_t address[3],
const int64_t grid_index,
const int64_t D_diag[3]) {
int64_t nn;
#ifndef GRID_ORDER_XYZ
nn = D_diag[0] * D_diag[1];
@ -351,9 +366,10 @@ static void get_grid_address_from_index(long address[3], const long grid_index,
/* Usually address has to be reduced to [0, D_diag[i]) */
/* by calling reduce_grid_address after this operation. */
static void get_grid_address(long address[3], const long address_double[3],
const long PS[3]) {
long i;
static void get_grid_address(int64_t address[3],
const int64_t address_double[3],
const int64_t PS[3]) {
int64_t i;
for (i = 0; i < 3; i++) {
address[i] = (address_double[i] - PS[i]) / 2;
@ -362,18 +378,20 @@ static void get_grid_address(long address[3], const long address_double[3],
/* Usually address_double has to be reduced to [0, 2*D_diag[i]) */
/* by calling reduce_double_grid_address after this operation. */
static void get_double_grid_address(long address_double[3],
const long address[3], const long PS[3]) {
long i;
static void get_double_grid_address(int64_t address_double[3],
const int64_t address[3],
const int64_t PS[3]) {
int64_t i;
for (i = 0; i < 3; i++) {
address_double[i] = address[i] * 2 + PS[i];
}
}
static long rotate_grid_index(const long grid_index, const long rotation[3][3],
const long D_diag[3], const long PS[3]) {
long adrs[3], dadrs[3], dadrs_rot[3];
static int64_t rotate_grid_index(const int64_t grid_index,
const int64_t rotation[3][3],
const int64_t D_diag[3], const int64_t PS[3]) {
int64_t adrs[3], dadrs[3], dadrs_rot[3];
get_grid_address_from_index(adrs, grid_index, D_diag);
get_double_grid_address(dadrs, adrs, PS);
@ -384,11 +402,12 @@ static long rotate_grid_index(const long grid_index, const long rotation[3][3],
/* Find ir-grid points. */
/* This algorithm relies on the ir-grid index is always smallest */
/* number among symmetrically equivalent grid points. */
static void 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]) {
long gp, num_gp, r_gp;
long i;
static void get_ir_grid_map(int64_t *ir_grid_map,
const int64_t (*rotations)[3][3],
const int64_t num_rot, const int64_t D_diag[3],
const int64_t PS[3]) {
int64_t gp, num_gp, r_gp;
int64_t i;
num_gp = D_diag[0] * D_diag[1] * D_diag[2];

View File

@ -36,31 +36,36 @@
#define __grgrid_H__
#include <stddef.h>
#include <stdint.h>
long grg_get_snf3x3(long D_diag[3], long P[3][3], long Q[3][3],
const long A[3][3]);
long grg_transform_rotations(long (*transformed_rots)[3][3],
const long (*rotations)[3][3], const long num_rot,
const long D_diag[3], const long Q[3][3]);
void grg_get_all_grid_addresses(long (*grid_address)[3], const long D_diag[3]);
void grg_get_double_grid_address(long address_double[3], const long address[3],
const long PS[3]);
void grg_get_grid_address(long address[3], const long address_double[3],
const long PS[3]);
long grg_get_grid_index(const long address[3], const long D_diag[3]);
long grg_get_double_grid_index(const long address_double[3],
const long D_diag[3], const long PS[3]);
void grg_get_grid_address_from_index(long address[3], const long grid_index,
const long D_diag[3]);
long grg_rotate_grid_index(const long grid_index, const long rotations[3][3],
const long D_diag[3], const long PS[3]);
void grg_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]);
long grg_get_reciprocal_point_group(long rec_rotations[48][3][3],
const long (*rotations)[3][3],
const long num_rot,
const long is_time_reversal,
const long is_transpose);
int64_t grg_get_snf3x3(int64_t D_diag[3], int64_t P[3][3], int64_t Q[3][3],
const int64_t A[3][3]);
int64_t grg_transform_rotations(int64_t (*transformed_rots)[3][3],
const int64_t (*rotations)[3][3],
const int64_t num_rot, const int64_t D_diag[3],
const int64_t Q[3][3]);
void grg_get_all_grid_addresses(int64_t (*grid_address)[3],
const int64_t D_diag[3]);
void grg_get_double_grid_address(int64_t address_double[3],
const int64_t address[3], const int64_t PS[3]);
void grg_get_grid_address(int64_t address[3], const int64_t address_double[3],
const int64_t PS[3]);
int64_t grg_get_grid_index(const int64_t address[3], const int64_t D_diag[3]);
int64_t grg_get_double_grid_index(const int64_t address_double[3],
const int64_t D_diag[3], const int64_t PS[3]);
void grg_get_grid_address_from_index(int64_t address[3],
const int64_t grid_index,
const int64_t D_diag[3]);
int64_t grg_rotate_grid_index(const int64_t grid_index,
const int64_t rotations[3][3],
const int64_t D_diag[3], const int64_t PS[3]);
void grg_get_ir_grid_map(int64_t *ir_grid_map, const int64_t (*rotations)[3][3],
const int64_t num_rot, const int64_t D_diag[3],
const int64_t PS[3]);
int64_t grg_get_reciprocal_point_group(int64_t rec_rotations[48][3][3],
const int64_t (*rotations)[3][3],
const int64_t num_rot,
const int64_t is_time_reversal,
const int64_t is_transpose);
#endif

View File

@ -34,6 +34,7 @@
#include "gridsys.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@ -48,73 +49,79 @@
#define GRIDSYS_NIGGLI_TOLERANCE 1e-5
void gridsys_get_all_grid_addresses(long (*gr_grid_addresses)[3],
const long D_diag[3]) {
void gridsys_get_all_grid_addresses(int64_t (*gr_grid_addresses)[3],
const int64_t D_diag[3]) {
grg_get_all_grid_addresses(gr_grid_addresses, D_diag);
}
void gridsys_get_double_grid_address(long address_double[3],
const long address[3], const long PS[3]) {
void gridsys_get_double_grid_address(int64_t address_double[3],
const int64_t address[3],
const int64_t PS[3]) {
grg_get_double_grid_address(address_double, address, PS);
}
void gridsys_get_grid_address_from_index(long address[3], const long grid_index,
const long D_diag[3]) {
void gridsys_get_grid_address_from_index(int64_t address[3],
const int64_t grid_index,
const int64_t D_diag[3]) {
grg_get_grid_address_from_index(address, grid_index, D_diag);
}
long gridsys_get_double_grid_index(const long address_double[3],
const long D_diag[3], const long PS[3]) {
int64_t gridsys_get_double_grid_index(const int64_t address_double[3],
const int64_t D_diag[3],
const int64_t PS[3]) {
return grg_get_double_grid_index(address_double, D_diag, PS);
}
long gridsys_get_grid_index_from_address(const long address[3],
const long D_diag[3]) {
int64_t gridsys_get_grid_index_from_address(const int64_t address[3],
const int64_t D_diag[3]) {
return grg_get_grid_index(address, D_diag);
}
long gridsys_rotate_grid_index(const long grid_index, const long rotation[3][3],
const long D_diag[3], const long PS[3]) {
int64_t gridsys_rotate_grid_index(const int64_t grid_index,
const int64_t rotation[3][3],
const int64_t D_diag[3],
const int64_t PS[3]) {
return grg_rotate_grid_index(grid_index, rotation, D_diag, PS);
}
long gridsys_get_reciprocal_point_group(long rec_rotations[48][3][3],
const long (*rotations)[3][3],
const long num_rot,
const long is_time_reversal) {
int64_t gridsys_get_reciprocal_point_group(int64_t rec_rotations[48][3][3],
const int64_t (*rotations)[3][3],
const int64_t num_rot,
const int64_t is_time_reversal) {
return grg_get_reciprocal_point_group(rec_rotations, rotations, num_rot,
is_time_reversal, 1);
}
long gridsys_get_snf3x3(long D_diag[3], long P[3][3], long Q[3][3],
const long A[3][3]) {
int64_t gridsys_get_snf3x3(int64_t D_diag[3], int64_t P[3][3], int64_t Q[3][3],
const int64_t A[3][3]) {
return grg_get_snf3x3(D_diag, P, Q, A);
}
long gridsys_transform_rotations(long (*transformed_rots)[3][3],
const long (*rotations)[3][3],
const long num_rot, const long D_diag[3],
const long Q[3][3]) {
long succeeded;
int64_t gridsys_transform_rotations(int64_t (*transformed_rots)[3][3],
const int64_t (*rotations)[3][3],
const int64_t num_rot,
const int64_t D_diag[3],
const int64_t Q[3][3]) {
int64_t succeeded;
succeeded = grg_transform_rotations(transformed_rots, rotations, num_rot,
D_diag, Q);
return succeeded;
}
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]) {
void gridsys_get_ir_grid_map(int64_t *ir_grid_map,
const int64_t (*rotations)[3][3],
const int64_t num_rot, const int64_t D_diag[3],
const int64_t PS[3]) {
grg_get_ir_grid_map(ir_grid_map, rotations, num_rot, D_diag, PS);
}
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],
const double rec_lattice[3][3],
const long bz_grid_type) {
int64_t gridsys_get_bz_grid_addresses(
int64_t (*bz_grid_addresses)[3], int64_t *bz_map, int64_t *bzg2grg,
const int64_t D_diag[3], const int64_t Q[3][3], const int64_t PS[3],
const double rec_lattice[3][3], const int64_t bz_grid_type) {
RecgridBZGrid *bzgrid;
long i, j, size;
long inv_Mpr_int[3][3];
int64_t i, j, size;
int64_t inv_Mpr_int[3][3];
double inv_Lr[3][3], inv_Mpr[3][3];
double niggli_lattice[9];
@ -167,13 +174,12 @@ long gridsys_get_bz_grid_addresses(long (*bz_grid_addresses)[3], long *bz_map,
return size;
}
long gridsys_rotate_bz_grid_index(const long bz_grid_index,
const long rotation[3][3],
const long (*bz_grid_addresses)[3],
const long *bz_map, const long D_diag[3],
const long PS[3], const long bz_grid_type) {
int64_t gridsys_rotate_bz_grid_index(
const int64_t bz_grid_index, const int64_t rotation[3][3],
const int64_t (*bz_grid_addresses)[3], const int64_t *bz_map,
const int64_t D_diag[3], const int64_t PS[3], const int64_t bz_grid_type) {
RecgridConstBZGrid *bzgrid;
long i, rot_bz_gp;
int64_t i, rot_bz_gp;
if ((bzgrid = (RecgridConstBZGrid *)malloc(sizeof(RecgridConstBZGrid))) ==
NULL) {
@ -197,25 +203,26 @@ long gridsys_rotate_bz_grid_index(const long bz_grid_index,
return rot_bz_gp;
}
long gridsys_get_triplets_at_q(long *map_triplets, long *map_q,
const long grid_point, const long D_diag[3],
const long is_time_reversal, const long num_rot,
const long (*rec_rotations)[3][3],
const long swappable) {
int64_t gridsys_get_triplets_at_q(int64_t *map_triplets, int64_t *map_q,
const int64_t grid_point,
const int64_t D_diag[3],
const int64_t is_time_reversal,
const int64_t num_rot,
const int64_t (*rec_rotations)[3][3],
const int64_t swappable) {
return tpl_get_triplets_reciprocal_mesh_at_q(
map_triplets, map_q, grid_point, D_diag, is_time_reversal, num_rot,
rec_rotations, swappable);
}
long gridsys_get_bz_triplets_at_q(long (*ir_triplets)[3],
const long bz_grid_index,
const long (*bz_grid_addresses)[3],
const long *bz_map, const long *map_triplets,
const long num_map_triplets,
const long D_diag[3], const long Q[3][3],
const long bz_grid_type) {
int64_t gridsys_get_bz_triplets_at_q(
int64_t (*ir_triplets)[3], const int64_t bz_grid_index,
const int64_t (*bz_grid_addresses)[3], const int64_t *bz_map,
const int64_t *map_triplets, const int64_t num_map_triplets,
const int64_t D_diag[3], const int64_t Q[3][3],
const int64_t bz_grid_type) {
RecgridConstBZGrid *bzgrid;
long i, j, num_ir;
int64_t i, j, num_ir;
if ((bzgrid = (RecgridConstBZGrid *)malloc(sizeof(RecgridConstBZGrid))) ==
NULL) {
@ -250,28 +257,29 @@ double gridsys_get_thm_integration_weight(const double omega,
}
void gridsys_get_thm_all_relative_grid_address(
long relative_grid_address[4][24][4][3]) {
int64_t relative_grid_address[4][24][4][3]) {
thm_get_all_relative_grid_address(relative_grid_address);
}
long gridsys_get_thm_relative_grid_address(
long relative_grid_addresses[24][4][3], const double rec_lattice[3][3]) {
int64_t gridsys_get_thm_relative_grid_address(
int64_t relative_grid_addresses[24][4][3], const double rec_lattice[3][3]) {
return thm_get_relative_grid_address(relative_grid_addresses, rec_lattice);
}
/* relative_grid_addresses are given as P multipled with those from */
/* dataset, i.e., */
/* np.dot(relative_grid_addresses, P.T) */
long gridsys_get_integration_weight(
int64_t gridsys_get_integration_weight(
double *iw, char *iw_zero, const double *frequency_points,
const long num_band0, const long relative_grid_address[24][4][3],
const long D_diag[3], const long (*triplets)[3], const long num_triplets,
const long (*bz_grid_addresses)[3], const long *bz_map,
const long bz_grid_type, const double *frequencies1, const long num_band1,
const double *frequencies2, const long num_band2, const long tp_type,
const long openmp_per_triplets) {
const int64_t num_band0, const int64_t relative_grid_address[24][4][3],
const int64_t D_diag[3], const int64_t (*triplets)[3],
const int64_t num_triplets, const int64_t (*bz_grid_addresses)[3],
const int64_t *bz_map, const int64_t bz_grid_type,
const double *frequencies1, const int64_t num_band1,
const double *frequencies2, const int64_t num_band2, const int64_t tp_type,
const int64_t openmp_per_triplets) {
RecgridConstBZGrid *bzgrid;
long i;
int64_t i;
if ((bzgrid = (RecgridConstBZGrid *)malloc(sizeof(RecgridConstBZGrid))) ==
NULL) {
@ -298,9 +306,9 @@ long gridsys_get_integration_weight(
void gridsys_get_integration_weight_with_sigma(
double *iw, char *iw_zero, const double sigma, const double sigma_cutoff,
const double *frequency_points, const long num_band0,
const long (*triplets)[3], const long num_triplets,
const double *frequencies, const long num_band, const long tp_type) {
const double *frequency_points, const int64_t num_band0,
const int64_t (*triplets)[3], const int64_t num_triplets,
const double *frequencies, const int64_t num_band, const int64_t tp_type) {
tpl_get_integration_weight_with_sigma(
iw, iw_zero, sigma, sigma_cutoff, frequency_points, num_band0, triplets,
num_triplets, frequencies, num_band, tp_type);

View File

@ -38,6 +38,7 @@
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
/* Generalized regular (GR) grid
@ -46,7 +47,7 @@ by D = P M_g Q, which can be achieved by Smith normal form like transformation.
P and Q used are integer unimodular matrices with determinant=1.
S in PS is doubled shift with respect to microzone basis vectors, i.e.,
half-grid shift along an axis corresponds to 1.
half-grid shift aint64_t an axis corresponds to 1.
*/
@ -54,11 +55,11 @@ half-grid shift along an axis corresponds to 1.
* @brief Return all GR-grid addresses with respect to n_1, n_2, n_3
*
* @param gr_grid_addresses All GR-grid addresses
* @param D_diag Numbers of divisions along a, b, c directions of GR-grid
* @param D_diag Numbers of divisions aint64_t a, b, c directions of GR-grid
* @return void
*/
void gridsys_get_all_grid_addresses(long (*gr_grid_addresses)[3],
const long D_diag[3]);
void gridsys_get_all_grid_addresses(int64_t (*gr_grid_addresses)[3],
const int64_t D_diag[3]);
/**
* @brief Return double grid address in GR-grid
@ -69,53 +70,57 @@ void gridsys_get_all_grid_addresses(long (*gr_grid_addresses)[3],
* @param PS Shift in GR-grid
* @return void
*/
void gridsys_get_double_grid_address(long address_double[3],
const long address[3], const long PS[3]);
void gridsys_get_double_grid_address(int64_t address_double[3],
const int64_t address[3],
const int64_t PS[3]);
/**
* @brief Return single grid address in GR-grid with given grid point index.
*
* @param address Single grid address in GR-grid
* @param grid_index Grid point index in GR-grid
* @param D_diag Numbers of divisions along a, b, c directions of GR-grid
* @param D_diag Numbers of divisions aint64_t a, b, c directions of GR-grid
* @return void
*/
void gridsys_get_grid_address_from_index(long address[3], const long grid_index,
const long D_diag[3]);
void gridsys_get_grid_address_from_index(int64_t address[3],
const int64_t grid_index,
const int64_t D_diag[3]);
/**
* @brief Return grid point index of double grid address in GR-grid
*
* @param address_double Double grid address, i.e., possibly with shift in
* GR-grid
* @param D_diag Numbers of divisions along a, b, c directions of GR-grid
* @param D_diag Numbers of divisions aint64_t a, b, c directions of GR-grid
* @param PS Shift in GR-grid
* @return long
* @return int64_t
*/
long gridsys_get_double_grid_index(const long address_double[3],
const long D_diag[3], const long PS[3]);
int64_t gridsys_get_double_grid_index(const int64_t address_double[3],
const int64_t D_diag[3],
const int64_t PS[3]);
/**
* @brief Return grid point index of single grid address in GR-grid
*
* @param address Single grid address in GR-grid
* @param D_diag Numbers of divisions along a, b, c directions of GR-grid
* @return long
* @param D_diag Numbers of divisions aint64_t a, b, c directions of GR-grid
* @return int64_t
*/
long gridsys_get_grid_index_from_address(const long address[3],
const long D_diag[3]);
int64_t gridsys_get_grid_index_from_address(const int64_t address[3],
const int64_t D_diag[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 Transformed rotation in reciprocal space tilde-R^T
* @param D_diag Numbers of divisions along a, b, c directions of GR-grid
* @param D_diag Numbers of divisions aint64_t a, b, c directions of GR-grid
* @param PS Shift in GR-grid
* @return long
* @return int64_t
*/
long gridsys_rotate_grid_index(const long grid_index, const long rotation[3][3],
const long D_diag[3], const long PS[3]);
int64_t gridsys_rotate_grid_index(const int64_t grid_index,
const int64_t rotation[3][3],
const int64_t D_diag[3], const int64_t PS[3]);
/**
* @brief Return {R^T} of crystallographic point group {R} with and without time
@ -125,12 +130,12 @@ long gridsys_rotate_grid_index(const long grid_index, const long rotation[3][3],
* @param rotations Rotations in direct space {R}
* @param num_rot Number of given rotations |{R}|
* @param is_time_reversal With (1) or without (0) time reversal symmetry
* @return long
* @return int64_t
*/
long gridsys_get_reciprocal_point_group(long rec_rotations[48][3][3],
const long (*rotations)[3][3],
const long num_rot,
const long is_time_reversal);
int64_t gridsys_get_reciprocal_point_group(int64_t rec_rotations[48][3][3],
const int64_t (*rotations)[3][3],
const int64_t num_rot,
const int64_t is_time_reversal);
/**
* @brief Return D, P, Q of Smith normal form of A.
@ -139,10 +144,10 @@ long gridsys_get_reciprocal_point_group(long rec_rotations[48][3][3],
* @param P Unimodular matrix P
* @param Q Unimodular matrix Q
* @param A Integer matrix
* @return long
* @return int64_t
*/
long gridsys_get_snf3x3(long D_diag[3], long P[3][3], long Q[3][3],
const long A[3][3]);
int64_t gridsys_get_snf3x3(int64_t D_diag[3], int64_t P[3][3], int64_t Q[3][3],
const int64_t A[3][3]);
/**
* @brief Transform {R^T} to {R^T} with respect to transformed microzone basis
@ -154,12 +159,13 @@ long gridsys_get_snf3x3(long D_diag[3], long P[3][3], long Q[3][3],
* @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
* @return long
* @return int64_t
*/
long gridsys_transform_rotations(long (*transformed_rots)[3][3],
const long (*rotations)[3][3],
const long num_rot, const long D_diag[3],
const long Q[3][3]);
int64_t gridsys_transform_rotations(int64_t (*transformed_rots)[3][3],
const int64_t (*rotations)[3][3],
const int64_t num_rot,
const int64_t D_diag[3],
const int64_t Q[3][3]);
/**
* @brief Return mapping table from GR-grid points to GR-ir-grid points
@ -171,9 +177,10 @@ long gridsys_transform_rotations(long (*transformed_rots)[3][3],
* @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]);
void gridsys_get_ir_grid_map(int64_t *ir_grid_map,
const int64_t (*rotations)[3][3],
const int64_t num_rot, const int64_t D_diag[3],
const int64_t PS[3]);
/**
* @brief Find shortest grid points from Gamma considering periodicity of
@ -192,13 +199,12 @@ void gridsys_get_ir_grid_map(long *ir_grid_map, const long (*rotations)[3][3],
* @param rec_lattice Reduced reciprocal basis vectors in column vectors
* @param bz_grid_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.
* @return int64_t 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],
const double rec_lattice[3][3],
const long bz_grid_type);
int64_t gridsys_get_bz_grid_addresses(
int64_t (*bz_grid_addresses)[3], int64_t *bz_map, int64_t *bzg2grg,
const int64_t D_diag[3], const int64_t Q[3][3], const int64_t PS[3],
const double rec_lattice[3][3], const int64_t bz_grid_type);
/**
* @brief Return index of rotated bz grid point
@ -209,17 +215,16 @@ long gridsys_get_bz_grid_addresses(long (*bz_grid_addresses)[3], long *bz_map,
* @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 D_diag Numbers of divisions along a, b, c directions of GR-grid
* @param D_diag Numbers of divisions aint64_t a, b, c directions of GR-grid
* @param PS Shift in GR-grid
* @param bz_grid_type Data structure type I (old and sparse) or II (new and
* dense, recommended) of bz_map
* @return long
* @return int64_t
*/
long gridsys_rotate_bz_grid_index(const long bz_grid_index,
const long rotation[3][3],
const long (*bz_grid_addresses)[3],
const long *bz_map, const long D_diag[3],
const long PS[3], const long bz_grid_type);
int64_t gridsys_rotate_bz_grid_index(
const int64_t bz_grid_index, const int64_t rotation[3][3],
const int64_t (*bz_grid_addresses)[3], const int64_t *bz_map,
const int64_t D_diag[3], const int64_t PS[3], const int64_t bz_grid_type);
/**
* @brief Find independent q' of (q, q', q'') with given q.
@ -235,13 +240,15 @@ long gridsys_rotate_bz_grid_index(const long bz_grid_index,
* @param rec_rotations Transformed rotation matrices in reciprocal space
* @param swappable With (1) or without (0) permutation symmetry between q'
* and q''
* @return long Number of unique element of map_triplets
* @return int64_t Number of unique element of map_triplets
*/
long gridsys_get_triplets_at_q(long *map_triplets, long *map_q,
const long grid_index, const long D_diag[3],
const long is_time_reversal, const long num_rot,
const long (*rec_rotations)[3][3],
const long swappable);
int64_t gridsys_get_triplets_at_q(int64_t *map_triplets, int64_t *map_q,
const int64_t grid_index,
const int64_t D_diag[3],
const int64_t is_time_reversal,
const int64_t num_rot,
const int64_t (*rec_rotations)[3][3],
const int64_t swappable);
/**
* @brief Search grid point triplets considering BZ surface.
@ -259,15 +266,13 @@ long gridsys_get_triplets_at_q(long *map_triplets, long *map_q,
* @param Q Unimodular matrix Q of Smith normal form
* @param bz_grid_type Data structure type I (old and sparse) or II (new and
* dense, recommended) of bz_map
* @return long
* @return int64_t
*/
long gridsys_get_bz_triplets_at_q(long (*ir_triplets)[3],
const long bz_grid_index,
const long (*bz_grid_addresses)[3],
const long *bz_map, const long *map_triplets,
const long num_map_triplets,
const long D_diag[3], const long Q[3][3],
const long bz_grid_type);
int64_t gridsys_get_bz_triplets_at_q(
int64_t (*ir_triplets)[3], const int64_t bz_grid_index,
const int64_t (*bz_grid_addresses)[3], const int64_t *bz_map,
const int64_t *map_triplets, const int64_t num_map_triplets,
const int64_t D_diag[3], const int64_t Q[3][3], const int64_t bz_grid_type);
/**
* @brief Return integration weight of linear tetrahedron method
@ -289,7 +294,7 @@ double gridsys_get_thm_integration_weight(const double omega,
* tetrahedron method
*/
void gridsys_get_thm_all_relative_grid_address(
long relative_grid_address[4][24][4][3]);
int64_t relative_grid_address[4][24][4][3]);
/**
* @brief Return predefined relative grid addresses of main diagonal determined
@ -298,24 +303,25 @@ void gridsys_get_thm_all_relative_grid_address(
* @param relative_grid_addresses predefined relative grid addresses of given
* reciprocal basis vectors
* @param rec_lattice Reciprocal basis vectors in column vectors
* @return * long
* @return * int64_t
*/
long gridsys_get_thm_relative_grid_address(
long relative_grid_addresses[24][4][3], const double rec_lattice[3][3]);
int64_t gridsys_get_thm_relative_grid_address(
int64_t relative_grid_addresses[24][4][3], const double rec_lattice[3][3]);
long gridsys_get_integration_weight(
int64_t gridsys_get_integration_weight(
double *iw, char *iw_zero, const double *frequency_points,
const long num_band0, const long relative_grid_address[24][4][3],
const long D_diag[3], const long (*triplets)[3], const long num_triplets,
const long (*bz_grid_addresses)[3], const long *bz_map,
const long bz_grid_type, const double *frequencies1, const long num_band1,
const double *frequencies2, const long num_band2, const long tp_type,
const long openmp_per_triplets);
const int64_t num_band0, const int64_t relative_grid_address[24][4][3],
const int64_t D_diag[3], const int64_t (*triplets)[3],
const int64_t num_triplets, const int64_t (*bz_grid_addresses)[3],
const int64_t *bz_map, const int64_t bz_grid_type,
const double *frequencies1, const int64_t num_band1,
const double *frequencies2, const int64_t num_band2, const int64_t tp_type,
const int64_t openmp_per_triplets);
void gridsys_get_integration_weight_with_sigma(
double *iw, char *iw_zero, const double sigma, const double sigma_cutoff,
const double *frequency_points, const long num_band0,
const long (*triplets)[3], const long num_triplets,
const double *frequencies, const long num_band, const long tp_type);
const double *frequency_points, const int64_t num_band0,
const int64_t (*triplets)[3], const int64_t num_triplets,
const double *frequencies, const int64_t num_band, const int64_t tp_type);
#ifdef __cplusplus
}

View File

@ -35,6 +35,7 @@
#include "imag_self_energy_with_g.h"
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@ -43,38 +44,41 @@
#include "phonoc_array.h"
#include "triplet.h"
static long set_g_pos_frequency_point(long (*g_pos)[4], const long num_band0,
const long num_band, const char *g_zero);
static int64_t set_g_pos_frequency_point(int64_t (*g_pos)[4],
const int64_t num_band0,
const int64_t num_band,
const char *g_zero);
static void detailed_imag_self_energy_at_triplet(
double *detailed_imag_self_energy, double *imag_self_energy,
const long num_band0, const long num_band, const double *fc3_normal_squared,
const double *frequencies, const long triplet[3], const double *g1,
const double *g2_3, const char *g_zero, const double *temperatures,
const long num_temps, const double cutoff_frequency);
const int64_t num_band0, const int64_t num_band,
const double *fc3_normal_squared, const double *frequencies,
const int64_t triplet[3], const double *g1, const double *g2_3,
const char *g_zero, const double *temperatures, const int64_t num_temps,
const double cutoff_frequency);
static double collect_detailed_imag_self_energy(
double *imag_self_energy, const long num_band,
double *imag_self_energy, const int64_t num_band,
const double *fc3_normal_squared, const double *n1, const double *n2,
const double *g1, const double *g2_3, const char *g_zero);
static double collect_detailed_imag_self_energy_0K(
double *imag_self_energy, const long num_band,
double *imag_self_energy, const int64_t num_band,
const double *fc3_normal_squared, const double *n1, const double *n2,
const double *g, const char *g_zero);
static void set_occupations(double *n1, double *n2, const long num_band,
const double temperature, const long triplet[3],
static void set_occupations(double *n1, double *n2, const int64_t num_band,
const double temperature, const int64_t triplet[3],
const double *frequencies,
const double cutoff_frequency);
void ise_get_imag_self_energy_with_g(
double *imag_self_energy, const Darray *fc3_normal_squared,
const double *frequencies, const long (*triplets)[3],
const long *triplet_weights, const double *g, const char *g_zero,
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplet_weights, const double *g, const char *g_zero,
const double temperature, const double cutoff_frequency,
const long num_frequency_points, const long frequency_point_index) {
long i, j, num_triplets, num_band0, num_band, num_band_prod;
long num_g_pos, g_index_dims, g_index_shift;
long(*g_pos)[4];
const int64_t num_frequency_points, const int64_t frequency_point_index) {
int64_t i, j, num_triplets, num_band0, num_band, num_band_prod;
int64_t num_g_pos, g_index_dims, g_index_shift;
int64_t(*g_pos)[4];
double *ise;
long at_a_frequency_point;
int64_t at_a_frequency_point;
g_pos = NULL;
ise = NULL;
@ -114,7 +118,7 @@ void ise_get_imag_self_energy_with_g(
* ise_set_g_pos works for frquency points as bands.
* set_g_pos_frequency_point works for frequency sampling mode.
*/
g_pos = (long(*)[4])malloc(sizeof(long[4]) * num_band_prod);
g_pos = (int64_t(*)[4])malloc(sizeof(int64_t[4]) * num_band_prod);
if (at_a_frequency_point) {
num_g_pos = set_g_pos_frequency_point(
g_pos, num_band0, num_band,
@ -154,13 +158,13 @@ void ise_get_imag_self_energy_with_g(
void ise_get_detailed_imag_self_energy_with_g(
double *detailed_imag_self_energy, double *imag_self_energy_N,
double *imag_self_energy_U, const Darray *fc3_normal_squared,
const double *frequencies, const long (*triplets)[3],
const long *triplet_weights, const long (*bz_grid_addresses)[3],
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplet_weights, const int64_t (*bz_grid_addresses)[3],
const double *g, const char *g_zero, const double temperature,
const double cutoff_frequency) {
double *ise;
long i, j, num_triplets, num_band0, num_band, num_band_prod;
long *is_N;
int64_t i, j, num_triplets, num_band0, num_band, num_band_prod;
int64_t *is_N;
double ise_tmp, N, U;
ise = NULL;
@ -186,7 +190,7 @@ void ise_get_detailed_imag_self_energy_with_g(
&temperature, 1, cutoff_frequency);
}
is_N = (long *)malloc(sizeof(long) * num_triplets);
is_N = (int64_t *)malloc(sizeof(int64_t) * num_triplets);
for (i = 0; i < num_triplets; i++) {
is_N[i] = tpl_is_N(triplets[i], bz_grid_addresses);
}
@ -216,16 +220,16 @@ void ise_get_detailed_imag_self_energy_with_g(
}
void ise_imag_self_energy_at_triplet(
double *imag_self_energy, const long num_band0, const long num_band,
double *imag_self_energy, const int64_t num_band0, const int64_t num_band,
const double *fc3_normal_squared, const double *frequencies,
const long triplet[3], const long triplet_weight, const double *g1,
const double *g2_3, const long (*g_pos)[4], const long num_g_pos,
const double *temperatures, const long num_temps,
const double cutoff_frequency, const long openmp_per_triplets,
const long at_a_frequency_point) {
long i, j;
const int64_t triplet[3], const int64_t triplet_weight, const double *g1,
const double *g2_3, const int64_t (*g_pos)[4], const int64_t num_g_pos,
const double *temperatures, const int64_t num_temps,
const double cutoff_frequency, const int64_t openmp_per_triplets,
const int64_t at_a_frequency_point) {
int64_t i, j;
double *n1, *n2, *ise_at_g_pos;
long g_pos_3;
int64_t g_pos_3;
n1 = (double *)malloc(sizeof(double) * num_temps * num_band);
n2 = (double *)malloc(sizeof(double) * num_temps * num_band);
@ -291,9 +295,9 @@ void ise_imag_self_energy_at_triplet(
n2 = NULL;
}
long ise_set_g_pos(long (*g_pos)[4], const long num_band0, const long num_band,
const char *g_zero) {
long num_g_pos, j, k, l, jkl;
int64_t ise_set_g_pos(int64_t (*g_pos)[4], const int64_t num_band0,
const int64_t num_band, const char *g_zero) {
int64_t num_g_pos, j, k, l, jkl;
num_g_pos = 0;
jkl = 0;
@ -321,11 +325,13 @@ long ise_set_g_pos(long (*g_pos)[4], const long num_band0, const long num_band,
* @param num_band0
* @param num_band
* @param g_zero
* @return long
* @return int64_t
*/
static long set_g_pos_frequency_point(long (*g_pos)[4], const long num_band0,
const long num_band, const char *g_zero) {
long num_g_pos, j, k, l, kl, jkl;
static int64_t set_g_pos_frequency_point(int64_t (*g_pos)[4],
const int64_t num_band0,
const int64_t num_band,
const char *g_zero) {
int64_t num_g_pos, j, k, l, kl, jkl;
num_g_pos = 0;
jkl = 0;
@ -350,11 +356,12 @@ static long set_g_pos_frequency_point(long (*g_pos)[4], const long num_band0,
static void detailed_imag_self_energy_at_triplet(
double *detailed_imag_self_energy, double *imag_self_energy,
const long num_band0, const long num_band, const double *fc3_normal_squared,
const double *frequencies, const long triplet[3], const double *g1,
const double *g2_3, const char *g_zero, const double *temperatures,
const long num_temps, const double cutoff_frequency) {
long i, j, adrs_shift;
const int64_t num_band0, const int64_t num_band,
const double *fc3_normal_squared, const double *frequencies,
const int64_t triplet[3], const double *g1, const double *g2_3,
const char *g_zero, const double *temperatures, const int64_t num_temps,
const double cutoff_frequency) {
int64_t i, j, adrs_shift;
double *n1, *n2;
n1 = NULL;
@ -393,10 +400,10 @@ static void detailed_imag_self_energy_at_triplet(
}
static double collect_detailed_imag_self_energy(
double *imag_self_energy, const long num_band,
double *imag_self_energy, const int64_t num_band,
const double *fc3_normal_squared, const double *n1, const double *n2,
const double *g1, const double *g2_3, const char *g_zero) {
long ij, i, j;
int64_t ij, i, j;
double sum_g;
sum_g = 0;
@ -420,10 +427,10 @@ static double collect_detailed_imag_self_energy(
}
static double collect_detailed_imag_self_energy_0K(
double *imag_self_energy, const long num_band,
double *imag_self_energy, const int64_t num_band,
const double *fc3_normal_squared, const double *n1, const double *n2,
const double *g1, const char *g_zero) {
long ij, i, j;
int64_t ij, i, j;
double sum_g;
sum_g = 0;
@ -444,11 +451,11 @@ static double collect_detailed_imag_self_energy_0K(
return sum_g;
}
static void set_occupations(double *n1, double *n2, const long num_band,
const double temperature, const long triplet[3],
static void set_occupations(double *n1, double *n2, const int64_t num_band,
const double temperature, const int64_t triplet[3],
const double *frequencies,
const double cutoff_frequency) {
long j;
int64_t j;
double f1, f2;
for (j = 0; j < num_band; j++) {

View File

@ -36,31 +36,32 @@
#define __imag_self_energy_with_g_H__
#include <stddef.h>
#include <stdint.h>
#include "phonoc_array.h"
void ise_get_imag_self_energy_with_g(
double *imag_self_energy, const Darray *fc3_normal_squared,
const double *frequencies, const long (*triplets)[3],
const long *triplet_weights, const double *g, const char *g_zero,
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplet_weights, const double *g, const char *g_zero,
const double temperature, const double cutoff_frequency,
const long num_frequency_points, const long frequency_point_index);
const int64_t num_frequency_points, const int64_t frequency_point_index);
void ise_get_detailed_imag_self_energy_with_g(
double *detailed_imag_self_energy, double *imag_self_energy_N,
double *imag_self_energy_U, const Darray *fc3_normal_squared,
const double *frequencies, const long (*triplets)[3],
const long *triplet_weights, const long (*bz_grid_addresses)[3],
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplet_weights, const int64_t (*bz_grid_addresses)[3],
const double *g, const char *g_zero, const double temperature,
const double cutoff_frequency);
void ise_imag_self_energy_at_triplet(
double *imag_self_energy, const long num_band0, const long num_band,
double *imag_self_energy, const int64_t num_band0, const int64_t num_band,
const double *fc3_normal_squared, const double *frequencies,
const long triplet[3], const long triplet_weight, const double *g1,
const double *g2_3, const long (*g_pos)[4], const long num_g_pos,
const double *temperatures, const long num_temps,
const double cutoff_frequency, const long openmp_possible,
const long at_a_frequency_point);
long ise_set_g_pos(long (*g_pos)[4], const long num_band0, const long num_band,
const char *g_zero);
const int64_t triplet[3], const int64_t triplet_weight, const double *g1,
const double *g2_3, const int64_t (*g_pos)[4], const int64_t num_g_pos,
const double *temperatures, const int64_t num_temps,
const double cutoff_frequency, const int64_t openmp_possible,
const int64_t at_a_frequency_point);
int64_t ise_set_g_pos(int64_t (*g_pos)[4], const int64_t num_band0,
const int64_t num_band, const char *g_zero);
#endif

View File

@ -34,6 +34,7 @@
#include "interaction.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@ -45,43 +46,42 @@
#include "recgrid.h"
#include "reciprocal_to_normal.h"
static const long index_exchange[6][3] = {{0, 1, 2}, {2, 0, 1}, {1, 2, 0},
{2, 1, 0}, {0, 2, 1}, {1, 0, 2}};
static void real_to_normal(double *fc3_normal_squared, const long (*g_pos)[4],
const long num_g_pos, const double *freqs0,
const double *freqs1, const double *freqs2,
const lapack_complex_double *eigvecs0,
const lapack_complex_double *eigvecs1,
const lapack_complex_double *eigvecs2,
const double *fc3, const long is_compact_fc3,
const double q_vecs[3][3], /* q0, q1, q2 */
const AtomTriplets *atom_triplets,
const double *masses, const long *band_indices,
const long num_band, const double cutoff_frequency,
const long triplet_index, const long num_triplets,
const long openmp_per_triplets);
static void real_to_normal_sym_q(
double *fc3_normal_squared, const long (*g_pos)[4], const long num_g_pos,
double *const freqs[3], lapack_complex_double *const eigvecs[3],
const double *fc3, const long is_compact_fc3,
const double q_vecs[3][3], /* q0, q1, q2 */
static const int64_t index_exchange[6][3] = {{0, 1, 2}, {2, 0, 1}, {1, 2, 0},
{2, 1, 0}, {0, 2, 1}, {1, 0, 2}};
static void real_to_normal(
double *fc3_normal_squared, const int64_t (*g_pos)[4],
const int64_t num_g_pos, const double *freqs0, const double *freqs1,
const double *freqs2, const lapack_complex_double *eigvecs0,
const lapack_complex_double *eigvecs1,
const lapack_complex_double *eigvecs2, const double *fc3,
const int64_t is_compact_fc3, const double q_vecs[3][3], /* q0, q1, q2 */
const AtomTriplets *atom_triplets, const double *masses,
const long *band_indices, const long num_band0, const long num_band,
const double cutoff_frequency, const long triplet_index,
const long num_triplets, const long openmp_per_triplets);
const int64_t *band_indices, const int64_t num_band,
const double cutoff_frequency, const int64_t triplet_index,
const int64_t num_triplets, const int64_t openmp_per_triplets);
static void real_to_normal_sym_q(
double *fc3_normal_squared, const int64_t (*g_pos)[4],
const int64_t num_g_pos, double *const freqs[3],
lapack_complex_double *const eigvecs[3], const double *fc3,
const int64_t is_compact_fc3, const double q_vecs[3][3], /* q0, q1, q2 */
const AtomTriplets *atom_triplets, const double *masses,
const int64_t *band_indices, const int64_t num_band0,
const int64_t num_band, const double cutoff_frequency,
const int64_t triplet_index, const int64_t num_triplets,
const int64_t openmp_per_triplets);
/* fc3_normal_squared[num_triplets, num_band0, num_band, num_band] */
void itr_get_interaction(
Darray *fc3_normal_squared, const char *g_zero, const Darray *frequencies,
const lapack_complex_double *eigenvectors, const long (*triplets)[3],
const long num_triplets, const RecgridConstBZGrid *bzgrid,
const double *fc3, const long is_compact_fc3,
const lapack_complex_double *eigenvectors, const int64_t (*triplets)[3],
const int64_t num_triplets, const RecgridConstBZGrid *bzgrid,
const double *fc3, const int64_t is_compact_fc3,
const AtomTriplets *atom_triplets, const double *masses,
const long *band_indices, const long symmetrize_fc3_q,
const double cutoff_frequency, const long openmp_per_triplets) {
long(*g_pos)[4];
long i;
long num_band, num_band0, num_band_prod, num_g_pos;
const int64_t *band_indices, const int64_t symmetrize_fc3_q,
const double cutoff_frequency, const int64_t openmp_per_triplets) {
int64_t(*g_pos)[4];
int64_t i;
int64_t num_band, num_band0, num_band_prod, num_g_pos;
g_pos = NULL;
@ -94,7 +94,7 @@ void itr_get_interaction(
num_g_pos, g_pos) if (openmp_per_triplets)
#endif
for (i = 0; i < num_triplets; i++) {
g_pos = (long(*)[4])malloc(sizeof(long[4]) * num_band_prod);
g_pos = (int64_t(*)[4])malloc(sizeof(int64_t[4]) * num_band_prod);
num_g_pos = ise_set_g_pos(g_pos, num_band0, num_band,
g_zero + i * num_band_prod);
@ -111,17 +111,18 @@ void itr_get_interaction(
}
void itr_get_interaction_at_triplet(
double *fc3_normal_squared, const long num_band0, const long num_band,
const long (*g_pos)[4], const long num_g_pos, const double *frequencies,
const lapack_complex_double *eigenvectors, const long triplet[3],
const RecgridConstBZGrid *bzgrid, const double *fc3,
const long is_compact_fc3, const AtomTriplets *atom_triplets,
const double *masses, const long *band_indices, const long symmetrize_fc3_q,
double *fc3_normal_squared, const int64_t num_band0, const int64_t num_band,
const int64_t (*g_pos)[4], const int64_t num_g_pos,
const double *frequencies, const lapack_complex_double *eigenvectors,
const int64_t triplet[3], const RecgridConstBZGrid *bzgrid,
const double *fc3, const int64_t is_compact_fc3,
const AtomTriplets *atom_triplets, const double *masses,
const int64_t *band_indices, const int64_t symmetrize_fc3_q,
const double cutoff_frequency,
const long triplet_index, /* only for print */
const long num_triplets, /* only for print */
const long openmp_per_triplets) {
long j, k;
const int64_t triplet_index, /* only for print */
const int64_t num_triplets, /* only for print */
const int64_t openmp_per_triplets) {
int64_t j, k;
double *freqs[3];
lapack_complex_double *eigvecs[3];
double q_vecs[3][3];
@ -182,22 +183,20 @@ void itr_get_interaction_at_triplet(
}
}
static void real_to_normal(double *fc3_normal_squared, const long (*g_pos)[4],
const long num_g_pos, const double *freqs0,
const double *freqs1, const double *freqs2,
const lapack_complex_double *eigvecs0,
const lapack_complex_double *eigvecs1,
const lapack_complex_double *eigvecs2,
const double *fc3, const long is_compact_fc3,
const double q_vecs[3][3], /* q0, q1, q2 */
const AtomTriplets *atom_triplets,
const double *masses, const long *band_indices,
const long num_band, const double cutoff_frequency,
const long triplet_index, const long num_triplets,
const long openmp_per_triplets) {
static void real_to_normal(
double *fc3_normal_squared, const int64_t (*g_pos)[4],
const int64_t num_g_pos, const double *freqs0, const double *freqs1,
const double *freqs2, const lapack_complex_double *eigvecs0,
const lapack_complex_double *eigvecs1,
const lapack_complex_double *eigvecs2, const double *fc3,
const int64_t is_compact_fc3, const double q_vecs[3][3], /* q0, q1, q2 */
const AtomTriplets *atom_triplets, const double *masses,
const int64_t *band_indices, const int64_t num_band,
const double cutoff_frequency, const int64_t triplet_index,
const int64_t num_triplets, const int64_t openmp_per_triplets) {
lapack_complex_double *fc3_reciprocal;
lapack_complex_double comp_zero;
long i;
int64_t i;
comp_zero = lapack_make_complex_double(0, 0);
fc3_reciprocal = (lapack_complex_double *)malloc(
@ -224,16 +223,17 @@ static void real_to_normal(double *fc3_normal_squared, const long (*g_pos)[4],
}
static void real_to_normal_sym_q(
double *fc3_normal_squared, const long (*g_pos)[4], const long num_g_pos,
double *const freqs[3], lapack_complex_double *const eigvecs[3],
const double *fc3, const long is_compact_fc3,
const double q_vecs[3][3], /* q0, q1, q2 */
double *fc3_normal_squared, const int64_t (*g_pos)[4],
const int64_t num_g_pos, double *const freqs[3],
lapack_complex_double *const eigvecs[3], const double *fc3,
const int64_t is_compact_fc3, const double q_vecs[3][3], /* q0, q1, q2 */
const AtomTriplets *atom_triplets, const double *masses,
const long *band_indices, const long num_band0, const long num_band,
const double cutoff_frequency, const long triplet_index,
const long num_triplets, const long openmp_per_triplets) {
long i, j, k, l;
long band_ex[3];
const int64_t *band_indices, const int64_t num_band0,
const int64_t num_band, const double cutoff_frequency,
const int64_t triplet_index, const int64_t num_triplets,
const int64_t openmp_per_triplets) {
int64_t i, j, k, l;
int64_t band_ex[3];
double q_vecs_ex[3][3];
double *fc3_normal_squared_ex;

View File

@ -35,6 +35,8 @@
#ifndef __interaction_H__
#define __interaction_H__
#include <stdint.h>
#include "lapack_wrapper.h"
#include "phonoc_array.h"
#include "real_to_reciprocal.h"
@ -42,22 +44,23 @@
void itr_get_interaction(
Darray *fc3_normal_squared, const char *g_zero, const Darray *frequencies,
const lapack_complex_double *eigenvectors, const long (*triplets)[3],
const long num_triplets, const RecgridConstBZGrid *bzgrid,
const double *fc3, const long is_compact_fc3,
const lapack_complex_double *eigenvectors, const int64_t (*triplets)[3],
const int64_t num_triplets, const RecgridConstBZGrid *bzgrid,
const double *fc3, const int64_t is_compact_fc3,
const AtomTriplets *atom_triplets, const double *masses,
const long *band_indices, const long symmetrize_fc3_q,
const double cutoff_frequency, const long openmp_per_triplets);
const int64_t *band_indices, const int64_t symmetrize_fc3_q,
const double cutoff_frequency, const int64_t openmp_per_triplets);
void itr_get_interaction_at_triplet(
double *fc3_normal_squared, const long num_band0, const long num_band,
const long (*g_pos)[4], const long num_g_pos, const double *frequencies,
const lapack_complex_double *eigenvectors, const long triplet[3],
const RecgridConstBZGrid *bzgrid, const double *fc3,
const long is_compact_fc3, const AtomTriplets *atom_triplets,
const double *masses, const long *band_indices, const long symmetrize_fc3_q,
double *fc3_normal_squared, const int64_t num_band0, const int64_t num_band,
const int64_t (*g_pos)[4], const int64_t num_g_pos,
const double *frequencies, const lapack_complex_double *eigenvectors,
const int64_t triplet[3], const RecgridConstBZGrid *bzgrid,
const double *fc3, const int64_t is_compact_fc3,
const AtomTriplets *atom_triplets, const double *masses,
const int64_t *band_indices, const int64_t symmetrize_fc3_q,
const double cutoff_frequency,
const long triplet_index, /* only for print */
const long num_triplets, /* only for print */
const long openmp_per_triplets);
const int64_t triplet_index, /* only for print */
const int64_t num_triplets, /* only for print */
const int64_t openmp_per_triplets);
#endif

View File

@ -34,6 +34,7 @@
#include "isotope.h"
#include <stdint.h>
#include <stdlib.h>
#include "funcs.h"
@ -41,12 +42,13 @@
#include "phonoc_const.h"
void iso_get_isotope_scattering_strength(
double *gamma, const long grid_point, const long *ir_grid_points,
double *gamma, const int64_t grid_point, const int64_t *ir_grid_points,
const double *weights, const double *mass_variances,
const double *frequencies, const lapack_complex_double *eigenvectors,
const long num_grid_points, const long *band_indices, const long num_band,
const long num_band0, const double sigma, const double cutoff_frequency) {
long i, j, k, l, m, gp;
const int64_t num_grid_points, const int64_t *band_indices,
const int64_t num_band, const int64_t num_band0, const double sigma,
const double cutoff_frequency) {
int64_t i, j, k, l, m, gp;
double *e0_r, *e0_i, e1_r, e1_i, a, b, f, *f0, dist, sum_g, sum_g_k;
e0_r = (double *)malloc(sizeof(double) * num_band * num_band0);
@ -126,13 +128,13 @@ void iso_get_isotope_scattering_strength(
}
void iso_get_thm_isotope_scattering_strength(
double *gamma, const long grid_point, const long *ir_grid_points,
double *gamma, const int64_t grid_point, const int64_t *ir_grid_points,
const double *weights, const double *mass_variances,
const double *frequencies, const lapack_complex_double *eigenvectors,
const long num_grid_points, const long *band_indices, const long num_band,
const long num_band0, const double *integration_weights,
const double cutoff_frequency) {
long i, j, k, l, m, gp;
const int64_t num_grid_points, const int64_t *band_indices,
const int64_t num_band, const int64_t num_band0,
const double *integration_weights, const double cutoff_frequency) {
int64_t i, j, k, l, m, gp;
double *e0_r, *e0_i, *f0, *gamma_ij;
double e1_r, e1_i, a, b, f, dist, sum_g_k;

View File

@ -35,19 +35,22 @@
#ifndef __isotope_H__
#define __isotope_H__
#include <stdint.h>
#include "lapack_wrapper.h"
void iso_get_isotope_scattering_strength(
double *gamma, const long grid_point, const long *ir_grid_points,
double *gamma, const int64_t grid_point, const int64_t *ir_grid_points,
const double *weights, const double *mass_variances,
const double *frequencies, const lapack_complex_double *eigenvectors,
const long num_grid_points, const long *band_indices, const long num_band,
const long num_band0, const double sigma, const double cutoff_frequency);
void iso_get_thm_isotope_scattering_strength(
double *gamma, const long grid_point, const long *ir_grid_points,
const double *weights, const double *mass_variances,
const double *frequencies, const lapack_complex_double *eigenvectors,
const long num_grid_points, const long *band_indices, const long num_band,
const long num_band0, const double *integration_weights,
const int64_t num_grid_points, const int64_t *band_indices,
const int64_t num_band, const int64_t num_band0, const double sigma,
const double cutoff_frequency);
void iso_get_thm_isotope_scattering_strength(
double *gamma, const int64_t grid_point, const int64_t *ir_grid_points,
const double *weights, const double *mass_variances,
const double *frequencies, const lapack_complex_double *eigenvectors,
const int64_t num_grid_points, const int64_t *band_indices,
const int64_t num_band, const int64_t num_band0,
const double *integration_weights, const double cutoff_frequency);
#endif

View File

@ -34,7 +34,9 @@
#include "lagrid.h"
long lagmat_get_determinant_l3(const long a[3][3]) {
#include <stdint.h>
int64_t lagmat_get_determinant_l3(const int64_t a[3][3]) {
return a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) +
a[0][1] * (a[1][2] * a[2][0] - a[1][0] * a[2][2]) +
a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]);
@ -46,7 +48,7 @@ double lagmat_get_determinant_d3(const double a[3][3]) {
a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]);
}
void lagmat_cast_matrix_3l_to_3d(double m[3][3], const long a[3][3]) {
void lagmat_cast_matrix_3l_to_3d(double m[3][3], const int64_t a[3][3]) {
m[0][0] = a[0][0];
m[0][1] = a[0][1];
m[0][2] = a[0][2];
@ -58,7 +60,7 @@ void lagmat_cast_matrix_3l_to_3d(double m[3][3], const long a[3][3]) {
m[2][2] = a[2][2];
}
void lagmat_cast_matrix_3d_to_3l(long m[3][3], const double a[3][3]) {
void lagmat_cast_matrix_3d_to_3l(int64_t m[3][3], const double a[3][3]) {
m[0][0] = lagmat_Nint(a[0][0]);
m[0][1] = lagmat_Nint(a[0][1]);
m[0][2] = lagmat_Nint(a[0][2]);
@ -70,9 +72,9 @@ void lagmat_cast_matrix_3d_to_3l(long m[3][3], const double a[3][3]) {
m[2][2] = lagmat_Nint(a[2][2]);
}
long lagmat_get_similar_matrix_ld3(double m[3][3], const long a[3][3],
const double b[3][3],
const double precision) {
int64_t lagmat_get_similar_matrix_ld3(double m[3][3], const int64_t a[3][3],
const double b[3][3],
const double precision) {
double c[3][3];
if (!lagmat_inverse_matrix_d3(c, b, precision)) {
warning_print("No similar matrix due to 0 determinant.\n");
@ -83,7 +85,8 @@ long lagmat_get_similar_matrix_ld3(double m[3][3], const long a[3][3],
return 1;
}
long lagmat_check_identity_matrix_l3(const long a[3][3], const long b[3][3]) {
int64_t lagmat_check_identity_matrix_l3(const int64_t a[3][3],
const int64_t b[3][3]) {
if (a[0][0] - b[0][0] || a[0][1] - b[0][1] || a[0][2] - b[0][2] ||
a[1][0] - b[1][0] || a[1][1] - b[1][1] || a[1][2] - b[1][2] ||
a[2][0] - b[2][0] || a[2][1] - b[2][1] || a[2][2] - b[2][2]) {
@ -93,8 +96,9 @@ long lagmat_check_identity_matrix_l3(const long a[3][3], const long b[3][3]) {
}
}
long lagmat_check_identity_matrix_ld3(const long a[3][3], const double b[3][3],
const double symprec) {
int64_t lagmat_check_identity_matrix_ld3(const int64_t a[3][3],
const double b[3][3],
const double symprec) {
if (lagmat_Dabs(a[0][0] - b[0][0]) > symprec ||
lagmat_Dabs(a[0][1] - b[0][1]) > symprec ||
lagmat_Dabs(a[0][2] - b[0][2]) > symprec ||
@ -110,8 +114,8 @@ long lagmat_check_identity_matrix_ld3(const long a[3][3], const double b[3][3],
}
}
long lagmat_inverse_matrix_d3(double m[3][3], const double a[3][3],
const double precision) {
int64_t lagmat_inverse_matrix_d3(double m[3][3], const double a[3][3],
const double precision) {
double det;
double c[3][3];
det = lagmat_get_determinant_d3(a);
@ -133,8 +137,8 @@ long lagmat_inverse_matrix_d3(double m[3][3], const double a[3][3],
return 1;
}
void lagmat_transpose_matrix_l3(long a[3][3], const long b[3][3]) {
long c[3][3];
void lagmat_transpose_matrix_l3(int64_t a[3][3], const int64_t b[3][3]) {
int64_t c[3][3];
c[0][0] = b[0][0];
c[0][1] = b[1][0];
c[0][2] = b[2][0];
@ -147,10 +151,10 @@ void lagmat_transpose_matrix_l3(long a[3][3], const long b[3][3]) {
lagmat_copy_matrix_l3(a, c);
}
void lagmat_multiply_matrix_vector_l3(long v[3], const long a[3][3],
const long b[3]) {
long i;
long c[3];
void lagmat_multiply_matrix_vector_l3(int64_t v[3], const int64_t a[3][3],
const int64_t b[3]) {
int64_t i;
int64_t c[3];
for (i = 0; i < 3; i++) {
c[i] = a[i][0] * b[0] + a[i][1] * b[1] + a[i][2] * b[2];
}
@ -159,10 +163,10 @@ void lagmat_multiply_matrix_vector_l3(long v[3], const long a[3][3],
}
}
void lagmat_multiply_matrix_l3(long m[3][3], const long a[3][3],
const long b[3][3]) {
long i, j; /* a_ij */
long c[3][3];
void lagmat_multiply_matrix_l3(int64_t m[3][3], const int64_t a[3][3],
const int64_t b[3][3]) {
int64_t i, j; /* a_ij */
int64_t c[3][3];
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
c[i][j] = a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j];
@ -171,9 +175,9 @@ void lagmat_multiply_matrix_l3(long m[3][3], const long a[3][3],
lagmat_copy_matrix_l3(m, c);
}
void lagmat_multiply_matrix_ld3(double m[3][3], const long a[3][3],
void lagmat_multiply_matrix_ld3(double m[3][3], const int64_t a[3][3],
const double b[3][3]) {
long i, j; /* a_ij */
int64_t i, j; /* a_ij */
double c[3][3];
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
@ -185,7 +189,7 @@ void lagmat_multiply_matrix_ld3(double m[3][3], const long a[3][3],
void lagmat_multiply_matrix_d3(double m[3][3], const double a[3][3],
const double b[3][3]) {
long i, j; /* a_ij */
int64_t i, j; /* a_ij */
double c[3][3];
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
@ -195,7 +199,7 @@ void lagmat_multiply_matrix_d3(double m[3][3], const double a[3][3],
lagmat_copy_matrix_d3(m, c);
}
void lagmat_copy_matrix_l3(long a[3][3], const long b[3][3]) {
void lagmat_copy_matrix_l3(int64_t a[3][3], const int64_t b[3][3]) {
a[0][0] = b[0][0];
a[0][1] = b[0][1];
a[0][2] = b[0][2];
@ -219,14 +223,14 @@ void lagmat_copy_matrix_d3(double a[3][3], const double b[3][3]) {
a[2][2] = b[2][2];
}
void lagmat_copy_vector_l3(long a[3], const long b[3]) {
void lagmat_copy_vector_l3(int64_t a[3], const int64_t b[3]) {
a[0] = b[0];
a[1] = b[1];
a[2] = b[2];
}
long lagmat_modulo_l(const long a, const long b) {
long c;
int64_t lagmat_modulo_l(const int64_t a, const int64_t b) {
int64_t c;
c = a % b;
if (c < 0) {
c += b;
@ -234,11 +238,11 @@ long lagmat_modulo_l(const long a, const long b) {
return c;
}
long lagmat_Nint(const double a) {
int64_t lagmat_Nint(const double a) {
if (a < 0.0)
return (long)(a - 0.5);
return (int64_t)(a - 0.5);
else
return (long)(a + 0.5);
return (int64_t)(a + 0.5);
}
double lagmat_Dabs(const double a) {

View File

@ -35,38 +35,42 @@
#ifndef __lagrid_H__
#define __lagrid_H__
#include <stdint.h>
#ifdef LAGWARNING
#define warning_print(...) fprintf(stderr, __VA_ARGS__)
#else
#define warning_print(...)
#endif
long lagmat_get_determinant_l3(const long a[3][3]);
int64_t lagmat_get_determinant_l3(const int64_t a[3][3]);
double lagmat_get_determinant_d3(const double a[3][3]);
void lagmat_cast_matrix_3l_to_3d(double m[3][3], const long a[3][3]);
void lagmat_cast_matrix_3d_to_3l(long m[3][3], const double a[3][3]);
long lagmat_get_similar_matrix_ld3(double m[3][3], const long a[3][3],
const double b[3][3],
const double precision);
long lagmat_check_identity_matrix_l3(const long a[3][3], const long b[3][3]);
long lagmat_check_identity_matrix_ld3(const long a[3][3], const double b[3][3],
const double symprec);
long lagmat_inverse_matrix_d3(double m[3][3], const double a[3][3],
const double precision);
void lagmat_transpose_matrix_l3(long a[3][3], const long b[3][3]);
void lagmat_multiply_matrix_vector_l3(long v[3], const long a[3][3],
const long b[3]);
void lagmat_multiply_matrix_l3(long m[3][3], const long a[3][3],
const long b[3][3]);
void lagmat_multiply_matrix_ld3(double m[3][3], const long a[3][3],
void lagmat_cast_matrix_3l_to_3d(double m[3][3], const int64_t a[3][3]);
void lagmat_cast_matrix_3d_to_3l(int64_t m[3][3], const double a[3][3]);
int64_t lagmat_get_similar_matrix_ld3(double m[3][3], const int64_t a[3][3],
const double b[3][3],
const double precision);
int64_t lagmat_check_identity_matrix_l3(const int64_t a[3][3],
const int64_t b[3][3]);
int64_t lagmat_check_identity_matrix_ld3(const int64_t a[3][3],
const double b[3][3],
const double symprec);
int64_t lagmat_inverse_matrix_d3(double m[3][3], const double a[3][3],
const double precision);
void lagmat_transpose_matrix_l3(int64_t a[3][3], const int64_t b[3][3]);
void lagmat_multiply_matrix_vector_l3(int64_t v[3], const int64_t a[3][3],
const int64_t b[3]);
void lagmat_multiply_matrix_l3(int64_t m[3][3], const int64_t a[3][3],
const int64_t b[3][3]);
void lagmat_multiply_matrix_ld3(double m[3][3], const int64_t a[3][3],
const double b[3][3]);
void lagmat_multiply_matrix_d3(double m[3][3], const double a[3][3],
const double b[3][3]);
void lagmat_copy_matrix_l3(long a[3][3], const long b[3][3]);
void lagmat_copy_matrix_l3(int64_t a[3][3], const int64_t b[3][3]);
void lagmat_copy_matrix_d3(double a[3][3], const double b[3][3]);
void lagmat_copy_vector_l3(long a[3], const long b[3]);
long lagmat_modulo_l(const long a, const long b);
long lagmat_Nint(const double a);
void lagmat_copy_vector_l3(int64_t a[3], const int64_t b[3]);
int64_t lagmat_modulo_l(const int64_t a, const int64_t b);
int64_t lagmat_Nint(const double a);
double lagmat_Dabs(const double a);
#endif

View File

@ -35,6 +35,7 @@
#include "lapack_wrapper.h"
#include <math.h>
#include <stdint.h>
#define min(a, b) ((a) > (b) ? (b) : (a))
@ -141,7 +142,7 @@ int phonopy_dsyev(double *data, double *eigvals, const int size,
lapack_int info;
lapack_int liwork;
long lwork;
int64_t lwork;
lapack_int *iwork;
double *work;
lapack_int iwork_query;
@ -164,7 +165,7 @@ int phonopy_dsyev(double *data, double *eigvals, const int size,
eigvals, &work_query, lwork,
&iwork_query, liwork);
liwork = iwork_query;
lwork = (long)work_query;
lwork = (int64_t)work_query;
/* printf("liwork %d, lwork %ld\n", liwork, lwork); */
if ((iwork = (lapack_int *)LAPACKE_malloc(sizeof(lapack_int) *
liwork)) == NULL) {
@ -203,12 +204,12 @@ int phonopy_dsyev(double *data, double *eigvals, const int size,
}
void pinv_from_eigensolution(double *data, const double *eigvals,
const long size, const double cutoff,
const long pinv_method) {
long i, ib, j, k, max_l, i_s, j_s;
const int64_t size, const double cutoff,
const int64_t pinv_method) {
int64_t i, ib, j, k, max_l, i_s, j_s;
double *tmp_data;
double e, sum;
long *l;
int64_t *l;
l = NULL;
tmp_data = NULL;
@ -222,7 +223,7 @@ void pinv_from_eigensolution(double *data, const double *eigvals,
tmp_data[i] = data[i];
}
l = (long *)malloc(sizeof(long) * size);
l = (int64_t *)malloc(sizeof(int64_t) * size);
max_l = 0;
for (i = 0; i < size; i++) {
if (pinv_method == 0) {

View File

@ -35,6 +35,8 @@
#ifndef __lapack_wrapper_H__
#define __lapack_wrapper_H__
#include <stdint.h>
#if defined(_MSC_VER) || defined(MKL_BLAS) || defined(SCIPY_MKL_H)
#if defined(_MSC_VER)
typedef struct {
@ -82,8 +84,8 @@ int phonopy_dsyev(double *data, double *eigvals, const int size,
const int algorithm);
void pinv_from_eigensolution(double *data, const double *eigvals,
const long size, const double cutoff,
const long pinv_method);
const int64_t size, const double cutoff,
const int64_t pinv_method);
#endif
#endif

View File

@ -34,6 +34,7 @@
#include "phono3py.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@ -57,20 +58,20 @@
#include <omp.h>
#endif
long ph3py_get_interaction(
int64_t ph3py_get_interaction(
Darray *fc3_normal_squared, const char *g_zero, const Darray *frequencies,
const _lapack_complex_double *eigenvectors, const long (*triplets)[3],
const long num_triplets, const long (*bz_grid_addresses)[3],
const long D_diag[3], const long Q[3][3], const double *fc3,
const long is_compact_fc3, const double (*svecs)[3],
const long multi_dims[2], const long (*multiplicity)[2],
const double *masses, const long *p2s_map, const long *s2p_map,
const long *band_indices, const long symmetrize_fc3_q,
const long make_r0_average, const char *all_shortest,
const double cutoff_frequency, const long openmp_per_triplets) {
const _lapack_complex_double *eigenvectors, const int64_t (*triplets)[3],
const int64_t num_triplets, const int64_t (*bz_grid_addresses)[3],
const int64_t D_diag[3], const int64_t Q[3][3], const double *fc3,
const int64_t is_compact_fc3, const double (*svecs)[3],
const int64_t multi_dims[2], const int64_t (*multiplicity)[2],
const double *masses, const int64_t *p2s_map, const int64_t *s2p_map,
const int64_t *band_indices, const int64_t symmetrize_fc3_q,
const int64_t make_r0_average, const char *all_shortest,
const double cutoff_frequency, const int64_t openmp_per_triplets) {
RecgridConstBZGrid *bzgrid;
AtomTriplets *atom_triplets;
long i, j;
int64_t i, j;
if ((bzgrid = (RecgridConstBZGrid *)malloc(sizeof(RecgridConstBZGrid))) ==
NULL) {
@ -117,24 +118,25 @@ long ph3py_get_interaction(
return 1;
}
long ph3py_get_pp_collision(
int64_t ph3py_get_pp_collision(
double *imag_self_energy,
const long relative_grid_address[24][4][3], /* thm */
const int64_t relative_grid_address[24][4][3], /* thm */
const double *frequencies, const _lapack_complex_double *eigenvectors,
const long (*triplets)[3], const long num_triplets,
const long *triplet_weights, const long (*bz_grid_addresses)[3], /* thm */
const long *bz_map, /* thm */
const long bz_grid_type, const long D_diag[3], const long Q[3][3],
const double *fc3, const long is_compact_fc3, const double (*svecs)[3],
const long multi_dims[2], const long (*multiplicity)[2],
const double *masses, const long *p2s_map, const long *s2p_map,
const Larray *band_indices, const Darray *temperatures, const long is_NU,
const long symmetrize_fc3_q, const long make_r0_average,
const int64_t (*triplets)[3], const int64_t num_triplets,
const int64_t *triplet_weights,
const int64_t (*bz_grid_addresses)[3], /* thm */
const int64_t *bz_map, /* thm */
const int64_t bz_grid_type, const int64_t D_diag[3], const int64_t Q[3][3],
const double *fc3, const int64_t is_compact_fc3, const double (*svecs)[3],
const int64_t multi_dims[2], const int64_t (*multiplicity)[2],
const double *masses, const int64_t *p2s_map, const int64_t *s2p_map,
const Larray *band_indices, const Darray *temperatures, const int64_t is_NU,
const int64_t symmetrize_fc3_q, const int64_t make_r0_average,
const char *all_shortest, const double cutoff_frequency,
const long openmp_per_triplets) {
const int64_t openmp_per_triplets) {
RecgridConstBZGrid *bzgrid;
AtomTriplets *atom_triplets;
long i, j;
int64_t i, j;
if ((bzgrid = (RecgridConstBZGrid *)malloc(sizeof(RecgridConstBZGrid))) ==
NULL) {
@ -184,22 +186,22 @@ long ph3py_get_pp_collision(
return 1;
}
long ph3py_get_pp_collision_with_sigma(
int64_t ph3py_get_pp_collision_with_sigma(
double *imag_self_energy, const double sigma, const double sigma_cutoff,
const double *frequencies, const _lapack_complex_double *eigenvectors,
const long (*triplets)[3], const long num_triplets,
const long *triplet_weights, const long (*bz_grid_addresses)[3],
const long D_diag[3], const long Q[3][3], const double *fc3,
const long is_compact_fc3, const double (*svecs)[3],
const long multi_dims[2], const long (*multiplicity)[2],
const double *masses, const long *p2s_map, const long *s2p_map,
const Larray *band_indices, const Darray *temperatures, const long is_NU,
const long symmetrize_fc3_q, const long make_r0_average,
const int64_t (*triplets)[3], const int64_t num_triplets,
const int64_t *triplet_weights, const int64_t (*bz_grid_addresses)[3],
const int64_t D_diag[3], const int64_t Q[3][3], const double *fc3,
const int64_t is_compact_fc3, const double (*svecs)[3],
const int64_t multi_dims[2], const int64_t (*multiplicity)[2],
const double *masses, const int64_t *p2s_map, const int64_t *s2p_map,
const Larray *band_indices, const Darray *temperatures, const int64_t is_NU,
const int64_t symmetrize_fc3_q, const int64_t make_r0_average,
const char *all_shortest, const double cutoff_frequency,
const long openmp_per_triplets) {
const int64_t openmp_per_triplets) {
RecgridConstBZGrid *bzgrid;
AtomTriplets *atom_triplets;
long i, j;
int64_t i, j;
if ((bzgrid = (RecgridConstBZGrid *)malloc(sizeof(RecgridConstBZGrid))) ==
NULL) {
@ -249,10 +251,10 @@ long ph3py_get_pp_collision_with_sigma(
void ph3py_get_imag_self_energy_at_bands_with_g(
double *imag_self_energy, const Darray *fc3_normal_squared,
const double *frequencies, const long (*triplets)[3],
const long *triplet_weights, const double *g, const char *g_zero,
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplet_weights, const double *g, const char *g_zero,
const double temperature, const double cutoff_frequency,
const long num_frequency_points, const long frequency_point_index) {
const int64_t num_frequency_points, const int64_t frequency_point_index) {
ise_get_imag_self_energy_with_g(
imag_self_energy, fc3_normal_squared, frequencies, triplets,
triplet_weights, g, g_zero, temperature, cutoff_frequency,
@ -262,8 +264,8 @@ void ph3py_get_imag_self_energy_at_bands_with_g(
void ph3py_get_detailed_imag_self_energy_at_bands_with_g(
double *detailed_imag_self_energy, double *imag_self_energy_N,
double *imag_self_energy_U, const Darray *fc3_normal_squared,
const double *frequencies, const long (*triplets)[3],
const long *triplet_weights, const long (*bz_grid_addresses)[3],
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplet_weights, const int64_t (*bz_grid_addresses)[3],
const double *g, const char *g_zero, const double temperature,
const double cutoff_frequency) {
ise_get_detailed_imag_self_energy_with_g(
@ -274,8 +276,8 @@ void ph3py_get_detailed_imag_self_energy_at_bands_with_g(
void ph3py_get_real_self_energy_at_bands(
double *real_self_energy, const Darray *fc3_normal_squared,
const long *band_indices, const double *frequencies,
const long (*triplets)[3], const long *triplet_weights,
const int64_t *band_indices, const double *frequencies,
const int64_t (*triplets)[3], const int64_t *triplet_weights,
const double epsilon, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency) {
rse_get_real_self_energy_at_bands(real_self_energy, fc3_normal_squared,
@ -286,10 +288,11 @@ void ph3py_get_real_self_energy_at_bands(
void ph3py_get_real_self_energy_at_frequency_point(
double *real_self_energy, const double frequency_point,
const Darray *fc3_normal_squared, const long *band_indices,
const double *frequencies, const long (*triplets)[3],
const long *triplet_weights, const double epsilon, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency) {
const Darray *fc3_normal_squared, const int64_t *band_indices,
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplet_weights, const double epsilon,
const double temperature, const double unit_conversion_factor,
const double cutoff_frequency) {
rse_get_real_self_energy_at_frequency_point(
real_self_energy, frequency_point, fc3_normal_squared, band_indices,
frequencies, triplets, triplet_weights, epsilon, temperature,
@ -298,11 +301,11 @@ void ph3py_get_real_self_energy_at_frequency_point(
void ph3py_get_collision_matrix(
double *collision_matrix, const Darray *fc3_normal_squared,
const double *frequencies, const long (*triplets)[3],
const long *triplets_map, const long *map_q,
const long *rotated_grid_points, const double *rotations_cartesian,
const double *g, const long num_ir_gp, const long num_gp,
const long num_rot, const double temperature,
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplets_map, const int64_t *map_q,
const int64_t *rotated_grid_points, const double *rotations_cartesian,
const double *g, const int64_t num_ir_gp, const int64_t num_gp,
const int64_t num_rot, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency) {
col_get_collision_matrix(collision_matrix, fc3_normal_squared, frequencies,
triplets, triplets_map, map_q, rotated_grid_points,
@ -313,9 +316,9 @@ void ph3py_get_collision_matrix(
void ph3py_get_reducible_collision_matrix(
double *collision_matrix, const Darray *fc3_normal_squared,
const double *frequencies, const long (*triplets)[3],
const long *triplets_map, const long *map_q, const double *g,
const long num_gp, const double temperature,
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplets_map, const int64_t *map_q, const double *g,
const int64_t num_gp, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency) {
col_get_reducible_collision_matrix(
collision_matrix, fc3_normal_squared, frequencies, triplets,
@ -324,11 +327,11 @@ void ph3py_get_reducible_collision_matrix(
}
void ph3py_get_isotope_scattering_strength(
double *gamma, const long grid_point, const long *ir_grid_points,
double *gamma, const int64_t grid_point, const int64_t *ir_grid_points,
const double *weights, const double *mass_variances,
const double *frequencies, const _lapack_complex_double *eigenvectors,
const long num_ir_grid_points, const long *band_indices,
const long num_band, const long num_band0, const double sigma,
const int64_t num_ir_grid_points, const int64_t *band_indices,
const int64_t num_band, const int64_t num_band0, const double sigma,
const double cutoff_frequency) {
iso_get_isotope_scattering_strength(
gamma, grid_point, ir_grid_points, weights, mass_variances, frequencies,
@ -337,11 +340,11 @@ void ph3py_get_isotope_scattering_strength(
}
void ph3py_get_thm_isotope_scattering_strength(
double *gamma, const long grid_point, const long *ir_grid_points,
double *gamma, const int64_t grid_point, const int64_t *ir_grid_points,
const double *weights, const double *mass_variances,
const double *frequencies, const _lapack_complex_double *eigenvectors,
const long num_ir_grid_points, const long *band_indices,
const long num_band, const long num_band0,
const int64_t num_ir_grid_points, const int64_t *band_indices,
const int64_t num_band, const int64_t num_band0,
const double *integration_weights, const double cutoff_frequency) {
iso_get_thm_isotope_scattering_strength(
gamma, grid_point, ir_grid_points, weights, mass_variances, frequencies,
@ -349,9 +352,9 @@ void ph3py_get_thm_isotope_scattering_strength(
num_band, num_band0, integration_weights, cutoff_frequency);
}
void ph3py_distribute_fc3(double *fc3, const long target, const long source,
const long *atom_mapping, const long num_atom,
const double *rot_cart) {
void ph3py_distribute_fc3(double *fc3, const int64_t target,
const int64_t source, const int64_t *atom_mapping,
const int64_t num_atom, const double *rot_cart) {
fc3_distribute_fc3(fc3, target, source, atom_mapping, num_atom, rot_cart);
}
@ -359,48 +362,52 @@ void ph3py_rotate_delta_fc2(double (*fc3)[3][3][3],
const double (*delta_fc2s)[3][3],
const double *inv_U,
const double (*site_sym_cart)[3][3],
const long *rot_map_syms, const long num_atom,
const long num_site_sym, const long num_disp) {
const int64_t *rot_map_syms, const int64_t num_atom,
const int64_t num_site_sym,
const int64_t num_disp) {
fc3_rotate_delta_fc2(fc3, delta_fc2s, inv_U, site_sym_cart, rot_map_syms,
num_atom, num_site_sym, num_disp);
}
void ph3py_get_permutation_symmetry_fc3(double *fc3, const long num_atom) {
void ph3py_get_permutation_symmetry_fc3(double *fc3, const int64_t num_atom) {
fc3_set_permutation_symmetry_fc3(fc3, num_atom);
}
void ph3py_get_permutation_symmetry_compact_fc3(
double *fc3, const long p2s[], const long s2pp[], const long nsym_list[],
const long perms[], const long n_satom, const long n_patom) {
double *fc3, const int64_t p2s[], const int64_t s2pp[],
const int64_t nsym_list[], const int64_t perms[], const int64_t n_satom,
const int64_t n_patom) {
fc3_set_permutation_symmetry_compact_fc3(fc3, p2s, s2pp, nsym_list, perms,
n_satom, n_patom);
}
void ph3py_transpose_compact_fc3(double *fc3, const long p2s[],
const long s2pp[], const long nsym_list[],
const long perms[], const long n_satom,
const long n_patom, const long t_type) {
void ph3py_transpose_compact_fc3(double *fc3, const int64_t p2s[],
const int64_t s2pp[],
const int64_t nsym_list[],
const int64_t perms[], const int64_t n_satom,
const int64_t n_patom, const int64_t t_type) {
fc3_transpose_compact_fc3(fc3, p2s, s2pp, nsym_list, perms, n_satom,
n_patom, t_type);
}
long ph3py_get_triplets_reciprocal_mesh_at_q(
long *map_triplets, long *map_q, const long grid_point,
const long D_diag[3], const long is_time_reversal, const long num_rot,
const long (*rec_rotations)[3][3], const long swappable) {
int64_t ph3py_get_triplets_reciprocal_mesh_at_q(
int64_t *map_triplets, int64_t *map_q, const int64_t grid_point,
const int64_t D_diag[3], const int64_t is_time_reversal,
const int64_t num_rot, const int64_t (*rec_rotations)[3][3],
const int64_t swappable) {
return tpl_get_triplets_reciprocal_mesh_at_q(
map_triplets, map_q, grid_point, D_diag, is_time_reversal, num_rot,
rec_rotations, swappable);
}
long ph3py_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point,
const long (*bz_grid_addresses)[3],
const long *bz_map, const long *map_triplets,
const long num_map_triplets,
const long D_diag[3], const long Q[3][3],
const long bz_grid_type) {
int64_t ph3py_get_BZ_triplets_at_q(
int64_t (*triplets)[3], const int64_t grid_point,
const int64_t (*bz_grid_addresses)[3], const int64_t *bz_map,
const int64_t *map_triplets, const int64_t num_map_triplets,
const int64_t D_diag[3], const int64_t Q[3][3],
const int64_t bz_grid_type) {
RecgridConstBZGrid *bzgrid;
long i, j, num_ir;
int64_t i, j, num_ir;
if ((bzgrid = (RecgridConstBZGrid *)malloc(sizeof(RecgridConstBZGrid))) ==
NULL) {
@ -431,16 +438,17 @@ long ph3py_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point,
/* relative_grid_addresses are given as P multipled with those from dataset,
* i.e.,
* np.dot(relative_grid_addresses, P.T) */
long ph3py_get_integration_weight(
int64_t ph3py_get_integration_weight(
double *iw, char *iw_zero, const double *frequency_points,
const long num_band0, const long relative_grid_address[24][4][3],
const long D_diag[3], const long (*triplets)[3], const long num_triplets,
const long (*bz_grid_addresses)[3], const long *bz_map,
const long bz_grid_type, const double *frequencies1, const long num_band1,
const double *frequencies2, const long num_band2, const long tp_type,
const long openmp_per_triplets) {
const int64_t num_band0, const int64_t relative_grid_address[24][4][3],
const int64_t D_diag[3], const int64_t (*triplets)[3],
const int64_t num_triplets, const int64_t (*bz_grid_addresses)[3],
const int64_t *bz_map, const int64_t bz_grid_type,
const double *frequencies1, const int64_t num_band1,
const double *frequencies2, const int64_t num_band2, const int64_t tp_type,
const int64_t openmp_per_triplets) {
RecgridConstBZGrid *bzgrid;
long i;
int64_t i;
if ((bzgrid = (RecgridConstBZGrid *)malloc(sizeof(RecgridConstBZGrid))) ==
NULL) {
@ -467,20 +475,20 @@ long ph3py_get_integration_weight(
void ph3py_get_integration_weight_with_sigma(
double *iw, char *iw_zero, const double sigma, const double sigma_cutoff,
const double *frequency_points, const long num_band0,
const long (*triplets)[3], const long num_triplets,
const double *frequencies, const long num_band, const long tp_type) {
const double *frequency_points, const int64_t num_band0,
const int64_t (*triplets)[3], const int64_t num_triplets,
const double *frequencies, const int64_t num_band, const int64_t tp_type) {
tpl_get_integration_weight_with_sigma(
iw, iw_zero, sigma, sigma_cutoff, frequency_points, num_band0, triplets,
num_triplets, frequencies, num_band, tp_type);
}
void ph3py_symmetrize_collision_matrix(double *collision_matrix,
const long num_column,
const long num_temp,
const long num_sigma) {
const int64_t num_column,
const int64_t num_temp,
const int64_t num_sigma) {
double val;
long i, j, k, l, adrs_shift;
int64_t i, j, k, l, adrs_shift;
for (i = 0; i < num_sigma; i++) {
for (j = 0; j < num_temp; j++) {
@ -503,21 +511,19 @@ void ph3py_symmetrize_collision_matrix(double *collision_matrix,
}
}
void ph3py_expand_collision_matrix(double *collision_matrix,
const long *rot_grid_points,
const long *ir_grid_points,
const long num_ir_gp,
const long num_grid_points,
const long num_rot, const long num_sigma,
const long num_temp, const long num_band)
void ph3py_expand_collision_matrix(
double *collision_matrix, const int64_t *rot_grid_points,
const int64_t *ir_grid_points, const int64_t num_ir_gp,
const int64_t num_grid_points, const int64_t num_rot,
const int64_t num_sigma, const int64_t num_temp, const int64_t num_band)
{
long i, j, k, l, m, n, p, adrs_shift, adrs_shift_plus, ir_gp, gp_r;
long num_column, num_bgb;
long *multi;
int64_t i, j, k, l, m, n, p, adrs_shift, adrs_shift_plus, ir_gp, gp_r;
int64_t num_column, num_bgb;
int64_t *multi;
double *colmat_copy;
multi = (long *)malloc(sizeof(long) * num_ir_gp);
multi = (int64_t *)malloc(sizeof(int64_t) * num_ir_gp);
colmat_copy = NULL;
num_column = num_grid_points * num_band;
@ -587,7 +593,7 @@ void ph3py_expand_collision_matrix(double *collision_matrix,
* @param relative_grid_address
* @param reciprocal_lattice
*/
void ph3py_get_relative_grid_address(long relative_grid_address[24][4][3],
void ph3py_get_relative_grid_address(int64_t relative_grid_address[24][4][3],
const double reciprocal_lattice[3][3]) {
thm_get_relative_grid_address(relative_grid_address, reciprocal_lattice);
}
@ -598,13 +604,13 @@ void ph3py_get_relative_grid_address(long relative_grid_address[24][4][3],
* relative_grid_addresses are given as P multipled with those from dataset,
* i.e.,
* np.dot(relative_grid_addresses, P.T) */
long ph3py_get_neighboring_gird_points(
long *relative_grid_points, const long *grid_points,
const long (*relative_grid_address)[3], const long D_diag[3],
const long (*bz_grid_addresses)[3], const long *bz_map,
const long bz_grid_type, const long num_grid_points,
const long num_relative_grid_address) {
long i;
int64_t ph3py_get_neighboring_gird_points(
int64_t *relative_grid_points, const int64_t *grid_points,
const int64_t (*relative_grid_address)[3], const int64_t D_diag[3],
const int64_t (*bz_grid_addresses)[3], const int64_t *bz_map,
const int64_t bz_grid_type, const int64_t num_grid_points,
const int64_t num_relative_grid_address) {
int64_t i;
RecgridConstBZGrid *bzgrid;
if ((bzgrid = (RecgridConstBZGrid *)malloc(sizeof(RecgridConstBZGrid))) ==
@ -641,15 +647,16 @@ long ph3py_get_neighboring_gird_points(
* relative_grid_addresses are given as P multipled with those from dataset,
* i.e.,
* np.dot(relative_grid_addresses, P.T) */
long ph3py_get_thm_integration_weights_at_grid_points(
double *iw, const double *frequency_points, const long num_frequency_points,
const long num_band, const long num_gp,
const long (*relative_grid_address)[4][3], const long D_diag[3],
const long *grid_points, const long (*bz_grid_addresses)[3],
const long *bz_map, const long bz_grid_type, const double *frequencies,
const long *gp2irgp_map, const char function) {
long i, j, k, bi;
long vertices[24][4];
int64_t ph3py_get_thm_integration_weights_at_grid_points(
double *iw, const double *frequency_points,
const int64_t num_frequency_points, const int64_t num_band,
const int64_t num_gp, const int64_t (*relative_grid_address)[4][3],
const int64_t D_diag[3], const int64_t *grid_points,
const int64_t (*bz_grid_addresses)[3], const int64_t *bz_map,
const int64_t bz_grid_type, const double *frequencies,
const int64_t *gp2irgp_map, const char function) {
int64_t i, j, k, bi;
int64_t vertices[24][4];
double freq_vertices[24][4];
RecgridConstBZGrid *bzgrid;
@ -697,7 +704,7 @@ long ph3py_get_thm_integration_weights_at_grid_points(
return 1;
}
long ph3py_get_max_threads(void) {
int64_t ph3py_get_max_threads(void) {
#ifdef _OPENMP
return omp_get_max_threads();
#else
@ -706,19 +713,20 @@ long ph3py_get_max_threads(void) {
}
#ifndef NO_INCLUDE_LAPACKE
long ph3py_phonopy_dsyev(double *data, double *eigvals, const long size,
const long algorithm) {
return (long)phonopy_dsyev(data, eigvals, (int)size, (int)algorithm);
int64_t ph3py_phonopy_dsyev(double *data, double *eigvals, const int64_t size,
const int64_t algorithm) {
return (int64_t)phonopy_dsyev(data, eigvals, (int)size, (int)algorithm);
}
long ph3py_phonopy_pinv(double *data_out, const double *data_in, const long m,
const long n, const double cutoff) {
return (long)phonopy_pinv(data_out, data_in, (int)m, (int)n, cutoff);
int64_t ph3py_phonopy_pinv(double *data_out, const double *data_in,
const int64_t m, const int64_t n,
const double cutoff) {
return (int64_t)phonopy_pinv(data_out, data_in, (int)m, (int)n, cutoff);
}
void ph3py_pinv_from_eigensolution(double *data, const double *eigvals,
const long size, const double cutoff,
const long pinv_method) {
const int64_t size, const double cutoff,
const int64_t pinv_method) {
pinv_from_eigensolution(data, eigvals, size, cutoff, pinv_method);
}
#endif

View File

@ -39,6 +39,8 @@
extern "C" {
#endif
#include <stdlib.h>
#include "phonoc_array.h"
typedef struct {
@ -46,172 +48,178 @@ typedef struct {
double im;
} _lapack_complex_double;
long ph3py_get_interaction(
int64_t ph3py_get_interaction(
Darray *fc3_normal_squared, const char *g_zero, const Darray *frequencies,
const _lapack_complex_double *eigenvectors, const long (*triplets)[3],
const long num_triplets, const long (*bz_grid_addresses)[3],
const long D_diag[3], const long Q[3][3], const double *fc3,
const long is_compact_fc3, const double (*svecs)[3],
const long multi_dims[2], const long (*multi)[2], const double *masses,
const long *p2s_map, const long *s2p_map, const long *band_indices,
const long symmetrize_fc3_q, const long make_r0_average,
const char *all_shortest, const double cutoff_frequency,
const long openmp_per_triplets);
long ph3py_get_pp_collision(
const _lapack_complex_double *eigenvectors, const int64_t (*triplets)[3],
const int64_t num_triplets, const int64_t (*bz_grid_addresses)[3],
const int64_t D_diag[3], const int64_t Q[3][3], const double *fc3,
const int64_t is_compact_fc3, const double (*svecs)[3],
const int64_t multi_dims[2], const int64_t (*multi)[2],
const double *masses, const int64_t *p2s_map, const int64_t *s2p_map,
const int64_t *band_indices, const int64_t symmetrize_fc3_q,
const int64_t make_r0_average, const char *all_shortest,
const double cutoff_frequency, const int64_t openmp_per_triplets);
int64_t ph3py_get_pp_collision(
double *imag_self_energy,
const long relative_grid_address[24][4][3], /* thm */
const int64_t relative_grid_address[24][4][3], /* thm */
const double *frequencies, const _lapack_complex_double *eigenvectors,
const long (*triplets)[3], const long num_triplets,
const long *triplet_weights, const long (*bz_grid_addresses)[3], /* thm */
const long *bz_map, /* thm */
const long bz_grid_type, const long D_diag[3], const long Q[3][3],
const double *fc3, const long is_compact_fc3, const double (*svecs)[3],
const long multi_dims[2], const long (*multi)[2], const double *masses,
const long *p2s_map, const long *s2p_map, const Larray *band_indices,
const Darray *temperatures, const long is_NU, const long symmetrize_fc3_q,
const long make_r0_average, const char *all_shortest,
const double cutoff_frequency, const long openmp_per_triplets);
long ph3py_get_pp_collision_with_sigma(
const int64_t (*triplets)[3], const int64_t num_triplets,
const int64_t *triplet_weights,
const int64_t (*bz_grid_addresses)[3], /* thm */
const int64_t *bz_map, /* thm */
const int64_t bz_grid_type, const int64_t D_diag[3], const int64_t Q[3][3],
const double *fc3, const int64_t is_compact_fc3, const double (*svecs)[3],
const int64_t multi_dims[2], const int64_t (*multi)[2],
const double *masses, const int64_t *p2s_map, const int64_t *s2p_map,
const Larray *band_indices, const Darray *temperatures, const int64_t is_NU,
const int64_t symmetrize_fc3_q, const int64_t make_r0_average,
const char *all_shortest, const double cutoff_frequency,
const int64_t openmp_per_triplets);
int64_t ph3py_get_pp_collision_with_sigma(
double *imag_self_energy, const double sigma, const double sigma_cutoff,
const double *frequencies, const _lapack_complex_double *eigenvectors,
const long (*triplets)[3], const long num_triplets,
const long *triplet_weights, const long (*bz_grid_addresses)[3],
const long D_diag[3], const long Q[3][3], const double *fc3,
const long is_compact_fc3, const double (*svecs)[3],
const long multi_dims[2], const long (*multi)[2], const double *masses,
const long *p2s_map, const long *s2p_map, const Larray *band_indices,
const Darray *temperatures, const long is_NU, const long symmetrize_fc3_q,
const long make_r0_average, const char *all_shortest,
const double cutoff_frequency, const long openmp_per_triplets);
const int64_t (*triplets)[3], const int64_t num_triplets,
const int64_t *triplet_weights, const int64_t (*bz_grid_addresses)[3],
const int64_t D_diag[3], const int64_t Q[3][3], const double *fc3,
const int64_t is_compact_fc3, const double (*svecs)[3],
const int64_t multi_dims[2], const int64_t (*multi)[2],
const double *masses, const int64_t *p2s_map, const int64_t *s2p_map,
const Larray *band_indices, const Darray *temperatures, const int64_t is_NU,
const int64_t symmetrize_fc3_q, const int64_t make_r0_average,
const char *all_shortest, const double cutoff_frequency,
const int64_t openmp_per_triplets);
void ph3py_get_imag_self_energy_at_bands_with_g(
double *imag_self_energy, const Darray *fc3_normal_squared,
const double *frequencies, const long (*triplets)[3],
const long *triplet_weights, const double *g, const char *g_zero,
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplet_weights, const double *g, const char *g_zero,
const double temperature, const double cutoff_frequency,
const long num_frequency_points, const long frequency_point_index);
const int64_t num_frequency_points, const int64_t frequency_point_index);
void ph3py_get_detailed_imag_self_energy_at_bands_with_g(
double *detailed_imag_self_energy, double *imag_self_energy_N,
double *imag_self_energy_U, const Darray *fc3_normal_squared,
const double *frequencies, const long (*triplets)[3],
const long *triplet_weights, const long (*bz_grid_addresses)[3],
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplet_weights, const int64_t (*bz_grid_addresses)[3],
const double *g, const char *g_zero, const double temperature,
const double cutoff_frequency);
void ph3py_get_real_self_energy_at_bands(
double *real_self_energy, const Darray *fc3_normal_squared,
const long *band_indices, const double *frequencies,
const long (*triplets)[3], const long *triplet_weights,
const int64_t *band_indices, const double *frequencies,
const int64_t (*triplets)[3], const int64_t *triplet_weights,
const double epsilon, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency);
void ph3py_get_real_self_energy_at_frequency_point(
double *real_self_energy, const double frequency_point,
const Darray *fc3_normal_squared, const long *band_indices,
const double *frequencies, const long (*triplets)[3],
const long *triplet_weights, const double epsilon, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency);
const Darray *fc3_normal_squared, const int64_t *band_indices,
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplet_weights, const double epsilon,
const double temperature, const double unit_conversion_factor,
const double cutoff_frequency);
void ph3py_get_collision_matrix(
double *collision_matrix, const Darray *fc3_normal_squared,
const double *frequencies, const long (*triplets)[3],
const long *triplets_map, const long *map_q,
const long *rotated_grid_points, const double *rotations_cartesian,
const double *g, const long num_ir_gp, const long num_gp,
const long num_rot, const double temperature,
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplets_map, const int64_t *map_q,
const int64_t *rotated_grid_points, const double *rotations_cartesian,
const double *g, const int64_t num_ir_gp, const int64_t num_gp,
const int64_t num_rot, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency);
void ph3py_get_reducible_collision_matrix(
double *collision_matrix, const Darray *fc3_normal_squared,
const double *frequencies, const long (*triplets)[3],
const long *triplets_map, const long *map_q, const double *g,
const long num_gp, const double temperature,
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplets_map, const int64_t *map_q, const double *g,
const int64_t num_gp, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency);
void ph3py_get_isotope_scattering_strength(
double *gamma, const long grid_point, const long *ir_grid_points,
double *gamma, const int64_t grid_point, const int64_t *ir_grid_points,
const double *weights, const double *mass_variances,
const double *frequencies, const _lapack_complex_double *eigenvectors,
const long num_ir_grid_points, const long *band_indices,
const long num_band, const long num_band0, const double sigma,
const int64_t num_ir_grid_points, const int64_t *band_indices,
const int64_t num_band, const int64_t num_band0, const double sigma,
const double cutoff_frequency);
void ph3py_get_thm_isotope_scattering_strength(
double *gamma, const long grid_point, const long *ir_grid_points,
double *gamma, const int64_t grid_point, const int64_t *ir_grid_points,
const double *weights, const double *mass_variances,
const double *frequencies, const _lapack_complex_double *eigenvectors,
const long num_ir_grid_points, const long *band_indices,
const long num_band, const long num_band0,
const int64_t num_ir_grid_points, const int64_t *band_indices,
const int64_t num_band, const int64_t num_band0,
const double *integration_weights, const double cutoff_frequency);
void ph3py_distribute_fc3(double *fc3, const long target, const long source,
const long *atom_mapping, const long num_atom,
const double *rot_cart);
void ph3py_distribute_fc3(double *fc3, const int64_t target,
const int64_t source, const int64_t *atom_mapping,
const int64_t num_atom, const double *rot_cart);
void ph3py_rotate_delta_fc2(double (*fc3)[3][3][3],
const double (*delta_fc2s)[3][3],
const double *inv_U,
const double (*site_sym_cart)[3][3],
const long *rot_map_syms, const long num_atom,
const long num_site_sym, const long num_disp);
void ph3py_get_permutation_symmetry_fc3(double *fc3, const long num_atom);
const int64_t *rot_map_syms, const int64_t num_atom,
const int64_t num_site_sym, const int64_t num_disp);
void ph3py_get_permutation_symmetry_fc3(double *fc3, const int64_t num_atom);
void ph3py_get_permutation_symmetry_compact_fc3(
double *fc3, const long p2s[], const long s2pp[], const long nsym_list[],
const long perms[], const long n_satom, const long n_patom);
void ph3py_transpose_compact_fc3(double *fc3, const long p2s[],
const long s2pp[], const long nsym_list[],
const long perms[], const long n_satom,
const long n_patom, const long t_type);
long ph3py_get_triplets_reciprocal_mesh_at_q(
long *map_triplets, long *map_q, const long grid_point, const long mesh[3],
const long is_time_reversal, const long num_rot,
const long (*rec_rotations)[3][3], const long swappable);
long ph3py_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point,
const long (*bz_grid_addresses)[3],
const long *bz_map, const long *map_triplets,
const long num_map_triplets,
const long D_diag[3], const long Q[3][3],
const long bz_grid_type);
long ph3py_get_integration_weight(
double *fc3, const int64_t p2s[], const int64_t s2pp[],
const int64_t nsym_list[], const int64_t perms[], const int64_t n_satom,
const int64_t n_patom);
void ph3py_transpose_compact_fc3(double *fc3, const int64_t p2s[],
const int64_t s2pp[],
const int64_t nsym_list[],
const int64_t perms[], const int64_t n_satom,
const int64_t n_patom, const int64_t t_type);
int64_t ph3py_get_triplets_reciprocal_mesh_at_q(
int64_t *map_triplets, int64_t *map_q, const int64_t grid_point,
const int64_t mesh[3], const int64_t is_time_reversal,
const int64_t num_rot, const int64_t (*rec_rotations)[3][3],
const int64_t swappable);
int64_t ph3py_get_BZ_triplets_at_q(
int64_t (*triplets)[3], const int64_t grid_point,
const int64_t (*bz_grid_addresses)[3], const int64_t *bz_map,
const int64_t *map_triplets, const int64_t num_map_triplets,
const int64_t D_diag[3], const int64_t Q[3][3], const int64_t bz_grid_type);
int64_t ph3py_get_integration_weight(
double *iw, char *iw_zero, const double *frequency_points,
const long num_band0, const long relative_grid_address[24][4][3],
const long mesh[3], const long (*triplets)[3], const long num_triplets,
const long (*bz_grid_addresses)[3], const long *bz_map,
const long bz_grid_type, const double *frequencies1, const long num_band1,
const double *frequencies2, const long num_band2, const long tp_type,
const long openmp_per_triplets);
const int64_t num_band0, const int64_t relative_grid_address[24][4][3],
const int64_t mesh[3], const int64_t (*triplets)[3],
const int64_t num_triplets, const int64_t (*bz_grid_addresses)[3],
const int64_t *bz_map, const int64_t bz_grid_type,
const double *frequencies1, const int64_t num_band1,
const double *frequencies2, const int64_t num_band2, const int64_t tp_type,
const int64_t openmp_per_triplets);
void ph3py_get_integration_weight_with_sigma(
double *iw, char *iw_zero, const double sigma, const double sigma_cutoff,
const double *frequency_points, const long num_band0,
const long (*triplets)[3], const long num_triplets,
const double *frequencies, const long num_band, const long tp_type);
const double *frequency_points, const int64_t num_band0,
const int64_t (*triplets)[3], const int64_t num_triplets,
const double *frequencies, const int64_t num_band, const int64_t tp_type);
void ph3py_symmetrize_collision_matrix(double *collision_matrix,
const long num_column,
const long num_temp,
const long num_sigma);
void ph3py_expand_collision_matrix(double *collision_matrix,
const long *rot_grid_points,
const long *ir_grid_points,
const long num_ir_gp,
const long num_grid_points,
const long num_rot, const long num_sigma,
const long num_temp, const long num_band);
void ph3py_get_relative_grid_address(long relative_grid_address[24][4][3],
const int64_t num_column,
const int64_t num_temp,
const int64_t num_sigma);
void ph3py_expand_collision_matrix(
double *collision_matrix, const int64_t *rot_grid_points,
const int64_t *ir_grid_points, const int64_t num_ir_gp,
const int64_t num_grid_points, const int64_t num_rot,
const int64_t num_sigma, const int64_t num_temp, const int64_t num_band);
void ph3py_get_relative_grid_address(int64_t relative_grid_address[24][4][3],
const double reciprocal_lattice[3][3]);
long ph3py_get_neighboring_gird_points(
long *relative_grid_points, const long *grid_points,
const long (*relative_grid_address)[3], const long mesh[3],
const long (*bz_grid_addresses)[3], const long *bz_map,
const long bz_grid_type, const long num_grid_points,
const long num_relative_grid_address);
long ph3py_get_thm_integration_weights_at_grid_points(
double *iw, const double *frequency_points, const long num_band0,
const long num_band, const long num_gp,
const long (*relative_grid_address)[4][3], const long D_diag[3],
const long *grid_points, const long (*bz_grid_addresses)[3],
const long *bz_map, const long bz_grid_type, const double *frequencies,
const long *gp2irgp_map, const char function);
long ph3py_get_max_threads(void);
int64_t ph3py_get_neighboring_gird_points(
int64_t *relative_grid_points, const int64_t *grid_points,
const int64_t (*relative_grid_address)[3], const int64_t mesh[3],
const int64_t (*bz_grid_addresses)[3], const int64_t *bz_map,
const int64_t bz_grid_type, const int64_t num_grid_points,
const int64_t num_relative_grid_address);
int64_t ph3py_get_thm_integration_weights_at_grid_points(
double *iw, const double *frequency_points, const int64_t num_band0,
const int64_t num_band, const int64_t num_gp,
const int64_t (*relative_grid_address)[4][3], const int64_t D_diag[3],
const int64_t *grid_points, const int64_t (*bz_grid_addresses)[3],
const int64_t *bz_map, const int64_t bz_grid_type,
const double *frequencies, const int64_t *gp2irgp_map, const char function);
int64_t ph3py_get_max_threads(void);
#ifndef NO_INCLUDE_LAPACKE
long ph3py_phonopy_dsyev(double *data, double *eigvals, const long size,
const long algorithm);
long ph3py_phonopy_pinv(double *data_out, const double *data_in, const long m,
const long n, const double cutoff);
int64_t ph3py_phonopy_dsyev(double *data, double *eigvals, const int64_t size,
const int64_t algorithm);
int64_t ph3py_phonopy_pinv(double *data_out, const double *data_in,
const int64_t m, const int64_t n,
const double cutoff);
void ph3py_pinv_from_eigensolution(double *data, const double *eigvals,
const long size, const double cutoff,
const long pinv_method);
const int64_t size, const double cutoff,
const int64_t pinv_method);
#endif
#ifdef __cplusplus

View File

@ -35,12 +35,14 @@
#ifndef __phonoc_array_H__
#define __phonoc_array_H__
#include <stdint.h>
#define MAX_NUM_DIM 20
/* It is assumed that number of dimensions is known for each array. */
typedef struct {
long dims[MAX_NUM_DIM];
long *data;
int64_t dims[MAX_NUM_DIM];
int64_t *data;
} Larray;
typedef struct {

View File

@ -36,78 +36,84 @@
#include <math.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "dynmat.h"
#include "lapack_wrapper.h"
static long collect_undone_grid_points(long *undone, char *phonon_done,
const long num_grid_points,
const long *grid_points);
static int64_t collect_undone_grid_points(int64_t *undone, char *phonon_done,
const int64_t num_grid_points,
const int64_t *grid_points);
static void get_undone_phonons(
double *frequencies, lapack_complex_double *eigenvectors,
const long *undone_grid_points, const long num_undone_grid_points,
const long (*grid_address)[3], const double QDinv[3][3], const double *fc2,
const double (*svecs_fc2)[3], const long (*multi_fc2)[2],
const long num_patom, const long num_satom, const double *masses_fc2,
const long *p2s_fc2, const long *s2p_fc2,
const double unit_conversion_factor, const double (*born)[3][3],
const double dielectric[3][3], const double reciprocal_lattice[3][3],
const double *q_direction, const double nac_factor, const char uplo);
const int64_t *undone_grid_points, const int64_t num_undone_grid_points,
const int64_t (*grid_address)[3], const double QDinv[3][3],
const double *fc2, const double (*svecs_fc2)[3],
const int64_t (*multi_fc2)[2], const int64_t num_patom,
const int64_t num_satom, const double *masses_fc2, const int64_t *p2s_fc2,
const int64_t *s2p_fc2, const double unit_conversion_factor,
const double (*born)[3][3], const double dielectric[3][3],
const double reciprocal_lattice[3][3], const double *q_direction,
const double nac_factor, const char uplo);
static void get_gonze_undone_phonons(
double *frequencies, lapack_complex_double *eigenvectors,
const long *undone_grid_points, const long num_undone_grid_points,
const long (*grid_address)[3], const double QDinv[3][3], const double *fc2,
const double (*svecs_fc2)[3], const long (*multi_fc2)[2],
const double (*positions)[3], const long num_patom, const long num_satom,
const double *masses_fc2, const long *p2s_fc2, const long *s2p_fc2,
const int64_t *undone_grid_points, const int64_t num_undone_grid_points,
const int64_t (*grid_address)[3], const double QDinv[3][3],
const double *fc2, const double (*svecs_fc2)[3],
const int64_t (*multi_fc2)[2], const double (*positions)[3],
const int64_t num_patom, const int64_t num_satom, const double *masses_fc2,
const int64_t *p2s_fc2, const int64_t *s2p_fc2,
const double unit_conversion_factor, const double (*born)[3][3],
const double dielectric[3][3], const double reciprocal_lattice[3][3],
const double *q_direction, const double nac_factor,
const double (*dd_q0)[2], const double (*G_list)[3],
const long num_G_points, const double lambda, const char uplo);
const int64_t num_G_points, const double lambda, const char uplo);
static void get_gonze_phonons(
lapack_complex_double *eigvecs, const double q[3], const double *fc2,
const double *masses, const long *p2s, const long *s2p,
const long (*multi)[2], const double (*positions)[3], const long num_patom,
const long num_satom, const double (*svecs)[3], const long is_nac,
const double (*born)[3][3], const double dielectric[3][3],
const double reciprocal_lattice[3][3], const double *q_direction,
const double nac_factor, const double (*dd_q0)[2],
const double (*G_list)[3], const long num_G_points, const double lambda);
const double *masses, const int64_t *p2s, const int64_t *s2p,
const int64_t (*multi)[2], const double (*positions)[3],
const int64_t num_patom, const int64_t num_satom, const double (*svecs)[3],
const int64_t is_nac, const double (*born)[3][3],
const double dielectric[3][3], const double reciprocal_lattice[3][3],
const double *q_direction, const double nac_factor,
const double (*dd_q0)[2], const double (*G_list)[3],
const int64_t num_G_points, const double lambda);
static void get_dynamical_matrix(
lapack_complex_double *dynmat, const double q[3], const double *fc2,
const double *masses, const long *p2s, const long *s2p,
const long (*multi)[2], const long num_patom, const long num_satom,
const double (*svecs)[3], const long is_nac,
const double *masses, const int64_t *p2s, const int64_t *s2p,
const int64_t (*multi)[2], const int64_t num_patom, const int64_t num_satom,
const double (*svecs)[3], const int64_t is_nac,
const double (*born)[3][3], /* Wang NAC unless NULL */
const double dielectric[3][3], const double reciprocal_lattice[3][3],
const double *q_direction, const double nac_factor);
static void get_charge_sum(double (*charge_sum)[3][3], const long num_patom,
const long num_satom, const double q[3],
static void get_charge_sum(double (*charge_sum)[3][3], const int64_t num_patom,
const int64_t num_satom, const double q[3],
const double (*born)[3][3],
const double dielectric[3][3],
const double reciprocal_lattice[3][3],
const double *q_direction, const double nac_factor);
static long needs_nac(const double (*born)[3][3], const long (*grid_address)[3],
const long gp, const double *q_direction);
static int64_t needs_nac(const double (*born)[3][3],
const int64_t (*grid_address)[3], const int64_t gp,
const double *q_direction);
void phn_get_phonons_at_gridpoints(
double *frequencies, lapack_complex_double *eigenvectors, char *phonon_done,
const long num_phonons, const long *grid_points, const long num_grid_points,
const long (*grid_address)[3], const double QDinv[3][3], const double *fc2,
const double (*svecs_fc2)[3], const long (*multi_fc2)[2],
const long num_patom, const long num_satom, const double *masses_fc2,
const long *p2s_fc2, const long *s2p_fc2,
const double unit_conversion_factor, const double (*born)[3][3],
const double dielectric[3][3], const double reciprocal_lattice[3][3],
const int64_t num_phonons, const int64_t *grid_points,
const int64_t num_grid_points, const int64_t (*grid_address)[3],
const double QDinv[3][3], const double *fc2, const double (*svecs_fc2)[3],
const int64_t (*multi_fc2)[2], const int64_t num_patom,
const int64_t num_satom, const double *masses_fc2, const int64_t *p2s_fc2,
const int64_t *s2p_fc2, const double unit_conversion_factor,
const double (*born)[3][3], const double dielectric[3][3],
const double reciprocal_lattice[3][3],
const double *q_direction, /* must be pointer */
const double nac_factor, const char uplo) {
long num_undone;
long *undone;
int64_t num_undone;
int64_t *undone;
undone = (long *)malloc(sizeof(long) * num_phonons);
undone = (int64_t *)malloc(sizeof(int64_t) * num_phonons);
num_undone = collect_undone_grid_points(undone, phonon_done,
num_grid_points, grid_points);
@ -123,21 +129,22 @@ void phn_get_phonons_at_gridpoints(
void phn_get_gonze_phonons_at_gridpoints(
double *frequencies, lapack_complex_double *eigenvectors, char *phonon_done,
const long num_phonons, const long *grid_points, const long num_grid_points,
const long (*grid_address)[3], const double QDinv[3][3], const double *fc2,
const double (*svecs_fc2)[3], const long (*multi_fc2)[2],
const double (*positions)[3], const long num_patom, const long num_satom,
const double *masses_fc2, const long *p2s_fc2, const long *s2p_fc2,
const int64_t num_phonons, const int64_t *grid_points,
const int64_t num_grid_points, const int64_t (*grid_address)[3],
const double QDinv[3][3], const double *fc2, const double (*svecs_fc2)[3],
const int64_t (*multi_fc2)[2], const double (*positions)[3],
const int64_t num_patom, const int64_t num_satom, const double *masses_fc2,
const int64_t *p2s_fc2, const int64_t *s2p_fc2,
const double unit_conversion_factor, const double (*born)[3][3],
const double dielectric[3][3], const double reciprocal_lattice[3][3],
const double *q_direction, /* pointer */
const double nac_factor, const double (*dd_q0)[2],
const double (*G_list)[3], const long num_G_points, const double lambda,
const double (*G_list)[3], const int64_t num_G_points, const double lambda,
const char uplo) {
long num_undone;
long *undone;
int64_t num_undone;
int64_t *undone;
undone = (long *)malloc(sizeof(long) * num_phonons);
undone = (int64_t *)malloc(sizeof(int64_t) * num_phonons);
num_undone = collect_undone_grid_points(undone, phonon_done,
num_grid_points, grid_points);
@ -152,10 +159,10 @@ void phn_get_gonze_phonons_at_gridpoints(
undone = NULL;
}
static long collect_undone_grid_points(long *undone, char *phonon_done,
const long num_grid_points,
const long *grid_points) {
long i, gp, num_undone;
static int64_t collect_undone_grid_points(int64_t *undone, char *phonon_done,
const int64_t num_grid_points,
const int64_t *grid_points) {
int64_t i, gp, num_undone;
num_undone = 0;
for (i = 0; i < num_grid_points; i++) {
@ -172,16 +179,17 @@ static long collect_undone_grid_points(long *undone, char *phonon_done,
static void get_undone_phonons(
double *frequencies, lapack_complex_double *eigenvectors,
const long *undone_grid_points, const long num_undone_grid_points,
const long (*grid_address)[3], const double QDinv[3][3], const double *fc2,
const double (*svecs_fc2)[3], const long (*multi_fc2)[2],
const long num_patom, const long num_satom, const double *masses_fc2,
const long *p2s_fc2, const long *s2p_fc2,
const double unit_conversion_factor, const double (*born)[3][3],
const double dielectric[3][3], const double reciprocal_lattice[3][3],
const double *q_direction, const double nac_factor, const char uplo) {
long i, j, gp, num_band;
long is_nac, info;
const int64_t *undone_grid_points, const int64_t num_undone_grid_points,
const int64_t (*grid_address)[3], const double QDinv[3][3],
const double *fc2, const double (*svecs_fc2)[3],
const int64_t (*multi_fc2)[2], const int64_t num_patom,
const int64_t num_satom, const double *masses_fc2, const int64_t *p2s_fc2,
const int64_t *s2p_fc2, const double unit_conversion_factor,
const double (*born)[3][3], const double dielectric[3][3],
const double reciprocal_lattice[3][3], const double *q_direction,
const double nac_factor, const char uplo) {
int64_t i, j, gp, num_band;
int64_t is_nac, info;
double q[3];
double *freqs_tmp;
@ -232,18 +240,19 @@ static void get_undone_phonons(
static void get_gonze_undone_phonons(
double *frequencies, lapack_complex_double *eigenvectors,
const long *undone_grid_points, const long num_undone_grid_points,
const long (*grid_address)[3], const double QDinv[3][3], const double *fc2,
const double (*svecs_fc2)[3], const long (*multi_fc2)[2],
const double (*positions)[3], const long num_patom, const long num_satom,
const double *masses_fc2, const long *p2s_fc2, const long *s2p_fc2,
const int64_t *undone_grid_points, const int64_t num_undone_grid_points,
const int64_t (*grid_address)[3], const double QDinv[3][3],
const double *fc2, const double (*svecs_fc2)[3],
const int64_t (*multi_fc2)[2], const double (*positions)[3],
const int64_t num_patom, const int64_t num_satom, const double *masses_fc2,
const int64_t *p2s_fc2, const int64_t *s2p_fc2,
const double unit_conversion_factor, const double (*born)[3][3],
const double dielectric[3][3], const double reciprocal_lattice[3][3],
const double *q_direction, const double nac_factor,
const double (*dd_q0)[2], const double (*G_list)[3],
const long num_G_points, const double lambda, const char uplo) {
long i, j, gp, num_band;
long is_nac, info;
const int64_t num_G_points, const double lambda, const char uplo) {
int64_t i, j, gp, num_band;
int64_t is_nac, info;
double q[3];
double *freqs_tmp;
@ -294,14 +303,15 @@ static void get_gonze_undone_phonons(
static void get_gonze_phonons(
lapack_complex_double *eigvecs, const double q[3], const double *fc2,
const double *masses, const long *p2s, const long *s2p,
const long (*multi)[2], const double (*positions)[3], const long num_patom,
const long num_satom, const double (*svecs)[3], const long is_nac,
const double (*born)[3][3], const double dielectric[3][3],
const double reciprocal_lattice[3][3], const double *q_direction,
const double nac_factor, const double (*dd_q0)[2],
const double (*G_list)[3], const long num_G_points, const double lambda) {
long i, j, k, l, adrs, num_band;
const double *masses, const int64_t *p2s, const int64_t *s2p,
const int64_t (*multi)[2], const double (*positions)[3],
const int64_t num_patom, const int64_t num_satom, const double (*svecs)[3],
const int64_t is_nac, const double (*born)[3][3],
const double dielectric[3][3], const double reciprocal_lattice[3][3],
const double *q_direction, const double nac_factor,
const double (*dd_q0)[2], const double (*G_list)[3],
const int64_t num_G_points, const double lambda) {
int64_t i, j, k, l, adrs, num_band;
double mm;
double q_cart[3];
double *q_dir_cart;
@ -365,9 +375,9 @@ static void get_gonze_phonons(
static void get_dynamical_matrix(
lapack_complex_double *dynmat, const double q[3], const double *fc2,
const double *masses, const long *p2s, const long *s2p,
const long (*multi)[2], const long num_patom, const long num_satom,
const double (*svecs)[3], const long is_nac,
const double *masses, const int64_t *p2s, const int64_t *s2p,
const int64_t (*multi)[2], const int64_t num_patom, const int64_t num_satom,
const double (*svecs)[3], const int64_t is_nac,
const double (*born)[3][3], /* Wang NAC unless NULL */
const double dielectric[3][3], const double reciprocal_lattice[3][3],
const double *q_direction, const double nac_factor) {
@ -391,13 +401,13 @@ static void get_dynamical_matrix(
}
}
static void get_charge_sum(double (*charge_sum)[3][3], const long num_patom,
const long num_satom, const double q[3],
static void get_charge_sum(double (*charge_sum)[3][3], const int64_t num_patom,
const int64_t num_satom, const double q[3],
const double (*born)[3][3],
const double dielectric[3][3],
const double reciprocal_lattice[3][3],
const double *q_direction, const double nac_factor) {
long i, j;
int64_t i, j;
double inv_dielectric_factor, dielectric_factor, tmp_val;
double q_cart[3];
@ -432,9 +442,10 @@ static void get_charge_sum(double (*charge_sum)[3][3], const long num_patom,
dym_get_charge_sum(charge_sum, num_patom, dielectric_factor, q_cart, born);
}
static long needs_nac(const double (*born)[3][3], const long (*grid_address)[3],
const long gp, const double *q_direction) {
long is_nac;
static int64_t needs_nac(const double (*born)[3][3],
const int64_t (*grid_address)[3], const int64_t gp,
const double *q_direction) {
int64_t is_nac;
if (born) {
if (grid_address[gp][0] == 0 && grid_address[gp][1] == 0 &&

View File

@ -35,31 +35,35 @@
#ifndef __phonon_H__
#define __phonon_H__
#include <stdint.h>
#include "dynmat.h"
#include "lapack_wrapper.h"
void phn_get_phonons_at_gridpoints(
double *frequencies, lapack_complex_double *eigenvectors, char *phonon_done,
const long num_phonons, const long *grid_points, const long num_grid_points,
const long (*grid_address)[3], const double QDinv[3][3], const double *fc2,
const double (*svecs_fc2)[3], const long (*multi_fc2)[2],
const long num_patom, const long num_satom, const double *masses_fc2,
const long *p2s_fc2, const long *s2p_fc2,
const double unit_conversion_factor, const double (*born)[3][3],
const double dielectric[3][3], const double reciprocal_lattice[3][3],
const int64_t num_phonons, const int64_t *grid_points,
const int64_t num_grid_points, const int64_t (*grid_address)[3],
const double QDinv[3][3], const double *fc2, const double (*svecs_fc2)[3],
const int64_t (*multi_fc2)[2], const int64_t num_patom,
const int64_t num_satom, const double *masses_fc2, const int64_t *p2s_fc2,
const int64_t *s2p_fc2, const double unit_conversion_factor,
const double (*born)[3][3], const double dielectric[3][3],
const double reciprocal_lattice[3][3],
const double *q_direction, /* must be pointer */
const double nac_factor, const char uplo);
void phn_get_gonze_phonons_at_gridpoints(
double *frequencies, lapack_complex_double *eigenvectors, char *phonon_done,
const long num_phonons, const long *grid_points, const long num_grid_points,
const long (*grid_address)[3], const double QDinv[3][3], const double *fc2,
const double (*svecs_fc2)[3], const long (*multi_fc2)[2],
const double (*positions)[3], const long num_patom, const long num_satom,
const double *masses_fc2, const long *p2s_fc2, const long *s2p_fc2,
const int64_t num_phonons, const int64_t *grid_points,
const int64_t num_grid_points, const int64_t (*grid_address)[3],
const double QDinv[3][3], const double *fc2, const double (*svecs_fc2)[3],
const int64_t (*multi_fc2)[2], const double (*positions)[3],
const int64_t num_patom, const int64_t num_satom, const double *masses_fc2,
const int64_t *p2s_fc2, const int64_t *s2p_fc2,
const double unit_conversion_factor, const double (*born)[3][3],
const double dielectric[3][3], const double reciprocal_lattice[3][3],
const double *q_direction, /* pointer */
const double nac_factor, const double (*dd_q0)[2],
const double (*G_list)[3], const long num_G_points, const double lambda,
const double (*G_list)[3], const int64_t num_G_points, const double lambda,
const char uplo);
#endif

View File

@ -34,22 +34,24 @@
#include "phononcalc.h"
#include <stdint.h>
#include "lapack_wrapper.h"
#include "phonon.h"
void phcalc_get_phonons_at_gridpoints(
double *frequencies, _lapack_complex_double *eigenvectors,
char *phonon_done, const long num_phonons, const long *grid_points,
const long num_grid_points, const long (*grid_address)[3],
char *phonon_done, const int64_t num_phonons, const int64_t *grid_points,
const int64_t num_grid_points, const int64_t (*grid_address)[3],
const double QDinv[3][3], const double *fc2, const double (*svecs_fc2)[3],
const long (*multi_fc2)[2], const double (*positions_fc2)[3],
const long num_patom, const long num_satom, const double *masses_fc2,
const long *p2s_fc2, const long *s2p_fc2,
const int64_t (*multi_fc2)[2], const double (*positions_fc2)[3],
const int64_t num_patom, const int64_t num_satom, const double *masses_fc2,
const int64_t *p2s_fc2, const int64_t *s2p_fc2,
const double unit_conversion_factor, const double (*born)[3][3],
const double dielectric[3][3], const double reciprocal_lattice[3][3],
const double *q_direction, /* pointer */
const double nac_factor, const double (*dd_q0)[2],
const double (*G_list)[3], const long num_G_points, const double lambda,
const double (*G_list)[3], const int64_t num_G_points, const double lambda,
const char uplo) {
if (!dd_q0) {
phn_get_phonons_at_gridpoints(

View File

@ -39,6 +39,8 @@
extern "C" {
#endif
#include <stdint.h>
typedef struct {
double re;
double im;
@ -46,17 +48,17 @@ typedef struct {
void phcalc_get_phonons_at_gridpoints(
double *frequencies, _lapack_complex_double *eigenvectors,
char *phonon_done, const long num_phonons, const long *grid_points,
const long num_grid_points, const long (*grid_address)[3],
char *phonon_done, const int64_t num_phonons, const int64_t *grid_points,
const int64_t num_grid_points, const int64_t (*grid_address)[3],
const double QDinv[3][3], const double *fc2, const double (*svecs_fc2)[3],
const long (*multi_fc2)[2], const double (*positions_fc2)[3],
const long num_patom, const long num_satom, const double *masses_fc2,
const long *p2s_fc2, const long *s2p_fc2,
const int64_t (*multi_fc2)[2], const double (*positions_fc2)[3],
const int64_t num_patom, const int64_t num_satom, const double *masses_fc2,
const int64_t *p2s_fc2, const int64_t *s2p_fc2,
const double unit_conversion_factor, const double (*born)[3][3],
const double dielectric[3][3], const double reciprocal_lattice[3][3],
const double *q_direction, /* pointer */
const double nac_factor, const double (*dd_q0)[2],
const double (*G_list)[3], const long num_G_points, const double lambda,
const double (*G_list)[3], const int64_t num_G_points, const double lambda,
const char uplo);
#ifdef __cplusplus

View File

@ -34,6 +34,7 @@
#include "pp_collision.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@ -48,37 +49,37 @@
#include "triplet_iw.h"
static void get_collision(
double *ise, const long num_band0, const long num_band,
const long num_temps, const double *temperatures, const double *g,
double *ise, const int64_t num_band0, const int64_t num_band,
const int64_t num_temps, const double *temperatures, const double *g,
const char *g_zero, const double *frequencies,
const lapack_complex_double *eigenvectors, const long triplet[3],
const long triplet_weight, const RecgridConstBZGrid *bzgrid,
const double *fc3, const long is_compact_fc3,
const lapack_complex_double *eigenvectors, const int64_t triplet[3],
const int64_t triplet_weight, const RecgridConstBZGrid *bzgrid,
const double *fc3, const int64_t is_compact_fc3,
const AtomTriplets *atom_triplets, const double *masses,
const long *band_indices, const long symmetrize_fc3_q,
const double cutoff_frequency, const long openmp_per_triplets);
const int64_t *band_indices, const int64_t symmetrize_fc3_q,
const double cutoff_frequency, const int64_t openmp_per_triplets);
static void finalize_ise(double *imag_self_energy, const double *ise,
const long (*bz_grid_address)[3],
const long (*triplets)[3], const long num_triplets,
const long num_temps, const long num_band0,
const long is_NU);
const int64_t (*bz_grid_address)[3],
const int64_t (*triplets)[3],
const int64_t num_triplets, const int64_t num_temps,
const int64_t num_band0, const int64_t is_NU);
void ppc_get_pp_collision(
double *imag_self_energy,
const long relative_grid_address[24][4][3], /* thm */
const int64_t relative_grid_address[24][4][3], /* thm */
const double *frequencies, const lapack_complex_double *eigenvectors,
const long (*triplets)[3], const long num_triplets,
const long *triplet_weights, const RecgridConstBZGrid *bzgrid,
const double *fc3, const long is_compact_fc3,
const int64_t (*triplets)[3], const int64_t num_triplets,
const int64_t *triplet_weights, const RecgridConstBZGrid *bzgrid,
const double *fc3, const int64_t is_compact_fc3,
const AtomTriplets *atom_triplets, const double *masses,
const Larray *band_indices, const Darray *temperatures, const long is_NU,
const long symmetrize_fc3_q, const double cutoff_frequency,
const long openmp_per_triplets) {
long i;
long num_band, num_band0, num_band_prod, num_temps;
const Larray *band_indices, const Darray *temperatures, const int64_t is_NU,
const int64_t symmetrize_fc3_q, const double cutoff_frequency,
const int64_t openmp_per_triplets) {
int64_t i;
int64_t num_band, num_band0, num_band_prod, num_temps;
double *ise, *freqs_at_gp, *g;
char *g_zero;
long tp_relative_grid_address[2][24][4][3];
int64_t tp_relative_grid_address[2][24][4][3];
ise = NULL;
freqs_at_gp = NULL;
@ -138,16 +139,16 @@ void ppc_get_pp_collision(
void ppc_get_pp_collision_with_sigma(
double *imag_self_energy, const double sigma, const double sigma_cutoff,
const double *frequencies, const lapack_complex_double *eigenvectors,
const long (*triplets)[3], const long num_triplets,
const long *triplet_weights, const RecgridConstBZGrid *bzgrid,
const double *fc3, const long is_compact_fc3,
const int64_t (*triplets)[3], const int64_t num_triplets,
const int64_t *triplet_weights, const RecgridConstBZGrid *bzgrid,
const double *fc3, const int64_t is_compact_fc3,
const AtomTriplets *atom_triplets, const double *masses,
const Larray *band_indices, const Darray *temperatures, const long is_NU,
const long symmetrize_fc3_q, const double cutoff_frequency,
const long openmp_per_triplets) {
long i;
long num_band, num_band0, num_band_prod, num_temps;
long const_adrs_shift;
const Larray *band_indices, const Darray *temperatures, const int64_t is_NU,
const int64_t symmetrize_fc3_q, const double cutoff_frequency,
const int64_t openmp_per_triplets) {
int64_t i;
int64_t num_band, num_band0, num_band_prod, num_temps;
int64_t const_adrs_shift;
double cutoff;
double *ise, *freqs_at_gp, *g;
char *g_zero;
@ -207,26 +208,26 @@ void ppc_get_pp_collision_with_sigma(
}
static void get_collision(
double *ise, const long num_band0, const long num_band,
const long num_temps, const double *temperatures, const double *g,
double *ise, const int64_t num_band0, const int64_t num_band,
const int64_t num_temps, const double *temperatures, const double *g,
const char *g_zero, const double *frequencies,
const lapack_complex_double *eigenvectors, const long triplet[3],
const long triplet_weight, const RecgridConstBZGrid *bzgrid,
const double *fc3, const long is_compact_fc3,
const lapack_complex_double *eigenvectors, const int64_t triplet[3],
const int64_t triplet_weight, const RecgridConstBZGrid *bzgrid,
const double *fc3, const int64_t is_compact_fc3,
const AtomTriplets *atom_triplets, const double *masses,
const long *band_indices, const long symmetrize_fc3_q,
const double cutoff_frequency, const long openmp_per_triplets) {
long i;
long num_band_prod, num_g_pos;
const int64_t *band_indices, const int64_t symmetrize_fc3_q,
const double cutoff_frequency, const int64_t openmp_per_triplets) {
int64_t i;
int64_t num_band_prod, num_g_pos;
double *fc3_normal_squared;
long(*g_pos)[4];
int64_t(*g_pos)[4];
fc3_normal_squared = NULL;
g_pos = NULL;
num_band_prod = num_band0 * num_band * num_band;
fc3_normal_squared = (double *)malloc(sizeof(double) * num_band_prod);
g_pos = (long(*)[4])malloc(sizeof(long[4]) * num_band_prod);
g_pos = (int64_t(*)[4])malloc(sizeof(int64_t[4]) * num_band_prod);
for (i = 0; i < num_band_prod; i++) {
fc3_normal_squared[i] = 0;
@ -252,12 +253,12 @@ static void get_collision(
}
static void finalize_ise(double *imag_self_energy, const double *ise,
const long (*bz_grid_addresses)[3],
const long (*triplets)[3], const long num_triplets,
const long num_temps, const long num_band0,
const long is_NU) {
long i, j, k;
long is_N;
const int64_t (*bz_grid_addresses)[3],
const int64_t (*triplets)[3],
const int64_t num_triplets, const int64_t num_temps,
const int64_t num_band0, const int64_t is_NU) {
int64_t i, j, k;
int64_t is_N;
if (is_NU) {
for (i = 0; i < 2 * num_temps * num_band0; i++) {

View File

@ -35,6 +35,8 @@
#ifndef __pp_collision_H__
#define __pp_collision_H__
#include <stdint.h>
#include "lapack_wrapper.h"
#include "phonoc_array.h"
#include "real_to_reciprocal.h"
@ -42,24 +44,24 @@
void ppc_get_pp_collision(
double *imag_self_energy,
const long relative_grid_address[24][4][3], /* thm */
const int64_t relative_grid_address[24][4][3], /* thm */
const double *frequencies, const lapack_complex_double *eigenvectors,
const long (*triplets)[3], const long num_triplets,
const long *triplet_weights, const RecgridConstBZGrid *bzgrid,
const double *fc3, const long is_compact_fc3,
const int64_t (*triplets)[3], const int64_t num_triplets,
const int64_t *triplet_weights, const RecgridConstBZGrid *bzgrid,
const double *fc3, const int64_t is_compact_fc3,
const AtomTriplets *atom_triplets, const double *masses,
const Larray *band_indices, const Darray *temperatures, const long is_NU,
const long symmetrize_fc3_q, const double cutoff_frequency,
const long openmp_per_triplets);
const Larray *band_indices, const Darray *temperatures, const int64_t is_NU,
const int64_t symmetrize_fc3_q, const double cutoff_frequency,
const int64_t openmp_per_triplets);
void ppc_get_pp_collision_with_sigma(
double *imag_self_energy, const double sigma, const double sigma_cutoff,
const double *frequencies, const lapack_complex_double *eigenvectors,
const long (*triplets)[3], const long num_triplets,
const long *triplet_weights, const RecgridConstBZGrid *bzgrid,
const double *fc3, const long is_compact_fc3,
const int64_t (*triplets)[3], const int64_t num_triplets,
const int64_t *triplet_weights, const RecgridConstBZGrid *bzgrid,
const double *fc3, const int64_t is_compact_fc3,
const AtomTriplets *atom_triplets, const double *masses,
const Larray *band_indices, const Darray *temperatures, const long is_NU,
const long symmetrize_fc3_q, const double cutoff_frequency,
const long openmp_per_triplets);
const Larray *band_indices, const Darray *temperatures, const int64_t is_NU,
const int64_t symmetrize_fc3_q, const double cutoff_frequency,
const int64_t openmp_per_triplets);
#endif

View File

@ -35,6 +35,7 @@
#include "real_self_energy.h"
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include "funcs.h"
@ -42,26 +43,28 @@
#include "real_to_reciprocal.h"
static double get_real_self_energy_at_band(
const long band_index, const Darray *fc3_normal_squared,
const double fpoint, const double *frequencies, const long (*triplets)[3],
const long *triplet_weights, const double epsilon, const double temperature,
const int64_t band_index, const Darray *fc3_normal_squared,
const double fpoint, const double *frequencies,
const int64_t (*triplets)[3], const int64_t *triplet_weights,
const double epsilon, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency);
static double sum_real_self_energy_at_band(
const long num_band, const double *fc3_normal_squared, const double fpoint,
const double *freqs1, const double *freqs2, const double epsilon,
const double temperature, const double cutoff_frequency);
static double sum_real_self_energy_at_band_0K(
const long num_band, const double *fc3_normal_squared, const double fpoint,
const double *freqs1, const double *freqs2, const double epsilon,
const int64_t num_band, const double *fc3_normal_squared,
const double fpoint, const double *freqs1, const double *freqs2,
const double epsilon, const double temperature,
const double cutoff_frequency);
static double sum_real_self_energy_at_band_0K(
const int64_t num_band, const double *fc3_normal_squared,
const double fpoint, const double *freqs1, const double *freqs2,
const double epsilon, const double cutoff_frequency);
void rse_get_real_self_energy_at_bands(
double *real_self_energy, const Darray *fc3_normal_squared,
const long *band_indices, const double *frequencies,
const long (*triplets)[3], const long *triplet_weights,
const int64_t *band_indices, const double *frequencies,
const int64_t (*triplets)[3], const int64_t *triplet_weights,
const double epsilon, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency) {
long i, num_band0, num_band, gp0;
int64_t i, num_band0, num_band, gp0;
double fpoint;
num_band0 = fc3_normal_squared->dims[1];
@ -84,11 +87,12 @@ void rse_get_real_self_energy_at_bands(
void rse_get_real_self_energy_at_frequency_point(
double *real_self_energy, const double frequency_point,
const Darray *fc3_normal_squared, const long *band_indices,
const double *frequencies, const long (*triplets)[3],
const long *triplet_weights, const double epsilon, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency) {
long i, num_band0;
const Darray *fc3_normal_squared, const int64_t *band_indices,
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplet_weights, const double epsilon,
const double temperature, const double unit_conversion_factor,
const double cutoff_frequency) {
int64_t i, num_band0;
num_band0 = fc3_normal_squared->dims[1];
@ -106,11 +110,12 @@ void rse_get_real_self_energy_at_frequency_point(
}
static double get_real_self_energy_at_band(
const long band_index, const Darray *fc3_normal_squared,
const double fpoint, const double *frequencies, const long (*triplets)[3],
const long *triplet_weights, const double epsilon, const double temperature,
const int64_t band_index, const Darray *fc3_normal_squared,
const double fpoint, const double *frequencies,
const int64_t (*triplets)[3], const int64_t *triplet_weights,
const double epsilon, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency) {
long i, num_triplets, num_band0, num_band, gp1, gp2;
int64_t i, num_triplets, num_band0, num_band, gp1, gp2;
double shift;
num_triplets = fc3_normal_squared->dims[0];
@ -150,10 +155,11 @@ static double get_real_self_energy_at_band(
}
static double sum_real_self_energy_at_band(
const long num_band, const double *fc3_normal_squared, const double fpoint,
const double *freqs1, const double *freqs2, const double epsilon,
const double temperature, const double cutoff_frequency) {
long i, j;
const int64_t num_band, const double *fc3_normal_squared,
const double fpoint, const double *freqs1, const double *freqs2,
const double epsilon, const double temperature,
const double cutoff_frequency) {
int64_t i, j;
double n1, n2, f1, f2, f3, f4, shift;
/* double sum; */
@ -198,10 +204,10 @@ static double sum_real_self_energy_at_band(
}
static double sum_real_self_energy_at_band_0K(
const long num_band, const double *fc3_normal_squared, const double fpoint,
const double *freqs1, const double *freqs2, const double epsilon,
const double cutoff_frequency) {
long i, j;
const int64_t num_band, const double *fc3_normal_squared,
const double fpoint, const double *freqs1, const double *freqs2,
const double epsilon, const double cutoff_frequency) {
int64_t i, j;
double f1, f2, shift;
shift = 0;

View File

@ -35,19 +35,22 @@
#ifndef __real_self_energy_H__
#define __real_self_energy_H__
#include <stdint.h>
#include "phonoc_array.h"
#endif
void rse_get_real_self_energy_at_bands(
double *real_self_energy, const Darray *fc3_normal_squared,
const long *band_indices, const double *frequencies,
const long (*triplets)[3], const long *triplet_weights,
const int64_t *band_indices, const double *frequencies,
const int64_t (*triplets)[3], const int64_t *triplet_weights,
const double epsilon, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency);
void rse_get_real_self_energy_at_frequency_point(
double *real_self_energy, const double frequency_point,
const Darray *fc3_normal_squared, const long *band_indices,
const double *frequencies, const long (*triplets)[3],
const long *triplet_weights, const double epsilon, const double temperature,
const double unit_conversion_factor, const double cutoff_frequency);
const Darray *fc3_normal_squared, const int64_t *band_indices,
const double *frequencies, const int64_t (*triplets)[3],
const int64_t *triplet_weights, const double epsilon,
const double temperature, const double unit_conversion_factor,
const double cutoff_frequency);

View File

@ -36,6 +36,7 @@
#include <assert.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@ -48,27 +49,28 @@ static void real_to_reciprocal_legacy(
const lapack_complex_double *pre_phase_factors,
const lapack_complex_double *phase_factor1,
const lapack_complex_double *phase_factor2, const double *fc3,
const long is_compact_fc3, const AtomTriplets *atom_triplets,
const long openmp_per_triplets);
const int64_t is_compact_fc3, const AtomTriplets *atom_triplets,
const int64_t openmp_per_triplets);
static void real_to_reciprocal_r0_average(
lapack_complex_double *fc3_reciprocal,
const lapack_complex_double *pre_phase_factors,
const lapack_complex_double *phase_factor0,
const lapack_complex_double *phase_factor1,
const lapack_complex_double *phase_factor2, const double *fc3,
const long is_compact_fc3, const AtomTriplets *atom_triplets,
const long openmp_per_triplets);
const int64_t is_compact_fc3, const AtomTriplets *atom_triplets,
const int64_t openmp_per_triplets);
static void real_to_reciprocal_elements(
lapack_complex_double *fc3_rec_elem,
const lapack_complex_double *phase_factor1,
const lapack_complex_double *phase_factor2, const double *fc3,
const long is_compact_fc3, const AtomTriplets *atom_triplets,
const long pi0, const long pi1, const long pi2, const long leg_index);
const int64_t is_compact_fc3, const AtomTriplets *atom_triplets,
const int64_t pi0, const int64_t pi1, const int64_t pi2,
const int64_t leg_index);
static lapack_complex_double get_phase_factor(const double q[3],
const double (*svecs)[3],
const long multi[2]);
const int64_t multi[2]);
static lapack_complex_double get_pre_phase_factor(
const long i_patom, const double q_vecs[3][3],
const int64_t i_patom, const double q_vecs[3][3],
const AtomTriplets *atom_triplets);
static lapack_complex_double sum_lapack_complex_double(lapack_complex_double a,
lapack_complex_double b);
@ -76,10 +78,10 @@ static lapack_complex_double sum_lapack_complex_double(lapack_complex_double a,
/* fc3_reciprocal[num_patom, num_patom, num_patom, 3, 3, 3] */
void r2r_real_to_reciprocal(lapack_complex_double *fc3_reciprocal,
const double q_vecs[3][3], const double *fc3,
const long is_compact_fc3,
const int64_t is_compact_fc3,
const AtomTriplets *atom_triplets,
const long openmp_per_triplets) {
long i, j, num_band, num_patom, num_satom, adrs_vec;
const int64_t openmp_per_triplets) {
int64_t i, j, num_band, num_patom, num_satom, adrs_vec;
lapack_complex_double *pre_phase_factors, *phase_factors, *phase_factor0,
*phase_factor1, *phase_factor2;
@ -143,10 +145,10 @@ static void real_to_reciprocal_legacy(
const lapack_complex_double *pre_phase_factors,
const lapack_complex_double *phase_factor1,
const lapack_complex_double *phase_factor2, const double *fc3,
const long is_compact_fc3, const AtomTriplets *atom_triplets,
const long openmp_per_triplets) {
long i, j, k, l, m, n, ijk;
long num_patom, num_satom, num_band;
const int64_t is_compact_fc3, const AtomTriplets *atom_triplets,
const int64_t openmp_per_triplets) {
int64_t i, j, k, l, m, n, ijk;
int64_t num_patom, num_satom, num_band;
lapack_complex_double fc3_rec_elem[27];
num_patom = atom_triplets->multi_dims[1];
@ -190,10 +192,10 @@ static void real_to_reciprocal_r0_average(
const lapack_complex_double *phase_factor0,
const lapack_complex_double *phase_factor1,
const lapack_complex_double *phase_factor2, const double *fc3,
const long is_compact_fc3, const AtomTriplets *atom_triplets,
const long openmp_per_triplets) {
long i, j, k, l, m, n, ijk;
long num_patom, num_satom, num_band;
const int64_t is_compact_fc3, const AtomTriplets *atom_triplets,
const int64_t openmp_per_triplets) {
int64_t i, j, k, l, m, n, ijk;
int64_t num_patom, num_satom, num_band;
lapack_complex_double fc3_rec_elem[27], fc3_rec;
num_patom = atom_triplets->multi_dims[1];
@ -271,10 +273,11 @@ static void real_to_reciprocal_elements(
lapack_complex_double *fc3_rec_elem,
const lapack_complex_double *phase_factor1,
const lapack_complex_double *phase_factor2, const double *fc3,
const long is_compact_fc3, const AtomTriplets *atom_triplets,
const long pi0, const long pi1, const long pi2, const long leg_index) {
long i, j, k, l;
long num_satom, adrs_shift;
const int64_t is_compact_fc3, const AtomTriplets *atom_triplets,
const int64_t pi0, const int64_t pi1, const int64_t pi2,
const int64_t leg_index) {
int64_t i, j, k, l;
int64_t num_satom, adrs_shift;
lapack_complex_double phase_factor;
double fc3_rec_real[27], fc3_rec_imag[27];
@ -344,9 +347,9 @@ static void real_to_reciprocal_elements(
// This function doesn't need to think about position +
// lattice-translation because q+q'+q''=G.
static lapack_complex_double get_pre_phase_factor(
const long i_patom, const double q_vecs[3][3],
const int64_t i_patom, const double q_vecs[3][3],
const AtomTriplets *atom_triplets) {
long j, svecs_adrs;
int64_t j, svecs_adrs;
double pre_phase;
lapack_complex_double pre_phase_factor;
@ -366,8 +369,8 @@ static lapack_complex_double get_pre_phase_factor(
static lapack_complex_double get_phase_factor(const double q[3],
const double (*svecs)[3],
const long multi[2]) {
long i, j;
const int64_t multi[2]) {
int64_t i, j;
double sum_real, sum_imag, phase;
sum_real = 0;

View File

@ -35,22 +35,24 @@
#ifndef __real_to_reciprocal_H__
#define __real_to_reciprocal_H__
#include <stdint.h>
#include "lapack_wrapper.h"
#include "phonoc_array.h"
typedef struct {
const double (*svecs)[3];
long multi_dims[2];
const long (*multiplicity)[2];
const long *p2s_map;
const long *s2p_map;
long make_r0_average;
int64_t multi_dims[2];
const int64_t (*multiplicity)[2];
const int64_t *p2s_map;
const int64_t *s2p_map;
int64_t make_r0_average;
const char *all_shortest;
} AtomTriplets;
void r2r_real_to_reciprocal(lapack_complex_double *fc3_reciprocal,
const double q_vecs[3][3], const double *fc3,
const long is_compact_fc3,
const int64_t is_compact_fc3,
const AtomTriplets *atom_triplets,
const long openmp_per_triplets);
const int64_t openmp_per_triplets);
#endif

View File

@ -34,6 +34,7 @@
#include "recgrid.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@ -44,64 +45,71 @@
#define GRID_TOLERANCE_FACTOR 0.01
void recgrid_get_all_grid_addresses(long (*gr_grid_addresses)[3],
const long D_diag[3]) {
void recgrid_get_all_grid_addresses(int64_t (*gr_grid_addresses)[3],
const int64_t D_diag[3]) {
grg_get_all_grid_addresses(gr_grid_addresses, D_diag);
}
void recgrid_get_double_grid_address(long address_double[3],
const long address[3], const long PS[3]) {
void recgrid_get_double_grid_address(int64_t address_double[3],
const int64_t address[3],
const int64_t PS[3]) {
grg_get_double_grid_address(address_double, address, PS);
}
void recgrid_get_grid_address_from_index(long address[3], const long grid_index,
const long D_diag[3]) {
void recgrid_get_grid_address_from_index(int64_t address[3],
const int64_t grid_index,
const int64_t D_diag[3]) {
grg_get_grid_address_from_index(address, grid_index, D_diag);
}
long recgrid_get_double_grid_index(const long address_double[3],
const long D_diag[3], const long PS[3]) {
int64_t recgrid_get_double_grid_index(const int64_t address_double[3],
const int64_t D_diag[3],
const int64_t PS[3]) {
return grg_get_double_grid_index(address_double, D_diag, PS);
}
long recgrid_get_grid_index_from_address(const long address[3],
const long D_diag[3]) {
int64_t recgrid_get_grid_index_from_address(const int64_t address[3],
const int64_t D_diag[3]) {
return grg_get_grid_index(address, D_diag);
}
long recgrid_rotate_grid_index(const long grid_index, const long rotation[3][3],
const long D_diag[3], const long PS[3]) {
int64_t recgrid_rotate_grid_index(const int64_t grid_index,
const int64_t rotation[3][3],
const int64_t D_diag[3],
const int64_t PS[3]) {
return grg_rotate_grid_index(grid_index, rotation, D_diag, PS);
}
long recgrid_get_reciprocal_point_group(long rec_rotations[48][3][3],
const long (*rotations)[3][3],
const long num_rot,
const long is_time_reversal,
const long is_transpose) {
int64_t recgrid_get_reciprocal_point_group(int64_t rec_rotations[48][3][3],
const int64_t (*rotations)[3][3],
const int64_t num_rot,
const int64_t is_time_reversal,
const int64_t is_transpose) {
return grg_get_reciprocal_point_group(rec_rotations, rotations, num_rot,
is_time_reversal, is_transpose);
}
long recgrid_get_snf3x3(long D_diag[3], long P[3][3], long Q[3][3],
const long A[3][3]) {
int64_t recgrid_get_snf3x3(int64_t D_diag[3], int64_t P[3][3], int64_t Q[3][3],
const int64_t A[3][3]) {
return grg_get_snf3x3(D_diag, P, Q, A);
}
long recgrid_transform_rotations(long (*transformed_rots)[3][3],
const long (*rotations)[3][3],
const long num_rot, const long D_diag[3],
const long Q[3][3]) {
long succeeded;
int64_t recgrid_transform_rotations(int64_t (*transformed_rots)[3][3],
const int64_t (*rotations)[3][3],
const int64_t num_rot,
const int64_t D_diag[3],
const int64_t Q[3][3]) {
int64_t succeeded;
succeeded = grg_transform_rotations(transformed_rots, rotations, num_rot,
D_diag, Q);
return succeeded;
}
long recgrid_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]) {
long num_ir, i;
int64_t recgrid_get_ir_grid_map(int64_t *ir_grid_map,
const int64_t (*rotations)[3][3],
const int64_t num_rot, const int64_t D_diag[3],
const int64_t PS[3]) {
int64_t num_ir, i;
grg_get_ir_grid_map(ir_grid_map, rotations, num_rot, D_diag, PS);
@ -114,13 +122,12 @@ long recgrid_get_ir_grid_map(long *ir_grid_map, const long (*rotations)[3][3],
return num_ir;
}
long recgrid_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],
const double rec_lattice[3][3],
const long bz_grid_type) {
int64_t recgrid_get_bz_grid_addresses(
int64_t (*bz_grid_addresses)[3], int64_t *bz_map, int64_t *bzg2grg,
const int64_t D_diag[3], const int64_t Q[3][3], const int64_t PS[3],
const double rec_lattice[3][3], const int64_t bz_grid_type) {
RecgridBZGrid *bzgrid;
long i, j, size;
int64_t i, j, size;
if ((bzgrid = (RecgridBZGrid *)malloc(sizeof(RecgridBZGrid))) == NULL) {
warning_print("Memory could not be allocated.");
@ -152,13 +159,12 @@ long recgrid_get_bz_grid_addresses(long (*bz_grid_addresses)[3], long *bz_map,
return size;
}
long recgrid_rotate_bz_grid_index(const long bz_grid_index,
const long rotation[3][3],
const long (*bz_grid_addresses)[3],
const long *bz_map, const long D_diag[3],
const long PS[3], const long bz_grid_type) {
int64_t recgrid_rotate_bz_grid_index(
const int64_t bz_grid_index, const int64_t rotation[3][3],
const int64_t (*bz_grid_addresses)[3], const int64_t *bz_map,
const int64_t D_diag[3], const int64_t PS[3], const int64_t bz_grid_type) {
RecgridConstBZGrid *bzgrid;
long i, rot_bz_gp;
int64_t i, rot_bz_gp;
if ((bzgrid = (RecgridConstBZGrid *)malloc(sizeof(RecgridConstBZGrid))) ==
NULL) {
@ -184,7 +190,7 @@ long recgrid_rotate_bz_grid_index(const long bz_grid_index,
/* Note: Tolerance in squared distance. */
double recgrid_get_tolerance_for_BZ_reduction(const RecgridBZGrid *bzgrid) {
long i, j;
int64_t i, j;
double tolerance;
double length[3];
double reclatQ[3][3];
@ -215,7 +221,7 @@ double recgrid_get_tolerance_for_BZ_reduction(const RecgridBZGrid *bzgrid) {
return tolerance;
}
RecgridMats *recgrid_alloc_RotMats(const long size) {
RecgridMats *recgrid_alloc_RotMats(const int64_t size) {
RecgridMats *rotmats;
rotmats = NULL;
@ -227,8 +233,8 @@ RecgridMats *recgrid_alloc_RotMats(const long size) {
rotmats->size = size;
if (size > 0) {
if ((rotmats->mat = (long(*)[3][3])malloc(sizeof(long[3][3]) * size)) ==
NULL) {
if ((rotmats->mat = (int64_t(*)[3][3])malloc(sizeof(int64_t[3][3]) *
size)) == NULL) {
warning_print("Memory could not be allocated ");
warning_print("(RecgridMats, line %d, %s).\n", __LINE__, __FILE__);
free(rotmats);

View File

@ -39,23 +39,25 @@
extern "C" {
#endif
#include <stdint.h>
typedef struct {
long size;
long (*mat)[3][3];
int64_t size;
int64_t (*mat)[3][3];
} RecgridMats;
/* Data structure of Brillouin zone grid
*
* size : long
* size : int64_t
* Number of grid points in Brillouin zone including its surface.
* D_diag : long array
* D_diag : int64_t array
* Diagonal part of matrix D of SNF.
* shape=(3, )
* PS : long array
* PS : int64_t array
* Matrix P of SNF multiplied by shift.
* shape=(3, )
* gp_map : long array
* Type1 : Twice enlarged grid space along basis vectors.
* gp_map : int64_t array
* Type1 : Twice enlarged grid space aint64_t basis vectors.
* Grid index is recovered in the same way as regular grid.
* shape=(prod(mesh * 2), )
* Type2 : In the last index, multiplicity and array index of
@ -63,36 +65,36 @@ typedef struct {
* multiplicity means the number of translationally
* equivalent grid points in BZ.
* shape=(prod(mesh), 2) -> flattened.
* addresses : long array
* addresses : int64_t array
* Grid point addresses.
* shape=(size, 3)
* reclat : double array
* Reciprocal basis vectors given as column vectors.
* shape=(3, 3)
* type : long
* type : int64_t
* 1 or 2. */
typedef struct {
long size;
long D_diag[3];
long Q[3][3];
long PS[3];
long *gp_map;
long *bzg2grg;
long (*addresses)[3];
int64_t size;
int64_t D_diag[3];
int64_t Q[3][3];
int64_t PS[3];
int64_t *gp_map;
int64_t *bzg2grg;
int64_t (*addresses)[3];
double reclat[3][3];
long type;
int64_t type;
} RecgridBZGrid;
typedef struct {
long size;
long D_diag[3];
long Q[3][3];
long PS[3];
const long *gp_map;
const long *bzg2grg;
const long (*addresses)[3];
int64_t size;
int64_t D_diag[3];
int64_t Q[3][3];
int64_t PS[3];
const int64_t *gp_map;
const int64_t *bzg2grg;
const int64_t (*addresses)[3];
double reclat[3][3];
long type;
int64_t type;
} RecgridConstBZGrid;
/* Generalized regular (GR) grid
@ -110,11 +112,11 @@ half-grid shift along an axis corresponds to 1.
* @brief Return all GR-grid addresses with respect to n_1, n_2, n_3
*
* @param gr_grid_addresses All GR-grid addresses
* @param D_diag Numbers of divisions along a, b, c directions of GR-grid
* @param D_diag Numbers of divisions aint64_t a, b, c directions of GR-grid
* @return void
*/
void recgrid_get_all_grid_addresses(long (*gr_grid_addresses)[3],
const long D_diag[3]);
void recgrid_get_all_grid_addresses(int64_t (*gr_grid_addresses)[3],
const int64_t D_diag[3]);
/**
* @brief Return double grid address in GR-grid
@ -125,53 +127,57 @@ void recgrid_get_all_grid_addresses(long (*gr_grid_addresses)[3],
* @param PS Shift in GR-grid
* @return void
*/
void recgrid_get_double_grid_address(long address_double[3],
const long address[3], const long PS[3]);
void recgrid_get_double_grid_address(int64_t address_double[3],
const int64_t address[3],
const int64_t PS[3]);
/**
* @brief Return single grid address in GR-grid with given grid point index.
*
* @param address Single grid address in GR-grid
* @param grid_index Grid point index in GR-grid
* @param D_diag Numbers of divisions along a, b, c directions of GR-grid
* @param D_diag Numbers of divisions aint64_t a, b, c directions of GR-grid
* @return void
*/
void recgrid_get_grid_address_from_index(long address[3], const long grid_index,
const long D_diag[3]);
void recgrid_get_grid_address_from_index(int64_t address[3],
const int64_t grid_index,
const int64_t D_diag[3]);
/**
* @brief Return grid point index of double grid address in GR-grid
*
* @param address_double Double grid address, i.e., possibly with shift in
* GR-grid
* @param D_diag Numbers of divisions along a, b, c directions of GR-grid
* @param D_diag Numbers of divisions aint64_t a, b, c directions of GR-grid
* @param PS Shift in GR-grid
* @return long
* @return int64_t
*/
long recgrid_get_double_grid_index(const long address_double[3],
const long D_diag[3], const long PS[3]);
int64_t recgrid_get_double_grid_index(const int64_t address_double[3],
const int64_t D_diag[3],
const int64_t PS[3]);
/**
* @brief Return grid point index of single grid address in GR-grid
*
* @param address Single grid address in GR-grid
* @param D_diag Numbers of divisions along a, b, c directions of GR-grid
* @return long
* @param D_diag Numbers of divisions aint64_t a, b, c directions of GR-grid
* @return int64_t
*/
long recgrid_get_grid_index_from_address(const long address[3],
const long D_diag[3]);
int64_t recgrid_get_grid_index_from_address(const int64_t address[3],
const int64_t D_diag[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 Transformed rotation in reciprocal space tilde-R^T
* @param D_diag Numbers of divisions along a, b, c directions of GR-grid
* @param D_diag Numbers of divisions aint64_t a, b, c directions of GR-grid
* @param PS Shift in GR-grid
* @return long
* @return int64_t
*/
long recgrid_rotate_grid_index(const long grid_index, const long rotation[3][3],
const long D_diag[3], const long PS[3]);
int64_t recgrid_rotate_grid_index(const int64_t grid_index,
const int64_t rotation[3][3],
const int64_t D_diag[3], const int64_t PS[3]);
/**
* @brief Return {R^T} of crystallographic point group {R} with and without time
@ -182,13 +188,13 @@ long recgrid_rotate_grid_index(const long grid_index, const long rotation[3][3],
* @param num_rot Number of given rotations |{R}|
* @param is_time_reversal With (1) or without (0) time reversal symmetry
* @param is_transpose With (1) or without (0) transpose of rotation matrices
* @return long
* @return int64_t
*/
long recgrid_get_reciprocal_point_group(long rec_rotations[48][3][3],
const long (*rotations)[3][3],
const long num_rot,
const long is_time_reversal,
const long is_transpose);
int64_t recgrid_get_reciprocal_point_group(int64_t rec_rotations[48][3][3],
const int64_t (*rotations)[3][3],
const int64_t num_rot,
const int64_t is_time_reversal,
const int64_t is_transpose);
/**
* @brief Return D, P, Q of Smith normal form of A.
*
@ -196,10 +202,10 @@ long recgrid_get_reciprocal_point_group(long rec_rotations[48][3][3],
* @param P Unimodular matrix P
* @param Q Unimodular matrix Q
* @param A Integer matrix
* @return long
* @return int64_t
*/
long recgrid_get_snf3x3(long D_diag[3], long P[3][3], long Q[3][3],
const long A[3][3]);
int64_t recgrid_get_snf3x3(int64_t D_diag[3], int64_t P[3][3], int64_t Q[3][3],
const int64_t A[3][3]);
/**
* @brief Transform {R^T} to {R^T} with respect to transformed microzone basis
@ -211,12 +217,13 @@ long recgrid_get_snf3x3(long D_diag[3], long P[3][3], long Q[3][3],
* @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
* @return long
* @return int64_t
*/
long recgrid_transform_rotations(long (*transformed_rots)[3][3],
const long (*rotations)[3][3],
const long num_rot, const long D_diag[3],
const long Q[3][3]);
int64_t recgrid_transform_rotations(int64_t (*transformed_rots)[3][3],
const int64_t (*rotations)[3][3],
const int64_t num_rot,
const int64_t D_diag[3],
const int64_t Q[3][3]);
/**
* @brief Return mapping table from GR-grid points to GR-ir-grid points
@ -227,11 +234,12 @@ long recgrid_transform_rotations(long (*transformed_rots)[3][3],
* @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
* @return long Number of ir_grid_points.
* @return int64_t Number of ir_grid_points.
*/
long recgrid_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]);
int64_t recgrid_get_ir_grid_map(int64_t *ir_grid_map,
const int64_t (*rotations)[3][3],
const int64_t num_rot, const int64_t D_diag[3],
const int64_t PS[3]);
/**
* @brief Find shortest grid points from Gamma considering periodicity of
@ -250,13 +258,12 @@ long recgrid_get_ir_grid_map(long *ir_grid_map, const long (*rotations)[3][3],
* @param rec_lattice Reduced reciprocal basis vectors in column vectors
* @param bz_grid_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.
* @return int64_t Number of bz_grid_addresses stored.
*/
long recgrid_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],
const double rec_lattice[3][3],
const long bz_grid_type);
int64_t recgrid_get_bz_grid_addresses(
int64_t (*bz_grid_addresses)[3], int64_t *bz_map, int64_t *bzg2grg,
const int64_t D_diag[3], const int64_t Q[3][3], const int64_t PS[3],
const double rec_lattice[3][3], const int64_t bz_grid_type);
/**
* @brief Return index of rotated bz grid point
@ -271,15 +278,14 @@ long recgrid_get_bz_grid_addresses(long (*bz_grid_addresses)[3], long *bz_map,
* @param PS Shift in GR-grid
* @param bz_grid_type Data structure type I (old and sparse) or II (new and
* dense, recommended) of bz_map
* @return long
* @return int64_t
*/
long recgrid_rotate_bz_grid_index(const long bz_grid_index,
const long rotation[3][3],
const long (*bz_grid_addresses)[3],
const long *bz_map, const long D_diag[3],
const long PS[3], const long bz_grid_type);
int64_t recgrid_rotate_bz_grid_index(
const int64_t bz_grid_index, const int64_t rotation[3][3],
const int64_t (*bz_grid_addresses)[3], const int64_t *bz_map,
const int64_t D_diag[3], const int64_t PS[3], const int64_t bz_grid_type);
double recgrid_get_tolerance_for_BZ_reduction(const RecgridBZGrid *bzgrid);
RecgridMats *recgrid_alloc_RotMats(const long size);
RecgridMats *recgrid_alloc_RotMats(const int64_t size);
void recgrid_free_RotMats(RecgridMats *rotmats);
#ifdef __cplusplus

View File

@ -34,6 +34,8 @@
#include "reciprocal_to_normal.h"
#include <stdint.h>
#ifdef MULTITHREADED_BLAS
#if defined(MKL_BLAS) || defined(SCIPY_MKL_H)
#include <mkl_cblas.h>
@ -56,29 +58,29 @@ static double get_fc3_sum(const lapack_complex_double *e0,
const lapack_complex_double *e1,
const lapack_complex_double *e2,
const lapack_complex_double *fc3_reciprocal,
const long num_band);
const int64_t num_band);
#ifdef MULTITHREADED_BLAS
static double get_fc3_sum_blas(const lapack_complex_double *e0,
const lapack_complex_double *e1,
const lapack_complex_double *e2,
const lapack_complex_double *fc3_reciprocal,
const long num_band);
const int64_t num_band);
#endif
static double get_fc3_sum_blas_like(const lapack_complex_double *e0,
const lapack_complex_double *e1,
const lapack_complex_double *e2,
const lapack_complex_double *fc3_reciprocal,
const long num_band);
const int64_t num_band);
void reciprocal_to_normal_squared(
double *fc3_normal_squared, const long (*g_pos)[4], const long num_g_pos,
const lapack_complex_double *fc3_reciprocal, const double *freqs0,
const double *freqs1, const double *freqs2,
double *fc3_normal_squared, const int64_t (*g_pos)[4],
const int64_t num_g_pos, const lapack_complex_double *fc3_reciprocal,
const double *freqs0, const double *freqs1, const double *freqs2,
const lapack_complex_double *eigvecs0,
const lapack_complex_double *eigvecs1,
const lapack_complex_double *eigvecs2, const double *masses,
const long *band_indices, const long num_band,
const double cutoff_frequency, const long openmp_per_triplets) {
long i, j, ij, num_atom, use_multithreaded_blas;
const int64_t *band_indices, const int64_t num_band,
const double cutoff_frequency, const int64_t openmp_per_triplets) {
int64_t i, j, ij, num_atom, use_multithreaded_blas;
double *inv_sqrt_masses;
lapack_complex_double *e0, *e1, *e2;
@ -199,8 +201,8 @@ static double get_fc3_sum(const lapack_complex_double *e0,
const lapack_complex_double *e1,
const lapack_complex_double *e2,
const lapack_complex_double *fc3_reciprocal,
const long num_band) {
long i, j, jk;
const int64_t num_band) {
int64_t i, j, jk;
double sum_real, sum_imag;
lapack_complex_double e_012_fc3, fc3_i_e_12, *e_12_cache;
const lapack_complex_double *fc3_i;
@ -237,8 +239,8 @@ static double get_fc3_sum_blas(const lapack_complex_double *e0,
const lapack_complex_double *e1,
const lapack_complex_double *e2,
const lapack_complex_double *fc3_reciprocal,
const long num_band) {
long i;
const int64_t num_band) {
int64_t i;
lapack_complex_double *fc3_e12, *e_12, zero, one, retval;
e_12 = (lapack_complex_double *)malloc(sizeof(lapack_complex_double) *
@ -274,8 +276,8 @@ static double get_fc3_sum_blas_like(const lapack_complex_double *e0,
const lapack_complex_double *e1,
const lapack_complex_double *e2,
const lapack_complex_double *fc3_reciprocal,
const long num_band) {
long i, j;
const int64_t num_band) {
int64_t i, j;
double sum_real, sum_imag, retval_real, retval_imag;
lapack_complex_double *e_12, fc3_e_12, fc3_e_012;

View File

@ -35,16 +35,18 @@
#ifndef __reciprocal_to_normal_H__
#define __reciprocal_to_normal_H__
#include <stdint.h>
#include "lapack_wrapper.h"
void reciprocal_to_normal_squared(
double *fc3_normal_squared, const long (*g_pos)[4], const long num_g_pos,
const lapack_complex_double *fc3_reciprocal, const double *freqs0,
const double *freqs1, const double *freqs2,
double *fc3_normal_squared, const int64_t (*g_pos)[4],
const int64_t num_g_pos, const lapack_complex_double *fc3_reciprocal,
const double *freqs0, const double *freqs1, const double *freqs2,
const lapack_complex_double *eigvecs0,
const lapack_complex_double *eigvecs1,
const lapack_complex_double *eigvecs2, const double *masses,
const long *band_indices, const long num_band,
const double cutoff_frequency, const long openmp_per_triplets);
const int64_t *band_indices, const int64_t num_band,
const double cutoff_frequency, const int64_t openmp_per_triplets);
#endif

View File

@ -1,45 +1,47 @@
#include <assert.h>
#include <stdint.h>
/* #include <stdio.h> */
#ifndef SNF3x3CONST
#define SNF3x3CONST
#endif
static void initialize_PQ(long P[3][3], long Q[3][3]);
static int first(long A[3][3], long P[3][3], long Q[3][3]);
static void first_one_loop(long A[3][3], long P[3][3], long Q[3][3]);
static void first_column(long A[3][3], long P[3][3]);
static void zero_first_column(long L[3][3], const int j,
SNF3x3CONST long A[3][3]);
static int search_first_pivot(SNF3x3CONST long A[3][3]);
static void first_finalize(long L[3][3], SNF3x3CONST long A[3][3]);
static int second(long A[3][3], long P[3][3], long Q[3][3]);
static void second_one_loop(long A[3][3], long P[3][3], long Q[3][3]);
static void second_column(long A[3][3], long P[3][3]);
static void zero_second_column(long L[3][3], SNF3x3CONST long A[3][3]);
static void second_finalize(long L[3][3], SNF3x3CONST long A[3][3]);
static void finalize(long A[3][3], long P[3][3], long Q[3][3]);
static void finalize_sort(long A[3][3], long P[3][3], long Q[3][3]);
static void finalize_disturb(long A[3][3], long Q[3][3], const int i,
static void initialize_PQ(int64_t P[3][3], int64_t Q[3][3]);
static int first(int64_t A[3][3], int64_t P[3][3], int64_t Q[3][3]);
static void first_one_loop(int64_t A[3][3], int64_t P[3][3], int64_t Q[3][3]);
static void first_column(int64_t A[3][3], int64_t P[3][3]);
static void zero_first_column(int64_t L[3][3], const int j,
SNF3x3CONST int64_t A[3][3]);
static int search_first_pivot(SNF3x3CONST int64_t A[3][3]);
static void first_finalize(int64_t L[3][3], SNF3x3CONST int64_t A[3][3]);
static int second(int64_t A[3][3], int64_t P[3][3], int64_t Q[3][3]);
static void second_one_loop(int64_t A[3][3], int64_t P[3][3], int64_t Q[3][3]);
static void second_column(int64_t A[3][3], int64_t P[3][3]);
static void zero_second_column(int64_t L[3][3], SNF3x3CONST int64_t A[3][3]);
static void second_finalize(int64_t L[3][3], SNF3x3CONST int64_t A[3][3]);
static void finalize(int64_t A[3][3], int64_t P[3][3], int64_t Q[3][3]);
static void finalize_sort(int64_t A[3][3], int64_t P[3][3], int64_t Q[3][3]);
static void finalize_disturb(int64_t A[3][3], int64_t Q[3][3], const int i,
const int j);
static void disturb_rows(long L[3][3], const int i, const int j);
static void swap_diag_elems(long A[3][3], long P[3][3], long Q[3][3],
static void disturb_rows(int64_t L[3][3], const int i, const int j);
static void swap_diag_elems(int64_t A[3][3], int64_t P[3][3], int64_t Q[3][3],
const int i, const int j);
static void make_diagA_positive(long A[3][3], long P[3][3]);
static void flip_PQ(long P[3][3], long Q[3][3]);
static void swap_rows(long L[3][3], const int i, const int j);
static void set_zero(long L[3][3], const int i, const int j, const long a,
const long b, const long r, const long s, const long t);
static void extended_gcd(long retvals[3], const long a, const long b);
static void extended_gcd_step(long vals[6]);
static void flip_sign_row(long L[3][3], const int i);
static void transpose(long m[3][3]);
static void matmul(long m[3][3], SNF3x3CONST long a[3][3],
SNF3x3CONST long b[3][3]);
static long det(SNF3x3CONST long m[3][3]);
static void make_diagA_positive(int64_t A[3][3], int64_t P[3][3]);
static void flip_PQ(int64_t P[3][3], int64_t Q[3][3]);
static void swap_rows(int64_t L[3][3], const int i, const int j);
static void set_zero(int64_t L[3][3], const int i, const int j, const int64_t a,
const int64_t b, const int64_t r, const int64_t s,
const int64_t t);
static void extended_gcd(int64_t retvals[3], const int64_t a, const int64_t b);
static void extended_gcd_step(int64_t vals[6]);
static void flip_sign_row(int64_t L[3][3], const int i);
static void transpose(int64_t m[3][3]);
static void matmul(int64_t m[3][3], SNF3x3CONST int64_t a[3][3],
SNF3x3CONST int64_t b[3][3]);
static int64_t det(SNF3x3CONST int64_t m[3][3]);
/* static void test_set_A(long A[3][3]);
* static void test_show_A(SNF3x3CONST long A[3][3]);
/* static void test_set_A(int64_t A[3][3]);
* static void test_show_A(SNF3x3CONST int64_t A[3][3]);
* static void test_extended_gcd(void);
* static void test_transpose(void);
* static void test_swap_rows(void);
@ -51,7 +53,7 @@ static long det(SNF3x3CONST long m[3][3]);
* static void test_second_one_loop(void);
* static void test_second(void); */
int snf3x3(long A[3][3], long P[3][3], long Q[3][3]) {
int snf3x3(int64_t A[3][3], int64_t P[3][3], int64_t Q[3][3]) {
int i;
initialize_PQ(P, Q);
@ -70,7 +72,7 @@ succeeded:
return 1;
}
static void initialize_PQ(long P[3][3], long Q[3][3]) {
static void initialize_PQ(int64_t P[3][3], int64_t Q[3][3]) {
int i, j;
for (i = 0; i < 3; i++) {
@ -86,8 +88,8 @@ static void initialize_PQ(long P[3][3], long Q[3][3]) {
}
}
static int first(long A[3][3], long P[3][3], long Q[3][3]) {
long L[3][3];
static int first(int64_t A[3][3], int64_t P[3][3], int64_t Q[3][3]) {
int64_t L[3][3];
first_one_loop(A, P, Q);
@ -108,16 +110,16 @@ static int first(long A[3][3], long P[3][3], long Q[3][3]) {
return 0;
}
static void first_one_loop(long A[3][3], long P[3][3], long Q[3][3]) {
static void first_one_loop(int64_t A[3][3], int64_t P[3][3], int64_t Q[3][3]) {
first_column(A, P);
transpose(A);
first_column(A, Q);
transpose(A);
}
static void first_column(long A[3][3], long P[3][3]) {
static void first_column(int64_t A[3][3], int64_t P[3][3]) {
int i;
long L[3][3];
int64_t L[3][3];
i = search_first_pivot(A);
if (i > 0) {
@ -143,15 +145,15 @@ static void first_column(long A[3][3], long P[3][3]) {
err:;
}
static void zero_first_column(long L[3][3], const int j,
SNF3x3CONST long A[3][3]) {
long vals[3];
static void zero_first_column(int64_t L[3][3], const int j,
SNF3x3CONST int64_t A[3][3]) {
int64_t vals[3];
extended_gcd(vals, A[0][0], A[j][0]);
set_zero(L, 0, j, A[0][0], A[j][0], vals[0], vals[1], vals[2]);
}
static int search_first_pivot(SNF3x3CONST long A[3][3]) {
static int search_first_pivot(SNF3x3CONST int64_t A[3][3]) {
int i;
for (i = 0; i < 3; i++) {
@ -162,7 +164,7 @@ static int search_first_pivot(SNF3x3CONST long A[3][3]) {
return -1;
}
static void first_finalize(long L[3][3], SNF3x3CONST long A[3][3]) {
static void first_finalize(int64_t L[3][3], SNF3x3CONST int64_t A[3][3]) {
L[0][0] = 1;
L[0][1] = 0;
L[0][2] = 0;
@ -174,8 +176,8 @@ static void first_finalize(long L[3][3], SNF3x3CONST long A[3][3]) {
L[2][2] = 1;
}
static int second(long A[3][3], long P[3][3], long Q[3][3]) {
long L[3][3];
static int second(int64_t A[3][3], int64_t P[3][3], int64_t Q[3][3]) {
int64_t L[3][3];
second_one_loop(A, P, Q);
@ -193,15 +195,15 @@ static int second(long A[3][3], long P[3][3], long Q[3][3]) {
return 0;
}
static void second_one_loop(long A[3][3], long P[3][3], long Q[3][3]) {
static void second_one_loop(int64_t A[3][3], int64_t P[3][3], int64_t Q[3][3]) {
second_column(A, P);
transpose(A);
second_column(A, Q);
transpose(A);
}
static void second_column(long A[3][3], long P[3][3]) {
long L[3][3];
static void second_column(int64_t A[3][3], int64_t P[3][3]) {
int64_t L[3][3];
if ((A[1][1] == 0) && (A[2][1] != 0)) {
swap_rows(L, 1, 2);
@ -216,14 +218,14 @@ static void second_column(long A[3][3], long P[3][3]) {
}
}
static void zero_second_column(long L[3][3], SNF3x3CONST long A[3][3]) {
long vals[3];
static void zero_second_column(int64_t L[3][3], SNF3x3CONST int64_t A[3][3]) {
int64_t vals[3];
extended_gcd(vals, A[1][1], A[2][1]);
set_zero(L, 1, 2, A[1][1], A[2][1], vals[0], vals[1], vals[2]);
}
static void second_finalize(long L[3][3], SNF3x3CONST long A[3][3]) {
static void second_finalize(int64_t L[3][3], SNF3x3CONST int64_t A[3][3]) {
L[0][0] = 1;
L[0][1] = 0;
L[0][2] = 0;
@ -235,7 +237,7 @@ static void second_finalize(long L[3][3], SNF3x3CONST long A[3][3]) {
L[2][2] = 1;
}
static void finalize(long A[3][3], long P[3][3], long Q[3][3]) {
static void finalize(int64_t A[3][3], int64_t P[3][3], int64_t Q[3][3]) {
make_diagA_positive(A, P);
finalize_sort(A, P, Q);
@ -247,7 +249,7 @@ static void finalize(long A[3][3], long P[3][3], long Q[3][3]) {
flip_PQ(P, Q);
}
static void finalize_sort(long A[3][3], long P[3][3], long Q[3][3]) {
static void finalize_sort(int64_t A[3][3], int64_t P[3][3], int64_t Q[3][3]) {
if (A[0][0] > A[1][1]) {
swap_diag_elems(A, P, Q, 0, 1);
}
@ -259,9 +261,9 @@ static void finalize_sort(long A[3][3], long P[3][3], long Q[3][3]) {
}
}
static void finalize_disturb(long A[3][3], long Q[3][3], const int i,
static void finalize_disturb(int64_t A[3][3], int64_t Q[3][3], const int i,
const int j) {
long L[3][3];
int64_t L[3][3];
if (A[j][j] % A[i][i] != 0) {
transpose(A);
@ -272,7 +274,7 @@ static void finalize_disturb(long A[3][3], long Q[3][3], const int i,
}
}
static void disturb_rows(long L[3][3], const int i, const int j) {
static void disturb_rows(int64_t L[3][3], const int i, const int j) {
L[0][0] = 1;
L[0][1] = 0;
L[0][2] = 0;
@ -288,9 +290,9 @@ static void disturb_rows(long L[3][3], const int i, const int j) {
L[j][j] = 1;
}
static void swap_diag_elems(long A[3][3], long P[3][3], long Q[3][3],
static void swap_diag_elems(int64_t A[3][3], int64_t P[3][3], int64_t Q[3][3],
const int i, const int j) {
long L[3][3];
int64_t L[3][3];
swap_rows(L, i, j);
matmul(A, L, A);
@ -302,9 +304,9 @@ static void swap_diag_elems(long A[3][3], long P[3][3], long Q[3][3],
transpose(A);
}
static void make_diagA_positive(long A[3][3], long P[3][3]) {
static void make_diagA_positive(int64_t A[3][3], int64_t P[3][3]) {
int i;
long L[3][3];
int64_t L[3][3];
for (i = 0; i < 3; i++) {
if (A[i][i] < 0) {
@ -315,7 +317,7 @@ static void make_diagA_positive(long A[3][3], long P[3][3]) {
}
}
static void flip_PQ(long P[3][3], long Q[3][3]) {
static void flip_PQ(int64_t P[3][3], int64_t Q[3][3]) {
int i, j;
if (det(P) < 0) {
@ -328,7 +330,7 @@ static void flip_PQ(long P[3][3], long Q[3][3]) {
}
}
static void swap_rows(long L[3][3], const int r1, const int r2) {
static void swap_rows(int64_t L[3][3], const int r1, const int r2) {
L[0][0] = 1;
L[0][1] = 0;
L[0][2] = 0;
@ -344,8 +346,9 @@ static void swap_rows(long L[3][3], const int r1, const int r2) {
L[r2][r1] = 1;
}
static void set_zero(long L[3][3], const int i, const int j, const long a,
const long b, const long r, const long s, const long t) {
static void set_zero(int64_t L[3][3], const int i, const int j, const int64_t a,
const int64_t b, const int64_t r, const int64_t s,
const int64_t t) {
L[0][0] = 1;
L[0][1] = 0;
L[0][2] = 0;
@ -365,9 +368,9 @@ static void set_zero(long L[3][3], const int i, const int j, const long a,
* Extended Euclidean algorithm
* See https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
*/
static void extended_gcd(long retvals[3], const long a, const long b) {
static void extended_gcd(int64_t retvals[3], const int64_t a, const int64_t b) {
int i;
long vals[6];
int64_t vals[6];
vals[0] = a; /* r0 */
vals[1] = b; /* r1 */
@ -390,8 +393,8 @@ static void extended_gcd(long retvals[3], const long a, const long b) {
assert(vals[0] == a * vals[2] + b * vals[4]);
}
static void extended_gcd_step(long vals[6]) {
long q, r2, s2, t2;
static void extended_gcd_step(int64_t vals[6]) {
int64_t q, r2, s2, t2;
q = vals[0] / vals[1];
r2 = vals[0] % vals[1];
@ -415,7 +418,7 @@ static void extended_gcd_step(long vals[6]) {
vals[5] = t2;
}
static void flip_sign_row(long L[3][3], const int i) {
static void flip_sign_row(int64_t L[3][3], const int i) {
L[0][0] = 1;
L[0][1] = 0;
L[0][2] = 0;
@ -431,8 +434,8 @@ static void flip_sign_row(long L[3][3], const int i) {
/**
* Matrix operation utils
*/
static void transpose(long m[3][3]) {
long tmp;
static void transpose(int64_t m[3][3]) {
int64_t tmp;
int i, j;
for (i = 0; i < 3; i++) {
@ -444,10 +447,10 @@ static void transpose(long m[3][3]) {
}
}
static void matmul(long m[3][3], SNF3x3CONST long a[3][3],
SNF3x3CONST long b[3][3]) {
static void matmul(int64_t m[3][3], SNF3x3CONST int64_t a[3][3],
SNF3x3CONST int64_t b[3][3]) {
int i, j;
long c[3][3];
int64_t c[3][3];
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
@ -462,7 +465,7 @@ static void matmul(long m[3][3], SNF3x3CONST long a[3][3],
}
}
static long det(SNF3x3CONST long m[3][3]) {
static int64_t det(SNF3x3CONST int64_t m[3][3]) {
return m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) +
m[0][1] * (m[1][2] * m[2][0] - m[1][0] * m[2][2]) +
m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);
@ -482,7 +485,7 @@ static long det(SNF3x3CONST long m[3][3]) {
* test_second();
* }
*
* static void test_set_A(long A[3][3])
* static void test_set_A(int64_t A[3][3])
* {
* int i, j;
*
@ -494,7 +497,7 @@ static long det(SNF3x3CONST long m[3][3]) {
* A[0][0] = 1; /\* to avoid det(A) = 0 *\/
* }
*
* static void test_show_A(SNF3x3CONST long A[3][3])
* static void test_show_A(SNF3x3CONST int64_t A[3][3])
* {
* int i, j;
*
@ -518,7 +521,7 @@ static long det(SNF3x3CONST long m[3][3]) {
* static void test_transpose(void)
* {
* int i, j;
* long A[3][3];
* int64_t A[3][3];
*
* printf("Test transpose\n");
*
@ -531,7 +534,7 @@ static long det(SNF3x3CONST long m[3][3]) {
* static void test_swap_rows(void)
* {
* int i, j;
* long A[3][3], L[3][3];
* int64_t A[3][3], L[3][3];
*
* printf("Test swap_rows 1 <-> 2\n");
*
@ -545,7 +548,7 @@ static long det(SNF3x3CONST long m[3][3]) {
* static void test_zero_first_column(void)
* {
* int i, j;
* long A[3][3], L[3][3];
* int64_t A[3][3], L[3][3];
*
* printf("Test zero_first_column\n");
*
@ -562,7 +565,7 @@ static long det(SNF3x3CONST long m[3][3]) {
* static void test_first_column(void)
* {
* int i, j;
* long A[3][3], P[3][3];
* int64_t A[3][3], P[3][3];
*
* printf("Test first_column\n");
*
@ -579,7 +582,7 @@ static long det(SNF3x3CONST long m[3][3]) {
* static void test_first_one_loop(void)
* {
* int i, j;
* long A[3][3], P[3][3], Q[3][3];
* int64_t A[3][3], P[3][3], Q[3][3];
*
* printf("Test first_one_loop\n");
*
@ -592,7 +595,7 @@ static long det(SNF3x3CONST long m[3][3]) {
* static void test_first(void)
* {
* int i, j;
* long A[3][3], P[3][3], Q[3][3];
* int64_t A[3][3], P[3][3], Q[3][3];
*
* printf("Test first\n");
*
@ -605,7 +608,7 @@ static long det(SNF3x3CONST long m[3][3]) {
* static void test_second_column(void)
* {
* int i, j;
* long A[3][3], P[3][3], Q[3][3];
* int64_t A[3][3], P[3][3], Q[3][3];
*
* printf("Test second_column\n");
*
@ -620,7 +623,7 @@ static long det(SNF3x3CONST long m[3][3]) {
* static void test_second_one_loop(void)
* {
* int i, j;
* long A[3][3], P[3][3], Q[3][3];
* int64_t A[3][3], P[3][3], Q[3][3];
*
* printf("Test second_one_loop\n");
*
@ -635,7 +638,7 @@ static long det(SNF3x3CONST long m[3][3]) {
* static void test_second(void)
* {
* int i, j;
* long A[3][3], P[3][3], Q[3][3];
* int64_t A[3][3], P[3][3], Q[3][3];
*
* printf("Test second\n");
*

View File

@ -5,11 +5,13 @@
extern "C" {
#endif
#include <stdint.h>
#define SNF3X3_MAJOR_VERSION 0
#define SNF3X3_MINOR_VERSION 1
#define SNF3X3_MICRO_VERSION 0
int snf3x3(long A[3][3], long P[3][3], long Q[3][3]);
int snf3x3(int64_t A[3][3], int64_t P[3][3], int64_t Q[3][3]);
#ifdef __cplusplus
}

View File

@ -37,6 +37,7 @@
#include "tetrahedron_method.h"
#include <stddef.h>
#include <stdint.h>
#ifdef THMWARNING
#include <stdio.h>
@ -68,12 +69,12 @@
/* 6: c + b 2, 4, 7 */
/* 7: c + a + b 3, 5, 6 */
static long main_diagonals[4][3] = {{1, 1, 1}, /* 0-7 */
{-1, 1, 1}, /* 1-6 */
{1, -1, 1}, /* 2-5 */
{1, 1, -1}}; /* 3-4 */
static int64_t main_diagonals[4][3] = {{1, 1, 1}, /* 0-7 */
{-1, 1, 1}, /* 1-6 */
{1, -1, 1}, /* 2-5 */
{1, 1, -1}}; /* 3-4 */
static long db_relative_grid_address[4][24][4][3] = {
static int64_t db_relative_grid_address[4][24][4][3] = {
{
{
{0, 0, 0},
@ -662,22 +663,22 @@ static long db_relative_grid_address[4][24][4][3] = {
static double get_integration_weight(
const double omega, const double tetrahedra_omegas[24][4],
double (*gn)(const long, const double, const double[4]),
double (*IJ)(const long, const long, const double, const double[4]));
static long get_main_diagonal(const double rec_lattice[3][3]);
static long sort_omegas(double v[4]);
double (*gn)(const int64_t, const double, const double[4]),
double (*IJ)(const int64_t, const int64_t, const double, const double[4]));
static int64_t get_main_diagonal(const double rec_lattice[3][3]);
static int64_t sort_omegas(double v[4]);
static double norm_squared_d3(const double a[3]);
static void multiply_matrix_vector_dl3(double v[3], const double a[3][3],
const long b[3]);
static double _f(const long n, const long m, const double omega,
const int64_t b[3]);
static double _f(const int64_t n, const int64_t m, const double omega,
const double vertices_omegas[4]);
static double _J(const long i, const long ci, const double omega,
static double _J(const int64_t i, const int64_t ci, const double omega,
const double vertices_omegas[4]);
static double _I(const long i, const long ci, const double omega,
static double _I(const int64_t i, const int64_t ci, const double omega,
const double vertices_omegas[4]);
static double _n(const long i, const double omega,
static double _n(const int64_t i, const double omega,
const double vertices_omegas[4]);
static double _g(const long i, const double omega,
static double _g(const int64_t i, const double omega,
const double vertices_omegas[4]);
static double _n_0(void);
static double _n_1(const double omega, const double vertices_omegas[4]);
@ -718,9 +719,9 @@ static double _I_32(const double omega, const double vertices_omegas[4]);
static double _I_33(const double omega, const double vertices_omegas[4]);
static double _I_4(void);
long thm_get_relative_grid_address(long relative_grid_address[24][4][3],
const double rec_lattice[3][3]) {
long i, j, k, main_diag_index;
int64_t thm_get_relative_grid_address(int64_t relative_grid_address[24][4][3],
const double rec_lattice[3][3]) {
int64_t i, j, k, main_diag_index;
main_diag_index = get_main_diagonal(rec_lattice);
@ -736,8 +737,8 @@ long thm_get_relative_grid_address(long relative_grid_address[24][4][3],
}
void thm_get_all_relative_grid_address(
long relative_grid_address[4][24][4][3]) {
long i, j, k, main_diag_index;
int64_t relative_grid_address[4][24][4][3]) {
int64_t i, j, k, main_diag_index;
for (main_diag_index = 0; main_diag_index < 4; main_diag_index++) {
for (i = 0; i < 24; i++) {
@ -761,8 +762,8 @@ double thm_get_integration_weight(const double omega,
}
}
long thm_in_tetrahedra(const double f0, const double freq_vertices[24][4]) {
long i, j;
int64_t thm_in_tetrahedra(const double f0, const double freq_vertices[24][4]) {
int64_t i, j;
double fmin, fmax;
fmin = freq_vertices[0][0];
@ -788,9 +789,9 @@ long thm_in_tetrahedra(const double f0, const double freq_vertices[24][4]) {
static double get_integration_weight(
const double omega, const double tetrahedra_omegas[24][4],
double (*gn)(const long, const double, const double[4]),
double (*IJ)(const long, const long, const double, const double[4])) {
long i, j, ci;
double (*gn)(const int64_t, const double, const double[4]),
double (*IJ)(const int64_t, const int64_t, const double, const double[4])) {
int64_t i, j, ci;
double sum;
double v[4];
@ -823,8 +824,8 @@ static double get_integration_weight(
return sum / 6;
}
static long sort_omegas(double v[4]) {
long i;
static int64_t sort_omegas(double v[4]) {
int64_t i;
double w[4];
i = 0;
@ -892,8 +893,8 @@ static long sort_omegas(double v[4]) {
return i;
}
static long get_main_diagonal(const double rec_lattice[3][3]) {
long i, shortest;
static int64_t get_main_diagonal(const double rec_lattice[3][3]) {
int64_t i, shortest;
double length, min_length;
double main_diag[3];
@ -916,8 +917,8 @@ static double norm_squared_d3(const double a[3]) {
}
static void multiply_matrix_vector_dl3(double v[3], const double a[3][3],
const long b[3]) {
long i;
const int64_t b[3]) {
int64_t i;
double c[3];
for (i = 0; i < 3; i++) {
@ -929,7 +930,7 @@ static void multiply_matrix_vector_dl3(double v[3], const double a[3][3],
}
}
static double _f(const long n, const long m, const double omega,
static double _f(const int64_t n, const int64_t m, const double omega,
const double vertices_omegas[4]) {
double delta;
delta = vertices_omegas[n] - vertices_omegas[m];
@ -943,7 +944,7 @@ static double _f(const long n, const long m, const double omega,
return ((omega - vertices_omegas[m]) / delta);
}
static double _J(const long i, const long ci, const double omega,
static double _J(const int64_t i, const int64_t ci, const double omega,
const double vertices_omegas[4]) {
switch (i) {
case 0:
@ -993,7 +994,7 @@ static double _J(const long i, const long ci, const double omega,
return 0;
}
static double _I(const long i, const long ci, const double omega,
static double _I(const int64_t i, const int64_t ci, const double omega,
const double vertices_omegas[4]) {
switch (i) {
case 0:
@ -1043,7 +1044,7 @@ static double _I(const long i, const long ci, const double omega,
return 0;
}
static double _n(const long i, const double omega,
static double _n(const int64_t i, const double omega,
const double vertices_omegas[4]) {
switch (i) {
case 0:
@ -1066,7 +1067,7 @@ static double _n(const long i, const double omega,
return 0;
}
static double _g(const long i, const double omega,
static double _g(const int64_t i, const double omega,
const double vertices_omegas[4]) {
switch (i) {
case 0:

View File

@ -36,13 +36,15 @@
#define __tetrahedron_method_H__
#include <stddef.h>
#include <stdint.h>
long thm_get_relative_grid_address(long relative_grid_address[24][4][3],
const double rec_lattice[3][3]);
void thm_get_all_relative_grid_address(long relative_grid_address[4][24][4][3]);
int64_t thm_get_relative_grid_address(int64_t relative_grid_address[24][4][3],
const double rec_lattice[3][3]);
void thm_get_all_relative_grid_address(
int64_t relative_grid_address[4][24][4][3]);
double thm_get_integration_weight(const double omega,
const double tetrahedra_omegas[24][4],
const char function);
long thm_in_tetrahedra(const double f0, const double freq_vertices[24][4]);
int64_t thm_in_tetrahedra(const double f0, const double freq_vertices[24][4]);
#endif

View File

@ -36,21 +36,25 @@
#include "triplet.h"
#include <stdint.h>
#include "recgrid.h"
#include "triplet_grid.h"
#include "triplet_iw.h"
long tpl_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point,
const RecgridConstBZGrid *bzgrid,
const long *map_triplets) {
int64_t tpl_get_BZ_triplets_at_q(int64_t (*triplets)[3],
const int64_t grid_point,
const RecgridConstBZGrid *bzgrid,
const int64_t *map_triplets) {
return tpk_get_BZ_triplets_at_q(triplets, grid_point, bzgrid, map_triplets);
}
long tpl_get_triplets_reciprocal_mesh_at_q(
long *map_triplets, long *map_q, const long grid_point, const long mesh[3],
const long is_time_reversal, const long num_rot,
const long (*rec_rotations)[3][3], const long swappable) {
long num_ir;
int64_t tpl_get_triplets_reciprocal_mesh_at_q(
int64_t *map_triplets, int64_t *map_q, const int64_t grid_point,
const int64_t mesh[3], const int64_t is_time_reversal,
const int64_t num_rot, const int64_t (*rec_rotations)[3][3],
const int64_t swappable) {
int64_t num_ir;
num_ir = tpk_get_ir_triplets_at_q(map_triplets, map_q, grid_point, mesh,
is_time_reversal, rec_rotations, num_rot,
@ -60,13 +64,14 @@ long tpl_get_triplets_reciprocal_mesh_at_q(
void tpl_get_integration_weight(
double *iw, char *iw_zero, const double *frequency_points,
const long num_band0, const long relative_grid_address[24][4][3],
const long (*triplets)[3], const long num_triplets,
const int64_t num_band0, const int64_t relative_grid_address[24][4][3],
const int64_t (*triplets)[3], const int64_t num_triplets,
const RecgridConstBZGrid *bzgrid, const double *frequencies1,
const long num_band1, const double *frequencies2, const long num_band2,
const long tp_type, const long openmp_per_triplets) {
long i, num_band_prod;
long tp_relative_grid_address[2][24][4][3];
const int64_t num_band1, const double *frequencies2,
const int64_t num_band2, const int64_t tp_type,
const int64_t openmp_per_triplets) {
int64_t i, num_band_prod;
int64_t tp_relative_grid_address[2][24][4][3];
tpl_set_relative_grid_address(tp_relative_grid_address,
relative_grid_address, tp_type);
@ -88,10 +93,10 @@ void tpl_get_integration_weight(
void tpl_get_integration_weight_with_sigma(
double *iw, char *iw_zero, const double sigma, const double sigma_cutoff,
const double *frequency_points, const long num_band0,
const long (*triplets)[3], const long num_triplets,
const double *frequencies, const long num_band, const long tp_type) {
long i, num_band_prod, const_adrs_shift;
const double *frequency_points, const int64_t num_band0,
const int64_t (*triplets)[3], const int64_t num_triplets,
const double *frequencies, const int64_t num_band, const int64_t tp_type) {
int64_t i, num_band_prod, const_adrs_shift;
double cutoff;
cutoff = sigma * sigma_cutoff;
@ -109,8 +114,9 @@ void tpl_get_integration_weight_with_sigma(
}
}
long tpl_is_N(const long triplet[3], const long (*bz_grid_addresses)[3]) {
long i, j, sum_q, is_N;
int64_t tpl_is_N(const int64_t triplet[3],
const int64_t (*bz_grid_addresses)[3]) {
int64_t i, j, sum_q, is_N;
is_N = 1;
for (i = 0; i < 3; i++) {
@ -126,11 +132,11 @@ long tpl_is_N(const long triplet[3], const long (*bz_grid_addresses)[3]) {
return is_N;
}
void tpl_set_relative_grid_address(long tp_relative_grid_address[2][24][4][3],
const long relative_grid_address[24][4][3],
const long tp_type) {
long i, j, k, l;
long signs[2];
void tpl_set_relative_grid_address(
int64_t tp_relative_grid_address[2][24][4][3],
const int64_t relative_grid_address[24][4][3], const int64_t tp_type) {
int64_t i, j, k, l;
int64_t signs[2];
signs[0] = 1;
signs[1] = 1;

View File

@ -38,6 +38,7 @@
#define __triplet_H__
#include <stddef.h>
#include <stdint.h>
#include "recgrid.h"
@ -47,35 +48,39 @@
/* and map_q[prod(mesh)] are required. rotations are point-group- */
/* operations in real space for which duplicate operations are allowed */
/* in the input. */
long tpl_get_triplets_reciprocal_mesh_at_q(
long *map_triplets, long *map_q, const long grid_point, const long mesh[3],
const long is_time_reversal, const long num_rot,
const long (*rec_rotations)[3][3], const long swappable);
int64_t tpl_get_triplets_reciprocal_mesh_at_q(
int64_t *map_triplets, int64_t *map_q, const int64_t grid_point,
const int64_t mesh[3], const int64_t is_time_reversal,
const int64_t num_rot, const int64_t (*rec_rotations)[3][3],
const int64_t swappable);
/* Irreducible grid-point-triplets in BZ are stored. */
/* triplets are recovered from grid_point and triplet_weights. */
/* BZ boundary is considered in this recovery. Therefore grid addresses */
/* are given not by grid_address, but by bz_grid_address. */
/* triplets[num_ir_triplets][3] = number of non-zero triplets weights*/
/* Number of ir-triplets is returned. */
long tpl_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point,
const RecgridConstBZGrid *bzgrid,
const long *map_triplets);
int64_t tpl_get_BZ_triplets_at_q(int64_t (*triplets)[3],
const int64_t grid_point,
const RecgridConstBZGrid *bzgrid,
const int64_t *map_triplets);
void tpl_get_integration_weight(
double *iw, char *iw_zero, const double *frequency_points,
const long num_band0, const long relative_grid_address[24][4][3],
const long (*triplets)[3], const long num_triplets,
const int64_t num_band0, const int64_t relative_grid_address[24][4][3],
const int64_t (*triplets)[3], const int64_t num_triplets,
const RecgridConstBZGrid *bzgrid, const double *frequencies1,
const long num_band1, const double *frequencies2, const long num_band2,
const long tp_type, const long openmp_per_triplets);
const int64_t num_band1, const double *frequencies2,
const int64_t num_band2, const int64_t tp_type,
const int64_t openmp_per_triplets);
void tpl_get_integration_weight_with_sigma(
double *iw, char *iw_zero, const double sigma, const double sigma_cutoff,
const double *frequency_points, const long num_band0,
const long (*triplets)[3], const long num_triplets,
const double *frequencies, const long num_band, const long tp_type);
const double *frequency_points, const int64_t num_band0,
const int64_t (*triplets)[3], const int64_t num_triplets,
const double *frequencies, const int64_t num_band, const int64_t tp_type);
long tpl_is_N(const long triplet[3], const long (*bz_grid_addresses)[3]);
void tpl_set_relative_grid_address(long tp_relative_grid_address[2][24][4][3],
const long relative_grid_address[24][4][3],
const long tp_type);
int64_t tpl_is_N(const int64_t triplet[3],
const int64_t (*bz_grid_addresses)[3]);
void tpl_set_relative_grid_address(
int64_t tp_relative_grid_address[2][24][4][3],
const int64_t relative_grid_address[24][4][3], const int64_t tp_type);
#endif

View File

@ -37,50 +37,57 @@
#include "triplet_grid.h"
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include "grgrid.h"
static long get_ir_triplets_at_q(long *map_triplets, long *map_q,
const long grid_point, const long D_diag[3],
const RecgridMats *rot_reciprocal,
const long swappable);
static long get_ir_triplets_at_q_perm_q1q2(long *map_triplets,
const long *map_q,
const long grid_point,
const long D_diag[3]);
static long get_ir_triplets_at_q_noperm(long *map_triplets, const long *map_q,
const long grid_point,
const long D_diag[3]);
static long get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point,
const RecgridConstBZGrid *bzgrid,
const long *map_triplets);
static void get_BZ_triplets_at_q_type1(long (*triplets)[3],
const long grid_point,
static int64_t get_ir_triplets_at_q(int64_t *map_triplets, int64_t *map_q,
const int64_t grid_point,
const int64_t D_diag[3],
const RecgridMats *rot_reciprocal,
const int64_t swappable);
static int64_t get_ir_triplets_at_q_perm_q1q2(int64_t *map_triplets,
const int64_t *map_q,
const int64_t grid_point,
const int64_t D_diag[3]);
static int64_t get_ir_triplets_at_q_noperm(int64_t *map_triplets,
const int64_t *map_q,
const int64_t grid_point,
const int64_t D_diag[3]);
static int64_t get_BZ_triplets_at_q(int64_t (*triplets)[3],
const int64_t grid_point,
const RecgridConstBZGrid *bzgrid,
const int64_t *map_triplets);
static void get_BZ_triplets_at_q_type1(int64_t (*triplets)[3],
const int64_t grid_point,
const RecgridConstBZGrid *bzgrid,
const long *ir_q1_gps,
const long num_ir);
static void get_BZ_triplets_at_q_type2(long (*triplets)[3],
const long grid_point,
const int64_t *ir_q1_gps,
const int64_t num_ir);
static void get_BZ_triplets_at_q_type2(int64_t (*triplets)[3],
const int64_t grid_point,
const RecgridConstBZGrid *bzgrid,
const long *ir_q1_gps,
const long num_ir);
static double get_squared_distance(const long G[3], const double LQD_inv[3][3]);
const int64_t *ir_q1_gps,
const int64_t num_ir);
static double get_squared_distance(const int64_t G[3],
const double LQD_inv[3][3]);
static void get_LQD_inv(double LQD_inv[3][3], const RecgridConstBZGrid *bzgrid);
static RecgridMats *get_reciprocal_point_group_with_q(
const RecgridMats *rot_reciprocal, const long D_diag[3],
const long grid_point);
const RecgridMats *rot_reciprocal, const int64_t D_diag[3],
const int64_t grid_point);
static RecgridMats *get_reciprocal_point_group(
const long (*rec_rotations_in)[3][3], const long num_rot,
const long is_time_reversal, const long is_transpose);
static void copy_matrix_l3(long a[3][3], const long b[3][3]);
const int64_t (*rec_rotations_in)[3][3], const int64_t num_rot,
const int64_t is_time_reversal, const int64_t is_transpose);
static void copy_matrix_l3(int64_t a[3][3], const int64_t b[3][3]);
long tpk_get_ir_triplets_at_q(long *map_triplets, long *map_q,
const long grid_point, const long D_diag[3],
const long is_time_reversal,
const long (*rec_rotations_in)[3][3],
const long num_rot, const long swappable) {
long num_ir;
int64_t tpk_get_ir_triplets_at_q(int64_t *map_triplets, int64_t *map_q,
const int64_t grid_point,
const int64_t D_diag[3],
const int64_t is_time_reversal,
const int64_t (*rec_rotations_in)[3][3],
const int64_t num_rot,
const int64_t swappable) {
int64_t num_ir;
RecgridMats *rotations;
rotations = get_reciprocal_point_group(rec_rotations_in, num_rot,
@ -97,18 +104,20 @@ long tpk_get_ir_triplets_at_q(long *map_triplets, long *map_q,
return num_ir;
}
long tpk_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point,
const RecgridConstBZGrid *bzgrid,
const long *map_triplets) {
int64_t tpk_get_BZ_triplets_at_q(int64_t (*triplets)[3],
const int64_t grid_point,
const RecgridConstBZGrid *bzgrid,
const int64_t *map_triplets) {
return get_BZ_triplets_at_q(triplets, grid_point, bzgrid, map_triplets);
}
static long get_ir_triplets_at_q(long *map_triplets, long *map_q,
const long grid_point, const long D_diag[3],
const RecgridMats *rot_reciprocal,
const long swappable) {
long i, num_ir_q, num_ir_triplets;
long PS[3];
static int64_t get_ir_triplets_at_q(int64_t *map_triplets, int64_t *map_q,
const int64_t grid_point,
const int64_t D_diag[3],
const RecgridMats *rot_reciprocal,
const int64_t swappable) {
int64_t i, num_ir_q, num_ir_triplets;
int64_t PS[3];
RecgridMats *rot_reciprocal_q;
rot_reciprocal_q = NULL;
@ -138,12 +147,12 @@ static long get_ir_triplets_at_q(long *map_triplets, long *map_q,
return num_ir_triplets;
}
static long get_ir_triplets_at_q_perm_q1q2(long *map_triplets,
const long *map_q,
const long grid_point,
const long D_diag[3]) {
long j, num_grid, num_ir_triplets, gp1, gp2;
long adrs0[3], adrs1[3], adrs2[3];
static int64_t get_ir_triplets_at_q_perm_q1q2(int64_t *map_triplets,
const int64_t *map_q,
const int64_t grid_point,
const int64_t D_diag[3]) {
int64_t j, num_grid, num_ir_triplets, gp1, gp2;
int64_t adrs0[3], adrs1[3], adrs2[3];
num_ir_triplets = 0;
num_grid = D_diag[0] * D_diag[1] * D_diag[2];
@ -185,10 +194,11 @@ static long get_ir_triplets_at_q_perm_q1q2(long *map_triplets,
return num_ir_triplets;
}
static long get_ir_triplets_at_q_noperm(long *map_triplets, const long *map_q,
const long grid_point,
const long D_diag[3]) {
long gp1, num_grid, num_ir_triplets;
static int64_t get_ir_triplets_at_q_noperm(int64_t *map_triplets,
const int64_t *map_q,
const int64_t grid_point,
const int64_t D_diag[3]) {
int64_t gp1, num_grid, num_ir_triplets;
num_ir_triplets = 0;
num_grid = D_diag[0] * D_diag[1] * D_diag[2];
@ -205,16 +215,18 @@ static long get_ir_triplets_at_q_noperm(long *map_triplets, const long *map_q,
return num_ir_triplets;
}
static long get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point,
const RecgridConstBZGrid *bzgrid,
const long *map_triplets) {
long gp1, num_ir;
long *ir_q1_gps;
static int64_t get_BZ_triplets_at_q(int64_t (*triplets)[3],
const int64_t grid_point,
const RecgridConstBZGrid *bzgrid,
const int64_t *map_triplets) {
int64_t gp1, num_ir;
int64_t *ir_q1_gps;
ir_q1_gps = NULL;
num_ir = 0;
if ((ir_q1_gps = (long *)malloc(sizeof(long) * bzgrid->size)) == NULL) {
if ((ir_q1_gps = (int64_t *)malloc(sizeof(int64_t) * bzgrid->size)) ==
NULL) {
warning_print("Memory could not be allocated.");
goto ret;
}
@ -241,16 +253,16 @@ ret:
return num_ir;
}
static void get_BZ_triplets_at_q_type1(long (*triplets)[3],
const long grid_point,
static void get_BZ_triplets_at_q_type1(int64_t (*triplets)[3],
const int64_t grid_point,
const RecgridConstBZGrid *bzgrid,
const long *ir_q1_gps,
const long num_ir) {
long i, j, gp2, num_gp, num_bzgp, bz0, bz1, bz2;
long bzgp[3], G[3];
long bz_adrs0[3], bz_adrs1[3], bz_adrs2[3];
const long *gp_map;
const long(*bz_adrs)[3];
const int64_t *ir_q1_gps,
const int64_t num_ir) {
int64_t i, j, gp2, num_gp, num_bzgp, bz0, bz1, bz2;
int64_t bzgp[3], G[3];
int64_t bz_adrs0[3], bz_adrs1[3], bz_adrs2[3];
const int64_t *gp_map;
const int64_t(*bz_adrs)[3];
double d2, min_d2, tolerance;
double LQD_inv[3][3];
@ -327,16 +339,16 @@ static void get_BZ_triplets_at_q_type1(long (*triplets)[3],
}
}
static void get_BZ_triplets_at_q_type2(long (*triplets)[3],
const long grid_point,
static void get_BZ_triplets_at_q_type2(int64_t (*triplets)[3],
const int64_t grid_point,
const RecgridConstBZGrid *bzgrid,
const long *ir_q1_gps,
const long num_ir) {
long i, j, gp0, gp2;
long bzgp[3], G[3];
long bz_adrs0[3], bz_adrs1[3], bz_adrs2[3];
const long *gp_map;
const long(*bz_adrs)[3];
const int64_t *ir_q1_gps,
const int64_t num_ir) {
int64_t i, j, gp0, gp2;
int64_t bzgp[3], G[3];
int64_t bz_adrs0[3], bz_adrs1[3], bz_adrs2[3];
const int64_t *gp_map;
const int64_t(*bz_adrs)[3];
double d2, min_d2, tolerance;
double LQD_inv[3][3];
@ -392,10 +404,10 @@ static void get_BZ_triplets_at_q_type2(long (*triplets)[3],
}
}
static double get_squared_distance(const long G[3],
static double get_squared_distance(const int64_t G[3],
const double LQD_inv[3][3]) {
double d, d2;
long i;
int64_t i;
d2 = 0;
for (i = 0; i < 3; i++) {
@ -408,7 +420,7 @@ static double get_squared_distance(const long G[3],
static void get_LQD_inv(double LQD_inv[3][3],
const RecgridConstBZGrid *bzgrid) {
long i, j, k;
int64_t i, j, k;
/* LQD^-1 */
for (i = 0; i < 3; i++) {
@ -423,11 +435,11 @@ static void get_LQD_inv(double LQD_inv[3][3],
/* Return NULL if failed */
static RecgridMats *get_reciprocal_point_group_with_q(
const RecgridMats *rot_reciprocal, const long D_diag[3],
const long grid_point) {
long i, j, num_rot, gp_rot;
long *ir_rot;
long adrs[3], adrs_rot[3];
const RecgridMats *rot_reciprocal, const int64_t D_diag[3],
const int64_t grid_point) {
int64_t i, j, num_rot, gp_rot;
int64_t *ir_rot;
int64_t adrs[3], adrs_rot[3];
RecgridMats *rot_reciprocal_q;
ir_rot = NULL;
@ -436,7 +448,7 @@ static RecgridMats *get_reciprocal_point_group_with_q(
recgrid_get_grid_address_from_index(adrs, grid_point, D_diag);
if ((ir_rot = (long *)malloc(sizeof(long) * rot_reciprocal->size)) ==
if ((ir_rot = (int64_t *)malloc(sizeof(int64_t) * rot_reciprocal->size)) ==
NULL) {
warning_print("Memory of ir_rot could not be allocated.");
return NULL;
@ -473,10 +485,10 @@ static RecgridMats *get_reciprocal_point_group_with_q(
}
static RecgridMats *get_reciprocal_point_group(
const long (*rec_rotations_in)[3][3], const long num_rot,
const long is_time_reversal, const long is_transpose) {
long i, num_rot_out;
long rec_rotations_out[48][3][3];
const int64_t (*rec_rotations_in)[3][3], const int64_t num_rot,
const int64_t is_time_reversal, const int64_t is_transpose) {
int64_t i, num_rot_out;
int64_t rec_rotations_out[48][3][3];
RecgridMats *rec_rotations;
num_rot_out = recgrid_get_reciprocal_point_group(
@ -494,7 +506,7 @@ static RecgridMats *get_reciprocal_point_group(
return rec_rotations;
}
static void copy_matrix_l3(long a[3][3], const long b[3][3]) {
static void copy_matrix_l3(int64_t a[3][3], const int64_t b[3][3]) {
a[0][0] = b[0][0];
a[0][1] = b[0][1];
a[0][2] = b[0][2];

View File

@ -37,16 +37,21 @@
#ifndef __triplet_grid_H__
#define __triplet_grid_H__
#include <stdint.h>
#include "bzgrid.h"
#include "lagrid.h"
long tpk_get_ir_triplets_at_q(long *map_triplets, long *map_q,
const long grid_point, const long D_diag[3],
const long is_time_reversal,
const long (*rec_rotations_in)[3][3],
const long num_rot, const long swappable);
long tpk_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point,
const RecgridConstBZGrid *bzgrid,
const long *map_triplets);
int64_t tpk_get_ir_triplets_at_q(int64_t *map_triplets, int64_t *map_q,
const int64_t grid_point,
const int64_t D_diag[3],
const int64_t is_time_reversal,
const int64_t (*rec_rotations_in)[3][3],
const int64_t num_rot,
const int64_t swappable);
int64_t tpk_get_BZ_triplets_at_q(int64_t (*triplets)[3],
const int64_t grid_point,
const RecgridConstBZGrid *bzgrid,
const int64_t *map_triplets);
#endif

View File

@ -35,6 +35,7 @@
#include "triplet_iw.h"
#include <math.h>
#include <stdint.h>
#include "funcs.h"
#include "grgrid.h"
@ -43,32 +44,36 @@
static void set_freq_vertices(double freq_vertices[3][24][4],
const double *frequencies1,
const double *frequencies2,
const long vertices[2][24][4],
const long num_band1, const long num_band2,
const long b1, const long b2, const long tp_type);
static long set_g(double g[3], const double f0,
const double freq_vertices[3][24][4], const long max_i);
const int64_t vertices[2][24][4],
const int64_t num_band1, const int64_t num_band2,
const int64_t b1, const int64_t b2,
const int64_t tp_type);
static int64_t set_g(double g[3], const double f0,
const double freq_vertices[3][24][4], const int64_t max_i);
static void get_triplet_tetrahedra_vertices(
long vertices[2][24][4], const long tp_relative_grid_address[2][24][4][3],
const long triplet[3], const RecgridConstBZGrid *bzgrid);
int64_t vertices[2][24][4],
const int64_t tp_relative_grid_address[2][24][4][3],
const int64_t triplet[3], const RecgridConstBZGrid *bzgrid);
static void get_neighboring_grid_points_type1(
long *neighboring_grid_points, const long grid_point,
const long (*relative_grid_address)[3],
const long num_relative_grid_address, const RecgridConstBZGrid *bzgrid);
int64_t *neighboring_grid_points, const int64_t grid_point,
const int64_t (*relative_grid_address)[3],
const int64_t num_relative_grid_address, const RecgridConstBZGrid *bzgrid);
static void get_neighboring_grid_points_type2(
long *neighboring_grid_points, const long grid_point,
const long (*relative_grid_address)[3],
const long num_relative_grid_address, const RecgridConstBZGrid *bzgrid);
int64_t *neighboring_grid_points, const int64_t grid_point,
const int64_t (*relative_grid_address)[3],
const int64_t num_relative_grid_address, const RecgridConstBZGrid *bzgrid);
void tpi_get_integration_weight(
double *iw, char *iw_zero, const double *frequency_points,
const long num_band0, const long tp_relative_grid_address[2][24][4][3],
const long triplets[3], const long num_triplets,
const int64_t num_band0,
const int64_t tp_relative_grid_address[2][24][4][3],
const int64_t triplets[3], const int64_t num_triplets,
const RecgridConstBZGrid *bzgrid, const double *frequencies1,
const long num_band1, const double *frequencies2, const long num_band2,
const long tp_type, const long openmp_per_triplets) {
long max_i, j, b1, b2, b12, num_band_prod, adrs_shift;
long vertices[2][24][4];
const int64_t num_band1, const double *frequencies2,
const int64_t num_band2, const int64_t tp_type,
const int64_t openmp_per_triplets) {
int64_t max_i, j, b1, b2, b12, num_band_prod, adrs_shift;
int64_t vertices[2][24][4];
double g[3];
double freq_vertices[3][24][4];
@ -129,10 +134,11 @@ void tpi_get_integration_weight(
void tpi_get_integration_weight_with_sigma(
double *iw, char *iw_zero, const double sigma, const double cutoff,
const double *frequency_points, const long num_band0, const long triplet[3],
const long const_adrs_shift, const double *frequencies, const long num_band,
const long tp_type, const long openmp_per_triplets) {
long j, b12, b1, b2, adrs_shift;
const double *frequency_points, const int64_t num_band0,
const int64_t triplet[3], const int64_t const_adrs_shift,
const double *frequencies, const int64_t num_band, const int64_t tp_type,
const int64_t openmp_per_triplets) {
int64_t j, b12, b1, b2, adrs_shift;
double f0, f1, f2, g0, g1, g2;
#ifdef _OPENMP
@ -199,10 +205,10 @@ void tpi_get_integration_weight_with_sigma(
* @param num_relative_grid_address Number of relative grid addresses.
* @param bzgrid
*/
void tpi_get_neighboring_grid_points(long *neighboring_grid_points,
const long grid_point,
const long (*relative_grid_address)[3],
const long num_relative_grid_address,
void tpi_get_neighboring_grid_points(int64_t *neighboring_grid_points,
const int64_t grid_point,
const int64_t (*relative_grid_address)[3],
const int64_t num_relative_grid_address,
const RecgridConstBZGrid *bzgrid) {
if (bzgrid->type == 1) {
get_neighboring_grid_points_type1(neighboring_grid_points, grid_point,
@ -218,11 +224,11 @@ void tpi_get_neighboring_grid_points(long *neighboring_grid_points,
static void set_freq_vertices(double freq_vertices[3][24][4],
const double *frequencies1,
const double *frequencies2,
const long vertices[2][24][4],
const long num_band1, const long num_band2,
const long b1, const long b2,
const long tp_type) {
long i, j;
const int64_t vertices[2][24][4],
const int64_t num_band1, const int64_t num_band2,
const int64_t b1, const int64_t b2,
const int64_t tp_type) {
int64_t i, j;
double f1, f2;
for (i = 0; i < 24; i++) {
@ -255,9 +261,10 @@ static void set_freq_vertices(double freq_vertices[3][24][4],
/* iw_zero=1 information can be used to omit to compute particles */
/* interaction strength that is often heaviest part in throughout */
/* calculation. */
static long set_g(double g[3], const double f0,
const double freq_vertices[3][24][4], const long max_i) {
long i, iw_zero;
static int64_t set_g(double g[3], const double f0,
const double freq_vertices[3][24][4],
const int64_t max_i) {
int64_t i, iw_zero;
iw_zero = 1;
@ -274,9 +281,10 @@ static long set_g(double g[3], const double f0,
}
static void get_triplet_tetrahedra_vertices(
long vertices[2][24][4], const long tp_relative_grid_address[2][24][4][3],
const long triplet[3], const RecgridConstBZGrid *bzgrid) {
long i, j;
int64_t vertices[2][24][4],
const int64_t tp_relative_grid_address[2][24][4][3],
const int64_t triplet[3], const RecgridConstBZGrid *bzgrid) {
int64_t i, j;
for (i = 0; i < 2; i++) {
for (j = 0; j < 24; j++) {
@ -288,11 +296,11 @@ static void get_triplet_tetrahedra_vertices(
}
static void get_neighboring_grid_points_type1(
long *neighboring_grid_points, const long grid_point,
const long (*relative_grid_address)[3],
const long num_relative_grid_address, const RecgridConstBZGrid *bzgrid) {
long bzmesh[3], bz_address[3];
long i, j, bz_gp, prod_bz_mesh;
int64_t *neighboring_grid_points, const int64_t grid_point,
const int64_t (*relative_grid_address)[3],
const int64_t num_relative_grid_address, const RecgridConstBZGrid *bzgrid) {
int64_t bzmesh[3], bz_address[3];
int64_t i, j, bz_gp, prod_bz_mesh;
for (i = 0; i < 3; i++) {
bzmesh[i] = bzgrid->D_diag[i] * 2;
@ -315,11 +323,11 @@ static void get_neighboring_grid_points_type1(
}
static void get_neighboring_grid_points_type2(
long *neighboring_grid_points, const long grid_point,
const long (*relative_grid_address)[3],
const long num_relative_grid_address, const RecgridConstBZGrid *bzgrid) {
long bz_address[3];
long i, j, gp;
int64_t *neighboring_grid_points, const int64_t grid_point,
const int64_t (*relative_grid_address)[3],
const int64_t num_relative_grid_address, const RecgridConstBZGrid *bzgrid) {
int64_t bz_address[3];
int64_t i, j, gp;
for (i = 0; i < num_relative_grid_address; i++) {
for (j = 0; j < 3; j++) {

View File

@ -35,24 +35,29 @@
#ifndef __triplet_iw_H__
#define __triplet_iw_H__
#include <stdint.h>
#include "bzgrid.h"
void tpi_get_integration_weight(
double *iw, char *iw_zero, const double *frequency_points,
const long num_band0, const long tp_relative_grid_address[2][24][4][3],
const long triplets[3], const long num_triplets,
const int64_t num_band0,
const int64_t tp_relative_grid_address[2][24][4][3],
const int64_t triplets[3], const int64_t num_triplets,
const RecgridConstBZGrid *bzgrid, const double *frequencies1,
const long num_band1, const double *frequencies2, const long num_band2,
const long tp_type, const long openmp_per_triplets);
const int64_t num_band1, const double *frequencies2,
const int64_t num_band2, const int64_t tp_type,
const int64_t openmp_per_triplets);
void tpi_get_integration_weight_with_sigma(
double *iw, char *iw_zero, const double sigma, const double cutoff,
const double *frequency_points, const long num_band0, const long triplet[3],
const long const_adrs_shift, const double *frequencies, const long num_band,
const long tp_type, const long openmp_per_triplets);
void tpi_get_neighboring_grid_points(long *neighboring_grid_points,
const long grid_point,
const long (*relative_grid_address)[3],
const long num_relative_grid_address,
const double *frequency_points, const int64_t num_band0,
const int64_t triplet[3], const int64_t const_adrs_shift,
const double *frequencies, const int64_t num_band, const int64_t tp_type,
const int64_t openmp_per_triplets);
void tpi_get_neighboring_grid_points(int64_t *neighboring_grid_points,
const int64_t grid_point,
const int64_t (*relative_grid_address)[3],
const int64_t num_relative_grid_address,
const RecgridConstBZGrid *bzgrid);
#endif

View File

@ -107,7 +107,7 @@ class Phono3pyIsotope:
(len(self._sigmas), len(grid_points), len(self._iso.band_indices)),
dtype="double",
)
self._grid_points = np.array(grid_points, dtype="long")
self._grid_points = np.array(grid_points, dtype="int64")
for j, gp in enumerate(grid_points):
self._iso.set_grid_point(gp)

View File

@ -235,14 +235,16 @@ class Phono3py:
# Create supercell and primitive cell
self._unitcell = unitcell
self._supercell_matrix = np.array(
shape_supercell_matrix(supercell_matrix), dtype="long", order="C"
shape_supercell_matrix(supercell_matrix), dtype="int64", order="C"
)
pmat = self._determine_primitive_matrix(primitive_matrix)
self._primitive_matrix = pmat
self._nac_params = None
if phonon_supercell_matrix is not None:
self._phonon_supercell_matrix = np.array(
shape_supercell_matrix(phonon_supercell_matrix), dtype="long", order="C"
shape_supercell_matrix(phonon_supercell_matrix),
dtype="int64",
order="C",
)
else:
self._phonon_supercell_matrix = None
@ -539,7 +541,7 @@ class Phono3py:
ndarray
Supercell matrix with respect to unit cell.
shape=(3, 3), dtype='long', order='C'
shape=(3, 3), dtype='int64', order='C'
"""
return self._supercell_matrix
@ -550,7 +552,7 @@ class Phono3py:
ndarray
Supercell matrix with respect to unit cell.
shape=(3, 3), dtype='long', order='C'
shape=(3, 3), dtype='int64', order='C'
"""
return self._phonon_supercell_matrix
@ -744,10 +746,10 @@ class Phono3py:
def _set_band_indices(self, band_indices=None):
if band_indices is None:
num_band = len(self._primitive) * 3
self._band_indices = [np.arange(num_band, dtype="long")]
self._band_indices = [np.arange(num_band, dtype="int64")]
else:
self._band_indices = [np.array(bi, dtype="long") for bi in band_indices]
self._band_indices_flatten = np.hstack(self._band_indices).astype("long")
self._band_indices = [np.array(bi, dtype="int64") for bi in band_indices]
self._band_indices_flatten = np.hstack(self._band_indices).astype("int64")
@property
def masses(self) -> np.ndarray:
@ -1994,7 +1996,7 @@ class Phono3py:
List of grid point indices where mode thermal conductivities are
calculated. With None, all the grid points that are necessary
for thermal conductivity are set internally.
shape(num_grid_points, ), dtype='long'.
shape(num_grid_points, ), dtype='int64'.
boundary_mfp : float, optiona, default is None
Mean free path in micrometre to calculate simple boundary
scattering contribution to thermal conductivity.

View File

@ -281,7 +281,7 @@ class ConductivityBase(ABC):
grid_points : array_like or None, optional
Grid point indices in BZgrid. When None, ir-grid points are searched
internally. Default is None.
shape=(grid_points, ), dtype='long'.
shape=(grid_points, ), dtype='int64'.
temperatures : array_like, optional, default is None
Temperatures at which thermal conductivity is calculated.
shape=(temperature_points, ), dtype='double'.
@ -675,7 +675,7 @@ class ConductivityBase(ABC):
-------
point_operations : ndarray
Operations in reduced coordinates.
shape=(num_operations, 3, 3), dtype='long'
shape=(num_operations, 3, 3), dtype='int64'
rotations_cartesian : ndarray
Operations in Cartesian coordinates.
shape=(num_operations, 3, 3), dtype='double'
@ -683,7 +683,7 @@ class ConductivityBase(ABC):
"""
if not self._is_kappa_star:
point_operations = np.array(
[np.eye(3, dtype="long")], dtype="long", order="C"
[np.eye(3, dtype="int64")], dtype="int64", order="C"
)
rotations_cartesian = np.array(
[np.eye(3, dtype="double")], dtype="double", order="C"
@ -701,10 +701,10 @@ class ConductivityBase(ABC):
-------
grid_points : ndarray
Grid point indices in BZ-grid to be iterated over.
shape=(len(grid_points),), dtype='long'
shape=(len(grid_points),), dtype='int64'
ir_grid_points : ndarray
Irreducible grid points in BZ-grid on regular grid.
shape=(len(ir_grid_points),), dtype='long'
shape=(len(ir_grid_points),), dtype='int64'
grid_weights : ndarray
Grid weights of `grid_points`. If grid symmetry is not broken,
these values are equivalent to numbers of k-star arms.
@ -712,13 +712,13 @@ class ConductivityBase(ABC):
"""
ir_grid_points, grid_weights = self._get_ir_grid_points(grid_points)
if grid_points is not None: # Specify grid points
_grid_points = np.array(grid_points, dtype="long")
_grid_points = np.array(grid_points, dtype="int64")
_ir_grid_points = ir_grid_points
_grid_weights = grid_weights
elif not self._is_kappa_star: # All grid points
_grid_points = self._pp.bz_grid.grg2bzg
_ir_grid_points = _grid_points
_grid_weights = np.ones(len(_grid_points), dtype="long")
_grid_weights = np.ones(len(_grid_points), dtype="int64")
else: # Automatic sampling
_grid_points = ir_grid_points
_ir_grid_points = ir_grid_points
@ -776,7 +776,7 @@ class ConductivityBase(ABC):
self._pp.bz_grid
)
ir_grid_points = np.array(
self._pp.bz_grid.grg2bzg[ir_grid_points], dtype="long"
self._pp.bz_grid.grg2bzg[ir_grid_points], dtype="int64"
)
if grid_points is None:
grid_weights = ir_grid_weights
@ -786,7 +786,7 @@ class ConductivityBase(ABC):
weights[gp] += 1
grid_weights = np.array(
weights[ir_grid_map[self._pp.bz_grid.bzg2grg[grid_points]]],
dtype="long",
dtype="int64",
)
return ir_grid_points, grid_weights

View File

@ -298,7 +298,7 @@ class ConductivityLBTEBase(ConductivityBase):
def _get_rot_grid_points(self):
num_ir_grid_points = len(self._ir_grid_points)
rot_grid_points = np.zeros(
(num_ir_grid_points, len(self._point_operations)), dtype="long"
(num_ir_grid_points, len(self._point_operations)), dtype="int64"
)
if self._is_kappa_star:
rotations = self._pp.bz_grid.rotations # rotations of GR-grid
@ -536,15 +536,17 @@ class ConductivityLBTEBase(ConductivityBase):
def _prepare_collision_matrix(self):
"""Collect pieces and construct collision matrix."""
if self._log_level:
print(f"- Collision matrix shape {self._collision_matrix.shape}")
if self._is_reducible_collision_matrix:
if self._is_kappa_star:
self._average_collision_matrix_by_degeneracy()
num_mesh_points = np.prod(self._pp.mesh_numbers)
num_rot = len(self._point_operations)
rot_grid_points = np.zeros((num_rot, num_mesh_points), dtype="long")
rot_grid_points = np.zeros((num_rot, num_mesh_points), dtype="int64")
# Ir-grid points and rot_grid_points in generalized regular grid
ir_gr_grid_points = np.array(
self._pp.bz_grid.bzg2grg[self._ir_grid_points], dtype="long"
self._pp.bz_grid.bzg2grg[self._ir_grid_points], dtype="int64"
)
for i in range(num_mesh_points):
rot_grid_points[:, i] = self._pp.bz_grid.bzg2grg[
@ -555,7 +557,7 @@ class ConductivityLBTEBase(ConductivityBase):
self._expand_reducible_collisions(ir_gr_grid_points, rot_grid_points)
self._expand_local_values(ir_gr_grid_points, rot_grid_points)
self._combine_reducible_collisions()
weights = np.ones(np.prod(self._pp.mesh_numbers), dtype="long")
weights = np.ones(np.prod(self._pp.mesh_numbers), dtype="int64")
self._symmetrize_collision_matrix()
else:
self._combine_collisions()
@ -658,7 +660,7 @@ class ConductivityLBTEBase(ConductivityBase):
self._rot_grid_points : ndarray
Grid points generated by applying point group to ir-grid-points
in BZ-grid.
shape=(ir_grid_points, point_operations), dtype='long'
shape=(ir_grid_points, point_operations), dtype='int64'
r_gps : grid points of arms of k-star with duplicates
len(r_gps) == order of crystallographic point group

View File

@ -372,7 +372,7 @@ class ConductivityRTABase(ConductivityBase):
collisions,
np.array(
np.dot(tetrahedra, self._pp.bz_grid.P.T),
dtype="long",
dtype="int64",
order="C",
),
self._frequencies,

View File

@ -85,7 +85,7 @@ def _get_ir_grid_info(
-------
ir_grid_points : ndarray
Ir-grid point indices in BZ-grid.
shape=(ir_grid_points, ), dtype='long'
shape=(ir_grid_points, ), dtype='int64'
ir_grid_map : ndarray
Mapping table to ir-grid point indices in GR-grid.
@ -254,9 +254,9 @@ def _collect_data(
]:
# bz_grid
if "grid_matrix" in f_kappa:
mesh = np.array(f_kappa["grid_matrix"][:], dtype="long")
mesh = np.array(f_kappa["grid_matrix"][:], dtype="int64")
else:
mesh = np.array(f_kappa["mesh"][:], dtype="long")
mesh = np.array(f_kappa["mesh"][:], dtype="int64")
primitive_symmetry = Symmetry(primitive)
bz_grid = BZGrid(
mesh,
@ -293,7 +293,7 @@ def _collect_data(
else:
print("# Read frequency.")
frequencies = f_kappa["frequency"][:]
ir_weights = np.ones(len(frequencies), dtype="long")
ir_weights = np.ones(len(frequencies), dtype="int64")
# ir_grid_points (GR-grid), ir_grid_map (GR-grid)
if args.no_gridsym or (ir_weights == 1).all():

View File

@ -872,7 +872,7 @@ def init_phph_interaction(
if settings.write_phonon:
freqs, eigvecs, grid_address = phono3py.get_phonon_data()
ir_grid_points, ir_grid_weights, _ = get_ir_grid_points(bz_grid)
ir_grid_points = np.array(bz_grid.grg2bzg[ir_grid_points], dtype="long")
ir_grid_points = np.array(bz_grid.grg2bzg[ir_grid_points], dtype="int64")
filename = write_phonon_to_hdf5(
freqs,
eigvecs,

View File

@ -154,12 +154,12 @@ class _TripletsNumbers:
def _get_ir_grid_points(bz_grid: BZGrid, is_kappa_star: bool = True):
if is_kappa_star:
ir_grid_points, ir_grid_weights, _ = get_ir_grid_points(bz_grid)
ir_grid_points = np.array(bz_grid.grg2bzg[ir_grid_points], dtype="long")
ir_grid_points = np.array(bz_grid.grg2bzg[ir_grid_points], dtype="int64")
else:
ir_grid_points = np.array(
bz_grid.grg2bzg[: np.prod(bz_grid.D_diag)], dtype="long", order="C"
bz_grid.grg2bzg[: np.prod(bz_grid.D_diag)], dtype="int64", order="C"
)
ir_grid_weights = np.ones(len(ir_grid_points), dtype="long")
ir_grid_weights = np.ones(len(ir_grid_points), dtype="int64")
return ir_grid_points, ir_grid_weights

View File

@ -714,7 +714,7 @@ def write_spectral_function_to_hdf5(
if all_band_exist:
_band_indices = None
else:
_band_indices = np.hstack(band_indices).astype("long")
_band_indices = np.hstack(band_indices).astype("int64")
suffix = _get_filename_suffix(
mesh, grid_point=grid_point, band_indices=_band_indices, sigma=sigma
)

View File

@ -136,9 +136,9 @@ class Isotope:
num_band = len(self._primitive) * 3
if band_indices is None:
self._band_indices = np.arange(num_band, dtype="long")
self._band_indices = np.arange(num_band, dtype="int64")
else:
self._band_indices = np.array(band_indices, dtype="long")
self._band_indices = np.array(band_indices, dtype="int64")
if self._bz_grid is None:
primitive_symmetry = Symmetry(self._primitive, self._symprec)
@ -153,7 +153,7 @@ class Isotope:
def set_grid_point(self, grid_point):
"""Initialize grid points."""
self._grid_point = grid_point
self._grid_points = np.arange(len(self._bz_grid.addresses), dtype="long")
self._grid_points = np.arange(len(self._bz_grid.addresses), dtype="int64")
if self._phonon_done is None:
self._allocate_phonon()
@ -319,7 +319,7 @@ class Isotope:
self._bz_grid.addresses,
np.array(
np.dot(thm.tetrahedra, self._bz_grid.P.T),
dtype="long",
dtype="int64",
order="C",
),
self._bz_grid.grg2bzg,

View File

@ -76,17 +76,17 @@ class KappaDOSTHM:
ir_grid_points : ndarray
Irreducible grid point indices in GR-grid (as obtained by
get_ir_grid_points).
shape=(num_ir_grid_points, ), dtype='long'
shape=(num_ir_grid_points, ), dtype='int64'
ir_grid_weights : ndarray
Weights of irreducible grid points. Its sum is the number of grid
points in GR-grid (prod(D_diag)) (as obtained by
get_ir_grid_points).
shape=(num_ir_grid_points, ), dtype='long'
shape=(num_ir_grid_points, ), dtype='int64'
ir_grid_map : ndarray
Index mapping table to irreducible grid points from all grid points
in GR-grid such as, [0, 0, 2, 3, 3, ...]. (as obtained by
get_ir_grid_points).
shape=(prod(D_diag), ), dtype='long'
shape=(prod(D_diag), ), dtype='int64'
frequency_points : array_like, optional, default=None
This is used as the frequency points. When None, frequency points
are created from `num_sampling_points`.
@ -120,7 +120,7 @@ class KappaDOSTHM:
bz_grid.bzg2grg, _ir_grid_map, _ir_grid_points
)
if ir_grid_weights is None:
grid_weights = np.ones(mode_kappa.shape[1], dtype="long")
grid_weights = np.ones(mode_kappa.shape[1], dtype="int64")
else:
grid_weights = ir_grid_weights
for j, function in enumerate(("J", "I")):
@ -164,13 +164,13 @@ class KappaDOSTHM:
----------
bzg2grg : ndarray
Mapping table from BZ-grid to GR-grid.
shape=(len(all-BZ-grid-points), ), dtype='long'
shape=(len(all-BZ-grid-points), ), dtype='int64'
ir_grid_map : ndarray
Mapping table from all grid points to ir-grid points in GR-grid.
shape=(np.prod(D_diag), ), dtype='long'
shape=(np.prod(D_diag), ), dtype='int64'
ir_grid_points : ndarray
Irreducible grid points in GR-grid. shape=(num_ir_grid_points, ),
dtype='long'
dtype='int64'
Returns
-------
@ -184,7 +184,7 @@ class KappaDOSTHM:
# ir-grid points in GR-grid to the index of unique grid points.
gp_map = {j: i for i, j in enumerate(unique_gps)}
bzgp2irgp_map = np.array(
[gp_map[ir_grid_map[grgp]] for grgp in bzg2grg], dtype="long"
[gp_map[ir_grid_map[grgp]] for grgp in bzg2grg], dtype="int64"
)
return bzgp2irgp_map
@ -210,7 +210,7 @@ class GammaDOSsmearing:
shape=(ir_grid_points, num_band), dtype='double'
ir_grid_weights : ndarray
Grid point weights at ir-grid points.
shape=(ir_grid_points, ), dtype='long'
shape=(ir_grid_points, ), dtype='int64'
sigma : float
Smearing width.
num_sampling_points : int, optional, default=100

View File

@ -57,23 +57,23 @@ def get_unique_grid_points(grid_points, bz_grid: BZGrid):
-------
ndarray
Unique grid points on tetrahedron vertices around input grid points.
shape=(unique_grid_points, ), dtype='long'.
shape=(unique_grid_points, ), dtype='int64'.
"""
import phono3py._phono3py as phono3c
if _check_ndarray_state(grid_points, "long"):
if _check_ndarray_state(grid_points, "int64"):
_grid_points = grid_points
else:
_grid_points = np.array(grid_points, dtype="long")
_grid_points = np.array(grid_points, dtype="int64")
thm = TetrahedronMethod(bz_grid.microzone_lattice)
unique_vertices = np.array(
np.dot(thm.get_unique_tetrahedra_vertices(), bz_grid.P.T),
dtype="long",
dtype="int64",
order="C",
)
neighboring_grid_points = np.zeros(
len(unique_vertices) * len(_grid_points), dtype="long"
len(unique_vertices) * len(_grid_points), dtype="int64"
)
phono3c.neighboring_grid_points(
neighboring_grid_points,
@ -84,7 +84,7 @@ def get_unique_grid_points(grid_points, bz_grid: BZGrid):
bz_grid.gp_map,
bz_grid.store_dense_gp_map * 1 + 1,
)
unique_grid_points = np.array(np.unique(neighboring_grid_points), dtype="long")
unique_grid_points = np.array(np.unique(neighboring_grid_points), dtype="int64")
return unique_grid_points
@ -111,7 +111,7 @@ def get_integration_weights(
Grid information in reciprocal space.
grid_points : array_like, optional, default=None
Grid point indices in BZ-grid. If None, all regular grid points in
BZ-grid. shape=(grid_points, ), dtype='long'
BZ-grid. shape=(grid_points, ), dtype='int64'
bzgp2irgp_map : array_like, optional, default=None
Grid point index mapping from bz_grid to index of the first dimension of
`grid_values` array, i.e., usually irreducible grid point count.
@ -131,15 +131,15 @@ def get_integration_weights(
np.dot(
get_tetrahedra_relative_grid_address(bz_grid.microzone_lattice), bz_grid.P.T
),
dtype="long",
dtype="int64",
order="C",
)
if grid_points is None:
_grid_points = bz_grid.grg2bzg
elif _check_ndarray_state(grid_points, "long"):
elif _check_ndarray_state(grid_points, "int64"):
_grid_points = grid_points
else:
_grid_points = np.array(grid_points, dtype="long")
_grid_points = np.array(grid_points, dtype="int64")
if _check_ndarray_state(grid_values, "double"):
_grid_values = grid_values
else:
@ -149,11 +149,11 @@ def get_integration_weights(
else:
_sampling_points = np.array(sampling_points, dtype="double")
if bzgp2irgp_map is None:
_bzgp2irgp_map = np.arange(len(grid_values), dtype="long")
elif _check_ndarray_state(bzgp2irgp_map, "long"):
_bzgp2irgp_map = np.arange(len(grid_values), dtype="int64")
elif _check_ndarray_state(bzgp2irgp_map, "int64"):
_bzgp2irgp_map = bzgp2irgp_map
else:
_bzgp2irgp_map = np.array(bzgp2irgp_map, dtype="long")
_bzgp2irgp_map = np.array(bzgp2irgp_map, dtype="int64")
num_grid_points = len(_grid_points)
num_band = _grid_values.shape[1]
@ -188,7 +188,7 @@ def get_tetrahedra_relative_grid_address(microzone_lattice):
"""
import phono3py._phono3py as phono3c
relative_grid_address = np.zeros((24, 4, 3), dtype="long", order="C")
relative_grid_address = np.zeros((24, 4, 3), dtype="int64", order="C")
phono3c.tetrahedra_relative_grid_address(
relative_grid_address, np.array(microzone_lattice, dtype="double", order="C")
)

View File

@ -156,7 +156,7 @@ class BZGrid:
"""Init method.
mesh : array_like or float
Mesh numbers or length. shape=(3,), dtype='long'
Mesh numbers or length. shape=(3,), dtype='int64'
reciprocal_lattice : array_like
Reciprocal primitive basis vectors given as column vectors shape=(3,
3), dtype='double', order='C'
@ -174,7 +174,7 @@ class BZGrid:
is_shift : array_like or None, optional
[0, 0, 0] (or [False, False, False]) gives Gamma center mesh and
value 1 (or True) gives half mesh shift along the basis vectors.
Default is None. dtype='long', shape=(3,)
Default is None. dtype='int64', shape=(3,)
is_time_reveral : bool, optional
Inversion symmetry is included in reciprocal point group. Default is
True.
@ -205,9 +205,9 @@ class BZGrid:
self._addresses = None
self._gp_map = None
self._grid_matrix = None
self._D_diag = np.ones(3, dtype="long")
self._Q = np.eye(3, dtype="long", order="C")
self._P = np.eye(3, dtype="long", order="C")
self._D_diag = np.ones(3, dtype="int64")
self._Q = np.eye(3, dtype="int64", order="C")
self._P = np.eye(3, dtype="int64", order="C")
self._QDinv = None
self._microzone_lattice = None
self._rotations = None
@ -237,7 +237,7 @@ class BZGrid:
This corresponds to the mesh numbers in transformed reciprocal
basis vectors.
shape=(3,), dtype='long'
shape=(3,), dtype='int64'
"""
return self._D_diag
@ -247,7 +247,7 @@ class BZGrid:
"""Left unimodular matrix after SNF: D=PAQ.
Left unimodular matrix after SNF: D=PAQ.
shape=(3, 3), dtype='long', order='C'.
shape=(3, 3), dtype='int64', order='C'.
"""
return self._P
@ -257,7 +257,7 @@ class BZGrid:
"""Right unimodular matrix after SNF: D=PAQ.
Right unimodular matrix after SNF: D=PAQ.
shape=(3, 3), dtype='long', order='C'.
shape=(3, 3), dtype='int64', order='C'.
"""
return self._Q
@ -276,9 +276,9 @@ class BZGrid:
def PS(self):
"""Integer shift vectors of GRGrid."""
if self._is_shift is None:
return np.zeros(3, dtype="long")
return np.zeros(3, dtype="int64")
else:
return np.array(np.dot(self.P, self._is_shift), dtype="long")
return np.array(np.dot(self.P, self._is_shift), dtype="int64")
@property
def grid_matrix(self):
@ -286,7 +286,7 @@ class BZGrid:
Grid generating matrix used for SNF.
When SNF is used, ndarray, otherwise None.
shape=(3, 3), dtype='long', order='C'.
shape=(3, 3), dtype='int64', order='C'.
"""
return self._grid_matrix
@ -298,7 +298,7 @@ class BZGrid:
Integer grid address of the points in Brillouin zone including
surface. There are two types of address order by either
`store_dense_gp_map` is True or False.
shape=(np.prod(D_diag) + some on surface, 3), dtype='long', order='C'.
shape=(np.prod(D_diag) + some on surface, 3), dtype='int64', order='C'.
"""
return self._addresses
@ -324,7 +324,7 @@ class BZGrid:
"""Transform grid point indices from BZG to GRG.
Grid index mapping table from BZGrid to GRgrid.
shape=(len(addresses), ), dtype='long'.
shape=(len(addresses), ), dtype='int64'.
Equivalent to
get_grid_point_from_address(
@ -339,7 +339,7 @@ class BZGrid:
Grid index mapping table from GRgrid to BZGrid. Unique one
of translationally equivalent grid points in BZGrid is chosen.
shape=(prod(D_diag), ), dtype='long'.
shape=(prod(D_diag), ), dtype='int64'.
"""
return self._grg2bzg
@ -370,7 +370,7 @@ class BZGrid:
Rotation matrices for GR-grid addresses (g) defined as g'=Rg. This can
be different from ``reciprocal_operations`` when GR-grid is used because
grid addresses are defined on an oblique lattice.
shape=(rotations, 3, 3), dtype='long', order='C'.
shape=(rotations, 3, 3), dtype='int64', order='C'.
"""
return self._rotations
@ -386,7 +386,7 @@ class BZGrid:
Reciprocal space rotation matrices in fractional coordinates defined as
q'=Rq.
shape=(rotations, 3, 3), dtype='long', order='C'.
shape=(rotations, 3, 3), dtype='int64', order='C'.
"""
return self._reciprocal_operations
@ -411,7 +411,7 @@ class BZGrid:
Grid point indices corresponding to the grid addresses. Each
returned grid point index is one of those of the
translationally equivalent grid points.
shape=(n, ), dtype='long' when multiple addresses are given.
shape=(n, ), dtype='int64' when multiple addresses are given.
Otherwise one integer value is returned.
"""
@ -423,7 +423,7 @@ class BZGrid:
)
gps = [get_grid_point_from_address(adrs, self._D_diag) for adrs in addresses]
return np.array(self._grg2bzg[gps], dtype="long")
return np.array(self._grg2bzg[gps], dtype="int64")
def _generate_grid(
self, mesh, use_grg=False, force_SNF=False, SNF_coordinates="reciprocal"
@ -454,9 +454,9 @@ class BZGrid:
store_dense_gp_map=self._store_dense_gp_map,
)
if self._store_dense_gp_map:
self._grg2bzg = np.array(self._gp_map[:-1], dtype="long")
self._grg2bzg = np.array(self._gp_map[:-1], dtype="int64")
else:
self._grg2bzg = np.arange(np.prod(self._D_diag), dtype="long")
self._grg2bzg = np.arange(np.prod(self._D_diag), dtype="int64")
self._QDinv = np.array(
self.Q * (1 / self.D_diag.astype("double")), dtype="double", order="C"
@ -477,17 +477,17 @@ class BZGrid:
import phono3py._recgrid as recgrid
if self._symmetry_dataset is None:
direct_rotations = np.eye(3, dtype="long", order="C").reshape(1, 3, 3)
direct_rotations = np.eye(3, dtype="int64", order="C").reshape(1, 3, 3)
else:
direct_rotations = np.array(
self._symmetry_dataset.rotations, dtype="long", order="C"
self._symmetry_dataset.rotations, dtype="int64", order="C"
)
rec_rotations = np.zeros((48, 3, 3), dtype="long", order="C")
rec_rotations = np.zeros((48, 3, 3), dtype="int64", order="C")
num_rec_rot = recgrid.reciprocal_rotations(
rec_rotations, direct_rotations, self._is_time_reversal
)
self._reciprocal_operations = np.array(
rec_rotations[:num_rec_rot], dtype="long", order="C"
rec_rotations[:num_rec_rot], dtype="int64", order="C"
)
self._rotations_cartesian = np.array(
[
@ -498,7 +498,7 @@ class BZGrid:
order="C",
)
self._rotations = np.zeros(
self._reciprocal_operations.shape, dtype="long", order="C"
self._reciprocal_operations.shape, dtype="int64", order="C"
)
if not recgrid.transform_rotations(
self._rotations, self._reciprocal_operations, self._D_diag, self._Q
@ -550,8 +550,8 @@ class GridMatrix:
Mesh numbers or length. With float number, either conventional or
generalized regular grid is computed depending on the given flags
(`use_grg`, `force_SNF`). Given ndarry with
shape=(3,), dtype='long': conventional regular grid shape=(3,
3), dtype='long': generalized regular grid
shape=(3,), dtype='int64': conventional regular grid shape=(3,
3), dtype='int64': generalized regular grid
lattice : array_like
Primitive basis vectors in direct space given as row vectors.
shape=(3, 3), dtype='double', order='C'
@ -577,9 +577,9 @@ class GridMatrix:
self._mesh = mesh
self._lattice = lattice
self._grid_matrix = None
self._D_diag = np.ones(3, dtype="long")
self._Q = np.eye(3, dtype="long", order="C")
self._P = np.eye(3, dtype="long", order="C")
self._D_diag = np.ones(3, dtype="int64")
self._Q = np.eye(3, dtype="int64", order="C")
self._P = np.eye(3, dtype="int64", order="C")
self._set_mesh_numbers(
mesh,
@ -596,7 +596,7 @@ class GridMatrix:
Grid generating matrix used for SNF.
When SNF is used, ndarray, otherwise None.
shape=(3, 3), dtype='long', order='C'.
shape=(3, 3), dtype='int64', order='C'.
"""
return self._grid_matrix
@ -607,7 +607,7 @@ class GridMatrix:
This corresponds to the mesh numbers in transformed reciprocal
basis vectors.
shape=(3,), dtype='long'
shape=(3,), dtype='int64'
"""
return self._D_diag
@ -617,7 +617,7 @@ class GridMatrix:
"""Left unimodular matrix after SNF: D=PAQ.
Left unimodular matrix after SNF: D=PAQ.
shape=(3, 3), dtype='long', order='C'.
shape=(3, 3), dtype='int64', order='C'.
"""
return self._P
@ -627,7 +627,7 @@ class GridMatrix:
"""Right unimodular matrix after SNF: D=PAQ.
Right unimodular matrix after SNF: D=PAQ.
shape=(3, 3), dtype='long', order='C'.
shape=(3, 3), dtype='int64', order='C'.
"""
return self._Q
@ -684,7 +684,7 @@ class GridMatrix:
mesh_numbers = length2mesh(
length, self._lattice, rotations=symmetry_dataset.rotations
)
self._D_diag = np.array(mesh_numbers, dtype="long")
self._D_diag = np.array(mesh_numbers, dtype="int64")
if num_values == 9:
self._run_grg(
symmetry_dataset,
@ -695,7 +695,7 @@ class GridMatrix:
coordinates,
)
if num_values == 3:
self._D_diag = np.array(mesh, dtype="long")
self._D_diag = np.array(mesh, dtype="int64")
def _run_grg(
self,
@ -786,12 +786,12 @@ class GridMatrix:
sym_dataset, length, coordinates=coordinates
)
elif grid_matrix is not None:
_grid_matrix = np.array(grid_matrix, dtype="long", order="C")
_grid_matrix = np.array(grid_matrix, dtype="int64", order="C")
# If grid_matrix is a diagonal matrix, use it as D matrix.
gm_diag = np.diagonal(_grid_matrix)
if (np.diag(gm_diag) == _grid_matrix).all() and not force_SNF:
self._D_diag = np.array(gm_diag, dtype="long")
self._D_diag = np.array(gm_diag, dtype="int64")
else:
import phono3py._recgrid as recgrid
@ -850,7 +850,7 @@ class GridMatrix:
inv_tmat_int = np.rint(inv_tmat).astype(int)
assert (np.abs(inv_tmat - inv_tmat_int) < 1e-5).all()
grid_matrix = np.array(
(inv_tmat_int * conv_mesh_numbers).T, dtype="long", order="C"
(inv_tmat_int * conv_mesh_numbers).T, dtype="int64", order="C"
)
return grid_matrix
@ -876,12 +876,12 @@ def get_grid_point_from_address(address, D_diag):
----------
address : array_like
Grid address.
shape=(3, ) or (n, 3), dtype='long'
shape=(3, ) or (n, 3), dtype='int64'
D_diag : array_like
This corresponds to mesh numbers. More precisely, this gives
diagonal elements of diagonal matrix of Smith normal form of
grid generating matrix. See the detail in the docstring of BZGrid.
shape=(3,), dtype='long'
shape=(3,), dtype='int64'
Returns
-------
@ -891,18 +891,18 @@ def get_grid_point_from_address(address, D_diag):
ndarray
GR-grid point indices.
shape=(n, ), dtype='long'
shape=(n, ), dtype='int64'
"""
import phono3py._recgrid as recgrid
adrs_array = np.array(address, dtype="long", order="C")
mesh_array = np.array(D_diag, dtype="long")
adrs_array = np.array(address, dtype="int64", order="C")
mesh_array = np.array(D_diag, dtype="int64")
if adrs_array.ndim == 1:
return recgrid.grid_index_from_address(adrs_array, mesh_array)
gps = np.zeros(adrs_array.shape[0], dtype="long")
gps = np.zeros(adrs_array.shape[0], dtype="int64")
for i, adrs in enumerate(adrs_array):
gps[i] = recgrid.grid_index_from_address(adrs, mesh_array)
return gps
@ -918,15 +918,15 @@ def get_ir_grid_points(bz_grid: BZGrid) -> tuple[np.ndarray, np.ndarray, np.ndar
-------
ir_grid_points : ndarray
Irreducible grid point indices in GR-grid.
shape=(num_ir_grid_points, ), dtype='long'
shape=(num_ir_grid_points, ), dtype='int64'
ir_grid_weights : ndarray
Weights of irreducible grid points. Its sum is the number of
grid points in GR-grid (prod(D_diag)).
shape=(num_ir_grid_points, ), dtype='long'
shape=(num_ir_grid_points, ), dtype='int64'
ir_grid_map : ndarray
Index mapping table to irreducible grid points from all grid points
such as, [0, 0, 2, 3, 3, ...] in GR-grid.
shape=(prod(D_diag), ), dtype='long'
shape=(prod(D_diag), ), dtype='int64'
"""
ir_grid_map = _get_ir_grid_map(bz_grid.D_diag, bz_grid.rotations, PS=bz_grid.PS)
@ -950,7 +950,7 @@ def get_grid_points_by_rotations(
Rotation matrices {R} with respect to basis vectors of GR-grid.
Defined by g'=Rg, where g is the grid point address represented by
three integers in BZ-grid.
dtype='long', shape=(rotations, 3, 3)
dtype='int64', shape=(rotations, 3, 3)
with_surface : Bool, optional
This parameter affects to how to treat grid points on BZ surface.
When False, rotated BZ surface points are moved to representative
@ -962,7 +962,7 @@ def get_grid_points_by_rotations(
-------
rot_grid_indices : ndarray
BZ-grid point indices obtained after rotating a grid point index.
dtype='long', shape=(rotations,)
dtype='int64', shape=(rotations,)
"""
if reciprocal_rotations is not None:
@ -994,7 +994,7 @@ def _get_grid_points_by_bz_rotations(bz_gp, bz_grid: BZGrid, rotations, lang="C"
def _get_grid_points_by_bz_rotations_c(bz_gp, bz_grid: BZGrid, rotations):
import phono3py._recgrid as recgrid
bzgps = np.zeros(len(rotations), dtype="long")
bzgps = np.zeros(len(rotations), dtype="int64")
for i, r in enumerate(rotations):
bzgps[i] = recgrid.rotate_bz_grid_index(
bz_gp,
@ -1018,7 +1018,7 @@ def _get_grid_points_by_bz_rotations_py(bz_gp, bz_grid: BZGrid, rotations):
"""
rot_adrs = np.dot(rotations, bz_grid.addresses[bz_gp])
grgps = get_grid_point_from_address(rot_adrs, bz_grid.D_diag)
bzgps = np.zeros(len(grgps), dtype="long")
bzgps = np.zeros(len(grgps), dtype="int64")
if bz_grid.store_dense_gp_map:
for i, (gp, adrs) in enumerate(zip(grgps, rot_adrs)):
indices = np.where(
@ -1058,20 +1058,20 @@ def _get_grid_address(D_diag):
----------
D_diag : array_like
Three integers that represent the generalized regular grid.
shape=(3, ), dtype='long'
shape=(3, ), dtype='int64'
Returns
-------
gr_grid_addresses : ndarray
Integer triplets that represents grid point addresses in
generalized regular grid.
shape=(prod(D_diag), 3), dtype='long'
shape=(prod(D_diag), 3), dtype='int64'
"""
import phono3py._recgrid as recgrid
gr_grid_addresses = np.zeros((np.prod(D_diag), 3), dtype="long")
recgrid.gr_grid_addresses(gr_grid_addresses, np.array(D_diag, dtype="long"))
gr_grid_addresses = np.zeros((np.prod(D_diag), 3), dtype="int64")
recgrid.gr_grid_addresses(gr_grid_addresses, np.array(D_diag, dtype="int64"))
return gr_grid_addresses
@ -1140,37 +1140,37 @@ def _relocate_BZ_grid_address(
import phono3py._recgrid as recgrid
if PS is None:
_PS = np.zeros(3, dtype="long")
_PS = np.zeros(3, dtype="int64")
else:
_PS = np.array(PS, dtype="long")
bz_grid_addresses = np.zeros((np.prod(D_diag) * 8, 3), dtype="long", order="C")
bzg2grg = np.zeros(len(bz_grid_addresses), dtype="long")
_PS = np.array(PS, dtype="int64")
bz_grid_addresses = np.zeros((np.prod(D_diag) * 8, 3), dtype="int64", order="C")
bzg2grg = np.zeros(len(bz_grid_addresses), dtype="int64")
if store_dense_gp_map:
bz_map = np.zeros(np.prod(D_diag) + 1, dtype="long")
bz_map = np.zeros(np.prod(D_diag) + 1, dtype="int64")
else:
bz_map = np.zeros(np.prod(D_diag) * 9 + 1, dtype="long")
bz_map = np.zeros(np.prod(D_diag) * 9 + 1, dtype="int64")
# Mpr^-1 = Lr^-1 Lp
reclat_T = np.array(np.transpose(reciprocal_lattice), dtype="double", order="C")
reduced_basis = get_reduced_bases(reclat_T)
tmat_inv = np.dot(np.linalg.inv(reduced_basis.T), reclat_T.T)
tmat_inv_int = np.rint(tmat_inv).astype("long")
tmat_inv_int = np.rint(tmat_inv).astype("int64")
assert (np.abs(tmat_inv - tmat_inv_int) < 1e-5).all()
num_gp = recgrid.bz_grid_addresses(
bz_grid_addresses,
bz_map,
bzg2grg,
np.array(D_diag, dtype="long"),
np.array(np.dot(tmat_inv_int, Q), dtype="long", order="C"),
np.array(D_diag, dtype="int64"),
np.array(np.dot(tmat_inv_int, Q), dtype="int64", order="C"),
_PS,
np.array(reduced_basis.T, dtype="double", order="C"),
store_dense_gp_map * 1 + 1,
)
bz_grid_addresses = np.array(bz_grid_addresses[:num_gp], dtype="long", order="C")
bzg2grg = np.array(bzg2grg[:num_gp], dtype="long")
bz_grid_addresses = np.array(bz_grid_addresses[:num_gp], dtype="int64", order="C")
bzg2grg = np.array(bzg2grg[:num_gp], dtype="int64")
return bz_grid_addresses, bz_map, bzg2grg
@ -1187,34 +1187,34 @@ def _get_ir_grid_map(
This corresponds to mesh numbers. More precisely, this gives
diagonal elements of diagonal matrix of Smith normal form of
grid generating matrix. See the detail in the docstring of BZGrid.
shape=(3,), dtype='long'
shape=(3,), dtype='int64'
grg_rotations : array_like
GR-grid rotation matrices.
dtype='long', shape=(grg_rotations, 3)
dtype='int64', shape=(grg_rotations, 3)
PS : array_like
GR-grid shift defined.
dtype='long', shape=(3,)
dtype='int64', shape=(3,)
Returns
-------
ir_grid_map : ndarray
Grid point mapping from all indices to ir-gird-point indices in GR-grid.
dtype='long', shape=(prod(mesh),)
dtype='int64', shape=(prod(mesh),)
"""
import phono3py._recgrid as recgrid
ir_grid_map = np.zeros(np.prod(D_diag), dtype="long")
ir_grid_map = np.zeros(np.prod(D_diag), dtype="int64")
if PS is None:
_PS = np.zeros(3, dtype="long")
_PS = np.zeros(3, dtype="int64")
else:
_PS = np.array(PS, dtype="long")
_PS = np.array(PS, dtype="int64")
num_ir = recgrid.ir_grid_map(
ir_grid_map,
np.array(D_diag, dtype="long"),
np.array(D_diag, dtype="int64"),
_PS,
np.array(grg_rotations, dtype="long", order="C"),
np.array(grg_rotations, dtype="int64", order="C"),
)
if num_ir > 0:

View File

@ -67,7 +67,7 @@ def run_phonon_solver_c(
See Interaction.get_phonons().
grid_points : ndarray
Grid point indices.
shape=(grid_points, ), dtype='long'
shape=(grid_points, ), dtype='int64'
grid_address : ndarray
See BZGrid.addresses.
QDinv : ndarray
@ -127,7 +127,7 @@ def run_phonon_solver_c(
is_nac_q_zero = True
_nac_q_direction = np.array(nac_q_direction, dtype="double")
assert grid_points.dtype == np.dtype("long")
assert grid_points.dtype == np.dtype("int64")
assert grid_points.flags.c_contiguous
assert QDinv.dtype == np.dtype("double")
assert QDinv.flags.c_contiguous
@ -256,4 +256,4 @@ def _get_fc_elements_mapping(dm, fc):
fc_p2s = np.arange(len(p2s_map), dtype="intc")
fc_s2p = s2pp_map
return np.array(fc_p2s, dtype="long"), np.array(fc_s2p, dtype="long")
return np.array(fc_p2s, dtype="int64"), np.array(fc_s2p, dtype="int64")

View File

@ -91,7 +91,7 @@ class CollisionMatrix(ImagSelfEnergy):
if not self._is_reducible_collision_matrix:
self._num_ir_grid_points = num_ir_grid_points
self._rot_grid_points = np.array(
self._pp.bz_grid.bzg2grg[rot_grid_points], dtype="long", order="C"
self._pp.bz_grid.bzg2grg[rot_grid_points], dtype="int64", order="C"
)
self._rotations_cartesian = rotations_cartesian
@ -271,8 +271,8 @@ class CollisionMatrix(ImagSelfEnergy):
"""
map_triplets = self._triplets_map_at_q
map_q = self._ir_map_at_q
gp2tp = -np.ones(len(map_triplets), dtype="long")
tp2s = -np.ones(len(map_triplets), dtype="long")
gp2tp = -np.ones(len(map_triplets), dtype="int64")
tp2s = -np.ones(len(map_triplets), dtype="int64")
swapped = np.zeros(len(map_triplets), dtype="bytes")
num_tps = 0

View File

@ -110,13 +110,13 @@ def get_fc3(
if is_compact_fc and "cutoff_distance" not in disp_dataset:
s2p_map = primitive.s2p_map
p2p_map = primitive.p2p_map
s2compact = np.array([p2p_map[i] for i in s2p_map], dtype="long")
s2compact = np.array([p2p_map[i] for i in s2p_map], dtype="int64")
target_atoms = [i for i in p2s_map if i not in first_disp_atoms]
else:
# distribute_fc3 prefers pure translation operations in distributing
# fc3. Below, fc3 already computed are distributed to the first index
# atoms in primitive cell, and then distribute to all the other atoms.
s2compact = np.arange(len(supercell), dtype="long")
s2compact = np.arange(len(supercell), dtype="int64")
target_atoms = [i for i in p2s_map if i not in first_disp_atoms]
distribute_fc3(
fc3,
@ -211,7 +211,7 @@ def distribute_fc3(
if rot_i in pure_trans_indices:
rot_index = rot_i
break
atom_mapping = np.array(permutations[rot_index], dtype="long")
atom_mapping = np.array(permutations[rot_index], dtype="int64")
rot = rotations[rot_index]
rot_cart_inv = np.array(
similarity_transformation(lattice, rot).T, dtype="double", order="C"
@ -271,10 +271,10 @@ def set_permutation_symmetry_compact_fc3(fc3, primitive):
s2pp_map, nsym_list = get_nsym_list_and_s2pp(s2p_map, p2p_map, permutations)
phono3c.permutation_symmetry_compact_fc3(
fc3,
np.array(permutations, dtype="long", order="C"),
np.array(s2pp_map, dtype="long"),
np.array(p2s_map, dtype="long"),
np.array(nsym_list, dtype="long"),
np.array(permutations, dtype="int64", order="C"),
np.array(s2pp_map, dtype="int64"),
np.array(p2s_map, dtype="int64"),
np.array(nsym_list, dtype="int64"),
)
except ImportError as exc:
text = (
@ -325,10 +325,10 @@ def set_translational_invariance_compact_fc3(fc3, primitive: Primitive):
permutations = primitive.atomic_permutations
s2pp_map, nsym_list = get_nsym_list_and_s2pp(s2p_map, p2p_map, permutations)
permutations = np.array(permutations, dtype="long", order="C")
s2pp_map = np.array(s2pp_map, dtype="long")
p2s_map = np.array(p2s_map, dtype="long")
nsym_list = np.array(nsym_list, dtype="long")
permutations = np.array(permutations, dtype="int64", order="C")
s2pp_map = np.array(s2pp_map, dtype="int64")
p2s_map = np.array(p2s_map, dtype="int64")
nsym_list = np.array(nsym_list, dtype="int64")
phono3c.transpose_compact_fc3(
fc3, permutations, s2pp_map, p2s_map, nsym_list, 0
) # dim[0] <--> dim[1]
@ -492,7 +492,7 @@ def _solve_fc3(
rot_map_syms = get_positions_sent_by_rot_inv(
lattice, positions, site_symmetry, symprec
)
rot_map_syms = np.array(rot_map_syms, dtype="long", order="C")
rot_map_syms = np.array(rot_map_syms, dtype="int64", order="C")
rot_disps = get_rotated_displacement(displacements_first, site_sym_cart)
logger.debug("pinv")
@ -599,10 +599,10 @@ def show_drift_fc3(fc3, primitive=None, name="fc3"):
p2p_map = primitive.p2p_map
permutations = primitive.atomic_permutations
s2pp_map, nsym_list = get_nsym_list_and_s2pp(s2p_map, p2p_map, permutations)
permutations = np.array(permutations, dtype="long", order="C")
s2pp_map = np.array(s2pp_map, dtype="long")
p2s_map = np.array(p2s_map, dtype="long")
nsym_list = np.array(nsym_list, dtype="long")
permutations = np.array(permutations, dtype="int64", order="C")
s2pp_map = np.array(s2pp_map, dtype="int64")
p2s_map = np.array(p2s_map, dtype="int64")
nsym_list = np.array(nsym_list, dtype="int64")
num_patom = fc3.shape[0]
num_satom = fc3.shape[1]
maxval1 = 0

View File

@ -170,8 +170,8 @@ class Interaction:
self._svecs, self._multi = self._primitive.get_smallest_vectors()
self._masses = np.array(self._primitive.masses, dtype="double")
self._p2s = np.array(self._primitive.p2s_map, dtype="long")
self._s2p = np.array(self._primitive.s2p_map, dtype="long")
self._p2s = np.array(self._primitive.p2s_map, dtype="int64")
self._s2p = np.array(self._primitive.s2p_map, dtype="int64")
n_satom, n_patom, _ = self._multi.shape
self._all_shortest = np.zeros(
(n_patom, n_satom, n_satom), dtype="byte", order="C"
@ -233,7 +233,7 @@ class Interaction:
Returns
-------
ndarray
shape=(3, ), dtype='long'
shape=(3, ), dtype='int64'
"""
return self._bz_grid.D_diag
@ -332,7 +332,7 @@ class Interaction:
Returns
-------
ndarray
shape=(num_specified_bands, ), dtype='long'
shape=(num_specified_bands, ), dtype='int64'
"""
return self._band_indices
@ -715,7 +715,7 @@ class Interaction:
self.run_phonon_solver_with_eigvec_rotation()
else:
self._run_phonon_solver_c(
np.arange(len(self._bz_grid.addresses), dtype="long")
np.arange(len(self._bz_grid.addresses), dtype="int64")
)
else:
self._run_phonon_solver_c(grid_points)
@ -743,12 +743,12 @@ class Interaction:
self._phonon_done[self._bz_grid.gp_Gamma] = 0
if is_nac:
self._done_nac_at_gamma = True
self.run_phonon_solver(np.array([self._bz_grid.gp_Gamma], dtype="long"))
self.run_phonon_solver(np.array([self._bz_grid.gp_Gamma], dtype="int64"))
else:
self._done_nac_at_gamma = False
_nac_q_direction = self._nac_q_direction
self._nac_q_direction = None
self.run_phonon_solver(np.array([self._bz_grid.gp_Gamma], dtype="long"))
self.run_phonon_solver(np.array([self._bz_grid.gp_Gamma], dtype="int64"))
self._nac_q_direction = _nac_q_direction
def run_phonon_solver_with_eigvec_rotation(self):
@ -860,7 +860,7 @@ class Interaction:
in this method.
"""
r_inv = -np.eye(3, dtype="long")
r_inv = -np.eye(3, dtype="int64")
bz_grid_points_solved = []
for bzgp, done in enumerate(self._phonon_done):
if done:
@ -882,7 +882,7 @@ class Interaction:
[
bzgp_mq,
],
dtype="long",
dtype="int64",
)
)
bz_grid_points_solved.append(bzgp_mq)
@ -925,9 +925,9 @@ class Interaction:
def _set_band_indices(self, band_indices):
num_band = len(self._primitive) * 3
if band_indices is None:
self._band_indices = np.arange(num_band, dtype="long")
self._band_indices = np.arange(num_band, dtype="int64")
else:
self._band_indices = np.array(band_indices, dtype="long")
self._band_indices = np.array(band_indices, dtype="int64")
def _run_c(self, g_zero):
import phono3py._phono3py as phono3c

View File

@ -263,7 +263,7 @@ class JointDos:
)
raise RuntimeError(msg)
self.run_phonon_solver(np.array([gamma_gp, grid_point], dtype="long"))
self.run_phonon_solver(np.array([gamma_gp, grid_point], dtype="int64"))
def run_phonon_solver(self, grid_points=None):
"""Calculate phonons at grid_points.
@ -273,7 +273,7 @@ class JointDos:
"""
if grid_points is None:
_grid_points = np.arange(len(self._bz_grid.addresses), dtype="long")
_grid_points = np.arange(len(self._bz_grid.addresses), dtype="int64")
else:
_grid_points = grid_points
@ -306,11 +306,11 @@ class JointDos:
"""
self._phonon_done[self._bz_grid.gp_Gamma] = 0
if is_nac:
self.run_phonon_solver(np.array([self._bz_grid.gp_Gamma], dtype="long"))
self.run_phonon_solver(np.array([self._bz_grid.gp_Gamma], dtype="int64"))
else:
_nac_q_direction = self._nac_q_direction
self._nac_q_direction = None
self.run_phonon_solver(np.array([self._bz_grid.gp_Gamma], dtype="long"))
self.run_phonon_solver(np.array([self._bz_grid.gp_Gamma], dtype="int64"))
self._nac_q_direction = _nac_q_direction
def run(self):

View File

@ -67,7 +67,7 @@ def get_triplets_at_q(
reciprocal_rotations : array_like or None, optional
Rotation matrices {R} with respect to reciprocal basis vectors.
Defined by q'=Rq.
dtype='long', shape=(rotations, 3, 3)
dtype='int64', shape=(rotations, 3, 3)
is_time_reversal : bool, optional
Inversion symemtry is added if it doesn't exist. Default is True.
swappable : bool, optional
@ -78,10 +78,10 @@ def get_triplets_at_q(
triplets_at_q : ndarray
Symmetry reduced number of triplets are stored as grid point
integer numbers in BZGrid system.
shape=(n_triplets, 3), dtype='long'
shape=(n_triplets, 3), dtype='int64'
weights : ndarray
Weights of triplets in Brillouin zone
shape=(n_triplets,), dtype='long'
shape=(n_triplets,), dtype='int64'
map_triplets : ndarray or None
Mapping table of all triplets to symmetrically independent
tripelts in generalized regular grid system. More precisely,
@ -89,11 +89,11 @@ def get_triplets_at_q(
independent q' of q+q'+q''=G. Considering q' is enough because
q is fixed and q''=G-q-q' where G is automatically determined
to choose smallest |G|.
shape=(prod(mesh),), dtype='long'
shape=(prod(mesh),), dtype='int64'
map_q : ndarray
Irreducible q-points stabilized by q-point of specified grid_point
in generalized regular grid system.
shape=(prod(mesh),), dtype='long'
shape=(prod(mesh),), dtype='int64'
"""
if reciprocal_rotations is None:
@ -126,7 +126,7 @@ def get_all_triplets(grid_point: int, bz_grid: BZGrid):
"""
triplets_at_q, _ = _get_BZ_triplets_at_q(
grid_point, bz_grid, np.arange(np.prod(bz_grid.D_diag), dtype="long")
grid_point, bz_grid, np.arange(np.prod(bz_grid.D_diag), dtype="int64")
)
return triplets_at_q
@ -138,8 +138,8 @@ def get_nosym_triplets_at_q(grid_point: int, bz_grid: BZGrid):
See the docstring of get_triplets_at_q.
"""
map_triplets = np.arange(np.prod(bz_grid.D_diag), dtype="long")
map_q = np.arange(np.prod(bz_grid.D_diag), dtype="long")
map_triplets = np.arange(np.prod(bz_grid.D_diag), dtype="int64")
map_q = np.arange(np.prod(bz_grid.D_diag), dtype="int64")
triplets_at_q, weights = _get_BZ_triplets_at_q(grid_point, bz_grid, map_triplets)
return triplets_at_q, weights, map_triplets, map_q
@ -239,11 +239,11 @@ def _get_triplets_reciprocal_mesh_at_q(
fixed_grid_number : int
Grid point of q0
D_diag : array_like
Diagonal part of the diagonal matrix by SNF. shape=(3,), dtype='long'
Diagonal part of the diagonal matrix by SNF. shape=(3,), dtype='int64'
rec_rotations : array_like
Rotation matrices in reciprocal space, where the rotation matrix R is
defined like q'=Rq. Time reversal symmetry is taken care of by
is_time_reversal. shape=(n_rot, 3, 3), dtype='long'
is_time_reversal. shape=(n_rot, 3, 3), dtype='int64'
is_time_reversal : bool
Inversion symemtry is added if it doesn't exist.
swappable : bool
@ -257,24 +257,24 @@ def _get_triplets_reciprocal_mesh_at_q(
independent q' of q+q'+q''=G. Considering q' is enough because q is
fixed and q''=G-q-q' where G is automatically determined to choose
smallest |G| without considering BZ surface (see docstring of
_get_BZ_triplets_at_q.) shape=(prod(mesh),), dtype='long'
_get_BZ_triplets_at_q.) shape=(prod(mesh),), dtype='int64'
map_q : ndarray
Irreducible q-points stabilized by q-point of specified grid_point.
shape=(prod(mesh),), dtype='long'
shape=(prod(mesh),), dtype='int64'
"""
import phono3py._phono3py as phono3c
map_triplets = np.zeros(np.prod(D_diag), dtype="long")
map_q = np.zeros(np.prod(D_diag), dtype="long")
map_triplets = np.zeros(np.prod(D_diag), dtype="int64")
map_q = np.zeros(np.prod(D_diag), dtype="int64")
num_triplets = phono3c.triplets_reciprocal_mesh_at_q(
map_triplets,
map_q,
fixed_grid_number,
np.array(D_diag, dtype="long"),
np.array(D_diag, dtype="int64"),
is_time_reversal * 1,
np.array(rec_rotations, dtype="long", order="C"),
np.array(rec_rotations, dtype="int64", order="C"),
swappable * 1,
)
assert num_triplets == len(np.unique(map_triplets))
@ -307,40 +307,40 @@ def _get_BZ_triplets_at_q(bz_grid_index, bz_grid: BZGrid, map_triplets):
q''=G-q-q' where G is automatically determined to choose
smallest |G| without considering BZ surface (see docstring of
_get_BZ_triplets_at_q.)
shape=(prod(mesh),), dtype='long'
shape=(prod(mesh),), dtype='int64'
Returns
-------
triplets : ndarray
Symmetry reduced number of triplets are stored as grid point
integer numbers.
shape=(n_triplets, 3), dtype='long'
shape=(n_triplets, 3), dtype='int64'
ir_weights : ndarray
Weights of triplets at a fixed q0.
shape=(n_triplets,), dtype='long'
shape=(n_triplets,), dtype='int64'
"""
import phono3py._phono3py as phono3c
weights = np.zeros(len(map_triplets), dtype="long")
weights = np.zeros(len(map_triplets), dtype="int64")
for g in map_triplets:
weights[g] += 1
ir_weights = np.extract(weights > 0, weights)
triplets = -np.ones((len(ir_weights), 3), dtype="long", order="C")
triplets = -np.ones((len(ir_weights), 3), dtype="int64", order="C")
num_ir_ret = phono3c.BZ_triplets_at_q(
triplets,
bz_grid_index,
bz_grid.addresses,
bz_grid.gp_map,
map_triplets,
np.array(bz_grid.D_diag, dtype="long"),
np.array(bz_grid.D_diag, dtype="int64"),
bz_grid.Q,
bz_grid.store_dense_gp_map * 1 + 1,
)
assert num_ir_ret == len(ir_weights)
return triplets, np.array(ir_weights, dtype="long")
return triplets, np.array(ir_weights, dtype="int64")
def _set_triplets_integration_weights_c(
@ -358,7 +358,7 @@ def _set_triplets_integration_weights_c(
g,
g_zero,
frequency_points, # f0
np.array(np.dot(tetrahedra, pp.bz_grid.P.T), dtype="long", order="C"),
np.array(np.dot(tetrahedra, pp.bz_grid.P.T), dtype="int64", order="C"),
pp.bz_grid.D_diag,
triplets_at_q,
frequencies, # f1
@ -381,7 +381,7 @@ def _set_triplets_integration_weights_py(
thm = TetrahedronMethod(pp.bz_grid.microzone_lattice)
triplets_at_q = pp.get_triplets_at_q()[0]
tetrahedra_vertices = _get_tetrahedra_vertices(
np.array(np.dot(thm.tetrahedra, pp.bz_grid.P.T), dtype="long", order="C"),
np.array(np.dot(thm.tetrahedra, pp.bz_grid.P.T), dtype="int64", order="C"),
triplets_at_q,
pp.bz_grid,
)
@ -415,7 +415,7 @@ def _get_tetrahedra_vertices(relative_address, triplets_at_q, bz_grid: BZGrid):
"""
num_triplets = len(triplets_at_q)
vertices = np.zeros((num_triplets, 2, 24, 4), dtype="long")
vertices = np.zeros((num_triplets, 2, 24, 4), dtype="int64")
for i, tp in enumerate(triplets_at_q):
for j, adrs_shift in enumerate((relative_address, -relative_address)):
adrs = bz_grid.addresses[tp[j + 1]] + adrs_shift

View File

@ -1446,7 +1446,7 @@ def test_agno2_BZGrid_with_shift(agno2_cell: PhonopyAtoms):
def test_relocate_BZ_grid_address_FCC():
"""Test of _relocate_BZ_grid_address by FCC."""
D_diag = [4, 4, 4]
Q = np.eye(3, dtype="long")
Q = np.eye(3, dtype="int64")
reciprocal_lattice = np.array([[-1, 1, 1], [1, -1, 1], [1, 1, -1]], dtype="double")
bz_grid_addresses, bz_map, bzg2grg = _relocate_BZ_grid_address(
D_diag,