Skip to content

Commit

Permalink
Fix segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Dec 23, 2022
1 parent c4c54c7 commit 06bd1f0
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/phono3py-pytest-conda-mkl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
pip install -e . -vvv
- name: Run pytest
run: |
pytest --cov=./ --cov-report=xml test
pytest -v --cov=./ --cov-report=xml test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phono3py-pytest-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
pip install -e . -vvv
- name: Run pytest
run: |
pytest --cov=./ --cov-report=xml test
pytest -v --cov=./ --cov-report=xml test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
Expand Down
8 changes: 4 additions & 4 deletions c/_phono3py.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ static PyObject *py_get_isotope_strength(PyObject *self, PyObject *args) {
double *gamma;
double *frequencies;
long *ir_grid_points;
long *weights;
double *weights;
_lapack_complex_double *eigenvectors;
long *band_indices;
double *mass_variances;
Expand All @@ -939,7 +939,7 @@ static PyObject *py_get_isotope_strength(PyObject *self, PyObject *args) {
frequencies = (double *)PyArray_DATA(py_frequencies);
eigenvectors = (_lapack_complex_double *)PyArray_DATA(py_eigenvectors);
ir_grid_points = (long *)PyArray_DATA(py_ir_grid_points);
weights = (long *)PyArray_DATA(py_weights);
weights = (double *)PyArray_DATA(py_weights);
band_indices = (long *)PyArray_DATA(py_band_indices);
mass_variances = (double *)PyArray_DATA(py_mass_variances);
num_band = (long)PyArray_DIMS(py_frequencies)[1];
Expand Down Expand Up @@ -969,7 +969,7 @@ static PyObject *py_get_thm_isotope_strength(PyObject *self, PyObject *args) {
double *gamma;
double *frequencies;
long *ir_grid_points;
long *weights;
double *weights;
_lapack_complex_double *eigenvectors;
long *band_indices;
double *mass_variances;
Expand All @@ -986,7 +986,7 @@ static PyObject *py_get_thm_isotope_strength(PyObject *self, PyObject *args) {
gamma = (double *)PyArray_DATA(py_gamma);
frequencies = (double *)PyArray_DATA(py_frequencies);
ir_grid_points = (long *)PyArray_DATA(py_ir_grid_points);
weights = (long *)PyArray_DATA(py_weights);
weights = (double *)PyArray_DATA(py_weights);
eigenvectors = (_lapack_complex_double *)PyArray_DATA(py_eigenvectors);
band_indices = (long *)PyArray_DATA(py_band_indices);
mass_variances = (double *)PyArray_DATA(py_mass_variances);
Expand Down
9 changes: 4 additions & 5 deletions c/isotope.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

void iso_get_isotope_scattering_strength(
double *gamma, const long grid_point, const long *ir_grid_points,
const long *weights, const double *mass_variances,
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) {
Expand Down Expand Up @@ -127,7 +127,7 @@ void iso_get_isotope_scattering_strength(

void iso_get_thm_isotope_scattering_strength(
double *gamma, const long grid_point, const long *ir_grid_points,
const long *weights, const double *mass_variances,
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,
Expand Down Expand Up @@ -196,7 +196,7 @@ void iso_get_thm_isotope_scattering_strength(
sum_g_k += (a * a + b * b) * mass_variances[l] * dist;
}
}
gamma_ij[gp * num_band0 + j] = sum_g_k * weights[gp];
gamma_ij[i * num_band0 + j] = sum_g_k * weights[gp];
}
}

Expand All @@ -205,9 +205,8 @@ void iso_get_thm_isotope_scattering_strength(
}

for (i = 0; i < num_grid_points; i++) {
gp = ir_grid_points[i];
for (j = 0; j < num_band0; j++) {
gamma[j] += gamma_ij[gp * num_band0 + j];
gamma[j] += gamma_ij[i * num_band0 + j];
}
}

Expand Down
4 changes: 2 additions & 2 deletions c/isotope.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@

void iso_get_isotope_scattering_strength(
double *gamma, const long grid_point, const long *ir_grid_points,
const long *weights, const double *mass_variances,
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 long *weights, const double *mass_variances,
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,
Expand Down
4 changes: 2 additions & 2 deletions c/phono3py.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void ph3py_get_reducible_collision_matrix(

void ph3py_get_isotope_scattering_strength(
double *gamma, const long grid_point, const long *ir_grid_points,
const long *weights, const double *mass_variances,
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,
Expand All @@ -275,7 +275,7 @@ void ph3py_get_isotope_scattering_strength(

void ph3py_get_thm_isotope_scattering_strength(
double *gamma, const long grid_point, const long *ir_grid_points,
const long *weights, const double *mass_variances,
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,
Expand Down
4 changes: 2 additions & 2 deletions c/phono3py.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ void ph3py_get_reducible_collision_matrix(
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,
const long *weights, const double *mass_variances,
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 double cutoff_frequency);
void ph3py_get_thm_isotope_scattering_strength(
double *gamma, const long grid_point, const long *ir_grid_points,
const long *weights, const double *mass_variances,
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,
Expand Down
2 changes: 1 addition & 1 deletion phono3py/other/isotope.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def _run_c(self):
import phono3py._phono3py as phono3c

gamma = np.zeros(len(self._band_indices), dtype="double")
weights_in_bzgp = np.ones(len(self._grid_points), dtype="int_")
weights_in_bzgp = np.ones(len(self._grid_points), dtype="double")
if self._sigma is None:
self._set_integration_weights()
phono3c.thm_isotope_strength(
Expand Down

0 comments on commit 06bd1f0

Please sign in to comment.