diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ae370e4f..5ac49352 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: - id: check-added-large-files - repo: https://github.com/pycqa/flake8 - rev: 6.1.0 + rev: 7.0.0 hooks: - id: flake8 args: @@ -19,7 +19,7 @@ repos: - "--ignore=E203,W503" - repo: https://github.com/psf/black - rev: 23.12.0 + rev: 24.1.1 hooks: - id: black args: diff --git a/doc/changelog.md b/doc/changelog.md index 06ed8ba8..a2cfd955 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -2,6 +2,10 @@ # Change Log +## Feb-2-2024: Version 2.9.2 + +- `boundary_mfp` value is stored in `kappa-*.hdf5` file when it is specified. + ## Dec-26-2023: Version 2.9.1 - Release to build conda-forge package. diff --git a/doc/command-options.md b/doc/command-options.md index 2e815fa0..a8b969d7 100644 --- a/doc/command-options.md +++ b/doc/command-options.md @@ -561,6 +561,8 @@ Then running with isotope calculation: In the result hdf5 file, currently isotope scattering strength is not written out, i.e., `gamma` is still imaginary part of self energy of ph-ph scattering. +(boundary_mfp_option)= + ### `--boundary-mfp`, `--bmfp` (`BOUNDARY_MFP`) A most simple phonon boundary scattering treatment is included. $v_g/L$ is just diff --git a/doc/conf.py b/doc/conf.py index b1aeed68..cae6e3a1 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -1,4 +1,5 @@ """Sphinx phono3py configuration file.""" + # # phono3py documentation build configuration file, created by # sphinx-quickstart on Wed Jun 26 13:13:14 2013. @@ -59,7 +60,7 @@ # The short X.Y version. version = "2.9" # The full version, including alpha/beta/rc tags. -release = "2.9.1" +release = "2.9.2" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/hdf5_howto.md b/doc/hdf5_howto.md index bf90878d..8569eac9 100644 --- a/doc/hdf5_howto.md +++ b/doc/hdf5_howto.md @@ -123,8 +123,9 @@ The array shape is (irreducible q-point, phonon band). (kappa_hdf5_file_gamma)= ### gamma -Imaginary part of self energy. The physical unit is THz, where THz -is in the ordinal frequency not the angular frequency. +Imaginary part of self energy of phonon bubble diagram (phonon-phonon +scattering). The physical unit is THz, where THz is in the ordinal frequency not +the angular frequency. The array shape for all grid-points (irreducible q-points) is (temperature, irreducible q-point, phonon band). @@ -262,9 +263,16 @@ P_{\mathbf{q}j} = \frac{1}{(3n_\mathrm{a})^2} \sum_{\lambda'\lambda''} $$ This is not going to be calculated in the RTA thermal coductivity -calculation mode by default. To calculate this, `--full_pp` option +calculation mode by default. To calculate this, `--full-pp` option has to be specified (see {ref}`full_pp_option`). +### boundary_mfp + +A value specified by {ref}`boundary_mfp_option`. The physical unit is +micrometre. + +When `--boundary-mfp` option is explicitly specified, its value is stored here. + ### kappa_unit_conversion This is used to convert the physical unit of lattice thermal diff --git a/example/Si-PBEsol/Si.py b/example/Si-PBEsol/Si.py index 763ddc8f..db2a8819 100644 --- a/example/Si-PBEsol/Si.py +++ b/example/Si-PBEsol/Si.py @@ -1,4 +1,5 @@ """Example to run thermal conductivity of Si.""" + import numpy as np from phonopy.interface.vasp import read_vasp diff --git a/example/zb-ZnTe-PBEsol/launch_phono3py_ZnTe_PBEsol_222.py b/example/zb-ZnTe-PBEsol/launch_phono3py_ZnTe_PBEsol_222.py index 9ab45e18..064574c9 100644 --- a/example/zb-ZnTe-PBEsol/launch_phono3py_ZnTe_PBEsol_222.py +++ b/example/zb-ZnTe-PBEsol/launch_phono3py_ZnTe_PBEsol_222.py @@ -1,4 +1,5 @@ """Launch script of ZnTe AiiDA calculation using aiida-phononpy.""" + from aiida.engine import submit from aiida.manage.configuration import load_profile from aiida.orm import Bool, Float, Str diff --git a/phono3py/__init__.py b/phono3py/__init__.py index d1e566cf..394c8838 100644 --- a/phono3py/__init__.py +++ b/phono3py/__init__.py @@ -1,4 +1,5 @@ """Shortcuts to important classes, methods, and variables.""" + # Copyright (C) 2019 Atsushi Togo # All rights reserved. # diff --git a/phono3py/api_isotope.py b/phono3py/api_isotope.py index 7bf4b6c9..de7b87eb 100644 --- a/phono3py/api_isotope.py +++ b/phono3py/api_isotope.py @@ -1,4 +1,5 @@ """API for isotope scattering.""" + # Copyright (C) 2019 Atsushi Togo # All rights reserved. # diff --git a/phono3py/api_jointdos.py b/phono3py/api_jointdos.py index a787e4a4..6b4841eb 100644 --- a/phono3py/api_jointdos.py +++ b/phono3py/api_jointdos.py @@ -1,4 +1,5 @@ """API for joint-density-of-states calculation.""" + # Copyright (C) 2019 Atsushi Togo # All rights reserved. # diff --git a/phono3py/api_phono3py.py b/phono3py/api_phono3py.py index dbb4d467..86efd8a7 100644 --- a/phono3py/api_phono3py.py +++ b/phono3py/api_phono3py.py @@ -1,4 +1,5 @@ """Phono3py main class.""" + # Copyright (C) 2016 Atsushi Togo # All rights reserved. # diff --git a/phono3py/conductivity/base.py b/phono3py/conductivity/base.py index 2123669d..05c14912 100644 --- a/phono3py/conductivity/base.py +++ b/phono3py/conductivity/base.py @@ -1,4 +1,5 @@ """Thermal conductivity base class.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # @@ -375,6 +376,8 @@ def __init__( volume = self._pp.primitive.volume self._conversion_factor = unit_to_WmK / volume + self._averaged_pp_interaction = None + # `self._velocity_obj` is the instance of an inherited class of # `GroupVelocity`. `self._init_velocity()` is the method setup the instance, # which must be implmented in the inherited class of `ConductivityBase`. @@ -632,6 +635,11 @@ def get_averaged_pp_interaction(self): ) return self.averaged_pp_interaction + @property + def boundary_mfp(self) -> float: + """Return boundary MFP.""" + return self._boundary_mfp + def get_number_of_sampling_grid_points(self): """Return number of grid points. diff --git a/phono3py/conductivity/direct_solution.py b/phono3py/conductivity/direct_solution.py index 132a4fd6..b8e027cb 100644 --- a/phono3py/conductivity/direct_solution.py +++ b/phono3py/conductivity/direct_solution.py @@ -1,4 +1,5 @@ """Calculate lattice thermal conductivity by direct solution.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # @@ -108,7 +109,6 @@ def __init__( self._init_velocity(gv_delta_q) self._lang = lang - self._averaged_pp_interaction = None self._collision_eigenvalues = None self._is_reducible_collision_matrix = is_reducible_collision_matrix self._solve_collective_phonon = solve_collective_phonon @@ -517,9 +517,9 @@ def _set_collision_matrix_at_sigmas(self, i_gp): else: i_data = 0 self._gamma[j, k, i_data] = self._collision.imag_self_energy - self._collision_matrix[ - j, k, i_data - ] = self._collision.get_collision_matrix() + self._collision_matrix[j, k, i_data] = ( + self._collision.get_collision_matrix() + ) def _prepare_collision_matrix(self): """Collect pieces and construct collision matrix.""" diff --git a/phono3py/conductivity/kubo.py b/phono3py/conductivity/kubo.py index 901b0eed..34da6283 100644 --- a/phono3py/conductivity/kubo.py +++ b/phono3py/conductivity/kubo.py @@ -1,4 +1,5 @@ """Kubo thermal conductivity base class.""" + # Copyright (C) 2022 Atsushi Togo # All rights reserved. # diff --git a/phono3py/conductivity/rta.py b/phono3py/conductivity/rta.py index be3fd1f0..64ac8bbe 100644 --- a/phono3py/conductivity/rta.py +++ b/phono3py/conductivity/rta.py @@ -1,4 +1,5 @@ """Lattice thermal conductivity calculation with RTA.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # @@ -97,7 +98,6 @@ def __init__( self._gamma_detail_at_q = None self._use_ave_pp = use_ave_pp self._use_const_ave_pp = None - self._averaged_pp_interaction = None self._num_ignored_phonon_modes = None super().__init__( @@ -298,9 +298,9 @@ def _set_gamma_at_sigmas(self, i): self._gamma_N[j, k, i] = g_N self._gamma_U[j, k, i] = g_U if self._is_gamma_detail: - self._gamma_detail_at_q[ - k - ] = self._collision.get_detailed_imag_self_energy() + self._gamma_detail_at_q[k] = ( + self._collision.get_detailed_imag_self_energy() + ) def _set_gamma_at_sigmas_lowmem(self, i): """Calculate gamma without storing ph-ph interaction strength. diff --git a/phono3py/conductivity/utils.py b/phono3py/conductivity/utils.py index 3059c2d2..62b62801 100644 --- a/phono3py/conductivity/utils.py +++ b/phono3py/conductivity/utils.py @@ -1,4 +1,5 @@ """Utilities for lattice thermal conductivity calculation.""" + # Copyright (C) 2022 Atsushi Togo # All rights reserved. # @@ -268,6 +269,7 @@ def write_kappa( qpoints = br.qpoints grid_points = br.grid_points weights = br.grid_weights + boundary_mfp = br.boundary_mfp for i, sigma in enumerate(sigmas): if kappa is None: @@ -314,6 +316,7 @@ def write_kappa( write_kappa_to_hdf5( temperatures, mesh, + boundary_mfp=boundary_mfp, bz_grid=bz_grid, frequency=frequencies, group_velocity=gv, @@ -487,13 +490,13 @@ def write_collision( @staticmethod def write_kappa( lbte: "cond_LBTE_type", - volume, - is_reducible_collision_matrix=False, - write_LBTE_solution=False, - pinv_solver=None, - compression="gzip", - filename=None, - log_level=0, + volume: float, + is_reducible_collision_matrix: bool = False, + write_LBTE_solution: bool = False, + pinv_solver: Optional[int] = None, + compression: str = "gzip", + filename: Optional[str] = None, + log_level: int = 0, ): """Write kappa related properties into a hdf5 file.""" from phono3py.conductivity.direct_solution import ( @@ -546,6 +549,7 @@ def write_kappa( f_vector = lbte.get_f_vectors() mode_cv = lbte.mode_heat_capacities mfp = lbte.get_mean_free_path() + boundary_mfp = lbte.boundary_mfp coleigs = lbte.get_collision_eigenvalues() # After kappa calculation, the variable is overwritten by unitary matrix @@ -612,6 +616,7 @@ def write_kappa( write_kappa_to_hdf5( temperatures, mesh, + boundary_mfp=boundary_mfp, bz_grid=bz_grid, frequency=frequencies, group_velocity=gv, diff --git a/phono3py/conductivity/wigner.py b/phono3py/conductivity/wigner.py index a6d754d0..9f91b609 100644 --- a/phono3py/conductivity/wigner.py +++ b/phono3py/conductivity/wigner.py @@ -1,4 +1,5 @@ """Wigner thermal conductivity base class.""" + # Copyright (C) 2022 Michele Simoncelli # All rights reserved. # diff --git a/phono3py/cui/create_force_constants.py b/phono3py/cui/create_force_constants.py index feb9873e..d0042586 100644 --- a/phono3py/cui/create_force_constants.py +++ b/phono3py/cui/create_force_constants.py @@ -1,4 +1,5 @@ """Force constants calculation utilities for command line user interface.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # diff --git a/phono3py/cui/create_supercells.py b/phono3py/cui/create_supercells.py index 0ff27a8f..55977358 100644 --- a/phono3py/cui/create_supercells.py +++ b/phono3py/cui/create_supercells.py @@ -1,4 +1,5 @@ """Utilities of main CUI script.""" + # Copyright (C) 2015 Atsushi Togo # All rights reserved. # diff --git a/phono3py/cui/kaccum_script.py b/phono3py/cui/kaccum_script.py index 598267be..744f8bbe 100644 --- a/phono3py/cui/kaccum_script.py +++ b/phono3py/cui/kaccum_script.py @@ -1,4 +1,5 @@ """Phono3py kaccum command line script.""" + import argparse import sys diff --git a/phono3py/cui/load.py b/phono3py/cui/load.py index 04a42847..59456ed6 100644 --- a/phono3py/cui/load.py +++ b/phono3py/cui/load.py @@ -1,4 +1,5 @@ """Phono3py loader.""" + # Copyright (C) 2019 Atsushi Togo # All rights reserved. # diff --git a/phono3py/cui/phono3py_argparse.py b/phono3py/cui/phono3py_argparse.py index 0c24ba78..0cbdc115 100644 --- a/phono3py/cui/phono3py_argparse.py +++ b/phono3py/cui/phono3py_argparse.py @@ -1,4 +1,5 @@ """Phono3py command option argument parser.""" + # Copyright (C) 2015 Atsushi Togo # All rights reserved. # diff --git a/phono3py/cui/phono3py_script.py b/phono3py/cui/phono3py_script.py index 8880f076..86ffeba2 100644 --- a/phono3py/cui/phono3py_script.py +++ b/phono3py/cui/phono3py_script.py @@ -1,4 +1,5 @@ """Phono3py main command line script.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # diff --git a/phono3py/cui/settings.py b/phono3py/cui/settings.py index 960fb524..5f35b37f 100644 --- a/phono3py/cui/settings.py +++ b/phono3py/cui/settings.py @@ -1,4 +1,5 @@ """Phono3py command option and conf file parser.""" + # Copyright (C) 2015 Atsushi Togo # All rights reserved. # diff --git a/phono3py/cui/show_log.py b/phono3py/cui/show_log.py index 7d37c9c8..2283e065 100644 --- a/phono3py/cui/show_log.py +++ b/phono3py/cui/show_log.py @@ -1,4 +1,5 @@ """Utilities to show various logs for main CUI script.""" + # Copyright (C) 2015 Atsushi Togo # All rights reserved. # diff --git a/phono3py/cui/triplets_info.py b/phono3py/cui/triplets_info.py index 9e2ae990..50ced6a5 100644 --- a/phono3py/cui/triplets_info.py +++ b/phono3py/cui/triplets_info.py @@ -1,4 +1,5 @@ """Show and write triplets information.""" + # Copyright (C) 2015 Atsushi Togo # All rights reserved. # diff --git a/phono3py/file_IO.py b/phono3py/file_IO.py index 7856a4d9..20040997 100644 --- a/phono3py/file_IO.py +++ b/phono3py/file_IO.py @@ -1,4 +1,5 @@ """File I/O methods.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # @@ -32,9 +33,12 @@ # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. +from __future__ import annotations import os import warnings +from collections.abc import Sequence +from typing import Optional, Union import h5py import numpy as np @@ -918,6 +922,7 @@ def write_collision_eigenvalues_to_hdf5( def write_kappa_to_hdf5( temperature, mesh, + boundary_mfp: float = None, bz_grid=None, frequency=None, group_velocity=None, @@ -1058,6 +1063,8 @@ def write_kappa_to_hdf5( w.create_dataset("sigma_cutoff_width", data=sigma_cutoff) if kappa_unit_conversion is not None: w.create_dataset("kappa_unit_conversion", data=kappa_unit_conversion) + if boundary_mfp is not None: + w.create_dataset("boundary_mfp", data=boundary_mfp) if verbose: text = "Thermal conductivity related properties " @@ -1720,12 +1727,12 @@ def get_length_of_first_line(f): def _get_filename_suffix( mesh, - grid_point=None, - band_indices=None, - sigma=None, - sigma_cutoff=None, - temperature=None, - filename=None, + grid_point: Optional[int] = None, + band_indices: Optional[Union[np.ndarray, Sequence]] = None, + sigma: Optional[float] = None, + sigma_cutoff: Optional[float] = None, + temperature: Optional[float] = None, + filename: Optional[str] = None, ): """Return filename suffix corresponding to parameters.""" suffix = "-m%d%d%d" % tuple(mesh) diff --git a/phono3py/interface/alm.py b/phono3py/interface/alm.py index 804b8702..91292761 100644 --- a/phono3py/interface/alm.py +++ b/phono3py/interface/alm.py @@ -1,4 +1,5 @@ """ALM interface for force constants calculation.""" + # Copyright (C) 2016 Atsushi Togo # All rights reserved. # diff --git a/phono3py/interface/calculator.py b/phono3py/interface/calculator.py index 1a987277..15f0014d 100644 --- a/phono3py/interface/calculator.py +++ b/phono3py/interface/calculator.py @@ -1,4 +1,5 @@ """Utilities of calculator interfaces.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # diff --git a/phono3py/interface/fc_calculator.py b/phono3py/interface/fc_calculator.py index c80cf1ce..239f1fc0 100644 --- a/phono3py/interface/fc_calculator.py +++ b/phono3py/interface/fc_calculator.py @@ -1,4 +1,5 @@ """Interfaces for force constants calculators.""" + # Copyright (C) 2019 Atsushi Togo # All rights reserved. # diff --git a/phono3py/interface/phono3py_yaml.py b/phono3py/interface/phono3py_yaml.py index f2ed69f8..79c03256 100644 --- a/phono3py/interface/phono3py_yaml.py +++ b/phono3py/interface/phono3py_yaml.py @@ -1,4 +1,5 @@ """phono3py_yaml reader and writer.""" + # Copyright (C) 2016 Atsushi Togo # All rights reserved. # diff --git a/phono3py/other/isotope.py b/phono3py/other/isotope.py index 8f1bacfc..a786c08f 100644 --- a/phono3py/other/isotope.py +++ b/phono3py/other/isotope.py @@ -1,4 +1,5 @@ """Isotope scattering calculation.""" + # Copyright (C) 2015 Atsushi Togo # All rights reserved. # diff --git a/phono3py/other/kaccum.py b/phono3py/other/kaccum.py index f95b3651..e57b1cbf 100644 --- a/phono3py/other/kaccum.py +++ b/phono3py/other/kaccum.py @@ -1,4 +1,5 @@ """Calculated accumulated property with respect to other property.""" + from typing import Optional import numpy as np diff --git a/phono3py/other/tetrahedron_method.py b/phono3py/other/tetrahedron_method.py index bbe34198..83a280fc 100644 --- a/phono3py/other/tetrahedron_method.py +++ b/phono3py/other/tetrahedron_method.py @@ -1,4 +1,5 @@ """Tetrahedron method python wrapper.""" + # Copyright (C) 2021 Atsushi Togo # All rights reserved. # diff --git a/phono3py/phonon/func.py b/phono3py/phonon/func.py index e320baa5..434feefd 100644 --- a/phono3py/phonon/func.py +++ b/phono3py/phonon/func.py @@ -1,4 +1,5 @@ """Mathematical functions.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # diff --git a/phono3py/phonon/grid.py b/phono3py/phonon/grid.py index d36457ec..ea7bc30f 100644 --- a/phono3py/phonon/grid.py +++ b/phono3py/phonon/grid.py @@ -1,4 +1,5 @@ """Regular grid tools.""" + # Copyright (C) 2021 Atsushi Togo # All rights reserved. # diff --git a/phono3py/phonon/group_velocity_matrix.py b/phono3py/phonon/group_velocity_matrix.py index 8f0017d7..b877875d 100644 --- a/phono3py/phonon/group_velocity_matrix.py +++ b/phono3py/phonon/group_velocity_matrix.py @@ -1,4 +1,5 @@ """Calculate group velocity matrix.""" + # Copyright (C) 2021 Atsushi Togo # All rights reserved. # diff --git a/phono3py/phonon/heat_capacity_matrix.py b/phono3py/phonon/heat_capacity_matrix.py index 8b4ef6d8..05056de6 100644 --- a/phono3py/phonon/heat_capacity_matrix.py +++ b/phono3py/phonon/heat_capacity_matrix.py @@ -1,4 +1,5 @@ """Calculate group velocity matrix.""" + # Copyright (C) 2021 Atsushi Togo # All rights reserved. # diff --git a/phono3py/phonon/solver.py b/phono3py/phonon/solver.py index 6307b056..983ee81e 100644 --- a/phono3py/phonon/solver.py +++ b/phono3py/phonon/solver.py @@ -1,4 +1,5 @@ """Create dynamical matrix and solve harmonic phonons on grid.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # diff --git a/phono3py/phonon/velocity_operator.py b/phono3py/phonon/velocity_operator.py index b1f68723..bc7ca02c 100644 --- a/phono3py/phonon/velocity_operator.py +++ b/phono3py/phonon/velocity_operator.py @@ -1,4 +1,5 @@ """Velocity operator of Simoncelli, Marzari, and Mauri.""" + # Copyright (C) 2013 Atsushi Togo # All rights reserved. # diff --git a/phono3py/phonon3/collision_matrix.py b/phono3py/phonon3/collision_matrix.py index 609085fa..a7fd3764 100644 --- a/phono3py/phonon3/collision_matrix.py +++ b/phono3py/phonon3/collision_matrix.py @@ -1,4 +1,5 @@ """Calculate collision matrix of direct solution of LBTE.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # diff --git a/phono3py/phonon3/dataset.py b/phono3py/phonon3/dataset.py index e896056b..b6e11663 100644 --- a/phono3py/phonon3/dataset.py +++ b/phono3py/phonon3/dataset.py @@ -1,4 +1,5 @@ """Parse displacement dataset.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # diff --git a/phono3py/phonon3/displacement_fc3.py b/phono3py/phonon3/displacement_fc3.py index f430c099..4f539977 100644 --- a/phono3py/phonon3/displacement_fc3.py +++ b/phono3py/phonon3/displacement_fc3.py @@ -1,4 +1,5 @@ """Procedures to handle atomic displacements for fc3.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # diff --git a/phono3py/phonon3/fc3.py b/phono3py/phonon3/fc3.py index 6b23e6bf..63e1e6c2 100644 --- a/phono3py/phonon3/fc3.py +++ b/phono3py/phonon3/fc3.py @@ -1,4 +1,5 @@ """Calculate fc3.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # diff --git a/phono3py/phonon3/gruneisen.py b/phono3py/phonon3/gruneisen.py index 8083d3c0..c803d22b 100644 --- a/phono3py/phonon3/gruneisen.py +++ b/phono3py/phonon3/gruneisen.py @@ -1,4 +1,5 @@ """Calculation of mode Grueneisen parameters from fc3.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # diff --git a/phono3py/phonon3/imag_self_energy.py b/phono3py/phonon3/imag_self_energy.py index 39b13ff9..563ba6a6 100644 --- a/phono3py/phonon3/imag_self_energy.py +++ b/phono3py/phonon3/imag_self_energy.py @@ -1,4 +1,5 @@ """Calculation of imaginary-part of self-energy of bubble diagram.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # diff --git a/phono3py/phonon3/interaction.py b/phono3py/phonon3/interaction.py index 4015aa50..581250d9 100644 --- a/phono3py/phonon3/interaction.py +++ b/phono3py/phonon3/interaction.py @@ -1,4 +1,5 @@ """Calculate ph-ph interaction and phonons on grid.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # diff --git a/phono3py/phonon3/joint_dos.py b/phono3py/phonon3/joint_dos.py index e183fb91..69fe9007 100644 --- a/phono3py/phonon3/joint_dos.py +++ b/phono3py/phonon3/joint_dos.py @@ -1,4 +1,5 @@ """Joint-density of states calculation.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # diff --git a/phono3py/phonon3/real_self_energy.py b/phono3py/phonon3/real_self_energy.py index c1e026fd..a49ee932 100644 --- a/phono3py/phonon3/real_self_energy.py +++ b/phono3py/phonon3/real_self_energy.py @@ -1,4 +1,5 @@ """Calculate real-part of self-energy of bubble diagram.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # diff --git a/phono3py/phonon3/real_to_reciprocal.py b/phono3py/phonon3/real_to_reciprocal.py index aca2145c..cafa700a 100644 --- a/phono3py/phonon3/real_to_reciprocal.py +++ b/phono3py/phonon3/real_to_reciprocal.py @@ -1,4 +1,5 @@ """Transform fc3 in real space to reciprocal space.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # diff --git a/phono3py/phonon3/reciprocal_to_normal.py b/phono3py/phonon3/reciprocal_to_normal.py index 0d569068..9cf2970e 100644 --- a/phono3py/phonon3/reciprocal_to_normal.py +++ b/phono3py/phonon3/reciprocal_to_normal.py @@ -1,4 +1,5 @@ """Transform fc3 in reciprocal space to phonon space.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # diff --git a/phono3py/phonon3/spectral_function.py b/phono3py/phonon3/spectral_function.py index 9b6943d1..4b0b9f99 100644 --- a/phono3py/phonon3/spectral_function.py +++ b/phono3py/phonon3/spectral_function.py @@ -1,4 +1,5 @@ """Calculate spectral function due to bubble diagram.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # diff --git a/phono3py/phonon3/triplets.py b/phono3py/phonon3/triplets.py index e6d9b755..139240a6 100644 --- a/phono3py/phonon3/triplets.py +++ b/phono3py/phonon3/triplets.py @@ -1,4 +1,5 @@ """Utilities to handle q-point triplets.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # diff --git a/phono3py/version.py b/phono3py/version.py index 14d42a0d..434dd992 100644 --- a/phono3py/version.py +++ b/phono3py/version.py @@ -1,4 +1,5 @@ """Define phono3py version.""" + # Copyright (C) 2020 Atsushi Togo # All rights reserved. # @@ -33,4 +34,4 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -__version__ = "2.9.1" +__version__ = "2.9.2" diff --git a/setup.py b/setup.py index f1cd0468..7f0c1780 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,7 @@ set PHONO3PY_USE_CMAKE=false to avoid running cmake. """ + import os import pathlib import shutil diff --git a/test/api/test_api_phono3py.py b/test/api/test_api_phono3py.py index 302e1e7c..38687170 100644 --- a/test/api/test_api_phono3py.py +++ b/test/api/test_api_phono3py.py @@ -1,4 +1,5 @@ """Tests of Phono3py API.""" + from pathlib import Path from phono3py import Phono3py diff --git a/test/conductivity/test_kappa_LBTE.py b/test/conductivity/test_kappa_LBTE.py index b7715791..f494b0e0 100644 --- a/test/conductivity/test_kappa_LBTE.py +++ b/test/conductivity/test_kappa_LBTE.py @@ -1,4 +1,5 @@ """Tests for direct solution of LBTE.""" + import numpy as np from phono3py.api_phono3py import Phono3py diff --git a/test/conductivity/test_kappa_LBTE_Wigner.py b/test/conductivity/test_kappa_LBTE_Wigner.py index f4b805fe..9f6cb548 100644 --- a/test/conductivity/test_kappa_LBTE_Wigner.py +++ b/test/conductivity/test_kappa_LBTE_Wigner.py @@ -1,4 +1,5 @@ """Tests for direct solution of LBTE.""" + import numpy as np import pytest diff --git a/test/conductivity/test_kappa_RTA.py b/test/conductivity/test_kappa_RTA.py index 499a64e1..46643819 100644 --- a/test/conductivity/test_kappa_RTA.py +++ b/test/conductivity/test_kappa_RTA.py @@ -1,4 +1,5 @@ """Test for Conductivity_RTA.py.""" + import itertools import numpy as np diff --git a/test/conductivity/test_kappa_RTA_Wigner.py b/test/conductivity/test_kappa_RTA_Wigner.py index eb1020ed..37426406 100644 --- a/test/conductivity/test_kappa_RTA_Wigner.py +++ b/test/conductivity/test_kappa_RTA_Wigner.py @@ -1,4 +1,5 @@ """Test for Conductivity_RTA.py.""" + import itertools import numpy as np diff --git a/test/conftest.py b/test/conftest.py index 3bb8515d..bfb10096 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -1,4 +1,5 @@ """Pytest conftest.py.""" + from pathlib import Path import numpy as np diff --git a/test/cui/test_phono3py_load_script.py b/test/cui/test_phono3py_load_script.py index 3540e274..e80627dd 100644 --- a/test/cui/test_phono3py_load_script.py +++ b/test/cui/test_phono3py_load_script.py @@ -1,4 +1,5 @@ """Tests of Phono3py API.""" + from __future__ import annotations import os diff --git a/test/file_IO/test_file_IO.py b/test/file_IO/test_file_IO.py new file mode 100644 index 00000000..a6da0028 --- /dev/null +++ b/test/file_IO/test_file_IO.py @@ -0,0 +1,95 @@ +"""Tests of Phono3py API.""" + +import pathlib +from collections.abc import Sequence +from typing import Optional + +import h5py +import numpy as np + +from phono3py import Phono3py +from phono3py.file_IO import _get_filename_suffix + +cwd = pathlib.Path(__file__).parent +cwd_called = pathlib.Path.cwd() + + +def test_kappa_filename(): + """Test _get_filename_suffix.""" + mesh = [4, 4, 4] + grid_point = None + band_indices = None + sigma = None + sigma_cutoff = None + filename = None + suffix = _get_filename_suffix( + mesh, + grid_point=grid_point, + band_indices=band_indices, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + filename=filename, + ) + full_filename = "kappa" + suffix + ".hdf5" + assert full_filename == "kappa-m444.hdf5" + + +def test_kappa_hdf5_with_boundary_mpf(si_pbesol: Phono3py): + """Test boundary_mfp in kappa-*.hdf5. + + Remember to clean files created by + Phono3py.run_thermal_conductivity(write_kappa=True). + + """ + key_ref = [ + "boundary_mfp", + "frequency", + "gamma", + "grid_point", + "group_velocity", + "gv_by_gv", + "heat_capacity", + "kappa", + "kappa_unit_conversion", + "mesh", + "mode_kappa", + "qpoint", + "temperature", + "version", + "weight", + ] + + boundary_mfp = 10000.0 + kappa_filename = _set_kappa( + si_pbesol, [4, 4, 4], write_kappa=True, boundary_mfp=boundary_mfp + ) + file_path = pathlib.Path(cwd_called / kappa_filename) + with h5py.File(file_path, "r") as f: + np.testing.assert_almost_equal(f["boundary_mfp"][()], boundary_mfp) + assert set(list(f)) == set(key_ref) + + if file_path.exists(): + file_path.unlink() + + +def _set_kappa( + ph3: Phono3py, + mesh: Sequence, + is_isotope: bool = False, + is_full_pp: bool = False, + write_kappa: bool = False, + boundary_mfp: Optional[float] = None, +) -> str: + ph3.mesh_numbers = mesh + ph3.init_phph_interaction() + ph3.run_thermal_conductivity( + temperatures=[ + 300, + ], + is_isotope=is_isotope, + is_full_pp=is_full_pp, + write_kappa=write_kappa, + boundary_mfp=boundary_mfp, + ) + suffix = _get_filename_suffix(mesh) + return "kappa" + suffix + ".hdf5" diff --git a/test/interface/test_phono3py_yaml.py b/test/interface/test_phono3py_yaml.py index 954f6abb..6702c50f 100644 --- a/test/interface/test_phono3py_yaml.py +++ b/test/interface/test_phono3py_yaml.py @@ -1,4 +1,5 @@ """Tests of PhonopyYaml.""" + from io import StringIO from pathlib import Path diff --git a/test/other/test_isotope.py b/test/other/test_isotope.py index 01594fa8..3e168326 100644 --- a/test/other/test_isotope.py +++ b/test/other/test_isotope.py @@ -1,4 +1,5 @@ """Tests for isotope scatterings.""" + import numpy as np import pytest diff --git a/test/other/test_kaccum.py b/test/other/test_kaccum.py index a2149dd4..47cf5b86 100644 --- a/test/other/test_kaccum.py +++ b/test/other/test_kaccum.py @@ -1,4 +1,5 @@ """Test for kaccum.py.""" + import numpy as np from phono3py import Phono3py diff --git a/test/phonon/test_grid.py b/test/phonon/test_grid.py index 0e187d6e..23905353 100644 --- a/test/phonon/test_grid.py +++ b/test/phonon/test_grid.py @@ -1,4 +1,5 @@ """Tests for grids.""" + from __future__ import annotations import numpy as np diff --git a/test/phonon/test_velocity_operator.py b/test/phonon/test_velocity_operator.py index 55a17680..1a51e700 100644 --- a/test/phonon/test_velocity_operator.py +++ b/test/phonon/test_velocity_operator.py @@ -1,4 +1,5 @@ """Tests for velocity operator calculation.""" + import numpy as np from phonopy import Phonopy from phonopy.units import THzToCm, VaspToTHz diff --git a/test/phonon3/test_displacements.py b/test/phonon3/test_displacements.py index 978f0222..992772e0 100644 --- a/test/phonon3/test_displacements.py +++ b/test/phonon3/test_displacements.py @@ -1,4 +1,5 @@ """Tests of displacements.py.""" + import numpy as np import phono3py diff --git a/test/phonon3/test_fc3.py b/test/phonon3/test_fc3.py index 1dab5060..65ba7533 100644 --- a/test/phonon3/test_fc3.py +++ b/test/phonon3/test_fc3.py @@ -1,4 +1,5 @@ """Tests for fc3.""" + import numpy as np import pytest diff --git a/test/phonon3/test_imag_self_energy.py b/test/phonon3/test_imag_self_energy.py index edae5771..9dfca8f6 100644 --- a/test/phonon3/test_imag_self_energy.py +++ b/test/phonon3/test_imag_self_energy.py @@ -1,4 +1,5 @@ """Test for imag_free_energy.py.""" + import numpy as np import pytest diff --git a/test/phonon3/test_interaction.py b/test/phonon3/test_interaction.py index 06da2b3b..29696fa2 100644 --- a/test/phonon3/test_interaction.py +++ b/test/phonon3/test_interaction.py @@ -1,4 +1,5 @@ """Test Interaction class.""" + from __future__ import annotations from collections.abc import Sequence diff --git a/test/phonon3/test_joint_dos.py b/test/phonon3/test_joint_dos.py index eca9a971..cb48cb31 100644 --- a/test/phonon3/test_joint_dos.py +++ b/test/phonon3/test_joint_dos.py @@ -1,4 +1,5 @@ """Tests for joint-density-of-states.""" + import numpy as np import pytest diff --git a/test/phonon3/test_real_self_energy.py b/test/phonon3/test_real_self_energy.py index c51c37d9..7eadc599 100644 --- a/test/phonon3/test_real_self_energy.py +++ b/test/phonon3/test_real_self_energy.py @@ -1,4 +1,5 @@ """Test for real_self_energy.py.""" + import numpy as np from phono3py import Phono3py diff --git a/test/phonon3/test_spectral_function.py b/test/phonon3/test_spectral_function.py index 947c2cee..6a25630b 100644 --- a/test/phonon3/test_spectral_function.py +++ b/test/phonon3/test_spectral_function.py @@ -1,4 +1,5 @@ """Test spectral_function.py.""" + import numpy as np import pytest diff --git a/test/phonon3/test_triplets.py b/test/phonon3/test_triplets.py index 9fd0d8cc..dceb62a8 100644 --- a/test/phonon3/test_triplets.py +++ b/test/phonon3/test_triplets.py @@ -1,4 +1,5 @@ """Test for triplets.py.""" + import numpy as np import pytest from phonopy import Phonopy diff --git a/test/sscha/test_sscha.py b/test/sscha/test_sscha.py index b0839bda..88388cc9 100644 --- a/test/sscha/test_sscha.py +++ b/test/sscha/test_sscha.py @@ -1,4 +1,5 @@ """Tests for SSCHA routines.""" + import numpy as np import pytest from phonopy.phonon.qpoints import QpointsPhonon