Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Dec 23, 2024
2 parents a8bb6c8 + 3d2236f commit 3927a34
Show file tree
Hide file tree
Showing 24 changed files with 237 additions and 224 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
exclude: ^example/AlN-LDA/

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.2
rev: v0.8.3
hooks:
- id: ruff
args: [ "--fix", "--show-fixes" ]
Expand Down
4 changes: 4 additions & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# Change Log

## Dec-23-2024: Version 3.10.1

- Replace `dtype="int_"` by `dtype="long"`.

## Dec-6-2024: Version 3.10.0

- Update to follow the change of phonopy's internal functions
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
# The short X.Y version.
version = "3.10"
# The full version, including alpha/beta/rc tags.
release = "3.10.0"
release = "3.10.1"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion phono3py/api_isotope.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def run(self, grid_points, lang="C"):
(len(self._sigmas), len(grid_points), len(self._iso.band_indices)),
dtype="double",
)
self._grid_points = np.array(grid_points, dtype="int_")
self._grid_points = np.array(grid_points, dtype="long")

for j, gp in enumerate(grid_points):
self._iso.set_grid_point(gp)
Expand Down
16 changes: 8 additions & 8 deletions phono3py/api_phono3py.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,14 @@ def __init__(
# Create supercell and primitive cell
self._unitcell = unitcell
self._supercell_matrix = np.array(
shape_supercell_matrix(supercell_matrix), dtype="int_", order="C"
shape_supercell_matrix(supercell_matrix), dtype="long", 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="int_", order="C"
shape_supercell_matrix(phonon_supercell_matrix), dtype="long", order="C"
)
else:
self._phonon_supercell_matrix = None
Expand Down Expand Up @@ -538,7 +538,7 @@ def supercell_matrix(self) -> np.ndarray:
ndarray
Supercell matrix with respect to unit cell.
shape=(3, 3), dtype='int_', order='C'
shape=(3, 3), dtype='long', order='C'
"""
return self._supercell_matrix
Expand All @@ -549,7 +549,7 @@ def phonon_supercell_matrix(self) -> Optional[np.ndarray]:
ndarray
Supercell matrix with respect to unit cell.
shape=(3, 3), dtype='int_', order='C'
shape=(3, 3), dtype='long', order='C'
"""
return self._phonon_supercell_matrix
Expand Down Expand Up @@ -743,10 +743,10 @@ def band_indices(self, band_indices):
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="int_")]
self._band_indices = [np.arange(num_band, dtype="long")]
else:
self._band_indices = [np.array(bi, dtype="int_") for bi in band_indices]
self._band_indices_flatten = np.hstack(self._band_indices).astype("int_")
self._band_indices = [np.array(bi, dtype="long") for bi in band_indices]
self._band_indices_flatten = np.hstack(self._band_indices).astype("long")

@property
def masses(self) -> np.ndarray:
Expand Down Expand Up @@ -1948,7 +1948,7 @@ def run_thermal_conductivity(
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='int_'.
shape(num_grid_points, ), dtype='long'.
boundary_mfp : float, optiona, default is None
Mean free path in micrometre to calculate simple boundary
scattering contribution to thermal conductivity.
Expand Down
18 changes: 9 additions & 9 deletions phono3py/conductivity/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def __init__(
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='int_'.
shape=(grid_points, ), dtype='long'.
temperatures : array_like, optional, default is None
Temperatures at which thermal conductivity is calculated.
shape=(temperature_points, ), dtype='double'.
Expand Down Expand Up @@ -676,15 +676,15 @@ def _get_point_operations(self) -> Tuple[np.ndarray, np.ndarray]:
-------
point_operations : ndarray
Operations in reduced coordinates.
shape=(num_operations, 3, 3), dtype='int_'
shape=(num_operations, 3, 3), dtype='long'
rotations_cartesian : ndarray
Operations in Cartesian coordinates.
shape=(num_operations, 3, 3), dtype='double'
"""
if not self._is_kappa_star:
point_operations = np.array(
[np.eye(3, dtype="int_")], dtype="int_", order="C"
[np.eye(3, dtype="long")], dtype="long", order="C"
)
rotations_cartesian = np.array(
[np.eye(3, dtype="double")], dtype="double", order="C"
Expand All @@ -702,24 +702,24 @@ def _get_grid_info(self, grid_points) -> Tuple[np.ndarray, np.ndarray, np.ndarra
-------
grid_points : ndarray
Grid point indices in BZ-grid to be iterated over.
shape=(len(grid_points),), dtype='int_'
shape=(len(grid_points),), dtype='long'
ir_grid_points : ndarray
Irreducible grid points in BZ-grid on regular grid.
shape=(len(ir_grid_points),), dtype='int_'
shape=(len(ir_grid_points),), dtype='long'
grid_weights : ndarray
Grid weights of `grid_points`. If grid symmetry is not broken,
these values are equivalent to numbers of k-star arms.
"""
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="int_")
_grid_points = np.array(grid_points, dtype="long")
_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="int_")
_grid_weights = np.ones(len(_grid_points), dtype="long")
else: # Automatic sampling
_grid_points = ir_grid_points
_ir_grid_points = ir_grid_points
Expand Down Expand Up @@ -777,7 +777,7 @@ def _get_ir_grid_points(self, grid_points):
self._pp.bz_grid
)
ir_grid_points = np.array(
self._pp.bz_grid.grg2bzg[ir_grid_points], dtype="int_"
self._pp.bz_grid.grg2bzg[ir_grid_points], dtype="long"
)
if grid_points is None:
grid_weights = ir_grid_weights
Expand All @@ -787,7 +787,7 @@ def _get_ir_grid_points(self, grid_points):
weights[gp] += 1
grid_weights = np.array(
weights[ir_grid_map[self._pp.bz_grid.bzg2grg[grid_points]]],
dtype="int_",
dtype="long",
)

