mirror of https://github.com/phonopy/phono3py.git
Phonon solver integer type changed from int -> long
This commit is contained in:
parent
b36fc7f17b
commit
e833a39d3e
|
@ -0,0 +1,82 @@
|
|||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_policy(SET CMP0007 NEW)
|
||||
|
||||
project(phono3py C)
|
||||
set(CMAKE_MACOSX_RPATH 1)
|
||||
set(CMAKE_C_FLAGS_RELEASE "-Wall -O2")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-g -DTHMWARNING -DMATWARNING -DKPTWARNING")
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
endif(NOT CMAKE_BUILD_TYPE)
|
||||
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
|
||||
# Version numbers
|
||||
file(READ ${PROJECT_SOURCE_DIR}/phono3py/version.py version_file)
|
||||
string(REGEX MATCH "__version__.*([0-9]+)[.]([0-9]+)[.]([0-9]+)" phono3py_version ${version_file})
|
||||
set(phono3py_major_version ${CMAKE_MATCH_1})
|
||||
set(phono3py_minor_version ${CMAKE_MATCH_2})
|
||||
set(phono3py_micro_version ${CMAKE_MATCH_3})
|
||||
set(serial "${phono3py_major_version}.${phono3py_minor_version}.${phono3py_micro_version}")
|
||||
set(soserial "1")
|
||||
|
||||
# Source code
|
||||
include_directories("${PROJECT_SOURCE_DIR}/c")
|
||||
set(SOURCES
|
||||
${PROJECT_SOURCE_DIR}/c/collision_matrix.c
|
||||
${PROJECT_SOURCE_DIR}/c/dynmat.c
|
||||
${PROJECT_SOURCE_DIR}/c/fc3.c
|
||||
${PROJECT_SOURCE_DIR}/c/imag_self_energy_with_g.c
|
||||
${PROJECT_SOURCE_DIR}/c/interaction.c
|
||||
${PROJECT_SOURCE_DIR}/c/isotope.c
|
||||
${PROJECT_SOURCE_DIR}/c/kgrid.c
|
||||
${PROJECT_SOURCE_DIR}/c/kpoint.c
|
||||
${PROJECT_SOURCE_DIR}/c/lapack_wrapper.c
|
||||
${PROJECT_SOURCE_DIR}/c/mathfunc.c
|
||||
${PROJECT_SOURCE_DIR}/c/phono3py.c
|
||||
${PROJECT_SOURCE_DIR}/c/phonoc_utils.c
|
||||
${PROJECT_SOURCE_DIR}/c/phonon.c
|
||||
${PROJECT_SOURCE_DIR}/c/pp_collision.c
|
||||
${PROJECT_SOURCE_DIR}/c/real_self_energy.c
|
||||
${PROJECT_SOURCE_DIR}/c/real_to_reciprocal.c
|
||||
${PROJECT_SOURCE_DIR}/c/reciprocal_to_normal.c
|
||||
${PROJECT_SOURCE_DIR}/c/tetrahedron_method.c
|
||||
${PROJECT_SOURCE_DIR}/c/triplet.c
|
||||
${PROJECT_SOURCE_DIR}/c/triplet_iw.c
|
||||
${PROJECT_SOURCE_DIR}/c/triplet_kpoint.c)
|
||||
|
||||
# Shared library
|
||||
add_library(ph3py SHARED ${SOURCES})
|
||||
|
||||
find_package(OpenMP)
|
||||
if (OPENMP_FOUND)
|
||||
set(openmp "-lgomp")
|
||||
else()
|
||||
set(openmp "-lomp")
|
||||
endif()
|
||||
|
||||
include_directories($ENV{CONDA_PREFIX}/include)
|
||||
link_directories($ENV{CONDA_PREFIX}/lib)
|
||||
set(LAPACK_LIBRARIES "-llapack")
|
||||
set(BLAS_LIBRARIES "-lopenblas")
|
||||
|
||||
if(NOT MSVC)
|
||||
target_link_libraries(ph3py m ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} ${openmp})
|
||||
endif()
|
||||
set_property(TARGET ph3py PROPERTY VERSION ${serial})
|
||||
set_property(TARGET ph3py PROPERTY SOVERSION ${soserial})
|
||||
install(TARGETS ph3py LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
# Static link library
|
||||
add_library(ph3py_static STATIC ${SOURCES})
|
||||
set_property(TARGET ph3py_static PROPERTY VERSION ${serial})
|
||||
set_property(TARGET ph3py_static PROPERTY SOVERSION ${soserial})
|
||||
set_property(TARGET ph3py_static PROPERTY OUTPUT_NAME ph3py)
|
||||
install(TARGETS ph3py_static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
# Header file
|
||||
install(FILES ${PROJECT_SOURCE_DIR}/c/phono3py.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
@ -97,6 +97,9 @@ static void show_colmat_info(const PyArrayObject *collision_matrix_py,
|
|||
const size_t i_sigma,
|
||||
const size_t i_temp,
|
||||
const size_t adrs_shift);
|
||||
static Iarray* convert_to_iarray(const PyArrayObject* npyary);
|
||||
static Darray* convert_to_darray(const PyArrayObject* npyary);
|
||||
|
||||
|
||||
struct module_state {
|
||||
PyObject *error;
|
||||
|
@ -323,20 +326,20 @@ static PyObject * py_get_phonons_at_gridpoints(PyObject *self, PyObject *args)
|
|||
double* freqs;
|
||||
lapack_complex_double* eigvecs;
|
||||
char* phonon_done;
|
||||
size_t* grid_points;
|
||||
int (*grid_address)[3];
|
||||
int* mesh;
|
||||
long* grid_points;
|
||||
long (*grid_address)[3];
|
||||
long* mesh;
|
||||
double* fc2;
|
||||
double(*svecs_fc2)[27][3];
|
||||
int* multi_fc2;
|
||||
long* multi_fc2;
|
||||
double (*positions_fc2)[3];
|
||||
double* masses_fc2;
|
||||
int* p2s_fc2;
|
||||
int* s2p_fc2;
|
||||
long* p2s_fc2;
|
||||
long* s2p_fc2;
|
||||
double (*rec_lat)[3];
|
||||
double * dd_q0;
|
||||
double (*G_list)[3];
|
||||
npy_intp num_patom, num_satom, num_phonons, num_grid_points, num_G_points;
|
||||
long num_patom, num_satom, num_phonons, num_grid_points, num_G_points;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "OOOOOOOOOOOOOdOOOOdOOds",
|
||||
&py_frequencies,
|
||||
|
@ -368,20 +371,20 @@ static PyObject * py_get_phonons_at_gridpoints(PyObject *self, PyObject *args)
|
|||
freqs = (double*)PyArray_DATA(py_frequencies);
|
||||
eigvecs = (lapack_complex_double*)PyArray_DATA(py_eigenvectors);
|
||||
phonon_done = (char*)PyArray_DATA(py_phonon_done);
|
||||
grid_points = (size_t*)PyArray_DATA(py_grid_points);
|
||||
grid_address = (int(*)[3])PyArray_DATA(py_grid_address);
|
||||
mesh = (int*)PyArray_DATA(py_mesh);
|
||||
grid_points = (long*)PyArray_DATA(py_grid_points);
|
||||
grid_address = (long(*)[3])PyArray_DATA(py_grid_address);
|
||||
mesh = (long*)PyArray_DATA(py_mesh);
|
||||
fc2 = (double*)PyArray_DATA(py_fc2);
|
||||
svecs_fc2 = (double(*)[27][3])PyArray_DATA(py_shortest_vectors_fc2);
|
||||
multi_fc2 = (int*)PyArray_DATA(py_multiplicity_fc2);
|
||||
multi_fc2 = (long*)PyArray_DATA(py_multiplicity_fc2);
|
||||
masses_fc2 = (double*)PyArray_DATA(py_masses_fc2);
|
||||
p2s_fc2 = (int*)PyArray_DATA(py_p2s_map_fc2);
|
||||
s2p_fc2 = (int*)PyArray_DATA(py_s2p_map_fc2);
|
||||
p2s_fc2 = (long*)PyArray_DATA(py_p2s_map_fc2);
|
||||
s2p_fc2 = (long*)PyArray_DATA(py_s2p_map_fc2);
|
||||
rec_lat = (double(*)[3])PyArray_DATA(py_reciprocal_lattice);
|
||||
num_patom = PyArray_DIMS(py_multiplicity_fc2)[1];
|
||||
num_satom = PyArray_DIMS(py_multiplicity_fc2)[0];
|
||||
num_phonons = PyArray_DIMS(py_frequencies)[0];
|
||||
num_grid_points = PyArray_DIMS(py_grid_points)[0];
|
||||
num_patom = (long)PyArray_DIMS(py_multiplicity_fc2)[1];
|
||||
num_satom = (long)PyArray_DIMS(py_multiplicity_fc2)[0];
|
||||
num_phonons = (long)PyArray_DIMS(py_frequencies)[0];
|
||||
num_grid_points = (long)PyArray_DIMS(py_grid_points)[0];
|
||||
if ((PyObject*)py_born_effective_charge == Py_None) {
|
||||
born = NULL;
|
||||
} else {
|
||||
|
@ -412,7 +415,7 @@ static PyObject * py_get_phonons_at_gridpoints(PyObject *self, PyObject *args)
|
|||
num_G_points = 0;
|
||||
} else {
|
||||
G_list = (double(*)[3])PyArray_DATA(py_G_list);
|
||||
num_G_points = PyArray_DIMS(py_G_list)[0];
|
||||
num_G_points = (long)PyArray_DIMS(py_G_list)[0];
|
||||
}
|
||||
if ((PyObject*)py_positions_fc2 == Py_None) {
|
||||
positions_fc2 = NULL;
|
||||
|
@ -1249,7 +1252,7 @@ static PyObject * py_expand_collision_matrix(PyObject *self, PyObject *args)
|
|||
double *collision_matrix;
|
||||
size_t *rot_grid_points;
|
||||
size_t *ir_grid_points;
|
||||
npy_intp num_band, num_grid_points, num_temp, num_sigma, num_rot, num_ir_gp;
|
||||
long num_band, num_grid_points, num_temp, num_sigma, num_rot, num_ir_gp;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "OOO",
|
||||
&py_collision_matrix,
|
||||
|
@ -1261,12 +1264,12 @@ static PyObject * py_expand_collision_matrix(PyObject *self, PyObject *args)
|
|||
collision_matrix = (double*)PyArray_DATA(py_collision_matrix);
|
||||
rot_grid_points = (size_t*)PyArray_DATA(py_rot_grid_points);
|
||||
ir_grid_points = (size_t*)PyArray_DATA(py_ir_grid_points);
|
||||
num_sigma = PyArray_DIMS(py_collision_matrix)[0];
|
||||
num_temp = PyArray_DIMS(py_collision_matrix)[1];
|
||||
num_grid_points = PyArray_DIMS(py_collision_matrix)[2];
|
||||
num_band = PyArray_DIMS(py_collision_matrix)[3];
|
||||
num_rot = PyArray_DIMS(py_rot_grid_points)[0];
|
||||
num_ir_gp = PyArray_DIMS(py_ir_grid_points)[0];
|
||||
num_sigma = (long)PyArray_DIMS(py_collision_matrix)[0];
|
||||
num_temp = (long)PyArray_DIMS(py_collision_matrix)[1];
|
||||
num_grid_points = (long)PyArray_DIMS(py_collision_matrix)[2];
|
||||
num_band = (long)PyArray_DIMS(py_collision_matrix)[3];
|
||||
num_rot = (long)PyArray_DIMS(py_rot_grid_points)[0];
|
||||
num_ir_gp = (long)PyArray_DIMS(py_ir_grid_points)[0];
|
||||
|
||||
ph3py_expand_collision_matrix(collision_matrix,
|
||||
rot_grid_points,
|
||||
|
@ -2152,3 +2155,31 @@ static void show_colmat_info(const PyArrayObject *py_collision_matrix,
|
|||
}
|
||||
printf("Data shift:%lu [%lu, %lu]\n", adrs_shift, i_sigma, i_temp);
|
||||
}
|
||||
|
||||
|
||||
static Iarray* convert_to_iarray(const PyArrayObject* npyary)
|
||||
{
|
||||
int i;
|
||||
Iarray *ary;
|
||||
|
||||
ary = (Iarray*) malloc(sizeof(Iarray));
|
||||
for (i = 0; i < PyArray_NDIM(npyary); i++) {
|
||||
ary->dims[i] = PyArray_DIMS(npyary)[i];
|
||||
}
|
||||
ary->data = (int*)PyArray_DATA(npyary);
|
||||
return ary;
|
||||
}
|
||||
|
||||
|
||||
static Darray* convert_to_darray(const PyArrayObject* npyary)
|
||||
{
|
||||
int i;
|
||||
Darray *ary;
|
||||
|
||||
ary = (Darray*) malloc(sizeof(Darray));
|
||||
for (i = 0; i < PyArray_NDIM(npyary); i++) {
|
||||
ary->dims[i] = PyArray_DIMS(npyary)[i];
|
||||
}
|
||||
ary->data = (double*)PyArray_DATA(npyary);
|
||||
return ary;
|
||||
}
|
||||
|
|
138
c/dynmat.c
138
c/dynmat.c
|
@ -38,63 +38,63 @@
|
|||
#define PI 3.14159265358979323846
|
||||
|
||||
static void get_dynmat_ij(double *dynamical_matrix,
|
||||
const int num_patom,
|
||||
const int num_satom,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
const double *fc,
|
||||
const double q[3],
|
||||
PHPYCONST double (*svecs)[27][3],
|
||||
const int *multi,
|
||||
const long *multi,
|
||||
const double *mass,
|
||||
const int *s2p_map,
|
||||
const int *p2s_map,
|
||||
const long *s2p_map,
|
||||
const long *p2s_map,
|
||||
PHPYCONST double (*charge_sum)[3][3],
|
||||
const int i,
|
||||
const int j);
|
||||
const long i,
|
||||
const long j);
|
||||
static void get_dm(double dm_real[3][3],
|
||||
double dm_imag[3][3],
|
||||
const int num_patom,
|
||||
const int num_satom,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
const double *fc,
|
||||
const double q[3],
|
||||
PHPYCONST double (*svecs)[27][3],
|
||||
const int *multi,
|
||||
const int *p2s_map,
|
||||
const long *multi,
|
||||
const long *p2s_map,
|
||||
PHPYCONST double (*charge_sum)[3][3],
|
||||
const int i,
|
||||
const int j,
|
||||
const int k);
|
||||
const long i,
|
||||
const long j,
|
||||
const long k);
|
||||
static double get_dielectric_part(const double q_cart[3],
|
||||
PHPYCONST double dielectric[3][3]);
|
||||
static void get_KK(double *dd_part, /* [natom, 3, natom, 3, (real,imag)] */
|
||||
PHPYCONST double (*G_list)[3], /* [num_G, 3] */
|
||||
const int num_G,
|
||||
const int num_patom,
|
||||
const long num_G,
|
||||
const long num_patom,
|
||||
const double q_cart[3],
|
||||
const double *q_direction_cart,
|
||||
PHPYCONST double dielectric[3][3],
|
||||
PHPYCONST double (*pos)[3], /* [num_patom, 3] */
|
||||
const double lambda,
|
||||
const double tolerance);
|
||||
static void make_Hermitian(double *mat, const int num_band);
|
||||
static void make_Hermitian(double *mat, const long num_band);
|
||||
static void multiply_borns(double *dd,
|
||||
const double *dd_in,
|
||||
const int num_patom,
|
||||
const long num_patom,
|
||||
PHPYCONST double (*born)[3][3]);
|
||||
|
||||
int dym_get_dynamical_matrix_at_q(double *dynamical_matrix,
|
||||
const int num_patom,
|
||||
const int num_satom,
|
||||
const double *fc,
|
||||
const double q[3],
|
||||
PHPYCONST double (*svecs)[27][3],
|
||||
const int *multi,
|
||||
const double *mass,
|
||||
const int *s2p_map,
|
||||
const int *p2s_map,
|
||||
PHPYCONST double (*charge_sum)[3][3],
|
||||
const int with_openmp)
|
||||
long dym_get_dynamical_matrix_at_q(double *dynamical_matrix,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
const double *fc,
|
||||
const double q[3],
|
||||
PHPYCONST double (*svecs)[27][3],
|
||||
const long *multi,
|
||||
const double *mass,
|
||||
const long *s2p_map,
|
||||
const long *p2s_map,
|
||||
PHPYCONST double (*charge_sum)[3][3],
|
||||
const long with_openmp)
|
||||
{
|
||||
int i, j, ij;
|
||||
long i, j, ij;
|
||||
|
||||
if (with_openmp) {
|
||||
#pragma omp parallel for
|
||||
|
@ -141,8 +141,8 @@ int dym_get_dynamical_matrix_at_q(double *dynamical_matrix,
|
|||
void dym_get_recip_dipole_dipole(double *dd, /* [natom, 3, natom, 3, (real,imag)] */
|
||||
const double *dd_q0, /* [natom, 3, 3, (real,imag)] */
|
||||
PHPYCONST double (*G_list)[3], /* [num_G, 3] */
|
||||
const int num_G,
|
||||
const int num_patom,
|
||||
const long num_G,
|
||||
const long num_patom,
|
||||
const double q_cart[3],
|
||||
const double *q_direction_cart, /* must be pointer */
|
||||
PHPYCONST double (*born)[3][3],
|
||||
|
@ -152,7 +152,7 @@ void dym_get_recip_dipole_dipole(double *dd, /* [natom, 3, natom, 3, (real,imag)
|
|||
const double lambda,
|
||||
const double tolerance)
|
||||
{
|
||||
int i, k, l, adrs, adrs_sum;
|
||||
long i, k, l, adrs, adrs_sum;
|
||||
double *dd_tmp;
|
||||
|
||||
dd_tmp = NULL;
|
||||
|
@ -200,15 +200,15 @@ void dym_get_recip_dipole_dipole(double *dd, /* [natom, 3, natom, 3, (real,imag)
|
|||
|
||||
void dym_get_recip_dipole_dipole_q0(double *dd_q0, /* [natom, 3, 3, (real,imag)] */
|
||||
PHPYCONST double (*G_list)[3], /* [num_G, 3] */
|
||||
const int num_G,
|
||||
const int num_patom,
|
||||
const long num_G,
|
||||
const long num_patom,
|
||||
PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST double dielectric[3][3],
|
||||
PHPYCONST double (*pos)[3], /* [num_patom, 3] */
|
||||
const double lambda,
|
||||
const double tolerance)
|
||||
{
|
||||
int i, j, k, l, adrs_tmp, adrs, adrsT;
|
||||
long i, j, k, l, adrs_tmp, adrs, adrsT;
|
||||
double zero_vec[3];
|
||||
double *dd_tmp1, *dd_tmp2;
|
||||
|
||||
|
@ -292,12 +292,12 @@ void dym_get_recip_dipole_dipole_q0(double *dd_q0, /* [natom, 3, 3, (real,imag)]
|
|||
}
|
||||
|
||||
void dym_get_charge_sum(double (*charge_sum)[3][3],
|
||||
const int num_patom,
|
||||
const long num_patom,
|
||||
const double factor, /* 4pi/V*unit-conv and denominator */
|
||||
const double q_cart[3],
|
||||
PHPYCONST double (*born)[3][3])
|
||||
{
|
||||
int i, j, k, a, b;
|
||||
long i, j, k, a, b;
|
||||
double (*q_born)[3];
|
||||
|
||||
q_born = (double (*)[3]) malloc(sizeof(double[3]) * num_patom);
|
||||
|
@ -339,14 +339,14 @@ void dym_transform_dynmat_to_fc(double *fc,
|
|||
const double *dm,
|
||||
PHPYCONST double (*comm_points)[3],
|
||||
PHPYCONST double (*shortest_vectors)[27][3],
|
||||
const int *multiplicities,
|
||||
const long *multiplicities,
|
||||
const double *masses,
|
||||
const int *s2pp_map,
|
||||
const int *fc_index_map,
|
||||
const int num_patom,
|
||||
const int num_satom)
|
||||
const long *s2pp_map,
|
||||
const long *fc_index_map,
|
||||
const long num_patom,
|
||||
const long num_satom)
|
||||
{
|
||||
int i, j, k, l, m, N, adrs, multi;
|
||||
long i, j, k, l, m, N, adrs, multi;
|
||||
double coef, phase, cos_phase, sin_phase;
|
||||
|
||||
N = num_satom / num_patom;
|
||||
|
@ -387,20 +387,20 @@ void dym_transform_dynmat_to_fc(double *fc,
|
|||
|
||||
|
||||
static void get_dynmat_ij(double *dynamical_matrix,
|
||||
const int num_patom,
|
||||
const int num_satom,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
const double *fc,
|
||||
const double q[3],
|
||||
PHPYCONST double (*svecs)[27][3],
|
||||
const int *multi,
|
||||
const long *multi,
|
||||
const double *mass,
|
||||
const int *s2p_map,
|
||||
const int *p2s_map,
|
||||
const long *s2p_map,
|
||||
const long *p2s_map,
|
||||
PHPYCONST double (*charge_sum)[3][3],
|
||||
const int i,
|
||||
const int j)
|
||||
const long i,
|
||||
const long j)
|
||||
{
|
||||
int k, l, adrs;
|
||||
long k, l, adrs;
|
||||
double mass_sqrt;
|
||||
double dm_real[3][3], dm_imag[3][3];
|
||||
|
||||
|
@ -443,19 +443,19 @@ static void get_dynmat_ij(double *dynamical_matrix,
|
|||
|
||||
static void get_dm(double dm_real[3][3],
|
||||
double dm_imag[3][3],
|
||||
const int num_patom,
|
||||
const int num_satom,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
const double *fc,
|
||||
const double q[3],
|
||||
PHPYCONST double (*svecs)[27][3],
|
||||
const int *multi,
|
||||
const int *p2s_map,
|
||||
const long *multi,
|
||||
const long *p2s_map,
|
||||
PHPYCONST double (*charge_sum)[3][3],
|
||||
const int i,
|
||||
const int j,
|
||||
const int k)
|
||||
const long i,
|
||||
const long j,
|
||||
const long k)
|
||||
{
|
||||
int l, m;
|
||||
long l, m;
|
||||
double phase, cos_phase, sin_phase, fc_elem;
|
||||
|
||||
cos_phase = 0;
|
||||
|
@ -487,7 +487,7 @@ static void get_dm(double dm_real[3][3],
|
|||
static double get_dielectric_part(const double q_cart[3],
|
||||
PHPYCONST double dielectric[3][3])
|
||||
{
|
||||
int i, j;
|
||||
long i, j;
|
||||
double x[3];
|
||||
double sum;
|
||||
|
||||
|
@ -508,8 +508,8 @@ static double get_dielectric_part(const double q_cart[3],
|
|||
|
||||
static void get_KK(double *dd_part, /* [natom, 3, natom, 3, (real,imag)] */
|
||||
PHPYCONST double (*G_list)[3], /* [num_G, 3] */
|
||||
const int num_G,
|
||||
const int num_patom,
|
||||
const long num_G,
|
||||
const long num_patom,
|
||||
const double q_cart[3],
|
||||
const double *q_direction_cart,
|
||||
PHPYCONST double dielectric[3][3],
|
||||
|
@ -517,7 +517,7 @@ static void get_KK(double *dd_part, /* [natom, 3, natom, 3, (real,imag)] */
|
|||
const double lambda,
|
||||
const double tolerance)
|
||||
{
|
||||
int i, j, k, l, g, adrs;
|
||||
long i, j, k, l, g, adrs;
|
||||
double q_K[3];
|
||||
double norm, cos_phase, sin_phase, phase, dielectric_part, exp_damp, L2;
|
||||
double KK[3][3];
|
||||
|
@ -580,9 +580,9 @@ static void get_KK(double *dd_part, /* [natom, 3, natom, 3, (real,imag)] */
|
|||
}
|
||||
}
|
||||
|
||||
static void make_Hermitian(double *mat, const int num_band)
|
||||
static void make_Hermitian(double *mat, const long num_band)
|
||||
{
|
||||
int i, j, adrs, adrsT;
|
||||
long i, j, adrs, adrsT;
|
||||
|
||||
for (i = 0; i < num_band; i++) {
|
||||
for (j = i; j < num_band; j++) {
|
||||
|
@ -605,10 +605,10 @@ static void make_Hermitian(double *mat, const int num_band)
|
|||
|
||||
static void multiply_borns(double *dd,
|
||||
const double *dd_in,
|
||||
const int num_patom,
|
||||
const long num_patom,
|
||||
PHPYCONST double (*born)[3][3])
|
||||
{
|
||||
int i, j, k, l, m, n, adrs, adrs_in;
|
||||
long i, j, k, l, m, n, adrs, adrs_in;
|
||||
double zz;
|
||||
|
||||
for (i = 0; i < num_patom; i++) {
|
||||
|
|
44
c/dynmat.h
44
c/dynmat.h
|
@ -37,23 +37,23 @@
|
|||
|
||||
#define PHPYCONST
|
||||
|
||||
int dym_get_dynamical_matrix_at_q(double *dynamical_matrix,
|
||||
const int num_patom,
|
||||
const int num_satom,
|
||||
const double *fc,
|
||||
const double q[3],
|
||||
PHPYCONST double (*svecs)[27][3],
|
||||
const int *multi,
|
||||
const double *mass,
|
||||
const int *s2p_map,
|
||||
const int *p2s_map,
|
||||
PHPYCONST double (*charge_sum)[3][3],
|
||||
const int with_openmp);
|
||||
long dym_get_dynamical_matrix_at_q(double *dynamical_matrix,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
const double *fc,
|
||||
const double q[3],
|
||||
PHPYCONST double (*svecs)[27][3],
|
||||
const long *multi,
|
||||
const double *mass,
|
||||
const long *s2p_map,
|
||||
const long *p2s_map,
|
||||
PHPYCONST double (*charge_sum)[3][3],
|
||||
const long with_openmp);
|
||||
void dym_get_recip_dipole_dipole(double *dd, /* [natom, 3, natom, 3, (real,imag)] */
|
||||
const double *dd_q0, /* [natom, 3, 3, (real,imag)] */
|
||||
PHPYCONST double (*G_list)[3], /* [num_G, 3] */
|
||||
const int num_G,
|
||||
const int num_patom,
|
||||
const long num_G,
|
||||
const long num_patom,
|
||||
const double q_cart[3],
|
||||
const double *q_direction_cart, /* must be pointer */
|
||||
PHPYCONST double (*born)[3][3],
|
||||
|
@ -64,15 +64,15 @@ void dym_get_recip_dipole_dipole(double *dd, /* [natom, 3, natom, 3, (real,imag)
|
|||
const double tolerance);
|
||||
void dym_get_recip_dipole_dipole_q0(double *dd_q0, /* [natom, 3, 3, (real,imag)] */
|
||||
PHPYCONST double (*G_list)[3], /* [num_G, 3] */
|
||||
const int num_G,
|
||||
const int num_patom,
|
||||
const long num_G,
|
||||
const long num_patom,
|
||||
PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST double dielectric[3][3],
|
||||
PHPYCONST double (*pos)[3], /* [natom, 3] */
|
||||
const double lambda,
|
||||
const double tolerance);
|
||||
void dym_get_charge_sum(double (*charge_sum)[3][3],
|
||||
const int num_patom,
|
||||
const long num_patom,
|
||||
const double factor,
|
||||
const double q_cart[3],
|
||||
PHPYCONST double (*born)[3][3]);
|
||||
|
@ -85,11 +85,11 @@ void dym_transform_dynmat_to_fc(double *fc,
|
|||
const double *dm,
|
||||
PHPYCONST double (*comm_points)[3],
|
||||
PHPYCONST double (*shortest_vectors)[27][3],
|
||||
const int *multiplicities,
|
||||
const long *multiplicities,
|
||||
const double *masses,
|
||||
const int *s2pp_map,
|
||||
const int *fc_index_map,
|
||||
const int num_patom,
|
||||
const int num_satom);
|
||||
const long *s2pp_map,
|
||||
const long *fc_index_map,
|
||||
const long num_patom,
|
||||
const long num_satom);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -118,7 +118,7 @@ void itr_get_interaction(Darray *fc3_normal_squared,
|
|||
{
|
||||
int openmp_per_triplets;
|
||||
int (*g_pos)[4];
|
||||
size_t i, j, k, l, jkl;
|
||||
size_t i;
|
||||
size_t num_band, num_band0, num_band_prod, num_g_pos;
|
||||
|
||||
g_pos = NULL;
|
||||
|
|
23
c/phono3py.c
23
c/phono3py.c
|
@ -45,26 +45,27 @@
|
|||
#include "isotope.h"
|
||||
#include "fc3.h"
|
||||
#include "tetrahedron_method.h"
|
||||
#include "triplet.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void ph3py_get_phonons_at_gridpoints(double *frequencies,
|
||||
lapack_complex_double *eigenvectors,
|
||||
char *phonon_done,
|
||||
const size_t num_phonons,
|
||||
const size_t *grid_points,
|
||||
const size_t num_grid_points,
|
||||
PHPYCONST int (*grid_address)[3],
|
||||
const int mesh[3],
|
||||
const long num_phonons,
|
||||
const long *grid_points,
|
||||
const long num_grid_points,
|
||||
PHPYCONST long (*grid_address)[3],
|
||||
const long mesh[3],
|
||||
const double *fc2,
|
||||
PHPYCONST double(*svecs_fc2)[27][3],
|
||||
const int *multi_fc2,
|
||||
const long *multi_fc2,
|
||||
PHPYCONST double (*positions_fc2)[3],
|
||||
const size_t num_patom,
|
||||
const size_t num_satom,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
const double *masses_fc2,
|
||||
const int *p2s_fc2,
|
||||
const int *s2p_fc2,
|
||||
const long *p2s_fc2,
|
||||
const long *s2p_fc2,
|
||||
const double unit_conversion_factor,
|
||||
PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST double dielectric[3][3],
|
||||
|
@ -73,7 +74,7 @@ void ph3py_get_phonons_at_gridpoints(double *frequencies,
|
|||
const double nac_factor,
|
||||
const double *dd_q0,
|
||||
PHPYCONST double(*G_list)[3],
|
||||
const size_t num_G_points,
|
||||
const long num_G_points,
|
||||
const double lambda,
|
||||
const char uplo)
|
||||
{
|
||||
|
|
44
c/phono3py.h
44
c/phono3py.h
|
@ -45,20 +45,20 @@
|
|||
void ph3py_get_phonons_at_gridpoints(double *frequencies,
|
||||
lapack_complex_double *eigenvectors,
|
||||
char *phonon_done,
|
||||
const size_t num_phonons,
|
||||
const size_t *grid_points,
|
||||
const size_t num_grid_points,
|
||||
PHPYCONST int (*grid_address)[3],
|
||||
const int mesh[3],
|
||||
const long num_phonons,
|
||||
const long *grid_points,
|
||||
const long num_grid_points,
|
||||
PHPYCONST long (*grid_address)[3],
|
||||
const long mesh[3],
|
||||
const double *fc2,
|
||||
PHPYCONST double(*svecs_fc2)[27][3],
|
||||
const int *multi_fc2,
|
||||
const long *multi_fc2,
|
||||
PHPYCONST double (*positions_fc2)[3],
|
||||
const size_t num_patom,
|
||||
const size_t num_satom,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
const double *masses_fc2,
|
||||
const int *p2s_fc2,
|
||||
const int *s2p_fc2,
|
||||
const long *p2s_fc2,
|
||||
const long *s2p_fc2,
|
||||
const double unit_conversion_factor,
|
||||
PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST double dielectric[3][3],
|
||||
|
@ -67,7 +67,7 @@ void ph3py_get_phonons_at_gridpoints(double *frequencies,
|
|||
const double nac_factor,
|
||||
const double *dd_q0,
|
||||
PHPYCONST double(*G_list)[3],
|
||||
const size_t num_G_points,
|
||||
const long num_G_points,
|
||||
const double lambda,
|
||||
const char uplo);
|
||||
void ph3py_get_interaction(Darray *fc3_normal_squared,
|
||||
|
@ -161,6 +161,28 @@ void ph3py_get_detailed_imag_self_energy_at_bands_with_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 int *band_indices,
|
||||
const double *frequencies,
|
||||
const size_t (*triplets)[3],
|
||||
const int *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 int *band_indices,
|
||||
const double *frequencies,
|
||||
const size_t (*triplets)[3],
|
||||
const int *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,
|
||||
|
|
|
@ -36,42 +36,3 @@
|
|||
#include <numpy/arrayobject.h>
|
||||
#include "phonoc_array.h"
|
||||
#include "lapack_wrapper.h"
|
||||
|
||||
Iarray* convert_to_iarray(const PyArrayObject* npyary)
|
||||
{
|
||||
int i;
|
||||
Iarray *ary;
|
||||
|
||||
ary = (Iarray*) malloc(sizeof(Iarray));
|
||||
for (i = 0; i < PyArray_NDIM(npyary); i++) {
|
||||
ary->dims[i] = PyArray_DIMS(npyary)[i];
|
||||
}
|
||||
ary->data = (int*)PyArray_DATA(npyary);
|
||||
return ary;
|
||||
}
|
||||
|
||||
Darray* convert_to_darray(const PyArrayObject* npyary)
|
||||
{
|
||||
int i;
|
||||
Darray *ary;
|
||||
|
||||
ary = (Darray*) malloc(sizeof(Darray));
|
||||
for (i = 0; i < PyArray_NDIM(npyary); i++) {
|
||||
ary->dims[i] = PyArray_DIMS(npyary)[i];
|
||||
}
|
||||
ary->data = (double*)PyArray_DATA(npyary);
|
||||
return ary;
|
||||
}
|
||||
|
||||
Carray* convert_to_carray(const PyArrayObject* npyary)
|
||||
{
|
||||
int i;
|
||||
Carray *ary;
|
||||
|
||||
ary = (Carray*) malloc(sizeof(Carray));
|
||||
for (i = 0; i < PyArray_NDIM(npyary); i++) {
|
||||
ary->dims[i] = PyArray_DIMS(npyary)[i];
|
||||
}
|
||||
ary->data = (lapack_complex_double*)PyArray_DATA(npyary);
|
||||
return ary;
|
||||
}
|
||||
|
|
|
@ -35,8 +35,6 @@
|
|||
#ifndef __phonoc_array_H__
|
||||
#define __phonoc_array_H__
|
||||
|
||||
#include <Python.h>
|
||||
#include <numpy/arrayobject.h>
|
||||
#include "lapack_wrapper.h"
|
||||
|
||||
#define MAX_NUM_DIM 20
|
||||
|
@ -57,8 +55,4 @@ typedef struct {
|
|||
lapack_complex_double *data;
|
||||
} Carray;
|
||||
|
||||
Iarray* convert_to_iarray(const PyArrayObject* npyary);
|
||||
Darray* convert_to_darray(const PyArrayObject* npyary);
|
||||
Carray* convert_to_carray(const PyArrayObject* npyary);
|
||||
|
||||
#endif
|
||||
|
|
262
c/phonon.c
262
c/phonon.c
|
@ -39,24 +39,24 @@
|
|||
#include "phonon.h"
|
||||
#include "lapack_wrapper.h"
|
||||
|
||||
static size_t collect_undone_grid_points(size_t *undone,
|
||||
char *phonon_done,
|
||||
const size_t num_grid_points,
|
||||
const size_t *grid_points);
|
||||
static long collect_undone_grid_points(long *undone,
|
||||
char *phonon_done,
|
||||
const long num_grid_points,
|
||||
const long *grid_points);
|
||||
static void get_undone_phonons(double *frequencies,
|
||||
lapack_complex_double *eigenvectors,
|
||||
const size_t *undone_grid_points,
|
||||
const size_t num_undone_grid_points,
|
||||
PHPYCONST int (*grid_address)[3],
|
||||
const int mesh[3],
|
||||
const long *undone_grid_points,
|
||||
const long num_undone_grid_points,
|
||||
PHPYCONST long (*grid_address)[3],
|
||||
const long mesh[3],
|
||||
const double *fc2,
|
||||
PHPYCONST double(*svecs_fc2)[27][3],
|
||||
const int *multi_fc2,
|
||||
const size_t num_patom,
|
||||
const size_t num_satom,
|
||||
const long *multi_fc2,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
const double *masses_fc2,
|
||||
const int *p2s_fc2,
|
||||
const int *s2p_fc2,
|
||||
const long *p2s_fc2,
|
||||
const long *s2p_fc2,
|
||||
const double unit_conversion_factor,
|
||||
PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST double dielectric[3][3],
|
||||
|
@ -66,19 +66,19 @@ static void get_undone_phonons(double *frequencies,
|
|||
const char uplo);
|
||||
static void get_gonze_undone_phonons(double *frequencies,
|
||||
lapack_complex_double *eigenvectors,
|
||||
const size_t *undone_grid_points,
|
||||
const size_t num_undone_grid_points,
|
||||
PHPYCONST int (*grid_address)[3],
|
||||
const int mesh[3],
|
||||
const long *undone_grid_points,
|
||||
const long num_undone_grid_points,
|
||||
PHPYCONST long (*grid_address)[3],
|
||||
const long mesh[3],
|
||||
const double *fc2,
|
||||
PHPYCONST double(*svecs_fc2)[27][3],
|
||||
const int *multi_fc2,
|
||||
const long *multi_fc2,
|
||||
PHPYCONST double (*positions)[3],
|
||||
const size_t num_patom,
|
||||
const size_t num_satom,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
const double *masses_fc2,
|
||||
const int *p2s_fc2,
|
||||
const int *s2p_fc2,
|
||||
const long *p2s_fc2,
|
||||
const long *s2p_fc2,
|
||||
const double unit_conversion_factor,
|
||||
PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST double dielectric[3][3],
|
||||
|
@ -87,20 +87,20 @@ static void get_gonze_undone_phonons(double *frequencies,
|
|||
const double nac_factor,
|
||||
const double *dd_q0,
|
||||
PHPYCONST double(*G_list)[3],
|
||||
const size_t num_G_points,
|
||||
const long num_G_points,
|
||||
const double lambda,
|
||||
const char uplo);
|
||||
static void get_phonons(lapack_complex_double *eigvecs,
|
||||
const double q[3],
|
||||
const double *fc2,
|
||||
const double *masses,
|
||||
const int *p2s,
|
||||
const int *s2p,
|
||||
const int *multi,
|
||||
const size_t num_patom,
|
||||
const size_t num_satom,
|
||||
const long *p2s,
|
||||
const long *s2p,
|
||||
const long *multi,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
PHPYCONST double(*svecs)[27][3],
|
||||
const int is_nac,
|
||||
const long is_nac,
|
||||
PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST double dielectric[3][3],
|
||||
PHPYCONST double reciprocal_lattice[3][3],
|
||||
|
@ -111,14 +111,14 @@ static void get_gonze_phonons(lapack_complex_double *eigvecs,
|
|||
const double q[3],
|
||||
const double *fc2,
|
||||
const double *masses,
|
||||
const int *p2s,
|
||||
const int *s2p,
|
||||
const int *multi,
|
||||
const long *p2s,
|
||||
const long *s2p,
|
||||
const long *multi,
|
||||
PHPYCONST double (*positions)[3],
|
||||
const size_t num_patom,
|
||||
const size_t num_satom,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
PHPYCONST double(*svecs)[27][3],
|
||||
const int is_nac,
|
||||
const long is_nac,
|
||||
PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST double dielectric[3][3],
|
||||
PHPYCONST double reciprocal_lattice[3][3],
|
||||
|
@ -126,56 +126,56 @@ static void get_gonze_phonons(lapack_complex_double *eigvecs,
|
|||
const double nac_factor,
|
||||
const double *dd_q0,
|
||||
PHPYCONST double(*G_list)[3],
|
||||
const size_t num_G_points,
|
||||
const long 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 int *p2s,
|
||||
const int *s2p,
|
||||
const int *multi,
|
||||
const size_t num_patom,
|
||||
const size_t num_satom,
|
||||
const long *p2s,
|
||||
const long *s2p,
|
||||
const long *multi,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
PHPYCONST double(*svecs)[27][3],
|
||||
const int is_nac,
|
||||
const long is_nac,
|
||||
PHPYCONST double (*born)[3][3], /* Wang NAC unless NULL */
|
||||
PHPYCONST double dielectric[3][3],
|
||||
PHPYCONST double reciprocal_lattice[3][3],
|
||||
const double *q_direction,
|
||||
const double nac_factor);
|
||||
static void get_charge_sum(double (*charge_sum)[3][3],
|
||||
const size_t num_patom,
|
||||
const size_t num_satom,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
const double q[3],
|
||||
PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST double dielectric[3][3],
|
||||
PHPYCONST double reciprocal_lattice[3][3],
|
||||
const double *q_direction,
|
||||
const double nac_factor);
|
||||
static int needs_nac(PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST int (*grid_address)[3],
|
||||
const size_t gp,
|
||||
const double *q_direction);
|
||||
static long needs_nac(PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST long (*grid_address)[3],
|
||||
const long gp,
|
||||
const double *q_direction);
|
||||
|
||||
void
|
||||
phn_get_phonons_at_gridpoints(double *frequencies,
|
||||
lapack_complex_double *eigenvectors,
|
||||
char *phonon_done,
|
||||
const size_t num_phonons,
|
||||
const size_t *grid_points,
|
||||
const size_t num_grid_points,
|
||||
PHPYCONST int (*grid_address)[3],
|
||||
const int mesh[3],
|
||||
const long num_phonons,
|
||||
const long *grid_points,
|
||||
const long num_grid_points,
|
||||
PHPYCONST long (*grid_address)[3],
|
||||
const long mesh[3],
|
||||
const double *fc2,
|
||||
PHPYCONST double(*svecs_fc2)[27][3],
|
||||
const int *multi_fc2,
|
||||
const size_t num_patom,
|
||||
const size_t num_satom,
|
||||
const long *multi_fc2,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
const double *masses_fc2,
|
||||
const int *p2s_fc2,
|
||||
const int *s2p_fc2,
|
||||
const long *p2s_fc2,
|
||||
const long *s2p_fc2,
|
||||
const double unit_conversion_factor,
|
||||
PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST double dielectric[3][3],
|
||||
|
@ -184,10 +184,10 @@ phn_get_phonons_at_gridpoints(double *frequencies,
|
|||
const double nac_factor,
|
||||
const char uplo)
|
||||
{
|
||||
size_t num_undone;
|
||||
size_t *undone;
|
||||
long num_undone;
|
||||
long *undone;
|
||||
|
||||
undone = (size_t*)malloc(sizeof(size_t) * num_phonons);
|
||||
undone = (long*)malloc(sizeof(long) * num_phonons);
|
||||
num_undone = collect_undone_grid_points(undone,
|
||||
phonon_done,
|
||||
num_grid_points,
|
||||
|
@ -223,20 +223,20 @@ void
|
|||
phn_get_gonze_phonons_at_gridpoints(double *frequencies,
|
||||
lapack_complex_double *eigenvectors,
|
||||
char *phonon_done,
|
||||
const size_t num_phonons,
|
||||
const size_t *grid_points,
|
||||
const size_t num_grid_points,
|
||||
PHPYCONST int (*grid_address)[3],
|
||||
const int mesh[3],
|
||||
const long num_phonons,
|
||||
const long *grid_points,
|
||||
const long num_grid_points,
|
||||
PHPYCONST long (*grid_address)[3],
|
||||
const long mesh[3],
|
||||
const double *fc2,
|
||||
PHPYCONST double(*svecs_fc2)[27][3],
|
||||
const int *multi_fc2,
|
||||
const long *multi_fc2,
|
||||
PHPYCONST double (*positions)[3],
|
||||
const size_t num_patom,
|
||||
const size_t num_satom,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
const double *masses_fc2,
|
||||
const int *p2s_fc2,
|
||||
const int *s2p_fc2,
|
||||
const long *p2s_fc2,
|
||||
const long *s2p_fc2,
|
||||
const double unit_conversion_factor,
|
||||
PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST double dielectric[3][3],
|
||||
|
@ -245,14 +245,14 @@ phn_get_gonze_phonons_at_gridpoints(double *frequencies,
|
|||
const double nac_factor,
|
||||
const double *dd_q0,
|
||||
PHPYCONST double(*G_list)[3],
|
||||
const size_t num_G_points,
|
||||
const long num_G_points,
|
||||
const double lambda,
|
||||
const char uplo)
|
||||
{
|
||||
size_t num_undone;
|
||||
size_t *undone;
|
||||
long num_undone;
|
||||
long *undone;
|
||||
|
||||
undone = (size_t*)malloc(sizeof(size_t) * num_phonons);
|
||||
undone = (long*)malloc(sizeof(long) * num_phonons);
|
||||
num_undone = collect_undone_grid_points(undone,
|
||||
phonon_done,
|
||||
num_grid_points,
|
||||
|
@ -289,12 +289,12 @@ phn_get_gonze_phonons_at_gridpoints(double *frequencies,
|
|||
undone = NULL;
|
||||
}
|
||||
|
||||
static size_t collect_undone_grid_points(size_t *undone,
|
||||
char *phonon_done,
|
||||
const size_t num_grid_points,
|
||||
const size_t *grid_points)
|
||||
static long collect_undone_grid_points(long *undone,
|
||||
char *phonon_done,
|
||||
const long num_grid_points,
|
||||
const long *grid_points)
|
||||
{
|
||||
size_t i, gp, num_undone;
|
||||
long i, gp, num_undone;
|
||||
|
||||
num_undone = 0;
|
||||
for (i = 0; i < num_grid_points; i++) {
|
||||
|
@ -311,18 +311,18 @@ static size_t collect_undone_grid_points(size_t *undone,
|
|||
|
||||
static void get_undone_phonons(double *frequencies,
|
||||
lapack_complex_double *eigenvectors,
|
||||
const size_t *undone_grid_points,
|
||||
const size_t num_undone_grid_points,
|
||||
PHPYCONST int (*grid_address)[3],
|
||||
const int mesh[3],
|
||||
const long *undone_grid_points,
|
||||
const long num_undone_grid_points,
|
||||
PHPYCONST long (*grid_address)[3],
|
||||
const long mesh[3],
|
||||
const double *fc2,
|
||||
PHPYCONST double(*svecs_fc2)[27][3],
|
||||
const int *multi_fc2,
|
||||
const size_t num_patom,
|
||||
const size_t num_satom,
|
||||
const long *multi_fc2,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
const double *masses_fc2,
|
||||
const int *p2s_fc2,
|
||||
const int *s2p_fc2,
|
||||
const long *p2s_fc2,
|
||||
const long *s2p_fc2,
|
||||
const double unit_conversion_factor,
|
||||
PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST double dielectric[3][3],
|
||||
|
@ -331,8 +331,8 @@ static void get_undone_phonons(double *frequencies,
|
|||
const double nac_factor,
|
||||
const char uplo)
|
||||
{
|
||||
size_t i, j, gp, num_band;
|
||||
int is_nac, info;
|
||||
long i, j, gp, num_band;
|
||||
long is_nac, info;
|
||||
double q[3];
|
||||
double *freqs_tmp;
|
||||
|
||||
|
@ -389,19 +389,19 @@ static void get_undone_phonons(double *frequencies,
|
|||
|
||||
static void get_gonze_undone_phonons(double *frequencies,
|
||||
lapack_complex_double *eigenvectors,
|
||||
const size_t *undone_grid_points,
|
||||
const size_t num_undone_grid_points,
|
||||
PHPYCONST int (*grid_address)[3],
|
||||
const int mesh[3],
|
||||
const long *undone_grid_points,
|
||||
const long num_undone_grid_points,
|
||||
PHPYCONST long (*grid_address)[3],
|
||||
const long mesh[3],
|
||||
const double *fc2,
|
||||
PHPYCONST double(*svecs_fc2)[27][3],
|
||||
const int *multi_fc2,
|
||||
const long *multi_fc2,
|
||||
PHPYCONST double (*positions)[3],
|
||||
const size_t num_patom,
|
||||
const size_t num_satom,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
const double *masses_fc2,
|
||||
const int *p2s_fc2,
|
||||
const int *s2p_fc2,
|
||||
const long *p2s_fc2,
|
||||
const long *s2p_fc2,
|
||||
const double unit_conversion_factor,
|
||||
PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST double dielectric[3][3],
|
||||
|
@ -410,12 +410,12 @@ static void get_gonze_undone_phonons(double *frequencies,
|
|||
const double nac_factor,
|
||||
const double *dd_q0,
|
||||
PHPYCONST double(*G_list)[3],
|
||||
const size_t num_G_points,
|
||||
const long num_G_points,
|
||||
const double lambda,
|
||||
const char uplo)
|
||||
{
|
||||
size_t i, j, gp, num_band;
|
||||
int is_nac, info;
|
||||
long i, j, gp, num_band;
|
||||
long is_nac, info;
|
||||
double q[3];
|
||||
double *freqs_tmp;
|
||||
|
||||
|
@ -478,13 +478,13 @@ static void get_phonons(lapack_complex_double *eigvecs,
|
|||
const double q[3],
|
||||
const double *fc2,
|
||||
const double *masses,
|
||||
const int *p2s,
|
||||
const int *s2p,
|
||||
const int *multi,
|
||||
const size_t num_patom,
|
||||
const size_t num_satom,
|
||||
const long *p2s,
|
||||
const long *s2p,
|
||||
const long *multi,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
PHPYCONST double(*svecs)[27][3],
|
||||
const int is_nac,
|
||||
const long is_nac,
|
||||
PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST double dielectric[3][3],
|
||||
PHPYCONST double reciprocal_lattice[3][3],
|
||||
|
@ -515,14 +515,14 @@ static void get_gonze_phonons(lapack_complex_double *eigvecs,
|
|||
const double q[3],
|
||||
const double *fc2,
|
||||
const double *masses,
|
||||
const int *p2s,
|
||||
const int *s2p,
|
||||
const int *multi,
|
||||
const long *p2s,
|
||||
const long *s2p,
|
||||
const long *multi,
|
||||
PHPYCONST double (*positions)[3],
|
||||
const size_t num_patom,
|
||||
const size_t num_satom,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
PHPYCONST double(*svecs)[27][3],
|
||||
const int is_nac,
|
||||
const long is_nac,
|
||||
PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST double dielectric[3][3],
|
||||
PHPYCONST double reciprocal_lattice[3][3],
|
||||
|
@ -530,10 +530,10 @@ static void get_gonze_phonons(lapack_complex_double *eigvecs,
|
|||
const double nac_factor,
|
||||
const double *dd_q0,
|
||||
PHPYCONST double(*G_list)[3],
|
||||
const size_t num_G_points,
|
||||
const long num_G_points,
|
||||
const double lambda)
|
||||
{
|
||||
size_t i, j, k, l, adrs, num_band;
|
||||
long i, j, k, l, adrs, num_band;
|
||||
double mm;
|
||||
double q_cart[3];
|
||||
double *q_dir_cart;
|
||||
|
@ -619,13 +619,13 @@ get_dynamical_matrix(lapack_complex_double *dynmat,
|
|||
const double q[3],
|
||||
const double *fc2,
|
||||
const double *masses,
|
||||
const int *p2s,
|
||||
const int *s2p,
|
||||
const int *multi,
|
||||
const size_t num_patom,
|
||||
const size_t num_satom,
|
||||
const long *p2s,
|
||||
const long *s2p,
|
||||
const long *multi,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
PHPYCONST double(*svecs)[27][3],
|
||||
const int is_nac,
|
||||
const long is_nac,
|
||||
PHPYCONST double (*born)[3][3], /* Wang NAC unless NULL */
|
||||
PHPYCONST double dielectric[3][3],
|
||||
PHPYCONST double reciprocal_lattice[3][3],
|
||||
|
@ -669,8 +669,8 @@ get_dynamical_matrix(lapack_complex_double *dynmat,
|
|||
}
|
||||
|
||||
static void get_charge_sum(double (*charge_sum)[3][3],
|
||||
const size_t num_patom,
|
||||
const size_t num_satom,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
const double q[3],
|
||||
PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST double dielectric[3][3],
|
||||
|
@ -678,7 +678,7 @@ static void get_charge_sum(double (*charge_sum)[3][3],
|
|||
const double *q_direction,
|
||||
const double nac_factor)
|
||||
{
|
||||
size_t i, j;
|
||||
long i, j;
|
||||
double inv_dielectric_factor, dielectric_factor, tmp_val;
|
||||
double q_cart[3];
|
||||
|
||||
|
@ -717,12 +717,12 @@ static void get_charge_sum(double (*charge_sum)[3][3],
|
|||
born);
|
||||
}
|
||||
|
||||
static int needs_nac(PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST int (*grid_address)[3],
|
||||
const size_t gp,
|
||||
const double *q_direction)
|
||||
static long needs_nac(PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST long (*grid_address)[3],
|
||||
const long gp,
|
||||
const double *q_direction)
|
||||
{
|
||||
int is_nac;
|
||||
long is_nac;
|
||||
|
||||
if (born) {
|
||||
if (grid_address[gp][0] == 0 &&
|
||||
|
|
42
c/phonon.h
42
c/phonon.h
|
@ -42,19 +42,19 @@ void
|
|||
phn_get_phonons_at_gridpoints(double *frequencies,
|
||||
lapack_complex_double *eigenvectors,
|
||||
char *phonon_done,
|
||||
const size_t num_phonons,
|
||||
const size_t *grid_points,
|
||||
const size_t num_grid_points,
|
||||
PHPYCONST int (*grid_address)[3],
|
||||
const int mesh[3],
|
||||
const long num_phonons,
|
||||
const long *grid_points,
|
||||
const long num_grid_points,
|
||||
PHPYCONST long (*grid_address)[3],
|
||||
const long mesh[3],
|
||||
const double *fc2,
|
||||
PHPYCONST double(*svecs_fc2)[27][3],
|
||||
const int *multi_fc2,
|
||||
const size_t num_patom,
|
||||
const size_t num_satom,
|
||||
const long *multi_fc2,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
const double *masses_fc2,
|
||||
const int *p2s_fc2,
|
||||
const int *s2p_fc2,
|
||||
const long *p2s_fc2,
|
||||
const long *s2p_fc2,
|
||||
const double unit_conversion_factor,
|
||||
PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST double dielectric[3][3],
|
||||
|
@ -66,20 +66,20 @@ void
|
|||
phn_get_gonze_phonons_at_gridpoints(double *frequencies,
|
||||
lapack_complex_double *eigenvectors,
|
||||
char *phonon_done,
|
||||
const size_t num_phonons,
|
||||
const size_t *grid_points,
|
||||
const size_t num_grid_points,
|
||||
PHPYCONST int (*grid_address)[3],
|
||||
const int mesh[3],
|
||||
const long num_phonons,
|
||||
const long *grid_points,
|
||||
const long num_grid_points,
|
||||
PHPYCONST long (*grid_address)[3],
|
||||
const long mesh[3],
|
||||
const double *fc2,
|
||||
PHPYCONST double(*svecs_fc2)[27][3],
|
||||
const int *multi_fc2,
|
||||
const long *multi_fc2,
|
||||
PHPYCONST double (*positions)[3],
|
||||
const size_t num_patom,
|
||||
const size_t num_satom,
|
||||
const long num_patom,
|
||||
const long num_satom,
|
||||
const double *masses_fc2,
|
||||
const int *p2s_fc2,
|
||||
const int *s2p_fc2,
|
||||
const long *p2s_fc2,
|
||||
const long *s2p_fc2,
|
||||
const double unit_conversion_factor,
|
||||
PHPYCONST double (*born)[3][3],
|
||||
PHPYCONST double dielectric[3][3],
|
||||
|
@ -88,7 +88,7 @@ phn_get_gonze_phonons_at_gridpoints(double *frequencies,
|
|||
const double nac_factor,
|
||||
const double *dd_q0,
|
||||
PHPYCONST double(*G_list)[3],
|
||||
const size_t num_G_points,
|
||||
const long num_G_points,
|
||||
const double lambda,
|
||||
const char uplo);
|
||||
#endif
|
||||
|
|
|
@ -268,7 +268,12 @@ class Phono3py(object):
|
|||
elif isinstance(sigmas, float) or isinstance(sigmas, int):
|
||||
self._sigmas = [float(sigmas), ]
|
||||
else:
|
||||
self._sigmas = [float(s) for s in sigmas]
|
||||
self._sigmas = []
|
||||
for s in sigmas:
|
||||
if isinstance(s, float) or isinstance(s, int):
|
||||
self._sigmas.append(float(s))
|
||||
elif s is None:
|
||||
self._sigmas.append(None)
|
||||
|
||||
@property
|
||||
def sigma_cutoff(self):
|
||||
|
|
|
@ -263,7 +263,7 @@ class Isotope(object):
|
|||
phono3c.integration_weights(
|
||||
self._integration_weights,
|
||||
freq_points,
|
||||
thm.get_tetrahedra(),
|
||||
np.array(thm.get_tetrahedra(), dtype='intc', order='C'),
|
||||
self._mesh,
|
||||
self._grid_points,
|
||||
self._frequencies,
|
||||
|
@ -275,11 +275,12 @@ class Isotope(object):
|
|||
tfreqs = get_tetrahedra_frequencies(
|
||||
gp,
|
||||
self._mesh,
|
||||
[1, self._mesh[0], self._mesh[0] * self._mesh[1]],
|
||||
self._grid_address,
|
||||
thm.get_tetrahedra(),
|
||||
self._grid_points,
|
||||
self._frequencies)
|
||||
self._frequencies,
|
||||
grid_order=[1, self._mesh[0], self._mesh[0] * self._mesh[1]],
|
||||
lang='Py')
|
||||
|
||||
for bi, frequencies in enumerate(tfreqs):
|
||||
thm.set_tetrahedra_omegas(frequencies)
|
||||
|
|
|
@ -75,24 +75,24 @@ def run_phonon_solver_c(dm,
|
|||
Lambda = 0
|
||||
fc = dm.force_constants
|
||||
|
||||
assert grid_points.dtype == 'uintp'
|
||||
assert grid_points.flags.c_contiguous
|
||||
# assert grid_points.dtype == 'int_'
|
||||
# assert grid_points.flags.c_contiguous
|
||||
|
||||
fc_p2s, fc_s2p = _get_fc_elements_mapping(dm, fc)
|
||||
phono3c.phonons_at_gridpoints(
|
||||
frequencies,
|
||||
eigenvectors,
|
||||
phonon_done,
|
||||
grid_points,
|
||||
grid_address,
|
||||
np.array(mesh, dtype='intc'),
|
||||
np.array(grid_points, dtype='int_'),
|
||||
np.array(grid_address, dtype='int_', order='C'),
|
||||
np.array(mesh, dtype='int_'),
|
||||
fc,
|
||||
svecs,
|
||||
multiplicity,
|
||||
np.array(multiplicity, dtype='int_', order='C'),
|
||||
positions,
|
||||
masses,
|
||||
fc_p2s,
|
||||
fc_s2p,
|
||||
np.array(fc_p2s, dtype='int_'),
|
||||
np.array(fc_s2p, dtype='int_'),
|
||||
frequency_conversion_factor,
|
||||
born,
|
||||
dielectric,
|
||||
|
|
|
@ -586,7 +586,7 @@ def _set_triplets_integration_weights_c(g,
|
|||
phono3c.neighboring_grid_points(
|
||||
neighboring_grid_points,
|
||||
np.array(triplets_at_q[:, i], dtype='uintp').ravel(),
|
||||
j * unique_vertices,
|
||||
np.array(j * unique_vertices, dtype='intc', order='C'),
|
||||
mesh,
|
||||
grid_address,
|
||||
bz_map)
|
||||
|
@ -597,7 +597,7 @@ def _set_triplets_integration_weights_c(g,
|
|||
g,
|
||||
g_zero,
|
||||
frequency_points, # f0
|
||||
thm.get_tetrahedra(),
|
||||
np.array(thm.get_tetrahedra(), dtype='intc', order='C'),
|
||||
mesh,
|
||||
triplets_at_q,
|
||||
frequencies, # f1
|
||||
|
|
|
@ -6,22 +6,22 @@ si_pbesol_kappa_RTA_iso = [96.92419, 96.92419, 96.92419, 0, 0, 0]
|
|||
si_pbesol_kappa_RTA_with_sigmas_iso = [96.03248, 96.03248, 96.03248, 0, 0, 0]
|
||||
|
||||
|
||||
def test_kappa_RTA(si_pbesol):
|
||||
def test_kappa_RTA_si(si_pbesol):
|
||||
kappa = _get_kappa(si_pbesol, [9, 9, 9]).ravel()
|
||||
np.testing.assert_allclose(si_pbesol_kappa_RTA, kappa, atol=0.5)
|
||||
|
||||
|
||||
def test_kappa_RTA_full_pp(si_pbesol):
|
||||
def test_kappa_RTA_si_full_pp(si_pbesol):
|
||||
kappa = _get_kappa(si_pbesol, [9, 9, 9], is_full_pp=True).ravel()
|
||||
np.testing.assert_allclose(si_pbesol_kappa_RTA, kappa, atol=0.5)
|
||||
|
||||
|
||||
def test_kappa_RTA_iso(si_pbesol):
|
||||
def test_kappa_RTA_si_iso(si_pbesol):
|
||||
kappa = _get_kappa(si_pbesol, [9, 9, 9], is_isotope=True).ravel()
|
||||
np.testing.assert_allclose(si_pbesol_kappa_RTA_iso, kappa, atol=0.5)
|
||||
|
||||
|
||||
def test_kappa_RTA_with_sigma(si_pbesol):
|
||||
def test_kappa_RTA_si_with_sigma(si_pbesol):
|
||||
si_pbesol.sigmas = [0.1, ]
|
||||
kappa = _get_kappa(si_pbesol, [9, 9, 9]).ravel()
|
||||
np.testing.assert_allclose(
|
||||
|
@ -29,7 +29,7 @@ def test_kappa_RTA_with_sigma(si_pbesol):
|
|||
si_pbesol.sigmas = None
|
||||
|
||||
|
||||
def test_kappa_RTA_with_sigma_full_pp(si_pbesol):
|
||||
def test_kappa_RTA_si_with_sigma_full_pp(si_pbesol):
|
||||
si_pbesol.sigmas = [0.1, ]
|
||||
kappa = _get_kappa(si_pbesol, [9, 9, 9], is_full_pp=True).ravel()
|
||||
np.testing.assert_allclose(
|
||||
|
@ -37,7 +37,7 @@ def test_kappa_RTA_with_sigma_full_pp(si_pbesol):
|
|||
si_pbesol.sigmas = None
|
||||
|
||||
|
||||
def test_kappa_RTA_with_sigma_iso(si_pbesol):
|
||||
def test_kappa_RTA_si_with_sigma_iso(si_pbesol):
|
||||
si_pbesol.sigmas = [0.1, ]
|
||||
kappa = _get_kappa(si_pbesol, [9, 9, 9], is_isotope=True).ravel()
|
||||
np.testing.assert_allclose(
|
||||
|
@ -45,7 +45,7 @@ def test_kappa_RTA_with_sigma_iso(si_pbesol):
|
|||
si_pbesol.sigmas = None
|
||||
|
||||
|
||||
def test_kappa_RTA_compact_fc(si_pbesol_compact_fc):
|
||||
def test_kappa_RTA_si_compact_fc(si_pbesol_compact_fc):
|
||||
kappa = _get_kappa(si_pbesol_compact_fc, [9, 9, 9]).ravel()
|
||||
np.testing.assert_allclose(si_pbesol_kappa_RTA, kappa, atol=0.5)
|
||||
|
||||
|
|
Loading…
Reference in New Issue