return ir_grid_points, grid_weights
Expand Down
10 changes: 5 additions & 5 deletions phono3py/conductivity/direct_solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def _set_kappa_reducible_colmat(self, kappa, mode_kappa, i_sigma, i_temp, weight
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="int_"
(num_ir_grid_points, len(self._point_operations)), dtype="long"
)
if self._is_kappa_star:
rotations = self._pp.bz_grid.rotations # rotations of GR-grid
Expand Down Expand Up @@ -530,10 +530,10 @@ def _prepare_collision_matrix(self):
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="int_")
rot_grid_points = np.zeros((num_rot, num_mesh_points), dtype="long")
# 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="int_"
self._pp.bz_grid.bzg2grg[self._ir_grid_points], dtype="long"
)
for i in range(num_mesh_points):
rot_grid_points[:, i] = self._pp.bz_grid.bzg2grg[
Expand All @@ -544,7 +544,7 @@ def _prepare_collision_matrix(self):
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="int_")
weights = np.ones(np.prod(self._pp.mesh_numbers), dtype="long")
self._symmetrize_collision_matrix()
else:
self._combine_collisions()
Expand Down Expand Up @@ -647,7 +647,7 @@ def _get_weights(self):
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='int_'
shape=(ir_grid_points, point_operations), dtype='long'
r_gps : grid points of arms of k-star with duplicates
len(r_gps) == order of crystallographic point group
Expand Down
2 changes: 1 addition & 1 deletion phono3py/conductivity/rta.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ class instance.
collisions,
np.array(
np.dot(tetrahedra, self._pp.bz_grid.P.T),
dtype="int_",
dtype="long",
order="C",
),
self._frequencies,
Expand Down
8 changes: 4 additions & 4 deletions phono3py/cui/kaccum_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _get_ir_grid_info(bz_grid: BZGrid, weights, qpoints=None, ir_grid_points=Non
-------
ir_grid_points : ndarray
Ir-grid point indices in BZ-grid.
shape=(ir_grid_points, ), dtype='int_'
shape=(ir_grid_points, ), dtype='long'
ir_grid_map : ndarray, optional, default=None
Mapping table to ir-grid point indices in GR-grid.
Expand Down Expand Up @@ -289,9 +289,9 @@ def main():
f_kappa = h5py.File(args.filenames[0], "r")

if "grid_matrix" in f_kappa:
mesh = np.array(f_kappa["grid_matrix"][:], dtype="int_")
mesh = np.array(f_kappa["grid_matrix"][:], dtype="long")
else:
mesh = np.array(f_kappa["mesh"][:], dtype="int_")
mesh = np.array(f_kappa["mesh"][:], dtype="long")
if "temperature" in f_kappa:
temperatures = f_kappa["temperature"][:]
else:
Expand All @@ -308,7 +308,7 @@ def main():
frequencies = np.array(f_kappa["frequency"][ir_grid_points_BZ], dtype="double")
else:
frequencies = f_kappa["frequency"][:]
ir_weights = np.ones(len(frequencies), dtype="int_")
ir_weights = np.ones(len(frequencies), dtype="long")
primitive_symmetry = Symmetry(primitive)
bz_grid = BZGrid(
mesh,
Expand Down
2 changes: 1 addition & 1 deletion phono3py/cui/phono3py_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,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="int_")
ir_grid_points = np.array(bz_grid.grg2bzg[ir_grid_points], dtype="long")
filename = write_phonon_to_hdf5(
freqs,
eigvecs,
Expand Down
42 changes: 25 additions & 17 deletions phono3py/cui/triplets_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,27 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

from collections.abc import Sequence
from typing import Optional, Union

import numpy as np
from phonopy.structure.atoms import PhonopyAtoms

from phono3py.file_IO import write_grid_address_to_hdf5, write_ir_grid_points
from phono3py.phonon.grid import get_ir_grid_points
from phono3py.phonon.grid import BZGrid, get_ir_grid_points
from phono3py.phonon3.triplets import get_triplets_at_q


def write_grid_points(
primitive,
bz_grid,
band_indices=None,
sigmas=None,
temperatures=None,
is_kappa_star=True,
is_lbte=False,
compression="gzip",
filename=None,
primitive: PhonopyAtoms,
bz_grid: BZGrid,
band_indices: Optional[Union[Sequence, np.ndarray]] = None,
sigmas: Optional[Union[Sequence, np.ndarray]] = None,
temperatures: Optional[Union[Sequence, np.ndarray]] = None,
is_kappa_star: bool = True,
is_lbte: bool = False,
compression: Union[str, int] = "gzip",
filename: bool = None,
):
"""Write grid points into files."""
ir_grid_points, ir_grid_weights = _get_ir_grid_points(
Expand Down Expand Up @@ -103,7 +107,11 @@ def write_grid_points(


def show_num_triplets(
primitive, bz_grid, band_indices=None, grid_points=None, is_kappa_star=True
primitive: PhonopyAtoms,
bz_grid: BZGrid,
band_indices: Optional[Union[Sequence, np.ndarray]] = None,
grid_points: Optional[Union[Sequence, np.ndarray]] = None,
is_kappa_star: bool = True,
):
"""Show numbers of triplets at grid points."""
tp_nums = _TripletsNumbers(bz_grid, is_kappa_star=is_kappa_star)
Expand Down Expand Up @@ -131,7 +139,7 @@ def show_num_triplets(


class _TripletsNumbers:
def __init__(self, bz_grid, is_kappa_star=True):
def __init__(self, bz_grid: BZGrid, is_kappa_star: bool = True):
self._bz_grid = bz_grid
(
self.ir_grid_points,
Expand All @@ -143,19 +151,19 @@ def get_number_of_triplets(self, gp):
return num_triplets


def _get_ir_grid_points(bz_grid, is_kappa_star=True):
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="int_")
ir_grid_points = np.array(bz_grid.grg2bzg[ir_grid_points], dtype="long")
else:
ir_grid_points = np.array(
bz_grid.grg2bzg[: np.prod(bz_grid.D_diag)], dtype="int_", order="C"
bz_grid.grg2bzg[: np.prod(bz_grid.D_diag)], dtype="long", order="C"
)
ir_grid_weights = np.ones(len(ir_grid_points), dtype="int_")
ir_grid_weights = np.ones(len(ir_grid_points), dtype="long")

return ir_grid_points, ir_grid_weights


def _get_number_of_triplets(bz_grid, grid_point, swappable=True):
def _get_number_of_triplets(bz_grid: BZGrid, grid_point: int, swappable: bool = True):
triplets_at_q = get_triplets_at_q(grid_point, bz_grid, swappable=swappable)[0]
return len(triplets_at_q)
4 changes: 2 additions & 2 deletions phono3py/file_IO.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def write_grid_address_to_hdf5(
mesh,
grid_mapping_table,
bz_grid=None,
compression="gzip",
compression: Union[str, int] = "gzip",
filename=None,
):
"""Write grid addresses to grid_address.hdf5."""
Expand Down Expand Up @@ -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("int_")
_band_indices = np.hstack(band_indices).astype("long")
suffix = _get_filename_suffix(
mesh, grid_point=grid_point, band_indices=_band_indices, sigma=sigma
)
Expand Down
8 changes: 4 additions & 4 deletions phono3py/other/isotope.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ def __init__(

num_band = len(self._primitive) * 3
if band_indices is None:
self._band_indices = np.arange(num_band, dtype="int_")
self._band_indices = np.arange(num_band, dtype="long")
else:
self._band_indices = np.array(band_indices, dtype="int_")
self._band_indices = np.array(band_indices, dtype="long")

if self._bz_grid is None:
primitive_symmetry = Symmetry(self._primitive, self._symprec)
Expand All @@ -153,7 +153,7 @@ def __init__(
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="int_")
self._grid_points = np.arange(len(self._bz_grid.addresses), dtype="long")

if self._phonon_done is None:
self._allocate_phonon()
Expand Down Expand Up @@ -319,7 +319,7 @@ def _set_integration_weights_py(self):
self._bz_grid.addresses,
np.array(
np.dot(thm.tetrahedra, self._bz_grid.P.T),
dtype="int_",
dtype="long",
order="C",
),
self._bz_grid.grg2bzg,
Expand Down
Loading

0 comments on commit 3927a34

Please sign in to comment.