From 31c26e0d48f8987749056337f7fa19db75a4f988 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Fri, 23 Jul 2021 09:40:22 +0900 Subject: [PATCH 01/34] Update changelog. --- doc/changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changelog.md b/doc/changelog.md index 729ed487..c4dc6e08 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -9,6 +9,7 @@ This is a major version release. There are some backword-incompatible changes. is changed. 2. Most of integer array data type is changed to `dtype='int_'` from `dtype='intc'`. +3. Python 3.5 or later is required. To emulate the version 1.x behaviour in `phono3py` command, try `--v1` option. To emurate the version 1.x behaviour in API, From 8a77869432418395654fc0b1c87fc2a3e7681655 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Fri, 23 Jul 2021 09:52:15 +0900 Subject: [PATCH 02/34] Update changelog. --- doc/changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changelog.md b/doc/changelog.md index c4dc6e08..80db176e 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -7,7 +7,7 @@ This is a major version release. There are some backword-incompatible changes. 1. Grid point indexing system to address grid points of q-points is changed. -2. Most of integer array data type is changed to +2. Array data types of most of the integer arrays are changed to `dtype='int_'` from `dtype='intc'`. 3. Python 3.5 or later is required. From f631789ff36f415f519008f6970b05e095cf666c Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Mon, 26 Jul 2021 18:14:59 +0900 Subject: [PATCH 03/34] Refactorings --- phono3py/api_phono3py.py | 2 +- phono3py/phonon/grid.py | 122 ++++++++++++++++++++----------- phono3py/phonon/solver.py | 57 +++++++++++---- phono3py/phonon3/conductivity.py | 2 +- phono3py/phonon3/interaction.py | 51 +++++++++---- 5 files changed, 159 insertions(+), 75 deletions(-) diff --git a/phono3py/api_phono3py.py b/phono3py/api_phono3py.py index 53df1590..3b92de64 100644 --- a/phono3py/api_phono3py.py +++ b/phono3py/api_phono3py.py @@ -1262,7 +1262,7 @@ class Phono3py(object): is_mesh_symmetry=self._is_mesh_symmetry, symmetrize_fc3q=_symmetrize_fc3q, lapack_zheev_uplo=_lapack_zheev_uplo) - self._interaction.set_nac_q_direction(nac_q_direction=nac_q_direction) + self._interaction.nac_q_direction = nac_q_direction self._init_dynamical_matrix() def set_phph_interaction(self, diff --git a/phono3py/phonon/grid.py b/phono3py/phonon/grid.py index 5520b116..b4af6bac 100644 --- a/phono3py/phonon/grid.py +++ b/phono3py/phonon/grid.py @@ -100,46 +100,18 @@ class BZGrid(object): Attributes ---------- addresses : ndarray - Integer grid address of the points in Brillouin zone including - surface. There are two types of address order by either - `store_dense_gp_map` is True or False. - shape=(np.prod(D_diag) + some on surface, 3), dtype='int_', order='C' gp_map : ndarray - Grid point mapping table containing BZ surface. There are two types of - address order by either `store_dense_gp_map` is True or False. See more - detail in `_relocate_BZ_grid_address` docstring. bzg2grg : ndarray - Grid index mapping table from BZGrid to GRgrid. - shape=(len(addresses), ), dtype='int_' grg2bzg : ndarray - Grid index mapping table from GRgrid to BZGrid. Unique one - of translationally equivalent grid points in BZGrid is chosen. - shape=(prod(D_diag), ), dtype='int_' store_dense_gp_map : bool, optional - See the detail in the docstring of `_relocate_BZ_grid_address`. rotations : ndarray - Rotation matrices for GR-grid addresses (g) defined as g'=Rg. - shape=(rotations, 3, 3), dtype='int_', order='C'. reciprocal_operations : ndarray - Reciprocal space rotation matrices in fractional coordinates defined as - q'=Rq. - shape=(rotations, 3, 3), dtype='int_', order='C'. D_diag : ndarray - This corresponds to the mesh numbers in transformed reciprocal - basis vectors. - shape=(3,), dtype='int_' P : ndarray - Left unimodular matrix after SNF: D=PAQ. - shape=(3, 3), dtype='int_', order='C' Q : ndarray - Right unimodular matrix after SNF: D=PAQ. - shape=(3, 3), dtype='int_', order='C' + QDinv : ndarray grid_matrix : ndarray - Grid generating matrix used for SNF. - shape=(3, 3), dtype='int_', order='C' microzone_lattice : ndarray - Basis vectors of microzone of GR-grid. - shape=(3, 3), dtype='double', order='C' """ @@ -217,22 +189,43 @@ class BZGrid(object): @property def D_diag(self): - """Diagonal elements of diagonal matrix after SNF: D=PAQ.""" + """Diagonal elements of diagonal matrix after SNF: D=PAQ. + + This corresponds to the mesh numbers in transformed reciprocal + basis vectors. + shape=(3,), dtype='int_' + + """ return self._D_diag @property def P(self): - """Left unimodular matrix after SNF: D=PAQ.""" + """Left unimodular matrix after SNF: D=PAQ. + + Left unimodular matrix after SNF: D=PAQ. + shape=(3, 3), dtype='int_', order='C'. + + """ return self._P @property def Q(self): - """Right unimodular matrix after SNF: D=PAQ.""" + """Right unimodular matrix after SNF: D=PAQ. + + Right unimodular matrix after SNF: D=PAQ. + shape=(3, 3), dtype='int_', order='C'. + + """ return self._Q @property def QDinv(self): - """QD^-1.""" + """QD^-1. + + ndarray : + shape=(3, 3), dtype='double', order='C'. + + """ return self._QDinv @property @@ -245,23 +238,44 @@ class BZGrid(object): @property def grid_matrix(self): - """Grid generating matrix to be represented by SNF.""" + """Grid generating matrix to be represented by SNF. + + Grid generating matrix used for SNF. + shape=(3, 3), dtype='int_', order='C'. + + """ return self._grid_matrix @property def addresses(self): - """BZ-grid addresses.""" + """BZ-grid addresses. + + Integer grid address of the points in Brillouin zone including + surface. There are two types of address order by either + `store_dense_gp_map` is True or False. + shape=(np.prod(D_diag) + some on surface, 3), dtype='int_', order='C'. + + """ return self._addresses @property def gp_map(self): - """Definitions of grid index.""" + """Definitions of grid index. + + Grid point mapping table containing BZ surface. There are two types of + address order by either `store_dense_gp_map` is True or False. See more + detail in `_relocate_BZ_grid_address` docstring. + + """ return self._gp_map @property def bzg2grg(self): """Transform grid point indices from BZG to GRG. + Grid index mapping table from BZGrid to GRgrid. + shape=(len(addresses), ), dtype='int_'. + Equivalent to get_grid_point_from_address( self._addresses[bz_grid_index], self._D_diag) @@ -271,22 +285,42 @@ class BZGrid(object): @property def grg2bzg(self): - """Transform grid point indices from GRG to BZG.""" + """Transform grid point indices from GRG to BZG. + + Grid index mapping table from GRgrid to BZGrid. Unique one + of translationally equivalent grid points in BZGrid is chosen. + shape=(prod(D_diag), ), dtype='int_'. + + """ return self._grg2bzg @property def microzone_lattice(self): - """Basis vectors of microzone.""" + """Basis vectors of microzone. + + Basis vectors of microzone of GR-grid. + shape=(3, 3), dtype='double', order='C'. + + """ return self._microzone_lattice @property def store_dense_gp_map(self): - """Return gp_map type.""" + """Return gp_map type. + + See the detail in the docstring of `_relocate_BZ_grid_address`. + + """ return self._store_dense_gp_map @property def rotations(self): - """Return rotations.""" + """Return rotation matrices for grid points. + + Rotation matrices for GR-grid addresses (g) defined as g'=Rg. + shape=(rotations, 3, 3), dtype='int_', order='C'. + + """ return self._rotations @property @@ -296,7 +330,13 @@ class BZGrid(object): @property def reciprocal_operations(self): - """Return reciprocal rotations.""" + """Return reciprocal rotations. + + Reciprocal space rotation matrices in fractional coordinates defined as + q'=Rq. + shape=(rotations, 3, 3), dtype='int_', order='C'. + + """ return self._reciprocal_operations @property diff --git a/phono3py/phonon/solver.py b/phono3py/phonon/solver.py index 4d4ac199..9b27ef49 100644 --- a/phono3py/phonon/solver.py +++ b/phono3py/phonon/solver.py @@ -34,6 +34,7 @@ # POSSIBILITY OF SUCH DAMAGE. import numpy as np +from phonopy.units import VaspToTHz from phonopy.structure.cells import sparse_to_dense_svecs @@ -44,10 +45,31 @@ def run_phonon_solver_c(dm, grid_points, grid_address, QDinv, - frequency_conversion_factor, - nac_q_direction, # in reduced coordinates - lapack_zheev_uplo): - """Bulid and solve dynamical matrices on grid in C-API.""" + frequency_conversion_factor=VaspToTHz, + nac_q_direction=None, # in reduced coordinates + lapack_zheev_uplo='L'): + """Bulid and solve dynamical matrices on grid in C-API. + + dm : DynamicalMatrix + DynamicalMatrix instance. + frequencies, eigenvectors, phonon_done : + See Interaction.get_phonons(). + grid_points : ndarray + Grid point indices. + shape=(grid_points, ), dtype='int_' + grid_address : ndarray + See BZGrid.addresses. + QDinv : ndarray + See BZGrid.QDinv. + frequency_conversion_factor : float, optional + Frequency convertion factor that is multiplied with + sqrt or eigenvalue of dynamical matrix. Default is VaspToTHz. + nac_q_direction : array_like, optional + See Interaction.nac_q_direction. Default is None. + lapack_zheev_uplo : str, optional + 'U' or 'L' for lapack zheev solver. Default is 'L'. + + """ import phono3py._phononmod as phononmod (svecs, @@ -59,12 +81,6 @@ def run_phonon_solver_c(dm, nac_factor, dielectric) = _extract_params(dm) - if dm.primitive.store_dense_svecs: - _svecs = svecs - _multi = multi - else: - _svecs, _multi = sparse_to_dense_svecs(svecs, multi) - if dm.is_nac() and dm.nac_method == 'gonze': gonze_nac_dataset = dm.Gonze_nac_dataset if gonze_nac_dataset[0] is None: @@ -85,6 +101,9 @@ def run_phonon_solver_c(dm, assert grid_points.dtype == 'int_' assert grid_points.flags.c_contiguous + assert QDinv.dtype == 'double' + assert QDinv.flags.c_contiguous + assert lapack_zheev_uplo in ('L', 'U') fc_p2s, fc_s2p = _get_fc_elements_mapping(dm, fc) phononmod.phonons_at_gridpoints( @@ -93,10 +112,10 @@ def run_phonon_solver_c(dm, phonon_done, grid_points, grid_address, - np.array(QDinv, dtype='double', order='C'), + QDinv, fc, - _svecs, - _multi, + svecs, + multi, positions, masses, fc_p2s, @@ -137,7 +156,13 @@ def run_phonon_solver_py(grid_point, def _extract_params(dm): - svecs, multiplicity = dm.primitive.get_smallest_vectors() + svecs, multi = dm.primitive.get_smallest_vectors() + if dm.primitive.store_dense_svecs: + _svecs = svecs + _multi = multi + else: + _svecs, _multi = sparse_to_dense_svecs(svecs, multi) + masses = np.array(dm.primitive.masses, dtype='double') rec_lattice = np.array(np.linalg.inv(dm.primitive.cell), dtype='double', order='C') @@ -151,8 +176,8 @@ def _extract_params(dm): nac_factor = 0 dielectric = None - return (svecs, - multiplicity, + return (_svecs, + _multi, masses, rec_lattice, positions, diff --git a/phono3py/phonon3/conductivity.py b/phono3py/phonon3/conductivity.py index d5bc5028..f8a9d3cd 100644 --- a/phono3py/phonon3/conductivity.py +++ b/phono3py/phonon3/conductivity.py @@ -507,7 +507,7 @@ class Conductivity(object): raise NotImplementedError() def _set_grid_properties(self, grid_points): - self._pp.set_nac_q_direction(nac_q_direction=None) + self._pp.nac_q_direction = None if grid_points is not None: # Specify grid points self._grid_points = grid_points diff --git a/phono3py/phonon3/interaction.py b/phono3py/phonon3/interaction.py index 5ac45e0d..75e250c3 100644 --- a/phono3py/phonon3/interaction.py +++ b/phono3py/phonon3/interaction.py @@ -295,9 +295,25 @@ class Interaction(object): @property def nac_q_direction(self): - """Return q-direction used for NAC at q->0.""" + """Return q-direction used for NAC at q->0. + + Direction of q-vector watching from Gamma point used for + non-analytical term correction. This is effective only at q=0 + (physically q->0). The direction is given in crystallographic + (fractional) coordinates. + shape=(3,), dtype='double'. + Default value is None, which means this feature is not used. + + """ return self._nac_q_direction + @nac_q_direction.setter + def nac_q_direction(self, nac_q_direction): + if nac_q_direction is None: + self._nac_q_direction = None + else: + self._nac_q_direction = np.array(nac_q_direction, dtype='double') + def get_nac_q_direction(self): """Return q-direction used for NAC at q->0.""" warnings.warn("Use attribute, Interaction.nac_q_direction " @@ -305,6 +321,13 @@ class Interaction(object): DeprecationWarning) return self.nac_q_direction + def set_nac_q_direction(self, nac_q_direction=None): + """Set NAC q-point direction valid at q->0.""" + warnings.warn("Use attribute, Interaction.nac_q_direction " + "instead of Interaction.set_nac_q_direction().", + DeprecationWarning) + self.nac_q_direction = nac_q_direction + @property def zero_value_positions(self): """Return zero ph-ph interaction elements information. @@ -514,11 +537,6 @@ class Interaction(object): print(" But this frequency is forced to be zero.") print("=" * 61) - def set_nac_q_direction(self, nac_q_direction=None): - """Set NAC q-point direction valid at q->0.""" - if nac_q_direction is not None: - self._nac_q_direction = np.array(nac_q_direction, dtype='double') - def set_phonon_data(self, frequencies, eigenvectors, bz_grid_addresses): """Set phonons on grid.""" if bz_grid_addresses.shape != self._bz_grid.addresses.shape: @@ -730,16 +748,17 @@ class Interaction(object): self._g_zero = g_zero def _run_phonon_solver_c(self, grid_points): - run_phonon_solver_c(self._dm, - self._frequencies, - self._eigenvectors, - self._phonon_done, - grid_points, - self._bz_grid.addresses, - self._bz_grid.QDinv, - self._frequency_factor_to_THz, - self._nac_q_direction, - self._lapack_zheev_uplo) + run_phonon_solver_c( + self._dm, + self._frequencies, + self._eigenvectors, + self._phonon_done, + grid_points, + self._bz_grid.addresses, + self._bz_grid.QDinv, + frequency_conversion_factor=self._frequency_factor_to_THz, + nac_q_direction=self._nac_q_direction, + lapack_zheev_uplo=self._lapack_zheev_uplo) def _run_py(self): r2r = RealToReciprocal(self._fc3, From 4a54ba56553640d44129990eaeee259cb98d276d Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Tue, 27 Jul 2021 18:22:35 +0900 Subject: [PATCH 04/34] Refactoring of conductivity related classes. --- phono3py/api_phono3py.py | 1 - phono3py/phonon3/conductivity.py | 246 +++++++++++++------------ phono3py/phonon3/conductivity_LBTE.py | 70 ++++--- phono3py/phonon3/conductivity_RTA.py | 50 +++-- phono3py/phonon3/interaction.py | 45 +++-- phono3py/phonon3/real_to_reciprocal.py | 4 +- test/phonon3/test_interaction.py | 3 +- 7 files changed, 210 insertions(+), 209 deletions(-) diff --git a/phono3py/api_phono3py.py b/phono3py/api_phono3py.py index 3b92de64..8dff02e6 100644 --- a/phono3py/api_phono3py.py +++ b/phono3py/api_phono3py.py @@ -1249,7 +1249,6 @@ class Phono3py(object): _lapack_zheev_uplo = self._lapack_zheev_uplo self._interaction = Interaction( - self._supercell, self._primitive, self._bz_grid, self._primitive_symmetry, diff --git a/phono3py/phonon3/conductivity.py b/phono3py/phonon3/conductivity.py index f8a9d3cd..da5ab112 100644 --- a/phono3py/phonon3/conductivity.py +++ b/phono3py/phonon3/conductivity.py @@ -90,7 +90,93 @@ def write_pp(conductivity, compression=compression) -class Conductivity(object): +class ConductivityBase: + """Base class of Conductivity classes.""" + + def __init__(self, + interaction, + grid_points=None, + is_kappa_star=True, + gv_delta_q=None): + """Init method. + + interaction : Interaction + Interaction class instance. + grid_points : array_like or None, optional + Grid point indices. When None, ir-grid points are searched + internally. Default is None. + shape=(grid_points, ), dtype='int_'. + is_kappa_star : bool, optional + When True, reciprocal space symmetry is used to calculate + lattice thermal conductivity. This calculation is peformed + iterating over specific grid points. With `is_kappa_star=True` + and `grid_points=None`, ir-grid points are used for the iteration. + Default is True. + gv_delta_q : float, optional + See phonopy's GroupVelocity class. Default is None. + + """ + self._pp = interaction + self._is_kappa_star = is_kappa_star + + self._rotations_cartesian = None + self._point_operations = None + self._set_point_operations() + + self._grid_points = None + self._grid_weights = None + self._ir_grid_points = None + self._ir_grid_weights = None + self._set_grid_properties(grid_points) + + self._qpoints = np.array( + np.dot(self._pp.bz_grid.addresses[self._grid_points], + self._pp.bz_grid.QDinv.T), dtype='double', order='C') + + self._gv_obj = GroupVelocity( + self._pp.dynamical_matrix, + q_length=gv_delta_q, + symmetry=self._pp.primitive_symmetry, + frequency_factor_to_THz=self._pp.frequency_factor_to_THz) + + def _set_point_operations(self): + if not self._is_kappa_star: + self._point_operations = np.array( + [np.eye(3, dtype='int_')], dtype='int_', order='C') + else: + self._point_operations = np.array( + self._pp.bz_grid.reciprocal_operations, + dtype='int_', order='C') + rec_lat = np.linalg.inv(self._pp.primitive.cell) + self._rotations_cartesian = np.array( + [similarity_transformation(rec_lat, r) + for r in self._point_operations], dtype='double', order='C') + + def _set_grid_properties(self, grid_points): + if grid_points is not None: # Specify grid points + self._grid_points = grid_points + (self._ir_grid_points, + self._ir_grid_weights) = self._get_ir_grid_points() + elif not self._is_kappa_star: # All grid points + self._grid_points = self._pp.bz_grid.grg2bzg + self._grid_weights = np.ones(len(self._grid_points), dtype='int_') + self._ir_grid_points = self._grid_points + self._ir_grid_weights = self._grid_weights + else: # Automatic sampling + self._grid_points, self._grid_weights = self._get_ir_grid_points() + self._ir_grid_points = self._grid_points + self._ir_grid_weights = self._grid_weights + + def _get_ir_grid_points(self): + """Find irreducible grid points.""" + ir_grid_points, ir_grid_weights, _ = get_ir_grid_points( + self._pp.bz_grid) + ir_grid_points = np.array( + self._pp.bz_grid.grg2bzg[ir_grid_points], dtype='int_') + return ir_grid_points, ir_grid_weights + + +class Conductivity(ConductivityBase): """Thermal conductivity base class.""" def __init__(self, @@ -107,52 +193,43 @@ class Conductivity(object): is_full_pp=False, log_level=0): """Init method.""" + self._pp = None + self._is_kappa_star = None + self._grid_points = None + self._grid_weights = None + self._ir_grid_points = None + self._ir_grid_weights = None + self._qpoints = None + self._point_operations = None + self._gv_obj = None + + super().__init__(interaction, + grid_points=grid_points, + is_kappa_star=is_kappa_star, + gv_delta_q=gv_delta_q) + + self._is_full_pp = is_full_pp + self._log_level = log_level + + self._grid_point_count = 0 if sigmas is None: self._sigmas = [] else: self._sigmas = sigmas self._sigma_cutoff = sigma_cutoff - self._pp = interaction - self._is_full_pp = is_full_pp self._collision = None # has to be set derived class if temperatures is None: self._temperatures = None else: self._temperatures = np.array(temperatures, dtype='double') - self._is_kappa_star = is_kappa_star - self._gv_delta_q = gv_delta_q - self._log_level = log_level - self._primitive = self._pp.primitive - self._dm = self._pp.dynamical_matrix - self._frequency_factor_to_THz = self._pp.frequency_factor_to_THz - self._cutoff_frequency = self._pp.cutoff_frequency self._boundary_mfp = boundary_mfp - if not self._is_kappa_star: - self._point_operations = np.array([np.eye(3, dtype='int_')], - dtype='int_', order='C') - else: - self._point_operations = np.array( - self._pp.bz_grid.reciprocal_operations, - dtype='int_', order='C') - rec_lat = np.linalg.inv(self._primitive.cell) - self._rotations_cartesian = np.array( - [similarity_transformation(rec_lat, r) - for r in self._point_operations], dtype='double', order='C') - - self._grid_points = None - self._grid_weights = None - self._ir_grid_points = None - self._ir_grid_weights = None - self._bz_grid = self._pp.bz_grid - self._read_gamma = False self._read_gamma_iso = False self._kappa = None self._mode_kappa = None - self._frequencies = None self._cv = None self._gv = None self._gv_sum2 = None @@ -160,9 +237,16 @@ class Conductivity(object): self._gamma_iso = None self._num_sampling_grid_points = 0 - volume = self._primitive.volume + volume = self._pp.primitive.volume self._conversion_factor = unit_to_WmK / volume + self._pp.nac_q_direction = None + (self._frequencies, + self._eigenvectors, + self._phonon_done) = self._pp.get_phonons() + if (self._phonon_done == 0).any(): + self._pp.run_phonon_solver() + self._isotope = None self._mass_variances = None self._is_isotope = is_isotope @@ -171,32 +255,6 @@ class Conductivity(object): if self._is_isotope: self._set_isotope(mass_variances) - self._grid_point_count = None - self._set_grid_properties(grid_points) - - if (self._dm.is_nac() and - self._dm.nac_method == 'gonze' and - self._gv_delta_q is None): # noqa E129 - self._gv_delta_q = 1e-5 - if self._log_level: - msg = "Group velocity calculation:\n" - text = ("Analytical derivative of dynamical matrix is not " - "implemented for NAC by Gonze et al. Instead " - "numerical derivative of it is used with dq=1e-5 " - "for group velocity calculation.") - msg += textwrap.fill(text, - initial_indent=" ", - subsequent_indent=" ", - width=70) - print(msg) - self._gv_obj = GroupVelocity( - self._dm, - q_length=self._gv_delta_q, - symmetry=self._pp.primitive_symmetry, - frequency_factor_to_THz=self._frequency_factor_to_THz) - # gv_delta_q may be changed. - self._gv_delta_q = self._gv_obj.get_q_length() - def __iter__(self): """Calculate mode kappa at each grid point.""" return self @@ -506,36 +564,8 @@ class Conductivity(object): """Must be implementated in the inherited class.""" raise NotImplementedError() - def _set_grid_properties(self, grid_points): - self._pp.nac_q_direction = None - - if grid_points is not None: # Specify grid points - self._grid_points = grid_points - (self._ir_grid_points, - self._ir_grid_weights) = self._get_ir_grid_points() - elif not self._is_kappa_star: # All grid points - self._grid_points = self._bz_grid.grg2bzg - self._grid_weights = np.ones(len(self._grid_points), dtype='int_') - self._ir_grid_points = self._grid_points - self._ir_grid_weights = self._grid_weights - else: # Automatic sampling - self._grid_points, self._grid_weights = self._get_ir_grid_points() - self._ir_grid_points = self._grid_points - self._ir_grid_weights = self._grid_weights - - self._qpoints = np.array( - np.dot(self._bz_grid.addresses[self._grid_points], - self._bz_grid.QDinv.T), dtype='double', order='C') - self._grid_point_count = 0 - (self._frequencies, - self._eigenvectors, - phonon_done) = self._pp.get_phonons() - if (phonon_done == 0).any(): - self._pp.run_phonon_solver() - def _get_gamma_isotope_at_sigmas(self, i): gamma_iso = [] - pp_freqs, pp_eigvecs, pp_phonon_done = self._pp.get_phonons() for j, sigma in enumerate(self._sigmas): if self._log_level: @@ -547,10 +577,10 @@ class Conductivity(object): print(text) self._isotope.sigma = sigma - self._isotope.set_phonons(pp_freqs, - pp_eigvecs, - pp_phonon_done, - dm=self._dm) + self._isotope.set_phonons(self._frequencies, + self._eigenvectors, + self._phonon_done, + dm=self._pp.dynamical_matrix) gp = self._grid_points[i] self._isotope.set_grid_point(gp) self._isotope.run() @@ -558,14 +588,6 @@ class Conductivity(object): return np.array(gamma_iso, dtype='double', order='C') - def _get_ir_grid_points(self): - """Find irreducible grid points.""" - ir_grid_points, ir_grid_weights, _ = get_ir_grid_points(self._bz_grid) - ir_grid_points = np.array( - self._bz_grid.grg2bzg[ir_grid_points], dtype='int_') - - return ir_grid_points, ir_grid_weights - def _set_isotope(self, mass_variances): if mass_variances is True: mv = None @@ -573,12 +595,12 @@ class Conductivity(object): mv = mass_variances self._isotope = Isotope( self._pp.mesh_numbers, - self._primitive, + self._pp.primitive, mass_variances=mv, - bz_grid=self._bz_grid, - frequency_factor_to_THz=self._frequency_factor_to_THz, + bz_grid=self._pp.bz_grid, + frequency_factor_to_THz=self._pp.frequency_factor_to_THz, symprec=self._pp.primitive_symmetry.tolerance, - cutoff_frequency=self._cutoff_frequency, + cutoff_frequency=self._pp.cutoff_frequency, lapack_zheev_uplo=self._pp.lapack_zheev_uplo) self._mass_variances = self._isotope.mass_variances @@ -588,7 +610,7 @@ class Conductivity(object): freqs = self._frequencies[grid_point][self._pp.band_indices] self._cv[:, i_data, :] = self._get_cv(freqs) self._gv_obj.run([self._qpoints[i_irgp], ]) - gv = self._gv_obj.get_group_velocity()[0, self._pp.band_indices, :] + gv = self._gv_obj.group_velocities[0, self._pp.band_indices, :] self._gv[i_data] = gv def _get_cv(self, freqs): @@ -597,7 +619,7 @@ class Conductivity(object): # Otherwise just set 0. for i, f in enumerate(freqs): finite_t = (self._temperatures > f / 100) - if f > self._cutoff_frequency: + if f > self._pp.cutoff_frequency: cv[:, i] = np.where( finite_t, get_mode_cv( np.where(finite_t, self._temperatures, 10000), @@ -622,11 +644,11 @@ class Conductivity(object): if self._is_kappa_star: rotation_map = get_grid_points_by_rotations( self._grid_points[i_irgp], - self._bz_grid) + self._pp.bz_grid) else: rotation_map = get_grid_points_by_rotations( self._grid_points[i_irgp], - self._bz_grid, + self._pp.bz_grid, reciprocal_rotations=self._point_operations) gv = self._gv[i_data] @@ -662,24 +684,10 @@ class Conductivity(object): main_diagonal += self._gamma_iso[j, i] if self._boundary_mfp is not None: main_diagonal += self._get_boundary_scattering(i) - - # num_band = len(self._primitive) * 3 - # if self._boundary_mfp is not None: - # for l in range(num_band): - # # Acoustic modes at Gamma are avoided. - # if i == 0 and l < 3: - # continue - # gv_norm = np.linalg.norm(self._gv[i, l]) - # mean_free_path = (gv_norm * Angstrom * 1e6 / - # (4 * np.pi * main_diagonal[l])) - # if mean_free_path > self._boundary_mfp: - # main_diagonal[l] = ( - # gv_norm / (4 * np.pi * self._boundary_mfp)) - return main_diagonal def _get_boundary_scattering(self, i): - num_band = len(self._primitive) * 3 + num_band = len(self._pp.primitive) * 3 g_boundary = np.zeros(num_band, dtype='double') for ll in range(num_band): g_boundary[ll] = (np.linalg.norm(self._gv[i, ll]) * Angstrom * 1e6 diff --git a/phono3py/phonon3/conductivity_LBTE.py b/phono3py/phonon3/conductivity_LBTE.py index b3961988..77c4523b 100644 --- a/phono3py/phonon3/conductivity_LBTE.py +++ b/phono3py/phonon3/conductivity_LBTE.py @@ -64,7 +64,7 @@ def get_thermal_conductivity_LBTE( solve_collective_phonon=False, is_reducible_collision_matrix=False, is_kappa_star=True, - gv_delta_q=1e-4, # for group velocity + gv_delta_q=None, is_full_pp=False, pinv_cutoff=1.0e-8, pinv_solver=0, # default: dsyev in lapacke @@ -791,17 +791,13 @@ class Conductivity_LBTE(Conductivity): log_level=0): """Init method.""" self._pp = None + self._gv_obj = None self._temperatures = None self._sigmas = None self._sigma_cutoff = None self._is_kappa_star = None - self._gv_delta_q = None self._is_full_pp = None self._log_level = None - self._primitive = None - self._dm = None - self._frequency_factor_to_THz = None - self._cutoff_frequency = None self._boundary_mfp = None self._point_operations = None @@ -809,7 +805,6 @@ class Conductivity_LBTE(Conductivity): self._grid_points = None self._grid_weights = None - self._bz_grid = None self._ir_grid_points = None self._ir_grid_weights = None @@ -919,7 +914,7 @@ class Conductivity_LBTE(Conductivity): def get_frequencies_all(self): """Return phonon frequencies on GR-grid.""" - return self._frequencies[self._bz_grid.grg2bzg] + return self._frequencies[self._pp.bz_grid.grg2bzg] def get_kappa_RTA(self): """Return RTA lattice thermal conductivity.""" @@ -953,7 +948,7 @@ class Conductivity_LBTE(Conductivity): self._set_collision_matrix_at_sigmas(i) if self._is_reducible_collision_matrix: - i_data = self._bz_grid.bzg2grg[gp] + i_data = self._pp.bz_grid.bzg2grg[gp] else: i_data = i self._set_harmonic_properties(i, i_data) @@ -969,7 +964,7 @@ class Conductivity_LBTE(Conductivity): def _allocate_values(self): """Allocate arrays.""" num_band0 = len(self._pp.band_indices) - num_band = len(self._primitive) * 3 + num_band = len(self._pp.primitive) * 3 num_temp = len(self._temperatures) if self._is_reducible_collision_matrix: @@ -1060,7 +1055,7 @@ class Conductivity_LBTE(Conductivity): for i, ir_gp in enumerate(self._ir_grid_points): self._rot_grid_points[i] = get_grid_points_by_rotations( ir_gp, - self._bz_grid) + self._pp.bz_grid) self._collision = CollisionMatrix( self._pp, rotations_cartesian=self._rotations_cartesian, @@ -1137,7 +1132,7 @@ class Conductivity_LBTE(Conductivity): self._collision.run() if self._all_grid_points: if self._is_reducible_collision_matrix: - i_data = self._bz_grid.bzg2grg[self._grid_points[i]] + i_data = self._pp.bz_grid.bzg2grg[self._grid_points[i]] else: i_data = i else: @@ -1159,11 +1154,12 @@ class Conductivity_LBTE(Conductivity): # Ir-grid points and rot_grid_points in generalized regular # grid ir_gr_grid_points = np.array( - self._bz_grid.bzg2grg[self._ir_grid_points], dtype='int_') + self._pp.bz_grid.bzg2grg[self._ir_grid_points], + dtype='int_') for i in range(num_mesh_points): - rot_grid_points[:, i] = self._bz_grid.bzg2grg[ - get_grid_points_by_rotations(self._bz_grid.grg2bzg[i], - self._bz_grid)] + rot_grid_points[:, i] = self._pp.bz_grid.bzg2grg[ + get_grid_points_by_rotations( + self._pp.bz_grid.grg2bzg[i], self._pp.bz_grid)] self._expand_collisions(ir_gr_grid_points, rot_grid_points) self._expand_local_values(ir_gr_grid_points, rot_grid_points) self._combine_reducible_collisions() @@ -1221,7 +1217,7 @@ class Conductivity_LBTE(Conductivity): def _combine_collisions(self): """Include diagonal elements into collision matrix.""" - num_band = len(self._primitive) * 3 + num_band = len(self._pp.primitive) * 3 for j, k in list(np.ndindex( (len(self._sigmas), len(self._temperatures)))): for i, ir_gp in enumerate(self._ir_grid_points): @@ -1237,7 +1233,7 @@ class Conductivity_LBTE(Conductivity): def _combine_reducible_collisions(self): """Include diagonal elements into collision matrix.""" - num_band = len(self._primitive) * 3 + num_band = len(self._pp.primitive) * 3 num_mesh_points = np.prod(self._pp.mesh_numbers) for j, k in list( @@ -1391,7 +1387,7 @@ class Conductivity_LBTE(Conductivity): bi_set.append(j) if self._is_reducible_collision_matrix: - i_data = self._bz_grid.bzg2grg[gp] + i_data = self._pp.bz_grid.bzg2grg[gp] sum_col = (col_mat[:, :, i_data, bi_set, :, :].sum(axis=2) / len(bi_set)) for j in bi_set: @@ -1412,7 +1408,7 @@ class Conductivity_LBTE(Conductivity): if j in dset: bi_set.append(j) if self._is_reducible_collision_matrix: - i_data = self._bz_grid.bzg2grg[gp] + i_data = self._pp.bz_grid.bzg2grg[gp] sum_col = (col_mat[:, :, :, :, i_data, bi_set].sum(axis=4) / len(bi_set)) for j in bi_set: @@ -1430,15 +1426,15 @@ class Conductivity_LBTE(Conductivity): def _get_X(self, i_temp, weights, gv): """Calculate X in Chaput's paper.""" - num_band = len(self._primitive) * 3 + num_band = len(self._pp.primitive) * 3 X = gv.copy() if self._is_reducible_collision_matrix: - freqs = self._frequencies[self._bz_grid.grg2bzg] + freqs = self._frequencies[self._pp.bz_grid.grg2bzg] else: freqs = self._frequencies[self._ir_grid_points] t = self._temperatures[i_temp] - sinh = np.where(freqs > self._cutoff_frequency, + sinh = np.where(freqs > self._pp.cutoff_frequency, np.sinh(freqs * THzToEv / (2 * Kb * t)), -1.0) inv_sinh = np.where(sinh > 0, 1.0 / sinh, 0) @@ -1457,7 +1453,7 @@ class Conductivity_LBTE(Conductivity): def _get_Y(self, i_sigma, i_temp, weights, X): r"""Calculate Y = (\Omega^-1, X).""" solver = _select_solver(self._pinv_solver) - num_band = len(self._primitive) * 3 + num_band = len(self._pp.primitive) * 3 if self._is_reducible_collision_matrix: num_grid_points = np.prod(self._pp.mesh_numbers) @@ -1520,7 +1516,7 @@ class Conductivity_LBTE(Conductivity): Therefore Y is divided by 2. """ - num_band = len(self._primitive) * 3 + num_band = len(self._pp.primitive) * 3 self._f_vectors[:] = ((Y / 2).reshape(num_grid_points, num_band * 3).T / weights).T.reshape(self._f_vectors.shape) @@ -1630,7 +1626,7 @@ class Conductivity_LBTE(Conductivity): """ N = self._num_sampling_grid_points - num_band = len(self._primitive) * 3 + num_band = len(self._pp.primitive) * 3 X = self._get_X(i_temp, weights, self._gv) Y = np.zeros_like(X) num_ir_grid_points = len(self._ir_grid_points) @@ -1639,7 +1635,7 @@ class Conductivity_LBTE(Conductivity): g = self._get_main_diagonal(i, i_sigma, i_temp) frequencies = self._frequencies[gp] for j, f in enumerate(frequencies): - if f > self._cutoff_frequency: + if f > self._pp.cutoff_frequency: i_mode = i * num_band + j old_settings = np.seterr(all='raise') try: @@ -1673,7 +1669,7 @@ class Conductivity_LBTE(Conductivity): """ N = self._num_sampling_grid_points - num_band = len(self._primitive) * 3 + num_band = len(self._pp.primitive) * 3 X = self._get_X(i_temp, weights, self._gv) Y = np.zeros_like(X) @@ -1685,7 +1681,7 @@ class Conductivity_LBTE(Conductivity): for gp in range(num_mesh_points): frequencies = self._frequencies[gp] for j, f in enumerate(frequencies): - if f > self._cutoff_frequency: + if f > self._pp.cutoff_frequency: i_mode = gp * num_band + j Y[i_mode, :] = X[i_mode, :] / v_diag[i_mode] # Putting self._rotations_cartesian is to symmetrize kappa. @@ -1716,7 +1712,7 @@ class Conductivity_LBTE(Conductivity): The first parameter, mode_kappa, is overwritten. """ - num_band = len(self._primitive) * 3 + num_band = len(self._pp.primitive) * 3 for i, (v_gp, f_gp) in enumerate( zip(X.reshape(num_grid_points, num_band, 3), Y.reshape(num_grid_points, num_band, 3))): @@ -1724,7 +1720,7 @@ class Conductivity_LBTE(Conductivity): for j, (v, f) in enumerate(zip(v_gp, f_gp)): # Do not consider three lowest modes at Gamma-point # It is assumed that there are no imaginary modes. - if (self._bz_grid.addresses[i] == 0).all() and j < 3: + if (self._pp.bz_grid.addresses[i] == 0).all() and j < 3: continue if rotations_cartesian is None: @@ -1753,7 +1749,7 @@ class Conductivity_LBTE(Conductivity): """ X = self._get_X(i_temp, weights, self._gv).ravel() num_ir_grid_points = len(self._ir_grid_points) - num_band = len(self._primitive) * 3 + num_band = len(self._pp.primitive) * 3 size = num_ir_grid_points * num_band * 3 v = self._collision_matrix[i_sigma, i_temp].reshape(size, size) solver = _select_solver(self._pinv_solver) @@ -1823,7 +1819,7 @@ class Conductivity_LBTE(Conductivity): gp = self._grid_points[i] frequencies = self._frequencies[gp] if self._is_reducible_collision_matrix: - gv = self._gv[self._bz_grid.bzg2grg[gp]] + gv = self._gv[self._pp.bz_grid.bzg2grg[gp]] else: gv = self._gv[i] if self._is_full_pp: @@ -1832,10 +1828,10 @@ class Conductivity_LBTE(Conductivity): else: text = "Frequency group velocity (x, y, z) |gv|" - if self._gv_delta_q is None: + if self._gv_obj.q_length is None: pass else: - text += " (dq=%3.1e)" % self._gv_delta_q + text += " (dq=%3.1e)" % self._gv_obj.q_length print(text) if self._is_full_pp: for f, v, pp in zip(frequencies, gv, ave_pp): @@ -1849,7 +1845,7 @@ class Conductivity_LBTE(Conductivity): sys.stdout.flush() def _py_symmetrize_collision_matrix(self): - num_band = self._primitive.get_number_of_atoms() * 3 + num_band = len(self._pp.primitive) * 3 num_ir_grid_points = len(self._ir_grid_points) for i in range(num_ir_grid_points): for j in range(num_band): @@ -1867,7 +1863,7 @@ class Conductivity_LBTE(Conductivity): self._collision_matrix[:, :, ll, m, n, i, j, k] = sym_val def _py_symmetrize_collision_matrix_no_kappa_stars(self): - num_band = self._primitive.get_number_of_atoms() * 3 + num_band = len(self._pp.primitive) * 3 num_ir_grid_points = len(self._ir_grid_points) for i in range(num_ir_grid_points): for j in range(num_band): diff --git a/phono3py/phonon3/conductivity_RTA.py b/phono3py/phonon3/conductivity_RTA.py index 6b925e16..202b66ad 100644 --- a/phono3py/phonon3/conductivity_RTA.py +++ b/phono3py/phonon3/conductivity_RTA.py @@ -59,7 +59,7 @@ def get_thermal_conductivity_RTA( use_ave_pp=False, gamma_unit_conversion=None, is_kappa_star=True, - gv_delta_q=1e-4, + gv_delta_q=None, is_full_pp=False, write_gamma=False, read_gamma=False, @@ -494,20 +494,16 @@ class Conductivity_RTA(Conductivity): log_level=0): """Init method.""" self._pp = None + self._gv_obj = None self._temperatures = None self._sigmas = None self._sigma_cutoff = None self._is_kappa_star = None - self._gv_delta_q = None self._is_full_pp = None self._is_N_U = is_N_U self._is_gamma_detail = is_gamma_detail self._is_frequency_shift_by_bubble = is_frequency_shift_by_bubble self._log_level = None - self._primitive = None - self._dm = None - self._frequency_factor_to_THz = None - self._cutoff_frequency = None self._boundary_mfp = None self._point_operations = None @@ -515,7 +511,6 @@ class Conductivity_RTA(Conductivity): self._grid_points = None self._grid_weights = None - self._bz_grid = None self._read_gamma = False self._read_gamma_iso = False @@ -567,7 +562,7 @@ class Conductivity_RTA(Conductivity): def set_kappa_at_sigmas(self): """Calculate kappa from ph-ph interaction results.""" - num_band = len(self._primitive) * 3 + num_band = len(self._pp.primitive) * 3 for i, grid_point in enumerate(self._grid_points): cv = self._cv[:, i, :] gp = self._grid_points[i] @@ -578,7 +573,7 @@ class Conductivity_RTA(Conductivity): for k in range(len(self._temperatures)): g_sum = self._get_main_diagonal(i, j, k) for ll in range(num_band): - if frequencies[ll] < self._cutoff_frequency: + if frequencies[ll] < self._pp.cutoff_frequency: self._num_ignored_phonon_modes[j, k] += 1 continue @@ -780,8 +775,8 @@ class Conductivity_RTA(Conductivity): """Calculate gamma without storing ph-ph interaction strength. `svecs` and `multi` below must not be simply replaced by - `self._primitive.get_smallest_vectors()` because they must be in dense - format as always so in Interaction class instance. + `self._pp.primitive.get_smallest_vectors()` because they must be in + dense format as always so in Interaction class instance. `p2s`, `s2p`, and `masses` have to be also given from Interaction class instance. @@ -797,7 +792,7 @@ class Conductivity_RTA(Conductivity): symmetrize_fc3_q = 0 if None in self._sigmas: - thm = TetrahedronMethod(self._bz_grid.microzone_lattice) + thm = TetrahedronMethod(self._pp.bz_grid.microzone_lattice) # It is assumed that self._sigmas = [None]. for j, sigma in enumerate(self._sigmas): @@ -814,17 +809,18 @@ class Conductivity_RTA(Conductivity): if sigma is None: phono3c.pp_collision( collisions, - np.array(np.dot(thm.get_tetrahedra(), self._bz_grid.P.T), - dtype='int_', order='C'), + np.array( + np.dot(thm.get_tetrahedra(), self._pp.bz_grid.P.T), + dtype='int_', order='C'), self._frequencies, self._eigenvectors, triplets_at_q, weights_at_q, - self._bz_grid.addresses, - self._bz_grid.gp_map, - self._bz_grid.store_dense_gp_map * 1 + 1, - self._bz_grid.D_diag, - self._bz_grid.Q, + self._pp.bz_grid.addresses, + self._pp.bz_grid.gp_map, + self._pp.bz_grid.store_dense_gp_map * 1 + 1, + self._pp.bz_grid.D_diag, + self._pp.bz_grid.Q, fc3, svecs, multi, @@ -835,7 +831,7 @@ class Conductivity_RTA(Conductivity): self._temperatures, self._is_N_U * 1, symmetrize_fc3_q, - self._cutoff_frequency) + self._pp.cutoff_frequency) else: if self._sigma_cutoff is None: sigma_cutoff = -1 @@ -848,9 +844,9 @@ class Conductivity_RTA(Conductivity): self._eigenvectors, triplets_at_q, weights_at_q, - self._bz_grid.addresses, - self._bz_grid.D_diag, - self._bz_grid.Q, + self._pp.bz_grid.addresses, + self._pp.bz_grid.D_diag, + self._pp.bz_grid.Q, fc3, svecs, multi, @@ -861,7 +857,7 @@ class Conductivity_RTA(Conductivity): self._temperatures, self._is_N_U * 1, symmetrize_fc3_q, - self._cutoff_frequency) + self._pp.cutoff_frequency) col_unit_conv = self._collision.get_unit_conversion_factor() pp_unit_conv = self._pp.get_unit_conversion_factor() if self._is_N_U: @@ -913,7 +909,7 @@ class Conductivity_RTA(Conductivity): (f, v[0], v[1], v[2], np.linalg.norm(v))) def _show_log_values_on_kstar(self, frequencies, gv, ave_pp, gp, q): - rotation_map = get_grid_points_by_rotations(gp, self._bz_grid) + rotation_map = get_grid_points_by_rotations(gp, self._pp.bz_grid) for i, j in enumerate(np.unique(rotation_map)): for k, (rot, rot_c) in enumerate(zip( self._point_operations, self._rotations_cartesian)): @@ -941,8 +937,8 @@ class Conductivity_RTA(Conductivity): text = "Frequency group velocity (x, y, z) |gv| Pqj" else: text = "Frequency group velocity (x, y, z) |gv|" - if self._gv_delta_q is None: + if self._gv_obj.q_length is None: pass else: - text += " (dq=%3.1e)" % self._gv_delta_q + text += " (dq=%3.1e)" % self._gv_obj.q_length print(text) diff --git a/phono3py/phonon3/interaction.py b/phono3py/phonon3/interaction.py index 75e250c3..93d234a5 100644 --- a/phono3py/phonon3/interaction.py +++ b/phono3py/phonon3/interaction.py @@ -34,13 +34,15 @@ # POSSIBILITY OF SUCH DAMAGE. import warnings +from typing import Union import numpy as np from phonopy.harmonic.dynamical_matrix import get_dynamical_matrix -from phonopy.structure.cells import sparse_to_dense_svecs +from phonopy.structure.cells import Primitive, sparse_to_dense_svecs +from phonopy.structure.symmetry import Symmetry from phonopy.units import VaspToTHz, Hbar, EV, Angstrom, THz, AMU from phonopy.structure.cells import compute_all_sg_permutations from phono3py.phonon.grid import ( - get_ir_grid_points, get_grid_points_by_rotations) + get_ir_grid_points, get_grid_points_by_rotations, BZGrid) from phono3py.phonon.solver import run_phonon_solver_c, run_phonon_solver_py from phono3py.phonon3.real_to_reciprocal import RealToReciprocal from phono3py.phonon3.reciprocal_to_normal import ReciprocalToNormal @@ -59,13 +61,30 @@ class Interaction(object): 2) set_grid_point 3) run + Attributes + ---------- + interaction_strength + mesh_numbers + is_mesh_symmetry + fc3 + dynamical_matrix + primitive + primitive_symmetry + bz_grid + band_indices + nac_params + nac_q_direction + zero_value_positions + frequency_factor_to_THz + lapack_zheev_uplo + cutoff_frequency + """ def __init__(self, - supercell, - primitive, - bz_grid, - primitive_symmetry, + primitive: Primitive, + bz_grid: BZGrid, + primitive_symmetry: Symmetry, fc3=None, band_indices=None, constant_averaged_interaction=None, @@ -77,7 +96,6 @@ class Interaction(object): cutoff_frequency=None, lapack_zheev_uplo='L'): """Init method.""" - self._supercell = supercell self._primitive = primitive self._bz_grid = bz_grid self._primitive_symmetry = primitive_symmetry @@ -245,18 +263,6 @@ class Interaction(object): """Return Symmetry class instance of primitive cell.""" return self._primitive_symmetry - @property - def supercell(self): - """Return Supercell class instance.""" - return self._supercell - - def get_supercell(self): - """Return Supercell class instance.""" - warnings.warn("Use attribute, Interaction.supercell " - "instead of Interaction.get_supercell().", - DeprecationWarning) - return self.supercell - def get_triplets_at_q(self): """Return grid point triplets information.""" return (self._triplets_at_q, @@ -762,7 +768,6 @@ class Interaction(object): def _run_py(self): r2r = RealToReciprocal(self._fc3, - self._supercell, self._primitive, self.mesh_numbers, symprec=self._symprec) diff --git a/phono3py/phonon3/real_to_reciprocal.py b/phono3py/phonon3/real_to_reciprocal.py index 7cb6097d..9eef15cc 100644 --- a/phono3py/phonon3/real_to_reciprocal.py +++ b/phono3py/phonon3/real_to_reciprocal.py @@ -42,13 +42,11 @@ class RealToReciprocal(object): def __init__(self, fc3, - supercell, primitive, mesh, symprec=1e-5): """Init method.""" self._fc3 = fc3 - self._supercell = supercell self._primitive = primitive self._mesh = mesh self._symprec = symprec @@ -92,7 +90,7 @@ class RealToReciprocal(object): self._fc3_reciprocal[i] *= prephase def _real_to_reciprocal_elements(self, patom_indices): - num_satom = len(self._supercell) + num_satom = len(self._s2p_map) pi = patom_indices i = self._p2s_map[pi[0]] dtype = "c%d" % (np.dtype('double').itemsize * 2) diff --git a/test/phonon3/test_interaction.py b/test/phonon3/test_interaction.py index e7d9154a..409f7423 100644 --- a/test/phonon3/test_interaction.py +++ b/test/phonon3/test_interaction.py @@ -49,8 +49,7 @@ def test_interaction_RTA_AlN(aln_lda): def _get_irt(ph3, mesh): ph3.mesh_numbers = mesh - itr = Interaction(ph3.supercell, - ph3.primitive, + itr = Interaction(ph3.primitive, ph3.grid, ph3.primitive_symmetry, ph3.fc3, From 894e698a60c0aabe1950a0a212ae2e67568ca3ff Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Sun, 1 Aug 2021 12:20:51 +0900 Subject: [PATCH 05/34] Performance tuning in reciprocal to normal fc3. --- c/interaction.c | 144 +++++++++++---------- c/reciprocal_to_normal.c | 261 +++++++++++++++++++++------------------ c/reciprocal_to_normal.h | 32 +++-- 3 files changed, 239 insertions(+), 198 deletions(-) diff --git a/c/interaction.c b/c/interaction.c index cc5457cd..897609ab 100644 --- a/c/interaction.c +++ b/c/interaction.c @@ -67,7 +67,6 @@ static void real_to_normal(double *fc3_normal_squared, const long *p2s_map, const long *s2p_map, const long *band_indices, - const long num_band0, const long num_band, const double cutoff_frequency, const long triplet_index, @@ -76,8 +75,8 @@ static void real_to_normal(double *fc3_normal_squared, static void real_to_normal_sym_q(double *fc3_normal_squared, const long (*g_pos)[4], const long num_g_pos, - double * const freqs[3], - lapack_complex_double * const eigvecs[3], + double *const freqs[3], + lapack_complex_double *const eigvecs[3], const double *fc3, const long is_compact_fc3, const double q_vecs[3][3], /* q0, q1, q2 */ @@ -116,7 +115,7 @@ void itr_get_interaction(Darray *fc3_normal_squared, const double cutoff_frequency) { long openmp_per_triplets; - long (*g_pos)[4]; + long(*g_pos)[4]; long i; long num_band, num_band0, num_band_prod, num_g_pos; @@ -126,16 +125,20 @@ void itr_get_interaction(Darray *fc3_normal_squared, num_band = frequencies->dims[1]; num_band_prod = num_band0 * num_band * num_band; - if (num_triplets > num_band) { + if (num_triplets > num_band) + { openmp_per_triplets = 1; - } else { + } + else + { openmp_per_triplets = 0; } #ifdef PHPYOPENMP #pragma omp parallel for schedule(guided) private(num_g_pos, g_pos) if (openmp_per_triplets) #endif - for (i = 0; i < num_triplets; i++) { + for (i = 0; i < num_triplets; i++) + { g_pos = (long(*)[4])malloc(sizeof(long[4]) * num_band_prod); num_g_pos = ise_set_g_pos(g_pos, num_band0, @@ -143,29 +146,29 @@ void itr_get_interaction(Darray *fc3_normal_squared, g_zero + i * num_band_prod); itr_get_interaction_at_triplet( - fc3_normal_squared->data + i * num_band_prod, - num_band0, - num_band, - g_pos, - num_g_pos, - frequencies->data, - eigenvectors, - triplets[i], - bzgrid, - fc3, - is_compact_fc3, - svecs, - multi_dims, - multiplicity, - masses, - p2s_map, - s2p_map, - band_indices, - symmetrize_fc3_q, - cutoff_frequency, - i, - num_triplets, - 1 - openmp_per_triplets); + fc3_normal_squared->data + i * num_band_prod, + num_band0, + num_band, + g_pos, + num_g_pos, + frequencies->data, + eigenvectors, + triplets[i], + bzgrid, + fc3, + is_compact_fc3, + svecs, + multi_dims, + multiplicity, + masses, + p2s_map, + s2p_map, + band_indices, + symmetrize_fc3_q, + cutoff_frequency, + i, + num_triplets, + 1 - openmp_per_triplets); free(g_pos); g_pos = NULL; @@ -193,7 +196,7 @@ void itr_get_interaction_at_triplet(double *fc3_normal_squared, const long symmetrize_fc3_q, const double cutoff_frequency, const long triplet_index, /* only for print */ - const long num_triplets, /* only for print */ + const long num_triplets, /* only for print */ const long openmp_at_bands) { long j, k; @@ -201,22 +204,28 @@ void itr_get_interaction_at_triplet(double *fc3_normal_squared, lapack_complex_double *eigvecs[3]; double q_vecs[3][3]; - for (j = 0; j < 3; j++) { - for (k = 0; k < 3; k++) { + for (j = 0; j < 3; j++) + { + for (k = 0; k < 3; k++) + { q_vecs[j][k] = ((double)bzgrid->addresses[triplet[j]][k]) / bzgrid->D_diag[k]; } bzg_multiply_matrix_vector_ld3(q_vecs[j], bzgrid->Q, q_vecs[j]); } - if (symmetrize_fc3_q) { - for (j = 0; j < 3; j++) { - freqs[j] = (double*)malloc(sizeof(double) * num_band); - eigvecs[j] = (lapack_complex_double*) - malloc(sizeof(lapack_complex_double) * num_band * num_band); - for (k = 0; k < num_band; k++) { + if (symmetrize_fc3_q) + { + for (j = 0; j < 3; j++) + { + freqs[j] = (double *)malloc(sizeof(double) * num_band); + eigvecs[j] = (lapack_complex_double *) + malloc(sizeof(lapack_complex_double) * num_band * num_band); + for (k = 0; k < num_band; k++) + { freqs[j][k] = frequencies[triplet[j] * num_band + k]; } - for (k = 0; k < num_band * num_band; k++) { + for (k = 0; k < num_band * num_band; k++) + { eigvecs[j][k] = eigenvectors[triplet[j] * num_band * num_band + k]; } } @@ -241,13 +250,16 @@ void itr_get_interaction_at_triplet(double *fc3_normal_squared, triplet_index, num_triplets, openmp_at_bands); - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { free(freqs[j]); freqs[j] = NULL; free(eigvecs[j]); eigvecs[j] = NULL; } - } else { + } + else + { real_to_normal(fc3_normal_squared, g_pos, num_g_pos, @@ -267,7 +279,6 @@ void itr_get_interaction_at_triplet(double *fc3_normal_squared, p2s_map, s2p_map, band_indices, - num_band0, num_band, cutoff_frequency, triplet_index, @@ -295,7 +306,6 @@ static void real_to_normal(double *fc3_normal_squared, const long *p2s_map, const long *s2p_map, const long *band_indices, - const long num_band0, const long num_band, const double cutoff_frequency, const long triplet_index, @@ -308,8 +318,8 @@ static void real_to_normal(double *fc3_normal_squared, num_patom = num_band / 3; fc3_reciprocal = - (lapack_complex_double*)malloc(sizeof(lapack_complex_double) * - num_patom * num_patom * num_patom * 27); + (lapack_complex_double *)malloc(sizeof(lapack_complex_double) * + num_patom * num_patom * num_patom * 27); r2r_real_to_reciprocal(fc3_reciprocal, q_vecs, fc3, @@ -322,7 +332,8 @@ static void real_to_normal(double *fc3_normal_squared, openmp_at_bands); #ifdef MEASURE_R2N - if (openmp_at_bands && num_triplets > 0) { + if (openmp_at_bands && num_triplets > 0) + { printf("At triplet %d/%d (# of bands=%d):\n", triplet_index, num_triplets, num_band0); } @@ -339,7 +350,6 @@ static void real_to_normal(double *fc3_normal_squared, eigvecs2, masses, band_indices, - num_band0, num_band, cutoff_frequency, openmp_at_bands); @@ -351,8 +361,8 @@ static void real_to_normal(double *fc3_normal_squared, static void real_to_normal_sym_q(double *fc3_normal_squared, const long (*g_pos)[4], const long num_g_pos, - double * const freqs[3], - lapack_complex_double * const eigvecs[3], + double *const freqs[3], + lapack_complex_double *const eigvecs[3], const double *fc3, const long is_compact_fc3, const double q_vecs[3][3], /* q0, q1, q2 */ @@ -376,15 +386,19 @@ static void real_to_normal_sym_q(double *fc3_normal_squared, double *fc3_normal_squared_ex; fc3_normal_squared_ex = - (double*)malloc(sizeof(double) * num_band * num_band * num_band); + (double *)malloc(sizeof(double) * num_band * num_band * num_band); - for (i = 0; i < num_band0 * num_band * num_band; i++) { + for (i = 0; i < num_band0 * num_band * num_band; i++) + { fc3_normal_squared[i] = 0; } - for (i = 0; i < 6; i++) { - for (j = 0; j < 3; j ++) { - for (k = 0; k < 3; k ++) { + for (i = 0; i < 6; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < 3; k++) + { q_vecs_ex[j][k] = q_vecs[index_exchange[i][j]][k]; } } @@ -408,29 +422,31 @@ static void real_to_normal_sym_q(double *fc3_normal_squared, s2p_map, band_indices, num_band, - num_band, cutoff_frequency, triplet_index, num_triplets, openmp_at_bands); - for (j = 0; j < num_band0; j++) { - for (k = 0; k < num_band; k++) { - for (l = 0; l < num_band; l++) { + for (j = 0; j < num_band0; j++) + { + for (k = 0; k < num_band; k++) + { + for (l = 0; l < num_band; l++) + { band_ex[0] = band_indices[j]; band_ex[1] = k; band_ex[2] = l; fc3_normal_squared[j * num_band * num_band + k * num_band + l] += - fc3_normal_squared_ex[band_ex[index_exchange[i][0]] * - num_band * num_band + - band_ex[index_exchange[i][1]] * num_band + - band_ex[index_exchange[i][2]]] / 6; + fc3_normal_squared_ex[band_ex[index_exchange[i][0]] * + num_band * num_band + + band_ex[index_exchange[i][1]] * num_band + + band_ex[index_exchange[i][2]]] / + 6; } } } } free(fc3_normal_squared_ex); - } diff --git a/c/reciprocal_to_normal.c b/c/reciprocal_to_normal.c index f86e0fc8..aec1edff 100644 --- a/c/reciprocal_to_normal.c +++ b/c/reciprocal_to_normal.c @@ -42,51 +42,74 @@ #include #endif -static lapack_complex_double fc3_sum_in_reciprocal_to_normal -(const long bi0, - const long bi1, - const long bi2, - const lapack_complex_double *eigvecs0, - const lapack_complex_double *eigvecs1, - const lapack_complex_double *eigvecs2, - const lapack_complex_double *fc3_reciprocal, - const double *masses, - const long num_atom); +static double get_fc3_sum(const long bi0, + const long bi1, + const long bi2, + const double *freqs0, + const double *freqs1, + const double *freqs2, + const lapack_complex_double *e0, + const lapack_complex_double *e1, + const lapack_complex_double *e2, + const lapack_complex_double *fc3_reciprocal, + const double *inv_sqrt_masses, + const long num_atom, + const long num_band, + const double cutoff_frequency); -static double get_fc3_sum -(const long j, - const long k, - const long bi, - const double *freqs0, - const double *freqs1, - const double *freqs2, - const lapack_complex_double *eigvecs0, - const lapack_complex_double *eigvecs1, - const lapack_complex_double *eigvecs2, - const lapack_complex_double *fc3_reciprocal, - const double *masses, - const long num_atom, - const double cutoff_frequency); +static double fc3_sum_in_reciprocal_to_normal(const lapack_complex_double *e0, + const lapack_complex_double *e1, + const lapack_complex_double *e2, + const lapack_complex_double *fc3_reciprocal, + const double *inv_sqrt_masses, + const long num_atom, + const long num_band); -void reciprocal_to_normal_squared -(double *fc3_normal_squared, - const long (*g_pos)[4], - const long num_g_pos, - const lapack_complex_double *fc3_reciprocal, - const double *freqs0, - const double *freqs1, - const double *freqs2, - const lapack_complex_double *eigvecs0, - const lapack_complex_double *eigvecs1, - const lapack_complex_double *eigvecs2, - const double *masses, - const long *band_indices, - const long num_band0, - const long num_band, - const double cutoff_frequency, - const long openmp_at_bands) +void reciprocal_to_normal_squared(double *fc3_normal_squared, + const long (*g_pos)[4], + const long num_g_pos, + const lapack_complex_double *fc3_reciprocal, + const double *freqs0, + const double *freqs1, + const double *freqs2, + const lapack_complex_double *eigvecs0, + const lapack_complex_double *eigvecs1, + const lapack_complex_double *eigvecs2, + const double *masses, + const long *band_indices, + const long num_band, + const double cutoff_frequency, + const long openmp_at_bands) { - long i, num_atom; + long i, j, num_atom; + double *inv_sqrt_masses; + lapack_complex_double *e0, *e1, *e2; + + num_atom = num_band / 3; + + /* Transpose eigenvectors for the better data alignment in memory. */ + e0 = (lapack_complex_double *) + malloc(sizeof(lapack_complex_double) * num_band * num_band); + e1 = (lapack_complex_double *) + malloc(sizeof(lapack_complex_double) * num_band * num_band); + e2 = (lapack_complex_double *) + malloc(sizeof(lapack_complex_double) * num_band * num_band); + + for (i = 0; i < num_band; i++) + { + for (j = 0; j < num_band; j++) + { + e0[j * num_band + i] = eigvecs0[i * num_band + j]; + e1[j * num_band + i] = eigvecs1[i * num_band + j]; + e2[j * num_band + i] = eigvecs2[i * num_band + j]; + } + } + + inv_sqrt_masses = (double *)malloc(sizeof(double) * num_atom); + for (i = 0; i < num_atom; i++) + { + inv_sqrt_masses[i] = 1.0 / sqrt(masses[i]); + } #ifdef MEASURE_R2N double loopTotalCPUTime, loopTotalWallTime; @@ -94,8 +117,6 @@ void reciprocal_to_normal_squared clock_t loopStartCPUTime; #endif - num_atom = num_band / 3; - #ifdef MEASURE_R2N loopStartWallTime = time(NULL); loopStartCPUTime = clock(); @@ -104,20 +125,23 @@ void reciprocal_to_normal_squared #ifdef PHPYOPENMP #pragma omp parallel for if (openmp_at_bands) #endif - for (i = 0; i < num_g_pos; i++) { - if (freqs0[band_indices[g_pos[i][0]]] > cutoff_frequency) { - fc3_normal_squared[g_pos[i][3]] = get_fc3_sum(g_pos[i][1], + for (i = 0; i < num_g_pos; i++) + { + if (freqs0[band_indices[g_pos[i][0]]] > cutoff_frequency) + { + fc3_normal_squared[g_pos[i][3]] = get_fc3_sum(band_indices[g_pos[i][0]], + g_pos[i][1], g_pos[i][2], - band_indices[g_pos[i][0]], freqs0, freqs1, freqs2, - eigvecs0, - eigvecs1, - eigvecs2, + e0, + e1, + e2, fc3_reciprocal, - masses, + inv_sqrt_masses, num_atom, + num_band, cutoff_frequency); } } @@ -128,90 +152,93 @@ void reciprocal_to_normal_squared printf(" %1.3fs (%1.3fs CPU)\n", loopTotalWallTime, loopTotalCPUTime); #endif + free(inv_sqrt_masses); + inv_sqrt_masses = NULL; + free(e0); + e0 = NULL; + free(e1); + e1 = NULL; + free(e2); + e2 = NULL; } -static double get_fc3_sum -(const long j, - const long k, - const long bi, - const double *freqs0, - const double *freqs1, - const double *freqs2, - const lapack_complex_double *eigvecs0, - const lapack_complex_double *eigvecs1, - const lapack_complex_double *eigvecs2, - const lapack_complex_double *fc3_reciprocal, - const double *masses, - const long num_atom, - const double cutoff_frequency) +static double get_fc3_sum(const long bi0, + const long bi1, + const long bi2, + const double *freqs0, + const double *freqs1, + const double *freqs2, + const lapack_complex_double *e0, + const lapack_complex_double *e1, + const lapack_complex_double *e2, + const lapack_complex_double *fc3_reciprocal, + const double *inv_sqrt_masses, + const long num_atom, + const long num_band, + const double cutoff_frequency) { - double fff, sum_real, sum_imag; - lapack_complex_double fc3_sum; + double fff; - if (freqs1[j] > cutoff_frequency && freqs2[k] > cutoff_frequency) { - fff = freqs0[bi] * freqs1[j] * freqs2[k]; - fc3_sum = fc3_sum_in_reciprocal_to_normal - (bi, j, k, - eigvecs0, eigvecs1, eigvecs2, - fc3_reciprocal, - masses, - num_atom); - sum_real = lapack_complex_double_real(fc3_sum); - sum_imag = lapack_complex_double_imag(fc3_sum); - return (sum_real * sum_real + sum_imag * sum_imag) / fff; - } else { + if (freqs1[bi1] > cutoff_frequency && freqs2[bi2] > cutoff_frequency) + { + fff = freqs0[bi0] * freqs1[bi1] * freqs2[bi2]; + return fc3_sum_in_reciprocal_to_normal(e0 + bi0 * num_band, + e1 + bi1 * num_band, + e2 + bi2 * num_band, + fc3_reciprocal, + inv_sqrt_masses, + num_atom, + num_band) / + fff; + } + else + { return 0; } } -static lapack_complex_double fc3_sum_in_reciprocal_to_normal -(const long bi0, - const long bi1, - const long bi2, - const lapack_complex_double *eigvecs0, - const lapack_complex_double *eigvecs1, - const lapack_complex_double *eigvecs2, - const lapack_complex_double *fc3_reciprocal, - const double *masses, - const long num_atom) +static double fc3_sum_in_reciprocal_to_normal(const lapack_complex_double *e0, + const lapack_complex_double *e1, + const lapack_complex_double *e2, + const lapack_complex_double *fc3_reciprocal, + const double *inv_sqrt_masses, + const long num_atom, + const long num_band) { - long baseIndex, index_l, index_lm, i, j, k, l, m, n; - double sum_real, sum_imag, mmm, mass_l, mass_lm; + long index_l, index_lm, index_lmn, i, j, k, l, m, n; + double sum_real, sum_imag, mass_lm, mass_lmn; lapack_complex_double eig_prod, eig_prod1; sum_real = 0; sum_imag = 0; - for (l = 0; l < num_atom; l++) { - mass_l = masses[l]; + for (l = 0; l < num_atom; l++) + { index_l = l * num_atom * num_atom * 27; - - for (m = 0; m < num_atom; m++) { - mass_lm = mass_l * masses[m]; - index_lm = index_l + m * num_atom * 27; - - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { - eig_prod1 = phonoc_complex_prod - (eigvecs0[(l * 3 + i) * num_atom * 3 + bi0], - eigvecs1[(m * 3 + j) * num_atom * 3 + bi1]); - - for (n = 0; n < num_atom; n++) { - mmm = 1.0 / sqrt(mass_lm * masses[n]); - baseIndex = index_lm + n * 27 + i * 9 + j * 3; - - for (k = 0; k < 3; k++) { - eig_prod = phonoc_complex_prod - (eig_prod1, eigvecs2[(n * 3 + k) * num_atom * 3 + bi2]); - eig_prod = phonoc_complex_prod - (eig_prod, fc3_reciprocal[baseIndex + k]); - sum_real += lapack_complex_double_real(eig_prod) * mmm; - sum_imag += lapack_complex_double_imag(eig_prod) * mmm; + for (i = 0; i < 3; i++) + { + for (m = 0; m < num_atom; m++) + { + mass_lm = inv_sqrt_masses[l] * inv_sqrt_masses[m]; + index_lm = index_l + m * num_atom * 27; + for (j = 0; j < 3; j++) + { + eig_prod1 = phonoc_complex_prod(e0[l * 3 + i], e1[m * 3 + j]); + for (n = 0; n < num_atom; n++) + { + mass_lmn = mass_lm * inv_sqrt_masses[n]; + index_lmn = index_lm + n * 27 + i * 9 + j * 3; + for (k = 0; k < 3; k++) + { + eig_prod = phonoc_complex_prod(eig_prod1, e2[n * 3 + k]); + eig_prod = phonoc_complex_prod(eig_prod, fc3_reciprocal[index_lmn + k]); + sum_real += lapack_complex_double_real(eig_prod) * mass_lmn; + sum_imag += lapack_complex_double_imag(eig_prod) * mass_lmn; } } } } } } - return lapack_make_complex_double(sum_real, sum_imag); + return (sum_real * sum_real + sum_imag * sum_imag); } diff --git a/c/reciprocal_to_normal.h b/c/reciprocal_to_normal.h index ae6ad593..3b2f9aef 100644 --- a/c/reciprocal_to_normal.h +++ b/c/reciprocal_to_normal.h @@ -37,22 +37,20 @@ #include "lapack_wrapper.h" -void reciprocal_to_normal_squared -(double *fc3_normal_squared, - const long (*g_pos)[4], - const long num_g_pos, - const lapack_complex_double *fc3_reciprocal, - const double *freqs0, - const double *freqs1, - const double *freqs2, - const lapack_complex_double *eigvecs0, - const lapack_complex_double *eigvecs1, - const lapack_complex_double *eigvecs2, - const double *masses, - const long *band_indices, - const long num_band0, - const long num_band, - const double cutoff_frequency, - const long openmp_at_bands); +void reciprocal_to_normal_squared(double *fc3_normal_squared, + const long (*g_pos)[4], + const long num_g_pos, + const lapack_complex_double *fc3_reciprocal, + const double *freqs0, + const double *freqs1, + const double *freqs2, + const lapack_complex_double *eigvecs0, + const lapack_complex_double *eigvecs1, + const lapack_complex_double *eigvecs2, + const double *masses, + const long *band_indices, + const long num_band, + const double cutoff_frequency, + const long openmp_at_bands); #endif From 145125573322e66a4b38b0f4c622816b9178458e Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Tue, 3 Aug 2021 09:22:06 +0900 Subject: [PATCH 06/34] Include inv-sqrt mass in copy of eigvecs. --- c/reciprocal_to_normal.c | 60 +++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/c/reciprocal_to_normal.c b/c/reciprocal_to_normal.c index aec1edff..6dee3b97 100644 --- a/c/reciprocal_to_normal.c +++ b/c/reciprocal_to_normal.c @@ -52,7 +52,6 @@ static double get_fc3_sum(const long bi0, const lapack_complex_double *e1, const lapack_complex_double *e2, const lapack_complex_double *fc3_reciprocal, - const double *inv_sqrt_masses, const long num_atom, const long num_band, const double cutoff_frequency); @@ -61,9 +60,7 @@ static double fc3_sum_in_reciprocal_to_normal(const lapack_complex_double *e0, const lapack_complex_double *e1, const lapack_complex_double *e2, const lapack_complex_double *fc3_reciprocal, - const double *inv_sqrt_masses, - const long num_atom, - const long num_band); + const long num_atom); void reciprocal_to_normal_squared(double *fc3_normal_squared, const long (*g_pos)[4], @@ -81,12 +78,19 @@ void reciprocal_to_normal_squared(double *fc3_normal_squared, const double cutoff_frequency, const long openmp_at_bands) { - long i, j, num_atom; + long i, j, k, num_atom; + double real, imag; double *inv_sqrt_masses; lapack_complex_double *e0, *e1, *e2; num_atom = num_band / 3; + inv_sqrt_masses = (double *)malloc(sizeof(double) * num_atom); + for (i = 0; i < num_atom; i++) + { + inv_sqrt_masses[i] = 1.0 / sqrt(masses[i]); + } + /* Transpose eigenvectors for the better data alignment in memory. */ e0 = (lapack_complex_double *) malloc(sizeof(lapack_complex_double) * num_band * num_band); @@ -105,14 +109,28 @@ void reciprocal_to_normal_squared(double *fc3_normal_squared, } } - inv_sqrt_masses = (double *)malloc(sizeof(double) * num_atom); - for (i = 0; i < num_atom; i++) + for (i = 0; i < num_band; i++) { - inv_sqrt_masses[i] = 1.0 / sqrt(masses[i]); + for (j = 0; j < num_atom; j++) + { + for (k = 0; k < 3; k++) + { + real = lapack_complex_double_real(e0[i * num_band + j * 3 + k]); + imag = lapack_complex_double_imag(e0[i * num_band + j * 3 + k]); + e0[i * num_band + j * 3 + k] = lapack_make_complex_double(real * inv_sqrt_masses[j], imag * inv_sqrt_masses[j]); + real = lapack_complex_double_real(e1[i * num_band + j * 3 + k]); + imag = lapack_complex_double_imag(e1[i * num_band + j * 3 + k]); + e1[i * num_band + j * 3 + k] = lapack_make_complex_double(real * inv_sqrt_masses[j], imag * inv_sqrt_masses[j]); + real = lapack_complex_double_real(e2[i * num_band + j * 3 + k]); + imag = lapack_complex_double_imag(e2[i * num_band + j * 3 + k]); + e2[i * num_band + j * 3 + k] = lapack_make_complex_double(real * inv_sqrt_masses[j], imag * inv_sqrt_masses[j]); + } + } } #ifdef MEASURE_R2N - double loopTotalCPUTime, loopTotalWallTime; + double loopTotalCPUTime, + loopTotalWallTime; time_t loopStartWallTime; clock_t loopStartCPUTime; #endif @@ -139,7 +157,6 @@ void reciprocal_to_normal_squared(double *fc3_normal_squared, e1, e2, fc3_reciprocal, - inv_sqrt_masses, num_atom, num_band, cutoff_frequency); @@ -172,7 +189,6 @@ static double get_fc3_sum(const long bi0, const lapack_complex_double *e1, const lapack_complex_double *e2, const lapack_complex_double *fc3_reciprocal, - const double *inv_sqrt_masses, const long num_atom, const long num_band, const double cutoff_frequency) @@ -186,9 +202,7 @@ static double get_fc3_sum(const long bi0, e1 + bi1 * num_band, e2 + bi2 * num_band, fc3_reciprocal, - inv_sqrt_masses, - num_atom, - num_band) / + num_atom) / fff; } else @@ -201,13 +215,11 @@ static double fc3_sum_in_reciprocal_to_normal(const lapack_complex_double *e0, const lapack_complex_double *e1, const lapack_complex_double *e2, const lapack_complex_double *fc3_reciprocal, - const double *inv_sqrt_masses, - const long num_atom, - const long num_band) + const long num_atom) { long index_l, index_lm, index_lmn, i, j, k, l, m, n; - double sum_real, sum_imag, mass_lm, mass_lmn; - lapack_complex_double eig_prod, eig_prod1; + double sum_real, sum_imag; + lapack_complex_double eig_prod; sum_real = 0; sum_imag = 0; @@ -219,21 +231,19 @@ static double fc3_sum_in_reciprocal_to_normal(const lapack_complex_double *e0, { for (m = 0; m < num_atom; m++) { - mass_lm = inv_sqrt_masses[l] * inv_sqrt_masses[m]; index_lm = index_l + m * num_atom * 27; for (j = 0; j < 3; j++) { - eig_prod1 = phonoc_complex_prod(e0[l * 3 + i], e1[m * 3 + j]); + eig_prod = phonoc_complex_prod(e0[l * 3 + i], e1[m * 3 + j]); for (n = 0; n < num_atom; n++) { - mass_lmn = mass_lm * inv_sqrt_masses[n]; index_lmn = index_lm + n * 27 + i * 9 + j * 3; for (k = 0; k < 3; k++) { - eig_prod = phonoc_complex_prod(eig_prod1, e2[n * 3 + k]); + eig_prod = phonoc_complex_prod(eig_prod, e2[n * 3 + k]); eig_prod = phonoc_complex_prod(eig_prod, fc3_reciprocal[index_lmn + k]); - sum_real += lapack_complex_double_real(eig_prod) * mass_lmn; - sum_imag += lapack_complex_double_imag(eig_prod) * mass_lmn; + sum_real += lapack_complex_double_real(eig_prod); + sum_imag += lapack_complex_double_imag(eig_prod); } } } From c3b7724b98659e665c7a694617cc99d80519b190 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Tue, 3 Aug 2021 09:56:15 +0900 Subject: [PATCH 07/34] Fix a bug introduced in the last commit. --- c/reciprocal_to_normal.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/c/reciprocal_to_normal.c b/c/reciprocal_to_normal.c index 6dee3b97..d2496804 100644 --- a/c/reciprocal_to_normal.c +++ b/c/reciprocal_to_normal.c @@ -128,6 +128,9 @@ void reciprocal_to_normal_squared(double *fc3_normal_squared, } } + free(inv_sqrt_masses); + inv_sqrt_masses = NULL; + #ifdef MEASURE_R2N double loopTotalCPUTime, loopTotalWallTime; @@ -169,8 +172,6 @@ void reciprocal_to_normal_squared(double *fc3_normal_squared, printf(" %1.3fs (%1.3fs CPU)\n", loopTotalWallTime, loopTotalCPUTime); #endif - free(inv_sqrt_masses); - inv_sqrt_masses = NULL; free(e0); e0 = NULL; free(e1); @@ -219,7 +220,7 @@ static double fc3_sum_in_reciprocal_to_normal(const lapack_complex_double *e0, { long index_l, index_lm, index_lmn, i, j, k, l, m, n; double sum_real, sum_imag; - lapack_complex_double eig_prod; + lapack_complex_double e_01, e_012, e_012_fc3; sum_real = 0; sum_imag = 0; @@ -234,16 +235,16 @@ static double fc3_sum_in_reciprocal_to_normal(const lapack_complex_double *e0, index_lm = index_l + m * num_atom * 27; for (j = 0; j < 3; j++) { - eig_prod = phonoc_complex_prod(e0[l * 3 + i], e1[m * 3 + j]); + e_01 = phonoc_complex_prod(e0[l * 3 + i], e1[m * 3 + j]); for (n = 0; n < num_atom; n++) { index_lmn = index_lm + n * 27 + i * 9 + j * 3; for (k = 0; k < 3; k++) { - eig_prod = phonoc_complex_prod(eig_prod, e2[n * 3 + k]); - eig_prod = phonoc_complex_prod(eig_prod, fc3_reciprocal[index_lmn + k]); - sum_real += lapack_complex_double_real(eig_prod); - sum_imag += lapack_complex_double_imag(eig_prod); + e_012 = phonoc_complex_prod(e_01, e2[n * 3 + k]); + e_012_fc3 = phonoc_complex_prod(e_012, fc3_reciprocal[index_lmn + k]); + sum_real += lapack_complex_double_real(e_012_fc3); + sum_imag += lapack_complex_double_imag(e_012_fc3); } } } From 7fe6007f900f42e4ee5ebcfc64807c28aecb84b3 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Tue, 3 Aug 2021 12:01:54 +0900 Subject: [PATCH 08/34] Memory layout of fc3_reciprocal was reorderd. --- c/interaction.c | 5 +- c/pp_collision.c | 224 ++++++++++++++++++++++----------------- c/real_to_reciprocal.c | 144 ++++++++++++++----------- c/reciprocal_to_normal.c | 150 ++++++++------------------ 4 files changed, 252 insertions(+), 271 deletions(-) diff --git a/c/interaction.c b/c/interaction.c index 897609ab..9a9ab813 100644 --- a/c/interaction.c +++ b/c/interaction.c @@ -312,14 +312,11 @@ static void real_to_normal(double *fc3_normal_squared, const long num_triplets, const long openmp_at_bands) { - long num_patom; lapack_complex_double *fc3_reciprocal; - num_patom = num_band / 3; - fc3_reciprocal = (lapack_complex_double *)malloc(sizeof(lapack_complex_double) * - num_patom * num_patom * num_patom * 27); + num_band * num_band * num_band); r2r_real_to_reciprocal(fc3_reciprocal, q_vecs, fc3, diff --git a/c/pp_collision.c b/c/pp_collision.c index ad54a97a..07c63a72 100644 --- a/c/pp_collision.c +++ b/c/pp_collision.c @@ -114,16 +114,19 @@ void ppc_get_pp_collision(double *imag_self_energy, num_band = multi_dims[1] * 3; num_band_prod = num_band0 * num_band * num_band; num_temps = temperatures->dims[0]; - ise = (double*)malloc(sizeof(double) * num_triplets * num_temps * num_band0); - freqs_at_gp = (double*)malloc(sizeof(double) * num_band0); - for (i = 0; i < num_band0; i++) { - freqs_at_gp[i] = frequencies[triplets[0][0] * num_band - + band_indices->data[i]]; + ise = (double *)malloc(sizeof(double) * num_triplets * num_temps * num_band0); + freqs_at_gp = (double *)malloc(sizeof(double) * num_band0); + for (i = 0; i < num_band0; i++) + { + freqs_at_gp[i] = frequencies[triplets[0][0] * num_band + band_indices->data[i]]; } - if (num_triplets > num_band) { + if (num_triplets > num_band) + { openmp_per_triplets = 1; - } else { + } + else + { openmp_per_triplets = 0; } @@ -134,20 +137,21 @@ void ppc_get_pp_collision(double *imag_self_energy, #ifdef PHPYOPENMP #pragma omp parallel for schedule(guided) private(g, g_zero) if (openmp_per_triplets) #endif - for (i = 0; i < num_triplets; i++) { - g = (double*)malloc(sizeof(double) * 2 * num_band_prod); - g_zero = (char*)malloc(sizeof(char) * num_band_prod); + for (i = 0; i < num_triplets; i++) + { + g = (double *)malloc(sizeof(double) * 2 * num_band_prod); + g_zero = (char *)malloc(sizeof(char) * num_band_prod); tpi_get_integration_weight(g, g_zero, - freqs_at_gp, /* used as f0 */ + freqs_at_gp, /* used as f0 */ num_band0, tp_relative_grid_address, triplets[i], 1, bzgrid, - frequencies, /* used as f1 */ + frequencies, /* used as f1 */ num_band, - frequencies, /* used as f2 */ + frequencies, /* used as f2 */ num_band, 2, 1 - openmp_per_triplets); @@ -199,28 +203,28 @@ void ppc_get_pp_collision(double *imag_self_energy, } void ppc_get_pp_collision_with_sigma( - double *imag_self_energy, - const double sigma, - const double sigma_cutoff, - const double *frequencies, - const lapack_complex_double *eigenvectors, - const long (*triplets)[3], - const long num_triplets, - const long *triplet_weights, - const ConstBZGrid *bzgrid, - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const Larray *band_indices, - const Darray *temperatures, - const long is_NU, - const long symmetrize_fc3_q, - const double cutoff_frequency) + double *imag_self_energy, + const double sigma, + const double sigma_cutoff, + const double *frequencies, + const lapack_complex_double *eigenvectors, + const long (*triplets)[3], + const long num_triplets, + const long *triplet_weights, + const ConstBZGrid *bzgrid, + const double *fc3, + const long is_compact_fc3, + const double (*svecs)[3], + const long multi_dims[2], + const long (*multiplicity)[2], + const double *masses, + const long *p2s_map, + const long *s2p_map, + const Larray *band_indices, + const Darray *temperatures, + const long is_NU, + const long symmetrize_fc3_q, + const double cutoff_frequency) { long i; long num_band, num_band0, num_band_prod, num_temps; @@ -240,16 +244,20 @@ void ppc_get_pp_collision_with_sigma( num_temps = temperatures->dims[0]; const_adrs_shift = num_band_prod; - ise = (double*)malloc(sizeof(double) * num_triplets * num_temps * num_band0); - freqs_at_gp = (double*)malloc(sizeof(double) * num_band0); - for (i = 0; i < num_band0; i++) { + ise = (double *)malloc(sizeof(double) * num_triplets * num_temps * num_band0); + freqs_at_gp = (double *)malloc(sizeof(double) * num_band0); + for (i = 0; i < num_band0; i++) + { freqs_at_gp[i] = frequencies[triplets[0][0] * num_band + band_indices->data[i]]; } - if (num_triplets > num_band) { + if (num_triplets > num_band) + { openmp_per_triplets = 1; - } else { + } + else + { openmp_per_triplets = 0; } @@ -258,9 +266,10 @@ void ppc_get_pp_collision_with_sigma( #ifdef PHPYOPENMP #pragma omp parallel for schedule(guided) private(g, g_zero) if (openmp_per_triplets) #endif - for (i = 0; i < num_triplets; i++) { - g = (double*)malloc(sizeof(double) * 2 * num_band_prod); - g_zero = (char*)malloc(sizeof(char) * num_band_prod); + for (i = 0; i < num_triplets; i++) + { + g = (double *)malloc(sizeof(double) * 2 * num_band_prod); + g_zero = (char *)malloc(sizeof(char) * num_band_prod); tpi_get_integration_weight_with_sigma(g, g_zero, sigma, @@ -348,16 +357,17 @@ static void get_collision(double *ise, long i; long num_band_prod, num_g_pos; double *fc3_normal_squared; - long (*g_pos)[4]; + long(*g_pos)[4]; fc3_normal_squared = NULL; g_pos = NULL; num_band_prod = num_band0 * num_band * num_band; - fc3_normal_squared = (double*)malloc(sizeof(double) * num_band_prod); + fc3_normal_squared = (double *)malloc(sizeof(double) * num_band_prod); g_pos = (long(*)[4])malloc(sizeof(long[4]) * num_band_prod); - for (i = 0; i < num_band_prod; i++) { + for (i = 0; i < num_band_prod; i++) + { fc3_normal_squared[i] = 0; } @@ -367,47 +377,47 @@ static void get_collision(double *ise, g_zero); itr_get_interaction_at_triplet( - fc3_normal_squared, - num_band0, - num_band, - g_pos, - num_g_pos, - frequencies, - eigenvectors, - triplet, - bzgrid, - fc3, - is_compact_fc3, - svecs, - multi_dims, - multiplicity, - masses, - p2s_map, - s2p_map, - band_indices, - symmetrize_fc3_q, - cutoff_frequency, - 0, - 0, - 1 - openmp_per_triplets); + fc3_normal_squared, + num_band0, + num_band, + g_pos, + num_g_pos, + frequencies, + eigenvectors, + triplet, + bzgrid, + fc3, + is_compact_fc3, + svecs, + multi_dims, + multiplicity, + masses, + p2s_map, + s2p_map, + band_indices, + symmetrize_fc3_q, + cutoff_frequency, + 0, + 0, + 1 - openmp_per_triplets); ise_imag_self_energy_at_triplet( - ise, - num_band0, - num_band, - fc3_normal_squared, - frequencies, - triplet, - triplet_weight, - g, - g + num_band_prod, - g_pos, - num_g_pos, - temperatures, - num_temps, - cutoff_frequency, - 1 - openmp_per_triplets, - 0); + ise, + num_band0, + num_band, + fc3_normal_squared, + frequencies, + triplet, + triplet_weight, + g, + g + num_band_prod, + g_pos, + num_g_pos, + temperatures, + num_temps, + cutoff_frequency, + 1 - openmp_per_triplets, + 0); free(fc3_normal_squared); fc3_normal_squared = NULL; @@ -427,33 +437,47 @@ static void finalize_ise(double *imag_self_energy, long i, j, k; long is_N; - if (is_NU) { - for (i = 0; i < 2 * num_temps * num_band0; i++) { + if (is_NU) + { + for (i = 0; i < 2 * num_temps * num_band0; i++) + { imag_self_energy[i] = 0; } - for (i = 0; i < num_triplets; i++) { + for (i = 0; i < num_triplets; i++) + { is_N = tpl_is_N(triplets[i], bz_grid_addresses); - for (j = 0; j < num_temps; j++) { - for (k = 0; k < num_band0; k++) { - if (is_N) { + for (j = 0; j < num_temps; j++) + { + for (k = 0; k < num_band0; k++) + { + if (is_N) + { imag_self_energy[j * num_band0 + k] += - ise[i * num_temps * num_band0 + j * num_band0 + k]; - } else { + ise[i * num_temps * num_band0 + j * num_band0 + k]; + } + else + { imag_self_energy[num_temps * num_band0 + j * num_band0 + k] += - ise[i * num_temps * num_band0 + j * num_band0 + k]; + ise[i * num_temps * num_band0 + j * num_band0 + k]; } } } } - } else { - for (i = 0; i < num_temps * num_band0; i++) { + } + else + { + for (i = 0; i < num_temps * num_band0; i++) + { imag_self_energy[i] = 0; } - for (i = 0; i < num_triplets; i++) { - for (j = 0; j < num_temps; j++) { - for (k = 0; k < num_band0; k++) { + for (i = 0; i < num_triplets; i++) + { + for (j = 0; j < num_temps; j++) + { + for (k = 0; k < num_band0; k++) + { imag_self_energy[j * num_band0 + k] += - ise[i * num_temps * num_band0 + j * num_band0 + k]; + ise[i * num_temps * num_band0 + j * num_band0 + k]; } } } diff --git a/c/real_to_reciprocal.c b/c/real_to_reciprocal.c index 7a0ebeeb..ea9322f1 100644 --- a/c/real_to_reciprocal.c +++ b/c/real_to_reciprocal.c @@ -97,7 +97,8 @@ void r2r_real_to_reciprocal(lapack_complex_double *fc3_reciprocal, const long *s2p_map, const long openmp_at_bands) { - if (openmp_at_bands) { + if (openmp_at_bands) + { real_to_reciprocal_openmp(fc3_reciprocal, q_vecs, fc3, @@ -107,7 +108,9 @@ void r2r_real_to_reciprocal(lapack_complex_double *fc3_reciprocal, multiplicity, p2s_map, s2p_map); - } else { + } + else + { real_to_reciprocal_single_thread(fc3_reciprocal, q_vecs, fc3, @@ -120,7 +123,6 @@ void r2r_real_to_reciprocal(lapack_complex_double *fc3_reciprocal, } } - static void real_to_reciprocal_single_thread(lapack_complex_double *fc3_reciprocal, const double q_vecs[3][3], @@ -132,19 +134,22 @@ real_to_reciprocal_single_thread(lapack_complex_double *fc3_reciprocal, const long *p2s_map, const long *s2p_map) { - long i, j, k; - long num_patom, adrs_shift; - lapack_complex_double pre_phase_factor; + long i, j, k, l, m, n; + long num_patom, num_band; + lapack_complex_double pre_phase_factor, fc3_rec_elem[27]; num_patom = multi_dims[1]; + num_band = num_patom * 3; - for (i = 0; i < num_patom; i++) { - for (j = 0; j < num_patom; j++) { - for (k = 0; k < num_patom; k++) { - real_to_reciprocal_elements(fc3_reciprocal + - i * 27 * num_patom * num_patom + - j * 27 * num_patom + - k * 27, + for (i = 0; i < num_patom; i++) + { + pre_phase_factor = get_pre_phase_factor( + i, q_vecs, svecs, multi_dims, multiplicity, p2s_map); + for (j = 0; j < num_patom; j++) + { + for (k = 0; k < num_patom; k++) + { + real_to_reciprocal_elements(fc3_rec_elem, q_vecs, fc3, is_compact_fc3, @@ -154,16 +159,19 @@ real_to_reciprocal_single_thread(lapack_complex_double *fc3_reciprocal, p2s_map, s2p_map, i, j, k); - + for (l = 0; l < 3; l++) + { + for (m = 0; m < 3; m++) + { + for (n = 0; n < 3; n++) + { + fc3_reciprocal[(i * 3 + l) * num_band * num_band + (j * 3 + m) * num_band + k * 3 + n] = + phonoc_complex_prod(fc3_rec_elem[l * 9 + m * 3 + n], pre_phase_factor); + } + } + } } } - pre_phase_factor = get_pre_phase_factor( - i, q_vecs, svecs, multi_dims, multiplicity, p2s_map); - adrs_shift = i * num_patom * num_patom * 27; - for (j = 0; j < num_patom * num_patom * 27; j++) { - fc3_reciprocal[adrs_shift + j] = - phonoc_complex_prod(fc3_reciprocal[adrs_shift + j], pre_phase_factor); - } } } @@ -178,23 +186,25 @@ real_to_reciprocal_openmp(lapack_complex_double *fc3_reciprocal, const long *p2s_map, const long *s2p_map) { - long i, j, k, jk; - long num_patom, adrs_shift; - lapack_complex_double pre_phase_factor; + long i, j, k, l, m, n, jk; + long num_patom, num_band; + lapack_complex_double pre_phase_factor, fc3_rec_elem[27]; num_patom = multi_dims[1]; + num_band = num_patom * 3; - for (i = 0; i < num_patom; i++) { + for (i = 0; i < num_patom; i++) + { + pre_phase_factor = get_pre_phase_factor( + i, q_vecs, svecs, multi_dims, multiplicity, p2s_map); #ifdef PHPYOPENMP -#pragma omp parallel for private(j, k) +#pragma omp parallel for private(j, k, l, m, n, fc3_rec_elem) #endif - for (jk = 0; jk < num_patom * num_patom; jk++) { + for (jk = 0; jk < num_patom * num_patom; jk++) + { j = jk / num_patom; k = jk % num_patom; - real_to_reciprocal_elements(fc3_reciprocal + - i * 27 * num_patom * num_patom + - j * 27 * num_patom + - k * 27, + real_to_reciprocal_elements(fc3_rec_elem, q_vecs, fc3, is_compact_fc3, @@ -204,17 +214,17 @@ real_to_reciprocal_openmp(lapack_complex_double *fc3_reciprocal, p2s_map, s2p_map, i, j, k); - - } - pre_phase_factor = get_pre_phase_factor( - i, q_vecs, svecs, multi_dims, multiplicity, p2s_map); - adrs_shift = i * num_patom * num_patom * 27; -#ifdef PHPYOPENMP -#pragma omp parallel for -#endif - for (j = 0; j < num_patom * num_patom * 27; j++) { - fc3_reciprocal[adrs_shift + j] = - phonoc_complex_prod(fc3_reciprocal[adrs_shift + j], pre_phase_factor); + for (l = 0; l < 3; l++) + { + for (m = 0; m < 3; m++) + { + for (n = 0; n < 3; n++) + { + fc3_reciprocal[(i * 3 + l) * num_band * num_band + (j * 3 + m) * num_band + k * 3 + n] = + phonoc_complex_prod(fc3_rec_elem[l * 9 + m * 3 + n], pre_phase_factor); + } + } + } } } } @@ -233,25 +243,31 @@ static void real_to_reciprocal_elements(lapack_complex_double *fc3_rec_elem, const long pi2) { long i, j, k, l; - long num_satom, adrs_shift, adrs_vec1, adrs_vec2 ; + long num_satom, adrs_shift, adrs_vec1, adrs_vec2; lapack_complex_double phase_factor, phase_factor1, phase_factor2; double fc3_rec_real[27], fc3_rec_imag[27]; - for (i = 0; i < 27; i++) { + for (i = 0; i < 27; i++) + { fc3_rec_real[i] = 0; fc3_rec_imag[i] = 0; } num_satom = multi_dims[0]; - if (is_compact_fc3) { + if (is_compact_fc3) + { i = pi0; - } else { + } + else + { i = p2s[pi0]; } - for (j = 0; j < num_satom; j++) { - if (s2p[j] != p2s[pi1]) { + for (j = 0; j < num_satom; j++) + { + if (s2p[j] != p2s[pi1]) + { continue; } @@ -260,8 +276,10 @@ static void real_to_reciprocal_elements(lapack_complex_double *fc3_rec_elem, 1, svecs, multiplicity[adrs_vec1]); - for (k = 0; k < num_satom; k++) { - if (s2p[k] != p2s[pi2]) { + for (k = 0; k < num_satom; k++) + { + if (s2p[k] != p2s[pi2]) + { continue; } adrs_vec2 = k * multi_dims[1] + pi0; @@ -271,18 +289,20 @@ static void real_to_reciprocal_elements(lapack_complex_double *fc3_rec_elem, multiplicity[adrs_vec2]); adrs_shift = i * 27 * num_satom * num_satom + j * 27 * num_satom + k * 27; phase_factor = phonoc_complex_prod(phase_factor1, phase_factor2); - for (l = 0; l < 27; l++) { + for (l = 0; l < 27; l++) + { fc3_rec_real[l] += - lapack_complex_double_real(phase_factor) * fc3[adrs_shift + l]; + lapack_complex_double_real(phase_factor) * fc3[adrs_shift + l]; fc3_rec_imag[l] += - lapack_complex_double_imag(phase_factor) * fc3[adrs_shift + l]; + lapack_complex_double_imag(phase_factor) * fc3[adrs_shift + l]; } } } - for (i = 0; i < 27; i++) { + for (i = 0; i < 27; i++) + { fc3_rec_elem[i] = - lapack_make_complex_double(fc3_rec_real[i], fc3_rec_imag[i]); + lapack_make_complex_double(fc3_rec_real[i], fc3_rec_imag[i]); } } @@ -301,11 +321,13 @@ get_pre_phase_factor(const long i_patom, svecs_adrs = p2s_map[i_patom] * multi_dims[1]; sum_real = 0; sum_imag = 0; - for (i = 0; i < multiplicity[svecs_adrs][0]; i++) { + for (i = 0; i < multiplicity[svecs_adrs][0]; i++) + { pre_phase = 0; - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { pre_phase += svecs[multiplicity[svecs_adrs][1] + i][j] * - (q_vecs[0][j] + q_vecs[1][j] + q_vecs[2][j]); + (q_vecs[0][j] + q_vecs[1][j] + q_vecs[2][j]); } pre_phase *= M_2PI; sum_real += cos(pre_phase); @@ -328,9 +350,11 @@ static lapack_complex_double get_phase_factor(const double q[3][3], sum_real = 0; sum_imag = 0; - for (i = 0; i < multi[0]; i++) { + for (i = 0; i < multi[0]; i++) + { phase = 0; - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { phase += q[qi][j] * svecs[multi[1] + i][j]; } phase *= M_2PI; diff --git a/c/reciprocal_to_normal.c b/c/reciprocal_to_normal.c index d2496804..2b38e5e5 100644 --- a/c/reciprocal_to_normal.c +++ b/c/reciprocal_to_normal.c @@ -42,25 +42,11 @@ #include #endif -static double get_fc3_sum(const long bi0, - const long bi1, - const long bi2, - const double *freqs0, - const double *freqs1, - const double *freqs2, - const lapack_complex_double *e0, +static double get_fc3_sum(const lapack_complex_double *e0, const lapack_complex_double *e1, const lapack_complex_double *e2, const lapack_complex_double *fc3_reciprocal, - const long num_atom, - const long num_band, - const double cutoff_frequency); - -static double fc3_sum_in_reciprocal_to_normal(const lapack_complex_double *e0, - const lapack_complex_double *e1, - const lapack_complex_double *e2, - const lapack_complex_double *fc3_reciprocal, - const long num_atom); + const long num_band); void reciprocal_to_normal_squared(double *fc3_normal_squared, const long (*g_pos)[4], @@ -83,21 +69,13 @@ void reciprocal_to_normal_squared(double *fc3_normal_squared, double *inv_sqrt_masses; lapack_complex_double *e0, *e1, *e2; - num_atom = num_band / 3; - - inv_sqrt_masses = (double *)malloc(sizeof(double) * num_atom); - for (i = 0; i < num_atom; i++) - { - inv_sqrt_masses[i] = 1.0 / sqrt(masses[i]); - } - /* Transpose eigenvectors for the better data alignment in memory. */ + /* Memory space for three eigenvector matrices is allocated at once */ + /* to make it contiguous. */ e0 = (lapack_complex_double *) - malloc(sizeof(lapack_complex_double) * num_band * num_band); - e1 = (lapack_complex_double *) - malloc(sizeof(lapack_complex_double) * num_band * num_band); - e2 = (lapack_complex_double *) - malloc(sizeof(lapack_complex_double) * num_band * num_band); + malloc(sizeof(lapack_complex_double) * 3 * num_band * num_band); + e1 = e0 + num_band * num_band; + e2 = e1 + num_band * num_band; for (i = 0; i < num_band; i++) { @@ -109,7 +87,17 @@ void reciprocal_to_normal_squared(double *fc3_normal_squared, } } - for (i = 0; i < num_band; i++) + /* Inverse sqrt mass is multipled with eigenvectors to reduce number of */ + /* operations in get_fc3_sum. Three eigenvector matrices are looped by */ + /* first loop leveraging contiguous memory layout of [e0, e1, e2]. */ + num_atom = num_band / 3; + inv_sqrt_masses = (double *)malloc(sizeof(double) * num_atom); + for (i = 0; i < num_atom; i++) + { + inv_sqrt_masses[i] = 1.0 / sqrt(masses[i]); + } + + for (i = 0; i < 3 * num_band; i++) { for (j = 0; j < num_atom; j++) { @@ -118,12 +106,6 @@ void reciprocal_to_normal_squared(double *fc3_normal_squared, real = lapack_complex_double_real(e0[i * num_band + j * 3 + k]); imag = lapack_complex_double_imag(e0[i * num_band + j * 3 + k]); e0[i * num_band + j * 3 + k] = lapack_make_complex_double(real * inv_sqrt_masses[j], imag * inv_sqrt_masses[j]); - real = lapack_complex_double_real(e1[i * num_band + j * 3 + k]); - imag = lapack_complex_double_imag(e1[i * num_band + j * 3 + k]); - e1[i * num_band + j * 3 + k] = lapack_make_complex_double(real * inv_sqrt_masses[j], imag * inv_sqrt_masses[j]); - real = lapack_complex_double_real(e2[i * num_band + j * 3 + k]); - imag = lapack_complex_double_imag(e2[i * num_band + j * 3 + k]); - e2[i * num_band + j * 3 + k] = lapack_make_complex_double(real * inv_sqrt_masses[j], imag * inv_sqrt_masses[j]); } } } @@ -148,21 +130,21 @@ void reciprocal_to_normal_squared(double *fc3_normal_squared, #endif for (i = 0; i < num_g_pos; i++) { - if (freqs0[band_indices[g_pos[i][0]]] > cutoff_frequency) + if (freqs0[band_indices[g_pos[i][0]]] > cutoff_frequency && + freqs1[g_pos[i][1]] > cutoff_frequency && + freqs2[g_pos[i][2]] > cutoff_frequency) { - fc3_normal_squared[g_pos[i][3]] = get_fc3_sum(band_indices[g_pos[i][0]], - g_pos[i][1], - g_pos[i][2], - freqs0, - freqs1, - freqs2, - e0, - e1, - e2, - fc3_reciprocal, - num_atom, - num_band, - cutoff_frequency); + fc3_normal_squared[g_pos[i][3]] = + get_fc3_sum(e0 + band_indices[g_pos[i][0]] * num_band, + e1 + g_pos[i][1] * num_band, + e2 + g_pos[i][2] * num_band, + fc3_reciprocal, + num_band) / + (freqs0[band_indices[g_pos[i][0]]] * freqs1[g_pos[i][1]] * freqs2[g_pos[i][2]]); + } + else + { + fc3_normal_squared[g_pos[i][3]] = 0; } } @@ -174,80 +156,34 @@ void reciprocal_to_normal_squared(double *fc3_normal_squared, free(e0); e0 = NULL; - free(e1); e1 = NULL; - free(e2); e2 = NULL; } -static double get_fc3_sum(const long bi0, - const long bi1, - const long bi2, - const double *freqs0, - const double *freqs1, - const double *freqs2, - const lapack_complex_double *e0, +static double get_fc3_sum(const lapack_complex_double *e0, const lapack_complex_double *e1, const lapack_complex_double *e2, const lapack_complex_double *fc3_reciprocal, - const long num_atom, - const long num_band, - const double cutoff_frequency) + const long num_band) { - double fff; - - if (freqs1[bi1] > cutoff_frequency && freqs2[bi2] > cutoff_frequency) - { - fff = freqs0[bi0] * freqs1[bi1] * freqs2[bi2]; - return fc3_sum_in_reciprocal_to_normal(e0 + bi0 * num_band, - e1 + bi1 * num_band, - e2 + bi2 * num_band, - fc3_reciprocal, - num_atom) / - fff; - } - else - { - return 0; - } -} - -static double fc3_sum_in_reciprocal_to_normal(const lapack_complex_double *e0, - const lapack_complex_double *e1, - const lapack_complex_double *e2, - const lapack_complex_double *fc3_reciprocal, - const long num_atom) -{ - long index_l, index_lm, index_lmn, i, j, k, l, m, n; + long i, j, k; double sum_real, sum_imag; lapack_complex_double e_01, e_012, e_012_fc3; sum_real = 0; sum_imag = 0; - for (l = 0; l < num_atom; l++) + for (i = 0; i < num_band; i++) { - index_l = l * num_atom * num_atom * 27; - for (i = 0; i < 3; i++) + for (j = 0; j < num_band; j++) { - for (m = 0; m < num_atom; m++) + e_01 = phonoc_complex_prod(e0[i], e1[j]); + for (k = 0; k < num_band; k++) { - index_lm = index_l + m * num_atom * 27; - for (j = 0; j < 3; j++) - { - e_01 = phonoc_complex_prod(e0[l * 3 + i], e1[m * 3 + j]); - for (n = 0; n < num_atom; n++) - { - index_lmn = index_lm + n * 27 + i * 9 + j * 3; - for (k = 0; k < 3; k++) - { - e_012 = phonoc_complex_prod(e_01, e2[n * 3 + k]); - e_012_fc3 = phonoc_complex_prod(e_012, fc3_reciprocal[index_lmn + k]); - sum_real += lapack_complex_double_real(e_012_fc3); - sum_imag += lapack_complex_double_imag(e_012_fc3); - } - } - } + e_012 = phonoc_complex_prod(e_01, e2[k]); + e_012_fc3 = phonoc_complex_prod(e_012, fc3_reciprocal[i * num_band * num_band + j * num_band + k]); + sum_real += lapack_complex_double_real(e_012_fc3); + sum_imag += lapack_complex_double_imag(e_012_fc3); } } } From a47433277365ccd2817da44c791dfeb55a6d989d Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Mon, 9 Aug 2021 16:24:55 +0900 Subject: [PATCH 09/34] Update document --- doc/command-options.md | 231 +++++++++++++++++++++++++++++++++++------ doc/hdf5_howto.md | 2 +- 2 files changed, 200 insertions(+), 33 deletions(-) diff --git a/doc/command-options.md b/doc/command-options.md index 3692b084..62f707dc 100644 --- a/doc/command-options.md +++ b/doc/command-options.md @@ -1,4 +1,5 @@ (command_options)= + # Command options / Setting tags Phono3py is operated with command options or with a configuration file @@ -54,7 +55,6 @@ This specifies input unit cell filename. ## Calculator interface - ### `--qe` (`CALCULATOR = QE`) Quantum espresso (pw) interface is invoked. @@ -90,6 +90,7 @@ to be specified except for VASP (default) case. ``` (cf3_file_option)= + ### `--cf3-file` (command option only) This is used to create `FORCES_FC3` from a text file containing a @@ -116,6 +117,7 @@ The order of the file names is important. This option may be useful to be used together with `--cutoff-pair` option. (cf2_option)= + ### `--cf2` (command option only) This is used to create `FORCES_FC2` similarly to `--cf3` @@ -129,6 +131,7 @@ with `--dim-fc2` option. ``` (cfz_option)= + ### `--cfz` (command option only) This is used to create `FORCES_FC3` and `FORCES_FC2` subtracting @@ -148,6 +151,7 @@ forces". Sometimes quality of force constants is improved in this way. ``` (fs2f2_option)= + ### `--fs2f2` or `--force-sets-to-forces-fc2` (command option only) `FORCES_FC2` is created from phonopy's `FORCE_SETS` file. @@ -158,6 +162,7 @@ Necessary yaml lines for `phono3py_disp.yaml` is displayed as text. ``` (cfs_option)= + ### `--cfs` or `--create-force-sets` (command option only) Phonopy's `FORCE_SETS` is created from @@ -178,6 +183,7 @@ instead of `FORCES_FC3` and `phono3py_disp.yaml`. ## Supercell and primitive cell (dim_option)= + ### `--dim` (`DIM`) Supercell dimension is specified. See the @@ -186,6 +192,7 @@ When a proper `phono3py_disp.yaml` exists in the current directory, this is unnecessary to be specified. (dim_fc2_option)= + ### `--dim-fc2` (`DIM_FC2`) Supercell dimension for 2nd order force constants (for harmonic @@ -231,6 +238,7 @@ usual phono3py run without `--dim-fc2` option. ``` (pa_option)= + ### `--pa`, `--primitive-axes` (`PRIMITIVE_AXES`) Transformation matrix from a non-primitive cell to the primitive @@ -242,6 +250,7 @@ this is unnecessary to be specified. ## Displacement creation (create_displacements_option)= + ### `-d` (`CREATE_DISPLACEMENTS = .TRUE.`) Supercell with displacements are created. Using with `--amplitude` @@ -252,9 +261,10 @@ structure is not a primitive cell, e.g., `--pa="F"` if the input unit cell has F-centring. (amplitude_option)= + ### `--amplitude` (`DISPLACEMENT_DISTANCE`) -Atomic displacement distance is specified. This +Atomic displacement distance is specified. This value may be increased for the weak interaction systems and descreased when the force calculator is numerically very accurate. @@ -264,6 +274,7 @@ The default value depends on calculator. See ## Force constants (compact_fc_option)= + ### `--cfc` or `--compact-fc` (`COMPACT_FC = .TRUE.`) When creating force constants from `FORCES_FC3` and/or @@ -273,7 +284,7 @@ fc2 and `(num_patom, num_satom, num_satom)` for fc3, where `num_patom` and `num_satom` are the numbers of atoms in primtive cell and supercell. In the full size force constants case, `num_patom` is replaced by `num_satom`. Therefore if the supercell -dimension is large, this reduction of data size becomes large. If the +dimension is large, this reduction of data size becomes large. If the input crystal structure has centring {ref}`--pa ` is necessary to have smallest data size. In this case, `--pa` option has to be specified on reading. Otherwise phono3py can recognize if @@ -287,6 +298,7 @@ employs. ``` (symmetrization_option)= + ### `--sym-fc` (`FC_SYMMETRY = .TRUE.`) Second- and third-order force constants are symmetrized. The index @@ -302,6 +314,7 @@ independently applied by `--sym-fc2` (`SYMMETRIZE_FC2 = .TRUE.`) and `--sym-fc3r` (`SYMMETRIZE_FC3 = .TRUE.`), , respectively. (cf3_option)= + ### `--cutoff-fc3` or `--cutoff-fc3-distance` (`CUTOFF_FC3_DISTANCE`) This option is **not** used to reduce number of supercells with @@ -315,6 +328,7 @@ reduce the supercell size and the second choice is using `--cutoff-pair` option. (cutoff_pair_option)= + ### `--cutoff-pair` or `--cutoff-pair-distance` (`CUTOFF_PAIR_DISTANCE`) This option is only used together with `-d` option. @@ -336,6 +350,7 @@ Gamma-centered, this works in the same way as written here, https://phonopy.github.io/phonopy/setting-tags.html#mesh-mp-or-mesh-numbers. (gp_option)= + ### `--gp` (`GRID_POINTS`) Grid points are specified by their unique indices, e.g., for selecting @@ -357,6 +372,7 @@ where `--gp="0 1 2 3 4 5"` can be also written for the same purpose. (ga_option)= + ### `--ga` (`GRID_ADDRESSES`) This is used to specify grid points like `--gp` option but in their @@ -370,23 +386,26 @@ as given by `--gp` option, and the values given by `--ga` option will not be shown in log files. (bi_option)= + ### `--bi` (`BAND_INDICES`) -Band indices are specified. The output file name will be, e.g., -`gammas-mxxx-gxx(-sx)-bx.dat` where `bxbx...` shows the band -indices used to be averaged. The calculated values at indices +Band indices are specified. The calculated values at indices separated by space are averaged, and those separated by comma are -separately calculated. +separately calculated. The output file name will be, e.g., +`gammas-mxxx-gxx(-sx)-bx.dat` where `bxbx...` shows the band +indices where the values are calcualted and summed and averaged over those +bands. ```bash % phono3py --fc3 --fc2 --dim="2 2 2" --mesh="16 16 16" -c POSCAR-unitcell --nac --gp="34" --bi="4 5, 6" ``` -This may be also useful to distribute the computational demand +This option may be also useful to distribute the computational demand such like that the unit cell is large and the calculation of phonon-phonon interaction is heavy. (wgp_option)= + ### `--wgp` (command option only) Irreducible grid point indices and related information are written @@ -406,6 +425,7 @@ sampling mesh numbers for respective reciprocal axes. ``` (stp_option)= + ### `--stp` (command option only) Numbers of q-point triplets to be calculated for irreducible grid @@ -420,6 +440,7 @@ points are shown by using with `--gp` or `--ga` option. ## Brillouin zone integration (thm_option)= + ### `--thm` (`TETRAHEDRON = .TRUE.`) Tetrahedron method is used for calculation of imaginary part of self @@ -428,6 +449,7 @@ specify this unless both results by tetrahedron method and smearing method in one time execution are expected. (sigma_option)= + ### `--sigma` (`SIGMA`) $\sigma$ value of Gaussian function for smearing when @@ -439,6 +461,7 @@ numerical values. This is used when we want to test several $\sigma$ values simultaneously. (sigma_cutoff_option)= + ### `--sigma-cutoff` (`SIGMA_CUTOFF_WIDTH`) The tails of the Gaussian functions that are used to replace delta @@ -451,13 +474,14 @@ phonon-phonon interaction strength becomes much faster in exchange for it. (full_pp_option)= + ### `--full-pp` (`FULL_PP = .TRUE.`) For thermal conductivity calculation using the linear tetrahedron method (from version 1.10.5) and smearing method with `--simga-cutoff` (from version 1.12.3), only necessary elements -(i.e., that have non-zero delta functions) of phonon-phonon interaction strength, -$\bigl|\Phi_{-\lambda\lambda'\lambda''}\bigl|^2$, is calculated +(i.e., that have non-zero delta functions) of phonon-phonon interaction +strength, $\bigl|\Phi_{-\lambda\lambda'\lambda''}\bigl|^2$, is calculated due to delta functions in calculation of $\Gamma_\lambda(\omega)$, @@ -475,8 +499,7 @@ $$ But using this option, full elements of phonon-phonon interaction strength are calculated and averaged phonon-phonon interaction -strength ($P_{\mathbf{q}j}$, see {ref}`--ave-pp -`) is also given and stored. +strength ($P_{\mathbf{q}j}$, see {ref}`--ave-pp `) is also given and stored. ## Method to solve BTE @@ -510,7 +533,7 @@ documented at {ref}`direct_solution`. Phonon-isotope scattering is calculated based on the formula by Shin-ichiro Tamura, Phys. Rev. B, **27**, 858 (1983). Mass variance parameters are read from database of the natural abundance data for -elements, which refers Laeter *et al.*, Pure Appl. Chem., **75**, 683 +elements, which refers Laeter _et al._, Pure Appl. Chem., **75**, 683 (2003). ```bash @@ -521,8 +544,8 @@ elements, which refers Laeter *et al.*, Pure Appl. Chem., **75**, 683 Mass variance parameters are specified by this option to include phonon-isotope scattering effect in the same way as `--isotope` -option. For example of GaN, this may be set like `--mv="1.97e-4 -1.97e-4 0 0"`. The number of elements has to correspond to the number +option. For example of GaN, this may be set like `--mv="1.97e-4 1.97e-4 0 0"`. +The number of elements has to correspond to the number of atoms in the primitive cell. Isotope effect to thermal conductivity may be checked first running @@ -552,6 +575,7 @@ metre, is just used to avoid divergence of phonon lifetime and the contribution to the thermal conducitivity is considered negligible. (ave_pp_option)= + ### `--ave-pp` (`USE_AVE_PP = .TRUE.`) Averaged phonon-phonon interaction strength ($P_{\mathbf{q}j}=P_\lambda$) @@ -612,6 +636,7 @@ to input. The physical unit of the value is $\text{eV}^2$. ``` (normal_umklapp_option)= + ### `--nu` (`N_U = .TRUE.`) Integration over q-point triplets for the calculation of @@ -668,6 +693,7 @@ Out[6]: (101, 56, 6) ## Temperature (ts_option)= + ### `--ts` (`TEMPERATURES`): Temperatures Specific temperatures are specified by `--ts`. @@ -689,6 +715,7 @@ http://phonopy.github.io/phonopy/setting-tags.html#tprop-tmin-tmax-tstep. ## Non-analytical term correction (nac_option)= + ### `--nac` (`NAC = .TRUE.`) Non-analytical term correction for harmonic phonons. Like as phonopy, @@ -703,24 +730,151 @@ at $\mathbf{q}\rightarrow \mathbf{0}$. See the detail at http://phonopy.github.io/phonopy/setting-tags.html#q-direction. (write_gamma_option)= -## Imaginary part of self energy + +## Imaginary and real parts of self energy + +Phonon self-energy of bubble diagram is written as, + +$$ +\Sigma_\lambda(\omega) = \Delta_\lambda(\omega) - i \Gamma_\lambda(\omega). +$$ + +The imaginary part and real part are written as + +$$ +\begin{align*} + \Gamma_\lambda(\omega) = \frac{18\pi}{\hbar^2} + \sum_{\lambda_1 \lambda_2} + \bigl|\Phi_{-\lambda\lambda_1\lambda_2}\bigl|^2 & + \left\{(n_{\lambda_1}+ n_{\lambda_2}+1) + \left[ \delta(\omega-\omega_{\lambda_1}-\omega_{\lambda_2}) + - \delta(\omega-\omega_{\lambda_1}-\omega_{\lambda_2}) \right] \right. + \\ + & + (n_{\lambda_1}-n_{\lambda_2}) + \left[\delta(\omega+\omega_{\lambda_1}-\omega_{\lambda_2}) + - \left. \delta(\omega-\omega_{\lambda_1}+\omega_{\lambda_2}) + \right]\right\}, + \end{align*} +$$ + +and + +$$ +\begin{align*} +\Delta_\lambda(\omega) = \frac{18\pi}{\hbar^2} + \sum_{\lambda_1 \lambda_2} + \bigl|\Phi_{-\lambda\lambda_1\lambda_2}\bigl|^2 & + \left\{ + \left[ \frac{(n_{\lambda_1}+ n_{\lambda_2}+1)}{ + (\omega-\omega_{\lambda_1}-\omega_{\lambda_2})_\mathrm{p}} + - \frac{(n_{\lambda_1}+ n_{\lambda_2}+1)}{ + (\omega+\omega_{\lambda_1}+\omega_{\lambda_2})_\mathrm{p}} + \right] + \right. \\ + & + \left[ + \frac{(n_{\lambda_1}-n_{\lambda_2})}{(\omega + + \omega_{\lambda_1} - \omega_{\lambda_2})_\mathrm{p}} + - \left. \frac{(n_{\lambda_1}-n_{\lambda_2})}{(\omega - + \omega_{\lambda_1} + \omega_{\lambda_2})_\mathrm{p}} + \right]\right\}, +\end{align*} +$$ + +respectively. In the above formulae, angular frequency $\omega$ is used, +but in the calculation results, ordinal frequency $\nu$ is used. Be careful +about $2\pi$ treatment. (ise_option)= + ### `--ise` (`IMAG_SELF_ENERGY = .TRUE.`) Imaginary part of self energy $\Gamma_\lambda(\omega)$ is -calculated with respect to $\omega$. The output is written to -`gammas-mxxx-gx(-sx)-tx-bx.dat` in THz (without $2\pi$) -with respect to frequency in THz (without $2\pi$). Frequency sampling -points can be specified by {ref}`freq_sampling_option`. +calculated with respect to frequency $\omega$, where $\omega$ is sampled +following {ref}`freq_sampling_option`. The output of $\Gamma_\lambda(\omega)$ +is written to `gammas-mxxx-gx(-sx)-tx-bx.dat` in THz (without $2\pi$) +with respect to samplied frequency points of $\omega$ in THz (without $2\pi$). ```bash % phono3py --fc3 --fc2 --dim="2 2 2" --mesh="16 16 16" -c POSCAR-unitcell --nac --q-direction="1 0 0" --gp=0 --ise --bi="4 5, 6" ``` +(rse_option)= + +### `--rse` (`REAL_SELF_ENERGY = .TRUE.`) + +Real part of self energy $\Delta_\lambda(\omega)$ is +calculated with respect to frequency $\omega$, where $\omega$ is sampled +following {ref}`freq_sampling_option`. With this option, only smearing +approach is provide, for which values given by `--sigma` option are +used to approximate the principal +value as $\varepsilon$ in the following equation: + +$$ +\mathcal{P} \int^{\omega_\text{min}}_{\omega_\text{max}} +\frac{f(\omega)}{\omega} dx +\sim +\lim_{\varepsilon \rightarrow 0} \int^{\omega_\text{min}}_{\omega_\text{max}} +\frac{\omega}{\omega^2 + \varepsilon^2} f(\omega) dx +$$ + +where $\mathcal{P}$ denotes the Cauchy principal value. +The output of $\Delta_\lambda(\omega)$ +is written to `deltas-mxxx-gx-sx-tx-bx.dat` in THz (without $2\pi$) +with respect to samplied frequency points of $\omega$ in THz (without $2\pi$). + +```bash +% phono3py --fc3 --fc2 --dim="2 2 2" --mesh="16 16 16" -c POSCAR-unitcell --nac --q-direction="1 0 0" --gp=0 --rse --sigma="0.1" --bi="4 5, 6" +``` + +## Spectral function + +Phonon spectral function of bubble diagram is written as + +$$ +A_\lambda(\omega) = \frac{1}{\pi} \frac{4\Omega^2_\lambda + \Gamma_\lambda(\omega)} + {\left[\omega^2 - \Omega^2_\lambda - + 2\Omega_\lambda \Delta_\lambda(\omega) \right]^2 + + \left[ 2\Omega_\lambda + \Gamma_\lambda(\omega) \right]^2}, +$$ + +where $A_\lambda(\omega)$ is defined to be normalized as + +$$ + \int_0^\infty \frac{d\omega}{2\pi} A_\lambda(\omega) = 1. +$$ + +### `--spf` (`SPECTRAL_FUNCTION = .TRUE.`) + +Spectral function of self energy $A_\lambda(\omega)$ is +calculated with respect to frequency $\omega$, where $\omega$ is sampled +following {ref}`freq_sampling_option`. First, imaginary part of self-energy is calculated +and then the real part is calculatd using the Kramers–Kronig relation. +The output of $A_\lambda(\omega)$ +is written to `spectral-mxxx-gx(-sx)-tx-bx.dat` in THz (without $2\pi$) +with respect to samplied frequency points of $\omega$ in THz (without $2\pi$), +and `spectral-mxxx-gx.hdf5`. + +```bash +% phono3py --fc3 --fc2 --dim="2 2 2" --mesh="16 16 16" -c POSCAR-unitcell --nac --q-direction="1 0 0" --gp=0 --spf +``` + +```{note} +When `--bi` option is unspecified, spectral functions of all bands are +calculated and the sum divided by the number of bands is stored in +`spectral-mxxx-gx(-sx)-tx-bx.dat`, i.e., +$(\sum_j A_{\mathbf{q}j}) / N_\text{b}$, where $N_\text{b}$ is the +number of bands and $\lambda \equiv (\mathbf{q},j)$ is the phonon mode. +The spectral function of each band is written in the hdf5 +file, where $A_{\mathrm{q}j}$ is normalied as given above, i.e., numerical +sum of stored value for each band should become roughly 1. +``` + ## Joint density of states (jdos_option)= + ### `--jdos` (`JOINT_DOS = .TRUE.`) Two classes of joint density of states (JDOS) are calculated. The @@ -733,14 +887,16 @@ The first column is the frequency, and the second and third columns are the values given as follows, respectively, $$ -&D_2^{(1)}(\mathbf{q}, \omega) = \frac{1}{N} +\begin{align} +& D_2^{(1)}(\mathbf{q}, \omega) = \frac{1}{N} \sum_{\lambda',\lambda''} \Delta(-\mathbf{q}+\mathbf{q}'+\mathbf{q}'') \left[\delta(\omega+\omega_{\lambda'}-\omega_{\lambda''}) + \delta(\omega-\omega_{\lambda'}+\omega_{\lambda''}) \right], \\ -&D_2^{(2)}(\mathbf{q}, \omega) = \frac{1}{N} +& D_2^{(2)}(\mathbf{q}, \omega) = \frac{1}{N} \sum_{\lambda',\lambda''} \Delta(-\mathbf{q}+\mathbf{q}'+\mathbf{q}'') \delta(\omega-\omega_{\lambda'} -\omega_{\lambda''}). +\end{align} $$ ```bash @@ -756,15 +912,17 @@ first column is the frequency, and the second and third columns are the values given as follows, respectively, $$ -&N_2^{(1)}(\mathbf{q}, \omega) = \frac{1}{N} +\begin{align} +& N_2^{(1)}(\mathbf{q}, \omega) = \frac{1}{N} \sum_{\lambda'\lambda''} \Delta(-\mathbf{q}+\mathbf{q}'+\mathbf{q}'') (n_{\lambda'} - n_{\lambda''}) [ \delta( \omega + \omega_{\lambda'} - \omega_{\lambda''}) - \delta( \omega - \omega_{\lambda'} + \omega_{\lambda''})], \\ -&N_2^{(2)}(\mathbf{q}, \omega) = \frac{1}{N} +& N_2^{(2)}(\mathbf{q}, \omega) = \frac{1}{N} \sum_{\lambda'\lambda''} \Delta(-\mathbf{q}+\mathbf{q}'+\mathbf{q}'') (n_{\lambda'}+ n_{\lambda''}+1) \delta( \omega - \omega_{\lambda'} - \omega_{\lambda''}). +\end{align} $$ ```bash @@ -780,11 +938,13 @@ This is an example of `Si-PBEsol`. ## Sampling frequency for distribution functions (freq_sampling_option)= + ### `--num-freq-points`, `--freq-pitch` (`NUM_FREQUENCY_POINTS`) -For spectrum like calculations of imaginary part of self energy and -JDOS, number of sampling frequency points is controlled by -`--num-freq-points` or `--freq-pitch`. +For spectrum-like calculations of imaginary part of self energy, spectral +function, and JDOS, number or interval of uniform sampling frequency points is +controlled by `--num-freq-points` or `--freq-pitch`. Both are unspecified, +default value of `--num-freq-points` of 200 is used. ## Mode-Gruneisen parameter from 3rd order force constants @@ -818,17 +978,18 @@ Read 3rd order force constants from `fc3.hdf5`. Imaginary parts of self energy at harmonic phonon frequencies $\Gamma_\lambda(\omega_\lambda)$ are written into file in hdf5 -format. The result is written into `kappa-mxxx-gx(-sx-sdx).hdf5` or +format. The result is written into `kappa-mxxx-gx(-sx-sdx).hdf5` or `kappa-mxxx-gx-bx(-sx-sdx).hdf5` with `--bi` option. With `--sigma` and `--sigma-cutoff` options, `-sx` and `--sdx` are inserted, respectively, in front of `.hdf5`. (read_gamma_option)= + ### `--read-gamma` (`READ_GAMMA = .TRUE.`) Imaginary parts of self energy at harmonic phonon frequencies $\Gamma_\lambda(\omega_\lambda)$ -are read from `kappa` file in hdf5 format. Initially the usual +are read from `kappa` file in hdf5 format. Initially the usual result file of `kappa-mxxx(-sx-sdx).hdf5` is searched. Unless it is found, it tries to read `kappa` file for each grid point, `kappa-mxxx-gx(-sx-sdx).hdf5`. Then, similarly, @@ -836,6 +997,7 @@ found, it tries to read `kappa` file for each grid point, `kappa-mxxx-gx-bx(-sx-sdx).hdf5` files for band indices are searched. (write_detailed_gamma_option)= + ### `--write-gamma-detail` (`WRITE_GAMMA_DETAIL = .TRUE.`) Each q-point triplet contribution to imaginary part of self energy is @@ -906,11 +1068,11 @@ np.dot(weight, contrib_tp) # is one ``` (write_phonon_option)= + ### `--write-phonon` (`WRITE_PHONON = .TRUE.`) Phonon frequencies, eigenvectors, and grid point addresses are stored -in `phonon-mxxx.hdf5` file. {ref}`--pa ` and {ref}`--nac -` may be required depending on calculation setting. +in `phonon-mxxx.hdf5` file. {ref}`--pa ` and {ref}`--nac ` may be required depending on calculation setting. ```bash % phono3py --fc2 --dim="2 2 2" --pa="F" --mesh="11 11 11" -c POSCAR-unitcell --nac --write-phoonon @@ -952,7 +1114,8 @@ vectors. This is convenient to categorize phonon triplets into Umklapp and Normal scatterings based on the Brillouin zone. (read_phonon_option)= -### `--read-phonon` (`READ_PHONON = .TRUE.`) + +### `--read-phonon` (`READ_PHONON = .TRUE.`) Phonon frequencies, eigenvectors, and grid point addresses are read from `phonon-mxxx.hdf5` file and the calculation is continued using @@ -967,6 +1130,7 @@ may be required depending on calculation setting. ``` (write_read_pp_option)= + ### `--write-pp` (`WRITE_PP = .TRUE.`) and `--read-pp` (`READ_PP = .TRUE.`) Phonon-phonon (ph-ph) intraction strengths are written to and read @@ -990,6 +1154,7 @@ than usual RTA calculation. ``` (hdf5_compression_option)= + ### `--hdf5-compression` (command option only) Most of phono3py HDF5 output file is compressed by default with the @@ -1000,6 +1165,7 @@ documentation (http://docs.h5py.org/en/stable/high/dataset.html#filter-pipeline). (output_filename_option)= + ### `-o` (command option only) This modifies default output file names to write. @@ -1018,6 +1184,7 @@ This rule is applied to - `gamma_detail-xxx.hdf5` (write only) (input_filename_option)= + ### `-i` (command option only) This modifies default input file names to read. diff --git a/doc/hdf5_howto.md b/doc/hdf5_howto.md index 4041ab27..bf90878d 100644 --- a/doc/hdf5_howto.md +++ b/doc/hdf5_howto.md @@ -279,7 +279,7 @@ $$ For example, $\kappa_{\lambda,{xx}}$ is calculated by: -```badh +```bash In [1]: import h5py In [2]: f = h5py.File("kappa-m111111.hdf5") From e4c2d1396aeb20f49e742af0f3853d8186cab4b5 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Fri, 1 Oct 2021 23:07:55 +0900 Subject: [PATCH 10/34] Minor refactoring --- phono3py/api_phono3py.py | 1059 ++++++++++++++++++++++---------------- phono3py/cui/load.py | 504 ++++++++++-------- 2 files changed, 881 insertions(+), 682 deletions(-) diff --git a/phono3py/api_phono3py.py b/phono3py/api_phono3py.py index 8dff02e6..ab82fa20 100644 --- a/phono3py/api_phono3py.py +++ b/phono3py/api_phono3py.py @@ -37,8 +37,12 @@ import warnings import numpy as np from phonopy.structure.symmetry import Symmetry from phonopy.structure.cells import ( - get_supercell, get_primitive, guess_primitive_matrix, - shape_supercell_matrix, get_primitive_matrix) + get_supercell, + get_primitive, + guess_primitive_matrix, + shape_supercell_matrix, + get_primitive_matrix, +) from phonopy.structure.atoms import PhonopyAtoms from phonopy.structure.dataset import get_displacements_and_forces from phonopy.units import VaspToTHz @@ -46,28 +50,38 @@ from phonopy.harmonic.force_constants import ( symmetrize_force_constants, symmetrize_compact_force_constants, set_translational_invariance, - set_permutation_symmetry) + set_permutation_symmetry, +) from phonopy.harmonic.force_constants import get_fc2 as get_phonopy_fc2 from phonopy.interface.fc_calculator import get_fc2 from phonopy.harmonic.displacement import ( - get_least_displacements, directions_to_displacement_dataset) + get_least_displacements, + directions_to_displacement_dataset, +) from phono3py.version import __version__ -from phono3py.phonon3.imag_self_energy import (get_imag_self_energy, - write_imag_self_energy) +from phono3py.phonon3.imag_self_energy import ( + get_imag_self_energy, + write_imag_self_energy, +) from phono3py.phonon3.real_self_energy import ( - get_real_self_energy, write_real_self_energy) + get_real_self_energy, + write_real_self_energy, +) from phono3py.phonon3.spectral_function import run_spectral_function from phono3py.phonon3.interaction import Interaction from phono3py.phonon3.conductivity_RTA import get_thermal_conductivity_RTA from phono3py.phonon3.conductivity_LBTE import get_thermal_conductivity_LBTE -from phono3py.phonon3.displacement_fc3 import (get_third_order_displacements, - direction_to_displacement) +from phono3py.phonon3.displacement_fc3 import ( + get_third_order_displacements, + direction_to_displacement, +) from phono3py.phonon3.fc3 import ( set_permutation_symmetry_fc3, set_permutation_symmetry_compact_fc3, set_translational_invariance_fc3, set_translational_invariance_compact_fc3, - cutoff_fc3_by_zero) + cutoff_fc3_by_zero, +) from phono3py.phonon3.fc3 import get_fc3 as get_phono3py_fc3 from phono3py.phonon.grid import BZGrid from phono3py.phonon3.dataset import get_displacements_and_forces_fc3 @@ -116,27 +130,29 @@ class Phono3py(object): """ - def __init__(self, - unitcell, - supercell_matrix, - primitive_matrix=None, - phonon_supercell_matrix=None, - masses=None, - band_indices=None, - sigmas=None, - sigma_cutoff=None, - cutoff_frequency=1e-4, - frequency_factor_to_THz=VaspToTHz, - is_symmetry=True, - is_mesh_symmetry=True, - use_grg=False, - symmetrize_fc3q=None, - store_dense_gp_map=True, - store_dense_svecs=True, - symprec=1e-5, - calculator=None, - log_level=0, - lapack_zheev_uplo=None): + def __init__( + self, + unitcell, + supercell_matrix, + primitive_matrix=None, + phonon_supercell_matrix=None, + masses=None, + band_indices=None, + sigmas=None, + sigma_cutoff=None, + cutoff_frequency=1e-4, + frequency_factor_to_THz=VaspToTHz, + is_symmetry=True, + is_mesh_symmetry=True, + use_grg=False, + symmetrize_fc3q=None, + store_dense_gp_map=True, + store_dense_svecs=True, + symprec=1e-5, + calculator=None, + log_level=0, + lapack_zheev_uplo=None, + ): """Init method. Parameters @@ -224,7 +240,8 @@ class Phono3py(object): self._nac_params = None if phonon_supercell_matrix is not None: self._phonon_supercell_matrix = shape_supercell_matrix( - phonon_supercell_matrix) + phonon_supercell_matrix + ) else: self._phonon_supercell_matrix = None self._supercell = None @@ -236,7 +253,9 @@ class Phono3py(object): self._build_phonon_supercell() self._build_phonon_primitive_cell() - self._sigmas = [None, ] + self._sigmas = [ + None, + ] self._sigma_cutoff = None # Grid @@ -282,36 +301,43 @@ class Phono3py(object): self._set_band_indices() if masses is not None: - warnings.warn("Phono3py init parameter of masses is deprecated. " - "Use Phono3py.masses attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py init parameter of masses is deprecated. " + "Use Phono3py.masses attribute instead.", + DeprecationWarning, + ) self.masses = masses if band_indices is not None: warnings.warn( "Phono3py init parameter of band_indices is deprecated. " "Use Phono3py.band_indices attribute instead.", - DeprecationWarning) + DeprecationWarning, + ) self.band_indices = band_indices if sigmas is not None: - warnings.warn("Phono3py init parameter of sigmas is deprecated. " - "Use Phono3py.sigmas attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py init parameter of sigmas is deprecated. " + "Use Phono3py.sigmas attribute instead.", + DeprecationWarning, + ) self.sigmas = sigmas if sigma_cutoff is not None: warnings.warn( "Phono3py init parameter of sigma_cutoff is deprecated. " "Use Phono3py.sigma_cutoff attribute instead.", - DeprecationWarning) + DeprecationWarning, + ) self.sigma_cutoff = sigma_cutoff if symmetrize_fc3q is not None: warnings.warn( "Phono3py init parameter of symmetrize_fc3q is deprecated. " "Set this at Phono3py.init_phph_interaction().", - DeprecationWarning) + DeprecationWarning, + ) self._symmetrize_fc3q = symmetrize_fc3q else: self._symmetrize_fc3q = None @@ -320,7 +346,8 @@ class Phono3py(object): warnings.warn( "Phono3py init parameter of lapack_zheev_uplo is deprecated. " "Set this at Phono3py.init_phph_interaction().", - DeprecationWarning) + DeprecationWarning, + ) self._lapack_zheev_uplo = lapack_zheev_uplo else: self._lapack_zheev_uplo = None @@ -337,9 +364,11 @@ class Phono3py(object): def get_version(self): """Return phono3py release version number.""" - warnings.warn("Phono3py.get_version() is deprecated." - "Use Phono3py.version attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.get_version() is deprecated." + "Use Phono3py.version attribute instead.", + DeprecationWarning, + ) return self.version @property @@ -371,16 +400,18 @@ class Phono3py(object): def get_fc3(self): """Return third order force constants (fc3).""" - warnings.warn("Phono3py.get_fc3() is deprecated." - "Use Phono3py.fc3 attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.get_fc3() is deprecated." "Use Phono3py.fc3 attribute instead.", + DeprecationWarning, + ) return self.fc3 def set_fc3(self, fc3): """Set fc3.""" - warnings.warn("Phono3py.set_fc3() is deprecated." - "Use Phono3py.fc3 attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.set_fc3() is deprecated." "Use Phono3py.fc3 attribute instead.", + DeprecationWarning, + ) self.fc3 = fc3 @property @@ -402,16 +433,18 @@ class Phono3py(object): def get_fc2(self): """Return second order force constants (fc2).""" - warnings.warn("Phono3py.get_fc2() is deprecated." - "Use Phono3py.fc2 attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.get_fc2() is deprecated." "Use Phono3py.fc2 attribute instead.", + DeprecationWarning, + ) return self.fc2 def set_fc2(self, fc2): """Set fc2.""" - warnings.warn("Phono3py.set_fc2() is deprecated." - "Use Phono3py.fc2 attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.set_fc2() is deprecated." "Use Phono3py.fc2 attribute instead.", + DeprecationWarning, + ) self.fc2 = fc2 @property @@ -434,9 +467,13 @@ class Phono3py(object): @sigmas.setter def sigmas(self, sigmas): if sigmas is None: - self._sigmas = [None, ] + self._sigmas = [ + None, + ] elif isinstance(sigmas, float) or isinstance(sigmas, int): - self._sigmas = [float(sigmas), ] + self._sigmas = [ + float(sigmas), + ] else: self._sigmas = [] for s in sigmas: @@ -487,16 +524,20 @@ class Phono3py(object): def get_nac_params(self): """Return NAC parameters.""" - warnings.warn("Phono3py.get_nac_params() is deprecated." - "Use Phono3py.nac_params attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.get_nac_params() is deprecated." + "Use Phono3py.nac_params attribute instead.", + DeprecationWarning, + ) return self.nac_params def set_nac_params(self, nac_params): """Set NAC parameters.""" - warnings.warn("Phono3py.set_nac_params() is deprecated." - "Use Phono3py.nac_params attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.set_nac_params() is deprecated." + "Use Phono3py.nac_params attribute instead.", + DeprecationWarning, + ) self.nac_params = nac_params @property @@ -524,9 +565,11 @@ class Phono3py(object): def get_primitive(self): """Return primitive cell.""" - warnings.warn("Phono3py.get_primitive() is deprecated." - "Use Phono3py.primitive attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.get_primitive() is deprecated." + "Use Phono3py.primitive attribute instead.", + DeprecationWarning, + ) return self.primitive @property @@ -541,9 +584,11 @@ class Phono3py(object): def get_unitcell(self): """Return Unit cell.""" - warnings.warn("Phono3py.get_unitcell() is deprecated." - "Use Phono3py.unitcell attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.get_unitcell() is deprecated." + "Use Phono3py.unitcell attribute instead.", + DeprecationWarning, + ) return self.unitcell @property @@ -558,9 +603,11 @@ class Phono3py(object): def get_supercell(self): """Return supercell.""" - warnings.warn("Phono3py.get_supercell() is deprecated." - "Use Phono3py.supercell attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.get_supercell() is deprecated." + "Use Phono3py.supercell attribute instead.", + DeprecationWarning, + ) return self.supercell @property @@ -575,9 +622,11 @@ class Phono3py(object): def get_phonon_supercell(self): """Return supercell for fc2.""" - warnings.warn("Phono3py.get_phonon_supercell() is deprecated." - "Use Phono3py.phonon_supercell attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.get_phonon_supercell() is deprecated." + "Use Phono3py.phonon_supercell attribute instead.", + DeprecationWarning, + ) return self.phonon_supercell @property @@ -594,9 +643,11 @@ class Phono3py(object): def get_phonon_primitive(self): """Return primitive cell for fc2.""" - warnings.warn("Phono3py.get_phonon_primitive() is deprecated." - "Use Phono3py.phonon_primitive attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.get_phonon_primitive() is deprecated." + "Use Phono3py.phonon_primitive attribute instead.", + DeprecationWarning, + ) return self.phonon_primitive @property @@ -611,9 +662,11 @@ class Phono3py(object): def get_symmetry(self): """Return symmetry of supercell.""" - warnings.warn("Phono3py.get_symmetry() is deprecated." - "Use Phono3py.symmetry attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.get_symmetry() is deprecated." + "Use Phono3py.symmetry attribute instead.", + DeprecationWarning, + ) return self.symmetry @property @@ -628,9 +681,11 @@ class Phono3py(object): def get_primitive_symmetry(self): """Return symmetry of primitive cell.""" - warnings.warn("Phono3py.get_primitive_symmetry() is deprecated." - "Use Phono3py.primitive_symmetry attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.get_primitive_symmetry() is deprecated." + "Use Phono3py.primitive_symmetry attribute instead.", + DeprecationWarning, + ) return self.primitive_symmetry @property @@ -648,7 +703,8 @@ class Phono3py(object): warnings.warn( "Phono3py.get_phonon_supercell_symmetry() is deprecated." "Use Phono3py.phonon_supercell_symmetry attribute instead.", - DeprecationWarning) + DeprecationWarning, + ) return self.phonon_supercell_symmetry @property @@ -664,9 +720,11 @@ class Phono3py(object): def get_supercell_matrix(self): """Return transformation matrix to supercell cell from unit cell.""" - warnings.warn("Phono3py.get_supercell_matrix() is deprecated." - "Use Phono3py.supercell_matrix attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.get_supercell_matrix() is deprecated." + "Use Phono3py.supercell_matrix attribute instead.", + DeprecationWarning, + ) return self.supercell_matrix @property @@ -685,7 +743,8 @@ class Phono3py(object): warnings.warn( "Phono3py.get_phonon_supercell_matrix() is deprecated." "Use Phono3py.phonon_supercell_matrix attribute instead.", - DeprecationWarning) + DeprecationWarning, + ) return self.phonon_supercell_matrix @property @@ -701,9 +760,11 @@ class Phono3py(object): def get_primitive_matrix(self): """Return transformation matrix to primitive cell from unit cell.""" - warnings.warn("Phono3py.get_primitive_matrix() is deprecated." - "Use Phono3py.primitive_matrix attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.get_primitive_matrix() is deprecated." + "Use Phono3py.primitive_matrix attribute instead.", + DeprecationWarning, + ) return self.primitive_matrix @property @@ -720,9 +781,11 @@ class Phono3py(object): def set_displacement_dataset(self, dataset): """Set displacement-force dataset.""" - warnings.warn("Phono3py.set_displacement_dataset() is deprecated." - "Use Phono3py.dataset attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.set_displacement_dataset() is deprecated." + "Use Phono3py.dataset attribute instead.", + DeprecationWarning, + ) self._dataset = dataset @property @@ -772,16 +835,19 @@ class Phono3py(object): @property def displacement_dataset(self): """Return displacement-force dataset.""" - warnings.warn("Phono3py.displacement_dataset is deprecated." - "Use Phono3py.dataset.", - DeprecationWarning) + warnings.warn( + "Phono3py.displacement_dataset is deprecated." "Use Phono3py.dataset.", + DeprecationWarning, + ) return self.dataset def get_displacement_dataset(self): """Return displacement-force dataset.""" - warnings.warn("Phono3py.get_displacement_dataset() is deprecated." - "Use Phono3py.dataset.", - DeprecationWarning) + warnings.warn( + "Phono3py.get_displacement_dataset() is deprecated." + "Use Phono3py.dataset.", + DeprecationWarning, + ) return self.displacement_dataset @property @@ -815,9 +881,11 @@ class Phono3py(object): @property def phonon_displacement_dataset(self): """Return phonon dispalcement-force dataset.""" - warnings.warn("Phono3py.phonon_displacement_dataset is deprecated." - "Use Phono3py.phonon_dataset.", - DeprecationWarning) + warnings.warn( + "Phono3py.phonon_displacement_dataset is deprecated." + "Use Phono3py.phonon_dataset.", + DeprecationWarning, + ) return self._phonon_dataset def get_phonon_displacement_dataset(self): @@ -825,7 +893,8 @@ class Phono3py(object): warnings.warn( "Phono3py.get_phonon_displacement_dataset() is deprecated." "Use Phono3py.phonon_dataset.", - DeprecationWarning) + DeprecationWarning, + ) return self.phonon_displacement_dataset @property @@ -845,19 +914,20 @@ class Phono3py(object): def set_band_indices(self, band_indices): """Set band indices.""" - warnings.warn("Phono3py.set_band_indices() is deprecated." - "Use Phono3py.band_indices attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.set_band_indices() is deprecated." + "Use Phono3py.band_indices attribute instead.", + DeprecationWarning, + ) self.band_indices = 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="int_")] else: self._band_indices = band_indices - self._band_indices_flatten = np.hstack( - self._band_indices).astype('int_') + self._band_indices_flatten = np.hstack(self._band_indices).astype("int_") @property def masses(self): @@ -878,8 +948,7 @@ class Phono3py(object): self._unitcell.masses = u_masses self._phonon_primitive.masses = p_masses p2p_map = self._phonon_primitive.p2p_map - s_masses = p_masses[ - [p2p_map[x] for x in self._phonon_primitive.s2p_map]] + s_masses = p_masses[[p2p_map[x] for x in self._phonon_primitive.s2p_map]] self._phonon_supercell.masses = s_masses @property @@ -900,7 +969,8 @@ class Phono3py(object): warnings.warn( "Phono3py.get_supercells_with_displacements() is deprecated." "Use Phono3py.supercells_with_displacements attribute instead.", - DeprecationWarning) + DeprecationWarning, + ) return self.supercells_with_displacements @property @@ -914,10 +984,11 @@ class Phono3py(object): """ if self._phonon_supercells_with_displacements is None: if self._phonon_dataset is not None: - self._phonon_supercells_with_displacements = \ - self._build_phonon_supercells_with_displacements( - self._phonon_supercell, - self._phonon_dataset) + self._phonon_supercells_with_displacements = ( + self._build_phonon_supercells_with_displacements( + self._phonon_supercell, self._phonon_dataset + ) + ) return self._phonon_supercells_with_displacements def get_phonon_supercells_with_displacements(self): @@ -926,7 +997,8 @@ class Phono3py(object): "Phono3py.get_phonon_supercells_with_displacements() " "is deprecated. Use Phono3py.phonon_supercells_with_displacements " "attribute instead.", - DeprecationWarning) + DeprecationWarning, + ) return self.phonon_supercells_with_displacements @property @@ -948,9 +1020,11 @@ class Phono3py(object): def get_thermal_conductivity(self): """Return thermal conductivity class instance.""" - warnings.warn("Phono3py.get_thermal_conductivity() is deprecated." - "Use Phono3py.thermal_conductivity attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.get_thermal_conductivity() is deprecated." + "Use Phono3py.thermal_conductivity attribute instead.", + DeprecationWarning, + ) return self.thermal_conductivity @property @@ -974,23 +1048,25 @@ class Phono3py(object): """ dataset = self._dataset - if 'first_atoms' in dataset: - num_scells = len(dataset['first_atoms']) - for disp1 in dataset['first_atoms']: - num_scells += len(disp1['second_atoms']) + if "first_atoms" in dataset: + num_scells = len(dataset["first_atoms"]) + for disp1 in dataset["first_atoms"]: + num_scells += len(disp1["second_atoms"]) displacements = np.zeros( (num_scells, self._supercell.get_number_of_atoms(), 3), - dtype='double', order='C') + dtype="double", + order="C", + ) i = 0 - for disp1 in dataset['first_atoms']: - displacements[i, disp1['number']] = disp1['displacement'] + for disp1 in dataset["first_atoms"]: + displacements[i, disp1["number"]] = disp1["displacement"] i += 1 - for disp1 in dataset['first_atoms']: - for disp2 in disp1['second_atoms']: - displacements[i, disp2['number']] = disp2['displacement'] + for disp1 in dataset["first_atoms"]: + for disp2 in disp1["second_atoms"]: + displacements[i, disp2["number"]] = disp2["displacement"] i += 1 - elif 'forces' in dataset or 'displacements' in dataset: - displacements = dataset['displacements'] + elif "forces" in dataset or "displacements" in dataset: + displacements = dataset["displacements"] else: raise RuntimeError("displacement dataset has wrong format.") @@ -999,15 +1075,15 @@ class Phono3py(object): @displacements.setter def displacements(self, displacements): dataset = self._dataset - disps = np.array(displacements, dtype='double', order='C') + disps = np.array(displacements, dtype="double", order="C") natom = self._supercell.get_number_of_atoms() - if (disps.ndim != 3 or disps.shape[1:] != (natom, 3)): + if disps.ndim != 3 or disps.shape[1:] != (natom, 3): raise RuntimeError("Array shape of displacements is incorrect.") - if 'first_atoms' in dataset: - dataset = {'displacements': disps} - elif 'displacements' in dataset or 'forces' in dataset: - dataset['displacements'] = disps + if "first_atoms" in dataset: + dataset = {"displacements": disps} + elif "displacements" in dataset or "forces" in dataset: + dataset["displacements"] = disps @property def forces(self): @@ -1025,22 +1101,24 @@ class Phono3py(object): """ dataset = self._dataset - if 'forces' in dataset: - return dataset['forces'] - elif 'first_atoms' in dataset: - num_scells = len(dataset['first_atoms']) - for disp1 in dataset['first_atoms']: - num_scells += len(disp1['second_atoms']) + if "forces" in dataset: + return dataset["forces"] + elif "first_atoms" in dataset: + num_scells = len(dataset["first_atoms"]) + for disp1 in dataset["first_atoms"]: + num_scells += len(disp1["second_atoms"]) forces = np.zeros( (num_scells, self._supercell.get_number_of_atoms(), 3), - dtype='double', order='C') + dtype="double", + order="C", + ) i = 0 - for disp1 in dataset['first_atoms']: - forces[i] = disp1['forces'] + for disp1 in dataset["first_atoms"]: + forces[i] = disp1["forces"] i += 1 - for disp1 in dataset['first_atoms']: - for disp2 in disp1['second_atoms']: - forces[i] = disp2['forces'] + for disp1 in dataset["first_atoms"]: + for disp2 in disp1["second_atoms"]: + forces[i] = disp2["forces"] i += 1 return forces else: @@ -1048,19 +1126,19 @@ class Phono3py(object): @forces.setter def forces(self, forces_fc3): - forces = np.array(forces_fc3, dtype='double', order='C') + forces = np.array(forces_fc3, dtype="double", order="C") dataset = self._dataset - if 'first_atoms' in dataset: + if "first_atoms" in dataset: i = 0 - for disp1 in dataset['first_atoms']: - disp1['forces'] = forces[i] + for disp1 in dataset["first_atoms"]: + disp1["forces"] = forces[i] i += 1 - for disp1 in dataset['first_atoms']: - for disp2 in disp1['second_atoms']: - disp2['forces'] = forces[i] + for disp1 in dataset["first_atoms"]: + for disp2 in disp1["second_atoms"]: + disp2["forces"] = forces[i] i += 1 - elif 'displacements' in dataset or 'forces' in dataset: - dataset['forces'] = forces + elif "displacements" in dataset or "forces" in dataset: + dataset["forces"] = forces @property def phonon_displacements(self): @@ -1083,15 +1161,14 @@ class Phono3py(object): raise RuntimeError("phonon_displacement_dataset does not exist.") dataset = self._phonon_dataset - if 'first_atoms' in dataset: - num_scells = len(dataset['first_atoms']) + if "first_atoms" in dataset: + num_scells = len(dataset["first_atoms"]) natom = self._phonon_supercell.get_number_of_atoms() - displacements = np.zeros( - (num_scells, natom, 3), dtype='double', order='C') - for i, disp1 in enumerate(dataset['first_atoms']): - displacements[i, disp1['number']] = disp1['displacement'] - elif 'forces' in dataset or 'displacements' in dataset: - displacements = dataset['displacements'] + displacements = np.zeros((num_scells, natom, 3), dtype="double", order="C") + for i, disp1 in enumerate(dataset["first_atoms"]): + displacements[i, disp1["number"]] = disp1["displacement"] + elif "forces" in dataset or "displacements" in dataset: + displacements = dataset["displacements"] else: raise RuntimeError("displacement dataset has wrong format.") @@ -1103,15 +1180,15 @@ class Phono3py(object): raise RuntimeError("phonon_displacement_dataset does not exist.") dataset = self._phonon_dataset - disps = np.array(displacements, dtype='double', order='C') + disps = np.array(displacements, dtype="double", order="C") natom = self._phonon_supercell.get_number_of_atoms() - if (disps.ndim != 3 or disps.shape[1:] != (natom, 3)): + if disps.ndim != 3 or disps.shape[1:] != (natom, 3): raise RuntimeError("Array shape of displacements is incorrect.") - if 'first_atoms' in dataset: - dataset = {'displacements': disps} - elif 'displacements' in dataset or 'forces' in dataset: - dataset['displacements'] = disps + if "first_atoms" in dataset: + dataset = {"displacements": disps} + elif "displacements" in dataset or "forces" in dataset: + dataset["displacements"] = disps @property def phonon_forces(self): @@ -1133,15 +1210,17 @@ class Phono3py(object): raise RuntimeError("phonon_displacement_dataset does not exist.") dataset = self._phonon_dataset - if 'forces' in dataset: - return dataset['forces'] - elif 'first_atoms' in dataset: - num_scells = len(dataset['first_atoms']) + if "forces" in dataset: + return dataset["forces"] + elif "first_atoms" in dataset: + num_scells = len(dataset["first_atoms"]) forces = np.zeros( (num_scells, self._phonon_supercell.get_number_of_atoms(), 3), - dtype='double', order='C') - for i, disp1 in enumerate(dataset['first_atoms']): - forces[i] = disp1['forces'] + dtype="double", + order="C", + ) + for i, disp1 in enumerate(dataset["first_atoms"]): + forces[i] = disp1["forces"] return forces else: raise RuntimeError("displacement dataset has wrong format.") @@ -1151,15 +1230,15 @@ class Phono3py(object): if self._phonon_dataset is None: raise RuntimeError("phonon_displacement_dataset does not exist.") - forces = np.array(forces_fc2, dtype='double', order='C') + forces = np.array(forces_fc2, dtype="double", order="C") dataset = self._phonon_dataset - if 'first_atoms' in dataset: + if "first_atoms" in dataset: i = 0 - for i, disp1 in enumerate(dataset['first_atoms']): - disp1['forces'] = forces[i] + for i, disp1 in enumerate(dataset["first_atoms"]): + disp1["forces"] = forces[i] i += 1 - elif 'displacements' in dataset or 'forces' in dataset: - dataset['forces'] = forces + elif "displacements" in dataset or "forces" in dataset: + dataset["forces"] = forces @property def phph_interaction(self): @@ -1168,9 +1247,11 @@ class Phono3py(object): def get_phph_interaction(self): """Return Interaction instance.""" - warnings.warn("Phono3py.get_phph_interaction() is deprecated." - "Use Phono3py.phph_interaction attribute instead.", - DeprecationWarning) + warnings.warn( + "Phono3py.get_phph_interaction() is deprecated." + "Use Phono3py.phph_interaction attribute instead.", + DeprecationWarning, + ) return self.phph_interaction @property @@ -1188,12 +1269,14 @@ class Phono3py(object): """ return self._bz_grid - def init_phph_interaction(self, - nac_q_direction=None, - constant_averaged_interaction=None, - frequency_scale_factor=None, - symmetrize_fc3q=False, - lapack_zheev_uplo='L'): + def init_phph_interaction( + self, + nac_q_direction=None, + constant_averaged_interaction=None, + frequency_scale_factor=None, + symmetrize_fc3q=False, + lapack_zheev_uplo="L", + ): """Initialize ph-ph interaction calculation. This method creates an instance of Interaction class, which @@ -1260,16 +1343,19 @@ class Phono3py(object): cutoff_frequency=self._cutoff_frequency, is_mesh_symmetry=self._is_mesh_symmetry, symmetrize_fc3q=_symmetrize_fc3q, - lapack_zheev_uplo=_lapack_zheev_uplo) + lapack_zheev_uplo=_lapack_zheev_uplo, + ) self._interaction.nac_q_direction = nac_q_direction self._init_dynamical_matrix() - def set_phph_interaction(self, - nac_params=None, - nac_q_direction=None, - constant_averaged_interaction=None, - frequency_scale_factor=None, - solve_dynamical_matrices=True): + def set_phph_interaction( + self, + nac_params=None, + nac_q_direction=None, + constant_averaged_interaction=None, + frequency_scale_factor=None, + solve_dynamical_matrices=True, + ): """Initialize ph-ph interaction calculation. This method is deprecated at v2.0. Phono3py.init_phph_interaction @@ -1292,20 +1378,23 @@ class Phono3py(object): shape=(3, 3), dtype='double', order='C' """ - msg = ("Phono3py.init_phph_interaction is deprecated at v2.0. " - "Use Phono3py.prepare_interaction instead.") + msg = ( + "Phono3py.init_phph_interaction is deprecated at v2.0. " + "Use Phono3py.prepare_interaction instead." + ) warnings.warn(msg, DeprecationWarning) if nac_params is not None: self._nac_params = nac_params - msg = ("nac_params will be set by Phono3py.nac_params attributes.") + msg = "nac_params will be set by Phono3py.nac_params attributes." warnings.warn(msg, DeprecationWarning) self.init_phph_interaction( nac_q_direction=nac_q_direction, constant_averaged_interaction=constant_averaged_interaction, frequency_scale_factor=frequency_scale_factor, - solve_dynamical_matrices=solve_dynamical_matrices) + solve_dynamical_matrices=solve_dynamical_matrices, + ) def set_phonon_data(self, frequencies, eigenvectors, grid_address): """Set phonon frequencies and eigenvectors in Interaction instance. @@ -1333,8 +1422,7 @@ class Phono3py(object): """ if self._interaction is not None: - self._interaction.set_phonon_data( - frequencies, eigenvectors, grid_address) + self._interaction.set_phonon_data(frequencies, eigenvectors, grid_address) def get_phonon_data(self): """Get phonon frequencies and eigenvectors in Interaction instance. @@ -1356,8 +1444,10 @@ class Phono3py(object): freqs, eigvecs, _ = self._interaction.get_phonons() return freqs, eigvecs, self._interaction.bz_grid.addresses else: - msg = ("Phono3py.init_phph_interaction has to be called " - "before running this method.") + msg = ( + "Phono3py.init_phph_interaction has to be called " + "before running this method." + ) raise RuntimeError(msg) def run_phonon_solver(self, grid_points=None): @@ -1379,15 +1469,19 @@ class Phono3py(object): if self._interaction is not None: self._interaction.run_phonon_solver(grid_points=grid_points) else: - msg = ("Phono3py.init_phph_interaction has to be called " - "before running this method.") + msg = ( + "Phono3py.init_phph_interaction has to be called " + "before running this method." + ) raise RuntimeError(msg) - def generate_displacements(self, - distance=0.03, - cutoff_pair_distance=None, - is_plusminus='auto', - is_diagonal=True): + def generate_displacements( + self, + distance=0.03, + cutoff_pair_distance=None, + is_plusminus="auto", + is_diagonal=True, + ): """Generate displacement dataset in supercell for fc3. This systematically generates single and pair atomic displacements @@ -1435,22 +1529,23 @@ class Phono3py(object): self._supercell, self._symmetry, is_plusminus=is_plusminus, - is_diagonal=is_diagonal) + is_diagonal=is_diagonal, + ) self._dataset = direction_to_displacement( direction_dataset, distance, self._supercell, - cutoff_distance=cutoff_pair_distance) + cutoff_distance=cutoff_pair_distance, + ) if self._phonon_supercell_matrix is not None: - self.generate_fc2_displacements(distance=distance, - is_plusminus=is_plusminus, - is_diagonal=False) + self.generate_fc2_displacements( + distance=distance, is_plusminus=is_plusminus, is_diagonal=False + ) - def generate_fc2_displacements(self, - distance=0.03, - is_plusminus='auto', - is_diagonal=False): + def generate_fc2_displacements( + self, distance=0.03, is_plusminus="auto", is_diagonal=False + ): """Generate displacement dataset in phonon supercell for fc2. This systematically generates single atomic displacements @@ -1481,28 +1576,31 @@ class Phono3py(object): """ if self._phonon_supercell_matrix is None: - msg = ("phonon_supercell_matrix is not set. " - "This method is used to generate displacements to " - "calculate phonon_fc2.") + msg = ( + "phonon_supercell_matrix is not set. " + "This method is used to generate displacements to " + "calculate phonon_fc2." + ) raise RuntimeError(msg) phonon_displacement_directions = get_least_displacements( self._phonon_supercell_symmetry, is_plusminus=is_plusminus, - is_diagonal=is_diagonal) + is_diagonal=is_diagonal, + ) self._phonon_dataset = directions_to_displacement_dataset( - phonon_displacement_directions, - distance, - self._phonon_supercell) + phonon_displacement_directions, distance, self._phonon_supercell + ) - def produce_fc3(self, - forces_fc3=None, - displacement_dataset=None, - cutoff_distance=None, # set fc3 zero - symmetrize_fc3r=False, - is_compact_fc=False, - fc_calculator=None, - fc_calculator_options=None): + def produce_fc3( + self, + forces_fc3=None, + displacement_dataset=None, + symmetrize_fc3r=False, + is_compact_fc=False, + fc_calculator=None, + fc_calculator_options=None, + ): """Calculate fc3 from displacements and forces. Parameters @@ -1511,9 +1609,6 @@ class Phono3py(object): Dummy argument. Deprecated at v2.0. displacement_dataset : dict See docstring of Phono3py.dataset. Deprecated at v2.0. - cutoff_distance : float - After creating force constants, fc elements where any pair - distance in atom triplets larger than cutoff_distance are set zero. symmetrize_fc3r : bool Only for type 1 displacement_dataset, translational and permutation symmetries are applied after creating fc3. This @@ -1536,45 +1631,48 @@ class Phono3py(object): if displacement_dataset is None: disp_dataset = self._dataset else: - msg = ("Displacement dataset has to set by Phono3py.dataset.") + msg = "Displacement dataset has to set by Phono3py.dataset." warnings.warn(msg, DeprecationWarning) disp_dataset = displacement_dataset if forces_fc3 is not None: self.forces = forces_fc3 - msg = ("Forces have to be set by Phono3py.forces or via " - "Phono3py.dataset.") + msg = "Forces have to be set by Phono3py.forces or via " "Phono3py.dataset." warnings.warn(msg, DeprecationWarning) if fc_calculator is not None: disps, forces = get_displacements_and_forces_fc3(disp_dataset) - fc2, fc3 = get_fc3(self._supercell, - self._primitive, - disps, - forces, - fc_calculator=fc_calculator, - fc_calculator_options=fc_calculator_options, - is_compact_fc=is_compact_fc, - log_level=self._log_level) + fc2, fc3 = get_fc3( + self._supercell, + self._primitive, + disps, + forces, + fc_calculator=fc_calculator, + fc_calculator_options=fc_calculator_options, + is_compact_fc=is_compact_fc, + log_level=self._log_level, + ) else: - if 'displacements' in disp_dataset: - msg = ("fc_calculator has to be set to produce force " - "constans from this dataset.") + if "displacements" in disp_dataset: + msg = ( + "fc_calculator has to be set to produce force " + "constans from this dataset." + ) raise RuntimeError(msg) - fc2, fc3 = get_phono3py_fc3(self._supercell, - self._primitive, - disp_dataset, - self._symmetry, - is_compact_fc=is_compact_fc, - verbose=self._log_level) + fc2, fc3 = get_phono3py_fc3( + self._supercell, + self._primitive, + disp_dataset, + self._symmetry, + is_compact_fc=is_compact_fc, + verbose=self._log_level, + ) if symmetrize_fc3r: if is_compact_fc: - set_translational_invariance_compact_fc3( - fc3, self._primitive) + set_translational_invariance_compact_fc3(fc3, self._primitive) set_permutation_symmetry_compact_fc3(fc3, self._primitive) if self._fc2 is None: - symmetrize_compact_force_constants(fc2, - self._primitive) + symmetrize_compact_force_constants(fc2, self._primitive) else: set_translational_invariance_fc3(fc3) set_permutation_symmetry_fc3(fc3) @@ -1588,13 +1686,15 @@ class Phono3py(object): if self._fc2 is None: self._fc2 = fc2 - def produce_fc2(self, - forces_fc2=None, - displacement_dataset=None, - symmetrize_fc2=False, - is_compact_fc=False, - fc_calculator=None, - fc_calculator_options=None): + def produce_fc2( + self, + forces_fc2=None, + displacement_dataset=None, + symmetrize_fc2=False, + is_compact_fc=False, + fc_calculator=None, + fc_calculator_options=None, + ): """Calculate fc2 from displacements and forces. Parameters @@ -1629,14 +1729,17 @@ class Phono3py(object): disp_dataset = self._phonon_dataset else: disp_dataset = displacement_dataset - msg = ("Displacement dataset for fc2 has to set by " - "Phono3py.phonon_dataset.") + msg = ( + "Displacement dataset for fc2 has to set by " "Phono3py.phonon_dataset." + ) warnings.warn(msg, DeprecationWarning) if forces_fc2 is not None: self.phonon_forces = forces_fc2 - msg = ("Forces for fc2 have to be set by Phono3py.phonon_forces " - "or via Phono3py.phonon_dataset.") + msg = ( + "Forces for fc2 have to be set by Phono3py.phonon_forces " + "or via Phono3py.phonon_dataset." + ) warnings.warn(msg, DeprecationWarning) if is_compact_fc: @@ -1646,40 +1749,52 @@ class Phono3py(object): if fc_calculator is not None: disps, forces = get_displacements_and_forces(disp_dataset) - self._fc2 = get_fc2(self._phonon_supercell, - self._phonon_primitive, - disps, - forces, - fc_calculator=fc_calculator, - fc_calculator_options=fc_calculator_options, - atom_list=p2s_map, - log_level=self._log_level) + self._fc2 = get_fc2( + self._phonon_supercell, + self._phonon_primitive, + disps, + forces, + fc_calculator=fc_calculator, + fc_calculator_options=fc_calculator_options, + atom_list=p2s_map, + log_level=self._log_level, + ) else: - if 'displacements' in disp_dataset: - msg = ("fc_calculator has to be set to produce force " - "constans from this dataset for fc2.") + if "displacements" in disp_dataset: + msg = ( + "fc_calculator has to be set to produce force " + "constans from this dataset for fc2." + ) raise RuntimeError(msg) - self._fc2 = get_phonopy_fc2(self._phonon_supercell, - self._phonon_supercell_symmetry, - disp_dataset, - atom_list=p2s_map) + self._fc2 = get_phonopy_fc2( + self._phonon_supercell, + self._phonon_supercell_symmetry, + disp_dataset, + atom_list=p2s_map, + ) if symmetrize_fc2: if is_compact_fc: symmetrize_compact_force_constants( - self._fc2, self._phonon_primitive) + self._fc2, self._phonon_primitive + ) else: symmetrize_force_constants(self._fc2) def cutoff_fc3_by_zero(self, cutoff_distance, fc3=None): - """Set zero to fc3 elements out of cutoff distance.""" + """Set zero to fc3 elements out of cutoff distance. + + cutoff_distance : float + After creating force constants, fc elements where any pair + distance in atom triplets larger than cutoff_distance are set zero. + + """ if fc3 is None: _fc3 = self._fc3 else: _fc3 = fc3 - cutoff_fc3_by_zero(_fc3, # overwritten - self._supercell, - cutoff_distance, - self._symprec) + cutoff_fc3_by_zero( + _fc3, self._supercell, cutoff_distance, self._symprec # overwritten + ) def set_permutation_symmetry(self): """Enforce permutation symmetry to fc2 and fc3.""" @@ -1700,18 +1815,20 @@ class Phono3py(object): if self._fc3 is not None: set_translational_invariance_fc3(self._fc3) - def run_imag_self_energy(self, - grid_points, - temperatures, - frequency_points=None, - frequency_step=None, - num_frequency_points=None, - frequency_points_at_bands=False, - scattering_event_class=None, - write_txt=False, - write_gamma_detail=False, - keep_gamma_detail=False, - output_filename=None): + def run_imag_self_energy( + self, + grid_points, + temperatures, + frequency_points=None, + frequency_step=None, + num_frequency_points=None, + frequency_points_at_bands=False, + scattering_event_class=None, + write_txt=False, + write_gamma_detail=False, + keep_gamma_detail=False, + output_filename=None, + ): """Calculate imaginary part of self-energy of bubble diagram (Gamma). Pi = Delta - i Gamma. @@ -1758,12 +1875,16 @@ class Phono3py(object): """ if self._interaction is None: - msg = ("Phono3py.init_phph_interaction has to be called " - "before running this method.") + msg = ( + "Phono3py.init_phph_interaction has to be called " + "before running this method." + ) raise RuntimeError(msg) if temperatures is None: - self._temperatures = [300.0, ] + self._temperatures = [ + 300.0, + ] else: self._temperatures = temperatures self._grid_points = grid_points @@ -1781,11 +1902,10 @@ class Phono3py(object): write_gamma_detail=write_gamma_detail, return_gamma_detail=keep_gamma_detail, output_filename=output_filename, - log_level=self._log_level) + log_level=self._log_level, + ) if keep_gamma_detail: - (self._frequency_points, - self._gammas, - self._detailed_gammas) = vals + (self._frequency_points, self._gammas, self._detailed_gammas) = vals else: self._frequency_points, self._gammas = vals @@ -1796,9 +1916,11 @@ class Phono3py(object): def write_imag_self_energy(self, filename=None): """Write imaginary part of self energy to a file.""" - warnings.warn("Phono3py.write_imag_self_energy is deprecated." - "Use Phono3py.run_imag_self_energy with write_txt=True.", - DeprecationWarning) + warnings.warn( + "Phono3py.write_imag_self_energy is deprecated." + "Use Phono3py.run_imag_self_energy with write_txt=True.", + DeprecationWarning, + ) self._write_imag_self_energy(output_filename=filename) def _write_imag_self_energy(self, output_filename=None): @@ -1813,20 +1935,22 @@ class Phono3py(object): scattering_event_class=self._scattering_event_class, output_filename=output_filename, is_mesh_symmetry=self._is_mesh_symmetry, - log_level=self._log_level) + log_level=self._log_level, + ) def run_real_self_energy( - self, - grid_points, - temperatures, - frequency_points_at_bands=False, - frequency_points=None, - frequency_step=None, - num_frequency_points=None, - epsilons=None, - write_txt=False, - write_hdf5=False, - output_filename=None): + self, + grid_points, + temperatures, + frequency_points_at_bands=False, + frequency_points=None, + frequency_step=None, + num_frequency_points=None, + epsilons=None, + write_txt=False, + write_hdf5=False, + output_filename=None, + ): """Calculate real-part of self-energy of bubble diagram (Delta). Pi = Delta - i Gamma. @@ -1871,8 +1995,10 @@ class Phono3py(object): """ if self._interaction is None: - msg = ("Phono3py.init_phph_interaction has to be called " - "before running this method.") + msg = ( + "Phono3py.init_phph_interaction has to be called " + "before running this method." + ) raise RuntimeError(msg) if epsilons is not None: @@ -1897,7 +2023,8 @@ class Phono3py(object): frequency_points_at_bands=frequency_points_at_bands, write_hdf5=write_hdf5, output_filename=output_filename, - log_level=self._log_level) + log_level=self._log_level, + ) if write_txt: write_real_self_energy( @@ -1910,21 +2037,23 @@ class Phono3py(object): _epsilons, output_filename=output_filename, is_mesh_symmetry=self._is_mesh_symmetry, - log_level=self._log_level) + log_level=self._log_level, + ) return frequency_points, deltas def run_spectral_function( - self, - grid_points, - temperatures, - frequency_points=None, - frequency_step=None, - num_frequency_points=None, - num_points_in_batch=None, - write_txt=False, - write_hdf5=False, - output_filename=None): + self, + grid_points, + temperatures, + frequency_points=None, + frequency_step=None, + num_frequency_points=None, + num_points_in_batch=None, + write_txt=False, + write_hdf5=False, + output_filename=None, + ): """Frequency shift from lowest order diagram is calculated. Parameters @@ -1963,8 +2092,10 @@ class Phono3py(object): """ if self._interaction is None: - msg = ("Phono3py.init_phph_interaction has to be called " - "before running this method.") + msg = ( + "Phono3py.init_phph_interaction has to be called " + "before running this method." + ) raise RuntimeError(msg) self._spectral_function = run_spectral_function( @@ -1979,38 +2110,40 @@ class Phono3py(object): band_indices=self._band_indices, write_txt=write_txt, write_hdf5=write_hdf5, - log_level=self._log_level) + log_level=self._log_level, + ) def run_thermal_conductivity( - self, - is_LBTE=False, - temperatures=None, - is_isotope=False, - mass_variances=None, - grid_points=None, - boundary_mfp=None, # in micrometre - solve_collective_phonon=False, - use_ave_pp=False, - gamma_unit_conversion=None, - is_reducible_collision_matrix=False, - is_kappa_star=True, - gv_delta_q=None, # for group velocity - is_full_pp=False, - pinv_cutoff=1.0e-8, # for pseudo-inversion of collision matrix - pinv_solver=0, # solver of pseudo-inversion of collision matrix - write_gamma=False, - read_gamma=False, - is_N_U=False, - write_kappa=False, - write_gamma_detail=False, - write_collision=False, - read_collision=False, - write_pp=False, - read_pp=False, - write_LBTE_solution=False, - compression="gzip", - input_filename=None, - output_filename=None): + self, + is_LBTE=False, + temperatures=None, + is_isotope=False, + mass_variances=None, + grid_points=None, + boundary_mfp=None, # in micrometre + solve_collective_phonon=False, + use_ave_pp=False, + gamma_unit_conversion=None, + is_reducible_collision_matrix=False, + is_kappa_star=True, + gv_delta_q=None, # for group velocity + is_full_pp=False, + pinv_cutoff=1.0e-8, # for pseudo-inversion of collision matrix + pinv_solver=0, # solver of pseudo-inversion of collision matrix + write_gamma=False, + read_gamma=False, + is_N_U=False, + write_kappa=False, + write_gamma_detail=False, + write_collision=False, + read_collision=False, + write_pp=False, + read_pp=False, + write_LBTE_solution=False, + compression="gzip", + input_filename=None, + output_filename=None, + ): """Run thermal conductivity calculation. Parameters @@ -2142,13 +2275,17 @@ class Phono3py(object): """ if self._interaction is None: - msg = ("Phono3py.init_phph_interaction has to be called " - "before running this method.") + msg = ( + "Phono3py.init_phph_interaction has to be called " + "before running this method." + ) raise RuntimeError(msg) if is_LBTE: if temperatures is None: - _temperatures = [300, ] + _temperatures = [ + 300, + ] else: _temperatures = temperatures self._thermal_conductivity = get_thermal_conductivity_LBTE( @@ -2176,10 +2313,11 @@ class Phono3py(object): compression=compression, input_filename=input_filename, output_filename=output_filename, - log_level=self._log_level) + log_level=self._log_level, + ) else: if temperatures is None: - _temperatures = np.arange(0, 1001, 10, dtype='double') + _temperatures = np.arange(0, 1001, 10, dtype="double") else: _temperatures = temperatures self._thermal_conductivity = get_thermal_conductivity_RTA( @@ -2206,11 +2344,10 @@ class Phono3py(object): compression=compression, input_filename=input_filename, output_filename=output_filename, - log_level=self._log_level) + log_level=self._log_level, + ) - def save(self, - filename="phono3py_params.yaml", - settings=None): + def save(self, filename="phono3py_params.yaml", settings=None): """Save parameters in Phono3py instants into file. Parameters @@ -2231,38 +2368,39 @@ class Phono3py(object): """ ph3py_yaml = Phono3pyYaml(settings=settings) ph3py_yaml.set_phonon_info(self) - with open(filename, 'w') as w: + with open(filename, "w") as w: w.write(str(ph3py_yaml)) ################### # private methods # ################### def _search_symmetry(self): - self._symmetry = Symmetry(self._supercell, - self._symprec, - self._is_symmetry) + self._symmetry = Symmetry(self._supercell, self._symprec, self._is_symmetry) def _search_primitive_symmetry(self): - self._primitive_symmetry = Symmetry(self._primitive, - self._symprec, - self._is_symmetry) - if (len(self._symmetry.get_pointgroup_operations()) != - len(self._primitive_symmetry.get_pointgroup_operations())): # noqa E129 - print("Warning: point group symmetries of supercell and primitive" - "cell are different.") + self._primitive_symmetry = Symmetry( + self._primitive, self._symprec, self._is_symmetry + ) + if len(self._symmetry.get_pointgroup_operations()) != len( + self._primitive_symmetry.get_pointgroup_operations() + ): # noqa E129 + print( + "Warning: point group symmetries of supercell and primitive" + "cell are different." + ) def _search_phonon_supercell_symmetry(self): if self._phonon_supercell_matrix is None: self._phonon_supercell_symmetry = self._symmetry else: - self._phonon_supercell_symmetry = Symmetry(self._phonon_supercell, - self._symprec, - self._is_symmetry) + self._phonon_supercell_symmetry = Symmetry( + self._phonon_supercell, self._symprec, self._is_symmetry + ) def _build_supercell(self): - self._supercell = get_supercell(self._unitcell, - self._supercell_matrix, - self._symprec) + self._supercell = get_supercell( + self._unitcell, self._supercell_matrix, self._symprec + ) def _build_primitive_cell(self): """Create primitive cell. @@ -2276,7 +2414,8 @@ class Phono3py(object): """ self._primitive = self._get_primitive_cell( - self._supercell, self._supercell_matrix, self._primitive_matrix) + self._supercell, self._supercell_matrix, self._primitive_matrix + ) def _build_phonon_supercell(self): """Create phonon supercell for fc2. @@ -2292,7 +2431,8 @@ class Phono3py(object): self._phonon_supercell = self._supercell else: self._phonon_supercell = get_supercell( - self._unitcell, self._phonon_supercell_matrix, self._symprec) + self._unitcell, self._phonon_supercell_matrix, self._symprec + ) def _build_phonon_primitive_cell(self): if self._phonon_supercell_matrix is None: @@ -2301,32 +2441,38 @@ class Phono3py(object): self._phonon_primitive = self._get_primitive_cell( self._phonon_supercell, self._phonon_supercell_matrix, - self._primitive_matrix) - if (self._primitive is not None and - (self._primitive.numbers != - self._phonon_primitive.numbers).any()): + self._primitive_matrix, + ) + if ( + self._primitive is not None + and (self._primitive.numbers != self._phonon_primitive.numbers).any() + ): print(" Primitive cells for fc2 and fc3 can be different.") raise RuntimeError - def _build_phonon_supercells_with_displacements(self, - supercell, - displacement_dataset): + def _build_phonon_supercells_with_displacements( + self, supercell, displacement_dataset + ): supercells = [] magmoms = supercell.magnetic_moments masses = supercell.masses numbers = supercell.numbers lattice = supercell.cell - for disp1 in displacement_dataset['first_atoms']: - disp_cart1 = disp1['displacement'] + for disp1 in displacement_dataset["first_atoms"]: + disp_cart1 = disp1["displacement"] positions = supercell.get_positions() - positions[disp1['number']] += disp_cart1 - supercells.append(PhonopyAtoms(numbers=numbers, - masses=masses, - magmoms=magmoms, - positions=positions, - cell=lattice, - pbc=True)) + positions[disp1["number"]] += disp_cart1 + supercells.append( + PhonopyAtoms( + numbers=numbers, + masses=masses, + magmoms=magmoms, + positions=positions, + cell=lattice, + pbc=True, + ) + ) return supercells @@ -2338,49 +2484,50 @@ class Phono3py(object): lattice = self._supercell.cell supercells = self._build_phonon_supercells_with_displacements( - self._supercell, - self._dataset) + self._supercell, self._dataset + ) - for disp1 in self._dataset['first_atoms']: - disp_cart1 = disp1['displacement'] - for disp2 in disp1['second_atoms']: - if 'included' in disp2: - included = disp2['included'] + for disp1 in self._dataset["first_atoms"]: + disp_cart1 = disp1["displacement"] + for disp2 in disp1["second_atoms"]: + if "included" in disp2: + included = disp2["included"] else: included = True if included: positions = self._supercell.get_positions() - positions[disp1['number']] += disp_cart1 - positions[disp2['number']] += disp2['displacement'] - supercells.append(PhonopyAtoms(numbers=numbers, - masses=masses, - magmoms=magmoms, - positions=positions, - cell=lattice, - pbc=True)) + positions[disp1["number"]] += disp_cart1 + positions[disp2["number"]] += disp2["displacement"] + supercells.append( + PhonopyAtoms( + numbers=numbers, + masses=masses, + magmoms=magmoms, + positions=positions, + cell=lattice, + pbc=True, + ) + ) else: supercells.append(None) self._supercells_with_displacements = supercells - def _get_primitive_cell(self, - supercell, - supercell_matrix, - primitive_matrix): + def _get_primitive_cell(self, supercell, supercell_matrix, primitive_matrix): inv_supercell_matrix = np.linalg.inv(supercell_matrix) if primitive_matrix is None: t_mat = inv_supercell_matrix else: t_mat = np.dot(inv_supercell_matrix, primitive_matrix) - return get_primitive(supercell, t_mat, self._symprec, - store_dense_svecs=self._store_dense_svecs) + return get_primitive( + supercell, t_mat, self._symprec, store_dense_svecs=self._store_dense_svecs + ) def _determine_primitive_matrix(self, primitive_matrix): pmat = get_primitive_matrix(primitive_matrix, symprec=self._symprec) - if isinstance(pmat, str) and pmat == 'auto': - return guess_primitive_matrix(self._unitcell, - symprec=self._symprec) + if isinstance(pmat, str) and pmat == "auto": + return guess_primitive_matrix(self._unitcell, symprec=self._symprec) else: return pmat @@ -2393,7 +2540,8 @@ class Phono3py(object): lattice=self._primitive.cell, symmetry_dataset=self._primitive_symmetry.dataset, use_grg=self._use_grg, - store_dense_gp_map=self._store_dense_gp_map) + store_dense_gp_map=self._store_dense_gp_map, + ) def _init_dynamical_matrix(self): if self._interaction is not None: @@ -2402,4 +2550,5 @@ class Phono3py(object): self._phonon_supercell, self._phonon_primitive, nac_params=self._nac_params, - solve_dynamical_matrices=False) + solve_dynamical_matrices=False, + ) diff --git a/phono3py/cui/load.py b/phono3py/cui/load.py index 411d5c29..e3b7d8ad 100644 --- a/phono3py/cui/load.py +++ b/phono3py/cui/load.py @@ -34,6 +34,7 @@ # POSSIBILITY OF SUCH DAMAGE. import os +import typing import numpy as np from phono3py import Phono3py from phono3py.interface.phono3py_yaml import Phono3pyYaml @@ -45,36 +46,37 @@ from phonopy.interface.calculator import get_default_physical_units import phonopy.cui.load_helper as load_helper -def load(phono3py_yaml=None, # phono3py.yaml-like must be the first argument. - supercell_matrix=None, - primitive_matrix=None, - phonon_supercell_matrix=None, - mesh=None, - is_nac=True, - calculator=None, - unitcell=None, - supercell=None, - nac_params=None, - unitcell_filename=None, - supercell_filename=None, - born_filename=None, - forces_fc3_filename=None, - forces_fc2_filename=None, - fc3_filename=None, - fc2_filename=None, - fc_calculator=None, - fc_calculator_options=None, - factor=None, - produce_fc=True, - is_symmetry=True, - symmetrize_fc=True, - is_mesh_symmetry=True, - is_compact_fc=False, - use_grg=False, - store_dense_gp_map=True, - store_dense_svecs=True, - symprec=1e-5, - log_level=0): +def load( + phono3py_yaml=None, # phono3py.yaml-like must be the first argument. + supercell_matrix=None, + primitive_matrix=None, + phonon_supercell_matrix=None, + is_nac=True, + calculator=None, + unitcell=None, + supercell=None, + nac_params=None, + unitcell_filename=None, + supercell_filename=None, + born_filename=None, + forces_fc3_filename=None, + forces_fc2_filename=None, + fc3_filename=None, + fc2_filename=None, + fc_calculator=None, + fc_calculator_options=None, + factor=None, + produce_fc=True, + is_symmetry=True, + symmetrize_fc=True, + is_mesh_symmetry=True, + is_compact_fc=False, + use_grg=False, + store_dense_gp_map=True, + store_dense_svecs=True, + symprec=1e-5, + log_level=0, +): """Create Phono3py instance from parameters and/or input files. "phono3py_yaml"-like file is parsed unless crystal structure information @@ -245,10 +247,12 @@ def load(phono3py_yaml=None, # phono3py.yaml-like must be the first argument. Verbosity control. Default is 0. """ - if (supercell is not None or - supercell_filename is not None or - unitcell is not None or - unitcell_filename is not None): # noqa E129 + if ( + supercell is not None + or supercell_filename is not None + or unitcell is not None + or unitcell_filename is not None + ): # noqa E129 cell, smat, pmat = load_helper.get_cell_settings( supercell_matrix=supercell_matrix, primitive_matrix=primitive_matrix, @@ -257,11 +261,14 @@ def load(phono3py_yaml=None, # phono3py.yaml-like must be the first argument. unitcell_filename=unitcell_filename, supercell_filename=supercell_filename, calculator=calculator, - symprec=symprec) + symprec=symprec, + ) if phonon_supercell_matrix is not None: if unitcell is None and unitcell_filename is None: - msg = ("phonon_supercell_matrix can be used only when " - "unitcell or unitcell_filename is given.") + msg = ( + "phonon_supercell_matrix can be used only when " + "unitcell or unitcell_filename is given." + ) raise RuntimeError(msg) ph_smat = phonon_supercell_matrix else: @@ -275,9 +282,9 @@ def load(phono3py_yaml=None, # phono3py.yaml-like must be the first argument. smat = ph3py_yaml.supercell_matrix ph_smat = ph3py_yaml.phonon_supercell_matrix if smat is None: - smat = np.eye(3, dtype='intc', order='C') - if primitive_matrix == 'auto': - pmat = 'auto' + smat = np.eye(3, dtype="intc", order="C") + if primitive_matrix == "auto": + pmat = "auto" else: pmat = ph3py_yaml.primitive_matrix @@ -291,22 +298,24 @@ def load(phono3py_yaml=None, # phono3py.yaml-like must be the first argument. # units keywords: factor, nac_factor, distance_to_A physical_units = get_default_physical_units(calculator) if factor is None: - _factor = physical_units['factor'] + _factor = physical_units["factor"] else: _factor = factor - ph3py = Phono3py(cell, - smat, - primitive_matrix=pmat, - phonon_supercell_matrix=ph_smat, - frequency_factor_to_THz=_factor, - symprec=symprec, - is_symmetry=is_symmetry, - is_mesh_symmetry=is_mesh_symmetry, - use_grg=use_grg, - store_dense_gp_map=store_dense_gp_map, - store_dense_svecs=store_dense_svecs, - calculator=calculator, - log_level=log_level) + ph3py = Phono3py( + cell, + smat, + primitive_matrix=pmat, + phonon_supercell_matrix=ph_smat, + frequency_factor_to_THz=_factor, + symprec=symprec, + is_symmetry=is_symmetry, + is_mesh_symmetry=is_mesh_symmetry, + use_grg=use_grg, + store_dense_gp_map=store_dense_gp_map, + store_dense_svecs=store_dense_svecs, + calculator=calculator, + log_level=log_level, + ) # NAC params if born_filename is not None or _nac_params is not None or is_nac: @@ -315,12 +324,13 @@ def load(phono3py_yaml=None, # phono3py.yaml-like must be the first argument. _nac_params, born_filename, is_nac, - physical_units['nac_factor'], - log_level=log_level) + physical_units["nac_factor"], + log_level=log_level, + ) set_dataset_and_force_constants( ph3py, - ph3py_yaml=ph3py_yaml, + ph3py_yaml, fc3_filename=fc3_filename, fc2_filename=fc2_filename, forces_fc3_filename=forces_fc3_filename, @@ -330,56 +340,60 @@ def load(phono3py_yaml=None, # phono3py.yaml-like must be the first argument. produce_fc=produce_fc, symmetrize_fc=symmetrize_fc, is_compact_fc=is_compact_fc, - log_level=log_level) + log_level=log_level, + ) return ph3py def set_dataset_and_force_constants( - ph3py, - ph3py_yaml=None, - fc3_filename=None, - fc2_filename=None, - forces_fc3_filename=None, - forces_fc2_filename=None, - fc_calculator=None, - fc_calculator_options=None, - produce_fc=True, - symmetrize_fc=True, - is_compact_fc=False, - cutoff_pair_distance=None, - log_level=0): + ph3py: Phono3py, + ph3py_yaml: typing.Union[Phono3pyYaml, None] = None, + fc3_filename=None, + fc2_filename=None, + forces_fc3_filename=None, + forces_fc2_filename=None, + fc_calculator=None, + fc_calculator_options=None, + produce_fc=True, + symmetrize_fc=True, + is_compact_fc=False, + cutoff_pair_distance=None, + log_level=0, +): """Set displacements, forces, and create force constants.""" - read_fc = {'fc2': False, 'fc3': False} + read_fc = {"fc2": False, "fc3": False} p2s_map = ph3py.primitive.p2s_map if fc3_filename is not None: fc3 = read_fc3_from_hdf5(filename=fc3_filename, p2s_map=p2s_map) ph3py.fc3 = fc3 - read_fc['fc3'] = True + read_fc["fc3"] = True if log_level: - print("fc3 was read from \"%s\"." % fc3_filename) + print('fc3 was read from "%s".' % fc3_filename) elif forces_fc3_filename is not None: if type(forces_fc3_filename) is str: force_filename = forces_fc3_filename disp_filename = None else: force_filename, disp_filename = forces_fc3_filename - _set_forces_fc3(ph3py, - ph3py_yaml, - force_filename, - disp_filename, - produce_fc, - symmetrize_fc, - is_compact_fc, - fc_calculator, - fc_calculator_options, - cutoff_pair_distance, - log_level) + _set_forces_fc3( + ph3py, + ph3py_yaml, + force_filename, + disp_filename, + produce_fc, + symmetrize_fc, + is_compact_fc, + fc_calculator, + fc_calculator_options, + cutoff_pair_distance, + log_level, + ) elif os.path.isfile("fc3.hdf5"): ph3py.fc3 = read_fc3_from_hdf5(filename="fc3.hdf5", p2s_map=p2s_map) - read_fc['fc3'] = True + read_fc["fc3"] = True if log_level: - print("fc3 was read from \"fc3.hdf5\".") + print('fc3 was read from "fc3.hdf5".') elif os.path.isfile("FORCES_FC3"): disp_filename = None if os.path.isfile("disp_fc3.yaml"): @@ -387,31 +401,37 @@ def set_dataset_and_force_constants( disp_filename = "disp_fc3.yaml" elif ph3py_yaml.dataset is None: disp_filename = "disp_fc3.yaml" - _set_forces_fc3(ph3py, - ph3py_yaml, - "FORCES_FC3", - disp_filename, - produce_fc, - symmetrize_fc, - is_compact_fc, - fc_calculator, - fc_calculator_options, - cutoff_pair_distance, - log_level) - elif (ph3py_yaml is not None and - ph3py_yaml.dataset is not None and - forces_in_dataset(ph3py_yaml.dataset)): - _set_forces_fc3(ph3py, - ph3py_yaml, - None, - None, - produce_fc, - symmetrize_fc, - is_compact_fc, - fc_calculator, - fc_calculator_options, - cutoff_pair_distance, - log_level) + _set_forces_fc3( + ph3py, + ph3py_yaml, + "FORCES_FC3", + disp_filename, + produce_fc, + symmetrize_fc, + is_compact_fc, + fc_calculator, + fc_calculator_options, + cutoff_pair_distance, + log_level, + ) + elif ( + ph3py_yaml is not None + and ph3py_yaml.dataset is not None + and forces_in_dataset(ph3py_yaml.dataset) + ): + _set_forces_fc3( + ph3py, + ph3py_yaml, + None, + None, + produce_fc, + symmetrize_fc, + is_compact_fc, + fc_calculator, + fc_calculator_options, + cutoff_pair_distance, + log_level, + ) if log_level and ph3py.fc3 is not None: show_drift_fc3(ph3py.fc3, primitive=ph3py.primitive) @@ -419,31 +439,33 @@ def set_dataset_and_force_constants( if fc2_filename is not None: fc2 = read_fc2_from_hdf5(filename=fc2_filename, p2s_map=p2s_map) ph3py.fc2 = fc2 - read_fc['fc2'] = True + read_fc["fc2"] = True if log_level: - print("fc2 was read from \"%s\"." % fc2_filename) + print('fc2 was read from "%s".' % fc2_filename) elif forces_fc2_filename is not None: if type(forces_fc2_filename) is str: force_filename = forces_fc2_filename disp_filename = None else: force_filename, disp_filename = forces_fc2_filename - _set_forces_fc2(ph3py, - ph3py_yaml, - force_filename, - disp_filename, - produce_fc, - symmetrize_fc, - is_compact_fc, - fc_calculator, - fc_calculator_options, - "phonon_fc2", - log_level) + _set_forces_fc2( + ph3py, + ph3py_yaml, + force_filename, + disp_filename, + produce_fc, + symmetrize_fc, + is_compact_fc, + fc_calculator, + fc_calculator_options, + "phonon_fc2", + log_level, + ) elif os.path.isfile("fc2.hdf5"): ph3py.fc2 = read_fc2_from_hdf5(filename="fc2.hdf5", p2s_map=p2s_map) - read_fc['fc2'] = True + read_fc["fc2"] = True if log_level: - print("fc2 was read from \"fc2.hdf5\".") + print('fc2 was read from "fc2.hdf5".') elif os.path.isfile("FORCES_FC2"): disp_filename = None if os.path.isfile("disp_fc2.yaml"): @@ -451,54 +473,69 @@ def set_dataset_and_force_constants( disp_filename = "disp_fc2.yaml" elif ph3py_yaml.phonon_dataset is None: disp_filename = "disp_fc2.yaml" - if disp_filename is None and ph3py_yaml.phonon_dataset is None: - msg = ("\"FORCES_FC2\" was found. " - "But displacement dataset was not found.") + if ( + disp_filename is None + and ph3py_yaml is not None + and ph3py_yaml.phonon_dataset is None + ): + msg = '"FORCES_FC2" was found. ' "But displacement dataset was not found." raise RuntimeError(msg) - _set_forces_fc2(ph3py, - ph3py_yaml, - "FORCES_FC2", - disp_filename, - produce_fc, - symmetrize_fc, - is_compact_fc, - fc_calculator, - fc_calculator_options, - "phonon_fc2", - log_level) - elif (ph3py.phonon_supercell_matrix is None and - fc_calculator == 'alm' and - ph3py.fc2 is not None): + _set_forces_fc2( + ph3py, + ph3py_yaml, + "FORCES_FC2", + disp_filename, + produce_fc, + symmetrize_fc, + is_compact_fc, + fc_calculator, + fc_calculator_options, + "phonon_fc2", + log_level, + ) + elif ( + ph3py.phonon_supercell_matrix is None + and fc_calculator == "alm" + and ph3py.fc2 is not None + ): if log_level: print("fc2 that was fit simultaneously with fc3 by ALM is used.") - elif (ph3py_yaml is not None and - ph3py_yaml.phonon_dataset is not None and - forces_in_dataset(ph3py_yaml.phonon_dataset)): - _set_forces_fc2(ph3py, - ph3py_yaml, - None, - None, - produce_fc, - symmetrize_fc, - is_compact_fc, - fc_calculator, - fc_calculator_options, - "phonon_fc2", - log_level) - elif (ph3py_yaml is not None and - ph3py_yaml.dataset is not None and - forces_in_dataset(ph3py_yaml.dataset)): - _set_forces_fc2(ph3py, - ph3py_yaml, - None, - None, - produce_fc, - symmetrize_fc, - is_compact_fc, - fc_calculator, - fc_calculator_options, - "fc2", - log_level) + elif ( + ph3py_yaml is not None + and ph3py_yaml.phonon_dataset is not None + and forces_in_dataset(ph3py_yaml.phonon_dataset) + ): + _set_forces_fc2( + ph3py, + ph3py_yaml, + None, + None, + produce_fc, + symmetrize_fc, + is_compact_fc, + fc_calculator, + fc_calculator_options, + "phonon_fc2", + log_level, + ) + elif ( + ph3py_yaml is not None + and ph3py_yaml.dataset is not None + and forces_in_dataset(ph3py_yaml.dataset) + ): + _set_forces_fc2( + ph3py, + ph3py_yaml, + None, + None, + produce_fc, + symmetrize_fc, + is_compact_fc, + fc_calculator, + fc_calculator_options, + "fc2", + log_level, + ) elif os.path.isfile("FORCES_FC3"): # suppose fc3.hdf5 is read but fc2.hdf5 doesn't exist. disp_filename = None @@ -507,86 +544,99 @@ def set_dataset_and_force_constants( disp_filename = "disp_fc3.yaml" elif ph3py_yaml.dataset is None: disp_filename = "disp_fc3.yaml" - _set_forces_fc2(ph3py, - ph3py_yaml, - "FORCES_FC3", - disp_filename, - produce_fc, - symmetrize_fc, - is_compact_fc, - fc_calculator, - fc_calculator_options, - "fc2", - log_level) + _set_forces_fc2( + ph3py, + ph3py_yaml, + "FORCES_FC3", + disp_filename, + produce_fc, + symmetrize_fc, + is_compact_fc, + fc_calculator, + fc_calculator_options, + "fc2", + log_level, + ) if log_level and ph3py.fc2 is not None: - show_drift_force_constants(ph3py.fc2, - primitive=ph3py.phonon_primitive, - name='fc2') + show_drift_force_constants( + ph3py.fc2, primitive=ph3py.phonon_primitive, name="fc2" + ) # Cases that dataset is in phono3py.yaml but not forces. if ph3py.dataset is None: - if (ph3py_yaml is not None and ph3py_yaml.dataset is not None): + if ph3py_yaml is not None and ph3py_yaml.dataset is not None: ph3py.dataset = ph3py_yaml.dataset - if (ph3py_yaml is not None and ph3py_yaml.phonon_dataset is not None): + if ph3py_yaml is not None and ph3py_yaml.phonon_dataset is not None: ph3py.phonon_dataset = ph3py_yaml.phonon_dataset return read_fc -def _set_forces_fc3(ph3py, - ph3py_yaml, - force_filename, - disp_filename, - produce_fc, - symmetrize_fc, - is_compact_fc, - fc_calculator, - fc_calculator_options, - cutoff_pair_distance, - log_level): +def _set_forces_fc3( + ph3py: Phono3py, + ph3py_yaml: typing.Union[Phono3pyYaml, None], + force_filename, + disp_filename, + produce_fc, + symmetrize_fc, + is_compact_fc, + fc_calculator, + fc_calculator_options, + cutoff_pair_distance, + log_level, +): ph3py.dataset = parse_forces( ph3py, ph3py_yaml=ph3py_yaml, cutoff_pair_distance=cutoff_pair_distance, force_filename=force_filename, disp_filename=disp_filename, - fc_type='fc3', - log_level=log_level) + fc_type="fc3", + log_level=log_level, + ) if produce_fc: - ph3py.produce_fc3(symmetrize_fc3r=symmetrize_fc, - is_compact_fc=is_compact_fc, - fc_calculator=fc_calculator, - fc_calculator_options=fc_calculator_options) + ph3py.produce_fc3( + symmetrize_fc3r=symmetrize_fc, + is_compact_fc=is_compact_fc, + fc_calculator=fc_calculator, + fc_calculator_options=fc_calculator_options, + ) if log_level and symmetrize_fc: print("fc3 was symmetrized.") -def _set_forces_fc2(ph3py, - ph3py_yaml, - force_filename, - disp_filename, - produce_fc, - symmetrize_fc, - is_compact_fc, - fc_calculator, - fc_calculator_options, - fc_type, - log_level): - dataset = parse_forces(ph3py, - ph3py_yaml=ph3py_yaml, - force_filename=force_filename, - disp_filename=disp_filename, - fc_type=fc_type, - log_level=log_level) - if fc_type == 'phonon_fc2': +def _set_forces_fc2( + ph3py: Phono3py, + ph3py_yaml: typing.Union[Phono3pyYaml, None], + force_filename, + disp_filename, + produce_fc, + symmetrize_fc, + is_compact_fc, + fc_calculator, + fc_calculator_options, + fc_type, + log_level, +): + dataset = parse_forces( + ph3py, + ph3py_yaml=ph3py_yaml, + force_filename=force_filename, + disp_filename=disp_filename, + fc_type=fc_type, + log_level=log_level, + ) + if fc_type == "phonon_fc2": ph3py.phonon_dataset = dataset else: ph3py.dataset = dataset if produce_fc: - ph3py.produce_fc2(symmetrize_fc2=symmetrize_fc, - is_compact_fc=is_compact_fc, - fc_calculator=fc_calculator, - fc_calculator_options=fc_calculator_options) + ph3py.produce_fc2( + symmetrize_fc2=symmetrize_fc, + is_compact_fc=is_compact_fc, + fc_calculator=fc_calculator, + fc_calculator_options=fc_calculator_options, + ) if log_level and symmetrize_fc: print("fc2 was symmetrized.") From 2a474567d8d35dfda29d22c41f901c4e47cd479f Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Tue, 12 Oct 2021 15:56:14 +0900 Subject: [PATCH 11/34] Formatted c files by VScode --- c/_lapackepy.c | 90 +-- c/_phono3py.c | 1205 ++++++++++++++++++----------------- c/_phononmod.c | 199 +++--- c/bzgrid.c | 415 ++++++------ c/bzgrid.h | 14 +- c/collision_matrix.c | 156 +++-- c/dynmat.c | 267 +++++--- c/dynmat.h | 8 +- c/fc3.c | 343 ++++++---- c/fc3.h | 4 +- c/grgrid.c | 114 ++-- c/gridsys.c | 44 +- c/gridsys.h | 180 +++--- c/imag_self_energy_with_g.c | 324 ++++++---- c/imag_self_energy_with_g.h | 25 +- c/isotope.c | 182 +++--- c/isotope.h | 50 +- c/lagrid.c | 69 +- c/lapack_wrapper.c | 72 ++- c/phono3py.c | 399 ++++++------ c/phono3py.h | 198 +++--- c/phonon.c | 280 ++++---- c/phonon.h | 104 ++- c/phononmod.c | 11 +- c/phononmod.h | 4 +- c/real_self_energy.c | 173 ++--- c/real_self_energy.h | 22 +- c/snf3x3.c | 139 ++-- c/tetrahedron_method.c | 1080 +++++++++++++++++++++++-------- c/triplet.c | 70 +- c/triplet_grid.c | 256 +++++--- c/triplet_iw.c | 196 +++--- 32 files changed, 3938 insertions(+), 2755 deletions(-) diff --git a/c/_lapackepy.c b/c/_lapackepy.c index 0515d3af..6fd9bc60 100644 --- a/c/_lapackepy.c +++ b/c/_lapackepy.c @@ -38,57 +38,59 @@ #include #include "lapack_wrapper.h" -static PyObject * py_phonopy_pinv(PyObject *self, PyObject *args); -static PyObject * py_phonopy_zheev(PyObject *self, PyObject *args); +static PyObject *py_phonopy_pinv(PyObject *self, PyObject *args); +static PyObject *py_phonopy_zheev(PyObject *self, PyObject *args); -struct module_state { +struct module_state +{ PyObject *error; }; #if PY_MAJOR_VERSION >= 3 -#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m)) +#define GETSTATE(m) ((struct module_state *)PyModule_GetState(m)) #else #define GETSTATE(m) (&_state) static struct module_state _state; #endif static PyObject * -error_out(PyObject *m) { +error_out(PyObject *m) +{ struct module_state *st = GETSTATE(m); PyErr_SetString(st->error, "something bad happened"); return NULL; } static PyMethodDef _lapackepy_methods[] = { - {"error_out", (PyCFunction)error_out, METH_NOARGS, NULL}, - {"pinv", py_phonopy_pinv, METH_VARARGS, "Pseudo-inverse using Lapack dgesvd"}, - {"zheev", py_phonopy_zheev, METH_VARARGS, "Lapack zheev wrapper"}, - {NULL, NULL, 0, NULL} -}; + {"error_out", (PyCFunction)error_out, METH_NOARGS, NULL}, + {"pinv", py_phonopy_pinv, METH_VARARGS, "Pseudo-inverse using Lapack dgesvd"}, + {"zheev", py_phonopy_zheev, METH_VARARGS, "Lapack zheev wrapper"}, + {NULL, NULL, 0, NULL}}; #if PY_MAJOR_VERSION >= 3 -static int _lapackepy_traverse(PyObject *m, visitproc visit, void *arg) { +static int _lapackepy_traverse(PyObject *m, visitproc visit, void *arg) +{ Py_VISIT(GETSTATE(m)->error); return 0; } -static int _lapackepy_clear(PyObject *m) { +static int _lapackepy_clear(PyObject *m) +{ Py_CLEAR(GETSTATE(m)->error); return 0; } static struct PyModuleDef moduledef = { - PyModuleDef_HEAD_INIT, - "_lapackepy", - NULL, - sizeof(struct module_state), - _lapackepy_methods, - NULL, - _lapackepy_traverse, - _lapackepy_clear, - NULL -}; + PyModuleDef_HEAD_INIT, + "_lapackepy", + NULL, + sizeof(struct module_state), + _lapackepy_methods, + NULL, + _lapackepy_traverse, + _lapackepy_clear, + NULL}; #define INITERROR return NULL @@ -98,8 +100,7 @@ PyInit__lapackepy(void) #else #define INITERROR return - void - init_lapackepy(void) +void init_lapackepy(void) #endif { #if PY_MAJOR_VERSION >= 3 @@ -114,7 +115,8 @@ PyInit__lapackepy(void) st = GETSTATE(module); st->error = PyErr_NewException("_lapackepy.Error", NULL, NULL); - if (st->error == NULL) { + if (st->error == NULL) + { Py_DECREF(module); INITERROR; } @@ -124,10 +126,10 @@ PyInit__lapackepy(void) #endif } -static PyObject * py_phonopy_zheev(PyObject *self, PyObject *args) +static PyObject *py_phonopy_zheev(PyObject *self, PyObject *args) { - PyArrayObject* dynamical_matrix; - PyArrayObject* eigenvalues; + PyArrayObject *dynamical_matrix; + PyArrayObject *eigenvalues; int dimension; npy_cdouble *dynmat; @@ -137,36 +139,39 @@ static PyObject * py_phonopy_zheev(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "OO", &dynamical_matrix, - &eigenvalues)) { + &eigenvalues)) + { return NULL; } dimension = (int)PyArray_DIMS(dynamical_matrix)[0]; - dynmat = (npy_cdouble*)PyArray_DATA(dynamical_matrix); - eigvals = (double*)PyArray_DATA(eigenvalues); + dynmat = (npy_cdouble *)PyArray_DATA(dynamical_matrix); + eigvals = (double *)PyArray_DATA(eigenvalues); - a = (lapack_complex_double*) malloc(sizeof(lapack_complex_double) * + a = (lapack_complex_double *)malloc(sizeof(lapack_complex_double) * dimension * dimension); - for (i = 0; i < dimension * dimension; i++) { + for (i = 0; i < dimension * dimension; i++) + { a[i] = lapack_make_complex_double(dynmat[i].real, dynmat[i].imag); } info = phonopy_zheev(eigvals, a, dimension, 'L'); - for (i = 0; i < dimension * dimension; i++) { + for (i = 0; i < dimension * dimension; i++) + { dynmat[i].real = lapack_complex_double_real(a[i]); dynmat[i].imag = lapack_complex_double_imag(a[i]); } free(a); - return PyLong_FromLong((long) info); + return PyLong_FromLong((long)info); } -static PyObject * py_phonopy_pinv(PyObject *self, PyObject *args) +static PyObject *py_phonopy_pinv(PyObject *self, PyObject *args) { - PyArrayObject* data_in_py; - PyArrayObject* data_out_py; + PyArrayObject *data_in_py; + PyArrayObject *data_out_py; double cutoff; int m; @@ -178,16 +183,17 @@ static PyObject * py_phonopy_pinv(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "OOd", &data_out_py, &data_in_py, - &cutoff)) { + &cutoff)) + { return NULL; } m = (int)PyArray_DIMS(data_in_py)[0]; n = (int)PyArray_DIMS(data_in_py)[1]; - data_in = (double*)PyArray_DATA(data_in_py); - data_out = (double*)PyArray_DATA(data_out_py); + data_in = (double *)PyArray_DATA(data_in_py); + data_out = (double *)PyArray_DATA(data_out_py); info = phonopy_pinv(data_out, data_in, m, n, cutoff); - return PyLong_FromLong((long) info); + return PyLong_FromLong((long)info); } diff --git a/c/_phono3py.c b/c/_phono3py.c index 366cd893..894056a8 100644 --- a/c/_phono3py.c +++ b/c/_phono3py.c @@ -43,40 +43,39 @@ #include "phono3py.h" #include "phonoc_array.h" - -static PyObject * py_get_interaction(PyObject *self, PyObject *args); -static PyObject * py_get_pp_collision(PyObject *self, PyObject *args); +static PyObject *py_get_interaction(PyObject *self, PyObject *args); +static PyObject *py_get_pp_collision(PyObject *self, PyObject *args); static PyObject * py_get_pp_collision_with_sigma(PyObject *self, PyObject *args); static PyObject * py_get_imag_self_energy_with_g(PyObject *self, PyObject *args); static PyObject * py_get_detailed_imag_self_energy_with_g(PyObject *self, PyObject *args); -static PyObject * py_get_real_self_energy_at_bands(PyObject *self, +static PyObject *py_get_real_self_energy_at_bands(PyObject *self, + PyObject *args); +static PyObject *py_get_real_self_energy_at_frequency_point(PyObject *self, + PyObject *args); +static PyObject *py_get_collision_matrix(PyObject *self, PyObject *args); +static PyObject *py_get_reducible_collision_matrix(PyObject *self, PyObject *args); -static PyObject * py_get_real_self_energy_at_frequency_point(PyObject *self, - PyObject *args); -static PyObject * py_get_collision_matrix(PyObject *self, PyObject *args); -static PyObject * py_get_reducible_collision_matrix(PyObject *self, - PyObject *args); -static PyObject * py_symmetrize_collision_matrix(PyObject *self, - PyObject *args); -static PyObject * py_expand_collision_matrix(PyObject *self, PyObject *args); -static PyObject * py_distribute_fc3(PyObject *self, PyObject *args); -static PyObject * py_rotate_delta_fc2s(PyObject *self, PyObject *args); -static PyObject * py_get_isotope_strength(PyObject *self, PyObject *args); -static PyObject * py_get_thm_isotope_strength(PyObject *self, PyObject *args); +static PyObject *py_symmetrize_collision_matrix(PyObject *self, + PyObject *args); +static PyObject *py_expand_collision_matrix(PyObject *self, PyObject *args); +static PyObject *py_distribute_fc3(PyObject *self, PyObject *args); +static PyObject *py_rotate_delta_fc2s(PyObject *self, PyObject *args); +static PyObject *py_get_isotope_strength(PyObject *self, PyObject *args); +static PyObject *py_get_thm_isotope_strength(PyObject *self, PyObject *args); static PyObject * py_get_permutation_symmetry_fc3(PyObject *self, PyObject *args); static PyObject * py_get_permutation_symmetry_compact_fc3(PyObject *self, PyObject *args); -static PyObject * py_transpose_compact_fc3(PyObject *self, PyObject *args); -static PyObject * py_get_neighboring_grid_points(PyObject *self, PyObject *args); +static PyObject *py_transpose_compact_fc3(PyObject *self, PyObject *args); +static PyObject *py_get_neighboring_grid_points(PyObject *self, PyObject *args); static PyObject * py_get_thm_integration_weights_at_grid_points(PyObject *self, PyObject *args); static PyObject * py_tpl_get_triplets_reciprocal_mesh_at_q(PyObject *self, PyObject *args); -static PyObject * py_tpl_get_BZ_triplets_at_q(PyObject *self, PyObject *args); +static PyObject *py_tpl_get_BZ_triplets_at_q(PyObject *self, PyObject *args); static PyObject * py_get_triplets_integration_weights(PyObject *self, PyObject *args); static PyObject * @@ -91,12 +90,12 @@ static PyObject * py_get_snf3x3(PyObject *self, PyObject *args); static PyObject * py_get_ir_grid_map(PyObject *self, PyObject *args); -static PyObject * py_get_bz_grid_addresses(PyObject *self, PyObject *args); -static PyObject * py_rotate_bz_grid_addresses(PyObject *self, PyObject *args); +static PyObject *py_get_bz_grid_addresses(PyObject *self, PyObject *args); +static PyObject *py_rotate_bz_grid_addresses(PyObject *self, PyObject *args); static PyObject * py_diagonalize_collision_matrix(PyObject *self, PyObject *args); -static PyObject * py_pinv_from_eigensolution(PyObject *self, PyObject *args); -static PyObject * py_get_default_colmat_solver(PyObject *self, PyObject *args); +static PyObject *py_pinv_from_eigensolution(PyObject *self, PyObject *args); +static PyObject *py_get_default_colmat_solver(PyObject *self, PyObject *args); static void pinv_from_eigensolution(double *data, const double *eigvals, @@ -107,196 +106,197 @@ static void show_colmat_info(const PyArrayObject *collision_matrix_py, const long i_sigma, const long i_temp, const long adrs_shift); -static Larray* convert_to_larray(const PyArrayObject* npyary); -static Darray* convert_to_darray(const PyArrayObject* npyary); +static Larray *convert_to_larray(const PyArrayObject *npyary); +static Darray *convert_to_darray(const PyArrayObject *npyary); - -struct module_state { +struct module_state +{ PyObject *error; }; #if PY_MAJOR_VERSION >= 3 -#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m)) +#define GETSTATE(m) ((struct module_state *)PyModule_GetState(m)) #else #define GETSTATE(m) (&_state) static struct module_state _state; #endif static PyObject * -error_out(PyObject *m) { +error_out(PyObject *m) +{ struct module_state *st = GETSTATE(m); PyErr_SetString(st->error, "something bad happened"); return NULL; } static PyMethodDef _phono3py_methods[] = { - {"error_out", (PyCFunction)error_out, METH_NOARGS, NULL}, - {"interaction", - (PyCFunction)py_get_interaction, - METH_VARARGS, - "Interaction of triplets"}, - {"pp_collision", - (PyCFunction)py_get_pp_collision, - METH_VARARGS, - "Collision and ph-ph calculation"}, - {"pp_collision_with_sigma", - (PyCFunction)py_get_pp_collision_with_sigma, - METH_VARARGS, - "Collision and ph-ph calculation for smearing method"}, - {"imag_self_energy_with_g", - (PyCFunction)py_get_imag_self_energy_with_g, - METH_VARARGS, - "Imaginary part of self energy at frequency points with g"}, - {"detailed_imag_self_energy_with_g", - (PyCFunction)py_get_detailed_imag_self_energy_with_g, - METH_VARARGS, - "Detailed contribution to imaginary part of self energy at frequency points with g"}, - {"real_self_energy_at_bands", - (PyCFunction)py_get_real_self_energy_at_bands, - METH_VARARGS, - "Real part of self energy from third order force constants"}, - {"real_self_energy_at_frequency_point", - (PyCFunction)py_get_real_self_energy_at_frequency_point, - METH_VARARGS, - "Real part of self energy from third order force constants at a frequency point"}, - {"collision_matrix", - (PyCFunction)py_get_collision_matrix, - METH_VARARGS, - "Collision matrix with g"}, - {"reducible_collision_matrix", - (PyCFunction)py_get_reducible_collision_matrix, - METH_VARARGS, - "Collision matrix with g for reducible grid points"}, - {"symmetrize_collision_matrix", - (PyCFunction)py_symmetrize_collision_matrix, - METH_VARARGS, - "Symmetrize collision matrix"}, - {"expand_collision_matrix", - (PyCFunction)py_expand_collision_matrix, - METH_VARARGS, - "Expand collision matrix"}, - {"distribute_fc3", - (PyCFunction)py_distribute_fc3, - METH_VARARGS, - "Distribute least fc3 to full fc3"}, - {"rotate_delta_fc2s", - (PyCFunction)py_rotate_delta_fc2s, - METH_VARARGS, - "Rotate delta fc2s"}, - {"isotope_strength", - (PyCFunction)py_get_isotope_strength, - METH_VARARGS, - "Isotope scattering strength"}, - {"thm_isotope_strength", - (PyCFunction)py_get_thm_isotope_strength, - METH_VARARGS, - "Isotope scattering strength for tetrahedron_method"}, - {"permutation_symmetry_fc3", - (PyCFunction)py_get_permutation_symmetry_fc3, - METH_VARARGS, - "Set permutation symmetry for fc3"}, - {"permutation_symmetry_compact_fc3", - (PyCFunction)py_get_permutation_symmetry_compact_fc3, - METH_VARARGS, - "Set permutation symmetry for compact-fc3"}, - {"transpose_compact_fc3", - (PyCFunction)py_transpose_compact_fc3, - METH_VARARGS, - "Transpose compact fc3"}, - {"neighboring_grid_points", - (PyCFunction)py_get_neighboring_grid_points, - METH_VARARGS, - "Neighboring grid points by relative grid addresses"}, - {"integration_weights_at_grid_points", - (PyCFunction)py_get_thm_integration_weights_at_grid_points, - METH_VARARGS, - "Integration weights of tetrahedron method at grid points"}, - {"triplets_reciprocal_mesh_at_q", - (PyCFunction)py_tpl_get_triplets_reciprocal_mesh_at_q, - METH_VARARGS, - "Triplets on reciprocal mesh points at a specific q-point"}, - {"BZ_triplets_at_q", - (PyCFunction)py_tpl_get_BZ_triplets_at_q, - METH_VARARGS, - "Triplets in reciprocal primitive lattice are transformed to those in BZ."}, - {"triplets_integration_weights", - (PyCFunction)py_get_triplets_integration_weights, - METH_VARARGS, - "Integration weights of tetrahedron method for triplets"}, - {"triplets_integration_weights_with_sigma", - (PyCFunction)py_get_triplets_integration_weights_with_sigma, - METH_VARARGS, - "Integration weights of smearing method for triplets"}, - {"grid_index_from_address", - (PyCFunction)py_get_grid_index_from_address, - METH_VARARGS, - "Grid index from grid address"}, - {"ir_grid_map", - (PyCFunction)py_get_ir_grid_map, - METH_VARARGS, - "Reciprocal mesh points with ir grid mapping table"}, - {"gr_grid_addresses", - (PyCFunction)py_get_gr_grid_addresses, - METH_VARARGS, - "Get generalized regular grid addresses"}, - {"reciprocal_rotations", - (PyCFunction)py_get_reciprocal_rotations, - METH_VARARGS, - "Return rotation matrices in reciprocal space"}, - {"transform_rotations", - (PyCFunction)py_transform_rotations, - METH_VARARGS, - "Transform rotations to those in generalized regular grid"}, - {"snf3x3", - (PyCFunction)py_get_snf3x3, - METH_VARARGS, - "Get Smith formal form for 3x3 integer matrix"}, - {"bz_grid_addresses", - (PyCFunction)py_get_bz_grid_addresses, - METH_VARARGS, - "Get grid addresses including Brillouin zone surface"}, - {"rotate_bz_grid_index", - (PyCFunction)py_rotate_bz_grid_addresses, - METH_VARARGS, - "Rotate grid point considering Brillouin zone surface"}, - {"diagonalize_collision_matrix", - (PyCFunction)py_diagonalize_collision_matrix, - METH_VARARGS, - "Diagonalize and optionally pseudo-inverse using Lapack dsyev(d)"}, - {"pinv_from_eigensolution", - (PyCFunction)py_pinv_from_eigensolution, - METH_VARARGS, - "Pseudo-inverse from eigensolution"}, - {"default_colmat_solver", - (PyCFunction)py_get_default_colmat_solver, - METH_VARARGS, - "Return default collison matrix solver by integer value"}, - {NULL, NULL, 0, NULL} -}; + {"error_out", (PyCFunction)error_out, METH_NOARGS, NULL}, + {"interaction", + (PyCFunction)py_get_interaction, + METH_VARARGS, + "Interaction of triplets"}, + {"pp_collision", + (PyCFunction)py_get_pp_collision, + METH_VARARGS, + "Collision and ph-ph calculation"}, + {"pp_collision_with_sigma", + (PyCFunction)py_get_pp_collision_with_sigma, + METH_VARARGS, + "Collision and ph-ph calculation for smearing method"}, + {"imag_self_energy_with_g", + (PyCFunction)py_get_imag_self_energy_with_g, + METH_VARARGS, + "Imaginary part of self energy at frequency points with g"}, + {"detailed_imag_self_energy_with_g", + (PyCFunction)py_get_detailed_imag_self_energy_with_g, + METH_VARARGS, + "Detailed contribution to imaginary part of self energy at frequency points with g"}, + {"real_self_energy_at_bands", + (PyCFunction)py_get_real_self_energy_at_bands, + METH_VARARGS, + "Real part of self energy from third order force constants"}, + {"real_self_energy_at_frequency_point", + (PyCFunction)py_get_real_self_energy_at_frequency_point, + METH_VARARGS, + "Real part of self energy from third order force constants at a frequency point"}, + {"collision_matrix", + (PyCFunction)py_get_collision_matrix, + METH_VARARGS, + "Collision matrix with g"}, + {"reducible_collision_matrix", + (PyCFunction)py_get_reducible_collision_matrix, + METH_VARARGS, + "Collision matrix with g for reducible grid points"}, + {"symmetrize_collision_matrix", + (PyCFunction)py_symmetrize_collision_matrix, + METH_VARARGS, + "Symmetrize collision matrix"}, + {"expand_collision_matrix", + (PyCFunction)py_expand_collision_matrix, + METH_VARARGS, + "Expand collision matrix"}, + {"distribute_fc3", + (PyCFunction)py_distribute_fc3, + METH_VARARGS, + "Distribute least fc3 to full fc3"}, + {"rotate_delta_fc2s", + (PyCFunction)py_rotate_delta_fc2s, + METH_VARARGS, + "Rotate delta fc2s"}, + {"isotope_strength", + (PyCFunction)py_get_isotope_strength, + METH_VARARGS, + "Isotope scattering strength"}, + {"thm_isotope_strength", + (PyCFunction)py_get_thm_isotope_strength, + METH_VARARGS, + "Isotope scattering strength for tetrahedron_method"}, + {"permutation_symmetry_fc3", + (PyCFunction)py_get_permutation_symmetry_fc3, + METH_VARARGS, + "Set permutation symmetry for fc3"}, + {"permutation_symmetry_compact_fc3", + (PyCFunction)py_get_permutation_symmetry_compact_fc3, + METH_VARARGS, + "Set permutation symmetry for compact-fc3"}, + {"transpose_compact_fc3", + (PyCFunction)py_transpose_compact_fc3, + METH_VARARGS, + "Transpose compact fc3"}, + {"neighboring_grid_points", + (PyCFunction)py_get_neighboring_grid_points, + METH_VARARGS, + "Neighboring grid points by relative grid addresses"}, + {"integration_weights_at_grid_points", + (PyCFunction)py_get_thm_integration_weights_at_grid_points, + METH_VARARGS, + "Integration weights of tetrahedron method at grid points"}, + {"triplets_reciprocal_mesh_at_q", + (PyCFunction)py_tpl_get_triplets_reciprocal_mesh_at_q, + METH_VARARGS, + "Triplets on reciprocal mesh points at a specific q-point"}, + {"BZ_triplets_at_q", + (PyCFunction)py_tpl_get_BZ_triplets_at_q, + METH_VARARGS, + "Triplets in reciprocal primitive lattice are transformed to those in BZ."}, + {"triplets_integration_weights", + (PyCFunction)py_get_triplets_integration_weights, + METH_VARARGS, + "Integration weights of tetrahedron method for triplets"}, + {"triplets_integration_weights_with_sigma", + (PyCFunction)py_get_triplets_integration_weights_with_sigma, + METH_VARARGS, + "Integration weights of smearing method for triplets"}, + {"grid_index_from_address", + (PyCFunction)py_get_grid_index_from_address, + METH_VARARGS, + "Grid index from grid address"}, + {"ir_grid_map", + (PyCFunction)py_get_ir_grid_map, + METH_VARARGS, + "Reciprocal mesh points with ir grid mapping table"}, + {"gr_grid_addresses", + (PyCFunction)py_get_gr_grid_addresses, + METH_VARARGS, + "Get generalized regular grid addresses"}, + {"reciprocal_rotations", + (PyCFunction)py_get_reciprocal_rotations, + METH_VARARGS, + "Return rotation matrices in reciprocal space"}, + {"transform_rotations", + (PyCFunction)py_transform_rotations, + METH_VARARGS, + "Transform rotations to those in generalized regular grid"}, + {"snf3x3", + (PyCFunction)py_get_snf3x3, + METH_VARARGS, + "Get Smith formal form for 3x3 integer matrix"}, + {"bz_grid_addresses", + (PyCFunction)py_get_bz_grid_addresses, + METH_VARARGS, + "Get grid addresses including Brillouin zone surface"}, + {"rotate_bz_grid_index", + (PyCFunction)py_rotate_bz_grid_addresses, + METH_VARARGS, + "Rotate grid point considering Brillouin zone surface"}, + {"diagonalize_collision_matrix", + (PyCFunction)py_diagonalize_collision_matrix, + METH_VARARGS, + "Diagonalize and optionally pseudo-inverse using Lapack dsyev(d)"}, + {"pinv_from_eigensolution", + (PyCFunction)py_pinv_from_eigensolution, + METH_VARARGS, + "Pseudo-inverse from eigensolution"}, + {"default_colmat_solver", + (PyCFunction)py_get_default_colmat_solver, + METH_VARARGS, + "Return default collison matrix solver by integer value"}, + {NULL, NULL, 0, NULL}}; #if PY_MAJOR_VERSION >= 3 -static int _phono3py_traverse(PyObject *m, visitproc visit, void *arg) { +static int _phono3py_traverse(PyObject *m, visitproc visit, void *arg) +{ Py_VISIT(GETSTATE(m)->error); return 0; } -static int _phono3py_clear(PyObject *m) { +static int _phono3py_clear(PyObject *m) +{ Py_CLEAR(GETSTATE(m)->error); return 0; } static struct PyModuleDef moduledef = { - PyModuleDef_HEAD_INIT, - "_phono3py", - NULL, - sizeof(struct module_state), - _phono3py_methods, - NULL, - _phono3py_traverse, - _phono3py_clear, - NULL -}; + PyModuleDef_HEAD_INIT, + "_phono3py", + NULL, + sizeof(struct module_state), + _phono3py_methods, + NULL, + _phono3py_traverse, + _phono3py_clear, + NULL}; #define INITERROR return NULL @@ -306,8 +306,7 @@ PyInit__phono3py(void) #else #define INITERROR return - void - init_phono3py(void) +void init_phono3py(void) #endif { #if PY_MAJOR_VERSION >= 3 @@ -322,7 +321,8 @@ PyInit__phono3py(void) st = GETSTATE(module); st->error = PyErr_NewException("_phono3py.Error", NULL, NULL); - if (st->error == NULL) { + if (st->error == NULL) + { Py_DECREF(module); INITERROR; } @@ -332,8 +332,7 @@ PyInit__phono3py(void) #endif } - -static PyObject * py_get_interaction(PyObject *self, PyObject *args) +static PyObject *py_get_interaction(PyObject *self, PyObject *args) { PyArrayObject *py_fc3_normal_squared; PyArrayObject *py_g_zero; @@ -356,15 +355,15 @@ static PyObject * py_get_interaction(PyObject *self, PyObject *args) Darray *fc3_normal_squared; Darray *freqs; lapack_complex_double *eigvecs; - long (*triplets)[3]; + long(*triplets)[3]; long num_triplets; - char* g_zero; - long (*bz_grid_addresses)[3]; + char *g_zero; + long(*bz_grid_addresses)[3]; long *D_diag; - long (*Q)[3]; + long(*Q)[3]; double *fc3; - double (*svecs)[3]; - long (*multi)[2]; + double(*svecs)[3]; + long(*multi)[2]; double *masses; long *p2s; long *s2p; @@ -390,37 +389,41 @@ static PyObject * py_get_interaction(PyObject *self, PyObject *args) &py_s2p_map, &py_band_indices, &symmetrize_fc3_q, - &cutoff_frequency)) { + &cutoff_frequency)) + { return NULL; } - fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); freqs = convert_to_darray(py_frequencies); /* npy_cdouble and lapack_complex_double may not be compatible. */ /* So eigenvectors should not be used in Python side */ - eigvecs = (lapack_complex_double*)PyArray_DATA(py_eigenvectors); + eigvecs = (lapack_complex_double *)PyArray_DATA(py_eigenvectors); triplets = (long(*)[3])PyArray_DATA(py_triplets); num_triplets = (long)PyArray_DIMS(py_triplets)[0]; - g_zero = (char*)PyArray_DATA(py_g_zero); + g_zero = (char *)PyArray_DATA(py_g_zero); bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); - D_diag = (long*)PyArray_DATA(py_D_diag); + D_diag = (long *)PyArray_DATA(py_D_diag); Q = (long(*)[3])PyArray_DATA(py_Q); - fc3 = (double*)PyArray_DATA(py_fc3); - if (PyArray_DIMS(py_fc3)[0] == PyArray_DIMS(py_fc3)[1]) { + fc3 = (double *)PyArray_DATA(py_fc3); + if (PyArray_DIMS(py_fc3)[0] == PyArray_DIMS(py_fc3)[1]) + { is_compact_fc3 = 0; - } else { + } + else + { is_compact_fc3 = 1; } svecs = (double(*)[3])PyArray_DATA(py_svecs); - for (i = 0; i < 2; i++) { + for (i = 0; i < 2; i++) + { multi_dims[i] = PyArray_DIMS(py_multi)[i]; } multi = (long(*)[2])PyArray_DATA(py_multi); - masses = (double*)PyArray_DATA(py_masses); - p2s = (long*)PyArray_DATA(py_p2s_map); - s2p = (long*)PyArray_DATA(py_s2p_map); - band_indices = (long*)PyArray_DATA(py_band_indices); + masses = (double *)PyArray_DATA(py_masses); + p2s = (long *)PyArray_DATA(py_p2s_map); + s2p = (long *)PyArray_DATA(py_s2p_map); + band_indices = (long *)PyArray_DATA(py_band_indices); ph3py_get_interaction(fc3_normal_squared, g_zero, @@ -451,8 +454,7 @@ static PyObject * py_get_interaction(PyObject *self, PyObject *args) Py_RETURN_NONE; } - -static PyObject * py_get_pp_collision(PyObject *self, PyObject *args) +static PyObject *py_get_pp_collision(PyObject *self, PyObject *args) { PyArrayObject *py_gamma; PyArrayObject *py_relative_grid_address; @@ -478,19 +480,19 @@ static PyObject * py_get_pp_collision(PyObject *self, PyObject *args) long bz_grid_type; double *gamma; - long (*relative_grid_address)[4][3]; + long(*relative_grid_address)[4][3]; double *frequencies; lapack_complex_double *eigenvectors; - long (*triplets)[3]; + long(*triplets)[3]; long num_triplets; long *triplet_weights; - long (*bz_grid_addresses)[3]; + long(*bz_grid_addresses)[3]; long *bz_map; long *D_diag; - long (*Q)[3]; + long(*Q)[3]; double *fc3; - double (*svecs)[3]; - long (*multi)[2]; + double(*svecs)[3]; + long(*multi)[2]; double *masses; long *p2s; long *s2p; @@ -522,35 +524,40 @@ static PyObject * py_get_pp_collision(PyObject *self, PyObject *args) &py_temperatures, &is_NU, &symmetrize_fc3_q, - &cutoff_frequency)) { + &cutoff_frequency)) + { return NULL; } - gamma = (double*)PyArray_DATA(py_gamma); + gamma = (double *)PyArray_DATA(py_gamma); relative_grid_address = (long(*)[4][3])PyArray_DATA(py_relative_grid_address); - frequencies = (double*)PyArray_DATA(py_frequencies); - eigenvectors = (lapack_complex_double*)PyArray_DATA(py_eigenvectors); + frequencies = (double *)PyArray_DATA(py_frequencies); + eigenvectors = (lapack_complex_double *)PyArray_DATA(py_eigenvectors); triplets = (long(*)[3])PyArray_DATA(py_triplets); num_triplets = (long)PyArray_DIMS(py_triplets)[0]; - triplet_weights = (long*)PyArray_DATA(py_triplet_weights); + triplet_weights = (long *)PyArray_DATA(py_triplet_weights); bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); - bz_map = (long*)PyArray_DATA(py_bz_map); - D_diag = (long*)PyArray_DATA(py_D_diag); + bz_map = (long *)PyArray_DATA(py_bz_map); + D_diag = (long *)PyArray_DATA(py_D_diag); Q = (long(*)[3])PyArray_DATA(py_Q); - fc3 = (double*)PyArray_DATA(py_fc3); - if (PyArray_DIMS(py_fc3)[0] == PyArray_DIMS(py_fc3)[1]) { + fc3 = (double *)PyArray_DATA(py_fc3); + if (PyArray_DIMS(py_fc3)[0] == PyArray_DIMS(py_fc3)[1]) + { is_compact_fc3 = 0; - } else { + } + else + { is_compact_fc3 = 1; } svecs = (double(*)[3])PyArray_DATA(py_svecs); - for (i = 0; i < 2; i++) { + for (i = 0; i < 2; i++) + { multi_dims[i] = PyArray_DIMS(py_multi)[i]; } multi = (long(*)[2])PyArray_DATA(py_multi); - masses = (double*)PyArray_DATA(py_masses); - p2s = (long*)PyArray_DATA(py_p2s_map); - s2p = (long*)PyArray_DATA(py_s2p_map); + masses = (double *)PyArray_DATA(py_masses); + p2s = (long *)PyArray_DATA(py_p2s_map); + s2p = (long *)PyArray_DATA(py_s2p_map); band_indices = convert_to_larray(py_band_indices); temperatures = convert_to_darray(py_temperatures); @@ -588,8 +595,7 @@ static PyObject * py_get_pp_collision(PyObject *self, PyObject *args) Py_RETURN_NONE; } - -static PyObject * py_get_pp_collision_with_sigma(PyObject *self, PyObject *args) +static PyObject *py_get_pp_collision_with_sigma(PyObject *self, PyObject *args) { PyArrayObject *py_gamma; PyArrayObject *py_frequencies; @@ -616,15 +622,15 @@ static PyObject * py_get_pp_collision_with_sigma(PyObject *self, PyObject *args) double *gamma; double *frequencies; lapack_complex_double *eigenvectors; - long (*triplets)[3]; + long(*triplets)[3]; long num_triplets; long *triplet_weights; - long (*bz_grid_addresses)[3]; + long(*bz_grid_addresses)[3]; long *D_diag; - long (*Q)[3]; + long(*Q)[3]; double *fc3; - double (*svecs)[3]; - long (*multi)[2]; + double(*svecs)[3]; + long(*multi)[2]; double *masses; long *p2s; long *s2p; @@ -655,33 +661,38 @@ static PyObject * py_get_pp_collision_with_sigma(PyObject *self, PyObject *args) &py_temperatures, &is_NU, &symmetrize_fc3_q, - &cutoff_frequency)) { + &cutoff_frequency)) + { return NULL; } - gamma = (double*)PyArray_DATA(py_gamma); - frequencies = (double*)PyArray_DATA(py_frequencies); - eigenvectors = (lapack_complex_double*)PyArray_DATA(py_eigenvectors); + gamma = (double *)PyArray_DATA(py_gamma); + frequencies = (double *)PyArray_DATA(py_frequencies); + eigenvectors = (lapack_complex_double *)PyArray_DATA(py_eigenvectors); triplets = (long(*)[3])PyArray_DATA(py_triplets); num_triplets = (long)PyArray_DIMS(py_triplets)[0]; - triplet_weights = (long*)PyArray_DATA(py_triplet_weights); + triplet_weights = (long *)PyArray_DATA(py_triplet_weights); bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); - D_diag = (long*)PyArray_DATA(py_D_diag); + D_diag = (long *)PyArray_DATA(py_D_diag); Q = (long(*)[3])PyArray_DATA(py_Q); - fc3 = (double*)PyArray_DATA(py_fc3); - if (PyArray_DIMS(py_fc3)[0] == PyArray_DIMS(py_fc3)[1]) { + fc3 = (double *)PyArray_DATA(py_fc3); + if (PyArray_DIMS(py_fc3)[0] == PyArray_DIMS(py_fc3)[1]) + { is_compact_fc3 = 0; - } else { + } + else + { is_compact_fc3 = 1; } svecs = (double(*)[3])PyArray_DATA(py_svecs); - for (i = 0; i < 2; i++) { + for (i = 0; i < 2; i++) + { multi_dims[i] = PyArray_DIMS(py_multi)[i]; } multi = (long(*)[2])PyArray_DATA(py_multi); - masses = (double*)PyArray_DATA(py_masses); - p2s = (long*)PyArray_DATA(py_p2s_map); - s2p = (long*)PyArray_DATA(py_s2p_map); + masses = (double *)PyArray_DATA(py_masses); + p2s = (long *)PyArray_DATA(py_p2s_map); + s2p = (long *)PyArray_DATA(py_s2p_map); band_indices = convert_to_larray(py_band_indices); temperatures = convert_to_darray(py_temperatures); @@ -718,8 +729,7 @@ static PyObject * py_get_pp_collision_with_sigma(PyObject *self, PyObject *args) Py_RETURN_NONE; } - -static PyObject * py_get_imag_self_energy_with_g(PyObject *self, PyObject *args) +static PyObject *py_get_imag_self_energy_with_g(PyObject *self, PyObject *args) { PyArrayObject *py_gamma; PyArrayObject *py_fc3_normal_squared; @@ -734,9 +744,9 @@ static PyObject * py_get_imag_self_energy_with_g(PyObject *self, PyObject *args) Darray *fc3_normal_squared; double *gamma; double *g; - char* g_zero; + char *g_zero; double *frequencies; - long (*triplets)[3]; + long(*triplets)[3]; long *triplet_weights; long num_frequency_points; @@ -750,17 +760,18 @@ static PyObject * py_get_imag_self_energy_with_g(PyObject *self, PyObject *args) &py_g, &py_g_zero, &cutoff_frequency, - &frequency_point_index)) { + &frequency_point_index)) + { return NULL; } fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); - gamma = (double*)PyArray_DATA(py_gamma); - g = (double*)PyArray_DATA(py_g); - g_zero = (char*)PyArray_DATA(py_g_zero); - frequencies = (double*)PyArray_DATA(py_frequencies); + gamma = (double *)PyArray_DATA(py_gamma); + g = (double *)PyArray_DATA(py_g); + g_zero = (char *)PyArray_DATA(py_g_zero); + frequencies = (double *)PyArray_DATA(py_frequencies); triplets = (long(*)[3])PyArray_DATA(py_triplets); - triplet_weights = (long*)PyArray_DATA(py_triplet_weights); + triplet_weights = (long *)PyArray_DATA(py_triplet_weights); num_frequency_points = (long)PyArray_DIMS(py_g)[2]; ph3py_get_imag_self_energy_at_bands_with_g(gamma, @@ -781,7 +792,6 @@ static PyObject * py_get_imag_self_energy_with_g(PyObject *self, PyObject *args) Py_RETURN_NONE; } - static PyObject * py_get_detailed_imag_self_energy_with_g(PyObject *self, PyObject *args) { @@ -802,11 +812,11 @@ py_get_detailed_imag_self_energy_with_g(PyObject *self, PyObject *args) double *gamma_N; double *gamma_U; double *g; - char* g_zero; + char *g_zero; double *frequencies; - long (*triplets)[3]; + long(*triplets)[3]; long *triplet_weights; - long (*bz_grid_addresses)[3]; + long(*bz_grid_addresses)[3]; if (!PyArg_ParseTuple(args, "OOOOOOOOdOOd", &py_gamma_detail, @@ -820,19 +830,20 @@ py_get_detailed_imag_self_energy_with_g(PyObject *self, PyObject *args) &temperature, &py_g, &py_g_zero, - &cutoff_frequency)) { + &cutoff_frequency)) + { return NULL; } fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); - gamma_detail = (double*)PyArray_DATA(py_gamma_detail); - gamma_N = (double*)PyArray_DATA(py_gamma_N); - gamma_U = (double*)PyArray_DATA(py_gamma_U); - g = (double*)PyArray_DATA(py_g); - g_zero = (char*)PyArray_DATA(py_g_zero); - frequencies = (double*)PyArray_DATA(py_frequencies); + gamma_detail = (double *)PyArray_DATA(py_gamma_detail); + gamma_N = (double *)PyArray_DATA(py_gamma_N); + gamma_U = (double *)PyArray_DATA(py_gamma_U); + g = (double *)PyArray_DATA(py_g); + g_zero = (char *)PyArray_DATA(py_g_zero); + frequencies = (double *)PyArray_DATA(py_frequencies); triplets = (long(*)[3])PyArray_DATA(py_triplets); - triplet_weights = (long*)PyArray_DATA(py_triplet_weights); + triplet_weights = (long *)PyArray_DATA(py_triplet_weights); bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); ph3py_get_detailed_imag_self_energy_at_bands_with_g(gamma_detail, @@ -854,9 +865,8 @@ py_get_detailed_imag_self_energy_with_g(PyObject *self, PyObject *args) Py_RETURN_NONE; } - -static PyObject * py_get_real_self_energy_at_bands(PyObject *self, - PyObject *args) +static PyObject *py_get_real_self_energy_at_bands(PyObject *self, + PyObject *args) { PyArrayObject *py_shift; PyArrayObject *py_fc3_normal_squared; @@ -870,7 +880,7 @@ static PyObject * py_get_real_self_energy_at_bands(PyObject *self, double *shift; double *frequencies; long *band_indices; - long (*triplets)[3]; + long(*triplets)[3]; long *triplet_weights; if (!PyArg_ParseTuple(args, "OOOOOOdddd", @@ -883,17 +893,17 @@ static PyObject * py_get_real_self_energy_at_bands(PyObject *self, &temperature, &epsilon, &unit_conversion_factor, - &cutoff_frequency)) { + &cutoff_frequency)) + { return NULL; } - fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); - shift = (double*)PyArray_DATA(py_shift); - frequencies = (double*)PyArray_DATA(py_frequencies); - band_indices = (long*)PyArray_DATA(py_band_indices); + shift = (double *)PyArray_DATA(py_shift); + frequencies = (double *)PyArray_DATA(py_frequencies); + band_indices = (long *)PyArray_DATA(py_band_indices); triplets = (long(*)[3])PyArray_DATA(py_triplets); - triplet_weights = (long*)PyArray_DATA(py_triplet_weights); + triplet_weights = (long *)PyArray_DATA(py_triplet_weights); ph3py_get_real_self_energy_at_bands(shift, fc3_normal_squared, @@ -912,9 +922,8 @@ static PyObject * py_get_real_self_energy_at_bands(PyObject *self, Py_RETURN_NONE; } - -static PyObject * py_get_real_self_energy_at_frequency_point(PyObject *self, - PyObject *args) +static PyObject *py_get_real_self_energy_at_frequency_point(PyObject *self, + PyObject *args) { PyArrayObject *py_shift; PyArrayObject *py_fc3_normal_squared; @@ -929,7 +938,7 @@ static PyObject * py_get_real_self_energy_at_frequency_point(PyObject *self, double *shift; double *frequencies; long *band_indices; - long (*triplets)[3]; + long(*triplets)[3]; long *triplet_weights; if (!PyArg_ParseTuple(args, "OdOOOOOdddd", @@ -943,17 +952,17 @@ static PyObject * py_get_real_self_energy_at_frequency_point(PyObject *self, &temperature, &epsilon, &unit_conversion_factor, - &cutoff_frequency)) { + &cutoff_frequency)) + { return NULL; } - fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); - shift = (double*)PyArray_DATA(py_shift); - frequencies = (double*)PyArray_DATA(py_frequencies); - band_indices = (long*)PyArray_DATA(py_band_indices); + shift = (double *)PyArray_DATA(py_shift); + frequencies = (double *)PyArray_DATA(py_frequencies); + band_indices = (long *)PyArray_DATA(py_band_indices); triplets = (long(*)[3])PyArray_DATA(py_triplets); - triplet_weights = (long*)PyArray_DATA(py_triplet_weights); + triplet_weights = (long *)PyArray_DATA(py_triplet_weights); ph3py_get_real_self_energy_at_frequency_point(shift, frequency_point, @@ -973,8 +982,7 @@ static PyObject * py_get_real_self_energy_at_frequency_point(PyObject *self, Py_RETURN_NONE; } - -static PyObject * py_get_collision_matrix(PyObject *self, PyObject *args) +static PyObject *py_get_collision_matrix(PyObject *self, PyObject *args) { PyArrayObject *py_collision_matrix; PyArrayObject *py_fc3_normal_squared; @@ -991,7 +999,7 @@ static PyObject * py_get_collision_matrix(PyObject *self, PyObject *args) double *collision_matrix; double *g; double *frequencies; - long (*triplets)[3]; + long(*triplets)[3]; long *triplets_map; long *map_q; long *rotated_grid_points; @@ -1010,22 +1018,23 @@ static PyObject * py_get_collision_matrix(PyObject *self, PyObject *args) &py_rotations_cartesian, &temperature, &unit_conversion_factor, - &cutoff_frequency)) { + &cutoff_frequency)) + { return NULL; } fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); - collision_matrix = (double*)PyArray_DATA(py_collision_matrix); - g = (double*)PyArray_DATA(py_g); - frequencies = (double*)PyArray_DATA(py_frequencies); + collision_matrix = (double *)PyArray_DATA(py_collision_matrix); + g = (double *)PyArray_DATA(py_g); + frequencies = (double *)PyArray_DATA(py_frequencies); triplets = (long(*)[3])PyArray_DATA(py_triplets); - triplets_map = (long*)PyArray_DATA(py_triplets_map); + triplets_map = (long *)PyArray_DATA(py_triplets_map); num_gp = (long)PyArray_DIMS(py_triplets_map)[0]; - map_q = (long*)PyArray_DATA(py_map_q); - rotated_grid_points = (long*)PyArray_DATA(py_rotated_grid_points); + map_q = (long *)PyArray_DATA(py_map_q); + rotated_grid_points = (long *)PyArray_DATA(py_rotated_grid_points); num_ir_gp = (long)PyArray_DIMS(py_rotated_grid_points)[0]; num_rot = (long)PyArray_DIMS(py_rotated_grid_points)[1]; - rotations_cartesian = (double*)PyArray_DATA(py_rotations_cartesian); + rotations_cartesian = (double *)PyArray_DATA(py_rotations_cartesian); assert(num_rot == PyArray_DIMS(py_rotations_cartesian)[0]); assert(num_gp == PyArray_DIMS(py_frequencies)[0]); @@ -1052,8 +1061,7 @@ static PyObject * py_get_collision_matrix(PyObject *self, PyObject *args) Py_RETURN_NONE; } - -static PyObject * py_get_reducible_collision_matrix(PyObject *self, PyObject *args) +static PyObject *py_get_reducible_collision_matrix(PyObject *self, PyObject *args) { PyArrayObject *py_collision_matrix; PyArrayObject *py_fc3_normal_squared; @@ -1068,7 +1076,7 @@ static PyObject * py_get_reducible_collision_matrix(PyObject *self, PyObject *ar double *collision_matrix; double *g; double *frequencies; - long (*triplets)[3]; + long(*triplets)[3]; long *triplets_map; long num_gp; long *map_q; @@ -1083,18 +1091,19 @@ static PyObject * py_get_reducible_collision_matrix(PyObject *self, PyObject *ar &py_map_q, &temperature, &unit_conversion_factor, - &cutoff_frequency)) { + &cutoff_frequency)) + { return NULL; } fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); - collision_matrix = (double*)PyArray_DATA(py_collision_matrix); - g = (double*)PyArray_DATA(py_g); - frequencies = (double*)PyArray_DATA(py_frequencies); + collision_matrix = (double *)PyArray_DATA(py_collision_matrix); + g = (double *)PyArray_DATA(py_g); + frequencies = (double *)PyArray_DATA(py_frequencies); triplets = (long(*)[3])PyArray_DATA(py_triplets); - triplets_map = (long*)PyArray_DATA(py_triplets_map); + triplets_map = (long *)PyArray_DATA(py_triplets_map); num_gp = (long)PyArray_DIMS(py_triplets_map)[0]; - map_q = (long*)PyArray_DATA(py_map_q); + map_q = (long *)PyArray_DATA(py_map_q); ph3py_get_reducible_collision_matrix(collision_matrix, fc3_normal_squared, @@ -1114,8 +1123,7 @@ static PyObject * py_get_reducible_collision_matrix(PyObject *self, PyObject *ar Py_RETURN_NONE; } - -static PyObject * py_symmetrize_collision_matrix(PyObject *self, PyObject *args) +static PyObject *py_symmetrize_collision_matrix(PyObject *self, PyObject *args) { PyArrayObject *py_collision_matrix; @@ -1124,19 +1132,23 @@ static PyObject * py_symmetrize_collision_matrix(PyObject *self, PyObject *args) long num_column; if (!PyArg_ParseTuple(args, "O", - &py_collision_matrix)) { + &py_collision_matrix)) + { return NULL; } - collision_matrix = (double*)PyArray_DATA(py_collision_matrix); + collision_matrix = (double *)PyArray_DATA(py_collision_matrix); 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]; - if (PyArray_NDIM(py_collision_matrix) == 8) { + if (PyArray_NDIM(py_collision_matrix) == 8) + { num_column = num_grid_points * num_band * 3; - } else { + } + else + { num_column = num_grid_points * num_band; } @@ -1148,8 +1160,7 @@ static PyObject * py_symmetrize_collision_matrix(PyObject *self, PyObject *args) Py_RETURN_NONE; } - -static PyObject * py_expand_collision_matrix(PyObject *self, PyObject *args) +static PyObject *py_expand_collision_matrix(PyObject *self, PyObject *args) { PyArrayObject *py_collision_matrix; PyArrayObject *py_ir_grid_points; @@ -1163,13 +1174,14 @@ static PyObject * py_expand_collision_matrix(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "OOO", &py_collision_matrix, &py_ir_grid_points, - &py_rot_grid_points)) { + &py_rot_grid_points)) + { return NULL; } - collision_matrix = (double*)PyArray_DATA(py_collision_matrix); - rot_grid_points = (long*)PyArray_DATA(py_rot_grid_points); - ir_grid_points = (long*)PyArray_DATA(py_ir_grid_points); + collision_matrix = (double *)PyArray_DATA(py_collision_matrix); + rot_grid_points = (long *)PyArray_DATA(py_rot_grid_points); + ir_grid_points = (long *)PyArray_DATA(py_ir_grid_points); 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]; @@ -1190,8 +1202,7 @@ static PyObject * py_expand_collision_matrix(PyObject *self, PyObject *args) Py_RETURN_NONE; } - -static PyObject * py_get_isotope_strength(PyObject *self, PyObject *args) +static PyObject *py_get_isotope_strength(PyObject *self, PyObject *args) { PyArrayObject *py_gamma; PyArrayObject *py_frequencies; @@ -1219,16 +1230,16 @@ static PyObject * py_get_isotope_strength(PyObject *self, PyObject *args) &py_band_indices, &num_grid_points, &sigma, - &cutoff_frequency)) { + &cutoff_frequency)) + { return NULL; } - - gamma = (double*)PyArray_DATA(py_gamma); - frequencies = (double*)PyArray_DATA(py_frequencies); - eigenvectors = (lapack_complex_double*)PyArray_DATA(py_eigenvectors); - band_indices = (long*)PyArray_DATA(py_band_indices); - mass_variances = (double*)PyArray_DATA(py_mass_variances); + gamma = (double *)PyArray_DATA(py_gamma); + frequencies = (double *)PyArray_DATA(py_frequencies); + eigenvectors = (lapack_complex_double *)PyArray_DATA(py_eigenvectors); + band_indices = (long *)PyArray_DATA(py_band_indices); + mass_variances = (double *)PyArray_DATA(py_mass_variances); num_band = (long)PyArray_DIMS(py_frequencies)[1]; num_band0 = (long)PyArray_DIMS(py_band_indices)[0]; @@ -1247,8 +1258,7 @@ static PyObject * py_get_isotope_strength(PyObject *self, PyObject *args) Py_RETURN_NONE; } - -static PyObject * py_get_thm_isotope_strength(PyObject *self, PyObject *args) +static PyObject *py_get_thm_isotope_strength(PyObject *self, PyObject *args) { PyArrayObject *py_gamma; PyArrayObject *py_frequencies; @@ -1281,21 +1291,21 @@ static PyObject * py_get_thm_isotope_strength(PyObject *self, PyObject *args) &py_eigenvectors, &py_band_indices, &py_integration_weights, - &cutoff_frequency)) { + &cutoff_frequency)) + { return NULL; } - - 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); - eigenvectors = (lapack_complex_double*)PyArray_DATA(py_eigenvectors); - band_indices = (long*)PyArray_DATA(py_band_indices); - mass_variances = (double*)PyArray_DATA(py_mass_variances); + 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); + eigenvectors = (lapack_complex_double *)PyArray_DATA(py_eigenvectors); + band_indices = (long *)PyArray_DATA(py_band_indices); + mass_variances = (double *)PyArray_DATA(py_mass_variances); num_band = (long)PyArray_DIMS(py_frequencies)[1]; num_band0 = (long)PyArray_DIMS(py_band_indices)[0]; - integration_weights = (double*)PyArray_DATA(py_integration_weights); + integration_weights = (double *)PyArray_DATA(py_integration_weights); num_ir_grid_points = (long)PyArray_DIMS(py_ir_grid_points)[0]; ph3py_get_thm_isotope_scattering_strength(gamma, @@ -1315,8 +1325,7 @@ static PyObject * py_get_thm_isotope_strength(PyObject *self, PyObject *args) Py_RETURN_NONE; } - -static PyObject * py_distribute_fc3(PyObject *self, PyObject *args) +static PyObject *py_distribute_fc3(PyObject *self, PyObject *args) { PyArrayObject *force_constants_third; long target; @@ -1334,13 +1343,14 @@ static PyObject * py_distribute_fc3(PyObject *self, PyObject *args) &target, &source, &atom_mapping_py, - &rotation_cart_inv)) { + &rotation_cart_inv)) + { return NULL; } - fc3 = (double*)PyArray_DATA(force_constants_third); - rot_cart_inv = (double*)PyArray_DATA(rotation_cart_inv); - atom_mapping = (long*)PyArray_DATA(atom_mapping_py); + fc3 = (double *)PyArray_DATA(force_constants_third); + rot_cart_inv = (double *)PyArray_DATA(rotation_cart_inv); + atom_mapping = (long *)PyArray_DATA(atom_mapping_py); num_atom = (long)PyArray_DIMS(atom_mapping_py)[0]; ph3py_distribute_fc3(fc3, @@ -1353,8 +1363,7 @@ static PyObject * py_distribute_fc3(PyObject *self, PyObject *args) Py_RETURN_NONE; } - -static PyObject * py_rotate_delta_fc2s(PyObject *self, PyObject *args) +static PyObject *py_rotate_delta_fc2s(PyObject *self, PyObject *args) { PyArrayObject *py_fc3; PyArrayObject *py_delta_fc2s; @@ -1362,10 +1371,10 @@ static PyObject * py_rotate_delta_fc2s(PyObject *self, PyObject *args) PyArrayObject *py_site_sym_cart; PyArrayObject *py_rot_map_syms; - double (*fc3)[3][3][3]; - double (*delta_fc2s)[3][3]; + double(*fc3)[3][3][3]; + double(*delta_fc2s)[3][3]; double *inv_U; - double (*site_sym_cart)[3][3]; + double(*site_sym_cart)[3][3]; long *rot_map_syms; long num_atom, num_disp, num_site_sym; @@ -1374,7 +1383,8 @@ static PyObject * py_rotate_delta_fc2s(PyObject *self, PyObject *args) &py_delta_fc2s, &py_inv_U, &py_site_sym_cart, - &py_rot_map_syms)) { + &py_rot_map_syms)) + { return NULL; } @@ -1383,11 +1393,11 @@ static PyObject * py_rotate_delta_fc2s(PyObject *self, PyObject *args) /* (n_u1, num_atom, num_atom, 3, 3) */ delta_fc2s = (double(*)[3][3])PyArray_DATA(py_delta_fc2s); /* (3, n_u1 * n_sym) */ - inv_U = (double*)PyArray_DATA(py_inv_U); + inv_U = (double *)PyArray_DATA(py_inv_U); /* (n_sym, 3, 3) */ site_sym_cart = (double(*)[3][3])PyArray_DATA(py_site_sym_cart); /* (n_sym, natom) */ - rot_map_syms = (long*)PyArray_DATA(py_rot_map_syms); + rot_map_syms = (long *)PyArray_DATA(py_rot_map_syms); num_atom = (long)PyArray_DIMS(py_fc3)[0]; num_disp = (long)PyArray_DIMS(py_delta_fc2s)[0]; @@ -1405,7 +1415,6 @@ static PyObject * py_rotate_delta_fc2s(PyObject *self, PyObject *args) Py_RETURN_NONE; } - static PyObject * py_get_permutation_symmetry_fc3(PyObject *self, PyObject *args) { @@ -1414,11 +1423,12 @@ py_get_permutation_symmetry_fc3(PyObject *self, PyObject *args) double *fc3; long num_atom; - if (!PyArg_ParseTuple(args, "O", &py_fc3)) { + if (!PyArg_ParseTuple(args, "O", &py_fc3)) + { return NULL; } - fc3 = (double*)PyArray_DATA(py_fc3); + fc3 = (double *)PyArray_DATA(py_fc3); num_atom = (long)PyArray_DIMS(py_fc3)[0]; ph3py_get_permutation_symmetry_fc3(fc3, num_atom); @@ -1426,15 +1436,14 @@ py_get_permutation_symmetry_fc3(PyObject *self, PyObject *args) Py_RETURN_NONE; } - static PyObject * py_get_permutation_symmetry_compact_fc3(PyObject *self, PyObject *args) { - PyArrayObject* py_fc3; - PyArrayObject* py_permutations; - PyArrayObject* py_s2pp_map; - PyArrayObject* py_p2s_map; - PyArrayObject* py_nsym_list; + PyArrayObject *py_fc3; + PyArrayObject *py_permutations; + PyArrayObject *py_s2pp_map; + PyArrayObject *py_p2s_map; + PyArrayObject *py_nsym_list; double *fc3; long *s2pp; @@ -1448,15 +1457,16 @@ py_get_permutation_symmetry_compact_fc3(PyObject *self, PyObject *args) &py_permutations, &py_s2pp_map, &py_p2s_map, - &py_nsym_list)) { + &py_nsym_list)) + { return NULL; } - fc3 = (double*)PyArray_DATA(py_fc3); - perms = (long*)PyArray_DATA(py_permutations); - s2pp = (long*)PyArray_DATA(py_s2pp_map); - p2s = (long*)PyArray_DATA(py_p2s_map); - nsym_list = (long*)PyArray_DATA(py_nsym_list); + fc3 = (double *)PyArray_DATA(py_fc3); + perms = (long *)PyArray_DATA(py_permutations); + s2pp = (long *)PyArray_DATA(py_s2pp_map); + p2s = (long *)PyArray_DATA(py_p2s_map); + nsym_list = (long *)PyArray_DATA(py_nsym_list); n_patom = (long)PyArray_DIMS(py_fc3)[0]; n_satom = (long)PyArray_DIMS(py_fc3)[1]; @@ -1471,14 +1481,13 @@ py_get_permutation_symmetry_compact_fc3(PyObject *self, PyObject *args) Py_RETURN_NONE; } - -static PyObject * py_transpose_compact_fc3(PyObject *self, PyObject *args) +static PyObject *py_transpose_compact_fc3(PyObject *self, PyObject *args) { - PyArrayObject* py_fc3; - PyArrayObject* py_permutations; - PyArrayObject* py_s2pp_map; - PyArrayObject* py_p2s_map; - PyArrayObject* py_nsym_list; + PyArrayObject *py_fc3; + PyArrayObject *py_permutations; + PyArrayObject *py_s2pp_map; + PyArrayObject *py_p2s_map; + PyArrayObject *py_nsym_list; long t_type; double *fc3; @@ -1494,15 +1503,16 @@ static PyObject * py_transpose_compact_fc3(PyObject *self, PyObject *args) &py_s2pp_map, &py_p2s_map, &py_nsym_list, - &t_type)) { + &t_type)) + { return NULL; } - fc3 = (double*)PyArray_DATA(py_fc3); - perms = (long*)PyArray_DATA(py_permutations); - s2pp = (long*)PyArray_DATA(py_s2pp_map); - p2s = (long*)PyArray_DATA(py_p2s_map); - nsym_list = (long*)PyArray_DATA(py_nsym_list); + fc3 = (double *)PyArray_DATA(py_fc3); + perms = (long *)PyArray_DATA(py_permutations); + s2pp = (long *)PyArray_DATA(py_s2pp_map); + p2s = (long *)PyArray_DATA(py_p2s_map); + nsym_list = (long *)PyArray_DATA(py_nsym_list); n_patom = (long)PyArray_DIMS(py_fc3)[0]; n_satom = (long)PyArray_DIMS(py_fc3)[1]; @@ -1518,8 +1528,7 @@ static PyObject * py_transpose_compact_fc3(PyObject *self, PyObject *args) Py_RETURN_NONE; } - -static PyObject * py_get_neighboring_grid_points(PyObject *self, PyObject *args) +static PyObject *py_get_neighboring_grid_points(PyObject *self, PyObject *args) { PyArrayObject *py_relative_grid_points; PyArrayObject *py_grid_points; @@ -1532,9 +1541,9 @@ static PyObject * py_get_neighboring_grid_points(PyObject *self, PyObject *args) long *relative_grid_points; long *grid_points; long num_grid_points, num_relative_grid_address; - long (*relative_grid_address)[3]; + long(*relative_grid_address)[3]; long *D_diag; - long (*bz_grid_address)[3]; + long(*bz_grid_address)[3]; long *bz_map; if (!PyArg_ParseTuple(args, "OOOOOOl", @@ -1544,18 +1553,19 @@ static PyObject * py_get_neighboring_grid_points(PyObject *self, PyObject *args) &py_D_diag, &py_bz_grid_address, &py_bz_map, - &bz_grid_type)) { + &bz_grid_type)) + { return NULL; } - relative_grid_points = (long*)PyArray_DATA(py_relative_grid_points); - grid_points = (long*)PyArray_DATA(py_grid_points); + relative_grid_points = (long *)PyArray_DATA(py_relative_grid_points); + grid_points = (long *)PyArray_DATA(py_grid_points); num_grid_points = (long)PyArray_DIMS(py_grid_points)[0]; relative_grid_address = (long(*)[3])PyArray_DATA(py_relative_grid_address); num_relative_grid_address = (long)PyArray_DIMS(py_relative_grid_address)[0]; - D_diag = (long*)PyArray_DATA(py_D_diag); + D_diag = (long *)PyArray_DATA(py_D_diag); bz_grid_address = (long(*)[3])PyArray_DATA(py_bz_grid_address); - bz_map = (long*)PyArray_DATA(py_bz_map); + bz_map = (long *)PyArray_DATA(py_bz_map); ph3py_get_neighboring_gird_points(relative_grid_points, grid_points, @@ -1570,7 +1580,6 @@ static PyObject * py_get_neighboring_grid_points(PyObject *self, PyObject *args) Py_RETURN_NONE; } - static PyObject * py_get_thm_integration_weights_at_grid_points(PyObject *self, PyObject *args) { @@ -1584,15 +1593,15 @@ py_get_thm_integration_weights_at_grid_points(PyObject *self, PyObject *args) PyArrayObject *py_gp2irgp_map; PyArrayObject *py_bz_map; long bz_grid_type; - char* function; + char *function; double *iw; double *frequency_points; long num_frequency_points, num_band, num_gp; - long (*relative_grid_address)[4][3]; + long(*relative_grid_address)[4][3]; long *D_diag; long *grid_points; - long (*bz_grid_address)[3]; + long(*bz_grid_address)[3]; long *bz_map; long *gp2irgp_map; double *frequencies; @@ -1608,43 +1617,43 @@ py_get_thm_integration_weights_at_grid_points(PyObject *self, PyObject *args) &py_bz_map, &py_gp2irgp_map, &bz_grid_type, - &function)) { + &function)) + { return NULL; } - iw = (double*)PyArray_DATA(py_iw); - frequency_points = (double*)PyArray_DATA(py_frequency_points); + iw = (double *)PyArray_DATA(py_iw); + frequency_points = (double *)PyArray_DATA(py_frequency_points); num_frequency_points = (long)PyArray_DIMS(py_frequency_points)[0]; relative_grid_address = (long(*)[4][3])PyArray_DATA(py_relative_grid_address); - D_diag = (long*)PyArray_DATA(py_D_diag); - grid_points = (long*)PyArray_DATA(py_grid_points); + D_diag = (long *)PyArray_DATA(py_D_diag); + grid_points = (long *)PyArray_DATA(py_grid_points); num_gp = (long)PyArray_DIMS(py_grid_points)[0]; bz_grid_address = (long(*)[3])PyArray_DATA(py_bz_grid_address); - bz_map = (long*)PyArray_DATA(py_bz_map); - gp2irgp_map = (long*)PyArray_DATA(py_gp2irgp_map); - frequencies = (double*)PyArray_DATA(py_frequencies); + bz_map = (long *)PyArray_DATA(py_bz_map); + gp2irgp_map = (long *)PyArray_DATA(py_gp2irgp_map); + frequencies = (double *)PyArray_DATA(py_frequencies); num_band = (long)PyArray_DIMS(py_frequencies)[1]; ph3py_get_thm_integration_weights_at_grid_points( - iw, - frequency_points, - num_frequency_points, - num_band, - num_gp, - relative_grid_address, - D_diag, - grid_points, - bz_grid_address, - bz_map, - bz_grid_type, - frequencies, - gp2irgp_map, - function[0]); + iw, + frequency_points, + num_frequency_points, + num_band, + num_gp, + relative_grid_address, + D_diag, + grid_points, + bz_grid_address, + bz_map, + bz_grid_type, + frequencies, + gp2irgp_map, + function[0]); Py_RETURN_NONE; } - static PyObject * py_tpl_get_triplets_reciprocal_mesh_at_q(PyObject *self, PyObject *args) { @@ -1659,7 +1668,7 @@ py_tpl_get_triplets_reciprocal_mesh_at_q(PyObject *self, PyObject *args) long *map_triplets; long *map_q; long *D_diag; - long (*rot)[3][3]; + long(*rot)[3][3]; long num_rot; long num_ir; @@ -1670,13 +1679,14 @@ py_tpl_get_triplets_reciprocal_mesh_at_q(PyObject *self, PyObject *args) &py_D_diag, &is_time_reversal, &py_rotations, - &swappable)) { + &swappable)) + { return NULL; } - map_triplets = (long*)PyArray_DATA(py_map_triplets); - map_q = (long*)PyArray_DATA(py_map_q); - D_diag = (long*)PyArray_DATA(py_D_diag); + map_triplets = (long *)PyArray_DATA(py_map_triplets); + map_q = (long *)PyArray_DATA(py_map_q); + D_diag = (long *)PyArray_DATA(py_D_diag); rot = (long(*)[3][3])PyArray_DATA(py_rotations); num_rot = (long)PyArray_DIMS(py_rotations)[0]; num_ir = ph3py_get_triplets_reciprocal_mesh_at_q(map_triplets, @@ -1691,8 +1701,7 @@ py_tpl_get_triplets_reciprocal_mesh_at_q(PyObject *self, PyObject *args) return PyLong_FromLong(num_ir); } - -static PyObject * py_tpl_get_BZ_triplets_at_q(PyObject *self, PyObject *args) +static PyObject *py_tpl_get_BZ_triplets_at_q(PyObject *self, PyObject *args) { PyArrayObject *py_triplets; PyArrayObject *py_bz_grid_address; @@ -1703,13 +1712,13 @@ static PyObject * py_tpl_get_BZ_triplets_at_q(PyObject *self, PyObject *args) long grid_point; long bz_grid_type; - long (*triplets)[3]; - long (*bz_grid_address)[3]; + long(*triplets)[3]; + long(*bz_grid_address)[3]; long *bz_map; long *map_triplets; long num_map_triplets; long *D_diag; - long (*Q)[3]; + long(*Q)[3]; long num_ir; if (!PyArg_ParseTuple(args, "OlOOOOOl", @@ -1720,16 +1729,17 @@ static PyObject * py_tpl_get_BZ_triplets_at_q(PyObject *self, PyObject *args) &py_map_triplets, &py_D_diag, &py_Q, - &bz_grid_type)) { + &bz_grid_type)) + { return NULL; } triplets = (long(*)[3])PyArray_DATA(py_triplets); bz_grid_address = (long(*)[3])PyArray_DATA(py_bz_grid_address); - bz_map = (long*)PyArray_DATA(py_bz_map); - map_triplets = (long*)PyArray_DATA(py_map_triplets); + bz_map = (long *)PyArray_DATA(py_bz_map); + map_triplets = (long *)PyArray_DATA(py_map_triplets); num_map_triplets = (long)PyArray_DIMS(py_map_triplets)[0]; - D_diag = (long*)PyArray_DATA(py_D_diag); + D_diag = (long *)PyArray_DATA(py_D_diag); Q = (long(*)[3])PyArray_DATA(py_Q); num_ir = ph3py_get_BZ_triplets_at_q(triplets, @@ -1745,7 +1755,6 @@ static PyObject * py_tpl_get_BZ_triplets_at_q(PyObject *self, PyObject *args) return PyLong_FromLong(num_ir); } - static PyObject * py_get_triplets_integration_weights(PyObject *self, PyObject *args) { @@ -1765,10 +1774,10 @@ py_get_triplets_integration_weights(PyObject *self, PyObject *args) double *iw; char *iw_zero; double *frequency_points; - long (*relative_grid_address)[4][3]; + long(*relative_grid_address)[4][3]; long *D_diag; - long (*triplets)[3]; - long (*bz_grid_addresses)[3]; + long(*triplets)[3]; + long(*bz_grid_addresses)[3]; long *bz_map; double *frequencies1, *frequencies2; long num_band0, num_band1, num_band2, num_triplets; @@ -1785,22 +1794,23 @@ py_get_triplets_integration_weights(PyObject *self, PyObject *args) &py_bz_grid_addresses, &py_bz_map, &bz_grid_type, - &tp_type)) { + &tp_type)) + { return NULL; } - iw = (double*)PyArray_DATA(py_iw); - iw_zero = (char*)PyArray_DATA(py_iw_zero); - frequency_points = (double*)PyArray_DATA(py_frequency_points); + iw = (double *)PyArray_DATA(py_iw); + iw_zero = (char *)PyArray_DATA(py_iw_zero); + frequency_points = (double *)PyArray_DATA(py_frequency_points); num_band0 = (long)PyArray_DIMS(py_frequency_points)[0]; relative_grid_address = (long(*)[4][3])PyArray_DATA(py_relative_grid_address); - D_diag = (long*)PyArray_DATA(py_D_diag); + D_diag = (long *)PyArray_DATA(py_D_diag); triplets = (long(*)[3])PyArray_DATA(py_triplets); num_triplets = (long)PyArray_DIMS(py_triplets)[0]; bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); - bz_map = (long*)PyArray_DATA(py_bz_map); - frequencies1 = (double*)PyArray_DATA(py_frequencies1); - frequencies2 = (double*)PyArray_DATA(py_frequencies2); + bz_map = (long *)PyArray_DATA(py_bz_map); + frequencies1 = (double *)PyArray_DATA(py_frequencies1); + frequencies2 = (double *)PyArray_DATA(py_frequencies2); num_band1 = (long)PyArray_DIMS(py_frequencies1)[1]; num_band2 = (long)PyArray_DIMS(py_frequencies2)[1]; @@ -1826,7 +1836,6 @@ py_get_triplets_integration_weights(PyObject *self, PyObject *args) Py_RETURN_NONE; } - static PyObject * py_get_triplets_integration_weights_with_sigma(PyObject *self, PyObject *args) { @@ -1840,7 +1849,7 @@ py_get_triplets_integration_weights_with_sigma(PyObject *self, PyObject *args) double *iw; char *iw_zero; double *frequency_points; - long (*triplets)[3]; + long(*triplets)[3]; double *frequencies; long num_band0, num_band, num_iw, num_triplets; @@ -1851,17 +1860,18 @@ py_get_triplets_integration_weights_with_sigma(PyObject *self, PyObject *args) &py_triplets, &py_frequencies, &sigma, - &sigma_cutoff)) { + &sigma_cutoff)) + { return NULL; } - iw = (double*)PyArray_DATA(py_iw); - iw_zero = (char*)PyArray_DATA(py_iw_zero); - frequency_points = (double*)PyArray_DATA(py_frequency_points); + iw = (double *)PyArray_DATA(py_iw); + iw_zero = (char *)PyArray_DATA(py_iw_zero); + frequency_points = (double *)PyArray_DATA(py_frequency_points); num_band0 = (long)PyArray_DIMS(py_frequency_points)[0]; triplets = (long(*)[3])PyArray_DATA(py_triplets); num_triplets = (long)PyArray_DIMS(py_triplets)[0]; - frequencies = (double*)PyArray_DATA(py_frequencies); + frequencies = (double *)PyArray_DATA(py_frequencies); num_band = (long)PyArray_DIMS(py_frequencies)[1]; num_iw = (long)PyArray_DIMS(py_iw)[0]; @@ -1880,25 +1890,25 @@ py_get_triplets_integration_weights_with_sigma(PyObject *self, PyObject *args) Py_RETURN_NONE; } - static PyObject * py_get_grid_index_from_address(PyObject *self, PyObject *args) { - PyArrayObject* py_address; - PyArrayObject* py_D_diag; + PyArrayObject *py_address; + PyArrayObject *py_D_diag; - long* address; - long* D_diag; + long *address; + long *D_diag; long gp; if (!PyArg_ParseTuple(args, "OO", &py_address, - &py_D_diag)) { + &py_D_diag)) + { return NULL; } - address = (long*)PyArray_DATA(py_address); - D_diag = (long*)PyArray_DATA(py_D_diag); + address = (long *)PyArray_DATA(py_address); + D_diag = (long *)PyArray_DATA(py_D_diag); gp = ph3py_get_grid_index_from_address(address, D_diag); @@ -1908,43 +1918,42 @@ py_get_grid_index_from_address(PyObject *self, PyObject *args) static PyObject * py_get_gr_grid_addresses(PyObject *self, PyObject *args) { - PyArrayObject* py_gr_grid_addresses; - PyArrayObject* py_D_diag; + PyArrayObject *py_gr_grid_addresses; + PyArrayObject *py_D_diag; - long (*gr_grid_addresses)[3]; + long(*gr_grid_addresses)[3]; long *D_diag; if (!PyArg_ParseTuple(args, "OO", &py_gr_grid_addresses, - &py_D_diag)) { + &py_D_diag)) + { return NULL; } gr_grid_addresses = (long(*)[3])PyArray_DATA(py_gr_grid_addresses); - D_diag = (long*)PyArray_DATA(py_D_diag); + D_diag = (long *)PyArray_DATA(py_D_diag); ph3py_get_gr_grid_addresses(gr_grid_addresses, D_diag); Py_RETURN_NONE; } - static PyObject *py_get_reciprocal_rotations(PyObject *self, PyObject *args) { - PyArrayObject* py_rec_rotations; - PyArrayObject* py_rotations; + PyArrayObject *py_rec_rotations; + PyArrayObject *py_rotations; long is_time_reversal; - long (*rec_rotations)[3][3]; - long (*rotations)[3][3]; + long(*rec_rotations)[3][3]; + long(*rotations)[3][3]; long num_rot, num_rec_rot; - - if (!PyArg_ParseTuple(args, "OOl", &py_rec_rotations, &py_rotations, - &is_time_reversal)) { + &is_time_reversal)) + { return NULL; } @@ -1960,31 +1969,31 @@ static PyObject *py_get_reciprocal_rotations(PyObject *self, PyObject *args) return PyLong_FromLong(num_rec_rot); } - static PyObject *py_transform_rotations(PyObject *self, PyObject *args) { - PyArrayObject* py_transformed_rotations; - PyArrayObject* py_rotations; - PyArrayObject* py_D_diag; - PyArrayObject* py_Q; + PyArrayObject *py_transformed_rotations; + PyArrayObject *py_rotations; + PyArrayObject *py_D_diag; + PyArrayObject *py_Q; - long (*transformed_rotations)[3][3]; - long (*rotations)[3][3]; + long(*transformed_rotations)[3][3]; + long(*rotations)[3][3]; long *D_diag; - long (*Q)[3]; + long(*Q)[3]; long num_rot, succeeded; if (!PyArg_ParseTuple(args, "OOOO", &py_transformed_rotations, &py_rotations, &py_D_diag, - &py_Q)) { + &py_Q)) + { return NULL; } transformed_rotations = (long(*)[3][3])PyArray_DATA(py_transformed_rotations); rotations = (long(*)[3][3])PyArray_DATA(py_rotations); - D_diag = (long*)PyArray_DATA(py_D_diag); + D_diag = (long *)PyArray_DATA(py_D_diag); Q = (long(*)[3])PyArray_DATA(py_Q); num_rot = (long)PyArray_DIMS(py_transformed_rotations)[0]; @@ -1993,59 +2002,64 @@ static PyObject *py_transform_rotations(PyObject *self, PyObject *args) num_rot, D_diag, Q); - if (succeeded) { + if (succeeded) + { Py_RETURN_TRUE; - } else { + } + else + { Py_RETURN_FALSE; } } - static PyObject *py_get_snf3x3(PyObject *self, PyObject *args) { - PyArrayObject* py_D_diag; - PyArrayObject* py_P; - PyArrayObject* py_Q; - PyArrayObject* py_A; + PyArrayObject *py_D_diag; + PyArrayObject *py_P; + PyArrayObject *py_Q; + PyArrayObject *py_A; long *D_diag; - long (*P)[3]; - long (*Q)[3]; - long (*A)[3]; + long(*P)[3]; + long(*Q)[3]; + long(*A)[3]; long succeeded; if (!PyArg_ParseTuple(args, "OOOO", &py_D_diag, &py_P, &py_Q, - &py_A)) { + &py_A)) + { return NULL; } - D_diag = (long*)PyArray_DATA(py_D_diag); + D_diag = (long *)PyArray_DATA(py_D_diag); P = (long(*)[3])PyArray_DATA(py_P); Q = (long(*)[3])PyArray_DATA(py_Q); A = (long(*)[3])PyArray_DATA(py_A); succeeded = ph3py_get_snf3x3(D_diag, P, Q, A); - if (succeeded) { + if (succeeded) + { Py_RETURN_TRUE; - } else { + } + else + { Py_RETURN_FALSE; } } - static PyObject *py_get_ir_grid_map(PyObject *self, PyObject *args) { - PyArrayObject* py_grid_mapping_table; - PyArrayObject* py_D_diag; - PyArrayObject* py_is_shift; - PyArrayObject* py_rotations; + PyArrayObject *py_grid_mapping_table; + PyArrayObject *py_D_diag; + PyArrayObject *py_is_shift; + PyArrayObject *py_rotations; - long* D_diag; - long* is_shift; - long (*rot)[3][3]; + long *D_diag; + long *is_shift; + long(*rot)[3][3]; long num_rot; long *grid_mapping_table; @@ -2055,15 +2069,16 @@ static PyObject *py_get_ir_grid_map(PyObject *self, PyObject *args) &py_grid_mapping_table, &py_D_diag, &py_is_shift, - &py_rotations)) { + &py_rotations)) + { return NULL; } - D_diag = (long*)PyArray_DATA(py_D_diag); - is_shift = (long*)PyArray_DATA(py_is_shift); + D_diag = (long *)PyArray_DATA(py_D_diag); + is_shift = (long *)PyArray_DATA(py_is_shift); rot = (long(*)[3][3])PyArray_DATA(py_rotations); num_rot = (long)PyArray_DIMS(py_rotations)[0]; - grid_mapping_table = (long*)PyArray_DATA(py_grid_mapping_table); + grid_mapping_table = (long *)PyArray_DATA(py_grid_mapping_table); num_ir = ph3py_get_ir_grid_map(grid_mapping_table, D_diag, @@ -2073,8 +2088,7 @@ static PyObject *py_get_ir_grid_map(PyObject *self, PyObject *args) return PyLong_FromLong(num_ir); } - -static PyObject * py_get_bz_grid_addresses(PyObject *self, PyObject *args) +static PyObject *py_get_bz_grid_addresses(PyObject *self, PyObject *args) { PyArrayObject *py_bz_grid_addresses; PyArrayObject *py_bz_map; @@ -2085,13 +2099,13 @@ static PyObject * py_get_bz_grid_addresses(PyObject *self, PyObject *args) PyArrayObject *py_reciprocal_lattice; long type; - long (*bz_grid_addresses)[3]; + long(*bz_grid_addresses)[3]; long *bz_map; long *bzg2grg; long *D_diag; - long (*Q)[3]; + long(*Q)[3]; long *PS; - double (*reciprocal_lattice)[3]; + double(*reciprocal_lattice)[3]; long num_total_gp; if (!PyArg_ParseTuple(args, "OOOOOOOl", @@ -2102,16 +2116,17 @@ static PyObject * py_get_bz_grid_addresses(PyObject *self, PyObject *args) &py_Q, &py_PS, &py_reciprocal_lattice, - &type)) { + &type)) + { return NULL; } bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); - bz_map = (long*)PyArray_DATA(py_bz_map); - bzg2grg = (long*)PyArray_DATA(py_bzg2grg); - D_diag = (long*)PyArray_DATA(py_D_diag); + bz_map = (long *)PyArray_DATA(py_bz_map); + bzg2grg = (long *)PyArray_DATA(py_bzg2grg); + D_diag = (long *)PyArray_DATA(py_D_diag); Q = (long(*)[3])PyArray_DATA(py_Q); - PS = (long*)PyArray_DATA(py_PS); + PS = (long *)PyArray_DATA(py_PS); reciprocal_lattice = (double(*)[3])PyArray_DATA(py_reciprocal_lattice); num_total_gp = ph3py_get_bz_grid_addresses(bz_grid_addresses, @@ -2126,8 +2141,7 @@ static PyObject * py_get_bz_grid_addresses(PyObject *self, PyObject *args) return PyLong_FromLong(num_total_gp); } - -static PyObject * py_rotate_bz_grid_addresses(PyObject *self, PyObject *args) +static PyObject *py_rotate_bz_grid_addresses(PyObject *self, PyObject *args) { PyArrayObject *py_bz_grid_addresses; PyArrayObject *py_rotation; @@ -2137,8 +2151,8 @@ static PyObject * py_rotate_bz_grid_addresses(PyObject *self, PyObject *args) long bz_grid_index; long type; - long (*bz_grid_addresses)[3]; - long (*rotation)[3]; + long(*bz_grid_addresses)[3]; + long(*rotation)[3]; long *bz_map; long *D_diag; long *PS; @@ -2151,15 +2165,16 @@ static PyObject * py_rotate_bz_grid_addresses(PyObject *self, PyObject *args) &py_bz_map, &py_D_diag, &py_PS, - &type)) { + &type)) + { return NULL; } bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); rotation = (long(*)[3])PyArray_DATA(py_rotation); - bz_map = (long*)PyArray_DATA(py_bz_map); - D_diag = (long*)PyArray_DATA(py_D_diag); - PS = (long*)PyArray_DATA(py_PS); + bz_map = (long *)PyArray_DATA(py_bz_map); + D_diag = (long *)PyArray_DATA(py_D_diag); + PS = (long *)PyArray_DATA(py_PS); ret_bz_gp = ph3py_rotate_bz_grid_index(bz_grid_index, rotation, @@ -2172,7 +2187,6 @@ static PyObject * py_rotate_bz_grid_addresses(PyObject *self, PyObject *args) return PyLong_FromLong(ret_bz_gp); } - static PyObject * py_diagonalize_collision_matrix(PyObject *self, PyObject *args) { @@ -2194,23 +2208,30 @@ py_diagonalize_collision_matrix(PyObject *self, PyObject *args) &i_temp, &cutoff, &solver, - &is_pinv)) { + &is_pinv)) + { return NULL; } - collision_matrix = (double*)PyArray_DATA(py_collision_matrix); - eigvals = (double*)PyArray_DATA(py_eigenvalues); + collision_matrix = (double *)PyArray_DATA(py_collision_matrix); + eigvals = (double *)PyArray_DATA(py_eigenvalues); - if (PyArray_NDIM(py_collision_matrix) == 2) { + if (PyArray_NDIM(py_collision_matrix) == 2) + { num_temp = 1; num_column = (long)PyArray_DIM(py_collision_matrix, 1); - } else { + } + else + { num_temp = (long)PyArray_DIM(py_collision_matrix, 1); num_grid_point = (long)PyArray_DIM(py_collision_matrix, 2); num_band = (long)PyArray_DIM(py_collision_matrix, 3); - if (PyArray_NDIM(py_collision_matrix) == 8) { + if (PyArray_NDIM(py_collision_matrix) == 8) + { num_column = num_grid_point * num_band * 3; - } else { + } + else + { num_column = num_grid_point * num_band; } } @@ -2221,7 +2242,8 @@ py_diagonalize_collision_matrix(PyObject *self, PyObject *args) info = phonopy_dsyev(collision_matrix + adrs_shift, eigvals, num_column, solver); - if (is_pinv) { + if (is_pinv) + { pinv_from_eigensolution(collision_matrix + adrs_shift, eigvals, num_column, cutoff, 0); } @@ -2229,8 +2251,7 @@ py_diagonalize_collision_matrix(PyObject *self, PyObject *args) return PyLong_FromLong(info); } - -static PyObject * py_pinv_from_eigensolution(PyObject *self, PyObject *args) +static PyObject *py_pinv_from_eigensolution(PyObject *self, PyObject *args) { PyArrayObject *py_collision_matrix; PyArrayObject *py_eigenvalues; @@ -2248,19 +2269,23 @@ static PyObject * py_pinv_from_eigensolution(PyObject *self, PyObject *args) &i_sigma, &i_temp, &cutoff, - &pinv_method)) { + &pinv_method)) + { return NULL; } - collision_matrix = (double*)PyArray_DATA(py_collision_matrix); - eigvals = (double*)PyArray_DATA(py_eigenvalues); + collision_matrix = (double *)PyArray_DATA(py_collision_matrix); + eigvals = (double *)PyArray_DATA(py_eigenvalues); num_temp = (long)PyArray_DIMS(py_collision_matrix)[1]; num_grid_point = (long)PyArray_DIMS(py_collision_matrix)[2]; num_band = (long)PyArray_DIMS(py_collision_matrix)[3]; - if (PyArray_NDIM(py_collision_matrix) == 8) { + if (PyArray_NDIM(py_collision_matrix) == 8) + { num_column = num_grid_point * num_band * 3; - } else { + } + else + { num_column = num_grid_point * num_band; } adrs_shift = (i_sigma * num_column * num_column * num_temp + @@ -2274,22 +2299,20 @@ static PyObject * py_pinv_from_eigensolution(PyObject *self, PyObject *args) Py_RETURN_NONE; } - -static PyObject * py_get_default_colmat_solver(PyObject *self, PyObject *args) +static PyObject *py_get_default_colmat_solver(PyObject *self, PyObject *args) { - if (!PyArg_ParseTuple(args, "")) { + if (!PyArg_ParseTuple(args, "")) + { return NULL; } #ifdef MKL_LAPACKE - return PyLong_FromLong((long) 1); + return PyLong_FromLong((long)1); #else - return PyLong_FromLong((long) 4); + return PyLong_FromLong((long)4); #endif - } - static void pinv_from_eigensolution(double *data, const double *eigvals, const long size, @@ -2304,24 +2327,30 @@ static void pinv_from_eigensolution(double *data, l = NULL; tmp_data = NULL; - tmp_data = (double*)malloc(sizeof(double) * size * size); + tmp_data = (double *)malloc(sizeof(double) * size * size); #ifdef PHPYOPENMP #pragma omp parallel for #endif - for (i = 0; i < size * size; i++) { + for (i = 0; i < size * size; i++) + { tmp_data[i] = data[i]; } - l = (long*)malloc(sizeof(long) * size); + l = (long *)malloc(sizeof(long) * size); max_l = 0; - for (i = 0; i < size; i++) { - if (pinv_method == 0) { + for (i = 0; i < size; i++) + { + if (pinv_method == 0) + { e = fabs(eigvals[i]); - } else { + } + else + { e = eigvals[i]; } - if (e > cutoff) { + if (e > cutoff) + { l[max_l] = i; max_l++; } @@ -2330,13 +2359,16 @@ static void pinv_from_eigensolution(double *data, #ifdef PHPYOPENMP #pragma omp parallel for private(ib, j, k, i_s, j_s, sum) #endif - for (i = 0; i < size / 2; i++) { + for (i = 0; i < size / 2; i++) + { /* from front */ i_s = i * size; - for (j = i; j < size; j++) { + for (j = i; j < size; j++) + { j_s = j * size; sum = 0; - for (k = 0; k < max_l; k++) { + for (k = 0; k < max_l; k++) + { sum += tmp_data[i_s + l[k]] * tmp_data[j_s + l[k]] / eigvals[l[k]]; } data[i_s + j] = sum; @@ -2345,10 +2377,12 @@ static void pinv_from_eigensolution(double *data, /* from back */ ib = size - i - 1; i_s = ib * size; - for (j = ib; j < size; j++) { + for (j = ib; j < size; j++) + { j_s = j * size; sum = 0; - for (k = 0; k < max_l; k++) { + for (k = 0; k < max_l; k++) + { sum += tmp_data[i_s + l[k]] * tmp_data[j_s + l[k]] / eigvals[l[k]]; } data[i_s + j] = sum; @@ -2357,13 +2391,16 @@ static void pinv_from_eigensolution(double *data, } /* when size is odd */ - if ((size % 2) == 1) { + if ((size % 2) == 1) + { i = (size - 1) / 2; i_s = i * size; - for (j = i; j < size; j++) { + for (j = i; j < size; j++) + { j_s = j * size; sum = 0; - for (k = 0; k < max_l; k++) { + for (k = 0; k < max_l; k++) + { sum += tmp_data[i_s + l[k]] * tmp_data[j_s + l[k]] / eigvals[l[k]]; } data[i_s + j] = sum; @@ -2378,7 +2415,6 @@ static void pinv_from_eigensolution(double *data, tmp_data = NULL; } - static void show_colmat_info(const PyArrayObject *py_collision_matrix, const long i_sigma, const long i_temp, @@ -2387,40 +2423,45 @@ static void show_colmat_info(const PyArrayObject *py_collision_matrix, long i; printf(" Array_shape:("); - for (i = 0; i < PyArray_NDIM(py_collision_matrix); i++) { + for (i = 0; i < PyArray_NDIM(py_collision_matrix); i++) + { printf("%d", (int)PyArray_DIM(py_collision_matrix, i)); - if (i < PyArray_NDIM(py_collision_matrix) - 1) { + if (i < PyArray_NDIM(py_collision_matrix) - 1) + { printf(","); - } else { + } + else + { printf("), "); } } printf("Data shift:%lu [%lu, %lu]\n", adrs_shift, i_sigma, i_temp); } - -static Larray* convert_to_larray(const PyArrayObject* npyary) +static Larray *convert_to_larray(const PyArrayObject *npyary) { long i; Larray *ary; - ary = (Larray*) malloc(sizeof(Larray)); - for (i = 0; i < PyArray_NDIM(npyary); i++) { + ary = (Larray *)malloc(sizeof(Larray)); + for (i = 0; i < PyArray_NDIM(npyary); i++) + { ary->dims[i] = PyArray_DIMS(npyary)[i]; } - ary->data = (long*)PyArray_DATA(npyary); + ary->data = (long *)PyArray_DATA(npyary); return ary; } -static Darray* convert_to_darray(const PyArrayObject* npyary) +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 = (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); + ary->data = (double *)PyArray_DATA(npyary); return ary; } diff --git a/c/_phononmod.c b/c/_phononmod.c index a941a863..78f36415 100644 --- a/c/_phononmod.c +++ b/c/_phononmod.c @@ -37,59 +37,60 @@ #include "lapack_wrapper.h" #include "phononmod.h" +static PyObject *py_get_phonons_at_gridpoints(PyObject *self, PyObject *args); -static PyObject * py_get_phonons_at_gridpoints(PyObject *self, PyObject *args); - -struct module_state { +struct module_state +{ PyObject *error; }; #if PY_MAJOR_VERSION >= 3 -#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m)) +#define GETSTATE(m) ((struct module_state *)PyModule_GetState(m)) #else #define GETSTATE(m) (&_state) static struct module_state _state; #endif static PyObject * -error_out(PyObject *m) { +error_out(PyObject *m) +{ struct module_state *st = GETSTATE(m); PyErr_SetString(st->error, "something bad happened"); return NULL; } static PyMethodDef _phononmod_methods[] = { - {"error_out", (PyCFunction)error_out, METH_NOARGS, NULL}, - {"phonons_at_gridpoints", - py_get_phonons_at_gridpoints, - METH_VARARGS, - "Set phonons at grid points"}, - {NULL, NULL, 0, NULL} -}; + {"error_out", (PyCFunction)error_out, METH_NOARGS, NULL}, + {"phonons_at_gridpoints", + py_get_phonons_at_gridpoints, + METH_VARARGS, + "Set phonons at grid points"}, + {NULL, NULL, 0, NULL}}; #if PY_MAJOR_VERSION >= 3 -static int _phononmod_traverse(PyObject *m, visitproc visit, void *arg) { +static int _phononmod_traverse(PyObject *m, visitproc visit, void *arg) +{ Py_VISIT(GETSTATE(m)->error); return 0; } -static int _phononmod_clear(PyObject *m) { +static int _phononmod_clear(PyObject *m) +{ Py_CLEAR(GETSTATE(m)->error); return 0; } static struct PyModuleDef moduledef = { - PyModuleDef_HEAD_INIT, - "_phononmod", - NULL, - sizeof(struct module_state), - _phononmod_methods, - NULL, - _phononmod_traverse, - _phononmod_clear, - NULL -}; + PyModuleDef_HEAD_INIT, + "_phononmod", + NULL, + sizeof(struct module_state), + _phononmod_methods, + NULL, + _phononmod_traverse, + _phononmod_clear, + NULL}; #define INITERROR return NULL @@ -99,8 +100,7 @@ PyInit__phononmod(void) #else #define INITERROR return - void - init_phononmod(void) +void init_phononmod(void) #endif { #if PY_MAJOR_VERSION >= 3 @@ -115,7 +115,8 @@ PyInit__phononmod(void) st = GETSTATE(module); st->error = PyErr_NewException("_phononmod.Error", NULL, NULL); - if (st->error == NULL) { + if (st->error == NULL) + { Py_DECREF(module); INITERROR; } @@ -125,51 +126,51 @@ PyInit__phononmod(void) #endif } -static PyObject * py_get_phonons_at_gridpoints(PyObject *self, PyObject *args) +static PyObject *py_get_phonons_at_gridpoints(PyObject *self, PyObject *args) { - PyArrayObject* py_frequencies; - PyArrayObject* py_eigenvectors; - PyArrayObject* py_phonon_done; - PyArrayObject* py_grid_points; - PyArrayObject* py_grid_address; - PyArrayObject* py_QDinv; - PyArrayObject* py_shortest_vectors_fc2; - PyArrayObject* py_multiplicity_fc2; - PyArrayObject* py_positions_fc2; - PyArrayObject* py_fc2; - PyArrayObject* py_masses_fc2; - PyArrayObject* py_p2s_map_fc2; - PyArrayObject* py_s2p_map_fc2; - PyArrayObject* py_reciprocal_lattice; - PyArrayObject* py_born_effective_charge; - PyArrayObject* py_q_direction; - PyArrayObject* py_dielectric_constant; - PyArrayObject* py_dd_q0; - PyArrayObject* py_G_list; + PyArrayObject *py_frequencies; + PyArrayObject *py_eigenvectors; + PyArrayObject *py_phonon_done; + PyArrayObject *py_grid_points; + PyArrayObject *py_grid_address; + PyArrayObject *py_QDinv; + PyArrayObject *py_shortest_vectors_fc2; + PyArrayObject *py_multiplicity_fc2; + PyArrayObject *py_positions_fc2; + PyArrayObject *py_fc2; + PyArrayObject *py_masses_fc2; + PyArrayObject *py_p2s_map_fc2; + PyArrayObject *py_s2p_map_fc2; + PyArrayObject *py_reciprocal_lattice; + PyArrayObject *py_born_effective_charge; + PyArrayObject *py_q_direction; + PyArrayObject *py_dielectric_constant; + PyArrayObject *py_dd_q0; + PyArrayObject *py_G_list; double nac_factor; double unit_conversion_factor; double lambda; - char* uplo; + char *uplo; - double (*born)[3][3]; - double (*dielectric)[3]; + double(*born)[3][3]; + double(*dielectric)[3]; double *q_dir; - double* freqs; - lapack_complex_double* eigvecs; - char* phonon_done; - long* grid_points; - long (*grid_address)[3]; - double (*QDinv)[3]; - double* fc2; + double *freqs; + lapack_complex_double *eigvecs; + char *phonon_done; + long *grid_points; + long(*grid_address)[3]; + double(*QDinv)[3]; + double *fc2; double(*svecs_fc2)[3]; - long (*multi_fc2)[2]; - double (*positions_fc2)[3]; - double* masses_fc2; - long* p2s_fc2; - long* s2p_fc2; - double (*rec_lat)[3]; - double * dd_q0; - double (*G_list)[3]; + long(*multi_fc2)[2]; + double(*positions_fc2)[3]; + double *masses_fc2; + long *p2s_fc2; + long *s2p_fc2; + double(*rec_lat)[3]; + double *dd_q0; + double(*G_list)[3]; long num_patom, num_satom, num_phonons, num_grid_points, num_G_points; if (!PyArg_ParseTuple(args, "OOOOOOOOOOOOOdOOOOdOOds", @@ -195,62 +196,82 @@ static PyObject * py_get_phonons_at_gridpoints(PyObject *self, PyObject *args) &py_dd_q0, &py_G_list, &lambda, - &uplo)) { + &uplo)) + { return NULL; } - freqs = (double*)PyArray_DATA(py_frequencies); - eigvecs = (lapack_complex_double*)PyArray_DATA(py_eigenvectors); - phonon_done = (char*)PyArray_DATA(py_phonon_done); - grid_points = (long*)PyArray_DATA(py_grid_points); + freqs = (double *)PyArray_DATA(py_frequencies); + eigvecs = (lapack_complex_double *)PyArray_DATA(py_eigenvectors); + phonon_done = (char *)PyArray_DATA(py_phonon_done); + grid_points = (long *)PyArray_DATA(py_grid_points); grid_address = (long(*)[3])PyArray_DATA(py_grid_address); QDinv = (double(*)[3])PyArray_DATA(py_QDinv); - fc2 = (double*)PyArray_DATA(py_fc2); + fc2 = (double *)PyArray_DATA(py_fc2); svecs_fc2 = (double(*)[3])PyArray_DATA(py_shortest_vectors_fc2); multi_fc2 = (long(*)[2])PyArray_DATA(py_multiplicity_fc2); - masses_fc2 = (double*)PyArray_DATA(py_masses_fc2); - p2s_fc2 = (long*)PyArray_DATA(py_p2s_map_fc2); - s2p_fc2 = (long*)PyArray_DATA(py_s2p_map_fc2); + masses_fc2 = (double *)PyArray_DATA(py_masses_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 = (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) { + if ((PyObject *)py_born_effective_charge == Py_None) + { born = NULL; - } else { + } + else + { born = (double(*)[3][3])PyArray_DATA(py_born_effective_charge); } - if ((PyObject*)py_dielectric_constant == Py_None) { + if ((PyObject *)py_dielectric_constant == Py_None) + { dielectric = NULL; - } else { + } + else + { dielectric = (double(*)[3])PyArray_DATA(py_dielectric_constant); } - if ((PyObject*)py_q_direction == Py_None) { + if ((PyObject *)py_q_direction == Py_None) + { q_dir = NULL; - } else { - q_dir = (double*)PyArray_DATA(py_q_direction); + } + else + { + q_dir = (double *)PyArray_DATA(py_q_direction); if (fabs(q_dir[0]) < 1e-10 && fabs(q_dir[1]) < 1e-10 && - fabs(q_dir[2]) < 1e-10) { + fabs(q_dir[2]) < 1e-10) + { q_dir = NULL; } } - if ((PyObject*)py_dd_q0 == Py_None) { + if ((PyObject *)py_dd_q0 == Py_None) + { dd_q0 = NULL; - } else { - dd_q0 = (double*)PyArray_DATA(py_dd_q0); } - if ((PyObject*)py_G_list == Py_None) { + else + { + dd_q0 = (double *)PyArray_DATA(py_dd_q0); + } + if ((PyObject *)py_G_list == Py_None) + { G_list = NULL; num_G_points = 0; - } else { + } + else + { G_list = (double(*)[3])PyArray_DATA(py_G_list); num_G_points = (long)PyArray_DIMS(py_G_list)[0]; } - if ((PyObject*)py_positions_fc2 == Py_None) { + if ((PyObject *)py_positions_fc2 == Py_None) + { positions_fc2 = NULL; - } else { + } + else + { positions_fc2 = (double(*)[3])PyArray_DATA(py_positions_fc2); } diff --git a/c/bzgrid.c b/c/bzgrid.c index aed00a07..1e327e8e 100644 --- a/c/bzgrid.c +++ b/c/bzgrid.c @@ -42,133 +42,131 @@ #define BZG_NUM_BZ_SEARCH_SPACE 125 #define GRID_TOLERANCE_FACTOR 0.01 static long bz_search_space[BZG_NUM_BZ_SEARCH_SPACE][3] = { - { 0, 0, 0}, - { 0, 0, 1}, - { 0, 0, 2}, - { 0, 0, -2}, - { 0, 0, -1}, - { 0, 1, 0}, - { 0, 1, 1}, - { 0, 1, 2}, - { 0, 1, -2}, - { 0, 1, -1}, - { 0, 2, 0}, - { 0, 2, 1}, - { 0, 2, 2}, - { 0, 2, -2}, - { 0, 2, -1}, - { 0, -2, 0}, - { 0, -2, 1}, - { 0, -2, 2}, - { 0, -2, -2}, - { 0, -2, -1}, - { 0, -1, 0}, - { 0, -1, 1}, - { 0, -1, 2}, - { 0, -1, -2}, - { 0, -1, -1}, - { 1, 0, 0}, - { 1, 0, 1}, - { 1, 0, 2}, - { 1, 0, -2}, - { 1, 0, -1}, - { 1, 1, 0}, - { 1, 1, 1}, - { 1, 1, 2}, - { 1, 1, -2}, - { 1, 1, -1}, - { 1, 2, 0}, - { 1, 2, 1}, - { 1, 2, 2}, - { 1, 2, -2}, - { 1, 2, -1}, - { 1, -2, 0}, - { 1, -2, 1}, - { 1, -2, 2}, - { 1, -2, -2}, - { 1, -2, -1}, - { 1, -1, 0}, - { 1, -1, 1}, - { 1, -1, 2}, - { 1, -1, -2}, - { 1, -1, -1}, - { 2, 0, 0}, - { 2, 0, 1}, - { 2, 0, 2}, - { 2, 0, -2}, - { 2, 0, -1}, - { 2, 1, 0}, - { 2, 1, 1}, - { 2, 1, 2}, - { 2, 1, -2}, - { 2, 1, -1}, - { 2, 2, 0}, - { 2, 2, 1}, - { 2, 2, 2}, - { 2, 2, -2}, - { 2, 2, -1}, - { 2, -2, 0}, - { 2, -2, 1}, - { 2, -2, 2}, - { 2, -2, -2}, - { 2, -2, -1}, - { 2, -1, 0}, - { 2, -1, 1}, - { 2, -1, 2}, - { 2, -1, -2}, - { 2, -1, -1}, - {-2, 0, 0}, - {-2, 0, 1}, - {-2, 0, 2}, - {-2, 0, -2}, - {-2, 0, -1}, - {-2, 1, 0}, - {-2, 1, 1}, - {-2, 1, 2}, - {-2, 1, -2}, - {-2, 1, -1}, - {-2, 2, 0}, - {-2, 2, 1}, - {-2, 2, 2}, - {-2, 2, -2}, - {-2, 2, -1}, - {-2, -2, 0}, - {-2, -2, 1}, - {-2, -2, 2}, - {-2, -2, -2}, - {-2, -2, -1}, - {-2, -1, 0}, - {-2, -1, 1}, - {-2, -1, 2}, - {-2, -1, -2}, - {-2, -1, -1}, - {-1, 0, 0}, - {-1, 0, 1}, - {-1, 0, 2}, - {-1, 0, -2}, - {-1, 0, -1}, - {-1, 1, 0}, - {-1, 1, 1}, - {-1, 1, 2}, - {-1, 1, -2}, - {-1, 1, -1}, - {-1, 2, 0}, - {-1, 2, 1}, - {-1, 2, 2}, - {-1, 2, -2}, - {-1, 2, -1}, - {-1, -2, 0}, - {-1, -2, 1}, - {-1, -2, 2}, - {-1, -2, -2}, - {-1, -2, -1}, - {-1, -1, 0}, - {-1, -1, 1}, - {-1, -1, 2}, - {-1, -1, -2}, - {-1, -1, -1} -}; - + {0, 0, 0}, + {0, 0, 1}, + {0, 0, 2}, + {0, 0, -2}, + {0, 0, -1}, + {0, 1, 0}, + {0, 1, 1}, + {0, 1, 2}, + {0, 1, -2}, + {0, 1, -1}, + {0, 2, 0}, + {0, 2, 1}, + {0, 2, 2}, + {0, 2, -2}, + {0, 2, -1}, + {0, -2, 0}, + {0, -2, 1}, + {0, -2, 2}, + {0, -2, -2}, + {0, -2, -1}, + {0, -1, 0}, + {0, -1, 1}, + {0, -1, 2}, + {0, -1, -2}, + {0, -1, -1}, + {1, 0, 0}, + {1, 0, 1}, + {1, 0, 2}, + {1, 0, -2}, + {1, 0, -1}, + {1, 1, 0}, + {1, 1, 1}, + {1, 1, 2}, + {1, 1, -2}, + {1, 1, -1}, + {1, 2, 0}, + {1, 2, 1}, + {1, 2, 2}, + {1, 2, -2}, + {1, 2, -1}, + {1, -2, 0}, + {1, -2, 1}, + {1, -2, 2}, + {1, -2, -2}, + {1, -2, -1}, + {1, -1, 0}, + {1, -1, 1}, + {1, -1, 2}, + {1, -1, -2}, + {1, -1, -1}, + {2, 0, 0}, + {2, 0, 1}, + {2, 0, 2}, + {2, 0, -2}, + {2, 0, -1}, + {2, 1, 0}, + {2, 1, 1}, + {2, 1, 2}, + {2, 1, -2}, + {2, 1, -1}, + {2, 2, 0}, + {2, 2, 1}, + {2, 2, 2}, + {2, 2, -2}, + {2, 2, -1}, + {2, -2, 0}, + {2, -2, 1}, + {2, -2, 2}, + {2, -2, -2}, + {2, -2, -1}, + {2, -1, 0}, + {2, -1, 1}, + {2, -1, 2}, + {2, -1, -2}, + {2, -1, -1}, + {-2, 0, 0}, + {-2, 0, 1}, + {-2, 0, 2}, + {-2, 0, -2}, + {-2, 0, -1}, + {-2, 1, 0}, + {-2, 1, 1}, + {-2, 1, 2}, + {-2, 1, -2}, + {-2, 1, -1}, + {-2, 2, 0}, + {-2, 2, 1}, + {-2, 2, 2}, + {-2, 2, -2}, + {-2, 2, -1}, + {-2, -2, 0}, + {-2, -2, 1}, + {-2, -2, 2}, + {-2, -2, -2}, + {-2, -2, -1}, + {-2, -1, 0}, + {-2, -1, 1}, + {-2, -1, 2}, + {-2, -1, -2}, + {-2, -1, -1}, + {-1, 0, 0}, + {-1, 0, 1}, + {-1, 0, 2}, + {-1, 0, -2}, + {-1, 0, -1}, + {-1, 1, 0}, + {-1, 1, 1}, + {-1, 1, 2}, + {-1, 1, -2}, + {-1, 1, -1}, + {-1, 2, 0}, + {-1, 2, 1}, + {-1, 2, 2}, + {-1, 2, -2}, + {-1, 2, -1}, + {-1, -2, 0}, + {-1, -2, 1}, + {-1, -2, 2}, + {-1, -2, -2}, + {-1, -2, -1}, + {-1, -1, 0}, + {-1, -1, 1}, + {-1, -1, 2}, + {-1, -1, -2}, + {-1, -1, -1}}; static void get_bz_grid_addresses_type1(BZGrid *bzgrid, const long Qinv[3][3]); @@ -192,7 +190,6 @@ static long get_inverse_unimodular_matrix_l3(long m[3][3], const long a[3][3]); static double norm_squared_d3(const double a[3]); - long bzg_rotate_grid_index(const long bz_grid_index, const long rotation[3][3], const ConstBZGrid *bzgrid) @@ -205,27 +202,35 @@ long bzg_rotate_grid_index(const long bz_grid_index, grg_get_grid_address(adrs_rot, dadrs_rot, bzgrid->PS); gp = grg_get_grid_index(adrs_rot, bzgrid->D_diag); - if (bzgrid->type == 1) { - if (bzgrid->addresses[gp][0] == adrs_rot[0] && - bzgrid->addresses[gp][1] == adrs_rot[1] && - bzgrid->addresses[gp][2] == adrs_rot[2]) { + if (bzgrid->type == 1) + { + if (bzgrid->addresses[gp][0] == adrs_rot[0] && + bzgrid->addresses[gp][1] == adrs_rot[1] && + bzgrid->addresses[gp][2] == adrs_rot[2]) + { return gp; } num_grgp = bzgrid->D_diag[0] * bzgrid->D_diag[1] * bzgrid->D_diag[2]; num_bzgp = num_grgp * 8; for (i = bzgrid->gp_map[num_bzgp + gp] + num_grgp; - i < bzgrid->gp_map[num_bzgp + gp + 1] + num_grgp; i++) { - if (bzgrid->addresses[i][0] == adrs_rot[0] && - bzgrid->addresses[i][1] == adrs_rot[1] && - bzgrid->addresses[i][2] == adrs_rot[2]) { + i < bzgrid->gp_map[num_bzgp + gp + 1] + num_grgp; i++) + { + if (bzgrid->addresses[i][0] == adrs_rot[0] && + bzgrid->addresses[i][1] == adrs_rot[1] && + bzgrid->addresses[i][2] == adrs_rot[2]) + { return i; } } - } else { - for (i = bzgrid->gp_map[gp]; i < bzgrid->gp_map[gp + 1]; i++) { - if (bzgrid->addresses[i][0] == adrs_rot[0] && - bzgrid->addresses[i][1] == adrs_rot[1] && - bzgrid->addresses[i][2] == adrs_rot[2]) { + } + else + { + for (i = bzgrid->gp_map[gp]; i < bzgrid->gp_map[gp + 1]; i++) + { + if (bzgrid->addresses[i][0] == adrs_rot[0] && + bzgrid->addresses[i][1] == adrs_rot[1] && + bzgrid->addresses[i][2] == adrs_rot[2]) + { return i; } } @@ -235,27 +240,29 @@ long bzg_rotate_grid_index(const long bz_grid_index, return bzgrid->gp_map[gp]; } - long bzg_get_bz_grid_addresses(BZGrid *bzgrid) { long det; long Qinv[3][3]; det = get_inverse_unimodular_matrix_l3(Qinv, bzgrid->Q); - if (det == 0) { + if (det == 0) + { return 0; } - if (bzgrid->type == 1) { + if (bzgrid->type == 1) + { get_bz_grid_addresses_type1(bzgrid, Qinv); - } else { + } + else + { get_bz_grid_addresses_type2(bzgrid, Qinv); } return 1; } - /* Note: Tolerance in squared distance. */ double bzg_get_tolerance_for_BZ_reduction(const BZGrid *bzgrid) { @@ -264,25 +271,29 @@ double bzg_get_tolerance_for_BZ_reduction(const BZGrid *bzgrid) double length[3]; double reclatQ[3][3]; - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { reclatQ[i][j] = - bzgrid->reclat[i][0] * bzgrid->Q[0][j] - + bzgrid->reclat[i][1] * bzgrid->Q[1][j] - + bzgrid->reclat[i][2] * bzgrid->Q[2][j]; + bzgrid->reclat[i][0] * bzgrid->Q[0][j] + bzgrid->reclat[i][1] * bzgrid->Q[1][j] + bzgrid->reclat[i][2] * bzgrid->Q[2][j]; } } - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { length[i] = 0; - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { length[i] += reclatQ[j][i] * reclatQ[j][i]; } length[i] /= bzgrid->D_diag[i] * bzgrid->D_diag[i]; } tolerance = length[0]; - for (i = 1; i < 3; i++) { - if (tolerance < length[i]) { + for (i = 1; i < 3; i++) + { + if (tolerance < length[i]) + { tolerance = length[i]; } } @@ -291,21 +302,23 @@ double bzg_get_tolerance_for_BZ_reduction(const BZGrid *bzgrid) return tolerance; } -RotMats * bzg_alloc_RotMats(const long size) +RotMats *bzg_alloc_RotMats(const long size) { RotMats *rotmats; rotmats = NULL; - if ((rotmats = (RotMats*) malloc(sizeof(RotMats))) == NULL) { + if ((rotmats = (RotMats *)malloc(sizeof(RotMats))) == NULL) + { warning_print("Memory could not be allocated."); return NULL; } rotmats->size = size; - if (size > 0) { - if ((rotmats->mat = (long (*)[3][3]) malloc(sizeof(long[3][3]) * size)) - == NULL) { + if (size > 0) + { + if ((rotmats->mat = (long(*)[3][3])malloc(sizeof(long[3][3]) * size)) == NULL) + { warning_print("Memory could not be allocated "); warning_print("(RotMats, line %d, %s).\n", __LINE__, __FILE__); free(rotmats); @@ -316,9 +329,10 @@ RotMats * bzg_alloc_RotMats(const long size) return rotmats; } -void bzg_free_RotMats(RotMats * rotmats) +void bzg_free_RotMats(RotMats *rotmats) { - if (rotmats->size > 0) { + if (rotmats->size > 0) + { free(rotmats->mat); rotmats->mat = NULL; } @@ -331,10 +345,12 @@ void bzg_multiply_matrix_vector_ld3(double v[3], { long i; double c[3]; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { c[i] = a[i][0] * b[0] + a[i][1] * b[1] + a[i][2] * b[2]; } - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { v[i] = c[i]; } } @@ -349,12 +365,14 @@ static void get_bz_grid_addresses_type1(BZGrid *bzgrid, long count, id_shift; tolerance = bzg_get_tolerance_for_BZ_reduction(bzgrid); - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { bzmesh[j] = bzgrid->D_diag[j] * 2; } num_bzmesh = bzmesh[0] * bzmesh[1] * bzmesh[2]; - for (i = 0; i < num_bzmesh; i++) { + for (i = 0; i < num_bzmesh; i++) + { bzgrid->gp_map[i] = num_bzmesh; } @@ -365,16 +383,22 @@ static void get_bz_grid_addresses_type1(BZGrid *bzgrid, /* with boundary_num_gp is unstable to store bz_grid_address. */ bzgrid->gp_map[num_bzmesh] = 0; id_shift = 0; - for (i = 0; i < total_num_gp; i++) { + for (i = 0; i < total_num_gp; i++) + { grg_get_grid_address_from_index(gr_adrs, i, bzgrid->D_diag); min_distance = get_bz_distances(nint, distances, bzgrid, gr_adrs, tolerance); count = 0; - for (j = 0; j < BZG_NUM_BZ_SEARCH_SPACE; j++) { - if (distances[j] < min_distance + tolerance) { - if (count == 0) { + for (j = 0; j < BZG_NUM_BZ_SEARCH_SPACE; j++) + { + if (distances[j] < min_distance + tolerance) + { + if (count == 0) + { gp = i; - } else { + } + else + { gp = boundary_num_gp + total_num_gp; boundary_num_gp++; } @@ -385,11 +409,12 @@ static void get_bz_grid_addresses_type1(BZGrid *bzgrid, bzgrid->D_diag, nint, Qinv); - for (k = 0; k < 3; k++) { + for (k = 0; k < 3; k++) + { bz_address_double[k] = bzgrid->addresses[gp][k] * 2 + bzgrid->PS[k]; } bzgp = grg_get_double_grid_index( - bz_address_double, bzmesh, bzgrid->PS); + bz_address_double, bzmesh, bzgrid->PS); bzgrid->gp_map[bzgp] = gp; bzgrid->bzg2grg[gp] = i; } @@ -417,12 +442,15 @@ static void get_bz_grid_addresses_type2(BZGrid *bzgrid, bzgrid->gp_map[0] = 0; for (i = 0; - i < bzgrid->D_diag[0] * bzgrid->D_diag[1] * bzgrid->D_diag[2]; i++) { + i < bzgrid->D_diag[0] * bzgrid->D_diag[1] * bzgrid->D_diag[2]; i++) + { grg_get_grid_address_from_index(gr_adrs, i, bzgrid->D_diag); min_distance = get_bz_distances(nint, distances, bzgrid, gr_adrs, tolerance); - for (j = 0; j < BZG_NUM_BZ_SEARCH_SPACE; j++) { - if (distances[j] < min_distance + tolerance) { + for (j = 0; j < BZG_NUM_BZ_SEARCH_SPACE; j++) + { + if (distances[j] < min_distance + tolerance) + { set_bz_address(bzgrid->addresses[num_gp], j, gr_adrs, @@ -433,7 +461,7 @@ static void get_bz_grid_addresses_type2(BZGrid *bzgrid, num_gp++; } } - bzgrid->gp_map[i + 1] = num_gp; + bzgrid->gp_map[i + 1] = num_gp; } bzgrid->size = num_gp; @@ -449,11 +477,13 @@ static void set_bz_address(long address[3], long i; long deltaG[3]; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { deltaG[i] = bz_search_space[bz_index][i] - nint[i]; } lagmat_multiply_matrix_vector_l3(deltaG, Qinv, deltaG); - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { address[i] = grid_address[i] + deltaG[i] * D_diag[i]; } } @@ -471,17 +501,21 @@ static double get_bz_distances(long nint[3], grg_get_double_grid_address(dadrs, grid_address, bzgrid->PS); - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { q_red[i] = dadrs[i] / (2.0 * bzgrid->D_diag[i]); } bzg_multiply_matrix_vector_ld3(q_red, bzgrid->Q, q_red); - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { nint[i] = lagmat_Nint(q_red[i]); q_red[i] -= nint[i]; } - for (i = 0; i < BZG_NUM_BZ_SEARCH_SPACE; i++) { - for (j = 0; j < 3; j++) { + for (i = 0; i < BZG_NUM_BZ_SEARCH_SPACE; i++) + { + for (j = 0; j < 3; j++) + { q_vec[j] = q_red[j] + bz_search_space[i][j]; } multiply_matrix_vector_d3(q_vec, bzgrid->reclat, q_vec); @@ -493,8 +527,10 @@ static double get_bz_distances(long nint[3], * those translationally equivalent can change by very tiny numerical * fluctuation. */ min_distance = distances[0]; - for (i = 1; i < BZG_NUM_BZ_SEARCH_SPACE; i++) { - if (distances[i] < min_distance - tolerance) { + for (i = 1; i < BZG_NUM_BZ_SEARCH_SPACE; i++) + { + if (distances[i] < min_distance - tolerance) + { min_distance = distances[i]; } } @@ -508,10 +544,12 @@ static void multiply_matrix_vector_d3(double v[3], { long i; double c[3]; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { c[i] = a[i][0] * b[0] + a[i][1] * b[1] + a[i][2] * b[2]; } - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { v[i] = c[i]; } } @@ -523,7 +561,8 @@ static long get_inverse_unimodular_matrix_l3(long m[3][3], long c[3][3]; det = lagmat_get_determinant_l3(a); - if (labs(det) != 1) { + if (labs(det) != 1) + { return 0; } diff --git a/c/bzgrid.h b/c/bzgrid.h index 6d287ab6..0105fc23 100644 --- a/c/bzgrid.h +++ b/c/bzgrid.h @@ -35,7 +35,8 @@ #ifndef __bzgrid_H__ #define __bzgrid_H__ -typedef struct { +typedef struct +{ long size; long (*mat)[3][3]; } RotMats; @@ -67,7 +68,8 @@ typedef struct { * shape=(3, 3) * type : long * 1 or 2. */ -typedef struct { +typedef struct +{ long size; long D_diag[3]; long Q[3][3]; @@ -79,7 +81,8 @@ typedef struct { long type; } BZGrid; -typedef struct { +typedef struct +{ long size; long D_diag[3]; long Q[3][3]; @@ -91,14 +94,13 @@ typedef struct { long type; } ConstBZGrid; - long bzg_rotate_grid_index(const long grid_index, const long rotation[3][3], const ConstBZGrid *bzgrid); long bzg_get_bz_grid_addresses(BZGrid *bzgrid); double bzg_get_tolerance_for_BZ_reduction(const BZGrid *bzgrid); -RotMats * bzg_alloc_RotMats(const long size); -void bzg_free_RotMats(RotMats * rotmats); +RotMats *bzg_alloc_RotMats(const long size); +void bzg_free_RotMats(RotMats *rotmats); void bzg_multiply_matrix_vector_ld3(double v[3], const long a[3][3], const double b[3]); diff --git a/c/collision_matrix.c b/c/collision_matrix.c index 80a72d2d..c628177a 100644 --- a/c/collision_matrix.c +++ b/c/collision_matrix.c @@ -105,23 +105,23 @@ void col_get_collision_matrix(double *collision_matrix, num_band = fc3_normal_squared->dims[2]; get_collision_matrix( - collision_matrix, - fc3_normal_squared->data, - num_band0, - num_band, - frequencies, - triplets, - triplets_map, - num_gp, - map_q, - rot_grid_points, - num_ir_gp, - num_rot, - rotations_cartesian, - g + 2 * num_triplets * num_band0 * num_band * num_band, - temperature, - unit_conversion_factor, - cutoff_frequency); + collision_matrix, + fc3_normal_squared->data, + num_band0, + num_band, + frequencies, + triplets, + triplets_map, + num_gp, + map_q, + rot_grid_points, + num_ir_gp, + num_rot, + rotations_cartesian, + g + 2 * num_triplets * num_band0 * num_band * num_band, + temperature, + unit_conversion_factor, + cutoff_frequency); } void col_get_reducible_collision_matrix(double *collision_matrix, @@ -143,19 +143,19 @@ void col_get_reducible_collision_matrix(double *collision_matrix, num_band = fc3_normal_squared->dims[2]; get_reducible_collision_matrix( - collision_matrix, - fc3_normal_squared->data, - num_band0, - num_band, - frequencies, - triplets, - triplets_map, - num_gp, - map_q, - g + 2 * num_triplets * num_band0 * num_band * num_band, - temperature, - unit_conversion_factor, - cutoff_frequency); + collision_matrix, + fc3_normal_squared->data, + num_band0, + num_band, + frequencies, + triplets, + triplets_map, + num_gp, + map_q, + g + 2 * num_triplets * num_band0 * num_band * num_band, + temperature, + unit_conversion_factor, + cutoff_frequency); } static void get_collision_matrix(double *collision_matrix, @@ -186,9 +186,11 @@ static void get_collision_matrix(double *collision_matrix, #ifdef PHPYOPENMP #pragma omp parallel for private(j, k, l, m, n, ti, r_gp, collision, inv_sinh) #endif - for (i = 0; i < num_ir_gp; i++) { - inv_sinh = (double*)malloc(sizeof(double) * num_band); - for (j = 0; j < num_rot; j++) { + for (i = 0; i < num_ir_gp; i++) + { + inv_sinh = (double *)malloc(sizeof(double) * num_band); + for (j = 0; j < num_rot; j++) + { r_gp = rot_grid_points[i * num_rot + j]; ti = gp2tp_map[triplets_map[r_gp]]; get_inv_sinh(inv_sinh, @@ -201,25 +203,30 @@ static void get_collision_matrix(double *collision_matrix, num_band, cutoff_frequency); - for (k = 0; k < num_band0; k++) { - for (l = 0; l < num_band; l++) { + for (k = 0; k < num_band0; k++) + { + for (l = 0; l < num_band; l++) + { collision = 0; - for (m = 0; m < num_band; m++) { + for (m = 0; m < num_band; m++) + { collision += - fc3_normal_squared[ti * num_band0 * num_band * num_band + - k * num_band * num_band + - l * num_band + m] * - g[ti * num_band0 * num_band * num_band + - k * num_band * num_band + - l * num_band + m] * - inv_sinh[m] * unit_conversion_factor; + fc3_normal_squared[ti * num_band0 * num_band * num_band + + k * num_band * num_band + + l * num_band + m] * + g[ti * num_band0 * num_band * num_band + + k * num_band * num_band + + l * num_band + m] * + inv_sinh[m] * unit_conversion_factor; } - for (m = 0; m < 3; m++) { - for (n = 0; n < 3; n++) { + for (m = 0; m < 3; m++) + { + for (n = 0; n < 3; n++) + { collision_matrix[k * 3 * num_ir_gp * num_band * 3 + m * num_ir_gp * num_band * 3 + i * num_band * 3 + l * 3 + n] += - collision * rotations_cartesian[j * 9 + m * 3 + n]; + collision * rotations_cartesian[j * 9 + m * 3 + n]; } } } @@ -258,8 +265,9 @@ get_reducible_collision_matrix(double *collision_matrix, #ifdef PHPYOPENMP #pragma omp parallel for private(j, k, l, ti, collision, inv_sinh) #endif - for (i = 0; i < num_gp; i++) { - inv_sinh = (double*)malloc(sizeof(double) * num_band); + for (i = 0; i < num_gp; i++) + { + inv_sinh = (double *)malloc(sizeof(double) * num_band); ti = gp2tp_map[triplets_map[i]]; get_inv_sinh(inv_sinh, i, @@ -271,18 +279,21 @@ get_reducible_collision_matrix(double *collision_matrix, num_band, cutoff_frequency); - for (j = 0; j < num_band0; j++) { - for (k = 0; k < num_band; k++) { + for (j = 0; j < num_band0; j++) + { + for (k = 0; k < num_band; k++) + { collision = 0; - for (l = 0; l < num_band; l++) { + for (l = 0; l < num_band; l++) + { collision += - fc3_normal_squared[ti * num_band0 * num_band * num_band + - j * num_band * num_band + - k * num_band + l] * - g[ti * num_band0 * num_band * num_band + - j * num_band * num_band + - k * num_band + l] * - inv_sinh[l] * unit_conversion_factor; + fc3_normal_squared[ti * num_band0 * num_band * num_band + + j * num_band * num_band + + k * num_band + l] * + g[ti * num_band0 * num_band * num_band + + j * num_band * num_band + + k * num_band + l] * + inv_sinh[l] * unit_conversion_factor; } collision_matrix[j * num_gp * num_band + i * num_band + k] += collision; } @@ -312,17 +323,24 @@ static void get_inv_sinh(double *inv_sinh, /* This assumes the algorithm of get_ir_triplets_at_q_perm_q1q2, */ /* where defined triplets_map[gp] == triplets_map[map_q[gp]]. */ /* If triplets_map[map_q[gp]] != map_q[gp], q1 and q2 are permuted. */ - if (triplets_map[gp] == map_q[gp]) { + if (triplets_map[gp] == map_q[gp]) + { gp2 = triplet[2]; - } else { + } + else + { gp2 = triplet[1]; } - for (i = 0; i < num_band; i++) { + for (i = 0; i < num_band; i++) + { f = frequencies[gp2 * num_band + i]; - if (f > cutoff_frequency) { + if (f > cutoff_frequency) + { inv_sinh[i] = phonoc_inv_sinh_occupation(f, temperature); - } else { + } + else + { inv_sinh[i] = 0; } } @@ -337,13 +355,17 @@ static long *create_gp2tp_map(const long *triplets_map, long i, num_ir; long *gp2tp_map; - gp2tp_map = (long*)malloc(sizeof(long) * num_gp); + gp2tp_map = (long *)malloc(sizeof(long) * num_gp); num_ir = 0; - for (i = 0; i < num_gp; i++) { - if (triplets_map[i] == i) { + for (i = 0; i < num_gp; i++) + { + if (triplets_map[i] == i) + { gp2tp_map[i] = num_ir; num_ir++; - } else { /* This should not be used. */ + } + else + { /* This should not be used. */ gp2tp_map[i] = -1; } } diff --git a/c/dynmat.c b/c/dynmat.c index 6b97a1b8..2701edf3 100644 --- a/c/dynmat.c +++ b/c/dynmat.c @@ -65,7 +65,7 @@ static void get_dm(double dm_real[3][3], const long k); static double get_dielectric_part(const double q_cart[3], const double dielectric[3][3]); -static void get_KK(double *dd_part, /* [natom, 3, natom, 3, (real,imag)] */ +static void get_KK(double *dd_part, /* [natom, 3, natom, 3, (real,imag)] */ const double (*G_list)[3], /* [num_G, 3] */ const long num_G, const long num_patom, @@ -96,11 +96,13 @@ long dym_get_dynamical_matrix_at_q(double *dynamical_matrix, { long i, j, ij; - if (with_openmp) { + if (with_openmp) + { #ifdef PHPYOPENMP #pragma omp parallel for #endif - for (ij = 0; ij < num_patom * num_patom ; ij++) { + for (ij = 0; ij < num_patom * num_patom; ij++) + { get_dynmat_ij(dynamical_matrix, num_patom, num_satom, @@ -115,9 +117,13 @@ long dym_get_dynamical_matrix_at_q(double *dynamical_matrix, ij / num_patom, /* i */ ij % num_patom); /* j */ } - } else { - for (i = 0; i < num_patom; i++) { - for (j = 0; j < num_patom; j++) { + } + else + { + for (i = 0; i < num_patom; i++) + { + for (j = 0; j < num_patom; j++) + { get_dynmat_ij(dynamical_matrix, num_patom, num_satom, @@ -140,8 +146,8 @@ long dym_get_dynamical_matrix_at_q(double *dynamical_matrix, return 0; } -void dym_get_recip_dipole_dipole(double *dd, /* [natom, 3, natom, 3, (real,imag)] */ - const double *dd_q0, /* [natom, 3, 3, (real,imag)] */ +void dym_get_recip_dipole_dipole(double *dd, /* [natom, 3, natom, 3, (real,imag)] */ + const double *dd_q0, /* [natom, 3, 3, (real,imag)] */ const double (*G_list)[3], /* [num_G, 3] */ const long num_G, const long num_patom, @@ -150,7 +156,7 @@ void dym_get_recip_dipole_dipole(double *dd, /* [natom, 3, natom, 3, (real,imag) const double (*born)[3][3], const double dielectric[3][3], const double (*pos)[3], /* [num_patom, 3] */ - const double factor, /* 4pi/V*unit-conv */ + const double factor, /* 4pi/V*unit-conv */ const double lambda, const double tolerance) { @@ -158,9 +164,10 @@ void dym_get_recip_dipole_dipole(double *dd, /* [natom, 3, natom, 3, (real,imag) double *dd_tmp; dd_tmp = NULL; - dd_tmp = (double*) malloc(sizeof(double) * num_patom * num_patom * 18); + dd_tmp = (double *)malloc(sizeof(double) * num_patom * num_patom * 18); - for (i = 0; i < num_patom * num_patom * 18; i++) { + for (i = 0; i < num_patom * num_patom * 18; i++) + { dd[i] = 0; dd_tmp[i] = 0; } @@ -178,9 +185,12 @@ void dym_get_recip_dipole_dipole(double *dd, /* [natom, 3, natom, 3, (real,imag) multiply_borns(dd, dd_tmp, num_patom, born); - for (i = 0; i < num_patom; i++) { - for (k = 0; k < 3; k++) { /* alpha */ - for (l = 0; l < 3; l++) { /* beta */ + for (i = 0; i < num_patom; i++) + { + for (k = 0; k < 3; k++) + { /* alpha */ + for (l = 0; l < 3; l++) + { /* beta */ adrs = i * num_patom * 9 + k * num_patom * 3 + i * 3 + l; adrs_sum = i * 9 + k * 3 + l; dd[adrs * 2] -= dd_q0[adrs_sum * 2]; @@ -189,7 +199,8 @@ void dym_get_recip_dipole_dipole(double *dd, /* [natom, 3, natom, 3, (real,imag) } } - for (i = 0; i < num_patom * num_patom * 18; i++) { + for (i = 0; i < num_patom * num_patom * 18; i++) + { dd[i] *= factor; } @@ -200,7 +211,7 @@ void dym_get_recip_dipole_dipole(double *dd, /* [natom, 3, natom, 3, (real,imag) dd_tmp = NULL; } -void dym_get_recip_dipole_dipole_q0(double *dd_q0, /* [natom, 3, 3, (real,imag)] */ +void dym_get_recip_dipole_dipole_q0(double *dd_q0, /* [natom, 3, 3, (real,imag)] */ const double (*G_list)[3], /* [num_G, 3] */ const long num_G, const long num_patom, @@ -215,11 +226,12 @@ void dym_get_recip_dipole_dipole_q0(double *dd_q0, /* [natom, 3, 3, (real,imag)] double *dd_tmp1, *dd_tmp2; dd_tmp1 = NULL; - dd_tmp1 = (double*) malloc(sizeof(double) * num_patom * num_patom * 18); + dd_tmp1 = (double *)malloc(sizeof(double) * num_patom * num_patom * 18); dd_tmp2 = NULL; - dd_tmp2 = (double*) malloc(sizeof(double) * num_patom * num_patom * 18); + dd_tmp2 = (double *)malloc(sizeof(double) * num_patom * num_patom * 18); - for (i = 0; i < num_patom * num_patom * 18; i++) { + for (i = 0; i < num_patom * num_patom * 18; i++) + { dd_tmp1[i] = 0; dd_tmp2[i] = 0; } @@ -241,16 +253,21 @@ void dym_get_recip_dipole_dipole_q0(double *dd_q0, /* [natom, 3, 3, (real,imag)] multiply_borns(dd_tmp2, dd_tmp1, num_patom, born); - for (i = 0; i < num_patom * 18; i++) { + for (i = 0; i < num_patom * 18; i++) + { dd_q0[i] = 0; } - for (i = 0; i < num_patom; i++) { - for (k = 0; k < 3; k++) { /* alpha */ - for (l = 0; l < 3; l++) { /* beta */ + for (i = 0; i < num_patom; i++) + { + for (k = 0; k < 3; k++) + { /* alpha */ + for (l = 0; l < 3; l++) + { /* beta */ adrs = i * 9 + k * 3 + l; - for (j = 0; j < num_patom; j++) { - adrs_tmp = i * num_patom * 9 + k * num_patom * 3 + j * 3 + l ; + for (j = 0; j < num_patom; j++) + { + adrs_tmp = i * num_patom * 9 + k * num_patom * 3 + j * 3 + l; dd_q0[adrs * 2] += dd_tmp2[adrs_tmp * 2]; dd_q0[adrs * 2 + 1] += dd_tmp2[adrs_tmp * 2 + 1]; } @@ -272,9 +289,12 @@ void dym_get_recip_dipole_dipole_q0(double *dd_q0, /* [natom, 3, 3, (real,imag)] /* } */ /* } */ - for (i = 0; i < num_patom; i++) { - for (k = 0; k < 3; k++) { /* alpha */ - for (l = 0; l < 3; l++) { /* beta */ + for (i = 0; i < num_patom; i++) + { + for (k = 0; k < 3; k++) + { /* alpha */ + for (l = 0; l < 3; l++) + { /* beta */ adrs = i * 9 + k * 3 + l; adrsT = i * 9 + l * 3 + k; dd_q0[adrs * 2] += dd_q0[adrsT * 2]; @@ -300,29 +320,38 @@ void dym_get_charge_sum(double (*charge_sum)[3][3], const double (*born)[3][3]) { long i, j, k, a, b; - double (*q_born)[3]; + double(*q_born)[3]; - q_born = (double (*)[3]) malloc(sizeof(double[3]) * num_patom); - for (i = 0; i < num_patom; i++) { - for (j = 0; j < 3; j++) { + q_born = (double(*)[3])malloc(sizeof(double[3]) * num_patom); + for (i = 0; i < num_patom; i++) + { + for (j = 0; j < 3; j++) + { q_born[i][j] = 0; } } - for (i = 0; i < num_patom; i++) { - for (j = 0; j < 3; j++) { - for (k = 0; k < 3; k++) { + for (i = 0; i < num_patom; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < 3; k++) + { q_born[i][j] += q_cart[k] * born[i][k][j]; } } } - for (i = 0; i < num_patom; i++) { - for (j = 0; j < num_patom; j++) { - for (a = 0; a < 3; a++) { - for (b = 0; b < 3; b++) { + for (i = 0; i < num_patom; i++) + { + for (j = 0; j < num_patom; j++) + { + for (a = 0; a < 3; a++) + { + for (b = 0; b < 3; b++) + { charge_sum[i * num_patom + j][a][b] = - q_born[i][a] * q_born[j][b] * factor; + q_born[i][a] * q_born[j][b] * factor; } } } @@ -352,35 +381,43 @@ void dym_transform_dynmat_to_fc(double *fc, double coef, phase, cos_phase, sin_phase; N = num_satom / num_patom; - for (i = 0; i < num_patom * num_satom * 9; i++) { + for (i = 0; i < num_patom * num_satom * 9; i++) + { fc[i] = 0; } - for (i = 0; i < num_patom; i++) { - for (j = 0; j < num_satom; j++) { + for (i = 0; i < num_patom; i++) + { + for (j = 0; j < num_satom; j++) + { i_pair = j * num_patom + i; m_pair = multi[i_pair][0]; svecs_adrs = multi[i_pair][1]; coef = sqrt(masses[i] * masses[s2pp_map[j]]) / N; - for (k = 0; k < N; k++) { + for (k = 0; k < N; k++) + { cos_phase = 0; sin_phase = 0; - for (l = 0; l < m_pair; l++) { + for (l = 0; l < m_pair; l++) + { phase = 0; - for (m = 0; m < 3; m++) { + for (m = 0; m < 3; m++) + { phase -= comm_points[k][m] * svecs[svecs_adrs + l][m]; } cos_phase += cos(phase * 2 * PI); sin_phase += sin(phase * 2 * PI); } - cos_phase /= m_pair; - sin_phase /= m_pair; - for (l = 0; l < 3; l++) { - for (m = 0; m < 3; m++) { + cos_phase /= m_pair; + sin_phase /= m_pair; + for (l = 0; l < 3; l++) + { + for (m = 0; m < 3; m++) + { adrs = k * num_patom * num_patom * 18 + i * num_patom * 18 + - l * num_patom * 6 + s2pp_map[j] * 6 + m * 2; + l * num_patom * 6 + s2pp_map[j] * 6 + m * 2; fc[fc_index_map[i] * num_satom * 9 + j * 9 + l * 3 + m] += - (dm[adrs] * cos_phase - dm[adrs + 1] * sin_phase) * coef; + (dm[adrs] * cos_phase - dm[adrs + 1] * sin_phase) * coef; } } } @@ -388,7 +425,6 @@ void dym_transform_dynmat_to_fc(double *fc, } } - static void get_dynmat_ij(double *dynamical_matrix, const long num_patom, const long num_satom, @@ -409,15 +445,19 @@ static void get_dynmat_ij(double *dynamical_matrix, mass_sqrt = sqrt(mass[i] * mass[j]); - for (k = 0; k < 3; k++) { - for (l = 0; l < 3; l++) { + for (k = 0; k < 3; k++) + { + for (l = 0; l < 3; l++) + { dm_real[k][l] = 0; dm_imag[k][l] = 0; } } - for (k = 0; k < num_satom; k++) { /* Lattice points of right index of fc */ - if (s2p_map[k] != p2s_map[j]) { + for (k = 0; k < num_satom; k++) + { /* Lattice points of right index of fc */ + if (s2p_map[k] != p2s_map[j]) + { continue; } get_dm(dm_real, @@ -435,8 +475,10 @@ static void get_dynmat_ij(double *dynamical_matrix, k); } - for (k = 0; k < 3; k++) { - for (l = 0; l < 3; l++) { + for (k = 0; k < 3; k++) + { + for (l = 0; l < 3; l++) + { adrs = (i * 3 + k) * num_patom * 3 + j * 3 + l; dynamical_matrix[adrs * 2] = dm_real[k][l] / mass_sqrt; dynamical_matrix[adrs * 2 + 1] = dm_imag[k][l] / mass_sqrt; @@ -468,21 +510,28 @@ static void get_dm(double dm_real[3][3], m_pair = multi[i_pair][0]; adrs = multi[i_pair][1]; - for (l = 0; l < m_pair; l++) { + for (l = 0; l < m_pair; l++) + { phase = 0; - for (m = 0; m < 3; m++) { + for (m = 0; m < 3; m++) + { phase += q[m] * svecs[adrs + l][m]; } cos_phase += cos(phase * 2 * PI) / m_pair; sin_phase += sin(phase * 2 * PI) / m_pair; } - for (l = 0; l < 3; l++) { - for (m = 0; m < 3; m++) { - if (charge_sum) { + for (l = 0; l < 3; l++) + { + for (m = 0; m < 3; m++) + { + if (charge_sum) + { fc_elem = (fc[p2s_map[i] * num_satom * 9 + k * 9 + l * 3 + m] + charge_sum[i * num_patom + j][l][m]); - } else { + } + else + { fc_elem = fc[p2s_map[i] * num_satom * 9 + k * 9 + l * 3 + m]; } dm_real[l][m] += fc_elem * cos_phase; @@ -498,22 +547,25 @@ static double get_dielectric_part(const double q_cart[3], double x[3]; double sum; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { x[i] = 0; - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { x[i] += dielectric[i][j] * q_cart[j]; } } sum = 0; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { sum += q_cart[i] * x[i]; } return sum; } -static void get_KK(double *dd_part, /* [natom, 3, natom, 3, (real,imag)] */ +static void get_KK(double *dd_part, /* [natom, 3, natom, 3, (real,imag)] */ const double (*G_list)[3], /* [num_G, 3] */ const long num_G, const long num_patom, @@ -534,39 +586,54 @@ static void get_KK(double *dd_part, /* [natom, 3, natom, 3, (real,imag)] */ /* sum over K = G + q and over G (i.e. q=0) */ /* q_direction has values for summation over K at Gamma point. */ /* q_direction is NULL for summation over G */ - for (g = 0; g < num_G; g++) { + for (g = 0; g < num_G; g++) + { norm = 0; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { q_K[i] = G_list[g][i] + q_cart[i]; norm += q_K[i] * q_K[i]; } - if (sqrt(norm) < tolerance) { - if (!q_direction_cart) { + if (sqrt(norm) < tolerance) + { + if (!q_direction_cart) + { continue; - } else { + } + else + { dielectric_part = get_dielectric_part(q_direction_cart, dielectric); - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { KK[i][j] = - q_direction_cart[i] * q_direction_cart[j] / dielectric_part; + q_direction_cart[i] * q_direction_cart[j] / dielectric_part; } } } - } else { + } + else + { dielectric_part = get_dielectric_part(q_K, dielectric); exp_damp = exp(-dielectric_part / L2); - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { KK[i][j] = q_K[i] * q_K[j] / dielectric_part * exp_damp; } } } - for (i = 0; i < num_patom; i++) { - for (j = 0; j < num_patom; j++) { + for (i = 0; i < num_patom; i++) + { + for (j = 0; j < num_patom; j++) + { phase = 0; - for (k = 0; k < 3; k++) { + for (k = 0; k < 3; k++) + { /* For D-type dynamical matrix */ /* phase += (pos[i][k] - pos[j][k]) * q_K[k]; */ /* For C-type dynamical matrix */ @@ -575,8 +642,10 @@ static void get_KK(double *dd_part, /* [natom, 3, natom, 3, (real,imag)] */ phase *= 2 * PI; cos_phase = cos(phase); sin_phase = sin(phase); - for (k = 0; k < 3; k++) { - for (l = 0; l < 3; l++) { + for (k = 0; k < 3; k++) + { + for (l = 0; l < 3; l++) + { adrs = i * num_patom * 9 + k * num_patom * 3 + j * 3 + l; dd_part[adrs * 2] += KK[k][l] * cos_phase; dd_part[adrs * 2 + 1] += KK[k][l] * sin_phase; @@ -591,8 +660,10 @@ static void make_Hermitian(double *mat, const long num_band) { long i, j, adrs, adrsT; - for (i = 0; i < num_band; i++) { - for (j = i; j < num_band; j++) { + for (i = 0; i < num_band; i++) + { + for (j = i; j < num_band; j++) + { adrs = i * num_band + j * 1; adrs *= 2; adrsT = j * num_band + i * 1; @@ -601,7 +672,7 @@ static void make_Hermitian(double *mat, const long num_band) mat[adrs] += mat[adrsT]; mat[adrs] /= 2; /* imaginary part */ - mat[adrs + 1] -= mat[adrsT+ 1]; + mat[adrs + 1] -= mat[adrsT + 1]; mat[adrs + 1] /= 2; /* store */ mat[adrsT] = mat[adrs]; @@ -618,14 +689,20 @@ static void multiply_borns(double *dd, long i, j, k, l, m, n, adrs, adrs_in; double zz; - for (i = 0; i < num_patom; i++) { - for (j = 0; j < num_patom; j++) { - for (k = 0; k < 3; k++) { /* alpha */ - for (l = 0; l < 3; l++) { /* beta */ + for (i = 0; i < num_patom; i++) + { + for (j = 0; j < num_patom; j++) + { + for (k = 0; k < 3; k++) + { /* alpha */ + for (l = 0; l < 3; l++) + { /* beta */ adrs = i * num_patom * 9 + k * num_patom * 3 + j * 3 + l; - for (m = 0; m < 3; m++) { /* alpha' */ - for (n = 0; n < 3; n++) { /* beta' */ - adrs_in = i * num_patom * 9 + m * num_patom * 3 + j * 3 + n ; + for (m = 0; m < 3; m++) + { /* alpha' */ + for (n = 0; n < 3; n++) + { /* beta' */ + adrs_in = i * num_patom * 9 + m * num_patom * 3 + j * 3 + n; zz = born[i][m][k] * born[j][n][l]; dd[adrs * 2] += dd_in[adrs_in * 2] * zz; dd[adrs * 2 + 1] += dd_in[adrs_in * 2 + 1] * zz; diff --git a/c/dynmat.h b/c/dynmat.h index 7c7007e6..db93c55b 100644 --- a/c/dynmat.h +++ b/c/dynmat.h @@ -47,8 +47,8 @@ long dym_get_dynamical_matrix_at_q(double *dynamical_matrix, const long *p2s_map, const 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)] */ +void dym_get_recip_dipole_dipole(double *dd, /* [natom, 3, natom, 3, (real,imag)] */ + const double *dd_q0, /* [natom, 3, 3, (real,imag)] */ const double (*G_list)[3], /* [num_G, 3] */ const long num_G, const long num_patom, @@ -57,10 +57,10 @@ void dym_get_recip_dipole_dipole(double *dd, /* [natom, 3, natom, 3, (real,imag) const double (*born)[3][3], const double dielectric[3][3], const double (*pos)[3], /* [num_patom, 3] */ - const double factor, /* 4pi/V*unit-conv */ + const double factor, /* 4pi/V*unit-conv */ const double lambda, const double tolerance); -void dym_get_recip_dipole_dipole_q0(double *dd_q0, /* [natom, 3, 3, (real,imag)] */ +void dym_get_recip_dipole_dipole_q0(double *dd_q0, /* [natom, 3, 3, (real,imag)] */ const double (*G_list)[3], /* [num_G, 3] */ const long num_G, const long num_patom, diff --git a/c/fc3.c b/c/fc3.c index 2d3fa681..bc97c61c 100644 --- a/c/fc3.c +++ b/c/fc3.c @@ -65,14 +65,14 @@ static void set_permutation_symmetry_fc3_elem(double *fc3_elem, const long b, const long c, const long num_atom); -static void set_permutation_symmetry_compact_fc3(double * fc3, +static void set_permutation_symmetry_compact_fc3(double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], const long perms[], const long n_satom, const long n_patom); -static void transpose_compact_fc3_type01(double * fc3, +static void transpose_compact_fc3_type01(double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], @@ -80,7 +80,7 @@ static void transpose_compact_fc3_type01(double * fc3, const long n_satom, const long n_patom, const long t_type); -static void transpose_compact_fc3_type2(double * fc3, +static void transpose_compact_fc3_type2(double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], @@ -97,12 +97,12 @@ void fc3_distribute_fc3(double *fc3, { long i, j, adrs_out, adrs_in; - for (i = 0; i < num_atom; i++) { - for (j = 0; j < num_atom; j++) { + for (i = 0; i < num_atom; i++) + { + for (j = 0; j < num_atom; j++) + { adrs_out = (num_atom * num_atom * target + num_atom * i + j) * 27; - adrs_in = (num_atom * num_atom * source - + num_atom * atom_mapping[i] - + atom_mapping[j]) * 27; + adrs_in = (num_atom * num_atom * source + num_atom * atom_mapping[i] + atom_mapping[j]) * 27; tensor3_rotation(fc3 + adrs_out, fc3 + adrs_in, rot_cart); } } @@ -118,11 +118,11 @@ void fc3_rotate_delta_fc2(double (*fc3)[3][3][3], const long num_disp) { long i_atoms, i, j, k, l, m, n; - double (*rot_delta_fc2s)[3][3]; + double(*rot_delta_fc2s)[3][3]; - rot_delta_fc2s = (double(*)[3][3]) malloc(sizeof(double[3][3]) - * num_site_sym * num_disp); - for (i_atoms = 0; i_atoms < num_atom * num_atom; i_atoms++) { + rot_delta_fc2s = (double(*)[3][3])malloc(sizeof(double[3][3]) * num_site_sym * num_disp); + for (i_atoms = 0; i_atoms < num_atom * num_atom; i_atoms++) + { i = i_atoms / num_atom; j = i_atoms % num_atom; rotate_delta_fc2s(rot_delta_fc2s, @@ -134,14 +134,17 @@ void fc3_rotate_delta_fc2(double (*fc3)[3][3][3], num_atom, num_site_sym, num_disp); - for (k = 0; k < 3; k++) { - for (l = 0; l < 3; l++) { - for (m = 0; m < 3; m++) { + for (k = 0; k < 3; k++) + { + for (l = 0; l < 3; l++) + { + for (m = 0; m < 3; m++) + { fc3[i_atoms][k][l][m] = 0; - for (n = 0; n < num_site_sym * num_disp; n++) { + for (n = 0; n < num_site_sym * num_disp; n++) + { fc3[i_atoms][k][l][m] += - inv_U[k * num_site_sym * num_disp + n] - * rot_delta_fc2s[n][l][m]; + inv_U[k * num_site_sym * num_disp + n] * rot_delta_fc2s[n][l][m]; } } } @@ -160,9 +163,12 @@ void fc3_set_permutation_symmetry_fc3(double *fc3, const long num_atom) #ifdef PHPYOPENMP #pragma omp parallel for private(j, k, fc3_elem) #endif - for (i = 0; i < num_atom; i++) { - for (j = i; j < num_atom; j++) { - for (k = j; k < num_atom; k++) { + for (i = 0; i < num_atom; i++) + { + for (j = i; j < num_atom; j++) + { + for (k = j; k < num_atom; k++) + { set_permutation_symmetry_fc3_elem(fc3_elem, fc3, i, j, k, num_atom); copy_permutation_symmetry_fc3_elem(fc3, fc3_elem, i, j, k, num_atom); @@ -171,7 +177,7 @@ void fc3_set_permutation_symmetry_fc3(double *fc3, const long num_atom) } } -void fc3_set_permutation_symmetry_compact_fc3(double * fc3, +void fc3_set_permutation_symmetry_compact_fc3(double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], @@ -188,7 +194,7 @@ void fc3_set_permutation_symmetry_compact_fc3(double * fc3, n_patom); } -void fc3_transpose_compact_fc3(double * fc3, +void fc3_transpose_compact_fc3(double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], @@ -201,7 +207,8 @@ void fc3_transpose_compact_fc3(double * fc3, /* t_type=0: dim[0] <-> dim[1] */ /* t_type=1: dim[0] <-> dim[2] */ /* t_type=2: dim[1] <-> dim[2] */ - if (t_type == 0 || t_type == 1) { + if (t_type == 0 || t_type == 1) + { transpose_compact_fc3_type01(fc3, p2s, s2pp, @@ -210,8 +217,11 @@ void fc3_transpose_compact_fc3(double * fc3, n_satom, n_patom, t_type); - } else { - if (t_type == 2) { + } + else + { + if (t_type == 2) + { transpose_compact_fc3_type2(fc3, p2s, s2pp, @@ -235,12 +245,12 @@ static void rotate_delta_fc2s(double (*rot_delta_fc2s)[3][3], { long i, j; - for (i = 0; i < num_disp; i++) { - for (j = 0; j < num_site_sym; j++) { + for (i = 0; i < num_disp; i++) + { + for (j = 0; j < num_site_sym; j++) + { tensor2_rotation(rot_delta_fc2s[i * num_site_sym + j], - delta_fc2s[i * num_atom * num_atom - + rot_map_sym[j * num_atom + i_atom] * num_atom - + rot_map_sym[j * num_atom + j_atom]], + delta_fc2s[i * num_atom * num_atom + rot_map_sym[j * num_atom + i_atom] * num_atom + rot_map_sym[j * num_atom + j_atom]], site_sym_cart[j]); } } @@ -252,16 +262,22 @@ static void tensor2_rotation(double rot_tensor[3][3], { long i, j, k, l; - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { rot_tensor[i][j] = 0; } } - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { - for (k = 0; k < 3; k++) { - for (l = 0; l < 3; l++) { + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < 3; k++) + { + for (l = 0; l < 3; l++) + { rot_tensor[i][j] += r[i][k] * r[j][l] * tensor[k][l]; } } @@ -275,7 +291,8 @@ static void tensor3_rotation(double *rot_tensor, { long l; - for (l = 0; l < 27; l++) { + for (l = 0; l < 27; l++) + { rot_tensor[l] = tensor3_rotation_elem(tensor, rot_cartesian, l); } } @@ -292,11 +309,14 @@ static double tensor3_rotation_elem(const double *tensor, n = pos % 3; sum = 0.0; - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { - for (k = 0; k < 3; k++) { + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < 3; k++) + { sum += r[l * 3 + i] * r[m * 3 + j] * r[n * 3 + k] * - tensor[i * 9 + j * 3 + k]; + tensor[i * 9 + j * 3 + k]; } } } @@ -312,33 +332,36 @@ static void copy_permutation_symmetry_fc3_elem(double *fc3, { long i, j, k; - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { - for (k = 0; k < 3; k++) { + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < 3; k++) + { fc3[a * num_atom * num_atom * 27 + b * num_atom * 27 + c * 27 + i * 9 + j * 3 + k] = - fc3_elem[i * 9 + j * 3 + k]; + fc3_elem[i * 9 + j * 3 + k]; fc3[a * num_atom * num_atom * 27 + c * num_atom * 27 + b * 27 + i * 9 + k * 3 + j] = - fc3_elem[i * 9 + j * 3 + k]; + fc3_elem[i * 9 + j * 3 + k]; fc3[b * num_atom * num_atom * 27 + a * num_atom * 27 + c * 27 + j * 9 + i * 3 + k] = - fc3_elem[i * 9 + j * 3 + k]; + fc3_elem[i * 9 + j * 3 + k]; fc3[b * num_atom * num_atom * 27 + c * num_atom * 27 + a * 27 + j * 9 + k * 3 + i] = - fc3_elem[i * 9 + j * 3 + k]; + fc3_elem[i * 9 + j * 3 + k]; fc3[c * num_atom * num_atom * 27 + a * num_atom * 27 + b * 27 + k * 9 + i * 3 + j] = - fc3_elem[i * 9 + j * 3 + k]; + fc3_elem[i * 9 + j * 3 + k]; fc3[c * num_atom * num_atom * 27 + b * num_atom * 27 + a * 27 + k * 9 + j * 3 + i] = - fc3_elem[i * 9 + j * 3 + k]; + fc3_elem[i * 9 + j * 3 + k]; } } } @@ -353,34 +376,38 @@ static void set_permutation_symmetry_fc3_elem(double *fc3_elem, { long i, j, k; - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { - for (k = 0; k < 3; k++) { + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < 3; k++) + { fc3_elem[i * 9 + j * 3 + k] = - (fc3[a * num_atom * num_atom * 27 + - b * num_atom * 27 + - c * 27 + i * 9 + j * 3 + k] + - fc3[a * num_atom * num_atom * 27 + - c * num_atom * 27 + - b * 27 + i * 9 + k * 3 + j] + - fc3[b * num_atom * num_atom * 27 + - a * num_atom * 27 + - c * 27 + j * 9 + i * 3 + k] + - fc3[b * num_atom * num_atom * 27 + - c * num_atom * 27 + - a * 27 + j * 9 + k * 3 + i] + - fc3[c * num_atom * num_atom * 27 + - a * num_atom * 27 + - b * 27 + k * 9 + i * 3 + j] + - fc3[c * num_atom * num_atom * 27 + - b * num_atom * 27 + - a * 27 + k * 9 + j * 3 + i]) / 6; + (fc3[a * num_atom * num_atom * 27 + + b * num_atom * 27 + + c * 27 + i * 9 + j * 3 + k] + + fc3[a * num_atom * num_atom * 27 + + c * num_atom * 27 + + b * 27 + i * 9 + k * 3 + j] + + fc3[b * num_atom * num_atom * 27 + + a * num_atom * 27 + + c * 27 + j * 9 + i * 3 + k] + + fc3[b * num_atom * num_atom * 27 + + c * num_atom * 27 + + a * 27 + j * 9 + k * 3 + i] + + fc3[c * num_atom * num_atom * 27 + + a * num_atom * 27 + + b * 27 + k * 9 + i * 3 + j] + + fc3[c * num_atom * num_atom * 27 + + b * num_atom * 27 + + a * 27 + k * 9 + j * 3 + i]) / + 6; } } } } -static void set_permutation_symmetry_compact_fc3(double * fc3, +static void set_permutation_symmetry_compact_fc3(double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], @@ -400,17 +427,21 @@ static void set_permutation_symmetry_compact_fc3(double * fc3, char *done; done = NULL; - done = (char*)malloc(sizeof(char) * n_patom * n_satom * n_satom); - for (i = 0; i < n_patom * n_satom * n_satom; i++) { + done = (char *)malloc(sizeof(char) * n_patom * n_satom * n_satom); + for (i = 0; i < n_patom * n_satom * n_satom; i++) + { done[i] = 0; } - for (i_p = 0; i_p < n_patom; i_p++) { + for (i_p = 0; i_p < n_patom; i_p++) + { i = p2s[i_p]; - for (j = 0; j < n_satom; j++) { + for (j = 0; j < n_satom; j++) + { j_p = s2pp[j]; i_trans_j = perms[nsym_list[j] * n_satom + i]; - for (k = 0; k < n_satom; k++) { + for (k = 0; k < n_satom; k++) + { k_p = s2pp[k]; k_trans_j = perms[nsym_list[j] * n_satom + k]; i_trans_k = perms[nsym_list[k] * n_satom + i]; @@ -425,24 +456,31 @@ static void set_permutation_symmetry_compact_fc3(double * fc3, adrs[5] = k_p * n_satom * n_satom + j_trans_k * n_satom + i_trans_k; done_any = 0; - for (l = 0; l < 6; l++) { - if (done[adrs[l]]) { + for (l = 0; l < 6; l++) + { + if (done[adrs[l]]) + { done_any = 1; break; } } - if (done_any) { + if (done_any) + { continue; } - for (l = 0; l < 6; l++) { + for (l = 0; l < 6; l++) + { done[adrs[l]] = 1; adrs[l] *= 27; } - for (l = 0; l < 3; l++) { - for (m = 0; m < 3; m++) { - for (n = 0; n < 3; n++) { + for (l = 0; l < 3; l++) + { + for (m = 0; m < 3; m++) + { + for (n = 0; n < 3; n++) + { fc3_elem[l][m][n] = fc3[adrs[0] + l * 9 + m * 3 + n]; fc3_elem[l][m][n] += fc3[adrs[1] + l * 9 + n * 3 + m]; fc3_elem[l][m][n] += fc3[adrs[2] + m * 9 + l * 3 + n]; @@ -453,9 +491,12 @@ static void set_permutation_symmetry_compact_fc3(double * fc3, } } } - for (l = 0; l < 3; l++) { - for (m = 0; m < 3; m++) { - for (n = 0; n < 3; n++) { + for (l = 0; l < 3; l++) + { + for (m = 0; m < 3; m++) + { + for (n = 0; n < 3; n++) + { fc3[adrs[0] + l * 9 + m * 3 + n] = fc3_elem[l][m][n]; fc3[adrs[1] + l * 9 + n * 3 + m] = fc3_elem[l][m][n]; fc3[adrs[2] + m * 9 + l * 3 + n] = fc3_elem[l][m][n]; @@ -471,11 +512,9 @@ static void set_permutation_symmetry_compact_fc3(double * fc3, free(done); done = NULL; - - } -static void transpose_compact_fc3_type01(double * fc3, +static void transpose_compact_fc3_type01(double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], @@ -494,16 +533,20 @@ static void transpose_compact_fc3_type01(double * fc3, char *done; done = NULL; - done = (char*)malloc(sizeof(char) * n_satom * n_patom); - for (i = 0; i < n_satom * n_patom; i++) { + done = (char *)malloc(sizeof(char) * n_satom * n_patom); + for (i = 0; i < n_satom * n_patom; i++) + { done[i] = 0; } - for (i_p = 0; i_p < n_patom; i_p++) { + for (i_p = 0; i_p < n_patom; i_p++) + { i = p2s[i_p]; - for (j = 0; j < n_satom; j++) { + for (j = 0; j < n_satom; j++) + { j_p = s2pp[j]; - if (!done[i_p * n_satom + j]) { + if (!done[i_p * n_satom + j]) + { /* (j, i) -- nsym_list[j] --> (j', i') */ /* nsym_list[j] translates j to j' where j' is in */ /* primitive cell. The same translation sends i to i' */ @@ -512,32 +555,44 @@ static void transpose_compact_fc3_type01(double * fc3, i_trans = perms[nsym_list[j] * n_satom + i]; done[i_p * n_satom + j] = 1; done[j_p * n_satom + i_trans] = 1; - for (k = 0; k < n_satom; k++) { + for (k = 0; k < n_satom; k++) + { k_trans = perms[nsym_list[j] * n_satom + k]; - switch (t_type) { + switch (t_type) + { case 0: adrs = (i_p * n_satom * n_satom + j * n_satom + k) * 27; adrs_t = (j_p * n_satom * n_satom + i_trans * n_satom + k_trans) * 27; - for (l = 0; l < 3; l++) { - for (m = 0; m < 3; m++) { - for (n = 0; n < 3; n++) { + for (l = 0; l < 3; l++) + { + for (m = 0; m < 3; m++) + { + for (n = 0; n < 3; n++) + { fc3_elem[l][m][n] = fc3[adrs + l * 9 + m * 3 + n]; } } } - if (adrs != adrs_t) { - for (l = 0; l < 3; l++) { - for (m = 0; m < 3; m++) { - for (n = 0; n < 3; n++) { + if (adrs != adrs_t) + { + for (l = 0; l < 3; l++) + { + for (m = 0; m < 3; m++) + { + for (n = 0; n < 3; n++) + { fc3[adrs + l * 9 + m * 3 + n] = fc3[adrs_t + m * 9 + l * 3 + n]; } } } } - for (l = 0; l < 3; l++) { - for (m = 0; m < 3; m++) { - for (n = 0; n < 3; n++) { + for (l = 0; l < 3; l++) + { + for (m = 0; m < 3; m++) + { + for (n = 0; n < 3; n++) + { fc3[adrs_t + m * 9 + l * 3 + n] = fc3_elem[l][m][n]; } } @@ -546,32 +601,41 @@ static void transpose_compact_fc3_type01(double * fc3, case 1: adrs = (i_p * n_satom * n_satom + k * n_satom + j) * 27; adrs_t = (j_p * n_satom * n_satom + k_trans * n_satom + i_trans) * 27; - for (l = 0; l < 3; l++) { - for (m = 0; m < 3; m++) { - for (n = 0; n < 3; n++) { + for (l = 0; l < 3; l++) + { + for (m = 0; m < 3; m++) + { + for (n = 0; n < 3; n++) + { fc3_elem[l][m][n] = fc3[adrs + l * 9 + m * 3 + n]; } } } - if (adrs != adrs_t) { - for (l = 0; l < 3; l++) { - for (m = 0; m < 3; m++) { - for (n = 0; n < 3; n++) { + if (adrs != adrs_t) + { + for (l = 0; l < 3; l++) + { + for (m = 0; m < 3; m++) + { + for (n = 0; n < 3; n++) + { fc3[adrs + l * 9 + m * 3 + n] = fc3[adrs_t + n * 9 + m * 3 + l]; } } } } - for (l = 0; l < 3; l++) { - for (m = 0; m < 3; m++) { - for (n = 0; n < 3; n++) { + for (l = 0; l < 3; l++) + { + for (m = 0; m < 3; m++) + { + for (n = 0; n < 3; n++) + { fc3[adrs_t + n * 9 + m * 3 + l] = fc3_elem[l][m][n]; } } } break; } /* end switch */ - } } } @@ -581,7 +645,7 @@ static void transpose_compact_fc3_type01(double * fc3, done = NULL; } -static void transpose_compact_fc3_type2(double * fc3, +static void transpose_compact_fc3_type2(double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], @@ -593,30 +657,43 @@ static void transpose_compact_fc3_type2(double * fc3, long adrs, adrs_t; double fc3_elem[3][3][3]; - for (i_p = 0; i_p < n_patom; i_p++) { - for (j = 0; j < n_satom; j++) { - for (k = j; k < n_satom; k++) { /* k >= j */ + for (i_p = 0; i_p < n_patom; i_p++) + { + for (j = 0; j < n_satom; j++) + { + for (k = j; k < n_satom; k++) + { /* k >= j */ adrs = (i_p * n_satom * n_satom + j * n_satom + k) * 27; adrs_t = (i_p * n_satom * n_satom + k * n_satom + j) * 27; - for (l = 0; l < 3; l++) { - for (m = 0; m < 3; m++) { - for (n = 0; n < 3; n++) { + for (l = 0; l < 3; l++) + { + for (m = 0; m < 3; m++) + { + for (n = 0; n < 3; n++) + { fc3_elem[l][m][n] = fc3[adrs + l * 9 + m * 3 + n]; } } } - if (k != j) { - for (l = 0; l < 3; l++) { - for (m = 0; m < 3; m++) { - for (n = 0; n < 3; n++) { + if (k != j) + { + for (l = 0; l < 3; l++) + { + for (m = 0; m < 3; m++) + { + for (n = 0; n < 3; n++) + { fc3[adrs + l * 9 + m * 3 + n] = fc3[adrs_t + l * 9 + n * 3 + m]; } } } } - for (l = 0; l < 3; l++) { - for (m = 0; m < 3; m++) { - for (n = 0; n < 3; n++) { + for (l = 0; l < 3; l++) + { + for (m = 0; m < 3; m++) + { + for (n = 0; n < 3; n++) + { fc3[adrs_t + l * 9 + n * 3 + m] = fc3_elem[l][m][n]; } } diff --git a/c/fc3.h b/c/fc3.h index c161d966..90c1ad03 100644 --- a/c/fc3.h +++ b/c/fc3.h @@ -50,14 +50,14 @@ void fc3_rotate_delta_fc2(double (*fc3)[3][3][3], const long num_site_sym, const long num_disp); void fc3_set_permutation_symmetry_fc3(double *fc3, const long num_atom); -void fc3_set_permutation_symmetry_compact_fc3(double * fc3, +void fc3_set_permutation_symmetry_compact_fc3(double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], const long perms[], const long n_satom, const long n_patom); -void fc3_transpose_compact_fc3(double * fc3, +void fc3_transpose_compact_fc3(double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], diff --git a/c/grgrid.c b/c/grgrid.c index 21f7c7e0..6f3b2877 100644 --- a/c/grgrid.c +++ b/c/grgrid.c @@ -68,7 +68,6 @@ static void get_ir_grid_map(long *ir_grid_map, const long D_diag[3], const long PS[3]); - long grg_get_snf3x3(long D_diag[3], long P[3][3], long Q[3][3], @@ -79,18 +78,22 @@ long grg_get_snf3x3(long D_diag[3], succeeded = 0; - if (lagmat_get_determinant_l3(A) == 0) { + if (lagmat_get_determinant_l3(A) == 0) + { goto err; } - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { D[i][j] = A[i][j]; } } succeeded = snf3x3(D, P, Q); - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { D_diag[i] = D[i][i]; } @@ -122,16 +125,20 @@ long grg_transform_rotations(long (*transformed_rots)[3][3], /* 2. Compute D(Q^-1)RQ */ /* 3. Compute D(Q^-1)RQ(D^-1) */ lagmat_cast_matrix_3l_to_3d(Q_double, Q); - for (i = 0; i < num_rot; i++) { + for (i = 0; i < num_rot; i++) + { lagmat_get_similar_matrix_ld3(r, rotations[i], Q_double, 0); - for (j = 0; j < 3; j++) { - for (k = 0; k < 3; k++) { + for (j = 0; j < 3; j++) + { + for (k = 0; k < 3; k++) + { r[j][k] *= D_diag[j]; r[j][k] /= D_diag[k]; } } lagmat_cast_matrix_3d_to_3l(transformed_rots[i], r); - if (!lagmat_check_identity_matrix_ld3(transformed_rots[i], r, IDENTITY_TOL)) { + if (!lagmat_check_identity_matrix_ld3(transformed_rots[i], r, IDENTITY_TOL)) + { return 0; } } @@ -218,7 +225,6 @@ void grg_get_grid_address_from_index(long address[3], get_grid_address_from_index(address, grid_index, D_diag); } - /* ---------------------------*/ /* Rotate grid point by index */ /* ---------------------------*/ @@ -263,49 +269,59 @@ long grg_get_reciprocal_point_group(long rec_rotations[48][3][3], { long i, j, num_rot_ret, inv_exist; const long inversion[3][3] = { - {-1, 0, 0 }, - { 0,-1, 0 }, - { 0, 0,-1 } - }; + {-1, 0, 0}, + {0, -1, 0}, + {0, 0, -1}}; /* Collect unique rotations */ num_rot_ret = 0; - for (i = 0; i < num_rot; i++) { - for (j = 0; j < num_rot_ret; j++) { - if (lagmat_check_identity_matrix_l3(rotations[i], rec_rotations[j])) { + for (i = 0; i < num_rot; i++) + { + for (j = 0; j < num_rot_ret; j++) + { + if (lagmat_check_identity_matrix_l3(rotations[i], rec_rotations[j])) + { goto escape; } } - if (num_rot_ret == 48) { + if (num_rot_ret == 48) + { goto err; } lagmat_copy_matrix_l3(rec_rotations[num_rot_ret], rotations[i]); num_rot_ret++; - escape: - ; + escape:; } - if (is_transpose) { - for (i = 0; i < num_rot_ret; i++) { + if (is_transpose) + { + for (i = 0; i < num_rot_ret; i++) + { lagmat_transpose_matrix_l3(rec_rotations[i], rec_rotations[i]); } } - if (is_time_reversal) { + if (is_time_reversal) + { inv_exist = 0; - for (i = 0; i < num_rot_ret; i++) { - if (lagmat_check_identity_matrix_l3(inversion, rec_rotations[i])) { + for (i = 0; i < num_rot_ret; i++) + { + if (lagmat_check_identity_matrix_l3(inversion, rec_rotations[i])) + { inv_exist = 1; break; } } - if (!inv_exist) { - if (num_rot_ret > 24) { + if (!inv_exist) + { + if (num_rot_ret > 24) + { goto err; } - for (i = 0; i < num_rot_ret; i++) { + for (i = 0; i < num_rot_ret; i++) + { lagmat_multiply_matrix_l3(rec_rotations[num_rot_ret + i], inversion, rec_rotations[i]); } @@ -318,17 +334,16 @@ err: return 0; } - static void reduce_grid_address(long address[3], const long D_diag[3]) { long i; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { address[i] = lagmat_modulo_l(address[i], D_diag[i]); } } - static long get_double_grid_index(const long address_double[3], const long D_diag[3], const long PS[3]) @@ -348,11 +363,9 @@ static long get_grid_index_from_address(const long address[3], const long D_diag[3]) { #ifndef GRID_ORDER_XYZ - return (address[2] * D_diag[0] * D_diag[1] - + address[1] * D_diag[0] + address[0]); + return (address[2] * D_diag[0] * D_diag[1] + address[1] * D_diag[0] + address[0]); #else - return (address[0] * D_diag[1] * D_diag[2] - + address[1] * D_diag[2] + address[2]); + return (address[0] * D_diag[1] * D_diag[2] + address[1] * D_diag[2] + address[2]); #endif } @@ -362,11 +375,14 @@ static void get_all_grid_addresses(long grid_address[][3], long i, j, k, grid_index; long address[3]; - for (i = 0; i < D_diag[0]; i++) { + for (i = 0; i < D_diag[0]; i++) + { address[0] = i; - for (j = 0; j < D_diag[1]; j++) { + for (j = 0; j < D_diag[1]; j++) + { address[1] = j; - for (k = 0; k < D_diag[2]; k++) { + for (k = 0; k < D_diag[2]; k++) + { address[2] = k; grid_index = get_grid_index_from_address(address, D_diag); lagmat_copy_vector_l3(grid_address[grid_index], address); @@ -403,7 +419,8 @@ static void get_grid_address(long address[3], { long i; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { address[i] = (address_double[i] - PS[i]) / 2; } } @@ -416,7 +433,8 @@ static void get_double_grid_address(long address_double[3], { long i; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { address_double[i] = address[i] * 2 + PS[i]; } } @@ -448,23 +466,27 @@ static void get_ir_grid_map(long *ir_grid_map, num_gp = D_diag[0] * D_diag[1] * D_diag[2]; - for (gp = 0; gp < num_gp; gp++) { + for (gp = 0; gp < num_gp; gp++) + { ir_grid_map[gp] = num_gp; } /* Do not simply multithreaded this for-loop. */ /* This algorithm contains race condition in different gp's. */ - for (gp = 0; gp < num_gp; gp++) { - for (i = 0; i < num_rot; i++) { + for (gp = 0; gp < num_gp; gp++) + { + for (i = 0; i < num_rot; i++) + { r_gp = rotate_grid_index(gp, rotations[i], D_diag, PS); - if (r_gp < gp) { + if (r_gp < gp) + { ir_grid_map[gp] = ir_grid_map[r_gp]; break; } } - if (ir_grid_map[gp] == num_gp) { + if (ir_grid_map[gp] == num_gp) + { ir_grid_map[gp] = gp; } } - } diff --git a/c/gridsys.c b/c/gridsys.c index c9891913..1d28e77c 100644 --- a/c/gridsys.c +++ b/c/gridsys.c @@ -50,7 +50,6 @@ void gridsys_get_all_grid_addresses(long (*gr_grid_addresses)[3], grg_get_all_grid_addresses(gr_grid_addresses, D_diag); } - void gridsys_get_double_grid_address(long address_double[3], const long address[3], const long PS[3]) @@ -58,7 +57,6 @@ void gridsys_get_double_grid_address(long address_double[3], grg_get_double_grid_address(address_double, address, PS); } - void gridsys_get_grid_address_from_index(long address[3], const long grid_index, const long D_diag[3]) @@ -66,7 +64,6 @@ void gridsys_get_grid_address_from_index(long address[3], grg_get_grid_address_from_index(address, grid_index, D_diag); } - long gridsys_get_double_grid_index(const long address_double[3], const long D_diag[3], const long PS[3]) @@ -74,7 +71,6 @@ long gridsys_get_double_grid_index(const long address_double[3], return grg_get_double_grid_index(address_double, D_diag, PS); } - /* From single address to grid index */ long gridsys_get_grid_index_from_address(const long address[3], const long D_diag[3]) @@ -82,7 +78,6 @@ long gridsys_get_grid_index_from_address(const long address[3], return grg_get_grid_index(address, D_diag); } - long gridsys_rotate_grid_index(const long grid_index, const long rotation[3][3], const long D_diag[3], @@ -103,7 +98,6 @@ long gridsys_get_reciprocal_point_group(long rec_rotations[48][3][3], 1); } - long gridsys_get_snf3x3(long D_diag[3], long P[3][3], long Q[3][3], @@ -112,7 +106,6 @@ long gridsys_get_snf3x3(long D_diag[3], return grg_get_snf3x3(D_diag, P, Q, A); } - /* Rotation matrices with respect to reciprocal basis vectors are * transformed to those for GRGrid. This set of the rotations are * used always in GRGrid handling. */ @@ -131,7 +124,6 @@ long gridsys_transform_rotations(long (*transformed_rots)[3][3], return succeeded; } - double gridsys_get_thm_integration_weight(const double omega, const double tetrahedra_omegas[24][4], const char function) @@ -139,7 +131,6 @@ double gridsys_get_thm_integration_weight(const double omega, return thm_get_integration_weight(omega, tetrahedra_omegas, function); } - /* Get one dataset of relative grid address used for tetrahedron */ /* method. rec_lattice is used to choose the one. */ /* rec_lattice : microzone basis vectors in column vectors */ @@ -149,7 +140,6 @@ void gridsys_get_thm_relative_grid_address(long relative_grid_addresses[24][4][3 thm_get_relative_grid_address(relative_grid_addresses, rec_lattice); } - /* The rotations are those after proper transformation in GRGrid. */ void gridsys_get_ir_grid_map(long *ir_grid_map, const long (*rotations)[3][3], @@ -160,7 +150,6 @@ void gridsys_get_ir_grid_map(long *ir_grid_map, grg_get_ir_grid_map(ir_grid_map, rotations, num_rot, D_diag, PS); } - /* Find shortest grid points from Gamma considering periodicity of */ /* reciprocal lattice. See the details in docstring of BZGrid. */ /* */ @@ -196,7 +185,8 @@ long gridsys_get_bz_grid_addresses(long (*bz_grid_addresses)[3], BZGrid *bzgrid; long i, j, size; - if ((bzgrid = (BZGrid*) malloc(sizeof(BZGrid))) == NULL) { + if ((bzgrid = (BZGrid *)malloc(sizeof(BZGrid))) == NULL) + { warning_print("Memory could not be allocated."); return 0; } @@ -205,18 +195,23 @@ long gridsys_get_bz_grid_addresses(long (*bz_grid_addresses)[3], bzgrid->gp_map = bz_map; bzgrid->bzg2grg = bzg2grg; bzgrid->type = type; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { bzgrid->D_diag[i] = D_diag[i]; bzgrid->PS[i] = PS[i]; - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { bzgrid->Q[i][j] = Q[i][j]; bzgrid->reclat[i][j] = rec_lattice[i][j]; } } - if (bzg_get_bz_grid_addresses(bzgrid)) { + if (bzg_get_bz_grid_addresses(bzgrid)) + { size = bzgrid->size; - } else { + } + else + { size = 0; } @@ -226,7 +221,6 @@ long gridsys_get_bz_grid_addresses(long (*bz_grid_addresses)[3], return size; } - long gridsys_get_triplets_at_q(long *map_triplets, long *map_q, const long grid_point, @@ -246,7 +240,6 @@ long gridsys_get_triplets_at_q(long *map_triplets, swappable); } - long gridsys_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point, const long (*bz_grid_addresses)[3], @@ -260,7 +253,8 @@ long gridsys_get_BZ_triplets_at_q(long (*triplets)[3], ConstBZGrid *bzgrid; long i, j, num_ir; - if ((bzgrid = (ConstBZGrid*) malloc(sizeof(ConstBZGrid))) == NULL) { + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) + { warning_print("Memory could not be allocated."); return 0; } @@ -268,10 +262,12 @@ long gridsys_get_BZ_triplets_at_q(long (*triplets)[3], bzgrid->addresses = bz_grid_addresses; bzgrid->gp_map = bz_map; bzgrid->type = bz_grid_type; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { bzgrid->D_diag[i] = D_diag[i]; bzgrid->PS[i] = 0; - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { bzgrid->Q[i][j] = Q[i][j]; } } @@ -312,7 +308,8 @@ long gridsys_get_integration_weight(double *iw, ConstBZGrid *bzgrid; long i; - if ((bzgrid = (ConstBZGrid*) malloc(sizeof(ConstBZGrid))) == NULL) { + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) + { warning_print("Memory could not be allocated."); return 0; } @@ -320,7 +317,8 @@ long gridsys_get_integration_weight(double *iw, bzgrid->addresses = bz_grid_addresses; bzgrid->gp_map = bz_map; bzgrid->type = bz_grid_type; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { bzgrid->D_diag[i] = D_diag[i]; } diff --git a/c/gridsys.h b/c/gridsys.h index fb9b0dba..2d78d742 100644 --- a/c/gridsys.h +++ b/c/gridsys.h @@ -36,104 +36,104 @@ #define __gridsys_H__ #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif -void gridsys_get_all_grid_addresses(long (*gr_grid_addresses)[3], - const long D_diag[3]); -void gridsys_get_double_grid_address(long address_double[3], - const long address[3], - const long PS[3]); -void gridsys_get_grid_address_from_index(long address[3], - const long grid_index, - const long D_diag[3]); -long gridsys_get_double_grid_index(const long address_double[3], + void gridsys_get_all_grid_addresses(long (*gr_grid_addresses)[3], + const long D_diag[3]); + void gridsys_get_double_grid_address(long address_double[3], + const long address[3], + const long PS[3]); + void gridsys_get_grid_address_from_index(long address[3], + const long grid_index, + const long D_diag[3]); + long gridsys_get_double_grid_index(const long address_double[3], + const long D_diag[3], + const long PS[3]); + long gridsys_get_grid_index_from_address(const long address[3], + const long D_diag[3]); + long gridsys_rotate_grid_index(const long grid_index, + const long rotation[3][3], const long D_diag[3], const long PS[3]); -long gridsys_get_grid_index_from_address(const long address[3], - const long D_diag[3]); -long gridsys_rotate_grid_index(const long grid_index, - const long rotation[3][3], - const long D_diag[3], - const long PS[3]); -long gridsys_get_reciprocal_point_group(long rec_rotations[48][3][3], - const long (*rotations)[3][3], - const long num_rot, - const long is_time_reversal); -long gridsys_get_snf3x3(long D_diag[3], - long P[3][3], - long Q[3][3], - const long A[3][3]); -long gridsys_transform_rotations(long (*transformed_rots)[3][3], + long gridsys_get_reciprocal_point_group(long rec_rotations[48][3][3], + const long (*rotations)[3][3], + const long num_rot, + const long is_time_reversal); + long gridsys_get_snf3x3(long D_diag[3], + long P[3][3], + long Q[3][3], + const long A[3][3]); + long gridsys_transform_rotations(long (*transformed_rots)[3][3], + const long (*rotations)[3][3], + const long num_rot, + const long D_diag[3], + const long Q[3][3]); + double gridsys_get_thm_integration_weight(const double omega, + const double tetrahedra_omegas[24][4], + const char function); + void gridsys_get_thm_relative_grid_address(long relative_grid_addresses[24][4][3], + const double rec_lattice[3][3]); + void gridsys_get_ir_grid_map(long *ir_grid_map, const long (*rotations)[3][3], const long num_rot, const long D_diag[3], - const long Q[3][3]); -double gridsys_get_thm_integration_weight(const double omega, - const double tetrahedra_omegas[24][4], - const char function); -void gridsys_get_thm_relative_grid_address(long relative_grid_addresses[24][4][3], - const double rec_lattice[3][3]); -void gridsys_get_ir_grid_map(long *ir_grid_map, - const long (*rotations)[3][3], - const long num_rot, - const long D_diag[3], - const long PS[3]); -long gridsys_get_bz_grid_addresses(long (*bz_grid_addresses)[3], - long *bz_map, - long *bzg2grg, + const long PS[3]); + long gridsys_get_bz_grid_addresses(long (*bz_grid_addresses)[3], + long *bz_map, + long *bzg2grg, + const long D_diag[3], + const long Q[3][3], + const long PS[3], + const double rec_lattice[3][3], + const long type); + long gridsys_get_triplets_at_q(long *map_triplets, + long *map_q, + const long grid_point, const long D_diag[3], - const long Q[3][3], - const long PS[3], - const double rec_lattice[3][3], - const long type); -long gridsys_get_triplets_at_q(long *map_triplets, - long *map_q, - const long grid_point, - const long D_diag[3], - const long is_time_reversal, - const long num_rot, - const long (*rec_rotations)[3][3], - const long swappable); -long gridsys_get_BZ_triplets_at_q(long (*triplets)[3], - const long grid_point, - const long (*bz_grid_addresses)[3], - const long *bz_map, - const long *map_triplets, - const long num_map_triplets, - const long D_diag[3], - const long Q[3][3], - const long bz_grid_type); -long gridsys_get_integration_weight(double *iw, - char *iw_zero, - const double *frequency_points, - const long num_band0, - const long relative_grid_address[24][4][3], - const long D_diag[3], - const long (*triplets)[3], - const long num_triplets, - const long (*bz_grid_addresses)[3], - const long *bz_map, - const long bz_grid_type, - const double *frequencies1, - const long num_band1, - const double *frequencies2, - const long num_band2, - const long tp_type, - const long openmp_per_triplets, - const long openmp_per_bands); -void gridsys_get_integration_weight_with_sigma(double *iw, - char *iw_zero, - const double sigma, - const double sigma_cutoff, - const double *frequency_points, - const long num_band0, - const long (*triplets)[3], - const long num_triplets, - const double *frequencies, - const long num_band, - const long tp_type); - + const long is_time_reversal, + const long num_rot, + const long (*rec_rotations)[3][3], + const long swappable); + long gridsys_get_BZ_triplets_at_q(long (*triplets)[3], + const long grid_point, + const long (*bz_grid_addresses)[3], + const long *bz_map, + const long *map_triplets, + const long num_map_triplets, + const long D_diag[3], + const long Q[3][3], + const long bz_grid_type); + long gridsys_get_integration_weight(double *iw, + char *iw_zero, + const double *frequency_points, + const long num_band0, + const long relative_grid_address[24][4][3], + const long D_diag[3], + const long (*triplets)[3], + const long num_triplets, + const long (*bz_grid_addresses)[3], + const long *bz_map, + const long bz_grid_type, + const double *frequencies1, + const long num_band1, + const double *frequencies2, + const long num_band2, + const long tp_type, + const long openmp_per_triplets, + const long openmp_per_bands); + void gridsys_get_integration_weight_with_sigma(double *iw, + char *iw_zero, + const double sigma, + const double sigma_cutoff, + const double *frequency_points, + const long num_band0, + const long (*triplets)[3], + const long num_triplets, + const double *frequencies, + const long num_band, + const long tp_type); #ifdef __cplusplus } diff --git a/c/imag_self_energy_with_g.c b/c/imag_self_energy_with_g.c index 142fed2d..1ff938d1 100644 --- a/c/imag_self_energy_with_g.c +++ b/c/imag_self_energy_with_g.c @@ -98,7 +98,7 @@ void ise_get_imag_self_energy_at_bands_with_g(double *imag_self_energy, { long i, j, num_triplets, num_band0, num_band, num_band_prod; long num_g_pos, g_index_dims, g_index_shift; - long (*g_pos)[4]; + long(*g_pos)[4]; double *ise; long at_a_frequency_point; @@ -109,14 +109,17 @@ void ise_get_imag_self_energy_at_bands_with_g(double *imag_self_energy, num_band0 = fc3_normal_squared->dims[1]; num_band = fc3_normal_squared->dims[2]; num_band_prod = num_band0 * num_band * num_band; - ise = (double*)malloc(sizeof(double) * num_triplets * num_band0); + ise = (double *)malloc(sizeof(double) * num_triplets * num_band0); - if (frequency_point_index < 0) { + if (frequency_point_index < 0) + { /* frequency_points == frequencies at bands */ at_a_frequency_point = 0; g_index_dims = num_band_prod; g_index_shift = 0; - } else { + } + else + { /* At an arbitrary frequency point. */ at_a_frequency_point = 1; g_index_dims = num_frequency_points * num_band * num_band; @@ -126,19 +129,23 @@ void ise_get_imag_self_energy_at_bands_with_g(double *imag_self_energy, #ifdef PHPYOPENMP #pragma omp parallel for private(num_g_pos, j, g_pos) #endif - for (i = 0; i < num_triplets; i++) { + for (i = 0; i < num_triplets; i++) + { g_pos = (long(*)[4])malloc(sizeof(long[4]) * num_band_prod); /* ise_set_g_pos only works for the case of frquency points at */ /* bands. For frequency sampling mode, g_zero is assumed all */ /* with the array shape of (num_triplets, num_band0, num_band, */ /* num_band). */ - if (at_a_frequency_point) { + if (at_a_frequency_point) + { num_g_pos = ise_set_g_pos_frequency_point( - g_pos, - num_band0, - num_band, - g_zero + i * g_index_dims + g_index_shift); - } else { + g_pos, + num_band0, + num_band, + g_zero + i * g_index_dims + g_index_shift); + } + else + { num_g_pos = ise_set_g_pos(g_pos, num_band0, num_band, @@ -146,33 +153,36 @@ void ise_get_imag_self_energy_at_bands_with_g(double *imag_self_energy, } ise_imag_self_energy_at_triplet( - ise + i * num_band0, - num_band0, - num_band, - fc3_normal_squared->data + i * num_band_prod, - frequencies, - triplets[i], - triplet_weights[i], - g + i * g_index_dims + g_index_shift, - g + (i + num_triplets) * g_index_dims + g_index_shift, - g_pos, - num_g_pos, - &temperature, - 1, - cutoff_frequency, - 0, - at_a_frequency_point); + ise + i * num_band0, + num_band0, + num_band, + fc3_normal_squared->data + i * num_band_prod, + frequencies, + triplets[i], + triplet_weights[i], + g + i * g_index_dims + g_index_shift, + g + (i + num_triplets) * g_index_dims + g_index_shift, + g_pos, + num_g_pos, + &temperature, + 1, + cutoff_frequency, + 0, + at_a_frequency_point); free(g_pos); g_pos = NULL; } - for (i = 0; i < num_band0; i++) { + for (i = 0; i < num_band0; i++) + { imag_self_energy[i] = 0; } - for (i = 0; i < num_triplets; i++) { - for (j = 0; j < num_band0; j++) { + for (i = 0; i < num_triplets; i++) + { + for (j = 0; j < num_band0; j++) + { imag_self_energy[j] += ise[i * num_band0 + j]; } } @@ -181,19 +191,18 @@ void ise_get_imag_self_energy_at_bands_with_g(double *imag_self_energy, ise = NULL; } -void ise_get_detailed_imag_self_energy_at_bands_with_g -(double *detailed_imag_self_energy, - double *imag_self_energy_N, - double *imag_self_energy_U, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const long (*bz_grid_addresses)[3], - const double *g, - const char *g_zero, - const double temperature, - const double cutoff_frequency) +void ise_get_detailed_imag_self_energy_at_bands_with_g(double *detailed_imag_self_energy, + double *imag_self_energy_N, + double *imag_self_energy_U, + const Darray *fc3_normal_squared, + const double *frequencies, + const long (*triplets)[3], + const long *triplet_weights, + const long (*bz_grid_addresses)[3], + const double *g, + const char *g_zero, + const double temperature, + const double cutoff_frequency) { double *ise; long i, j, num_triplets, num_band0, num_band, num_band_prod; @@ -207,46 +216,52 @@ void ise_get_detailed_imag_self_energy_at_bands_with_g num_band0 = fc3_normal_squared->dims[1]; num_band = fc3_normal_squared->dims[2]; num_band_prod = num_band0 * num_band * num_band; - ise = (double*)malloc(sizeof(double) * num_triplets * num_band0); + ise = (double *)malloc(sizeof(double) * num_triplets * num_band0); /* detailed_imag_self_energy has the same shape as fc3_normal_squared. */ #ifdef PHPYOPENMP #pragma omp parallel for #endif - for (i = 0; i < num_triplets; i++) { - detailed_imag_self_energy_at_triplet - (detailed_imag_self_energy + i * num_band_prod, - ise + i * num_band0, - num_band0, - num_band, - fc3_normal_squared->data + i * num_band_prod, - frequencies, - triplets[i], - g + i * num_band_prod, - g + (i + num_triplets) * num_band_prod, - g_zero + i * num_band_prod, - &temperature, - 1, - cutoff_frequency); + for (i = 0; i < num_triplets; i++) + { + detailed_imag_self_energy_at_triplet(detailed_imag_self_energy + i * num_band_prod, + ise + i * num_band0, + num_band0, + num_band, + fc3_normal_squared->data + i * num_band_prod, + frequencies, + triplets[i], + g + i * num_band_prod, + g + (i + num_triplets) * num_band_prod, + g_zero + i * num_band_prod, + &temperature, + 1, + cutoff_frequency); } - is_N = (long*)malloc(sizeof(long) * num_triplets); - for (i = 0; i < num_triplets; i++) { + is_N = (long *)malloc(sizeof(long) * num_triplets); + for (i = 0; i < num_triplets; i++) + { is_N[i] = tpl_is_N(triplets[i], bz_grid_addresses); } - for (i = 0; i < num_band0; i++) { + for (i = 0; i < num_band0; i++) + { N = 0; U = 0; -/* #ifdef PHPYOPENMP */ -/* #pragma omp parallel for private(ise_tmp) reduction(+:N,U) */ -/* #endif */ - for (j = 0; j < num_triplets; j++) { + /* #ifdef PHPYOPENMP */ + /* #pragma omp parallel for private(ise_tmp) reduction(+:N,U) */ + /* #endif */ + for (j = 0; j < num_triplets; j++) + { ise_tmp = ise[j * num_band0 + i] * triplet_weights[j]; - if (is_N[j]) { + if (is_N[j]) + { N += ise_tmp; - } else { + } + else + { U += ise_tmp; } } @@ -281,9 +296,10 @@ void ise_imag_self_energy_at_triplet(double *imag_self_energy, double *n1, *n2; long g_pos_3; - n1 = (double*)malloc(sizeof(double) * num_temps * num_band); - n2 = (double*)malloc(sizeof(double) * num_temps * num_band); - for (i = 0; i < num_temps; i++) { + n1 = (double *)malloc(sizeof(double) * num_temps * num_band); + n2 = (double *)malloc(sizeof(double) * num_temps * num_band); + for (i = 0; i < num_temps; i++) + { set_occupations(n1 + i * num_band, n2 + i * num_band, num_band, @@ -293,36 +309,50 @@ void ise_imag_self_energy_at_triplet(double *imag_self_energy, cutoff_frequency); } - for (i = 0; i < num_band0 * num_temps; i++) { + for (i = 0; i < num_band0 * num_temps; i++) + { imag_self_energy[i] = 0; } -/* Do not use OpenMP here!! */ -/* g_pos[i][0] takes value 0 <= x < num_band0 only, */ -/* which causes race condition. */ - for (i = 0; i < num_g_pos; i++) { - if (at_a_frequency_point) { + /* Do not use OpenMP here!! */ + /* g_pos[i][0] takes value 0 <= x < num_band0 only, */ + /* which causes race condition. */ + for (i = 0; i < num_g_pos; i++) + { + if (at_a_frequency_point) + { /* At an arbitrary frequency point */ g_pos_3 = g_pos[i][3] % (num_band * num_band); - } else { + } + else + { /* frequency_points == frequencies at bands */ g_pos_3 = g_pos[i][3]; } - for (j = 0; j < num_temps; j++) { + for (j = 0; j < num_temps; j++) + { if (n1[j * num_band + g_pos[i][1]] < 0 || - n2[j * num_band + g_pos[i][2]] < 0) { + n2[j * num_band + g_pos[i][2]] < 0) + { ; - } else { - if (temperatures[j] > 0) { + } + else + { + if (temperatures[j] > 0) + { imag_self_energy[j * num_band0 + g_pos[i][0]] += - ((n1[j * num_band + g_pos[i][1]] + - n2[j * num_band + g_pos[i][2]] + 1) * g1[g_pos_3] + - (n1[j * num_band + g_pos[i][1]] - - n2[j * num_band + g_pos[i][2]]) * g2_3[g_pos_3]) * - fc3_normal_squared[g_pos[i][3]] * triplet_weight; - } else { + ((n1[j * num_band + g_pos[i][1]] + + n2[j * num_band + g_pos[i][2]] + 1) * + g1[g_pos_3] + + (n1[j * num_band + g_pos[i][1]] - + n2[j * num_band + g_pos[i][2]]) * + g2_3[g_pos_3]) * + fc3_normal_squared[g_pos[i][3]] * triplet_weight; + } + else + { imag_self_energy[j * num_band0 + g_pos[i][0]] += - g1[g_pos_3] * fc3_normal_squared[g_pos[i][3]] * triplet_weight; + g1[g_pos_3] * fc3_normal_squared[g_pos[i][3]] * triplet_weight; } } } @@ -343,10 +373,14 @@ long ise_set_g_pos(long (*g_pos)[4], num_g_pos = 0; jkl = 0; - for (j = 0; j < num_band0; j++) { - for (k = 0; k < num_band; k++) { - for (l = 0; l < num_band; l++) { - if (!g_zero[jkl]) { + for (j = 0; j < num_band0; j++) + { + for (k = 0; k < num_band; k++) + { + for (l = 0; l < num_band; l++) + { + if (!g_zero[jkl]) + { g_pos[num_g_pos][0] = j; g_pos[num_g_pos][1] = k; g_pos[num_g_pos][2] = l; @@ -369,11 +403,15 @@ static long ise_set_g_pos_frequency_point(long (*g_pos)[4], num_g_pos = 0; jkl = 0; - for (j = 0; j < num_band0; j++) { + for (j = 0; j < num_band0; j++) + { kl = 0; - for (k = 0; k < num_band; k++) { - for (l = 0; l < num_band; l++) { - if (!g_zero[kl]) { + for (k = 0; k < num_band; k++) + { + for (l = 0; l < num_band; l++) + { + if (!g_zero[kl]) + { g_pos[num_g_pos][0] = j; g_pos[num_g_pos][1] = k; g_pos[num_g_pos][2] = l; @@ -409,10 +447,11 @@ detailed_imag_self_energy_at_triplet(double *detailed_imag_self_energy, n1 = NULL; n2 = NULL; - n1 = (double*)malloc(sizeof(double) * num_band); - n2 = (double*)malloc(sizeof(double) * num_band); + n1 = (double *)malloc(sizeof(double) * num_band); + n2 = (double *)malloc(sizeof(double) * num_band); - for (i = 0; i < num_temps; i++) { + for (i = 0; i < num_temps; i++) + { set_occupations(n1, n2, num_band, @@ -421,29 +460,31 @@ detailed_imag_self_energy_at_triplet(double *detailed_imag_self_energy, frequencies, cutoff_frequency); - for (j = 0; j < num_band0; j++) { + for (j = 0; j < num_band0; j++) + { adrs_shift = j * num_band * num_band; - if (temperatures[i] > 0) { + if (temperatures[i] > 0) + { imag_self_energy[i * num_band0 + j] = - collect_detailed_imag_self_energy - (detailed_imag_self_energy + adrs_shift, - num_band, - fc3_normal_squared + adrs_shift, - n1, - n2, - g1 + adrs_shift, - g2_3 + adrs_shift, - g_zero + adrs_shift); - } else { + collect_detailed_imag_self_energy(detailed_imag_self_energy + adrs_shift, + num_band, + fc3_normal_squared + adrs_shift, + n1, + n2, + g1 + adrs_shift, + g2_3 + adrs_shift, + g_zero + adrs_shift); + } + else + { imag_self_energy[i * num_band0 + j] = - collect_detailed_imag_self_energy_0K - (detailed_imag_self_energy + adrs_shift, - num_band, - fc3_normal_squared + adrs_shift, - n1, - n2, - g1 + adrs_shift, - g_zero + adrs_shift); + collect_detailed_imag_self_energy_0K(detailed_imag_self_energy + adrs_shift, + num_band, + fc3_normal_squared + adrs_shift, + n1, + n2, + g1 + adrs_shift, + g_zero + adrs_shift); } } } @@ -468,12 +509,19 @@ collect_detailed_imag_self_energy(double *imag_self_energy, double sum_g; sum_g = 0; - for (ij = 0; ij < num_band * num_band; ij++) { + for (ij = 0; ij < num_band * num_band; ij++) + { imag_self_energy[ij] = 0; - if (g_zero[ij]) {continue;} + if (g_zero[ij]) + { + continue; + } i = ij / num_band; j = ij % num_band; - if (n1[i] < 0 || n2[j] < 0) {continue;} + if (n1[i] < 0 || n2[j] < 0) + { + continue; + } imag_self_energy[ij] = (((n1[i] + n2[j] + 1) * g1[ij] + (n1[i] - n2[j]) * g2_3[ij]) * fc3_normal_squared[ij]); @@ -496,12 +544,19 @@ collect_detailed_imag_self_energy_0K(double *imag_self_energy, double sum_g; sum_g = 0; - for (ij = 0; ij < num_band * num_band; ij++) { + for (ij = 0; ij < num_band * num_band; ij++) + { imag_self_energy[ij] = 0; - if (g_zero[ij]) {continue;} + if (g_zero[ij]) + { + continue; + } i = ij / num_band; j = ij % num_band; - if (n1[i] < 0 || n2[j] < 0) {continue;} + if (n1[i] < 0 || n2[j] < 0) + { + continue; + } imag_self_energy[ij] = g1[ij] * fc3_normal_squared[ij]; sum_g += imag_self_energy[ij]; } @@ -520,17 +575,24 @@ static void set_occupations(double *n1, long j; double f1, f2; - for (j = 0; j < num_band; j++) { + for (j = 0; j < num_band; j++) + { f1 = frequencies[triplet[1] * num_band + j]; f2 = frequencies[triplet[2] * num_band + j]; - if (f1 > cutoff_frequency) { + if (f1 > cutoff_frequency) + { n1[j] = phonoc_bose_einstein(f1, temperature); - } else { + } + else + { n1[j] = -1; } - if (f2 > cutoff_frequency) { + if (f2 > cutoff_frequency) + { n2[j] = phonoc_bose_einstein(f2, temperature); - } else { + } + else + { n2[j] = -1; } } diff --git a/c/imag_self_energy_with_g.h b/c/imag_self_energy_with_g.h index fc6df326..57e6a480 100644 --- a/c/imag_self_energy_with_g.h +++ b/c/imag_self_energy_with_g.h @@ -49,19 +49,18 @@ void ise_get_imag_self_energy_at_bands_with_g(double *imag_self_energy, const double cutoff_frequency, const long num_frequency_points, const long frequency_point_index); -void ise_get_detailed_imag_self_energy_at_bands_with_g -(double *detailed_imag_self_energy, - double *imag_self_energy_N, - double *imag_self_energy_U, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const long (*bz_grid_addresses)[3], - const double *g, - const char *g_zero, - const double temperature, - const double cutoff_frequency); +void ise_get_detailed_imag_self_energy_at_bands_with_g(double *detailed_imag_self_energy, + double *imag_self_energy_N, + double *imag_self_energy_U, + const Darray *fc3_normal_squared, + const double *frequencies, + const long (*triplets)[3], + const long *triplet_weights, + const long (*bz_grid_addresses)[3], + const double *g, + const char *g_zero, + const double temperature, + const double cutoff_frequency); void ise_imag_self_energy_at_triplet(double *imag_self_energy, const long num_band0, const long num_band, diff --git a/c/isotope.c b/c/isotope.c index 9f65320b..38784673 100644 --- a/c/isotope.c +++ b/c/isotope.c @@ -38,68 +38,74 @@ #include "isotope.h" #include "lapack_wrapper.h" -void -iso_get_isotope_scattering_strength(double *gamma, - const long grid_point, - 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_isotope_scattering_strength(double *gamma, + const long grid_point, + const double *mass_variances, + const double *frequencies, + const lapack_complex_double *eigenvectors, + const long num_grid_points, + const long *band_indices, + const long num_band, + const long num_band0, + const double sigma, + const double cutoff_frequency) { long i, j, k, l, m; double *e0_r, *e0_i, e1_r, e1_i, a, b, f, *f0, dist, sum_g, sum_g_k; - e0_r = (double*)malloc(sizeof(double) * num_band * num_band0); - e0_i = (double*)malloc(sizeof(double) * num_band * num_band0); - f0 = (double*)malloc(sizeof(double) * num_band0); + e0_r = (double *)malloc(sizeof(double) * num_band * num_band0); + e0_i = (double *)malloc(sizeof(double) * num_band * num_band0); + f0 = (double *)malloc(sizeof(double) * num_band0); - for (i = 0; i < num_band0; i++) { + for (i = 0; i < num_band0; i++) + { f0[i] = frequencies[grid_point * num_band + band_indices[i]]; - for (j = 0; j < num_band; j++) { - e0_r[i * num_band + j] = lapack_complex_double_real - (eigenvectors[grid_point * num_band * num_band + - j * num_band + band_indices[i]]); - e0_i[i * num_band + j] = lapack_complex_double_imag - (eigenvectors[grid_point * num_band * num_band + - j * num_band + band_indices[i]]); + for (j = 0; j < num_band; j++) + { + e0_r[i * num_band + j] = lapack_complex_double_real(eigenvectors[grid_point * num_band * num_band + + j * num_band + band_indices[i]]); + e0_i[i * num_band + j] = lapack_complex_double_imag(eigenvectors[grid_point * num_band * num_band + + j * num_band + band_indices[i]]); } } - for (i = 0; i < num_band0; i++) { + for (i = 0; i < num_band0; i++) + { gamma[i] = 0; } - for (i = 0; i < num_band0; i++) { /* band index0 */ - if (f0[i] < cutoff_frequency) { + for (i = 0; i < num_band0; i++) + { /* band index0 */ + if (f0[i] < cutoff_frequency) + { continue; } sum_g = 0; #ifdef PHPYOPENMP -#pragma omp parallel for private(k, l, m, f, e1_r, e1_i, a, b, dist, sum_g_k) reduction(+:sum_g) +#pragma omp parallel for private(k, l, m, f, e1_r, e1_i, a, b, dist, sum_g_k) reduction(+ \ + : sum_g) #endif - for (j = 0; j < num_grid_points; j++) { + for (j = 0; j < num_grid_points; j++) + { sum_g_k = 0; - for (k = 0; k < num_band; k++) { /* band index */ + for (k = 0; k < num_band; k++) + { /* band index */ f = frequencies[j * num_band + k]; - if (f < cutoff_frequency) { + if (f < cutoff_frequency) + { continue; } dist = phonoc_gaussian(f - f0[i], sigma); - for (l = 0; l < num_band / 3; l++) { /* elements */ + for (l = 0; l < num_band / 3; l++) + { /* elements */ a = 0; b = 0; - for (m = 0; m < 3; m++) { - e1_r = lapack_complex_double_real - (eigenvectors[j * num_band * num_band + - (l * 3 + m) * num_band + k]); - e1_i = lapack_complex_double_imag - (eigenvectors[j * num_band * num_band + - (l * 3 + m) * num_band + k]); + for (m = 0; m < 3; m++) + { + e1_r = lapack_complex_double_real(eigenvectors[j * num_band * num_band + + (l * 3 + m) * num_band + k]); + e1_i = lapack_complex_double_imag(eigenvectors[j * num_band * num_band + + (l * 3 + m) * num_band + k]); a += (e0_r[i * num_band + l * 3 + m] * e1_r + e0_i[i * num_band + l * 3 + m] * e1_i); b += (e0_i[i * num_band + l * 3 + m] * e1_r - @@ -113,7 +119,8 @@ iso_get_isotope_scattering_strength(double *gamma, gamma[i] = sum_g; } - for (i = 0; i < num_band0; i++) { + for (i = 0; i < num_band0; i++) + { /* Frequency unit to ang-freq: *(2pi)**2/(2pi) */ /* Ang-freq to freq unit (for lifetime): /2pi */ /* gamma = 1/2t */ @@ -128,76 +135,81 @@ iso_get_isotope_scattering_strength(double *gamma, e0_i = NULL; } -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 *frequencies, - const lapack_complex_double *eigenvectors, - const long num_grid_points, - const long *band_indices, - const long num_band, - const long num_band0, - const double *integration_weights, - const double cutoff_frequency) +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 *frequencies, + const lapack_complex_double *eigenvectors, + const long num_grid_points, + const long *band_indices, + const long num_band, + const long num_band0, + const double *integration_weights, + const double cutoff_frequency) { long i, j, k, l, m, gp; double *e0_r, *e0_i, *f0, *gamma_ij; double e1_r, e1_i, a, b, f, dist, sum_g_k; - e0_r = (double*)malloc(sizeof(double) * num_band * num_band0); - e0_i = (double*)malloc(sizeof(double) * num_band * num_band0); - f0 = (double*)malloc(sizeof(double) * num_band0); + e0_r = (double *)malloc(sizeof(double) * num_band * num_band0); + e0_i = (double *)malloc(sizeof(double) * num_band * num_band0); + f0 = (double *)malloc(sizeof(double) * num_band0); - for (i = 0; i < num_band0; i++) { + for (i = 0; i < num_band0; i++) + { f0[i] = frequencies[grid_point * num_band + band_indices[i]]; - for (j = 0; j < num_band; j++) { - e0_r[i * num_band + j] = lapack_complex_double_real - (eigenvectors[grid_point * num_band * num_band + - j * num_band + band_indices[i]]); - e0_i[i * num_band + j] = lapack_complex_double_imag - (eigenvectors[grid_point * num_band * num_band + - j * num_band + band_indices[i]]); + for (j = 0; j < num_band; j++) + { + e0_r[i * num_band + j] = lapack_complex_double_real(eigenvectors[grid_point * num_band * num_band + + j * num_band + band_indices[i]]); + e0_i[i * num_band + j] = lapack_complex_double_imag(eigenvectors[grid_point * num_band * num_band + + j * num_band + band_indices[i]]); } } - gamma_ij = (double*)malloc(sizeof(double) * num_grid_points * num_band0); + gamma_ij = (double *)malloc(sizeof(double) * num_grid_points * num_band0); #ifdef PHPYOPENMP #pragma omp parallel for #endif - for (i = 0; i < num_grid_points * num_band0; i++) { + for (i = 0; i < num_grid_points * num_band0; i++) + { gamma_ij[i] = 0; } #ifdef PHPYOPENMP #pragma omp parallel for private(j, k, l, m, f, gp, e1_r, e1_i, a, b, dist, sum_g_k) #endif - for (i = 0; i < num_grid_points; i++) { + for (i = 0; i < num_grid_points; i++) + { gp = ir_grid_points[i]; - for (j = 0; j < num_band0; j++) { /* band index0 */ - if (f0[j] < cutoff_frequency) { + for (j = 0; j < num_band0; j++) + { /* band index0 */ + if (f0[j] < cutoff_frequency) + { continue; } sum_g_k = 0; - for (k = 0; k < num_band; k++) { /* band index */ + for (k = 0; k < num_band; k++) + { /* band index */ f = frequencies[gp * num_band + k]; - if (f < cutoff_frequency) { + if (f < cutoff_frequency) + { continue; } dist = integration_weights[gp * num_band0 * num_band + j * num_band + k]; - for (l = 0; l < num_band / 3; l++) { /* elements */ + for (l = 0; l < num_band / 3; l++) + { /* elements */ a = 0; b = 0; - for (m = 0; m < 3; m++) { - e1_r = lapack_complex_double_real - (eigenvectors - [gp * num_band * num_band + (l * 3 + m) * num_band + k]); - e1_i = lapack_complex_double_imag - (eigenvectors - [gp * num_band * num_band + (l * 3 + m) * num_band + k]); + for (m = 0; m < 3; m++) + { + e1_r = lapack_complex_double_real(eigenvectors + [gp * num_band * num_band + (l * 3 + m) * num_band + k]); + e1_i = lapack_complex_double_imag(eigenvectors + [gp * num_band * num_band + (l * 3 + m) * num_band + k]); a += (e0_r[j * num_band + l * 3 + m] * e1_r + e0_i[j * num_band + l * 3 + m] * e1_i); b += (e0_i[j * num_band + l * 3 + m] * e1_r - @@ -210,18 +222,22 @@ void iso_get_thm_isotope_scattering_strength } } - for (i = 0; i < num_band0; i++) { + for (i = 0; i < num_band0; i++) + { gamma[i] = 0; } - for (i = 0; i < num_grid_points; i++) { + for (i = 0; i < num_grid_points; i++) + { gp = ir_grid_points[i]; - for (j = 0; j < num_band0; j++) { + for (j = 0; j < num_band0; j++) + { gamma[j] += gamma_ij[gp * num_band0 + j]; } } - for (i = 0; i < num_band0; i++) { + for (i = 0; i < num_band0; i++) + { /* Frequency unit to ang-freq: *(2pi)**2/(2pi) */ /* Ang-freq to freq unit (for lifetime): /2pi */ /* gamma = 1/2t */ diff --git a/c/isotope.h b/c/isotope.h index ccc4837b..3438bc03 100644 --- a/c/isotope.h +++ b/c/isotope.h @@ -37,30 +37,28 @@ #include "lapack_wrapper.h" -void -iso_get_isotope_scattering_strength(double *gamma, - const long grid_point, - 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 *frequencies, - const lapack_complex_double *eigenvectors, - const long num_grid_points, - const long *band_indices, - const long num_band, - const long num_band0, - const double *integration_weights, - const double cutoff_frequency); +void iso_get_isotope_scattering_strength(double *gamma, + const long grid_point, + 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 *frequencies, + const lapack_complex_double *eigenvectors, + const long num_grid_points, + const long *band_indices, + const long num_band, + const long num_band0, + const double *integration_weights, + const double cutoff_frequency); #endif diff --git a/c/lagrid.c b/c/lagrid.c index d64f3332..b463ae59 100644 --- a/c/lagrid.c +++ b/c/lagrid.c @@ -36,16 +36,12 @@ long lagmat_get_determinant_l3(const long a[3][3]) { - return a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) - + a[0][1] * (a[1][2] * a[2][0] - a[1][0] * a[2][2]) - + a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]); + return a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) + a[0][1] * (a[1][2] * a[2][0] - a[1][0] * a[2][2]) + a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]); } double lagmat_get_determinant_d3(const double a[3][3]) { - return a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) - + a[0][1] * (a[1][2] * a[2][0] - a[1][0] * a[2][2]) - + a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]); + return a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) + a[0][1] * (a[1][2] * a[2][0] - a[1][0] * a[2][2]) + a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]); } void lagmat_cast_matrix_3l_to_3d(double m[3][3], const long a[3][3]) @@ -80,7 +76,8 @@ long lagmat_get_similar_matrix_ld3(double m[3][3], const double precision) { double c[3][3]; - if (!lagmat_inverse_matrix_d3(c, b, precision)) { + if (!lagmat_inverse_matrix_d3(c, b, precision)) + { warning_print("No similar matrix due to 0 determinant.\n"); return 0; } @@ -100,10 +97,12 @@ long lagmat_check_identity_matrix_l3(const long a[3][3], a[1][2] - b[1][2] || a[2][0] - b[2][0] || a[2][1] - b[2][1] || - a[2][2] - b[2][2]) { + a[2][2] - b[2][2]) + { return 0; } - else { + else + { return 1; } } @@ -120,10 +119,12 @@ long lagmat_check_identity_matrix_ld3(const long a[3][3], lagmat_Dabs(a[1][2] - b[1][2]) > symprec || lagmat_Dabs(a[2][0] - b[2][0]) > symprec || lagmat_Dabs(a[2][1] - b[2][1]) > symprec || - lagmat_Dabs(a[2][2] - b[2][2]) > symprec) { + lagmat_Dabs(a[2][2] - b[2][2]) > symprec) + { return 0; } - else { + else + { return 1; } } @@ -135,7 +136,8 @@ long lagmat_inverse_matrix_d3(double m[3][3], double det; double c[3][3]; det = lagmat_get_determinant_d3(a); - if (lagmat_Dabs(det) < precision) { + if (lagmat_Dabs(det) < precision) + { warning_print("No inverse matrix (det=%f)\n", det); return 0; } @@ -174,10 +176,12 @@ void lagmat_multiply_matrix_vector_l3(long v[3], { long i; long c[3]; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { c[i] = a[i][0] * b[0] + a[i][1] * b[1] + a[i][2] * b[2]; } - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { v[i] = c[i]; } } @@ -186,12 +190,14 @@ void lagmat_multiply_matrix_l3(long m[3][3], const long a[3][3], const long b[3][3]) { - long i, j; /* a_ij */ + long i, j; /* a_ij */ long c[3][3]; - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { c[i][j] = - a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; + a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; } } lagmat_copy_matrix_l3(m, c); @@ -201,12 +207,14 @@ void lagmat_multiply_matrix_ld3(double m[3][3], const long a[3][3], const double b[3][3]) { - long i, j; /* a_ij */ + long i, j; /* a_ij */ double c[3][3]; - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { c[i][j] = - a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; + a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; } } lagmat_copy_matrix_d3(m, c); @@ -216,12 +224,14 @@ void lagmat_multiply_matrix_d3(double m[3][3], const double a[3][3], const double b[3][3]) { - long i, j; /* a_ij */ + long i, j; /* a_ij */ double c[3][3]; - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { c[i][j] = - a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; + a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; } } lagmat_copy_matrix_d3(m, c); @@ -264,7 +274,8 @@ long lagmat_modulo_l(const long a, const long b) { long c; c = a % b; - if (c < 0) { + if (c < 0) + { c += b; } return c; @@ -273,9 +284,9 @@ long lagmat_modulo_l(const long a, const long b) long lagmat_Nint(const double a) { if (a < 0.0) - return (long) (a - 0.5); + return (long)(a - 0.5); else - return (long) (a + 0.5); + return (long)(a + 0.5); } double lagmat_Dabs(const double a) diff --git a/c/lapack_wrapper.c b/c/lapack_wrapper.c index d84dea9c..1eaa3cea 100644 --- a/c/lapack_wrapper.c +++ b/c/lapack_wrapper.c @@ -34,20 +34,21 @@ #include "lapack_wrapper.h" -#define min(a,b) ((a)>(b)?(b):(a)) +#define min(a, b) ((a) > (b) ? (b) : (a)) #ifdef MKL_LAPACKE -MKL_Complex16 lapack_make_complex_double( double re, double im ) { +MKL_Complex16 lapack_make_complex_double(double re, double im) +{ MKL_Complex16 z; z.real = re; z.imag = im; return z; } #ifndef LAPACKE_malloc -#define LAPACKE_malloc( size ) malloc( size ) +#define LAPACKE_malloc(size) malloc(size) #endif #ifndef LAPACKE_free -#define LAPACKE_free( p ) free( p ) +#define LAPACKE_free(p) free(p) #endif #endif @@ -57,7 +58,7 @@ int phonopy_zheev(double *w, const char uplo) { lapack_int info; - info = LAPACKE_zheev(LAPACK_ROW_MAJOR,'V', uplo, + info = LAPACKE_zheev(LAPACK_ROW_MAJOR, 'V', uplo, (lapack_int)n, a, (lapack_int)n, w); return (int)info; } @@ -72,13 +73,14 @@ int phonopy_pinv(double *data_out, lapack_int info; double *s, *a, *u, *vt, *superb; - a = (double*)malloc(sizeof(double) * m * n); - s = (double*)malloc(sizeof(double) * min(m,n)); - u = (double*)malloc(sizeof(double) * m * m); - vt = (double*)malloc(sizeof(double) * n * n); - superb = (double*)malloc(sizeof(double) * (min(m,n) - 1)); + a = (double *)malloc(sizeof(double) * m * n); + s = (double *)malloc(sizeof(double) * min(m, n)); + u = (double *)malloc(sizeof(double) * m * m); + vt = (double *)malloc(sizeof(double) * n * n); + superb = (double *)malloc(sizeof(double) * (min(m, n) - 1)); - for (i = 0; i < m * n; i++) { + for (i = 0; i < m * n; i++) + { a[i] = data_in[i]; } @@ -96,14 +98,19 @@ int phonopy_pinv(double *data_out, (lapack_int)n, superb); - for (i = 0; i < n * m; i++) { + for (i = 0; i < n * m; i++) + { data_out[i] = 0; } - for (i = 0; i < m; i++) { - for (j = 0; j < n; j++) { - for (k = 0; k < min(m,n); k++) { - if (s[k] > cutoff) { + for (i = 0; i < m; i++) + { + for (j = 0; j < n; j++) + { + for (k = 0; k < min(m, n); k++) + { + if (s[k] > cutoff) + { data_out[j * m + i] += u[i * m + k] / s[k] * vt[k * n + j]; } } @@ -133,7 +140,8 @@ void phonopy_pinv_mt(double *data_out, #ifdef PHPYOPENMP #pragma omp parallel for #endif - for (i = 0; i < num_thread; i++) { + for (i = 0; i < num_thread; i++) + { info_out[i] = phonopy_pinv(data_out + i * max_row_num * column_num, data_in + i * max_row_num * column_num, row_nums[i], @@ -151,8 +159,8 @@ int phonopy_dsyev(double *data, lapack_int liwork; long lwork; - lapack_int* iwork; - double* work; + lapack_int *iwork; + double *work; lapack_int iwork_query; double work_query; @@ -162,7 +170,8 @@ int phonopy_dsyev(double *data, iwork = NULL; work = NULL; - switch (algorithm) { + switch (algorithm) + { case 0: /* dsyev */ info = LAPACKE_dsyev(LAPACK_COL_MAJOR, 'V', @@ -187,11 +196,12 @@ int phonopy_dsyev(double *data, liwork = iwork_query; lwork = (long)work_query; /* printf("liwork %d, lwork %ld\n", liwork, lwork); */ - if ((iwork = (lapack_int*)LAPACKE_malloc(sizeof(lapack_int) * liwork)) - == NULL) { + if ((iwork = (lapack_int *)LAPACKE_malloc(sizeof(lapack_int) * liwork)) == NULL) + { goto end; }; - if ((work = (double*)LAPACKE_malloc(sizeof(double) * lwork)) == NULL) { + if ((work = (double *)LAPACKE_malloc(sizeof(double) * lwork)) == NULL) + { goto end; } @@ -208,11 +218,13 @@ int phonopy_dsyev(double *data, liwork); end: - if (iwork) { + if (iwork) + { LAPACKE_free(iwork); iwork = NULL; } - if (work) { + if (work) + { LAPACKE_free(work); work = NULL; } @@ -230,16 +242,14 @@ int phonopy_dsyev(double *data, return (int)info; } - lapack_complex_double phonoc_complex_prod(const lapack_complex_double a, const lapack_complex_double b) { lapack_complex_double c; - c = lapack_make_complex_double - (lapack_complex_double_real(a) * lapack_complex_double_real(b) - - lapack_complex_double_imag(a) * lapack_complex_double_imag(b), - lapack_complex_double_imag(a) * lapack_complex_double_real(b) + - lapack_complex_double_real(a) * lapack_complex_double_imag(b)); + c = lapack_make_complex_double(lapack_complex_double_real(a) * lapack_complex_double_real(b) - + lapack_complex_double_imag(a) * lapack_complex_double_imag(b), + lapack_complex_double_imag(a) * lapack_complex_double_real(b) + + lapack_complex_double_real(a) * lapack_complex_double_imag(b)); return c; } diff --git a/c/phono3py.c b/c/phono3py.c index 842538b2..b1a15e3c 100644 --- a/c/phono3py.c +++ b/c/phono3py.c @@ -53,7 +53,6 @@ #include #include - long ph3py_get_interaction(Darray *fc3_normal_squared, const char *g_zero, const Darray *frequencies, @@ -78,16 +77,19 @@ long ph3py_get_interaction(Darray *fc3_normal_squared, ConstBZGrid *bzgrid; long i, j; - if ((bzgrid = (ConstBZGrid*) malloc(sizeof(ConstBZGrid))) == NULL) { + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) + { warning_print("Memory could not be allocated."); return 0; } bzgrid->addresses = bz_grid_addresses; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { bzgrid->D_diag[i] = D_diag[i]; bzgrid->PS[i] = 0; - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { bzgrid->Q[i][j] = Q[i][j]; } } @@ -116,7 +118,6 @@ long ph3py_get_interaction(Darray *fc3_normal_squared, return 1; } - long ph3py_get_pp_collision(double *imag_self_energy, const long relative_grid_address[24][4][3], /* thm */ const double *frequencies, @@ -125,7 +126,7 @@ long ph3py_get_pp_collision(double *imag_self_energy, const long num_triplets, const long *triplet_weights, const long (*bz_grid_addresses)[3], /* thm */ - const long *bz_map, /* thm */ + const long *bz_map, /* thm */ const long bz_grid_type, const long D_diag[3], const long Q[3][3], @@ -146,7 +147,8 @@ long ph3py_get_pp_collision(double *imag_self_energy, ConstBZGrid *bzgrid; long i, j; - if ((bzgrid = (ConstBZGrid*) malloc(sizeof(ConstBZGrid))) == NULL) { + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) + { warning_print("Memory could not be allocated."); return 0; } @@ -154,10 +156,12 @@ long ph3py_get_pp_collision(double *imag_self_energy, bzgrid->addresses = bz_grid_addresses; bzgrid->gp_map = bz_map; bzgrid->type = bz_grid_type; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { bzgrid->D_diag[i] = D_diag[i]; bzgrid->PS[i] = 0; - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { bzgrid->Q[i][j] = Q[i][j]; } } @@ -190,46 +194,48 @@ long ph3py_get_pp_collision(double *imag_self_energy, return 1; } - long ph3py_get_pp_collision_with_sigma( - double *imag_self_energy, - const double sigma, - const double sigma_cutoff, - const double *frequencies, - const lapack_complex_double *eigenvectors, - const long (*triplets)[3], - const long num_triplets, - const long *triplet_weights, - const long (*bz_grid_addresses)[3], - const long D_diag[3], - const long Q[3][3], - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const Larray *band_indices, - const Darray *temperatures, - const long is_NU, - const long symmetrize_fc3_q, - const double cutoff_frequency) + double *imag_self_energy, + const double sigma, + const double sigma_cutoff, + const double *frequencies, + const lapack_complex_double *eigenvectors, + const long (*triplets)[3], + const long num_triplets, + const long *triplet_weights, + const long (*bz_grid_addresses)[3], + const long D_diag[3], + const long Q[3][3], + const double *fc3, + const long is_compact_fc3, + const double (*svecs)[3], + const long multi_dims[2], + const long (*multiplicity)[2], + const double *masses, + const long *p2s_map, + const long *s2p_map, + const Larray *band_indices, + const Darray *temperatures, + const long is_NU, + const long symmetrize_fc3_q, + const double cutoff_frequency) { ConstBZGrid *bzgrid; long i, j; - if ((bzgrid = (ConstBZGrid*) malloc(sizeof(ConstBZGrid))) == NULL) { + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) + { warning_print("Memory could not be allocated."); return 0; } bzgrid->addresses = bz_grid_addresses; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { bzgrid->D_diag[i] = D_diag[i]; bzgrid->PS[i] = 0; - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { bzgrid->Q[i][j] = Q[i][j]; } } @@ -263,19 +269,18 @@ long ph3py_get_pp_collision_with_sigma( return 1; } - void ph3py_get_imag_self_energy_at_bands_with_g( - double *imag_self_energy, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double *g, - const char *g_zero, - const double temperature, - const double cutoff_frequency, - const long num_frequency_points, - const long frequency_point_index) + double *imag_self_energy, + const Darray *fc3_normal_squared, + const double *frequencies, + const long (*triplets)[3], + const long *triplet_weights, + const double *g, + const char *g_zero, + const double temperature, + const double cutoff_frequency, + const long num_frequency_points, + const long frequency_point_index) { ise_get_imag_self_energy_at_bands_with_g(imag_self_energy, fc3_normal_squared, @@ -290,20 +295,19 @@ void ph3py_get_imag_self_energy_at_bands_with_g( frequency_point_index); } - void ph3py_get_detailed_imag_self_energy_at_bands_with_g( - double *detailed_imag_self_energy, - double *imag_self_energy_N, - double *imag_self_energy_U, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const long (*bz_grid_addresses)[3], - const double *g, - const char *g_zero, - const double temperature, - const double cutoff_frequency) + double *detailed_imag_self_energy, + double *imag_self_energy_N, + double *imag_self_energy_U, + const Darray *fc3_normal_squared, + const double *frequencies, + const long (*triplets)[3], + const long *triplet_weights, + const long (*bz_grid_addresses)[3], + const double *g, + const char *g_zero, + const double temperature, + const double cutoff_frequency) { ise_get_detailed_imag_self_energy_at_bands_with_g(detailed_imag_self_energy, imag_self_energy_N, @@ -319,7 +323,6 @@ void ph3py_get_detailed_imag_self_energy_at_bands_with_g( cutoff_frequency); } - void ph3py_get_real_self_energy_at_bands(double *real_self_energy, const Darray *fc3_normal_squared, const long *band_indices, @@ -343,19 +346,18 @@ void ph3py_get_real_self_energy_at_bands(double *real_self_energy, cutoff_frequency); } - void ph3py_get_real_self_energy_at_frequency_point( - double *real_self_energy, - const double frequency_point, - const Darray *fc3_normal_squared, - const long *band_indices, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double epsilon, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency) + double *real_self_energy, + const double frequency_point, + const Darray *fc3_normal_squared, + const long *band_indices, + const double *frequencies, + const long (*triplets)[3], + const long *triplet_weights, + const double epsilon, + const double temperature, + const double unit_conversion_factor, + const double cutoff_frequency) { rse_get_real_self_energy_at_frequency_point(real_self_energy, frequency_point, @@ -370,7 +372,6 @@ void ph3py_get_real_self_energy_at_frequency_point( cutoff_frequency); } - void ph3py_get_collision_matrix(double *collision_matrix, const Darray *fc3_normal_squared, const double *frequencies, @@ -404,7 +405,6 @@ void ph3py_get_collision_matrix(double *collision_matrix, cutoff_frequency); } - void ph3py_get_reducible_collision_matrix(double *collision_matrix, const Darray *fc3_normal_squared, const double *frequencies, @@ -430,19 +430,18 @@ void ph3py_get_reducible_collision_matrix(double *collision_matrix, cutoff_frequency); } - void ph3py_get_isotope_scattering_strength( - double *gamma, - const long grid_point, - 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) + double *gamma, + const long grid_point, + 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) { iso_get_isotope_scattering_strength(gamma, grid_point, @@ -457,21 +456,19 @@ void ph3py_get_isotope_scattering_strength( 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 *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 *integration_weights, - 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 *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 *integration_weights, + const double cutoff_frequency) { iso_get_thm_isotope_scattering_strength(gamma, grid_point, @@ -503,7 +500,6 @@ void ph3py_distribute_fc3(double *fc3, rot_cart); } - void ph3py_rotate_delta_fc2(double (*fc3)[3][3][3], const double (*delta_fc2s)[3][3], const double *inv_U, @@ -523,14 +519,12 @@ void ph3py_rotate_delta_fc2(double (*fc3)[3][3][3], num_disp); } - void ph3py_get_permutation_symmetry_fc3(double *fc3, const long num_atom) { fc3_set_permutation_symmetry_fc3(fc3, num_atom); } - -void ph3py_get_permutation_symmetry_compact_fc3(double * fc3, +void ph3py_get_permutation_symmetry_compact_fc3(double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], @@ -547,7 +541,7 @@ void ph3py_get_permutation_symmetry_compact_fc3(double * fc3, n_patom); } -void ph3py_transpose_compact_fc3(double * fc3, +void ph3py_transpose_compact_fc3(double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], @@ -566,7 +560,6 @@ void ph3py_transpose_compact_fc3(double * fc3, t_type); } - long ph3py_get_triplets_reciprocal_mesh_at_q(long *map_triplets, long *map_q, const long grid_point, @@ -586,7 +579,6 @@ long ph3py_get_triplets_reciprocal_mesh_at_q(long *map_triplets, swappable); } - long ph3py_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point, const long (*bz_grid_addresses)[3], @@ -600,7 +592,8 @@ long ph3py_get_BZ_triplets_at_q(long (*triplets)[3], ConstBZGrid *bzgrid; long i, j, num_ir; - if ((bzgrid = (ConstBZGrid*) malloc(sizeof(ConstBZGrid))) == NULL) { + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) + { warning_print("Memory could not be allocated."); return 0; } @@ -608,10 +601,12 @@ long ph3py_get_BZ_triplets_at_q(long (*triplets)[3], bzgrid->addresses = bz_grid_addresses; bzgrid->gp_map = bz_map; bzgrid->type = bz_grid_type; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { bzgrid->D_diag[i] = D_diag[i]; bzgrid->PS[i] = 0; - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { bzgrid->Q[i][j] = Q[i][j]; } } @@ -652,7 +647,8 @@ long ph3py_get_integration_weight(double *iw, ConstBZGrid *bzgrid; long i; - if ((bzgrid = (ConstBZGrid*) malloc(sizeof(ConstBZGrid))) == NULL) { + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) + { warning_print("Memory could not be allocated."); return 0; } @@ -660,7 +656,8 @@ long ph3py_get_integration_weight(double *iw, bzgrid->addresses = bz_grid_addresses; bzgrid->gp_map = bz_map; bzgrid->type = bz_grid_type; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { bzgrid->D_diag[i] = D_diag[i]; } @@ -710,7 +707,6 @@ void ph3py_get_integration_weight_with_sigma(double *iw, tp_type); } - /* From single address to grid index */ long ph3py_get_grid_index_from_address(const long address[3], const long D_diag[3]) @@ -718,14 +714,12 @@ long ph3py_get_grid_index_from_address(const long address[3], return grg_get_grid_index(address, D_diag); } - void ph3py_get_gr_grid_addresses(long gr_grid_addresses[][3], const long D_diag[3]) { grg_get_all_grid_addresses(gr_grid_addresses, D_diag); } - long ph3py_get_reciprocal_rotations(long rec_rotations[48][3][3], const long (*rotations)[3][3], const long num_rot, @@ -738,7 +732,6 @@ long ph3py_get_reciprocal_rotations(long rec_rotations[48][3][3], 1); } - /* Rotation matrices with respect to reciprocal basis vectors are * transformed to those for GRGrid. This set of the rotations are * used always in GRGrid handling. */ @@ -775,8 +768,10 @@ long ph3py_get_ir_grid_map(long *ir_grid_map, grg_get_ir_grid_map(ir_grid_map, grg_rotations, num_rot, D_diag, PS); num_ir = 0; - for (i = 0; i < D_diag[0] * D_diag[1] * D_diag[2]; i ++) { - if (ir_grid_map[i] == i) { + for (i = 0; i < D_diag[0] * D_diag[1] * D_diag[2]; i++) + { + if (ir_grid_map[i] == i) + { num_ir++; } } @@ -796,7 +791,8 @@ long ph3py_get_bz_grid_addresses(long (*bz_grid_addresses)[3], BZGrid *bzgrid; long i, j, size; - if ((bzgrid = (BZGrid*) malloc(sizeof(BZGrid))) == NULL) { + if ((bzgrid = (BZGrid *)malloc(sizeof(BZGrid))) == NULL) + { warning_print("Memory could not be allocated."); return 0; } @@ -805,18 +801,23 @@ long ph3py_get_bz_grid_addresses(long (*bz_grid_addresses)[3], bzgrid->gp_map = bz_map; bzgrid->bzg2grg = bzg2grg; bzgrid->type = type; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { bzgrid->D_diag[i] = D_diag[i]; bzgrid->PS[i] = PS[i]; - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { bzgrid->Q[i][j] = Q[i][j]; bzgrid->reclat[i][j] = rec_lattice[i][j]; } } - if (bzg_get_bz_grid_addresses(bzgrid)) { + if (bzg_get_bz_grid_addresses(bzgrid)) + { size = bzgrid->size; - } else { + } + else + { size = 0; } @@ -837,7 +838,8 @@ long ph3py_rotate_bz_grid_index(const long bz_grid_index, ConstBZGrid *bzgrid; long i, rot_bz_gp; - if ((bzgrid = (ConstBZGrid*) malloc(sizeof(ConstBZGrid))) == NULL) { + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) + { warning_print("Memory could not be allocated."); return 0; } @@ -845,7 +847,8 @@ long ph3py_rotate_bz_grid_index(const long bz_grid_index, bzgrid->addresses = bz_grid_addresses; bzgrid->gp_map = bz_map; bzgrid->type = bz_grid_type; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { bzgrid->D_diag[i] = D_diag[i]; bzgrid->PS[i] = 0; } @@ -858,7 +861,6 @@ long ph3py_rotate_bz_grid_index(const long bz_grid_index, return rot_bz_gp; } - void ph3py_symmetrize_collision_matrix(double *collision_matrix, const long num_column, const long num_temp, @@ -867,18 +869,23 @@ void ph3py_symmetrize_collision_matrix(double *collision_matrix, double val; long i, j, k, l, adrs_shift; - for (i = 0; i < num_sigma; i++) { - for (j = 0; j < num_temp; j++) { + for (i = 0; i < num_sigma; i++) + { + for (j = 0; j < num_temp; j++) + { adrs_shift = (i * num_column * num_column * num_temp + j * num_column * num_column); /* show_colmat_info(py_collision_matrix, i, j, adrs_shift); */ #ifdef PHPYOPENMP #pragma omp parallel for schedule(guided) private(l, val) #endif - for (k = 0; k < num_column; k++) { - for (l = k + 1; l < num_column; l++) { + for (k = 0; k < num_column; k++) + { + for (l = k + 1; l < num_column; l++) + { val = (collision_matrix[adrs_shift + k * num_column + l] + - collision_matrix[adrs_shift + l * num_column + k]) / 2; + collision_matrix[adrs_shift + l * num_column + k]) / + 2; collision_matrix[adrs_shift + k * num_column + l] = val; collision_matrix[adrs_shift + l * num_column + k] = val; } @@ -887,7 +894,6 @@ void ph3py_symmetrize_collision_matrix(double *collision_matrix, } } - void ph3py_expand_collision_matrix(double *collision_matrix, const long *rot_grid_points, const long *ir_grid_points, @@ -904,7 +910,7 @@ void ph3py_expand_collision_matrix(double *collision_matrix, long *multi; double *colmat_copy; - multi = (long*)malloc(sizeof(long) * num_ir_gp); + multi = (long *)malloc(sizeof(long) * num_ir_gp); colmat_copy = NULL; num_column = num_grid_points * num_band; @@ -913,40 +919,49 @@ void ph3py_expand_collision_matrix(double *collision_matrix, #ifdef PHPYOPENMP #pragma omp parallel for schedule(guided) private(j, ir_gp) #endif - for (i = 0; i < num_ir_gp; i++) { + for (i = 0; i < num_ir_gp; i++) + { ir_gp = ir_grid_points[i]; multi[i] = 0; - for (j = 0; j < num_rot; j++) { - if (rot_grid_points[j * num_grid_points + ir_gp] == ir_gp) { + for (j = 0; j < num_rot; j++) + { + if (rot_grid_points[j * num_grid_points + ir_gp] == ir_gp) + { multi[i]++; } } } - for (i = 0; i < num_sigma; i++) { - for (j = 0; j < num_temp; j++) { + for (i = 0; i < num_sigma; i++) + { + for (j = 0; j < num_temp; j++) + { adrs_shift = (i * num_column * num_column * num_temp + j * num_column * num_column); #ifdef PHPYOPENMP #pragma omp parallel for private(ir_gp, adrs_shift_plus, colmat_copy, l, gp_r, m, n, p) #endif - for (k = 0; k < num_ir_gp; k++) { + for (k = 0; k < num_ir_gp; k++) + { ir_gp = ir_grid_points[k]; adrs_shift_plus = adrs_shift + ir_gp * num_bgb; - colmat_copy = (double*)malloc(sizeof(double) * num_bgb); - for (l = 0; l < num_bgb; l++) { + colmat_copy = (double *)malloc(sizeof(double) * num_bgb); + for (l = 0; l < num_bgb; l++) + { colmat_copy[l] = collision_matrix[adrs_shift_plus + l] / multi[k]; collision_matrix[adrs_shift_plus + l] = 0; } - for (l = 0; l < num_rot; l++) { + for (l = 0; l < num_rot; l++) + { gp_r = rot_grid_points[l * num_grid_points + ir_gp]; - for (m = 0; m < num_band; m++) { - for (n = 0; n < num_grid_points; n++) { - for (p = 0; p < num_band; p++) { - collision_matrix[ - adrs_shift + gp_r * num_bgb + m * num_grid_points * num_band - + rot_grid_points[l * num_grid_points + n] * num_band + p] += - colmat_copy[m * num_grid_points * num_band + n * num_band + p]; + for (m = 0; m < num_band; m++) + { + for (n = 0; n < num_grid_points; n++) + { + for (p = 0; p < num_band; p++) + { + collision_matrix[adrs_shift + gp_r * num_bgb + m * num_grid_points * num_band + rot_grid_points[l * num_grid_points + n] * num_band + p] += + colmat_copy[m * num_grid_points * num_band + n * num_band + p]; } } } @@ -979,7 +994,8 @@ long ph3py_get_neighboring_gird_points(long *relative_grid_points, long i; ConstBZGrid *bzgrid; - if ((bzgrid = (ConstBZGrid*) malloc(sizeof(ConstBZGrid))) == NULL) { + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) + { warning_print("Memory could not be allocated."); return 0; } @@ -987,20 +1003,21 @@ long ph3py_get_neighboring_gird_points(long *relative_grid_points, bzgrid->addresses = bz_grid_addresses; bzgrid->gp_map = bz_map; bzgrid->type = bz_grid_type; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { bzgrid->D_diag[i] = D_diag[i]; } #ifdef PHPYOPENMP #pragma omp parallel for #endif - for (i = 0; i < num_grid_points; i++) { - tpi_get_neighboring_grid_points - (relative_grid_points + i * num_relative_grid_address, - grid_points[i], - relative_grid_address, - num_relative_grid_address, - bzgrid); + for (i = 0; i < num_grid_points; i++) + { + tpi_get_neighboring_grid_points(relative_grid_points + i * num_relative_grid_address, + grid_points[i], + relative_grid_address, + num_relative_grid_address, + bzgrid); } free(bzgrid); @@ -1009,34 +1026,34 @@ long ph3py_get_neighboring_gird_points(long *relative_grid_points, return 1; } - /* thm_get_integration_weight at multiple grid points for using openmp * * relative_grid_addresses are given as P multipled with those from dataset, * i.e., * np.dot(relative_grid_addresses, P.T) */ long ph3py_get_thm_integration_weights_at_grid_points( - double *iw, - const double *frequency_points, - const long num_frequency_points, - const long num_band, - const long num_gp, - const long (*relative_grid_address)[4][3], - const long D_diag[3], - const long *grid_points, - const long (*bz_grid_addresses)[3], - const long *bz_map, - const long bz_grid_type, - const double *frequencies, - const long *gp2irgp_map, - const char function) + double *iw, + const double *frequency_points, + const long num_frequency_points, + const long num_band, + const long num_gp, + const long (*relative_grid_address)[4][3], + const long D_diag[3], + const long *grid_points, + const long (*bz_grid_addresses)[3], + const long *bz_map, + const long bz_grid_type, + const double *frequencies, + const long *gp2irgp_map, + const char function) { long i, j, k, bi; long vertices[24][4]; double freq_vertices[24][4]; ConstBZGrid *bzgrid; - if ((bzgrid = (ConstBZGrid*) malloc(sizeof(ConstBZGrid))) == NULL) { + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) + { warning_print("Memory could not be allocated."); return 0; } @@ -1044,31 +1061,37 @@ long ph3py_get_thm_integration_weights_at_grid_points( bzgrid->addresses = bz_grid_addresses; bzgrid->gp_map = bz_map; bzgrid->type = bz_grid_type; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { bzgrid->D_diag[i] = D_diag[i]; } #ifdef PHPYOPENMP #pragma omp parallel for private(j, k, bi, vertices, freq_vertices) #endif - for (i = 0; i < num_gp; i++) { - for (j = 0; j < 24; j++) { + for (i = 0; i < num_gp; i++) + { + for (j = 0; j < 24; j++) + { tpi_get_neighboring_grid_points(vertices[j], grid_points[i], relative_grid_address[j], 4, bzgrid); } - for (bi = 0; bi < num_band; bi++) { - for (j = 0; j < 24; j++) { - for (k = 0; k < 4; k++) { - freq_vertices[j][k] = frequencies[ - gp2irgp_map[vertices[j][k]] * num_band + bi]; + for (bi = 0; bi < num_band; bi++) + { + for (j = 0; j < 24; j++) + { + for (k = 0; k < 4; k++) + { + freq_vertices[j][k] = frequencies[gp2irgp_map[vertices[j][k]] * num_band + bi]; } } - for (j = 0; j < num_frequency_points; j++) { + for (j = 0; j < num_frequency_points; j++) + { iw[i * num_frequency_points * num_band + j * num_band + bi] = - thm_get_integration_weight(frequency_points[j], freq_vertices, function); + thm_get_integration_weight(frequency_points[j], freq_vertices, function); } } } diff --git a/c/phono3py.h b/c/phono3py.h index 4197a7e4..fc0e6e2f 100644 --- a/c/phono3py.h +++ b/c/phono3py.h @@ -70,7 +70,7 @@ long ph3py_get_pp_collision(double *imag_self_energy, const long num_triplets, const long *triplet_weights, const long (*bz_grid_addresses)[3], /* thm */ - const long *bz_map, /* thm */ + const long *bz_map, /* thm */ const long bz_grid_type, const long D_diag[3], const long Q[3][3], @@ -88,55 +88,55 @@ long ph3py_get_pp_collision(double *imag_self_energy, const long symmetrize_fc3_q, const double cutoff_frequency); long ph3py_get_pp_collision_with_sigma( - double *imag_self_energy, - const double sigma, - const double sigma_cutoff, - const double *frequencies, - const lapack_complex_double *eigenvectors, - const long (*triplets)[3], - const long num_triplets, - const long *triplet_weights, - const long (*bz_grid_addresses)[3], - const long D_diag[3], - const long Q[3][3], - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multi)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const Larray *band_indices, - const Darray *temperatures, - const long is_NU, - const long symmetrize_fc3_q, - const double cutoff_frequency); + double *imag_self_energy, + const double sigma, + const double sigma_cutoff, + const double *frequencies, + const lapack_complex_double *eigenvectors, + const long (*triplets)[3], + const long num_triplets, + const long *triplet_weights, + const long (*bz_grid_addresses)[3], + const long D_diag[3], + const long Q[3][3], + const double *fc3, + const long is_compact_fc3, + const double (*svecs)[3], + const long multi_dims[2], + const long (*multi)[2], + const double *masses, + const long *p2s_map, + const long *s2p_map, + const Larray *band_indices, + const Darray *temperatures, + const long is_NU, + const long symmetrize_fc3_q, + const double cutoff_frequency); void ph3py_get_imag_self_energy_at_bands_with_g( - double *imag_self_energy, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double *g, - const char *g_zero, - const double temperature, - const double cutoff_frequency, - const long num_frequency_points, - const long frequency_point_index); + double *imag_self_energy, + const Darray *fc3_normal_squared, + const double *frequencies, + const long (*triplets)[3], + const long *triplet_weights, + const double *g, + const char *g_zero, + const double temperature, + const double cutoff_frequency, + const long num_frequency_points, + const long frequency_point_index); void ph3py_get_detailed_imag_self_energy_at_bands_with_g( - double *detailed_imag_self_energy, - double *imag_self_energy_N, - double *imag_self_energy_U, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const long (*bz_grid_addresses)[3], - const double *g, - const char *g_zero, - const double temperature, - const double cutoff_frequency); + double *detailed_imag_self_energy, + double *imag_self_energy_N, + double *imag_self_energy_U, + const Darray *fc3_normal_squared, + const double *frequencies, + const long (*triplets)[3], + const long *triplet_weights, + const long (*bz_grid_addresses)[3], + const double *g, + const char *g_zero, + const double temperature, + const double cutoff_frequency); void ph3py_get_real_self_energy_at_bands(double *real_self_energy, const Darray *fc3_normal_squared, const long *band_indices, @@ -148,17 +148,17 @@ void ph3py_get_real_self_energy_at_bands(double *real_self_energy, const double unit_conversion_factor, const double cutoff_frequency); void ph3py_get_real_self_energy_at_frequency_point( - double *real_self_energy, - const double frequency_point, - const Darray *fc3_normal_squared, - const long *band_indices, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double epsilon, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency); + double *real_self_energy, + const double frequency_point, + const Darray *fc3_normal_squared, + const long *band_indices, + const double *frequencies, + const long (*triplets)[3], + const long *triplet_weights, + const double epsilon, + const double temperature, + const double unit_conversion_factor, + const double cutoff_frequency); void ph3py_get_collision_matrix(double *collision_matrix, const Darray *fc3_normal_squared, const double *frequencies, @@ -186,31 +186,31 @@ void ph3py_get_reducible_collision_matrix(double *collision_matrix, const double unit_conversion_factor, const double cutoff_frequency); void ph3py_get_isotope_scattering_strength( - double *gamma, - const long grid_point, - 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); + double *gamma, + const long grid_point, + 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 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 *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 *integration_weights, - const double cutoff_frequency); + double *gamma, + const long grid_point, + const long *ir_grid_points, + const long *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 *integration_weights, + const double cutoff_frequency); void ph3py_distribute_fc3(double *fc3, const long target, const long source, @@ -226,14 +226,14 @@ void ph3py_rotate_delta_fc2(double (*fc3)[3][3][3], const long num_site_sym, const long num_disp); void ph3py_get_permutation_symmetry_fc3(double *fc3, const long num_atom); -void ph3py_get_permutation_symmetry_compact_fc3(double * fc3, +void ph3py_get_permutation_symmetry_compact_fc3(double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], const long perms[], const long n_satom, const long n_patom); -void ph3py_transpose_compact_fc3(double * fc3, +void ph3py_transpose_compact_fc3(double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], @@ -352,19 +352,19 @@ long ph3py_get_neighboring_gird_points(long *relative_grid_points, const long num_grid_points, const long num_relative_grid_address); long ph3py_get_thm_integration_weights_at_grid_points( - double *iw, - const double *frequency_points, - const long num_band0, - const long num_band, - const long num_gp, - const long (*relative_grid_address)[4][3], - const long D_diag[3], - const long *grid_points, - const long (*bz_grid_addresses)[3], - const long *bz_map, - const long bz_grid_type, - const double *frequencies, - const long *gp2irgp_map, - const char function); + double *iw, + const double *frequency_points, + const long num_band0, + const long num_band, + const long num_gp, + const long (*relative_grid_address)[4][3], + const long D_diag[3], + const long *grid_points, + const long (*bz_grid_addresses)[3], + const long *bz_map, + const long bz_grid_type, + const double *frequencies, + const long *gp2irgp_map, + const char function); #endif diff --git a/c/phonon.c b/c/phonon.c index 313109e8..8b51ef16 100644 --- a/c/phonon.c +++ b/c/phonon.c @@ -50,7 +50,7 @@ static void get_undone_phonons(double *frequencies, const long (*grid_address)[3], const double QDinv[3][3], const double *fc2, - const double(*svecs_fc2)[3], + const double (*svecs_fc2)[3], const long (*multi_fc2)[2], const long num_patom, const long num_satom, @@ -71,7 +71,7 @@ static void get_gonze_undone_phonons(double *frequencies, const long (*grid_address)[3], const double QDinv[3][3], const double *fc2, - const double(*svecs_fc2)[3], + const double (*svecs_fc2)[3], const long (*multi_fc2)[2], const double (*positions)[3], const long num_patom, @@ -86,7 +86,7 @@ static void get_gonze_undone_phonons(double *frequencies, const double *q_direction, const double nac_factor, const double *dd_q0, - const double(*G_list)[3], + const double (*G_list)[3], const long num_G_points, const double lambda, const char uplo); @@ -99,7 +99,7 @@ static void get_phonons(lapack_complex_double *eigvecs, const long (*multi)[2], const long num_patom, const long num_satom, - const double(*svecs)[3], + const double (*svecs)[3], const long is_nac, const double (*born)[3][3], const double dielectric[3][3], @@ -117,7 +117,7 @@ static void get_gonze_phonons(lapack_complex_double *eigvecs, const double (*positions)[3], const long num_patom, const long num_satom, - const double(*svecs)[3], + const double (*svecs)[3], const long is_nac, const double (*born)[3][3], const double dielectric[3][3], @@ -125,7 +125,7 @@ static void get_gonze_phonons(lapack_complex_double *eigvecs, const double *q_direction, const double nac_factor, const double *dd_q0, - const double(*G_list)[3], + const double (*G_list)[3], const long num_G_points, const double lambda); static void @@ -138,7 +138,7 @@ get_dynamical_matrix(lapack_complex_double *dynmat, const long (*multi)[2], const long num_patom, const long num_satom, - const double(*svecs)[3], + const double (*svecs)[3], const long is_nac, const double (*born)[3][3], /* Wang NAC unless NULL */ const double dielectric[3][3], @@ -159,35 +159,34 @@ static long needs_nac(const double (*born)[3][3], const long gp, const double *q_direction); -void -phn_get_phonons_at_gridpoints(double *frequencies, - lapack_complex_double *eigenvectors, - char *phonon_done, - const long num_phonons, - const long *grid_points, - const long num_grid_points, - const long (*grid_address)[3], - const double QDinv[3][3], - const double *fc2, - const double(*svecs_fc2)[3], - const long (*multi_fc2)[2], - const long num_patom, - const long num_satom, - const double *masses_fc2, - const long *p2s_fc2, - const long *s2p_fc2, - const double unit_conversion_factor, - const double (*born)[3][3], - const double dielectric[3][3], - const double reciprocal_lattice[3][3], - const double *q_direction, /* must be pointer */ - const double nac_factor, - const char uplo) +void phn_get_phonons_at_gridpoints(double *frequencies, + lapack_complex_double *eigenvectors, + char *phonon_done, + const long num_phonons, + const long *grid_points, + const long num_grid_points, + const long (*grid_address)[3], + const double QDinv[3][3], + const double *fc2, + const double (*svecs_fc2)[3], + const long (*multi_fc2)[2], + const long num_patom, + const long num_satom, + const double *masses_fc2, + const long *p2s_fc2, + const long *s2p_fc2, + const double unit_conversion_factor, + const double (*born)[3][3], + const double dielectric[3][3], + const double reciprocal_lattice[3][3], + const double *q_direction, /* must be pointer */ + const double nac_factor, + const char uplo) { long num_undone; long *undone; - undone = (long*)malloc(sizeof(long) * num_phonons); + undone = (long *)malloc(sizeof(long) * num_phonons); num_undone = collect_undone_grid_points(undone, phonon_done, num_grid_points, @@ -219,40 +218,39 @@ phn_get_phonons_at_gridpoints(double *frequencies, undone = NULL; } -void -phn_get_gonze_phonons_at_gridpoints(double *frequencies, - lapack_complex_double *eigenvectors, - char *phonon_done, - const long num_phonons, - const long *grid_points, - const long num_grid_points, - const long (*grid_address)[3], - const double QDinv[3][3], - const double *fc2, - const double(*svecs_fc2)[3], - const long (*multi_fc2)[2], - const double (*positions)[3], - const long num_patom, - const long num_satom, - const double *masses_fc2, - const long *p2s_fc2, - const long *s2p_fc2, - const double unit_conversion_factor, - const double (*born)[3][3], - const double dielectric[3][3], - const double reciprocal_lattice[3][3], - const double *q_direction, /* pointer */ - const double nac_factor, - const double *dd_q0, - const double(*G_list)[3], - const long num_G_points, - const double lambda, - const char uplo) +void phn_get_gonze_phonons_at_gridpoints(double *frequencies, + lapack_complex_double *eigenvectors, + char *phonon_done, + const long num_phonons, + const long *grid_points, + const long num_grid_points, + const long (*grid_address)[3], + const double QDinv[3][3], + const double *fc2, + const double (*svecs_fc2)[3], + const long (*multi_fc2)[2], + const double (*positions)[3], + const long num_patom, + const long num_satom, + const double *masses_fc2, + const long *p2s_fc2, + const long *s2p_fc2, + const double unit_conversion_factor, + const double (*born)[3][3], + const double dielectric[3][3], + const double reciprocal_lattice[3][3], + const double *q_direction, /* pointer */ + const double nac_factor, + const double *dd_q0, + const double (*G_list)[3], + const long num_G_points, + const double lambda, + const char uplo) { long num_undone; long *undone; - undone = (long*)malloc(sizeof(long) * num_phonons); + undone = (long *)malloc(sizeof(long) * num_phonons); num_undone = collect_undone_grid_points(undone, phonon_done, num_grid_points, @@ -297,9 +295,11 @@ static long collect_undone_grid_points(long *undone, long i, gp, num_undone; num_undone = 0; - for (i = 0; i < num_grid_points; i++) { + for (i = 0; i < num_grid_points; i++) + { gp = grid_points[i]; - if (phonon_done[gp] == 0) { + if (phonon_done[gp] == 0) + { undone[num_undone] = gp; num_undone++; phonon_done[gp] = 1; @@ -316,7 +316,7 @@ static void get_undone_phonons(double *frequencies, const long (*grid_address)[3], const double QDinv[3][3], const double *fc2, - const double(*svecs_fc2)[3], + const double (*svecs_fc2)[3], const long (*multi_fc2)[2], const long num_patom, const long num_satom, @@ -341,12 +341,12 @@ static void get_undone_phonons(double *frequencies, #ifdef PHPYOPENMP #pragma omp parallel for private(j, q, gp, is_nac) #endif - for (i = 0; i < num_undone_grid_points; i++) { + for (i = 0; i < num_undone_grid_points; i++) + { gp = undone_grid_points[i]; - for (j = 0; j < 3; j++) { - q[j] = QDinv[j][0] * grid_address[gp][0] - + QDinv[j][1] * grid_address[gp][1] - + QDinv[j][2] * grid_address[gp][2]; + for (j = 0; j < 3; j++) + { + q[j] = QDinv[j][0] * grid_address[gp][0] + QDinv[j][1] * grid_address[gp][1] + QDinv[j][2] * grid_address[gp][2]; } is_nac = needs_nac(born, grid_address, gp, q_direction); @@ -375,7 +375,8 @@ static void get_undone_phonons(double *frequencies, #pragma omp parallel for private(j, gp, freqs_tmp, info) #endif #endif - for (i = 0; i < num_undone_grid_points; i++) { + for (i = 0; i < num_undone_grid_points; i++) + { gp = undone_grid_points[i]; freqs_tmp = frequencies + num_band * gp; /* Store eigenvalues in freqs array. */ @@ -386,9 +387,10 @@ static void get_undone_phonons(double *frequencies, uplo); /* Sqrt of eigenvalues are re-stored in freqs array.*/ - for (j = 0; j < num_band; j++) { + for (j = 0; j < num_band; j++) + { freqs_tmp[j] = sqrt(fabs(freqs_tmp[j])) * - ((freqs_tmp[j] > 0) - (freqs_tmp[j] < 0)) * unit_conversion_factor; + ((freqs_tmp[j] > 0) - (freqs_tmp[j] < 0)) * unit_conversion_factor; } } } @@ -400,7 +402,7 @@ static void get_gonze_undone_phonons(double *frequencies, const long (*grid_address)[3], const double QDinv[3][3], const double *fc2, - const double(*svecs_fc2)[3], + const double (*svecs_fc2)[3], const long (*multi_fc2)[2], const double (*positions)[3], const long num_patom, @@ -415,7 +417,7 @@ static void get_gonze_undone_phonons(double *frequencies, const double *q_direction, const double nac_factor, const double *dd_q0, - const double(*G_list)[3], + const double (*G_list)[3], const long num_G_points, const double lambda, const char uplo) @@ -430,12 +432,12 @@ static void get_gonze_undone_phonons(double *frequencies, #ifdef PHPYOPENMP #pragma omp parallel for private(j, q, gp, is_nac) #endif - for (i = 0; i < num_undone_grid_points; i++) { + for (i = 0; i < num_undone_grid_points; i++) + { gp = undone_grid_points[i]; - for (j = 0; j < 3; j++) { - q[j] = QDinv[j][0] * grid_address[gp][0] - + QDinv[j][1] * grid_address[gp][1] - + QDinv[j][2] * grid_address[gp][2]; + for (j = 0; j < 3; j++) + { + q[j] = QDinv[j][0] * grid_address[gp][0] + QDinv[j][1] * grid_address[gp][1] + QDinv[j][2] * grid_address[gp][2]; } is_nac = needs_nac(born, grid_address, gp, q_direction); get_gonze_phonons(eigenvectors + num_band * num_band * gp, @@ -461,14 +463,14 @@ static void get_gonze_undone_phonons(double *frequencies, lambda); } - /* To avoid multithreaded BLAS in OpenMP loop */ #ifdef PHPYOPENMP #ifndef MULTITHREADED_BLAS #pragma omp parallel for private(j, gp, freqs_tmp, info) #endif #endif - for (i = 0; i < num_undone_grid_points; i++) { + for (i = 0; i < num_undone_grid_points; i++) + { gp = undone_grid_points[i]; /* Store eigenvalues in freqs array. */ /* Eigenvectors are overwritten on eigvecs array. */ @@ -479,9 +481,10 @@ static void get_gonze_undone_phonons(double *frequencies, uplo); /* Sqrt of eigenvalues are re-stored in freqs array.*/ - for (j = 0; j < num_band; j++) { + for (j = 0; j < num_band; j++) + { freqs_tmp[j] = sqrt(fabs(freqs_tmp[j])) * - ((freqs_tmp[j] > 0) - (freqs_tmp[j] < 0)) * unit_conversion_factor; + ((freqs_tmp[j] > 0) - (freqs_tmp[j] < 0)) * unit_conversion_factor; } } } @@ -495,7 +498,7 @@ static void get_phonons(lapack_complex_double *eigvecs, const long (*multi)[2], const long num_patom, const long num_satom, - const double(*svecs)[3], + const double (*svecs)[3], const long is_nac, const double (*born)[3][3], const double dielectric[3][3], @@ -533,7 +536,7 @@ static void get_gonze_phonons(lapack_complex_double *eigvecs, const double (*positions)[3], const long num_patom, const long num_satom, - const double(*svecs)[3], + const double (*svecs)[3], const long is_nac, const double (*born)[3][3], const double dielectric[3][3], @@ -541,7 +544,7 @@ static void get_gonze_phonons(lapack_complex_double *eigvecs, const double *q_direction, const double nac_factor, const double *dd_q0, - const double(*G_list)[3], + const double (*G_list)[3], const long num_G_points, const double lambda) { @@ -555,7 +558,7 @@ static void get_gonze_phonons(lapack_complex_double *eigvecs, q_dir_cart = NULL; num_band = num_patom * 3; - dym_get_dynamical_matrix_at_q((double*)eigvecs, + dym_get_dynamical_matrix_at_q((double *)eigvecs, num_patom, num_satom, fc2, @@ -568,26 +571,31 @@ static void get_gonze_phonons(lapack_complex_double *eigvecs, NULL, 0); - dd = (lapack_complex_double*) - malloc(sizeof(lapack_complex_double) * num_band * num_band); - for (i = 0; i < 3; i++) { + dd = (lapack_complex_double *) + malloc(sizeof(lapack_complex_double) * num_band * num_band); + for (i = 0; i < 3; i++) + { q_cart[i] = 0; - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { q_cart[i] += reciprocal_lattice[i][j] * q[j]; } } - if (q_direction) { - q_dir_cart = (double*)malloc(sizeof(double) * 3); - for (i = 0; i < 3; i++) { + if (q_direction) + { + q_dir_cart = (double *)malloc(sizeof(double) * 3); + for (i = 0; i < 3; i++) + { q_dir_cart[i] = 0; - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { q_dir_cart[i] += reciprocal_lattice[i][j] * q_direction[j]; } } } - dym_get_recip_dipole_dipole((double*)dd, + dym_get_recip_dipole_dipole((double *)dd, dd_q0, G_list, num_G_points, @@ -601,22 +609,27 @@ static void get_gonze_phonons(lapack_complex_double *eigvecs, lambda, 1e-5); - if (q_direction) { + if (q_direction) + { free(q_dir_cart); q_dir_cart = NULL; } - for (i = 0; i < num_patom; i++) { - for (j = 0; j < num_patom; j++) { + for (i = 0; i < num_patom; i++) + { + for (j = 0; j < num_patom; j++) + { mm = sqrt(masses[i] * masses[j]); - for (k = 0; k < 3; k++) { - for (l = 0; l < 3; l++) { + for (k = 0; k < 3; k++) + { + for (l = 0; l < 3; l++) + { adrs = i * num_patom * 9 + k * num_patom * 3 + j * 3 + l; eigvecs[adrs] = lapack_make_complex_double( - lapack_complex_double_real(eigvecs[adrs]) + - lapack_complex_double_real(dd[adrs]) / mm, - lapack_complex_double_imag(eigvecs[adrs]) + - lapack_complex_double_imag(dd[adrs]) / mm); + lapack_complex_double_real(eigvecs[adrs]) + + lapack_complex_double_real(dd[adrs]) / mm, + lapack_complex_double_imag(eigvecs[adrs]) + + lapack_complex_double_imag(dd[adrs]) / mm); } } } @@ -636,7 +649,7 @@ get_dynamical_matrix(lapack_complex_double *dynmat, const long (*multi)[2], const long num_patom, const long num_satom, - const double(*svecs)[3], + const double (*svecs)[3], const long is_nac, const double (*born)[3][3], /* Wang NAC unless NULL */ const double dielectric[3][3], @@ -644,13 +657,14 @@ get_dynamical_matrix(lapack_complex_double *dynmat, const double *q_direction, const double nac_factor) { - double (*charge_sum)[3][3]; + double(*charge_sum)[3][3]; charge_sum = NULL; - if (is_nac) { + if (is_nac) + { charge_sum = (double(*)[3][3]) - malloc(sizeof(double[3][3]) * num_patom * num_patom * 9); + malloc(sizeof(double[3][3]) * num_patom * num_patom * 9); get_charge_sum(charge_sum, num_patom, num_satom, @@ -662,7 +676,7 @@ get_dynamical_matrix(lapack_complex_double *dynmat, nac_factor); } - dym_get_dynamical_matrix_at_q((double*)dynmat, + dym_get_dynamical_matrix_at_q((double *)dynmat, num_patom, num_satom, fc2, @@ -674,7 +688,8 @@ get_dynamical_matrix(lapack_complex_double *dynmat, p2s, charge_sum, 0); - if (is_nac) { + if (is_nac) + { free(charge_sum); charge_sum = NULL; } @@ -694,26 +709,35 @@ static void get_charge_sum(double (*charge_sum)[3][3], double inv_dielectric_factor, dielectric_factor, tmp_val; double q_cart[3]; - if (q_direction) { - for (i = 0; i < 3; i++) { + if (q_direction) + { + for (i = 0; i < 3; i++) + { q_cart[i] = 0.0; - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { q_cart[i] += reciprocal_lattice[i][j] * q_direction[j]; } } - } else { - for (i = 0; i < 3; i++) { + } + else + { + for (i = 0; i < 3; i++) + { q_cart[i] = 0.0; - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { q_cart[i] += reciprocal_lattice[i][j] * q[j]; } } } inv_dielectric_factor = 0.0; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { tmp_val = 0.0; - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { tmp_val += dielectric[i][j] * q_cart[j]; } inv_dielectric_factor += tmp_val * q_cart[i]; @@ -721,7 +745,7 @@ static void get_charge_sum(double (*charge_sum)[3][3], /* N = num_satom / num_patom = number of prim-cell in supercell */ /* N is used for Wang's method. */ dielectric_factor = nac_factor / - inv_dielectric_factor / num_satom * num_patom; + inv_dielectric_factor / num_satom * num_patom; dym_get_charge_sum(charge_sum, num_patom, dielectric_factor, @@ -736,16 +760,22 @@ static long needs_nac(const double (*born)[3][3], { long is_nac; - if (born) { + if (born) + { if (grid_address[gp][0] == 0 && grid_address[gp][1] == 0 && grid_address[gp][2] == 0 && - q_direction == NULL) { + q_direction == NULL) + { is_nac = 0; - } else { + } + else + { is_nac = 1; } - } else { + } + else + { is_nac = 0; } diff --git a/c/phonon.h b/c/phonon.h index a5e13a60..1693f253 100644 --- a/c/phonon.h +++ b/c/phonon.h @@ -38,57 +38,55 @@ #include "dynmat.h" #include "lapack_wrapper.h" -void -phn_get_phonons_at_gridpoints(double *frequencies, - lapack_complex_double *eigenvectors, - char *phonon_done, - const long num_phonons, - const long *grid_points, - const long num_grid_points, - const long (*grid_address)[3], - const double QDinv[3][3], - const double *fc2, - const double(*svecs_fc2)[3], - const long (*multi_fc2)[2], - const long num_patom, - const long num_satom, - const double *masses_fc2, - const long *p2s_fc2, - const long *s2p_fc2, - const double unit_conversion_factor, - const double (*born)[3][3], - const double dielectric[3][3], - const double reciprocal_lattice[3][3], - const double *q_direction, /* must be pointer */ - const double nac_factor, - const char uplo); -void -phn_get_gonze_phonons_at_gridpoints(double *frequencies, - lapack_complex_double *eigenvectors, - char *phonon_done, - const long num_phonons, - const long *grid_points, - const long num_grid_points, - const long (*grid_address)[3], - const double QDinv[3][3], - const double *fc2, - const double(*svecs_fc2)[3], - const long (*multi_fc2)[2], - const double (*positions)[3], - const long num_patom, - const long num_satom, - const double *masses_fc2, - const long *p2s_fc2, - const long *s2p_fc2, - const double unit_conversion_factor, - const double (*born)[3][3], - const double dielectric[3][3], - const double reciprocal_lattice[3][3], - const double *q_direction, /* pointer */ - const double nac_factor, - const double *dd_q0, - const double(*G_list)[3], - const long num_G_points, - const double lambda, - const char uplo); +void phn_get_phonons_at_gridpoints(double *frequencies, + lapack_complex_double *eigenvectors, + char *phonon_done, + const long num_phonons, + const long *grid_points, + const long num_grid_points, + const long (*grid_address)[3], + const double QDinv[3][3], + const double *fc2, + const double (*svecs_fc2)[3], + const long (*multi_fc2)[2], + const long num_patom, + const long num_satom, + const double *masses_fc2, + const long *p2s_fc2, + const long *s2p_fc2, + const double unit_conversion_factor, + const double (*born)[3][3], + const double dielectric[3][3], + const double reciprocal_lattice[3][3], + const double *q_direction, /* must be pointer */ + const double nac_factor, + const char uplo); +void phn_get_gonze_phonons_at_gridpoints(double *frequencies, + lapack_complex_double *eigenvectors, + char *phonon_done, + const long num_phonons, + const long *grid_points, + const long num_grid_points, + const long (*grid_address)[3], + const double QDinv[3][3], + const double *fc2, + const double (*svecs_fc2)[3], + const long (*multi_fc2)[2], + const double (*positions)[3], + const long num_patom, + const long num_satom, + const double *masses_fc2, + const long *p2s_fc2, + const long *s2p_fc2, + const double unit_conversion_factor, + const double (*born)[3][3], + const double dielectric[3][3], + const double reciprocal_lattice[3][3], + const double *q_direction, /* pointer */ + const double nac_factor, + const double *dd_q0, + const double (*G_list)[3], + const long num_G_points, + const double lambda, + const char uplo); #endif diff --git a/c/phononmod.c b/c/phononmod.c index 829b69c5..ccdc5746 100644 --- a/c/phononmod.c +++ b/c/phononmod.c @@ -45,7 +45,7 @@ void phmod_get_phonons_at_gridpoints(double *frequencies, const long (*grid_address)[3], const double QDinv[3][3], const double *fc2, - const double(*svecs_fc2)[3], + const double (*svecs_fc2)[3], const long (*multi_fc2)[2], const double (*positions_fc2)[3], const long num_patom, @@ -60,12 +60,13 @@ void phmod_get_phonons_at_gridpoints(double *frequencies, const double *q_direction, /* pointer */ const double nac_factor, const double *dd_q0, - const double(*G_list)[3], + const double (*G_list)[3], const long num_G_points, const double lambda, const char uplo) { - if (!dd_q0) { + if (!dd_q0) + { phn_get_phonons_at_gridpoints(frequencies, eigenvectors, phonon_done, @@ -89,7 +90,9 @@ void phmod_get_phonons_at_gridpoints(double *frequencies, q_direction, nac_factor, uplo); - } else { + } + else + { phn_get_gonze_phonons_at_gridpoints(frequencies, eigenvectors, phonon_done, diff --git a/c/phononmod.h b/c/phononmod.h index 50aeaa62..82807b8f 100644 --- a/c/phononmod.h +++ b/c/phononmod.h @@ -46,7 +46,7 @@ void phmod_get_phonons_at_gridpoints(double *frequencies, const long (*grid_address)[3], const double QDinv[3][3], const double *fc2, - const double(*svecs_fc2)[3], + const double (*svecs_fc2)[3], const long (*multi_fc2)[2], const double (*positions_fc2)[3], const long num_patom, @@ -61,7 +61,7 @@ void phmod_get_phonons_at_gridpoints(double *frequencies, const double *q_direction, /* pointer */ const double nac_factor, const double *dd_q0, - const double(*G_list)[3], + const double (*G_list)[3], const long num_G_points, const double lambda, const char uplo); diff --git a/c/real_self_energy.c b/c/real_self_energy.c index fa6c3890..eb911e37 100644 --- a/c/real_self_energy.c +++ b/c/real_self_energy.c @@ -84,59 +84,67 @@ void rse_get_real_self_energy_at_bands(double *real_self_energy, gp0 = triplets[0][0]; /* num_band0 and num_band_indices have to be same. */ - for (i = 0; i < num_band0; i++) { + for (i = 0; i < num_band0; i++) + { fpoint = frequencies[gp0 * num_band + band_indices[i]]; - if (fpoint < cutoff_frequency) { + if (fpoint < cutoff_frequency) + { real_self_energy[i] = 0; - } else { + } + else + { real_self_energy[i] = - get_real_self_energy_at_band(i, - fc3_normal_squared, - fpoint, - frequencies, - triplets, - triplet_weights, - epsilon, - temperature, - unit_conversion_factor, - cutoff_frequency); + get_real_self_energy_at_band(i, + fc3_normal_squared, + fpoint, + frequencies, + triplets, + triplet_weights, + epsilon, + temperature, + unit_conversion_factor, + cutoff_frequency); } } } void rse_get_real_self_energy_at_frequency_point( - double *real_self_energy, - const double frequency_point, - const Darray *fc3_normal_squared, - const long *band_indices, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double epsilon, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency) + double *real_self_energy, + const double frequency_point, + const Darray *fc3_normal_squared, + const long *band_indices, + const double *frequencies, + const long (*triplets)[3], + const long *triplet_weights, + const double epsilon, + const double temperature, + const double unit_conversion_factor, + const double cutoff_frequency) { long i, num_band0; num_band0 = fc3_normal_squared->dims[1]; /* num_band0 and num_band_indices have to be same. */ - for (i = 0; i < num_band0; i++) { - if (frequency_point < cutoff_frequency) { + for (i = 0; i < num_band0; i++) + { + if (frequency_point < cutoff_frequency) + { real_self_energy[i] = 0; - } else { + } + else + { real_self_energy[i] = - get_real_self_energy_at_band(i, - fc3_normal_squared, - frequency_point, - frequencies, - triplets, - triplet_weights, - epsilon, - temperature, - unit_conversion_factor, - cutoff_frequency); + get_real_self_energy_at_band(i, + fc3_normal_squared, + frequency_point, + frequencies, + triplets, + triplet_weights, + epsilon, + temperature, + unit_conversion_factor, + cutoff_frequency); } } } @@ -161,36 +169,41 @@ static double get_real_self_energy_at_band(const long band_index, shift = 0; #ifdef PHPYOPENMP -#pragma omp parallel for private(gp1, gp2) reduction(+:shift) +#pragma omp parallel for private(gp1, gp2) reduction(+ \ + : shift) #endif - for (i = 0; i < num_triplets; i++) { + for (i = 0; i < num_triplets; i++) + { gp1 = triplets[i][1]; gp2 = triplets[i][2]; - if (temperature > 0) { + if (temperature > 0) + { shift += - sum_real_self_energy_at_band(num_band, - fc3_normal_squared->data + - i * num_band0 * num_band * num_band + - band_index * num_band * num_band, - fpoint, - frequencies + gp1 * num_band, - frequencies + gp2 * num_band, - epsilon, - temperature, - cutoff_frequency) * - triplet_weights[i] * unit_conversion_factor; - } else { + sum_real_self_energy_at_band(num_band, + fc3_normal_squared->data + + i * num_band0 * num_band * num_band + + band_index * num_band * num_band, + fpoint, + frequencies + gp1 * num_band, + frequencies + gp2 * num_band, + epsilon, + temperature, + cutoff_frequency) * + triplet_weights[i] * unit_conversion_factor; + } + else + { shift += - sum_real_self_energy_at_band_0K(num_band, - fc3_normal_squared->data + - i * num_band0 * num_band * num_band + - band_index * num_band * num_band, - fpoint, - frequencies + gp1 * num_band, - frequencies + gp2 * num_band, - epsilon, - cutoff_frequency) * - triplet_weights[i] * unit_conversion_factor; + sum_real_self_energy_at_band_0K(num_band, + fc3_normal_squared->data + + i * num_band0 * num_band * num_band + + band_index * num_band * num_band, + fpoint, + frequencies + gp1 * num_band, + frequencies + gp2 * num_band, + epsilon, + cutoff_frequency) * + triplet_weights[i] * unit_conversion_factor; } } return shift; @@ -210,11 +223,15 @@ static double sum_real_self_energy_at_band(const long num_band, /* double sum; */ shift = 0; - for (i = 0; i < num_band; i++) { - if (freqs1[i] > cutoff_frequency) { + for (i = 0; i < num_band; i++) + { + if (freqs1[i] > cutoff_frequency) + { n1 = phonoc_bose_einstein(freqs1[i], temperature); - for (j = 0; j < num_band; j++) { - if (freqs2[j] > cutoff_frequency) { + for (j = 0; j < num_band; j++) + { + if (freqs2[j] > cutoff_frequency) + { n2 = phonoc_bose_einstein(freqs2[j], temperature); f1 = fpoint + freqs1[i] + freqs2[j]; f2 = fpoint - freqs1[i] - freqs2[j]; @@ -236,11 +253,8 @@ static double sum_real_self_energy_at_band(const long num_band, * } * shift += sum * fc3_normal_squared[i * num_band + j]; */ - shift += (- (n1 + n2 + 1) * f1 / (f1 * f1 + epsilon * epsilon) - + (n1 + n2 + 1) * f2 / (f2 * f2 + epsilon * epsilon) - - (n1 - n2) * f3 / (f3 * f3 + epsilon * epsilon) - + (n1 - n2) * f4 / (f4 * f4 + epsilon * epsilon)) * - fc3_normal_squared[i * num_band + j]; + shift += (-(n1 + n2 + 1) * f1 / (f1 * f1 + epsilon * epsilon) + (n1 + n2 + 1) * f2 / (f2 * f2 + epsilon * epsilon) - (n1 - n2) * f3 / (f3 * f3 + epsilon * epsilon) + (n1 - n2) * f4 / (f4 * f4 + epsilon * epsilon)) * + fc3_normal_squared[i * num_band + j]; } } } @@ -260,15 +274,18 @@ static double sum_real_self_energy_at_band_0K(const long num_band, double f1, f2, shift; shift = 0; - for (i = 0; i < num_band; i++) { - if (freqs1[i] > cutoff_frequency) { - for (j = 0; j < num_band; j++) { - if (freqs2[j] > cutoff_frequency) { + for (i = 0; i < num_band; i++) + { + if (freqs1[i] > cutoff_frequency) + { + for (j = 0; j < num_band; j++) + { + if (freqs2[j] > cutoff_frequency) + { f1 = fpoint + freqs1[i] + freqs2[j]; f2 = fpoint - freqs1[i] - freqs2[j]; - shift += (- 1 * f1 / (f1 * f1 + epsilon * epsilon) - + 1 * f2 / (f2 * f2 + epsilon * epsilon)) * - fc3_normal_squared[i * num_band + j]; + shift += (-1 * f1 / (f1 * f1 + epsilon * epsilon) + 1 * f2 / (f2 * f2 + epsilon * epsilon)) * + fc3_normal_squared[i * num_band + j]; } } } diff --git a/c/real_self_energy.h b/c/real_self_energy.h index df06c403..44b20aef 100644 --- a/c/real_self_energy.h +++ b/c/real_self_energy.h @@ -50,14 +50,14 @@ void rse_get_real_self_energy_at_bands(double *real_self_energy, const double unit_conversion_factor, const double cutoff_frequency); void rse_get_real_self_energy_at_frequency_point( - double *real_self_energy, - const double frequency_point, - const Darray *fc3_normal_squared, - const long *band_indices, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double epsilon, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency); + double *real_self_energy, + const double frequency_point, + const Darray *fc3_normal_squared, + const long *band_indices, + const double *frequencies, + const long (*triplets)[3], + const long *triplet_weights, + const double epsilon, + const double temperature, + const double unit_conversion_factor, + const double cutoff_frequency); diff --git a/c/snf3x3.c b/c/snf3x3.c index 1c3b1ee7..c39534d1 100644 --- a/c/snf3x3.c +++ b/c/snf3x3.c @@ -38,7 +38,6 @@ static void matmul(long m[3][3], SNF3x3CONST long b[3][3]); static long det(SNF3x3CONST long m[3][3]); - /* static void test_set_A(long A[3][3]); * static void test_show_A(SNF3x3CONST long A[3][3]); * static void test_extended_gcd(void); @@ -57,9 +56,12 @@ int snf3x3(long A[3][3], long P[3][3], long Q[3][3]) int i; initialize_PQ(P, Q); - for (i = 0; i < 100; i++) { - if (first(A, P, Q)) { - if (second(A, P, Q)) { + for (i = 0; i < 100; i++) + { + if (first(A, P, Q)) + { + if (second(A, P, Q)) + { finalize(A, P, Q); transpose(Q); goto succeeded; @@ -76,12 +78,17 @@ static void initialize_PQ(long P[3][3], long Q[3][3]) { int i, j; - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { - if (i == j) { + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { + if (i == j) + { P[i][j] = 1; Q[i][j] = 1; - } else { + } + else + { P[i][j] = 0; Q[i][j] = 0; } @@ -96,14 +103,16 @@ static int first(long A[3][3], long P[3][3], long Q[3][3]) first_one_loop(A, P, Q); /* rows and columns are all zero except for the pivot */ - if ((A[1][0] == 0) && (A[2][0] == 0)) { + if ((A[1][0] == 0) && (A[2][0] == 0)) + { return 1; } /* columns of the pivot are assumed zero because of first_one_loop. */ /* rows of the pivot are non-zero, but divisible by the pivot. */ /* first_finalize makes the rows be zero. */ - if ((A[1][0] % A[0][0] == 0) && (A[2][0] % A[0][0] == 0)) { + if ((A[1][0] % A[0][0] == 0) && (A[2][0] % A[0][0] == 0)) + { first_finalize(L, A); matmul(A, L, A); matmul(P, L, P); @@ -126,28 +135,31 @@ static void first_column(long A[3][3], long P[3][3]) long L[3][3]; i = search_first_pivot(A); - if (i > 0) { + if (i > 0) + { swap_rows(L, 0, i); matmul(A, L, A); matmul(P, L, P); } - if (i < 0) { + if (i < 0) + { goto err; } - if (A[1][0] != 0) { + if (A[1][0] != 0) + { zero_first_column(L, 1, A); matmul(A, L, A); matmul(P, L, P); } - if (A[2][0] != 0) { + if (A[2][0] != 0) + { zero_first_column(L, 2, A); matmul(A, L, A); matmul(P, L, P); } -err: - ; +err:; } static void zero_first_column(long L[3][3], const int j, @@ -163,8 +175,10 @@ static int search_first_pivot(SNF3x3CONST long A[3][3]) { int i; - for (i = 0; i < 3; i++) { - if (A[i][0] != 0) { + for (i = 0; i < 3; i++) + { + if (A[i][0] != 0) + { return i; } } @@ -190,11 +204,13 @@ static int second(long A[3][3], long P[3][3], long Q[3][3]) second_one_loop(A, P, Q); - if (A[2][1] == 0) { + if (A[2][1] == 0) + { return 1; } - if (A[2][1] % A[1][1] == 0) { + if (A[2][1] % A[1][1] == 0) + { second_finalize(L, A); matmul(A, L, A); matmul(P, L, P); @@ -216,13 +232,15 @@ static void second_column(long A[3][3], long P[3][3]) { long L[3][3]; - if ((A[1][1] == 0) && (A[2][1] != 0)) { + if ((A[1][1] == 0) && (A[2][1] != 0)) + { swap_rows(L, 1, 2); matmul(A, L, A); matmul(P, L, P); } - if (A[2][1] != 0) { + if (A[2][1] != 0) + { zero_second_column(L, A); matmul(A, L, A); matmul(P, L, P); @@ -265,13 +283,16 @@ static void finalize(long A[3][3], long P[3][3], long Q[3][3]) static void finalize_sort(long A[3][3], long P[3][3], long Q[3][3]) { - if (A[0][0] > A[1][1]) { + if (A[0][0] > A[1][1]) + { swap_diag_elems(A, P, Q, 0, 1); } - if (A[1][1] > A[2][2]) { + if (A[1][1] > A[2][2]) + { swap_diag_elems(A, P, Q, 1, 2); } - if (A[0][0] > A[1][1]) { + if (A[0][0] > A[1][1]) + { swap_diag_elems(A, P, Q, 0, 1); } } @@ -280,7 +301,8 @@ static void finalize_disturb(long A[3][3], long Q[3][3], const int i, const int { long L[3][3]; - if (A[j][j] % A[i][i] != 0) { + if (A[j][j] % A[i][i] != 0) + { transpose(A); disturb_rows(L, i, j); matmul(A, L, A); @@ -325,8 +347,10 @@ static void make_diagA_positive(long A[3][3], long P[3][3]) int i; long L[3][3]; - for (i = 0; i < 3; i++) { - if (A[i][i] < 0) { + for (i = 0; i < 3; i++) + { + if (A[i][i] < 0) + { flip_sign_row(L, i); matmul(A, L, A); matmul(P, L, P); @@ -338,9 +362,12 @@ static void flip_PQ(long P[3][3], long Q[3][3]) { int i, j; - if (det(P) < 0) { - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { + if (det(P) < 0) + { + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { P[i][j] *= -1; Q[i][j] *= -1; } @@ -393,16 +420,18 @@ static void extended_gcd(long retvals[3], const long a, const long b) int i; long vals[6]; - vals[0] = a; /* r0 */ - vals[1] = b; /* r1 */ - vals[2] = 1; /* s0 */ - vals[3] = 0; /* s1 */ - vals[4] = 0; /* t0 */ - vals[5] = 1; /* t1 */ + vals[0] = a; /* r0 */ + vals[1] = b; /* r1 */ + vals[2] = 1; /* s0 */ + vals[3] = 0; /* s1 */ + vals[4] = 0; /* t0 */ + vals[5] = 1; /* t1 */ - for (i = 0; i < 1000; i++) { + for (i = 0; i < 1000; i++) + { extended_gcd_step(vals); - if (vals[1] == 0) { + if (vals[1] == 0) + { break; } } @@ -420,12 +449,15 @@ static void extended_gcd_step(long vals[6]) q = vals[0] / vals[1]; r2 = vals[0] % vals[1]; - if (r2 < 0) { - if (vals[1] > 0) { + if (r2 < 0) + { + if (vals[1] > 0) + { r2 += vals[1]; q -= 1; } - if (vals[1] < 0) { + if (vals[1] < 0) + { r2 -= vals[1]; q += 1; } @@ -462,8 +494,10 @@ static void transpose(long m[3][3]) long tmp; int i, j; - for (i = 0; i < 3; i++) { - for (j = i; j < 3; j++) { + for (i = 0; i < 3; i++) + { + for (j = i; j < 3; j++) + { tmp = m[i][j]; m[i][j] = m[j][i]; m[j][i] = tmp; @@ -478,14 +512,18 @@ static void matmul(long m[3][3], int i, j; long c[3][3]; - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { c[i][j] = a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; } } - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { m[i][j] = c[i][j]; } } @@ -493,12 +531,9 @@ static void matmul(long m[3][3], static long det(SNF3x3CONST long m[3][3]) { - return m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) - + m[0][1] * (m[1][2] * m[2][0] - m[1][0] * m[2][2]) - + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]); + return m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) + m[0][1] * (m[1][2] * m[2][0] - m[1][0] * m[2][2]) + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]); } - /* int main() * { * test_extended_gcd(); diff --git a/c/tetrahedron_method.c b/c/tetrahedron_method.c index b0ad399d..abf33873 100644 --- a/c/tetrahedron_method.c +++ b/c/tetrahedron_method.c @@ -39,7 +39,7 @@ #ifdef THMWARNING #include -#define warning_print(...) fprintf(stderr,__VA_ARGS__) +#define warning_print(...) fprintf(stderr, __VA_ARGS__) #else #define warning_print(...) #endif @@ -63,117 +63,596 @@ /* 6: c + b 2, 4, 7 */ /* 7: c + a + b 3, 5, 6 */ - -static long main_diagonals[4][3] = {{ 1, 1, 1}, /* 0-7 */ +static long main_diagonals[4][3] = {{1, 1, 1}, /* 0-7 */ {-1, 1, 1}, /* 1-6 */ - { 1,-1, 1}, /* 2-5 */ - { 1, 1,-1}}; /* 3-4 */ + {1, -1, 1}, /* 2-5 */ + {1, 1, -1}}; /* 3-4 */ static long db_relative_grid_address[4][24][4][3] = { - { - { { 0, 0, 0}, { 1, 0, 0}, { 1, 1, 0}, { 1, 1, 1}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 1, 0, 1}, { 1, 1, 1}, }, - { { 0, 0, 0}, { 0, 1, 0}, { 1, 1, 0}, { 1, 1, 1}, }, - { { 0, 0, 0}, { 0, 1, 0}, { 0, 1, 1}, { 1, 1, 1}, }, - { { 0, 0, 0}, { 0, 0, 1}, { 1, 0, 1}, { 1, 1, 1}, }, - { { 0, 0, 0}, { 0, 0, 1}, { 0, 1, 1}, { 1, 1, 1}, }, - { { 0, 0, 0}, { 0, 1, 0}, { 0, 1, 1}, {-1, 0, 0}, }, - { { 0, 0, 0}, { 0, 0, 1}, { 0, 1, 1}, {-1, 0, 0}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 1, 0, 1}, { 0, -1, 0}, }, - { { 0, 0, 0}, { 0, 0, 1}, { 1, 0, 1}, { 0, -1, 0}, }, - { { 0, 0, 0}, { 0, 0, 1}, {-1, -1, 0}, { 0, -1, 0}, }, - { { 0, 0, 0}, { 0, 0, 1}, {-1, -1, 0}, {-1, 0, 0}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 1, 1, 0}, { 0, 0, -1}, }, - { { 0, 0, 0}, { 0, 1, 0}, { 1, 1, 0}, { 0, 0, -1}, }, - { { 0, 0, 0}, { 0, 1, 0}, {-1, 0, -1}, { 0, 0, -1}, }, - { { 0, 0, 0}, { 0, 1, 0}, {-1, 0, -1}, {-1, 0, 0}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 0, -1, -1}, { 0, 0, -1}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 0, -1, -1}, { 0, -1, 0}, }, - { { 0, 0, 0}, {-1, -1, -1}, { 0, -1, -1}, { 0, 0, -1}, }, - { { 0, 0, 0}, {-1, -1, -1}, { 0, -1, -1}, { 0, -1, 0}, }, - { { 0, 0, 0}, {-1, -1, -1}, {-1, 0, -1}, { 0, 0, -1}, }, - { { 0, 0, 0}, {-1, -1, -1}, {-1, 0, -1}, {-1, 0, 0}, }, - { { 0, 0, 0}, {-1, -1, -1}, {-1, -1, 0}, { 0, -1, 0}, }, - { { 0, 0, 0}, {-1, -1, -1}, {-1, -1, 0}, {-1, 0, 0}, }, - }, - { - { { 0, 0, 0}, { 1, 0, 0}, { 0, 1, 0}, { 0, 1, 1}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 0, 0, 1}, { 0, 1, 1}, }, - { { 0, 0, 0}, {-1, 1, 0}, {-1, 1, 1}, {-1, 0, 0}, }, - { { 0, 0, 0}, {-1, 0, 1}, {-1, 1, 1}, {-1, 0, 0}, }, - { { 0, 0, 0}, {-1, 1, 0}, { 0, 1, 0}, {-1, 1, 1}, }, - { { 0, 0, 0}, { 0, 1, 0}, {-1, 1, 1}, { 0, 1, 1}, }, - { { 0, 0, 0}, {-1, 0, 1}, { 0, 0, 1}, {-1, 1, 1}, }, - { { 0, 0, 0}, { 0, 0, 1}, {-1, 1, 1}, { 0, 1, 1}, }, - { { 0, 0, 0}, { 0, 0, 1}, { 0, -1, 0}, { 1, -1, 0}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 0, 0, 1}, { 1, -1, 0}, }, - { { 0, 0, 0}, {-1, 0, 1}, { 0, -1, 0}, {-1, 0, 0}, }, - { { 0, 0, 0}, {-1, 0, 1}, { 0, 0, 1}, { 0, -1, 0}, }, - { { 0, 0, 0}, { 0, 1, 0}, { 0, 0, -1}, { 1, 0, -1}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 0, 1, 0}, { 1, 0, -1}, }, - { { 0, 0, 0}, {-1, 1, 0}, { 0, 0, -1}, {-1, 0, 0}, }, - { { 0, 0, 0}, {-1, 1, 0}, { 0, 1, 0}, { 0, 0, -1}, }, - { { 0, 0, 0}, { 0, -1, -1}, { 1, -1, -1}, { 0, 0, -1}, }, - { { 0, 0, 0}, { 0, -1, -1}, { 1, -1, -1}, { 0, -1, 0}, }, - { { 0, 0, 0}, { 1, -1, -1}, { 0, 0, -1}, { 1, 0, -1}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 1, -1, -1}, { 1, 0, -1}, }, - { { 0, 0, 0}, { 1, -1, -1}, { 0, -1, 0}, { 1, -1, 0}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 1, -1, -1}, { 1, -1, 0}, }, - { { 0, 0, 0}, { 0, -1, -1}, { 0, 0, -1}, {-1, 0, 0}, }, - { { 0, 0, 0}, { 0, -1, -1}, { 0, -1, 0}, {-1, 0, 0}, }, - }, - { - { { 0, 0, 0}, { 1, 0, 0}, { 0, 1, 0}, { 1, 0, 1}, }, - { { 0, 0, 0}, { 0, 1, 0}, { 0, 0, 1}, { 1, 0, 1}, }, - { { 0, 0, 0}, {-1, 1, 0}, { 0, 0, 1}, {-1, 0, 0}, }, - { { 0, 0, 0}, {-1, 1, 0}, { 0, 1, 0}, { 0, 0, 1}, }, - { { 0, 0, 0}, { 1, -1, 1}, { 0, -1, 0}, { 1, -1, 0}, }, - { { 0, 0, 0}, { 0, -1, 1}, { 1, -1, 1}, { 0, -1, 0}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 1, -1, 1}, { 1, -1, 0}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 1, -1, 1}, { 1, 0, 1}, }, - { { 0, 0, 0}, { 0, -1, 1}, { 1, -1, 1}, { 0, 0, 1}, }, - { { 0, 0, 0}, { 1, -1, 1}, { 0, 0, 1}, { 1, 0, 1}, }, - { { 0, 0, 0}, { 0, -1, 1}, { 0, -1, 0}, {-1, 0, 0}, }, - { { 0, 0, 0}, { 0, -1, 1}, { 0, 0, 1}, {-1, 0, 0}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 0, 0, -1}, { 0, 1, -1}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 0, 1, 0}, { 0, 1, -1}, }, - { { 0, 0, 0}, {-1, 0, -1}, { 0, 0, -1}, {-1, 1, -1}, }, - { { 0, 0, 0}, {-1, 0, -1}, {-1, 1, -1}, {-1, 0, 0}, }, - { { 0, 0, 0}, { 0, 0, -1}, {-1, 1, -1}, { 0, 1, -1}, }, - { { 0, 0, 0}, { 0, 1, 0}, {-1, 1, -1}, { 0, 1, -1}, }, - { { 0, 0, 0}, {-1, 1, 0}, {-1, 1, -1}, {-1, 0, 0}, }, - { { 0, 0, 0}, {-1, 1, 0}, { 0, 1, 0}, {-1, 1, -1}, }, - { { 0, 0, 0}, { 0, 0, -1}, { 0, -1, 0}, { 1, -1, 0}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 0, 0, -1}, { 1, -1, 0}, }, - { { 0, 0, 0}, {-1, 0, -1}, { 0, 0, -1}, { 0, -1, 0}, }, - { { 0, 0, 0}, {-1, 0, -1}, { 0, -1, 0}, {-1, 0, 0}, }, - }, - { - { { 0, 0, 0}, { 1, 0, 0}, { 1, 1, 0}, { 0, 0, 1}, }, - { { 0, 0, 0}, { 0, 1, 0}, { 1, 1, 0}, { 0, 0, 1}, }, - { { 0, 0, 0}, { 0, 1, 0}, {-1, 0, 1}, {-1, 0, 0}, }, - { { 0, 0, 0}, { 0, 1, 0}, {-1, 0, 1}, { 0, 0, 1}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 0, -1, 1}, { 0, -1, 0}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 0, -1, 1}, { 0, 0, 1}, }, - { { 0, 0, 0}, {-1, -1, 1}, {-1, -1, 0}, { 0, -1, 0}, }, - { { 0, 0, 0}, {-1, -1, 1}, {-1, -1, 0}, {-1, 0, 0}, }, - { { 0, 0, 0}, {-1, -1, 1}, { 0, -1, 1}, { 0, -1, 0}, }, - { { 0, 0, 0}, {-1, -1, 1}, {-1, 0, 1}, {-1, 0, 0}, }, - { { 0, 0, 0}, {-1, -1, 1}, { 0, -1, 1}, { 0, 0, 1}, }, - { { 0, 0, 0}, {-1, -1, 1}, {-1, 0, 1}, { 0, 0, 1}, }, - { { 0, 0, 0}, { 0, 0, -1}, { 1, 0, -1}, { 1, 1, -1}, }, - { { 0, 0, 0}, { 0, 0, -1}, { 0, 1, -1}, { 1, 1, -1}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 1, 0, -1}, { 1, 1, -1}, }, - { { 0, 0, 0}, { 0, 1, 0}, { 0, 1, -1}, { 1, 1, -1}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 1, 1, 0}, { 1, 1, -1}, }, - { { 0, 0, 0}, { 0, 1, 0}, { 1, 1, 0}, { 1, 1, -1}, }, - { { 0, 0, 0}, { 0, 0, -1}, { 0, 1, -1}, {-1, 0, 0}, }, - { { 0, 0, 0}, { 0, 1, 0}, { 0, 1, -1}, {-1, 0, 0}, }, - { { 0, 0, 0}, { 0, 0, -1}, { 1, 0, -1}, { 0, -1, 0}, }, - { { 0, 0, 0}, { 1, 0, 0}, { 1, 0, -1}, { 0, -1, 0}, }, - { { 0, 0, 0}, { 0, 0, -1}, {-1, -1, 0}, { 0, -1, 0}, }, - { { 0, 0, 0}, { 0, 0, -1}, {-1, -1, 0}, {-1, 0, 0}, }, - }, + { + { + {0, 0, 0}, + {1, 0, 0}, + {1, 1, 0}, + {1, 1, 1}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {1, 0, 1}, + {1, 1, 1}, + }, + { + {0, 0, 0}, + {0, 1, 0}, + {1, 1, 0}, + {1, 1, 1}, + }, + { + {0, 0, 0}, + {0, 1, 0}, + {0, 1, 1}, + {1, 1, 1}, + }, + { + {0, 0, 0}, + {0, 0, 1}, + {1, 0, 1}, + {1, 1, 1}, + }, + { + {0, 0, 0}, + {0, 0, 1}, + {0, 1, 1}, + {1, 1, 1}, + }, + { + {0, 0, 0}, + {0, 1, 0}, + {0, 1, 1}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {0, 0, 1}, + {0, 1, 1}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {1, 0, 1}, + {0, -1, 0}, + }, + { + {0, 0, 0}, + {0, 0, 1}, + {1, 0, 1}, + {0, -1, 0}, + }, + { + {0, 0, 0}, + {0, 0, 1}, + {-1, -1, 0}, + {0, -1, 0}, + }, + { + {0, 0, 0}, + {0, 0, 1}, + {-1, -1, 0}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {1, 1, 0}, + {0, 0, -1}, + }, + { + {0, 0, 0}, + {0, 1, 0}, + {1, 1, 0}, + {0, 0, -1}, + }, + { + {0, 0, 0}, + {0, 1, 0}, + {-1, 0, -1}, + {0, 0, -1}, + }, + { + {0, 0, 0}, + {0, 1, 0}, + {-1, 0, -1}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {0, -1, -1}, + {0, 0, -1}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {0, -1, -1}, + {0, -1, 0}, + }, + { + {0, 0, 0}, + {-1, -1, -1}, + {0, -1, -1}, + {0, 0, -1}, + }, + { + {0, 0, 0}, + {-1, -1, -1}, + {0, -1, -1}, + {0, -1, 0}, + }, + { + {0, 0, 0}, + {-1, -1, -1}, + {-1, 0, -1}, + {0, 0, -1}, + }, + { + {0, 0, 0}, + {-1, -1, -1}, + {-1, 0, -1}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {-1, -1, -1}, + {-1, -1, 0}, + {0, -1, 0}, + }, + { + {0, 0, 0}, + {-1, -1, -1}, + {-1, -1, 0}, + {-1, 0, 0}, + }, + }, + { + { + {0, 0, 0}, + {1, 0, 0}, + {0, 1, 0}, + {0, 1, 1}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {0, 0, 1}, + {0, 1, 1}, + }, + { + {0, 0, 0}, + {-1, 1, 0}, + {-1, 1, 1}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {-1, 0, 1}, + {-1, 1, 1}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {-1, 1, 0}, + {0, 1, 0}, + {-1, 1, 1}, + }, + { + {0, 0, 0}, + {0, 1, 0}, + {-1, 1, 1}, + {0, 1, 1}, + }, + { + {0, 0, 0}, + {-1, 0, 1}, + {0, 0, 1}, + {-1, 1, 1}, + }, + { + {0, 0, 0}, + {0, 0, 1}, + {-1, 1, 1}, + {0, 1, 1}, + }, + { + {0, 0, 0}, + {0, 0, 1}, + {0, -1, 0}, + {1, -1, 0}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {0, 0, 1}, + {1, -1, 0}, + }, + { + {0, 0, 0}, + {-1, 0, 1}, + {0, -1, 0}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {-1, 0, 1}, + {0, 0, 1}, + {0, -1, 0}, + }, + { + {0, 0, 0}, + {0, 1, 0}, + {0, 0, -1}, + {1, 0, -1}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {0, 1, 0}, + {1, 0, -1}, + }, + { + {0, 0, 0}, + {-1, 1, 0}, + {0, 0, -1}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {-1, 1, 0}, + {0, 1, 0}, + {0, 0, -1}, + }, + { + {0, 0, 0}, + {0, -1, -1}, + {1, -1, -1}, + {0, 0, -1}, + }, + { + {0, 0, 0}, + {0, -1, -1}, + {1, -1, -1}, + {0, -1, 0}, + }, + { + {0, 0, 0}, + {1, -1, -1}, + {0, 0, -1}, + {1, 0, -1}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {1, -1, -1}, + {1, 0, -1}, + }, + { + {0, 0, 0}, + {1, -1, -1}, + {0, -1, 0}, + {1, -1, 0}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {1, -1, -1}, + {1, -1, 0}, + }, + { + {0, 0, 0}, + {0, -1, -1}, + {0, 0, -1}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {0, -1, -1}, + {0, -1, 0}, + {-1, 0, 0}, + }, + }, + { + { + {0, 0, 0}, + {1, 0, 0}, + {0, 1, 0}, + {1, 0, 1}, + }, + { + {0, 0, 0}, + {0, 1, 0}, + {0, 0, 1}, + {1, 0, 1}, + }, + { + {0, 0, 0}, + {-1, 1, 0}, + {0, 0, 1}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {-1, 1, 0}, + {0, 1, 0}, + {0, 0, 1}, + }, + { + {0, 0, 0}, + {1, -1, 1}, + {0, -1, 0}, + {1, -1, 0}, + }, + { + {0, 0, 0}, + {0, -1, 1}, + {1, -1, 1}, + {0, -1, 0}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {1, -1, 1}, + {1, -1, 0}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {1, -1, 1}, + {1, 0, 1}, + }, + { + {0, 0, 0}, + {0, -1, 1}, + {1, -1, 1}, + {0, 0, 1}, + }, + { + {0, 0, 0}, + {1, -1, 1}, + {0, 0, 1}, + {1, 0, 1}, + }, + { + {0, 0, 0}, + {0, -1, 1}, + {0, -1, 0}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {0, -1, 1}, + {0, 0, 1}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {0, 0, -1}, + {0, 1, -1}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {0, 1, 0}, + {0, 1, -1}, + }, + { + {0, 0, 0}, + {-1, 0, -1}, + {0, 0, -1}, + {-1, 1, -1}, + }, + { + {0, 0, 0}, + {-1, 0, -1}, + {-1, 1, -1}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {0, 0, -1}, + {-1, 1, -1}, + {0, 1, -1}, + }, + { + {0, 0, 0}, + {0, 1, 0}, + {-1, 1, -1}, + {0, 1, -1}, + }, + { + {0, 0, 0}, + {-1, 1, 0}, + {-1, 1, -1}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {-1, 1, 0}, + {0, 1, 0}, + {-1, 1, -1}, + }, + { + {0, 0, 0}, + {0, 0, -1}, + {0, -1, 0}, + {1, -1, 0}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {0, 0, -1}, + {1, -1, 0}, + }, + { + {0, 0, 0}, + {-1, 0, -1}, + {0, 0, -1}, + {0, -1, 0}, + }, + { + {0, 0, 0}, + {-1, 0, -1}, + {0, -1, 0}, + {-1, 0, 0}, + }, + }, + { + { + {0, 0, 0}, + {1, 0, 0}, + {1, 1, 0}, + {0, 0, 1}, + }, + { + {0, 0, 0}, + {0, 1, 0}, + {1, 1, 0}, + {0, 0, 1}, + }, + { + {0, 0, 0}, + {0, 1, 0}, + {-1, 0, 1}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {0, 1, 0}, + {-1, 0, 1}, + {0, 0, 1}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {0, -1, 1}, + {0, -1, 0}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {0, -1, 1}, + {0, 0, 1}, + }, + { + {0, 0, 0}, + {-1, -1, 1}, + {-1, -1, 0}, + {0, -1, 0}, + }, + { + {0, 0, 0}, + {-1, -1, 1}, + {-1, -1, 0}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {-1, -1, 1}, + {0, -1, 1}, + {0, -1, 0}, + }, + { + {0, 0, 0}, + {-1, -1, 1}, + {-1, 0, 1}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {-1, -1, 1}, + {0, -1, 1}, + {0, 0, 1}, + }, + { + {0, 0, 0}, + {-1, -1, 1}, + {-1, 0, 1}, + {0, 0, 1}, + }, + { + {0, 0, 0}, + {0, 0, -1}, + {1, 0, -1}, + {1, 1, -1}, + }, + { + {0, 0, 0}, + {0, 0, -1}, + {0, 1, -1}, + {1, 1, -1}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {1, 0, -1}, + {1, 1, -1}, + }, + { + {0, 0, 0}, + {0, 1, 0}, + {0, 1, -1}, + {1, 1, -1}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {1, 1, 0}, + {1, 1, -1}, + }, + { + {0, 0, 0}, + {0, 1, 0}, + {1, 1, 0}, + {1, 1, -1}, + }, + { + {0, 0, 0}, + {0, 0, -1}, + {0, 1, -1}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {0, 1, 0}, + {0, 1, -1}, + {-1, 0, 0}, + }, + { + {0, 0, 0}, + {0, 0, -1}, + {1, 0, -1}, + {0, -1, 0}, + }, + { + {0, 0, 0}, + {1, 0, 0}, + {1, 0, -1}, + {0, -1, 0}, + }, + { + {0, 0, 0}, + {0, 0, -1}, + {-1, -1, 0}, + {0, -1, 0}, + }, + { + {0, 0, 0}, + {0, 0, -1}, + {-1, -1, 0}, + {-1, 0, 0}, + }, + }, }; static double @@ -279,7 +758,6 @@ static double _I_33(const double omega, const double vertices_omegas[4]); static double _I_4(void); - void thm_get_relative_grid_address(long relative_grid_address[24][4][3], const double rec_lattice[3][3]) { @@ -287,11 +765,14 @@ void thm_get_relative_grid_address(long relative_grid_address[24][4][3], main_diag_index = get_main_diagonal(rec_lattice); - for (i = 0; i < 24; i++) { - for (j = 0; j < 4; j++) { - for (k = 0; k < 3; k++) { + for (i = 0; i < 24; i++) + { + for (j = 0; j < 4; j++) + { + for (k = 0; k < 3; k++) + { relative_grid_address[i][j][k] = - db_relative_grid_address[main_diag_index][i][j][k]; + db_relative_grid_address[main_diag_index][i][j][k]; } } } @@ -301,12 +782,16 @@ void thm_get_all_relative_grid_address(long relative_grid_address[4][24][4][3]) { long i, j, k, main_diag_index; - for (main_diag_index = 0; main_diag_index < 4; main_diag_index++) { - for (i = 0; i < 24; i++) { - for (j = 0; j < 4; j++) { - for (k = 0; k < 3; k++) { + for (main_diag_index = 0; main_diag_index < 4; main_diag_index++) + { + for (i = 0; i < 24; i++) + { + for (j = 0; j < 4; j++) + { + for (k = 0; k < 3; k++) + { relative_grid_address[main_diag_index][i][j][k] = - db_relative_grid_address[main_diag_index][i][j][k]; + db_relative_grid_address[main_diag_index][i][j][k]; } } } @@ -317,11 +802,14 @@ double thm_get_integration_weight(const double omega, const double tetrahedra_omegas[24][4], const char function) { - if (function == 'I') { + if (function == 'I') + { return get_integration_weight(omega, tetrahedra_omegas, _g, _I); - } else { + } + else + { return get_integration_weight(omega, tetrahedra_omegas, _n, _J); @@ -336,20 +824,27 @@ long thm_in_tetrahedra(const double f0, const double freq_vertices[24][4]) fmin = freq_vertices[0][0]; fmax = freq_vertices[0][0]; - for (i = 0; i < 24; i++) { - for (j = 0; j < 4; j++) { - if (fmin > freq_vertices[i][j]) { + for (i = 0; i < 24; i++) + { + for (j = 0; j < 4; j++) + { + if (fmin > freq_vertices[i][j]) + { fmin = freq_vertices[i][j]; } - if (fmax < freq_vertices[i][j]) { + if (fmax < freq_vertices[i][j]) + { fmax = freq_vertices[i][j]; } } } - if (fmin > f0 || fmax < f0) { + if (fmin > f0 || fmax < f0) + { return 0; - } else { + } + else + { return 1; } } @@ -370,24 +865,39 @@ get_integration_weight(const double omega, double v[4]; sum = 0; - for (i = 0; i < 24; i++) { - for (j = 0; j < 4; j++) { + for (i = 0; i < 24; i++) + { + for (j = 0; j < 4; j++) + { v[j] = tetrahedra_omegas[i][j]; } ci = sort_omegas(v); - if (omega < v[0]) { + if (omega < v[0]) + { sum += IJ(0, ci, omega, v) * gn(0, omega, v); - } else { - if (v[0] < omega && omega < v[1]) { + } + else + { + if (v[0] < omega && omega < v[1]) + { sum += IJ(1, ci, omega, v) * gn(1, omega, v); - } else { - if (v[1] < omega && omega < v[2]) { + } + else + { + if (v[1] < omega && omega < v[2]) + { sum += IJ(2, ci, omega, v) * gn(2, omega, v); - } else { - if (v[2] < omega && omega < v[3]) { + } + else + { + if (v[2] < omega && omega < v[3]) + { sum += IJ(3, ci, omega, v) * gn(3, omega, v); - } else { - if (v[3] < omega) { + } + else + { + if (v[3] < omega) + { sum += IJ(4, ci, omega, v) * gn(4, omega, v); } } @@ -405,63 +915,85 @@ static long sort_omegas(double v[4]) i = 0; - if (v[0] > v[1]) { + if (v[0] > v[1]) + { w[0] = v[1]; w[1] = v[0]; i = 1; - } else { + } + else + { w[0] = v[0]; w[1] = v[1]; } - if (v[2] > v[3]) { + if (v[2] > v[3]) + { w[2] = v[3]; w[3] = v[2]; - } else { + } + else + { w[2] = v[2]; w[3] = v[3]; } - if (w[0] > w[2]) { + if (w[0] > w[2]) + { v[0] = w[2]; v[1] = w[0]; - if (i == 0) { + if (i == 0) + { i = 4; } - } else { + } + else + { v[0] = w[0]; v[1] = w[2]; } - if (w[1] > w[3]) { + if (w[1] > w[3]) + { v[3] = w[1]; v[2] = w[3]; - if (i == 1) { + if (i == 1) + { i = 3; } - } else { + } + else + { v[3] = w[3]; v[2] = w[1]; - if (i == 1) { + if (i == 1) + { i = 5; } } - if (v[1] > v[2]) { + if (v[1] > v[2]) + { w[1] = v[1]; v[1] = v[2]; v[2] = w[1]; - if (i == 4) { + if (i == 4) + { i = 2; } - if (i == 5) { + if (i == 5) + { i = 1; } - } else { - if (i == 4) { + } + else + { + if (i == 4) + { i = 1; } - if (i == 5) { + if (i == 5) + { i = 2; } } @@ -477,10 +1009,12 @@ static long get_main_diagonal(const double rec_lattice[3][3]) shortest = 0; multiply_matrix_vector_dl3(main_diag, rec_lattice, main_diagonals[0]); min_length = norm_squared_d3(main_diag); - for (i = 1; i < 4; i++) { + for (i = 1; i < 4; i++) + { multiply_matrix_vector_dl3(main_diag, rec_lattice, main_diagonals[i]); length = norm_squared_d3(main_diag); - if (min_length > length) { + if (min_length > length) + { min_length = length; shortest = i; } @@ -500,11 +1034,13 @@ static void multiply_matrix_vector_dl3(double v[3], long i; double c[3]; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { c[i] = a[i][0] * b[0] + a[i][1] * b[1] + a[i][2] * b[2]; } - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { v[i] = c[i]; } } @@ -523,11 +1059,13 @@ static double _J(const long i, const double omega, const double vertices_omegas[4]) { - switch (i) { + switch (i) + { case 0: return _J_0(); case 1: - switch (ci) { + switch (ci) + { case 0: return _J_10(omega, vertices_omegas); case 1: @@ -538,7 +1076,8 @@ static double _J(const long i, return _J_13(omega, vertices_omegas); } case 2: - switch (ci) { + switch (ci) + { case 0: return _J_20(omega, vertices_omegas); case 1: @@ -549,7 +1088,8 @@ static double _J(const long i, return _J_23(omega, vertices_omegas); } case 3: - switch (ci) { + switch (ci) + { case 0: return _J_30(omega, vertices_omegas); case 1: @@ -571,17 +1111,18 @@ static double _J(const long i, return 0; } - static double _I(const long i, const long ci, const double omega, const double vertices_omegas[4]) { - switch (i) { + switch (i) + { case 0: return _I_0(); case 1: - switch (ci) { + switch (ci) + { case 0: return _I_10(omega, vertices_omegas); case 1: @@ -592,7 +1133,8 @@ static double _I(const long i, return _I_13(omega, vertices_omegas); } case 2: - switch (ci) { + switch (ci) + { case 0: return _I_20(omega, vertices_omegas); case 1: @@ -603,7 +1145,8 @@ static double _I(const long i, return _I_23(omega, vertices_omegas); } case 3: - switch (ci) { + switch (ci) + { case 0: return _I_30(omega, vertices_omegas); case 1: @@ -629,7 +1172,8 @@ static double _n(const long i, const double omega, const double vertices_omegas[4]) { - switch (i) { + switch (i) + { case 0: return _n_0(); case 1: @@ -654,7 +1198,8 @@ static double _g(const long i, const double omega, const double vertices_omegas[4]) { - switch (i) { + switch (i) + { case 0: return _g_0(); case 1: @@ -695,13 +1240,13 @@ static double _n_2(const double omega, const double vertices_omegas[4]) { return (_f(3, 1, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) + + _f(2, 1, omega, vertices_omegas) + _f(3, 0, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) + + _f(1, 3, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) + _f(3, 0, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) * - _f(1, 2, omega, vertices_omegas)); + _f(2, 0, omega, vertices_omegas) * + _f(1, 2, omega, vertices_omegas)); } /* omega2 < omega < omega3 */ @@ -710,8 +1255,8 @@ static double _n_3(const double omega, { return (1.0 - _f(0, 3, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 3, omega, vertices_omegas)); + _f(1, 3, omega, vertices_omegas) * + _f(2, 3, omega, vertices_omegas)); } /* omega4 < omega */ @@ -743,9 +1288,9 @@ static double _g_2(const double omega, return (3 / (vertices_omegas[3] - vertices_omegas[0]) * (_f(1, 2, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) + + _f(2, 0, omega, vertices_omegas) + _f(2, 1, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas))); + _f(1, 3, omega, vertices_omegas))); } /* omega3 < omega < omega4 */ @@ -775,7 +1320,8 @@ static double _J_10(const double omega, return (1.0 + _f(0, 1, omega, vertices_omegas) + _f(0, 2, omega, vertices_omegas) + - _f(0, 3, omega, vertices_omegas)) / 4; + _f(0, 3, omega, vertices_omegas)) / + 4; } static double _J_11(const double omega, @@ -800,71 +1346,75 @@ static double _J_20(const double omega, const double vertices_omegas[4]) { return (_f(3, 1, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) + + _f(2, 1, omega, vertices_omegas) + _f(3, 0, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) * - (1.0 + - _f(0, 3, omega, vertices_omegas)) + + _f(1, 3, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) * + (1.0 + + _f(0, 3, omega, vertices_omegas)) + _f(3, 0, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) * - _f(1, 2, omega, vertices_omegas) * - (1.0 + - _f(0, 3, omega, vertices_omegas) + - _f(0, 2, omega, vertices_omegas))) / 4 / _n_2(omega, vertices_omegas); + _f(2, 0, omega, vertices_omegas) * + _f(1, 2, omega, vertices_omegas) * + (1.0 + + _f(0, 3, omega, vertices_omegas) + + _f(0, 2, omega, vertices_omegas))) / + 4 / _n_2(omega, vertices_omegas); } static double _J_21(const double omega, const double vertices_omegas[4]) { return (_f(3, 1, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) * - (1.0 + - _f(1, 3, omega, vertices_omegas) + - _f(1, 2, omega, vertices_omegas)) + + _f(2, 1, omega, vertices_omegas) * + (1.0 + + _f(1, 3, omega, vertices_omegas) + + _f(1, 2, omega, vertices_omegas)) + _f(3, 0, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) * - (_f(1, 3, omega, vertices_omegas) + - _f(1, 2, omega, vertices_omegas)) + + _f(1, 3, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) * + (_f(1, 3, omega, vertices_omegas) + + _f(1, 2, omega, vertices_omegas)) + _f(3, 0, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) * - _f(1, 2, omega, vertices_omegas) * - _f(1, 2, omega, vertices_omegas)) / 4 / _n_2(omega, vertices_omegas); + _f(2, 0, omega, vertices_omegas) * + _f(1, 2, omega, vertices_omegas) * + _f(1, 2, omega, vertices_omegas)) / + 4 / _n_2(omega, vertices_omegas); } static double _J_22(const double omega, const double vertices_omegas[4]) { return (_f(3, 1, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) + + _f(2, 1, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) + _f(3, 0, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) + + _f(1, 3, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) + _f(3, 0, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) * - _f(1, 2, omega, vertices_omegas) * - (_f(2, 1, omega, vertices_omegas) + - _f(2, 0, omega, vertices_omegas))) / 4 / _n_2(omega, vertices_omegas); + _f(2, 0, omega, vertices_omegas) * + _f(1, 2, omega, vertices_omegas) * + (_f(2, 1, omega, vertices_omegas) + + _f(2, 0, omega, vertices_omegas))) / + 4 / _n_2(omega, vertices_omegas); } static double _J_23(const double omega, const double vertices_omegas[4]) { return (_f(3, 1, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) * - _f(3, 1, omega, vertices_omegas) + + _f(2, 1, omega, vertices_omegas) * + _f(3, 1, omega, vertices_omegas) + _f(3, 0, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) * - (_f(3, 1, omega, vertices_omegas) + - _f(3, 0, omega, vertices_omegas)) + + _f(1, 3, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) * + (_f(3, 1, omega, vertices_omegas) + + _f(3, 0, omega, vertices_omegas)) + _f(3, 0, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) * - _f(1, 2, omega, vertices_omegas) * - _f(3, 0, omega, vertices_omegas)) / 4 / _n_2(omega, vertices_omegas); + _f(2, 0, omega, vertices_omegas) * + _f(1, 2, omega, vertices_omegas) * + _f(3, 0, omega, vertices_omegas)) / + 4 / _n_2(omega, vertices_omegas); } static double _J_30(const double omega, @@ -872,9 +1422,10 @@ static double _J_30(const double omega, { return (1.0 - _f(0, 3, omega, vertices_omegas) * - _f(0, 3, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 3, omega, vertices_omegas)) / 4 / _n_3(omega, vertices_omegas); + _f(0, 3, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas) * + _f(2, 3, omega, vertices_omegas)) / + 4 / _n_3(omega, vertices_omegas); } static double _J_31(const double omega, @@ -882,9 +1433,10 @@ static double _J_31(const double omega, { return (1.0 - _f(0, 3, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 3, omega, vertices_omegas)) / 4 / _n_3(omega, vertices_omegas); + _f(1, 3, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas) * + _f(2, 3, omega, vertices_omegas)) / + 4 / _n_3(omega, vertices_omegas); } static double _J_32(const double omega, @@ -892,9 +1444,10 @@ static double _J_32(const double omega, { return (1.0 - _f(0, 3, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 3, omega, vertices_omegas) * - _f(2, 3, omega, vertices_omegas)) / 4 / _n_3(omega, vertices_omegas); + _f(1, 3, omega, vertices_omegas) * + _f(2, 3, omega, vertices_omegas) * + _f(2, 3, omega, vertices_omegas)) / + 4 / _n_3(omega, vertices_omegas); } static double _J_33(const double omega, @@ -902,12 +1455,13 @@ static double _J_33(const double omega, { return (1.0 - _f(0, 3, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 3, omega, vertices_omegas) * - (1.0 + - _f(3, 0, omega, vertices_omegas) + - _f(3, 1, omega, vertices_omegas) + - _f(3, 2, omega, vertices_omegas))) / 4 / _n_3(omega, vertices_omegas); + _f(1, 3, omega, vertices_omegas) * + _f(2, 3, omega, vertices_omegas) * + (1.0 + + _f(3, 0, omega, vertices_omegas) + + _f(3, 1, omega, vertices_omegas) + + _f(3, 2, omega, vertices_omegas))) / + 4 / _n_3(omega, vertices_omegas); } static double _J_4(void) @@ -925,7 +1479,8 @@ static double _I_10(const double omega, { return (_f(0, 1, omega, vertices_omegas) + _f(0, 2, omega, vertices_omegas) + - _f(0, 3, omega, vertices_omegas)) / 3; + _f(0, 3, omega, vertices_omegas)) / + 3; } static double _I_11(const double omega, @@ -951,12 +1506,13 @@ static double _I_20(const double omega, { return (_f(0, 3, omega, vertices_omegas) + _f(0, 2, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) * - _f(1, 2, omega, vertices_omegas) / - (_f(1, 2, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) + - _f(2, 1, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas))) / 3; + _f(2, 0, omega, vertices_omegas) * + _f(1, 2, omega, vertices_omegas) / + (_f(1, 2, omega, vertices_omegas) * + _f(2, 0, omega, vertices_omegas) + + _f(2, 1, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas))) / + 3; } static double _I_21(const double omega, @@ -964,12 +1520,13 @@ static double _I_21(const double omega, { return (_f(1, 2, omega, vertices_omegas) + _f(1, 3, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) / - (_f(1, 2, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) + - _f(2, 1, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas))) / 3; + _f(1, 3, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) / + (_f(1, 2, omega, vertices_omegas) * + _f(2, 0, omega, vertices_omegas) + + _f(2, 1, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas))) / + 3; } static double _I_22(const double omega, @@ -977,12 +1534,13 @@ static double _I_22(const double omega, { return (_f(2, 1, omega, vertices_omegas) + _f(2, 0, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) * - _f(1, 2, omega, vertices_omegas) / - (_f(1, 2, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) + - _f(2, 1, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas))) / 3; + _f(2, 0, omega, vertices_omegas) * + _f(1, 2, omega, vertices_omegas) / + (_f(1, 2, omega, vertices_omegas) * + _f(2, 0, omega, vertices_omegas) + + _f(2, 1, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas))) / + 3; } static double _I_23(const double omega, @@ -990,12 +1548,13 @@ static double _I_23(const double omega, { return (_f(3, 0, omega, vertices_omegas) + _f(3, 1, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) / - (_f(1, 2, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) + - _f(2, 1, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas))) / 3; + _f(1, 3, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) / + (_f(1, 2, omega, vertices_omegas) * + _f(2, 0, omega, vertices_omegas) + + _f(2, 1, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas))) / + 3; } static double _I_30(const double omega, @@ -1021,7 +1580,8 @@ static double _I_33(const double omega, { return (_f(3, 0, omega, vertices_omegas) + _f(3, 1, omega, vertices_omegas) + - _f(3, 2, omega, vertices_omegas)) / 3; + _f(3, 2, omega, vertices_omegas)) / + 3; } static double _I_4(void) diff --git a/c/triplet.c b/c/triplet.c index 764af9f6..7794fe2c 100644 --- a/c/triplet.c +++ b/c/triplet.c @@ -99,25 +99,25 @@ void tpl_get_integration_weight(double *iw, #ifdef PHPYOPENMP #pragma omp parallel for if (openmp_per_triplets) #endif - for (i = 0; i < num_triplets; i++) { + for (i = 0; i < num_triplets; i++) + { tpi_get_integration_weight(iw + i * num_band_prod, iw_zero + i * num_band_prod, - frequency_points, /* f0 */ + frequency_points, /* f0 */ num_band0, tp_relative_grid_address, triplets[i], num_triplets, bzgrid, - frequencies1, /* f1 */ + frequencies1, /* f1 */ num_band1, - frequencies2, /* f2 */ + frequencies2, /* f2 */ num_band2, tp_type, openmp_per_bands); } } - void tpl_get_integration_weight_with_sigma(double *iw, char *iw_zero, const double sigma, @@ -140,35 +140,38 @@ void tpl_get_integration_weight_with_sigma(double *iw, #ifdef PHPYOPENMP #pragma omp parallel for #endif - for (i = 0; i < num_triplets; i++) { + for (i = 0; i < num_triplets; i++) + { tpi_get_integration_weight_with_sigma( - iw + i * num_band_prod, - iw_zero + i * num_band_prod, - sigma, - cutoff, - frequency_points, - num_band0, - triplets[i], - const_adrs_shift, - frequencies, - num_band, - tp_type, - 0); + iw + i * num_band_prod, + iw_zero + i * num_band_prod, + sigma, + cutoff, + frequency_points, + num_band0, + triplets[i], + const_adrs_shift, + frequencies, + num_band, + tp_type, + 0); } } - long tpl_is_N(const long triplet[3], const long (*bz_grid_addresses)[3]) { long i, j, sum_q, is_N; is_N = 1; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { sum_q = 0; - for (j = 0; j < 3; j++) { /* 1st, 2nd, 3rd triplet */ + for (j = 0; j < 3; j++) + { /* 1st, 2nd, 3rd triplet */ sum_q += bz_grid_addresses[triplet[j]][i]; } - if (sum_q) { + if (sum_q) + { is_N = 0; break; } @@ -177,28 +180,33 @@ long tpl_is_N(const long triplet[3], const long (*bz_grid_addresses)[3]) } void tpl_set_relative_grid_address( - long tp_relative_grid_address[2][24][4][3], - const long relative_grid_address[24][4][3], - const long tp_type) + long tp_relative_grid_address[2][24][4][3], + const long relative_grid_address[24][4][3], + const long tp_type) { long i, j, k, l; long signs[2]; signs[0] = 1; signs[1] = 1; - if ((tp_type == 2) || (tp_type == 3)) { + if ((tp_type == 2) || (tp_type == 3)) + { /* q1+q2+q3=G */ /* To set q2+1, q3-1 is needed to keep G */ signs[1] = -1; } /* tp_type == 4, q+k_i-k_f=G */ - for (i = 0; i < 2; i++) { - for (j = 0; j < 24; j++) { - for (k = 0; k < 4; k++) { - for (l = 0; l < 3; l++) { + for (i = 0; i < 2; i++) + { + for (j = 0; j < 24; j++) + { + for (k = 0; k < 4; k++) + { + for (l = 0; l < 3; l++) + { tp_relative_grid_address[i][j][k][l] = - relative_grid_address[j][k][l] * signs[i]; + relative_grid_address[j][k][l] * signs[i]; } } } diff --git a/c/triplet_grid.c b/c/triplet_grid.c index c283c9c1..d3c72b7b 100644 --- a/c/triplet_grid.c +++ b/c/triplet_grid.c @@ -46,19 +46,19 @@ static long get_ir_triplets_at_q(long *map_triplets, long *map_q, const long grid_point, const long D_diag[3], - const RotMats * rot_reciprocal, + const RotMats *rot_reciprocal, const long swappable); static long get_ir_triplets_at_q_perm_q1q2(long *map_triplets, const long *map_q, const long grid_point, const long D_diag[3], - const RotMats * rot_reciprocal_q, + const RotMats *rot_reciprocal_q, const long num_ir_q); static long get_ir_triplets_at_q_noperm(long *map_triplets, const long *map_q, const long grid_point, const long D_diag[3], - const RotMats * rot_reciprocal_q); + const RotMats *rot_reciprocal_q); static long get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point, const ConstBZGrid *bzgrid, @@ -76,7 +76,7 @@ static void get_BZ_triplets_at_q_type2(long (*triplets)[3], static double get_squared_distance(const long G[3], const double LQD_inv[3][3]); static void get_LQD_inv(double LQD_inv[3][3], const ConstBZGrid *bzgrid); -static RotMats *get_reciprocal_point_group_with_q(const RotMats * rot_reciprocal, +static RotMats *get_reciprocal_point_group_with_q(const RotMats *rot_reciprocal, const long D_diag[3], const long grid_point); static RotMats *get_reciprocal_point_group(const long (*rec_rotations_in)[3][3], @@ -100,7 +100,8 @@ long tpk_get_ir_triplets_at_q(long *map_triplets, num_rot, is_time_reversal, 0); - if (rotations == NULL) { + if (rotations == NULL) + { return 0; } @@ -131,7 +132,7 @@ static long get_ir_triplets_at_q(long *map_triplets, long *map_q, const long grid_point, const long D_diag[3], - const RotMats * rot_reciprocal, + const RotMats *rot_reciprocal, const long swappable) { long i, num_ir_q, num_ir_triplets; @@ -140,7 +141,8 @@ static long get_ir_triplets_at_q(long *map_triplets, rot_reciprocal_q = NULL; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { PS[i] = 0; } @@ -155,20 +157,25 @@ static long get_ir_triplets_at_q(long *map_triplets, D_diag, PS); num_ir_q = 0; - for (i = 0; i < D_diag[0] * D_diag[1] * D_diag[2]; i++) { - if (map_q[i] == i) { + for (i = 0; i < D_diag[0] * D_diag[1] * D_diag[2]; i++) + { + if (map_q[i] == i) + { num_ir_q++; } } - if (swappable) { + if (swappable) + { num_ir_triplets = get_ir_triplets_at_q_perm_q1q2(map_triplets, map_q, grid_point, D_diag, rot_reciprocal_q, num_ir_q); - } else { + } + else + { num_ir_triplets = get_ir_triplets_at_q_noperm(map_triplets, map_q, grid_point, @@ -186,7 +193,7 @@ static long get_ir_triplets_at_q_perm_q1q2(long *map_triplets, const long *map_q, const long grid_point, const long D_diag[3], - const RotMats * rot_reciprocal_q, + const RotMats *rot_reciprocal_q, const long num_ir_q) { long i, j, num_grid, num_ir_triplets, ir_gp, count; @@ -199,19 +206,23 @@ static long get_ir_triplets_at_q_perm_q1q2(long *map_triplets, num_grid = D_diag[0] * D_diag[1] * D_diag[2]; - if ((q_2 = (long*) malloc(sizeof(long) * num_ir_q)) == NULL) { + if ((q_2 = (long *)malloc(sizeof(long) * num_ir_q)) == NULL) + { warning_print("Memory could not be allocated."); goto ret; } - if ((ir_gps_at_q = (long*) malloc(sizeof(long) * num_ir_q)) == NULL) { + if ((ir_gps_at_q = (long *)malloc(sizeof(long) * num_ir_q)) == NULL) + { warning_print("Memory could not be allocated."); goto ret; } count = 0; - for (i = 0; i < num_grid; i++) { - if (map_q[i] == i) { + for (i = 0; i < num_grid; i++) + { + if (map_q[i] == i) + { ir_gps_at_q[count] = i; count++; } @@ -222,22 +233,28 @@ static long get_ir_triplets_at_q_perm_q1q2(long *map_triplets, #ifdef PHPYOPENMP #pragma omp parallel for private(j, adrs1, adrs2) #endif - for (i = 0; i < num_ir_q; i++) { + for (i = 0; i < num_ir_q; i++) + { grg_get_grid_address_from_index(adrs1, ir_gps_at_q[i], D_diag); - for (j = 0; j < 3; j++) { /* q'' */ - adrs2[j] = - adrs0[j] - adrs1[j]; + for (j = 0; j < 3; j++) + { /* q'' */ + adrs2[j] = -adrs0[j] - adrs1[j]; } - q_2[i] = grg_get_grid_index(adrs2, D_diag); + q_2[i] = grg_get_grid_index(adrs2, D_diag); } /* map_q[q_2[i]] is in ir_gps_at_q. */ /* If map_q[q_2[i]] < ir_gps_at_q[i], this should be already */ /* stored. So the counter is not incremented. */ - for (i = 0; i < num_ir_q; i++) { + for (i = 0; i < num_ir_q; i++) + { ir_gp = ir_gps_at_q[i]; - if (map_q[q_2[i]] < ir_gp) { + if (map_q[q_2[i]] < ir_gp) + { map_triplets[ir_gp] = map_q[q_2[i]]; - } else { + } + else + { map_triplets[ir_gp] = ir_gp; num_ir_triplets++; } @@ -246,16 +263,19 @@ static long get_ir_triplets_at_q_perm_q1q2(long *map_triplets, #ifdef PHPYOPENMP #pragma omp parallel for #endif - for (i = 0; i < num_grid; i++) { + for (i = 0; i < num_grid; i++) + { map_triplets[i] = map_triplets[map_q[i]]; } ret: - if (q_2) { + if (q_2) + { free(q_2); q_2 = NULL; } - if (ir_gps_at_q) { + if (ir_gps_at_q) + { free(ir_gps_at_q); ir_gps_at_q = NULL; } @@ -266,18 +286,22 @@ static long get_ir_triplets_at_q_noperm(long *map_triplets, const long *map_q, const long grid_point, const long D_diag[3], - const RotMats * rot_reciprocal_q) + const RotMats *rot_reciprocal_q) { long i, num_grid, num_ir_triplets; num_ir_triplets = 0; num_grid = D_diag[0] * D_diag[1] * D_diag[2]; - for (i = 0; i < num_grid; i++) { - if (map_q[i] == i) { + for (i = 0; i < num_grid; i++) + { + if (map_q[i] == i) + { map_triplets[i] = i; num_ir_triplets++; - } else { + } + else + { map_triplets[i] = map_triplets[map_q[i]]; } } @@ -296,26 +320,31 @@ static long get_BZ_triplets_at_q(long (*triplets)[3], ir_q1_gps = NULL; num_ir = 0; - if ((ir_q1_gps = (long*) malloc(sizeof(long) * bzgrid->size)) - == NULL) { + if ((ir_q1_gps = (long *)malloc(sizeof(long) * bzgrid->size)) == NULL) + { warning_print("Memory could not be allocated."); goto ret; } - for (i = 0; i < bzgrid->size; i++) { - if (map_triplets[i] == i) { + for (i = 0; i < bzgrid->size; i++) + { + if (map_triplets[i] == i) + { ir_q1_gps[num_ir] = i; num_ir++; } } - if (bzgrid->type == 1) { + if (bzgrid->type == 1) + { get_BZ_triplets_at_q_type1(triplets, grid_point, bzgrid, ir_q1_gps, num_ir); - } else { + } + else + { get_BZ_triplets_at_q_type2(triplets, grid_point, bzgrid, @@ -340,7 +369,7 @@ static void get_BZ_triplets_at_q_type1(long (*triplets)[3], long bzgp[3], G[3]; long bz_adrs0[3], bz_adrs1[3], bz_adrs2[3]; const long *gp_map; - const long (*bz_adrs)[3]; + const long(*bz_adrs)[3]; double d2, min_d2, tolerance; double LQD_inv[3][3]; @@ -348,9 +377,10 @@ static void get_BZ_triplets_at_q_type1(long (*triplets)[3], bz_adrs = bzgrid->addresses; get_LQD_inv(LQD_inv, bzgrid); /* This tolerance is used to be consistent to BZ reduction in bzgrid. */ - tolerance = bzg_get_tolerance_for_BZ_reduction((BZGrid*)bzgrid); + tolerance = bzg_get_tolerance_for_BZ_reduction((BZGrid *)bzgrid); - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { bz_adrs0[i] = bz_adrs[grid_point][i]; } num_gp = bzgrid->D_diag[0] * bzgrid->D_diag[1] * bzgrid->D_diag[2]; @@ -359,61 +389,77 @@ static void get_BZ_triplets_at_q_type1(long (*triplets)[3], #ifdef PHPYOPENMP #pragma omp parallel for private(j, gp2, bzgp, G, bz_adrs1, bz_adrs2, d2, min_d2, bz0, bz1, bz2) #endif - for (i = 0; i < num_ir; i++) { - for (j = 0; j < 3; j++) { + for (i = 0; i < num_ir; i++) + { + for (j = 0; j < 3; j++) + { bz_adrs1[j] = bz_adrs[ir_q1_gps[i]][j]; - bz_adrs2[j] = - bz_adrs0[j] - bz_adrs1[j]; + bz_adrs2[j] = -bz_adrs0[j] - bz_adrs1[j]; } gp2 = grg_get_grid_index(bz_adrs2, bzgrid->D_diag); /* Negative value is the signal to initialize min_d2 later. */ min_d2 = -1; for (bz0 = 0; - bz0 < gp_map[num_bzgp + grid_point + 1] - - gp_map[num_bzgp + grid_point] + 1; - bz0++) { - if (bz0 == 0) { + bz0 < gp_map[num_bzgp + grid_point + 1] - gp_map[num_bzgp + grid_point] + 1; + bz0++) + { + if (bz0 == 0) + { bzgp[0] = grid_point; - } else { + } + else + { bzgp[0] = num_gp + gp_map[num_bzgp + grid_point] + bz0 - 1; } for (bz1 = 0; - bz1 < gp_map[num_bzgp + ir_q1_gps[i] + 1] - - gp_map[num_bzgp + ir_q1_gps[i]] + 1; - bz1++) { - if (bz1 == 0) { + bz1 < gp_map[num_bzgp + ir_q1_gps[i] + 1] - gp_map[num_bzgp + ir_q1_gps[i]] + 1; + bz1++) + { + if (bz1 == 0) + { bzgp[1] = ir_q1_gps[i]; - } else { + } + else + { bzgp[1] = num_gp + gp_map[num_bzgp + ir_q1_gps[i]] + bz1 - 1; } for (bz2 = 0; bz2 < gp_map[num_bzgp + gp2 + 1] - gp_map[num_bzgp + gp2] + 1; - bz2++) { - if (bz2 == 0) { + bz2++) + { + if (bz2 == 0) + { bzgp[2] = gp2; - } else { + } + else + { bzgp[2] = num_gp + gp_map[num_bzgp + gp2] + bz2 - 1; } - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { G[j] = bz_adrs[bzgp[0]][j] + bz_adrs[bzgp[1]][j] + bz_adrs[bzgp[2]][j]; } - if (G[0] == 0 && G[1] == 0 && G[2] == 0) { - for (j = 0; j < 3; j++) { + if (G[0] == 0 && G[1] == 0 && G[2] == 0) + { + for (j = 0; j < 3; j++) + { triplets[i][j] = bzgp[j]; } goto found; } d2 = get_squared_distance(G, LQD_inv); - if (d2 < min_d2 - tolerance || min_d2 < 0) { + if (d2 < min_d2 - tolerance || min_d2 < 0) + { min_d2 = d2; - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { triplets[i][j] = bzgp[j]; } } } } } - found: - ; + found:; } } @@ -427,7 +473,7 @@ static void get_BZ_triplets_at_q_type2(long (*triplets)[3], long bzgp[3], G[3]; long bz_adrs0[3], bz_adrs1[3], bz_adrs2[3]; const long *gp_map; - const long (*bz_adrs)[3]; + const long(*bz_adrs)[3]; double d2, min_d2, tolerance; double LQD_inv[3][3]; @@ -435,9 +481,10 @@ static void get_BZ_triplets_at_q_type2(long (*triplets)[3], bz_adrs = bzgrid->addresses; get_LQD_inv(LQD_inv, bzgrid); /* This tolerance is used to be consistent to BZ reduction in bzgrid. */ - tolerance = bzg_get_tolerance_for_BZ_reduction((BZGrid*)bzgrid); + tolerance = bzg_get_tolerance_for_BZ_reduction((BZGrid *)bzgrid); - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { bz_adrs0[i] = bz_adrs[grid_point][i]; } gp0 = grg_get_grid_index(bz_adrs0, bzgrid->D_diag); @@ -445,39 +492,48 @@ static void get_BZ_triplets_at_q_type2(long (*triplets)[3], #ifdef PHPYOPENMP #pragma omp parallel for private(j, gp2, bzgp, G, bz_adrs1, bz_adrs2, d2, min_d2) #endif - for (i = 0; i < num_ir; i++) { - for (j = 0; j < 3; j++) { + for (i = 0; i < num_ir; i++) + { + for (j = 0; j < 3; j++) + { bz_adrs1[j] = bz_adrs[gp_map[ir_q1_gps[i]]][j]; - bz_adrs2[j] = - bz_adrs0[j] - bz_adrs1[j]; + bz_adrs2[j] = -bz_adrs0[j] - bz_adrs1[j]; } gp2 = grg_get_grid_index(bz_adrs2, bzgrid->D_diag); /* Negative value is the signal to initialize min_d2 later. */ min_d2 = -1; - for (bzgp[0] = gp_map[gp0]; bzgp[0] < gp_map[gp0 + 1]; bzgp[0]++) { + for (bzgp[0] = gp_map[gp0]; bzgp[0] < gp_map[gp0 + 1]; bzgp[0]++) + { for (bzgp[1] = gp_map[ir_q1_gps[i]]; - bzgp[1] < gp_map[ir_q1_gps[i] + 1]; bzgp[1]++) { - for (bzgp[2] = gp_map[gp2]; bzgp[2] < gp_map[gp2 + 1]; bzgp[2]++) { - for (j = 0; j < 3; j++) { + bzgp[1] < gp_map[ir_q1_gps[i] + 1]; bzgp[1]++) + { + for (bzgp[2] = gp_map[gp2]; bzgp[2] < gp_map[gp2 + 1]; bzgp[2]++) + { + for (j = 0; j < 3; j++) + { G[j] = bz_adrs[bzgp[0]][j] + bz_adrs[bzgp[1]][j] + bz_adrs[bzgp[2]][j]; } - if (G[0] == 0 && G[1] == 0 && G[2] == 0) { - for (j = 0; j < 3; j++) { + if (G[0] == 0 && G[1] == 0 && G[2] == 0) + { + for (j = 0; j < 3; j++) + { triplets[i][j] = bzgp[j]; } goto found; } d2 = get_squared_distance(G, LQD_inv); - if (d2 < min_d2 - tolerance || min_d2 < 0) { + if (d2 < min_d2 - tolerance || min_d2 < 0) + { min_d2 = d2; - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) + { triplets[i][j] = bzgp[j]; } } } } } - found: - ; + found:; } } @@ -488,7 +544,8 @@ static double get_squared_distance(const long G[3], long i; d2 = 0; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { d = LQD_inv[i][0] * G[0] + LQD_inv[i][1] * G[1] + LQD_inv[i][2] * G[2]; d2 += d * d; } @@ -501,25 +558,27 @@ static void get_LQD_inv(double LQD_inv[3][3], const ConstBZGrid *bzgrid) long i, j, k; /* LQD^-1 */ - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { - for (k = 0; k < 3; k++) { - LQD_inv[i][k] - = bzgrid->reclat[i][j] * bzgrid->Q[j][k] / bzgrid->D_diag[k]; + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { + for (k = 0; k < 3; k++) + { + LQD_inv[i][k] = bzgrid->reclat[i][j] * bzgrid->Q[j][k] / bzgrid->D_diag[k]; } } } } /* Return NULL if failed */ -static RotMats *get_reciprocal_point_group_with_q(const RotMats * rot_reciprocal, +static RotMats *get_reciprocal_point_group_with_q(const RotMats *rot_reciprocal, const long D_diag[3], const long grid_point) { long i, num_rot, gp_rot; long *ir_rot; long adrs[3], adrs_rot[3]; - RotMats * rot_reciprocal_q; + RotMats *rot_reciprocal_q; ir_rot = NULL; rot_reciprocal_q = NULL; @@ -527,26 +586,32 @@ static RotMats *get_reciprocal_point_group_with_q(const RotMats * rot_reciprocal grg_get_grid_address_from_index(adrs, grid_point, D_diag); - if ((ir_rot = (long*)malloc(sizeof(long) * rot_reciprocal->size)) == NULL) { + if ((ir_rot = (long *)malloc(sizeof(long) * rot_reciprocal->size)) == NULL) + { warning_print("Memory of ir_rot could not be allocated."); return NULL; } - for (i = 0; i < rot_reciprocal->size; i++) { + for (i = 0; i < rot_reciprocal->size; i++) + { ir_rot[i] = -1; } - for (i = 0; i < rot_reciprocal->size; i++) { + for (i = 0; i < rot_reciprocal->size; i++) + { lagmat_multiply_matrix_vector_l3(adrs_rot, rot_reciprocal->mat[i], adrs); gp_rot = grg_get_grid_index(adrs_rot, D_diag); - if (gp_rot == grid_point) { + if (gp_rot == grid_point) + { ir_rot[num_rot] = i; num_rot++; } } - if ((rot_reciprocal_q = bzg_alloc_RotMats(num_rot)) != NULL) { - for (i = 0; i < num_rot; i++) { + if ((rot_reciprocal_q = bzg_alloc_RotMats(num_rot)) != NULL) + { + for (i = 0; i < num_rot; i++) + { lagmat_copy_matrix_l3(rot_reciprocal_q->mat[i], rot_reciprocal->mat[ir_rot[i]]); } @@ -558,7 +623,6 @@ static RotMats *get_reciprocal_point_group_with_q(const RotMats * rot_reciprocal return rot_reciprocal_q; } - static RotMats *get_reciprocal_point_group(const long (*rec_rotations_in)[3][3], const long num_rot, const long is_time_reversal, @@ -573,12 +637,14 @@ static RotMats *get_reciprocal_point_group(const long (*rec_rotations_in)[3][3], num_rot, is_time_reversal, is_transpose); - if (num_rot_out == 0) { + if (num_rot_out == 0) + { return NULL; } rec_rotations = bzg_alloc_RotMats(num_rot_out); - for (i = 0; i < num_rot_out; i++) { + for (i = 0; i < num_rot_out; i++) + { lagmat_copy_matrix_l3(rec_rotations->mat[i], rec_rotations_out[i]); } diff --git a/c/triplet_iw.c b/c/triplet_iw.c index 1daf1dac..82983438 100644 --- a/c/triplet_iw.c +++ b/c/triplet_iw.c @@ -53,10 +53,10 @@ static long set_g(double g[3], const double freq_vertices[3][24][4], const long max_i); static void get_triplet_tetrahedra_vertices( - long vertices[2][24][4], - const long tp_relative_grid_address[2][24][4][3], - const long triplet[3], - const ConstBZGrid *bzgrid); + long vertices[2][24][4], + const long tp_relative_grid_address[2][24][4][3], + const long triplet[3], + const ConstBZGrid *bzgrid); static void get_neighboring_grid_points_type1(long *neighboring_grid_points, const long grid_point, @@ -70,21 +70,20 @@ get_neighboring_grid_points_type2(long *neighboring_grid_points, const long num_relative_grid_address, const ConstBZGrid *bzgrid); -void -tpi_get_integration_weight(double *iw, - char *iw_zero, - const double *frequency_points, - const long num_band0, - const long tp_relative_grid_address[2][24][4][3], - const long triplets[3], - const long num_triplets, - const ConstBZGrid *bzgrid, - const double *frequencies1, - const long num_band1, - const double *frequencies2, - const long num_band2, - const long tp_type, - const long openmp_per_bands) +void tpi_get_integration_weight(double *iw, + char *iw_zero, + const double *frequency_points, + const long num_band0, + const long tp_relative_grid_address[2][24][4][3], + const long triplets[3], + const long num_triplets, + const ConstBZGrid *bzgrid, + const double *frequencies1, + const long num_band1, + const double *frequencies2, + const long num_band2, + const long tp_type, + const long openmp_per_bands) { long max_i, j, b1, b2, b12, num_band_prod, adrs_shift; long vertices[2][24][4]; @@ -109,37 +108,44 @@ tpi_get_integration_weight(double *iw, /* tp_type = 4: (g[0]) mainly for el-ph phonon decay, */ /* f0: ph, f1: el_i, f2: el_f */ - if ((tp_type == 2) || (tp_type == 3)) { + if ((tp_type == 2) || (tp_type == 3)) + { max_i = 3; } - if (tp_type == 4) { + if (tp_type == 4) + { max_i = 1; } #ifdef PHPYOPENMP #pragma omp parallel for private(j, b1, b2, adrs_shift, g, freq_vertices) if (openmp_per_bands) #endif - for (b12 = 0; b12 < num_band1 * num_band2; b12++) { + for (b12 = 0; b12 < num_band1 * num_band2; b12++) + { b1 = b12 / num_band2; b2 = b12 % num_band2; set_freq_vertices(freq_vertices, frequencies1, frequencies2, vertices, num_band1, num_band2, b1, b2, tp_type); - for (j = 0; j < num_band0; j++) { + for (j = 0; j < num_band0; j++) + { adrs_shift = j * num_band1 * num_band2 + b1 * num_band2 + b2; iw_zero[adrs_shift] = set_g(g, frequency_points[j], freq_vertices, max_i); - if (tp_type == 2) { + if (tp_type == 2) + { iw[adrs_shift] = g[2]; adrs_shift += num_band_prod; iw[adrs_shift] = g[0] - g[1]; } - if (tp_type == 3) { + if (tp_type == 3) + { iw[adrs_shift] = g[2]; adrs_shift += num_band_prod; iw[adrs_shift] = g[0] - g[1]; adrs_shift += num_band_prod; iw[adrs_shift] = g[0] + g[1] + g[2]; } - if (tp_type == 4) { + if (tp_type == 4) + { iw[adrs_shift] = g[0]; } } @@ -165,36 +171,44 @@ void tpi_get_integration_weight_with_sigma(double *iw, #ifdef PHPYOPENMP #pragma omp parallel for private(j, b1, b2, f0, f1, f2, g0, g1, g2, adrs_shift) if (openmp_per_bands) #endif - for (b12 = 0; b12 < num_band * num_band; b12++) { + for (b12 = 0; b12 < num_band * num_band; b12++) + { b1 = b12 / num_band; b2 = b12 % num_band; f1 = frequencies[triplet[1] * num_band + b1]; f2 = frequencies[triplet[2] * num_band + b2]; - for (j = 0; j < num_band0; j++) { + for (j = 0; j < num_band0; j++) + { f0 = frequency_points[j]; adrs_shift = j * num_band * num_band + b1 * num_band + b2; - if ((tp_type == 2) || (tp_type == 3)) { + if ((tp_type == 2) || (tp_type == 3)) + { if (cutoff > 0 && fabs(f0 + f1 - f2) > cutoff && fabs(f0 - f1 + f2) > cutoff && - fabs(f0 - f1 - f2) > cutoff) { + fabs(f0 - f1 - f2) > cutoff) + { iw_zero[adrs_shift] = 1; g0 = 0; g1 = 0; g2 = 0; - } else { + } + else + { iw_zero[adrs_shift] = 0; g0 = phonoc_gaussian(f0 + f1 - f2, sigma); g1 = phonoc_gaussian(f0 - f1 + f2, sigma); g2 = phonoc_gaussian(f0 - f1 - f2, sigma); } - if (tp_type == 2) { + if (tp_type == 2) + { iw[adrs_shift] = g2; adrs_shift += const_adrs_shift; iw[adrs_shift] = g0 - g1; } - if (tp_type == 3) { + if (tp_type == 3) + { iw[adrs_shift] = g2; adrs_shift += const_adrs_shift; iw[adrs_shift] = g0 - g1; @@ -202,11 +216,15 @@ void tpi_get_integration_weight_with_sigma(double *iw, iw[adrs_shift] = g0 + g1 + g2; } } - if (tp_type == 4) { - if (cutoff > 0 && fabs(f0 + f1 - f2) > cutoff) { + if (tp_type == 4) + { + if (cutoff > 0 && fabs(f0 + f1 - f2) > cutoff) + { iw_zero[adrs_shift] = 1; iw[adrs_shift] = 0; - } else { + } + else + { iw_zero[adrs_shift] = 0; iw[adrs_shift] = phonoc_gaussian(f0 + f1 - f2, sigma); } @@ -215,22 +233,22 @@ void tpi_get_integration_weight_with_sigma(double *iw, } } - - -void -tpi_get_neighboring_grid_points(long *neighboring_grid_points, - const long grid_point, - const long (*relative_grid_address)[3], - const long num_relative_grid_address, - const ConstBZGrid *bzgrid) +void tpi_get_neighboring_grid_points(long *neighboring_grid_points, + const long grid_point, + const long (*relative_grid_address)[3], + const long num_relative_grid_address, + const ConstBZGrid *bzgrid) { - if (bzgrid->type == 1) { + if (bzgrid->type == 1) + { get_neighboring_grid_points_type1(neighboring_grid_points, grid_point, relative_grid_address, num_relative_grid_address, bzgrid); - } else { + } + else + { get_neighboring_grid_points_type2(neighboring_grid_points, grid_point, relative_grid_address, @@ -252,17 +270,28 @@ static void set_freq_vertices(double freq_vertices[3][24][4], long i, j; double f1, f2; - for (i = 0; i < 24; i++) { - for (j = 0; j < 4; j++) { + for (i = 0; i < 24; i++) + { + for (j = 0; j < 4; j++) + { f1 = frequencies1[vertices[0][i][j] * num_band1 + b1]; f2 = frequencies2[vertices[1][i][j] * num_band2 + b2]; - if ((tp_type == 2) || (tp_type == 3)) { - if (f1 < 0) {f1 = 0;} - if (f2 < 0) {f2 = 0;} + if ((tp_type == 2) || (tp_type == 3)) + { + if (f1 < 0) + { + f1 = 0; + } + if (f2 < 0) + { + f2 = 0; + } freq_vertices[0][i][j] = -f1 + f2; freq_vertices[1][i][j] = f1 - f2; freq_vertices[2][i][j] = f1 + f2; - } else { + } + else + { freq_vertices[0][i][j] = -f1 + f2; } } @@ -287,11 +316,15 @@ static long set_g(double g[3], iw_zero = 1; - for (i = 0; i < max_i; i++) { - if (thm_in_tetrahedra(f0, freq_vertices[i])) { + for (i = 0; i < max_i; i++) + { + if (thm_in_tetrahedra(f0, freq_vertices[i])) + { g[i] = thm_get_integration_weight(f0, freq_vertices[i], 'I'); iw_zero = 0; - } else { + } + else + { g[i] = 0; } } @@ -300,14 +333,16 @@ static long set_g(double g[3], } static void get_triplet_tetrahedra_vertices(long vertices[2][24][4], - const long tp_relative_grid_address[2][24][4][3], - const long triplet[3], - const ConstBZGrid *bzgrid) + const long tp_relative_grid_address[2][24][4][3], + const long triplet[3], + const ConstBZGrid *bzgrid) { long i, j; - for (i = 0; i < 2; i++) { - for (j = 0; j < 24; j++) { + for (i = 0; i < 2; i++) + { + for (j = 0; j < 24; j++) + { tpi_get_neighboring_grid_points(vertices[i][j], triplet[i + 1], tp_relative_grid_address[i][j], @@ -327,20 +362,25 @@ get_neighboring_grid_points_type1(long *neighboring_grid_points, long bzmesh[3], bz_address[3]; long i, j, bz_gp, prod_bz_mesh; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) + { bzmesh[i] = bzgrid->D_diag[i] * 2; } prod_bz_mesh = bzmesh[0] * bzmesh[1] * bzmesh[2]; - for (i = 0; i < num_relative_grid_address; i++) { - for (j = 0; j < 3; j++) { - bz_address[j] = bzgrid->addresses[grid_point][j] - + relative_grid_address[i][j]; + for (i = 0; i < num_relative_grid_address; i++) + { + for (j = 0; j < 3; j++) + { + bz_address[j] = bzgrid->addresses[grid_point][j] + relative_grid_address[i][j]; } bz_gp = bzgrid->gp_map[grg_get_grid_index(bz_address, bzmesh)]; - if (bz_gp == prod_bz_mesh) { + if (bz_gp == prod_bz_mesh) + { neighboring_grid_points[i] = - grg_get_grid_index(bz_address, bzgrid->D_diag); - } else { + grg_get_grid_index(bz_address, bzgrid->D_diag); + } + else + { neighboring_grid_points[i] = bz_gp; } } @@ -356,18 +396,20 @@ get_neighboring_grid_points_type2(long *neighboring_grid_points, long bz_address[3]; long i, j, gp; - for (i = 0; i < num_relative_grid_address; i++) { - for (j = 0; j < 3; j++) { - bz_address[j] = bzgrid->addresses[grid_point][j] - + relative_grid_address[i][j]; + for (i = 0; i < num_relative_grid_address; i++) + { + for (j = 0; j < 3; j++) + { + bz_address[j] = bzgrid->addresses[grid_point][j] + relative_grid_address[i][j]; } gp = grg_get_grid_index(bz_address, bzgrid->D_diag); neighboring_grid_points[i] = bzgrid->gp_map[gp]; - if (bzgrid->gp_map[gp + 1] - bzgrid->gp_map[gp] > 1) { - for (j = bzgrid->gp_map[gp]; j < bzgrid->gp_map[gp + 1]; j++) { - if (bz_address[0] == bzgrid->addresses[j][0] - && bz_address[1] == bzgrid->addresses[j][1] - && bz_address[2] == bzgrid->addresses[j][2]) { + if (bzgrid->gp_map[gp + 1] - bzgrid->gp_map[gp] > 1) + { + for (j = bzgrid->gp_map[gp]; j < bzgrid->gp_map[gp + 1]; j++) + { + if (bz_address[0] == bzgrid->addresses[j][0] && bz_address[1] == bzgrid->addresses[j][1] && bz_address[2] == bzgrid->addresses[j][2]) + { neighboring_grid_points[i] = j; break; } From 117fe05c24c32ed14d0ba82289d94a07a189f184 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Tue, 12 Oct 2021 17:57:32 +0900 Subject: [PATCH 12/34] Update docstring and appy formatter. --- phono3py/phonon/grid.py | 289 +++++++++++++++------------ phono3py/phonon/solver.py | 122 ++++++----- phono3py/phonon3/collision_matrix.py | 129 ++++++------ 3 files changed, 296 insertions(+), 244 deletions(-) diff --git a/phono3py/phonon/grid.py b/phono3py/phonon/grid.py index b4af6bac..550c9d39 100644 --- a/phono3py/phonon/grid.py +++ b/phono3py/phonon/grid.py @@ -36,8 +36,10 @@ import numpy as np from phonopy.harmonic.force_constants import similarity_transformation from phonopy.structure.cells import ( - get_primitive_matrix_by_centring, estimate_supercell_matrix, - get_reduced_bases) + get_primitive_matrix_by_centring, + estimate_supercell_matrix, + get_reduced_bases, +) from phonopy.structure.grid_points import length2mesh, extract_ir_grid_points @@ -115,15 +117,17 @@ class BZGrid(object): """ - def __init__(self, - mesh, - reciprocal_lattice=None, - lattice=None, - symmetry_dataset=None, - is_shift=None, - is_time_reversal=True, - use_grg=False, - store_dense_gp_map=True): + def __init__( + self, + mesh, + reciprocal_lattice=None, + lattice=None, + symmetry_dataset=None, + is_shift=None, + is_time_reversal=True, + use_grg=False, + store_dense_gp_map=True, + ): """Init method. mesh : array_like or float @@ -153,10 +157,11 @@ class BZGrid(object): """ if symmetry_dataset is None: - identity = np.eye(3, dtype='int_', order='C') + identity = np.eye(3, dtype="int_", order="C") self._symmetry_dataset = { - 'rotations': identity.reshape(1, 3, 3), - 'translations': np.array([[0, 0, 0]], dtype='double')} + "rotations": identity.reshape(1, 3, 3), + "translations": np.array([[0, 0, 0]], dtype="double"), + } else: self._symmetry_dataset = symmetry_dataset self._is_shift = is_shift @@ -166,9 +171,9 @@ class BZGrid(object): self._addresses = None self._gp_map = None self._grid_matrix = None - self._D_diag = np.ones(3, dtype='int_') - self._Q = np.eye(3, dtype='int_', order='C') - self._P = np.eye(3, dtype='int_', order='C') + self._D_diag = np.ones(3, dtype="int_") + self._Q = np.eye(3, dtype="int_", order="C") + self._P = np.eye(3, dtype="int_", order="C") self._QDinv = None self._microzone_lattice = None self._rotations = None @@ -176,14 +181,16 @@ class BZGrid(object): if reciprocal_lattice is not None: self._reciprocal_lattice = np.array( - reciprocal_lattice, dtype='double', order='C') + reciprocal_lattice, dtype="double", order="C" + ) self._lattice = np.array( - np.linalg.inv(reciprocal_lattice), dtype='double', order='C') + np.linalg.inv(reciprocal_lattice), dtype="double", order="C" + ) if lattice is not None: - self._lattice = np.array( - lattice, dtype='double', order='C') + self._lattice = np.array(lattice, dtype="double", order="C") self._reciprocal_lattice = np.array( - np.linalg.inv(lattice), dtype='double', order='C') + np.linalg.inv(lattice), dtype="double", order="C" + ) self._generate_grid(mesh) @@ -232,9 +239,9 @@ class BZGrid(object): def PS(self): """Integer shift vectors of GRGrid.""" if self._is_shift is None: - return np.zeros(3, dtype='int_') + return np.zeros(3, dtype="int_") else: - return np.array(np.dot(self.P, self._is_shift), dtype='int_') + return np.array(np.dot(self.P, self._is_shift), dtype="int_") @property def grid_matrix(self): @@ -366,33 +373,33 @@ class BZGrid(object): try: len(addresses[0]) except TypeError: - return int(self._grg2bzg[get_grid_point_from_address( - addresses, self._D_diag)]) + return int( + self._grg2bzg[get_grid_point_from_address(addresses, self._D_diag)] + ) - gps = [get_grid_point_from_address(adrs, self._D_diag) - for adrs in addresses] - return np.array(self._grg2bzg[gps], dtype='int_') + gps = [get_grid_point_from_address(adrs, self._D_diag) for adrs in addresses] + return np.array(self._grg2bzg[gps], dtype="int_") def _set_bz_grid(self): """Generate BZ grid addresses and grid point mapping table.""" - (self._addresses, - self._gp_map, - self._bzg2grg) = _relocate_BZ_grid_address( - self._D_diag, - self._Q, - self._reciprocal_lattice, # column vectors - is_shift=self._is_shift, - store_dense_gp_map=self._store_dense_gp_map) + (self._addresses, self._gp_map, self._bzg2grg) = _relocate_BZ_grid_address( + self._D_diag, + self._Q, + self._reciprocal_lattice, # column vectors + is_shift=self._is_shift, + store_dense_gp_map=self._store_dense_gp_map, + ) if self._store_dense_gp_map: self._grg2bzg = self._gp_map[:-1] else: - self._grg2bzg = np.arange( - np.prod(self._D_diag), dtype='int_') + self._grg2bzg = np.arange(np.prod(self._D_diag), dtype="int_") - self._QDinv = np.array(self.Q * (1 / self.D_diag.astype('double')), - dtype='double', order='C') + self._QDinv = np.array( + self.Q * (1 / self.D_diag.astype("double")), dtype="double", order="C" + ) self._microzone_lattice = np.dot( - self._reciprocal_lattice, np.dot(self._QDinv, self._P)) + self._reciprocal_lattice, np.dot(self._QDinv, self._P) + ) def _generate_grid(self, mesh, force_SNF=False): self._set_mesh_numbers(mesh, force_SNF=force_SNF) @@ -402,24 +409,30 @@ class BZGrid(object): def _set_mesh_numbers(self, mesh, force_SNF=False): """Set mesh numbers from array or float value. - Three case: + Four cases: 1) Three integers are given. Use these numbers as regular grid. 2) One number is given with no symmetry provided. - Regular grid is computed from this value. - 3) One number is given and use_grg=True. + Regular grid is computed from this value. Grid is generated so that + distances in reciprocal space between neighboring grid points become + similar. + 3) One number is given and use_grg=False. Regular grid is computed from this value and point group symmetry. + Grid is generated so that distances in reciprocal space between + neighboring grid points become similar. 4) One number is given with symmetry provided and use_grg=True. Generalized regular grid is generated. However if the grid generating matrix is a diagonal matrix, use it as the D matrix of SNF and P and Q are set as identity matrices. Otherwise - D, P, Q matrices are computed using SNF. + D, P, Q matrices are computed using SNF. Grid is generated so that + basis vectors of supercell in direct space corresponding to this grid + have similar lengths. """ try: num_values = len(mesh) if num_values == 3: - self._D_diag = np.array(mesh, dtype='int_') + self._D_diag = np.array(mesh, dtype="int_") except TypeError: length = float(mesh) if self._use_grg: @@ -436,32 +449,30 @@ class BZGrid(object): """ sym_dataset = self._symmetry_dataset - tmat = sym_dataset['transformation_matrix'] - centring = sym_dataset['international'][0] + tmat = sym_dataset["transformation_matrix"] + centring = sym_dataset["international"][0] pmat = get_primitive_matrix_by_centring(centring) conv_lat = np.dot(np.linalg.inv(tmat).T, self._lattice) num_cells = int(np.prod(length2mesh(length, conv_lat))) - max_num_atoms = num_cells * len(sym_dataset['std_types']) + max_num_atoms = num_cells * len(sym_dataset["std_types"]) conv_mesh_numbers = estimate_supercell_matrix( - sym_dataset, - max_num_atoms=max_num_atoms, - max_iter=200) + sym_dataset, max_num_atoms=max_num_atoms, max_iter=200 + ) inv_pmat = np.linalg.inv(pmat) inv_pmat_int = np.rint(inv_pmat).astype(int) assert (np.abs(inv_pmat - inv_pmat_int) < 1e-5).all() # transpose in reciprocal space self._grid_matrix = np.array( - (inv_pmat_int * conv_mesh_numbers).T, dtype='int_', order='C') + (inv_pmat_int * conv_mesh_numbers).T, dtype="int_", order="C" + ) # If grid_matrix is a diagonal matrix, use it as D matrix. gm_diag = np.diagonal(self._grid_matrix) if (np.diag(gm_diag) == self._grid_matrix).all() and not force_SNF: - self._D_diag = np.array(gm_diag, dtype='int_') + self._D_diag = np.array(gm_diag, dtype="int_") else: import phono3py._phono3py as phono3c - if not phono3c.snf3x3(self._D_diag, - self._P, - self._Q, - self._grid_matrix): + + if not phono3c.snf3x3(self._D_diag, self._P, self._Q, self._grid_matrix): msg = "SNF3x3 failed." raise RuntimeError(msg) @@ -473,23 +484,30 @@ class BZGrid(object): """ import phono3py._phono3py as phono3c - direct_rotations = np.array(self._symmetry_dataset['rotations'], - dtype='int_', order='C') - rec_rotations = np.zeros((48, 3, 3), dtype='int_', order='C') - num_rec_rot = phono3c.reciprocal_rotations(rec_rotations, - direct_rotations, - self._is_time_reversal) - self._reciprocal_operations = np.array(rec_rotations[:num_rec_rot], - dtype='int_', order='C') + direct_rotations = np.array( + self._symmetry_dataset["rotations"], dtype="int_", order="C" + ) + rec_rotations = np.zeros((48, 3, 3), dtype="int_", order="C") + num_rec_rot = phono3c.reciprocal_rotations( + rec_rotations, direct_rotations, self._is_time_reversal + ) + self._reciprocal_operations = np.array( + rec_rotations[:num_rec_rot], dtype="int_", order="C" + ) self._rotations_cartesian = np.array( - [similarity_transformation(self._reciprocal_lattice, r) - for r in self._reciprocal_operations], dtype='double', order='C') - self._rotations = np.zeros(self._reciprocal_operations.shape, - dtype='int_', order='C') - if not phono3c.transform_rotations(self._rotations, - self._reciprocal_operations, - self._D_diag, - self._Q): + [ + similarity_transformation(self._reciprocal_lattice, r) + for r in self._reciprocal_operations + ], + dtype="double", + order="C", + ) + self._rotations = np.zeros( + self._reciprocal_operations.shape, dtype="int_", order="C" + ) + if not phono3c.transform_rotations( + self._rotations, self._reciprocal_operations, self._D_diag, self._Q + ): msg = "Grid symmetry is broken. Use generalized regular grid." raise RuntimeError(msg) @@ -499,9 +517,11 @@ def get_grid_point_from_address_py(address, mesh): # X runs first in XYZ # (*In spglib, Z first is possible with MACRO setting.) m = mesh - return (address[0] % m[0] + - (address[1] % m[1]) * m[0] + - (address[2] % m[2]) * m[0] * m[1]) + return ( + address[0] % m[0] + + (address[1] % m[1]) * m[0] + + (address[2] % m[2]) * m[0] * m[1] + ) def get_grid_point_from_address(address, D_diag): @@ -531,13 +551,13 @@ def get_grid_point_from_address(address, D_diag): """ import phono3py._phono3py as phono3c - adrs_array = np.array(address, dtype='int_', order='C') - mesh_array = np.array(D_diag, dtype='int_') + adrs_array = np.array(address, dtype="int_", order="C") + mesh_array = np.array(D_diag, dtype="int_") if adrs_array.ndim == 1: return phono3c.grid_index_from_address(adrs_array, mesh_array) - gps = np.zeros(adrs_array.shape[0], dtype='int_') + gps = np.zeros(adrs_array.shape[0], dtype="int_") for i, adrs in enumerate(adrs_array): gps[i] = phono3c.grid_index_from_address(adrs, mesh_array) return gps @@ -564,20 +584,15 @@ def get_ir_grid_points(bz_grid): shape=(prod(D_diag), ), dtype='int_' """ - ir_grid_map = _get_ir_grid_map( - bz_grid.D_diag, - bz_grid.rotations, - PS=bz_grid.PS) - (ir_grid_points, - ir_grid_weights) = extract_ir_grid_points(ir_grid_map) + ir_grid_map = _get_ir_grid_map(bz_grid.D_diag, bz_grid.rotations, PS=bz_grid.PS) + (ir_grid_points, ir_grid_weights) = extract_ir_grid_points(ir_grid_map) return ir_grid_points, ir_grid_weights, ir_grid_map -def get_grid_points_by_rotations(bz_gp, - bz_grid, - reciprocal_rotations=None, - with_surface=False): +def get_grid_points_by_rotations( + bz_gp, bz_grid, reciprocal_rotations=None, with_surface=False +): """Return BZ-grid point indices rotated from a BZ-grid point index. Parameters @@ -622,9 +637,9 @@ def _get_grid_points_by_rotations(bz_gp, bz_grid, rotations): return bz_grid.grg2bzg[grgps] -def _get_grid_points_by_bz_rotations(bz_gp, bz_grid, rotations, lang='C'): +def _get_grid_points_by_bz_rotations(bz_gp, bz_grid, rotations, lang="C"): """Grid point rotations with surface treatment.""" - if lang == 'C': + if lang == "C": return _get_grid_points_by_bz_rotations_c(bz_gp, bz_grid, rotations) else: return _get_grid_points_by_bz_rotations_py(bz_gp, bz_grid, rotations) @@ -633,7 +648,7 @@ def _get_grid_points_by_bz_rotations(bz_gp, bz_grid, rotations, lang='C'): def _get_grid_points_by_bz_rotations_c(bz_gp, bz_grid, rotations): import phono3py._phono3py as phono3c - bzgps = np.zeros(len(rotations), dtype='int_') + bzgps = np.zeros(len(rotations), dtype="int_") for i, r in enumerate(rotations): bzgps[i] = phono3c.rotate_bz_grid_index( bz_gp, @@ -642,7 +657,8 @@ def _get_grid_points_by_bz_rotations_c(bz_gp, bz_grid, rotations): bz_grid.gp_map, bz_grid.D_diag, bz_grid.PS, - bz_grid.store_dense_gp_map * 1 + 1) + bz_grid.store_dense_gp_map * 1 + 1, + ) return bzgps @@ -656,12 +672,15 @@ def _get_grid_points_by_bz_rotations_py(bz_gp, bz_grid, rotations): """ rot_adrs = np.dot(rotations, bz_grid.addresses[bz_gp]) grgps = get_grid_point_from_address(rot_adrs, bz_grid.D_diag) - bzgps = np.zeros(len(grgps), dtype='int_') + bzgps = np.zeros(len(grgps), dtype="int_") if bz_grid.store_dense_gp_map: for i, (gp, adrs) in enumerate(zip(grgps, rot_adrs)): indices = np.where( - (bz_grid.addresses[bz_grid.gp_map[gp]:bz_grid.gp_map[gp + 1]] - == adrs).all(axis=1))[0] + ( + bz_grid.addresses[bz_grid.gp_map[gp] : bz_grid.gp_map[gp + 1]] + == adrs + ).all(axis=1) + )[0] if len(indices) == 0: msg = "with_surface did not work properly." raise RuntimeError(msg) @@ -670,9 +689,12 @@ def _get_grid_points_by_bz_rotations_py(bz_gp, bz_grid, rotations): num_grgp = np.prod(bz_grid.D_diag) num_bzgp = num_grgp * 8 for i, (gp, adrs) in enumerate(zip(grgps, rot_adrs)): - gps = (np.arange( - bz_grid.gp_map[num_bzgp + gp], - bz_grid.gp_map[num_bzgp + gp + 1]) + num_grgp).tolist() + gps = ( + np.arange( + bz_grid.gp_map[num_bzgp + gp], bz_grid.gp_map[num_bzgp + gp + 1] + ) + + num_grgp + ).tolist() gps.insert(0, gp) indices = np.where((bz_grid.addresses[gps] == adrs).all(axis=1))[0] if len(indices) == 0: @@ -702,17 +724,18 @@ def _get_grid_address(D_diag): """ import phono3py._phono3py as phono3c - gr_grid_addresses = np.zeros((np.prod(D_diag), 3), dtype='int_') - phono3c.gr_grid_addresses(gr_grid_addresses, - np.array(D_diag, dtype='int_')) + gr_grid_addresses = np.zeros((np.prod(D_diag), 3), dtype="int_") + phono3c.gr_grid_addresses(gr_grid_addresses, np.array(D_diag, dtype="int_")) return gr_grid_addresses -def _relocate_BZ_grid_address(D_diag, - Q, - reciprocal_lattice, # column vectors - is_shift=None, - store_dense_gp_map=False): +def _relocate_BZ_grid_address( + D_diag, + Q, + reciprocal_lattice, # column vectors + is_shift=None, + store_dense_gp_map=False, +): """Grid addresses are relocated to be inside first Brillouin zone. Number of ir-grid-points inside Brillouin zone is returned. @@ -771,43 +794,42 @@ def _relocate_BZ_grid_address(D_diag, import phono3py._phono3py as phono3c if is_shift is None: - _is_shift = np.zeros(3, dtype='int_') + _is_shift = np.zeros(3, dtype="int_") else: - _is_shift = np.array(is_shift, dtype='int_') - bz_grid_addresses = np.zeros((np.prod(np.add(D_diag, 1)), 3), - dtype='int_', order='C') - bzg2grg = np.zeros(len(bz_grid_addresses), dtype='int_') + _is_shift = np.array(is_shift, dtype="int_") + bz_grid_addresses = np.zeros( + (np.prod(np.add(D_diag, 1)), 3), dtype="int_", order="C" + ) + bzg2grg = np.zeros(len(bz_grid_addresses), dtype="int_") if store_dense_gp_map: - bz_map = np.zeros(np.prod(D_diag) + 1, dtype='int_') + bz_map = np.zeros(np.prod(D_diag) + 1, dtype="int_") else: - bz_map = np.zeros(np.prod(D_diag) * 9 + 1, dtype='int_') + bz_map = np.zeros(np.prod(D_diag) * 9 + 1, dtype="int_") - reclat_T = np.array(reciprocal_lattice.T, dtype='double', order='C') + reclat_T = np.array(reciprocal_lattice.T, dtype="double", order="C") reduced_basis = get_reduced_bases(reclat_T) tmat_inv = np.dot(np.linalg.inv(reduced_basis.T), reclat_T.T) - tmat_inv_int = np.rint(tmat_inv).astype('int_') + tmat_inv_int = np.rint(tmat_inv).astype("int_") assert (np.abs(tmat_inv - tmat_inv_int) < 1e-5).all() num_gp = phono3c.bz_grid_addresses( bz_grid_addresses, bz_map, bzg2grg, - np.array(D_diag, dtype='int_'), - np.array(np.dot(tmat_inv_int, Q), dtype='int_', order='C'), + np.array(D_diag, dtype="int_"), + np.array(np.dot(tmat_inv_int, Q), dtype="int_", order="C"), _is_shift, - np.array(reduced_basis.T, dtype='double', order='C'), - store_dense_gp_map * 1 + 1) + np.array(reduced_basis.T, dtype="double", order="C"), + store_dense_gp_map * 1 + 1, + ) - bz_grid_addresses = np.array(bz_grid_addresses[:num_gp], - dtype='int_', order='C') - bzg2grg = np.array(bzg2grg[:num_gp], dtype='int_') + bz_grid_addresses = np.array(bz_grid_addresses[:num_gp], dtype="int_", order="C") + bzg2grg = np.array(bzg2grg[:num_gp], dtype="int_") return bz_grid_addresses, bz_map, bzg2grg -def _get_ir_grid_map(D_diag, - grg_rotations, - PS=None): +def _get_ir_grid_map(D_diag, grg_rotations, PS=None): """Irreducible k-points are searched. Parameters @@ -834,17 +856,18 @@ def _get_ir_grid_map(D_diag, """ import phono3py._phono3py as phono3c - ir_grid_map = np.zeros(np.prod(D_diag), dtype='int_') + ir_grid_map = np.zeros(np.prod(D_diag), dtype="int_") if PS is None: - _PS = np.zeros(3, dtype='int_') + _PS = np.zeros(3, dtype="int_") else: - _PS = np.array(PS, dtype='int_') + _PS = np.array(PS, dtype="int_") num_ir = phono3c.ir_grid_map( ir_grid_map, - np.array(D_diag, dtype='int_'), + np.array(D_diag, dtype="int_"), _PS, - np.array(grg_rotations, dtype='int_', order='C')) + np.array(grg_rotations, dtype="int_", order="C"), + ) if num_ir > 0: return ir_grid_map diff --git a/phono3py/phonon/solver.py b/phono3py/phonon/solver.py index 9b27ef49..43abc355 100644 --- a/phono3py/phonon/solver.py +++ b/phono3py/phonon/solver.py @@ -38,16 +38,18 @@ from phonopy.units import VaspToTHz from phonopy.structure.cells import sparse_to_dense_svecs -def run_phonon_solver_c(dm, - frequencies, - eigenvectors, - phonon_done, - grid_points, - grid_address, - QDinv, - frequency_conversion_factor=VaspToTHz, - nac_q_direction=None, # in reduced coordinates - lapack_zheev_uplo='L'): +def run_phonon_solver_c( + dm, + frequencies, + eigenvectors, + phonon_done, + grid_points, + grid_address, + QDinv, + frequency_conversion_factor=VaspToTHz, + nac_q_direction=None, # in reduced coordinates + lapack_zheev_uplo="L", +): """Bulid and solve dynamical matrices on grid in C-API. dm : DynamicalMatrix @@ -72,25 +74,29 @@ def run_phonon_solver_c(dm, """ import phono3py._phononmod as phononmod - (svecs, - multi, - masses, - rec_lattice, # column vectors - positions, - born, - nac_factor, - dielectric) = _extract_params(dm) + ( + svecs, + multi, + masses, + rec_lattice, # column vectors + positions, + born, + nac_factor, + dielectric, + ) = _extract_params(dm) - if dm.is_nac() and dm.nac_method == 'gonze': + if dm.is_nac() and dm.nac_method == "gonze": gonze_nac_dataset = dm.Gonze_nac_dataset if gonze_nac_dataset[0] is None: dm.make_Gonze_nac_dataset() gonze_nac_dataset = dm.Gonze_nac_dataset - (gonze_fc, # fc where the dipole-diple contribution is removed. - dd_q0, # second term of dipole-dipole expression. - G_cutoff, # Cutoff radius in reciprocal space. This will not be used. - G_list, # List of G points where d-d interactions are integrated. - Lambda) = gonze_nac_dataset # Convergence parameter + ( + gonze_fc, # fc where the dipole-diple contribution is removed. + dd_q0, # second term of dipole-dipole expression. + G_cutoff, # Cutoff radius in reciprocal space. This will not be used. + G_list, # List of G points where d-d interactions are integrated. + Lambda, + ) = gonze_nac_dataset # Convergence parameter fc = gonze_fc else: positions = None @@ -99,11 +105,11 @@ def run_phonon_solver_c(dm, Lambda = 0 fc = dm.force_constants - assert grid_points.dtype == 'int_' + assert grid_points.dtype == "int_" assert grid_points.flags.c_contiguous - assert QDinv.dtype == 'double' + assert QDinv.dtype == "double" assert QDinv.flags.c_contiguous - assert lapack_zheev_uplo in ('L', 'U') + assert lapack_zheev_uplo in ("L", "U") fc_p2s, fc_s2p = _get_fc_elements_mapping(dm, fc) phononmod.phonons_at_gridpoints( @@ -129,18 +135,21 @@ def run_phonon_solver_c(dm, dd_q0, G_list, Lambda, - lapack_zheev_uplo) + lapack_zheev_uplo, + ) -def run_phonon_solver_py(grid_point, - phonon_done, - frequencies, - eigenvectors, - grid_address, - QDinv, - dynamical_matrix, - frequency_conversion_factor, - lapack_zheev_uplo): +def run_phonon_solver_py( + grid_point, + phonon_done, + frequencies, + eigenvectors, + grid_address, + QDinv, + dynamical_matrix, + frequency_conversion_factor, + lapack_zheev_uplo, +): """Bulid and solve dynamical matrices on grid in python.""" gp = grid_point if phonon_done[gp] == 0: @@ -150,8 +159,9 @@ def run_phonon_solver_py(grid_point, dm = dynamical_matrix.dynamical_matrix eigvals, eigvecs = np.linalg.eigh(dm, UPLO=lapack_zheev_uplo) eigvals = eigvals.real - frequencies[gp] = (np.sqrt(np.abs(eigvals)) * np.sign(eigvals) - * frequency_conversion_factor) + frequencies[gp] = ( + np.sqrt(np.abs(eigvals)) * np.sign(eigvals) * frequency_conversion_factor + ) eigenvectors[gp] = eigvecs @@ -163,10 +173,9 @@ def _extract_params(dm): else: _svecs, _multi = sparse_to_dense_svecs(svecs, multi) - masses = np.array(dm.primitive.masses, dtype='double') - rec_lattice = np.array(np.linalg.inv(dm.primitive.cell), - dtype='double', order='C') - positions = np.array(dm.primitive.positions, dtype='double', order='C') + masses = np.array(dm.primitive.masses, dtype="double") + rec_lattice = np.array(np.linalg.inv(dm.primitive.cell), dtype="double", order="C") + positions = np.array(dm.primitive.positions, dtype="double", order="C") if dm.is_nac(): born = dm.born nac_factor = dm.nac_factor @@ -176,14 +185,16 @@ def _extract_params(dm): nac_factor = 0 dielectric = None - return (_svecs, - _multi, - masses, - rec_lattice, - positions, - born, - nac_factor, - dielectric) + return ( + _svecs, + _multi, + masses, + rec_lattice, + positions, + born, + nac_factor, + dielectric, + ) def _get_fc_elements_mapping(dm, fc): @@ -195,9 +206,10 @@ def _get_fc_elements_mapping(dm, fc): else: # compact fc primitive = dm.primitive p2p_map = primitive.p2p_map - s2pp_map = np.array([p2p_map[s2p_map[i]] for i in range(len(s2p_map))], - dtype='intc') - fc_p2s = np.arange(len(p2s_map), dtype='intc') + s2pp_map = np.array( + [p2p_map[s2p_map[i]] for i in range(len(s2p_map))], dtype="intc" + ) + fc_p2s = np.arange(len(p2s_map), dtype="intc") fc_s2p = s2pp_map - return np.array(fc_p2s, dtype='int_'), np.array(fc_s2p, dtype='int_') + return np.array(fc_p2s, dtype="int_"), np.array(fc_s2p, dtype="int_") diff --git a/phono3py/phonon3/collision_matrix.py b/phono3py/phonon3/collision_matrix.py index 123c34e9..f145df22 100644 --- a/phono3py/phonon3/collision_matrix.py +++ b/phono3py/phonon3/collision_matrix.py @@ -1,3 +1,4 @@ +"""Calculate collision matrix of direct solution of LBTE.""" # Copyright (C) 2020 Atsushi Togo # All rights reserved. # @@ -38,23 +39,26 @@ from phono3py.phonon3.imag_self_energy import ImagSelfEnergy class CollisionMatrix(ImagSelfEnergy): - """Collision matrix for direct solution of LBTE for one grid point + """Collision matrix of direct solution of LBTE for one grid point. Main diagonal part (imag-self-energy) and the other part are separately stored. """ - def __init__(self, - interaction, - rotations_cartesian=None, - num_ir_grid_points=None, - rot_grid_points=None, - temperature=None, - sigma=None, - is_reducible_collision_matrix=False, - log_level=0, - lang='C'): + def __init__( + self, + interaction, + rotations_cartesian=None, + num_ir_grid_points=None, + rot_grid_points=None, + temperature=None, + sigma=None, + is_reducible_collision_matrix=False, + log_level=0, + lang="C", + ): + """Init method.""" self._pp = None self._sigma = None self._frequency_points = None @@ -76,11 +80,9 @@ class CollisionMatrix(ImagSelfEnergy): self._unit_conversion = None self._log_level = log_level - ImagSelfEnergy.__init__(self, - interaction, - temperature=temperature, - sigma=sigma, - lang=lang) + ImagSelfEnergy.__init__( + self, interaction, temperature=temperature, sigma=sigma, lang=lang + ) self._is_reducible_collision_matrix = is_reducible_collision_matrix self._is_collision_matrix = True @@ -88,49 +90,55 @@ class CollisionMatrix(ImagSelfEnergy): if not self._is_reducible_collision_matrix: self._num_ir_grid_points = num_ir_grid_points self._rot_grid_points = np.array( - self._pp.bz_grid.bzg2grg[rot_grid_points], - dtype='int_', order='C') + self._pp.bz_grid.bzg2grg[rot_grid_points], dtype="int_", order="C" + ) self._rotations_cartesian = rotations_cartesian def run(self): + """Calculate collision matrix at a grid point.""" if self._pp_strength is None: self.run_interaction() num_band0 = self._pp_strength.shape[1] num_band = self._pp_strength.shape[2] - self._imag_self_energy = np.zeros(num_band0, dtype='double') + self._imag_self_energy = np.zeros(num_band0, dtype="double") if self._is_reducible_collision_matrix: num_mesh_points = np.prod(self._pp.mesh_numbers) self._collision_matrix = np.zeros( - (num_band0, num_mesh_points, num_band), dtype='double') + (num_band0, num_mesh_points, num_band), dtype="double" + ) else: self._collision_matrix = np.zeros( - (num_band0, 3, self._num_ir_grid_points, num_band, 3), - dtype='double') + (num_band0, 3, self._num_ir_grid_points, num_band, 3), dtype="double" + ) self._run_with_band_indices() self._run_collision_matrix() def get_collision_matrix(self): + """Return collision matrix at a grid point.""" return self._collision_matrix def set_grid_point(self, grid_point=None): + """Set a grid point and prepare for collision matrix calculation.""" if grid_point is None: self._grid_point = None else: self._pp.set_grid_point(grid_point, store_triplets_map=True) self._pp_strength = None - (self._triplets_at_q, - self._weights_at_q, - self._triplets_map_at_q, - self._ir_map_at_q) = self._pp.get_triplets_at_q() + ( + self._triplets_at_q, + self._weights_at_q, + self._triplets_map_at_q, + self._ir_map_at_q, + ) = self._pp.get_triplets_at_q() self._grid_point = grid_point self._frequencies, self._eigenvectors, _ = self._pp.get_phonons() def _run_collision_matrix(self): self._run_with_band_indices() if self._temperature > 0: - if self._lang == 'C': + if self._lang == "C": if self._is_reducible_collision_matrix: self._run_c_reducible_collision_matrix() else: @@ -143,31 +151,37 @@ class CollisionMatrix(ImagSelfEnergy): def _run_c_collision_matrix(self): import phono3py._phono3py as phono3c - phono3c.collision_matrix(self._collision_matrix, - self._pp_strength, - self._frequencies, - self._g, - self._triplets_at_q, - self._triplets_map_at_q, - self._ir_map_at_q, - self._rot_grid_points, # in GRGrid - self._rotations_cartesian, - self._temperature, - self._unit_conversion, - self._cutoff_frequency) + + phono3c.collision_matrix( + self._collision_matrix, + self._pp_strength, + self._frequencies, + self._g, + self._triplets_at_q, + self._triplets_map_at_q, + self._ir_map_at_q, + self._rot_grid_points, # in GRGrid + self._rotations_cartesian, + self._temperature, + self._unit_conversion, + self._cutoff_frequency, + ) def _run_c_reducible_collision_matrix(self): import phono3py._phono3py as phono3c - phono3c.reducible_collision_matrix(self._collision_matrix, - self._pp_strength, - self._frequencies, - self._g, - self._triplets_at_q, - self._triplets_map_at_q, - self._ir_map_at_q, - self._temperature, - self._unit_conversion, - self._cutoff_frequency) + + phono3c.reducible_collision_matrix( + self._collision_matrix, + self._pp_strength, + self._frequencies, + self._g, + self._triplets_at_q, + self._triplets_map_at_q, + self._ir_map_at_q, + self._temperature, + self._unit_conversion, + self._cutoff_frequency, + ) def _run_py_collision_matrix(self): num_band0 = self._pp_strength.shape[1] @@ -182,9 +196,11 @@ class CollisionMatrix(ImagSelfEnergy): for j in range(num_band0): for k in range(num_band): - collision = (self._pp_strength[ti, j, k] - * inv_sinh - * self._g[2, ti, j, k]).sum() + collision = ( + self._pp_strength[ti, j, k] + * inv_sinh + * self._g[2, ti, j, k] + ).sum() collision *= self._unit_conversion self._collision_matrix[j, :, i, k, :] += collision * r @@ -198,9 +214,9 @@ class CollisionMatrix(ImagSelfEnergy): ti = gp2tp_map[self._triplets_map_at_q[i]] inv_sinh = self._get_inv_sinh(i, gp2tp_map) for j, k in list(np.ndindex((num_band0, num_band))): - collision = (self._pp_strength[ti, j, k] - * inv_sinh - * self._g[2, ti, j, k]).sum() + collision = ( + self._pp_strength[ti, j, k] * inv_sinh * self._g[2, ti, j, k] + ).sum() collision *= self._unit_conversion self._collision_matrix[j, i, k] += collision @@ -225,7 +241,8 @@ class CollisionMatrix(ImagSelfEnergy): sinh = np.where( freqs > self._cutoff_frequency, np.sinh(freqs * THzToEv / (2 * Kb * self._temperature)), - -1.0) + -1.0, + ) inv_sinh = np.where(sinh > 0, 1.0 / sinh, 0) return inv_sinh From 55df7fb796732a8b8ee893420152468a344b5f92 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Tue, 12 Oct 2021 18:12:56 +0900 Subject: [PATCH 13/34] Formatted. --- phono3py/phonon3/conductivity.py | 396 +++++---- phono3py/phonon3/conductivity_LBTE.py | 1143 +++++++++++++------------ phono3py/phonon3/conductivity_RTA.py | 644 ++++++++------ 3 files changed, 1211 insertions(+), 972 deletions(-) diff --git a/phono3py/phonon3/conductivity.py b/phono3py/phonon3/conductivity.py index da5ab112..817af536 100644 --- a/phono3py/phonon3/conductivity.py +++ b/phono3py/phonon3/conductivity.py @@ -43,11 +43,11 @@ from phonopy.units import THzToEv, EV, THz, Angstrom from phono3py.file_IO import write_pp_to_hdf5 from phono3py.phonon3.triplets import get_all_triplets from phono3py.other.isotope import Isotope -from phono3py.phonon.grid import (get_ir_grid_points, - get_grid_points_by_rotations) +from phono3py.phonon.grid import get_ir_grid_points, get_grid_points_by_rotations -unit_to_WmK = ((THz * Angstrom) ** 2 / (Angstrom ** 3) * EV / THz / - (2 * np.pi)) # 2pi comes from definition of lifetime. +unit_to_WmK = ( + (THz * Angstrom) ** 2 / (Angstrom ** 3) * EV / THz / (2 * np.pi) +) # 2pi comes from definition of lifetime. def all_bands_exist(interaction): @@ -60,11 +60,7 @@ def all_bands_exist(interaction): return False -def write_pp(conductivity, - pp, - i, - filename=None, - compression="gzip"): +def write_pp(conductivity, pp, i, filename=None, compression="gzip"): """Write ph-ph interaction strength in hdf5 file.""" grid_point = conductivity.grid_points[i] sigmas = conductivity.sigmas @@ -77,27 +73,27 @@ def write_pp(conductivity, print("Multiple smearing parameters were given. The last one in ") print("ph-ph interaction calculations was written in the file.") - write_pp_to_hdf5(mesh, - pp=pp.interaction_strength, - g_zero=pp.zero_value_positions, - grid_point=grid_point, - triplet=triplets, - weight=weights, - triplet_all=all_triplets, - sigma=sigmas[-1], - sigma_cutoff=sigma_cutoff, - filename=filename, - compression=compression) + write_pp_to_hdf5( + mesh, + pp=pp.interaction_strength, + g_zero=pp.zero_value_positions, + grid_point=grid_point, + triplet=triplets, + weight=weights, + triplet_all=all_triplets, + sigma=sigmas[-1], + sigma_cutoff=sigma_cutoff, + filename=filename, + compression=compression, + ) class ConductivityBase: """Base class of Conductivity classes.""" - def __init__(self, - interaction, - grid_points=None, - is_kappa_star=True, - gv_delta_q=None): + def __init__( + self, interaction, grid_points=None, is_kappa_star=True, gv_delta_q=None + ): """Init method. interaction : Interaction @@ -130,36 +126,43 @@ class ConductivityBase: self._set_grid_properties(grid_points) self._qpoints = np.array( - np.dot(self._pp.bz_grid.addresses[self._grid_points], - self._pp.bz_grid.QDinv.T), dtype='double', order='C') + np.dot( + self._pp.bz_grid.addresses[self._grid_points], self._pp.bz_grid.QDinv.T + ), + dtype="double", + order="C", + ) self._gv_obj = GroupVelocity( self._pp.dynamical_matrix, q_length=gv_delta_q, symmetry=self._pp.primitive_symmetry, - frequency_factor_to_THz=self._pp.frequency_factor_to_THz) + frequency_factor_to_THz=self._pp.frequency_factor_to_THz, + ) def _set_point_operations(self): if not self._is_kappa_star: self._point_operations = np.array( - [np.eye(3, dtype='int_')], dtype='int_', order='C') + [np.eye(3, dtype="int_")], dtype="int_", order="C" + ) else: self._point_operations = np.array( - self._pp.bz_grid.reciprocal_operations, - dtype='int_', order='C') + self._pp.bz_grid.reciprocal_operations, dtype="int_", order="C" + ) rec_lat = np.linalg.inv(self._pp.primitive.cell) self._rotations_cartesian = np.array( - [similarity_transformation(rec_lat, r) - for r in self._point_operations], dtype='double', order='C') + [similarity_transformation(rec_lat, r) for r in self._point_operations], + dtype="double", + order="C", + ) def _set_grid_properties(self, grid_points): if grid_points is not None: # Specify grid points self._grid_points = grid_points - (self._ir_grid_points, - self._ir_grid_weights) = self._get_ir_grid_points() + (self._ir_grid_points, self._ir_grid_weights) = self._get_ir_grid_points() elif not self._is_kappa_star: # All grid points self._grid_points = self._pp.bz_grid.grg2bzg - self._grid_weights = np.ones(len(self._grid_points), dtype='int_') + self._grid_weights = np.ones(len(self._grid_points), dtype="int_") self._ir_grid_points = self._grid_points self._ir_grid_weights = self._grid_weights else: # Automatic sampling @@ -169,29 +172,31 @@ class ConductivityBase: def _get_ir_grid_points(self): """Find irreducible grid points.""" - ir_grid_points, ir_grid_weights, _ = get_ir_grid_points( - self._pp.bz_grid) + ir_grid_points, ir_grid_weights, _ = get_ir_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="int_" + ) return ir_grid_points, ir_grid_weights class Conductivity(ConductivityBase): """Thermal conductivity base class.""" - def __init__(self, - interaction, - grid_points=None, - temperatures=None, - sigmas=None, - sigma_cutoff=None, - is_isotope=False, - mass_variances=None, - boundary_mfp=None, # in micrometre - is_kappa_star=True, - gv_delta_q=None, # finite difference for group veolocity - is_full_pp=False, - log_level=0): + def __init__( + self, + interaction, + grid_points=None, + temperatures=None, + sigmas=None, + sigma_cutoff=None, + is_isotope=False, + mass_variances=None, + boundary_mfp=None, # in micrometre + is_kappa_star=True, + gv_delta_q=None, # finite difference for group veolocity + is_full_pp=False, + log_level=0, + ): """Init method.""" self._pp = None self._is_kappa_star = None @@ -203,10 +208,12 @@ class Conductivity(ConductivityBase): self._point_operations = None self._gv_obj = None - super().__init__(interaction, - grid_points=grid_points, - is_kappa_star=is_kappa_star, - gv_delta_q=gv_delta_q) + super().__init__( + interaction, + grid_points=grid_points, + is_kappa_star=is_kappa_star, + gv_delta_q=gv_delta_q, + ) self._is_full_pp = is_full_pp self._log_level = log_level @@ -221,7 +228,7 @@ class Conductivity(ConductivityBase): if temperatures is None: self._temperatures = None else: - self._temperatures = np.array(temperatures, dtype='double') + self._temperatures = np.array(temperatures, dtype="double") self._boundary_mfp = boundary_mfp self._read_gamma = False @@ -241,9 +248,11 @@ class Conductivity(ConductivityBase): self._conversion_factor = unit_to_WmK / volume self._pp.nac_q_direction = None - (self._frequencies, - self._eigenvectors, - self._phonon_done) = self._pp.get_phonons() + ( + self._frequencies, + self._eigenvectors, + self._phonon_done, + ) = self._pp.get_phonons() if (self._phonon_done == 0).any(): self._pp.run_phonon_solver() @@ -263,8 +272,10 @@ class Conductivity(ConductivityBase): """Return grid point count for mode kappa.""" if self._grid_point_count == len(self._grid_points): if self._log_level: - print("=================== End of collection of collisions " - "===================") + print( + "=================== End of collection of collisions " + "===================" + ) raise StopIteration else: self._run_at_grid_point() @@ -282,9 +293,11 @@ class Conductivity(ConductivityBase): def get_mesh_numbers(self): """Return mesh numbers of GR-grid.""" - warnings.warn("Use attribute, Conductivity.mesh_numbers " - "instead of Conductivity.get_mesh_numbers().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.mesh_numbers " + "instead of Conductivity.get_mesh_numbers().", + DeprecationWarning, + ) return self.mesh_numbers @property @@ -302,9 +315,11 @@ class Conductivity(ConductivityBase): Grid points are those at mode kappa are calculated. """ - warnings.warn("Use attribute, Conductivity.mode_heat_capacities " - "instead of Conductivity.get_mode_heat_capacities().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.mode_heat_capacities " + "instead of Conductivity.get_mode_heat_capacities().", + DeprecationWarning, + ) return self.mode_heat_capacities @property @@ -322,9 +337,11 @@ class Conductivity(ConductivityBase): Grid points are those at mode kappa are calculated. """ - warnings.warn("Use attribute, Conductivity.group_velocities " - "instead of Conductivity.get_group_velocities().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.group_velocities " + "instead of Conductivity.get_group_velocities().", + DeprecationWarning, + ) return self.group_velocities @property @@ -334,9 +351,11 @@ class Conductivity(ConductivityBase): def get_gv_by_gv(self): """Return gv_by_gv at grid points where mode kappa are calculated.""" - warnings.warn("Use attribute, Conductivity.gv_by_gv " - "instead of Conductivity.get_gv_by_gv().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.gv_by_gv " + "instead of Conductivity.get_gv_by_gv().", + DeprecationWarning, + ) return self.gv_by_gv @property @@ -354,9 +373,11 @@ class Conductivity(ConductivityBase): Grid points are those at mode kappa are calculated. """ - warnings.warn("Use attribute, Conductivity.frequencies " - "instead of Conductivity.get_frequencies().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.frequencies " + "instead of Conductivity.get_frequencies().", + DeprecationWarning, + ) return self.frequencies @property @@ -366,9 +387,11 @@ class Conductivity(ConductivityBase): def get_qpoints(self): """Return q-points where mode kappa are calculated.""" - warnings.warn("Use attribute, Conductivity.qpoints " - "instead of Conductivity.get_qpoints().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.qpoints " + "instead of Conductivity.get_qpoints().", + DeprecationWarning, + ) return self.qpoints @property @@ -386,9 +409,11 @@ class Conductivity(ConductivityBase): Grid point indices are given in BZ-grid. """ - warnings.warn("Use attribute, Conductivity.grid_points " - "instead of Conductivity.get_grid_points().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.grid_points " + "instead of Conductivity.get_grid_points().", + DeprecationWarning, + ) return self.grid_points @property @@ -398,9 +423,11 @@ class Conductivity(ConductivityBase): def get_grid_weights(self): """Return grid point weights where mode kappa are calculated.""" - warnings.warn("Use attribute, Conductivity.grid_weights " - "instead of Conductivity.get_grid_weights().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.grid_weights " + "instead of Conductivity.get_grid_weights().", + DeprecationWarning, + ) return self.grid_weights @property @@ -415,16 +442,20 @@ class Conductivity(ConductivityBase): def get_temperatures(self): """Return temperatures.""" - warnings.warn("Use attribute, Conductivity.temperatures " - "instead of Conductivity.get_temperatures().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.temperatures " + "instead of Conductivity.get_temperatures().", + DeprecationWarning, + ) return self.temperatures def set_temperatures(self, temperatures): """Set temperatures.""" - warnings.warn("Use attribute, Conductivity.temperatures " - "instead of Conductivity.set_temperatures().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.temperatures " + "instead of Conductivity.set_temperatures().", + DeprecationWarning, + ) self.temperatures = temperatures @property @@ -439,16 +470,18 @@ class Conductivity(ConductivityBase): def get_gamma(self): """Return gamma.""" - warnings.warn("Use attribute, Conductivity.gamma " - "instead of Conductivity.get_gamma().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.gamma " "instead of Conductivity.get_gamma().", + DeprecationWarning, + ) return self.gamma def set_gamma(self, gamma): """Set gamma.""" - warnings.warn("Use attribute, Conductivity.gamma " - "instead of Conductivity.set_gamma().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.gamma " "instead of Conductivity.set_gamma().", + DeprecationWarning, + ) self.gamma = gamma @property @@ -463,16 +496,20 @@ class Conductivity(ConductivityBase): def get_gamma_isotope(self): """Return gamma from isotope.""" - warnings.warn("Use attribute, Conductivity.gamma_isotope " - "instead of Conductivity.get_gamma_isotope().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.gamma_isotope " + "instead of Conductivity.get_gamma_isotope().", + DeprecationWarning, + ) return self.gamma_isotope def set_gamma_isotope(self, gamma_iso): """Set gamma from isotope.""" - warnings.warn("Use attribute, Conductivity.gamma_isotope " - "instead of Conductivity.set_gamma_isotope().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.gamma_isotope " + "instead of Conductivity.set_gamma_isotope().", + DeprecationWarning, + ) self.gamma_isotope = gamma_iso @property @@ -482,9 +519,10 @@ class Conductivity(ConductivityBase): def get_kappa(self): """Return kappa.""" - warnings.warn("Use attribute, Conductivity.kappa " - "instead of Conductivity.get_kappa().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.kappa " "instead of Conductivity.get_kappa().", + DeprecationWarning, + ) return self.kappa @property @@ -494,9 +532,11 @@ class Conductivity(ConductivityBase): def get_mode_kappa(self): """Return mode_kappa.""" - warnings.warn("Use attribute, Conductivity.mode_kappa " - "instead of Conductivity.get_mode_kappa().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.mode_kappa " + "instead of Conductivity.get_mode_kappa().", + DeprecationWarning, + ) return self.mode_kappa @property @@ -506,9 +546,11 @@ class Conductivity(ConductivityBase): def get_sigmas(self): """Return sigmas.""" - warnings.warn("Use attribute, Conductivity.sigmas " - "instead of Conductivity.get_sigmas().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.sigmas " + "instead of Conductivity.get_sigmas().", + DeprecationWarning, + ) return self.sigmas @property @@ -518,9 +560,11 @@ class Conductivity(ConductivityBase): def get_sigma_cutoff_width(self): """Return smearing width cutoff.""" - warnings.warn("Use attribute, Conductivity.sigma_cutoff_width " - "instead of Conductivity.get_sigma_cutoff_width().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.sigma_cutoff_width " + "instead of Conductivity.get_sigma_cutoff_width().", + DeprecationWarning, + ) return self.sigma_cutoff_width @property @@ -530,9 +574,11 @@ class Conductivity(ConductivityBase): def get_grid_point_count(self): """Return interator count of self.""" - warnings.warn("Use attribute, Conductivity.grid_point_count " - "instead of Conductivity.get_grid_point_count().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.grid_point_count " + "instead of Conductivity.get_grid_point_count().", + DeprecationWarning, + ) return self.grid_point_count @property @@ -542,9 +588,11 @@ class Conductivity(ConductivityBase): def get_averaged_pp_interaction(self): """Return averaged pp interaction strength.""" - warnings.warn("Use attribute, Conductivity.averaged_pp_interaction " - "instead of Conductivity.get_averaged_pp_interaction().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity.averaged_pp_interaction " + "instead of Conductivity.get_averaged_pp_interaction().", + DeprecationWarning, + ) return self.averaged_pp_interaction def get_number_of_sampling_grid_points(self): @@ -577,16 +625,18 @@ class Conductivity(ConductivityBase): print(text) self._isotope.sigma = sigma - self._isotope.set_phonons(self._frequencies, - self._eigenvectors, - self._phonon_done, - dm=self._pp.dynamical_matrix) + self._isotope.set_phonons( + self._frequencies, + self._eigenvectors, + self._phonon_done, + dm=self._pp.dynamical_matrix, + ) gp = self._grid_points[i] self._isotope.set_grid_point(gp) self._isotope.run() gamma_iso.append(self._isotope.gamma) - return np.array(gamma_iso, dtype='double', order='C') + return np.array(gamma_iso, dtype="double", order="C") def _set_isotope(self, mass_variances): if mass_variances is True: @@ -601,7 +651,8 @@ class Conductivity(ConductivityBase): frequency_factor_to_THz=self._pp.frequency_factor_to_THz, symprec=self._pp.primitive_symmetry.tolerance, cutoff_frequency=self._pp.cutoff_frequency, - lapack_zheev_uplo=self._pp.lapack_zheev_uplo) + lapack_zheev_uplo=self._pp.lapack_zheev_uplo, + ) self._mass_variances = self._isotope.mass_variances def _set_harmonic_properties(self, i_irgp, i_data): @@ -609,21 +660,28 @@ class Conductivity(ConductivityBase): grid_point = self._grid_points[i_irgp] freqs = self._frequencies[grid_point][self._pp.band_indices] self._cv[:, i_data, :] = self._get_cv(freqs) - self._gv_obj.run([self._qpoints[i_irgp], ]) + self._gv_obj.run( + [ + self._qpoints[i_irgp], + ] + ) gv = self._gv_obj.group_velocities[0, self._pp.band_indices, :] self._gv[i_data] = gv def _get_cv(self, freqs): - cv = np.zeros((len(self._temperatures), len(freqs)), dtype='double') + cv = np.zeros((len(self._temperatures), len(freqs)), dtype="double") # T/freq has to be large enough to avoid divergence. # Otherwise just set 0. for i, f in enumerate(freqs): - finite_t = (self._temperatures > f / 100) + finite_t = self._temperatures > f / 100 if f > self._pp.cutoff_frequency: cv[:, i] = np.where( - finite_t, get_mode_cv( - np.where(finite_t, self._temperatures, 10000), - f * THzToEv), 0) + finite_t, + get_mode_cv( + np.where(finite_t, self._temperatures, 10000), f * THzToEv + ), + 0, + ) return cv def _set_gv_by_gv(self, i_irgp, i_data): @@ -636,23 +694,23 @@ class Conductivity(ConductivityBase): self._num_sampling_grid_points += order_kstar # Sum all vxv at k* - for j, vxv in enumerate( - ([0, 0], [1, 1], [2, 2], [1, 2], [0, 2], [0, 1])): + for j, vxv in enumerate(([0, 0], [1, 1], [2, 2], [1, 2], [0, 2], [0, 1])): self._gv_sum2[i_data, :, j] = gv_by_gv_tensor[:, vxv[0], vxv[1]] def _get_gv_by_gv(self, i_irgp, i_data): if self._is_kappa_star: rotation_map = get_grid_points_by_rotations( - self._grid_points[i_irgp], - self._pp.bz_grid) + self._grid_points[i_irgp], self._pp.bz_grid + ) else: rotation_map = get_grid_points_by_rotations( self._grid_points[i_irgp], self._pp.bz_grid, - reciprocal_rotations=self._point_operations) + reciprocal_rotations=self._point_operations, + ) gv = self._gv[i_data] - gv_by_gv = np.zeros((len(gv), 3, 3), dtype='double') + gv_by_gv = np.zeros((len(gv), 3, 3), dtype="double") for r in self._rotations_cartesian: gvs_rot = np.dot(gv, r.T) @@ -663,15 +721,16 @@ class Conductivity(ConductivityBase): if self._grid_weights is not None: if order_kstar != self._grid_weights[i_irgp]: if self._log_level: - text = ("Number of elements in k* is unequal " - "to number of equivalent grid-points. " - "This means that the mesh sampling grids break " - "symmetry. Please check carefully " - "the convergence over grid point densities.") - msg = textwrap.fill(text, - initial_indent=" ", - subsequent_indent=" ", - width=70) + text = ( + "Number of elements in k* is unequal " + "to number of equivalent grid-points. " + "This means that the mesh sampling grids break " + "symmetry. Please check carefully " + "the convergence over grid point densities." + ) + msg = textwrap.fill( + text, initial_indent=" ", subsequent_indent=" ", width=70 + ) print("*" * 30 + "Warning" + "*" * 30) print(msg) print("*" * 67) @@ -688,27 +747,40 @@ class Conductivity(ConductivityBase): def _get_boundary_scattering(self, i): num_band = len(self._pp.primitive) * 3 - g_boundary = np.zeros(num_band, dtype='double') + g_boundary = np.zeros(num_band, dtype="double") for ll in range(num_band): - g_boundary[ll] = (np.linalg.norm(self._gv[i, ll]) * Angstrom * 1e6 - / (4 * np.pi * self._boundary_mfp)) + g_boundary[ll] = ( + np.linalg.norm(self._gv[i, ll]) + * Angstrom + * 1e6 + / (4 * np.pi * self._boundary_mfp) + ) return g_boundary def _show_log_header(self, i): if self._log_level: gp = self._grid_points[i] - print("======================= Grid point %d (%d/%d) " - "=======================" % - (gp, i + 1, len(self._grid_points))) + print( + "======================= Grid point %d (%d/%d) " + "=======================" % (gp, i + 1, len(self._grid_points)) + ) print("q-point: (%5.2f %5.2f %5.2f)" % tuple(self._qpoints[i])) if self._boundary_mfp is not None: if self._boundary_mfp > 1000: - print("Boundary mean free path (millimetre): %.3f" % - (self._boundary_mfp / 1000.0)) + print( + "Boundary mean free path (millimetre): %.3f" + % (self._boundary_mfp / 1000.0) + ) else: - print("Boundary mean free path (micrometre): %.5f" % - self._boundary_mfp) + print( + "Boundary mean free path (micrometre): %.5f" + % self._boundary_mfp + ) if self._is_isotope: - print(("Mass variance parameters: " + - "%5.2e " * len(self._mass_variances)) % - tuple(self._mass_variances)) + print( + ( + "Mass variance parameters: " + + "%5.2e " * len(self._mass_variances) + ) + % tuple(self._mass_variances) + ) diff --git a/phono3py/phonon3/conductivity_LBTE.py b/phono3py/phonon3/conductivity_LBTE.py index 77c4523b..76673af6 100644 --- a/phono3py/phonon3/conductivity_LBTE.py +++ b/phono3py/phonon3/conductivity_LBTE.py @@ -38,57 +38,62 @@ import time import warnings import numpy as np from phonopy.phonon.degeneracy import degenerate_sets -from phono3py.phonon3.conductivity import (Conductivity, all_bands_exist, - unit_to_WmK) +from phono3py.phonon3.conductivity import Conductivity, all_bands_exist, unit_to_WmK from phono3py.phonon3.conductivity import write_pp as _write_pp from phono3py.phonon3.collision_matrix import CollisionMatrix from phono3py.phonon.grid import get_grid_points_by_rotations -from phono3py.file_IO import (write_kappa_to_hdf5, - write_collision_to_hdf5, - read_collision_from_hdf5, - write_collision_eigenvalues_to_hdf5, - write_unitary_matrix_to_hdf5, - read_pp_from_hdf5) +from phono3py.file_IO import ( + write_kappa_to_hdf5, + write_collision_to_hdf5, + read_collision_from_hdf5, + write_collision_eigenvalues_to_hdf5, + write_unitary_matrix_to_hdf5, + read_pp_from_hdf5, +) from phonopy.units import THzToEv, Kb def get_thermal_conductivity_LBTE( - interaction, - temperatures=None, - sigmas=None, - sigma_cutoff=None, - is_isotope=False, - mass_variances=None, - grid_points=None, - boundary_mfp=None, # in micrometre - solve_collective_phonon=False, - is_reducible_collision_matrix=False, - is_kappa_star=True, - gv_delta_q=None, - is_full_pp=False, - pinv_cutoff=1.0e-8, - pinv_solver=0, # default: dsyev in lapacke - write_collision=False, - read_collision=False, - write_kappa=False, - write_pp=False, - read_pp=False, - write_LBTE_solution=False, - compression="gzip", - input_filename=None, - output_filename=None, - log_level=0): + interaction, + temperatures=None, + sigmas=None, + sigma_cutoff=None, + is_isotope=False, + mass_variances=None, + grid_points=None, + boundary_mfp=None, # in micrometre + solve_collective_phonon=False, + is_reducible_collision_matrix=False, + is_kappa_star=True, + gv_delta_q=None, + is_full_pp=False, + pinv_cutoff=1.0e-8, + pinv_solver=0, # default: dsyev in lapacke + write_collision=False, + read_collision=False, + write_kappa=False, + write_pp=False, + read_pp=False, + write_LBTE_solution=False, + compression="gzip", + input_filename=None, + output_filename=None, + log_level=0, +): """Calculate lattice thermal conductivity by direct solution.""" if temperatures is None: - _temperatures = [300, ] + _temperatures = [ + 300, + ] else: _temperatures = temperatures if sigmas is None: sigmas = [] if log_level: print("-" * 19 + " Lattice thermal conducitivity (LBTE) " + "-" * 19) - print("Cutoff frequency of pseudo inversion of collision matrix: %s" % - pinv_cutoff) + print( + "Cutoff frequency of pseudo inversion of collision matrix: %s" % pinv_cutoff + ) if read_collision: temps = None @@ -113,7 +118,8 @@ def get_thermal_conductivity_LBTE( pp_filename=input_filename, pinv_cutoff=pinv_cutoff, pinv_solver=pinv_solver, - log_level=log_level) + log_level=log_level, + ) if read_collision: read_from = _set_collision_from_file( @@ -122,7 +128,8 @@ def get_thermal_conductivity_LBTE( indices=read_collision, is_reducible_collision_matrix=is_reducible_collision_matrix, filename=input_filename, - log_level=log_level) + log_level=log_level, + ) if not read_from: print("Reading collision failed.") return False @@ -137,11 +144,9 @@ def get_thermal_conductivity_LBTE( for i in lbte: if write_pp: - _write_pp(lbte, - interaction, - i, - filename=output_filename, - compression=compression) + _write_pp( + lbte, interaction, i, filename=output_filename, compression=compression + ) if write_collision: _write_collision( @@ -150,17 +155,19 @@ def get_thermal_conductivity_LBTE( i=i, is_reducible_collision_matrix=is_reducible_collision_matrix, is_one_gp_colmat=(grid_points is not None), - filename=output_filename) + filename=output_filename, + ) lbte.delete_gp_collision_and_pp() # Write full collision matrix if write_LBTE_solution: - if ((read_collision and - all_bands_exist(interaction) and - read_from == "grid_points" and - grid_points is None) or - (not read_collision)): # noqa E129 + if ( + read_collision + and all_bands_exist(interaction) + and read_from == "grid_points" + and grid_points is None + ) or (not read_collision): _write_collision(lbte, interaction, filename=output_filename) if grid_points is None and all_bands_exist(interaction): @@ -174,17 +181,20 @@ def get_thermal_conductivity_LBTE( pinv_solver=pinv_solver, compression=compression, filename=output_filename, - log_level=log_level) + log_level=log_level, + ) return lbte -def _write_collision(lbte, - interaction, - i=None, - is_reducible_collision_matrix=False, - is_one_gp_colmat=False, - filename=None): +def _write_collision( + lbte, + interaction, + i=None, + is_reducible_collision_matrix=False, + is_one_gp_colmat=False, + filename=None, +): grid_points = lbte.get_grid_points() temperatures = lbte.temperatures sigmas = lbte.get_sigmas() @@ -218,7 +228,8 @@ def _write_collision(lbte, grid_point=gp, sigma=sigma, sigma_cutoff=sigma_cutoff, - filename=filename) + filename=filename, + ) else: for j, sigma in enumerate(sigmas): for k, bi in enumerate(interaction.band_indices): @@ -236,31 +247,36 @@ def _write_collision(lbte, band_index=bi, sigma=sigma, sigma_cutoff=sigma_cutoff, - filename=filename) + filename=filename, + ) else: for j, sigma in enumerate(sigmas): if gamma_isotope is not None: gamma_isotope_at_sigma = gamma_isotope[j] else: gamma_isotope_at_sigma = None - write_collision_to_hdf5(temperatures, - mesh, - gamma=gamma[j], - gamma_isotope=gamma_isotope_at_sigma, - collision_matrix=collision_matrix[j], - sigma=sigma, - sigma_cutoff=sigma_cutoff, - filename=filename) + write_collision_to_hdf5( + temperatures, + mesh, + gamma=gamma[j], + gamma_isotope=gamma_isotope_at_sigma, + collision_matrix=collision_matrix[j], + sigma=sigma, + sigma_cutoff=sigma_cutoff, + filename=filename, + ) -def _write_kappa(lbte, - volume, - is_reducible_collision_matrix=False, - write_LBTE_solution=False, - pinv_solver=None, - compression="gzip", - filename=None, - log_level=0): +def _write_kappa( + lbte, + volume, + is_reducible_collision_matrix=False, + write_LBTE_solution=False, + pinv_solver=None, + compression="gzip", + filename=None, + log_level=0, +): temperatures = lbte.temperatures sigmas = lbte.sigmas sigma_cutoff = lbte.sigma_cutoff_width @@ -295,38 +311,42 @@ def _write_kappa(lbte, gamma_isotope_at_sigma = gamma_isotope[i] else: gamma_isotope_at_sigma = None - write_kappa_to_hdf5(temperatures, - mesh, - frequency=frequencies, - group_velocity=gv, - gv_by_gv=gv_by_gv, - mean_free_path=mfp[i], - heat_capacity=mode_cv, - kappa=kappa[i], - mode_kappa=mode_kappa[i], - kappa_RTA=kappa_RTA[i], - mode_kappa_RTA=mode_kappa_RTA[i], - f_vector=f_vector, - gamma=gamma[i], - gamma_isotope=gamma_isotope_at_sigma, - averaged_pp_interaction=ave_pp, - qpoint=qpoints, - weight=weights, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - kappa_unit_conversion=unit_to_WmK / volume, - compression=compression, - filename=filename, - verbose=log_level) + write_kappa_to_hdf5( + temperatures, + mesh, + frequency=frequencies, + group_velocity=gv, + gv_by_gv=gv_by_gv, + mean_free_path=mfp[i], + heat_capacity=mode_cv, + kappa=kappa[i], + mode_kappa=mode_kappa[i], + kappa_RTA=kappa_RTA[i], + mode_kappa_RTA=mode_kappa_RTA[i], + f_vector=f_vector, + gamma=gamma[i], + gamma_isotope=gamma_isotope_at_sigma, + averaged_pp_interaction=ave_pp, + qpoint=qpoints, + weight=weights, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + kappa_unit_conversion=unit_to_WmK / volume, + compression=compression, + filename=filename, + verbose=log_level, + ) if coleigs is not None: - write_collision_eigenvalues_to_hdf5(temperatures, - mesh, - coleigs[i], - sigma=sigma, - sigma_cutoff=sigma_cutoff, - filename=filename, - verbose=log_level) + write_collision_eigenvalues_to_hdf5( + temperatures, + mesh, + coleigs[i], + sigma=sigma, + sigma_cutoff=sigma_cutoff, + filename=filename, + verbose=log_level, + ) if write_LBTE_solution: if pinv_solver is not None: @@ -340,15 +360,18 @@ def _write_kappa(lbte, sigma_cutoff=sigma_cutoff, solver=solver, filename=filename, - verbose=log_level) + verbose=log_level, + ) -def _set_collision_from_file(lbte, - bz_grid, - indices='all', - is_reducible_collision_matrix=False, - filename=None, - log_level=0): +def _set_collision_from_file( + lbte, + bz_grid, + indices="all", + is_reducible_collision_matrix=False, + filename=None, + log_level=0, +): sigmas = lbte.get_sigmas() sigma_cutoff = lbte.get_sigma_cutoff_width() mesh = lbte.mesh_numbers @@ -362,96 +385,105 @@ def _set_collision_from_file(lbte, read_from = None if log_level: - print("---------------------- Reading collision data from file " - "----------------------") + print( + "---------------------- Reading collision data from file " + "----------------------" + ) sys.stdout.flush() for j, sigma in enumerate(sigmas): - collisions = read_collision_from_hdf5(mesh, - indices=indices, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - filename=filename, - verbose=(log_level > 0)) + collisions = read_collision_from_hdf5( + mesh, + indices=indices, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + filename=filename, + verbose=(log_level > 0), + ) if log_level: sys.stdout.flush() if collisions: - (colmat_at_sigma, - gamma_at_sigma, - temperatures) = collisions + (colmat_at_sigma, gamma_at_sigma, temperatures) = collisions if len(sigmas) == 1: collision_matrix = colmat_at_sigma - gamma = np.zeros((1,) + gamma_at_sigma.shape, - dtype='double', order='C') + gamma = np.zeros((1,) + gamma_at_sigma.shape, dtype="double", order="C") gamma[0] = gamma_at_sigma else: collision_matrix.append(colmat_at_sigma) gamma.append(gamma_at_sigma) read_from = "full_matrix" else: - vals = _allocate_collision(True, - mesh, - sigma, - sigma_cutoff, - grid_points, - indices, - is_reducible_collision_matrix, - filename) + vals = _allocate_collision( + True, + mesh, + sigma, + sigma_cutoff, + grid_points, + indices, + is_reducible_collision_matrix, + filename, + ) if vals: colmat_at_sigma, gamma_at_sigma, temperatures = vals else: if log_level: - print("Collision at grid point %d doesn't exist." % - grid_points[0]) - vals = _allocate_collision(False, - mesh, - sigma, - sigma_cutoff, - grid_points, - indices, - is_reducible_collision_matrix, - filename) + print("Collision at grid point %d doesn't exist." % grid_points[0]) + vals = _allocate_collision( + False, + mesh, + sigma, + sigma_cutoff, + grid_points, + indices, + is_reducible_collision_matrix, + filename, + ) if vals: colmat_at_sigma, gamma_at_sigma, temperatures = vals else: if log_level: - print("Collision at (grid point %d, band index %d) " - "doesn't exist." % (grid_points[0], 1)) + print( + "Collision at (grid point %d, band index %d) " + "doesn't exist." % (grid_points[0], 1) + ) return False for i, gp in enumerate(grid_points): - if not _collect_collision_gp(colmat_at_sigma, - gamma_at_sigma, - temperatures, - mesh, - sigma, - sigma_cutoff, - i, - gp, - bz_grid.bzg2grg, - indices, - is_reducible_collision_matrix, - filename, - log_level): + if not _collect_collision_gp( + colmat_at_sigma, + gamma_at_sigma, + temperatures, + mesh, + sigma, + sigma_cutoff, + i, + gp, + bz_grid.bzg2grg, + indices, + is_reducible_collision_matrix, + filename, + log_level, + ): num_band = colmat_at_sigma.shape[3] for j in range(num_band): if not _collect_collision_band( - colmat_at_sigma, - gamma_at_sigma, - temperatures, - mesh, - sigma, - sigma_cutoff, - i, - gp, - bz_grid.bzg2grg, - j, - indices, - is_reducible_collision_matrix, - filename, - log_level): + colmat_at_sigma, + gamma_at_sigma, + temperatures, + mesh, + sigma, + sigma_cutoff, + i, + gp, + bz_grid.bzg2grg, + j, + indices, + is_reducible_collision_matrix, + filename, + log_level, + ): return False if len(sigmas) == 1: @@ -463,10 +495,9 @@ def _set_collision_from_file(lbte, read_from = "grid_points" if len(sigmas) > 1: - temperatures = np.array(temperatures, dtype='double', order='C') - gamma = np.array(gamma, dtype='double', order='C') - collision_matrix = np.array(collision_matrix, - dtype='double', order='C') + temperatures = np.array(temperatures, dtype="double", order="C") + gamma = np.array(gamma, dtype="double", order="C") + collision_matrix = np.array(collision_matrix, dtype="double", order="C") lbte.set_gamma(gamma) lbte.set_collision_matrix(collision_matrix) @@ -478,32 +509,38 @@ def _set_collision_from_file(lbte, return read_from -def _allocate_collision(for_gps, - mesh, - sigma, - sigma_cutoff, - grid_points, - indices, - is_reducible_collision_matrix, - filename): +def _allocate_collision( + for_gps, + mesh, + sigma, + sigma_cutoff, + grid_points, + indices, + is_reducible_collision_matrix, + filename, +): num_mesh_points = np.prod(mesh) if for_gps: - collision = read_collision_from_hdf5(mesh, - indices=indices, - grid_point=grid_points[0], - sigma=sigma, - sigma_cutoff=sigma_cutoff, - filename=filename, - verbose=False) + collision = read_collision_from_hdf5( + mesh, + indices=indices, + grid_point=grid_points[0], + sigma=sigma, + sigma_cutoff=sigma_cutoff, + filename=filename, + verbose=False, + ) else: - collision = read_collision_from_hdf5(mesh, - indices=indices, - grid_point=grid_points[0], - band_index=0, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - filename=filename, - verbose=False) + collision = read_collision_from_hdf5( + mesh, + indices=indices, + grid_point=grid_points[0], + band_index=0, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + filename=filename, + verbose=False, + ) if collision is None: return False @@ -514,44 +551,46 @@ def _allocate_collision(for_gps, else: num_band = collision[0].shape[3] # for bands (s,T,irgp,b) gamma_at_sigma = np.zeros( - (1, num_temp, num_mesh_points, num_band), - dtype='double', order='C') + (1, num_temp, num_mesh_points, num_band), dtype="double", order="C" + ) colmat_at_sigma = np.zeros( - (1, num_temp, - num_mesh_points, num_band, - num_mesh_points, num_band), - dtype='double', order='C') + (1, num_temp, num_mesh_points, num_band, num_mesh_points, num_band), + dtype="double", + order="C", + ) else: if for_gps: num_band = collision[0].shape[5] # for gps (s,T,b0,3,irgp,b,3) else: num_band = collision[0].shape[4] # for bands (s,T,3,irgp,b,3) gamma_at_sigma = np.zeros( - (1, num_temp, len(grid_points), num_band), - dtype='double', order='C') + (1, num_temp, len(grid_points), num_band), dtype="double", order="C" + ) colmat_at_sigma = np.zeros( - (1, num_temp, - len(grid_points), num_band, 3, - len(grid_points), num_band, 3), - dtype='double', order='C') - temperatures = np.zeros(num_temp, dtype='double', order='C') + (1, num_temp, len(grid_points), num_band, 3, len(grid_points), num_band, 3), + dtype="double", + order="C", + ) + temperatures = np.zeros(num_temp, dtype="double", order="C") return colmat_at_sigma, gamma_at_sigma, temperatures -def _collect_collision_gp(colmat_at_sigma, - gamma_at_sigma, - temperatures, - mesh, - sigma, - sigma_cutoff, - i, - gp, - bzg2grg, - indices, - is_reducible_collision_matrix, - filename, - log_level): +def _collect_collision_gp( + colmat_at_sigma, + gamma_at_sigma, + temperatures, + mesh, + sigma, + sigma_cutoff, + i, + gp, + bzg2grg, + indices, + is_reducible_collision_matrix, + filename, + log_level, +): collision_gp = read_collision_from_hdf5( mesh, indices=indices, @@ -559,16 +598,15 @@ def _collect_collision_gp(colmat_at_sigma, sigma=sigma, sigma_cutoff=sigma_cutoff, filename=filename, - verbose=(log_level > 0)) + verbose=(log_level > 0), + ) if log_level: sys.stdout.flush() if not collision_gp: return False - (colmat_at_gp, - gamma_at_gp, - temperatures_at_gp) = collision_gp + (colmat_at_gp, gamma_at_gp, temperatures_at_gp) = collision_gp if is_reducible_collision_matrix: igp = bzg2grg[gp] else: @@ -580,20 +618,22 @@ def _collect_collision_gp(colmat_at_sigma, return True -def _collect_collision_band(colmat_at_sigma, - gamma_at_sigma, - temperatures, - mesh, - sigma, - sigma_cutoff, - i, - gp, - bzg2grg, - j, - indices, - is_reducible_collision_matrix, - filename, - log_level): +def _collect_collision_band( + colmat_at_sigma, + gamma_at_sigma, + temperatures, + mesh, + sigma, + sigma_cutoff, + i, + gp, + bzg2grg, + j, + indices, + is_reducible_collision_matrix, + filename, + log_level, +): collision_band = read_collision_from_hdf5( mesh, indices=indices, @@ -602,16 +642,15 @@ def _collect_collision_band(colmat_at_sigma, sigma=sigma, sigma_cutoff=sigma_cutoff, filename=filename, - verbose=(log_level > 0)) + verbose=(log_level > 0), + ) if log_level: sys.stdout.flush() if collision_band is False: return False - (colmat_at_band, - gamma_at_band, - temperatures_at_band) = collision_band + (colmat_at_band, gamma_at_band, temperatures_at_band) = collision_band if is_reducible_collision_matrix: igp = bzg2grg[gp] else: @@ -626,6 +665,7 @@ def _collect_collision_band(colmat_at_sigma, def _select_solver(pinv_solver): try: import phono3py._phono3py as phono3c + default_solver = phono3c.default_colmat_solver() except ImportError: print("Phono3py C-routine is not compiled correctly.") @@ -637,7 +677,7 @@ def _select_solver(pinv_solver): if solver == 0: # default solver if default_solver in (4, 5, 6): try: - import scipy.linalg + import scipy.linalg # noqa F401 except ImportError: solver = 1 else: @@ -650,11 +690,9 @@ def _select_solver(pinv_solver): return solver -def diagonalize_collision_matrix(collision_matrices, - i_sigma=None, - i_temp=None, - pinv_solver=0, - log_level=0): +def diagonalize_collision_matrix( + collision_matrices, i_sigma=None, i_temp=None, pinv_solver=0, log_level=0 +): """Diagonalize collision matrices. Note @@ -713,11 +751,12 @@ def diagonalize_collision_matrix(collision_matrices, # [2] dsyevd: faster than dsyev and largest memory usage if solver in [1, 2]: if log_level: - routine = ['dsyev', 'dsyevd'][solver - 1] + routine = ["dsyev", "dsyevd"][solver - 1] sys.stdout.write("Diagonalizing by lapacke %s... " % routine) sys.stdout.flush() import phono3py._phono3py as phono3c - w = np.zeros(size, dtype='double') + + w = np.zeros(size, dtype="double") if i_sigma is None: _i_sigma = 0 else: @@ -726,38 +765,31 @@ def diagonalize_collision_matrix(collision_matrices, _i_temp = 0 else: _i_temp = i_temp - phono3c.diagonalize_collision_matrix(collision_matrices, - w, - _i_sigma, - _i_temp, - 0.0, - (solver + 1) % 2, - 0) # only diagonalization + phono3c.diagonalize_collision_matrix( + collision_matrices, w, _i_sigma, _i_temp, 0.0, (solver + 1) % 2, 0 + ) # only diagonalization elif solver == 3: # np.linalg.eigh depends on dsyevd. if log_level: sys.stdout.write("Diagonalizing by np.linalg.eigh... ") sys.stdout.flush() - col_mat = collision_matrices[i_sigma, i_temp].reshape( - size, size) + col_mat = collision_matrices[i_sigma, i_temp].reshape(size, size) w, col_mat[:] = np.linalg.eigh(col_mat) elif solver == 4: # fully scipy dsyev if log_level: - sys.stdout.write("Diagonalizing by " - "scipy.linalg.lapack.dsyev... ") + sys.stdout.write("Diagonalizing by " "scipy.linalg.lapack.dsyev... ") sys.stdout.flush() import scipy.linalg - col_mat = collision_matrices[i_sigma, i_temp].reshape( - size, size) + + col_mat = collision_matrices[i_sigma, i_temp].reshape(size, size) w, _, info = scipy.linalg.lapack.dsyev(col_mat.T, overwrite_a=1) elif solver == 5: # fully scipy dsyevd if log_level: - sys.stdout.write("Diagonalizing by " - "scipy.linalg.lapack.dsyevd... ") + sys.stdout.write("Diagonalizing by " "scipy.linalg.lapack.dsyevd... ") sys.stdout.flush() import scipy.linalg - col_mat = collision_matrices[i_sigma, i_temp].reshape( - size, size) + + col_mat = collision_matrices[i_sigma, i_temp].reshape(size, size) w, _, info = scipy.linalg.lapack.dsyevd(col_mat.T, overwrite_a=1) if log_level: @@ -770,25 +802,27 @@ def diagonalize_collision_matrix(collision_matrices, class Conductivity_LBTE(Conductivity): """Lattice thermal conductivity calculation by direct solution.""" - def __init__(self, - interaction, - grid_points=None, - temperatures=None, - sigmas=None, - sigma_cutoff=None, - is_isotope=False, - mass_variances=None, - boundary_mfp=None, # in micrometre - solve_collective_phonon=False, - is_reducible_collision_matrix=False, - is_kappa_star=True, - gv_delta_q=None, # finite difference for group veolocity - is_full_pp=False, - read_pp=False, - pp_filename=None, - pinv_cutoff=1.0e-8, - pinv_solver=0, - log_level=0): + def __init__( + self, + interaction, + grid_points=None, + temperatures=None, + sigmas=None, + sigma_cutoff=None, + is_isotope=False, + mass_variances=None, + boundary_mfp=None, # in micrometre + solve_collective_phonon=False, + is_reducible_collision_matrix=False, + is_kappa_star=True, + gv_delta_q=None, # finite difference for group veolocity + is_full_pp=False, + read_pp=False, + pp_filename=None, + pinv_cutoff=1.0e-8, + pinv_solver=0, + log_level=0, + ): """Init method.""" self._pp = None self._gv_obj = None @@ -835,19 +869,21 @@ class Conductivity_LBTE(Conductivity): self._collision_eigenvalues = None - Conductivity.__init__(self, - interaction, - grid_points=grid_points, - temperatures=temperatures, - sigmas=sigmas, - sigma_cutoff=sigma_cutoff, - is_isotope=is_isotope, - mass_variances=mass_variances, - boundary_mfp=boundary_mfp, - is_kappa_star=is_kappa_star, - gv_delta_q=gv_delta_q, - is_full_pp=is_full_pp, - log_level=log_level) + Conductivity.__init__( + self, + interaction, + grid_points=grid_points, + temperatures=temperatures, + sigmas=sigmas, + sigma_cutoff=sigma_cutoff, + is_isotope=is_isotope, + mass_variances=mass_variances, + boundary_mfp=boundary_mfp, + is_kappa_star=is_kappa_star, + gv_delta_q=gv_delta_q, + is_full_pp=is_full_pp, + log_level=log_level, + ) self._is_reducible_collision_matrix = is_reducible_collision_matrix self._solve_collective_phonon = solve_collective_phonon @@ -872,6 +908,7 @@ class Conductivity_LBTE(Conductivity): if len(self._grid_points) != len(self._ir_grid_points): print("Collision matrix is not well created.") import sys + sys.exit(1) else: weights = self._prepare_collision_matrix() @@ -892,16 +929,20 @@ class Conductivity_LBTE(Conductivity): def get_collision_matrix(self): """Return collision matrix.""" - warnings.warn("Use attribute, Conductivity_LBTE.collision_matrix " - "instead of Conductivity_LBTE.get_collision_matrix().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity_LBTE.collision_matrix " + "instead of Conductivity_LBTE.get_collision_matrix().", + DeprecationWarning, + ) return self.collision_matrix def set_collision_matrix(self, collision_matrix): """Set collision matrix.""" - warnings.warn("Use attribute, Conductivity_LBTE.collision_matrix " - "instead of Conductivity_LBTE.set_collision_matrix().", - DeprecationWarning) + warnings.warn( + "Use attribute, Conductivity_LBTE.collision_matrix " + "instead of Conductivity_LBTE.set_collision_matrix().", + DeprecationWarning, + ) self.collision_matrix = collision_matrix def get_collision_eigenvalues(self): @@ -942,8 +983,7 @@ class Conductivity_LBTE(Conductivity): self._collision.set_grid_point(gp) if self._log_level: - print("Number of triplets: %d" % - len(self._pp.get_triplets_at_q()[0])) + print("Number of triplets: %d" % len(self._pp.get_triplets_at_q()[0])) self._set_collision_matrix_at_sigmas(i) @@ -968,54 +1008,57 @@ class Conductivity_LBTE(Conductivity): num_temp = len(self._temperatures) if self._is_reducible_collision_matrix: - self._allocate_reducible_colmat_values( - num_temp, num_band0, num_band) + self._allocate_reducible_colmat_values(num_temp, num_band0, num_band) else: self._allocate_ir_colmat_values(num_temp, num_band0, num_band) def _allocate_local_values(self, num_temp, num_band0, num_grid_points): """Allocate grid point local arrays.""" - self._kappa = np.zeros((len(self._sigmas), num_temp, 6), - dtype='double', order='C') - self._kappa_RTA = np.zeros((len(self._sigmas), num_temp, 6), - dtype='double', order='C') - self._gv = np.zeros((num_grid_points, num_band0, 3), - dtype='double', order='C') - self._f_vectors = np.zeros((num_grid_points, num_band0, 3), - dtype='double', order='C') - self._gv_sum2 = np.zeros((num_grid_points, num_band0, 6), - dtype='double', order='C') - self._mfp = np.zeros((len(self._sigmas), - num_temp, - num_grid_points, - num_band0, - 3), dtype='double', order='C') - self._cv = np.zeros((num_temp, num_grid_points, num_band0), - dtype='double', order='C') + self._kappa = np.zeros( + (len(self._sigmas), num_temp, 6), dtype="double", order="C" + ) + self._kappa_RTA = np.zeros( + (len(self._sigmas), num_temp, 6), dtype="double", order="C" + ) + self._gv = np.zeros((num_grid_points, num_band0, 3), dtype="double", order="C") + self._f_vectors = np.zeros( + (num_grid_points, num_band0, 3), dtype="double", order="C" + ) + self._gv_sum2 = np.zeros( + (num_grid_points, num_band0, 6), dtype="double", order="C" + ) + self._mfp = np.zeros( + (len(self._sigmas), num_temp, num_grid_points, num_band0, 3), + dtype="double", + order="C", + ) + self._cv = np.zeros( + (num_temp, num_grid_points, num_band0), dtype="double", order="C" + ) if self._is_full_pp: self._averaged_pp_interaction = np.zeros( - (num_grid_points, num_band0), dtype='double', order='C') + (num_grid_points, num_band0), dtype="double", order="C" + ) if self._gamma is None: - self._gamma = np.zeros((len(self._sigmas), - num_temp, - num_grid_points, - num_band0), dtype='double', order='C') + self._gamma = np.zeros( + (len(self._sigmas), num_temp, num_grid_points, num_band0), + dtype="double", + order="C", + ) if self._isotope is not None: - self._gamma_iso = np.zeros((len(self._sigmas), - num_grid_points, - num_band0), dtype='double', order='C') + self._gamma_iso = np.zeros( + (len(self._sigmas), num_grid_points, num_band0), + dtype="double", + order="C", + ) - self._mode_kappa = np.zeros((len(self._sigmas), - num_temp, - num_grid_points, - num_band0, - 6), dtype='double') - self._mode_kappa_RTA = np.zeros((len(self._sigmas), - num_temp, - num_grid_points, - num_band0, - 6), dtype='double') + self._mode_kappa = np.zeros( + (len(self._sigmas), num_temp, num_grid_points, num_band0, 6), dtype="double" + ) + self._mode_kappa_RTA = np.zeros( + (len(self._sigmas), num_temp, num_grid_points, num_band0, 6), dtype="double" + ) def _allocate_reducible_colmat_values(self, num_temp, num_band0, num_band): """Allocate arrays for reducilble collision matrix.""" @@ -1026,19 +1069,27 @@ class Conductivity_LBTE(Conductivity): num_stored_grid_points = 1 self._allocate_local_values(num_temp, num_band0, num_mesh_points) self._collision = CollisionMatrix( - self._pp, - is_reducible_collision_matrix=True, - log_level=self._log_level) + self._pp, is_reducible_collision_matrix=True, log_level=self._log_level + ) if self._collision_matrix is None: self._collision_matrix = np.empty( - (len(self._sigmas), num_temp, - num_stored_grid_points, num_band0, - num_mesh_points, num_band), - dtype='double', order='C') + ( + len(self._sigmas), + num_temp, + num_stored_grid_points, + num_band0, + num_mesh_points, + num_band, + ), + dtype="double", + order="C", + ) self._collision_matrix[:] = 0 self._collision_eigenvalues = np.zeros( (len(self._sigmas), num_temp, num_mesh_points * num_band), - dtype='double', order='C') + dtype="double", + order="C", + ) def _allocate_ir_colmat_values(self, num_temp, num_band0, num_band): """Allocate arrays for ir collision matrix.""" @@ -1051,30 +1102,40 @@ class Conductivity_LBTE(Conductivity): self._allocate_local_values(num_temp, num_band0, num_grid_points) self._rot_grid_points = np.zeros( - (num_ir_grid_points, len(self._point_operations)), dtype='int_') + (num_ir_grid_points, len(self._point_operations)), dtype="int_" + ) for i, ir_gp in enumerate(self._ir_grid_points): self._rot_grid_points[i] = get_grid_points_by_rotations( - ir_gp, - self._pp.bz_grid) + ir_gp, self._pp.bz_grid + ) self._collision = CollisionMatrix( self._pp, rotations_cartesian=self._rotations_cartesian, num_ir_grid_points=num_ir_grid_points, rot_grid_points=self._rot_grid_points, - log_level=self._log_level) + log_level=self._log_level, + ) if self._collision_matrix is None: self._collision_matrix = np.empty( - (len(self._sigmas), - num_temp, - num_stored_grid_points, num_band0, 3, - num_ir_grid_points, num_band, 3), - dtype='double', order='C') + ( + len(self._sigmas), + num_temp, + num_stored_grid_points, + num_band0, + 3, + num_ir_grid_points, + num_band, + 3, + ), + dtype="double", + order="C", + ) self._collision_matrix[:] = 0 self._collision_eigenvalues = np.zeros( - (len(self._sigmas), - num_temp, - num_ir_grid_points * num_band * 3), - dtype='double', order='C') + (len(self._sigmas), num_temp, num_ir_grid_points * num_band * 3), + dtype="double", + order="C", + ) def _set_collision_matrix_at_sigmas(self, i): """Calculate collision matrices at grid point. @@ -1106,12 +1167,15 @@ class Conductivity_LBTE(Conductivity): sigma=sigma, sigma_cutoff=self._sigma_cutoff, filename=self._pp_filename, - verbose=(self._log_level > 0)) + verbose=(self._log_level > 0), + ) _, g_zero = self._collision.get_integration_weights() if self._log_level: if len(self._sigmas) > 1: - print("Multiple sigmas or mixing smearing and " - "tetrahedron method is not supported.") + print( + "Multiple sigmas or mixing smearing and " + "tetrahedron method is not supported." + ) if _g_zero is not None and (_g_zero != g_zero).any(): raise ValueError("Inconsistency found in g_zero.") self._collision.set_interaction_strength(pp) @@ -1124,8 +1188,7 @@ class Conductivity_LBTE(Conductivity): self._collision.run_interaction(is_full_pp=self._is_full_pp) if self._is_full_pp and j == 0: - self._averaged_pp_interaction[i] = ( - self._pp.get_averaged_interaction()) + self._averaged_pp_interaction[i] = self._pp.get_averaged_interaction() for k, t in enumerate(self._temperatures): self._collision.set_temperature(t) @@ -1137,10 +1200,10 @@ class Conductivity_LBTE(Conductivity): i_data = i else: i_data = 0 - self._gamma[j, k, i_data] = ( - self._collision.get_imag_self_energy()) - self._collision_matrix[j, k, i_data] = ( - self._collision.get_collision_matrix()) + self._gamma[j, k, i_data] = self._collision.get_imag_self_energy() + self._collision_matrix[ + j, k, i_data + ] = self._collision.get_collision_matrix() def _prepare_collision_matrix(self): """Prepare collision matrix to be solved.""" @@ -1149,21 +1212,22 @@ class Conductivity_LBTE(Conductivity): 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="int_") # 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="int_" + ) for i in range(num_mesh_points): rot_grid_points[:, i] = self._pp.bz_grid.bzg2grg[ get_grid_points_by_rotations( - self._pp.bz_grid.grg2bzg[i], self._pp.bz_grid)] + self._pp.bz_grid.grg2bzg[i], self._pp.bz_grid + ) + ] self._expand_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="int_") self._symmetrize_collision_matrix() else: self._combine_collisions() @@ -1197,52 +1261,56 @@ class Conductivity_LBTE(Conductivity): i_sigma=j, i_temp=k, pinv_solver=self._pinv_solver, - log_level=self._log_level) + log_level=self._log_level, + ) self._collision_eigenvalues[j, k] = w self._set_kappa(j, k, weights) if self._log_level: - print(("#%6s " + " %-10s" * 6) % - ("T(K)", "xx", "yy", "zz", "yz", "xz", "xy")) - print(("%7.1f " + " %10.3f" * 6) % - ((t,) + tuple(self._kappa[j, k]))) - print((" %6s " + " %10.3f" * 6) % - (("(RTA)",) + tuple(self._kappa_RTA[j, k]))) + print( + ("#%6s " + " %-10s" * 6) + % ("T(K)", "xx", "yy", "zz", "yz", "xz", "xy") + ) + print( + ("%7.1f " + " %10.3f" * 6) + % ((t,) + tuple(self._kappa[j, k])) + ) + print( + (" %6s " + " %10.3f" * 6) + % (("(RTA)",) + tuple(self._kappa_RTA[j, k])) + ) print("-" * 76) sys.stdout.flush() if self._log_level: - print('') + print("") def _combine_collisions(self): """Include diagonal elements into collision matrix.""" num_band = len(self._pp.primitive) * 3 - for j, k in list(np.ndindex( - (len(self._sigmas), len(self._temperatures)))): + for j, k in list(np.ndindex((len(self._sigmas), len(self._temperatures)))): for i, ir_gp in enumerate(self._ir_grid_points): - for r, r_gp in zip( - self._rotations_cartesian, self._rot_grid_points[i]): + for r, r_gp in zip(self._rotations_cartesian, self._rot_grid_points[i]): if ir_gp != r_gp: continue main_diagonal = self._get_main_diagonal(i, j, k) for ll in range(num_band): - self._collision_matrix[ - j, k, i, ll, :, i, ll, :] += main_diagonal[ll] * r + self._collision_matrix[j, k, i, ll, :, i, ll, :] += ( + main_diagonal[ll] * r + ) def _combine_reducible_collisions(self): """Include diagonal elements into collision matrix.""" num_band = len(self._pp.primitive) * 3 num_mesh_points = np.prod(self._pp.mesh_numbers) - for j, k in list( - np.ndindex((len(self._sigmas), len(self._temperatures)))): + for j, k in list(np.ndindex((len(self._sigmas), len(self._temperatures)))): for i in range(num_mesh_points): main_diagonal = self._get_main_diagonal(i, j, k) for ll in range(num_band): - self._collision_matrix[ - j, k, i, ll, i, ll] += main_diagonal[ll] + self._collision_matrix[j, k, i, ll, i, ll] += main_diagonal[ll] def _expand_collisions(self, ir_gr_grid_points, rot_grid_points): """Fill elements of full collision matrix by symmetry.""" @@ -1253,9 +1321,10 @@ class Conductivity_LBTE(Conductivity): try: import phono3py._phono3py as phono3c - phono3c.expand_collision_matrix(self._collision_matrix, - ir_gr_grid_points, - rot_grid_points) + + phono3c.expand_collision_matrix( + self._collision_matrix, ir_gr_grid_points, rot_grid_points + ) except ImportError: print("Phono3py C-routine is not compiled correctly.") num_mesh_points = np.prod(self._pp.mesh_numbers) @@ -1269,8 +1338,7 @@ class Conductivity_LBTE(Conductivity): gp_r = rot_grid_points[j, ir_gp] for k in range(num_mesh_points): gp_c = rot_grid_points[j, k] - colmat[:, :, gp_r, :, gp_c, :] += ( - colmat_irgp[:, :, :, k, :]) + colmat[:, :, gp_r, :, gp_c, :] += colmat_irgp[:, :, :, k, :] if self._log_level: print("[%.3fs]" % (time.time() - start)) @@ -1321,8 +1389,9 @@ class Conductivity_LBTE(Conductivity): sym_broken = False for gp in np.unique(r_gps): - if (len(np.where(r_gps == gp)[0]) != - self._rot_grid_points.shape[1] // len(np.unique(r_gps))): # noqa E129 + if len(np.where(r_gps == gp)[0]) != self._rot_grid_points.shape[ + 1 + ] // len(np.unique(r_gps)): sym_broken = True if sym_broken: @@ -1341,15 +1410,14 @@ class Conductivity_LBTE(Conductivity): try: import phono3py._phono3py as phono3c + if self._log_level: - sys.stdout.write("- Making collision matrix symmetric " - "(built-in) ") + sys.stdout.write("- Making collision matrix symmetric " "(built-in) ") sys.stdout.flush() phono3c.symmetrize_collision_matrix(self._collision_matrix) except ImportError: if self._log_level: - sys.stdout.write("- Making collision matrix symmetric " - "(numpy) ") + sys.stdout.write("- Making collision matrix symmetric " "(numpy) ") sys.stdout.flush() if self._is_reducible_collision_matrix: @@ -1372,8 +1440,9 @@ class Conductivity_LBTE(Conductivity): # Average matrix elements belonging to degenerate bands if self._log_level: - sys.stdout.write("- Averaging collision matrix elements " - "by phonon degeneracy ") + sys.stdout.write( + "- Averaging collision matrix elements " "by phonon degeneracy " + ) sys.stdout.flush() col_mat = self._collision_matrix @@ -1388,14 +1457,15 @@ class Conductivity_LBTE(Conductivity): if self._is_reducible_collision_matrix: i_data = self._pp.bz_grid.bzg2grg[gp] - sum_col = (col_mat[:, :, i_data, bi_set, :, :].sum(axis=2) - / len(bi_set)) + sum_col = col_mat[:, :, i_data, bi_set, :, :].sum(axis=2) / len( + bi_set + ) for j in bi_set: col_mat[:, :, i_data, j, :, :] = sum_col else: - sum_col = ( - col_mat[:, :, i, bi_set, :, :, :, :].sum(axis=2) / - len(bi_set)) + sum_col = col_mat[:, :, i, bi_set, :, :, :, :].sum(axis=2) / len( + bi_set + ) for j in bi_set: col_mat[:, :, i, j, :, :, :, :] = sum_col @@ -1409,14 +1479,15 @@ class Conductivity_LBTE(Conductivity): bi_set.append(j) if self._is_reducible_collision_matrix: i_data = self._pp.bz_grid.bzg2grg[gp] - sum_col = (col_mat[:, :, :, :, i_data, bi_set].sum(axis=4) - / len(bi_set)) + sum_col = col_mat[:, :, :, :, i_data, bi_set].sum(axis=4) / len( + bi_set + ) for j in bi_set: col_mat[:, :, :, :, i_data, j] = sum_col else: - sum_col = ( - col_mat[:, :, :, :, :, i, bi_set, :].sum(axis=5) / - len(bi_set)) + sum_col = col_mat[:, :, :, :, :, i, bi_set, :].sum(axis=5) / len( + bi_set + ) for j in bi_set: col_mat[:, :, :, :, :, i, j, :] = sum_col @@ -1434,9 +1505,11 @@ class Conductivity_LBTE(Conductivity): freqs = self._frequencies[self._ir_grid_points] t = self._temperatures[i_temp] - sinh = np.where(freqs > self._pp.cutoff_frequency, - np.sinh(freqs * THzToEv / (2 * Kb * t)), - -1.0) + sinh = np.where( + freqs > self._pp.cutoff_frequency, + np.sinh(freqs * THzToEv / (2 * Kb * t)), + -1.0, + ) inv_sinh = np.where(sinh > 0, 1.0 / sinh, 0) freqs_sinh = freqs * THzToEv * inv_sinh / (4 * Kb * t ** 2) @@ -1470,8 +1543,10 @@ class Conductivity_LBTE(Conductivity): if solver in [0, 1, 2, 3, 4, 5]: if self._log_level: - sys.stdout.write("Calculating pseudo-inv with cutoff=%-.1e " - "(np.dot) " % self._pinv_cutoff) + sys.stdout.write( + "Calculating pseudo-inv with cutoff=%-.1e " + "(np.dot) " % self._pinv_cutoff + ) sys.stdout.flush() e = self._get_eigvals_pinv(i_sigma, i_temp) @@ -1484,18 +1559,18 @@ class Conductivity_LBTE(Conductivity): Y = np.dot(v, e * np.dot(v.T, X.ravel())).reshape(-1, 3) else: # solver=6 This is slower as far as tested. import phono3py._phono3py as phono3c + if self._log_level: - sys.stdout.write("Calculating pseudo-inv with cutoff=%-.1e " - "(built-in) " % self._pinv_cutoff) + sys.stdout.write( + "Calculating pseudo-inv with cutoff=%-.1e " + "(built-in) " % self._pinv_cutoff + ) sys.stdout.flush() w = self._collision_eigenvalues[i_sigma, i_temp] - phono3c.pinv_from_eigensolution(self._collision_matrix, - w, - i_sigma, - i_temp, - self._pinv_cutoff, - 0) + phono3c.pinv_from_eigensolution( + self._collision_matrix, w, i_sigma, i_temp, self._pinv_cutoff, 0 + ) if self._is_reducible_collision_matrix: Y = np.dot(v, X) else: @@ -1517,8 +1592,9 @@ class Conductivity_LBTE(Conductivity): """ num_band = len(self._pp.primitive) * 3 - self._f_vectors[:] = ((Y / 2).reshape(num_grid_points, num_band * 3).T - / weights).T.reshape(self._f_vectors.shape) + self._f_vectors[:] = ( + (Y / 2).reshape(num_grid_points, num_band * 3).T / weights + ).T.reshape(self._f_vectors.shape) def _get_eigvals_pinv(self, i_sigma, i_temp): """Return inverse eigenvalues of eigenvalues > epsilon.""" @@ -1535,7 +1611,7 @@ class Conductivity_LBTE(Conductivity): None is returned if I is zero matrix. """ - r_sum = np.zeros((3, 3), dtype='double', order='C') + r_sum = np.zeros((3, 3), dtype="double", order="C") for r in self._rotations_cartesian: for i in range(3): for j in range(3): @@ -1549,9 +1625,9 @@ class Conductivity_LBTE(Conductivity): # Same as np.kron(np.eye(size), r_sum), but writen as below # to be sure the values in memory C-congiguous with 'double'. - I_mat = np.zeros((3 * size, 3 * size), dtype='double', order='C') + I_mat = np.zeros((3 * size, 3 * size), dtype="double", order="C") for i in range(size): - I_mat[(i * 3):((i + 1) * 3), (i * 3):((i + 1) * 3)] = r_sum + I_mat[(i * 3) : ((i + 1) * 3), (i * 3) : ((i + 1) * 3)] = r_sum return I_mat @@ -1576,13 +1652,15 @@ class Conductivity_LBTE(Conductivity): num_ir_grid_points = len(self._ir_grid_points) Y = self._get_Y(i_sigma, i_temp, weights, X) self._set_mean_free_path(i_sigma, i_temp, weights, Y) - self._set_mode_kappa(self._mode_kappa, - X, - Y, - num_ir_grid_points, - self._rotations_cartesian, - i_sigma, - i_temp) + self._set_mode_kappa( + self._mode_kappa, + X, + Y, + num_ir_grid_points, + self._rotations_cartesian, + i_sigma, + i_temp, + ) # self._set_mode_kappa_from_mfp(weights, # num_ir_grid_points, # self._rotations_cartesian, @@ -1590,7 +1668,8 @@ class Conductivity_LBTE(Conductivity): # i_temp) self._kappa[i_sigma, i_temp] = ( - self._mode_kappa[i_sigma, i_temp].sum(axis=0).sum(axis=0) / N) + self._mode_kappa[i_sigma, i_temp].sum(axis=0).sum(axis=0) / N + ) def _set_kappa_reducible_colmat(self, i_sigma, i_temp, weights): """Calculate direct solution thermal conductivity of full colmat.""" @@ -1601,16 +1680,19 @@ class Conductivity_LBTE(Conductivity): self._set_mean_free_path(i_sigma, i_temp, weights, Y) # Putting self._rotations_cartesian is to symmetrize kappa. # None can be put instead for watching pure information. - self._set_mode_kappa(self._mode_kappa, - X, - Y, - num_mesh_points, - self._rotations_cartesian, - i_sigma, - i_temp) + self._set_mode_kappa( + self._mode_kappa, + X, + Y, + num_mesh_points, + self._rotations_cartesian, + i_sigma, + i_temp, + ) self._mode_kappa[i_sigma, i_temp] /= len(self._rotations_cartesian) self._kappa[i_sigma, i_temp] = ( - self._mode_kappa[i_sigma, i_temp].sum(axis=0).sum(axis=0) / N) + self._mode_kappa[i_sigma, i_temp].sum(axis=0).sum(axis=0) / N + ) def _set_kappa_RTA(self, i_sigma, i_temp, weights): """Calculate RTA thermal conductivity with either ir or full colmat.""" @@ -1630,35 +1712,39 @@ class Conductivity_LBTE(Conductivity): X = self._get_X(i_temp, weights, self._gv) Y = np.zeros_like(X) num_ir_grid_points = len(self._ir_grid_points) - size = num_ir_grid_points * num_band * 3 for i, gp in enumerate(self._ir_grid_points): g = self._get_main_diagonal(i, i_sigma, i_temp) frequencies = self._frequencies[gp] for j, f in enumerate(frequencies): if f > self._pp.cutoff_frequency: i_mode = i * num_band + j - old_settings = np.seterr(all='raise') + old_settings = np.seterr(all="raise") try: Y[i_mode, :] = X[i_mode, :] / g[j] except Exception: print("=" * 26 + " Warning " + "=" * 26) - print(" Unexpected physical condition of ph-ph " - "interaction calculation was found.") - print(" g[j]=%f at gp=%d, band=%d, freq=%f" % - (g[j], gp, j + 1, f)) + print( + " Unexpected physical condition of ph-ph " + "interaction calculation was found." + ) + print( + " g[j]=%f at gp=%d, band=%d, freq=%f" % (g[j], gp, j + 1, f) + ) print("=" * 61) np.seterr(**old_settings) - self._set_mode_kappa(self._mode_kappa_RTA, - X, - Y, - num_ir_grid_points, - self._rotations_cartesian, - i_sigma, - i_temp) + self._set_mode_kappa( + self._mode_kappa_RTA, + X, + Y, + num_ir_grid_points, + self._rotations_cartesian, + i_sigma, + i_temp, + ) self._kappa_RTA[i_sigma, i_temp] = ( - self._mode_kappa_RTA[i_sigma, i_temp].sum(axis=0).sum(axis=0) / - N) + self._mode_kappa_RTA[i_sigma, i_temp].sum(axis=0).sum(axis=0) / N + ) def _set_kappa_RTA_reducible_colmat(self, i_sigma, i_temp, weights): """Calculate RTA thermal conductivity. @@ -1676,7 +1762,8 @@ class Conductivity_LBTE(Conductivity): num_mesh_points = np.prod(self._pp.mesh_numbers) size = num_mesh_points * num_band v_diag = np.diagonal( - self._collision_matrix[i_sigma, i_temp].reshape(size, size)) + self._collision_matrix[i_sigma, i_temp].reshape(size, size) + ) for gp in range(num_mesh_points): frequencies = self._frequencies[gp] @@ -1686,27 +1773,24 @@ class Conductivity_LBTE(Conductivity): Y[i_mode, :] = X[i_mode, :] / v_diag[i_mode] # Putting self._rotations_cartesian is to symmetrize kappa. # None can be put instead for watching pure information. - self._set_mode_kappa(self._mode_kappa_RTA, - X, - Y, - num_mesh_points, - self._rotations_cartesian, - i_sigma, - i_temp) + self._set_mode_kappa( + self._mode_kappa_RTA, + X, + Y, + num_mesh_points, + self._rotations_cartesian, + i_sigma, + i_temp, + ) g = len(self._rotations_cartesian) self._mode_kappa_RTA[i_sigma, i_temp] /= g self._kappa_RTA[i_sigma, i_temp] = ( - self._mode_kappa_RTA[i_sigma, i_temp].sum(axis=0).sum(axis=0) / - N) + self._mode_kappa_RTA[i_sigma, i_temp].sum(axis=0).sum(axis=0) / N + ) - def _set_mode_kappa(self, - mode_kappa, - X, - Y, - num_grid_points, - rotations_cartesian, - i_sigma, - i_temp): + def _set_mode_kappa( + self, mode_kappa, X, Y, num_grid_points, rotations_cartesian, i_sigma, i_temp + ): """Calculate mode thermal conductivity. The first parameter, mode_kappa, is overwritten. @@ -1714,8 +1798,11 @@ class Conductivity_LBTE(Conductivity): """ num_band = len(self._pp.primitive) * 3 for i, (v_gp, f_gp) in enumerate( - zip(X.reshape(num_grid_points, num_band, 3), - Y.reshape(num_grid_points, num_band, 3))): + zip( + X.reshape(num_grid_points, num_band, 3), + Y.reshape(num_grid_points, num_band, 3), + ) + ): for j, (v, f) in enumerate(zip(v_gp, f_gp)): # Do not consider three lowest modes at Gamma-point @@ -1726,12 +1813,13 @@ class Conductivity_LBTE(Conductivity): if rotations_cartesian is None: sum_k = np.outer(v, f) else: - sum_k = np.zeros((3, 3), dtype='double') + sum_k = np.zeros((3, 3), dtype="double") for r in rotations_cartesian: sum_k += np.outer(np.dot(r, v), np.dot(r, f)) sum_k = sum_k + sum_k.T for k, vxf in enumerate( - ((0, 0), (1, 1), (2, 2), (1, 2), (0, 2), (0, 1))): + ((0, 0), (1, 1), (2, 2), (1, 2), (0, 2), (0, 1)) + ): mode_kappa[i_sigma, i_temp, i, j, k] = sum_k[vxf] t = self._temperatures[i_temp] @@ -1758,7 +1846,7 @@ class Conductivity_LBTE(Conductivity): e = self._get_eigvals_pinv(i_sigma, i_temp) t = self._temperatures[i_temp] - omega_inv = np.empty(v.shape, dtype='double', order='C') + omega_inv = np.empty(v.shape, dtype="double", order="C") np.dot(v, (e * v).T, out=omega_inv) Y = np.dot(omega_inv, X) self._set_f_vectors(Y, num_ir_grid_points, weights) @@ -1771,9 +1859,9 @@ class Conductivity_LBTE(Conductivity): # vals = (X ** 2 * np.diag(mat)).reshape(-1, 3).sum(axis=1) # vals = vals.reshape(num_ir_grid_points, num_band) # self._mode_kappa[i_sigma, i_temp, :, :, i] = vals - w = diagonalize_collision_matrix(mat, - pinv_solver=self._pinv_solver, - log_level=self._log_level) + w = diagonalize_collision_matrix( + mat, pinv_solver=self._pinv_solver, log_level=self._log_level + ) if solver in [1, 2, 4, 5]: mat = mat.T spectra = np.dot(mat.T, X) ** 2 * w @@ -1785,24 +1873,22 @@ class Conductivity_LBTE(Conductivity): factor = self._conversion_factor * Kb * t ** 2 self._mode_kappa[i_sigma, i_temp] *= factor - def _set_mode_kappa_from_mfp(self, - weights, - num_grid_points, - rotations_cartesian, - i_sigma, - i_temp): + def _set_mode_kappa_from_mfp( + self, weights, num_grid_points, rotations_cartesian, i_sigma, i_temp + ): for i, (v_gp, mfp_gp, cv_gp) in enumerate( - zip(self._gv, self._mfp[i_sigma, i_temp], self._cv[i_temp])): + zip(self._gv, self._mfp[i_sigma, i_temp], self._cv[i_temp]) + ): for j, (v, mfp, cv) in enumerate(zip(v_gp, mfp_gp, cv_gp)): - sum_k = np.zeros((3, 3), dtype='double') + sum_k = np.zeros((3, 3), dtype="double") for r in rotations_cartesian: sum_k += np.outer(np.dot(r, v), np.dot(r, mfp)) - sum_k = ((sum_k + sum_k.T) / 2 * cv * weights[i] ** 2 - * 2 * np.pi) + sum_k = (sum_k + sum_k.T) / 2 * cv * weights[i] ** 2 * 2 * np.pi for k, vxf in enumerate( - ((0, 0), (1, 1), (2, 2), (1, 2), (0, 2), (0, 1))): + ((0, 0), (1, 1), (2, 2), (1, 2), (0, 2), (0, 1)) + ): self._mode_kappa[i_sigma, i_temp, i, j, k] = sum_k[vxf] - self._mode_kappa *= - self._conversion_factor + self._mode_kappa *= -self._conversion_factor def _set_mean_free_path(self, i_sigma, i_temp, weights, Y): t = self._temperatures[i_temp] @@ -1813,7 +1899,8 @@ class Conductivity_LBTE(Conductivity): if cv < 1e-10: continue self._mfp[i_sigma, i_temp, i, j] = ( - - 2 * t * np.sqrt(Kb / cv) * f / (2 * np.pi)) + -2 * t * np.sqrt(Kb / cv) * f / (2 * np.pi) + ) def _show_log(self, i): gp = self._grid_points[i] @@ -1835,12 +1922,16 @@ class Conductivity_LBTE(Conductivity): print(text) if self._is_full_pp: for f, v, pp in zip(frequencies, gv, ave_pp): - print("%8.3f (%8.3f %8.3f %8.3f) %8.3f %11.3e" % - (f, v[0], v[1], v[2], np.linalg.norm(v), pp)) + print( + "%8.3f (%8.3f %8.3f %8.3f) %8.3f %11.3e" + % (f, v[0], v[1], v[2], np.linalg.norm(v), pp) + ) else: for f, v in zip(frequencies, gv): - print("%8.3f (%8.3f %8.3f %8.3f) %8.3f" % - (f, v[0], v[1], v[2], np.linalg.norm(v))) + print( + "%8.3f (%8.3f %8.3f %8.3f) %8.3f" + % (f, v[0], v[1], v[2], np.linalg.norm(v)) + ) sys.stdout.flush() @@ -1853,12 +1944,13 @@ class Conductivity_LBTE(Conductivity): for ll in range(num_ir_grid_points): for m in range(num_band): for n in range(3): - self._py_set_symmetrized_element( - i, j, k, ll, m, n) + self._py_set_symmetrized_element(i, j, k, ll, m, n) def _py_set_symmetrized_element(self, i, j, k, ll, m, n): - sym_val = (self._collision_matrix[:, :, i, j, k, ll, m, n] + - self._collision_matrix[:, :, ll, m, n, i, j, k]) / 2 + sym_val = ( + self._collision_matrix[:, :, i, j, k, ll, m, n] + + self._collision_matrix[:, :, ll, m, n, i, j, k] + ) / 2 self._collision_matrix[:, :, i, j, k, ll, m, n] = sym_val self._collision_matrix[:, :, ll, m, n, i, j, k] = sym_val @@ -1869,11 +1961,12 @@ class Conductivity_LBTE(Conductivity): for j in range(num_band): for k in range(num_ir_grid_points): for ll in range(num_band): - self._py_set_symmetrized_element_no_kappa_stars( - i, j, k, ll) + self._py_set_symmetrized_element_no_kappa_stars(i, j, k, ll) def _py_set_symmetrized_element_no_kappa_stars(self, i, j, k, ll): - sym_val = (self._collision_matrix[:, :, i, j, k, ll] + - self._collision_matrix[:, :, k, ll, i, j]) / 2 + sym_val = ( + self._collision_matrix[:, :, i, j, k, ll] + + self._collision_matrix[:, :, k, ll, i, j] + ) / 2 self._collision_matrix[:, :, i, j, k, ll] = sym_val self._collision_matrix[:, :, k, ll, i, j] = sym_val diff --git a/phono3py/phonon3/conductivity_RTA.py b/phono3py/phonon3/conductivity_RTA.py index 202b66ad..a5d62e5e 100644 --- a/phono3py/phonon3/conductivity_RTA.py +++ b/phono3py/phonon3/conductivity_RTA.py @@ -36,51 +36,56 @@ import sys import numpy as np from phonopy.structure.tetrahedron_method import TetrahedronMethod -from phono3py.file_IO import (write_kappa_to_hdf5, read_gamma_from_hdf5, - write_gamma_detail_to_hdf5, read_pp_from_hdf5) -from phono3py.phonon3.conductivity import (Conductivity, all_bands_exist, - unit_to_WmK) +from phono3py.file_IO import ( + write_kappa_to_hdf5, + read_gamma_from_hdf5, + write_gamma_detail_to_hdf5, + read_pp_from_hdf5, +) +from phono3py.phonon3.conductivity import Conductivity, all_bands_exist, unit_to_WmK from phono3py.phonon3.conductivity import write_pp as _write_pp -from phono3py.phonon3.imag_self_energy import (ImagSelfEnergy, - average_by_degeneracy) +from phono3py.phonon3.imag_self_energy import ImagSelfEnergy, average_by_degeneracy from phono3py.phonon3.triplets import get_all_triplets from phono3py.phonon.grid import get_grid_points_by_rotations def get_thermal_conductivity_RTA( - interaction, - temperatures=None, - sigmas=None, - sigma_cutoff=None, - mass_variances=None, - grid_points=None, - is_isotope=False, - boundary_mfp=None, # in micrometre - use_ave_pp=False, - gamma_unit_conversion=None, - is_kappa_star=True, - gv_delta_q=None, - is_full_pp=False, - write_gamma=False, - read_gamma=False, - is_N_U=False, - write_kappa=False, - write_pp=False, - read_pp=False, - write_gamma_detail=False, - compression="gzip", - input_filename=None, - output_filename=None, - log_level=0): + interaction, + temperatures=None, + sigmas=None, + sigma_cutoff=None, + mass_variances=None, + grid_points=None, + is_isotope=False, + boundary_mfp=None, # in micrometre + use_ave_pp=False, + gamma_unit_conversion=None, + is_kappa_star=True, + gv_delta_q=None, + is_full_pp=False, + write_gamma=False, + read_gamma=False, + is_N_U=False, + write_kappa=False, + write_pp=False, + read_pp=False, + write_gamma_detail=False, + compression="gzip", + input_filename=None, + output_filename=None, + log_level=0, +): """Run RTA thermal conductivity calculation.""" if temperatures is None: - _temperatures = np.arange(0, 1001, 10, dtype='double') + _temperatures = np.arange(0, 1001, 10, dtype="double") else: _temperatures = temperatures if log_level: - print("-------------------- Lattice thermal conducitivity (RTA) " - "--------------------") + print( + "-------------------- Lattice thermal conducitivity (RTA) " + "--------------------" + ) br = Conductivity_RTA( interaction, grid_points=grid_points, @@ -100,7 +105,8 @@ def get_thermal_conductivity_RTA( pp_filename=input_filename, is_N_U=is_N_U, is_gamma_detail=write_gamma_detail, - log_level=log_level) + log_level=log_level, + ) if read_gamma: if not _set_gamma_from_file(br, filename=input_filename): @@ -109,42 +115,47 @@ def get_thermal_conductivity_RTA( for i in br: if write_pp: - _write_pp(br, - interaction, - i, - compression=compression, - filename=output_filename) + _write_pp( + br, interaction, i, compression=compression, filename=output_filename + ) if write_gamma: - _write_gamma(br, - interaction, - i, - compression=compression, - filename=output_filename, - verbose=log_level) + _write_gamma( + br, + interaction, + i, + compression=compression, + filename=output_filename, + verbose=log_level, + ) if write_gamma_detail: - _write_gamma_detail(br, - interaction, - i, - compression=compression, - filename=output_filename, - verbose=log_level) + _write_gamma_detail( + br, + interaction, + i, + compression=compression, + filename=output_filename, + verbose=log_level, + ) if grid_points is None and all_bands_exist(interaction): br.set_kappa_at_sigmas() if log_level: _show_kappa(br, log_level) if write_kappa: - _write_kappa(br, - interaction.primitive.volume, - compression=compression, - filename=output_filename, - log_level=log_level) + _write_kappa( + br, + interaction.primitive.volume, + compression=compression, + filename=output_filename, + log_level=log_level, + ) return br -def _write_gamma_detail(br, interaction, i, compression="gzip", filename=None, - verbose=True): +def _write_gamma_detail( + br, interaction, i, compression="gzip", filename=None, verbose=True +): gamma_detail = br.get_gamma_detail_at_q() temperatures = br.get_temperatures() mesh = br.get_mesh_numbers() @@ -169,7 +180,8 @@ def _write_gamma_detail(br, interaction, i, compression="gzip", filename=None, sigma_cutoff=sigma_cutoff, compression=compression, filename=filename, - verbose=verbose) + verbose=verbose, + ) else: for j, sigma in enumerate(sigmas): for k, bi in enumerate(interaction.get_band_indices()): @@ -185,11 +197,11 @@ def _write_gamma_detail(br, interaction, i, compression="gzip", filename=None, sigma_cutoff=sigma_cutoff, compression=compression, filename=filename, - verbose=verbose) + verbose=verbose, + ) -def _write_gamma(br, interaction, i, compression="gzip", filename=None, - verbose=True): +def _write_gamma(br, interaction, i, compression="gzip", filename=None, verbose=True): """Write mode kappa related properties into a hdf5 file.""" grid_points = br.grid_points group_velocities = br.group_velocities @@ -226,24 +238,26 @@ def _write_gamma(br, interaction, i, compression="gzip", filename=None, else: gamma_U_at_sigma = gamma_U[j, :, i] - write_kappa_to_hdf5(temperatures, - mesh, - frequency=frequencies, - group_velocity=group_velocities[i], - gv_by_gv=gv_by_gv[i], - heat_capacity=mode_heat_capacities[:, i], - gamma=gamma[j, :, i], - gamma_isotope=gamma_isotope_at_sigma, - gamma_N=gamma_N_at_sigma, - gamma_U=gamma_U_at_sigma, - averaged_pp_interaction=ave_pp_i, - grid_point=gp, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - kappa_unit_conversion=unit_to_WmK / volume, - compression=compression, - filename=filename, - verbose=verbose) + write_kappa_to_hdf5( + temperatures, + mesh, + frequency=frequencies, + group_velocity=group_velocities[i], + gv_by_gv=gv_by_gv[i], + heat_capacity=mode_heat_capacities[:, i], + gamma=gamma[j, :, i], + gamma_isotope=gamma_isotope_at_sigma, + gamma_N=gamma_N_at_sigma, + gamma_U=gamma_U_at_sigma, + averaged_pp_interaction=ave_pp_i, + grid_point=gp, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + kappa_unit_conversion=unit_to_WmK / volume, + compression=compression, + filename=filename, + verbose=verbose, + ) else: for j, sigma in enumerate(sigmas): for k, bi in enumerate(interaction.band_indices): @@ -283,7 +297,8 @@ def _write_gamma(br, interaction, i, compression="gzip", filename=None, kappa_unit_conversion=unit_to_WmK / volume, compression=compression, filename=filename, - verbose=verbose) + verbose=verbose, + ) def _show_kappa(br, log_level): @@ -301,18 +316,27 @@ def _show_kappa(br, log_level): text += "with tetrahedron method -----------" print(text) if log_level > 1: - print(("#%6s " + " %-10s" * 6 + "#ipm") % - ("T(K)", "xx", "yy", "zz", "yz", "xz", "xy")) + print( + ("#%6s " + " %-10s" * 6 + "#ipm") + % ("T(K)", "xx", "yy", "zz", "yz", "xz", "xy") + ) for j, (t, k) in enumerate(zip(temperatures, kappa[i])): - print(("%7.1f" + " %10.3f" * 6 + " %d/%d") % - ((t,) + tuple(k) + - (num_ignored_phonon_modes[i, j], num_phonon_modes))) + print( + ("%7.1f" + " %10.3f" * 6 + " %d/%d") + % ( + (t,) + + tuple(k) + + (num_ignored_phonon_modes[i, j], num_phonon_modes) + ) + ) else: - print(("#%6s " + " %-10s" * 6) % - ("T(K)", "xx", "yy", "zz", "yz", "xz", "xy")) + print( + ("#%6s " + " %-10s" * 6) + % ("T(K)", "xx", "yy", "zz", "yz", "xz", "xy") + ) for j, (t, k) in enumerate(zip(temperatures, kappa[i])): print(("%7.1f " + " %10.3f" * 6) % ((t,) + tuple(k))) - print('') + print("") def _write_kappa(br, volume, compression="gzip", filename=None, log_level=0): @@ -348,27 +372,29 @@ def _write_kappa(br, volume, compression="gzip", filename=None, log_level=0): else: gamma_U_at_sigma = gamma_U[i] - write_kappa_to_hdf5(temperatures, - mesh, - frequency=frequencies, - group_velocity=gv, - gv_by_gv=gv_by_gv, - heat_capacity=mode_cv, - kappa=kappa_at_sigma, - mode_kappa=mode_kappa[i], - gamma=gamma[i], - gamma_isotope=gamma_isotope_at_sigma, - gamma_N=gamma_N_at_sigma, - gamma_U=gamma_U_at_sigma, - averaged_pp_interaction=ave_pp, - qpoint=qpoints, - weight=weights, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - kappa_unit_conversion=unit_to_WmK / volume, - compression=compression, - filename=filename, - verbose=log_level) + write_kappa_to_hdf5( + temperatures, + mesh, + frequency=frequencies, + group_velocity=gv, + gv_by_gv=gv_by_gv, + heat_capacity=mode_cv, + kappa=kappa_at_sigma, + mode_kappa=mode_kappa[i], + gamma=gamma[i], + gamma_isotope=gamma_isotope_at_sigma, + gamma_N=gamma_N_at_sigma, + gamma_U=gamma_U_at_sigma, + averaged_pp_interaction=ave_pp, + qpoint=qpoints, + weight=weights, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + kappa_unit_conversion=unit_to_WmK / volume, + compression=compression, + filename=filename, + verbose=log_level, + ) def _set_gamma_from_file(br, filename=None, verbose=True): @@ -380,16 +406,13 @@ def _set_gamma_from_file(br, filename=None, verbose=True): temperatures = br.get_temperatures() num_band = br.get_frequencies().shape[1] - gamma = np.zeros((len(sigmas), - len(temperatures), - len(grid_points), - num_band), dtype='double') + gamma = np.zeros( + (len(sigmas), len(temperatures), len(grid_points), num_band), dtype="double" + ) gamma_N = np.zeros_like(gamma) gamma_U = np.zeros_like(gamma) - gamma_iso = np.zeros((len(sigmas), - len(grid_points), - num_band), dtype='double') - ave_pp = np.zeros((len(grid_points), num_band), dtype='double') + gamma_iso = np.zeros((len(sigmas), len(grid_points), num_band), dtype="double") + ave_pp = np.zeros((len(grid_points), num_band), dtype="double") is_gamma_N_U_in = False is_ave_pp_in = False @@ -401,18 +424,19 @@ def _set_gamma_from_file(br, filename=None, verbose=True): sigma=sigma, sigma_cutoff=sigma_cutoff, filename=filename, - verbose=verbose) + verbose=verbose, + ) if data: - gamma[j] = data['gamma'] - if 'gamma_isotope' in data: - gamma_iso[j] = data['gamma_isotope'] - if 'gamma_N' in data: + gamma[j] = data["gamma"] + if "gamma_isotope" in data: + gamma_iso[j] = data["gamma_isotope"] + if "gamma_N" in data: is_gamma_N_U_in = True - gamma_N[j] = data['gamma_N'] - gamma_U[j] = data['gamma_U'] - if 'ave_pp' in data: + gamma_N[j] = data["gamma_N"] + gamma_U[j] = data["gamma_U"] + if "ave_pp" in data: is_ave_pp_in = True - ave_pp[:] = data['ave_pp'] + ave_pp[:] = data["ave_pp"] else: for i, gp in enumerate(grid_points): data_gp = read_gamma_from_hdf5( @@ -421,18 +445,19 @@ def _set_gamma_from_file(br, filename=None, verbose=True): sigma=sigma, sigma_cutoff=sigma_cutoff, filename=filename, - verbose=verbose) + verbose=verbose, + ) if data_gp: - gamma[j, :, i] = data_gp['gamma'] - if 'gamma_iso' in data_gp: - gamma_iso[j, i] = data_gp['gamma_iso'] - if 'gamma_N' in data_gp: + gamma[j, :, i] = data_gp["gamma"] + if "gamma_iso" in data_gp: + gamma_iso[j, i] = data_gp["gamma_iso"] + if "gamma_N" in data_gp: is_gamma_N_U_in = True - gamma_N[j, :, i] = data_gp['gamma_N'] - gamma_U[j, :, i] = data_gp['gamma_U'] - if 'ave_pp' in data_gp: + gamma_N[j, :, i] = data_gp["gamma_N"] + gamma_U[j, :, i] = data_gp["gamma_U"] + if "ave_pp" in data_gp: is_ave_pp_in = True - ave_pp[i] = data_gp['ave_pp'] + ave_pp[i] = data_gp["ave_pp"] else: for bi in range(num_band): data_band = read_gamma_from_hdf5( @@ -442,18 +467,19 @@ def _set_gamma_from_file(br, filename=None, verbose=True): sigma=sigma, sigma_cutoff=sigma_cutoff, filename=filename, - verbose=verbose) + verbose=verbose, + ) if data_band: - gamma[j, :, i, bi] = data_band['gamma'] - if 'gamma_iso' in data_band: - gamma_iso[j, i, bi] = data_band['gamma_iso'] - if 'gamma_N' in data_band: + gamma[j, :, i, bi] = data_band["gamma"] + if "gamma_iso" in data_band: + gamma_iso[j, i, bi] = data_band["gamma_iso"] + if "gamma_N" in data_band: is_gamma_N_U_in = True - gamma_N[j, :, i, bi] = data_band['gamma_N'] - gamma_U[j, :, i, bi] = data_band['gamma_U'] - if 'ave_pp' in data_band: + gamma_N[j, :, i, bi] = data_band["gamma_N"] + gamma_U[j, :, i, bi] = data_band["gamma_U"] + if "ave_pp" in data_band: is_ave_pp_in = True - ave_pp[i, bi] = data_band['ave_pp'] + ave_pp[i, bi] = data_band["ave_pp"] else: read_succeeded = False @@ -471,27 +497,29 @@ def _set_gamma_from_file(br, filename=None, verbose=True): class Conductivity_RTA(Conductivity): """Lattice thermal conductivity calculation with RTA.""" - def __init__(self, - interaction, - grid_points=None, - temperatures=None, - sigmas=None, - sigma_cutoff=None, - is_isotope=False, - mass_variances=None, - boundary_mfp=None, # in micrometre - use_ave_pp=False, - gamma_unit_conversion=None, - is_kappa_star=True, - gv_delta_q=None, - is_full_pp=False, - read_pp=False, - store_pp=False, - pp_filename=None, - is_N_U=False, - is_gamma_detail=False, - is_frequency_shift_by_bubble=False, - log_level=0): + def __init__( + self, + interaction, + grid_points=None, + temperatures=None, + sigmas=None, + sigma_cutoff=None, + is_isotope=False, + mass_variances=None, + boundary_mfp=None, # in micrometre + use_ave_pp=False, + gamma_unit_conversion=None, + is_kappa_star=True, + gv_delta_q=None, + is_full_pp=False, + read_pp=False, + store_pp=False, + pp_filename=None, + is_N_U=False, + is_gamma_detail=False, + is_frequency_shift_by_bubble=False, + log_level=0, + ): """Init method.""" self._pp = None self._gv_obj = None @@ -538,19 +566,21 @@ class Conductivity_RTA(Conductivity): self._mass_variances = None self._grid_point_count = None - Conductivity.__init__(self, - interaction, - grid_points=grid_points, - temperatures=temperatures, - sigmas=sigmas, - sigma_cutoff=sigma_cutoff, - is_isotope=is_isotope, - mass_variances=mass_variances, - boundary_mfp=boundary_mfp, - is_kappa_star=is_kappa_star, - gv_delta_q=gv_delta_q, - is_full_pp=is_full_pp, - log_level=log_level) + Conductivity.__init__( + self, + interaction, + grid_points=grid_points, + temperatures=temperatures, + sigmas=sigmas, + sigma_cutoff=sigma_cutoff, + is_isotope=is_isotope, + mass_variances=mass_variances, + boundary_mfp=boundary_mfp, + is_kappa_star=is_kappa_star, + gv_delta_q=gv_delta_q, + is_full_pp=is_full_pp, + log_level=log_level, + ) self._use_const_ave_pp = self._pp.get_constant_averaged_interaction() self._read_pp = read_pp @@ -577,20 +607,27 @@ class Conductivity_RTA(Conductivity): self._num_ignored_phonon_modes[j, k] += 1 continue - old_settings = np.seterr(all='raise') + old_settings = np.seterr(all="raise") try: self._mode_kappa[j, k, i, ll] = ( - self._gv_sum2[i, ll] * cv[k, ll] / - (g_sum[ll] * 2) * self._conversion_factor) + self._gv_sum2[i, ll] + * cv[k, ll] + / (g_sum[ll] * 2) + * self._conversion_factor + ) except FloatingPointError: # supposed that g is almost 0 and |gv|=0 pass except Exception: print("=" * 26 + " Warning " + "=" * 26) - print(" Unexpected physical condition of ph-ph " - "interaction calculation was found.") - print(" g=%f at gp=%d, band=%d, freq=%f" % - (g_sum[ll], gp, ll + 1, frequencies[ll])) + print( + " Unexpected physical condition of ph-ph " + "interaction calculation was found." + ) + print( + " g=%f at gp=%d, band=%d, freq=%f" + % (g_sum[ll], gp, ll + 1, frequencies[ll]) + ) print("=" * 61) np.seterr(**old_settings) @@ -635,12 +672,14 @@ class Conductivity_RTA(Conductivity): if self._log_level: print("Number of triplets: %d" % num_triplets) - if (self._is_full_pp or - self._read_pp or - self._store_pp or - self._use_ave_pp or - self._use_const_ave_pp or - self._is_gamma_detail): # noqa E129 + if ( + self._is_full_pp + or self._read_pp + or self._store_pp + or self._use_ave_pp + or self._use_const_ave_pp + or self._is_gamma_detail + ): self._set_gamma_at_sigmas(i) else: # can save memory space self._set_gamma_at_sigmas_lowmem(i) @@ -656,43 +695,48 @@ class Conductivity_RTA(Conductivity): num_band0 = len(self._pp.band_indices) num_grid_points = len(self._grid_points) num_temp = len(self._temperatures) - self._kappa = np.zeros((len(self._sigmas), num_temp, 6), - order='C', dtype='double') - self._mode_kappa = np.zeros((len(self._sigmas), - num_temp, - num_grid_points, - num_band0, - 6), - order='C', dtype='double') + self._kappa = np.zeros( + (len(self._sigmas), num_temp, 6), order="C", dtype="double" + ) + self._mode_kappa = np.zeros( + (len(self._sigmas), num_temp, num_grid_points, num_band0, 6), + order="C", + dtype="double", + ) if not self._read_gamma: - self._gamma = np.zeros((len(self._sigmas), - num_temp, - num_grid_points, - num_band0), - order='C', dtype='double') + self._gamma = np.zeros( + (len(self._sigmas), num_temp, num_grid_points, num_band0), + order="C", + dtype="double", + ) if self._is_gamma_detail or self._is_N_U: self._gamma_N = np.zeros_like(self._gamma) self._gamma_U = np.zeros_like(self._gamma) - self._gv = np.zeros((num_grid_points, num_band0, 3), - order='C', dtype='double') - self._gv_sum2 = np.zeros((num_grid_points, num_band0, 6), - order='C', dtype='double') - self._cv = np.zeros((num_temp, num_grid_points, num_band0), - order='C', dtype='double') + self._gv = np.zeros((num_grid_points, num_band0, 3), order="C", dtype="double") + self._gv_sum2 = np.zeros( + (num_grid_points, num_band0, 6), order="C", dtype="double" + ) + self._cv = np.zeros( + (num_temp, num_grid_points, num_band0), order="C", dtype="double" + ) if self._isotope is not None: self._gamma_iso = np.zeros( (len(self._sigmas), num_grid_points, num_band0), - order='C', dtype='double') + order="C", + dtype="double", + ) if self._is_full_pp or self._use_ave_pp or self._use_const_ave_pp: self._averaged_pp_interaction = np.zeros( - (num_grid_points, num_band0), - order='C', dtype='double') + (num_grid_points, num_band0), order="C", dtype="double" + ) self._num_ignored_phonon_modes = np.zeros( - (len(self._sigmas), num_temp), order='C', dtype='intc') + (len(self._sigmas), num_temp), order="C", dtype="intc" + ) self._collision = ImagSelfEnergy( self._pp, with_detail=(self._is_gamma_detail or self._is_N_U), - unit_conversion=self._gamma_unit_conversion) + unit_conversion=self._gamma_unit_conversion, + ) def _set_gamma_at_sigmas(self, i): for j, sigma in enumerate(self._sigmas): @@ -718,25 +762,30 @@ class Conductivity_RTA(Conductivity): sigma=sigma, sigma_cutoff=self._sigma_cutoff, filename=self._pp_filename, - verbose=(self._log_level > 0)) + verbose=(self._log_level > 0), + ) _, g_zero = self._collision.get_integration_weights() if self._log_level: if len(self._sigmas) > 1: - print("Multiple sigmas or mixing smearing and " - "tetrahedron method is not supported.") + print( + "Multiple sigmas or mixing smearing and " + "tetrahedron method is not supported." + ) if _g_zero is not None and (_g_zero != g_zero).any(): raise ValueError("Inconsistency found in g_zero.") self._collision.set_interaction_strength(pp) elif self._use_ave_pp: self._collision.set_averaged_pp_interaction( - self._averaged_pp_interaction[i]) + self._averaged_pp_interaction[i] + ) elif self._use_const_ave_pp: if self._log_level: - print("Constant ph-ph interaction of %6.3e is used." % - self._pp.get_constant_averaged_interaction()) + print( + "Constant ph-ph interaction of %6.3e is used." + % self._pp.get_constant_averaged_interaction() + ) self._collision.run_interaction() - self._averaged_pp_interaction[i] = ( - self._pp.get_averaged_interaction()) + self._averaged_pp_interaction[i] = self._pp.get_averaged_interaction() elif j != 0 and (self._is_full_pp or self._sigma_cutoff is None): if self._log_level: print("Existing ph-ph interaction is used.") @@ -745,8 +794,9 @@ class Conductivity_RTA(Conductivity): print("Calculating ph-ph interaction...") self._collision.run_interaction(is_full_pp=self._is_full_pp) if self._is_full_pp: - self._averaged_pp_interaction[i] = ( - self._pp.get_averaged_interaction()) + self._averaged_pp_interaction[ + i + ] = self._pp.get_averaged_interaction() # Number of triplets depends on q-point. # So this is allocated each time. @@ -754,7 +804,9 @@ class Conductivity_RTA(Conductivity): num_temp = len(self._temperatures) self._gamma_detail_at_q = np.empty( ((num_temp,) + self._pp.get_interaction_strength().shape), - dtype='double', order='C') + dtype="double", + order="C", + ) self._gamma_detail_at_q[:] = 0 if self._log_level: @@ -768,8 +820,9 @@ class Conductivity_RTA(Conductivity): 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. @@ -782,11 +835,13 @@ class Conductivity_RTA(Conductivity): """ band_indices = self._pp.band_indices - (svecs, - multi, - p2s, - s2p, - masses) = self._pp.get_primitive_and_supercell_correspondence() + ( + svecs, + multi, + p2s, + s2p, + masses, + ) = self._pp.get_primitive_and_supercell_correspondence() fc3 = self._pp.fc3 triplets_at_q, weights_at_q, _, _ = self._pp.get_triplets_at_q() symmetrize_fc3_q = 0 @@ -798,20 +853,27 @@ class Conductivity_RTA(Conductivity): for j, sigma in enumerate(self._sigmas): self._collision.set_sigma(sigma) if self._is_N_U: - collisions = np.zeros((2, len(self._temperatures), - len(band_indices)), - dtype='double', order='C') + collisions = np.zeros( + (2, len(self._temperatures), len(band_indices)), + dtype="double", + order="C", + ) else: - collisions = np.zeros((len(self._temperatures), - len(band_indices)), - dtype='double', order='C') + collisions = np.zeros( + (len(self._temperatures), len(band_indices)), + dtype="double", + order="C", + ) import phono3py._phono3py as phono3c + if sigma is None: phono3c.pp_collision( collisions, np.array( np.dot(thm.get_tetrahedra(), self._pp.bz_grid.P.T), - dtype='int_', order='C'), + dtype="int_", + order="C", + ), self._frequencies, self._eigenvectors, triplets_at_q, @@ -831,33 +893,36 @@ class Conductivity_RTA(Conductivity): self._temperatures, self._is_N_U * 1, symmetrize_fc3_q, - self._pp.cutoff_frequency) + self._pp.cutoff_frequency, + ) else: if self._sigma_cutoff is None: sigma_cutoff = -1 else: sigma_cutoff = float(self._sigma_cutoff) - phono3c.pp_collision_with_sigma(collisions, - sigma, - sigma_cutoff, - self._frequencies, - self._eigenvectors, - triplets_at_q, - weights_at_q, - self._pp.bz_grid.addresses, - self._pp.bz_grid.D_diag, - self._pp.bz_grid.Q, - fc3, - svecs, - multi, - masses, - p2s, - s2p, - band_indices, - self._temperatures, - self._is_N_U * 1, - symmetrize_fc3_q, - self._pp.cutoff_frequency) + phono3c.pp_collision_with_sigma( + collisions, + sigma, + sigma_cutoff, + self._frequencies, + self._eigenvectors, + triplets_at_q, + weights_at_q, + self._pp.bz_grid.addresses, + self._pp.bz_grid.D_diag, + self._pp.bz_grid.Q, + fc3, + svecs, + multi, + masses, + p2s, + s2p, + band_indices, + self._temperatures, + self._is_N_U * 1, + symmetrize_fc3_q, + self._pp.cutoff_frequency, + ) col_unit_conv = self._collision.get_unit_conversion_factor() pp_unit_conv = self._pp.get_unit_conversion_factor() if self._is_N_U: @@ -870,16 +935,19 @@ class Conductivity_RTA(Conductivity): self._gamma[j, k, i, :] = average_by_degeneracy( col[k] * col_unit_conv * pp_unit_conv, band_indices, - self._frequencies[self._grid_points[i]]) + self._frequencies[self._grid_points[i]], + ) if self._is_N_U: self._gamma_N[j, k, i, :] = average_by_degeneracy( col_N[k] * col_unit_conv * pp_unit_conv, band_indices, - self._frequencies[self._grid_points[i]]) + self._frequencies[self._grid_points[i]], + ) self._gamma_U[j, k, i, :] = average_by_degeneracy( col_U[k] * col_unit_conv * pp_unit_conv, band_indices, - self._frequencies[self._grid_points[i]]) + self._frequencies[self._grid_points[i]], + ) def _show_log(self, q, i): gp = self._grid_points[i] @@ -901,36 +969,42 @@ class Conductivity_RTA(Conductivity): def _show_log_values(self, frequencies, gv, ave_pp): if self._is_full_pp or self._use_ave_pp or self._use_const_ave_pp: for f, v, pp in zip(frequencies, gv, ave_pp): - print("%8.3f (%8.3f %8.3f %8.3f) %8.3f %11.3e" % - (f, v[0], v[1], v[2], np.linalg.norm(v), pp)) + print( + "%8.3f (%8.3f %8.3f %8.3f) %8.3f %11.3e" + % (f, v[0], v[1], v[2], np.linalg.norm(v), pp) + ) else: for f, v in zip(frequencies, gv): - print("%8.3f (%8.3f %8.3f %8.3f) %8.3f" % - (f, v[0], v[1], v[2], np.linalg.norm(v))) + print( + "%8.3f (%8.3f %8.3f %8.3f) %8.3f" + % (f, v[0], v[1], v[2], np.linalg.norm(v)) + ) def _show_log_values_on_kstar(self, frequencies, gv, ave_pp, gp, q): rotation_map = get_grid_points_by_rotations(gp, self._pp.bz_grid) for i, j in enumerate(np.unique(rotation_map)): - for k, (rot, rot_c) in enumerate(zip( - self._point_operations, self._rotations_cartesian)): + for k, (rot, rot_c) in enumerate( + zip(self._point_operations, self._rotations_cartesian) + ): if rotation_map[k] != j: continue - print(" k*%-2d (%5.2f %5.2f %5.2f)" % - ((i + 1,) + tuple(np.dot(rot, q)))) - if (self._is_full_pp or - self._use_ave_pp or - self._use_const_ave_pp): # noqa E129 - for f, v, pp in zip(frequencies, - np.dot(rot_c, gv.T).T, - ave_pp): - print("%8.3f (%8.3f %8.3f %8.3f) %8.3f %11.3e" % - (f, v[0], v[1], v[2], np.linalg.norm(v), pp)) + print( + " k*%-2d (%5.2f %5.2f %5.2f)" % ((i + 1,) + tuple(np.dot(rot, q))) + ) + if self._is_full_pp or self._use_ave_pp or self._use_const_ave_pp: + for f, v, pp in zip(frequencies, np.dot(rot_c, gv.T).T, ave_pp): + print( + "%8.3f (%8.3f %8.3f %8.3f) %8.3f %11.3e" + % (f, v[0], v[1], v[2], np.linalg.norm(v), pp) + ) else: for f, v in zip(frequencies, np.dot(rot_c, gv.T).T): - print("%8.3f (%8.3f %8.3f %8.3f) %8.3f" % - (f, v[0], v[1], v[2], np.linalg.norm(v))) - print('') + print( + "%8.3f (%8.3f %8.3f %8.3f) %8.3f" + % (f, v[0], v[1], v[2], np.linalg.norm(v)) + ) + print("") def _show_log_value_names(self): if self._is_full_pp or self._use_ave_pp or self._use_const_ave_pp: From 1cc5e03c27b003fd1ce472f75523c27b94479156 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Fri, 15 Oct 2021 16:49:41 +0900 Subject: [PATCH 14/34] Refactoring using pre-commit setting --- .pre-commit-config.yaml | 31 + .travis.yml | 93 -- .vscode/settings.json | 2 +- README.md | 46 +- doc/citation.md | 2 +- doc/conf.py | 55 +- doc/cutoff-pair.md | 2 +- doc/interfaces.md | 2 +- doc/workload-distribution.md | 2 +- example/AlN-LDA/FORCES_FC2 | 12 +- example/AlN-LDA/POSCAR-unitcell | 2 +- example/AlN-LDA/README | 2 +- example/Si-CRYSTAL/FORCES_FC2 | 2 +- example/Si-CRYSTAL/FORCES_FC3 | 114 +- example/Si-CRYSTAL/README | 1 - example/Si-CRYSTAL/crystal.o | 50 +- example/Si-LDA/FORCES_FC3 | 222 +-- example/Si-LDA/POSCAR-unitcell | 2 +- example/Si-LDA/phono3py_disp.yaml | 2 +- example/Si-PBE/FORCES_FC3 | 222 +-- example/Si-PBE/POSCAR-unitcell | 2 +- example/Si-PBE/phono3py_disp.yaml | 2 +- example/Si-PBEsol/FORCES_FC3 | 222 +-- example/Si-PBEsol/POSCAR-unitcell | 2 +- example/Si-PBEsol/Si.py | 17 +- example/Si-PBEsol/phono3py_disp.yaml | 2 +- example/Si-QE/FORCES_FC3 | 222 +-- example/Si-QE/phono3py_disp.yaml | 2 +- example/Si-TURBOMOLE/FORCES_FC2 | 2 +- example/Si-TURBOMOLE/FORCES_FC3 | 222 +-- example/Si-TURBOMOLE/README | 3 +- example/Si-TURBOMOLE/control | 6 +- example/Si-TURBOMOLE/coord | 1 - .../launch_phono3py_ZnTe_PBEsol_222.py | 131 +- phono3py/__init__.py | 11 +- phono3py/api_isotope.py | 74 +- phono3py/api_jointdos.py | 91 +- phono3py/api_phono3py.py | 6 - phono3py/cui/__init__.py | 1 + phono3py/cui/create_force_constants.py | 456 +++--- phono3py/cui/create_supercells.py | 95 +- phono3py/cui/kaccum.py | 472 +++--- phono3py/cui/phono3py_argparse.py | 963 +++++++---- phono3py/cui/phono3py_script.py | 699 ++++---- phono3py/cui/settings.py | 810 +++++----- phono3py/cui/show_log.py | 112 +- phono3py/cui/triplets_info.py | 106 +- phono3py/file_IO.py | 1430 +++++++++-------- phono3py/interface/__init__.py | 1 + phono3py/interface/alm.py | 65 +- phono3py/interface/calculator.py | 52 +- phono3py/interface/fc_calculator.py | 40 +- phono3py/interface/phono3py_yaml.py | 268 +-- phono3py/other/isotope.py | 251 +-- phono3py/other/tetrahedron_method.py | 64 +- phono3py/phonon/func.py | 11 +- phono3py/phonon3/collision_matrix.py | 6 +- phono3py/phonon3/conductivity_RTA.py | 8 +- phono3py/phonon3/dataset.py | 42 +- phono3py/phonon3/displacement_fc3.py | 209 ++- phono3py/phonon3/fc3.py | 596 ++++--- phono3py/phonon3/gruneisen.py | 288 ++-- phono3py/phonon3/imag_self_energy.py | 714 ++++---- phono3py/phonon3/interaction.py | 474 +++--- phono3py/phonon3/joint_dos.py | 203 ++- phono3py/phonon3/real_self_energy.py | 288 ++-- phono3py/phonon3/real_to_reciprocal.py | 38 +- phono3py/phonon3/reciprocal_to_normal.py | 45 +- phono3py/phonon3/spectral_function.py | 132 +- phono3py/phonon3/triplets.py | 195 +-- phono3py/sscha/__init__.py | 1 + phono3py/sscha/sscha.py | 171 +- pyproject.toml | 7 + scripts/phono3py | 10 +- scripts/phono3py-coleigplot | 31 +- scripts/phono3py-kaccum | 2 +- scripts/phono3py-kdeplot | 263 +-- scripts/phono3py-load | 6 +- setup.py | 341 ++-- test/FORCES_FC3_si_pbesol | 222 +-- test/conftest.py | 170 +- test/cui/test_kaccum.py | 322 ++-- test/other/test_isotope.py | 61 +- test/phonon/__init__.py | 1 + test/phonon/test_grid.py | 974 +++++++++-- test/phonon3/test_displacements.py | 226 ++- test/phonon3/test_fc3.py | 3 + test/phonon3/test_imag_self_energy.py | 1106 ++++++++++--- test/phonon3/test_interaction.py | 112 +- test/phonon3/test_joint_dos.py | 272 +++- test/phonon3/test_kappa_LBTE.py | 17 +- test/phonon3/test_kappa_RTA.py | 179 ++- test/phonon3/test_real_self_energy.py | 98 +- test/phonon3/test_spectral_function.py | 306 +++- test/phonon3/test_triplets.py | 113 +- test/sscha/test_sscha.py | 109 +- 96 files changed, 9782 insertions(+), 6359 deletions(-) create mode 100644 .pre-commit-config.yaml delete mode 100644 .travis.yml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..6a044c56 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,31 @@ +# See https://pre-commit.com for more informatio +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + exclude: ^conda/ + - id: check-added-large-files + +- repo: https://github.com/pycqa/flake8 + rev: 4.0.1 + hooks: + - id: flake8 + args: + - "--max-line-length=88" + - "--ignore=E203,W503" + +- repo: https://github.com/psf/black + rev: 21.9b0 + hooks: + - id: black + args: + - --line-length=88 + +- repo: https://github.com/pycqa/pydocstyle + rev: 6.0.0 + hooks: + - id: pydocstyle diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 562960e3..00000000 --- a/.travis.yml +++ /dev/null @@ -1,93 +0,0 @@ -matrix: - include: - - python: '3.6' - env: TRAVIS_PYTHON_VERSION='3.6' - - python: '3.7' - env: TRAVIS_PYTHON_VERSION='3.7' - - python: '3.8' - env: TRAVIS_PYTHON_VERSION='3.8' - -before_install: - - wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh - - echo $TRAVIS_PYTHON_VERSION - - bash miniconda.sh -b -p ${HOME}/.miniconda - - export PATH=$HOME/.miniconda/bin:$PATH - - conda update --yes conda - - conda init bash - - source $(conda info --root)/etc/profile.d/conda.sh - - conda install --yes -c conda-forge python=$TRAVIS_PYTHON_VERSION - - export CONDA_PREFIX=$HOME/.miniconda - - export C_INCLUDE_PATH=$CONDA_PREFIX/include - - export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH - -install: - - conda install --yes -c conda-forge matplotlib-base pyyaml openblas libgfortran gcc_linux-64 gxx_linux-64 h5py scipy pytest spglib - - echo $TRAVIS_BRANCH - - if [[ "$TRAVIS_BRANCH" == "master" ]]; then - pip install https://github.com/phonopy/phonopy/archive/master.zip --user; - elif [[ "$TRAVIS_BRANCH" == "rc" ]]; then - pip install https://github.com/phonopy/phonopy/archive/rc.zip --user; - else - pip install https://github.com/phonopy/phonopy/archive/develop.zip --user; - fi - - pwd - - ./get_nanoversion.sh - - cat __nanoversion__.txt - - python setup.py build - - pip install -e . - -script: - - pytest - - cd example/Si-PBE - - tar xf vasprun_xmls.tar.lzma --lzma - - phono3py --cf3 vasprun_xmls/disp-{00001..00111}/vasprun.xml - - cd ../.. - - cd example/Si-QE - - tar xf supercell_out.tar.lzma --lzma - - phono3py --qe --cf3 supercell_out/disp-{00001..00111}/Si.out - - cd ../.. - -deploy: - # testing pypi - - provider: pypi - server: https://test.pypi.org/legacy/ - skip_existing: true - skip_cleanup: true - cleanup: false - distributions: sdist - user: atztogo - password: - secure: "NiGCFUvUZALME/raOyq5AspTc0sCBA+G7frAIAWLsNOk7JL25UIu/T4ufWHEpvssvXZ/zntEVKEnQo8kQYQfsfDtLccdVFKJ6jzKtqbL4s2+m8d61b+Ezu9mK1XM/ImiIkvhCD+j8jtzUbN24/qYhGgR8YeXxwfCJWU7SKNueTiyBT+xOoO4gswoRpA4Ztutzows0rKX1K/MBaKF9RGotIHCIay4ryWJUg9KWcp2rKGJeDiuTK81kSyZA1MV3x05PgnPH+gxTy8XbBP0Bk71FZUpkpQ7+UsmsUSLB9dlSgkhziYuDHb4Y48YO2XqHU7bi+pElUs660eez8m8IC5dUhjY3RPDQOSb3gpc1N56/RqfMugUyelEqfXaSCPBrXfhsvutwibA4ITNh4f86jylWFUQukHiK95NCVrvMDkNcFyNZVNHsWUIBWfCXPu4fmykOb4PR1eC1kZsuo0h3VTSzMn7vtFXbedt3VtaZMNEdbBMgKxoPwcE2DPBzZDZdSbVA8QuvmbwjGpxHNISssNzLhCVWbXSbjo2BntHzMIodz36rKQwqHqw58yUBNRZKLT1/0D2qGSSWQ/r4W6w2y7XoJXyJOIGRaAzTEWmGMZ7OHO1XON9cT8zOmikC9XhmC34mhzRrKmPx/5VMyzvM05wkCpNynx0SZc6w9wmIxhFl3Q=" - on: - repo: phonopy/phono3py - branch: rc - tags: false - - # testing anaconda - - provider: script - script: conda/anaconda_deploy.sh rc $ANACONDA_TOKEN2 $TRAVIS_BRANCH - on: - repo: phonopy/phono3py - branch: rc - tags: false - - # production pypi - - provider: pypi - skip_existing: true - skip_cleanup: true - cleanup: false - distributions: sdist - user: atztogo - password: - secure: "lqT3bcoiVePhx642M/dZBsnd8WUsYush58IGB2EiCu60FOhwfFJtSNEoJoKicGy54QiQ/Ho6xTcshf398CFSE2cVfW+YrTUtUaObOzFNLbmbvy5tnuvDgK/56T5jTCAVQaD68qDNR0O5qlnw/Xe8ZKoKTpoFwfnIv3brpokUFyMFcECuCtv2sNrVSF3d89S7jd9ahpjkvu0udA4jXKdwLMbjOmrpK7v7jkCtNXdJFLzprB4Y8tNX08TMovWzmrHk8YOx6v2YgNxW4/bqJbe+oGofpj9RcXfYdiXY797nz7D9b7BcRi1NMWoiMqOzpnlPEccQqhqOOxddkajiXHCyJPYJ9zWj3xuC2D50KdtGb5tm+qDI3EqzIiQv0akXE3nvMPinOQkjlUN/1/HmS5s99YMSg9GvmL4bPnu3phBjoND23IMPED4rra9IToeozPHaQGRoBvLNGAl28aAzuIP0JHmHQ26BNmOvOa+CQs1SbMytv570FMi6pN/vMgaMT71uXJWsIDb9aDG6V1snsTLIbwM/TYTLFM+2OGBN86nlmWQs0V46K2kPHcUbEv8GD148j1DTS4H0wDmc8pJSHqeSI2h35pbVbZJa6bk68V3Bhre/xo+zjxwJIkOATELbQCeFXIA059+hF+tsoQ0Jnd6RrbzP3tISdVThs3u7oSoddIE=" - on: - branch: master - tags: false - - # production anaconda - - provider: script - script: conda/anaconda_deploy.sh main $ANACONDA_TOKEN2 $TRAVIS_BRANCH - on: - repo: phonopy/phono3py - branch: master - tags: false diff --git a/.vscode/settings.json b/.vscode/settings.json index a4877b23..5e337ba7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,4 +5,4 @@ "python.testing.unittestEnabled": false, "python.testing.nosetestsEnabled": false, "python.testing.pytestEnabled": true -} \ No newline at end of file +} diff --git a/README.md b/README.md index 1b98015e..d3d698cb 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,51 @@ +[![Version Badge](https://anaconda.org/conda-forge/phono3py/badges/version.svg)](https://anaconda.org/conda-forge/phono3py) +[![Downloads Badge](https://anaconda.org/conda-forge/phono3py/badges/downloads.svg)](https://anaconda.org/conda-forge/phono3py) +[![PyPI version](https://badge.fury.io/py/phono3py.svg)](https://badge.fury.io/py/phono3py) +[![PyPI](https://img.shields.io/pypi/dm/phono3py.svg?maxAge=2592000)](https://pypi.python.org/pypi/phono3py) +[![codecov](https://codecov.io/gh/phonopy/phono3py/branch/develop/graph/badge.svg)](https://codecov.io/gh/phonopy/phono3py) + # phono3py -A simulation package of phonon-phonon interaction related properties. Phono3py user documetation is found at http://phonopy.github.io/phono3py/. + +A simulation package of phonon-phonon interaction related properties. Phono3py +user documentation is found at http://phonopy.github.io/phono3py/. ## Mailing list for questions -Usual phono3py questions should be sent to phonopy mailing list (https://sourceforge.net/p/phonopy/mailman/). +Usual phono3py questions should be sent to phonopy mailing list +(https://sourceforge.net/p/phonopy/mailman/). ## Development -The development of phono3py is managed on the `develop` branch of github phono3py repository. +The development of phono3py is managed on the `develop` branch of github +phono3py repository. -* Github issues is the place to discuss about phono3py issues. -* Github pull request is the place to request merging source code. +- Github issues is the place to discuss about phono3py issues. +- Github pull request is the place to request merging source code. +- Python 3.7 will be the minimum requirement soon. +- Formatting is written in `pyproject.toml`. +- Not strictly, but VSCode's `settings.json` may be written like + + ```json + "python.linting.flake8Enabled": true, + "python.linting.flake8Args": ["--max-line-length=88", "--ignore=E203,W503"], + "python.linting.enabled": true, + "python.linting.pylintEnabled": false, + "python.linting.mypyEnabled": true, + "python.linting.pycodestyleEnabled": false, + "python.linting.pydocstyleEnabled": true, + "python.formatting.provider": "black", + ``` ## Documentation -Phono3py user documetation is written using python sphinx. The source files are stored in `doc` directory. Please see how to write the documentation at `doc/README.md`. +Phono3py user documentation is written using python sphinx. The source files are +stored in `doc` directory. Please see how to write the documentation at +`doc/README.md`. + +## How to run tests + +You need pytest. At home directory of phono3py after setup, + +```bash +% pytest +``` diff --git a/doc/citation.md b/doc/citation.md index a7864ce3..c86c027b 100644 --- a/doc/citation.md +++ b/doc/citation.md @@ -47,4 +47,4 @@ following article: doi = {10.1103/PhysRevLett.110.265506}, url = {https://link.aps.org/doi/10.1103/PhysRevLett.110.265506} } - ``` \ No newline at end of file + ``` diff --git a/doc/conf.py b/doc/conf.py index 887d292a..c6f75408 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -12,9 +12,6 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys -import os - # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. @@ -28,33 +25,33 @@ import os # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. # extensions = ['sphinx.ext.imgmath'] -extensions = ['sphinx.ext.mathjax', 'myst_parser'] +extensions = ["sphinx.ext.mathjax", "myst_parser"] myst_enable_extensions = ["linkify", "dollarmath", "amsmath"] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix of source filenames. -source_suffix = '.rst' +source_suffix = ".rst" # The encoding of source files. # source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'phono3py' -copyright = u'2015, Atsushi Togo' +project = u"phono3py" +copyright = u"2015, Atsushi Togo" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '2.0' +version = "2.0" # The full version, including alpha/beta/rc tags. -release = '2.0.0' +release = "2.0.0" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -68,7 +65,7 @@ release = '2.0.0' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build'] +exclude_patterns = ["_build"] # The reST default role (used for this markup: `text`) to use for all # documents. @@ -86,7 +83,7 @@ exclude_patterns = ['_build'] # show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] @@ -149,12 +146,12 @@ pygments_style = 'sphinx' # # "globaltoc_includehidden": False, # } -html_theme = 'sphinx_book_theme' +html_theme = "sphinx_book_theme" # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". # html_title = None -html_title = 'Phono3py v.%s' % release +html_title = "Phono3py v.%s" % release # A shorter title for the navigation bar. Default is the same as html_title. # html_short_title = None @@ -171,7 +168,7 @@ html_title = 'Phono3py v.%s' % release # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. @@ -215,7 +212,7 @@ html_static_path = ['_static'] # html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'phono3pydoc' +htmlhelp_basename = "phono3pydoc" # -- Options for LaTeX output ------------------------------------------------- @@ -223,20 +220,17 @@ htmlhelp_basename = 'phono3pydoc' latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. - 'preamble': '', + "preamble": "", } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]) # . latex_documents = [ - ('index', 'phono3py.tex', u'phono3py manual', - u'Atsushi Togo', 'manual'), + ("index", "phono3py.tex", u"phono3py manual", u"Atsushi Togo", "manual"), ] # The name of an image file (relative to this directory) to place at the top of @@ -264,10 +258,7 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'phono3py', u'phono3py Documentation', - [u'Atsushi Togo'], 1) -] +man_pages = [("index", "phono3py", u"phono3py Documentation", [u"Atsushi Togo"], 1)] # If true, show URL addresses after external links. # man_show_urls = False @@ -279,9 +270,15 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'phono3py', u'phono3py Documentation', - u'Atsushi Togo', 'phono3py', 'One line description of project.', - 'Miscellaneous'), + ( + "index", + "phono3py", + u"phono3py Documentation", + u"Atsushi Togo", + "phono3py", + "One line description of project.", + "Miscellaneous", + ), ] # Documents to append as an appendix to all manuals. diff --git a/doc/cutoff-pair.md b/doc/cutoff-pair.md index 0e1e9ac5..d06b62f7 100644 --- a/doc/cutoff-pair.md +++ b/doc/cutoff-pair.md @@ -426,4 +426,4 @@ number_of_pairs_in_cutoff: 1248 300.0 235.887 235.887 219.301 0.000 -0.000 -0.000 300.0 235.642 235.642 219.348 0.000 -0.000 -0.000 300.0 235.728 235.728 219.102 0.000 -0.000 -0.000 -``` \ No newline at end of file +``` diff --git a/doc/interfaces.md b/doc/interfaces.md index 5f318776..4fc78fbd 100644 --- a/doc/interfaces.md +++ b/doc/interfaces.md @@ -71,4 +71,4 @@ Default displacement distances created by `-d` option without | CRYSTAL | 0.03 Angstrom | | Abinit | 0.06 au (bohr) | | TURBOMOLE | 0.06 au (bohr) | -``` \ No newline at end of file +``` diff --git a/doc/workload-distribution.md b/doc/workload-distribution.md index 48224467..4c7a8341 100644 --- a/doc/workload-distribution.md +++ b/doc/workload-distribution.md @@ -139,4 +139,4 @@ with `job.sh` (here for grid-engine): #$ -o std-phono3py-num.log phono3py --dim="2 2 2" --pa="F" -c POSCAR-unitcell --mesh="19 19 19" --fc3 --fc2 --br --gp="gps" --write-gamma -``` \ No newline at end of file +``` diff --git a/example/AlN-LDA/FORCES_FC2 b/example/AlN-LDA/FORCES_FC2 index 178f8346..7ec8c015 100644 --- a/example/AlN-LDA/FORCES_FC2 +++ b/example/AlN-LDA/FORCES_FC2 @@ -1,4 +1,4 @@ -# File: 1 +# File: 1 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.6484336900 0.0222671200 -0.0143461700 0.0736627500 0.0104173100 -0.0064302500 @@ -300,7 +300,7 @@ -0.0015703700 -0.0006418500 -0.0005758600 -0.0004825200 -0.0010922200 -0.0024545000 0.0040571700 -0.0000110700 0.0000039000 -# File: 2 +# File: 2 # 1 0.0000000000000000 0.0000000000000000 0.0300000000000000 0.0000000000 0.0000000000 -0.5557350900 0.0062250200 0.0092421200 -0.0203076300 @@ -602,7 +602,7 @@ -0.0005740400 -0.0003314200 -0.0002882300 -0.0020293600 -0.0025852000 -0.0014466500 0.0000000000 -0.0041471800 -0.0020932700 -# File: 3 +# File: 3 # 1 0.0000000000000000 0.0000000000000000 -0.0300000000000000 0.0000000000 0.0000000000 0.6160949400 -0.0070590800 -0.0093557300 0.0205786800 @@ -904,7 +904,7 @@ 0.0005759000 0.0003325000 0.0002754700 0.0020376100 0.0025736200 0.0014443900 0.0000000000 0.0041401500 0.0020869200 -# File: 4 +# File: 4 # 151 0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0204935100 -0.0000909100 0.0000019100 -0.0057412400 -0.0035612800 0.0073760100 @@ -1206,7 +1206,7 @@ 0.0009926100 0.0003849600 -0.0000351000 0.0000951900 0.0007041200 -0.0001422100 -0.0022182300 0.0000026900 -0.0000015100 -# File: 5 +# File: 5 # 151 0.0000000000000000 0.0000000000000000 0.0300000000000000 0.0000000000 0.0000000000 -0.0403186900 0.0150281200 0.0091882100 -0.0018635900 @@ -1508,7 +1508,7 @@ 0.0000345500 0.0000199500 0.0012992500 0.0001358800 0.0000710700 0.0029583400 0.0000000000 0.0001492100 0.0045891900 -# File: 6 +# File: 6 # 151 0.0000000000000000 0.0000000000000000 -0.0300000000000000 0.0000000000 0.0000000000 0.0413813900 -0.0150668500 -0.0092748700 0.0017799700 diff --git a/example/AlN-LDA/POSCAR-unitcell b/example/AlN-LDA/POSCAR-unitcell index f13349c4..818d8ba2 100644 --- a/example/AlN-LDA/POSCAR-unitcell +++ b/example/AlN-LDA/POSCAR-unitcell @@ -9,4 +9,4 @@ Direct 0.3333333333333333 0.6666666666666665 0.0009488200000000 0.6666666666666667 0.3333333333333333 0.5009488200000001 0.3333333333333333 0.6666666666666665 0.6190511800000000 - 0.6666666666666667 0.3333333333333333 0.1190511800000000 \ No newline at end of file + 0.6666666666666667 0.3333333333333333 0.1190511800000000 diff --git a/example/AlN-LDA/README b/example/AlN-LDA/README index 8a35a8d3..5ba60b15 100644 --- a/example/AlN-LDA/README +++ b/example/AlN-LDA/README @@ -41,7 +41,7 @@ k_zz=219.1. The shape of phonon band structure is important to fullfill energy and momentum conservations. Use of larger supercell of fc2 may change the shape of phonon band structure. -To see it, first regenerate phono3py_disp.yaml with --dim-fc2 option, +To see it, first regenerate phono3py_disp.yaml with --dim-fc2 option, % phono3py --dim="3 3 2" --dim-fc2="5 5 3" -c POSCAR-unitcell -d diff --git a/example/Si-CRYSTAL/FORCES_FC2 b/example/Si-CRYSTAL/FORCES_FC2 index 916fd28d..04fff7d9 100644 --- a/example/Si-CRYSTAL/FORCES_FC2 +++ b/example/Si-CRYSTAL/FORCES_FC2 @@ -1,4 +1,4 @@ -# File: 1 +# File: 1 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 0.0150976605 -0.3163819396 -0.3163819277 -0.0054602591 0.0087171452 0.0087171442 diff --git a/example/Si-CRYSTAL/FORCES_FC3 b/example/Si-CRYSTAL/FORCES_FC3 index e9c5afcd..87fe4f87 100644 --- a/example/Si-CRYSTAL/FORCES_FC3 +++ b/example/Si-CRYSTAL/FORCES_FC3 @@ -1,4 +1,4 @@ -# File: 1 +# File: 1 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 0.0152594970 -0.3211511680 -0.3211509706 -0.0001435085 0.0219927829 0.0219925626 @@ -16,7 +16,7 @@ 0.0001331050 -0.0055277344 -0.0053741157 -0.0057637037 0.0002712181 0.0002708504 0.0055534276 0.0001117032 0.0001114381 -# File: 2 +# File: 2 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 1 0.0212132034355964 0.0000000000000000 0.0212132034355964 -0.2915830406 -0.2915827297 -0.6267860517 @@ -35,7 +35,7 @@ 0.0002973816 -0.0110605876 -0.0052885305 -0.0110601987 0.0002976322 -0.0052887309 0.0054615894 0.0054615452 0.0000190373 -# File: 3 +# File: 3 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 1 -0.0212132034355964 0.0000000000000000 -0.0212132034355964 0.3211479920 -0.3211513093 -0.0152621589 @@ -54,7 +54,7 @@ -0.0001097860 0.0001116313 -0.0055511616 -0.0002684320 0.0002711970 0.0057659419 0.0053755648 -0.0055279210 -0.0001315307 -# File: 4 +# File: 4 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 0.0607208411 -0.6426014876 -0.6426016649 @@ -73,7 +73,7 @@ 0.0002335625 -0.0108857049 -0.0110189043 -0.0112282566 0.0004024542 0.0004019167 0.0108236885 -0.0001056704 -0.0001058760 -# File: 5 +# File: 5 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 1 0.0000000000000000 -0.0212132034355964 -0.0212132034355964 -0.0000009817 -0.0000010866 -0.0000009461 @@ -92,7 +92,7 @@ 0.0000012799 0.0000010706 0.0000007773 0.0000009165 0.0000010127 0.0000008509 0.0000010604 0.0000009847 0.0000008692 -# File: 6 +# File: 6 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 2 0.0212132034355964 0.0000000000000000 0.0212132034355964 -0.0044402241 -0.3100170076 -0.3107578808 @@ -111,7 +111,7 @@ 0.0277477410 -0.0066981645 0.0236783541 -0.0056534328 0.0058287134 0.0003825742 0.0000322018 0.0002440270 -0.0052585282 -# File: 7 +# File: 7 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 2 -0.0212132034355964 0.0000000000000000 -0.0212132034355964 0.0347404871 -0.3320822726 -0.3315779932 @@ -130,7 +130,7 @@ -0.0289290207 -0.0066944813 -0.0329837327 -0.0060382115 -0.0054979528 -0.0000001670 0.0109208828 0.0002438843 0.0056384786 -# File: 8 +# File: 8 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 2 0.0000000000000000 0.0212132034355964 0.0212132034355964 0.0152286518 -0.2990938262 -0.2990938072 @@ -149,7 +149,7 @@ -0.0010157867 0.0220827585 0.0236702310 -0.0002026923 0.0003819592 0.0003819492 -0.0002027130 0.0003819478 0.0003819828 -# File: 9 +# File: 9 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 2 0.0000000000000000 -0.0212132034355964 -0.0212132034355964 0.0149287171 -0.3429703545 -0.3429700900 @@ -168,7 +168,7 @@ -0.0010604463 -0.0345558816 -0.0329761904 -0.0115440948 0.0000010644 0.0000009115 0.0111011485 0.0000011505 0.0000011269 -# File: 10 +# File: 10 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 3 0.0000000000000000 0.0212132034355964 0.0212132034355964 0.0268075451 -0.3407067497 -0.3107684189 @@ -187,7 +187,7 @@ 0.0056797288 -0.0054343936 -0.0052534276 -0.0069594615 0.0278752642 0.0293363152 0.0056795496 -0.0054345663 -0.0052534671 -# File: 11 +# File: 11 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 3 0.0000000000000000 -0.0212132034355964 -0.0212132034355964 0.0041758774 -0.3016067538 -0.3317748142 @@ -206,7 +206,7 @@ -0.0056459234 -0.0058072124 -0.0056333221 -0.0068355352 -0.0287516455 -0.0274134432 0.0056696487 0.0054813402 0.0056529505 -# File: 12 +# File: 12 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 3 0.0212132034355964 0.0000000000000000 0.0212132034355964 0.0374367371 -0.3212101694 -0.2989610185 @@ -225,7 +225,7 @@ 0.0002439140 0.0000318128 -0.0052585180 0.0218302035 -0.0008959854 0.0293173115 0.0058288536 -0.0056536729 0.0003824074 -# File: 13 +# File: 13 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 3 -0.0212132034355964 0.0000000000000000 -0.0212132034355964 -0.0066743470 -0.3213106384 -0.3430608970 @@ -244,7 +244,7 @@ -0.0001364428 -0.0113081882 -0.0056483077 -0.0347924591 -0.0009193135 -0.0273224900 0.0054391115 0.0056687705 0.0000020573 -# File: 14 +# File: 14 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 3 0.0212132034355964 0.0212132034355964 0.0000000000000000 0.0258331232 -0.3407360577 -0.3097939478 @@ -263,7 +263,7 @@ 0.0002439476 -0.0054133260 0.0001823249 0.1335285993 0.1395544364 -0.1125849783 0.0001823138 -0.0054133110 0.0002439356 -# File: 15 +# File: 15 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 3 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 0.0046739689 -0.3018023578 -0.3322910711 @@ -282,7 +282,7 @@ -0.0001365123 -0.0058053942 -0.0111427823 -0.1352641482 -0.1292499640 0.0998249186 0.0110792052 0.0054851095 0.0002433439 -# File: 16 +# File: 16 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 4 0.0000000000000000 0.0212132034355964 0.0212132034355964 0.0040880746 -0.3100529400 -0.3408724414 @@ -301,7 +301,7 @@ -0.0056359057 -0.0052670470 -0.0050878342 -0.0056360093 -0.0052669832 -0.0050878275 0.0043602894 0.0277007812 0.0291663253 -# File: 17 +# File: 17 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 4 0.0000000000000000 -0.0212132034355964 -0.0212132034355964 0.0263442055 -0.3319366695 -0.3013107170 @@ -320,7 +320,7 @@ 0.0056699090 -0.0056510496 -0.0054787857 -0.0056460853 0.0056349492 0.0058094908 0.0042430551 -0.0290637005 -0.0276252811 -# File: 18 +# File: 18 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 4 0.0212132034355964 0.0000000000000000 0.0212132034355964 0.0260368501 -0.3319897664 -0.3407972776 @@ -339,7 +339,7 @@ -0.0054008117 -0.0054008102 -0.0107250628 -0.0055027211 -0.0055026753 0.0005598253 0.0331401863 -0.0010853512 0.0291767075 -# File: 19 +# File: 19 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 4 -0.0212132034355964 0.0000000000000000 -0.0212132034355964 0.0045206517 -0.3101426423 -0.3014161824 @@ -358,7 +358,7 @@ 0.0054931409 -0.0054108202 0.0001509796 -0.0058875886 0.0058122207 0.0001694714 -0.0236399359 -0.0011818566 -0.0276362899 -# File: 20 +# File: 20 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 4 0.0212132034355964 0.0212132034355964 0.0000000000000000 0.0148676009 -0.3215306550 -0.3208769657 @@ -377,7 +377,7 @@ -0.0053996649 -0.0109089977 -0.0052202745 -0.0111482654 -0.0052658778 0.0004239404 0.1448030745 0.1393852560 -0.1127455500 -# File: 21 +# File: 21 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 4 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 0.0155383005 -0.3208527551 -0.3212435940 @@ -396,7 +396,7 @@ 0.0055030629 -0.0000041260 -0.0052151709 -0.0002363760 0.0056449118 0.0004281880 -0.1239859593 -0.1294459102 0.0997239436 -# File: 22 +# File: 22 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 7 0.0212132034355964 0.0000000000000000 0.0212132034355964 -0.0043203881 -0.3322574331 -0.3101454253 @@ -415,7 +415,7 @@ -0.0052207069 -0.0054000030 -0.0109085789 0.1239436364 0.0997513012 0.1296882363 0.0345792825 -0.0010649748 0.0277212335 -# File: 23 +# File: 23 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 7 -0.0212132034355964 0.0000000000000000 -0.0212132034355964 0.0345774055 -0.3100193587 -0.3320395899 @@ -434,7 +434,7 @@ 0.0056832509 -0.0053991297 -0.0000035861 -0.1448866553 -0.1127514119 -0.1391485415 -0.0219818773 -0.0011038210 -0.0289905817 -# File: 24 +# File: 24 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 7 0.0000000000000000 0.0212132034355964 0.0212132034355964 0.0154984453 -0.3217672151 -0.3217674511 @@ -453,7 +453,7 @@ 0.0003063257 -0.0109015652 -0.0109017325 0.0939766085 0.1296859539 0.1296862441 -0.1071473783 0.1394933130 0.1394933545 -# File: 25 +# File: 25 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 7 0.0000000000000000 -0.0212132034355964 -0.0212132034355964 0.0149441918 -0.3206728595 -0.3206723495 @@ -472,7 +472,7 @@ 0.0002919565 0.0000015622 0.0000010779 -0.1184416208 -0.1391628674 -0.1391627646 0.1051898959 -0.1294474387 -0.1294477630 -# File: 26 +# File: 26 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 8 0.0212132034355964 0.0000000000000000 0.0212132034355964 0.0178987903 -0.3211620759 -0.3185125167 @@ -491,7 +491,7 @@ 0.1394250548 -0.1183785245 0.1339024332 0.0233157466 -0.0008940012 0.0278814388 0.1350605830 0.0996863172 0.1296363883 -# File: 27 +# File: 27 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 8 -0.0212132034355964 0.0000000000000000 -0.0212132034355964 0.0126146687 -0.3210838297 -0.3238163247 @@ -510,7 +510,7 @@ -0.1293890458 0.0940260121 -0.1348784921 -0.0333963806 -0.0009153373 -0.0287888975 -0.1337197485 -0.1127569076 -0.1391773640 -# File: 28 +# File: 28 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 8 0.0000000000000000 0.0212132034355964 0.0212132034355964 0.0152175545 -0.3184817266 -0.3184817374 @@ -529,7 +529,7 @@ -0.0010122801 0.0235394430 0.0222168690 -0.1186046129 0.1395502635 0.1395500693 0.1051354721 0.1296226417 0.1296227234 -# File: 29 +# File: 29 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 8 0.0000000000000000 -0.0212132034355964 -0.0212132034355964 0.0153652388 -0.3238488728 -0.3238490063 @@ -548,7 +548,7 @@ -0.0010580877 -0.0331549439 -0.0344068839 0.0937898270 -0.1292518331 -0.1292517037 -0.1073279705 -0.1391689292 -0.1391688687 -# File: 30 +# File: 30 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 9 0.0212132034355964 0.0000000000000000 0.0212132034355964 0.1423450012 -0.2205821574 -0.1926710296 @@ -567,7 +567,7 @@ -0.0004889308 -0.0058121692 -0.0059617917 -0.0255217406 -0.0111072283 0.0109237760 0.0082353165 0.0000819405 0.0027746183 -# File: 31 +# File: 31 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 9 -0.0212132034355964 0.0000000000000000 -0.0212132034355964 -0.1028039845 -0.4094250037 -0.4403521962 @@ -586,7 +586,7 @@ 0.0007450835 -0.0058668327 -0.0047828976 0.0137885489 0.0115784779 -0.0105392031 0.0028818949 0.0000865178 -0.0025411371 -# File: 32 +# File: 32 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 9 0.0000000000000000 0.0212132034355964 0.0212132034355964 0.1146780673 -0.1916061338 -0.1916062893 @@ -605,7 +605,7 @@ -0.0112639668 -0.0252760811 0.0053051659 -0.0060483464 -0.0003515865 -0.0003519135 0.0055218689 0.0027909169 0.0027909838 -# File: 33 +# File: 33 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 9 0.0000000000000000 -0.0212132034355964 -0.0212132034355964 -0.0719842260 -0.4411151738 -0.4411148050 @@ -624,7 +624,7 @@ 0.0114627684 0.0140013707 -0.0162022170 -0.0060864429 0.0008867342 0.0008868604 0.0055261070 -0.0025603898 -0.0025602488 -# File: 34 +# File: 34 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 10 0.0212132034355964 0.0000000000000000 0.0212132034355964 0.0415712930 -0.3210562121 -0.2946983820 @@ -643,7 +643,7 @@ 0.0109273884 0.0057752666 -0.0248875997 -0.0030837545 0.0002237073 0.0029533906 -0.0141559520 -0.0112597623 0.0107678407 -# File: 35 +# File: 35 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 10 -0.0212132034355964 0.0000000000000000 -0.0212132034355964 -0.0128583715 -0.3184989801 -0.3458769505 @@ -662,7 +662,7 @@ -0.0104928394 -0.0169056738 0.0143465042 -0.0084410738 0.0002590701 -0.0024089846 0.0250640861 0.0114214031 -0.0107055616 -# File: 36 +# File: 36 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 10 0.0000000000000000 0.0212132034355964 0.0212132034355964 -0.0977384048 -0.1819623776 -0.1819623570 @@ -681,7 +681,7 @@ 0.0114280970 0.0052507596 -0.0249092956 -0.0057950203 0.0029527957 0.0029524980 0.0052656740 -0.0005057819 -0.0005057761 -# File: 37 +# File: 37 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 10 0.0000000000000000 -0.0212132034355964 -0.0212132034355964 0.1427533662 -0.4704179484 -0.4704175032 @@ -700,7 +700,7 @@ -0.0112319693 -0.0161306670 0.0143694573 -0.0057832498 -0.0024154276 -0.0024149113 0.0052201955 0.0007351581 0.0007358405 -# File: 38 +# File: 38 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 11 0.0000000000000000 0.0212132034355964 0.0212132034355964 0.0142587300 -0.2922422201 -0.2934496235 @@ -719,7 +719,7 @@ 0.0000649770 -0.0028485245 -0.0026908137 0.0055575990 0.0110620460 -0.0192734744 -0.0058275738 -0.0196264000 0.0107721818 -# File: 39 +# File: 39 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 11 0.0000000000000000 -0.0212132034355964 -0.0212132034355964 0.0186583734 -0.3515549399 -0.3474279481 @@ -738,7 +738,7 @@ 0.0001416549 -0.0082040995 -0.0080528906 -0.0171447079 -0.0103515527 0.0200238796 0.0168632681 0.0196454432 -0.0107263245 -# File: 40 +# File: 40 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 11 0.0212132034355964 0.0000000000000000 0.0212132034355964 0.1436714629 -0.4218497459 -0.1941136773 @@ -757,7 +757,7 @@ 0.0027951237 -0.0055599389 -0.0026917737 0.0050209982 0.0115704175 -0.0192800347 0.0049650991 -0.0002060819 -0.0005023009 -# File: 41 +# File: 41 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 11 -0.0212132034355964 0.0000000000000000 -0.0212132034355964 -0.1225787167 -0.2071494981 -0.4573934030 @@ -776,7 +776,7 @@ -0.0025272683 -0.0055515909 -0.0080492337 -0.0163744612 -0.0110905091 0.0200287609 0.0061403690 -0.0001979406 0.0007333103 -# File: 42 +# File: 42 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 11 0.0212132034355964 0.0212132034355964 0.0000000000000000 0.0432153136 -0.2933226157 -0.3210775252 @@ -795,7 +795,7 @@ 0.0027979216 -0.0028668275 -0.0054211991 0.0162155598 0.0222692238 0.0004145929 0.0162164019 -0.0196221437 -0.0112544847 -# File: 43 +# File: 43 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 11 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.0112000794 -0.3504775085 -0.3188323496 @@ -814,7 +814,7 @@ -0.0025262651 -0.0081831346 -0.0053867608 -0.0277461010 -0.0217171682 0.0004116788 -0.0052728822 0.0196434281 0.0114109308 -# File: 44 +# File: 44 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 12 0.0000000000000000 0.0212132034355964 0.0212132034355964 0.0152483020 -0.3267442195 -0.3264610198 @@ -833,7 +833,7 @@ -0.0001800756 -0.0061547639 -0.0059854645 -0.0171540360 -0.0194694998 0.0109227700 0.0168545557 0.0109165924 -0.0194304460 -# File: 45 +# File: 45 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 12 0.0000000000000000 -0.0212132034355964 -0.0212132034355964 0.0150138353 -0.3157081600 -0.3156936768 @@ -852,7 +852,7 @@ -0.0001660372 -0.0049014507 -0.0047545657 0.0055549189 0.0198198829 -0.0105403880 -0.0058170385 -0.0105264717 0.0198527835 -# File: 46 +# File: 46 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 12 0.0212132034355964 0.0000000000000000 0.0212132034355964 0.0097912366 -0.3212138884 -0.3263967205 @@ -871,7 +871,7 @@ -0.0196092218 -0.0169179831 0.0052692701 -0.0063853825 -0.0000350558 -0.0003417367 0.0163534354 0.0114209522 -0.0194357189 -# File: 47 +# File: 47 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 12 -0.0212132034355964 0.0000000000000000 -0.0212132034355964 0.0205735101 -0.3213350436 -0.3157552086 @@ -890,7 +890,7 @@ 0.0196809348 0.0057888707 -0.0161745787 -0.0051446687 -0.0000286141 0.0008900977 -0.0050835190 -0.0112678291 0.0198552888 -# File: 48 +# File: 48 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 12 0.0212132034355964 0.0212132034355964 0.0000000000000000 0.0154371741 -0.3210711123 -0.3266682311 @@ -909,7 +909,7 @@ -0.0196107269 0.0051133745 -0.0167478902 0.0048756987 -0.0194638366 -0.0110995779 0.0275400673 0.0221060299 0.0002584058 -# File: 49 +# File: 49 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 12 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 0.0149311970 -0.3213669834 -0.3154179849 @@ -928,7 +928,7 @@ 0.0196808690 -0.0163351046 0.0059361530 -0.0165708822 0.0198133735 0.0115775132 -0.0164330851 -0.0218804765 0.0002501712 -# File: 50 +# File: 50 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 15 0.0212132034355964 0.0000000000000000 0.0212132034355964 0.0099184526 -0.3212126194 -0.3266920407 @@ -947,7 +947,7 @@ 0.0107831614 -0.0169173976 -0.0251186166 -0.3269383169 -0.0150508552 -0.3208434254 -0.0139906912 0.0114204540 0.0109195207 -# File: 51 +# File: 51 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 15 -0.0212132034355964 0.0000000000000000 -0.0212132034355964 0.0207251585 -0.3213416237 -0.3157479787 @@ -966,7 +966,7 @@ -0.0106824135 0.0057905169 0.0141728722 0.3154181047 -0.0149316541 0.3213671199 0.0253009355 -0.0112683054 -0.0105326012 -# File: 52 +# File: 52 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 15 0.0000000000000000 0.0212132034355964 0.0212132034355964 0.0096635017 -0.3209706287 -0.3209705585 @@ -985,7 +985,7 @@ -0.0112444660 0.0051172736 -0.0251108686 -0.0209689696 -0.3209382930 -0.3209385590 0.0056938867 0.0221084901 0.0221084504 -# File: 53 +# File: 53 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 15 0.0000000000000000 -0.0212132034355964 -0.0212132034355964 0.0210400347 -0.3214630706 -0.3214632639 @@ -1004,7 +1004,7 @@ 0.0114410894 -0.0163388013 0.0141643266 -0.0210399489 0.3214630537 0.3214632440 0.0057002617 -0.0218826229 -0.0218828342 -# File: 54 +# File: 54 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 16 0.0212132034355964 0.0000000000000000 0.0212132034355964 0.0154172860 -0.3154636736 -0.3208795584 @@ -1023,7 +1023,7 @@ 0.0221248215 -0.0053942124 0.0166102385 -0.0253120419 0.0115762128 0.0110745756 -0.3155111472 -0.0150597306 -0.3210296326 -# File: 55 +# File: 55 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 16 -0.0212132034355964 0.0000000000000000 -0.0212132034355964 0.0152298852 -0.3266395654 -0.3212776311 @@ -1042,7 +1042,7 @@ -0.0218576148 -0.0053769007 -0.0273614947 0.0139786056 -0.0111080196 -0.0103765236 0.3266396831 -0.0152299036 0.3212775233 -# File: 56 +# File: 56 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 16 0.0000000000000000 0.0212132034355964 0.0212132034355964 0.0209683493 -0.3209405075 -0.3209404024 @@ -1061,7 +1061,7 @@ 0.0114468887 -0.0250769097 0.0054350830 -0.0056267951 0.0222590743 0.0222591097 -0.0096636052 -0.3209681471 -0.3209681710 -# File: 57 +# File: 57 # 1 0.0000000000000000 0.0212132034355964 0.0212132034355964 # 16 0.0000000000000000 -0.0212132034355964 -0.0212132034355964 0.0097255863 -0.3212294883 -0.3212295526 diff --git a/example/Si-CRYSTAL/README b/example/Si-CRYSTAL/README index 9c380ecc..d8f15907 100644 --- a/example/Si-CRYSTAL/README +++ b/example/Si-CRYSTAL/README @@ -34,4 +34,3 @@ for the CRYSTAL interface, so the -c crystal.o parameter is not needed Add --isotope for isotope scattering Check the effect of --nac for polar systems - diff --git a/example/Si-CRYSTAL/crystal.o b/example/Si-CRYSTAL/crystal.o index 776c6f6f..8e4df4e8 100644 --- a/example/Si-CRYSTAL/crystal.o +++ b/example/Si-CRYSTAL/crystal.o @@ -79,7 +79,7 @@ SCF wavefunction si_cF8_alpha_pbe0_svp_fq.w is available as /chemtemp/CRY_6960/f PROCESS 10 OF 12 WORKING PROCESS 11 OF 12 WORKING - + ******************************************************************************* * * * CRYSTAL14 * @@ -119,14 +119,14 @@ SCF wavefunction si_cF8_alpha_pbe0_svp_fq.w is available as /chemtemp/CRY_6960/f * * ******************************************************************************** EEEEEEEEEE STARTING DATE 03 02 2017 TIME 23:03:41.1 - si_cF8_alpha + si_cF8_alpha CRYSTAL CALCULATION (INPUT ACCORDING TO THE INTERNATIONAL TABLES FOR X-RAY CRYSTALLOGRAPHY) - CRYSTAL FAMILY : CUBIC - CRYSTAL CLASS (GROTH - 1921) : CUBIC HEXAKISOCTAHEDRAL + CRYSTAL FAMILY : CUBIC + CRYSTAL CLASS (GROTH - 1921) : CUBIC HEXAKISOCTAHEDRAL - SPACE GROUP (CENTROSYMMETRIC) : F D 3 M + SPACE GROUP (CENTROSYMMETRIC) : F D 3 M LATTICE PARAMETERS (ANGSTROMS AND DEGREES) - CONVENTIONAL CELL A B C ALPHA BETA GAMMA @@ -159,7 +159,7 @@ SCF wavefunction si_cF8_alpha_pbe0_svp_fq.w is available as /chemtemp/CRY_6960/f NUMBER OF SYMMETRY OPERATORS : 48 ******************************************************************************* - * GEOMETRY EDITING - INPUT COORDINATES ARE GIVEN IN ANGSTROM + * GEOMETRY EDITING - INPUT COORDINATES ARE GIVEN IN ANGSTROM ******************************************************************************* GEOMETRY NOW FULLY CONSISTENT WITH THE GROUP @@ -179,11 +179,11 @@ SCF wavefunction si_cF8_alpha_pbe0_svp_fq.w is available as /chemtemp/CRY_6960/f ******************************************************************************* LATTICE PARAMETERS (ANGSTROMS AND DEGREES) - BOHR = 0.5291772083 ANGSTROM PRIMITIVE CELL - CENTRING CODE 5/0 VOLUME= 40.446798 - DENSITY 2.297 g/cm^3 - A B C ALPHA BETA GAMMA + A B C ALPHA BETA GAMMA 3.85300625 3.85300625 3.85300625 60.000000 60.000000 60.000000 ******************************************************************************* ATOMS IN THE ASYMMETRIC UNIT 1 - ATOMS IN THE UNIT CELL: 2 - ATOM X/A Y/B Z/C + ATOM X/A Y/B Z/C ******************************************************************************* 1 T 14 SI 1.250000000000E-01 1.250000000000E-01 1.250000000000E-01 2 F 14 SI -1.250000000000E-01 -1.250000000000E-01 -1.250000000000E-01 @@ -193,11 +193,11 @@ SCF wavefunction si_cF8_alpha_pbe0_svp_fq.w is available as /chemtemp/CRY_6960/f ******************************************************************************* CRYSTALLOGRAPHIC CELL (VOLUME= 161.78719119) - A B C ALPHA BETA GAMMA + A B C ALPHA BETA GAMMA 5.44897370 5.44897370 5.44897370 90.000000 90.000000 90.000000 COORDINATES IN THE CRYSTALLOGRAPHIC CELL - ATOM X/A Y/B Z/C + ATOM X/A Y/B Z/C ******************************************************************************* 1 T 14 SI 1.250000000000E-01 1.250000000000E-01 1.250000000000E-01 2 F 14 SI -1.250000000000E-01 -1.250000000000E-01 -1.250000000000E-01 @@ -276,29 +276,29 @@ SCF wavefunction si_cF8_alpha_pbe0_svp_fq.w is available as /chemtemp/CRY_6960/f ATOM X(AU) Y(AU) Z(AU) N. TYPE EXPONENT S COEF P COEF D/F/G COEF ******************************************************************************* 1 SI 1.287 1.287 1.287 - 1 S + 1 S 6.904E+03 1.337E-03 0.000E+00 0.000E+00 1.038E+03 9.997E-03 0.000E+00 0.000E+00 2.359E+02 4.491E-02 0.000E+00 0.000E+00 6.607E+01 1.146E-01 0.000E+00 0.000E+00 2.025E+01 1.028E-01 0.000E+00 0.000E+00 - 2 S + 2 S 3.435E+01 7.084E-02 0.000E+00 0.000E+00 3.637E+00-4.303E-01 0.000E+00 0.000E+00 1.400E+00-4.138E-01 0.000E+00 0.000E+00 - 3 S + 3 S 2.594E-01 1.000E+00 0.000E+00 0.000E+00 - 4- 7 SP + 4- 7 SP 1.200E-01 1.000E+00 1.000E+00 0.000E+00 - 8- 10 P + 8- 10 P 1.798E+02 0.000E+00 6.192E-03 0.000E+00 4.191E+01 0.000E+00 4.340E-02 0.000E+00 1.296E+01 0.000E+00 1.563E-01 0.000E+00 4.438E+00 0.000E+00 2.942E-01 0.000E+00 1.546E+00 0.000E+00 2.354E-01 0.000E+00 - 11- 13 P + 11- 13 P 4.098E-01 0.000E+00 1.000E+00 0.000E+00 - 14- 18 D + 14- 18 D 3.500E-01 0.000E+00 0.000E+00 1.000E+00 2 SI -1.287 -1.287 -1.287 INFORMATION **** SET_MPP **** PCRYSTAL CALCULATION @@ -360,7 +360,7 @@ SCF wavefunction si_cF8_alpha_pbe0_svp_fq.w is available as /chemtemp/CRY_6960/f 25-C( 4 3 1) 26-C( 5 3 1) 27-C( 6 3 1) 28-C( 5 4 1) 29-C( 6 4 2) - DIRECT LATTICE VECTORS COMPON. (A.U.) RECIP. LATTICE VECTORS COMPON. (A.U.) + DIRECT LATTICE VECTORS COMPON. (A.U.) RECIP. LATTICE VECTORS COMPON. (A.U.) X Y Z X Y Z 0.0000000 5.1485340 5.1485340 -0.6101917 0.6101917 0.6101917 5.1485340 0.0000000 5.1485340 0.6101917 -0.6101917 0.6101917 @@ -447,7 +447,7 @@ SCF wavefunction si_cF8_alpha_pbe0_svp_fq.w is available as /chemtemp/CRY_6960/f - ATOMS ISOTOPIC MASS (AMU) FOR FREQUENCY CALCULATION + ATOMS ISOTOPIC MASS (AMU) FOR FREQUENCY CALCULATION 1 SI 27.9769 2 SI 27.9769 @@ -455,10 +455,10 @@ SCF wavefunction si_cF8_alpha_pbe0_svp_fq.w is available as /chemtemp/CRY_6960/f GENERATING FREQUENCIES. IN PRINCIPLE 3N+1 SCF + GRADIENT CALCULATIONS ARE REQUIRED; FOR EACH OF THEM THE REMAINING POINT SYMMETRY IS INDICATED. - POINT SYMMETRY PERMITS TO GENERATE GRADIENTS FOR DISPLACEMENT B + POINT SYMMETRY PERMITS TO GENERATE GRADIENTS FOR DISPLACEMENT B STARTING FROM THE GRADIENT GENERATED BY DISPLACEMENT A. - N LABEL SYMBOL DISPLACEMENT SYM. + N LABEL SYMBOL DISPLACEMENT SYM. 1 EQUILIBRIUM GEOMETRY 48 @@ -519,7 +519,7 @@ SCF wavefunction si_cF8_alpha_pbe0_svp_fq.w is available as /chemtemp/CRY_6960/f TTTTTTTTTTTTTTTTTTTTTTTTTTTTTT INT_CALC TELAPSE 0.21 TCPU 0.14 ******************************************************************************* - si_cF8_alpha + si_cF8_alpha CRYSTAL - SCF - TYPE OF CALCULATION : RESTRICTED CLOSED SHELL ******************************************************************************* @@ -784,7 +784,7 @@ SCF wavefunction si_cF8_alpha_pbe0_svp_fq.w is available as /chemtemp/CRY_6960/f (2) ONLY RELEVANT CLASSES ARE CONSIDERED IN THE CHARACTER TABLE (3) SYMBOLS MAY NOT FULLY COINCIDE WITH THOSE FROM TEXT BOOKS.] - (P, D, RP, RD, STAND FOR PAIRING, DOUBLING, REAL PAIRING AND REAL DOUBLING + (P, D, RP, RD, STAND FOR PAIRING, DOUBLING, REAL PAIRING AND REAL DOUBLING OF THE IRREPS (SEE MANUAL)) CLASS | GROUP OPERATORS (SEE SYMMOPS KEYWORD) @@ -805,7 +805,7 @@ SCF wavefunction si_cF8_alpha_pbe0_svp_fq.w is available as /chemtemp/CRY_6960/f ------------------------------------------------------------------------------- F2g | 3.00 -1.00 0.00 1.00 -1.00 3.00 -1.00 0.00 1.00 -1.00 F1u | 3.00 -1.00 0.00 -1.00 1.00 -3.00 1.00 0.00 1.00 -1.00 - + F2g-(3, 1); F1u-(3, 1); @@ -902,4 +902,4 @@ SCF wavefunction fort.9 saved as /home/antti/work/crypho/phonopy-aalto-tests/si_ FREQCALC RESTART data FREQINFO.DAT saved as /home/antti/work/crypho/phonopy-aalto-tests/si_pbe0_svp/opt/si_cF8_alpha_pbe0_svp_fq.freqinfo Additional FREQCALC RESTART data fort.13 saved as /home/antti/work/crypho/phonopy-aalto-tests/si_pbe0_svp/opt/si_cF8_alpha_pbe0_svp_fq.f13 Temporary directory /chemtemp/CRY_6960 removed from node compute-0-6.local -Date: 2017-02-03 23:06:31 \ No newline at end of file +Date: 2017-02-03 23:06:31 diff --git a/example/Si-LDA/FORCES_FC3 b/example/Si-LDA/FORCES_FC3 index b782181f..6c2e98ab 100644 --- a/example/Si-LDA/FORCES_FC3 +++ b/example/Si-LDA/FORCES_FC3 @@ -1,4 +1,4 @@ -# File: 1 +# File: 1 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4048203000 0.0000000000 0.0000000000 0.0006218800 0.0000000000 0.0000000000 @@ -64,7 +64,7 @@ -0.0003516900 0.0009946800 -0.0009946800 -0.0015020600 0.0009793700 -0.0011994900 0.0007013600 0.0007746100 -0.0007891700 -# File: 2 +# File: 2 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 1 0.0212132034355964 0.0212132034355964 0.0000000000000000 -0.6908798200 -0.2876254800 -0.0368033800 @@ -131,7 +131,7 @@ 0.0000969100 0.0006039100 -0.0025355900 -0.0018578500 0.0014006000 -0.0027708900 0.0018214200 0.0018880400 -0.0019300800 -# File: 3 +# File: 3 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 1 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.1187255500 0.2863799600 0.0063107000 @@ -198,7 +198,7 @@ -0.0008159700 0.0013860800 0.0005377300 -0.0011499300 0.0005340700 0.0003587100 -0.0003306000 -0.0002550100 0.0003030300 -# File: 4 +# File: 4 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 2 0.0212132034355964 0.0212132034355964 0.0000000000000000 -0.4043807300 0.0009450800 0.0000353600 @@ -265,7 +265,7 @@ 0.1138381400 0.1151817300 -0.0928526700 -0.0004470300 0.0020344200 -0.0023071200 0.0003306200 0.0012234400 -0.0023354500 -# File: 5 +# File: 5 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 2 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.4052606200 -0.0009425000 -0.0000050800 @@ -332,7 +332,7 @@ -0.1244087000 -0.1230628800 0.1042817800 -0.0024784900 0.0000052500 -0.0001525100 0.0010772000 0.0003044300 0.0007481400 -# File: 6 +# File: 6 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 3 0.0212132034355964 0.0212132034355964 0.0000000000000000 -0.4038761900 0.0004429700 0.0000242300 @@ -399,7 +399,7 @@ 0.0007065800 0.0020542700 -0.0020973300 0.1126892300 0.1151657600 -0.0930514700 0.0011523500 0.0004042200 -0.0023350400 -# File: 7 +# File: 7 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 3 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.4057656500 -0.0004403200 0.0000067400 @@ -466,7 +466,7 @@ -0.0013223400 0.0000189800 0.0000510800 -0.1255692600 -0.1230802400 0.1040694300 0.0002349200 0.0011443500 0.0007477000 -# File: 8 +# File: 8 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 3 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.4048194600 0.0000303700 0.0013351100 @@ -533,7 +533,7 @@ -0.0011208600 0.0002234500 0.0052176300 -0.0738671300 -0.0713943100 0.0989761100 -0.0003137500 -0.0003955700 -0.0023368800 -# File: 9 +# File: 9 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 4 0.0212132034355964 0.0212132034355964 0.0000000000000000 -0.4048674100 -0.0000455400 0.0000113600 @@ -600,7 +600,7 @@ -0.0007228600 0.0014467300 -0.0025443600 -0.0010572600 0.0006059900 -0.0027523400 0.1148887100 0.1149656000 -0.0926232000 -# File: 10 +# File: 10 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 4 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.4047708000 0.0000512100 0.0000202200 @@ -667,7 +667,7 @@ 0.0000245800 0.0005233600 0.0005430800 -0.0019711200 0.0013515100 0.0003377100 -0.1233525000 -0.1232885200 0.1044680900 -# File: 11 +# File: 11 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 4 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.4048167100 0.0000313400 -0.0117451700 @@ -734,7 +734,7 @@ -0.0015198200 -0.0000161200 -0.0025431200 -0.0025225400 -0.0001901300 -0.0027488300 -0.0716719800 -0.0716151200 0.0993872900 -# File: 12 +# File: 12 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 7 0.0212132034355964 0.0212132034355964 0.0000000000000000 -0.4131153500 -0.0000450500 -0.0000062900 @@ -801,7 +801,7 @@ -0.0002135000 0.0011306500 -0.0020978500 -0.0017558800 0.0007257100 -0.0026093800 0.0017247700 0.0056690400 -0.0018804000 -# File: 13 +# File: 13 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 7 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.3965157000 0.0000490200 0.0000018100 @@ -868,7 +868,7 @@ -0.0005004100 0.0008441100 0.0001069200 -0.0012692800 0.0012142500 0.0002073300 -0.0003040300 -0.0041363800 0.0002694000 -# File: 14 +# File: 14 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 8 0.0212132034355964 0.0212132034355964 0.0000000000000000 -0.4043543400 0.0004688300 0.0000142700 @@ -935,7 +935,7 @@ 0.0045456200 0.0020230100 -0.0020865000 -0.0004763700 0.0058762100 -0.0022910500 0.0004513800 0.0005231200 -0.0021979100 -# File: 15 +# File: 15 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 8 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.4052874700 -0.0004658100 -0.0000016900 @@ -1002,7 +1002,7 @@ -0.0052597500 -0.0000192900 0.0000609900 -0.0025189900 -0.0039341900 -0.0001477300 0.0009391900 0.0010080400 0.0006238700 -# File: 16 +# File: 16 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4018514500 0.0060049500 0.0057824100 @@ -1069,7 +1069,7 @@ -0.0011201200 0.0072114400 -0.0017613200 -0.0022389100 0.0016361800 -0.0019383900 -0.0000822000 0.0001979900 -0.0015780300 -# File: 17 +# File: 17 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4076669500 -0.0058529600 -0.0056620500 @@ -1136,7 +1136,7 @@ 0.0004086100 -0.0051454800 -0.0002408900 -0.0007172400 0.0002746700 -0.0004244500 0.0014789200 0.0013481500 -0.0000079600 -# File: 18 +# File: 18 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4179138400 -0.0028628200 -0.0028628200 @@ -1203,7 +1203,7 @@ 0.0003535600 0.0002110000 -0.0002215100 0.0046345000 0.0002171600 -0.0004481600 0.0001193700 -0.0000024000 -0.0000115700 -# File: 19 +# File: 19 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 9 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3918188400 0.0027451300 0.0027451300 @@ -1270,7 +1270,7 @@ -0.0010110000 0.0017240700 -0.0017264400 -0.0077171600 0.0017526800 -0.0019652600 0.0012874000 0.0015625000 -0.0015762000 -# File: 20 +# File: 20 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4045796400 0.0010711100 -0.0018561800 @@ -1337,7 +1337,7 @@ -0.0015159100 -0.0005554900 -0.0020117900 -0.0022919500 0.0003992100 -0.0019891600 -0.0000298300 0.0014328000 -0.0015242200 -# File: 21 +# File: 21 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4050617200 -0.0010643500 0.0018718500 @@ -1404,7 +1404,7 @@ 0.0008496400 0.0025003200 -0.0000159000 -0.0007274400 0.0015565200 -0.0004238600 0.0014898600 0.0000689100 -0.0000112400 -# File: 22 +# File: 22 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4048901500 -0.0002387700 -0.0002387700 @@ -1471,7 +1471,7 @@ -0.0018532900 -0.0002059600 -0.0000118800 -0.0020806800 0.0002036100 -0.0004232900 0.0068395100 0.0000186500 -0.0000320700 -# File: 23 +# File: 23 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 10 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4047771300 0.0002461600 0.0002461600 @@ -1538,7 +1538,7 @@ 0.0011978900 0.0021643500 -0.0020128300 -0.0009233700 0.0017659600 -0.0019885300 -0.0055094800 0.0015417800 -0.0015573700 -# File: 24 +# File: 24 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 11 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4021791200 0.0057045700 -0.0057807800 @@ -1605,7 +1605,7 @@ -0.0011369300 0.0004161700 -0.0017843600 -0.0026752800 -0.0005673400 -0.0022247500 -0.0000563800 0.0069858300 -0.0015559300 -# File: 25 +# File: 25 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 11 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4075484600 -0.0058549800 0.0059063800 @@ -1672,7 +1672,7 @@ 0.0004275800 0.0015728900 -0.0002158100 -0.0003000100 0.0024792300 -0.0002161500 0.0014504200 -0.0053618400 -0.0000310800 -# File: 26 +# File: 26 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 11 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4176447700 -0.0027580400 0.0027580400 @@ -1739,7 +1739,7 @@ -0.0009325100 0.0002176400 -0.0002176400 -0.0029957700 -0.0002187200 -0.0002187200 0.0014023200 -0.0000179200 -0.0000179200 -# File: 27 +# File: 27 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 11 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3919080200 0.0028639600 -0.0028639600 @@ -1806,7 +1806,7 @@ 0.0002315300 0.0017816500 -0.0017816500 0.0000352000 0.0021463000 -0.0022173800 0.0000444600 0.0015127200 -0.0015208900 -# File: 28 +# File: 28 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 12 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4045685500 0.0010970200 0.0018690400 @@ -1873,7 +1873,7 @@ -0.0010855600 0.0016521800 -0.0017291400 -0.0022716600 0.0071872500 -0.0019717300 -0.0004648900 -0.0007749300 -0.0018038300 -# File: 29 +# File: 29 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 12 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4050730800 -0.0010984500 -0.0018531900 @@ -1940,7 +1940,7 @@ 0.0004394100 0.0002918100 -0.0002206100 -0.0007497500 -0.0051534900 -0.0004431900 0.0019046800 0.0022774200 0.0001910700 -# File: 30 +# File: 30 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 12 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4048157100 -0.0002523000 0.0002523000 @@ -2007,7 +2007,7 @@ 0.0057865900 0.0002378900 -0.0002378900 -0.0008027600 0.0001914200 -0.0004229500 -0.0008027600 -0.0004229500 0.0001914200 -# File: 31 +# File: 31 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 12 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4048023100 0.0002462700 -0.0002462700 @@ -2074,7 +2074,7 @@ -0.0065643500 0.0017626900 -0.0017626900 -0.0021585200 0.0017139500 -0.0019375100 0.0022515100 0.0019393100 -0.0018065700 -# File: 32 +# File: 32 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3990408400 0.0029281300 0.0056664200 @@ -2141,7 +2141,7 @@ 0.0003053900 0.0002647100 -0.0017267900 0.0047027900 0.0002088700 -0.0019766800 0.0001283700 -0.0000090600 -0.0015726400 -# File: 33 +# File: 33 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4104351100 -0.0028224100 -0.0055354700 @@ -2208,7 +2208,7 @@ -0.0010503500 0.0017792400 -0.0002227100 -0.0076358600 0.0017362700 -0.0004371400 0.0012759900 0.0015457700 -0.0000142500 -# File: 34 +# File: 34 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4075631700 -0.0130137600 -0.0028484200 @@ -2275,7 +2275,7 @@ -0.0011036200 0.0071358700 -0.0002375100 -0.0022802700 0.0016754800 -0.0004254600 -0.0000671500 0.0002030700 -0.0000242700 -# File: 35 +# File: 35 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4021720100 0.0129214900 0.0027564100 @@ -2342,7 +2342,7 @@ 0.0004171900 -0.0052229300 -0.0017638500 -0.0007813600 0.0003275200 -0.0019370100 0.0014849800 0.0013463600 -0.0015611600 -# File: 36 +# File: 36 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3990957300 0.0027959400 0.0057509900 @@ -2409,7 +2409,7 @@ -0.0011222400 0.0017827100 -0.0002946900 -0.0023070000 0.0017567600 -0.0004914800 -0.0000719800 0.0015516000 -0.0013586700 -# File: 37 +# File: 37 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.4104167400 -0.0026919500 -0.0055889200 @@ -2476,7 +2476,7 @@ 0.0003848300 0.0002566900 -0.0016459600 -0.0007548000 0.0002403700 -0.0018615100 0.0014887000 -0.0000118200 -0.0002181000 -# File: 38 +# File: 38 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3988884000 0.0026740400 -0.0059103400 @@ -2543,7 +2543,7 @@ -0.0018983100 -0.0001699200 -0.0020116000 -0.0020855300 0.0001889500 -0.0019887600 0.0069180200 -0.0000001500 -0.0015499300 -# File: 39 +# File: 39 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4108850600 -0.0027776700 0.0060201200 @@ -2610,7 +2610,7 @@ 0.0011554900 0.0021912000 -0.0000147100 -0.0009255100 0.0017573400 -0.0004232700 -0.0054368500 0.0015356000 -0.0000387600 -# File: 40 +# File: 40 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4076611300 -0.0129310600 0.0027268900 @@ -2677,7 +2677,7 @@ -0.0015479400 -0.0005109000 -0.0000136600 -0.0022790700 0.0004027900 -0.0004225400 -0.0000921100 0.0014728300 -0.0000100700 -# File: 41 +# File: 41 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4018479800 0.0130187300 -0.0028562000 @@ -2744,7 +2744,7 @@ 0.0008168600 0.0025468000 -0.0020144100 -0.0007194000 0.0015553700 -0.0019908000 0.0014466200 0.0001205000 -0.0015250000 -# File: 42 +# File: 42 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.4107756800 -0.0029170600 0.0061046700 @@ -2811,7 +2811,7 @@ -0.0013397000 0.0019939500 -0.0013397000 -0.0022793600 0.0017557200 -0.0017742600 -0.0000886900 0.0015489700 -0.0000886900 -# File: 43 +# File: 43 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.3989744600 0.0028123300 -0.0059643900 @@ -2878,7 +2878,7 @@ 0.0006496600 -0.0000111200 -0.0006520000 -0.0007183200 0.0001900400 -0.0006245300 0.0014413700 0.0000377700 -0.0014429500 -# File: 44 +# File: 44 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4037398300 0.0002329500 -0.0018452900 @@ -2945,7 +2945,7 @@ -0.0009279400 0.0002089000 -0.0017815900 -0.0030532300 -0.0001887800 -0.0022182400 0.0013606600 0.0000371000 -0.0015252000 -# File: 45 +# File: 45 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4058938000 -0.0002307600 0.0018599700 @@ -3012,7 +3012,7 @@ 0.0002267800 0.0017710000 -0.0002184400 -0.0000008800 0.0021787700 -0.0002218900 -0.0000002200 0.0015636500 -0.0000109100 -# File: 46 +# File: 46 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4050669200 -0.0000413500 -0.0002455500 @@ -3079,7 +3079,7 @@ -0.0011271800 0.0004189900 -0.0002176100 -0.0027023600 -0.0005246600 -0.0002224600 -0.0000506700 0.0069097900 -0.0000321000 -# File: 47 +# File: 47 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4045704400 0.0000185900 0.0002523000 @@ -3146,7 +3146,7 @@ 0.0004387800 0.0015723100 -0.0017819500 -0.0003383100 0.0025274700 -0.0022187800 0.0014703300 -0.0054386900 -0.0015553600 -# File: 48 +# File: 48 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.4066898400 0.0002454100 0.0010967200 @@ -3213,7 +3213,7 @@ -0.0011260100 0.0017715000 -0.0015707900 -0.0024994200 0.0019732200 -0.0015509800 -0.0000709800 0.0015686900 -0.0000831800 -# File: 49 +# File: 49 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.4029375700 -0.0002434800 -0.0010925700 @@ -3280,7 +3280,7 @@ 0.0004376900 0.0002079900 -0.0004164800 -0.0005025400 -0.0000219800 -0.0008565300 0.0014377700 0.0000319500 -0.0014462500 -# File: 50 +# File: 50 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4037357800 0.0002633000 0.0018826900 @@ -3347,7 +3347,7 @@ 0.0058661000 0.0002254200 -0.0017608600 -0.0008471500 0.0002447300 -0.0019367400 -0.0008467100 -0.0003945400 -0.0018061300 -# File: 51 +# File: 51 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4059058600 -0.0002617400 -0.0018667700 @@ -3414,7 +3414,7 @@ -0.0064897800 0.0017527300 -0.0002407100 -0.0022069800 0.0017658800 -0.0004257300 0.0022079300 0.0019743500 0.0001921200 -# File: 52 +# File: 52 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4050666500 -0.0000221000 0.0002477100 @@ -3481,7 +3481,7 @@ -0.0011372000 0.0016994900 -0.0002218000 -0.0022590000 0.0071129100 -0.0004441800 -0.0004993500 -0.0007320900 0.0001910300 -# File: 53 +# File: 53 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4045796300 0.0000498400 -0.0002396200 @@ -3548,7 +3548,7 @@ 0.0003852300 0.0003371200 -0.0017283700 -0.0007369300 -0.0052327400 -0.0019711100 0.0018736800 0.0023247100 -0.0018033200 -# File: 54 +# File: 54 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.4029765200 -0.0002472800 0.0010743900 @@ -3615,7 +3615,7 @@ -0.0011391700 0.0017689500 -0.0002904100 -0.0022777000 0.0017704000 -0.0004977400 -0.0002904100 0.0017689500 -0.0011391700 -# File: 55 +# File: 55 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.4066760000 0.0002489300 -0.0010694800 @@ -3682,7 +3682,7 @@ 0.0003873800 0.0002597300 -0.0016532300 -0.0007709500 0.0002404300 -0.0018590900 0.0017049200 -0.0002278900 -0.0004411900 -# File: 56 +# File: 56 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 33 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4040336800 -0.0005657000 0.0007647900 @@ -3749,7 +3749,7 @@ 0.0015069300 0.0020802900 -0.0007485700 0.0003661000 0.0020593700 -0.0014468700 -0.0011663900 0.0018555000 -0.0005405900 -# File: 57 +# File: 57 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 33 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4056184200 0.0005688600 -0.0007743400 @@ -3816,7 +3816,7 @@ -0.0022221600 -0.0000866200 -0.0012414000 -0.0033590600 -0.0001054700 -0.0009539000 0.0025584800 -0.0003120700 -0.0010337800 -# File: 58 +# File: 58 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 33 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4054008600 0.0007878700 0.0007878700 @@ -3883,7 +3883,7 @@ 0.0007288900 0.0028661900 -0.0012407100 -0.0004187600 0.0028337400 -0.0009567500 0.0017849700 -0.0010970600 -0.0005400800 -# File: 59 +# File: 59 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 33 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4042389900 -0.0007966100 -0.0007966100 @@ -3950,7 +3950,7 @@ -0.0014353400 -0.0008613600 -0.0007474500 -0.0025825800 -0.0008916700 -0.0014466800 -0.0003819900 0.0026315200 -0.0010352800 -# File: 60 +# File: 60 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 34 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4040182200 0.0007077800 0.0007532000 @@ -4017,7 +4017,7 @@ -0.0022065500 0.0020812200 -0.0012399900 -0.0033734600 0.0020586000 -0.0009539800 0.0025759100 0.0018568200 -0.0010323500 -# File: 61 +# File: 61 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 34 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4055657000 -0.0006592800 -0.0007124900 @@ -4084,7 +4084,7 @@ 0.0015223700 -0.0000877500 -0.0007492900 0.0003510200 -0.0001061500 -0.0014482500 -0.0011544700 -0.0003130900 -0.0005427800 -# File: 62 +# File: 62 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 34 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3986122300 0.0007614100 0.0007614100 @@ -4151,7 +4151,7 @@ 0.0007295000 -0.0008622700 -0.0012429900 -0.0004198100 -0.0008892600 -0.0009549100 0.0017901100 0.0026353100 -0.0005455600 -# File: 63 +# File: 63 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 34 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4111043700 -0.0007716000 -0.0007716000 @@ -4218,7 +4218,7 @@ -0.0014279000 0.0028667200 -0.0007450800 -0.0025909900 0.0028312900 -0.0014473600 -0.0003771500 -0.0011007800 -0.0010306000 -# File: 64 +# File: 64 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4041595900 0.0007930400 0.0007386000 @@ -4285,7 +4285,7 @@ 0.0007311200 -0.0008759300 -0.0007476800 -0.0004211900 -0.0008785400 -0.0014494300 0.0017842700 0.0026447800 -0.0010317700 -# File: 65 +# File: 65 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4054311500 -0.0007383300 -0.0006941300 @@ -4352,7 +4352,7 @@ -0.0014345700 0.0028520300 -0.0012409300 -0.0025824800 0.0028502000 -0.0009527800 -0.0003811600 -0.0010818900 -0.0005442100 -# File: 66 +# File: 66 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4041169000 0.0061365400 0.0007526000 @@ -4419,7 +4419,7 @@ -0.0022209900 0.0020747700 -0.0007506400 -0.0033644100 0.0020654300 -0.0014456900 0.0025583600 0.0018578300 -0.0005360400 -# File: 67 +# File: 67 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4055313000 -0.0062107600 -0.0007587800 @@ -4486,7 +4486,7 @@ 0.0015078400 -0.0000888500 -0.0012387200 0.0003708400 -0.0001044400 -0.0009564300 -0.0011655900 -0.0003058900 -0.0010393800 -# File: 68 +# File: 68 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.4040833800 0.0007680500 0.0006656900 @@ -4553,7 +4553,7 @@ -0.0005970900 0.0007450900 -0.0010142100 -0.0012551900 0.0012287000 -0.0012185900 0.0009483400 0.0005315400 -0.0008314300 -# File: 69 +# File: 69 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.4055116100 -0.0007128300 -0.0006151200 @@ -4620,7 +4620,7 @@ -0.0001074500 0.0012396900 -0.0009497700 -0.0017471800 0.0007339200 -0.0011590200 0.0004521200 0.0010234600 -0.0007686600 -# File: 70 +# File: 70 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4063692000 0.0012580600 0.0009996500 @@ -4687,7 +4687,7 @@ 0.0007336500 0.0028512300 -0.0007485500 -0.0004231700 0.0028492200 -0.0014458500 0.0017882800 -0.0010843600 -0.0010313600 -# File: 71 +# File: 71 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4032239500 -0.0012220200 -0.0010365900 @@ -4754,7 +4754,7 @@ -0.0014287900 -0.0008759100 -0.0012416600 -0.0025897600 -0.0008774100 -0.0009559800 -0.0003770100 0.0026477000 -0.0005434300 -# File: 72 +# File: 72 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4036498400 -0.0014453600 0.0009797700 @@ -4821,7 +4821,7 @@ 0.0015227700 0.0020760300 -0.0012422200 0.0003533800 0.0020641200 -0.0009537000 -0.0011526600 0.0018589100 -0.0010348200 -# File: 73 +# File: 73 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4059601100 0.0014943000 -0.0010173100 @@ -4888,7 +4888,7 @@ -0.0022057500 -0.0000899000 -0.0007473100 -0.0033770300 -0.0001017100 -0.0014471700 0.0025749900 -0.0003061300 -0.0005408700 -# File: 74 +# File: 74 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.4037866000 0.0009569700 -0.0003515600 @@ -4955,7 +4955,7 @@ -0.0005925900 0.0012382800 -0.0010420800 -0.0012628700 0.0007358100 -0.0012476700 0.0009523700 0.0010223400 -0.0008072800 -# File: 75 +# File: 75 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.4058592600 -0.0009633700 0.0003485200 @@ -5022,7 +5022,7 @@ -0.0001003100 0.0007459600 -0.0009721300 -0.0017515800 0.0012271100 -0.0011798300 0.0004606000 0.0005313900 -0.0007425500 -# File: 76 +# File: 76 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 39 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4038339100 -0.0014841000 0.0012005300 @@ -5089,7 +5089,7 @@ 0.0053735000 0.0067719500 0.0017640100 0.0043424100 0.0069066400 -0.0040539700 -0.0051398200 0.0067024800 0.0020702000 -# File: 77 +# File: 77 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 39 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4058451000 0.0015309400 -0.0011672900 @@ -5156,7 +5156,7 @@ -0.0061941300 -0.0049338000 -0.0038575600 -0.0072312400 -0.0047999500 0.0015460600 0.0064268800 -0.0050041900 -0.0035396300 -# File: 78 +# File: 78 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 39 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4051684400 0.0009937100 0.0009937100 @@ -5223,7 +5223,7 @@ 0.0054263500 0.0067178100 0.0017596600 0.0044257300 0.0068195300 -0.0040589700 0.0064797800 -0.0049501200 -0.0035391400 -# File: 79 +# File: 79 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 39 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4044790100 -0.0009992800 -0.0009992800 @@ -5290,7 +5290,7 @@ -0.0062793500 -0.0048479300 -0.0038536400 -0.0072804300 -0.0047411600 0.0015511900 -0.0052221200 0.0066189400 0.0020679800 -# File: 80 +# File: 80 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 40 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3325372600 0.1030977700 0.0746091500 @@ -5357,7 +5357,7 @@ -0.0060645400 0.0067737800 -0.0037717800 -0.0073784200 0.0069263000 0.0016630000 0.0065476500 0.0067293200 -0.0036984800 -# File: 81 +# File: 81 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 40 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4829997500 -0.1060619800 -0.0807080700 @@ -5424,7 +5424,7 @@ 0.0054838500 -0.0049353400 0.0018868000 0.0042482300 -0.0048160800 -0.0039626400 -0.0050184400 -0.0050273700 0.0020175000 -# File: 82 +# File: 82 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 40 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3046512300 0.0724377800 0.0724377800 @@ -5491,7 +5491,7 @@ 0.0055671400 -0.0048435700 0.0018544400 0.0042743700 -0.0047482300 -0.0039265000 0.0065947700 0.0066367100 -0.0036208600 -# File: 83 +# File: 83 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 40 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.5075082400 -0.0781452500 -0.0781452500 @@ -5558,7 +5558,7 @@ -0.0061182400 0.0067144100 -0.0037371500 -0.0074307400 0.0068271200 0.0016264500 -0.0050365700 -0.0049690700 0.0019386100 -# File: 84 +# File: 84 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4063236200 -0.0009971600 0.0011131900 @@ -5625,7 +5625,7 @@ -0.0003700000 0.0012411100 -0.0007454800 -0.0145239400 0.0038384700 -0.0040606400 0.0006576400 0.0010169600 -0.0010270500 -# File: 85 +# File: 85 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4033629600 0.0009615000 -0.0011432600 @@ -5692,7 +5692,7 @@ -0.0003052800 0.0007545300 -0.0012377100 0.0114265200 -0.0017687200 0.0015453500 0.0007246000 0.0005249200 -0.0005433800 -# File: 86 +# File: 86 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4057781100 -0.0003474400 -0.0010333800 @@ -5759,7 +5759,7 @@ -0.0005934200 0.0020791600 -0.0028503100 -0.0042580100 0.0067520200 -0.0069228300 0.0004577000 0.0018526500 0.0010808700 -# File: 87 +# File: 87 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4038554300 0.0003453200 0.0010392500 @@ -5826,7 +5826,7 @@ -0.0001046700 -0.0000857000 0.0008760600 0.0013538500 -0.0049455200 0.0046403000 0.0009496400 -0.0003090600 -0.0026417300 -# File: 88 +# File: 88 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.4036189100 -0.0010139000 -0.0016030500 @@ -5893,7 +5893,7 @@ -0.0005941600 -0.0008620200 0.0000897900 0.0013531900 -0.0048631600 0.0047240400 0.0009488000 0.0026275100 0.0002967200 -# File: 89 +# File: 89 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.4060561100 0.0009804000 0.0015593200 @@ -5960,7 +5960,7 @@ -0.0001050100 0.0028667500 -0.0020739400 -0.0042569800 0.0067001300 -0.0069756400 0.0004580100 -0.0010953400 -0.0018669200 -# File: 90 +# File: 90 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4041141900 -0.0007766500 0.0007333600 @@ -6027,7 +6027,7 @@ -0.0132808500 0.0037415300 0.0017474700 -0.0015504900 0.0012215100 -0.0014435700 -0.0123126600 0.0036339100 -0.0036498900 -# File: 91 +# File: 91 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4055677200 0.0008152700 -0.0007851400 @@ -6094,7 +6094,7 @@ 0.0126723900 -0.0018636000 -0.0038493200 -0.0014826800 0.0007293100 -0.0009531200 0.0136302400 -0.0019738600 0.0019621400 -# File: 92 +# File: 92 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4056309200 0.0007431900 -0.0008125000 @@ -6161,7 +6161,7 @@ -0.0032156800 0.0069231700 0.0048433000 -0.0017508900 0.0020584000 0.0006671100 -0.0020508100 0.0065509100 -0.0065113500 -# File: 93 +# File: 93 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4040450100 -0.0006980800 0.0007591600 @@ -6228,7 +6228,7 @@ 0.0024097500 -0.0047831700 -0.0067128400 -0.0012584200 -0.0001043200 -0.0030542100 0.0035626200 -0.0051535900 0.0050569900 -# File: 94 +# File: 94 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.4040003800 -0.0007729500 0.0062067100 @@ -6295,7 +6295,7 @@ -0.0032099200 0.0068355300 0.0049346600 -0.0012620200 0.0028317800 -0.0001172800 0.0035647100 -0.0050712300 0.0051418900 -# File: 95 +# File: 95 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.4056224100 0.0007583300 -0.0061282200 @@ -6362,7 +6362,7 @@ 0.0024065500 -0.0047231500 -0.0067722500 -0.0017474100 -0.0008895200 -0.0022817900 -0.0020531400 0.0064964300 -0.0065646200 -# File: 96 +# File: 96 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 51 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4662241300 0.0919136500 -0.0594493100 @@ -6429,7 +6429,7 @@ -0.0005989900 0.0020835400 0.0008750100 -0.0043629900 0.0069073400 0.0046267000 0.0004449800 0.0018510100 -0.0026269100 -# File: 97 +# File: 97 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 51 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3381213400 -0.0946172300 0.0645655900 @@ -6496,7 +6496,7 @@ -0.0001014500 -0.0000984100 -0.0028477600 0.0012505400 -0.0048019500 -0.0069075600 0.0009581400 -0.0002987600 0.0010625200 -# File: 98 +# File: 98 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 51 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3074782900 -0.0667141300 0.0667141300 @@ -6563,7 +6563,7 @@ -0.0003875600 0.0012366600 -0.0012366600 -0.0144397700 0.0037427800 0.0015663200 0.0006699300 0.0010136800 -0.0005331900 -# File: 99 +# File: 99 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 51 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4990518600 0.0612594900 -0.0612594900 @@ -6630,7 +6630,7 @@ -0.0003398900 0.0007445000 -0.0007445000 0.0115207300 -0.0018940700 -0.0040745800 0.0007574200 0.0005409300 -0.0010392700 -# File: 100 +# File: 100 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 52 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4057940000 -0.0015210300 -0.0011996600 @@ -6697,7 +6697,7 @@ -0.0031022000 0.0067758100 -0.0067187700 -0.0017465800 0.0020625500 -0.0030577500 -0.0021532000 0.0067036800 0.0050529900 -# File: 101 +# File: 101 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 52 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4038076200 0.0015701900 0.0011672800 @@ -6764,7 +6764,7 @@ 0.0025084900 -0.0049357800 0.0048488000 -0.0012611700 -0.0001020700 0.0006699100 0.0034563100 -0.0050034300 -0.0065059200 -# File: 102 +# File: 102 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 52 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4051699900 -0.0010029900 0.0010029900 @@ -6831,7 +6831,7 @@ -0.0133659500 0.0038530200 -0.0038530200 -0.0015230400 0.0012263900 -0.0009519800 -0.0122301800 0.0035273500 0.0019606400 -# File: 103 +# File: 103 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 52 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4044659500 0.0009962100 -0.0009962100 @@ -6898,7 +6898,7 @@ 0.0125737900 -0.0017521300 0.0017521300 -0.0014574700 0.0007380300 -0.0014410200 0.0137228600 -0.0020903500 -0.0036504200 -# File: 104 +# File: 104 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 53 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4055940500 0.0007014600 -0.0007969600 @@ -6965,7 +6965,7 @@ -0.0001037600 0.0020770900 0.0008594700 0.0012481200 0.0067504400 0.0045203200 0.0009469100 0.0018549200 -0.0026631000 -# File: 105 +# File: 105 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 53 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4040955200 -0.0006530900 0.0007586100 @@ -7032,7 +7032,7 @@ -0.0005954200 -0.0000828600 -0.0028632900 -0.0043617400 -0.0049443300 -0.0070437600 0.0004609600 -0.0003109200 0.0010736200 -# File: 106 +# File: 106 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 53 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3986906600 -0.0007669500 0.0007669500 @@ -7099,7 +7099,7 @@ -0.0003974600 0.0007522100 -0.0007522100 -0.0144332800 -0.0017735900 -0.0039534900 0.0006795900 0.0005250100 -0.0010290000 -# File: 107 +# File: 107 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 53 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4108696800 0.0007543300 -0.0007543300 @@ -7166,7 +7166,7 @@ -0.0003290300 0.0012416200 -0.0012416200 0.0115146800 0.0038459000 0.0016675300 0.0007492600 0.0010176400 -0.0005555100 -# File: 108 +# File: 108 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 54 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4055853900 -0.0005862600 -0.0007885800 @@ -7233,7 +7233,7 @@ 0.0025098400 0.0069238500 -0.0068359300 -0.0012571000 0.0020586600 -0.0030695000 0.0034545800 0.0065466700 0.0049300700 -# File: 109 +# File: 109 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 54 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4040449600 0.0005907400 0.0008006200 @@ -7300,7 +7300,7 @@ -0.0031039500 -0.0047845200 0.0047284300 -0.0017498600 -0.0001049000 0.0006547000 -0.0021537300 -0.0051492500 -0.0066289600 -# File: 110 +# File: 110 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 54 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4053964000 -0.0007771900 0.0007771900 @@ -7367,7 +7367,7 @@ -0.0133649300 -0.0018698900 0.0018698900 -0.0015225300 0.0007303600 -0.0014483500 -0.0122234800 -0.0019798900 -0.0035452200 -# File: 111 +# File: 111 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 54 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4042435900 0.0007654400 -0.0007654400 diff --git a/example/Si-LDA/POSCAR-unitcell b/example/Si-LDA/POSCAR-unitcell index 113179e4..9ed0e5fc 100644 --- a/example/Si-LDA/POSCAR-unitcell +++ b/example/Si-LDA/POSCAR-unitcell @@ -13,4 +13,4 @@ Direct 0.1250000000000000 0.1250000000000000 0.1250000000000000 0.1250000000000000 0.6250000000000000 0.6250000000000000 0.6250000000000000 0.1250000000000000 0.6250000000000000 - 0.6250000000000000 0.6250000000000000 0.1250000000000000 \ No newline at end of file + 0.6250000000000000 0.6250000000000000 0.1250000000000000 diff --git a/example/Si-LDA/phono3py_disp.yaml b/example/Si-LDA/phono3py_disp.yaml index 4ff13fb0..0ecad25b 100644 --- a/example/Si-LDA/phono3py_disp.yaml +++ b/example/Si-LDA/phono3py_disp.yaml @@ -849,4 +849,4 @@ displacement_pairs: displacement_pair_info: number_of_singles: 1 - number_of_pairs: 110 \ No newline at end of file + number_of_pairs: 110 diff --git a/example/Si-PBE/FORCES_FC3 b/example/Si-PBE/FORCES_FC3 index af75bc50..7234188f 100644 --- a/example/Si-PBE/FORCES_FC3 +++ b/example/Si-PBE/FORCES_FC3 @@ -1,4 +1,4 @@ -# File: 1 +# File: 1 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3871386400 0.0000000000 0.0000000000 0.0005494400 0.0000000000 0.0000000000 @@ -64,7 +64,7 @@ -0.0002769400 0.0009038800 -0.0009038800 -0.0014327100 0.0008891400 -0.0012465000 0.0006623300 0.0006388400 -0.0007069700 -# File: 2 +# File: 2 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 1 0.0212132034355964 0.0212132034355964 0.0000000000000000 -0.6607453600 -0.2750030800 -0.0340348000 @@ -131,7 +131,7 @@ 0.0001573500 0.0005027100 -0.0024150800 -0.0017969100 0.0012991000 -0.0027872600 0.0016537300 0.0016242300 -0.0017348000 -# File: 3 +# File: 3 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 1 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.1135216400 0.2738477000 0.0058339700 @@ -198,7 +198,7 @@ -0.0007315300 0.0013081200 0.0005947800 -0.0010638700 0.0004596800 0.0002811500 -0.0002479500 -0.0002660600 0.0002682500 -# File: 4 +# File: 4 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 2 0.0212132034355964 0.0212132034355964 0.0000000000000000 -0.3867494600 0.0009304200 0.0000309000 @@ -265,7 +265,7 @@ 0.1069218400 0.1081008500 -0.0847210200 -0.0005016500 0.0018194600 -0.0022382500 0.0002762800 0.0010754300 -0.0022229000 -# File: 5 +# File: 5 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 2 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.3875260900 -0.0009306700 -0.0000051800 @@ -332,7 +332,7 @@ -0.1166478000 -0.1154647700 0.0953019000 -0.0022848000 0.0000377200 -0.0003153900 0.0010501700 0.0001839800 0.0007953900 -# File: 6 +# File: 6 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 3 0.0212132034355964 0.0212132034355964 0.0000000000000000 -0.3862050100 0.0003877100 0.0000212100 @@ -399,7 +399,7 @@ 0.0006537700 0.0018362600 -0.0018929100 0.1057718100 0.1080879800 -0.0850566000 0.0010977900 0.0002553700 -0.0022227400 -# File: 7 +# File: 7 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 3 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.3880702400 -0.0003888900 0.0000046800 @@ -466,7 +466,7 @@ -0.0011285500 0.0000503300 0.0000240500 -0.1178078100 -0.1154805700 0.0949533900 0.0002081800 0.0010239000 0.0007948500 -# File: 8 +# File: 8 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 3 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3871387000 0.0000256200 0.0013168200 @@ -533,7 +533,7 @@ -0.0009645100 0.0002155400 0.0053077000 -0.0675367500 -0.0652255000 0.0945514900 -0.0002627300 -0.0005723100 -0.0021826100 -# File: 9 +# File: 9 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 4 0.0212132034355964 0.0212132034355964 0.0000000000000000 -0.3872589100 -0.0001235400 0.0000148400 @@ -600,7 +600,7 @@ -0.0006630800 0.0013421600 -0.0024207100 -0.0009982500 0.0005037800 -0.0027649500 0.1078593900 0.1078425000 -0.0845045900 -# File: 10 +# File: 10 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 4 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.3870114500 0.0001266900 0.0000199700 @@ -667,7 +667,7 @@ 0.0001111000 0.0004474500 0.0005996400 -0.0018852300 0.0012765000 0.0002585600 -0.1157061000 -0.1157360400 0.0954806300 -# File: 11 +# File: 11 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 4 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3871340700 0.0000345800 -0.0115469500 @@ -734,7 +734,7 @@ -0.0014907700 -0.0000161000 -0.0023786600 -0.0023582400 -0.0003230400 -0.0027202400 -0.0654532400 -0.0654900600 0.0950904600 -# File: 12 +# File: 12 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 7 0.0212132034355964 0.0212132034355964 0.0000000000000000 -0.3952936400 -0.0001234600 -0.0000043900 @@ -801,7 +801,7 @@ -0.0001324700 0.0010483400 -0.0019629600 -0.0015987900 0.0007211800 -0.0025276900 0.0015983600 0.0054771600 -0.0016459300 -# File: 13 +# File: 13 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 7 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.3789725900 0.0001247000 0.0000008500 @@ -868,7 +868,7 @@ -0.0004348500 0.0007458400 0.0001533100 -0.0012797600 0.0010437700 0.0000340000 -0.0002595800 -0.0042154300 0.0001978900 -# File: 14 +# File: 14 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 8 0.0212132034355964 0.0212132034355964 0.0000000000000000 -0.3867296900 0.0004081400 0.0000117900 @@ -935,7 +935,7 @@ 0.0045601100 0.0018455500 -0.0018412400 -0.0004910000 0.0057290200 -0.0021820100 0.0004946800 0.0004722700 -0.0019901600 -# File: 15 +# File: 15 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 8 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.3875467400 -0.0004077200 -0.0000019100 @@ -1002,7 +1002,7 @@ -0.0051295000 -0.0000235200 -0.0000003500 -0.0023601700 -0.0039662200 -0.0003448700 0.0008164200 0.0007917400 0.0005751200 -# File: 16 +# File: 16 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3842647300 0.0058789300 0.0056309100 @@ -1069,7 +1069,7 @@ -0.0009635000 0.0071207400 -0.0015867900 -0.0020847200 0.0015074600 -0.0018493400 -0.0000909500 0.0001054800 -0.0014643400 -# File: 17 +# File: 17 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3898969200 -0.0057255100 -0.0055037500 @@ -1136,7 +1136,7 @@ 0.0003995900 -0.0052374400 -0.0002309000 -0.0007276400 0.0002262500 -0.0006055400 0.0014063800 0.0011712300 0.0000408000 -# File: 18 +# File: 18 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4001151700 -0.0027773400 -0.0027773400 @@ -1203,7 +1203,7 @@ 0.0003884700 0.0002027600 -0.0002671600 0.0047038800 0.0002085600 -0.0005767600 0.0001236100 -0.0001074100 0.0000397600 -# File: 19 +# File: 19 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 9 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3742682300 0.0026666300 0.0026666300 @@ -1270,7 +1270,7 @@ -0.0008977000 0.0015516900 -0.0015025000 -0.0076466100 0.0015793700 -0.0019261000 0.0012009300 0.0013941000 -0.0014632400 -# File: 20 +# File: 20 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3869151600 0.0010072300 -0.0018485800 @@ -1337,7 +1337,7 @@ -0.0014875500 -0.0005729300 -0.0018289700 -0.0021875500 0.0003530300 -0.0020019100 0.0000108800 0.0012578600 -0.0013092700 -# File: 21 +# File: 21 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3873613500 -0.0010034100 0.0018635900 @@ -1404,7 +1404,7 @@ 0.0009685400 0.0023377900 -0.0000143100 -0.0006871100 0.0014247200 -0.0005002900 0.0013668900 -0.0000248600 -0.0000667900 -# File: 22 +# File: 22 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3871848700 -0.0002230700 -0.0002230700 @@ -1471,7 +1471,7 @@ -0.0017102000 -0.0003437000 -0.0000122400 -0.0019679400 0.0001442000 -0.0005011900 0.0067997000 -0.0000353800 -0.0000310300 -# File: 23 +# File: 23 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 10 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3871132400 0.0002303800 0.0002303800 @@ -1538,7 +1538,7 @@ 0.0011986900 0.0021167400 -0.0018309000 -0.0008966800 0.0016437100 -0.0020009200 -0.0055518100 0.0013230500 -0.0013930600 -# File: 24 +# File: 24 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 11 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3845739500 0.0055726400 -0.0056168400 @@ -1605,7 +1605,7 @@ -0.0010322600 0.0003681600 -0.0016606800 -0.0026471100 -0.0005838600 -0.0021775200 -0.0000151000 0.0068516900 -0.0013914000 -# File: 25 +# File: 25 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 11 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3897815500 -0.0057288000 0.0057481100 @@ -1672,7 +1672,7 @@ 0.0004691100 0.0014391200 -0.0001563600 -0.0001826300 0.0023195900 -0.0003511500 0.0013292400 -0.0054982500 -0.0000320500 -# File: 26 +# File: 26 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 11 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3997973800 -0.0026699800 0.0026699800 @@ -1739,7 +1739,7 @@ -0.0008164600 0.0001578900 -0.0001578900 -0.0028554300 -0.0003563400 -0.0003563400 0.0013254100 -0.0000704600 -0.0000704600 -# File: 27 +# File: 27 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 11 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3743745900 0.0027713400 -0.0027713400 @@ -1806,7 +1806,7 @@ 0.0002628200 0.0016588600 -0.0016588600 0.0000326300 0.0021001200 -0.0021719400 0.0000435400 0.0012950200 -0.0013056600 -# File: 28 +# File: 28 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 12 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3869003300 0.0010309600 0.0018586100 @@ -1873,7 +1873,7 @@ -0.0009309200 0.0015218700 -0.0015042200 -0.0021161000 0.0070992700 -0.0019333000 -0.0005498200 -0.0008366000 -0.0016313200 -# File: 29 +# File: 29 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 12 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3873748000 -0.0010352300 -0.0018435500 @@ -1940,7 +1940,7 @@ 0.0004302100 0.0002413700 -0.0002656900 -0.0007589500 -0.0052445400 -0.0005693500 0.0019090300 0.0020711400 0.0001818600 -# File: 30 +# File: 30 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 12 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3871125900 -0.0002367000 0.0002367000 @@ -2007,7 +2007,7 @@ 0.0058594300 0.0002284700 -0.0002284700 -0.0007717300 0.0001832000 -0.0006050300 -0.0007717300 -0.0006050300 0.0001832000 -# File: 31 +# File: 31 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 12 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3871373600 0.0002298000 -0.0002298000 @@ -2074,7 +2074,7 @@ -0.0064899300 0.0015890300 -0.0015890300 -0.0020496500 0.0015418100 -0.0018498100 0.0021388500 0.0018481200 -0.0016328900 -# File: 32 +# File: 32 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3814869600 0.0028382700 0.0055085300 @@ -2141,7 +2141,7 @@ 0.0003392100 0.0002548600 -0.0015020500 0.0047762000 0.0002025800 -0.0019381700 0.0001297400 -0.0001120800 -0.0014600500 -# File: 33 +# File: 33 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3926216300 -0.0027427100 -0.0053709000 @@ -2208,7 +2208,7 @@ -0.0009376900 0.0016062700 -0.0002677300 -0.0075651700 0.0015661400 -0.0005642200 0.0011942000 0.0013803000 0.0000368000 -# File: 34 +# File: 34 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3897996400 -0.0128822100 -0.0027526500 @@ -2275,7 +2275,7 @@ -0.0009502500 0.0070455500 -0.0002277700 -0.0021281600 0.0015461100 -0.0006063500 -0.0000784500 0.0001094800 0.0000262500 -# File: 35 +# File: 35 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3845650200 0.0127713200 0.0026642200 @@ -2342,7 +2342,7 @@ 0.0004060800 -0.0053142800 -0.0015895700 -0.0007906400 0.0002766600 -0.0018486200 0.0014122100 0.0011685400 -0.0014492700 -# File: 36 +# File: 36 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3815721700 0.0027082700 0.0056206600 @@ -2409,7 +2409,7 @@ -0.0009148100 0.0016095300 -0.0002452300 -0.0021539800 0.0015313600 -0.0005795000 -0.0000817300 0.0013851100 -0.0012352800 -# File: 37 +# File: 37 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.3925662200 -0.0026132700 -0.0054574600 @@ -2476,7 +2476,7 @@ 0.0003230900 0.0002514100 -0.0015180600 -0.0007643700 0.0002846400 -0.0018689700 0.0014155600 -0.0001167000 -0.0001781100 -# File: 38 +# File: 38 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3813320900 0.0025897900 -0.0057518000 @@ -2543,7 +2543,7 @@ -0.0017525200 -0.0003047600 -0.0018282000 -0.0019702700 0.0001323400 -0.0020015700 0.0068769500 -0.0000508900 -0.0013869700 -# File: 39 +# File: 39 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3930845900 -0.0026881100 0.0058717100 @@ -2610,7 +2610,7 @@ 0.0011558400 0.0021470800 -0.0000150700 -0.0008954800 0.0016366400 -0.0005005300 -0.0054757400 0.0013183200 -0.0000367200 -# File: 40 +# File: 40 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3898874000 -0.0127750500 0.0026528200 @@ -2677,7 +2677,7 @@ -0.0015216600 -0.0005319900 -0.0000125000 -0.0021763700 0.0003559700 -0.0004988000 -0.0000511300 0.0012973600 -0.0000657600 -# File: 41 +# File: 41 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3842648600 0.0128760800 -0.0027770200 @@ -2744,7 +2744,7 @@ 0.0009329800 0.0023824400 -0.0018308500 -0.0006797800 0.0014227300 -0.0020035100 0.0013226000 0.0000241900 -0.0013101800 -# File: 42 +# File: 42 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3929529800 -0.0028255500 0.0059837600 @@ -2811,7 +2811,7 @@ -0.0011780800 0.0018132300 -0.0011780800 -0.0021767400 0.0016350900 -0.0017785100 -0.0000471000 0.0012787800 -0.0000471000 -# File: 43 +# File: 43 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.3814430100 0.0027264100 -0.0058383500 @@ -2878,7 +2878,7 @@ 0.0006307100 -0.0000118100 -0.0006305500 -0.0006792300 0.0001338800 -0.0007140200 0.0013179800 0.0000365500 -0.0013224100 -# File: 44 +# File: 44 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3861213800 0.0002162000 -0.0018376600 @@ -2945,7 +2945,7 @@ -0.0008124300 0.0001498200 -0.0016586100 -0.0029075700 -0.0003218800 -0.0021710500 0.0012802700 -0.0000161400 -0.0013100000 -# File: 45 +# File: 45 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3881504200 -0.0002170000 0.0018522900 @@ -3012,7 +3012,7 @@ 0.0002580100 0.0016484900 -0.0001582400 -0.0000005800 0.0021349800 -0.0003576500 -0.0000002400 0.0013471300 -0.0000660800 -# File: 46 +# File: 46 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3873647800 -0.0000219600 -0.0002291900 @@ -3079,7 +3079,7 @@ -0.0010232900 0.0003696200 -0.0001579300 -0.0026778400 -0.0005432200 -0.0003569700 -0.0000119700 0.0067752800 -0.0000321600 -# File: 47 +# File: 47 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3869040500 -0.0000021700 0.0002359600 @@ -3146,7 +3146,7 @@ 0.0004787700 0.0014385700 -0.0016589500 -0.0002222900 0.0023643700 -0.0021716300 0.0013463700 -0.0055741600 -0.0013914600 -# File: 48 +# File: 48 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3889995100 0.0002268300 0.0010312400 @@ -3213,7 +3213,7 @@ -0.0010226000 0.0016495700 -0.0014379400 -0.0023362900 0.0017924200 -0.0015226100 0.0000233900 0.0013506000 -0.0000435700 -# File: 49 +# File: 49 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.3852599800 -0.0002276000 -0.0010275900 @@ -3280,7 +3280,7 @@ 0.0004778100 0.0001492600 -0.0003692700 -0.0005230700 -0.0000202400 -0.0009714200 0.0012631800 -0.0000195900 -0.0013264100 -# File: 50 +# File: 50 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3861173900 0.0002446100 0.0018716100 @@ -3347,7 +3347,7 @@ 0.0059386600 0.0002175200 -0.0015874800 -0.0008144100 0.0002375000 -0.0018477100 -0.0008146800 -0.0005731200 -0.0016331400 -# File: 51 +# File: 51 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3881608200 -0.0002441300 -0.0018559300 @@ -3414,7 +3414,7 @@ -0.0064163800 0.0015802000 -0.0002301500 -0.0020955700 0.0015947500 -0.0006076500 0.0020959500 0.0018852900 0.0001832900 -# File: 52 +# File: 52 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3873685200 -0.0000046900 0.0002315200 @@ -3481,7 +3481,7 @@ -0.0009828600 0.0015666500 -0.0002663400 -0.0021071000 0.0070243800 -0.0005699100 -0.0005867000 -0.0007960200 0.0001820500 -# File: 53 +# File: 53 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3869124200 0.0000284900 -0.0002239200 @@ -3548,7 +3548,7 @@ 0.0003754700 0.0002852100 -0.0015034200 -0.0007484700 -0.0053224600 -0.0019329200 0.0018759500 0.0021161800 -0.0016314900 -# File: 54 +# File: 54 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3853055600 -0.0002317100 0.0010128000 @@ -3615,7 +3615,7 @@ -0.0009847200 0.0015427000 -0.0002410400 -0.0020698700 0.0015977600 -0.0005839300 -0.0002410400 0.0015427000 -0.0009847200 -# File: 55 +# File: 55 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.3889845200 0.0002324300 -0.0010081000 @@ -3682,7 +3682,7 @@ 0.0003776700 0.0003026500 -0.0015225000 -0.0008331600 0.0002337700 -0.0018645500 0.0015718800 -0.0002713500 -0.0004301500 -# File: 56 +# File: 56 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 33 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3863818600 -0.0005262500 0.0007344700 @@ -3749,7 +3749,7 @@ 0.0015699900 0.0019254200 -0.0006735000 0.0004286400 0.0019070800 -0.0014764900 -0.0011993600 0.0016568700 -0.0004764400 -# File: 57 +# File: 57 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 33 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3879028100 0.0005264100 -0.0007439500 @@ -3816,7 +3816,7 @@ -0.0021388200 -0.0001136700 -0.0011345500 -0.0032794000 -0.0001321400 -0.0010173500 0.0025087500 -0.0003831500 -0.0009368300 -# File: 58 +# File: 58 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 33 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3876740300 0.0007541600 0.0007541600 @@ -3883,7 +3883,7 @@ 0.0007401100 0.0027659500 -0.0011347500 -0.0004117400 0.0027351800 -0.0010174600 0.0016799800 -0.0012236600 -0.0004760700 -# File: 59 +# File: 59 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 33 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3866006700 -0.0007638500 -0.0007638500 @@ -3950,7 +3950,7 @@ -0.0012983900 -0.0009431500 -0.0006736000 -0.0024496300 -0.0009713100 -0.0014767600 -0.0003598500 0.0024863900 -0.0009381900 -# File: 60 +# File: 60 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 34 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3864190200 0.0006656900 0.0006192500 @@ -4017,7 +4017,7 @@ -0.0021246300 0.0019263500 -0.0011331300 -0.0032928100 0.0019058000 -0.0010149100 0.0025251800 0.0016579200 -0.0009361300 -# File: 61 +# File: 61 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 34 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3877987000 -0.0006213500 -0.0005814100 @@ -4084,7 +4084,7 @@ 0.0015857800 -0.0001151000 -0.0006740200 0.0004128100 -0.0001316900 -0.0014773000 -0.0011858900 -0.0003845200 -0.0004783500 -# File: 62 +# File: 62 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 34 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3809293000 0.0006799000 0.0006799000 @@ -4151,7 +4151,7 @@ 0.0007412400 -0.0009440800 -0.0011361800 -0.0004132300 -0.0009698200 -0.0010154500 0.0016846600 0.0024893300 -0.0004809100 -# File: 63 +# File: 63 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 34 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3934199400 -0.0006899700 -0.0006899700 @@ -4218,7 +4218,7 @@ -0.0012913300 0.0027665200 -0.0006712400 -0.0024557000 0.0027333700 -0.0014770500 -0.0003560600 -0.0012264500 -0.0009340500 -# File: 64 +# File: 64 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3865173600 0.0007097200 0.0006036200 @@ -4285,7 +4285,7 @@ 0.0007401100 -0.0009584300 -0.0006730800 -0.0004128000 -0.0009583300 -0.0014781500 0.0016794300 0.0025007000 -0.0009357000 -# File: 65 +# File: 65 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3877101200 -0.0006566300 -0.0005624700 @@ -4352,7 +4352,7 @@ -0.0012979800 0.0027512600 -0.0011340100 -0.0024486000 0.0027516400 -0.0010138900 -0.0003589900 -0.0012082200 -0.0004789200 -# File: 66 +# File: 66 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3865144500 0.0061372400 0.0006681700 @@ -4419,7 +4419,7 @@ -0.0021397600 0.0019201100 -0.0006754500 -0.0032833000 0.0019121500 -0.0014748800 0.0025075100 0.0016592400 -0.0004717200 -# File: 67 +# File: 67 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3877662600 -0.0062136000 -0.0006737600 @@ -4486,7 +4486,7 @@ 0.0015710300 -0.0001165500 -0.0011316200 0.0004331200 -0.0001299900 -0.0010173700 -0.0011977900 -0.0003775500 -0.0009429200 -# File: 68 +# File: 68 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3865344000 0.0006871300 0.0006262400 @@ -4553,7 +4553,7 @@ -0.0005099800 0.0006694200 -0.0009045200 -0.0011988100 0.0011240500 -0.0012451100 0.0008900000 0.0004125900 -0.0007309200 -# File: 69 +# File: 69 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.3876998100 -0.0006340500 -0.0005784300 @@ -4620,7 +4620,7 @@ -0.0000508900 0.0011312300 -0.0008791000 -0.0016594800 0.0006612200 -0.0012236700 0.0004274200 0.0008721900 -0.0007070800 -# File: 70 +# File: 70 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3886130400 0.0012989700 0.0009065000 @@ -4687,7 +4687,7 @@ 0.0007430100 0.0027504900 -0.0006743100 -0.0004148900 0.0027508000 -0.0014754200 0.0016837000 -0.0012097700 -0.0009351900 -# File: 71 +# File: 71 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3856180300 -0.0012628200 -0.0009431200 @@ -4754,7 +4754,7 @@ -0.0012931300 -0.0009576000 -0.0011341500 -0.0024543900 -0.0009572700 -0.0010177700 -0.0003559400 0.0025020800 -0.0004780700 -# File: 72 +# File: 72 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3859265400 -0.0013797000 0.0008889700 @@ -4821,7 +4821,7 @@ 0.0015858200 0.0019207700 -0.0011344500 0.0004156900 0.0019106000 -0.0010157700 -0.0011845600 0.0016601200 -0.0009374400 -# File: 73 +# File: 73 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3883136000 0.0014236700 -0.0009261400 @@ -4888,7 +4888,7 @@ -0.0021243800 -0.0001173300 -0.0006734000 -0.0032956100 -0.0001280100 -0.0014781200 0.0025232600 -0.0003783100 -0.0004760100 -# File: 74 +# File: 74 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3861980900 0.0008659800 -0.0002779800 @@ -4955,7 +4955,7 @@ -0.0005032000 0.0011306600 -0.0009311900 -0.0012074000 0.0006630200 -0.0012728300 0.0008959200 0.0008715600 -0.0007075300 -# File: 75 +# File: 75 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.3880827600 -0.0008741600 0.0002767600 @@ -5022,7 +5022,7 @@ -0.0000435700 0.0006699300 -0.0009005800 -0.0016648400 0.0011222300 -0.0012442300 0.0004356300 0.0004130400 -0.0006822200 -# File: 76 +# File: 76 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 39 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3862414400 -0.0014170400 0.0012458700 @@ -5089,7 +5089,7 @@ 0.0052838900 0.0065513300 0.0017717300 0.0042604800 0.0066917200 -0.0040095600 -0.0050274000 0.0064415600 0.0020607000 -# File: 77 +# File: 77 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 39 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3880687100 0.0014589100 -0.0012122600 @@ -5156,7 +5156,7 @@ -0.0059670400 -0.0048984900 -0.0036766400 -0.0069966500 -0.0047588400 0.0014194800 0.0062227500 -0.0050093600 -0.0033773900 -# File: 78 +# File: 78 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 39 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3874141000 0.0009029600 0.0009029600 @@ -5223,7 +5223,7 @@ 0.0053707300 0.0064643000 0.0017679900 0.0043696100 0.0065762200 -0.0040139200 0.0063081900 -0.0049228100 -0.0033764100 -# File: 79 +# File: 79 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 39 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3868619100 -0.0009094200 -0.0009094200 @@ -5290,7 +5290,7 @@ -0.0060795000 -0.0047858400 -0.0036729000 -0.0070800600 -0.0046688300 0.0014239100 -0.0051382300 0.0063296700 0.0020597900 -# File: 80 +# File: 80 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 40 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3211005800 0.0983802600 0.0681944700 @@ -5357,7 +5357,7 @@ -0.0058284400 0.0065524200 -0.0035989100 -0.0071496900 0.0067087300 0.0015349700 0.0063506500 0.0064627000 -0.0035248000 -# File: 81 +# File: 81 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 40 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4586056000 -0.1012365500 -0.0738186000 @@ -5424,7 +5424,7 @@ 0.0054033900 -0.0049003500 0.0018883500 0.0041555200 -0.0047752100 -0.0039329200 -0.0048972000 -0.0050287000 0.0020126400 -# File: 82 +# File: 82 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 40 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.2913478900 0.0661853000 0.0661853000 @@ -5491,7 +5491,7 @@ 0.0055173300 -0.0047832600 0.0018558400 0.0042153600 -0.0046763900 -0.0038892000 0.0064293000 0.0063452500 -0.0034525200 -# File: 83 +# File: 83 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 40 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4853727000 -0.0714499400 -0.0714499400 @@ -5558,7 +5558,7 @@ -0.0059156800 0.0064617100 -0.0035662600 -0.0072338300 0.0065833700 0.0014926000 -0.0049494500 -0.0049385400 0.0019403800 -# File: 84 +# File: 84 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3885702100 -0.0009092700 0.0011596100 @@ -5625,7 +5625,7 @@ -0.0002778200 0.0011347300 -0.0006699400 -0.0143158300 0.0036601700 -0.0040169000 0.0006363400 0.0008652600 -0.0009305500 -# File: 85 +# File: 85 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3857465300 0.0008743800 -0.0011932500 @@ -5692,7 +5692,7 @@ -0.0002520000 0.0006797200 -0.0011307000 0.0113446000 -0.0017760200 0.0014182900 0.0006636600 0.0004054600 -0.0004769600 -# File: 86 +# File: 86 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3880050000 -0.0002770600 -0.0009414100 @@ -5759,7 +5759,7 @@ -0.0005049300 0.0019247100 -0.0027502400 -0.0041040500 0.0065335400 -0.0068057100 0.0004320300 0.0016544400 0.0011529700 -# File: 87 +# File: 87 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3862632000 0.0002762500 0.0009458900 @@ -5826,7 +5826,7 @@ -0.0000482600 -0.0001131200 0.0009575200 0.0013356500 -0.0049100000 0.0044416900 0.0008918500 -0.0003810200 -0.0025520200 -# File: 88 +# File: 88 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3858913900 -0.0009234500 -0.0015271400 @@ -5893,7 +5893,7 @@ -0.0005056200 -0.0009435800 0.0001169200 0.0013349100 -0.0047989100 0.0045538300 0.0008912700 0.0024833800 0.0003138500 -# File: 89 +# File: 89 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.3884200000 0.0008891100 0.0014854500 @@ -5960,7 +5960,7 @@ -0.0000477000 0.0027659900 -0.0019204300 -0.0041034800 0.0064484000 -0.0068922100 0.0004325400 -0.0012207500 -0.0017236200 -# File: 90 +# File: 90 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3864728300 -0.0006416600 0.0006504400 @@ -6027,7 +6027,7 @@ -0.0130553100 0.0035682300 0.0017564400 -0.0014586200 0.0011156000 -0.0014723400 -0.0122188600 0.0034099500 -0.0034805500 -# File: 91 +# File: 91 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3878434300 0.0006760100 -0.0007035700 @@ -6094,7 +6094,7 @@ 0.0126078200 -0.0018665200 -0.0036703700 -0.0014308900 0.0006556800 -0.0010134700 0.0134373400 -0.0020262700 0.0019604500 -# File: 92 +# File: 92 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3878116200 0.0006981100 -0.0007273500 @@ -6161,7 +6161,7 @@ -0.0030503900 0.0067069300 0.0047813300 -0.0016629600 0.0019053900 0.0006129500 -0.0020098900 0.0062850000 -0.0062672500 -# File: 93 +# File: 93 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3864966900 -0.0006575700 0.0006738200 @@ -6228,7 +6228,7 @@ 0.0023991700 -0.0047448400 -0.0064606500 -0.0012029700 -0.0001306200 -0.0030911000 0.0034310000 -0.0051621700 0.0049830000 -# File: 94 +# File: 94 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3863981600 -0.0006931100 0.0062060800 @@ -6295,7 +6295,7 @@ -0.0030472200 0.0065909100 0.0048991900 -0.0012059600 0.0027342100 -0.0002257400 0.0034331700 -0.0050511800 0.0050955100 -# File: 95 +# File: 95 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.3878630400 0.0006792800 -0.0061293100 @@ -6362,7 +6362,7 @@ 0.0023960300 -0.0046542400 -0.0065522700 -0.0016599800 -0.0009707500 -0.0022631300 -0.0020116500 0.0061994200 -0.0063544700 -# File: 96 +# File: 96 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 51 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4431401500 0.0880460900 -0.0541813800 @@ -6429,7 +6429,7 @@ -0.0005094300 0.0019291800 0.0009563400 -0.0042029900 0.0066921500 0.0044279700 0.0004246500 0.0016526800 -0.0025358900 -# File: 97 +# File: 97 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 51 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3262487300 -0.0906604000 0.0588956600 @@ -6496,7 +6496,7 @@ -0.0000454100 -0.0001253700 -0.0027498300 0.0012412200 -0.0047600400 -0.0067927200 0.0009008800 -0.0003713100 0.0011358000 -# File: 98 +# File: 98 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 51 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.2940771700 -0.0608832600 0.0608832600 @@ -6563,7 +6563,7 @@ -0.0002923700 0.0011314200 -0.0011314200 -0.0142159600 0.0035675800 0.0014337200 0.0006519900 0.0008623100 -0.0004661800 -# File: 99 +# File: 99 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 51 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4772149200 0.0558590700 -0.0558590700 @@ -6630,7 +6630,7 @@ -0.0002860100 0.0006694100 -0.0006694100 0.0114545300 -0.0018949100 -0.0040316700 0.0006967200 0.0004222600 -0.0009412000 -# File: 100 +# File: 100 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 52 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3880204000 -0.0014488000 -0.0012459200 @@ -6697,7 +6697,7 @@ -0.0029475100 0.0065539800 -0.0064650100 -0.0016597400 0.0019100300 -0.0030938100 -0.0021054100 0.0064426100 0.0049802900 -# File: 101 +# File: 101 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 52 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3862166000 0.0014924900 0.0012097600 @@ -6764,7 +6764,7 @@ 0.0024908700 -0.0049007500 0.0047856000 -0.0012048400 -0.0001276200 0.0006156000 0.0033326200 -0.0050095600 -0.0062642000 -# File: 102 +# File: 102 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 52 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3874151800 -0.0009099000 0.0009099000 @@ -6831,7 +6831,7 @@ -0.0131545000 0.0036741100 -0.0036741100 -0.0014335500 0.0011210400 -0.0010138000 -0.0121162800 0.0033085900 0.0019596200 -# File: 103 +# File: 103 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 52 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3868570300 0.0009038300 -0.0009038300 @@ -6898,7 +6898,7 @@ 0.0124946500 -0.0017608400 0.0017608400 -0.0014079300 0.0006645500 -0.0014714900 0.0135465500 -0.0021376800 -0.0034807400 -# File: 104 +# File: 104 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 53 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3878324600 0.0006596900 -0.0006590900 @@ -6965,7 +6965,7 @@ -0.0000471500 0.0019228400 0.0009415500 0.0012373600 0.0065322500 0.0043130900 0.0008901600 0.0016570600 -0.0025729300 -# File: 105 +# File: 105 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 53 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3864915800 -0.0006150800 0.0006212900 @@ -7032,7 +7032,7 @@ -0.0005074400 -0.0001110600 -0.0027639700 -0.0042000200 -0.0049085000 -0.0069350200 0.0004350300 -0.0003834500 0.0011442200 -# File: 106 +# File: 106 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 53 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3810058900 -0.0006825900 0.0006825900 @@ -7099,7 +7099,7 @@ -0.0003021900 0.0006784400 -0.0006784400 -0.0142093300 -0.0017819600 -0.0039173300 0.0006597600 0.0004048800 -0.0009323600 -# File: 107 +# File: 107 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 53 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3931887400 0.0006721900 -0.0006721900 @@ -7166,7 +7166,7 @@ -0.0002759000 0.0011359200 -0.0011359200 0.0114484900 0.0036672200 0.0015314900 0.0006889400 0.0008657000 -0.0004891300 -# File: 108 +# File: 108 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 54 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3878723300 -0.0005436600 -0.0007568800 @@ -7233,7 +7233,7 @@ 0.0024919900 0.0067073200 -0.0065926700 -0.0012018900 0.0019057400 -0.0031075100 0.0033321700 0.0062821400 0.0048512500 -# File: 109 +# File: 109 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 54 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3863927700 0.0005447200 0.0007660900 @@ -7300,7 +7300,7 @@ -0.0029492700 -0.0047455900 0.0046571200 -0.0016622200 -0.0001311500 0.0006000500 -0.0021050200 -0.0051594200 -0.0063954500 -# File: 110 +# File: 110 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 54 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3876735600 -0.0007454400 0.0007454400 @@ -7367,7 +7367,7 @@ -0.0131544200 -0.0018697900 0.0018697900 -0.0014333600 0.0006548200 -0.0014805000 -0.0121095900 -0.0020325500 -0.0033792900 -# File: 111 +# File: 111 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 54 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3866021800 0.0007360500 -0.0007360500 diff --git a/example/Si-PBE/POSCAR-unitcell b/example/Si-PBE/POSCAR-unitcell index beec05e2..0f6fbe2f 100644 --- a/example/Si-PBE/POSCAR-unitcell +++ b/example/Si-PBE/POSCAR-unitcell @@ -13,4 +13,4 @@ Direct 0.1250000000000000 0.1250000000000000 0.1250000000000000 0.1250000000000000 0.6250000000000000 0.6250000000000000 0.6250000000000000 0.1250000000000000 0.6250000000000000 - 0.6250000000000000 0.6250000000000000 0.1250000000000000 \ No newline at end of file + 0.6250000000000000 0.6250000000000000 0.1250000000000000 diff --git a/example/Si-PBE/phono3py_disp.yaml b/example/Si-PBE/phono3py_disp.yaml index b736c863..967b9ae4 100644 --- a/example/Si-PBE/phono3py_disp.yaml +++ b/example/Si-PBE/phono3py_disp.yaml @@ -849,4 +849,4 @@ displacement_pairs: displacement_pair_info: number_of_singles: 1 - number_of_pairs: 110 \ No newline at end of file + number_of_pairs: 110 diff --git a/example/Si-PBEsol/FORCES_FC3 b/example/Si-PBEsol/FORCES_FC3 index ad46ce0b..963ff91b 100644 --- a/example/Si-PBEsol/FORCES_FC3 +++ b/example/Si-PBEsol/FORCES_FC3 @@ -1,4 +1,4 @@ -# File: 1 +# File: 1 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3968201400 0.0000000000 0.0000000000 0.0005878300 0.0000000000 0.0000000000 @@ -64,7 +64,7 @@ -0.0003760000 0.0009874300 -0.0009874300 -0.0014775900 0.0009712500 -0.0011918000 0.0006882300 0.0007423100 -0.0007584100 -# File: 2 +# File: 2 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 1 0.0212132034355964 0.0212132034355964 0.0000000000000000 -0.6772678900 -0.2819277000 -0.0358889800 @@ -131,7 +131,7 @@ 0.0000464900 0.0006116300 -0.0025198500 -0.0018160900 0.0013707700 -0.0027515600 0.0017720700 0.0018204600 -0.0018547700 -# File: 3 +# File: 3 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 1 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.1163652300 0.2806988700 0.0061513100 @@ -198,7 +198,7 @@ -0.0008199100 0.0013657300 0.0005330100 -0.0011352000 0.0005498300 0.0003556500 -0.0003131800 -0.0002539400 0.0002896400 -# File: 4 +# File: 4 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 2 0.0212132034355964 0.0212132034355964 0.0000000000000000 -0.3964039100 0.0009276500 0.0000337600 @@ -265,7 +265,7 @@ 0.1117584500 0.1131205300 -0.0911710900 -0.0004548000 0.0019931600 -0.0022553100 0.0003279600 0.0011691400 -0.0022945600 -# File: 5 +# File: 5 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 2 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.3972353300 -0.0009280600 -0.0000057100 @@ -332,7 +332,7 @@ -0.1221147600 -0.1207500000 0.1022652300 -0.0024204800 0.0000286000 -0.0001849800 0.0010493100 0.0002964800 0.0007646800 -# File: 6 +# File: 6 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 3 0.0212132034355964 0.0212132034355964 0.0000000000000000 -0.3958914300 0.0004157000 0.0000229300 @@ -399,7 +399,7 @@ 0.0006464300 0.0020121900 -0.0020474300 0.1106625200 0.1131050100 -0.0913683000 0.0011139600 0.0003857000 -0.0022942900 -# File: 7 +# File: 7 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 3 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.3977497000 -0.0004160400 0.0000051800 @@ -466,7 +466,7 @@ -0.0013180300 0.0000427700 0.0000157800 -0.1232211600 -0.1207674400 0.1020544100 0.0002429800 0.0011004000 0.0007644300 -# File: 8 +# File: 8 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 3 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3968203900 0.0000278800 0.0013129200 @@ -533,7 +533,7 @@ -0.0011163900 0.0002459000 0.0051490500 -0.0724609700 -0.0700235500 0.0971595300 -0.0003210400 -0.0004160600 -0.0022806600 -# File: 9 +# File: 9 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 4 0.0212132034355964 0.0212132034355964 0.0000000000000000 -0.3968876300 -0.0000693300 0.0000115000 @@ -600,7 +600,7 @@ -0.0007362400 0.0014161800 -0.0025251600 -0.0010537100 0.0006116500 -0.0027311800 0.1128203000 0.1128809000 -0.0909203700 -# File: 10 +# File: 10 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 4 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.3967475700 0.0000724300 0.0000190700 @@ -667,7 +667,7 @@ -0.0000142400 0.0005395400 0.0005371300 -0.0019208800 0.0013313900 0.0003344600 -0.1210479300 -0.1210000400 0.1024740800 -# File: 11 +# File: 11 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 4 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3968156800 0.0000303700 -0.0116038000 @@ -734,7 +734,7 @@ -0.0015371900 -0.0000160000 -0.0025086400 -0.0024877400 -0.0001889900 -0.0027123500 -0.0703073500 -0.0702668900 0.0975909800 -# File: 12 +# File: 12 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 7 0.0212132034355964 0.0212132034355964 0.0000000000000000 -0.4050146400 -0.0000691500 -0.0000064300 @@ -801,7 +801,7 @@ -0.0002384800 0.0011246300 -0.0020716000 -0.0017161900 0.0007312100 -0.0025890200 0.0016780500 0.0055644300 -0.0018076600 -# File: 13 +# File: 13 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 7 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.3886148600 0.0000702800 0.0000012200 @@ -868,7 +868,7 @@ -0.0005280300 0.0008352400 0.0000950800 -0.0012547600 0.0011947300 0.0002065900 -0.0002881700 -0.0040945700 0.0002556100 -# File: 14 +# File: 14 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 8 0.0212132034355964 0.0212132034355964 0.0000000000000000 -0.3963724100 0.0004475500 0.0000131500 @@ -935,7 +935,7 @@ 0.0044454200 0.0019837800 -0.0020355600 -0.0004812200 0.0057953700 -0.0022382200 0.0004486900 0.0005045100 -0.0021577900 -# File: 15 +# File: 15 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 8 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.3972681100 -0.0004471900 -0.0000021500 @@ -1002,7 +1002,7 @@ -0.0052118400 0.0000048600 0.0000254700 -0.0024603000 -0.0038683800 -0.0001805700 0.0009116500 0.0009644200 0.0006421200 -# File: 16 +# File: 16 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3939519800 0.0058183400 0.0055670600 @@ -1069,7 +1069,7 @@ -0.0011158200 0.0071295100 -0.0017236700 -0.0021824700 0.0016148900 -0.0018983100 -0.0000840200 0.0001823900 -0.0015351500 -# File: 17 +# File: 17 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3995693700 -0.0056732700 -0.0054537400 @@ -1136,7 +1136,7 @@ 0.0003523300 -0.0050800000 -0.0002632500 -0.0007213000 0.0002821600 -0.0004471400 0.0014498900 0.0013010900 0.0000075200 -# File: 18 +# File: 18 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4096762700 -0.0027672400 -0.0027672400 @@ -1203,7 +1203,7 @@ 0.0003150300 0.0002352300 -0.0002470100 0.0045852800 0.0002387800 -0.0004704200 0.0001221800 -0.0000216700 0.0000057500 -# File: 19 +# File: 19 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 9 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3840574800 0.0026527000 0.0026527000 @@ -1270,7 +1270,7 @@ -0.0010215900 0.0016873400 -0.0016892500 -0.0076171900 0.0017148000 -0.0019246100 0.0012551900 0.0015167100 -0.0015331800 -# File: 20 +# File: 20 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3965841300 0.0010517400 -0.0018379200 @@ -1337,7 +1337,7 @@ -0.0015335700 -0.0005359400 -0.0019966100 -0.0022513500 0.0004076500 -0.0019663500 -0.0000156900 0.0013874300 -0.0014644100 -# File: 21 +# File: 21 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3970558800 -0.0010481300 0.0018526200 @@ -1404,7 +1404,7 @@ 0.0008148100 0.0024666500 -0.0000159900 -0.0007144900 0.0015330300 -0.0004278200 0.0014437700 0.0000528000 -0.0000142700 -# File: 22 +# File: 22 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3968794600 -0.0002355700 -0.0002355700 @@ -1471,7 +1471,7 @@ -0.0018535900 -0.0002057500 -0.0000138000 -0.0020395200 0.0002080800 -0.0004291800 0.0067518800 0.0000166500 -0.0000310300 -# File: 23 +# File: 23 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 10 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3967852100 0.0002417800 0.0002417800 @@ -1538,7 +1538,7 @@ 0.0011463600 0.0021476500 -0.0019986700 -0.0009144400 0.0017446200 -0.0019649800 -0.0054512100 0.0014794600 -0.0014974700 -# File: 24 +# File: 24 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 11 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3942721300 0.0055232600 -0.0055693500 @@ -1605,7 +1605,7 @@ -0.0011499800 0.0004245700 -0.0017635200 -0.0026397000 -0.0005482000 -0.0022072200 -0.0000416200 0.0068803000 -0.0014963400 -# File: 25 +# File: 25 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 11 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3994511000 -0.0056719200 0.0056871700 @@ -1672,7 +1672,7 @@ 0.0003878200 0.0015493200 -0.0002221700 -0.0002819400 0.0024461600 -0.0002141500 0.0014056300 -0.0053204600 -0.0000317000 -# File: 26 +# File: 26 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 11 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4094040500 -0.0026590200 0.0026590200 @@ -1739,7 +1739,7 @@ -0.0009416200 0.0002241800 -0.0002241800 -0.0029449200 -0.0002196900 -0.0002196900 0.0013761300 -0.0000185400 -0.0000185400 -# File: 27 +# File: 27 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 11 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3841483200 0.0027636500 -0.0027636500 @@ -1806,7 +1806,7 @@ 0.0001909600 0.0017614800 -0.0017614800 0.0000339600 0.0021291800 -0.0022017700 0.0000443400 0.0014513300 -0.0014599500 -# File: 28 +# File: 28 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 12 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3965713400 0.0010774600 0.0018488900 @@ -1873,7 +1873,7 @@ -0.0010825200 0.0016309700 -0.0016914100 -0.0022139600 0.0071054400 -0.0019318800 -0.0004716000 -0.0007792000 -0.0017669400 -# File: 29 +# File: 29 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 12 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3970678900 -0.0010817900 -0.0018342900 @@ -1940,7 +1940,7 @@ 0.0003826600 0.0002992900 -0.0002457100 -0.0007528800 -0.0050880700 -0.0004633000 0.0018805300 0.0022197700 0.0002127400 -# File: 30 +# File: 30 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 12 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3968055600 -0.0002485000 0.0002485000 @@ -2007,7 +2007,7 @@ 0.0056869600 0.0002605900 -0.0002605900 -0.0007907600 0.0002139400 -0.0004468000 -0.0007907600 -0.0004468000 0.0002139400 -# File: 31 +# File: 31 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 12 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3968098400 0.0002423000 -0.0002423000 @@ -2074,7 +2074,7 @@ -0.0065142400 0.0017257200 -0.0017257200 -0.0021197300 0.0016763700 -0.0018990300 0.0022111400 0.0018986500 -0.0017684800 -# File: 32 +# File: 32 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3912195600 0.0028279300 0.0054555400 @@ -2141,7 +2141,7 @@ 0.0002656400 0.0002862400 -0.0016890300 0.0046556100 0.0002316900 -0.0019368100 0.0001290900 -0.0000268600 -0.0015301000 -# File: 33 +# File: 33 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4022598900 -0.0027286100 -0.0053310000 @@ -2208,7 +2208,7 @@ -0.0010619900 0.0017406700 -0.0002478100 -0.0075354300 0.0016990100 -0.0004580200 0.0012456800 0.0015011500 0.0000026100 -# File: 34 +# File: 34 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3994687700 -0.0127760000 -0.0027506100 @@ -2275,7 +2275,7 @@ -0.0011004300 0.0070552500 -0.0002603300 -0.0022238500 0.0016535300 -0.0004484400 -0.0000694700 0.0001870000 -0.0000080800 -# File: 35 +# File: 35 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3942633300 0.0126801700 0.0026584600 @@ -2342,7 +2342,7 @@ 0.0003603700 -0.0051557700 -0.0017261500 -0.0007833600 0.0003330800 -0.0018971100 0.0014562500 0.0012990700 -0.0015190500 -# File: 36 +# File: 36 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3913025800 0.0026982300 0.0055713200 @@ -2409,7 +2409,7 @@ -0.0011172800 0.0017446000 -0.0003033800 -0.0022495100 0.0017173300 -0.0004984200 -0.0000734500 0.0015063600 -0.0013129100 -# File: 37 +# File: 37 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.4022123900 -0.0025993400 -0.0054154600 @@ -2476,7 +2476,7 @@ 0.0003277600 0.0002820900 -0.0016269400 -0.0007572900 0.0002624200 -0.0018406900 0.0014602000 -0.0000321000 -0.0002026000 -# File: 38 +# File: 38 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3910727700 0.0025787300 -0.0056932700 @@ -2543,7 +2543,7 @@ -0.0018978800 -0.0001687600 -0.0019961700 -0.0020425100 0.0001951200 -0.0019656400 0.0068282400 -0.0000010700 -0.0014910300 -# File: 39 +# File: 39 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4026992700 -0.0026814200 0.0057988800 @@ -2610,7 +2610,7 @@ 0.0011020100 0.0021762000 -0.0000163700 -0.0009140200 0.0017362800 -0.0004283900 -0.0053761900 0.0014741000 -0.0000373600 -# File: 40 +# File: 40 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3995611300 -0.0126866900 0.0026337500 @@ -2677,7 +2677,7 @@ -0.0015659200 -0.0004928900 -0.0000141500 -0.0022390100 0.0004112000 -0.0004265700 -0.0000770100 0.0014263300 -0.0000135700 -# File: 41 +# File: 41 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3939515700 0.0127725200 -0.0027612100 @@ -2744,7 +2744,7 @@ 0.0007814900 0.0025119400 -0.0019984800 -0.0007057500 0.0015317400 -0.0019676600 0.0014017500 0.0001028200 -0.0014650400 -# File: 42 +# File: 42 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.4025581500 -0.0028185000 0.0059146900 @@ -2811,7 +2811,7 @@ -0.0013599000 0.0019795600 -0.0013599000 -0.0022392200 0.0017345700 -0.0017501200 -0.0000726800 0.0014863900 -0.0000726800 -# File: 43 +# File: 43 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.3911868900 0.0027150800 -0.0057777000 @@ -2878,7 +2878,7 @@ 0.0006137700 -0.0000098100 -0.0006209000 -0.0007054500 0.0001968400 -0.0006323400 0.0013966300 0.0000364600 -0.0013995100 -# File: 44 +# File: 44 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3957578500 0.0002274500 -0.0018267400 @@ -2945,7 +2945,7 @@ -0.0009382200 0.0002145700 -0.0017610700 -0.0029989000 -0.0001875700 -0.0022004400 0.0013316800 0.0000350700 -0.0014653000 -# File: 45 +# File: 45 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3978777000 -0.0002281400 0.0018408600 @@ -3012,7 +3012,7 @@ 0.0001853400 0.0017497100 -0.0002243400 -0.0000005100 0.0021623500 -0.0002207700 -0.0000001900 0.0015017300 -0.0000135900 -# File: 46 +# File: 46 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3970584800 -0.0000318200 -0.0002415400 @@ -3079,7 +3079,7 @@ -0.0011399000 0.0004271000 -0.0002240900 -0.0026680000 -0.0005064400 -0.0002201300 -0.0000368000 0.0068050900 -0.0000324700 -# File: 47 +# File: 47 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3965748200 0.0000071500 0.0002474000 @@ -3146,7 +3146,7 @@ 0.0003989800 0.0015490900 -0.0017614400 -0.0003200500 0.0024925400 -0.0022011000 0.0014248400 -0.0053955600 -0.0014958800 -# File: 48 +# File: 48 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3986710000 0.0002397000 0.0010777700 @@ -3213,7 +3213,7 @@ -0.0011390900 0.0017506800 -0.0015479900 -0.0024647200 0.0019577600 -0.0015665900 -0.0000541300 0.0015064000 -0.0000691200 -# File: 49 +# File: 49 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.3949538600 -0.0002400900 -0.0010741900 @@ -3280,7 +3280,7 @@ 0.0003980400 0.0002134600 -0.0004256000 -0.0004852800 -0.0000208000 -0.0008231000 0.0013923400 0.0000303700 -0.0014030900 -# File: 50 +# File: 50 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3957538500 0.0002575200 0.0018623500 @@ -3347,7 +3347,7 @@ 0.0057651900 0.0002479800 -0.0017238900 -0.0008339700 0.0002666500 -0.0018965600 -0.0008351500 -0.0004170400 -0.0017689100 -# File: 51 +# File: 51 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3978896800 -0.0002574400 -0.0018471800 @@ -3414,7 +3414,7 @@ -0.0064414000 0.0017154000 -0.0002624400 -0.0021658300 0.0017271400 -0.0004489800 0.0021669000 0.0019346300 0.0002144700 -# File: 52 +# File: 52 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3970639900 -0.0000139500 0.0002432500 @@ -3481,7 +3481,7 @@ -0.0011329900 0.0016764500 -0.0002466300 -0.0022029900 0.0070319200 -0.0004637600 -0.0005058800 -0.0007372000 0.0002124300 -# File: 53 +# File: 53 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3965817100 0.0000384800 -0.0002364200 @@ -3548,7 +3548,7 @@ 0.0003294700 0.0003431500 -0.0016904400 -0.0007406600 -0.0051656500 -0.0019314200 0.0018493400 0.0022663500 -0.0017666800 -# File: 54 +# File: 54 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3949971800 -0.0002435100 0.0010573300 @@ -3615,7 +3615,7 @@ -0.0011350900 0.0017299500 -0.0002985900 -0.0022181900 0.0017312900 -0.0005033900 -0.0002985900 0.0017299500 -0.0011350900 -# File: 55 +# File: 55 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.3986565100 0.0002437500 -0.0010526900 @@ -3682,7 +3682,7 @@ 0.0003317500 0.0002827400 -0.0016319700 -0.0007749800 0.0002623800 -0.0018356300 0.0016801100 -0.0002501300 -0.0003876000 -# File: 56 +# File: 56 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 33 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3960466400 -0.0005514700 0.0007511800 @@ -3749,7 +3749,7 @@ 0.0014612500 0.0020547600 -0.0007450400 0.0003737100 0.0020338600 -0.0014332700 -0.0011628000 0.0018062700 -0.0005156800 -# File: 57 +# File: 57 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 33 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3976044600 0.0005523200 -0.0007620200 @@ -3816,7 +3816,7 @@ -0.0022271400 -0.0000759100 -0.0012301000 -0.0033142800 -0.0000959500 -0.0009505800 0.0025244000 -0.0003252900 -0.0010008000 -# File: 58 +# File: 58 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 33 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3973832200 0.0007730100 0.0007730100 @@ -3883,7 +3883,7 @@ 0.0006868500 0.0028392200 -0.0012303600 -0.0004113300 0.0028070900 -0.0009506800 0.0017514700 -0.0011097900 -0.0005153300 -# File: 59 +# File: 59 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 33 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3962559000 -0.0007839200 -0.0007839200 @@ -3950,7 +3950,7 @@ -0.0014424000 -0.0008500600 -0.0007447900 -0.0025399700 -0.0008793300 -0.0014333300 -0.0003791400 0.0025800100 -0.0010013400 -# File: 60 +# File: 60 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 34 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3960474100 0.0006911400 0.0007209100 @@ -4017,7 +4017,7 @@ -0.0022137400 0.0020558900 -0.0012289800 -0.0033275400 0.0020334800 -0.0009482100 0.0025408700 0.0018076200 -0.0009994900 -# File: 61 +# File: 61 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 34 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3975352400 -0.0006467500 -0.0006829900 @@ -4084,7 +4084,7 @@ 0.0014767300 -0.0000775100 -0.0007459100 0.0003580500 -0.0000957300 -0.0014349500 -0.0011502200 -0.0003267200 -0.0005175100 -# File: 62 +# File: 62 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 34 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3906880500 0.0007307200 0.0007307200 @@ -4151,7 +4151,7 @@ 0.0006876000 -0.0008504400 -0.0012322800 -0.0004124500 -0.0008775100 -0.0009489100 0.0017561600 0.0025834700 -0.0005201800 -# File: 63 +# File: 63 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 34 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4030255700 -0.0007421700 -0.0007421700 @@ -4218,7 +4218,7 @@ -0.0014352900 0.0028393000 -0.0007422000 -0.0025465100 0.0028048100 -0.0014342400 -0.0003758000 -0.0011128400 -0.0009969400 -# File: 64 +# File: 64 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3961737000 0.0007608300 0.0007064700 @@ -4285,7 +4285,7 @@ 0.0006869100 -0.0008643700 -0.0007447400 -0.0004121500 -0.0008667400 -0.0014358000 0.0017510000 0.0025938900 -0.0009986600 -# File: 65 +# File: 65 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3974171700 -0.0007093400 -0.0006649700 @@ -4352,7 +4352,7 @@ -0.0014422600 0.0028247900 -0.0012299900 -0.0025392100 0.0028234400 -0.0009471900 -0.0003789200 -0.0010944000 -0.0005185200 -# File: 66 +# File: 66 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3961433300 0.0060622000 0.0007220800 @@ -4419,7 +4419,7 @@ -0.0022283500 0.0020495000 -0.0007472100 -0.0033182900 0.0020399000 -0.0014323700 0.0025234800 0.0018086300 -0.0005108600 -# File: 67 +# File: 67 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3975026300 -0.0061376400 -0.0007293900 @@ -4486,7 +4486,7 @@ 0.0014622900 -0.0000786500 -0.0012274900 0.0003778600 -0.0000942100 -0.0009508600 -0.0011616400 -0.0003196100 -0.0010063200 -# File: 68 +# File: 68 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3961125800 0.0007366000 0.0006512200 @@ -4553,7 +4553,7 @@ -0.0006203200 0.0007414600 -0.0009974600 -0.0012321100 0.0012175300 -0.0011995500 0.0009286100 0.0005039100 -0.0007920700 -# File: 69 +# File: 69 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.3974849600 -0.0006850500 -0.0006030900 @@ -4620,7 +4620,7 @@ -0.0001374800 0.0012272100 -0.0009528800 -0.0017169200 0.0007305900 -0.0011594300 0.0004412000 0.0009873200 -0.0007494500 -# File: 70 +# File: 70 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3983412100 0.0012465100 0.0009906200 @@ -4687,7 +4687,7 @@ 0.0006894700 0.0028241900 -0.0007455800 -0.0004142700 0.0028222400 -0.0014325600 0.0017550100 -0.0010964100 -0.0009985600 -# File: 71 +# File: 71 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3952542700 -0.0012124900 -0.0010290400 @@ -4754,7 +4754,7 @@ -0.0014370900 -0.0008636900 -0.0012297100 -0.0025449300 -0.0008658100 -0.0009514600 -0.0003748500 0.0025960700 -0.0005177300 -# File: 72 +# File: 72 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3956611600 -0.0014223600 0.0009709800 @@ -4821,7 +4821,7 @@ 0.0014767500 0.0020501100 -0.0012302400 0.0003607500 0.0020380100 -0.0009486600 -0.0011486200 0.0018093900 -0.0010012400 -# File: 73 +# File: 73 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3979468600 0.0014677600 -0.0010099800 @@ -4888,7 +4888,7 @@ -0.0022135500 -0.0000793100 -0.0007448500 -0.0033301500 -0.0000922000 -0.0014350500 0.0025393600 -0.0003204400 -0.0005152800 -# File: 74 +# File: 74 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3957947400 0.0009494800 -0.0003788600 @@ -4955,7 +4955,7 @@ -0.0006146600 0.0012267600 -0.0010249800 -0.0012401100 0.0007324300 -0.0012281200 0.0009333200 0.0009868900 -0.0007684300 -# File: 75 +# File: 75 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.3978485800 -0.0009568600 0.0003728800 @@ -5022,7 +5022,7 @@ -0.0001307100 0.0007419500 -0.0009746000 -0.0017211600 0.0012155700 -0.0011800900 0.0004491400 0.0005042700 -0.0007237000 -# File: 76 +# File: 76 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 39 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3958428300 -0.0014597800 0.0011913500 @@ -5089,7 +5089,7 @@ 0.0051363000 0.0065841100 0.0016759800 0.0041531900 0.0067145400 -0.0039459300 -0.0049390600 0.0064864900 0.0020007300 -# File: 77 +# File: 77 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 39 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3978331200 0.0015031600 -0.0011598500 @@ -5156,7 +5156,7 @@ -0.0060033500 -0.0047559900 -0.0037523000 -0.0069926400 -0.0046258300 0.0014612500 0.0061995600 -0.0048546800 -0.0034162600 -# File: 78 +# File: 78 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 39 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3971898300 0.0009842300 0.0009842300 @@ -5223,7 +5223,7 @@ 0.0052211100 0.0064986700 0.0016718500 0.0042657900 0.0065951800 -0.0039506000 0.0062829300 -0.0047702600 -0.0034153900 -# File: 79 +# File: 79 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 39 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3964552900 -0.0009894900 -0.0009894900 @@ -5290,7 +5290,7 @@ -0.0061194500 -0.0046397000 -0.0037478200 -0.0070741500 -0.0045377600 0.0014659400 -0.0050535900 0.0063708400 0.0019997700 -# File: 80 +# File: 80 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 40 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3259103400 0.1011996400 0.0731806400 @@ -5357,7 +5357,7 @@ -0.0058795400 0.0065857300 -0.0036704000 -0.0071339400 0.0067334700 0.0015759200 0.0063148700 0.0065112900 -0.0035701800 -# File: 81 +# File: 81 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 40 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4734658100 -0.1040813600 -0.0791169700 @@ -5424,7 +5424,7 @@ 0.0052433600 -0.0047589300 0.0017964300 0.0040636400 -0.0046444700 -0.0038603700 -0.0048236300 -0.0048780500 0.0019509300 -# File: 82 +# File: 82 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 40 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.2984766100 0.0710577600 0.0710577600 @@ -5491,7 +5491,7 @@ 0.0053588800 -0.0046358300 0.0017625400 0.0041196900 -0.0045453800 -0.0038215100 0.0063960300 0.0063885700 -0.0034945400 -# File: 83 +# File: 83 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 40 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4976123500 -0.0766133800 -0.0766133800 @@ -5558,7 +5558,7 @@ -0.0059625600 0.0064947800 -0.0036361700 -0.0072202000 0.0066026400 0.0015382500 -0.0048723100 -0.0047884200 0.0018754700 -# File: 84 +# File: 84 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3982967000 -0.0009912600 0.0011047900 @@ -5625,7 +5625,7 @@ -0.0003861000 0.0012296000 -0.0007420400 -0.0142556800 0.0037332000 -0.0039533800 0.0006523100 0.0009814200 -0.0009941000 -# File: 85 +# File: 85 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3953871700 0.0009543800 -0.0011362300 @@ -5692,7 +5692,7 @@ -0.0003409200 0.0007513500 -0.0012266200 0.0112097700 -0.0016815100 0.0014600600 0.0006993500 0.0004973300 -0.0005166000 -# File: 86 +# File: 86 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3977680500 -0.0003737100 -0.0010249400 @@ -5759,7 +5759,7 @@ -0.0006158000 0.0020540300 -0.0028240100 -0.0041367100 0.0065638900 -0.0067019100 0.0004458700 0.0018036100 0.0010909200 -# File: 87 +# File: 87 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3958649400 0.0003677000 0.0010280600 @@ -5826,7 +5826,7 @@ -0.0001354800 -0.0000752000 0.0008634600 0.0012823500 -0.0047689200 0.0044337500 0.0009299700 -0.0003226500 -0.0025931000 -# File: 88 +# File: 88 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3956283600 -0.0010072400 -0.0015755800 @@ -5893,7 +5893,7 @@ -0.0006164800 -0.0008500300 0.0000787900 0.0012815900 -0.0046546400 0.0045491100 0.0009292800 0.0025766100 0.0003078600 -# File: 89 +# File: 89 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.3980447900 0.0009709500 0.0015326000 @@ -5960,7 +5960,7 @@ -0.0001347700 0.0028393800 -0.0020496500 -0.0041361100 0.0064811000 -0.0067859400 0.0004465800 -0.0011061500 -0.0018207500 -# File: 90 +# File: 90 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3961290100 -0.0007461200 0.0007035400 @@ -6027,7 +6027,7 @@ -0.0130642100 0.0036392300 0.0016600700 -0.0015134800 0.0012098800 -0.0014300000 -0.0120873000 0.0035048700 -0.0035231100 -# File: 91 +# File: 91 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3975508200 0.0007802300 -0.0007553200 @@ -6094,7 +6094,7 @@ 0.0124038900 -0.0017737800 -0.0037449400 -0.0014663200 0.0007260400 -0.0009473900 0.0133726000 -0.0019103800 0.0018967700 -# File: 92 +# File: 92 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3975983900 0.0007250100 -0.0007806300 @@ -6161,7 +6161,7 @@ -0.0031411700 0.0067321800 0.0046355100 -0.0017199600 0.0020321600 0.0006568900 -0.0019710500 0.0063380300 -0.0062707700 -# File: 93 +# File: 93 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3960745200 -0.0006841200 0.0007287500 @@ -6228,7 +6228,7 @@ 0.0022884800 -0.0046101200 -0.0064947300 -0.0012356000 -0.0000941900 -0.0030259800 0.0034486000 -0.0049998600 0.0048693800 -# File: 94 +# File: 94 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3960282200 -0.0007435200 0.0061319300 @@ -6295,7 +6295,7 @@ -0.0031380800 0.0066111300 0.0047564300 -0.0012389000 0.0028057700 -0.0001255700 0.0034507000 -0.0048853100 0.0049856600 -# File: 95 +# File: 95 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.3975945300 0.0007276400 -0.0060560800 @@ -6362,7 +6362,7 @@ 0.0022851100 -0.0045208400 -0.0065847600 -0.0017166900 -0.0008783300 -0.0022540700 -0.0019734900 0.0062546000 -0.0063553200 -# File: 96 +# File: 96 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 51 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4571417700 0.0903113000 -0.0584047600 @@ -6429,7 +6429,7 @@ -0.0006199600 0.0020587400 0.0008626400 -0.0042382900 0.0067158000 0.0044205900 0.0004377500 0.0018017100 -0.0025776600 -# File: 97 +# File: 97 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 51 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3313446300 -0.0929414100 0.0633816100 @@ -6496,7 +6496,7 @@ -0.0001322600 -0.0000878000 -0.0028235700 0.0011829100 -0.0046276200 -0.0066884100 0.0009391500 -0.0003134200 0.0010745000 -# File: 98 +# File: 98 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 51 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3012259200 -0.0654834700 0.0654834700 @@ -6563,7 +6563,7 @@ -0.0004016400 0.0012272000 -0.0012272000 -0.0141716700 0.0036370400 0.0014766100 0.0006679400 0.0009776600 -0.0005061300 -# File: 99 +# File: 99 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 51 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4893953100 0.0601783600 -0.0601783600 @@ -6630,7 +6630,7 @@ -0.0003750300 0.0007416000 -0.0007416000 0.0113051700 -0.0018040000 -0.0039688600 0.0007326300 0.0005130700 -0.0010050100 -# File: 100 +# File: 100 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 52 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3977851900 -0.0014959500 -0.0011912300 @@ -6697,7 +6697,7 @@ -0.0030341100 0.0065870500 -0.0064997600 -0.0017166400 0.0020374900 -0.0030292900 -0.0020709400 0.0064873400 0.0048654500 -# File: 101 +# File: 101 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 52 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3958154300 0.0015410800 0.0011570700 @@ -6764,7 +6764,7 @@ 0.0023835100 -0.0047589600 0.0046404200 -0.0012382300 -0.0000916700 0.0006601800 0.0033463000 -0.0048550600 -0.0062665500 -# File: 102 +# File: 102 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 52 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3971955700 -0.0009945400 0.0009945400 @@ -6831,7 +6831,7 @@ -0.0131484300 0.0037489900 -0.0037489900 -0.0014878100 0.0012141900 -0.0009478800 -0.0120006500 0.0034003000 0.0018962100 -# File: 103 +# File: 103 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 52 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3964374700 0.0009893800 -0.0009893800 @@ -6898,7 +6898,7 @@ 0.0123058700 -0.0016643900 0.0016643900 -0.0014426300 0.0007341800 -0.0014293800 0.0134673900 -0.0020249000 -0.0035227600 -# File: 104 +# File: 104 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 53 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3975639300 0.0006856700 -0.0007647500 @@ -6965,7 +6965,7 @@ -0.0001338000 0.0020517400 0.0008476000 0.0011797800 0.0065625300 0.0043187600 0.0009275700 0.0018060100 -0.0026144500 -# File: 105 +# File: 105 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 53 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3961222400 -0.0006409100 0.0007267500 @@ -7032,7 +7032,7 @@ -0.0006182500 -0.0000728200 -0.0028369600 -0.0042363200 -0.0047672600 -0.0068177700 0.0004490500 -0.0003249000 0.0010833000 -# File: 106 +# File: 106 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 53 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3907636100 -0.0007364400 0.0007364400 @@ -7099,7 +7099,7 @@ -0.0004116000 0.0007497500 -0.0007497500 -0.0141648000 -0.0016873900 -0.0038507500 0.0006760000 0.0004967400 -0.0009949100 -# File: 107 +# File: 107 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 53 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4027991200 0.0007246700 -0.0007246700 @@ -7166,7 +7166,7 @@ -0.0003647100 0.0012310600 -0.0012310600 0.0112994900 0.0037392300 0.0015765200 0.0007248500 0.0009818600 -0.0005281800 -# File: 108 +# File: 108 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 54 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3975728200 -0.0005715000 -0.0007755800 @@ -7233,7 +7233,7 @@ 0.0023849800 0.0067329400 -0.0066149700 -0.0012355600 0.0020327400 -0.0030428100 0.0033458600 0.0063346900 0.0047515800 -# File: 109 +# File: 109 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 54 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3960568400 0.0005730200 0.0007858600 @@ -7300,7 +7300,7 @@ -0.0030356600 -0.0046112600 0.0045244600 -0.0017194500 -0.0000949000 0.0006448100 -0.0020706100 -0.0049964900 -0.0063836800 -# File: 110 +# File: 110 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 54 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3973817100 -0.0007631700 0.0007631700 @@ -7367,7 +7367,7 @@ -0.0131488400 -0.0017770900 0.0017770900 -0.0014875200 0.0007249800 -0.0014376700 -0.0119935800 -0.0019169100 -0.0034188000 -# File: 111 +# File: 111 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 54 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3962594500 0.0007529500 -0.0007529500 diff --git a/example/Si-PBEsol/POSCAR-unitcell b/example/Si-PBEsol/POSCAR-unitcell index 54a20471..0773cbdb 100644 --- a/example/Si-PBEsol/POSCAR-unitcell +++ b/example/Si-PBEsol/POSCAR-unitcell @@ -13,4 +13,4 @@ Direct 0.1250000000000000 0.1250000000000000 0.1250000000000000 0.1250000000000000 0.6250000000000000 0.6250000000000000 0.6250000000000000 0.1250000000000000 0.6250000000000000 - 0.6250000000000000 0.6250000000000000 0.1250000000000000 \ No newline at end of file + 0.6250000000000000 0.6250000000000000 0.1250000000000000 diff --git a/example/Si-PBEsol/Si.py b/example/Si-PBEsol/Si.py index f6dc1954..6e359605 100644 --- a/example/Si-PBEsol/Si.py +++ b/example/Si-PBEsol/Si.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python - +"""Example to run thermal conductivity of Si.""" import numpy as np from phonopy.interface.vasp import read_vasp from phono3py import Phono3py @@ -11,24 +10,20 @@ def run_thermal_conductivity(): ph3 = phono3py.load("phono3py_disp.yaml", log_level=2) ph3.mesh_numbers = [11, 11, 11] ph3.init_phph_interaction() - ph3.run_thermal_conductivity( - temperatures=range(0, 1001, 10), - write_kappa=True) + ph3.run_thermal_conductivity(temperatures=range(0, 1001, 10), write_kappa=True) # Conductivity_RTA object - cond_rta = ph3.thermal_conductivity + print(ph3.thermal_conductivity.kappa) def create_supercells_with_displacements(): """Create supercells with displacements.""" cell = read_vasp("POSCAR-unitcell") - ph3 = Phono3py(cell, - np.diag([2, 2, 2]), - primitive_matrix='F') + ph3 = Phono3py(cell, np.diag([2, 2, 2]), primitive_matrix="F") ph3.generate_displacements(distance=0.03) - scells_with_disps = ph3.supercells_with_displacements + print(ph3.supercells_with_displacements) # List of PhonopyAtoms print(ph3.displacements.shape) # (supercells, atoms, xyz) -if __name__ == '__main__': +if __name__ == "__main__": create_supercells_with_displacements() run_thermal_conductivity() diff --git a/example/Si-PBEsol/phono3py_disp.yaml b/example/Si-PBEsol/phono3py_disp.yaml index bca67284..ad71d0cf 100644 --- a/example/Si-PBEsol/phono3py_disp.yaml +++ b/example/Si-PBEsol/phono3py_disp.yaml @@ -849,4 +849,4 @@ displacement_pairs: displacement_pair_info: number_of_singles: 1 - number_of_pairs: 110 \ No newline at end of file + number_of_pairs: 110 diff --git a/example/Si-QE/FORCES_FC3 b/example/Si-QE/FORCES_FC3 index fb7ea849..7da51a61 100644 --- a/example/Si-QE/FORCES_FC3 +++ b/example/Si-QE/FORCES_FC3 @@ -1,4 +1,4 @@ -# File: 1 +# File: 1 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0158902702 0.0000000000 0.0000000000 0.0000216298 0.0000000000 0.0000000000 @@ -64,7 +64,7 @@ -0.0000126802 0.0000380200 -0.0000380200 -0.0000583502 0.0000373600 -0.0000513800 0.0000277798 0.0000267700 -0.0000290700 -# File: 2 +# File: 2 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 1 0.0424264068711929 0.0424264068711929 0.0000000000000000 -0.0270710495 -0.0113236900 -0.0014670197 @@ -131,7 +131,7 @@ 0.0000046605 0.0000224300 -0.0001005497 -0.0000734495 0.0000541800 -0.0001154697 0.0000694705 0.0000692100 -0.0000708997 -# File: 3 +# File: 3 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 1 -0.0424264068711929 -0.0424264068711929 0.0000000000000000 -0.0046710003 0.0112507700 0.0002498402 @@ -198,7 +198,7 @@ -0.0000318103 0.0000541100 0.0000248102 -0.0000434103 0.0000192100 0.0000132002 -0.0000103603 -0.0000111000 0.0000108602 -# File: 4 +# File: 4 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 2 0.0424264068711929 0.0424264068711929 0.0000000000000000 -0.0158746402 0.0000386706 0.0000013500 @@ -265,7 +265,7 @@ 0.0043645098 0.0044150006 -0.0034451700 -0.0000191302 0.0000767706 -0.0000924600 0.0000132198 0.0000439206 -0.0000928600 -# File: 5 +# File: 5 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 2 -0.0424264068711929 -0.0424264068711929 0.0000000000000000 -0.0159077603 -0.0000386200 -0.0000004803 @@ -332,7 +332,7 @@ -0.0047851503 -0.0047353000 0.0039052197 -0.0000941703 0.0000009700 -0.0000130003 0.0000429197 0.0000086000 0.0000342297 -# File: 6 +# File: 6 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 3 0.0424264068711929 0.0424264068711929 0.0000000000000000 -0.0158514405 0.0000162498 0.0000008102 @@ -399,7 +399,7 @@ 0.0000269895 0.0000775498 -0.0000786198 0.0043180995 0.0044139398 -0.0034587598 0.0000462495 0.0000118398 -0.0000923598 -# File: 7 +# File: 7 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 3 -0.0424264068711929 -0.0424264068711929 0.0000000000000000 -0.0159296302 -0.0000167394 -0.0000005900 @@ -466,7 +466,7 @@ -0.0000486902 0.0000016106 -0.0000002900 -0.0048315102 -0.0047351394 0.0038910800 0.0000096998 0.0000419306 0.0000334700 -# File: 8 +# File: 8 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 3 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0158899895 0.0000012897 0.0000542705 @@ -533,7 +533,7 @@ -0.0000400695 0.0000106597 0.0002186905 -0.0027637395 -0.0026677803 0.0038780305 -0.0000099995 -0.0000229703 -0.0000886895 -# File: 9 +# File: 9 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 4 0.0424264068711929 0.0424264068711929 0.0000000000000000 -0.0158951398 -0.0000039597 0.0000001600 @@ -600,7 +600,7 @@ -0.0000275298 0.0000560703 -0.0001011600 -0.0000403798 0.0000221303 -0.0001145800 0.0044046202 0.0044034403 -0.0034348800 -# File: 10 +# File: 10 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 4 -0.0424264068711929 -0.0424264068711929 0.0000000000000000 -0.0158851897 0.0000054505 0.0000003898 @@ -667,7 +667,7 @@ 0.0000028603 0.0000197605 0.0000240498 -0.0000773897 0.0000518505 0.0000103098 -0.0047442097 -0.0047468095 0.0039118198 -# File: 11 +# File: 11 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 4 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0158909398 0.0000012105 -0.0004742191 @@ -734,7 +734,7 @@ -0.0000618798 -0.0000011895 -0.0000977391 -0.0000982698 -0.0000122095 -0.0001109491 -0.0026761598 -0.0026785695 0.0039005609 -# File: 12 +# File: 12 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 7 0.0424264068711929 0.0424264068711929 0.0000000000000000 -0.0162249700 -0.0000055000 0.0000000200 @@ -801,7 +801,7 @@ -0.0000061800 0.0000442900 -0.0000805700 -0.0000641600 0.0000316500 -0.0001040300 0.0000667400 0.0002265900 -0.0000669500 -# File: 13 +# File: 13 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 7 -0.0424264068711929 -0.0424264068711929 0.0000000000000000 -0.0155550398 0.0000049203 -0.0000002495 @@ -868,7 +868,7 @@ -0.0000193598 0.0000309703 0.0000054005 -0.0000529898 0.0000425703 0.0000019805 -0.0000102098 -0.0001737397 0.0000082405 -# File: 14 +# File: 14 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 8 0.0424264068711929 0.0424264068711929 0.0000000000000000 -0.0158733302 0.0000170794 0.0000001997 @@ -935,7 +935,7 @@ 0.0001875598 0.0000769994 -0.0000762903 -0.0000195402 0.0002373494 -0.0000902003 0.0000224498 0.0000205994 -0.0000825203 -# File: 15 +# File: 15 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 8 -0.0424264068711929 -0.0424264068711929 0.0000000000000000 -0.0159075898 -0.0000174308 -0.0000000403 @@ -1002,7 +1002,7 @@ -0.0002124098 -0.0000009008 -0.0000003703 -0.0000978698 -0.0001627808 -0.0000136703 0.0000341702 0.0000324092 0.0000247697 -# File: 16 +# File: 16 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0157717697 0.0002409398 0.0002297398 @@ -1069,7 +1069,7 @@ -0.0000401997 0.0002944898 -0.0000655002 -0.0000855997 0.0000635698 -0.0000762302 -0.0000027597 0.0000053298 -0.0000597102 -# File: 17 +# File: 17 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0160026598 -0.0002341200 -0.0002248905 @@ -1136,7 +1136,7 @@ 0.0000148102 -0.0002146200 -0.0000113505 -0.0000287698 0.0000093500 -0.0000237805 0.0000585902 0.0000485100 0.0000008595 -# File: 18 +# File: 18 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0164229508 -0.0001147202 -0.0001147202 @@ -1203,7 +1203,7 @@ 0.0000156692 0.0000094798 -0.0000110102 0.0001941892 0.0000092098 -0.0000239502 0.0000067992 -0.0000042102 0.0000021798 -# File: 19 +# File: 19 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 9 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0153630698 0.0001094202 0.0001094202 @@ -1270,7 +1270,7 @@ -0.0000386098 0.0000641702 -0.0000626498 -0.0003150098 0.0000658702 -0.0000793498 0.0000500502 0.0000582902 -0.0000603198 -# File: 20 +# File: 20 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0158817500 0.0000427506 -0.0000759803 @@ -1337,7 +1337,7 @@ -0.0000621900 -0.0000230694 -0.0000765003 -0.0000901000 0.0000159406 -0.0000824303 0.0000019800 0.0000532206 -0.0000537003 -# File: 21 +# File: 21 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0158999998 -0.0000424597 0.0000776603 @@ -1404,7 +1404,7 @@ 0.0000389502 0.0000968803 -0.0000000497 -0.0000275098 0.0000588703 -0.0000195997 0.0000566702 -0.0000020897 -0.0000018397 -# File: 22 +# File: 22 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0158926795 -0.0000094397 -0.0000094397 @@ -1471,7 +1471,7 @@ -0.0000709995 -0.0000141997 -0.0000007897 -0.0000801195 0.0000065003 -0.0000204997 0.0002809105 -0.0000003397 -0.0000008097 -# File: 23 +# File: 23 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 10 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0158882491 0.0000091600 0.0000091600 @@ -1538,7 +1538,7 @@ 0.0000474609 0.0000884500 -0.0000768000 -0.0000370891 0.0000688900 -0.0000836600 -0.0002278391 0.0000557100 -0.0000577700 -# File: 24 +# File: 24 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 11 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0157852403 0.0002281900 -0.0002298800 @@ -1605,7 +1605,7 @@ -0.0000440803 0.0000164000 -0.0000689000 -0.0001091303 -0.0000238000 -0.0000908300 0.0000011097 0.0002828700 -0.0000569600 -# File: 25 +# File: 25 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 11 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0159987202 -0.0002350997 0.0002348594 @@ -1672,7 +1672,7 @@ 0.0000185298 0.0000596503 -0.0000065006 -0.0000062802 0.0000959003 -0.0000140506 0.0000547798 -0.0002261997 -0.0000011006 -# File: 26 +# File: 26 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 11 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0164094797 -0.0001098602 0.0001099698 @@ -1739,7 +1739,7 @@ -0.0000333597 0.0000075898 -0.0000071502 -0.0001170497 -0.0000137102 -0.0000139202 0.0000567503 -0.0000022802 -0.0000015402 -# File: 27 +# File: 27 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 11 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0153672202 0.0001140995 -0.0001140995 @@ -1806,7 +1806,7 @@ 0.0000094498 0.0000692195 -0.0000692195 0.0000013598 0.0000873295 -0.0000900395 0.0000020098 0.0000533495 -0.0000535095 -# File: 28 +# File: 28 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 12 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0158801602 0.0000428203 0.0000776202 @@ -1873,7 +1873,7 @@ -0.0000400502 0.0000642103 -0.0000621998 -0.0000852602 0.0002933403 -0.0000787898 -0.0000230102 -0.0000337997 -0.0000673498 -# File: 29 +# File: 29 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 12 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0159006098 -0.0000436200 -0.0000759900 @@ -1940,7 +1940,7 @@ 0.0000160602 0.0000095100 -0.0000108800 -0.0000313798 -0.0002151000 -0.0000234800 0.0000801202 0.0000852400 0.0000080400 -# File: 30 +# File: 30 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 12 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0158883897 -0.0000101408 0.0000098800 @@ -2007,7 +2007,7 @@ 0.0002403703 0.0000105392 -0.0000099400 -0.0000297997 0.0000092192 -0.0000244000 -0.0000307697 -0.0000250308 0.0000086600 -# File: 31 +# File: 31 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 12 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0158923205 0.0000089098 -0.0000089098 @@ -2074,7 +2074,7 @@ -0.0002676605 0.0000652898 -0.0000652898 -0.0000855005 0.0000642798 -0.0000764098 0.0000895295 0.0000769698 -0.0000675598 -# File: 32 +# File: 32 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0156590200 0.0001166398 0.0002251303 @@ -2141,7 +2141,7 @@ 0.0000137100 0.0000111298 -0.0000625997 0.0001976800 0.0000100198 -0.0000790397 0.0000065000 -0.0000039102 -0.0000598397 -# File: 33 +# File: 33 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 17 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0161157198 -0.0001126798 -0.0002199098 @@ -2208,7 +2208,7 @@ -0.0000403198 0.0000659502 -0.0000116198 -0.0003113298 0.0000649602 -0.0000236098 0.0000500202 0.0000577702 0.0000018502 -# File: 34 +# File: 34 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0160000398 -0.0005282602 -0.0001139297 @@ -2275,7 +2275,7 @@ -0.0000398898 0.0002910198 -0.0000100197 -0.0000863398 0.0000655898 -0.0000248597 -0.0000027498 0.0000052598 0.0000017403 -# File: 35 +# File: 35 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0157851900 0.0005238703 0.0001091300 @@ -2342,7 +2342,7 @@ 0.0000158500 -0.0002188697 -0.0000662200 -0.0000330200 0.0000112503 -0.0000773400 0.0000597400 0.0000484403 -0.0000600000 -# File: 36 +# File: 36 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0156627006 0.0001107600 0.0002300900 @@ -2409,7 +2409,7 @@ -0.0000388306 0.0000666900 -0.0000098300 -0.0000882706 0.0000641500 -0.0000236200 -0.0000023806 0.0000576100 -0.0000507400 -# File: 37 +# File: 37 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 0.0000000000000000 -0.0600000000000000 -0.0161128000 -0.0001079405 -0.0002234609 @@ -2476,7 +2476,7 @@ 0.0000128300 0.0000111595 -0.0000645709 -0.0000318700 0.0000123795 -0.0000785809 0.0000597800 -0.0000045005 -0.0000081409 -# File: 38 +# File: 38 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0156525506 0.0001068695 -0.0002356298 @@ -2543,7 +2543,7 @@ -0.0000728806 -0.0000128605 -0.0000764598 -0.0000804206 0.0000061995 -0.0000825398 0.0002847694 -0.0000005805 -0.0000564198 -# File: 39 +# File: 39 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 18 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0161342800 -0.0001111600 0.0002403300 @@ -2610,7 +2610,7 @@ 0.0000459600 0.0000892700 -0.0000003400 -0.0000367000 0.0000688800 -0.0000200100 -0.0002249500 0.0000547800 -0.0000015100 -# File: 40 +# File: 40 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0160033698 -0.0005230203 0.0001083900 @@ -2677,7 +2677,7 @@ -0.0000641398 -0.0000206503 -0.0000008600 -0.0000893098 0.0000159697 -0.0000207300 -0.0000010898 0.0000547897 -0.0000025500 -# File: 41 +# File: 41 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0157721903 0.0005281095 -0.0001144397 @@ -2744,7 +2744,7 @@ 0.0000373997 0.0000986495 -0.0000769597 -0.0000269503 0.0000588995 -0.0000822397 0.0000547197 0.0000003395 -0.0000534397 -# File: 42 +# File: 42 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0161274102 -0.0001166997 0.0002454498 @@ -2811,7 +2811,7 @@ -0.0000499102 0.0000770003 -0.0000499102 -0.0000900002 0.0000680503 -0.0000725002 -0.0000001702 0.0000541903 -0.0000001702 -# File: 43 +# File: 43 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 0.0000000000000000 -0.0600000000000000 -0.0156582102 0.0001118602 -0.0002393603 @@ -2878,7 +2878,7 @@ 0.0000259998 -0.0000006298 -0.0000245703 -0.0000276702 0.0000062602 -0.0000295303 0.0000552298 0.0000017702 -0.0000545703 -# File: 44 +# File: 44 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0158486600 0.0000083603 -0.0000759200 @@ -2945,7 +2945,7 @@ -0.0000334000 0.0000069103 -0.0000684600 -0.0001196000 -0.0000125397 -0.0000897700 0.0000551400 -0.0000001097 -0.0000536300 -# File: 45 +# File: 45 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 19 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0159321598 -0.0000091900 0.0000769105 @@ -3012,7 +3012,7 @@ 0.0000084902 0.0000689400 -0.0000066895 0.0000011102 0.0000887800 -0.0000146295 -0.0000011498 0.0000553800 -0.0000022895 -# File: 46 +# File: 46 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0159000400 -0.0000004698 -0.0000097292 @@ -3079,7 +3079,7 @@ -0.0000434500 0.0000162502 -0.0000069292 -0.0001103100 -0.0000211098 -0.0000147192 0.0000009600 0.0002796902 -0.0000010192 -# File: 47 +# File: 47 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0158803300 -0.0000013191 0.0000099998 @@ -3146,7 +3146,7 @@ 0.0000180800 0.0000595009 -0.0000688602 -0.0000075300 0.0000980409 -0.0000903102 0.0000551700 -0.0002294991 -0.0000568302 -# File: 48 +# File: 48 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0159669205 0.0000090803 0.0000430105 @@ -3213,7 +3213,7 @@ -0.0000434805 0.0000688603 -0.0000589895 -0.0000961705 0.0000751403 -0.0000636995 0.0000012495 0.0000557703 -0.0000002695 -# File: 49 +# File: 49 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 0.0000000000000000 -0.0600000000000000 -0.0158127794 -0.0000094205 -0.0000431603 @@ -3280,7 +3280,7 @@ 0.0000187806 0.0000069195 -0.0000157403 -0.0000204094 -0.0000010505 -0.0000388403 0.0000532006 -0.0000003805 -0.0000549903 -# File: 50 +# File: 50 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0158475202 0.0000103894 0.0000778597 @@ -3347,7 +3347,7 @@ 0.0002435498 0.0000101194 -0.0000657703 -0.0000315302 0.0000101994 -0.0000763703 -0.0000331102 -0.0000235306 -0.0000687203 -# File: 51 +# File: 51 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 20 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0159339408 -0.0000101900 -0.0000766802 @@ -3414,7 +3414,7 @@ -0.0002655608 0.0000651900 -0.0000097502 -0.0000870808 0.0000659600 -0.0000243002 0.0000872092 0.0000786100 0.0000084998 -# File: 52 +# File: 52 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0159000098 0.0000003800 0.0000098097 @@ -3481,7 +3481,7 @@ -0.0000412898 0.0000663200 -0.0000113703 -0.0000860598 0.0002903000 -0.0000231203 -0.0000234998 -0.0000318400 0.0000084897 -# File: 53 +# File: 53 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0158811408 0.0000006903 -0.0000094603 @@ -3548,7 +3548,7 @@ 0.0000141292 0.0000116303 -0.0000630203 -0.0000312408 -0.0002190697 -0.0000793903 0.0000789292 0.0000876903 -0.0000681103 -# File: 54 +# File: 54 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0158145295 -0.0000092000 0.0000419005 @@ -3615,7 +3615,7 @@ -0.0000410195 0.0000653900 -0.0000088795 -0.0000860495 0.0000666800 -0.0000228795 -0.0000088795 0.0000653900 -0.0000410195 -# File: 55 +# File: 55 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 0.0000000000000000 -0.0600000000000000 -0.0159658197 0.0000095494 -0.0000420103 @@ -3682,7 +3682,7 @@ 0.0000135203 0.0000125994 -0.0000641003 -0.0000330597 0.0000110794 -0.0000778103 0.0000658703 -0.0000109606 -0.0000165803 -# File: 56 +# File: 56 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 33 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0158595005 -0.0000216592 0.0000306103 @@ -3749,7 +3749,7 @@ 0.0000644495 0.0000806808 -0.0000284997 0.0000175595 0.0000800508 -0.0000612497 -0.0000480005 0.0000694108 -0.0000193897 -# File: 57 +# File: 57 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 33 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0159221695 0.0000217195 -0.0000305900 @@ -3816,7 +3816,7 @@ -0.0000896995 -0.0000045705 -0.0000475500 -0.0001343195 -0.0000060805 -0.0000420800 0.0001041405 -0.0000163105 -0.0000385900 -# File: 58 +# File: 58 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 33 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0159120605 0.0000313500 0.0000313500 @@ -3883,7 +3883,7 @@ 0.0000304295 0.0001151600 -0.0000479700 -0.0000155505 0.0001140900 -0.0000414200 0.0000712995 -0.0000490200 -0.0000203100 -# File: 59 +# File: 59 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 33 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0158689600 -0.0000315600 -0.0000315600 @@ -3950,7 +3950,7 @@ -0.0000553000 -0.0000380300 -0.0000285300 -0.0001009700 -0.0000401900 -0.0000609200 -0.0000145200 0.0001026900 -0.0000386100 -# File: 60 +# File: 60 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 34 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0158608602 0.0000280394 0.0000251806 @@ -4017,7 +4017,7 @@ -0.0000892102 0.0000810794 -0.0000476194 -0.0001347002 0.0000800894 -0.0000417194 0.0001045198 0.0000691294 -0.0000381894 -# File: 61 +# File: 61 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 34 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0159165102 -0.0000258298 -0.0000244106 @@ -4084,7 +4084,7 @@ 0.0000642498 -0.0000047198 -0.0000280706 0.0000172798 -0.0000054698 -0.0000611206 -0.0000476002 -0.0000160298 -0.0000194606 -# File: 62 +# File: 62 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 34 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0156345787 0.0000281705 0.0000281705 @@ -4151,7 +4151,7 @@ 0.0000298013 -0.0000380595 -0.0000470695 -0.0000154787 -0.0000399095 -0.0000416395 0.0000708813 0.0001028405 -0.0000195595 -# File: 63 +# File: 63 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 34 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0161495600 -0.0000284100 -0.0000284100 @@ -4218,7 +4218,7 @@ -0.0000553000 0.0001150200 -0.0000281400 -0.0001017400 0.0001132600 -0.0000611800 -0.0000141400 -0.0000503100 -0.0000380900 -# File: 64 +# File: 64 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0158639902 0.0000281794 0.0000252705 @@ -4285,7 +4285,7 @@ 0.0000298898 -0.0000393506 -0.0000275395 -0.0000152302 -0.0000382206 -0.0000610495 0.0000703398 0.0001038194 -0.0000382695 -# File: 65 +# File: 65 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 35 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0159143100 -0.0000267900 -0.0000236500 @@ -4352,7 +4352,7 @@ -0.0000545600 0.0001142700 -0.0000464300 -0.0001016500 0.0001140900 -0.0000424300 -0.0000142600 -0.0000489300 -0.0000190300 -# File: 66 +# File: 66 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0158648998 0.0002526200 0.0000270298 @@ -4419,7 +4419,7 @@ -0.0000898898 0.0000807500 -0.0000281602 -0.0001340198 0.0000808100 -0.0000609402 0.0001035302 0.0000693300 -0.0000192302 -# File: 67 +# File: 67 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0159165698 -0.0002561400 -0.0000275397 @@ -4486,7 +4486,7 @@ 0.0000640402 -0.0000048700 -0.0000474997 0.0000182202 -0.0000053300 -0.0000423097 -0.0000483298 -0.0000159400 -0.0000389297 -# File: 68 +# File: 68 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0158656398 0.0000280602 0.0000266106 @@ -4553,7 +4553,7 @@ -0.0000217898 0.0000280802 -0.0000369794 -0.0000488998 0.0000474902 -0.0000508394 0.0000376602 0.0000172302 -0.0000291394 -# File: 69 +# File: 69 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 0.0000000000000000 -0.0600000000000000 -0.0159138705 -0.0000256600 -0.0000244195 @@ -4620,7 +4620,7 @@ -0.0000032105 0.0000470800 -0.0000377895 -0.0000679905 0.0000277200 -0.0000510095 0.0000184095 0.0000364500 -0.0000293195 -# File: 70 +# File: 70 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0159513295 0.0000539603 0.0000379402 @@ -4687,7 +4687,7 @@ 0.0000304205 0.0001130803 -0.0000284298 -0.0000160895 0.0001142803 -0.0000604298 0.0000713305 -0.0000485597 -0.0000385598 -# File: 71 +# File: 71 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 36 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0158275700 -0.0000517100 -0.0000397700 @@ -4754,7 +4754,7 @@ -0.0000543100 -0.0000398200 -0.0000466000 -0.0001023900 -0.0000396000 -0.0000417800 -0.0000138200 0.0001047600 -0.0000195900 -# File: 72 +# File: 72 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0158406700 -0.0000560505 0.0000373702 @@ -4821,7 +4821,7 @@ 0.0000650900 0.0000799195 -0.0000467998 0.0000168400 0.0000806395 -0.0000421498 -0.0000469800 0.0000701895 -0.0000382998 -# File: 73 +# File: 73 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0159388897 0.0000580497 -0.0000393300 @@ -4888,7 +4888,7 @@ -0.0000889197 -0.0000042503 -0.0000283800 -0.0001354697 -0.0000051503 -0.0000611300 0.0001049103 -0.0000165803 -0.0000196800 -# File: 74 +# File: 74 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0158513205 0.0000363398 -0.0000127897 @@ -4955,7 +4955,7 @@ -0.0000214305 0.0000474298 -0.0000377397 -0.0000490005 0.0000281398 -0.0000518597 0.0000376595 0.0000364698 -0.0000282397 -# File: 75 +# File: 75 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 0.0000000000000000 -0.0600000000000000 -0.0159299302 -0.0000361998 0.0000123508 @@ -5022,7 +5022,7 @@ -0.0000030302 0.0000285602 -0.0000386492 -0.0000682202 0.0000466502 -0.0000523292 0.0000191498 0.0000170202 -0.0000283792 -# File: 76 +# File: 76 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 39 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0158536002 -0.0000573602 0.0000510698 @@ -5089,7 +5089,7 @@ 0.0002158698 0.0002690598 0.0000719598 0.0001739098 0.0002754498 -0.0001651802 -0.0002039502 0.0002652798 0.0000849498 -# File: 77 +# File: 77 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 39 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0159293702 0.0000601305 -0.0000501698 @@ -5156,7 +5156,7 @@ -0.0002457902 -0.0001999495 -0.0001513498 -0.0002853002 -0.0001946295 0.0000586802 0.0002549198 -0.0002051395 -0.0001380698 -# File: 78 +# File: 78 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 39 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0159024700 0.0000381603 0.0000381603 @@ -5223,7 +5223,7 @@ 0.0002190600 0.0002651703 0.0000714403 0.0001796800 0.0002696603 -0.0001650697 0.0002593200 -0.0001996497 -0.0001377797 -# File: 79 +# File: 79 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 39 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0158783800 -0.0000381600 -0.0000381600 @@ -5290,7 +5290,7 @@ -0.0002503200 -0.0001952200 -0.0001519800 -0.0002899300 -0.0001898100 0.0000583500 -0.0002100500 0.0002598500 0.0000849700 -# File: 80 +# File: 80 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 40 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0131886002 0.0040410291 0.0027933905 @@ -5357,7 +5357,7 @@ -0.0002401002 0.0002700091 -0.0001487095 -0.0002919702 0.0002760691 0.0000626305 0.0002602398 0.0002651491 -0.0001450395 -# File: 81 +# File: 81 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 40 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0188283302 -0.0041643098 -0.0030393100 @@ -5424,7 +5424,7 @@ 0.0002196998 -0.0001994898 0.0000773500 0.0001703498 -0.0001954398 -0.0001617700 -0.0001998402 -0.0002063998 0.0000836300 -# File: 82 +# File: 82 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 40 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0119619700 0.0027067800 0.0027067800 @@ -5491,7 +5491,7 @@ 0.0002252900 -0.0001948900 0.0000756400 0.0001733900 -0.0001900000 -0.0001609400 0.0002643900 0.0002603400 -0.0001427000 -# File: 83 +# File: 83 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 40 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0199236100 -0.0029359800 -0.0029359800 @@ -5558,7 +5558,7 @@ -0.0002433300 0.0002648000 -0.0001474100 -0.0002969700 0.0002707200 0.0000612300 -0.0002017500 -0.0002010000 0.0000797600 -# File: 84 +# File: 84 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0159493205 -0.0000385297 0.0000481100 @@ -5625,7 +5625,7 @@ -0.0000118605 0.0000473403 -0.0000275600 -0.0005871305 0.0001517203 -0.0001659100 0.0000280395 0.0000360003 -0.0000381800 -# File: 85 +# File: 85 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 49 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0158342600 0.0000362800 -0.0000496700 @@ -5692,7 +5692,7 @@ -0.0000119500 0.0000281800 -0.0000471600 0.0004654200 -0.0000720500 0.0000579900 0.0000273200 0.0000175300 -0.0000189700 -# File: 86 +# File: 86 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0159262500 -0.0000128595 -0.0000398098 @@ -5759,7 +5759,7 @@ -0.0000222900 0.0000806105 -0.0001145498 -0.0001683400 0.0002689805 -0.0002800398 0.0000185400 0.0000693305 0.0000473602 -# File: 87 +# File: 87 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0158539995 0.0000122003 0.0000390097 @@ -5826,7 +5826,7 @@ -0.0000031195 -0.0000045297 0.0000394897 0.0000553805 -0.0002007097 0.0001813997 0.0000379005 -0.0000160097 -0.0001047803 -# File: 88 +# File: 88 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0158383909 -0.0000391303 -0.0000631305 @@ -5893,7 +5893,7 @@ -0.0000219809 -0.0000377403 0.0000053295 0.0000558091 -0.0001952403 0.0001865895 0.0000373491 0.0001022197 0.0000140395 -# File: 89 +# File: 89 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 0.0000000000000000 -0.0600000000000000 -0.0159435197 0.0000373000 0.0000606997 @@ -5960,7 +5960,7 @@ -0.0000031897 0.0001152800 -0.0000804303 -0.0001686997 0.0002643200 -0.0002831803 0.0000190503 -0.0000503900 -0.0000710503 -# File: 90 +# File: 90 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0158626102 -0.0000266494 0.0000268597 @@ -6027,7 +6027,7 @@ -0.0005365002 0.0001469206 0.0000721097 -0.0000583902 0.0000464106 -0.0000606003 -0.0005005402 0.0001411706 -0.0001427903 -# File: 91 +# File: 91 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 50 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0159207500 0.0000285700 -0.0000281700 @@ -6094,7 +6094,7 @@ 0.0005158600 -0.0000758800 -0.0001516000 -0.0000597200 0.0000271800 -0.0000422700 0.0005523500 -0.0000829800 0.0000807000 -# File: 92 +# File: 92 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0159187994 0.0000301100 -0.0000293098 @@ -6161,7 +6161,7 @@ -0.0001263394 0.0002762600 0.0001965702 -0.0000678794 0.0000804200 0.0000245302 -0.0000808394 0.0002588300 -0.0002558098 -# File: 93 +# File: 93 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0158633403 -0.0000277297 0.0000276202 @@ -6228,7 +6228,7 @@ 0.0000973597 -0.0001933897 -0.0002657898 -0.0000487203 -0.0000056197 -0.0001278598 0.0001417497 -0.0002117397 0.0002030302 -# File: 94 +# File: 94 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0158609897 -0.0000277397 0.0002556705 @@ -6295,7 +6295,7 @@ -0.0001260397 0.0002704203 0.0002005205 -0.0000498297 0.0001131003 -0.0000086695 0.0001428703 -0.0002060097 0.0002096005 -# File: 95 +# File: 95 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 0.0000000000000000 -0.0600000000000000 -0.0159206097 0.0000276597 -0.0002519405 @@ -6362,7 +6362,7 @@ 0.0000975003 -0.0001894103 -0.0002693305 -0.0000675997 -0.0000396603 -0.0000939205 -0.0000819997 0.0002542897 -0.0002604105 -# File: 96 +# File: 96 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 51 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0181591608 0.0035953192 -0.0021905800 @@ -6429,7 +6429,7 @@ -0.0000222208 0.0000809092 0.0000396400 -0.0001726808 0.0002751492 0.0001808700 0.0000185992 0.0000692592 -0.0001042100 -# File: 97 +# File: 97 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 51 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0134110203 -0.0037075602 0.0023932206 @@ -6496,7 +6496,7 @@ -0.0000024803 -0.0000052102 -0.0001140794 0.0000508797 -0.0001945502 -0.0002786194 0.0000385797 -0.0000154102 0.0000471206 -# File: 98 +# File: 98 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 51 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0120798198 -0.0024803103 0.0024803103 @@ -6563,7 +6563,7 @@ -0.0000122098 0.0000468997 -0.0000468997 -0.0005830298 0.0001474297 0.0000587403 0.0000286602 0.0000360497 -0.0000188997 -# File: 99 +# File: 99 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 51 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0195722400 0.0022614800 -0.0022614800 @@ -6630,7 +6630,7 @@ -0.0000138200 0.0000280200 -0.0000280200 0.0004698000 -0.0000775800 -0.0001665800 0.0000283400 0.0000197700 -0.0000382800 -# File: 100 +# File: 100 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 52 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0159280197 -0.0000595000 -0.0000514000 @@ -6697,7 +6697,7 @@ -0.0001219697 0.0002698200 -0.0002648200 -0.0000683497 0.0000801300 -0.0001270700 -0.0000853897 0.0002648000 0.0002037600 -# File: 101 +# File: 101 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 52 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0158524100 0.0000616495 0.0000501400 @@ -6764,7 +6764,7 @@ 0.0001013100 -0.0002005205 0.0001951800 -0.0000488100 -0.0000050705 0.0000261700 0.0001377300 -0.0002047305 -0.0002557700 -# File: 102 +# File: 102 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 52 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0159029005 -0.0000381405 0.0000381405 @@ -6831,7 +6831,7 @@ -0.0005407605 0.0001520595 -0.0001520595 -0.0000579305 0.0000465195 -0.0000419095 -0.0004956405 0.0001362295 0.0000809405 -# File: 103 +# File: 103 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 52 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0158786000 0.0000377600 -0.0000377600 @@ -6898,7 +6898,7 @@ 0.0005112500 -0.0000714200 0.0000714200 -0.0000583700 0.0000280400 -0.0000607400 0.0005564900 -0.0000876900 -0.0001430400 -# File: 104 +# File: 104 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 53 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0159193297 0.0000271103 -0.0000276697 @@ -6965,7 +6965,7 @@ -0.0000027697 0.0000806203 0.0000392603 0.0000509603 0.0002690403 0.0001766003 0.0000377403 0.0000695403 -0.0001054097 -# File: 105 +# File: 105 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 53 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0158639700 -0.0000260405 0.0000257295 @@ -7032,7 +7032,7 @@ -0.0000216500 -0.0000046505 -0.0001151505 -0.0001729400 -0.0002004805 -0.0002846005 0.0000190400 -0.0000162205 0.0000473595 -# File: 106 +# File: 106 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 53 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0156382502 -0.0000282400 0.0000282400 @@ -7099,7 +7099,7 @@ -0.0000127402 0.0000281300 -0.0000281300 -0.0005827002 -0.0000722000 -0.0001614000 0.0000290298 0.0000176600 -0.0000382100 -# File: 107 +# File: 107 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 53 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0161397102 0.0000268897 -0.0000274805 @@ -7166,7 +7166,7 @@ -0.0000126302 0.0000470797 -0.0000471405 0.0004696398 0.0001524697 0.0000629895 0.0000287898 0.0000362997 -0.0000193105 -# File: 108 +# File: 108 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 54 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0159209908 -0.0000221100 -0.0000312998 @@ -7233,7 +7233,7 @@ 0.0001017792 0.0002754700 -0.0002709098 -0.0000493408 0.0000800300 -0.0001282398 0.0001381192 0.0002585800 0.0001983202 -# File: 109 +# File: 109 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 54 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0158595598 0.0000220106 0.0000319203 @@ -7300,7 +7300,7 @@ -0.0001226698 -0.0001941594 0.0001902803 -0.0000683398 -0.0000055294 0.0000253503 -0.0000855498 -0.0002104994 -0.0002615297 -# File: 110 +# File: 110 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 54 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0159118592 -0.0000307298 0.0000307298 @@ -7367,7 +7367,7 @@ -0.0005406992 -0.0000762098 0.0000762098 -0.0000577792 0.0000270902 -0.0000618102 -0.0004953492 -0.0000833298 -0.0001391002 -# File: 111 +# File: 111 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 54 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0158689000 0.0000308500 -0.0000305302 diff --git a/example/Si-QE/phono3py_disp.yaml b/example/Si-QE/phono3py_disp.yaml index f0be1069..e80eec0a 100644 --- a/example/Si-QE/phono3py_disp.yaml +++ b/example/Si-QE/phono3py_disp.yaml @@ -851,4 +851,4 @@ displacement_pairs: displacement_pair_info: number_of_singles: 1 - number_of_pairs: 110 \ No newline at end of file + number_of_pairs: 110 diff --git a/example/Si-TURBOMOLE/FORCES_FC2 b/example/Si-TURBOMOLE/FORCES_FC2 index d1341d77..ae97ad62 100644 --- a/example/Si-TURBOMOLE/FORCES_FC2 +++ b/example/Si-TURBOMOLE/FORCES_FC2 @@ -1,4 +1,4 @@ -# File: 1 +# File: 1 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081048897 -0.0000000073 -0.0000000073 0.0000021030 -0.0000000064 -0.0000000065 diff --git a/example/Si-TURBOMOLE/FORCES_FC3 b/example/Si-TURBOMOLE/FORCES_FC3 index 8c25c9ef..721855c1 100644 --- a/example/Si-TURBOMOLE/FORCES_FC3 +++ b/example/Si-TURBOMOLE/FORCES_FC3 @@ -1,4 +1,4 @@ -# File: 1 +# File: 1 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081155391 -0.0000000096 -0.0000000095 0.0000079303 -0.0000000099 -0.0000000100 @@ -64,7 +64,7 @@ 0.0000130880 -0.0000150108 -0.0000077490 0.0001290470 -0.0000142987 -0.0000142988 -0.0000105152 -0.0000133962 -0.0000133962 -# File: 2 +# File: 2 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 1 0.0424264068711929 0.0424264068711929 0.0000000000000000 -0.0138525073 -0.0057683669 0.0007423657 @@ -131,7 +131,7 @@ 0.0000125442 0.0000658495 -0.0000028382 0.0002090655 -0.0000154119 -0.0000186496 -0.0000274866 -0.0000302377 -0.0000128809 -# File: 3 +# File: 3 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 1 -0.0424264068711929 -0.0424264068711929 0.0000000000000000 -0.0023801020 0.0057408591 -0.0001272804 @@ -198,7 +198,7 @@ 0.0000138718 -0.0000957648 -0.0000124295 0.0000484362 -0.0000134242 -0.0000097209 0.0000063675 0.0000034590 -0.0000134878 -# File: 4 +# File: 4 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 2 0.0424264068711929 0.0424264068711929 0.0000000000000000 -0.0081100003 0.0000185129 -0.0000004832 @@ -265,7 +265,7 @@ -0.0000222138 -0.0000519045 -0.0000074958 0.0001121705 -0.0000311858 -0.0000140853 0.0000708946 -0.0000148230 -0.0000182909 -# File: 5 +# File: 5 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 2 -0.0424264068711929 -0.0424264068711929 0.0000000000000000 -0.0081213662 -0.0000187337 0.0000000716 @@ -332,7 +332,7 @@ 0.0000497563 0.0000201965 -0.0000075542 0.0001458117 0.0000025768 -0.0000140913 -0.0000922048 -0.0000120268 -0.0000083359 -# File: 6 +# File: 6 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 3 0.0424264068711929 0.0424264068711929 0.0000000000000000 -0.0080969807 0.0000056027 -0.0000003152 @@ -399,7 +399,7 @@ -0.0000038679 -0.0000318321 -0.0000075296 0.0000938229 -0.0000510828 -0.0000140871 -0.0000117431 0.0000682357 -0.0000082690 -# File: 7 +# File: 7 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 3 -0.0424264068711929 -0.0424264068711929 0.0000000000000000 -0.0081342392 -0.0000056877 -0.0000000938 @@ -466,7 +466,7 @@ 0.0000299447 0.0000018499 -0.0000075239 0.0001657938 0.0000209246 -0.0000140382 -0.0000090628 -0.0000947505 -0.0000182819 -# File: 8 +# File: 8 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 3 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0081156848 -0.0000003890 0.0000263044 @@ -533,7 +533,7 @@ -0.0000004136 -0.0000015522 -0.0000181667 0.0001067189 0.0000080817 -0.0000210139 -0.0000175360 0.0000005568 -0.0000013976 -# File: 9 +# File: 9 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 4 0.0424264068711929 0.0424264068711929 0.0000000000000000 -0.0081171001 -0.0000015652 -0.0000005573 @@ -600,7 +600,7 @@ 0.0000942601 -0.0000163254 -0.0000128249 0.0001278333 0.0000671637 -0.0000090088 -0.0000458151 -0.0000502742 -0.0000131699 -# File: 10 +# File: 10 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 4 -0.0424264068711929 -0.0424264068711929 0.0000000000000000 -0.0081139644 0.0000015614 -0.0000002466 @@ -667,7 +667,7 @@ -0.0000684922 -0.0000138706 -0.0000025134 0.0001304738 -0.0000957054 -0.0000192457 0.0000263790 0.0000219561 -0.0000131368 -# File: 11 +# File: 11 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 4 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0081154203 -0.0000007186 -0.0002407769 @@ -734,7 +734,7 @@ -0.0000008489 -0.0000078540 0.0000042360 0.0001221282 -0.0000003935 -0.0000024120 -0.0000329223 0.0000089637 -0.0000201987 -# File: 12 +# File: 12 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 7 0.0424264068711929 0.0424264068711929 0.0000000000000000 -0.0082857181 -0.0000014481 -0.0000002797 @@ -801,7 +801,7 @@ 0.0000167539 -0.0000114783 -0.0000080982 0.0005817752 0.0004097433 -0.0000377665 -0.0000301063 -0.0000492589 -0.0000132791 -# File: 13 +# File: 13 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 7 -0.0424264068711929 -0.0424264068711929 0.0000000000000000 -0.0079455444 0.0000019250 0.0000000290 @@ -868,7 +868,7 @@ 0.0000097906 -0.0000183060 -0.0000081484 -0.0002944012 -0.0004679395 -0.0000366726 0.0000093955 0.0000221615 -0.0000136029 -# File: 14 +# File: 14 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 8 0.0424264068711929 0.0424264068711929 0.0000000000000000 -0.0081073943 0.0000082430 -0.0000005855 @@ -935,7 +935,7 @@ -0.0000229669 -0.0000351804 -0.0000078297 0.0001090237 -0.0000503838 -0.0000143837 0.0004431136 0.0004107065 -0.0000363007 -# File: 15 +# File: 15 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 8 -0.0424264068711929 -0.0424264068711929 0.0000000000000000 -0.0081235237 -0.0000079849 0.0000000901 @@ -1002,7 +1002,7 @@ 0.0000491035 0.0000047786 -0.0000076635 0.0001491099 0.0000216513 -0.0000144582 -0.0004344622 -0.0004668271 -0.0000364501 -# File: 16 +# File: 16 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0079926295 0.0001157077 -0.0000672572 @@ -1069,7 +1069,7 @@ 0.0000025311 -0.0000285304 0.0000057476 0.0001001839 -0.0000362066 0.0000076516 0.0000014840 -0.0000272649 -0.0000065816 -# File: 17 +# File: 17 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 9 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0082331919 -0.0001113373 0.0000644818 @@ -1136,7 +1136,7 @@ 0.0000235604 -0.0000017313 -0.0000210008 0.0001576070 0.0000082395 -0.0000357998 -0.0000235465 0.0000016139 -0.0000210009 -# File: 18 +# File: 18 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0079983484 0.0001225587 -0.0000640899 @@ -1203,7 +1203,7 @@ -0.0000001684 -0.0000251860 -0.0000210638 0.0001061127 -0.0000430325 -0.0000356923 -0.0000247482 0.0001153606 -0.0000275915 -# File: 19 +# File: 19 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0082281257 -0.0001176045 0.0000610459 @@ -1270,7 +1270,7 @@ 0.0000265110 -0.0000049014 0.0000057291 0.0001511370 0.0000145536 0.0000078154 0.0000040805 -0.0001434787 0.0000011616 -# File: 20 +# File: 20 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0080519857 0.0000652294 -0.0002655082 @@ -1337,7 +1337,7 @@ 0.0000265434 -0.0000282755 -0.0000180404 0.0001513922 -0.0000367508 -0.0000210995 -0.0000035218 -0.0000273531 -0.0000014233 -# File: 21 +# File: 21 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0000000000000000 0.0000000000000000 -0.0600000000000000 -0.0081803672 -0.0000666226 0.0002671262 @@ -1404,7 +1404,7 @@ -0.0000000924 -0.0000020099 0.0000024214 0.0001071720 0.0000076960 -0.0000080752 -0.0000180910 0.0000016803 -0.0000264486 -# File: 22 +# File: 22 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0079888106 -0.0001212716 -0.0000612530 @@ -1471,7 +1471,7 @@ 0.0001435279 -0.0000293841 0.0000068670 0.0001410366 -0.0000284074 -0.0000072341 -0.0000393363 -0.0000353577 0.0000085649 -# File: 23 +# File: 23 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 10 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0082475013 0.0001255594 0.0000642577 @@ -1538,7 +1538,7 @@ -0.0001162160 -0.0000010627 -0.0000219486 0.0001159267 0.0000006145 -0.0000220670 0.0000180976 0.0000093970 -0.0000348819 -# File: 24 +# File: 24 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0082394205 0.0001322460 0.0000676845 @@ -1605,7 +1605,7 @@ -0.0000019841 -0.0000020115 -0.0000154307 0.0001147517 0.0001146304 -0.0000286717 -0.0000331446 -0.0000419453 -0.0000348786 -# File: 25 +# File: 25 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0079957724 -0.0001270601 -0.0000647635 @@ -1672,7 +1672,7 @@ 0.0000271207 -0.0000268689 -0.0000007234 0.0001436553 -0.0001446812 0.0000003779 0.0000114067 0.0000153329 0.0000084775 -# File: 26 +# File: 26 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0080463564 -0.0000674887 -0.0002661160 @@ -1739,7 +1739,7 @@ 0.0000272384 -0.0000219751 0.0000041294 0.0001360055 -0.0000283715 -0.0000025210 0.0000118860 -0.0000357426 -0.0000203256 -# File: 27 +# File: 27 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0000000000000000 0.0000000000000000 -0.0600000000000000 -0.0081827272 0.0000654244 0.0002651539 @@ -1806,7 +1806,7 @@ -0.0000020622 -0.0000072820 -0.0000207424 0.0001213306 0.0000007814 -0.0000272021 -0.0000323540 0.0000083922 -0.0000073915 -# File: 28 +# File: 28 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 13 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0080950184 -0.0000354096 -0.0000057782 @@ -1873,7 +1873,7 @@ 0.0000250748 -0.0000220081 0.0000062377 0.0021279081 -0.0014221560 0.0013935255 -0.0000173514 -0.0000357750 0.0000089639 -# File: 29 +# File: 29 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 13 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081361971 0.0000358184 0.0000058431 @@ -1940,7 +1940,7 @@ 0.0000003540 -0.0000071513 -0.0000227626 -0.0018134844 0.0012820986 -0.0013106835 -0.0000043903 0.0000083178 -0.0000351018 -# File: 30 +# File: 30 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 13 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0081514476 0.0000209930 -0.0000060035 @@ -2007,7 +2007,7 @@ 0.0000053852 -0.0000019295 -0.0000227595 -0.0011666893 0.0019278209 -0.0013101108 -0.0000319704 -0.0000419634 -0.0000361258 -# File: 31 +# File: 31 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 13 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0080793701 -0.0000209335 0.0000060027 @@ -2074,7 +2074,7 @@ 0.0000200834 -0.0000270220 0.0000062452 0.0015363808 -0.0020128086 0.0013931099 0.0000114112 0.0000154317 0.0000086192 -# File: 32 +# File: 32 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 13 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0081094796 0.0000061631 -0.0000034745 @@ -2141,7 +2141,7 @@ 0.0000276317 -0.0000295519 0.0001226692 0.0015367513 -0.0014223196 0.0019847105 0.0000114293 -0.0000353540 -0.0000422487 -# File: 33 +# File: 33 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 13 0.0000000000000000 0.0000000000000000 -0.0600000000000000 -0.0081214812 -0.0000060603 0.0000043024 @@ -2208,7 +2208,7 @@ -0.0000011587 -0.0000007602 -0.0001368210 -0.0011670382 0.0012820780 -0.0019568806 -0.0000319870 0.0000092691 0.0000151820 -# File: 34 +# File: 34 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 14 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0080947688 0.0000359010 -0.0000063001 @@ -2275,7 +2275,7 @@ -0.0000158420 -0.0000368307 0.0000142782 0.0001222330 -0.0000366943 0.0000081057 0.0019882305 -0.0014211366 0.0013945453 -# File: 35 +# File: 35 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 14 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081364719 -0.0000357253 0.0000062670 @@ -2342,7 +2342,7 @@ 0.0000417431 0.0000064079 -0.0000304363 0.0001351960 0.0000076101 -0.0000362326 -0.0019529162 0.0012826676 -0.0013096812 -# File: 36 +# File: 36 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 14 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0080803094 0.0000206442 0.0000060039 @@ -2409,7 +2409,7 @@ -0.0000088522 -0.0000210978 -0.0000296488 0.0001076139 -0.0000429647 -0.0000370958 -0.0013066656 0.0019291842 -0.0013095543 -# File: 37 +# File: 37 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 14 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0081510610 -0.0000205770 -0.0000060831 @@ -2476,7 +2476,7 @@ 0.0000355336 -0.0000081771 0.0000146442 0.0001509502 0.0000146243 0.0000077847 0.0013972522 -0.0020124051 0.0013943838 -# File: 38 +# File: 38 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 14 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0081097566 -0.0000057683 -0.0000048026 @@ -2543,7 +2543,7 @@ 0.0000349719 -0.0000370152 -0.0000366018 0.0001510951 -0.0000360649 -0.0000431089 0.0013972806 -0.0014210458 0.0019857631 -# File: 39 +# File: 39 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 14 0.0000000000000000 0.0000000000000000 -0.0600000000000000 -0.0081214536 0.0000059445 0.0000038529 @@ -2610,7 +2610,7 @@ -0.0000096165 0.0000065055 0.0000209242 0.0001074725 0.0000082801 0.0000143303 -0.0013066879 0.0012826262 -0.0019559532 -# File: 40 +# File: 40 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 25 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0081783043 0.0001256756 0.0001221153 @@ -2677,7 +2677,7 @@ 0.0000206082 -0.0000019845 0.0000070346 0.0014247786 0.0019283779 0.0012807820 0.0000110061 -0.0000420888 0.0000092983 -# File: 41 +# File: 41 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 25 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0080552756 -0.0001202951 -0.0001177634 @@ -2744,7 +2744,7 @@ 0.0000062038 -0.0000268443 -0.0000217001 -0.0012783460 -0.0020134847 -0.0014210904 -0.0000324832 0.0000154238 -0.0000352703 -# File: 42 +# File: 42 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 25 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0083784891 0.0000651140 0.0000651140 @@ -2811,7 +2811,7 @@ 0.0000262364 -0.0000073786 0.0000072293 0.0020707024 0.0012820569 0.0012820570 -0.0000167153 0.0000084078 0.0000084078 -# File: 43 +# File: 43 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 25 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0078516934 -0.0000665942 -0.0000665942 @@ -2878,7 +2878,7 @@ 0.0000010438 -0.0000219580 -0.0000217048 -0.0018692189 -0.0014223580 -0.0014223578 -0.0000036104 -0.0000356757 -0.0000356757 -# File: 44 +# File: 44 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 26 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0081217735 0.0000210605 -0.0000355151 @@ -2945,7 +2945,7 @@ 0.0000349563 -0.0000210730 0.0000141900 0.0001504723 -0.0000428368 0.0000083545 0.0012858219 0.0019290397 0.0012828004 -# File: 45 +# File: 45 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 26 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0081094935 -0.0000210934 0.0000359358 @@ -3012,7 +3012,7 @@ -0.0000093038 -0.0000079608 -0.0000302222 0.0001070584 0.0000144424 -0.0000361178 -0.0014184210 -0.0020125553 -0.0014211519 -# File: 46 +# File: 46 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 26 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081184675 0.0000062533 0.0000062532 @@ -3079,7 +3079,7 @@ -0.0000155052 0.0000064494 0.0000148579 0.0001229842 0.0000075277 0.0000075275 0.0019318851 0.0012828537 0.0012828535 -# File: 47 +# File: 47 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 26 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081119924 -0.0000061178 -0.0000061179 @@ -3146,7 +3146,7 @@ 0.0000419434 -0.0000369263 -0.0000296410 0.0001358427 -0.0000366203 -0.0000366204 -0.0020093253 -0.0014212747 -0.0014212747 -# File: 48 +# File: 48 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 27 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0081807182 0.0001241513 -0.0001146900 @@ -3213,7 +3213,7 @@ 0.0000344076 -0.0000431855 0.0000148406 0.0001510690 -0.0000205262 0.0000075544 -0.0000026512 -0.0000004145 0.0000018283 -# File: 49 +# File: 49 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 27 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0080470026 -0.0001292813 0.0001189777 @@ -3280,7 +3280,7 @@ -0.0000086974 0.0000135703 -0.0000296829 0.0001065045 -0.0000074967 -0.0000366751 -0.0000176811 -0.0000254920 -0.0000276098 -# File: 50 +# File: 50 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 27 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0083842934 0.0000679510 -0.0000679663 @@ -3347,7 +3347,7 @@ 0.0000071080 0.0000069994 0.0000141891 0.0001004875 0.0000070375 0.0000084876 0.0000024887 -0.0000057256 0.0000015601 -# File: 51 +# File: 51 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 27 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0078484023 -0.0000660228 0.0000660075 @@ -3414,7 +3414,7 @@ 0.0000198156 -0.0000375091 -0.0000301910 0.0001578966 -0.0000361129 -0.0000363834 -0.0000224461 -0.0000203687 -0.0000273457 -# File: 52 +# File: 52 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 28 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0081214510 0.0000204907 0.0000358291 @@ -3481,7 +3481,7 @@ 0.0013091965 0.0019274178 0.0012885474 0.0001367699 -0.0000012237 0.0000006429 0.0000113869 -0.0000195089 0.0000084575 -# File: 53 +# File: 53 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 28 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0081097726 -0.0000206495 -0.0000356619 @@ -3548,7 +3548,7 @@ -0.0013948085 -0.0020140290 -0.0014158337 0.0001218868 -0.0000259496 -0.0000282885 -0.0000327412 -0.0000064800 -0.0000356110 -# File: 54 +# File: 54 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 28 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081208525 0.0000057900 -0.0000058053 @@ -3615,7 +3615,7 @@ 0.0019558562 0.0012814199 0.0012885783 0.0001421524 -0.0000065995 0.0000006060 -0.0000390906 0.0000080782 0.0000093119 -# File: 55 +# File: 55 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 28 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081111809 -0.0000059241 0.0000059086 @@ -3682,7 +3682,7 @@ -0.0019861052 -0.0014230655 -0.0014156997 0.0001170071 -0.0000212978 -0.0000282007 0.0000183282 -0.0000353364 -0.0000353891 -# File: 56 +# File: 56 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 33 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0068205738 0.0018878438 0.0012503888 @@ -3749,7 +3749,7 @@ 0.0000072069 0.0000058388 0.0000275257 0.0000665188 0.0001076990 0.0001027958 -0.0000166722 0.0000073935 -0.0000489858 -# File: 57 +# File: 57 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 33 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0093054450 -0.0018341164 -0.0011489248 @@ -3816,7 +3816,7 @@ 0.0000190828 -0.0000357902 -0.0000434295 0.0001945194 -0.0001414808 -0.0001356999 -0.0000043368 -0.0000342871 0.0000220283 -# File: 58 +# File: 58 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 33 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0061725893 0.0012942458 0.0012942459 @@ -3883,7 +3883,7 @@ 0.0000090740 -0.0000087365 -0.0000137627 -0.0001366568 0.0000526592 0.0000526591 -0.0000149655 -0.0000074775 -0.0000074775 -# File: 59 +# File: 59 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 33 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0099964380 -0.0011856534 -0.0011856533 @@ -3950,7 +3950,7 @@ 0.0000178313 -0.0000211175 -0.0000019083 0.0003932955 -0.0000794786 -0.0000794788 -0.0000069892 -0.0000195058 -0.0000195058 -# File: 60 +# File: 60 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 34 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0080941897 -0.0000290878 0.0000218677 @@ -4017,7 +4017,7 @@ -0.0000527668 0.0001123811 -0.0001283985 0.0001229750 0.0000064093 -0.0000501062 -0.0000736539 0.0001087878 0.0001029759 -# File: 61 +# File: 61 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 34 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0081365907 0.0000287489 -0.0000226729 @@ -4084,7 +4084,7 @@ 0.0000759959 -0.0001372352 0.0001084516 0.0001350508 -0.0000350848 0.0000211892 0.0000554659 -0.0001408921 -0.0001340209 -# File: 62 +# File: 62 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 34 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081221075 0.0000224218 0.0000224219 @@ -4151,7 +4151,7 @@ -0.0002523522 0.0000505264 -0.0000732916 0.0001245756 -0.0000083353 -0.0000083354 -0.0002770105 0.0000537523 0.0000537524 -# File: 63 +# File: 63 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 34 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081098013 -0.0000219110 -0.0000219110 @@ -4218,7 +4218,7 @@ 0.0002798837 -0.0000822395 0.0000594862 0.0001326846 -0.0000203613 -0.0000203613 0.0002547725 -0.0000788296 -0.0000788298 -# File: 64 +# File: 64 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081438950 0.0000217007 0.0000207944 @@ -4285,7 +4285,7 @@ 0.0000086273 -0.0000090737 -0.0000018556 -0.0001363381 0.0000512051 -0.0000798194 -0.0000141746 -0.0000073099 -0.0000194843 -# File: 65 +# File: 65 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 35 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0080875990 -0.0000212465 -0.0000214503 @@ -4352,7 +4352,7 @@ 0.0000167539 -0.0000210897 -0.0000137854 0.0003956549 -0.0000815399 0.0000529565 -0.0000059962 -0.0000193543 -0.0000074377 -# File: 66 +# File: 66 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0080941750 -0.0000068794 0.0000226609 @@ -4419,7 +4419,7 @@ 0.0000071028 0.0000058895 -0.0000436731 0.0000630511 0.0001132211 -0.0001347006 -0.0000165096 0.0000075024 0.0000223155 -# File: 67 +# File: 67 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0081363763 0.0000060353 -0.0000221757 @@ -4486,7 +4486,7 @@ 0.0000190871 -0.0000358676 0.0000277591 0.0001922068 -0.0001363742 0.0001019798 -0.0000044356 -0.0000341279 -0.0000492311 -# File: 68 +# File: 68 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0080926352 0.0000218339 -0.0000300400 @@ -4553,7 +4553,7 @@ 0.0000070271 -0.0000507072 0.0000129750 0.0001921061 -0.0001305045 0.0001078205 -0.0000044255 0.0000224652 0.0000073216 -# File: 69 +# File: 69 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 0.0000000000000000 -0.0600000000000000 -0.0081392437 -0.0000214159 0.0000297757 @@ -4620,7 +4620,7 @@ 0.0000191015 0.0000203465 -0.0000285799 0.0000630983 0.0001062686 -0.0001417000 -0.0000165596 -0.0000489056 -0.0000342206 -# File: 70 +# File: 70 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081024465 0.0000079064 0.0000140966 @@ -4687,7 +4687,7 @@ -0.0002536211 0.0000520287 0.0000593870 0.0001253820 -0.0000082504 -0.0000203523 -0.0002758044 0.0000520911 -0.0000789086 -# File: 71 +# File: 71 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 36 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081296112 -0.0000085234 -0.0000151389 @@ -4754,7 +4754,7 @@ 0.0002785045 -0.0000803442 -0.0000731763 0.0001335315 -0.0000202148 -0.0000083952 0.0002560442 -0.0000805865 0.0000538103 -# File: 72 +# File: 72 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0081077973 0.0000129127 0.0000144050 @@ -4821,7 +4821,7 @@ -0.0000498261 0.0001072566 0.0001085360 0.0001230045 0.0000065453 0.0000212783 -0.0000766035 0.0001139240 -0.0001339845 -# File: 73 +# File: 73 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0081240329 -0.0000138880 -0.0000154123 @@ -4888,7 +4888,7 @@ 0.0000788909 -0.0001425170 -0.0001284011 0.0001351297 -0.0000350654 -0.0000501792 0.0000526742 -0.0001354845 0.0001028177 -# File: 74 +# File: 74 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0081000805 0.0000146913 0.0001304092 @@ -4955,7 +4955,7 @@ -0.0000497312 0.0001014008 0.0001145095 0.0001349228 0.0000216070 0.0000065659 0.0000526649 -0.0001296341 0.0001088467 -# File: 75 +# File: 75 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 0.0000000000000000 -0.0600000000000000 -0.0081306225 -0.0000143394 -0.0001290836 @@ -5022,7 +5022,7 @@ 0.0000788111 -0.0001357941 -0.0001352524 0.0001232105 -0.0000499592 -0.0000352730 -0.0000766113 0.0001072210 -0.0001408906 -# File: 76 +# File: 76 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 39 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0081017207 0.0000122615 0.0000072614 @@ -5089,7 +5089,7 @@ 0.0000190661 0.0000059786 0.0000282354 0.0001948360 0.0001131829 0.0001064497 -0.0000044980 0.0000074539 -0.0000490380 -# File: 77 +# File: 77 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 39 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0081302181 -0.0000129264 -0.0000083077 @@ -5156,7 +5156,7 @@ 0.0000071121 -0.0000360449 -0.0000434614 0.0000659783 -0.0001362634 -0.0001310626 -0.0000166107 -0.0000341205 0.0000225853 -# File: 78 +# File: 78 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 39 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0079868546 0.0000146337 0.0000146336 @@ -5223,7 +5223,7 @@ 0.0000094289 -0.0000209135 -0.0000016347 -0.0001375690 -0.0000815270 -0.0000815272 -0.0000150200 -0.0000193391 -0.0000193393 -# File: 79 +# File: 79 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 39 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0082430697 -0.0000143540 -0.0000143539 @@ -5290,7 +5290,7 @@ 0.0000176231 -0.0000092563 -0.0000137174 0.0003943177 0.0000512302 0.0000512301 -0.0000067907 -0.0000073271 -0.0000073272 -# File: 80 +# File: 80 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 40 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0081021752 -0.0000105353 0.0000137921 @@ -5357,7 +5357,7 @@ 0.0000760764 0.0001072364 -0.0001239697 0.0001350480 0.0000064446 -0.0000498077 0.0000554206 0.0001139895 0.0001072089 -# File: 81 +# File: 81 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 40 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0081287711 0.0000105765 -0.0000136389 @@ -5424,7 +5424,7 @@ -0.0000527952 -0.0001425127 0.0001128154 0.0001230090 -0.0000349755 0.0000214808 -0.0000735499 -0.0001355597 -0.0001296395 -# File: 82 +# File: 82 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 40 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081260729 0.0000134224 0.0000134223 @@ -5491,7 +5491,7 @@ -0.0002521993 -0.0000807082 0.0000579560 0.0001245491 -0.0000202899 -0.0000202899 -0.0002771911 -0.0000806706 -0.0000806706 -# File: 83 +# File: 83 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 40 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081049089 -0.0000132920 -0.0000132920 @@ -5558,7 +5558,7 @@ 0.0002796384 0.0000523914 -0.0000751638 0.0001327457 -0.0000081795 -0.0000081795 0.0002548715 0.0000521598 0.0000521598 -# File: 84 +# File: 84 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 41 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0067101803 0.0020574680 -0.0014541762 @@ -5625,7 +5625,7 @@ 0.0000794809 -0.0002801255 -0.0000737448 0.0001351273 -0.0000186059 -0.0000083598 -0.0000044424 -0.0000170515 -0.0000196199 -# File: 85 +# File: 85 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 41 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0096393878 -0.0021168997 0.0015766074 @@ -5692,7 +5692,7 @@ -0.0000550432 0.0002513892 0.0000599763 0.0001228247 -0.0000108729 -0.0000203960 -0.0000164469 -0.0000089674 -0.0000073146 -# File: 86 +# File: 86 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 41 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0061177212 0.0014099476 -0.0014099627 @@ -5759,7 +5759,7 @@ 0.0001397326 -0.0000806495 -0.0001287325 0.0001499067 -0.0000204104 -0.0000501780 0.0000104162 -0.0000194795 0.0000221996 -# File: 87 +# File: 87 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 41 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0101639388 -0.0015242652 0.0015242500 @@ -5826,7 +5826,7 @@ -0.0001082609 0.0000476910 0.0001088612 0.0001081172 -0.0000082509 0.0000213041 -0.0000313356 -0.0000072918 -0.0000493076 -# File: 88 +# File: 88 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 42 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0080938641 -0.0000284858 -0.0000228345 @@ -5893,7 +5893,7 @@ 0.0000802568 -0.0002817176 0.0000594730 0.0001351422 -0.0000178797 -0.0000204502 -0.0000045751 -0.0000177920 -0.0000073850 -# File: 89 +# File: 89 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 42 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0081377671 0.0000286698 0.0000220590 @@ -5960,7 +5960,7 @@ -0.0000524226 0.0002504518 -0.0000733093 0.0001231352 -0.0000098890 -0.0000083402 -0.0000165796 -0.0000098329 -0.0000195347 -# File: 90 +# File: 90 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 42 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081220242 0.0000218067 -0.0000218219 @@ -6027,7 +6027,7 @@ 0.0001352191 -0.0000780165 0.0001085350 0.0001499316 -0.0000203145 0.0000212052 0.0000102430 -0.0000195004 -0.0000492279 -# File: 91 +# File: 91 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 42 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081085112 -0.0000222753 0.0000222601 @@ -6094,7 +6094,7 @@ -0.0001142766 0.0000509047 -0.0001283969 0.0001082381 -0.0000082523 -0.0000500991 -0.0000313486 -0.0000073366 0.0000221403 -# File: 92 +# File: 92 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 43 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081446245 0.0000216279 -0.0000238355 @@ -6161,7 +6161,7 @@ 0.0000339238 -0.0000209760 0.0000278529 0.0002512094 -0.0000770591 0.0001016341 0.0001169086 -0.0000793052 -0.0001339197 -# File: 93 +# File: 93 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 43 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0080862628 -0.0000222249 0.0000229846 @@ -6228,7 +6228,7 @@ -0.0000077439 -0.0000090461 -0.0000437913 0.0000014365 0.0000512382 -0.0001344279 -0.0001328958 0.0000495015 0.0001026070 -# File: 94 +# File: 94 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 43 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0080927872 -0.0000060334 -0.0000215475 @@ -6295,7 +6295,7 @@ 0.0000192217 -0.0000186788 -0.0000138697 0.0001962900 -0.0002807923 0.0000530301 0.0000549807 -0.0002788081 -0.0000789421 -# File: 95 +# File: 95 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 43 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0081390438 0.0000068748 0.0000220895 @@ -6362,7 +6362,7 @@ 0.0000071414 -0.0000104870 -0.0000018129 0.0000635094 0.0002509614 -0.0000799430 -0.0000777059 0.0002533327 0.0000538400 -# File: 96 +# File: 96 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 43 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0081366335 -0.0000219259 -0.0000276836 @@ -6429,7 +6429,7 @@ 0.0000490190 -0.0000089101 0.0000129964 0.0002455635 -0.0000770070 0.0001079696 -0.0001268384 0.0000497185 0.0001087858 -# File: 97 +# File: 97 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 43 0.0000000000000000 0.0000000000000000 -0.0600000000000000 -0.0080939327 0.0000215150 0.0000274648 @@ -6496,7 +6496,7 @@ -0.0000225865 -0.0000210209 -0.0000286718 0.0000084536 0.0000511651 -0.0001420863 0.0001098969 -0.0000793003 -0.0001410828 -# File: 98 +# File: 98 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 44 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081036155 0.0000069172 -0.0000147630 @@ -6563,7 +6563,7 @@ 0.0000337956 -0.0000210693 -0.0000435829 0.0002565055 -0.0000804127 -0.0001350219 0.0001117176 -0.0000763369 0.0001028951 -# File: 99 +# File: 99 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 44 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081264361 -0.0000061198 0.0000137564 @@ -6630,7 +6630,7 @@ -0.0000076962 -0.0000089865 0.0000277906 0.0000068382 0.0000489063 0.0001020378 -0.0001379850 0.0000524360 -0.0001340390 -# File: 100 +# File: 100 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 44 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0081085727 0.0000122810 -0.0000145282 @@ -6697,7 +6697,7 @@ 0.0000190547 -0.0000194727 -0.0000018280 0.0001945969 -0.0002797711 -0.0000798508 0.0000567107 -0.0002800762 0.0000538115 -# File: 101 +# File: 101 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 44 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0081218900 -0.0000111568 0.0000134991 @@ -6764,7 +6764,7 @@ 0.0000069591 -0.0000115311 -0.0000138501 0.0000617584 0.0002525012 0.0000529859 -0.0000760446 0.0002520531 -0.0000789192 -# File: 102 +# File: 102 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 44 0.0000000000000000 0.0000000000000000 0.0600000000000000 -0.0081290363 -0.0000142867 0.0001302213 @@ -6831,7 +6831,7 @@ -0.0000226974 -0.0000211747 0.0000129873 0.0000128890 0.0000488203 0.0001080333 0.0001057613 -0.0000762893 0.0001088393 -# File: 103 +# File: 103 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 44 0.0000000000000000 0.0000000000000000 -0.0600000000000000 -0.0081022002 0.0000140624 -0.0001288912 @@ -6898,7 +6898,7 @@ 0.0000485881 -0.0000088883 -0.0000285784 0.0002495883 -0.0000803321 -0.0001418864 -0.0001311698 0.0000523972 -0.0001408823 -# File: 104 +# File: 104 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 47 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0081002271 0.0000128777 -0.0000072762 @@ -6965,7 +6965,7 @@ 0.0000071205 -0.0000195273 -0.0000137034 0.0000636091 -0.0002796411 0.0000510025 -0.0000778141 -0.0002800266 -0.0000806016 -# File: 105 +# File: 105 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 47 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0081296823 -0.0000118641 0.0000065369 @@ -7032,7 +7032,7 @@ 0.0000191984 -0.0000113252 -0.0000016557 0.0001961956 0.0002523815 -0.0000812819 0.0000550835 0.0002519749 0.0000521088 -# File: 106 +# File: 106 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 47 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0079853238 0.0000141560 -0.0000141711 @@ -7099,7 +7099,7 @@ 0.0000339894 -0.0000090370 -0.0000433699 0.0002512392 0.0000487961 -0.0001303492 0.0001168264 0.0000521674 0.0001071024 -# File: 107 +# File: 107 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 47 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0082472240 -0.0000144675 0.0000144526 @@ -7166,7 +7166,7 @@ -0.0000077192 -0.0000210215 0.0000281651 0.0000016274 -0.0000802971 0.0001061116 -0.0001325917 -0.0000761072 -0.0001295603 -# File: 108 +# File: 108 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 48 0.0000000000000000 0.0600000000000000 0.0000000000000000 -0.0081021485 -0.0000103551 -0.0000129714 @@ -7233,7 +7233,7 @@ 0.0000071157 -0.0000188461 -0.0000017929 0.0000615356 -0.0002810103 -0.0000817762 -0.0000760023 -0.0002788127 0.0000520561 -# File: 109 +# File: 109 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 48 0.0000000000000000 -0.0600000000000000 0.0000000000000000 -0.0081292533 0.0000103640 0.0000132240 @@ -7300,7 +7300,7 @@ 0.0000190207 -0.0000105364 -0.0000136681 0.0001948955 0.0002510884 0.0000514980 0.0000567152 0.0002532579 -0.0000805910 -# File: 110 +# File: 110 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 48 0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081259458 0.0000133926 -0.0000134078 @@ -7367,7 +7367,7 @@ 0.0000338315 -0.0000089409 0.0000280763 0.0002565534 0.0000515445 0.0001064355 0.0001116565 0.0000496164 -0.0001296366 -# File: 111 +# File: 111 # 1 0.0600000000000000 0.0000000000000000 0.0000000000000000 # 48 -0.0600000000000000 0.0000000000000000 0.0000000000000000 -0.0081052377 -0.0000136036 0.0000135884 diff --git a/example/Si-TURBOMOLE/README b/example/Si-TURBOMOLE/README index b4355a46..edd36927 100644 --- a/example/Si-TURBOMOLE/README +++ b/example/Si-TURBOMOLE/README @@ -6,7 +6,7 @@ so the -c control parameter is not needed 1) Create displaced supercells 2x2x2 conventional cell for 3rd order FC 3x3x3 conventional cell for 2nd order FC - + phono3py --turbomole --dim="2 2 2" --dim-fc2="3 3 3" -d Complete TURBOMOLE inputs can be prepared manually @@ -32,4 +32,3 @@ so the -c control parameter is not needed --br -> Relaxation time approximation With 20x20x20 mesh, the lattice thermal conductivity at 300 K is 142 W m^-1 K^-1. - diff --git a/example/Si-TURBOMOLE/control b/example/Si-TURBOMOLE/control index e8192d29..3ed7940e 100644 --- a/example/Si-TURBOMOLE/control +++ b/example/Si-TURBOMOLE/control @@ -1,9 +1,9 @@ $periodic 3 $lattice - 10.357962933 0.0000000000 0.0000000000 - 0.0000000000 10.357962933 0.0000000000 + 10.357962933 0.0000000000 0.0000000000 + 0.0000000000 10.357962933 0.0000000000 0.0000000000 0.0000000000 10.357962933 -$coord file=coord +$coord file=coord $kpoints nkpoints 6 6 6 $riper diff --git a/example/Si-TURBOMOLE/coord b/example/Si-TURBOMOLE/coord index e2cd6ffa..d9a3de23 100644 --- a/example/Si-TURBOMOLE/coord +++ b/example/Si-TURBOMOLE/coord @@ -8,4 +8,3 @@ $coord 5.17898184151 0.00000000000 5.17898184151 si 0.00000000000 5.17898184151 5.17898184151 si $end - 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 9931c9f5..d15d2341 100644 --- a/example/zb-ZnTe-PBEsol/launch_phono3py_ZnTe_PBEsol_222.py +++ b/example/zb-ZnTe-PBEsol/launch_phono3py_ZnTe_PBEsol_222.py @@ -1,14 +1,14 @@ -import copy +"""Launch script of ZnTe AiiDA calculation using aiida-phononpy.""" from phonopy.interface.vasp import read_vasp_from_strings from aiida.manage.configuration import load_profile -from aiida.orm import Int, Float, Bool, Str, load_node, QueryBuilder +from aiida.orm import Float, Bool, Str from aiida.plugins import DataFactory, WorkflowFactory -from aiida.engine import run, submit +from aiida.engine import submit from aiida_phonopy.common.utils import phonopy_atoms_to_structure load_profile() -Dict = DataFactory('dict') +Dict = DataFactory("dict") def get_settings(cutoff_energy, is_nac=False): @@ -33,87 +33,100 @@ Direct structure = phonopy_atoms_to_structure(cell) base_incar_dict = { - 'PREC': 'Accurate', - 'IBRION': -1, - 'EDIFF': 1e-8, - 'NELMIN': 5, - 'NELM': 100, - 'ENCUT': cutoff_energy, - 'IALGO': 38, - 'ISMEAR': 0, - 'SIGMA': 0.01, - 'GGA' : 'PS', - 'LREAL': False, - 'lcharg': False, - 'lwave': False, + "PREC": "Accurate", + "IBRION": -1, + "EDIFF": 1e-8, + "NELMIN": 5, + "NELM": 100, + "ENCUT": cutoff_energy, + "IALGO": 38, + "ISMEAR": 0, + "SIGMA": 0.01, + "GGA": "PS", + "LREAL": False, + "lcharg": False, + "lwave": False, } - code_string = 'vasp544mpi@nancy' - resources = {'parallel_env': 'mpi*', 'tot_num_mpiprocs': 24} + code_string = "vasp544mpi@nancy" + resources = {"parallel_env": "mpi*", "tot_num_mpiprocs": 24} - base_config = {'code_string': code_string, - 'potential_family': 'PBE.54', - 'potential_mapping': {'Zn': 'Zn', 'Te': 'Te'}, - 'options': {'resources': resources, - 'max_wallclock_seconds': 3600 * 10}} - base_parser_settings = {'add_energies': True, - 'add_forces': True, - 'add_stress': True} + base_config = { + "code_string": code_string, + "potential_family": "PBE.54", + "potential_mapping": {"Zn": "Zn", "Te": "Te"}, + "options": {"resources": resources, "max_wallclock_seconds": 3600 * 10}, + } + base_parser_settings = { + "add_energies": True, + "add_forces": True, + "add_stress": True, + } forces_config = base_config.copy() kpoints_mesh = [2, 2, 2] - forces_config.update({'kpoints_mesh': kpoints_mesh, - 'kpoints_offset': [0.5, 0.5, 0.5], - 'parser_settings': base_parser_settings, - 'parameters': {'incar': base_incar_dict.copy()}}) - forces_config['parameters']['incar']['NPAR'] = 4 - nac_config = {'code_string': code_string, - 'potential_family': 'PBE.54', - 'potential_mapping': {'Zn': 'Zn', 'Te': 'Te'}, - 'options': {'resources': resources, - 'max_wallclock_seconds': 3600 * 10}} - nac_parser_settings = {'add_born_charges': True, - 'add_dielectrics': True} + forces_config.update( + { + "kpoints_mesh": kpoints_mesh, + "kpoints_offset": [0.5, 0.5, 0.5], + "parser_settings": base_parser_settings, + "parameters": {"incar": base_incar_dict.copy()}, + } + ) + forces_config["parameters"]["incar"]["NPAR"] = 4 + nac_config = { + "code_string": code_string, + "potential_family": "PBE.54", + "potential_mapping": {"Zn": "Zn", "Te": "Te"}, + "options": {"resources": resources, "max_wallclock_seconds": 3600 * 10}, + } + nac_parser_settings = {"add_born_charges": True, "add_dielectrics": True} nac_parser_settings.update(base_parser_settings) - nac_incar_dict = {'lepsilon': True} + nac_incar_dict = {"lepsilon": True} nac_incar_dict.update(base_incar_dict.copy()) - nac_config.update({'kpoints_mesh': [8, 8, 8], - 'kpoints_offset': [0.5, 0.5, 0.5], - 'parser_settings': nac_parser_settings, - 'parameters': {'incar': nac_incar_dict}}) - phonon_settings = {'supercell_matrix': [2, 2, 2], - 'distance': 0.03} + nac_config.update( + { + "kpoints_mesh": [8, 8, 8], + "kpoints_offset": [0.5, 0.5, 0.5], + "parser_settings": nac_parser_settings, + "parameters": {"incar": nac_incar_dict}, + } + ) + phonon_settings = {"supercell_matrix": [2, 2, 2], "distance": 0.03} if is_nac: - phonon_settings['is_nac'] = is_nac + phonon_settings["is_nac"] = is_nac return structure, forces_config, nac_config, phonon_settings def launch_phono3py(cutoff_energy=350, is_nac=False): structure, forces_config, nac_config, phonon_settings = get_settings( - cutoff_energy, is_nac) - Phono3pyWorkChain = WorkflowFactory('phonopy.phono3py') + cutoff_energy, is_nac + ) + Phono3pyWorkChain = WorkflowFactory("phonopy.phono3py") builder = Phono3pyWorkChain.get_builder() builder.structure = structure - builder.calculator_settings = Dict(dict={'forces': forces_config, - 'nac': nac_config}) + builder.calculator_settings = Dict( + dict={"forces": forces_config, "nac": nac_config} + ) builder.run_phono3py = Bool(False) builder.remote_phono3py = Bool(False) - builder.code_string = Str('phonopy@nancy') + builder.code_string = Str("phonopy@nancy") builder.phonon_settings = Dict(dict=phonon_settings) builder.symmetry_tolerance = Float(1e-5) - builder.options = Dict(dict=forces_config['options']) - dim = phonon_settings['supercell_matrix'] - kpoints_mesh = forces_config['kpoints_mesh'] - label = ("ZnTe phono3py %dx%dx%d kpt %dx%dx%d PBEsol %d eV" - % (tuple(dim) + tuple(kpoints_mesh) + (cutoff_energy, ))) + builder.options = Dict(dict=forces_config["options"]) + dim = phonon_settings["supercell_matrix"] + kpoints_mesh = forces_config["kpoints_mesh"] + label = "ZnTe phono3py %dx%dx%d kpt %dx%dx%d PBEsol %d eV" % ( + tuple(dim) + tuple(kpoints_mesh) + (cutoff_energy,) + ) builder.metadata.label = label builder.metadata.description = label future = submit(builder) print(label) print(future) - print('Running workchain with pk={}'.format(future.pk)) + print("Running workchain with pk={}".format(future.pk)) -if __name__ == '__main__': +if __name__ == "__main__": launch_phono3py(cutoff_energy=500, is_nac=True) diff --git a/phono3py/__init__.py b/phono3py/__init__.py index 7db4f39b..058516ff 100644 --- a/phono3py/__init__.py +++ b/phono3py/__init__.py @@ -1,3 +1,4 @@ +"""Shortcuts to important classes, methods, and variables.""" # Copyright (C) 2019 Atsushi Togo # All rights reserved. # @@ -32,8 +33,8 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -from phono3py.version import __version__ -from phono3py.api_phono3py import Phono3py -from phono3py.api_jointdos import Phono3pyJointDos -from phono3py.api_isotope import Phono3pyIsotope -from phono3py.cui.load import load +from phono3py.version import __version__ # noqa F401 +from phono3py.api_phono3py import Phono3py # noqa F401 +from phono3py.api_jointdos import Phono3pyJointDos # noqa F401 +from phono3py.api_isotope import Phono3pyIsotope # noqa F401 +from phono3py.cui.load import load # noqa F401 diff --git a/phono3py/api_isotope.py b/phono3py/api_isotope.py index 952d5d51..7741876b 100644 --- a/phono3py/api_isotope.py +++ b/phono3py/api_isotope.py @@ -38,31 +38,37 @@ from phono3py.other.isotope import Isotope class Phono3pyIsotope(object): - def __init__(self, - mesh, - primitive, - mass_variances=None, # length of list is num_atom. - band_indices=None, - sigmas=None, - frequency_factor_to_THz=VaspToTHz, - store_dense_gp_map=False, - symprec=1e-5, - cutoff_frequency=None, - lapack_zheev_uplo='L'): + def __init__( + self, + mesh, + primitive, + mass_variances=None, # length of list is num_atom. + band_indices=None, + sigmas=None, + frequency_factor_to_THz=VaspToTHz, + store_dense_gp_map=False, + symprec=1e-5, + cutoff_frequency=None, + lapack_zheev_uplo="L", + ): if sigmas is None: - self._sigmas = [None, ] + self._sigmas = [ + None, + ] else: self._sigmas = sigmas self._mesh_numbers = mesh - self._iso = Isotope(mesh, - primitive, - mass_variances=mass_variances, - band_indices=band_indices, - frequency_factor_to_THz=frequency_factor_to_THz, - store_dense_gp_map=store_dense_gp_map, - symprec=symprec, - cutoff_frequency=cutoff_frequency, - lapack_zheev_uplo=lapack_zheev_uplo) + self._iso = Isotope( + mesh, + primitive, + mass_variances=mass_variances, + band_indices=band_indices, + frequency_factor_to_THz=frequency_factor_to_THz, + store_dense_gp_map=store_dense_gp_map, + symprec=symprec, + cutoff_frequency=cutoff_frequency, + lapack_zheev_uplo=lapack_zheev_uplo, + ) @property def dynamical_matrix(self): @@ -75,7 +81,8 @@ class Phono3pyIsotope(object): def run(self, grid_points): gamma = np.zeros( (len(self._sigmas), len(grid_points), len(self._iso.band_indices)), - dtype='double') + dtype="double", + ) for j, gp in enumerate(grid_points): self._iso.set_grid_point(gp) @@ -83,7 +90,7 @@ class Phono3pyIsotope(object): print("--------------- Isotope scattering ---------------") print("Grid point: %d" % gp) adrs = self._iso.bz_grid.addresses[gp] - q = adrs.astype('double') / self._mesh_numbers + q = adrs.astype("double") / self._mesh_numbers print("q-point: %s" % q) if self._sigmas: @@ -96,7 +103,7 @@ class Phono3pyIsotope(object): self._iso.run() gamma[i, j] = self._iso.gamma frequencies = self._iso.get_phonons()[0] - print('') + print("") print("Phonon-isotope scattering rate in THz (1/4pi-tau)") print(" Frequency Rate") for g, f in zip(self._iso.gamma, frequencies[gp]): @@ -105,13 +112,15 @@ class Phono3pyIsotope(object): print("sigma or tetrahedron method has to be set.") self._gamma = gamma - def init_dynamical_matrix(self, - fc2, - supercell, - primitive, - nac_params=None, - frequency_scale_factor=None, - decimals=None): + def init_dynamical_matrix( + self, + fc2, + supercell, + primitive, + nac_params=None, + frequency_scale_factor=None, + decimals=None, + ): self._primitive = primitive self._iso.init_dynamical_matrix( fc2, @@ -119,7 +128,8 @@ class Phono3pyIsotope(object): primitive, nac_params=nac_params, frequency_scale_factor=frequency_scale_factor, - decimals=decimals) + decimals=decimals, + ) def set_sigma(self, sigma): self._iso.set_sigma(sigma) diff --git a/phono3py/api_jointdos.py b/phono3py/api_jointdos.py index 2cb22568..8564c1a1 100644 --- a/phono3py/api_jointdos.py +++ b/phono3py/api_jointdos.py @@ -42,25 +42,27 @@ from phono3py.file_IO import write_joint_dos class Phono3pyJointDos(object): - def __init__(self, - supercell, - primitive, - fc2, - mesh=None, - nac_params=None, - nac_q_direction=None, - sigmas=None, - cutoff_frequency=1e-4, - frequency_step=None, - num_frequency_points=None, - temperatures=None, - frequency_factor_to_THz=VaspToTHz, - frequency_scale_factor=None, - is_mesh_symmetry=True, - store_dense_gp_map=False, - symprec=1e-5, - output_filename=None, - log_level=0): + def __init__( + self, + supercell, + primitive, + fc2, + mesh=None, + nac_params=None, + nac_q_direction=None, + sigmas=None, + cutoff_frequency=1e-4, + frequency_step=None, + num_frequency_points=None, + temperatures=None, + frequency_factor_to_THz=VaspToTHz, + frequency_scale_factor=None, + is_mesh_symmetry=True, + store_dense_gp_map=False, + symprec=1e-5, + output_filename=None, + log_level=0, + ): if sigmas is None: self._sigmas = [None] else: @@ -71,10 +73,12 @@ class Phono3pyJointDos(object): self._log_level = log_level symmetry = Symmetry(primitive, symprec) - self._bz_grid = BZGrid(mesh, - lattice=primitive.cell, - symmetry_dataset=symmetry.dataset, - store_dense_gp_map=store_dense_gp_map) + self._bz_grid = BZGrid( + mesh, + lattice=primitive.cell, + symmetry_dataset=symmetry.dataset, + store_dense_gp_map=store_dense_gp_map, + ) self._jdos = JointDos( primitive, @@ -93,7 +97,8 @@ class Phono3pyJointDos(object): store_dense_gp_map=store_dense_gp_map, symprec=symprec, filename=output_filename, - log_level=self._log_level) + log_level=self._log_level, + ) self._joint_dos = None @@ -103,8 +108,10 @@ class Phono3pyJointDos(object): def run(self, grid_points, write_jdos=False): if self._log_level: - print("--------------------------------- Joint DOS " - "---------------------------------") + print( + "--------------------------------- Joint DOS " + "---------------------------------" + ) print("Sampling mesh: [ %d %d %d ]" % tuple(self._bz_grid.D_diag)) for i, gp in enumerate(grid_points): @@ -112,10 +119,11 @@ class Phono3pyJointDos(object): if self._log_level: weights = self._jdos.get_triplets_at_q()[1] - print("======================= " - "Grid point %d (%d/%d) " - "=======================" - % (gp, i + 1, len(grid_points))) + print( + "======================= " + "Grid point %d (%d/%d) " + "=======================" % (gp, i + 1, len(grid_points)) + ) adrs = self._jdos.bz_grid.addresses[gp] q = np.dot(adrs, self._bz_grid.QDinv.T) print("q-point: (%5.2f %5.2f %5.2f)" % tuple(q)) @@ -125,8 +133,7 @@ class Phono3pyJointDos(object): print("%8.3f" % f) if not self._sigmas: - raise RuntimeError( - "sigma or tetrahedron method has to be set.") + raise RuntimeError("sigma or tetrahedron method has to be set.") for sigma in self._sigmas: if self._log_level: @@ -140,7 +147,7 @@ class Phono3pyJointDos(object): if write_jdos: filename = self._write(gp, sigma=sigma) if self._log_level: - print("JDOS is written into \"%s\"." % filename) + print('JDOS is written into "%s".' % filename) @property def dynamical_matrix(self): @@ -155,11 +162,13 @@ class Phono3pyJointDos(object): return self._jdos.joint_dos def _write(self, gp, sigma=None): - return write_joint_dos(gp, - self._bz_grid.D_diag, - self._jdos.frequency_points, - self._jdos.joint_dos, - sigma=sigma, - temperatures=self._temperatures, - filename=self._filename, - is_mesh_symmetry=self._is_mesh_symmetry) + return write_joint_dos( + gp, + self._bz_grid.D_diag, + self._jdos.frequency_points, + self._jdos.joint_dos, + sigma=sigma, + temperatures=self._temperatures, + filename=self._filename, + is_mesh_symmetry=self._is_mesh_symmetry, + ) diff --git a/phono3py/api_phono3py.py b/phono3py/api_phono3py.py index ab82fa20..d942ebe6 100644 --- a/phono3py/api_phono3py.py +++ b/phono3py/api_phono3py.py @@ -2123,7 +2123,6 @@ class Phono3py(object): boundary_mfp=None, # in micrometre solve_collective_phonon=False, use_ave_pp=False, - gamma_unit_conversion=None, is_reducible_collision_matrix=False, is_kappa_star=True, gv_delta_q=None, # for group velocity @@ -2179,10 +2178,6 @@ class Phono3py(object): strength is used to calculate phonon lifetime. This does not reduce computational demand, but may be used to model thermal conductivity for analyze the calculation results. - gamma_unit_conversion : float, optional, default is None - RTA only (`is_LBTE=False`). Unit conversion factor when calculating - inversion phonon lifetime. This option should not be used - by users. is_reducible_collision_matrix : bool, optional, default is False Direct solution only (`is_LBTE=True`). This is an experimental option. With True, full collision matrix is created and solved. @@ -2330,7 +2325,6 @@ class Phono3py(object): grid_points=grid_points, boundary_mfp=boundary_mfp, use_ave_pp=use_ave_pp, - gamma_unit_conversion=gamma_unit_conversion, is_kappa_star=is_kappa_star, gv_delta_q=gv_delta_q, is_full_pp=is_full_pp, diff --git a/phono3py/cui/__init__.py b/phono3py/cui/__init__.py index e69de29b..ef701ecd 100644 --- a/phono3py/cui/__init__.py +++ b/phono3py/cui/__init__.py @@ -0,0 +1 @@ +"""Command user interface related routines.""" diff --git a/phono3py/cui/create_force_constants.py b/phono3py/cui/create_force_constants.py index b184984e..a54601c0 100644 --- a/phono3py/cui/create_force_constants.py +++ b/phono3py/cui/create_force_constants.py @@ -39,34 +39,44 @@ import numpy as np from phonopy.harmonic.force_constants import ( show_drift_force_constants, symmetrize_force_constants, - symmetrize_compact_force_constants) -from phonopy.file_IO import get_dataset_type2, parse_FORCE_SETS + symmetrize_compact_force_constants, +) +from phonopy.file_IO import get_dataset_type2 from phonopy.cui.phonopy_script import print_error, file_exists from phonopy.interface.calculator import get_default_physical_units from phono3py.phonon3.fc3 import show_drift_fc3 from phono3py.file_IO import ( - parse_disp_fc3_yaml, parse_disp_fc2_yaml, parse_FORCES_FC2, - parse_FORCES_FC3, read_fc3_from_hdf5, read_fc2_from_hdf5, - write_fc3_to_hdf5, write_fc2_to_hdf5, get_length_of_first_line) + parse_disp_fc3_yaml, + parse_disp_fc2_yaml, + parse_FORCES_FC2, + parse_FORCES_FC3, + read_fc3_from_hdf5, + read_fc2_from_hdf5, + write_fc3_to_hdf5, + write_fc2_to_hdf5, + get_length_of_first_line, +) from phono3py.cui.show_log import show_phono3py_force_constants_settings from phono3py.phonon3.fc3 import ( - set_permutation_symmetry_fc3, set_translational_invariance_fc3) + set_permutation_symmetry_fc3, + set_translational_invariance_fc3, +) from phono3py.interface.phono3py_yaml import Phono3pyYaml -def create_phono3py_force_constants(phono3py, - settings, - ph3py_yaml=None, - input_filename=None, - output_filename=None, - phono3py_yaml_filename=None, - log_level=1): +def create_phono3py_force_constants( + phono3py, + settings, + ph3py_yaml=None, + input_filename=None, + output_filename=None, + phono3py_yaml_filename=None, + log_level=1, +): """Read or calculate force constants.""" if settings.fc_calculator is None: - symmetrize_fc3r = (settings.is_symmetrize_fc3_r or - settings.fc_symmetry) - symmetrize_fc2 = (settings.is_symmetrize_fc2 or - settings.fc_symmetry) + symmetrize_fc3r = settings.is_symmetrize_fc3_r or settings.fc_symmetry + symmetrize_fc2 = settings.is_symmetrize_fc2 or settings.fc_symmetry else: # Rely on fc calculator the symmetrization of fc. symmetrize_fc2 = False symmetrize_fc3r = False @@ -77,46 +87,49 @@ def create_phono3py_force_constants(phono3py, ####### # fc3 # ####### - if (settings.is_joint_dos or - (settings.is_isotope and - not (settings.is_bterta or settings.is_lbte)) or - settings.read_gamma or - settings.read_pp or - (not settings.is_bterta and settings.write_phonon) or - settings.constant_averaged_pp_interaction is not None): # noqa E129 + if ( + settings.is_joint_dos + or (settings.is_isotope and not (settings.is_bterta or settings.is_lbte)) + or settings.read_gamma + or settings.read_pp + or (not settings.is_bterta and settings.write_phonon) + or settings.constant_averaged_pp_interaction is not None + ): # noqa E129 pass else: if settings.read_fc3: - _read_phono3py_fc3(phono3py, - symmetrize_fc3r, - input_filename, - log_level) + _read_phono3py_fc3(phono3py, symmetrize_fc3r, input_filename, log_level) else: # fc3 from FORCES_FC3 or ph3py_yaml - _create_phono3py_fc3(phono3py, - ph3py_yaml, - symmetrize_fc3r, - input_filename, - settings.is_compact_fc, - settings.cutoff_pair_distance, - settings.fc_calculator, - settings.fc_calculator_options, - log_level) + _create_phono3py_fc3( + phono3py, + ph3py_yaml, + symmetrize_fc3r, + input_filename, + settings.is_compact_fc, + settings.cutoff_pair_distance, + settings.fc_calculator, + settings.fc_calculator_options, + log_level, + ) if output_filename is None: - filename = 'fc3.hdf5' + filename = "fc3.hdf5" else: - filename = 'fc3.' + output_filename + '.hdf5' + filename = "fc3." + output_filename + ".hdf5" if log_level: - print("Writing fc3 to \"%s\"." % filename) - write_fc3_to_hdf5(phono3py.fc3, - filename=filename, - p2s_map=phono3py.primitive.p2s_map, - compression=settings.hdf5_compression) + print('Writing fc3 to "%s".' % filename) + write_fc3_to_hdf5( + phono3py.fc3, + filename=filename, + p2s_map=phono3py.primitive.p2s_map, + compression=settings.hdf5_compression, + ) cutoff_distance = settings.cutoff_fc3_distance if cutoff_distance is not None and cutoff_distance > 0: if log_level: - print("Cutting-off fc3 by zero (cut-off distance: %f)" % - cutoff_distance) + print( + "Cutting-off fc3 by zero (cut-off distance: %f)" % cutoff_distance + ) phono3py.cutoff_fc3_by_zero(cutoff_distance) if log_level: @@ -128,63 +141,65 @@ def create_phono3py_force_constants(phono3py, phonon_primitive = phono3py.phonon_primitive p2s_map = phonon_primitive.p2s_map if settings.read_fc2: - _read_phono3py_fc2(phono3py, - symmetrize_fc2, - input_filename, - log_level) + _read_phono3py_fc2(phono3py, symmetrize_fc2, input_filename, log_level) else: if phono3py.phonon_supercell_matrix is None: - if (settings.fc_calculator == 'alm' and phono3py.fc2 is not None): + if settings.fc_calculator == "alm" and phono3py.fc2 is not None: if log_level: - print("fc2 that was fit simultaneously with fc3 " - "by ALM is used.") + print("fc2 that was fit simultaneously with fc3 " "by ALM is used.") else: - _create_phono3py_fc2(phono3py, - ph3py_yaml, - symmetrize_fc2, - input_filename, - settings.is_compact_fc, - settings.fc_calculator, - settings.fc_calculator_options, - log_level) + _create_phono3py_fc2( + phono3py, + ph3py_yaml, + symmetrize_fc2, + input_filename, + settings.is_compact_fc, + settings.fc_calculator, + settings.fc_calculator_options, + log_level, + ) else: - _create_phono3py_phonon_fc2(phono3py, - ph3py_yaml, - symmetrize_fc2, - input_filename, - settings.is_compact_fc, - settings.fc_calculator, - settings.fc_calculator_options, - log_level) + _create_phono3py_phonon_fc2( + phono3py, + ph3py_yaml, + symmetrize_fc2, + input_filename, + settings.is_compact_fc, + settings.fc_calculator, + settings.fc_calculator_options, + log_level, + ) if output_filename is None: - filename = 'fc2.hdf5' + filename = "fc2.hdf5" else: - filename = 'fc2.' + output_filename + '.hdf5' + filename = "fc2." + output_filename + ".hdf5" if log_level: - print("Writing fc2 to \"%s\"." % filename) - write_fc2_to_hdf5(phono3py.fc2, - filename=filename, - p2s_map=p2s_map, - physical_unit='eV/angstrom^2', - compression=settings.hdf5_compression) + print('Writing fc2 to "%s".' % filename) + write_fc2_to_hdf5( + phono3py.fc2, + filename=filename, + p2s_map=p2s_map, + physical_unit="eV/angstrom^2", + compression=settings.hdf5_compression, + ) if log_level: - show_drift_force_constants(phono3py.fc2, - primitive=phonon_primitive, - name='fc2') + show_drift_force_constants(phono3py.fc2, primitive=phonon_primitive, name="fc2") -def parse_forces(phono3py, - ph3py_yaml=None, - cutoff_pair_distance=None, - force_filename="FORCES_FC3", - disp_filename=None, - fc_type=None, - log_level=0): +def parse_forces( + phono3py, + ph3py_yaml=None, + cutoff_pair_distance=None, + force_filename="FORCES_FC3", + disp_filename=None, + fc_type=None, + log_level=0, +): """Read displacements and forces.""" filename_read_from = None - if fc_type == 'phonon_fc2': + if fc_type == "phonon_fc2": natom = len(phono3py.phonon_supercell) else: natom = len(phono3py.supercell) @@ -197,12 +212,12 @@ def parse_forces(phono3py, # Try to read FORCES_FC* if type-2 and return dataset. # None is returned unless type-2. # can emit FileNotFoundError. - if (dataset is None or - dataset is not None and not forces_in_dataset(dataset)): # noqa E129 - _dataset = _get_type2_dataset(natom, - phono3py.calculator, - filename=force_filename, - log_level=log_level) + if ( + dataset is None or dataset is not None and not forces_in_dataset(dataset) + ): # noqa E129 + _dataset = _get_type2_dataset( + natom, phono3py.calculator, filename=force_filename, log_level=log_level + ) # Do not overwrite dataset when _dataset is None. if _dataset: filename_read_from = force_filename @@ -214,34 +229,38 @@ def parse_forces(phono3py, dataset = _read_disp_fc_yaml(disp_filename, fc_type) filename_read_from = disp_filename - if 'natom' in dataset and dataset['natom'] != natom: - msg = ("Number of atoms in supercell is not consistent with " - "\"%s\"." % filename_read_from) + if "natom" in dataset and dataset["natom"] != natom: + msg = ( + "Number of atoms in supercell is not consistent with " + '"%s".' % filename_read_from + ) raise RuntimeError(msg) if log_level and filename_read_from is not None: - print("Displacement dataset for %s was read from \"%s\"." - % (fc_type, filename_read_from)) + print( + 'Displacement dataset for %s was read from "%s".' + % (fc_type, filename_read_from) + ) if cutoff_pair_distance: - if ('cutoff_distance' not in dataset or - ('cutoff_distance' in dataset and - cutoff_pair_distance < dataset['cutoff_distance'])): - dataset['cutoff_distance'] = cutoff_pair_distance + if "cutoff_distance" not in dataset or ( + "cutoff_distance" in dataset + and cutoff_pair_distance < dataset["cutoff_distance"] + ): + dataset["cutoff_distance"] = cutoff_pair_distance if log_level: print("Cutoff-pair-distance: %f" % cutoff_pair_distance) # Type-1 FORCES_FC*. # dataset comes either from disp_fc*.yaml or phono3py*.yaml. if not forces_in_dataset(dataset): - if fc_type == 'phonon_fc2': + if fc_type == "phonon_fc2": parse_FORCES_FC2(dataset, filename=force_filename) else: parse_FORCES_FC3(dataset, filename=force_filename) if log_level: - print("Sets of supercell forces were read from \"%s\"." - % force_filename) + print('Sets of supercell forces were read from "%s".' % force_filename) sys.stdout.flush() _convert_unit_in_dataset(dataset, phono3py.calculator) @@ -251,13 +270,13 @@ def parse_forces(phono3py, def forces_in_dataset(dataset): """Return whether forces in dataset or not.""" - return ('forces' in dataset or - ('first_atoms' in dataset and - 'forces' in dataset['first_atoms'][0])) + return "forces" in dataset or ( + "first_atoms" in dataset and "forces" in dataset["first_atoms"][0] + ) def _read_disp_fc_yaml(disp_filename, fc_type): - if fc_type == 'phonon_fc2': + if fc_type == "phonon_fc2": dataset = parse_disp_fc2_yaml(filename=disp_filename) else: dataset = parse_disp_fc3_yaml(filename=disp_filename) @@ -265,23 +284,21 @@ def _read_disp_fc_yaml(disp_filename, fc_type): return dataset -def _read_phono3py_fc3(phono3py, - symmetrize_fc3r, - input_filename, - log_level): +def _read_phono3py_fc3(phono3py, symmetrize_fc3r, input_filename, log_level): if input_filename is None: - filename = 'fc3.hdf5' + filename = "fc3.hdf5" else: - filename = 'fc3.' + input_filename + '.hdf5' + filename = "fc3." + input_filename + ".hdf5" file_exists(filename, log_level) if log_level: - print("Reading fc3 from \"%s\"." % filename) + print('Reading fc3 from "%s".' % filename) p2s_map = phono3py.primitive.p2s_map try: fc3 = read_fc3_from_hdf5(filename=filename, p2s_map=p2s_map) except RuntimeError: import traceback + traceback.print_exc() if log_level: print_error() @@ -300,17 +317,14 @@ def _read_phono3py_fc3(phono3py, phono3py.fc3 = fc3 -def _read_phono3py_fc2(phono3py, - symmetrize_fc2, - input_filename, - log_level): +def _read_phono3py_fc2(phono3py, symmetrize_fc2, input_filename, log_level): if input_filename is None: - filename = 'fc2.hdf5' + filename = "fc2.hdf5" else: - filename = 'fc2.' + input_filename + '.hdf5' + filename = "fc2." + input_filename + ".hdf5" file_exists(filename, log_level) if log_level: - print("Reading fc2 from \"%s\"." % filename) + print('Reading fc2 from "%s".' % filename) num_atom = phono3py.phonon_supercell.get_number_of_atoms() p2s_map = phono3py.phonon_primitive.p2s_map @@ -318,6 +332,7 @@ def _read_phono3py_fc2(phono3py, phonon_fc2 = read_fc2_from_hdf5(filename=filename, p2s_map=p2s_map) except RuntimeError: import traceback + traceback.print_exc() if log_level: print_error() @@ -333,8 +348,7 @@ def _read_phono3py_fc2(phono3py, if phonon_fc2.shape[0] == phonon_fc2.shape[1]: symmetrize_force_constants(phonon_fc2) else: - symmetrize_compact_force_constants(phonon_fc2, - phono3py.phonon_primitive) + symmetrize_compact_force_constants(phonon_fc2, phono3py.phonon_primitive) phono3py.fc2 = phonon_fc2 @@ -343,27 +357,31 @@ def _get_type2_dataset(natom, calculator, filename="FORCES_FC3", log_level=0): if not os.path.isfile(filename): return None - with open(filename, 'r') as f: + with open(filename, "r") as f: len_first_line = get_length_of_first_line(f) if len_first_line == 6: dataset = get_dataset_type2(f, natom) if log_level: - print("%d snapshots were found in %s." - % (len(dataset['displacements']), "FORCES_FC3")) + print( + "%d snapshots were found in %s." + % (len(dataset["displacements"]), "FORCES_FC3") + ) else: dataset = None return dataset -def _create_phono3py_fc3(phono3py, - ph3py_yaml, - symmetrize_fc3r, - input_filename, - is_compact_fc, - cutoff_pair_distance, - fc_calculator, - fc_calculator_options, - log_level): +def _create_phono3py_fc3( + phono3py, + ph3py_yaml, + symmetrize_fc3r, + input_filename, + is_compact_fc, + cutoff_pair_distance, + fc_calculator, + fc_calculator_options, + log_level, +): """Read or calculate fc3. Note @@ -379,20 +397,22 @@ def _create_phono3py_fc3(phono3py, """ if input_filename is None: - disp_filename = 'disp_fc3.yaml' + disp_filename = "disp_fc3.yaml" else: - disp_filename = 'disp_fc3.' + input_filename + '.yaml' + disp_filename = "disp_fc3." + input_filename + ".yaml" _ph3py_yaml = _get_ph3py_yaml(disp_filename, ph3py_yaml) try: - dataset = parse_forces(phono3py, - ph3py_yaml=_ph3py_yaml, - cutoff_pair_distance=cutoff_pair_distance, - force_filename="FORCES_FC3", - disp_filename=disp_filename, - fc_type='fc3', - log_level=log_level) + dataset = parse_forces( + phono3py, + ph3py_yaml=_ph3py_yaml, + cutoff_pair_distance=cutoff_pair_distance, + force_filename="FORCES_FC3", + disp_filename=disp_filename, + fc_type="fc3", + log_level=log_level, + ) except RuntimeError as e: # from _parse_forces_type1 if log_level: @@ -404,34 +424,40 @@ def _create_phono3py_fc3(phono3py, file_exists(e.filename, log_level) phono3py.dataset = dataset - phono3py.produce_fc3(symmetrize_fc3r=symmetrize_fc3r, - is_compact_fc=is_compact_fc, - fc_calculator=fc_calculator, - fc_calculator_options=fc_calculator_options) + phono3py.produce_fc3( + symmetrize_fc3r=symmetrize_fc3r, + is_compact_fc=is_compact_fc, + fc_calculator=fc_calculator, + fc_calculator_options=fc_calculator_options, + ) -def _create_phono3py_fc2(phono3py, - ph3py_yaml, - symmetrize_fc2, - input_filename, - is_compact_fc, - fc_calculator, - fc_calculator_options, - log_level): +def _create_phono3py_fc2( + phono3py, + ph3py_yaml, + symmetrize_fc2, + input_filename, + is_compact_fc, + fc_calculator, + fc_calculator_options, + log_level, +): if input_filename is None: - disp_filename = 'disp_fc3.yaml' + disp_filename = "disp_fc3.yaml" else: - disp_filename = 'disp_fc3.' + input_filename + '.yaml' + disp_filename = "disp_fc3." + input_filename + ".yaml" _ph3py_yaml = _get_ph3py_yaml(disp_filename, ph3py_yaml) try: - dataset = parse_forces(phono3py, - ph3py_yaml=_ph3py_yaml, - force_filename="FORCES_FC3", - disp_filename=disp_filename, - fc_type='fc2', - log_level=log_level) + dataset = parse_forces( + phono3py, + ph3py_yaml=_ph3py_yaml, + force_filename="FORCES_FC3", + disp_filename=disp_filename, + fc_type="fc2", + log_level=log_level, + ) except RuntimeError as e: if log_level: print(str(e)) @@ -445,7 +471,8 @@ def _create_phono3py_fc2(phono3py, symmetrize_fc2=symmetrize_fc2, is_compact_fc=is_compact_fc, fc_calculator=fc_calculator, - fc_calculator_options=fc_calculator_options) + fc_calculator_options=fc_calculator_options, + ) def _get_ph3py_yaml(disp_filename, ph3py_yaml): @@ -453,34 +480,38 @@ def _get_ph3py_yaml(disp_filename, ph3py_yaml): # Try to use phono3py.phonon_dataset when the disp file not found if not os.path.isfile(disp_filename): disp_filename = None - if _ph3py_yaml is None and os.path.isfile('phono3py_disp.yaml'): + if _ph3py_yaml is None and os.path.isfile("phono3py_disp.yaml"): _ph3py_yaml = Phono3pyYaml() - _ph3py_yaml.read('phono3py_disp.yaml') + _ph3py_yaml.read("phono3py_disp.yaml") return _ph3py_yaml -def _create_phono3py_phonon_fc2(phono3py, - ph3py_yaml, - symmetrize_fc2, - input_filename, - is_compact_fc, - fc_calculator, - fc_calculator_options, - log_level): +def _create_phono3py_phonon_fc2( + phono3py, + ph3py_yaml, + symmetrize_fc2, + input_filename, + is_compact_fc, + fc_calculator, + fc_calculator_options, + log_level, +): if input_filename is None: - disp_filename = 'disp_fc2.yaml' + disp_filename = "disp_fc2.yaml" else: - disp_filename = 'disp_fc2.' + input_filename + '.yaml' + disp_filename = "disp_fc2." + input_filename + ".yaml" _ph3py_yaml = _get_ph3py_yaml(disp_filename, ph3py_yaml) try: - dataset = parse_forces(phono3py, - ph3py_yaml=_ph3py_yaml, - force_filename="FORCES_FC2", - disp_filename=disp_filename, - fc_type='phonon_fc2', - log_level=log_level) + dataset = parse_forces( + phono3py, + ph3py_yaml=_ph3py_yaml, + force_filename="FORCES_FC2", + disp_filename=disp_filename, + fc_type="phonon_fc2", + log_level=log_level, + ) except RuntimeError as e: if log_level: print(str(e)) @@ -494,49 +525,50 @@ def _create_phono3py_phonon_fc2(phono3py, symmetrize_fc2=symmetrize_fc2, is_compact_fc=is_compact_fc, fc_calculator=fc_calculator, - fc_calculator_options=fc_calculator_options) + fc_calculator_options=fc_calculator_options, + ) def _convert_unit_in_dataset(dataset, calculator): physical_units = get_default_physical_units(calculator) - force_to_eVperA = physical_units['force_to_eVperA'] - distance_to_A = physical_units['distance_to_A'] + force_to_eVperA = physical_units["force_to_eVperA"] + distance_to_A = physical_units["distance_to_A"] - if 'first_atoms' in dataset: - for d1 in dataset['first_atoms']: + if "first_atoms" in dataset: + for d1 in dataset["first_atoms"]: if distance_to_A is not None: - disp = _to_ndarray(d1['displacement']) - d1['displacement'] = disp * distance_to_A - if force_to_eVperA is not None and 'forces' in d1: - forces = _to_ndarray(d1['forces']) - d1['forces'] = forces * force_to_eVperA - if 'second_atoms' in d1: - for d2 in d1['second_atoms']: + disp = _to_ndarray(d1["displacement"]) + d1["displacement"] = disp * distance_to_A + if force_to_eVperA is not None and "forces" in d1: + forces = _to_ndarray(d1["forces"]) + d1["forces"] = forces * force_to_eVperA + if "second_atoms" in d1: + for d2 in d1["second_atoms"]: if distance_to_A is not None: - disp = _to_ndarray(d2['displacement']) - d2['displacement'] = disp * distance_to_A - if force_to_eVperA is not None and 'forces' in d2: - forces = _to_ndarray(d2['forces']) - d2['forces'] = forces * force_to_eVperA + disp = _to_ndarray(d2["displacement"]) + d2["displacement"] = disp * distance_to_A + if force_to_eVperA is not None and "forces" in d2: + forces = _to_ndarray(d2["forces"]) + d2["forces"] = forces * force_to_eVperA else: - if distance_to_A is not None and 'displacements' in dataset: - disp = _to_ndarray(dataset['displacements']) - dataset['displacements'] = disp * distance_to_A - if force_to_eVperA is not None and 'forces' in dataset: - forces = _to_ndarray(dataset['forces']) - dataset['forces'] = forces * force_to_eVperA + if distance_to_A is not None and "displacements" in dataset: + disp = _to_ndarray(dataset["displacements"]) + dataset["displacements"] = disp * distance_to_A + if force_to_eVperA is not None and "forces" in dataset: + forces = _to_ndarray(dataset["forces"]) + dataset["forces"] = forces * force_to_eVperA -def _to_ndarray(array, dtype='double'): +def _to_ndarray(array, dtype="double"): if type(array) is not np.ndarray: - return np.array(array, dtype=dtype, order='C') + return np.array(array, dtype=dtype, order="C") else: return array def _extract_datast_from_ph3py_yaml(ph3py_yaml, fc_type): dataset = None - if fc_type == 'phonon_fc2': + if fc_type == "phonon_fc2": if ph3py_yaml and ph3py_yaml.phonon_dataset is not None: # copy dataset # otherwise unit conversion can be applied multiple times. diff --git a/phono3py/cui/create_supercells.py b/phono3py/cui/create_supercells.py index d3bb42a4..f37c4bd2 100644 --- a/phono3py/cui/create_supercells.py +++ b/phono3py/cui/create_supercells.py @@ -1,3 +1,4 @@ +"""Utilities of main CUI script.""" # Copyright (C) 2015 Atsushi Togo # All rights reserved. # @@ -37,56 +38,59 @@ from phono3py.file_IO import write_disp_fc3_yaml, write_disp_fc2_yaml from phono3py.interface.calculator import ( get_additional_info_to_write_fc2_supercells, get_additional_info_to_write_supercells, - get_default_displacement_distance) + get_default_displacement_distance, +) from phonopy.interface.calculator import write_supercells_with_displacements -def create_phono3py_supercells(cell_info, - settings, - symprec, - output_filename=None, - interface_mode='vasp', - log_level=1): - """create displacements and supercells +def create_phono3py_supercells( + cell_info, + settings, + symprec, + output_filename=None, + interface_mode="vasp", + log_level=1, +): + """Create displacements and supercells. Distance unit used is that for the calculator interface. The default unit is Angstron. """ - - optional_structure_info = cell_info['optional_structure_info'] + optional_structure_info = cell_info["optional_structure_info"] if settings.displacement_distance is None: distance = get_default_displacement_distance(interface_mode) else: distance = settings.displacement_distance phono3py = Phono3py( - cell_info['unitcell'], - cell_info['supercell_matrix'], - primitive_matrix=cell_info['primitive_matrix'], - phonon_supercell_matrix=cell_info['phonon_supercell_matrix'], + cell_info["unitcell"], + cell_info["supercell_matrix"], + primitive_matrix=cell_info["primitive_matrix"], + phonon_supercell_matrix=cell_info["phonon_supercell_matrix"], is_symmetry=settings.is_symmetry, symprec=symprec, - calculator=interface_mode) + calculator=interface_mode, + ) phono3py.generate_displacements( distance=distance, cutoff_pair_distance=settings.cutoff_pair_distance, is_plusminus=settings.is_plusminus_displacement, - is_diagonal=settings.is_diagonal_displacement) + is_diagonal=settings.is_diagonal_displacement, + ) if log_level: - print('') - print("Unit cell was read from \"%s\"." % - optional_structure_info[0]) + print("") + print('Unit cell was read from "%s".' % optional_structure_info[0]) print("Displacement distance: %s" % distance) if output_filename is None: - filename = 'disp_fc3.yaml' + filename = "disp_fc3.yaml" else: - filename = 'disp_fc3.' + output_filename + '.yaml' - num_disps, num_disp_files = write_disp_fc3_yaml(phono3py.dataset, - phono3py.supercell, - filename=filename) + filename = "disp_fc3." + output_filename + ".yaml" + num_disps, num_disp_files = write_disp_fc3_yaml( + phono3py.dataset, phono3py.supercell, filename=filename + ) ids = [] disp_cells = [] for i, cell in enumerate(phono3py.supercells_with_displacements): @@ -95,41 +99,46 @@ def create_phono3py_supercells(cell_info, disp_cells.append(cell) additional_info = get_additional_info_to_write_supercells( - interface_mode, phono3py.supercell_matrix) - write_supercells_with_displacements(interface_mode, - phono3py.supercell, - disp_cells, - optional_structure_info, - displacement_ids=ids, - zfill_width=5, - additional_info=additional_info) + interface_mode, phono3py.supercell_matrix + ) + write_supercells_with_displacements( + interface_mode, + phono3py.supercell, + disp_cells, + optional_structure_info, + displacement_ids=ids, + zfill_width=5, + additional_info=additional_info, + ) if log_level: print("Number of displacements: %d" % num_disps) if settings.cutoff_pair_distance is not None: - print("Cutoff distance for displacements: %s" % - settings.cutoff_pair_distance) - print("Number of displacement supercell files created: %d" % - num_disp_files) + print( + "Cutoff distance for displacements: %s" % settings.cutoff_pair_distance + ) + print("Number of displacement supercell files created: %d" % num_disp_files) if phono3py.phonon_supercell_matrix is not None: if output_filename is None: - filename = 'disp_fc2.yaml' + filename = "disp_fc2.yaml" else: - filename = 'disp_fc2.' + output_filename + '.yaml' + filename = "disp_fc2." + output_filename + ".yaml" - num_disps = write_disp_fc2_yaml(phono3py.phonon_dataset, - phono3py.phonon_supercell, - filename=filename) + num_disps = write_disp_fc2_yaml( + phono3py.phonon_dataset, phono3py.phonon_supercell, filename=filename + ) additional_info = get_additional_info_to_write_fc2_supercells( - interface_mode, phono3py.phonon_supercell_matrix) + interface_mode, phono3py.phonon_supercell_matrix + ) write_supercells_with_displacements( interface_mode, phono3py.supercell, phono3py.phonon_supercells_with_displacements, optional_structure_info, zfill_width=5, - additional_info=additional_info) + additional_info=additional_info, + ) if log_level: print("Number of displacements for special fc2: %d" % num_disps) diff --git a/phono3py/cui/kaccum.py b/phono3py/cui/kaccum.py index fa8b239b..e830921d 100644 --- a/phono3py/cui/kaccum.py +++ b/phono3py/cui/kaccum.py @@ -8,8 +8,7 @@ from phonopy.structure.cells import get_primitive from phonopy.structure.symmetry import Symmetry from phonopy.interface.calculator import read_crystal_structure from phonopy.phonon.dos import NormalDistribution -from phonopy.structure.cells import ( - get_primitive_matrix, guess_primitive_matrix) +from phonopy.structure.cells import get_primitive_matrix, guess_primitive_matrix from phono3py.phonon.grid import BZGrid, get_ir_grid_points from phono3py.other.tetrahedron_method import get_integration_weights @@ -19,14 +18,16 @@ epsilon = 1.0e-8 class KappaDOS(object): """Class to calculate thermal conductivity spectram.""" - def __init__(self, - mode_kappa, - frequencies, - bz_grid, - ir_grid_points, - ir_grid_map=None, - frequency_points=None, - num_sampling_points=100): + def __init__( + self, + mode_kappa, + frequencies, + bz_grid, + ir_grid_points, + ir_grid_map=None, + frequency_points=None, + num_sampling_points=100, + ): """Init method. mode_kappa : ndarray @@ -53,29 +54,33 @@ class KappaDOS(object): max_freq = max(frequencies.ravel()) + epsilon if frequency_points is None: self._frequency_points = np.linspace( - min_freq, max_freq, num_sampling_points, dtype='double') + min_freq, max_freq, num_sampling_points, dtype="double" + ) else: - self._frequency_points = np.array( - frequency_points, dtype='double') + self._frequency_points = np.array(frequency_points, dtype="double") n_temp, _, _, n_elem = mode_kappa.shape self._kdos = np.zeros( - (n_temp, len(self._frequency_points), 2, n_elem), dtype='double') + (n_temp, len(self._frequency_points), 2, n_elem), dtype="double" + ) if ir_grid_map is None: bzgp2irgp_map = None else: bzgp2irgp_map = self._get_bzgp2irgp_map(bz_grid, ir_grid_map) - for j, function in enumerate(('J', 'I')): - iweights = get_integration_weights(self._frequency_points, - frequencies, - bz_grid, - grid_points=ir_grid_points, - bzgp2irgp_map=bzgp2irgp_map, - function=function) + for j, function in enumerate(("J", "I")): + iweights = get_integration_weights( + self._frequency_points, + frequencies, + bz_grid, + grid_points=ir_grid_points, + bzgp2irgp_map=bzgp2irgp_map, + function=function, + ) for i, iw in enumerate(iweights): self._kdos[:, :, j] += np.transpose( - np.dot(iw, mode_kappa[:, i]), axes=(1, 0, 2)) + np.dot(iw, mode_kappa[:, i]), axes=(1, 0, 2) + ) self._kdos /= np.prod(bz_grid.D_diag) def get_kdos(self): @@ -97,20 +102,17 @@ class KappaDOS(object): unique_gps = np.unique(ir_grid_map) gp_map = {j: i for i, j in enumerate(unique_gps)} bzgp2irgp_map = np.array( - [gp_map[ir_grid_map[grgp]] for grgp in bz_grid.bzg2grg], - dtype='int_') + [gp_map[ir_grid_map[grgp]] for grgp in bz_grid.bzg2grg], dtype="int_" + ) return bzgp2irgp_map class GammaDOSsmearing(object): """Class to calculate Gamma spectram by smearing method.""" - def __init__(self, - gamma, - frequencies, - ir_grid_weights, - sigma=None, - num_fpoints=200): + def __init__( + self, gamma, frequencies, ir_grid_weights, sigma=None, num_fpoints=200 + ): """Init method.""" self._gamma = gamma self._frequencies = frequencies @@ -118,10 +120,12 @@ class GammaDOSsmearing(object): self._num_fpoints = num_fpoints self._set_frequency_points() self._gdos = np.zeros( - (len(gamma), len(self._frequency_points), 2), dtype='double') + (len(gamma), len(self._frequency_points), 2), dtype="double" + ) if sigma is None: - self._sigma = (max(self._frequency_points) - - min(self._frequency_points)) / 100 + self._sigma = ( + max(self._frequency_points) - min(self._frequency_points) + ) / 100 else: self._sigma = 0.1 self._smearing_function = NormalDistribution(self._sigma) @@ -134,9 +138,7 @@ class GammaDOSsmearing(object): def _set_frequency_points(self): min_freq = np.min(self._frequencies) max_freq = np.max(self._frequencies) + epsilon - self._frequency_points = np.linspace(min_freq, - max_freq, - self._num_fpoints) + self._frequency_points = np.linspace(min_freq, max_freq, self._num_fpoints) def _run_smearing_method(self): self._dos = [] @@ -144,8 +146,9 @@ class GammaDOSsmearing(object): for i, f in enumerate(self._frequency_points): dos = self._smearing_function.calc(self._frequencies - f) for j, g_t in enumerate(self._gamma): - self._gdos[j, i, 1] = np.sum(np.dot(self._ir_grid_weights, - dos * g_t)) / num_gp + self._gdos[j, i, 1] = ( + np.sum(np.dot(self._ir_grid_weights, dos * g_t)) / num_gp + ) def _show_tensor(kdos, temperatures, sampling_points, args): @@ -156,15 +159,14 @@ def _show_tensor(kdos, temperatures, sampling_points, args): for f, k in zip(sampling_points[i], kdos_t): # show kappa_xx if args.average: - print(("%13.5f " * 3) % - (f, k[0][:3].sum() / 3, k[1][:3].sum() / 3)) + print(("%13.5f " * 3) % (f, k[0][:3].sum() / 3, k[1][:3].sum() / 3)) elif args.trace: print(("%13.5f " * 3) % (f, k[0][:3].sum(), k[1][:3].sum())) else: print(("%f " * 13) % ((f,) + tuple(k[0]) + tuple(k[1]))) - print('') - print('') + print("") + print("") def _show_scalar(gdos, temperatures, sampling_points, args): @@ -177,39 +179,35 @@ def _show_scalar(gdos, temperatures, sampling_points, args): print("# %d K" % temperatures[i]) for f, g in zip(sampling_points[i], gdos_t): print("%f %f %f" % (f, g[0], g[1])) - print('') - print('') + print("") + print("") -def _set_T_target(temperatures, - mode_prop, - T_target, - mean_freepath=None): +def _set_T_target(temperatures, mode_prop, T_target, mean_freepath=None): """Extract property at specified temperature.""" for i, t in enumerate(temperatures): if np.abs(t - T_target) < epsilon: - temperatures = temperatures[i:i+1] - mode_prop = mode_prop[i:i+1, :, :] + temperatures = temperatures[i : i + 1] + mode_prop = mode_prop[i : i + 1, :, :] if mean_freepath is not None: - mean_freepath = mean_freepath[i:i+1] + mean_freepath = mean_freepath[i : i + 1] return temperatures, mode_prop, mean_freepath else: return temperatures, mode_prop -def _run_prop_dos(frequencies, - mode_prop, - ir_grid_map, - ir_grid_points, - num_sampling_points, - bz_grid): +def _run_prop_dos( + frequencies, mode_prop, ir_grid_map, ir_grid_points, num_sampling_points, bz_grid +): """Run DOS-like calculation.""" - kappa_dos = KappaDOS(mode_prop, - frequencies, - bz_grid, - ir_grid_points, - ir_grid_map=ir_grid_map, - num_sampling_points=num_sampling_points) + kappa_dos = KappaDOS( + mode_prop, + frequencies, + bz_grid, + ir_grid_points, + ir_grid_map=ir_grid_map, + num_sampling_points=num_sampling_points, + ) freq_points, kdos = kappa_dos.get_kdos() sampling_points = np.tile(freq_points, (len(kdos), 1)) return kdos, sampling_points @@ -223,12 +221,9 @@ def _get_mfp(g, gv): return mean_freepath -def _run_mfp_dos(mean_freepath, - mode_prop, - ir_grid_map, - ir_grid_points, - num_sampling_points, - bz_grid): +def _run_mfp_dos( + mean_freepath, mode_prop, ir_grid_map, ir_grid_points, num_sampling_points, bz_grid +): """Run DOS-like calculation for mean free path. mean_freepath : shape=(temperatures, ir_grid_points, 6) @@ -238,12 +233,14 @@ def _run_mfp_dos(mean_freepath, kdos = [] sampling_points = [] for i, _ in enumerate(mean_freepath): - kappa_dos = KappaDOS(mode_prop[i:i+1, :, :], - mean_freepath[i], - bz_grid, - ir_grid_points, - ir_grid_map=ir_grid_map, - num_sampling_points=num_sampling_points) + kappa_dos = KappaDOS( + mode_prop[i : i + 1, :, :], + mean_freepath[i], + bz_grid, + ir_grid_points, + ir_grid_map=ir_grid_map, + num_sampling_points=num_sampling_points, + ) sampling_points_at_T, kdos_at_T = kappa_dos.get_kdos() kdos.append(kdos_at_T[0]) sampling_points.append(sampling_points_at_T) @@ -254,9 +251,7 @@ def _run_mfp_dos(mean_freepath, def _get_grid_symmetry(bz_grid, weights, qpoints): - (ir_grid_points, - weights_for_check, - ir_grid_map) = get_ir_grid_points(bz_grid) + (ir_grid_points, weights_for_check, ir_grid_map) = get_ir_grid_points(bz_grid) try: np.testing.assert_array_equal(weights, weights_for_check) @@ -267,7 +262,7 @@ def _get_grid_symmetry(bz_grid, weights, qpoints): raise addresses = bz_grid.addresses[ir_grid_points] - D_diag = bz_grid.D_diag.astype('double') + D_diag = bz_grid.D_diag.astype("double") qpoints_for_check = np.dot(addresses / D_diag, bz_grid.Q.T) diff_q = qpoints - qpoints_for_check np.testing.assert_almost_equal(diff_q, np.rint(diff_q)) @@ -279,13 +274,13 @@ def _get_calculator(args): """Return calculator name.""" interface_mode = None if args.qe_mode: - interface_mode = 'qe' + interface_mode = "qe" elif args.crystal_mode: - interface_mode = 'crystal' + interface_mode = "crystal" elif args.abinit_mode: - interface_mode = 'abinit' + interface_mode = "abinit" elif args.turbomole_mode: - interface_mode = 'turbomole' + interface_mode = "turbomole" return interface_mode @@ -293,13 +288,15 @@ def _read_files(args): """Read crystal structure and kappa.hdf5 files.""" interface_mode = _get_calculator(args) if len(args.filenames) > 1: - cell, _ = read_crystal_structure(args.filenames[0], - interface_mode=interface_mode) - f = h5py.File(args.filenames[1], 'r') + cell, _ = read_crystal_structure( + args.filenames[0], interface_mode=interface_mode + ) + f = h5py.File(args.filenames[1], "r") else: - cell, _ = read_crystal_structure(args.cell_filename, - interface_mode=interface_mode) - f = h5py.File(args.filenames[0], 'r') + cell, _ = read_crystal_structure( + args.cell_filename, interface_mode=interface_mode + ) + f = h5py.File(args.filenames[0], "r") return cell, f @@ -307,27 +304,25 @@ def _read_files(args): def _get_mode_property(args, f_kappa): """Read property data from hdf5 file object.""" if args.pqj: - mode_prop = f_kappa['ave_pp'][:].reshape( - (1,) + f_kappa['ave_pp'].shape) + mode_prop = f_kappa["ave_pp"][:].reshape((1,) + f_kappa["ave_pp"].shape) elif args.cv: - mode_prop = f_kappa['heat_capacity'][:] + mode_prop = f_kappa["heat_capacity"][:] elif args.tau: - g = f_kappa['gamma'][:] + g = f_kappa["gamma"][:] g = np.where(g > 0, g, -1) mode_prop = np.where(g > 0, 1.0 / (2 * 2 * np.pi * g), 0) elif args.gv_norm: - mode_prop = np.sqrt( - (f_kappa['group_velocity'][:, :, :] ** 2).sum(axis=2)) + mode_prop = np.sqrt((f_kappa["group_velocity"][:, :, :] ** 2).sum(axis=2)) mode_prop = mode_prop.reshape((1,) + mode_prop.shape) elif args.gamma: - mode_prop = f_kappa['gamma'][:] + mode_prop = f_kappa["gamma"][:] elif args.gruneisen: - mode_prop = f_kappa['gruneisen'][:].reshape( - (1,) + f_kappa['gruneisen'].shape) + mode_prop = f_kappa["gruneisen"][:].reshape((1,) + f_kappa["gruneisen"].shape) mode_prop **= 2 elif args.dos: - mode_prop = np.ones((1, ) + f_kappa['frequency'].shape, - dtype='double', order='C') + mode_prop = np.ones( + (1,) + f_kappa["frequency"].shape, dtype="double", order="C" + ) else: raise RuntimeError("No property target is specified.") return mode_prop @@ -337,74 +332,105 @@ def _get_parser(): """Return args of ArgumentParser.""" parser = argparse.ArgumentParser(description="Show unit cell volume") parser.add_argument( - "--pa", "--primitive-axis", "--primitive-axes", nargs='+', - dest="primitive_matrix", default=None, - help="Same as PRIMITIVE_AXES tags") + "--pa", + "--primitive-axis", + "--primitive-axes", + nargs="+", + dest="primitive_matrix", + default=None, + help="Same as PRIMITIVE_AXES tags", + ) parser.add_argument( - "-c", "--cell", dest="cell_filename", metavar="FILE", default=None, - help="Read unit cell") + "-c", + "--cell", + dest="cell_filename", + metavar="FILE", + default=None, + help="Read unit cell", + ) parser.add_argument( - '--gv', action='store_true', - help='Calculate for gv_x_gv (tensor)') + "--gv", action="store_true", help="Calculate for gv_x_gv (tensor)" + ) + parser.add_argument("--pqj", action="store_true", help="Calculate for Pqj (scalar)") + parser.add_argument("--cv", action="store_true", help="Calculate for Cv (scalar)") parser.add_argument( - '--pqj', action='store_true', - help='Calculate for Pqj (scalar)') + "--tau", action="store_true", help="Calculate for lifetimes (scalar)" + ) parser.add_argument( - '--cv', action='store_true', - help='Calculate for Cv (scalar)') + "--dos", action="store_true", help="Calculate for phonon DOS (scalar)" + ) parser.add_argument( - '--tau', action='store_true', - help='Calculate for lifetimes (scalar)') + "--gamma", action="store_true", help="Calculate for Gamma (scalar)" + ) parser.add_argument( - '--dos', action='store_true', - help='Calculate for phonon DOS (scalar)') + "--gruneisen", + action="store_true", + help="Calculate for mode-Gruneisen parameters squared (scalar)", + ) parser.add_argument( - '--gamma', action='store_true', - help='Calculate for Gamma (scalar)') + "--gv-norm", action="store_true", help="Calculate for |g_v| (scalar)" + ) parser.add_argument( - '--gruneisen', action='store_true', - help='Calculate for mode-Gruneisen parameters squared (scalar)') + "--mfp", action="store_true", help="Mean free path is used instead of frequency" + ) parser.add_argument( - '--gv-norm', action='store_true', - help='Calculate for |g_v| (scalar)') + "--temperature", + type=float, + dest="temperature", + help="Temperature to output data at", + ) parser.add_argument( - '--mfp', action='store_true', - help='Mean free path is used instead of frequency') - parser.add_argument( - '--temperature', type=float, dest='temperature', - help='Temperature to output data at') - parser.add_argument( - '--nsp', '--num-sampling-points', type=int, dest='num_sampling_points', + "--nsp", + "--num-sampling-points", + type=int, + dest="num_sampling_points", default=100, - help="Number of sampling points in frequency or MFP axis") + help="Number of sampling points in frequency or MFP axis", + ) parser.add_argument( - '--average', action='store_true', - help=("Output the traces of the tensors divided by 3 " - "rather than the unique elements")) + "--average", + action="store_true", + help=( + "Output the traces of the tensors divided by 3 " + "rather than the unique elements" + ), + ) parser.add_argument( - '--trace', action='store_true', - help=("Output the traces of the tensors " - "rather than the unique elements")) + "--trace", + action="store_true", + help=("Output the traces of the tensors " "rather than the unique elements"), + ) parser.add_argument( - '--smearing', action='store_true', - help='Use smearing method (only for scalar density)') + "--smearing", + action="store_true", + help="Use smearing method (only for scalar density)", + ) parser.add_argument( - '--qe', '--pwscf', dest="qe_mode", - action="store_true", help="Invoke Pwscf mode") + "--qe", "--pwscf", dest="qe_mode", action="store_true", help="Invoke Pwscf mode" + ) parser.add_argument( - '--crystal', dest="crystal_mode", - action="store_true", help="Invoke CRYSTAL mode") + "--crystal", + dest="crystal_mode", + action="store_true", + help="Invoke CRYSTAL mode", + ) parser.add_argument( - '--abinit', dest="abinit_mode", - action="store_true", help="Invoke Abinit mode") + "--abinit", dest="abinit_mode", action="store_true", help="Invoke Abinit mode" + ) parser.add_argument( - '--turbomole', dest="turbomole_mode", - action="store_true", help="Invoke TURBOMOLE mode") + "--turbomole", + dest="turbomole_mode", + action="store_true", + help="Invoke TURBOMOLE mode", + ) parser.add_argument( - "--noks", "--no-kappa-stars", - dest="no_kappa_stars", action="store_true", - help="Deactivate summation of partial kappa at q-stars") - parser.add_argument('filenames', nargs='*') + "--noks", + "--no-kappa-stars", + dest="no_kappa_stars", + action="store_true", + help="Deactivate summation of partial kappa at q-stars", + ) + parser.add_argument("filenames", nargs="*") args = parser.parse_args() return args @@ -417,22 +443,21 @@ def _analyze_primitive_matrix_option(args, unitcell=None): else: _primitive_matrix = args.primitive_matrix.strip() - if _primitive_matrix.lower() == 'auto': - primitive_matrix = 'auto' - elif _primitive_matrix.upper() in ('P', 'F', 'I', 'A', 'C', 'R'): + if _primitive_matrix.lower() == "auto": + primitive_matrix = "auto" + elif _primitive_matrix.upper() in ("P", "F", "I", "A", "C", "R"): primitive_matrix = _primitive_matrix.upper() elif len(_primitive_matrix.split()) != 9: - raise SyntaxError( - "Number of elements in --pa option argument has to be 9.") + raise SyntaxError("Number of elements in --pa option argument has to be 9.") else: primitive_matrix = np.reshape( - [fracval(x) for x in _primitive_matrix.split()], (3, 3)) + [fracval(x) for x in _primitive_matrix.split()], (3, 3) + ) if np.linalg.det(primitive_matrix) < 1e-8: - raise SyntaxError( - "Primitive matrix has to have positive determinant.") + raise SyntaxError("Primitive matrix has to have positive determinant.") pmat = get_primitive_matrix(primitive_matrix) - if unitcell is not None and isinstance(pmat, str) and pmat == 'auto': + if unitcell is not None and isinstance(pmat, str) and pmat == "auto": return guess_primitive_matrix(unitcell) else: return pmat @@ -442,100 +467,117 @@ def main(): """Calculate kappa spectrum.""" args = _get_parser() cell, f_kappa = _read_files(args) - mesh = np.array(f_kappa['mesh'][:], dtype='int_') - temperatures = f_kappa['temperature'][:] - ir_weights = f_kappa['weight'][:] + mesh = np.array(f_kappa["mesh"][:], dtype="int_") + temperatures = f_kappa["temperature"][:] + ir_weights = f_kappa["weight"][:] primitive_matrix = _analyze_primitive_matrix_option(args, unitcell=cell) primitive = get_primitive(cell, primitive_matrix) primitive_symmetry = Symmetry(primitive) - bz_grid = BZGrid(mesh, - lattice=primitive.cell, - symmetry_dataset=primitive_symmetry.dataset, - store_dense_gp_map=False) + bz_grid = BZGrid( + mesh, + lattice=primitive.cell, + symmetry_dataset=primitive_symmetry.dataset, + store_dense_gp_map=False, + ) if args.no_kappa_stars or (ir_weights == 1).all(): - ir_grid_points = np.arange(np.prod(mesh), dtype='int_') - ir_grid_map = np.arange(np.prod(mesh), dtype='int_') + ir_grid_points = np.arange(np.prod(mesh), dtype="int_") + ir_grid_map = np.arange(np.prod(mesh), dtype="int_") else: ir_grid_points, ir_grid_map = _get_grid_symmetry( - bz_grid, ir_weights, f_kappa['qpoint'][:]) - frequencies = f_kappa['frequency'][:] + bz_grid, ir_weights, f_kappa["qpoint"][:] + ) + frequencies = f_kappa["frequency"][:] conditions = frequencies > 0 if np.logical_not(conditions).sum() > 3: - sys.stderr.write("# Imaginary frequencies are found. " - "They are set to be zero.\n") + sys.stderr.write( + "# Imaginary frequencies are found. " "They are set to be zero.\n" + ) frequencies = np.where(conditions, frequencies, 0) # Run for scaler - if (args.gamma or args.gruneisen or args.pqj or - args.cv or args.tau or args.gv_norm or args.dos): # noqa E129 + if ( + args.gamma + or args.gruneisen + or args.pqj + or args.cv + or args.tau + or args.gv_norm + or args.dos + ): # noqa E129 mode_prop = _get_mode_property(args, f_kappa) - if (args.temperature is not None and - not (args.gv_norm or args.pqj or args.gruneisen or args.dos)): # noqa E129 - temperatures, mode_prop = _set_T_target(temperatures, - mode_prop, - args.temperature) + if args.temperature is not None and not ( + args.gv_norm or args.pqj or args.gruneisen or args.dos + ): # noqa E129 + temperatures, mode_prop = _set_T_target( + temperatures, mode_prop, args.temperature + ) if args.smearing: mode_prop_dos = GammaDOSsmearing( - mode_prop, - frequencies, - ir_weights, - num_fpoints=args.num_sampling_points) + mode_prop, frequencies, ir_weights, num_fpoints=args.num_sampling_points + ) sampling_points, gdos = mode_prop_dos.get_gdos() sampling_points = np.tile(sampling_points, (len(gdos), 1)) _show_scalar(gdos[:, :, :], temperatures, sampling_points, args) else: for i, w in enumerate(ir_weights): mode_prop[:, i, :] *= w - kdos, sampling_points = _run_prop_dos(frequencies, - mode_prop[:, :, :, None], - ir_grid_map, - ir_grid_points, - args.num_sampling_points, - bz_grid) + kdos, sampling_points = _run_prop_dos( + frequencies, + mode_prop[:, :, :, None], + ir_grid_map, + ir_grid_points, + args.num_sampling_points, + bz_grid, + ) _show_scalar(kdos[:, :, :, 0], temperatures, sampling_points, args) else: # Run for tensor if args.gv: - gv_sum2 = f_kappa['gv_by_gv'][:] + gv_sum2 = f_kappa["gv_by_gv"][:] # gv x gv is divied by primitive cell volume. unit_conversion = primitive.volume mode_prop = gv_sum2.reshape((1,) + gv_sum2.shape) / unit_conversion else: - mode_prop = f_kappa['mode_kappa'][:] + mode_prop = f_kappa["mode_kappa"][:] if args.mfp: - if 'mean_free_path' in f_kappa: - mfp = f_kappa['mean_free_path'][:] + if "mean_free_path" in f_kappa: + mfp = f_kappa["mean_free_path"][:] mean_freepath = np.sqrt((mfp ** 2).sum(axis=3)) else: - mean_freepath = _get_mfp(f_kappa['gamma'][:], - f_kappa['group_velocity'][:]) + mean_freepath = _get_mfp( + f_kappa["gamma"][:], f_kappa["group_velocity"][:] + ) if args.temperature is not None: - (temperatures, - mode_prop, - mean_freepath) = _set_T_target(temperatures, - mode_prop, - args.temperature, - mean_freepath=mean_freepath) + (temperatures, mode_prop, mean_freepath) = _set_T_target( + temperatures, + mode_prop, + args.temperature, + mean_freepath=mean_freepath, + ) - kdos, sampling_points = _run_mfp_dos(mean_freepath, - mode_prop, - ir_grid_map, - ir_grid_points, - args.num_sampling_points, - bz_grid) + kdos, sampling_points = _run_mfp_dos( + mean_freepath, + mode_prop, + ir_grid_map, + ir_grid_points, + args.num_sampling_points, + bz_grid, + ) _show_tensor(kdos, temperatures, sampling_points, args) else: if args.temperature is not None and not args.gv: - temperatures, mode_prop = _set_T_target(temperatures, - mode_prop, - args.temperature) - kdos, sampling_points = _run_prop_dos(frequencies, - mode_prop, - ir_grid_map, - ir_grid_points, - args.num_sampling_points, - bz_grid) + temperatures, mode_prop = _set_T_target( + temperatures, mode_prop, args.temperature + ) + kdos, sampling_points = _run_prop_dos( + frequencies, + mode_prop, + ir_grid_map, + ir_grid_points, + args.num_sampling_points, + bz_grid, + ) _show_tensor(kdos, temperatures, sampling_points, args) diff --git a/phono3py/cui/phono3py_argparse.py b/phono3py/cui/phono3py_argparse.py index c535b02b..4e177356 100644 --- a/phono3py/cui/phono3py_argparse.py +++ b/phono3py/cui/phono3py_argparse.py @@ -37,400 +37,757 @@ import sys from phonopy.cui.phonopy_argparse import fix_deprecated_option_names -def get_parser(fc_symmetry=False, - is_nac=False, - load_phono3py_yaml=False): +def get_parser(fc_symmetry=False, is_nac=False, load_phono3py_yaml=False): """Return ArgumentParser instance.""" deprecated = fix_deprecated_option_names(sys.argv) import argparse from phonopy.interface.calculator import add_arguments_of_calculators from phono3py.interface.calculator import calculator_info - parser = argparse.ArgumentParser( - description="Phono3py command-line-tool") + parser = argparse.ArgumentParser(description="Phono3py command-line-tool") add_arguments_of_calculators(parser, calculator_info) parser.add_argument( - "--alm", dest="use_alm", action="store_true", default=False, - help=("Use ALM for generating 2nd and 3rd force constants " - "in one fitting")) - parser.add_argument( - "--amplitude", dest="displacement_distance", type=float, default=None, - help="Distance of displacements") - parser.add_argument( - "--ave-pp", dest="use_ave_pp", action="store_true", default=False, - help="Use averaged ph-ph interaction") - parser.add_argument( - "--band", nargs='+', dest="band_paths", default=None, - help="Band structure paths calculated for Gruneisen parameter") - parser.add_argument( - "--band-points", dest="band_points", type=int, default=None, - help=("Number of points calculated on a band segment in the band " - "structure Gruneisen parameter calculation")) - parser.add_argument( - "--bi", "--band-indices", nargs='+', dest="band_indices", default=None, - help="Band indices where life time is calculated") - parser.add_argument( - "--boundary-mfp", "--bmfp", dest="boundary_mfp", type=float, - default=None, - help=("Boundary mean free path in micrometre for thermal conductivity " - "calculation")) - parser.add_argument( - "--br", "--bterta", dest="is_bterta", action="store_true", + "--alm", + dest="use_alm", + action="store_true", default=False, - help="Calculate thermal conductivity in BTE-RTA") + help=("Use ALM for generating 2nd and 3rd force constants " "in one fitting"), + ) + parser.add_argument( + "--amplitude", + dest="displacement_distance", + type=float, + default=None, + help="Distance of displacements", + ) + parser.add_argument( + "--ave-pp", + dest="use_ave_pp", + action="store_true", + default=False, + help="Use averaged ph-ph interaction", + ) + parser.add_argument( + "--band", + nargs="+", + dest="band_paths", + default=None, + help="Band structure paths calculated for Gruneisen parameter", + ) + parser.add_argument( + "--band-points", + dest="band_points", + type=int, + default=None, + help=( + "Number of points calculated on a band segment in the band " + "structure Gruneisen parameter calculation" + ), + ) + parser.add_argument( + "--bi", + "--band-indices", + nargs="+", + dest="band_indices", + default=None, + help="Band indices where life time is calculated", + ) + parser.add_argument( + "--boundary-mfp", + "--bmfp", + dest="boundary_mfp", + type=float, + default=None, + help=( + "Boundary mean free path in micrometre for thermal conductivity " + "calculation" + ), + ) + parser.add_argument( + "--br", + "--bterta", + dest="is_bterta", + action="store_true", + default=False, + help="Calculate thermal conductivity in BTE-RTA", + ) if not load_phono3py_yaml: parser.add_argument( - "-c", "--cell", dest="cell_filename", metavar="FILE", default=None, - help="Read unit cell") + "-c", + "--cell", + dest="cell_filename", + metavar="FILE", + default=None, + help="Read unit cell", + ) parser.add_argument( - "--cf2", "--create-f2", dest="create_forces_fc2", nargs='+', - default=None, help="Create FORCES_FC2") - parser.add_argument( - "--cf3", "--create-f3", dest="create_forces_fc3", nargs='+', - default=None, help="Create FORCES_FC3") - parser.add_argument( - "--cf3-file", "--create-f3-from-file", - metavar="FILE", dest="create_forces_fc3_file", default=None, - help="Create FORCES_FC3 from file name list") - parser.add_argument( - "--cfz", "--subtract-forces", - metavar="FILE", dest="subtract_forces", default=None, - help="Subtract recidual forces from supercell forces") - parser.add_argument( - "--cfc", "--compact-fc", dest="is_compact_fc", action="store_true", - default=False, - help="Use compact force cosntants") - parser.add_argument( - "--cfs", "--create-force-sets", dest="force_sets_mode", - action="store_true", default=False, - help="Create phonopy FORCE_SETS from FORCES_FC2") - parser.add_argument( - "--cph", "--collective-phonon", dest="solve_collective_phonon", - action="store_true", default=False, - help="Solve collective phonons") - parser.add_argument( - "--const-ave-pp", dest="const_ave_pp", type=float, default=None, - help="Set constant averaged ph-ph interaction (Pqj)") - parser.add_argument( - "--cutoff-fc3", "--cutoff-fc3-distance", dest="cutoff_fc3_distance", - type=float, default=None, - help=("Cutoff distance of third-order force constants. Elements where " - "any pair of atoms has larger distance than cut-off distance " - "are set zero.")) - parser.add_argument( - "--cutoff-freq", "--cutoff-frequency", dest="cutoff_frequency", - type=float, default=None, - help="Phonon modes below this frequency are ignored.") - parser.add_argument( - "--cutoff-pair", "--cutoff-pair-distance", dest="cutoff_pair_distance", - type=float, default=None, - help=("Cutoff distance between pairs of displaced atoms used for " - "supercell creation with displacements and making third-order " - "force constants")) - parser.add_argument( - "-d", "--disp", dest="is_displacement", action="store_true", - default=False, - help="As first stage, get least displacements") - parser.add_argument( - "--dim", nargs='+', dest="supercell_dimension", default=None, - help="Supercell dimension") - parser.add_argument( - "--dim-fc2", nargs='+', dest="phonon_supercell_dimension", + "--cf2", + "--create-f2", + dest="create_forces_fc2", + nargs="+", default=None, - help="Supercell dimension for extra fc2") + help="Create FORCES_FC2", + ) parser.add_argument( - "--emulate-v1", dest="emulate_v1", action="store_true", - default=False, - help="Emulate v1.x grid system and shortest vectors.") - parser.add_argument( - "--factor", dest="frequency_conversion_factor", type=float, + "--cf3", + "--create-f3", + dest="create_forces_fc3", + nargs="+", default=None, - help="Frequency unit conversion factor") + help="Create FORCES_FC3", + ) + parser.add_argument( + "--cf3-file", + "--create-f3-from-file", + metavar="FILE", + dest="create_forces_fc3_file", + default=None, + help="Create FORCES_FC3 from file name list", + ) + parser.add_argument( + "--cfz", + "--subtract-forces", + metavar="FILE", + dest="subtract_forces", + default=None, + help="Subtract recidual forces from supercell forces", + ) + parser.add_argument( + "--cfc", + "--compact-fc", + dest="is_compact_fc", + action="store_true", + default=False, + help="Use compact force cosntants", + ) + parser.add_argument( + "--cfs", + "--create-force-sets", + dest="force_sets_mode", + action="store_true", + default=False, + help="Create phonopy FORCE_SETS from FORCES_FC2", + ) + parser.add_argument( + "--cph", + "--collective-phonon", + dest="solve_collective_phonon", + action="store_true", + default=False, + help="Solve collective phonons", + ) + parser.add_argument( + "--const-ave-pp", + dest="const_ave_pp", + type=float, + default=None, + help="Set constant averaged ph-ph interaction (Pqj)", + ) + parser.add_argument( + "--cutoff-fc3", + "--cutoff-fc3-distance", + dest="cutoff_fc3_distance", + type=float, + default=None, + help=( + "Cutoff distance of third-order force constants. Elements where " + "any pair of atoms has larger distance than cut-off distance " + "are set zero." + ), + ) + parser.add_argument( + "--cutoff-freq", + "--cutoff-frequency", + dest="cutoff_frequency", + type=float, + default=None, + help="Phonon modes below this frequency are ignored.", + ) + parser.add_argument( + "--cutoff-pair", + "--cutoff-pair-distance", + dest="cutoff_pair_distance", + type=float, + default=None, + help=( + "Cutoff distance between pairs of displaced atoms used for " + "supercell creation with displacements and making third-order " + "force constants" + ), + ) + parser.add_argument( + "-d", + "--disp", + dest="is_displacement", + action="store_true", + default=False, + help="As first stage, get least displacements", + ) + parser.add_argument( + "--dim", + nargs="+", + dest="supercell_dimension", + default=None, + help="Supercell dimension", + ) + parser.add_argument( + "--dim-fc2", + nargs="+", + dest="phonon_supercell_dimension", + default=None, + help="Supercell dimension for extra fc2", + ) + parser.add_argument( + "--emulate-v1", + dest="emulate_v1", + action="store_true", + default=False, + help="Emulate v1.x grid system and shortest vectors.", + ) + parser.add_argument( + "--factor", + dest="frequency_conversion_factor", + type=float, + default=None, + help="Frequency unit conversion factor", + ) if not load_phono3py_yaml: parser.add_argument( - "--fc2", dest="read_fc2", action="store_true", default=False, - help="Read second order force constants") + "--fc2", + dest="read_fc2", + action="store_true", + default=False, + help="Read second order force constants", + ) parser.add_argument( - "--fc3", dest="read_fc3", action="store_true", default=False, - help="Read third order force constants") + "--fc3", + dest="read_fc3", + action="store_true", + default=False, + help="Read third order force constants", + ) parser.add_argument( - "--fc-calc-opt", "--fc-calculator-options", - dest="fc_calculator_options", default=None, - help=("Options for force constants calculator as comma separated " - "string with the style of key = values")) + "--fc-calc-opt", + "--fc-calculator-options", + dest="fc_calculator_options", + default=None, + help=( + "Options for force constants calculator as comma separated " + "string with the style of key = values" + ), + ) if not fc_symmetry: parser.add_argument( - "--fc-symmetry", "--sym-fc", dest="fc_symmetry", - action="store_true", default=False, - help="Symmetrize force constants") + "--fc-symmetry", + "--sym-fc", + dest="fc_symmetry", + action="store_true", + default=False, + help="Symmetrize force constants", + ) parser.add_argument( - "--freq-scale", dest="frequency_scale_factor", type=float, + "--freq-scale", + dest="frequency_scale_factor", + type=float, default=None, - help=("Factor multiplied as fc2 * factor^2 and fc3 * factor^2. " - "Phonon frequency is changed but the contribution from NAC is " - "not changed.")) + help=( + "Factor multiplied as fc2 * factor^2 and fc3 * factor^2. " + "Phonon frequency is changed but the contribution from NAC is " + "not changed." + ), + ) parser.add_argument( - "--freq-pitch", dest="fpitch", type=float, default=None, - help="Pitch in frequency for spectrum") - parser.add_argument( - "--fs2f2", "--force-sets-to-forces-fc2", - dest="force_sets_to_forces_fc2_mode", default=False, - action="store_true", help="Create FORCES_FC2 from FORCE_SETS") - parser.add_argument( - "--full-pp", dest="is_full_pp", action="store_true", default=False, - help=("Calculate full ph-ph interaction for RTA conductivity." - "This may be activated when full elements of ph-ph interaction " - "strength are needed, i.e., to calculate average ph-ph " - "interaction strength.")) - parser.add_argument( - "--ga", "--grid-addresses", nargs='+', dest="grid_addresses", + "--freq-pitch", + dest="fpitch", + type=float, default=None, - help="Fixed grid addresses where anharmonic properties are calculated") + help="Pitch in frequency for spectrum", + ) parser.add_argument( - "--gamma-unit-conversion", dest="gamma_unit_conversion", type=float, + "--fs2f2", + "--force-sets-to-forces-fc2", + dest="force_sets_to_forces_fc2_mode", + default=False, + action="store_true", + help="Create FORCES_FC2 from FORCE_SETS", + ) + parser.add_argument( + "--full-pp", + dest="is_full_pp", + action="store_true", + default=False, + help=( + "Calculate full ph-ph interaction for RTA conductivity." + "This may be activated when full elements of ph-ph interaction " + "strength are needed, i.e., to calculate average ph-ph " + "interaction strength." + ), + ) + parser.add_argument( + "--ga", + "--grid-addresses", + nargs="+", + dest="grid_addresses", default=None, - help="Conversion factor for gamma") + help="Fixed grid addresses where anharmonic properties are calculated", + ) parser.add_argument( - "--gp", "--grid-points", nargs='+', dest="grid_points", default=None, - help="Fixed grid points where anharmonic properties are calculated") + "--gp", + "--grid-points", + nargs="+", + dest="grid_points", + default=None, + help="Fixed grid points where anharmonic properties are calculated", + ) parser.add_argument( - "--grg", "--generalized-regular-grid", dest="use_grg", - action="store_true", default=False, - help="Use generalized regular grid.") + "--grg", + "--generalized-regular-grid", + dest="use_grg", + action="store_true", + default=False, + help="Use generalized regular grid.", + ) parser.add_argument( - "--gruneisen", dest="is_gruneisen", action="store_true", default=False, - help="Calculate phonon Gruneisen parameter") + "--gruneisen", + dest="is_gruneisen", + action="store_true", + default=False, + help="Calculate phonon Gruneisen parameter", + ) parser.add_argument( - "--gv-delta-q", dest="gv_delta_q", type=float, default=None, - help="Delta-q distance used for group velocity calculation") + "--gv-delta-q", + dest="gv_delta_q", + type=float, + default=None, + help="Delta-q distance used for group velocity calculation", + ) parser.add_argument( - "--hdf5-compression", dest="hdf5_compression", default=None, - help="hdf5 compression filter (default: gzip)") + "--hdf5-compression", + dest="hdf5_compression", + default=None, + help="hdf5 compression filter (default: gzip)", + ) if not load_phono3py_yaml: parser.add_argument( - "-i", dest="input_filename", default=None, - help="Input filename extension") + "-i", dest="input_filename", default=None, help="Input filename extension" + ) parser.add_argument( - "--io", dest="input_output_filename", default=None, - help="Input and output filename extension") + "--io", + dest="input_output_filename", + default=None, + help="Input and output filename extension", + ) parser.add_argument( - "--ion-clamped", dest="ion_clamped", action="store_true", + "--ion-clamped", + dest="ion_clamped", + action="store_true", default=False, - help=("Atoms are clamped under applied strain in Gruneisen parameter " - "calculation")) + help=( + "Atoms are clamped under applied strain in Gruneisen parameter " + "calculation" + ), + ) parser.add_argument( - "--ise", dest="is_imag_self_energy", action="store_true", + "--ise", + dest="is_imag_self_energy", + action="store_true", default=False, - help="Calculate imaginary part of self energy") + help="Calculate imaginary part of self energy", + ) parser.add_argument( - "--isotope", dest="is_isotope", action="store_true", default=False, - help="Isotope scattering lifetime") + "--isotope", + dest="is_isotope", + action="store_true", + default=False, + help="Isotope scattering lifetime", + ) parser.add_argument( - "--jdos", dest="is_joint_dos", action="store_true", default=False, - help="Calculate joint density of states") + "--jdos", + dest="is_joint_dos", + action="store_true", + default=False, + help="Calculate joint density of states", + ) parser.add_argument( - "--lbte", dest="is_lbte", action="store_true", default=False, - help="Calculate thermal conductivity LBTE with Chaput's method") + "--lbte", + dest="is_lbte", + action="store_true", + default=False, + help="Calculate thermal conductivity LBTE with Chaput's method", + ) parser.add_argument( - "--loglevel", dest="log_level", type=int, default=None, - help="Log level") + "--loglevel", dest="log_level", type=int, default=None, help="Log level" + ) parser.add_argument( - "--mass", nargs='+', dest="masses", default=None, - help="Same as MASS tag") + "--mass", nargs="+", dest="masses", default=None, help="Same as MASS tag" + ) parser.add_argument( - "--mesh", nargs='+', dest="mesh_numbers", default=None, - help="Mesh numbers") + "--mesh", nargs="+", dest="mesh_numbers", default=None, help="Mesh numbers" + ) parser.add_argument( - "--mv", "--mass-variances", nargs='+', dest="mass_variances", + "--mv", + "--mass-variances", + nargs="+", + dest="mass_variances", default=None, - help="Mass variance parameters for isotope scattering") + help="Mass variance parameters for isotope scattering", + ) if not is_nac: parser.add_argument( - "--nac", dest="is_nac", action="store_true", default=False, - help="Non-analytical term correction") + "--nac", + dest="is_nac", + action="store_true", + default=False, + help="Non-analytical term correction", + ) parser.add_argument( - "--nac-method", dest="nac_method", default=None, - help="Non-analytical term correction method: Wang (default) or Gonze") + "--nac-method", + dest="nac_method", + default=None, + help="Non-analytical term correction method: Wang (default) or Gonze", + ) if fc_symmetry: parser.add_argument( - "--no-fc-symmetry", "--no-sym-fc", - dest="fc_symmetry", action="store_false", - default=True, help="Do not symmetrize force constants") + "--no-fc-symmetry", + "--no-sym-fc", + dest="fc_symmetry", + action="store_false", + default=True, + help="Do not symmetrize force constants", + ) parser.add_argument( - "--nodiag", dest="is_nodiag", action="store_true", default=False, - help="Set displacements parallel to axes") + "--nodiag", + dest="is_nodiag", + action="store_true", + default=False, + help="Set displacements parallel to axes", + ) parser.add_argument( - "--noks", "--no-kappa-stars", dest="no_kappa_stars", - action="store_true", default=False, - help="Deactivate summation of partial kappa at q-stars"), + "--noks", + "--no-kappa-stars", + dest="no_kappa_stars", + action="store_true", + default=False, + help="Deactivate summation of partial kappa at q-stars", + ), parser.add_argument( - "--nomeshsym", dest="is_nomeshsym", action="store_true", default=False, - help="No symmetrization of triplets is made.") + "--nomeshsym", + dest="is_nomeshsym", + action="store_true", + default=False, + help="No symmetrization of triplets is made.", + ) if is_nac: parser.add_argument( - "--nonac", dest="is_nac", action="store_false", default=True, - help="Non-analytical term correction") + "--nonac", + dest="is_nac", + action="store_false", + default=True, + help="Non-analytical term correction", + ) parser.add_argument( - "--nosym", dest="is_nosym", action="store_true", default=False, - help="Symmetry is not imposed.") + "--nosym", + dest="is_nosym", + action="store_true", + default=False, + help="Symmetry is not imposed.", + ) parser.add_argument( - "--nu", dest="is_N_U", action="store_true", default=False, - help="Split Gamma into Normal and Umklapp processes") + "--nu", + dest="is_N_U", + action="store_true", + default=False, + help="Split Gamma into Normal and Umklapp processes", + ) parser.add_argument( - "--num-freq-points", dest="num_frequency_points", type=int, + "--num-freq-points", + dest="num_frequency_points", + type=int, default=None, - help="Number of sampling points for spectrum") + help="Number of sampling points for spectrum", + ) parser.add_argument( - "--num-points-in-batch", dest="num_points_in_batch", type=int, + "--num-points-in-batch", + dest="num_points_in_batch", + type=int, default=None, - help=("Number of frequency points in a batch for the frequency " - "sampling modes of imag-self-energy calculation")) + help=( + "Number of frequency points in a batch for the frequency " + "sampling modes of imag-self-energy calculation" + ), + ) if not load_phono3py_yaml: parser.add_argument( - "-o", dest="output_filename", default=None, - help="Output filename extension") + "-o", dest="output_filename", default=None, help="Output filename extension" + ) parser.add_argument( - "--pa", "--primitive-axis", "--primitive-axes", nargs='+', - dest="primitive_axes", default=None, - help="Same as PRIMITIVE_AXES tags") - parser.add_argument( - "--pinv-cutoff", dest="pinv_cutoff", type=float, default=None, - help="Cutoff frequency (THz) for pseudo inversion of collision matrix") - parser.add_argument( - "--pinv-solver", dest="pinv_solver", type=int, default=None, - help="Switch of LBTE pinv solver") - parser.add_argument( - "--pm", dest="is_plusminus_displacements", action="store_true", - default=False, - help="Set plus minus displacements") - parser.add_argument( - "--pp-unit-conversion", dest="pp_unit_conversion", type=float, + "--pa", + "--primitive-axis", + "--primitive-axes", + nargs="+", + dest="primitive_axes", default=None, - help="Conversion factor for ph-ph interaction") + help="Same as PRIMITIVE_AXES tags", + ) parser.add_argument( - "--qpoints", nargs='+', dest="qpoints", default=None, - help="Calculate at specified q-points") - parser.add_argument( - "--q-direction", nargs='+', dest="nac_q_direction", default=None, - help="q-vector direction at q->0 for non-analytical term correction") - parser.add_argument( - "-q", "--quiet", dest="quiet", action="store_true", default=False, - help="Print out smallest information") - parser.add_argument( - "--read-collision", dest="read_collision", default=None, - help="Read collision matrix and Gammas from files") - parser.add_argument( - "--read-gamma", dest="read_gamma", action="store_true", default=False, - help="Read Gammas from files") - parser.add_argument( - "--read-phonon", dest="read_phonon", action="store_true", - default=False, - help="Read phonons from files") - parser.add_argument( - "--read-pp", dest="read_pp", action="store_true", default=False, - help="Read phonon-phonon interaction strength") - parser.add_argument( - "--reducible-colmat", dest="is_reducible_collision_matrix", - action="store_true", default=False, - help="Solve reducible collision matrix") - parser.add_argument( - "--rse", dest="is_real_self_energy", action="store_true", - default=False, - help="Calculate real part of self energy") - parser.add_argument( - "--scattering-event-class", dest="scattering_event_class", type=int, + "--pinv-cutoff", + dest="pinv_cutoff", + type=float, default=None, - help=("Scattering event class 1 or 2 to draw imaginary part of self " - "energy")) + help="Cutoff frequency (THz) for pseudo inversion of collision matrix", + ) parser.add_argument( - "--sigma", nargs='+', dest="sigma", default=None, - help=("A sigma value or multiple sigma values (separated by space) " - "for smearing function")) + "--pinv-solver", + dest="pinv_solver", + type=int, + default=None, + help="Switch of LBTE pinv solver", + ) parser.add_argument( - "--sigma-cutoff", dest="sigma_cutoff_width", type=float, default=None, - help="Cutoff width of smearing function (ratio to sigma value)") - parser.add_argument( - "--spf", dest="is_spectral_function", action="store_true", + "--pm", + dest="is_plusminus_displacements", + action="store_true", default=False, - help="Calculate spectral function") + help="Set plus minus displacements", + ) parser.add_argument( - "--stp", "--show-num-triplets", dest="show_num_triplets", - action="store_true", default=False, - help=("Show reduced number of triplets to be calculated at " - "specified grid points")) + "--pp-unit-conversion", + dest="pp_unit_conversion", + type=float, + default=None, + help="Conversion factor for ph-ph interaction", + ) + parser.add_argument( + "--qpoints", + nargs="+", + dest="qpoints", + default=None, + help="Calculate at specified q-points", + ) + parser.add_argument( + "--q-direction", + nargs="+", + dest="nac_q_direction", + default=None, + help="q-vector direction at q->0 for non-analytical term correction", + ) + parser.add_argument( + "-q", + "--quiet", + dest="quiet", + action="store_true", + default=False, + help="Print out smallest information", + ) + parser.add_argument( + "--read-collision", + dest="read_collision", + default=None, + help="Read collision matrix and Gammas from files", + ) + parser.add_argument( + "--read-gamma", + dest="read_gamma", + action="store_true", + default=False, + help="Read Gammas from files", + ) + parser.add_argument( + "--read-phonon", + dest="read_phonon", + action="store_true", + default=False, + help="Read phonons from files", + ) + parser.add_argument( + "--read-pp", + dest="read_pp", + action="store_true", + default=False, + help="Read phonon-phonon interaction strength", + ) + parser.add_argument( + "--reducible-colmat", + dest="is_reducible_collision_matrix", + action="store_true", + default=False, + help="Solve reducible collision matrix", + ) + parser.add_argument( + "--rse", + dest="is_real_self_energy", + action="store_true", + default=False, + help="Calculate real part of self energy", + ) + parser.add_argument( + "--scattering-event-class", + dest="scattering_event_class", + type=int, + default=None, + help=("Scattering event class 1 or 2 to draw imaginary part of self " "energy"), + ) + parser.add_argument( + "--sigma", + nargs="+", + dest="sigma", + default=None, + help=( + "A sigma value or multiple sigma values (separated by space) " + "for smearing function" + ), + ) + parser.add_argument( + "--sigma-cutoff", + dest="sigma_cutoff_width", + type=float, + default=None, + help="Cutoff width of smearing function (ratio to sigma value)", + ) + parser.add_argument( + "--spf", + dest="is_spectral_function", + action="store_true", + default=False, + help="Calculate spectral function", + ) + parser.add_argument( + "--stp", + "--show-num-triplets", + dest="show_num_triplets", + action="store_true", + default=False, + help=( + "Show reduced number of triplets to be calculated at " + "specified grid points" + ), + ) if not load_phono3py_yaml: parser.add_argument( - "--sym-fc2", dest="is_symmetrize_fc2", action="store_true", + "--sym-fc2", + dest="is_symmetrize_fc2", + action="store_true", default=False, - help="Symmetrize fc2 by index exchange") + help="Symmetrize fc2 by index exchange", + ) parser.add_argument( - "--sym-fc3r", dest="is_symmetrize_fc3_r", action="store_true", + "--sym-fc3r", + dest="is_symmetrize_fc3_r", + action="store_true", default=False, - help="Symmetrize fc3 in real space by index exchange") + help="Symmetrize fc3 in real space by index exchange", + ) parser.add_argument( - "--sym-fc3q", dest="is_symmetrize_fc3_q", action="store_true", + "--sym-fc3q", + dest="is_symmetrize_fc3_q", + action="store_true", default=False, - help="Symmetrize fc3 in reciprocal space by index exchange") + help="Symmetrize fc3 in reciprocal space by index exchange", + ) parser.add_argument( - "--thm", "--tetrahedron-method", dest="is_tetrahedron_method", - action="store_true", default=False, - help="Use tetrahedron method.") - parser.add_argument( - "--tmax", dest="tmax", default=None, - help="Maximum calculated temperature") - parser.add_argument( - "--tmin", dest="tmin", default=None, - help="Minimum calculated temperature") - parser.add_argument( - "--ts", nargs='+', dest="temperatures", default=None, - help="Temperatures for damping functions") - parser.add_argument( - "--tstep", dest="tstep", default=None, - help="Calculated temperature step") - parser.add_argument( - "--tolerance", dest="symmetry_tolerance", type=float, default=None, - help="Symmetry tolerance to search") - parser.add_argument( - "--uplo", dest="lapack_zheev_uplo", default=None, - help="Lapack zheev UPLO for phonon solver (default: L)") - parser.add_argument( - "-v", "--verbose", dest="verbose", action="store_true", default=False, - help="Detailed run-time information is displayed") - parser.add_argument( - "--wgp", "--write-grid-points", dest="write_grid_points", - action="store_true", default=False, - help=("Write grid address of irreducible grid points for specified " - "mesh numbers to ir_grid_address.yaml")) - parser.add_argument( - "--write-collision", dest="write_collision", action="store_true", + "--thm", + "--tetrahedron-method", + dest="is_tetrahedron_method", + action="store_true", default=False, - help="Write collision matrix and Gammas to files") + help="Use tetrahedron method.", + ) parser.add_argument( - "--write-gamma", dest="write_gamma", action="store_true", + "--tmax", dest="tmax", default=None, help="Maximum calculated temperature" + ) + parser.add_argument( + "--tmin", dest="tmin", default=None, help="Minimum calculated temperature" + ) + parser.add_argument( + "--ts", + nargs="+", + dest="temperatures", + default=None, + help="Temperatures for damping functions", + ) + parser.add_argument( + "--tstep", dest="tstep", default=None, help="Calculated temperature step" + ) + parser.add_argument( + "--tolerance", + dest="symmetry_tolerance", + type=float, + default=None, + help="Symmetry tolerance to search", + ) + parser.add_argument( + "--uplo", + dest="lapack_zheev_uplo", + default=None, + help="Lapack zheev UPLO for phonon solver (default: L)", + ) + parser.add_argument( + "-v", + "--verbose", + dest="verbose", + action="store_true", default=False, - help="Write imag-part of self energy to files") + help="Detailed run-time information is displayed", + ) parser.add_argument( - "--write-gamma-detail", "--write_detailed_gamma", - dest="write_gamma_detail", action="store_true", default=False, - help="Write out detailed imag-part of self energy") - parser.add_argument( - "--write-phonon", dest="write_phonon", action="store_true", + "--wgp", + "--write-grid-points", + dest="write_grid_points", + action="store_true", default=False, - help="Write all phonons on grid points to files") + help=( + "Write grid address of irreducible grid points for specified " + "mesh numbers to ir_grid_address.yaml" + ), + ) parser.add_argument( - "--write-pp", dest="write_pp", action="store_true", default=False, - help="Write phonon-phonon interaction strength") + "--write-collision", + dest="write_collision", + action="store_true", + default=False, + help="Write collision matrix and Gammas to files", + ) parser.add_argument( - "--write-lbte-solution", dest="write_LBTE_solution", - action="store_true", default=False, - help="Write direct solution of LBTE to hdf5 files") + "--write-gamma", + dest="write_gamma", + action="store_true", + default=False, + help="Write imag-part of self energy to files", + ) + parser.add_argument( + "--write-gamma-detail", + "--write_detailed_gamma", + dest="write_gamma_detail", + action="store_true", + default=False, + help="Write out detailed imag-part of self energy", + ) + parser.add_argument( + "--write-phonon", + dest="write_phonon", + action="store_true", + default=False, + help="Write all phonons on grid points to files", + ) + parser.add_argument( + "--write-pp", + dest="write_pp", + action="store_true", + default=False, + help="Write phonon-phonon interaction strength", + ) + parser.add_argument( + "--write-lbte-solution", + dest="write_LBTE_solution", + action="store_true", + default=False, + help="Write direct solution of LBTE to hdf5 files", + ) if load_phono3py_yaml: - parser.add_argument( - "filename", nargs='*', help="phono3py.yaml like file") + parser.add_argument("filename", nargs="*", help="phono3py.yaml like file") else: - parser.add_argument( - "filename", nargs='*', help="Phono3py configure file") + parser.add_argument("filename", nargs="*", help="Phono3py configure file") return parser, deprecated diff --git a/phono3py/cui/phono3py_script.py b/phono3py/cui/phono3py_script.py index 6bc28517..0b3d2ba0 100644 --- a/phono3py/cui/phono3py_script.py +++ b/phono3py/cui/phono3py_script.py @@ -35,25 +35,41 @@ import sys import numpy as np -from phonopy.file_IO import ( - write_FORCE_SETS, parse_FORCE_SETS, is_file_phonopy_yaml) +from phonopy.file_IO import write_FORCE_SETS, parse_FORCE_SETS, is_file_phonopy_yaml from phonopy.units import VaspToTHz, Bohr, Hartree from phonopy.cui.collect_cell_info import collect_cell_info from phonopy.cui.create_force_sets import check_number_of_force_files from phonopy.interface.calculator import ( - get_force_sets, get_default_physical_units, get_interface_mode) + get_force_sets, + get_default_physical_units, + get_interface_mode, +) from phonopy.cui.phonopy_argparse import show_deprecated_option_warnings from phonopy.phonon.band_structure import get_band_qpoints from phonopy.cui.phonopy_script import ( - store_nac_params, print_end, print_error, print_error_message, - print_version, file_exists, files_exist, get_fc_calculator_params) + store_nac_params, + print_end, + print_error, + print_error_message, + print_version, + file_exists, + files_exist, + get_fc_calculator_params, +) from phonopy.structure.cells import isclose as cells_isclose from phono3py.version import __version__ from phono3py.file_IO import ( - parse_disp_fc2_yaml, parse_disp_fc3_yaml, - write_disp_fc2_yaml, read_phonon_from_hdf5, write_phonon_to_hdf5, - parse_FORCES_FC2, write_FORCES_FC2, write_FORCES_FC3, - get_length_of_first_line, write_fc3_to_hdf5, write_fc2_to_hdf5) + parse_disp_fc2_yaml, + parse_disp_fc3_yaml, + read_phonon_from_hdf5, + write_phonon_to_hdf5, + parse_FORCES_FC2, + write_FORCES_FC2, + write_FORCES_FC3, + get_length_of_first_line, + write_fc3_to_hdf5, + write_fc2_to_hdf5, +) from phono3py.cui.settings import Phono3pyConfParser from phono3py.cui.load import set_dataset_and_force_constants from phono3py import Phono3py, Phono3pyJointDos, Phono3pyIsotope @@ -61,12 +77,17 @@ from phono3py.phonon3.gruneisen import run_gruneisen_parameters from phono3py.phonon.grid import get_grid_point_from_address from phono3py.cui.phono3py_argparse import get_parser from phono3py.cui.show_log import ( - show_general_settings, show_phono3py_settings, show_phono3py_cells) + show_general_settings, + show_phono3py_settings, + show_phono3py_cells, +) from phono3py.cui.triplets_info import write_grid_points, show_num_triplets from phono3py.cui.create_supercells import create_phono3py_supercells from phono3py.cui.create_force_constants import create_phono3py_force_constants from phono3py.interface.phono3py_yaml import ( - Phono3pyYaml, displacements_yaml_lines_type1) + Phono3pyYaml, + displacements_yaml_lines_type1, +) # import logging @@ -77,19 +98,19 @@ from phono3py.interface.phono3py_yaml import ( # AA is created at http://www.network-science.de/ascii/. def print_phono3py(): """Show phono3py logo.""" - print(r""" _ _____ + print( + r""" _ _____ _ __ | |__ ___ _ __ ___|___ / _ __ _ _ | '_ \| '_ \ / _ \| '_ \ / _ \ |_ \| '_ \| | | | | |_) | | | | (_) | | | | (_) |__) | |_) | |_| | | .__/|_| |_|\___/|_| |_|\___/____/| .__/ \__, | - |_| |_| |___/ """) + |_| |_| |___/ """ + ) -def finalize_phono3py(phono3py, - confs, - log_level, - displacements_mode=False, - filename="phono3py.yaml"): +def finalize_phono3py( + phono3py, confs, log_level, displacements_mode=False, filename="phono3py.yaml" +): """Write phono3py.yaml and then exit. Parameters @@ -114,25 +135,22 @@ def finalize_phono3py(phono3py, _calculator = None _physical_units = get_default_physical_units(_calculator) - yaml_settings = { - 'force_sets': False, - 'displacements': displacements_mode - } + yaml_settings = {"force_sets": False, "displacements": displacements_mode} - ph3py_yaml = Phono3pyYaml(configuration=confs, - physical_units=_physical_units, - settings=yaml_settings) + ph3py_yaml = Phono3pyYaml( + configuration=confs, physical_units=_physical_units, settings=yaml_settings + ) ph3py_yaml.set_phonon_info(phono3py) ph3py_yaml.calculator = _calculator - with open(filename, 'w') as w: + with open(filename, "w") as w: w.write(str(ph3py_yaml)) if log_level > 0: print("") if displacements_mode: - print("Displacement dataset was written in \"%s\"." % filename) + print('Displacement dataset was written in "%s".' % filename) else: - print("Summary of calculation was written in \"%s\"." % filename) + print('Summary of calculation was written in "%s".' % filename) print_end() sys.exit(0) @@ -181,10 +199,11 @@ def start_phono3py(**argparse_control): if log_level: print_phono3py() print_version(__version__) - if argparse_control.get('load_phono3py_yaml', False): + if argparse_control.get("load_phono3py_yaml", False): print("Running in phono3py.load mode.") print("Python version %d.%d.%d" % sys.version_info[:3]) import spglib + print("Spglib version %d.%d.%d" % spglib.get_version()) if deprecated: @@ -202,21 +221,23 @@ def read_phono3py_settings(args, argparse_control, log_level): * Command line options """ - load_phono3py_yaml = argparse_control.get('load_phono3py_yaml', False) + load_phono3py_yaml = argparse_control.get("load_phono3py_yaml", False) if len(args.filename) > 0: file_exists(args.filename[0], log_level) if load_phono3py_yaml: phono3py_conf_parser = Phono3pyConfParser( - args=args, default_settings=argparse_control) + args=args, default_settings=argparse_control + ) cell_filename = args.filename[0] else: - if is_file_phonopy_yaml(args.filename[0], keyword='phono3py'): + if is_file_phonopy_yaml(args.filename[0], keyword="phono3py"): phono3py_conf_parser = Phono3pyConfParser(args=args) cell_filename = args.filename[0] else: phono3py_conf_parser = Phono3pyConfParser( - filename=args.filename[0], args=args) + filename=args.filename[0], args=args + ) cell_filename = phono3py_conf_parser.settings.cell_filename else: phono3py_conf_parser = Phono3pyConfParser(args=args) @@ -230,7 +251,7 @@ def read_phono3py_settings(args, argparse_control, log_level): def create_FORCES_FC2_from_FORCE_SETS_then_exit(log_level): """Convert FORCE_SETS to FORCES_FC2.""" - filename = 'FORCE_SETS' + filename = "FORCE_SETS" file_exists(filename, log_level) disp_dataset = parse_FORCE_SETS(filename=filename) write_FORCES_FC2(disp_dataset) @@ -249,24 +270,22 @@ def create_FORCES_FC2_from_FORCE_SETS_then_exit(log_level): sys.exit(0) -def create_FORCE_SETS_from_FORCES_FCx_then_exit(phonon_smat, - input_filename, - log_level): +def create_FORCE_SETS_from_FORCES_FCx_then_exit(phonon_smat, input_filename, log_level): """Convert FORCES_FC3 or FORCES_FC2 to FORCE_SETS.""" if phonon_smat is not None: if input_filename is None: - disp_filename = 'disp_fc2.yaml' + disp_filename = "disp_fc2.yaml" else: - disp_filename = 'disp_fc2.' + input_filename + '.yaml' + disp_filename = "disp_fc2." + input_filename + ".yaml" forces_filename = "FORCES_FC2" else: if input_filename is None: - disp_filename = 'disp_fc3.yaml' + disp_filename = "disp_fc3.yaml" else: - disp_filename = 'disp_fc3.' + input_filename + '.yaml' + disp_filename = "disp_fc3." + input_filename + ".yaml" forces_filename = "FORCES_FC3" - with open(forces_filename, 'r') as f: + with open(forces_filename, "r") as f: len_first_line = get_length_of_first_line(f) if len_first_line == 3: @@ -275,8 +294,7 @@ def create_FORCE_SETS_from_FORCES_FCx_then_exit(phonon_smat, file_exists(forces_filename, log_level) parse_FORCES_FC2(disp_dataset, filename=forces_filename) if log_level: - print("Displacement dataset was read from \"%s\"." - % disp_filename) + print('Displacement dataset was read from "%s".' % disp_filename) write_FORCE_SETS(disp_dataset) if log_level: @@ -284,16 +302,17 @@ def create_FORCE_SETS_from_FORCES_FCx_then_exit(phonon_smat, print_end() else: if log_level: - print("The file format of %s is already readable by phonopy." - % forces_filename) + print( + "The file format of %s is already readable by phonopy." + % forces_filename + ) print_end() sys.exit(0) -def create_FORCES_FC3_and_FORCES_FC2_then_exit(settings, - input_filename, - output_filename, - log_level): +def create_FORCES_FC3_and_FORCES_FC2_then_exit( + settings, input_filename, output_filename, log_level +): """Create FORCES_FC3 and FORCES_FC2 from files.""" interface_mode = settings.calculator @@ -302,25 +321,26 @@ def create_FORCES_FC3_and_FORCES_FC2_then_exit(settings, ##################### if settings.create_forces_fc3 or settings.create_forces_fc3_file: if input_filename is None: - disp_fc3_filename = 'disp_fc3.yaml' + disp_fc3_filename = "disp_fc3.yaml" else: - disp_fc3_filename = 'disp_fc3.' + input_filename + '.yaml' + disp_fc3_filename = "disp_fc3." + input_filename + ".yaml" ph3py_yaml = None disp_filenames = files_exist( - ['phono3py_disp.yaml', disp_fc3_filename], log_level, is_any=True) + ["phono3py_disp.yaml", disp_fc3_filename], log_level, is_any=True + ) - if disp_filenames[0] == 'phono3py_disp.yaml': + if disp_filenames[0] == "phono3py_disp.yaml": try: ph3py_yaml = Phono3pyYaml() - ph3py_yaml.read('phono3py_disp.yaml') + ph3py_yaml.read("phono3py_disp.yaml") if ph3py_yaml.calculator is not None: interface_mode = ph3py_yaml.calculator # overwrite - disp_filename = 'phono3py_disp.yaml' + disp_filename = "phono3py_disp.yaml" except KeyError: - file_exists('disp_fc3.yaml', log_level) + file_exists("disp_fc3.yaml", log_level) if log_level > 0: - print("\"phono3py_disp.yaml\" was found but wasn't used.") + print('"phono3py_disp.yaml" was found but wasn\'t used.') disp_filename = disp_fc3_filename else: disp_filename = disp_filenames[0] @@ -332,20 +352,19 @@ def create_FORCES_FC3_and_FORCES_FC2_then_exit(settings, disp_dataset = ph3py_yaml.dataset if log_level: - print('') - print("Displacement dataset was read from \"%s\"." % disp_filename) + print("") + print('Displacement dataset was read from "%s".' % disp_filename) - num_atoms = disp_dataset['natom'] - num_disps = len(disp_dataset['first_atoms']) - for d1 in disp_dataset['first_atoms']: - for d2 in d1['second_atoms']: - if 'included' not in d2 or d2['included']: + num_atoms = disp_dataset["natom"] + num_disps = len(disp_dataset["first_atoms"]) + for d1 in disp_dataset["first_atoms"]: + for d2 in d1["second_atoms"]: + if "included" not in d2 or d2["included"]: num_disps += 1 if settings.create_forces_fc3_file: file_exists(settings.create_forces_fc3_file, log_level) - force_filenames = [ - x.strip() for x in open(settings.create_forces_fc3_file)] + force_filenames = [x.strip() for x in open(settings.create_forces_fc3_file)] else: force_filenames = settings.create_forces_fc3 @@ -356,37 +375,41 @@ def create_FORCES_FC3_and_FORCES_FC2_then_exit(settings, print("Number of displacements: %d" % num_disps) print("Number of supercell files: %d" % len(force_filenames)) - if not check_number_of_force_files(num_disps, - force_filenames, - disp_filename): + if not check_number_of_force_files(num_disps, force_filenames, disp_filename): force_sets = [] else: - force_sets = get_force_sets(interface_mode, - num_atoms, - num_disps, - force_filenames, - disp_filename=disp_filename, - verbose=(log_level > 0)) + force_sets = get_force_sets( + interface_mode, + num_atoms, + num_disps, + force_filenames, + disp_filename=disp_filename, + verbose=(log_level > 0), + ) if settings.subtract_forces: force_filename = settings.subtract_forces file_exists(force_filename, log_level) - force_set_zero = get_force_sets(interface_mode, - num_atoms, - 1, - [force_filename, ], - verbose=(log_level > 0))[0] + force_set_zero = get_force_sets( + interface_mode, + num_atoms, + 1, + [ + force_filename, + ], + verbose=(log_level > 0), + )[0] for fs in force_sets: fs -= force_set_zero if log_level > 0: - print("Forces in \'%s\' were subtracted from supercell forces." - % force_filename) + print( + "Forces in '%s' were subtracted from supercell forces." + % force_filename + ) if force_sets: - write_FORCES_FC3(disp_dataset, - forces_fc3=force_sets, - filename="FORCES_FC3") + write_FORCES_FC3(disp_dataset, forces_fc3=force_sets, filename="FORCES_FC3") if log_level: print("") print("%s has been created." % "FORCES_FC3") @@ -404,15 +427,15 @@ def create_FORCES_FC3_and_FORCES_FC2_then_exit(settings, ##################### if settings.create_forces_fc2: if input_filename is None: - disp_filename = 'disp_fc2.yaml' + disp_filename = "disp_fc2.yaml" else: - disp_filename = 'disp_fc2.' + input_filename + '.yaml' + disp_filename = "disp_fc2." + input_filename + ".yaml" file_exists(disp_filename, log_level) disp_dataset = parse_disp_fc2_yaml(filename=disp_filename) if log_level: - print("Displacement dataset was read from \"%s\"." % disp_filename) - num_atoms = disp_dataset['natom'] - num_disps = len(disp_dataset['first_atoms']) + print('Displacement dataset was read from "%s".' % disp_filename) + num_atoms = disp_dataset["natom"] + num_disps = len(disp_dataset["first_atoms"]) force_filenames = settings.create_forces_fc2 for filename in force_filenames: file_exists(filename, log_level) @@ -420,32 +443,38 @@ def create_FORCES_FC3_and_FORCES_FC2_then_exit(settings, if log_level > 0: print("Number of displacements: %d" % num_disps) print("Number of supercell files: %d" % len(force_filenames)) - force_sets = get_force_sets(interface_mode, - num_atoms, - num_disps, - force_filenames, - disp_filename, - verbose=(log_level > 0)) + force_sets = get_force_sets( + interface_mode, + num_atoms, + num_disps, + force_filenames, + disp_filename, + verbose=(log_level > 0), + ) if settings.subtract_forces: force_filename = settings.subtract_forces file_exists(force_filename, log_level) - force_set_zero = get_force_sets(interface_mode, - num_atoms, - 1, - [force_filename, ], - verbose=(log_level > 0))[0] + force_set_zero = get_force_sets( + interface_mode, + num_atoms, + 1, + [ + force_filename, + ], + verbose=(log_level > 0), + )[0] for fs in force_sets: fs -= force_set_zero if log_level > 0: - print("Forces in \'%s\' were subtracted from supercell forces." - % force_filename) + print( + "Forces in '%s' were subtracted from supercell forces." + % force_filename + ) if force_sets: - write_FORCES_FC2(disp_dataset, - forces_fc2=force_sets, - filename="FORCES_FC2") + write_FORCES_FC2(disp_dataset, forces_fc2=force_sets, filename="FORCES_FC2") if log_level: print("") print("%s has been created." % "FORCES_FC2") @@ -479,7 +508,8 @@ def get_cell_info(settings, cell_filename, symprec, log_level): chemical_symbols=settings.chemical_symbols, phonopy_yaml_cls=Phono3pyYaml, symprec=symprec, - return_dict=True) + return_dict=True, + ) if type(cell_info) is str: print_error_message(cell_info) if log_level > 0: @@ -490,11 +520,11 @@ def get_cell_info(settings, cell_filename, symprec, log_level): # ('unitcell', 'supercell_matrix', 'primitive_matrix', # 'optional_structure_info', 'interface_mode', 'phonopy_yaml') - cell_info['phonon_supercell_matrix'] = settings.phonon_supercell_matrix - ph3py_yaml = cell_info['phonopy_yaml'] - if cell_info['phonon_supercell_matrix'] is None and ph3py_yaml: + cell_info["phonon_supercell_matrix"] = settings.phonon_supercell_matrix + ph3py_yaml = cell_info["phonopy_yaml"] + if cell_info["phonon_supercell_matrix"] is None and ph3py_yaml: ph_smat = ph3py_yaml.phonon_supercell_matrix - cell_info['phonon_supercell_matrix'] = ph_smat + cell_info["phonon_supercell_matrix"] = ph_smat return cell_info @@ -560,61 +590,63 @@ def get_default_values(settings): cutoff_frequency = settings.cutoff_frequency params = {} - params['sigmas'] = sigmas - params['temperature_points'] = temperature_points - params['temperatures'] = temperatures - params['frequency_factor_to_THz'] = frequency_factor_to_THz - params['num_frequency_points'] = num_frequency_points - params['num_points_in_batch'] = num_points_in_batch - params['frequency_step'] = frequency_step - params['frequency_scale_factor'] = frequency_scale_factor - params['cutoff_frequency'] = cutoff_frequency + params["sigmas"] = sigmas + params["temperature_points"] = temperature_points + params["temperatures"] = temperatures + params["frequency_factor_to_THz"] = frequency_factor_to_THz + params["num_frequency_points"] = num_frequency_points + params["num_points_in_batch"] = num_points_in_batch + params["frequency_step"] = frequency_step + params["frequency_scale_factor"] = frequency_scale_factor + params["cutoff_frequency"] = cutoff_frequency return params def check_supercell_in_yaml(cell_info, ph3, distance_to_A, log_level): """Check consistency between generated cells and cells in yaml.""" - if cell_info['phonopy_yaml'] is not None: + if cell_info["phonopy_yaml"] is not None: if distance_to_A is None: d2A = 1.0 else: d2A = distance_to_A - if (cell_info['phonopy_yaml'].supercell is not None and - ph3.supercell is not None): # noqa E129 - yaml_cell = cell_info['phonopy_yaml'].supercell.copy() + if ( + cell_info["phonopy_yaml"].supercell is not None + and ph3.supercell is not None + ): # noqa E129 + yaml_cell = cell_info["phonopy_yaml"].supercell.copy() yaml_cell.cell = yaml_cell.cell * d2A if not cells_isclose(yaml_cell, ph3.supercell): if log_level: - print("Generated supercell is inconsistent with " - "that in \"%s\"." % - cell_info['optional_structure_info'][0]) + print( + "Generated supercell is inconsistent with " + 'that in "%s".' % cell_info["optional_structure_info"][0] + ) print_error() sys.exit(1) - if (cell_info['phonopy_yaml'].phonon_supercell is not None and - ph3.phonon_supercell is not None): # noqa E129 - yaml_cell = cell_info['phonopy_yaml'].phonon_supercell.copy() + if ( + cell_info["phonopy_yaml"].phonon_supercell is not None + and ph3.phonon_supercell is not None + ): # noqa E129 + yaml_cell = cell_info["phonopy_yaml"].phonon_supercell.copy() yaml_cell.cell = yaml_cell.cell * d2A if not cells_isclose(yaml_cell, ph3.phonon_supercell): if log_level: - print("Generated phonon supercell is inconsistent with " - "that in \"%s\"." % - cell_info['optional_structure_info'][0]) + print( + "Generated phonon supercell is inconsistent with " + 'that in "%s".' % cell_info["optional_structure_info"][0] + ) print_error() sys.exit(1) -def init_phono3py(settings, - cell_info, - interface_mode, - symprec, - log_level): +def init_phono3py(settings, cell_info, interface_mode, symprec, log_level): """Initialize phono3py and update settings by default values.""" physical_units = get_default_physical_units(interface_mode) - distance_to_A = physical_units['distance_to_A'] + distance_to_A = physical_units["distance_to_A"] # Change unit of lattice parameters to angstrom - unitcell = cell_info['unitcell'].copy() + unitcell = cell_info["unitcell"].copy() if distance_to_A is not None: lattice = unitcell.cell lattice *= distance_to_A @@ -629,11 +661,11 @@ def init_phono3py(settings, phono3py = Phono3py( unitcell, - cell_info['supercell_matrix'], - primitive_matrix=cell_info['primitive_matrix'], - phonon_supercell_matrix=cell_info['phonon_supercell_matrix'], - cutoff_frequency=updated_settings['cutoff_frequency'], - frequency_factor_to_THz=updated_settings['frequency_factor_to_THz'], + cell_info["supercell_matrix"], + primitive_matrix=cell_info["primitive_matrix"], + phonon_supercell_matrix=cell_info["phonon_supercell_matrix"], + cutoff_frequency=updated_settings["cutoff_frequency"], + frequency_factor_to_THz=updated_settings["frequency_factor_to_THz"], is_symmetry=settings.is_symmetry, is_mesh_symmetry=settings.is_mesh_symmetry, use_grg=settings.use_grg, @@ -641,10 +673,11 @@ def init_phono3py(settings, store_dense_svecs=(not settings.emulate_v1), symprec=symprec, calculator=interface_mode, - log_level=log_level) + log_level=log_level, + ) phono3py.masses = settings.masses phono3py.band_indices = settings.band_indices - phono3py.sigmas = updated_settings['sigmas'] + phono3py.sigmas = updated_settings["sigmas"] phono3py.sigma_cutoff = settings.sigma_cutoff_width check_supercell_in_yaml(cell_info, phono3py, distance_to_A, log_level) @@ -655,8 +688,7 @@ def init_phono3py(settings, def settings_to_grid_points(settings, bz_grid): """Read or set grid point indices.""" if settings.grid_addresses is not None: - grid_points = grid_addresses_to_grid_points( - settings.grid_addresses, bz_grid) + grid_points = grid_addresses_to_grid_points(settings.grid_addresses, bz_grid) elif settings.grid_points is not None: grid_points = settings.grid_points else: @@ -666,26 +698,28 @@ def settings_to_grid_points(settings, bz_grid): def grid_addresses_to_grid_points(grid_addresses, bz_grid): """Return grid point indices from grid addresses.""" - grid_points = [get_grid_point_from_address(ga, bz_grid.D_diag) - for ga in grid_addresses] + grid_points = [ + get_grid_point_from_address(ga, bz_grid.D_diag) for ga in grid_addresses + ] return bz_grid.grg2bzg[grid_points] -def store_force_constants(phono3py, - settings, - ph3py_yaml, - physical_units, - input_filename, - output_filename, - load_phono3py_yaml, - log_level): +def store_force_constants( + phono3py, + settings, + ph3py_yaml, + physical_units, + input_filename, + output_filename, + load_phono3py_yaml, + log_level, +): """Calculate, read, and write force constants.""" if load_phono3py_yaml: if log_level: print("-" * 29 + " Force constants " + "-" * 30) - (fc_calculator, - fc_calculator_options) = get_fc_calculator_params(settings) + (fc_calculator, fc_calculator_options) = get_fc_calculator_params(settings) read_fc = set_dataset_and_force_constants( phono3py, @@ -694,7 +728,8 @@ def store_force_constants(phono3py, fc_calculator_options=fc_calculator_options, symmetrize_fc=settings.fc_symmetry, is_compact_fc=settings.is_compact_fc, - log_level=log_level) + log_level=log_level, + ) if log_level: if phono3py.fc3 is None: @@ -705,19 +740,23 @@ def store_force_constants(phono3py, print_error() sys.exit(1) - if not read_fc['fc3']: - write_fc3_to_hdf5(phono3py.fc3, - p2s_map=phono3py.primitive.p2s_map, - compression=settings.hdf5_compression) + if not read_fc["fc3"]: + write_fc3_to_hdf5( + phono3py.fc3, + p2s_map=phono3py.primitive.p2s_map, + compression=settings.hdf5_compression, + ) if log_level: - print("fc3 was written into \"fc3.hdf5\".") - if not read_fc['fc2']: - write_fc2_to_hdf5(phono3py.fc2, - p2s_map=phono3py.primitive.p2s_map, - physical_unit='eV/angstrom^2', - compression=settings.hdf5_compression) + print('fc3 was written into "fc3.hdf5".') + if not read_fc["fc2"]: + write_fc2_to_hdf5( + phono3py.fc2, + p2s_map=phono3py.primitive.p2s_map, + physical_unit="eV/angstrom^2", + compression=settings.hdf5_compression, + ) if log_level: - print("fc2 was written into \"fc2.hdf5\".") + print('fc2 was written into "fc2.hdf5".') else: create_phono3py_force_constants( phono3py, @@ -725,14 +764,17 @@ def store_force_constants(phono3py, ph3py_yaml=ph3py_yaml, input_filename=input_filename, output_filename=output_filename, - log_level=log_level) + log_level=log_level, + ) def run_gruneisen_then_exit(phono3py, settings, output_filename, log_level): """Run mode Grueneisen parameter calculation from fc3.""" - if (settings.mesh_numbers is None and - settings.band_paths is None and - settings.qpoints is None): # noqa E129 + if ( + settings.mesh_numbers is None + and settings.band_paths is None + and settings.qpoints is None + ): # noqa E129 print("An option of --mesh, --band, or --qpoints has to be specified.") if log_level: print_error() @@ -770,18 +812,17 @@ def run_gruneisen_then_exit(phono3py, settings, output_filename, log_level): factor=VaspToTHz, symprec=phono3py.symmetry.tolerance, output_filename=output_filename, - log_level=log_level) + log_level=log_level, + ) if log_level: print_end() sys.exit(0) -def run_jdos_then_exit(phono3py, - settings, - updated_settings, - output_filename, - log_level): +def run_jdos_then_exit( + phono3py, settings, updated_settings, output_filename, log_level +): """Run joint-DOS calculation.""" joint_dos = Phono3pyJointDos( phono3py.phonon_supercell, @@ -790,22 +831,23 @@ def run_jdos_then_exit(phono3py, mesh=settings.mesh_numbers, nac_params=phono3py.nac_params, nac_q_direction=settings.nac_q_direction, - sigmas=updated_settings['sigmas'], - cutoff_frequency=updated_settings['cutoff_frequency'], - frequency_step=updated_settings['frequency_step'], - num_frequency_points=updated_settings['num_frequency_points'], - temperatures=updated_settings['temperature_points'], - frequency_factor_to_THz=updated_settings['frequency_factor_to_THz'], - frequency_scale_factor=updated_settings['frequency_scale_factor'], + sigmas=updated_settings["sigmas"], + cutoff_frequency=updated_settings["cutoff_frequency"], + frequency_step=updated_settings["frequency_step"], + num_frequency_points=updated_settings["num_frequency_points"], + temperatures=updated_settings["temperature_points"], + frequency_factor_to_THz=updated_settings["frequency_factor_to_THz"], + frequency_scale_factor=updated_settings["frequency_scale_factor"], is_mesh_symmetry=settings.is_mesh_symmetry, store_dense_gp_map=settings.store_dense_gp_map, symprec=phono3py.symmetry.tolerance, output_filename=output_filename, - log_level=log_level) + log_level=log_level, + ) if log_level > 0: dm = joint_dos.dynamical_matrix - if (dm.is_nac() and dm.nac_method == 'gonze'): + if dm.is_nac() and dm.nac_method == "gonze": dm.show_Gonze_nac_message() grid_points = settings_to_grid_points(settings, joint_dos.grid) @@ -820,7 +862,7 @@ def run_isotope_then_exit(phono3py, settings, updated_settings, log_level): """Run isotope scattering calculation.""" mass_variances = settings.mass_variances if settings.band_indices is not None: - band_indices = np.hstack(settings.band_indices).astype('intc') + band_indices = np.hstack(settings.band_indices).astype("intc") else: band_indices = None iso = Phono3pyIsotope( @@ -828,21 +870,23 @@ def run_isotope_then_exit(phono3py, settings, updated_settings, log_level): phono3py.phonon_primitive, mass_variances=mass_variances, band_indices=band_indices, - sigmas=updated_settings['sigmas'], - frequency_factor_to_THz=updated_settings['frequency_factor_to_THz'], + sigmas=updated_settings["sigmas"], + frequency_factor_to_THz=updated_settings["frequency_factor_to_THz"], store_dense_gp_map=settings.store_dense_gp_map, symprec=phono3py.symmetry.tolerance, cutoff_frequency=settings.cutoff_frequency, - lapack_zheev_uplo=settings.lapack_zheev_uplo) + lapack_zheev_uplo=settings.lapack_zheev_uplo, + ) iso.init_dynamical_matrix( phono3py.fc2, phono3py.phonon_supercell, phono3py.phonon_primitive, nac_params=phono3py.nac_params, - frequency_scale_factor=updated_settings['frequency_scale_factor']) + frequency_scale_factor=updated_settings["frequency_scale_factor"], + ) if log_level > 0: dm = iso.dynamical_matrix - if (dm.is_nac() and dm.nac_method == 'gonze'): + if dm.is_nac() and dm.nac_method == "gonze": dm.show_Gonze_nac_message() grid_points = settings_to_grid_points(settings, iso.grid) @@ -853,28 +897,23 @@ def run_isotope_then_exit(phono3py, settings, updated_settings, log_level): sys.exit(0) -def init_phph_interaction(phono3py, - settings, - updated_settings, - input_filename, - output_filename, - log_level): +def init_phph_interaction( + phono3py, settings, updated_settings, input_filename, output_filename, log_level +): """Initialize ph-ph interaction and phonons on grid.""" if log_level: sys.stdout.write("Generating grid system ... ") sys.stdout.flush() phono3py.mesh_numbers = settings.mesh_numbers bz_grid = phono3py.grid - identity = np.eye(3, dtype='int_') - not_grg = ((bz_grid.P == identity).all() and - (bz_grid.Q == identity).all()) + identity = np.eye(3, dtype="int_") + not_grg = (bz_grid.P == identity).all() and (bz_grid.Q == identity).all() if log_level: if not_grg: print("[ %d %d %d ]" % tuple(phono3py.mesh_numbers)) else: print("") - print("Generalized regular grid: [ %d %d %d ]" - % tuple(bz_grid.D_diag)) + print("Generalized regular grid: [ %d %d %d ]" % tuple(bz_grid.D_diag)) print("Grid generation matrix:") print(" [ %d %d %d ]" % tuple(bz_grid.grid_matrix[0])) print(" [ %d %d %d ]" % tuple(bz_grid.grid_matrix[1])) @@ -884,15 +923,16 @@ def init_phph_interaction(phono3py, phono3py.init_phph_interaction( nac_q_direction=settings.nac_q_direction, constant_averaged_interaction=ave_pp, - frequency_scale_factor=updated_settings['frequency_scale_factor'], + frequency_scale_factor=updated_settings["frequency_scale_factor"], symmetrize_fc3q=settings.is_symmetrize_fc3_q, - lapack_zheev_uplo=settings.lapack_zheev_uplo) + lapack_zheev_uplo=settings.lapack_zheev_uplo, + ) if not settings.read_phonon: if log_level: print("-" * 27 + " Phonon calculations " + "-" * 28) dm = phono3py.dynamical_matrix - if (dm.is_nac() and dm.nac_method == 'gonze'): + if dm.is_nac() and dm.nac_method == "gonze": dm.show_nac_message() print("Running harmonic phonon calculations...") sys.stdout.flush() @@ -906,10 +946,11 @@ def init_phph_interaction(phono3py, grid_address, phono3py.mesh_numbers, compression=settings.hdf5_compression, - filename=output_filename) + filename=output_filename, + ) if filename: if log_level: - print("Phonons are written into \"%s\"." % filename) + print('Phonons are written into "%s".' % filename) else: print("Writing phonons failed.") if log_level: @@ -917,9 +958,9 @@ def init_phph_interaction(phono3py, sys.exit(1) if settings.read_phonon: - phonons = read_phonon_from_hdf5(phono3py.mesh_numbers, - filename=input_filename, - verbose=(log_level > 0)) + phonons = read_phonon_from_hdf5( + phono3py.mesh_numbers, filename=input_filename, verbose=(log_level > 0) + ) if phonons is None: print("Reading phonons failed.") if log_level: @@ -936,9 +977,9 @@ def init_phph_interaction(phono3py, def main(**argparse_control): """Phono3py main part of command line interface.""" - import warnings + # import warnings # warnings.simplefilter('error') - load_phono3py_yaml = argparse_control.get('load_phono3py_yaml', False) + load_phono3py_yaml = argparse_control.get("load_phono3py_yaml", False) args, log_level = start_phono3py(**argparse_control) physical_units = get_default_physical_units(get_interface_mode(vars(args))) @@ -947,17 +988,18 @@ def main(**argparse_control): input_filename = None output_filename = None else: - (input_filename, - output_filename) = get_input_output_filenames_from_args(args) + (input_filename, output_filename) = get_input_output_filenames_from_args(args) settings, confs, cell_filename = read_phono3py_settings( - args, argparse_control, log_level) + args, argparse_control, log_level + ) if args.force_sets_to_forces_fc2_mode: create_FORCES_FC2_from_FORCE_SETS_then_exit(log_level) if args.force_sets_mode: create_FORCE_SETS_from_FORCES_FCx_then_exit( - settings.phonon_supercell_matrix, input_filename, log_level) + settings.phonon_supercell_matrix, input_filename, log_level + ) if args.write_grid_points: run_mode = "write_grid_info" elif args.show_num_triplets: @@ -973,7 +1015,8 @@ def main(**argparse_control): # Create FORCES_FC3 and FORCES_FC2 # #################################### create_FORCES_FC3_and_FORCES_FC2_then_exit( - settings, input_filename, output_filename, log_level) + settings, input_filename, output_filename, log_level + ) ########################################################### # Symmetry tolerance. Distance unit depends on interface. # @@ -984,8 +1027,8 @@ def main(**argparse_control): symprec = settings.symmetry_tolerance cell_info = get_cell_info(settings, cell_filename, symprec, log_level) - unitcell_filename = cell_info['optional_structure_info'][0] - interface_mode = cell_info['interface_mode'] + unitcell_filename = cell_info["optional_structure_info"][0] + interface_mode = cell_info["interface_mode"] # ph3py_yaml = cell_info['phonopy_yaml'] if run_mode is None: @@ -1001,13 +1044,16 @@ def main(**argparse_control): symprec, output_filename=output_filename, interface_mode=interface_mode, - log_level=log_level) + log_level=log_level, + ) - finalize_phono3py(phono3py, - confs, - log_level, - displacements_mode=True, - filename="phono3py_disp.yaml") + finalize_phono3py( + phono3py, + confs, + log_level, + displacements_mode=True, + filename="phono3py_disp.yaml", + ) ####################### # Initialize phono3py # @@ -1017,40 +1063,46 @@ def main(**argparse_control): # 'frequency_factor_to_THz', 'num_frequency_points', # 'frequency_step', 'frequency_scale_factor', # 'cutoff_frequency') - phono3py, updated_settings = init_phono3py(settings, - cell_info, - interface_mode, - symprec, - log_level) + phono3py, updated_settings = init_phono3py( + settings, cell_info, interface_mode, symprec, log_level + ) ################################################# # Show phono3py settings and crystal structures # ################################################# if log_level: - show_general_settings(settings, - run_mode, - phono3py, - unitcell_filename, - input_filename, - output_filename) + show_general_settings( + settings, + run_mode, + phono3py, + unitcell_filename, + input_filename, + output_filename, + ) if log_level > 1: show_phono3py_cells(phono3py, settings) else: - print("Spacegroup: %s" % - phono3py.symmetry.get_international_table()) - print("Use -v option to watch primitive cell, unit cell, " - "and supercell structures.") + print("Spacegroup: %s" % phono3py.symmetry.get_international_table()) + print( + "Use -v option to watch primitive cell, unit cell, " + "and supercell structures." + ) ################## # Check settings # ################## - run_modes_with_mesh = ("conductivity-RTA", "conductivity-LBTE", - "imag_self_energy", "real_self_energy", - "jdos", "isotope", - "write_grid_info", "show_triplets_info") - run_modes_with_gp = ("imag_self_energy", "real_self_energy", - "jdos", "isotope") + run_modes_with_mesh = ( + "conductivity-RTA", + "conductivity-LBTE", + "imag_self_energy", + "real_self_energy", + "jdos", + "isotope", + "write_grid_info", + "show_triplets_info", + ) + run_modes_with_gp = ("imag_self_energy", "real_self_energy", "jdos", "isotope") if settings.mesh_numbers is None and run_mode in run_modes_with_mesh: print("") print("Mesh numbers have to be specified.") @@ -1059,9 +1111,11 @@ def main(**argparse_control): print_error() sys.exit(1) - if (run_mode in run_modes_with_gp and - settings.grid_points is None and - settings.grid_addresses is None): # noqa E129 + if ( + run_mode in run_modes_with_gp + and settings.grid_points is None + and settings.grid_addresses is None + ): # noqa E129 print("") print("Grid point(s) has to be specified.") print("") @@ -1074,15 +1128,16 @@ def main(**argparse_control): ######################################################### if run_mode == "write_grid_info": phono3py.mesh_numbers = settings.mesh_numbers - write_grid_points(phono3py.primitive, - phono3py.grid, - band_indices=settings.band_indices, - sigmas=updated_settings['sigmas'], - temperatures=updated_settings['temperatures'], - is_kappa_star=settings.is_kappa_star, - is_lbte=(settings.write_collision or - settings.is_lbte), - compression=settings.hdf5_compression) + write_grid_points( + phono3py.primitive, + phono3py.grid, + band_indices=settings.band_indices, + sigmas=updated_settings["sigmas"], + temperatures=updated_settings["temperatures"], + is_kappa_star=settings.is_kappa_star, + is_lbte=(settings.write_collision or settings.is_lbte), + compression=settings.hdf5_compression, + ) if log_level: print_end() @@ -1094,11 +1149,13 @@ def main(**argparse_control): if run_mode == "show_triplets_info": phono3py.mesh_numbers = settings.mesh_numbers grid_points = settings_to_grid_points(settings, phono3py.grid) - show_num_triplets(phono3py.primitive, - phono3py.grid, - band_indices=settings.band_indices, - grid_points=grid_points, - is_kappa_star=settings.is_kappa_star) + show_num_triplets( + phono3py.primitive, + phono3py.grid, + band_indices=settings.band_indices, + grid_points=grid_points, + is_kappa_star=settings.is_kappa_star, + ) if log_level: print_end() @@ -1107,25 +1164,29 @@ def main(**argparse_control): ################################## # Non-analytical term correction # ################################## - store_nac_params(phono3py, - settings, - cell_info['phonopy_yaml'], - unitcell_filename, - log_level, - nac_factor=Hartree * Bohr, - load_phonopy_yaml=load_phono3py_yaml) + store_nac_params( + phono3py, + settings, + cell_info["phonopy_yaml"], + unitcell_filename, + log_level, + nac_factor=Hartree * Bohr, + load_phonopy_yaml=load_phono3py_yaml, + ) ################### # Force constants # ################### - store_force_constants(phono3py, - settings, - cell_info['phonopy_yaml'], - physical_units, - input_filename, - output_filename, - load_phono3py_yaml, - log_level) + store_force_constants( + phono3py, + settings, + cell_info["phonopy_yaml"], + physical_units, + input_filename, + output_filename, + load_phono3py_yaml, + log_level, + ) ############################################ # Phonon Gruneisen parameter and then exit # @@ -1143,17 +1204,16 @@ def main(**argparse_control): # Joint DOS and then exit # ########################### if run_mode == "jdos": - run_jdos_then_exit(phono3py, - settings, - updated_settings, - output_filename, - log_level) + run_jdos_then_exit( + phono3py, settings, updated_settings, output_filename, log_level + ) ################################################ # Mass variances for phonon-isotope scattering # ################################################ if settings.is_isotope and settings.mass_variances is None: from phonopy.structure.atoms import isotope_data + symbols = phono3py.phonon_primitive.symbols in_database = True for s in set(symbols): @@ -1177,12 +1237,14 @@ def main(**argparse_control): # Initialize phonon-phonon interaction # ######################################## if run_mode is not None: - init_phph_interaction(phono3py, - settings, - updated_settings, - input_filename, - output_filename, - log_level) + init_phph_interaction( + phono3py, + settings, + updated_settings, + input_filename, + output_filename, + log_level, + ) ####################################################### # Run imaginary part of self energy of bubble diagram # @@ -1190,13 +1252,14 @@ def main(**argparse_control): if run_mode == "imag_self_energy": phono3py.run_imag_self_energy( settings_to_grid_points(settings, phono3py.grid), - updated_settings['temperature_points'], - frequency_step=updated_settings['frequency_step'], - num_frequency_points=updated_settings['num_frequency_points'], + updated_settings["temperature_points"], + frequency_step=updated_settings["frequency_step"], + num_frequency_points=updated_settings["num_frequency_points"], scattering_event_class=settings.scattering_event_class, write_txt=True, write_gamma_detail=settings.write_gamma_detail, - output_filename=output_filename) + output_filename=output_filename, + ) ##################################################### # Run frequency shift calculation of bubble diagram # @@ -1204,12 +1267,13 @@ def main(**argparse_control): elif run_mode == "real_self_energy": phono3py.run_real_self_energy( settings_to_grid_points(settings, phono3py.grid), - updated_settings['temperature_points'], - frequency_step=updated_settings['frequency_step'], - num_frequency_points=updated_settings['num_frequency_points'], + updated_settings["temperature_points"], + frequency_step=updated_settings["frequency_step"], + num_frequency_points=updated_settings["num_frequency_points"], write_txt=True, write_hdf5=True, - output_filename=output_filename) + output_filename=output_filename, + ) ####################################################### # Run spectral function calculation of bubble diagram # @@ -1217,13 +1281,14 @@ def main(**argparse_control): elif run_mode == "spectral_function": phono3py.run_spectral_function( settings_to_grid_points(settings, phono3py.grid), - updated_settings['temperature_points'], - frequency_step=updated_settings['frequency_step'], - num_frequency_points=updated_settings['num_frequency_points'], - num_points_in_batch=updated_settings['num_points_in_batch'], + updated_settings["temperature_points"], + frequency_step=updated_settings["frequency_step"], + num_frequency_points=updated_settings["num_frequency_points"], + num_points_in_batch=updated_settings["num_points_in_batch"], write_txt=True, write_hdf5=True, - output_filename=output_filename) + output_filename=output_filename, + ) #################################### # Run lattice thermal conductivity # @@ -1232,14 +1297,13 @@ def main(**argparse_control): grid_points = settings_to_grid_points(settings, phono3py.grid) phono3py.run_thermal_conductivity( is_LBTE=settings.is_lbte, - temperatures=updated_settings['temperatures'], + temperatures=updated_settings["temperatures"], is_isotope=settings.is_isotope, mass_variances=settings.mass_variances, grid_points=grid_points, boundary_mfp=settings.boundary_mfp, solve_collective_phonon=settings.solve_collective_phonon, use_ave_pp=settings.use_ave_pp, - gamma_unit_conversion=settings.gamma_conversion_factor, is_reducible_collision_matrix=settings.is_reducible_collision_matrix, # noqa E501 is_kappa_star=settings.is_kappa_star, gv_delta_q=settings.group_velocity_delta_q, @@ -1258,11 +1322,14 @@ def main(**argparse_control): write_LBTE_solution=settings.write_LBTE_solution, compression=settings.hdf5_compression, input_filename=input_filename, - output_filename=output_filename) + output_filename=output_filename, + ) else: if log_level: - print("-" * 11 + - " None of ph-ph interaction calculation was performed. " + - "-" * 11) + print( + "-" * 11 + + " None of ph-ph interaction calculation was performed. " + + "-" * 11 + ) finalize_phono3py(phono3py, confs, log_level) diff --git a/phono3py/cui/settings.py b/phono3py/cui/settings.py index c502e73a..3bd1af75 100644 --- a/phono3py/cui/settings.py +++ b/phono3py/cui/settings.py @@ -42,61 +42,60 @@ class Phono3pySettings(Settings): _default = { # In micrometre. The default value is just set to avoid divergence. - 'boundary_mfp': 1.0e6, - 'constant_averaged_pp_interaction': None, - 'create_forces_fc2': None, - 'create_forces_fc3': None, - 'create_forces_fc3_file': None, - 'cutoff_fc3_distance': None, - 'cutoff_pair_distance': None, - 'gamma_conversion_factor': None, - 'grid_addresses': None, - 'grid_points': None, - 'ion_clamped': False, - 'is_bterta': False, - 'is_compact_fc': False, - 'is_full_pp': False, - 'is_gruneisen': False, - 'is_imag_self_energy': False, - 'is_isotope': False, - 'is_joint_dos': False, - 'is_kappa_star': True, - 'is_lbte': False, - 'is_N_U': False, - 'is_real_self_energy': False, - 'is_reducible_collision_matrix': False, - 'is_spectral_function': False, - 'is_symmetrize_fc2': False, - 'is_symmetrize_fc3_q': False, - 'is_symmetrize_fc3_r': False, - 'is_tetrahedron_method': False, - 'lapack_zheev_uplo': 'L', - 'mass_variances': None, - 'max_freepath': None, - 'num_points_in_batch': None, - 'read_collision': None, - 'read_fc2': False, - 'read_fc3': False, - 'read_gamma': False, - 'read_phonon': False, - 'read_pp': False, - 'phonon_supercell_matrix': None, - 'pinv_cutoff': 1.0e-8, - 'pinv_solver': 0, - 'pp_conversion_factor': None, - 'scattering_event_class': None, # scattering event class 1 or 2 - 'sigma_cutoff_width': None, - 'solve_collective_phonon': False, - 'emulate_v1': False, - 'subtract_forces': None, - 'use_ave_pp': False, - 'use_grg': False, - 'write_collision': False, - 'write_gamma_detail': False, - 'write_gamma': False, - 'write_phonon': False, - 'write_pp': False, - 'write_LBTE_solution': False + "boundary_mfp": 1.0e6, + "constant_averaged_pp_interaction": None, + "create_forces_fc2": None, + "create_forces_fc3": None, + "create_forces_fc3_file": None, + "cutoff_fc3_distance": None, + "cutoff_pair_distance": None, + "grid_addresses": None, + "grid_points": None, + "ion_clamped": False, + "is_bterta": False, + "is_compact_fc": False, + "is_full_pp": False, + "is_gruneisen": False, + "is_imag_self_energy": False, + "is_isotope": False, + "is_joint_dos": False, + "is_kappa_star": True, + "is_lbte": False, + "is_N_U": False, + "is_real_self_energy": False, + "is_reducible_collision_matrix": False, + "is_spectral_function": False, + "is_symmetrize_fc2": False, + "is_symmetrize_fc3_q": False, + "is_symmetrize_fc3_r": False, + "is_tetrahedron_method": False, + "lapack_zheev_uplo": "L", + "mass_variances": None, + "max_freepath": None, + "num_points_in_batch": None, + "read_collision": None, + "read_fc2": False, + "read_fc3": False, + "read_gamma": False, + "read_phonon": False, + "read_pp": False, + "phonon_supercell_matrix": None, + "pinv_cutoff": 1.0e-8, + "pinv_solver": 0, + "pp_conversion_factor": None, + "scattering_event_class": None, # scattering event class 1 or 2 + "sigma_cutoff_width": None, + "solve_collective_phonon": False, + "emulate_v1": False, + "subtract_forces": None, + "use_ave_pp": False, + "use_grg": False, + "write_collision": False, + "write_gamma_detail": False, + "write_gamma": False, + "write_phonon": False, + "write_pp": False, + "write_LBTE_solution": False, } def __init__(self, default=None): @@ -112,219 +111,215 @@ class Phono3pySettings(Settings): def set_boundary_mfp(self, val): """Set boundary_mfp.""" - self._v['boundary_mfp'] = val + self._v["boundary_mfp"] = val def set_constant_averaged_pp_interaction(self, val): """Set constant_averaged_pp_interaction.""" - self._v['constant_averaged_pp_interaction'] = val + self._v["constant_averaged_pp_interaction"] = val def set_create_forces_fc2(self, val): """Set create_forces_fc2.""" - self._v['create_forces_fc2'] = val + self._v["create_forces_fc2"] = val def set_create_forces_fc3(self, val): """Set create_forces_fc3.""" - self._v['create_forces_fc3'] = val + self._v["create_forces_fc3"] = val def set_create_forces_fc3_file(self, val): """Set create_forces_fc3_file.""" - self._v['create_forces_fc3_file'] = val + self._v["create_forces_fc3_file"] = val def set_cutoff_fc3_distance(self, val): """Set cutoff_fc3_distance.""" - self._v['cutoff_fc3_distance'] = val + self._v["cutoff_fc3_distance"] = val def set_cutoff_pair_distance(self, val): """Set cutoff_pair_distance.""" - self._v['cutoff_pair_distance'] = val + self._v["cutoff_pair_distance"] = val def set_emulate_v1(self, val): """Set emulate_v1.""" - self._v['emulate_v1'] = val - - def set_gamma_conversion_factor(self, val): - """Set gamma_conversion_factor.""" - self._v['gamma_conversion_factor'] = val + self._v["emulate_v1"] = val def set_grid_addresses(self, val): """Set grid_addresses.""" - self._v['grid_addresses'] = val + self._v["grid_addresses"] = val def set_grid_points(self, val): """Set grid_points.""" - self._v['grid_points'] = val + self._v["grid_points"] = val def set_ion_clamped(self, val): """Set ion_clamped.""" - self._v['ion_clamped'] = val + self._v["ion_clamped"] = val def set_is_bterta(self, val): """Set is_bterta.""" - self._v['is_bterta'] = val + self._v["is_bterta"] = val def set_is_compact_fc(self, val): """Set is_compact_fc.""" - self._v['is_compact_fc'] = val + self._v["is_compact_fc"] = val def set_is_full_pp(self, val): """Set is_full_pp.""" - self._v['is_full_pp'] = val + self._v["is_full_pp"] = val def set_is_gruneisen(self, val): """Set is_gruneisen.""" - self._v['is_gruneisen'] = val + self._v["is_gruneisen"] = val def set_is_imag_self_energy(self, val): """Set is_imag_self_energy.""" - self._v['is_imag_self_energy'] = val + self._v["is_imag_self_energy"] = val def set_is_isotope(self, val): """Set is_isotope.""" - self._v['is_isotope'] = val + self._v["is_isotope"] = val def set_is_joint_dos(self, val): """Set is_joint_dos.""" - self._v['is_joint_dos'] = val + self._v["is_joint_dos"] = val def set_is_kappa_star(self, val): """Set is_kappa_star.""" - self._v['is_kappa_star'] = val + self._v["is_kappa_star"] = val def set_is_lbte(self, val): """Set is_lbte.""" - self._v['is_lbte'] = val + self._v["is_lbte"] = val def set_is_N_U(self, val): """Set is_N_U.""" - self._v['is_N_U'] = val + self._v["is_N_U"] = val def set_is_real_self_energy(self, val): """Set is_real_self_energy.""" - self._v['is_real_self_energy'] = val + self._v["is_real_self_energy"] = val def set_is_reducible_collision_matrix(self, val): """Set is_reducible_collision_matrix.""" - self._v['is_reducible_collision_matrix'] = val + self._v["is_reducible_collision_matrix"] = val def set_is_spectral_function(self, val): """Set is_spectral_function.""" - self._v['is_spectral_function'] = val + self._v["is_spectral_function"] = val def set_is_symmetrize_fc2(self, val): """Set is_symmetrize_fc2.""" - self._v['is_symmetrize_fc2'] = val + self._v["is_symmetrize_fc2"] = val def set_is_symmetrize_fc3_q(self, val): """Set is_symmetrize_fc3_q.""" - self._v['is_symmetrize_fc3_q'] = val + self._v["is_symmetrize_fc3_q"] = val def set_is_symmetrize_fc3_r(self, val): """Set is_symmetrize_fc3_r.""" - self._v['is_symmetrize_fc3_r'] = val + self._v["is_symmetrize_fc3_r"] = val def set_lapack_zheev_uplo(self, val): """Set lapack_zheev_uplo.""" - self._v['lapack_zheev_uplo'] = val + self._v["lapack_zheev_uplo"] = val def set_mass_variances(self, val): """Set mass_variances.""" - self._v['mass_variances'] = val + self._v["mass_variances"] = val def set_max_freepath(self, val): """Set max_freepath.""" - self._v['max_freepath'] = val + self._v["max_freepath"] = val def set_num_points_in_batch(self, val): """Set num_points_in_batch.""" - self._v['num_points_in_batch'] = val + self._v["num_points_in_batch"] = val def set_phonon_supercell_matrix(self, val): """Set phonon_supercell_matrix.""" - self._v['phonon_supercell_matrix'] = val + self._v["phonon_supercell_matrix"] = val def set_pinv_cutoff(self, val): """Set pinv_cutoff.""" - self._v['pinv_cutoff'] = val + self._v["pinv_cutoff"] = val def set_pinv_solver(self, val): """Set pinv_solver.""" - self._v['pinv_solver'] = val + self._v["pinv_solver"] = val def set_pp_conversion_factor(self, val): """Set pp_conversion_factor.""" - self._v['pp_conversion_factor'] = val + self._v["pp_conversion_factor"] = val def set_read_collision(self, val): """Set read_collision.""" - self._v['read_collision'] = val + self._v["read_collision"] = val def set_read_fc2(self, val): """Set read_fc2.""" - self._v['read_fc2'] = val + self._v["read_fc2"] = val def set_read_fc3(self, val): """Set read_fc3.""" - self._v['read_fc3'] = val + self._v["read_fc3"] = val def set_read_gamma(self, val): """Set read_gamma.""" - self._v['read_gamma'] = val + self._v["read_gamma"] = val def set_read_phonon(self, val): """Set read_phonon.""" - self._v['read_phonon'] = val + self._v["read_phonon"] = val def set_read_pp(self, val): """Set read_pp.""" - self._v['read_pp'] = val + self._v["read_pp"] = val def set_scattering_event_class(self, val): """Set scattering_event_class.""" - self._v['scattering_event_class'] = val + self._v["scattering_event_class"] = val def set_sigma_cutoff_width(self, val): """Set sigma_cutoff_width.""" - self._v['sigma_cutoff_width'] = val + self._v["sigma_cutoff_width"] = val def set_solve_collective_phonon(self, val): """Set solve_collective_phonon.""" - self._v['solve_collective_phonon'] = val + self._v["solve_collective_phonon"] = val def set_subtract_forces(self, val): """Set subtract_forces.""" - self._v['subtract_forces'] = val + self._v["subtract_forces"] = val def set_use_ave_pp(self, val): """Set use_ave_pp.""" - self._v['use_ave_pp'] = val + self._v["use_ave_pp"] = val def set_use_grg(self, val): """Set use_grg.""" - self._v['use_grg'] = val + self._v["use_grg"] = val def set_write_collision(self, val): """Set write_collision.""" - self._v['write_collision'] = val + self._v["write_collision"] = val def set_write_gamma_detail(self, val): """Set write_gamma_detail.""" - self._v['write_gamma_detail'] = val + self._v["write_gamma_detail"] = val def set_write_gamma(self, val): """Set write_gamma.""" - self._v['write_gamma'] = val + self._v["write_gamma"] = val def set_write_phonon(self, val): """Set write_phonon.""" - self._v['write_phonon'] = val + self._v["write_phonon"] = val def set_write_pp(self, val): """Set write_pp.""" - self._v['write_pp'] = val + self._v["write_pp"] = val def set_write_LBTE_solution(self, val): """Set write_LBTE_solution.""" - self._v['write_LBTE_solution'] = val + self._v["write_LBTE_solution"] = val class Phono3pyConfParser(ConfParser): @@ -350,237 +345,232 @@ class Phono3pyConfParser(ConfParser): def _read_options(self): ConfParser.read_options(self) # store data in self._confs - if 'phonon_supercell_dimension' in self._args: + if "phonon_supercell_dimension" in self._args: dim_fc2 = self._args.phonon_supercell_dimension if dim_fc2 is not None: - self._confs['dim_fc2'] = " ".join(dim_fc2) + self._confs["dim_fc2"] = " ".join(dim_fc2) - if 'boundary_mfp' in self._args: + if "boundary_mfp" in self._args: if self._args.boundary_mfp is not None: - self._confs['boundary_mfp'] = self._args.boundary_mfp + self._confs["boundary_mfp"] = self._args.boundary_mfp - if 'const_ave_pp' in self._args: + if "const_ave_pp" in self._args: const_ave_pp = self._args.const_ave_pp if const_ave_pp is not None: - self._confs['const_ave_pp'] = const_ave_pp + self._confs["const_ave_pp"] = const_ave_pp - if 'create_forces_fc2' in self._args: + if "create_forces_fc2" in self._args: if self._args.create_forces_fc2: - self._confs['create_forces_fc2'] = self._args.create_forces_fc2 + self._confs["create_forces_fc2"] = self._args.create_forces_fc2 - if 'create_forces_fc3' in self._args: + if "create_forces_fc3" in self._args: if self._args.create_forces_fc3: - self._confs['create_forces_fc3'] = self._args.create_forces_fc3 + self._confs["create_forces_fc3"] = self._args.create_forces_fc3 - if 'create_forces_fc3_file' in self._args: + if "create_forces_fc3_file" in self._args: if self._args.create_forces_fc3_file: cfc3_file = self._args.create_forces_fc3_file - self._confs['create_forces_fc3_file'] = cfc3_file + self._confs["create_forces_fc3_file"] = cfc3_file - if 'cutoff_fc3_distance' in self._args: + if "cutoff_fc3_distance" in self._args: cutoff_fc3 = self._args.cutoff_fc3_distance if cutoff_fc3 is not None: - self._confs['cutoff_fc3_distance'] = cutoff_fc3 + self._confs["cutoff_fc3_distance"] = cutoff_fc3 - if 'cutoff_pair_distance' in self._args: + if "cutoff_pair_distance" in self._args: cutoff_pair = self._args.cutoff_pair_distance if cutoff_pair is not None: - self._confs['cutoff_pair_distance'] = cutoff_pair + self._confs["cutoff_pair_distance"] = cutoff_pair - if 'gamma_conversion_factor' in self._args: - g_conv_factor = self._args.gamma_conversion_factor - if g_conv_factor is not None: - self._confs['gamma_conversion_factor'] = g_conv_factor - - if 'grid_addresses' in self._args: + if "grid_addresses" in self._args: grid_adrs = self._args.grid_addresses if grid_adrs is not None: - self._confs['grid_addresses'] = " ".join(grid_adrs) + self._confs["grid_addresses"] = " ".join(grid_adrs) - if 'grid_points' in self._args: + if "grid_points" in self._args: if self._args.grid_points is not None: - self._confs['grid_points'] = " ".join(self._args.grid_points) + self._confs["grid_points"] = " ".join(self._args.grid_points) - if 'ion_clamped' in self._args: + if "ion_clamped" in self._args: if self._args.ion_clamped: - self._confs['ion_clamped'] = '.true.' + self._confs["ion_clamped"] = ".true." - if 'is_bterta' in self._args: + if "is_bterta" in self._args: if self._args.is_bterta: - self._confs['bterta'] = '.true.' + self._confs["bterta"] = ".true." - if 'is_compact_fc' in self._args: + if "is_compact_fc" in self._args: if self._args.is_compact_fc: - self._confs['compact_fc'] = '.true.' + self._confs["compact_fc"] = ".true." - if 'emulate_v1' in self._args: + if "emulate_v1" in self._args: if self._args.emulate_v1: - self._confs['emulate_v1'] = '.true.' + self._confs["emulate_v1"] = ".true." - if 'is_gruneisen' in self._args: + if "is_gruneisen" in self._args: if self._args.is_gruneisen: - self._confs['gruneisen'] = '.true.' + self._confs["gruneisen"] = ".true." - if 'is_full_pp' in self._args: + if "is_full_pp" in self._args: if self._args.is_full_pp: - self._confs['full_pp'] = '.true.' + self._confs["full_pp"] = ".true." - if 'is_imag_self_energy' in self._args: + if "is_imag_self_energy" in self._args: if self._args.is_imag_self_energy: - self._confs['imag_self_energy'] = '.true.' + self._confs["imag_self_energy"] = ".true." - if 'is_isotope' in self._args: + if "is_isotope" in self._args: if self._args.is_isotope: - self._confs['isotope'] = '.true.' + self._confs["isotope"] = ".true." - if 'is_joint_dos' in self._args: + if "is_joint_dos" in self._args: if self._args.is_joint_dos: - self._confs['joint_dos'] = '.true.' + self._confs["joint_dos"] = ".true." - if 'no_kappa_stars' in self._args: + if "no_kappa_stars" in self._args: if self._args.no_kappa_stars: - self._confs['kappa_star'] = '.false.' + self._confs["kappa_star"] = ".false." - if 'is_lbte' in self._args: + if "is_lbte" in self._args: if self._args.is_lbte: - self._confs['lbte'] = '.true.' + self._confs["lbte"] = ".true." - if 'is_N_U' in self._args: + if "is_N_U" in self._args: if self._args.is_N_U: - self._confs['N_U'] = '.true.' + self._confs["N_U"] = ".true." - if 'is_real_self_energy' in self._args: + if "is_real_self_energy" in self._args: if self._args.is_real_self_energy: - self._confs['real_self_energy'] = '.true.' + self._confs["real_self_energy"] = ".true." - if 'is_reducible_collision_matrix' in self._args: + if "is_reducible_collision_matrix" in self._args: if self._args.is_reducible_collision_matrix: - self._confs['reducible_collision_matrix'] = '.true.' + self._confs["reducible_collision_matrix"] = ".true." - if 'is_spectral_function' in self._args: + if "is_spectral_function" in self._args: if self._args.is_spectral_function: - self._confs['spectral_function'] = '.true.' + self._confs["spectral_function"] = ".true." - if 'is_symmetrize_fc2' in self._args: + if "is_symmetrize_fc2" in self._args: if self._args.is_symmetrize_fc2: - self._confs['symmetrize_fc2'] = '.true.' + self._confs["symmetrize_fc2"] = ".true." - if 'is_symmetrize_fc3_q' in self._args: + if "is_symmetrize_fc3_q" in self._args: if self._args.is_symmetrize_fc3_q: - self._confs['symmetrize_fc3_q'] = '.true.' + self._confs["symmetrize_fc3_q"] = ".true." - if 'is_symmetrize_fc3_r' in self._args: + if "is_symmetrize_fc3_r" in self._args: if self._args.is_symmetrize_fc3_r: - self._confs['symmetrize_fc3_r'] = '.true.' + self._confs["symmetrize_fc3_r"] = ".true." - if 'is_tetrahedron_method' in self._args: + if "is_tetrahedron_method" in self._args: if self._args.is_tetrahedron_method: - self._confs['tetrahedron'] = '.true.' + self._confs["tetrahedron"] = ".true." - if 'lapack_zheev_uplo' in self._args: + if "lapack_zheev_uplo" in self._args: if self._args.lapack_zheev_uplo is not None: - self._confs['lapack_zheev_uplo'] = self._args.lapack_zheev_uplo + self._confs["lapack_zheev_uplo"] = self._args.lapack_zheev_uplo - if 'mass_variances' in self._args: + if "mass_variances" in self._args: mass_variances = self._args.mass_variances if mass_variances is not None: - self._confs['mass_variances'] = " ".join(mass_variances) + self._confs["mass_variances"] = " ".join(mass_variances) - if 'max_freepath' in self._args: + if "max_freepath" in self._args: if self._args.max_freepath is not None: - self._confs['max_freepath'] = self._args.max_freepath + self._confs["max_freepath"] = self._args.max_freepath - if 'num_points_in_batch' in self._args: + if "num_points_in_batch" in self._args: num_points_in_batch = self._args.num_points_in_batch if num_points_in_batch is not None: - self._confs['num_points_in_batch'] = num_points_in_batch + self._confs["num_points_in_batch"] = num_points_in_batch - if 'pinv_cutoff' in self._args: + if "pinv_cutoff" in self._args: if self._args.pinv_cutoff is not None: - self._confs['pinv_cutoff'] = self._args.pinv_cutoff + self._confs["pinv_cutoff"] = self._args.pinv_cutoff - if 'pinv_solver' in self._args: + if "pinv_solver" in self._args: if self._args.pinv_solver is not None: - self._confs['pinv_solver'] = self._args.pinv_solver + self._confs["pinv_solver"] = self._args.pinv_solver - if 'pp_conversion_factor' in self._args: + if "pp_conversion_factor" in self._args: pp_conv_factor = self._args.pp_conversion_factor if pp_conv_factor is not None: - self._confs['pp_conversion_factor'] = pp_conv_factor + self._confs["pp_conversion_factor"] = pp_conv_factor - if 'read_fc2' in self._args: + if "read_fc2" in self._args: if self._args.read_fc2: - self._confs['read_fc2'] = '.true.' + self._confs["read_fc2"] = ".true." - if 'read_fc3' in self._args: + if "read_fc3" in self._args: if self._args.read_fc3: - self._confs['read_fc3'] = '.true.' + self._confs["read_fc3"] = ".true." - if 'read_gamma' in self._args: + if "read_gamma" in self._args: if self._args.read_gamma: - self._confs['read_gamma'] = '.true.' + self._confs["read_gamma"] = ".true." - if 'read_phonon' in self._args: + if "read_phonon" in self._args: if self._args.read_phonon: - self._confs['read_phonon'] = '.true.' + self._confs["read_phonon"] = ".true." - if 'read_pp' in self._args: + if "read_pp" in self._args: if self._args.read_pp: - self._confs['read_pp'] = '.true.' + self._confs["read_pp"] = ".true." - if 'read_collision' in self._args: + if "read_collision" in self._args: if self._args.read_collision is not None: - self._confs['read_collision'] = self._args.read_collision + self._confs["read_collision"] = self._args.read_collision - if 'scattering_event_class' in self._args: + if "scattering_event_class" in self._args: scatt_class = self._args.scattering_event_class if scatt_class is not None: - self._confs['scattering_event_class'] = scatt_class + self._confs["scattering_event_class"] = scatt_class - if 'sigma_cutoff_width' in self._args: + if "sigma_cutoff_width" in self._args: sigma_cutoff = self._args.sigma_cutoff_width if sigma_cutoff is not None: - self._confs['sigma_cutoff_width'] = sigma_cutoff + self._confs["sigma_cutoff_width"] = sigma_cutoff - if 'solve_collective_phonon' in self._args: + if "solve_collective_phonon" in self._args: if self._args.solve_collective_phonon: - self._confs['collective_phonon'] = '.true.' + self._confs["collective_phonon"] = ".true." - if 'subtract_forces' in self._args: + if "subtract_forces" in self._args: if self._args.subtract_forces: - self._confs['subtract_forces'] = self._args.subtract_forces + self._confs["subtract_forces"] = self._args.subtract_forces - if 'use_ave_pp' in self._args: + if "use_ave_pp" in self._args: if self._args.use_ave_pp: - self._confs['use_ave_pp'] = '.true.' + self._confs["use_ave_pp"] = ".true." - if 'use_grg' in self._args: + if "use_grg" in self._args: if self._args.use_grg: - self._confs['use_grg'] = '.true.' + self._confs["use_grg"] = ".true." - if 'write_gamma_detail' in self._args: + if "write_gamma_detail" in self._args: if self._args.write_gamma_detail: - self._confs['write_gamma_detail'] = '.true.' + self._confs["write_gamma_detail"] = ".true." - if 'write_gamma' in self._args: + if "write_gamma" in self._args: if self._args.write_gamma: - self._confs['write_gamma'] = '.true.' + self._confs["write_gamma"] = ".true." - if 'write_collision' in self._args: + if "write_collision" in self._args: if self._args.write_collision: - self._confs['write_collision'] = '.true.' + self._confs["write_collision"] = ".true." - if 'write_phonon' in self._args: + if "write_phonon" in self._args: if self._args.write_phonon: - self._confs['write_phonon'] = '.true.' + self._confs["write_phonon"] = ".true." - if 'write_pp' in self._args: + if "write_pp" in self._args: if self._args.write_pp: - self._confs['write_pp'] = '.true.' + self._confs["write_pp"] = ".true." - if 'write_LBTE_solution' in self._args: + if "write_LBTE_solution" in self._args: if self._args.write_LBTE_solution: - self._confs['write_LBTE_solution'] = '.true.' + self._confs["write_LBTE_solution"] = ".true." def _parse_conf(self): ConfParser.parse_conf(self) @@ -589,338 +579,348 @@ class Phono3pyConfParser(ConfParser): for conf_key in confs.keys(): # Boolean if conf_key in ( - 'read_fc2', 'read_fc3', 'read_gamma', 'read_phonon', - 'read_pp', 'use_ave_pp', 'use_grg', 'collective_phonon', - 'write_gamma_detail', 'write_gamma', - 'write_collision', 'write_phonon', 'write_pp', - 'write_LBTE_solution', 'full_pp', 'ion_clamped', - 'bterta', 'compact_fc', 'emulate_v1', 'real_self_energy', - 'gruneisen', 'imag_self_energy', 'isotope', - 'joint_dos', 'lbte', 'N_U', 'spectral_function', - 'reducible_collision_matrix', 'symmetrize_fc2', - 'symmetrize_fc3_q', 'symmetrize_fc3_r', 'kappa_star'): - if confs[conf_key].lower() == '.true.': + "read_fc2", + "read_fc3", + "read_gamma", + "read_phonon", + "read_pp", + "use_ave_pp", + "use_grg", + "collective_phonon", + "write_gamma_detail", + "write_gamma", + "write_collision", + "write_phonon", + "write_pp", + "write_LBTE_solution", + "full_pp", + "ion_clamped", + "bterta", + "compact_fc", + "emulate_v1", + "real_self_energy", + "gruneisen", + "imag_self_energy", + "isotope", + "joint_dos", + "lbte", + "N_U", + "spectral_function", + "reducible_collision_matrix", + "symmetrize_fc2", + "symmetrize_fc3_q", + "symmetrize_fc3_r", + "kappa_star", + ): + if confs[conf_key].lower() == ".true.": self.set_parameter(conf_key, True) - elif confs[conf_key].lower() == '.false.': + elif confs[conf_key].lower() == ".false.": self.set_parameter(conf_key, False) # float if conf_key in ( - 'boundary_mfp', 'cutoff_fc3_distance', - 'cutoff_pair_distance', 'gamma_conversion_factor', - 'max_freepath', 'pinv_cutoff', 'pp_conversion_factor', - 'sigma_cutoff_width'): + "boundary_mfp", + "cutoff_fc3_distance", + "cutoff_pair_distance", + "max_freepath", + "pinv_cutoff", + "pp_conversion_factor", + "sigma_cutoff_width", + ): self.set_parameter(conf_key, float(confs[conf_key])) # int - if conf_key in ('pinv_solver', 'num_points_in_batch'): + if conf_key in ("pinv_solver", "num_points_in_batch"): self.set_parameter(conf_key, int(confs[conf_key])) # specials - if conf_key in ('create_forces_fc2', 'create_forces_fc3'): + if conf_key in ("create_forces_fc2", "create_forces_fc3"): if type(confs[conf_key]) is str: fnames = confs[conf_key].split() else: fnames = confs[conf_key] self.set_parameter(conf_key, fnames) - if conf_key == 'create_forces_fc3_file': + if conf_key == "create_forces_fc3_file": self.set_parameter( - 'create_forces_fc3_file', confs['create_forces_fc3_file']) + "create_forces_fc3_file", confs["create_forces_fc3_file"] + ) - if conf_key == 'dim_fc2': - matrix = [int(x) for x in confs['dim_fc2'].split()] + if conf_key == "dim_fc2": + matrix = [int(x) for x in confs["dim_fc2"].split()] if len(matrix) == 9: matrix = np.array(matrix).reshape(3, 3) elif len(matrix) == 3: matrix = np.diag(matrix) else: - self.setting_error( - "Number of elements of dim2 has to be 3 or 9.") + self.setting_error("Number of elements of dim2 has to be 3 or 9.") if matrix.shape == (3, 3): if np.linalg.det(matrix) < 1: self.setting_error( - "Determinant of supercell matrix has " + - "to be positive.") + "Determinant of supercell matrix has " + "to be positive." + ) else: - self.set_parameter('dim_fc2', matrix) + self.set_parameter("dim_fc2", matrix) - if conf_key in ('constant_averaged_pp_interaction' - 'const_ave_pp'): - self.set_parameter('const_ave_pp', - float(confs['const_ave_pp'])) + if conf_key in ("constant_averaged_pp_interaction" "const_ave_pp"): + self.set_parameter("const_ave_pp", float(confs["const_ave_pp"])) - if conf_key == 'grid_addresses': - vals = [int(x) for x in - confs['grid_addresses'].replace(',', ' ').split()] + if conf_key == "grid_addresses": + vals = [ + int(x) for x in confs["grid_addresses"].replace(",", " ").split() + ] if len(vals) % 3 == 0 and len(vals) > 0: - self.set_parameter('grid_addresses', - np.reshape(vals, (-1, 3))) + self.set_parameter("grid_addresses", np.reshape(vals, (-1, 3))) else: self.setting_error("Grid addresses are incorrectly set.") - if conf_key == 'grid_points': - vals = [int(x) for x in - confs['grid_points'].replace(',', ' ').split()] - self.set_parameter('grid_points', vals) + if conf_key == "grid_points": + vals = [int(x) for x in confs["grid_points"].replace(",", " ").split()] + self.set_parameter("grid_points", vals) - if conf_key == 'lapack_zheev_uplo': - self.set_parameter('lapack_zheev_uplo', - confs['lapack_zheev_uplo'].upper()) + if conf_key == "lapack_zheev_uplo": + self.set_parameter( + "lapack_zheev_uplo", confs["lapack_zheev_uplo"].upper() + ) - if conf_key == 'mass_variances': - vals = [fracval(x) for x in confs['mass_variances'].split()] + if conf_key == "mass_variances": + vals = [fracval(x) for x in confs["mass_variances"].split()] if len(vals) < 1: - self.setting_error( - "Mass variance parameters are incorrectly set.") + self.setting_error("Mass variance parameters are incorrectly set.") else: - self.set_parameter('mass_variances', vals) + self.set_parameter("mass_variances", vals) - if conf_key == 'read_collision': - if confs['read_collision'] == 'all': - self.set_parameter('read_collision', 'all') + if conf_key == "read_collision": + if confs["read_collision"] == "all": + self.set_parameter("read_collision", "all") else: - vals = [int(x) for x in confs['read_collision'].split()] - self.set_parameter('read_collision', vals) + vals = [int(x) for x in confs["read_collision"].split()] + self.set_parameter("read_collision", vals) - if conf_key == 'scattering_event_class': - self.set_parameter('scattering_event_class', - int(confs['scattering_event_class'])) + if conf_key == "scattering_event_class": + self.set_parameter( + "scattering_event_class", int(confs["scattering_event_class"]) + ) def _set_settings(self): self.set_settings() params = self._parameters # Supercell dimension for fc2 - if 'dim_fc2' in params: - self._settings.set_phonon_supercell_matrix(params['dim_fc2']) + if "dim_fc2" in params: + self._settings.set_phonon_supercell_matrix(params["dim_fc2"]) # Boundary mean free path for thermal conductivity calculation - if 'boundary_mfp' in params: - self._settings.set_boundary_mfp(params['boundary_mfp']) + if "boundary_mfp" in params: + self._settings.set_boundary_mfp(params["boundary_mfp"]) # Calculate thermal conductivity in BTE-RTA - if 'bterta' in params: - self._settings.set_is_bterta(params['bterta']) + if "bterta" in params: + self._settings.set_is_bterta(params["bterta"]) # Solve collective phonons - if 'collective_phonon' in params: - self._settings.set_solve_collective_phonon( - params['collective_phonon']) + if "collective_phonon" in params: + self._settings.set_solve_collective_phonon(params["collective_phonon"]) # Compact force constants or full force constants - if 'compact_fc' in params: - self._settings.set_is_compact_fc(params['compact_fc']) + if "compact_fc" in params: + self._settings.set_is_compact_fc(params["compact_fc"]) # Peierls type approximation for squared ph-ph interaction strength - if 'const_ave_pp' in params: - self._settings.set_constant_averaged_pp_interaction( - params['const_ave_pp']) + if "const_ave_pp" in params: + self._settings.set_constant_averaged_pp_interaction(params["const_ave_pp"]) # Trigger to create FORCES_FC2 and FORCES_FC3 - if 'create_forces_fc2' in params: - self._settings.set_create_forces_fc2(params['create_forces_fc2']) + if "create_forces_fc2" in params: + self._settings.set_create_forces_fc2(params["create_forces_fc2"]) - if 'create_forces_fc3' in params: - self._settings.set_create_forces_fc3(params['create_forces_fc3']) + if "create_forces_fc3" in params: + self._settings.set_create_forces_fc3(params["create_forces_fc3"]) - if 'create_forces_fc3_file' in params: - self._settings.set_create_forces_fc3_file( - params['create_forces_fc3_file']) + if "create_forces_fc3_file" in params: + self._settings.set_create_forces_fc3_file(params["create_forces_fc3_file"]) # Cutoff distance of third-order force constants. Elements where any # pair of atoms has larger distance than cut-off distance are set zero. - if 'cutoff_fc3_distance' in params: - self._settings.set_cutoff_fc3_distance( - params['cutoff_fc3_distance']) + if "cutoff_fc3_distance" in params: + self._settings.set_cutoff_fc3_distance(params["cutoff_fc3_distance"]) # Cutoff distance between pairs of displaced atoms used for supercell # creation with displacements and making third-order force constants - if 'cutoff_pair_distance' in params: - self._settings.set_cutoff_pair_distance( - params['cutoff_pair_distance']) + if "cutoff_pair_distance" in params: + self._settings.set_cutoff_pair_distance(params["cutoff_pair_distance"]) # Emulate v1.x grid system and shortest vectors. - if 'emulate_v1' in params: - self._settings.set_emulate_v1(params['emulate_v1']) - - # Gamma unit conversion factor - if 'gamma_conversion_factor' in params: - self._settings.set_gamma_conversion_factor( - params['gamma_conversion_factor']) + if "emulate_v1" in params: + self._settings.set_emulate_v1(params["emulate_v1"]) # Grid addresses (sets of three integer values) - if 'grid_addresses' in params: - self._settings.set_grid_addresses(params['grid_addresses']) + if "grid_addresses" in params: + self._settings.set_grid_addresses(params["grid_addresses"]) # Grid points - if 'grid_points' in params: - self._settings.set_grid_points(params['grid_points']) + if "grid_points" in params: + self._settings.set_grid_points(params["grid_points"]) # Atoms are clamped under applied strain in Gruneisen parameter # calculation. - if 'ion_clamped' in params: - self._settings.set_ion_clamped(params['ion_clamped']) + if "ion_clamped" in params: + self._settings.set_ion_clamped(params["ion_clamped"]) # Calculate full ph-ph interaction strength for RTA conductivity - if 'full_pp' in params: - self._settings.set_is_full_pp(params['full_pp']) + if "full_pp" in params: + self._settings.set_is_full_pp(params["full_pp"]) # Calculate phonon-Gruneisen parameters - if 'gruneisen' in params: - self._settings.set_is_gruneisen(params['gruneisen']) + if "gruneisen" in params: + self._settings.set_is_gruneisen(params["gruneisen"]) # Calculate imaginary part of self energy - if 'imag_self_energy' in params: - self._settings.set_is_imag_self_energy(params['imag_self_energy']) + if "imag_self_energy" in params: + self._settings.set_is_imag_self_energy(params["imag_self_energy"]) # Calculate lifetime due to isotope scattering - if 'isotope' in params: - self._settings.set_is_isotope(params['isotope']) + if "isotope" in params: + self._settings.set_is_isotope(params["isotope"]) # Calculate joint-DOS - if 'joint_dos' in params: - self._settings.set_is_joint_dos(params['joint_dos']) + if "joint_dos" in params: + self._settings.set_is_joint_dos(params["joint_dos"]) # Sum partial kappa at q-stars - if 'kappa_star' in params: - self._settings.set_is_kappa_star(params['kappa_star']) + if "kappa_star" in params: + self._settings.set_is_kappa_star(params["kappa_star"]) - if 'lapack_zheev_uplo' in params: - self._settings.set_lapack_zheev_uplo(params['lapack_zheev_uplo']) + if "lapack_zheev_uplo" in params: + self._settings.set_lapack_zheev_uplo(params["lapack_zheev_uplo"]) # Calculate thermal conductivity in LBTE with Chaput's method - if 'lbte' in params: - self._settings.set_is_lbte(params['lbte']) + if "lbte" in params: + self._settings.set_is_lbte(params["lbte"]) # Number of frequency points in a batch. - if 'num_points_in_batch' in params: - self._settings.set_num_points_in_batch( - params['num_points_in_batch']) + if "num_points_in_batch" in params: + self._settings.set_num_points_in_batch(params["num_points_in_batch"]) # Calculate Normal and Umklapp processes - if 'N_U' in params: - self._settings.set_is_N_U(params['N_U']) + if "N_U" in params: + self._settings.set_is_N_U(params["N_U"]) # Solve reducible collision matrix but not reduced matrix - if 'reducible_collision_matrix' in params: + if "reducible_collision_matrix" in params: self._settings.set_is_reducible_collision_matrix( - params['reducible_collision_matrix']) + params["reducible_collision_matrix"] + ) # Symmetrize fc2 by index exchange - if 'symmetrize_fc2' in params: - self._settings.set_is_symmetrize_fc2(params['symmetrize_fc2']) + if "symmetrize_fc2" in params: + self._settings.set_is_symmetrize_fc2(params["symmetrize_fc2"]) # Symmetrize phonon fc3 by index exchange - if 'symmetrize_fc3_q' in params: - self._settings.set_is_symmetrize_fc3_q(params['symmetrize_fc3_q']) + if "symmetrize_fc3_q" in params: + self._settings.set_is_symmetrize_fc3_q(params["symmetrize_fc3_q"]) # Symmetrize fc3 by index exchange - if 'symmetrize_fc3_r' in params: - self._settings.set_is_symmetrize_fc3_r(params['symmetrize_fc3_r']) + if "symmetrize_fc3_r" in params: + self._settings.set_is_symmetrize_fc3_r(params["symmetrize_fc3_r"]) # Mass variance parameters - if 'mass_variances' in params: - self._settings.set_mass_variances(params['mass_variances']) + if "mass_variances" in params: + self._settings.set_mass_variances(params["mass_variances"]) # Maximum mean free path - if 'max_freepath' in params: - self._settings.set_max_freepath(params['max_freepath']) + if "max_freepath" in params: + self._settings.set_max_freepath(params["max_freepath"]) # Cutoff frequency for pseudo inversion of collision matrix - if 'pinv_cutoff' in params: - self._settings.set_pinv_cutoff(params['pinv_cutoff']) + if "pinv_cutoff" in params: + self._settings.set_pinv_cutoff(params["pinv_cutoff"]) # Switch for pseudo-inverse solver - if 'pinv_solver' in params: - self._settings.set_pinv_solver(params['pinv_solver']) + if "pinv_solver" in params: + self._settings.set_pinv_solver(params["pinv_solver"]) # Ph-ph interaction unit conversion factor - if 'pp_conversion_factor' in params: - self._settings.set_pp_conversion_factor( - params['pp_conversion_factor']) + if "pp_conversion_factor" in params: + self._settings.set_pp_conversion_factor(params["pp_conversion_factor"]) # Calculate real_self_energys - if 'real_self_energy' in params: - self._settings.set_is_real_self_energy(params['real_self_energy']) + if "real_self_energy" in params: + self._settings.set_is_real_self_energy(params["real_self_energy"]) # Read phonon-phonon interaction amplitudes from hdf5 - if 'read_amplitude' in params: - self._settings.set_read_amplitude(params['read_amplitude']) + if "read_amplitude" in params: + self._settings.set_read_amplitude(params["read_amplitude"]) # Read collision matrix and gammas from hdf5 - if 'read_collision' in params: - self._settings.set_read_collision(params['read_collision']) + if "read_collision" in params: + self._settings.set_read_collision(params["read_collision"]) # Read fc2 from hdf5 - if 'read_fc2' in params: - self._settings.set_read_fc2(params['read_fc2']) + if "read_fc2" in params: + self._settings.set_read_fc2(params["read_fc2"]) # Read fc3 from hdf5 - if 'read_fc3' in params: - self._settings.set_read_fc3(params['read_fc3']) + if "read_fc3" in params: + self._settings.set_read_fc3(params["read_fc3"]) # Read gammas from hdf5 - if 'read_gamma' in params: - self._settings.set_read_gamma(params['read_gamma']) + if "read_gamma" in params: + self._settings.set_read_gamma(params["read_gamma"]) # Read phonons from hdf5 - if 'read_phonon' in params: - self._settings.set_read_phonon(params['read_phonon']) + if "read_phonon" in params: + self._settings.set_read_phonon(params["read_phonon"]) # Read ph-ph interaction strength from hdf5 - if 'read_pp' in params: - self._settings.set_read_pp(params['read_pp']) + if "read_pp" in params: + self._settings.set_read_pp(params["read_pp"]) # Scattering event class 1 or 2 - if 'scattering_event_class' in params: - self._settings.set_scattering_event_class( - params['scattering_event_class']) + if "scattering_event_class" in params: + self._settings.set_scattering_event_class(params["scattering_event_class"]) # Cutoff width of smearing function (ratio to sigma value) - if 'sigma_cutoff_width' in params: - self._settings.set_sigma_cutoff_width(params['sigma_cutoff_width']) + if "sigma_cutoff_width" in params: + self._settings.set_sigma_cutoff_width(params["sigma_cutoff_width"]) # Calculate spectral_functions - if 'spectral_function' in params: - self._settings.set_is_spectral_function( - params['spectral_function']) + if "spectral_function" in params: + self._settings.set_is_spectral_function(params["spectral_function"]) # Subtract residual forces to create FORCES_FC2 and FORCES_FC3 - if 'subtract_forces' in params: - self._settings.set_subtract_forces(params['subtract_forces']) + if "subtract_forces" in params: + self._settings.set_subtract_forces(params["subtract_forces"]) # Use averaged ph-ph interaction - if 'use_ave_pp' in params: - self._settings.set_use_ave_pp(params['use_ave_pp']) + if "use_ave_pp" in params: + self._settings.set_use_ave_pp(params["use_ave_pp"]) # Use generalized regular grid - if 'use_grg' in params: - self._settings.set_use_grg(params['use_grg']) + if "use_grg" in params: + self._settings.set_use_grg(params["use_grg"]) # Write detailed imag-part of self energy to hdf5 - if 'write_gamma_detail' in params: - self._settings.set_write_gamma_detail( - params['write_gamma_detail']) + if "write_gamma_detail" in params: + self._settings.set_write_gamma_detail(params["write_gamma_detail"]) # Write imag-part of self energy to hdf5 - if 'write_gamma' in params: - self._settings.set_write_gamma(params['write_gamma']) + if "write_gamma" in params: + self._settings.set_write_gamma(params["write_gamma"]) # Write collision matrix and gammas to hdf5 - if 'write_collision' in params: - self._settings.set_write_collision(params['write_collision']) + if "write_collision" in params: + self._settings.set_write_collision(params["write_collision"]) # Write all phonons on grid points to hdf5 - if 'write_phonon' in params: - self._settings.set_write_phonon(params['write_phonon']) + if "write_phonon" in params: + self._settings.set_write_phonon(params["write_phonon"]) # Write phonon-phonon interaction amplitudes to hdf5 - if 'write_pp' in params: - self._settings.set_write_pp(params['write_pp']) + if "write_pp" in params: + self._settings.set_write_pp(params["write_pp"]) # Write direct solution of LBTE to hdf5 files - if 'write_LBTE_solution' in params: - self._settings.set_write_LBTE_solution( - params['write_LBTE_solution']) + if "write_LBTE_solution" in params: + self._settings.set_write_LBTE_solution(params["write_LBTE_solution"]) diff --git a/phono3py/cui/show_log.py b/phono3py/cui/show_log.py index 914e2c90..50fc8432 100644 --- a/phono3py/cui/show_log.py +++ b/phono3py/cui/show_log.py @@ -37,14 +37,12 @@ import numpy as np from phonopy.structure.cells import print_cell -def show_general_settings(settings, - run_mode, - phono3py, - cell_filename, - input_filename, - output_filename): - is_primitive_axes_auto = (type(phono3py.primitive_matrix) is str and - phono3py.primitive_matrix == 'auto') +def show_general_settings( + settings, run_mode, phono3py, cell_filename, input_filename, output_filename +): + is_primitive_axes_auto = ( + type(phono3py.primitive_matrix) is str and phono3py.primitive_matrix == "auto" + ) primitive_matrix = phono3py.primitive_matrix supercell_matrix = phono3py.supercell_matrix phonon_supercell_matrix = phono3py.phonon_supercell_matrix @@ -60,7 +58,7 @@ def show_general_settings(settings, if phono3py.calculator: print("Calculator interface: %s" % phono3py.calculator) - print("Crystal structure was read from \"%s\"." % cell_filename) + print('Crystal structure was read from "%s".' % cell_filename) if (np.diag(np.diag(supercell_matrix)) - supercell_matrix).any(): print("Supercell matrix (dim):") @@ -69,14 +67,12 @@ def show_general_settings(settings, else: print("Supercell (dim): %s" % np.diag(supercell_matrix)) if phonon_supercell_matrix is not None: - if (np.diag(np.diag(phonon_supercell_matrix)) - - phonon_supercell_matrix).any(): + if (np.diag(np.diag(phonon_supercell_matrix)) - phonon_supercell_matrix).any(): print("Phonon supercell matrix (dim-fc2):") for v in phonon_supercell_matrix: print(" %s" % v) else: - print("Phonon supercell (dim-fc2): %s" - % np.diag(phonon_supercell_matrix)) + print("Phonon supercell (dim-fc2): %s" % np.diag(phonon_supercell_matrix)) if is_primitive_axes_auto: print("Primitive matrix (Auto):") for v in primitive_matrix: @@ -110,54 +106,59 @@ def show_phono3py_cells(phono3py, settings): def show_phono3py_force_constants_settings(settings): read_fc3 = settings.read_fc3 read_fc2 = settings.read_fc2 - symmetrize_fc3r = (settings.is_symmetrize_fc3_r or - settings.fc_symmetry) + symmetrize_fc3r = settings.is_symmetrize_fc3_r or settings.fc_symmetry symmetrize_fc3q = settings.is_symmetrize_fc3_q - symmetrize_fc2 = (settings.is_symmetrize_fc2 or - settings.fc_symmetry) + symmetrize_fc2 = settings.is_symmetrize_fc2 or settings.fc_symmetry print("-" * 29 + " Force constants " + "-" * 30) - if settings.fc_calculator == 'alm' and not read_fc2: + if settings.fc_calculator == "alm" and not read_fc2: print("Use ALM for getting fc2 (simultaneous fit to fc2 and fc3)") else: - print("Imposing translational and index exchange symmetry to fc2: %s" % - symmetrize_fc2) + print( + "Imposing translational and index exchange symmetry to fc2: %s" + % symmetrize_fc2 + ) if settings.is_isotope or settings.is_joint_dos: pass - elif settings.fc_calculator == 'alm' and not read_fc3: + elif settings.fc_calculator == "alm" and not read_fc3: print("Use ALM for getting fc3") else: - print("Imposing translational and index exchange symmetry to fc3: " - "%s" % symmetrize_fc3r) - print(("Imposing symmetry of index exchange to fc3 in reciprocal " - "space: %s") % symmetrize_fc3q) + print( + "Imposing translational and index exchange symmetry to fc3: " + "%s" % symmetrize_fc3r + ) + print( + ("Imposing symmetry of index exchange to fc3 in reciprocal " "space: %s") + % symmetrize_fc3q + ) if settings.cutoff_fc3_distance is not None: print("FC3 cutoff distance: %s" % settings.cutoff_fc3_distance) def show_phono3py_settings(phono3py, settings, updated_settings, log_level): - sigmas = updated_settings['sigmas'] - temperatures = updated_settings['temperatures'] - temperature_points = updated_settings['temperature_points'] - cutoff_frequency = updated_settings['cutoff_frequency'] - frequency_factor_to_THz = updated_settings['frequency_factor_to_THz'] - frequency_scale_factor = updated_settings['frequency_scale_factor'] - frequency_step = updated_settings['frequency_step'] - num_frequency_points = updated_settings['num_frequency_points'] + sigmas = updated_settings["sigmas"] + temperatures = updated_settings["temperatures"] + temperature_points = updated_settings["temperature_points"] + cutoff_frequency = updated_settings["cutoff_frequency"] + frequency_factor_to_THz = updated_settings["frequency_factor_to_THz"] + frequency_scale_factor = updated_settings["frequency_scale_factor"] + frequency_step = updated_settings["frequency_step"] + num_frequency_points = updated_settings["num_frequency_points"] print("-" * 27 + " Calculation settings " + "-" * 27) if settings.is_nac: print("Non-analytical term correction (NAC): %s" % settings.is_nac) if phono3py.nac_params: - print("NAC unit conversion factor: %9.5f" - % phono3py.nac_params['factor']) + print("NAC unit conversion factor: %9.5f" % phono3py.nac_params["factor"]) if settings.nac_q_direction is not None: print("NAC q-direction: %s" % settings.nac_q_direction) if settings.band_indices is not None and not settings.is_bterta: - print(("Band indices: [" + " %s" * len(settings.band_indices) + " ]") % - tuple([np.array(bi) + 1 for bi in settings.band_indices])) + print( + ("Band indices: [" + " %s" * len(settings.band_indices) + " ]") + % tuple([np.array(bi) + 1 for bi in settings.band_indices]) + ) if sigmas: text = "BZ integration: " for i, sigma in enumerate(sigmas): @@ -183,47 +184,44 @@ def show_phono3py_settings(phono3py, settings, updated_settings, log_level): text = (" %.1f " * len(temperatures)) % tuple(temperatures) print("Temperature: " + text) elif temperature_points is not None: - print(("Temperatures:" + " %.1f " * len(temperature_points)) - % tuple(temperature_points)) + print( + ("Temperatures:" + " %.1f " * len(temperature_points)) + % tuple(temperature_points) + ) if settings.scattering_event_class is not None: - print("Scattering event class: %s" - % settings.scattering_event_class) + print("Scattering event class: %s" % settings.scattering_event_class) if cutoff_frequency: print("Cutoff frequency: %s" % cutoff_frequency) - if (settings.use_ave_pp and - (settings.is_bterta or settings.is_lbte)): + if settings.use_ave_pp and (settings.is_bterta or settings.is_lbte): print("Use averaged ph-ph interaction") const_ave_pp = settings.constant_averaged_pp_interaction - if (const_ave_pp is not None and - (settings.is_bterta or settings.is_lbte)): + if const_ave_pp is not None and (settings.is_bterta or settings.is_lbte): print("Constant ph-ph interaction: %6.3e" % const_ave_pp) - print("Frequency conversion factor to THz: %9.5f" % - frequency_factor_to_THz) + print("Frequency conversion factor to THz: %9.5f" % frequency_factor_to_THz) if frequency_scale_factor is not None: print("Frequency scale factor: %8.5f" % frequency_scale_factor) - if (settings.is_joint_dos or - settings.is_imag_self_energy or - settings.is_real_self_energy or - settings.is_spectral_function): + if ( + settings.is_joint_dos + or settings.is_imag_self_energy + or settings.is_real_self_energy + or settings.is_spectral_function + ): if frequency_step is not None: print("Frequency step for spectrum: %s" % frequency_step) if num_frequency_points is not None: - print("Number of frequency sampling points: %d" % - num_frequency_points) + print("Number of frequency sampling points: %d" % num_frequency_points) if settings.mesh_numbers is not None: try: if len(settings.mesh_numbers) == 3: - print("Mesh sampling: [ %d %d %d ]" % - tuple(settings.mesh_numbers)) + print("Mesh sampling: [ %d %d %d ]" % tuple(settings.mesh_numbers)) except TypeError: - print("Length for sampling mesh generation: %.2f" % - settings.mesh_numbers) + print("Length for sampling mesh generation: %.2f" % settings.mesh_numbers) sys.stdout.flush() diff --git a/phono3py/cui/triplets_info.py b/phono3py/cui/triplets_info.py index 08be3f99..d18c0394 100644 --- a/phono3py/cui/triplets_info.py +++ b/phono3py/cui/triplets_info.py @@ -38,30 +38,33 @@ from phono3py.phonon3.triplets import get_triplets_at_q from phono3py.phonon.grid import get_ir_grid_points -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): +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, +): ir_grid_points, ir_grid_weights = _get_ir_grid_points( - bz_grid, - is_kappa_star=is_kappa_star) - write_ir_grid_points(bz_grid, - ir_grid_points, - ir_grid_weights, - np.linalg.inv(primitive.cell)) - gadrs_hdf5_fname = write_grid_address_to_hdf5(bz_grid.addresses, - bz_grid.D_diag, - bz_grid.gp_map, - compression=compression, - filename=filename) + bz_grid, is_kappa_star=is_kappa_star + ) + write_ir_grid_points( + bz_grid, ir_grid_points, ir_grid_weights, np.linalg.inv(primitive.cell) + ) + gadrs_hdf5_fname = write_grid_address_to_hdf5( + bz_grid.addresses, + bz_grid.D_diag, + bz_grid.gp_map, + compression=compression, + filename=filename, + ) - print("Ir-grid points are written into \"ir_grid_points.yaml\".") - print("Grid addresses are written into \"%s\"." % gadrs_hdf5_fname) + print('Ir-grid points are written into "ir_grid_points.yaml".') + print('Grid addresses are written into "%s".' % gadrs_hdf5_fname) if is_lbte and temperatures is not None: num_temp = len(temperatures) @@ -75,26 +78,29 @@ def write_grid_points(primitive, num_band0 = len(band_indices) print("Memory requirements:") size = (num_band0 * 3 * num_ir_gp * num_band * 3) * 8 / 1.0e9 - print("- Piece of collision matrix at each grid point, temp and " - "sigma: %.2f Gb" % size) + print( + "- Piece of collision matrix at each grid point, temp and " + "sigma: %.2f Gb" % size + ) size = (num_ir_gp * num_band * 3) ** 2 * 8 / 1.0e9 - print("- Full collision matrix at each temp and sigma: %.2f Gb" - % size) + print("- Full collision matrix at each temp and sigma: %.2f Gb" % size) size = num_gp * (num_band ** 2 * 16 + num_band * 8 + 1) / 1.0e9 print("- Phonons: %.2f Gb" % size) size = num_gp * 5 * 4 / 1.0e9 print("- Grid point information: %.2f Gb" % size) - size = (num_ir_gp * num_band0 * - (3 + 6 + num_temp * 2 + num_sigma * num_temp * 15 + 2) * - 8 / 1.0e9) + size = ( + num_ir_gp + * num_band0 + * (3 + 6 + num_temp * 2 + num_sigma * num_temp * 15 + 2) + * 8 + / 1.0e9 + ) print("- Phonon properties: %.2f Gb" % size) -def show_num_triplets(primitive, - bz_grid, - band_indices=None, - grid_points=None, - is_kappa_star=True): +def show_num_triplets( + primitive, bz_grid, band_indices=None, grid_points=None, is_kappa_star=True +): tp_nums = _TripletsNumbers(bz_grid, is_kappa_star=is_kappa_star) num_band = len(primitive) * 3 if band_indices is None: @@ -113,40 +119,38 @@ def show_num_triplets(primitive, num_triplets = tp_nums.get_number_of_triplets(gp) q = np.dot(bz_grid.addresses[gp], bz_grid.QDinv.T) size = num_triplets * num_band0 * num_band ** 2 * 8 / 1e6 - print(" %5d (%5.2f %5.2f %5.2f) %8d %d Mb" % - (gp, q[0], q[1], q[2], num_triplets, size)) + print( + " %5d (%5.2f %5.2f %5.2f) %8d %d Mb" + % (gp, q[0], q[1], q[2], num_triplets, size) + ) class _TripletsNumbers(object): def __init__(self, bz_grid, is_kappa_star=True): self._bz_grid = bz_grid - self.ir_grid_points, _, = _get_ir_grid_points( - self._bz_grid, - is_kappa_star=is_kappa_star) + ( + self.ir_grid_points, + _, + ) = _get_ir_grid_points(self._bz_grid, is_kappa_star=is_kappa_star) def get_number_of_triplets(self, gp): - num_triplets = _get_number_of_triplets( - self._bz_grid, gp, swappable=True) + num_triplets = _get_number_of_triplets(self._bz_grid, gp, swappable=True) return num_triplets def _get_ir_grid_points(bz_grid, is_kappa_star=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="int_") else: ir_grid_points = np.array( - bz_grid.grg2bzg[:np.prod(bz_grid.D_diag)], - dtype='int_', order='C') - ir_grid_weights = np.ones(len(ir_grid_points), dtype='int_') + bz_grid.grg2bzg[: np.prod(bz_grid.D_diag)], dtype="int_", order="C" + ) + ir_grid_weights = np.ones(len(ir_grid_points), dtype="int_") return ir_grid_points, ir_grid_weights -def _get_number_of_triplets(bz_grid, - grid_point, - swappable=True): - triplets_at_q = get_triplets_at_q(grid_point, - bz_grid, - swappable=swappable)[0] +def _get_number_of_triplets(bz_grid, grid_point, swappable=True): + triplets_at_q = get_triplets_at_q(grid_point, bz_grid, swappable=swappable)[0] return len(triplets_at_q) diff --git a/phono3py/file_IO.py b/phono3py/file_IO.py index c37d8afb..92244351 100644 --- a/phono3py/file_IO.py +++ b/phono3py/file_IO.py @@ -40,8 +40,7 @@ import h5py # This import is deactivated for a while. # from phonopy.file_IO import write_force_constants_to_hdf5 -from phonopy.file_IO import (check_force_constants_indices, - get_cell_from_disp_yaml) +from phonopy.file_IO import check_force_constants_indices, get_cell_from_disp_yaml from phonopy.cui.load_helper import read_force_constants_from_hdf5 from phono3py.version import __version__ @@ -53,8 +52,7 @@ def write_cell_yaml(w, supercell): These methods are also deprecated. """ - warnings.warn("write_cell_yaml() is deprecated.", - DeprecationWarning) + warnings.warn("write_cell_yaml() is deprecated.", DeprecationWarning) w.write("lattice:\n") for axis in supercell.get_cell(): @@ -63,31 +61,30 @@ def write_cell_yaml(w, supercell): positions = supercell.get_scaled_positions() w.write("atoms:\n") for i, (s, v) in enumerate(zip(symbols, positions)): - w.write("- symbol: %-2s # %d\n" % (s, i+1)) + w.write("- symbol: %-2s # %d\n" % (s, i + 1)) w.write(" position: [ %18.14f,%18.14f,%18.14f ]\n" % tuple(v)) -def write_disp_fc3_yaml(dataset, supercell, filename='disp_fc3.yaml'): +def write_disp_fc3_yaml(dataset, supercell, filename="disp_fc3.yaml"): """Write disp_fc3.yaml.""" - warnings.warn("write_disp_fc3_yaml() is deprecated.", - DeprecationWarning) + warnings.warn("write_disp_fc3_yaml() is deprecated.", DeprecationWarning) - w = open(filename, 'w') - w.write("natom: %d\n" % dataset['natom']) + w = open(filename, "w") + w.write("natom: %d\n" % dataset["natom"]) - num_first = len(dataset['first_atoms']) + num_first = len(dataset["first_atoms"]) w.write("num_first_displacements: %d\n" % num_first) - if 'cutoff_distance' in dataset: - w.write("cutoff_distance: %f\n" % dataset['cutoff_distance']) + if "cutoff_distance" in dataset: + w.write("cutoff_distance: %f\n" % dataset["cutoff_distance"]) num_second = 0 num_disp_files = 0 - for d1 in dataset['first_atoms']: + for d1 in dataset["first_atoms"]: num_disp_files += 1 - num_second += len(d1['second_atoms']) - for d2 in d1['second_atoms']: - if 'included' in d2: - if d2['included']: + num_second += len(d1["second_atoms"]) + for d2 in d1["second_atoms"]: + if "included" in d2: + if d2["included"]: num_disp_files += 1 else: num_disp_files += 1 @@ -95,39 +92,42 @@ def write_disp_fc3_yaml(dataset, supercell, filename='disp_fc3.yaml'): w.write("num_second_displacements: %d\n" % num_second) w.write("num_displacements_created: %d\n" % num_disp_files) - if 'duplicates' in dataset: + if "duplicates" in dataset: w.write("duplicates:\n") - for (i, j) in dataset['duplicates']: + for (i, j) in dataset["duplicates"]: w.write("- [ %d, %d ]\n" % (i, j)) w.write("first_atoms:\n") count1 = 0 - count2 = len(dataset['first_atoms']) - for disp1 in dataset['first_atoms']: + count2 = len(dataset["first_atoms"]) + for disp1 in dataset["first_atoms"]: count1 += 1 - disp_cart1 = disp1['displacement'] - w.write("- number: %5d\n" % (disp1['number'] + 1)) + disp_cart1 = disp1["displacement"] + w.write("- number: %5d\n" % (disp1["number"] + 1)) w.write(" displacement:\n") - w.write(" [%20.16f,%20.16f,%20.16f ] # %05d\n" % - (disp_cart1[0], disp_cart1[1], disp_cart1[2], count1)) + w.write( + " [%20.16f,%20.16f,%20.16f ] # %05d\n" + % (disp_cart1[0], disp_cart1[1], disp_cart1[2], count1) + ) w.write(" displacement_id: %d\n" % count1) w.write(" second_atoms:\n") included = None - atom2_list = np.array([disp2['number'] - for disp2 in disp1['second_atoms']], dtype=int) + atom2_list = np.array( + [disp2["number"] for disp2 in disp1["second_atoms"]], dtype=int + ) _, indices = np.unique(atom2_list, return_index=True) for atom2 in atom2_list[indices]: disp2_list = [] - for disp2 in disp1['second_atoms']: - if disp2['number'] == atom2: + for disp2 in disp1["second_atoms"]: + if disp2["number"] == atom2: disp2_list.append(disp2) disp2 = disp2_list[0] - atom2 = disp2['number'] - if 'included' in disp2: - included = disp2['included'] - pair_distance = disp2['pair_distance'] + atom2 = disp2["number"] + if "included" in disp2: + included = disp2["included"] + pair_distance = disp2["pair_distance"] w.write(" - number: %5d\n" % (atom2 + 1)) w.write(" distance: %f\n" % pair_distance) if included is not None: @@ -141,15 +141,16 @@ def write_disp_fc3_yaml(dataset, supercell, filename='disp_fc3.yaml'): count2 += 1 # Assert all disp2s belonging to same atom2 appear straight. - assert disp2['id'] == count2 + assert disp2["id"] == count2 - disp_cart2 = disp2['displacement'] - w.write(" - [%20.16f,%20.16f,%20.16f ] # %05d\n" % - (disp_cart2[0], disp_cart2[1], disp_cart2[2], - count2)) + disp_cart2 = disp2["displacement"] + w.write( + " - [%20.16f,%20.16f,%20.16f ] # %05d\n" + % (disp_cart2[0], disp_cart2[1], disp_cart2[2], count2) + ) - ids = ["%d" % disp2['id'] for disp2 in disp2_list] - w.write(" displacement_ids: [ %s ]\n" % ', '.join(ids)) + ids = ["%d" % disp2["id"] for disp2 in disp2_list] + w.write(" displacement_ids: [ %s ]\n" % ", ".join(ids)) write_cell_yaml(w, supercell) @@ -158,23 +159,24 @@ def write_disp_fc3_yaml(dataset, supercell, filename='disp_fc3.yaml'): return num_first + num_second, num_disp_files -def write_disp_fc2_yaml(dataset, supercell, filename='disp_fc2.yaml'): +def write_disp_fc2_yaml(dataset, supercell, filename="disp_fc2.yaml"): """Write disp_fc2.yaml.""" - warnings.warn("write_disp_fc2_yaml() is deprecated.", - DeprecationWarning) + warnings.warn("write_disp_fc2_yaml() is deprecated.", DeprecationWarning) - w = open(filename, 'w') - w.write("natom: %d\n" % dataset['natom']) + w = open(filename, "w") + w.write("natom: %d\n" % dataset["natom"]) - num_first = len(dataset['first_atoms']) + num_first = len(dataset["first_atoms"]) w.write("num_first_displacements: %d\n" % num_first) w.write("first_atoms:\n") - for i, disp1 in enumerate(dataset['first_atoms']): - disp_cart1 = disp1['displacement'] - w.write("- number: %5d\n" % (disp1['number'] + 1)) + for i, disp1 in enumerate(dataset["first_atoms"]): + disp_cart1 = disp1["displacement"] + w.write("- number: %5d\n" % (disp1["number"] + 1)) w.write(" displacement:\n") - w.write(" [%20.16f,%20.16f,%20.16f ] # %05d\n" % - (disp_cart1[0], disp_cart1[1], disp_cart1[2], i + 1)) + w.write( + " [%20.16f,%20.16f,%20.16f ] # %05d\n" + % (disp_cart1[0], disp_cart1[1], disp_cart1[2], i + 1) + ) if supercell is not None: write_cell_yaml(w, supercell) @@ -184,10 +186,7 @@ def write_disp_fc2_yaml(dataset, supercell, filename='disp_fc2.yaml'): return num_first -def write_FORCES_FC2(disp_dataset, - forces_fc2=None, - fp=None, - filename="FORCES_FC2"): +def write_FORCES_FC2(disp_dataset, forces_fc2=None, fp=None, filename="FORCES_FC2"): """Write FORCES_FC2. fp : IO object, optional, default=None @@ -195,26 +194,23 @@ def write_FORCES_FC2(disp_dataset, """ if fp is None: - w = open(filename, 'w') + w = open(filename, "w") else: w = fp - for i, disp1 in enumerate(disp_dataset['first_atoms']): + for i, disp1 in enumerate(disp_dataset["first_atoms"]): w.write("# File: %-5d\n" % (i + 1)) - w.write("# %-5d " % (disp1['number'] + 1)) - w.write("%20.16f %20.16f %20.16f\n" % tuple(disp1['displacement'])) - if 'forces' in disp1 and forces_fc2 is None: - force_set = disp1['forces'] + w.write("# %-5d " % (disp1["number"] + 1)) + w.write("%20.16f %20.16f %20.16f\n" % tuple(disp1["displacement"])) + if "forces" in disp1 and forces_fc2 is None: + force_set = disp1["forces"] else: force_set = forces_fc2[i] for forces in force_set: w.write("%15.10f %15.10f %15.10f\n" % tuple(forces)) -def write_FORCES_FC3(disp_dataset, - forces_fc3=None, - fp=None, - filename="FORCES_FC3"): +def write_FORCES_FC3(disp_dataset, forces_fc3=None, fp=None, filename="FORCES_FC3"): """Write FORCES_FC3. fp : IO object, optional, default=None @@ -222,34 +218,34 @@ def write_FORCES_FC3(disp_dataset, """ if fp is None: - w = open(filename, 'w') + w = open(filename, "w") else: w = fp - natom = disp_dataset['natom'] - num_disp1 = len(disp_dataset['first_atoms']) + natom = disp_dataset["natom"] + num_disp1 = len(disp_dataset["first_atoms"]) count = num_disp1 file_count = num_disp1 write_FORCES_FC2(disp_dataset, forces_fc2=forces_fc3, fp=w) - for i, disp1 in enumerate(disp_dataset['first_atoms']): - atom1 = disp1['number'] - for disp2 in disp1['second_atoms']: - atom2 = disp2['number'] + for i, disp1 in enumerate(disp_dataset["first_atoms"]): + atom1 = disp1["number"] + for disp2 in disp1["second_atoms"]: + atom2 = disp2["number"] w.write("# File: %-5d\n" % (count + 1)) w.write("# %-5d " % (atom1 + 1)) - w.write("%20.16f %20.16f %20.16f\n" % tuple(disp1['displacement'])) + w.write("%20.16f %20.16f %20.16f\n" % tuple(disp1["displacement"])) w.write("# %-5d " % (atom2 + 1)) - w.write("%20.16f %20.16f %20.16f\n" % tuple(disp2['displacement'])) + w.write("%20.16f %20.16f %20.16f\n" % tuple(disp2["displacement"])) # For supercell calculation reduction included = True - if 'included' in disp2: - included = disp2['included'] + if "included" in disp2: + included = disp2["included"] if included: - if 'forces' in disp2 and forces_fc3 is None: - force_set = disp2['forces'] + if "forces" in disp2 and forces_fc3 is None: + force_set = disp2["forces"] else: force_set = forces_fc3[file_count] for force in force_set: @@ -263,28 +259,26 @@ def write_FORCES_FC3(disp_dataset, count += 1 -def write_fc3_dat(force_constants_third, filename='fc3.dat'): +def write_fc3_dat(force_constants_third, filename="fc3.dat"): """Write fc3.dat.""" - warnings.warn("write_fc3_dat() is deprecated.", - DeprecationWarning) + warnings.warn("write_fc3_dat() is deprecated.", DeprecationWarning) - w = open(filename, 'w') + w = open(filename, "w") for i in range(force_constants_third.shape[0]): for j in range(force_constants_third.shape[1]): for k in range(force_constants_third.shape[2]): tensor3 = force_constants_third[i, j, k] - w.write(" %d - %d - %d (%f)\n" % (i + 1, j + 1, k + 1, - np.abs(tensor3).sum())) + w.write( + " %d - %d - %d (%f)\n" + % (i + 1, j + 1, k + 1, np.abs(tensor3).sum()) + ) for tensor2 in tensor3: for vec in tensor2: w.write("%20.14f %20.14f %20.14f\n" % tuple(vec)) w.write("\n") -def write_fc3_to_hdf5(fc3, - filename='fc3.hdf5', - p2s_map=None, - compression="gzip"): +def write_fc3_to_hdf5(fc3, filename="fc3.hdf5", p2s_map=None, compression="gzip"): """Write fc3 in fc3.hdf5. Parameters @@ -304,14 +298,14 @@ def write_fc3_to_hdf5(fc3, h5py.Group.create_dataset. Default is "gzip". """ - with h5py.File(filename, 'w') as w: - w.create_dataset('version', data=np.string_(__version__)) - w.create_dataset('fc3', data=fc3, compression=compression) + with h5py.File(filename, "w") as w: + w.create_dataset("version", data=np.string_(__version__)) + w.create_dataset("fc3", data=fc3, compression=compression) if p2s_map is not None: - w.create_dataset('p2s_map', data=p2s_map) + w.create_dataset("p2s_map", data=p2s_map) -def read_fc3_from_hdf5(filename='fc3.hdf5', p2s_map=None): +def read_fc3_from_hdf5(filename="fc3.hdf5", p2s_map=None): """Read fc3 from fc3.hdf5. fc3 can be in full or compact format. They are distinguished by @@ -322,92 +316,97 @@ def read_fc3_from_hdf5(filename='fc3.hdf5', p2s_map=None): respective indices. """ - with h5py.File(filename, 'r') as f: - fc3 = f['fc3'][:] - if 'p2s_map' in f: - p2s_map_in_file = f['p2s_map'][:] - check_force_constants_indices(fc3.shape[:2], - p2s_map_in_file, - p2s_map, - filename) + with h5py.File(filename, "r") as f: + fc3 = f["fc3"][:] + if "p2s_map" in f: + p2s_map_in_file = f["p2s_map"][:] + check_force_constants_indices( + fc3.shape[:2], p2s_map_in_file, p2s_map, filename + ) if fc3.dtype == np.double and fc3.flags.c_contiguous: return fc3 else: - msg = ("%s has to be read by h5py as numpy ndarray of " - "dtype='double' and c_contiguous." % filename) + msg = ( + "%s has to be read by h5py as numpy ndarray of " + "dtype='double' and c_contiguous." % filename + ) raise TypeError(msg) return None -def write_fc2_to_hdf5(force_constants, - filename='fc2.hdf5', - p2s_map=None, - physical_unit=None, - compression="gzip"): +def write_fc2_to_hdf5( + force_constants, + filename="fc2.hdf5", + p2s_map=None, + physical_unit=None, + compression="gzip", +): """Write fc2 in fc2.hdf5. write_force_constants_to_hdf5 was copied from phonopy because it in phonopy doesn't support 'version' dataset. """ - def write_force_constants_to_hdf5(force_constants, - filename='force_constants.hdf5', - p2s_map=None, - physical_unit=None, - compression=None, - version=None): + + def write_force_constants_to_hdf5( + force_constants, + filename="force_constants.hdf5", + p2s_map=None, + physical_unit=None, + compression=None, + version=None, + ): try: import h5py except ImportError: raise ModuleNotFoundError("You need to install python-h5py.") - with h5py.File(filename, 'w') as w: - w.create_dataset('force_constants', data=force_constants, - compression=compression) + with h5py.File(filename, "w") as w: + w.create_dataset( + "force_constants", data=force_constants, compression=compression + ) if p2s_map is not None: - w.create_dataset('p2s_map', data=p2s_map) + w.create_dataset("p2s_map", data=p2s_map) if physical_unit is not None: - dset = w.create_dataset('physical_unit', (1,), - dtype='S%d' % len(physical_unit)) + dset = w.create_dataset( + "physical_unit", (1,), dtype="S%d" % len(physical_unit) + ) dset[0] = np.string_(physical_unit) if version is not None: - w.create_dataset('version', data=np.string_(version)) + w.create_dataset("version", data=np.string_(version)) - write_force_constants_to_hdf5(force_constants, - filename=filename, - p2s_map=p2s_map, - physical_unit=physical_unit, - compression=compression, - version=__version__) + write_force_constants_to_hdf5( + force_constants, + filename=filename, + p2s_map=p2s_map, + physical_unit=physical_unit, + compression=compression, + version=__version__, + ) -def read_fc2_from_hdf5(filename='fc2.hdf5', - p2s_map=None): +def read_fc2_from_hdf5(filename="fc2.hdf5", p2s_map=None): """Read fc2 from fc2.hdf5.""" - return read_force_constants_from_hdf5(filename=filename, - p2s_map=p2s_map, - calculator='vasp') + return read_force_constants_from_hdf5( + filename=filename, p2s_map=p2s_map, calculator="vasp" + ) -def write_triplets(triplets, - weights, - mesh, - grid_address, - grid_point=None, - filename=None): +def write_triplets( + triplets, weights, mesh, grid_address, grid_point=None, filename=None +): """Write triplets in triplets.dat.""" - warnings.warn("write_triplets() is deprecated.", - DeprecationWarning) + warnings.warn("write_triplets() is deprecated.", DeprecationWarning) triplets_filename = "triplets" suffix = "-m%d%d%d" % tuple(mesh) if grid_point is not None: - suffix += ("-g%d" % grid_point) + suffix += "-g%d" % grid_point if filename is not None: suffix += "." + filename suffix += ".dat" triplets_filename += suffix - w = open(triplets_filename, 'w') + w = open(triplets_filename, "w") for weight, g3 in zip(weights, triplets): w.write("%4d " % weight) for q3 in grid_address[g3]: @@ -418,8 +417,7 @@ def write_triplets(triplets, def write_grid_address(grid_address, mesh, filename=None): """Write grid addresses in grid_address.dat.""" - warnings.warn("write_grid_address() is deprecated.", - DeprecationWarning) + warnings.warn("write_grid_address() is deprecated.", DeprecationWarning) grid_address_filename = "grid_address" suffix = "-m%d%d%d" % tuple(mesh) @@ -428,11 +426,20 @@ def write_grid_address(grid_address, mesh, filename=None): suffix += ".dat" grid_address_filename += suffix - w = open(grid_address_filename, 'w') + w = open(grid_address_filename, "w") w.write("# Grid addresses for %dx%dx%d mesh\n" % tuple(mesh)) - w.write("#%9s %8s %8s %8s %8s %8s %8s\n" % - ("index", "a", "b", "c", - ("a%%%d" % mesh[0]), ("b%%%d" % mesh[1]), ("c%%%d" % mesh[2]))) + w.write( + "#%9s %8s %8s %8s %8s %8s %8s\n" + % ( + "index", + "a", + "b", + "c", + ("a%%%d" % mesh[0]), + ("b%%%d" % mesh[1]), + ("c%%%d" % mesh[2]), + ) + ) for i, bz_q in enumerate(grid_address): if i == np.prod(mesh): w.write("#" + "-" * 78 + "\n") @@ -443,35 +450,35 @@ def write_grid_address(grid_address, mesh, filename=None): return grid_address_filename -def write_grid_address_to_hdf5(grid_address, - mesh, - grid_mapping_table, - compression="gzip", - filename=None): +def write_grid_address_to_hdf5( + grid_address, mesh, grid_mapping_table, compression="gzip", filename=None +): """Write grid addresses to grid_address.hdf5.""" suffix = _get_filename_suffix(mesh, filename=filename) full_filename = "grid_address" + suffix + ".hdf5" - with h5py.File(full_filename, 'w') as w: - w.create_dataset('version', data=np.string_(__version__)) - w.create_dataset('mesh', data=mesh) - w.create_dataset('grid_address', data=grid_address, - compression=compression) - w.create_dataset('grid_mapping_table', data=grid_mapping_table, - compression=compression) + with h5py.File(full_filename, "w") as w: + w.create_dataset("version", data=np.string_(__version__)) + w.create_dataset("mesh", data=mesh) + w.create_dataset("grid_address", data=grid_address, compression=compression) + w.create_dataset( + "grid_mapping_table", data=grid_mapping_table, compression=compression + ) return full_filename return None -def write_imag_self_energy_at_grid_point(gp, - band_indices, - mesh, - frequencies, - gammas, - sigma=None, - temperature=None, - scattering_event_class=None, - filename=None, - is_mesh_symmetry=True): +def write_imag_self_energy_at_grid_point( + gp, + band_indices, + mesh, + frequencies, + gammas, + sigma=None, + temperature=None, + scattering_event_class=None, + filename=None, + is_mesh_symmetry=True, +): """Write imaginary part of self-energy spectrum in gamma-*.dat.""" gammas_filename = "gammas" gammas_filename += "-m%d%d%d-g%d-" % (mesh[0], mesh[1], mesh[2], gp) @@ -493,7 +500,7 @@ def write_imag_self_energy_at_grid_point(gp, gammas_filename += ".nosym" gammas_filename += ".dat" - w = open(gammas_filename, 'w') + w = open(gammas_filename, "w") for freq, g in zip(frequencies, gammas): w.write("%15.7f %20.15e\n" % (freq, g)) w.close() @@ -501,48 +508,55 @@ def write_imag_self_energy_at_grid_point(gp, return gammas_filename -def write_joint_dos(gp, - mesh, - frequencies, - jdos, - sigma=None, - temperatures=None, - filename=None, - is_mesh_symmetry=True): +def write_joint_dos( + gp, + mesh, + frequencies, + jdos, + sigma=None, + temperatures=None, + filename=None, + is_mesh_symmetry=True, +): """Write joint-DOS spectrum in jdos-*.dat.""" if temperatures is None: - return _write_joint_dos_at_t(gp, - mesh, - frequencies, - jdos, - sigma=sigma, - temperature=None, - filename=filename, - is_mesh_symmetry=is_mesh_symmetry) + return _write_joint_dos_at_t( + gp, + mesh, + frequencies, + jdos, + sigma=sigma, + temperature=None, + filename=filename, + is_mesh_symmetry=is_mesh_symmetry, + ) else: for jdos_at_t, t in zip(jdos, temperatures): - return _write_joint_dos_at_t(gp, - mesh, - frequencies, - jdos_at_t, - sigma=sigma, - temperature=t, - filename=filename, - is_mesh_symmetry=is_mesh_symmetry) + return _write_joint_dos_at_t( + gp, + mesh, + frequencies, + jdos_at_t, + sigma=sigma, + temperature=t, + filename=filename, + is_mesh_symmetry=is_mesh_symmetry, + ) -def _write_joint_dos_at_t(grid_point, - mesh, - frequencies, - jdos, - sigma=None, - temperature=None, - filename=None, - is_mesh_symmetry=True): - suffix = _get_filename_suffix(mesh, - grid_point=grid_point, - sigma=sigma, - filename=filename) +def _write_joint_dos_at_t( + grid_point, + mesh, + frequencies, + jdos, + sigma=None, + temperature=None, + filename=None, + is_mesh_symmetry=True, +): + suffix = _get_filename_suffix( + mesh, grid_point=grid_point, sigma=sigma, filename=filename + ) jdos_filename = "jdos%s" % suffix if temperature is not None: jdos_filename += "-t" + _del_zeros(temperature) @@ -552,7 +566,7 @@ def _write_joint_dos_at_t(grid_point, jdos_filename += ".%s" % filename jdos_filename += ".dat" - with open(jdos_filename, 'w') as w: + with open(jdos_filename, "w") as w: for omega, vals in zip(frequencies, jdos): w.write("%15.7f" % omega) w.write((" %20.15e" * len(vals)) % tuple(vals)) @@ -560,15 +574,17 @@ def _write_joint_dos_at_t(grid_point, return jdos_filename -def write_real_self_energy_at_grid_point(gp, - band_indices, - frequency_points, - deltas, - mesh, - epsilon, - temperature, - filename=None, - is_mesh_symmetry=True): +def write_real_self_energy_at_grid_point( + gp, + band_indices, + frequency_points, + deltas, + mesh, + epsilon, + temperature, + filename=None, + is_mesh_symmetry=True, +): """Write real part of self-energy spectrum in deltas-*.dat.""" deltas_filename = "deltas" deltas_filename += _get_filename_suffix(mesh, grid_point=gp) @@ -586,22 +602,24 @@ def write_real_self_energy_at_grid_point(gp, deltas_filename += ".nosym" deltas_filename += ".dat" - with open(deltas_filename, 'w') as w: + with open(deltas_filename, "w") as w: for freq, v in zip(frequency_points, deltas): w.write("%15.7f %20.15e\n" % (freq, v)) return deltas_filename -def write_real_self_energy_to_hdf5(grid_point, - band_indices, - temperatures, - deltas, - mesh, - epsilon, - frequency_points=None, - frequencies=None, - filename=None): +def write_real_self_energy_to_hdf5( + grid_point, + band_indices, + temperatures, + deltas, + mesh, + epsilon, + frequency_points=None, + frequencies=None, + filename=None, +): """Wirte real part of self energy (currently only bubble) in hdf5. deltas : ndarray @@ -616,7 +634,7 @@ def write_real_self_energy_to_hdf5(grid_point, """ full_filename = "deltas" suffix = _get_filename_suffix(mesh, grid_point=grid_point) - _band_indices = np.array(band_indices, dtype='intc') + _band_indices = np.array(band_indices, dtype="intc") full_filename += suffix if epsilon > 1e-5: @@ -625,31 +643,33 @@ def write_real_self_energy_to_hdf5(grid_point, full_filename += "-e%.3e" % epsilon full_filename += ".hdf5" - with h5py.File(full_filename, 'w') as w: - w.create_dataset('version', data=np.string_(__version__)) - w.create_dataset('grid_point', data=grid_point) - w.create_dataset('mesh', data=mesh) - w.create_dataset('band_index', data=_band_indices) - w.create_dataset('delta', data=deltas) - w.create_dataset('temperature', data=temperatures) - w.create_dataset('epsilon', data=epsilon) + with h5py.File(full_filename, "w") as w: + w.create_dataset("version", data=np.string_(__version__)) + w.create_dataset("grid_point", data=grid_point) + w.create_dataset("mesh", data=mesh) + w.create_dataset("band_index", data=_band_indices) + w.create_dataset("delta", data=deltas) + w.create_dataset("temperature", data=temperatures) + w.create_dataset("epsilon", data=epsilon) if frequency_points is not None: - w.create_dataset('frequency_points', data=frequency_points) + w.create_dataset("frequency_points", data=frequency_points) if frequencies is not None: - w.create_dataset('frequency', data=frequencies) + w.create_dataset("frequency", data=frequencies) return full_filename -def write_spectral_function_at_grid_point(gp, - band_indices, - frequency_points, - spectral_functions, - mesh, - temperature, - sigma=None, - filename=None, - is_mesh_symmetry=True): +def write_spectral_function_at_grid_point( + gp, + band_indices, + frequency_points, + spectral_functions, + mesh, + temperature, + sigma=None, + filename=None, + is_mesh_symmetry=True, +): """Write spectral function spectrum in spectral-*.dat.""" spectral_filename = "spectral" spectral_filename += _get_filename_suffix(mesh, grid_point=gp, sigma=sigma) @@ -663,24 +683,26 @@ def write_spectral_function_at_grid_point(gp, spectral_filename += ".nosym" spectral_filename += ".dat" - with open(spectral_filename, 'w') as w: + with open(spectral_filename, "w") as w: for freq, v in zip(frequency_points, spectral_functions): w.write("%15.7f %20.15e\n" % (freq, v)) return spectral_filename -def write_spectral_function_to_hdf5(grid_point, - band_indices, - temperatures, - spectral_functions, - shifts, - half_linewidths, - mesh, - sigma=None, - frequency_points=None, - frequencies=None, - filename=None): +def write_spectral_function_to_hdf5( + grid_point, + band_indices, + temperatures, + spectral_functions, + shifts, + half_linewidths, + mesh, + sigma=None, + frequency_points=None, + frequencies=None, + filename=None, +): """Wirte spectral functions (currently only bubble) in hdf5. spectral_functions : ndarray @@ -691,67 +713,71 @@ def write_spectral_function_to_hdf5(grid_point, """ full_filename = "spectral" suffix = _get_filename_suffix(mesh, grid_point=grid_point, sigma=sigma) - _band_indices = np.array(band_indices, dtype='intc') + _band_indices = np.array(band_indices, dtype="intc") full_filename += suffix full_filename += ".hdf5" - with h5py.File(full_filename, 'w') as w: - w.create_dataset('version', data=np.string_(__version__)) - w.create_dataset('grid_point', data=grid_point) - w.create_dataset('mesh', data=mesh) - w.create_dataset('band_index', data=_band_indices) - w.create_dataset('spectral_function', data=spectral_functions) - w.create_dataset('shift', data=shifts) - w.create_dataset('half_linewidth', data=half_linewidths) - w.create_dataset('temperature', data=temperatures) + with h5py.File(full_filename, "w") as w: + w.create_dataset("version", data=np.string_(__version__)) + w.create_dataset("grid_point", data=grid_point) + w.create_dataset("mesh", data=mesh) + w.create_dataset("band_index", data=_band_indices) + w.create_dataset("spectral_function", data=spectral_functions) + w.create_dataset("shift", data=shifts) + w.create_dataset("half_linewidth", data=half_linewidths) + w.create_dataset("temperature", data=temperatures) if frequency_points is not None: - w.create_dataset('frequency_point', data=frequency_points) + w.create_dataset("frequency_point", data=frequency_points) if frequencies is not None: - w.create_dataset('frequency', data=frequencies) + w.create_dataset("frequency", data=frequencies) return full_filename -def write_collision_to_hdf5(temperature, - mesh, - gamma=None, - gamma_isotope=None, - collision_matrix=None, - grid_point=None, - band_index=None, - sigma=None, - sigma_cutoff=None, - filename=None): +def write_collision_to_hdf5( + temperature, + mesh, + gamma=None, + gamma_isotope=None, + collision_matrix=None, + grid_point=None, + band_index=None, + sigma=None, + sigma_cutoff=None, + filename=None, +): """Write collision matrix to collision-*.hdf5.""" if band_index is None: band_indices = None else: band_indices = [band_index] - suffix = _get_filename_suffix(mesh, - grid_point=grid_point, - band_indices=band_indices, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - filename=filename) + suffix = _get_filename_suffix( + mesh, + grid_point=grid_point, + band_indices=band_indices, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + filename=filename, + ) full_filename = "collision" + suffix + ".hdf5" - with h5py.File(full_filename, 'w') as w: - w.create_dataset('version', data=np.string_(__version__)) - w.create_dataset('temperature', data=temperature) + with h5py.File(full_filename, "w") as w: + w.create_dataset("version", data=np.string_(__version__)) + w.create_dataset("temperature", data=temperature) if gamma is not None: - w.create_dataset('gamma', data=gamma) + w.create_dataset("gamma", data=gamma) if gamma_isotope is not None: - w.create_dataset('gamma_isotope', data=gamma_isotope) + w.create_dataset("gamma_isotope", data=gamma_isotope) if collision_matrix is not None: - w.create_dataset('collision_matrix', data=collision_matrix) + w.create_dataset("collision_matrix", data=collision_matrix) if grid_point is not None: - w.create_dataset('grid_point', data=grid_point) + w.create_dataset("grid_point", data=grid_point) if band_index is not None: - w.create_dataset('band_index', data=(band_index + 1)) + w.create_dataset("band_index", data=(band_index + 1)) if sigma is not None: - w.create_dataset('sigma', data=sigma) + w.create_dataset("sigma", data=sigma) if sigma_cutoff is not None: - w.create_dataset('sigma_cutoff_width', data=sigma_cutoff) + w.create_dataset("sigma_cutoff_width", data=sigma_cutoff) text = "Collisions " if grid_point is not None: @@ -765,45 +791,46 @@ def write_collision_to_hdf5(temperature, text += "were written into " if sigma is not None: text += "\n" - text += "\"%s\"." % ("collision" + suffix + ".hdf5") + text += '"%s".' % ("collision" + suffix + ".hdf5") print(text) return full_filename -def write_full_collision_matrix(collision_matrix, filename='fcm.hdf5'): +def write_full_collision_matrix(collision_matrix, filename="fcm.hdf5"): """Write full (non-symmetrized) collision matrix to collision-*.hdf5.""" - with h5py.File(filename, 'w') as w: - w.create_dataset('version', data=np.string_(__version__)) - w.create_dataset('collision_matrix', data=collision_matrix) + with h5py.File(filename, "w") as w: + w.create_dataset("version", data=np.string_(__version__)) + w.create_dataset("collision_matrix", data=collision_matrix) -def write_unitary_matrix_to_hdf5(temperature, - mesh, - unitary_matrix=None, - sigma=None, - sigma_cutoff=None, - solver=None, - filename=None, - verbose=False): +def write_unitary_matrix_to_hdf5( + temperature, + mesh, + unitary_matrix=None, + sigma=None, + sigma_cutoff=None, + solver=None, + filename=None, + verbose=False, +): """Write eigenvectors of collision matrices at temperatures. Depending on the choice of the solver, eigenvectors are sotred in either column-wise or row-wise. """ - suffix = _get_filename_suffix(mesh, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - filename=filename) + suffix = _get_filename_suffix( + mesh, sigma=sigma, sigma_cutoff=sigma_cutoff, filename=filename + ) hdf5_filename = "unitary" + suffix + ".hdf5" - with h5py.File(hdf5_filename, 'w') as w: - w.create_dataset('version', data=np.string_(__version__)) - w.create_dataset('temperature', data=temperature) + with h5py.File(hdf5_filename, "w") as w: + w.create_dataset("version", data=np.string_(__version__)) + w.create_dataset("temperature", data=temperature) if unitary_matrix is not None: - w.create_dataset('unitary_matrix', data=unitary_matrix) + w.create_dataset("unitary_matrix", data=unitary_matrix) if solver is not None: - w.create_dataset('solver', data=solver) + w.create_dataset("solver", data=solver) if verbose: if len(temperature) > 1: @@ -820,26 +847,27 @@ def write_unitary_matrix_to_hdf5(temperature, text += "was written into " if sigma is not None: text += "\n" - text += "\"%s\"." % hdf5_filename + text += '"%s".' % hdf5_filename print(text) -def write_collision_eigenvalues_to_hdf5(temperatures, - mesh, - collision_eigenvalues, - sigma=None, - sigma_cutoff=None, - filename=None, - verbose=True): +def write_collision_eigenvalues_to_hdf5( + temperatures, + mesh, + collision_eigenvalues, + sigma=None, + sigma_cutoff=None, + filename=None, + verbose=True, +): """Write eigenvalues of collision matrix to coleigs-*.hdf5.""" - suffix = _get_filename_suffix(mesh, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - filename=filename) - with h5py.File("coleigs" + suffix + ".hdf5", 'w') as w: - w.create_dataset('version', data=np.string_(__version__)) - w.create_dataset('temperature', data=temperatures) - w.create_dataset('collision_eigenvalues', data=collision_eigenvalues) + suffix = _get_filename_suffix( + mesh, sigma=sigma, sigma_cutoff=sigma_cutoff, filename=filename + ) + with h5py.File("coleigs" + suffix + ".hdf5", "w") as w: + w.create_dataset("version", data=np.string_(__version__)) + w.create_dataset("temperature", data=temperatures) + w.create_dataset("collision_eigenvalues", data=collision_eigenvalues) w.close() if verbose: @@ -847,116 +875,116 @@ def write_collision_eigenvalues_to_hdf5(temperatures, if sigma is not None: text += "with sigma %s\n" % sigma text += "were written into " - text += "\"%s\"" % ("coleigs" + suffix + ".hdf5") + text += '"%s"' % ("coleigs" + suffix + ".hdf5") print(text) -def write_kappa_to_hdf5(temperature, - mesh, - frequency=None, - group_velocity=None, - gv_by_gv=None, - mean_free_path=None, - heat_capacity=None, - kappa=None, - mode_kappa=None, - kappa_RTA=None, # RTA calculated in LBTE - mode_kappa_RTA=None, # RTA calculated in LBTE - f_vector=None, - gamma=None, - gamma_isotope=None, - gamma_N=None, - gamma_U=None, - averaged_pp_interaction=None, - qpoint=None, - weight=None, - grid_point=None, - band_index=None, - sigma=None, - sigma_cutoff=None, - kappa_unit_conversion=None, - compression="gzip", - filename=None, - verbose=True): +def write_kappa_to_hdf5( + temperature, + mesh, + frequency=None, + group_velocity=None, + gv_by_gv=None, + mean_free_path=None, + heat_capacity=None, + kappa=None, + mode_kappa=None, + kappa_RTA=None, # RTA calculated in LBTE + mode_kappa_RTA=None, # RTA calculated in LBTE + f_vector=None, + gamma=None, + gamma_isotope=None, + gamma_N=None, + gamma_U=None, + averaged_pp_interaction=None, + qpoint=None, + weight=None, + grid_point=None, + band_index=None, + sigma=None, + sigma_cutoff=None, + kappa_unit_conversion=None, + compression="gzip", + filename=None, + verbose=True, +): """Write thermal conductivity related properties in kappa-*.hdf5.""" if band_index is None: band_indices = None else: band_indices = [band_index] - suffix = _get_filename_suffix(mesh, - grid_point=grid_point, - band_indices=band_indices, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - filename=filename) + 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" - with h5py.File(full_filename, 'w') as w: - w.create_dataset('version', data=np.string_(__version__)) - w.create_dataset('temperature', data=temperature) - w.create_dataset('mesh', data=mesh) + with h5py.File(full_filename, "w") as w: + w.create_dataset("version", data=np.string_(__version__)) + w.create_dataset("temperature", data=temperature) + w.create_dataset("mesh", data=mesh) if frequency is not None: if isinstance(frequency, np.floating): - w.create_dataset('frequency', data=frequency) + w.create_dataset("frequency", data=frequency) else: - w.create_dataset('frequency', data=frequency, - compression=compression) + w.create_dataset("frequency", data=frequency, compression=compression) if group_velocity is not None: - w.create_dataset('group_velocity', data=group_velocity, - compression=compression) + w.create_dataset( + "group_velocity", data=group_velocity, compression=compression + ) if gv_by_gv is not None: - w.create_dataset('gv_by_gv', data=gv_by_gv) + w.create_dataset("gv_by_gv", data=gv_by_gv) # if mean_free_path is not None: # w.create_dataset('mean_free_path', data=mean_free_path, # compression=compression) if heat_capacity is not None: - w.create_dataset('heat_capacity', data=heat_capacity, - compression=compression) + w.create_dataset( + "heat_capacity", data=heat_capacity, compression=compression + ) if kappa is not None: - w.create_dataset('kappa', data=kappa) + w.create_dataset("kappa", data=kappa) if mode_kappa is not None: - w.create_dataset('mode_kappa', data=mode_kappa, - compression=compression) + w.create_dataset("mode_kappa", data=mode_kappa, compression=compression) if kappa_RTA is not None: - w.create_dataset('kappa_RTA', data=kappa_RTA) + w.create_dataset("kappa_RTA", data=kappa_RTA) if mode_kappa_RTA is not None: - w.create_dataset('mode_kappa_RTA', data=mode_kappa_RTA, - compression=compression) + w.create_dataset( + "mode_kappa_RTA", data=mode_kappa_RTA, compression=compression + ) if f_vector is not None: - w.create_dataset('f_vector', data=f_vector, - compression=compression) + w.create_dataset("f_vector", data=f_vector, compression=compression) if gamma is not None: - w.create_dataset('gamma', data=gamma, - compression=compression) + w.create_dataset("gamma", data=gamma, compression=compression) if gamma_isotope is not None: - w.create_dataset('gamma_isotope', data=gamma_isotope, - compression=compression) + w.create_dataset( + "gamma_isotope", data=gamma_isotope, compression=compression + ) if gamma_N is not None: - w.create_dataset('gamma_N', data=gamma_N, - compression=compression) + w.create_dataset("gamma_N", data=gamma_N, compression=compression) if gamma_U is not None: - w.create_dataset('gamma_U', data=gamma_U, - compression=compression) + w.create_dataset("gamma_U", data=gamma_U, compression=compression) if averaged_pp_interaction is not None: - w.create_dataset('ave_pp', data=averaged_pp_interaction, - compression=compression) + w.create_dataset( + "ave_pp", data=averaged_pp_interaction, compression=compression + ) if qpoint is not None: - w.create_dataset('qpoint', data=qpoint, - compression=compression) + w.create_dataset("qpoint", data=qpoint, compression=compression) if weight is not None: - w.create_dataset('weight', data=weight, - compression=compression) + w.create_dataset("weight", data=weight, compression=compression) if grid_point is not None: - w.create_dataset('grid_point', data=grid_point) + w.create_dataset("grid_point", data=grid_point) if band_index is not None: - w.create_dataset('band_index', data=(band_index + 1)) + w.create_dataset("band_index", data=(band_index + 1)) if sigma is not None: - w.create_dataset('sigma', data=sigma) + w.create_dataset("sigma", data=sigma) if sigma_cutoff is not None: - w.create_dataset('sigma_cutoff_width', data=sigma_cutoff) + 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) + w.create_dataset("kappa_unit_conversion", data=kappa_unit_conversion) if verbose: text = "" @@ -983,30 +1011,34 @@ def write_kappa_to_hdf5(temperature, text += "were written into " if band_index is None: text += "\n" - text += "\"%s\"." % full_filename + text += '"%s".' % full_filename print(text) return full_filename -def read_gamma_from_hdf5(mesh, - grid_point=None, - band_index=None, - sigma=None, - sigma_cutoff=None, - filename=None, - verbose=True): +def read_gamma_from_hdf5( + mesh, + grid_point=None, + band_index=None, + sigma=None, + sigma_cutoff=None, + filename=None, + verbose=True, +): """Read gamma from kappa-*.hdf5 file.""" if band_index is None: band_indices = None else: band_indices = [band_index] - suffix = _get_filename_suffix(mesh, - grid_point=grid_point, - band_indices=band_indices, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - filename=filename) + 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" if not os.path.exists(full_filename): if verbose: @@ -1015,12 +1047,9 @@ def read_gamma_from_hdf5(mesh, read_data = {} - with h5py.File(full_filename, 'r') as f: - read_data['gamma'] = f['gamma'][:] - for key in ('gamma_isotope', - 'ave_pp', - 'gamma_N', - 'gamma_U'): + with h5py.File(full_filename, "r") as f: + read_data["gamma"] = f["gamma"][:] + for key in ("gamma_isotope", "ave_pp", "gamma_N", "gamma_U"): if key in f.keys(): if len(f[key].shape) > 0: read_data[key] = f[key][:] @@ -1032,45 +1061,48 @@ def read_gamma_from_hdf5(mesh, return read_data -def read_collision_from_hdf5(mesh, - indices=None, - grid_point=None, - band_index=None, - sigma=None, - sigma_cutoff=None, - filename=None, - verbose=True): +def read_collision_from_hdf5( + mesh, + indices=None, + grid_point=None, + band_index=None, + sigma=None, + sigma_cutoff=None, + filename=None, + verbose=True, +): """Read colliction matrix.""" if band_index is None: band_indices = None else: band_indices = [band_index] - suffix = _get_filename_suffix(mesh, - grid_point=grid_point, - band_indices=band_indices, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - filename=filename) + suffix = _get_filename_suffix( + mesh, + grid_point=grid_point, + band_indices=band_indices, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + filename=filename, + ) full_filename = "collision" + suffix + ".hdf5" if not os.path.exists(full_filename): if verbose: print("%s not found." % full_filename) return None - with h5py.File(full_filename, 'r') as f: - if indices == 'all': - colmat_shape = (1,) + f['collision_matrix'].shape - collision_matrix = np.zeros(colmat_shape, - dtype='double', order='C') - gamma = np.array(f['gamma'][:], dtype='double', order='C') - collision_matrix[0] = f['collision_matrix'][:] - temperatures = np.array(f['temperature'][:], dtype='double') + with h5py.File(full_filename, "r") as f: + if indices == "all": + colmat_shape = (1,) + f["collision_matrix"].shape + collision_matrix = np.zeros(colmat_shape, dtype="double", order="C") + gamma = np.array(f["gamma"][:], dtype="double", order="C") + collision_matrix[0] = f["collision_matrix"][:] + temperatures = np.array(f["temperature"][:], dtype="double") else: - colmat_shape = (1, len(indices)) + f['collision_matrix'].shape[1:] - collision_matrix = np.zeros(colmat_shape, dtype='double') - gamma = np.array(f['gamma'][indices], dtype='double', order='C') - collision_matrix[0] = f['collision_matrix'][indices] - temperatures = np.array(f['temperature'][indices], dtype='double') + colmat_shape = (1, len(indices)) + f["collision_matrix"].shape[1:] + collision_matrix = np.zeros(colmat_shape, dtype="double") + gamma = np.array(f["gamma"][indices], dtype="double", order="C") + collision_matrix[0] = f["collision_matrix"][indices] + temperatures = np.array(f["temperature"][indices], dtype="double") if verbose: text = "Collisions " @@ -1079,8 +1111,10 @@ def read_collision_from_hdf5(mesh, text += "at grid point %d " % grid_point else: if grid_point is not None: - text += ("at (grid point %d, band index %d) " % - (grid_point, band_index)) + text += "at (grid point %d, band index %d) " % ( + grid_point, + band_index, + ) if sigma is not None: if grid_point is not None: text += "and " @@ -1095,7 +1129,7 @@ def read_collision_from_hdf5(mesh, else: text += "\n" text += "were read from " - text += "\"%s\"." % full_filename + text += '"%s".' % full_filename print(text) return collision_matrix, gamma, temperatures @@ -1103,72 +1137,70 @@ def read_collision_from_hdf5(mesh, return None -def write_pp_to_hdf5(mesh, - pp=None, - g_zero=None, - grid_point=None, - triplet=None, - weight=None, - triplet_map=None, - triplet_all=None, - sigma=None, - sigma_cutoff=None, - filename=None, - verbose=True, - check_consistency=False, - compression="gzip"): +def write_pp_to_hdf5( + mesh, + pp=None, + g_zero=None, + grid_point=None, + triplet=None, + weight=None, + triplet_map=None, + triplet_all=None, + sigma=None, + sigma_cutoff=None, + filename=None, + verbose=True, + check_consistency=False, + compression="gzip", +): """Write ph-ph interaction strength in its hdf5 file.""" - suffix = _get_filename_suffix(mesh, - grid_point=grid_point, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - filename=filename) + suffix = _get_filename_suffix( + mesh, + grid_point=grid_point, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + filename=filename, + ) full_filename = "pp" + suffix + ".hdf5" - with h5py.File(full_filename, 'w') as w: - w.create_dataset('version', data=np.string_(__version__)) + with h5py.File(full_filename, "w") as w: + w.create_dataset("version", data=np.string_(__version__)) if pp is not None: if g_zero is None: - w.create_dataset('pp', data=pp, - compression=compression) + w.create_dataset("pp", data=pp, compression=compression) if triplet is not None: - w.create_dataset('triplet', data=triplet, - compression=compression) + w.create_dataset("triplet", data=triplet, compression=compression) if weight is not None: - w.create_dataset('weight', data=weight, - compression=compression) + w.create_dataset("weight", data=weight, compression=compression) if triplet_map is not None: - w.create_dataset('triplet_map', data=triplet_map, - compression=compression) + w.create_dataset( + "triplet_map", data=triplet_map, compression=compression + ) if triplet_all is not None: - w.create_dataset('triplet_all', data=triplet_all, - compression=compression) + w.create_dataset( + "triplet_all", data=triplet_all, compression=compression + ) else: x = g_zero.ravel() - nonzero_pp = np.array(pp.ravel()[x == 0], dtype='double') + nonzero_pp = np.array(pp.ravel()[x == 0], dtype="double") bytelen = len(x) // 8 remlen = len(x) % 8 - y = x[:bytelen * 8].reshape(-1, 8) + y = x[: bytelen * 8].reshape(-1, 8) z = np.packbits(y) if remlen != 0: - z_rem = np.packbits(x[bytelen * 8:]) + z_rem = np.packbits(x[bytelen * 8 :]) # No compression for pp because already almost random. - w.create_dataset('nonzero_pp', data=nonzero_pp, - compression=None) - w.create_dataset('pp_shape', data=pp.shape, - compression=compression) - w.create_dataset('g_zero_bits', data=z, - compression=compression) + w.create_dataset("nonzero_pp", data=nonzero_pp, compression=None) + w.create_dataset("pp_shape", data=pp.shape, compression=compression) + w.create_dataset("g_zero_bits", data=z, compression=compression) if remlen != 0: - w.create_dataset('g_zero_bits_reminder', data=z_rem) + w.create_dataset("g_zero_bits_reminder", data=z_rem) # This is only for the test and coupled with read_pp_from_hdf5. if check_consistency: - w.create_dataset('pp', data=pp, - compression=compression) - w.create_dataset('g_zero', data=g_zero, - compression=compression) + w.create_dataset("pp", data=pp, compression=compression) + w.create_dataset("g_zero", data=g_zero, compression=compression) if verbose: text = "" @@ -1189,134 +1221,135 @@ def write_pp_to_hdf5(mesh, else: text += "were written into " text += "\n" - text += "\"%s\"." % full_filename + text += '"%s".' % full_filename print(text) return full_filename -def read_pp_from_hdf5(mesh, - grid_point=None, - sigma=None, - sigma_cutoff=None, - filename=None, - verbose=True, - check_consistency=False): +def read_pp_from_hdf5( + mesh, + grid_point=None, + sigma=None, + sigma_cutoff=None, + filename=None, + verbose=True, + check_consistency=False, +): """Read ph-ph interaction strength from its hdf5 file.""" - suffix = _get_filename_suffix(mesh, - grid_point=grid_point, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - filename=filename) + suffix = _get_filename_suffix( + mesh, + grid_point=grid_point, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + filename=filename, + ) full_filename = "pp" + suffix + ".hdf5" if not os.path.exists(full_filename): if verbose: print("%s not found." % full_filename) return None - with h5py.File(full_filename, 'r') as f: - if 'nonzero_pp' in f: - nonzero_pp = f['nonzero_pp'][:] - pp_shape = f['pp_shape'][:] - z = f['g_zero_bits'][:] + with h5py.File(full_filename, "r") as f: + if "nonzero_pp" in f: + nonzero_pp = f["nonzero_pp"][:] + pp_shape = f["pp_shape"][:] + z = f["g_zero_bits"][:] bytelen = np.prod(pp_shape) // 8 remlen = 0 - if 'g_zero_bits_reminder' in f: - z_rem = f['g_zero_bits_reminder'][:] + if "g_zero_bits_reminder" in f: + z_rem = f["g_zero_bits_reminder"][:] remlen = np.prod(pp_shape) - bytelen * 8 bits = np.unpackbits(z) - if not bits.flags['C_CONTIGUOUS']: - bits = np.array(bits, dtype='uint8') + if not bits.flags["C_CONTIGUOUS"]: + bits = np.array(bits, dtype="uint8") - g_zero = np.zeros(pp_shape, dtype='byte', order='C') + g_zero = np.zeros(pp_shape, dtype="byte", order="C") b = g_zero.ravel() - b[:(bytelen * 8)] = bits + b[: (bytelen * 8)] = bits if remlen != 0: b[-remlen:] = np.unpackbits(z_rem)[:remlen] - pp = np.zeros(pp_shape, dtype='double', order='C') + pp = np.zeros(pp_shape, dtype="double", order="C") pp_ravel = pp.ravel() pp_ravel[g_zero.ravel() == 0] = nonzero_pp # check_consistency==True in write_pp_to_hdf5 required. if check_consistency and g_zero is not None: if verbose: - print("Checking consistency of ph-ph interanction " - "strength.") - assert (g_zero == f['g_zero'][:]).all() - assert np.allclose(pp, f['pp'][:]) + print("Checking consistency of ph-ph interanction " "strength.") + assert (g_zero == f["g_zero"][:]).all() + assert np.allclose(pp, f["pp"][:]) else: - pp = np.zeros(f['pp'].shape, dtype='double', order='C') - pp[:] = f['pp'][:] + pp = np.zeros(f["pp"].shape, dtype="double", order="C") + pp[:] = f["pp"][:] g_zero = None if verbose: - print("Ph-ph interaction strength was read from \"%s\"." % - full_filename) + print('Ph-ph interaction strength was read from "%s".' % full_filename) return pp, g_zero return None -def write_gamma_detail_to_hdf5(temperature, - mesh, - gamma_detail=None, - grid_point=None, - triplet=None, - weight=None, - triplet_map=None, - triplet_all=None, - frequency_points=None, - band_index=None, - sigma=None, - sigma_cutoff=None, - compression="gzip", - filename=None, - verbose=True): +def write_gamma_detail_to_hdf5( + temperature, + mesh, + gamma_detail=None, + grid_point=None, + triplet=None, + weight=None, + triplet_map=None, + triplet_all=None, + frequency_points=None, + band_index=None, + sigma=None, + sigma_cutoff=None, + compression="gzip", + filename=None, + verbose=True, +): """Write detailed gamma in its hdf5 file.""" if band_index is None: band_indices = None else: band_indices = [band_index] - suffix = _get_filename_suffix(mesh, - grid_point=grid_point, - band_indices=band_indices, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - filename=filename) + suffix = _get_filename_suffix( + mesh, + grid_point=grid_point, + band_indices=band_indices, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + filename=filename, + ) full_filename = "gamma_detail" + suffix + ".hdf5" - with h5py.File(full_filename, 'w') as w: - w.create_dataset('version', data=np.string_(__version__)) - w.create_dataset('temperature', data=temperature) - w.create_dataset('mesh', data=mesh) + with h5py.File(full_filename, "w") as w: + w.create_dataset("version", data=np.string_(__version__)) + w.create_dataset("temperature", data=temperature) + w.create_dataset("mesh", data=mesh) if gamma_detail is not None: - w.create_dataset('gamma_detail', data=gamma_detail, - compression=compression) + w.create_dataset("gamma_detail", data=gamma_detail, compression=compression) if triplet is not None: - w.create_dataset('triplet', data=triplet, - compression=compression) + w.create_dataset("triplet", data=triplet, compression=compression) if weight is not None: - w.create_dataset('weight', data=weight, - compression=compression) + w.create_dataset("weight", data=weight, compression=compression) if triplet_map is not None: - w.create_dataset('triplet_map', data=triplet_map, - compression=compression) + w.create_dataset("triplet_map", data=triplet_map, compression=compression) if triplet_all is not None: - w.create_dataset('triplet_all', data=triplet_all, - compression=compression) + w.create_dataset("triplet_all", data=triplet_all, compression=compression) if grid_point is not None: - w.create_dataset('grid_point', data=grid_point) + w.create_dataset("grid_point", data=grid_point) if band_index is not None: - w.create_dataset('band_index', data=(band_index + 1)) + w.create_dataset("band_index", data=(band_index + 1)) if sigma is not None: - w.create_dataset('sigma', data=sigma) + w.create_dataset("sigma", data=sigma) if sigma_cutoff is not None: - w.create_dataset('sigma_cutoff_width', data=sigma_cutoff) + w.create_dataset("sigma_cutoff_width", data=sigma_cutoff) if frequency_points is not None: - w.create_dataset('frequency_point', data=frequency_points) + w.create_dataset("frequency_point", data=frequency_points) if verbose: text = "" @@ -1340,7 +1373,7 @@ def write_gamma_detail_to_hdf5(temperature, text += "were written into " if band_index is None: text += "\n" - text += "\"%s\"." % full_filename + text += '"%s".' % full_filename print(text) return full_filename @@ -1348,33 +1381,25 @@ def write_gamma_detail_to_hdf5(temperature, return None -def write_phonon_to_hdf5(frequency, - eigenvector, - grid_address, - mesh, - compression="gzip", - filename=None): +def write_phonon_to_hdf5( + frequency, eigenvector, grid_address, mesh, compression="gzip", filename=None +): """Write phonon on grid in its hdf5 file.""" suffix = _get_filename_suffix(mesh, filename=filename) full_filename = "phonon" + suffix + ".hdf5" - with h5py.File(full_filename, 'w') as w: - w.create_dataset('version', data=np.string_(__version__)) - w.create_dataset('mesh', data=mesh) - w.create_dataset('grid_address', data=grid_address, - compression=compression) - w.create_dataset('frequency', data=frequency, - compression=compression) - w.create_dataset('eigenvector', data=eigenvector, - compression=compression) + with h5py.File(full_filename, "w") as w: + w.create_dataset("version", data=np.string_(__version__)) + w.create_dataset("mesh", data=mesh) + w.create_dataset("grid_address", data=grid_address, compression=compression) + w.create_dataset("frequency", data=frequency, compression=compression) + w.create_dataset("eigenvector", data=eigenvector, compression=compression) return full_filename return None -def read_phonon_from_hdf5(mesh, - filename=None, - verbose=True): +def read_phonon_from_hdf5(mesh, filename=None, verbose=True): """Read phonon from its hdf5 file.""" suffix = _get_filename_suffix(mesh, filename=filename) full_filename = "phonon" + suffix + ".hdf5" @@ -1383,52 +1408,49 @@ def read_phonon_from_hdf5(mesh, print("%s not found." % full_filename) return None - with h5py.File(full_filename, 'r') as f: - frequencies = np.array(f['frequency'][:], dtype='double', order='C') + with h5py.File(full_filename, "r") as f: + frequencies = np.array(f["frequency"][:], dtype="double", order="C") itemsize = frequencies.itemsize - eigenvectors = np.array(f['eigenvector'][:], - dtype=("c%d" % (itemsize * 2)), order='C') - mesh_in_file = np.array(f['mesh'][:], dtype='intc') - grid_address = np.array(f['grid_address'][:], dtype='intc', order='C') + eigenvectors = np.array( + f["eigenvector"][:], dtype=("c%d" % (itemsize * 2)), order="C" + ) + mesh_in_file = np.array(f["mesh"][:], dtype="intc") + grid_address = np.array(f["grid_address"][:], dtype="intc", order="C") assert (mesh_in_file == mesh).all(), "Mesh numbers are inconsistent." if verbose: - print("Phonons are read from \"%s\"." % full_filename) + print('Phonons are read from "%s".' % full_filename) return frequencies, eigenvectors, grid_address return None -def write_ir_grid_points(bz_grid, - grid_points, - grid_weights, - primitive_lattice): +def write_ir_grid_points(bz_grid, grid_points, grid_weights, primitive_lattice): """Write ir-grid-points in yaml.""" lines = [] lines.append("mesh: [ %d, %d, %d ]" % tuple(bz_grid.D_diag)) lines.append("reciprocal_lattice:") - for vec, axis in zip(primitive_lattice.T, ('a*', 'b*', 'c*')): - lines.append("- [ %12.8f, %12.8f, %12.8f ] # %2s" - % (tuple(vec) + (axis,))) + for vec, axis in zip(primitive_lattice.T, ("a*", "b*", "c*")): + lines.append("- [ %12.8f, %12.8f, %12.8f ] # %2s" % (tuple(vec) + (axis,))) lines.append("microzone_lattice:") - for vec, axis in zip(bz_grid.microzone_lattice.T, ('a*', 'b*', 'c*')): - lines.append("- [ %12.8f, %12.8f, %12.8f ] # %2s" - % (tuple(vec) + (axis,))) + for vec, axis in zip(bz_grid.microzone_lattice.T, ("a*", "b*", "c*")): + lines.append("- [ %12.8f, %12.8f, %12.8f ] # %2s" % (tuple(vec) + (axis,))) lines.append("num_reduced_ir_grid_points: %d" % len(grid_points)) lines.append("ir_grid_points: # [address, weight]") for g, weight in zip(grid_points, grid_weights): lines.append("- grid_point: %d" % g) lines.append(" weight: %d" % weight) - lines.append(" grid_address: [ %12d, %12d, %12d ]" % - tuple(bz_grid.addresses[g])) + lines.append( + " grid_address: [ %12d, %12d, %12d ]" % tuple(bz_grid.addresses[g]) + ) q = np.dot(bz_grid.addresses[g], bz_grid.QDinv.T) lines.append(" q-point: [ %12.7f, %12.7f, %12.7f ]" % tuple(q)) lines.append("") - with open("ir_grid_points.yaml", 'w') as w: + with open("ir_grid_points.yaml", "w") as w: w.write("\n".join(lines)) @@ -1438,20 +1460,19 @@ def parse_disp_fc2_yaml(filename="disp_fc2.yaml", return_cell=False): This is obsolete at v2 and later versions. """ - warnings.warn("parse_disp_fc2_yaml() is deprecated.", - DeprecationWarning) + warnings.warn("parse_disp_fc2_yaml() is deprecated.", DeprecationWarning) dataset = _parse_yaml(filename) - natom = dataset['natom'] + natom = dataset["natom"] new_dataset = {} - new_dataset['natom'] = natom + new_dataset["natom"] = natom new_first_atoms = [] - for first_atoms in dataset['first_atoms']: - first_atoms['number'] -= 1 - atom1 = first_atoms['number'] - disp1 = first_atoms['displacement'] - new_first_atoms.append({'number': atom1, 'displacement': disp1}) - new_dataset['first_atoms'] = new_first_atoms + for first_atoms in dataset["first_atoms"]: + first_atoms["number"] -= 1 + atom1 = first_atoms["number"] + disp1 = first_atoms["displacement"] + new_first_atoms.append({"number": atom1, "displacement": disp1}) + new_dataset["first_atoms"] = new_first_atoms if return_cell: cell = get_cell_from_disp_yaml(dataset) @@ -1466,34 +1487,32 @@ def parse_disp_fc3_yaml(filename="disp_fc3.yaml", return_cell=False): This is obsolete at v2 and later versions. """ - warnings.warn("parse_disp_fc3_yaml() is deprecated.", - DeprecationWarning) + warnings.warn("parse_disp_fc3_yaml() is deprecated.", DeprecationWarning) dataset = _parse_yaml(filename) - natom = dataset['natom'] + natom = dataset["natom"] new_dataset = {} - new_dataset['natom'] = natom - if 'cutoff_distance' in dataset: - new_dataset['cutoff_distance'] = dataset['cutoff_distance'] + new_dataset["natom"] = natom + if "cutoff_distance" in dataset: + new_dataset["cutoff_distance"] = dataset["cutoff_distance"] new_first_atoms = [] - for first_atoms in dataset['first_atoms']: - atom1 = first_atoms['number'] - 1 - disp1 = first_atoms['displacement'] + for first_atoms in dataset["first_atoms"]: + atom1 = first_atoms["number"] - 1 + disp1 = first_atoms["displacement"] new_second_atoms = [] - for second_atom in first_atoms['second_atoms']: - disp2_dataset = {'number': second_atom['number'] - 1} - if 'included' in second_atom: - disp2_dataset.update({'included': second_atom['included']}) - if 'distance' in second_atom: - disp2_dataset.update( - {'pair_distance': second_atom['distance']}) - for disp2 in second_atom['displacements']: - disp2_dataset.update({'displacement': disp2}) + for second_atom in first_atoms["second_atoms"]: + disp2_dataset = {"number": second_atom["number"] - 1} + if "included" in second_atom: + disp2_dataset.update({"included": second_atom["included"]}) + if "distance" in second_atom: + disp2_dataset.update({"pair_distance": second_atom["distance"]}) + for disp2 in second_atom["displacements"]: + disp2_dataset.update({"displacement": disp2}) new_second_atoms.append(disp2_dataset.copy()) - new_first_atoms.append({'number': atom1, - 'displacement': disp1, - 'second_atoms': new_second_atoms}) - new_dataset['first_atoms'] = new_first_atoms + new_first_atoms.append( + {"number": atom1, "displacement": disp1, "second_atoms": new_second_atoms} + ) + new_dataset["first_atoms"] = new_first_atoms if return_cell: cell = get_cell_from_disp_yaml(dataset) @@ -1502,14 +1521,12 @@ def parse_disp_fc3_yaml(filename="disp_fc3.yaml", return_cell=False): return new_dataset -def parse_FORCES_FC2(disp_dataset, - filename="FORCES_FC2", - unit_conversion_factor=None): +def parse_FORCES_FC2(disp_dataset, filename="FORCES_FC2", unit_conversion_factor=None): """Parse type1 FORCES_FC2 file and store forces in disp_dataset.""" - num_atom = disp_dataset['natom'] - num_disp = len(disp_dataset['first_atoms']) + num_atom = disp_dataset["natom"] + num_disp = len(disp_dataset["first_atoms"]) forces_fc2 = [] - with open(filename, 'r') as f2: + with open(filename, "r") as f2: for i in range(num_disp): forces = _parse_force_lines(f2, num_atom) if forces is None: @@ -1517,29 +1534,27 @@ def parse_FORCES_FC2(disp_dataset, else: forces_fc2.append(forces) - for i, disp1 in enumerate(disp_dataset['first_atoms']): + for i, disp1 in enumerate(disp_dataset["first_atoms"]): if unit_conversion_factor is not None: - disp1['forces'] = forces_fc2[i] * unit_conversion_factor + disp1["forces"] = forces_fc2[i] * unit_conversion_factor else: - disp1['forces'] = forces_fc2[i] + disp1["forces"] = forces_fc2[i] -def parse_FORCES_FC3(disp_dataset, - filename="FORCES_FC3", - use_loadtxt=False, - unit_conversion_factor=None): +def parse_FORCES_FC3( + disp_dataset, filename="FORCES_FC3", use_loadtxt=False, unit_conversion_factor=None +): """Parse type1 FORCES_FC3 and store forces in disp_dataset.""" - num_atom = disp_dataset['natom'] - num_disp = len(disp_dataset['first_atoms']) - for disp1 in disp_dataset['first_atoms']: - num_disp += len(disp1['second_atoms']) + num_atom = disp_dataset["natom"] + num_disp = len(disp_dataset["first_atoms"]) + for disp1 in disp_dataset["first_atoms"]: + num_disp += len(disp1["second_atoms"]) if use_loadtxt: forces_fc3 = np.loadtxt(filename).reshape((num_disp, -1, 3)) else: - forces_fc3 = np.zeros((num_disp, num_atom, 3), - dtype='double', order='C') - with open(filename, 'r') as f3: + forces_fc3 = np.zeros((num_disp, num_atom, 3), dtype="double", order="C") + with open(filename, "r") as f3: for i in range(num_disp): forces = _parse_force_lines(f3, num_atom) if forces is None: @@ -1551,31 +1566,35 @@ def parse_FORCES_FC3(disp_dataset, forces_fc3 *= unit_conversion_factor i = 0 - for disp1 in disp_dataset['first_atoms']: - disp1['forces'] = forces_fc3[i] + for disp1 in disp_dataset["first_atoms"]: + disp1["forces"] = forces_fc3[i] i += 1 - for disp1 in disp_dataset['first_atoms']: - for disp2 in disp1['second_atoms']: - disp2['forces'] = forces_fc3[i] + for disp1 in disp_dataset["first_atoms"]: + for disp2 in disp1["second_atoms"]: + disp2["forces"] = forces_fc3[i] i += 1 -def get_filename_suffix(mesh, - grid_point=None, - band_indices=None, - sigma=None, - sigma_cutoff=None, - temperature=None, - filename=None): +def get_filename_suffix( + mesh, + grid_point=None, + band_indices=None, + sigma=None, + sigma_cutoff=None, + temperature=None, + filename=None, +): """Return filename suffix corresponding to parameters.""" - return _get_filename_suffix(mesh, - grid_point=grid_point, - band_indices=band_indices, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - temperature=temperature, - filename=filename) + return _get_filename_suffix( + mesh, + grid_point=grid_point, + band_indices=band_indices, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + temperature=temperature, + filename=filename, + ) def get_length_of_first_line(f): @@ -1586,9 +1605,9 @@ def get_length_of_first_line(f): """ for line in f: - if line.strip() == '': + if line.strip() == "": continue - elif line.strip()[0] == '#': + elif line.strip()[0] == "#": continue else: f.seek(0) @@ -1597,17 +1616,19 @@ def get_length_of_first_line(f): raise RuntimeError("File doesn't contain relevant infomration.") -def _get_filename_suffix(mesh, - grid_point=None, - band_indices=None, - sigma=None, - sigma_cutoff=None, - temperature=None, - filename=None): +def _get_filename_suffix( + mesh, + grid_point=None, + band_indices=None, + sigma=None, + sigma_cutoff=None, + temperature=None, + filename=None, +): """Return filename suffix corresponding to parameters.""" suffix = "-m%d%d%d" % tuple(mesh) if grid_point is not None: - suffix += ("-g%d" % grid_point) + suffix += "-g%d" % grid_point if band_indices is not None: suffix += "-" for bi in band_indices: @@ -1627,7 +1648,7 @@ def _get_filename_suffix(mesh, def _del_zeros(val): """Remove trailing zeros after decimal point.""" - return ("%f" % val).rstrip('0').rstrip(r'\.') + return ("%f" % val).rstrip("0").rstrip(r"\.") def _parse_yaml(file_yaml): @@ -1637,15 +1658,14 @@ def _parse_yaml(file_yaml): So this is obsolete at v2 and later versions. """ - warnings.warn("_parse_yaml() is deprecated.", - DeprecationWarning) + warnings.warn("_parse_yaml() is deprecated.", DeprecationWarning) import yaml + try: from yaml import CLoader as Loader - from yaml import CDumper as Dumper except ImportError: - from yaml import Loader, Dumper + from yaml import Loader with open(file_yaml) as f: string = f.read() @@ -1656,9 +1676,9 @@ def _parse_yaml(file_yaml): def _parse_force_lines(forcefile, num_atom): forces = [] for line in forcefile: - if line.strip() == '': + if line.strip() == "": continue - if line.strip()[0] == '#': + if line.strip()[0] == "#": continue forces.append([float(x) for x in line.strip().split()]) if len(forces) == num_atom: diff --git a/phono3py/interface/__init__.py b/phono3py/interface/__init__.py index e69de29b..857b8148 100644 --- a/phono3py/interface/__init__.py +++ b/phono3py/interface/__init__.py @@ -0,0 +1 @@ +"""Interfaces to routines and data structures.""" diff --git a/phono3py/interface/alm.py b/phono3py/interface/alm.py index 26c8a408..804b8702 100644 --- a/phono3py/interface/alm.py +++ b/phono3py/interface/alm.py @@ -1,3 +1,4 @@ +"""ALM interface for force constants calculation.""" # Copyright (C) 2016 Atsushi Togo # All rights reserved. # @@ -32,50 +33,26 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -import numpy as np from phonopy.interface.alm import run_alm -def get_fc3(supercell, - primitive, - displacements, - forces, - options=None, - is_compact_fc=False, - log_level=0): - return run_alm(supercell, - primitive, - displacements, - forces, - 2, - is_compact_fc=is_compact_fc, - options=options, - log_level=log_level) - - -def _extract_fc3_from_alm(alm, - natom, - is_compact_fc, - p2s_map=None, - p2p_map=None): - p2s_map_alm = alm.getmap_primitive_to_supercell()[0] - if (p2s_map is not None and - len(p2s_map_alm) == len(p2s_map) and - (p2s_map_alm == p2s_map).all()): - fc3 = np.zeros((len(p2s_map), natom, natom, 3, 3, 3), - dtype='double', order='C') - for (fc, indices) in zip(*alm.get_fc(2, mode='origin')): - v1, v2, v3 = indices // 3 - c1, c2, c3 = indices % 3 - fc3[p2p_map[v1], v2, v3, c1, c2, c3] = fc - fc3[p2p_map[v1], v3, v2, c1, c3, c2] = fc - else: - fc3 = np.zeros((natom, natom, natom, 3, 3, 3), - dtype='double', order='C') - for (fc, indices) in zip(*alm.get_fc(2, mode='all')): - v1, v2, v3 = indices // 3 - c1, c2, c3 = indices % 3 - fc3[v1, v2, v3, c1, c2, c3] = fc - fc3[v1, v3, v2, c1, c3, c2] = fc - - return fc3 +def get_fc3( + supercell, + primitive, + displacements, + forces, + options=None, + is_compact_fc=False, + log_level=0, +): + """Calculate fc3 using ALM.""" + return run_alm( + supercell, + primitive, + displacements, + forces, + 2, + is_compact_fc=is_compact_fc, + options=options, + log_level=log_level, + ) diff --git a/phono3py/interface/calculator.py b/phono3py/interface/calculator.py index 4bdffc64..a62da670 100644 --- a/phono3py/interface/calculator.py +++ b/phono3py/interface/calculator.py @@ -34,35 +34,30 @@ calculator_info = { - 'abinit': {'option': {'name': "--abinit", - 'help': "Invoke Abinit mode"}}, + "abinit": {"option": {"name": "--abinit", "help": "Invoke Abinit mode"}}, # 'aims': {'option': {'name': "--aims", # 'help': "Invoke FHI-aims mode"}}, # 'cp2k': {'option': {'name': "--cp2k", # 'help': "Invoke CP2K mode"}}, - 'crystal': {'option': {'name': "--crystal", - 'help': "Invoke CRYSTAL mode"}}, + "crystal": {"option": {"name": "--crystal", "help": "Invoke CRYSTAL mode"}}, # 'dftbp': {'option': {'name': "--dftb+", # 'help': "Invoke dftb+ mode"}}, # 'elk': {'option': {'name': "--elk", # 'help': "Invoke elk mode"}}, - 'qe': {'option': {'name': "--qe", - 'help': "Invoke Quantum espresso (QE) mode"}}, + "qe": {"option": {"name": "--qe", "help": "Invoke Quantum espresso (QE) mode"}}, # 'siesta': {'option': {'name': "--siesta", # 'help': "Invoke Siesta mode"}}, - 'turbomole': {'option': {'name': "--turbomole", - 'help': "Invoke TURBOMOLE mode"}}, - 'vasp': {'option': {'name': "--vasp", - 'help': "Invoke Vasp mode"}}, + "turbomole": {"option": {"name": "--turbomole", "help": "Invoke TURBOMOLE mode"}}, + "vasp": {"option": {"name": "--vasp", "help": "Invoke Vasp mode"}}, # 'wien2k': {'option': {'name': "--wien2k", # 'help': "Invoke Wien2k mode"}}, } def get_default_displacement_distance(interface_mode): - if interface_mode in ('qe', 'abinit', 'turbomole'): + if interface_mode in ("qe", "abinit", "turbomole"): displacement_distance = 0.06 - elif interface_mode == 'crystal': + elif interface_mode == "crystal": displacement_distance = 0.03 else: displacement_distance = 0.03 @@ -71,25 +66,26 @@ def get_default_displacement_distance(interface_mode): def get_additional_info_to_write_supercells(interface_mode, supercell_matrix): additional_info = {} - if interface_mode == 'crystal': - additional_info['template_file'] = "TEMPLATE3" - additional_info['supercell_matrix'] = supercell_matrix + if interface_mode == "crystal": + additional_info["template_file"] = "TEMPLATE3" + additional_info["supercell_matrix"] = supercell_matrix return additional_info -def get_additional_info_to_write_fc2_supercells(interface_mode, - phonon_supercell_matrix): +def get_additional_info_to_write_fc2_supercells( + interface_mode, phonon_supercell_matrix +): additional_info = {} - if interface_mode == 'qe': - additional_info['pre_filename'] = "supercell_fc2" - elif interface_mode == 'crystal': - additional_info['template_file'] = "TEMPLATE" - additional_info['pre_filename'] = "supercell_fc2" - additional_info['supercell_matrix'] = phonon_supercell_matrix - elif interface_mode == 'abinit': - additional_info['pre_filename'] = "supercell_fc2" - elif interface_mode == 'turbomole': - additional_info['pre_filename'] = "supercell_fc2" + if interface_mode == "qe": + additional_info["pre_filename"] = "supercell_fc2" + elif interface_mode == "crystal": + additional_info["template_file"] = "TEMPLATE" + additional_info["pre_filename"] = "supercell_fc2" + additional_info["supercell_matrix"] = phonon_supercell_matrix + elif interface_mode == "abinit": + additional_info["pre_filename"] = "supercell_fc2" + elif interface_mode == "turbomole": + additional_info["pre_filename"] = "supercell_fc2" else: - additional_info['pre_filename'] = "POSCAR_FC2" + additional_info["pre_filename"] = "POSCAR_FC2" return additional_info diff --git a/phono3py/interface/fc_calculator.py b/phono3py/interface/fc_calculator.py index cbc68f5d..8bfeff7f 100644 --- a/phono3py/interface/fc_calculator.py +++ b/phono3py/interface/fc_calculator.py @@ -33,14 +33,16 @@ # POSSIBILITY OF SUCH DAMAGE. -def get_fc3(supercell, - primitive, - displacements, - forces, - fc_calculator=None, - fc_calculator_options=None, - is_compact_fc=False, - log_level=0): +def get_fc3( + supercell, + primitive, + displacements, + forces, + fc_calculator=None, + fc_calculator_options=None, + is_compact_fc=False, + log_level=0, +): """Supercell 2nd order force constants (fc2) are calculated. The expected shape of supercell fc3 to be returned is @@ -82,16 +84,18 @@ def get_fc3(supercell, """ - if fc_calculator == 'alm': + if fc_calculator == "alm": from phono3py.interface.alm import get_fc3 - return get_fc3(supercell, - primitive, - displacements, - forces, - options=fc_calculator_options, - is_compact_fc=is_compact_fc, - log_level=log_level) + + return get_fc3( + supercell, + primitive, + displacements, + forces, + options=fc_calculator_options, + is_compact_fc=is_compact_fc, + log_level=log_level, + ) else: - msg = ("Force constants calculator of %s was not found ." - % fc_calculator) + msg = "Force constants calculator of %s was not found ." % fc_calculator raise RuntimeError(msg) diff --git a/phono3py/interface/phono3py_yaml.py b/phono3py/interface/phono3py_yaml.py index 1d9b5f9d..5592a3f6 100644 --- a/phono3py/interface/phono3py_yaml.py +++ b/phono3py/interface/phono3py_yaml.py @@ -1,4 +1,3 @@ - """phono3py_yaml reader and writer.""" # Copyright (C) 2016 Atsushi Togo # All rights reserved. @@ -62,17 +61,17 @@ class Phono3pyYaml(PhonopyYaml): command_name = "phono3py" default_filenames = ("phono3py_disp.yaml", "phono3py.yaml") - default_settings = {'force_sets': False, - 'displacements': True, - 'force_constants': False, - 'born_effective_charge': True, - 'dielectric_constant': True} + default_settings = { + "force_sets": False, + "displacements": True, + "force_constants": False, + "born_effective_charge": True, + "dielectric_constant": True, + } - def __init__(self, - configuration=None, - calculator=None, - physical_units=None, - settings=None): + def __init__( + self, configuration=None, calculator=None, physical_units=None, settings=None + ): """Init method.""" self.configuration = None self.calculator = None @@ -109,7 +108,8 @@ class Phono3pyYaml(PhonopyYaml): configuration=configuration, calculator=calculator, physical_units=physical_units, - settings=settings) + settings=settings, + ) def set_phonon_info(self, phono3py): """Store data in phono3py instance in this instance.""" @@ -131,15 +131,16 @@ class Phono3pyYaml(PhonopyYaml): """ super(Phono3pyYaml, self)._parse_all_cells() - if 'phonon_primitive_cell' in self._yaml: + if "phonon_primitive_cell" in self._yaml: self.phonon_primitive = self._parse_cell( - self._yaml['phonon_primitive_cell']) - if 'phonon_supercell' in self._yaml: - self.phonon_supercell = self._parse_cell( - self._yaml['phonon_supercell']) - if 'phonon_supercell_matrix' in self._yaml: + self._yaml["phonon_primitive_cell"] + ) + if "phonon_supercell" in self._yaml: + self.phonon_supercell = self._parse_cell(self._yaml["phonon_supercell"]) + if "phonon_supercell_matrix" in self._yaml: self.phonon_supercell_matrix = np.array( - self._yaml['phonon_supercell_matrix'], dtype='intc', order='C') + self._yaml["phonon_supercell_matrix"], dtype="intc", order="C" + ) def _parse_dataset(self): """Parse phonon_dataset. @@ -158,61 +159,67 @@ class Phono3pyYaml(PhonopyYaml): """ dataset = None - if 'displacement_pairs' in self._yaml: - disp = self._yaml['displacement_pairs'][0] + if "displacement_pairs" in self._yaml: + disp = self._yaml["displacement_pairs"][0] if type(disp) is dict: # type1 dataset = self._parse_forces_fc3_type1(len(self.supercell)) elif type(disp) is list: # type2 - if 'displacement' in disp[0]: + if "displacement" in disp[0]: dataset = self._parse_force_sets_type2() - if 'displacement_pair_info' in self._yaml: - info_yaml = self._yaml['displacement_pair_info'] - if 'cutoff_pair_distance' in info_yaml: - dataset['cutoff_distance'] = info_yaml['cutoff_pair_distance'] - if 'duplicated_supercell_ids' in info_yaml: - dataset['duplicates'] = info_yaml['duplicated_supercell_ids'] + if "displacement_pair_info" in self._yaml: + info_yaml = self._yaml["displacement_pair_info"] + if "cutoff_pair_distance" in info_yaml: + dataset["cutoff_distance"] = info_yaml["cutoff_pair_distance"] + if "duplicated_supercell_ids" in info_yaml: + dataset["duplicates"] = info_yaml["duplicated_supercell_ids"] self.dataset = dataset def _parse_forces_fc3_type1(self, natom): - dataset = {'natom': natom, 'first_atoms': []} - for d1 in self._yaml['displacement_pairs']: + dataset = {"natom": natom, "first_atoms": []} + for d1 in self._yaml["displacement_pairs"]: data1 = { - 'number': d1['atom'] - 1, - 'displacement': np.array(d1['displacement'], dtype='double'), - 'id': d1['displacement_id'], - 'second_atoms': []} - if 'forces' in d1: - data1['forces'] = np.array(d1['forces'], - dtype='double', order='C') - d2_list = d1.get('paired_with') + "number": d1["atom"] - 1, + "displacement": np.array(d1["displacement"], dtype="double"), + "id": d1["displacement_id"], + "second_atoms": [], + } + if "forces" in d1: + data1["forces"] = np.array(d1["forces"], dtype="double", order="C") + d2_list = d1.get("paired_with") if d2_list is None: # backward compatibility - d2_list = d1.get('second_atoms') + d2_list = d1.get("second_atoms") for d2 in d2_list: - if 'forces' in d2: - data1['second_atoms'].append( - {'number': d2['atom'] - 1, - 'displacement': np.array(d2['displacement'], - dtype='double'), - 'forces': np.array(d2['forces'], - dtype='double', order='C'), - 'id': d2['displacement_id'], - 'pair_distance': d2['pair_distance']}) + if "forces" in d2: + data1["second_atoms"].append( + { + "number": d2["atom"] - 1, + "displacement": np.array( + d2["displacement"], dtype="double" + ), + "forces": np.array(d2["forces"], dtype="double", order="C"), + "id": d2["displacement_id"], + "pair_distance": d2["pair_distance"], + } + ) else: - disps = [{'number': d2['atom'] - 1, - 'displacement': np.array(disp, dtype='double')} - for disp in d2['displacements']] - if 'pair_distance' in d2: + disps = [ + { + "number": d2["atom"] - 1, + "displacement": np.array(disp, dtype="double"), + } + for disp in d2["displacements"] + ] + if "pair_distance" in d2: for d2_dict in disps: - d2_dict['pair_distance'] = d2['pair_distance'] - if 'included' in d2: + d2_dict["pair_distance"] = d2["pair_distance"] + if "included" in d2: for d2_dict in disps: - d2_dict['included'] = d2['included'] - if 'displacement_ids' in d2: - for disp_id, d2_dict in zip( - d2['displacement_ids'], disps): - d2_dict['id'] = disp_id - data1['second_atoms'] += disps - dataset['first_atoms'].append(data1) + d2_dict["included"] = d2["included"] + if "displacement_ids" in d2: + for disp_id, d2_dict in zip(d2["displacement_ids"], disps): + d2_dict["id"] = disp_id + data1["second_atoms"] += disps + dataset["first_atoms"].append(data1) return dataset def _cell_info_yaml_lines(self): @@ -223,9 +230,11 @@ class Phono3pyYaml(PhonopyYaml): """ lines = super(Phono3pyYaml, self)._cell_info_yaml_lines() lines += self._supercell_matrix_yaml_lines( - self.phonon_supercell_matrix, "phonon_supercell_matrix") - lines += self._primitive_yaml_lines(self.phonon_primitive, - "phonon_primitive_cell") + self.phonon_supercell_matrix, "phonon_supercell_matrix" + ) + lines += self._primitive_yaml_lines( + self.phonon_primitive, "phonon_primitive_cell" + ) lines += self._phonon_supercell_yaml_lines() return lines @@ -241,9 +250,10 @@ class Phono3pyYaml(PhonopyYaml): def _phonon_supercell_yaml_lines(self): lines = [] if self.phonon_supercell is not None: - s2p_map = getattr(self.phonon_primitive, 's2p_map', None) + s2p_map = getattr(self.phonon_primitive, "s2p_map", None) lines += self._cell_yaml_lines( - self.phonon_supercell, "phonon_supercell", s2p_map) + self.phonon_supercell, "phonon_supercell", s2p_map + ) lines.append("") return lines @@ -254,11 +264,9 @@ class Phono3pyYaml(PhonopyYaml): """ if self.phonon_primitive is not None: - return self._nac_yaml_lines_given_symbols( - self.phonon_primitive.symbols) + return self._nac_yaml_lines_given_symbols(self.phonon_primitive.symbols) else: - return self._nac_yaml_lines_given_symbols( - self.primitive.symbols) + return self._nac_yaml_lines_given_symbols(self.primitive.symbols) def _displacements_yaml_lines(self, with_forces=False): """Get YAML lines for phonon_dataset and dataset. @@ -271,9 +279,11 @@ class Phono3pyYaml(PhonopyYaml): lines = [] if self.phonon_supercell_matrix is not None: lines += self._displacements_yaml_lines_2types( - self.phonon_dataset, with_forces=with_forces) + self.phonon_dataset, with_forces=with_forces + ) lines += self._displacements_yaml_lines_2types( - self.dataset, with_forces=with_forces) + self.dataset, with_forces=with_forces + ) return lines def _displacements_yaml_lines_type1(self, dataset, with_forces=False): @@ -289,120 +299,116 @@ class Phono3pyYaml(PhonopyYaml): def displacements_yaml_lines_type1(dataset, with_forces=False): """Get YAML lines for type1 phonon_dataset and dataset.""" - id_offset = len(dataset['first_atoms']) + id_offset = len(dataset["first_atoms"]) - if 'second_atoms' in dataset['first_atoms'][0]: + if "second_atoms" in dataset["first_atoms"][0]: lines = ["displacement_pairs:"] else: lines = ["displacements:"] - for i, d in enumerate(dataset['first_atoms']): - lines.append("- atom: %4d" % (d['number'] + 1)) + for i, d in enumerate(dataset["first_atoms"]): + lines.append("- atom: %4d" % (d["number"] + 1)) lines.append(" displacement:") - lines.append(" [ %19.16f, %19.16f, %19.16f ]" - % tuple(d['displacement'])) + lines.append(" [ %19.16f, %19.16f, %19.16f ]" % tuple(d["displacement"])) id_num = i + 1 - if 'id' in d: - assert id_num == d['id'] + if "id" in d: + assert id_num == d["id"] lines.append(" displacement_id: %d" % id_num) - if with_forces and 'forces' in d: + if with_forces and "forces" in d: lines.append(" forces:") - for v in d['forces']: - lines.append( - " - [ %19.16f, %19.16f, %19.16f ]" % tuple(v)) - if 'second_atoms' in d: + for v in d["forces"]: + lines.append(" - [ %19.16f, %19.16f, %19.16f ]" % tuple(v)) + if "second_atoms" in d: ret_lines, id_offset = _second_displacements_yaml_lines( - d['second_atoms'], id_offset, with_forces=with_forces) + d["second_atoms"], id_offset, with_forces=with_forces + ) lines += ret_lines lines.append("") - if 'second_atoms' in dataset['first_atoms'][0]: - n_single = len(dataset['first_atoms']) + if "second_atoms" in dataset["first_atoms"][0]: + n_single = len(dataset["first_atoms"]) n_pair = 0 n_included = 0 - for d1 in dataset['first_atoms']: - n_d2 = len(d1['second_atoms']) + for d1 in dataset["first_atoms"]: + n_d2 = len(d1["second_atoms"]) n_pair += n_d2 - for d2 in d1['second_atoms']: - if 'included' not in d2: + for d2 in d1["second_atoms"]: + if "included" not in d2: n_included += 1 - elif d2['included']: + elif d2["included"]: n_included += 1 lines.append("displacement_pair_info:") - if 'cutoff_distance' in dataset: - lines.append(" cutoff_pair_distance: %11.8f" - % dataset['cutoff_distance']) + if "cutoff_distance" in dataset: + lines.append(" cutoff_pair_distance: %11.8f" % dataset["cutoff_distance"]) lines.append(" number_of_singles: %d" % n_single) lines.append(" number_of_pairs: %d" % n_pair) - if 'cutoff_distance' in dataset: - lines.append(" number_of_pairs_in_cutoff: %d" - % n_included) + if "cutoff_distance" in dataset: + lines.append(" number_of_pairs_in_cutoff: %d" % n_included) # 'duplicates' is dict, but written as a list of list in yaml. # See the docstring of _parse_fc3_dataset for the reason. - if 'duplicates' in dataset and dataset['duplicates']: - lines.append(" duplicated_supercell_ids: " - "# 0 means perfect supercell") + if "duplicates" in dataset and dataset["duplicates"]: + lines.append(" duplicated_supercell_ids: " "# 0 means perfect supercell") # Backward compatibility for dict type - if type(dataset['duplicates']) is dict: - for i, j in dataset['duplicates'].items(): + if type(dataset["duplicates"]) is dict: + for i, j in dataset["duplicates"].items(): lines.append(" - [ %d, %d ]" % (int(i), j)) else: - for (i, j) in dataset['duplicates']: + for (i, j) in dataset["duplicates"]: lines.append(" - [ %d, %d ]" % (i, j)) lines.append("") return lines -def _second_displacements_yaml_lines(dataset2, - id_offset, - with_forces=False): +def _second_displacements_yaml_lines(dataset2, id_offset, with_forces=False): lines = [] id_num = id_offset # lines.append(" second_atoms:") lines.append(" paired_with:") - numbers = np.array([d['number'] for d in dataset2]) + numbers = np.array([d["number"] for d in dataset2]) unique_numbers = np.unique(numbers) for i in unique_numbers: indices_eq_i = np.sort(np.where(numbers == i)[0]) - if with_forces and 'forces' in dataset2[indices_eq_i[0]]: + if with_forces and "forces" in dataset2[indices_eq_i[0]]: for j in indices_eq_i: id_num += 1 lines.append(" - atom: %4d" % (i + 1)) - lines.append(" pair_distance: %.8f" - % dataset2[j]['pair_distance']) + lines.append(" pair_distance: %.8f" % dataset2[j]["pair_distance"]) lines.append(" displacement:") - lines.append(" [ %19.16f, %19.16f, %19.16f ]" - % tuple(dataset2[j]['displacement'])) + lines.append( + " [ %19.16f, %19.16f, %19.16f ]" + % tuple(dataset2[j]["displacement"]) + ) - if 'id' in dataset2[j]: - assert dataset2[j]['id'] == id_num + if "id" in dataset2[j]: + assert dataset2[j]["id"] == id_num lines.append(" displacement_id: %d" % id_num) lines.append(" forces:") - for v in dataset2[j]['forces']: - lines.append( - " - [ %19.16f, %19.16f, %19.16f ]" % tuple(v)) + for v in dataset2[j]["forces"]: + lines.append(" - [ %19.16f, %19.16f, %19.16f ]" % tuple(v)) else: lines.append(" - atom: %4d" % (i + 1)) - lines.append(" pair_distance: %.8f" - % dataset2[indices_eq_i[0]]['pair_distance']) - if 'included' in dataset2[indices_eq_i[0]]: - included = dataset2[indices_eq_i[0]]['included'] - lines.append(" included: %s" - % ("true" if included else "false")) + lines.append( + " pair_distance: %.8f" % dataset2[indices_eq_i[0]]["pair_distance"] + ) + if "included" in dataset2[indices_eq_i[0]]: + included = dataset2[indices_eq_i[0]]["included"] + lines.append(" included: %s" % ("true" if included else "false")) disp_ids = [] lines.append(" displacements:") for j in indices_eq_i: id_num += 1 - d = tuple(dataset2[j]['displacement']) + d = tuple(dataset2[j]["displacement"]) lines.append(" - [ %19.16f, %19.16f, %19.16f ]" % d) - if 'id' in dataset2[j]: - assert dataset2[j]['id'] == id_num - disp_ids.append(dataset2[j]['id']) + if "id" in dataset2[j]: + assert dataset2[j]["id"] == id_num + disp_ids.append(dataset2[j]["id"]) if disp_ids: - lines.append(" displacement_ids: [ %s ]" - % ', '.join(["%d" % j for j in disp_ids])) + lines.append( + " displacement_ids: [ %s ]" + % ", ".join(["%d" % j for j in disp_ids]) + ) return lines, id_num diff --git a/phono3py/other/isotope.py b/phono3py/other/isotope.py index e0a4f847..1d99b7b7 100644 --- a/phono3py/other/isotope.py +++ b/phono3py/other/isotope.py @@ -42,7 +42,9 @@ from phonopy.phonon.tetrahedron_mesh import get_tetrahedra_frequencies from phonopy.units import VaspToTHz from phonopy.structure.atoms import isotope_data from phono3py.other.tetrahedron_method import ( - get_integration_weights, get_unique_grid_points) + get_integration_weights, + get_unique_grid_points, +) from phono3py.phonon.solver import run_phonon_solver_c, run_phonon_solver_py from phono3py.phonon.grid import BZGrid from phono3py.phonon.func import gaussian @@ -59,31 +61,33 @@ def get_mass_variances(primitive): g = np.dot(fractions, (1 - masses / m_ave) ** 2) mass_variances.append(g) - return np.array(mass_variances, dtype='double') + return np.array(mass_variances, dtype="double") class Isotope(object): """Isotope scattering calculation class.""" - def __init__(self, - mesh, - primitive, - mass_variances=None, # length of list is num_atom. - band_indices=None, - sigma=None, - bz_grid=None, - frequency_factor_to_THz=VaspToTHz, - store_dense_gp_map=False, - symprec=1e-5, - cutoff_frequency=None, - lapack_zheev_uplo='L'): + def __init__( + self, + mesh, + primitive, + mass_variances=None, # length of list is num_atom. + band_indices=None, + sigma=None, + bz_grid=None, + frequency_factor_to_THz=VaspToTHz, + store_dense_gp_map=False, + symprec=1e-5, + cutoff_frequency=None, + lapack_zheev_uplo="L", + ): """Init method.""" - self._mesh = np.array(mesh, dtype='int_') + self._mesh = np.array(mesh, dtype="int_") if mass_variances is None: self._mass_variances = get_mass_variances(primitive) else: - self._mass_variances = np.array(mass_variances, dtype='double') + self._mass_variances = np.array(mass_variances, dtype="double") self._primitive = primitive self._sigma = sigma self._bz_grid = bz_grid @@ -106,22 +110,23 @@ class Isotope(object): 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="int_") else: - self._band_indices = np.array(band_indices, dtype='int_') + self._band_indices = np.array(band_indices, dtype="int_") if self._bz_grid is None: primitive_symmetry = Symmetry(self._primitive, self._symprec) - self._bz_grid = BZGrid(self._mesh, - lattice=self._primitive.cell, - symmetry_dataset=primitive_symmetry.dataset, - store_dense_gp_map=store_dense_gp_map) + self._bz_grid = BZGrid( + self._mesh, + lattice=self._primitive.cell, + symmetry_dataset=primitive_symmetry.dataset, + store_dense_gp_map=store_dense_gp_map, + ) 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="int_") if self._phonon_done is None: self._allocate_phonon() @@ -144,9 +149,10 @@ class Isotope(object): def set_sigma(self, sigma): """Set smearing width.""" - warnings.warn("Isotope.set_sigma() is deprecated." - "Use Isotope.sigma attribute.", - DeprecationWarning) + warnings.warn( + "Isotope.set_sigma() is deprecated." "Use Isotope.sigma attribute.", + DeprecationWarning, + ) self.sigma = sigma @property @@ -166,9 +172,10 @@ class Isotope(object): def get_gamma(self): """Return scattering strength.""" - warnings.warn("Isotope.get_gamma() is deprecated." - "Use Isotope.gamma attribute.", - DeprecationWarning) + warnings.warn( + "Isotope.get_gamma() is deprecated." "Use Isotope.gamma attribute.", + DeprecationWarning, + ) return self.gamma @property @@ -183,20 +190,18 @@ class Isotope(object): def get_mass_variances(self): """Return mass variances.""" - warnings.warn("Isotope.get_mass_variances() is deprecated." - "Use Isotope.mass_variances attribute.", - DeprecationWarning) + warnings.warn( + "Isotope.get_mass_variances() is deprecated." + "Use Isotope.mass_variances attribute.", + DeprecationWarning, + ) return self.mass_variances def get_phonons(self): """Return phonons on grid.""" return self._frequencies, self._eigenvectors, self._phonon_done - def set_phonons(self, - frequencies, - eigenvectors, - phonon_done, - dm=None): + def set_phonons(self, frequencies, eigenvectors, phonon_done, dm=None): """Set phonons on grid.""" self._frequencies = frequencies self._eigenvectors = eigenvectors @@ -204,13 +209,15 @@ class Isotope(object): if dm is not None: self._dm = dm - def init_dynamical_matrix(self, - fc2, - supercell, - primitive, - nac_params=None, - frequency_scale_factor=None, - decimals=None): + def init_dynamical_matrix( + self, + fc2, + supercell, + primitive, + nac_params=None, + frequency_scale_factor=None, + decimals=None, + ): """Initialize dynamical matrix.""" self._primitive = primitive self._dm = get_dynamical_matrix( @@ -220,40 +227,46 @@ class Isotope(object): nac_params=nac_params, frequency_scale_factor=frequency_scale_factor, decimals=decimals, - symprec=self._symprec) + symprec=self._symprec, + ) def set_nac_q_direction(self, nac_q_direction=None): """Set q-direction at q->0 used for NAC.""" if nac_q_direction is not None: - self._nac_q_direction = np.array(nac_q_direction, dtype='double') + self._nac_q_direction = np.array(nac_q_direction, dtype="double") def _run_c(self): self._run_phonon_solver_c(self._grid_points) import phono3py._phono3py as phono3c - gamma = np.zeros(len(self._band_indices), dtype='double') + + gamma = np.zeros(len(self._band_indices), dtype="double") if self._sigma is None: self._set_integration_weights() - weights = np.ones(len(self._grid_points), dtype='int_') - phono3c.thm_isotope_strength(gamma, - self._grid_point, - self._grid_points, - weights, - self._mass_variances, - self._frequencies, - self._eigenvectors, - self._band_indices, - self._integration_weights, - self._cutoff_frequency) + weights = np.ones(len(self._grid_points), dtype="int_") + phono3c.thm_isotope_strength( + gamma, + self._grid_point, + self._grid_points, + weights, + self._mass_variances, + self._frequencies, + self._eigenvectors, + self._band_indices, + self._integration_weights, + self._cutoff_frequency, + ) else: - phono3c.isotope_strength(gamma, - self._grid_point, - self._mass_variances, - self._frequencies, - self._eigenvectors, - self._band_indices, - np.prod(self._bz_grid.D_diag), - self._sigma, - self._cutoff_frequency) + phono3c.isotope_strength( + gamma, + self._grid_point, + self._mass_variances, + self._frequencies, + self._eigenvectors, + self._band_indices, + np.prod(self._bz_grid.D_diag), + self._sigma, + self._cutoff_frequency, + ) self._gamma = gamma / np.prod(self._bz_grid.D_diag) @@ -261,42 +274,47 @@ class Isotope(object): self._set_integration_weights_c() def _set_integration_weights_c(self): - unique_grid_points = get_unique_grid_points(self._grid_points, - self._bz_grid) + unique_grid_points = get_unique_grid_points(self._grid_points, self._bz_grid) self._run_phonon_solver_c(unique_grid_points) freq_points = np.array( self._frequencies[self._grid_point, self._band_indices], - dtype='double', order='C') + dtype="double", + order="C", + ) self._integration_weights = get_integration_weights( - freq_points, - self._frequencies, - self._bz_grid, - grid_points=self._grid_points) + freq_points, self._frequencies, self._bz_grid, grid_points=self._grid_points + ) def _set_integration_weights_py(self): thm = TetrahedronMethod(self._bz_grid.microzone_lattice) num_grid_points = len(self._grid_points) num_band = len(self._primitive) * 3 self._integration_weights = np.zeros( - (num_grid_points, len(self._band_indices), num_band), - dtype='double') + (num_grid_points, len(self._band_indices), num_band), dtype="double" + ) for i, gp in enumerate(self._grid_points): tfreqs = get_tetrahedra_frequencies( gp, self._bz_grid.D_diag, self._bz_grid.addresses, - np.array(np.dot(thm.get_tetrahedra(), self._bz_grid.P.T), - dtype='int_', order='C'), + np.array( + np.dot(thm.get_tetrahedra(), self._bz_grid.P.T), + dtype="int_", + order="C", + ), self._grid_points, self._frequencies, - grid_order=[1, self._bz_grid.D_diag[0], - self._bz_grid.D_diag[0] * self._bz_grid.D_diag[1]], - lang='Py') + grid_order=[ + 1, + self._bz_grid.D_diag[0], + self._bz_grid.D_diag[0] * self._bz_grid.D_diag[1], + ], + lang="Py", + ) for bi, frequencies in enumerate(tfreqs): thm.set_tetrahedra_omegas(frequencies) - thm.run(self._frequencies[self._grid_point, - self._band_indices]) + thm.run(self._frequencies[self._grid_point, self._band_indices]) iw = thm.get_integration_weight() self._integration_weights[i, :, bi] = iw @@ -314,50 +332,55 @@ class Isotope(object): ti_sum = 0.0 for i, gp in enumerate(self._grid_points): for j, (f, vec) in enumerate( - zip(self._frequencies[i], self._eigenvectors[i].T)): + zip(self._frequencies[i], self._eigenvectors[i].T) + ): if f < self._cutoff_frequency: continue ti_sum_band = np.sum( np.abs((vec * vec0).reshape(-1, 3).sum(axis=1)) ** 2 - * self._mass_variances) + * self._mass_variances + ) if self._sigma is None: - ti_sum += ti_sum_band * self._integration_weights[ - i, bi, j] + ti_sum += ti_sum_band * self._integration_weights[i, bi, j] else: ti_sum += ti_sum_band * gaussian(f0 - f, self._sigma) - t_inv.append(np.pi / 2 - / np.prod(self._bz_grid.D_diag) * f0 ** 2 * ti_sum) + t_inv.append(np.pi / 2 / np.prod(self._bz_grid.D_diag) * f0 ** 2 * ti_sum) - self._gamma = np.array(t_inv, dtype='double') / 2 + self._gamma = np.array(t_inv, dtype="double") / 2 def _run_phonon_solver_c(self, grid_points): - run_phonon_solver_c(self._dm, - self._frequencies, - self._eigenvectors, - self._phonon_done, - grid_points, - self._bz_grid.addresses, - self._bz_grid.QDinv, - self._frequency_factor_to_THz, - self._nac_q_direction, - self._lapack_zheev_uplo) + run_phonon_solver_c( + self._dm, + self._frequencies, + self._eigenvectors, + self._phonon_done, + grid_points, + self._bz_grid.addresses, + self._bz_grid.QDinv, + self._frequency_factor_to_THz, + self._nac_q_direction, + self._lapack_zheev_uplo, + ) def _run_phonon_solver_py(self, grid_point): - run_phonon_solver_py(grid_point, - self._phonon_done, - self._frequencies, - self._eigenvectors, - self._bz_grid.addresses, - self._bz_grid.QDinv, - self._dm, - self._frequency_factor_to_THz, - self._lapack_zheev_uplo) + run_phonon_solver_py( + grid_point, + self._phonon_done, + self._frequencies, + self._eigenvectors, + self._bz_grid.addresses, + self._bz_grid.QDinv, + self._dm, + self._frequency_factor_to_THz, + self._lapack_zheev_uplo, + ) def _allocate_phonon(self): num_band = len(self._primitive) * 3 num_grid = len(self._bz_grid.addresses) - self._phonon_done = np.zeros(num_grid, dtype='byte') - self._frequencies = np.zeros((num_grid, num_band), dtype='double') + self._phonon_done = np.zeros(num_grid, dtype="byte") + self._frequencies = np.zeros((num_grid, num_band), dtype="double") itemsize = self._frequencies.itemsize - self._eigenvectors = np.zeros((num_grid, num_band, num_band), - dtype=("c%d" % (itemsize * 2))) + self._eigenvectors = np.zeros( + (num_grid, num_band, num_band), dtype=("c%d" % (itemsize * 2)) + ) diff --git a/phono3py/other/tetrahedron_method.py b/phono3py/other/tetrahedron_method.py index 088c83c9..1bc6532d 100644 --- a/phono3py/other/tetrahedron_method.py +++ b/phono3py/other/tetrahedron_method.py @@ -58,16 +58,20 @@ def get_unique_grid_points(grid_points, bz_grid): """ import phono3py._phono3py as phono3c - if _check_ndarray_state(grid_points, 'int_'): + + if _check_ndarray_state(grid_points, "int_"): _grid_points = grid_points else: - _grid_points = np.array(grid_points, dtype='int_') + _grid_points = np.array(grid_points, dtype="int_") thm = TetrahedronMethod(bz_grid.microzone_lattice) unique_vertices = np.array( np.dot(thm.get_unique_tetrahedra_vertices(), bz_grid.P.T), - dtype='int_', order='C') + dtype="int_", + order="C", + ) neighboring_grid_points = np.zeros( - len(unique_vertices) * len(_grid_points), dtype='int_') + len(unique_vertices) * len(_grid_points), dtype="int_" + ) phono3c.neighboring_grid_points( neighboring_grid_points, _grid_points, @@ -75,18 +79,20 @@ def get_unique_grid_points(grid_points, bz_grid): bz_grid.D_diag, bz_grid.addresses, bz_grid.gp_map, - bz_grid.store_dense_gp_map * 1 + 1) - unique_grid_points = np.array(np.unique(neighboring_grid_points), - dtype='int_') + bz_grid.store_dense_gp_map * 1 + 1, + ) + unique_grid_points = np.array(np.unique(neighboring_grid_points), dtype="int_") return unique_grid_points -def get_integration_weights(sampling_points, - grid_values, - bz_grid, - grid_points=None, - bzgp2irgp_map=None, - function='I'): +def get_integration_weights( + sampling_points, + grid_values, + bz_grid, + grid_points=None, + bzgp2irgp_map=None, + function="I", +): """Return tetrahedron method integration weights. Parameters @@ -118,39 +124,39 @@ def get_integration_weights(sampling_points, """ import phono3py._phono3py as phono3c + thm = TetrahedronMethod(bz_grid.microzone_lattice) if grid_points is None: _grid_points = bz_grid.grg2bzg - elif _check_ndarray_state(grid_points, 'int_'): + elif _check_ndarray_state(grid_points, "int_"): _grid_points = grid_points else: - _grid_points = np.array(grid_points, dtype='int_') - if _check_ndarray_state(grid_values, 'double'): + _grid_points = np.array(grid_points, dtype="int_") + if _check_ndarray_state(grid_values, "double"): _grid_values = grid_values else: - _grid_values = np.array(grid_values, dtype='double', order='C') - if _check_ndarray_state(sampling_points, 'double'): + _grid_values = np.array(grid_values, dtype="double", order="C") + if _check_ndarray_state(sampling_points, "double"): _sampling_points = sampling_points else: - _sampling_points = np.array(sampling_points, dtype='double') + _sampling_points = np.array(sampling_points, dtype="double") if bzgp2irgp_map is None: - _bzgp2irgp_map = np.arange(len(grid_values), dtype='int_') - elif _check_ndarray_state(bzgp2irgp_map, 'int_'): + _bzgp2irgp_map = np.arange(len(grid_values), dtype="int_") + elif _check_ndarray_state(bzgp2irgp_map, "int_"): _bzgp2irgp_map = bzgp2irgp_map else: - _bzgp2irgp_map = np.array(bzgp2irgp_map, dtype='int_') + _bzgp2irgp_map = np.array(bzgp2irgp_map, dtype="int_") num_grid_points = len(_grid_points) num_band = _grid_values.shape[1] integration_weights = np.zeros( - (num_grid_points, len(_sampling_points), num_band), - dtype='double', order='C') + (num_grid_points, len(_sampling_points), num_band), dtype="double", order="C" + ) phono3c.integration_weights_at_grid_points( integration_weights, _sampling_points, - np.array(np.dot(thm.get_tetrahedra(), bz_grid.P.T), - dtype='int_', order='C'), + np.array(np.dot(thm.get_tetrahedra(), bz_grid.P.T), dtype="int_", order="C"), bz_grid.D_diag, _grid_points, _grid_values, @@ -158,11 +164,11 @@ def get_integration_weights(sampling_points, bz_grid.gp_map, _bzgp2irgp_map, bz_grid.store_dense_gp_map * 1 + 1, - function) + function, + ) return integration_weights def _check_ndarray_state(array, dtype): """Check contiguousness and dtype.""" - return (array.dtype == dtype and - array.flags.c_contiguous) + return array.dtype == dtype and array.flags.c_contiguous diff --git a/phono3py/phonon/func.py b/phono3py/phonon/func.py index b8eda680..066d111c 100644 --- a/phono3py/phonon/func.py +++ b/phono3py/phonon/func.py @@ -1,3 +1,4 @@ +"""Mathematical functions.""" # Copyright (C) 2020 Atsushi Togo # All rights reserved. # @@ -37,11 +38,12 @@ from phonopy.units import THzToEv, Kb, Hbar, EV, Angstrom, THz, AMU def gaussian(x, sigma): - return 1.0 / np.sqrt(2 * np.pi) / sigma * np.exp(-x**2 / 2 / sigma**2) + """Return normal distribution.""" + return 1.0 / np.sqrt(2 * np.pi) / sigma * np.exp(-(x ** 2) / 2 / sigma ** 2) def bose_einstein(x, T): - """Returns Bose-Einstein distribution + """Return Bose-Einstein distribution. Note ---- @@ -63,7 +65,7 @@ def bose_einstein(x, T): def mode_length(x, T): - """Returns mode length + """Return mode length. sqrt((0.5 + n) hbar / omega) @@ -87,9 +89,8 @@ def mode_length(x, T): Values in [sqrt(AMU) * Angstrom] """ - ##################################### - old_settings = np.seterr(all='raise') + old_settings = np.seterr(all="raise") ##################################### n = bose_einstein(x, T) diff --git a/phono3py/phonon3/collision_matrix.py b/phono3py/phonon3/collision_matrix.py index f145df22..7da6a0fc 100644 --- a/phono3py/phonon3/collision_matrix.py +++ b/phono3py/phonon3/collision_matrix.py @@ -52,8 +52,6 @@ class CollisionMatrix(ImagSelfEnergy): rotations_cartesian=None, num_ir_grid_points=None, rot_grid_points=None, - temperature=None, - sigma=None, is_reducible_collision_matrix=False, log_level=0, lang="C", @@ -80,9 +78,7 @@ class CollisionMatrix(ImagSelfEnergy): self._unit_conversion = None self._log_level = log_level - ImagSelfEnergy.__init__( - self, interaction, temperature=temperature, sigma=sigma, lang=lang - ) + ImagSelfEnergy.__init__(self, interaction, lang=lang) self._is_reducible_collision_matrix = is_reducible_collision_matrix self._is_collision_matrix = True diff --git a/phono3py/phonon3/conductivity_RTA.py b/phono3py/phonon3/conductivity_RTA.py index a5d62e5e..89046975 100644 --- a/phono3py/phonon3/conductivity_RTA.py +++ b/phono3py/phonon3/conductivity_RTA.py @@ -59,7 +59,6 @@ def get_thermal_conductivity_RTA( is_isotope=False, boundary_mfp=None, # in micrometre use_ave_pp=False, - gamma_unit_conversion=None, is_kappa_star=True, gv_delta_q=None, is_full_pp=False, @@ -96,7 +95,6 @@ def get_thermal_conductivity_RTA( mass_variances=mass_variances, boundary_mfp=boundary_mfp, use_ave_pp=use_ave_pp, - gamma_unit_conversion=gamma_unit_conversion, is_kappa_star=is_kappa_star, gv_delta_q=gv_delta_q, is_full_pp=is_full_pp, @@ -508,7 +506,6 @@ class Conductivity_RTA(Conductivity): mass_variances=None, boundary_mfp=None, # in micrometre use_ave_pp=False, - gamma_unit_conversion=None, is_kappa_star=True, gv_delta_q=None, is_full_pp=False, @@ -552,7 +549,6 @@ class Conductivity_RTA(Conductivity): self._gamma_N = None self._gamma_U = None self._gamma_detail_at_q = None - self._gamma_unit_conversion = gamma_unit_conversion self._use_ave_pp = use_ave_pp self._use_const_ave_pp = None self._averaged_pp_interaction = None @@ -733,9 +729,7 @@ class Conductivity_RTA(Conductivity): (len(self._sigmas), num_temp), order="C", dtype="intc" ) self._collision = ImagSelfEnergy( - self._pp, - with_detail=(self._is_gamma_detail or self._is_N_U), - unit_conversion=self._gamma_unit_conversion, + self._pp, with_detail=(self._is_gamma_detail or self._is_N_U) ) def _set_gamma_at_sigmas(self, i): diff --git a/phono3py/phonon3/dataset.py b/phono3py/phonon3/dataset.py index 0139ddc3..93ce3a92 100644 --- a/phono3py/phonon3/dataset.py +++ b/phono3py/phonon3/dataset.py @@ -60,35 +60,37 @@ def get_displacements_and_forces_fc3(disp_dataset): """ - if 'first_atoms' in disp_dataset: - natom = disp_dataset['natom'] - ndisp = len(disp_dataset['first_atoms']) - for disp1 in disp_dataset['first_atoms']: - ndisp += len(disp1['second_atoms']) - displacements = np.zeros((ndisp, natom, 3), dtype='double', order='C') + if "first_atoms" in disp_dataset: + natom = disp_dataset["natom"] + ndisp = len(disp_dataset["first_atoms"]) + for disp1 in disp_dataset["first_atoms"]: + ndisp += len(disp1["second_atoms"]) + displacements = np.zeros((ndisp, natom, 3), dtype="double", order="C") forces = np.zeros_like(displacements) indices = [] count = 0 - for disp1 in disp_dataset['first_atoms']: + for disp1 in disp_dataset["first_atoms"]: indices.append(count) - displacements[count, disp1['number']] = disp1['displacement'] - forces[count] = disp1['forces'] + displacements[count, disp1["number"]] = disp1["displacement"] + forces[count] = disp1["forces"] count += 1 - for disp1 in disp_dataset['first_atoms']: - for disp2 in disp1['second_atoms']: - if 'included' in disp2: - if disp2['included']: + for disp1 in disp_dataset["first_atoms"]: + for disp2 in disp1["second_atoms"]: + if "included" in disp2: + if disp2["included"]: indices.append(count) else: indices.append(count) - displacements[count, disp1['number']] = disp1['displacement'] - displacements[count, disp2['number']] = disp2['displacement'] - forces[count] = disp2['forces'] + displacements[count, disp1["number"]] = disp1["displacement"] + displacements[count, disp2["number"]] = disp2["displacement"] + forces[count] = disp2["forces"] count += 1 - return (np.array(displacements[indices], dtype='double', order='C'), - np.array(forces[indices], dtype='double', order='C')) - elif 'forces' in disp_dataset and 'displacements' in disp_dataset: - return disp_dataset['displacements'], disp_dataset['forces'] + return ( + np.array(displacements[indices], dtype="double", order="C"), + np.array(forces[indices], dtype="double", order="C"), + ) + elif "forces" in disp_dataset and "displacements" in disp_dataset: + return disp_dataset["displacements"], disp_dataset["forces"] else: raise RuntimeError("disp_dataset doesn't contain correct information.") diff --git a/phono3py/phonon3/displacement_fc3.py b/phono3py/phonon3/displacement_fc3.py index 4ea99f80..c48ba4d8 100644 --- a/phono3py/phonon3/displacement_fc3.py +++ b/phono3py/phonon3/displacement_fc3.py @@ -34,16 +34,18 @@ # POSSIBILITY OF SUCH DAMAGE. import numpy as np -from phonopy.harmonic.displacement import (get_least_displacements, - directions_axis, get_displacement, - is_minus_displacement) +from phonopy.harmonic.displacement import ( + get_least_displacements, + directions_axis, + get_displacement, + is_minus_displacement, +) from phonopy.structure.cells import get_smallest_vectors -def direction_to_displacement(direction_dataset, - displacement_distance, - supercell, - cutoff_distance=None): +def direction_to_displacement( + direction_dataset, displacement_distance, supercell, cutoff_distance=None +): """Convert displacement directions to those in Cartesian coordinates. Parameters @@ -75,52 +77,56 @@ def direction_to_displacement(direction_dataset, lattice = supercell.cell.T new_dataset = {} - new_dataset['natom'] = len(supercell) + new_dataset["natom"] = len(supercell) if duplicates: - new_dataset['duplicates'] = duplicates + new_dataset["duplicates"] = duplicates if cutoff_distance is not None: - new_dataset['cutoff_distance'] = cutoff_distance + new_dataset["cutoff_distance"] = cutoff_distance new_first_atoms = [] for i, first_atoms in enumerate(direction_dataset): - atom1 = first_atoms['number'] - direction1 = first_atoms['direction'] + atom1 = first_atoms["number"] + direction1 = first_atoms["direction"] disp_cart1 = np.dot(direction1, lattice.T) disp_cart1 *= displacement_distance / np.linalg.norm(disp_cart1) new_second_atoms = [] - for second_atom in first_atoms['second_atoms']: - atom2 = second_atom['number'] - pair_distance = second_atom['distance'] - included = (cutoff_distance is None or - pair_distance < cutoff_distance) - for direction2 in second_atom['directions']: + for second_atom in first_atoms["second_atoms"]: + atom2 = second_atom["number"] + pair_distance = second_atom["distance"] + included = cutoff_distance is None or pair_distance < cutoff_distance + for direction2 in second_atom["directions"]: disp_cart2 = np.dot(direction2, lattice.T) norm = np.linalg.norm(disp_cart2) disp_cart2 *= displacement_distance / norm - disp2_dict = {'id': d3_count, - 'number': atom2, - 'direction': direction2, - 'displacement': disp_cart2, - 'pair_distance': pair_distance} + disp2_dict = { + "id": d3_count, + "number": atom2, + "direction": direction2, + "displacement": disp_cart2, + "pair_distance": pair_distance, + } if cutoff_distance is not None: - disp2_dict['included'] = included + disp2_dict["included"] = included new_second_atoms.append(disp2_dict) d3_count += 1 - new_first_atoms.append({'number': atom1, - 'direction': direction1, - 'displacement': disp_cart1, - 'id': (i + 1), - 'second_atoms': new_second_atoms}) - new_dataset['first_atoms'] = new_first_atoms + new_first_atoms.append( + { + "number": atom1, + "direction": direction1, + "displacement": disp_cart1, + "id": (i + 1), + "second_atoms": new_second_atoms, + } + ) + new_dataset["first_atoms"] = new_first_atoms return new_dataset -def get_third_order_displacements(cell, - symmetry, - is_plusminus='auto', - is_diagonal=False): +def get_third_order_displacements( + cell, symmetry, is_plusminus="auto", is_diagonal=False +): """Create dispalcement dataset. Note @@ -163,9 +169,9 @@ def get_third_order_displacements(cell, # using respective site symmetries of the original crystal. # 'is_diagonal=False' below is made intentionally to expect # better accuracy. - disps_first = get_least_displacements(symmetry, - is_plusminus=is_plusminus, - is_diagonal=False) + disps_first = get_least_displacements( + symmetry, is_plusminus=is_plusminus, is_diagonal=False + ) symprec = symmetry.tolerance @@ -175,57 +181,37 @@ def get_third_order_displacements(cell, disp1 = disp[1:4] site_sym = symmetry.get_site_symmetry(atom1) - dds_atom1 = {'number': atom1, - 'direction': disp1, - 'second_atoms': []} + dds_atom1 = {"number": atom1, "direction": disp1, "second_atoms": []} # Reduced site symmetry at the first atom with respect to # the displacement of the first atoms. reduced_site_sym = get_reduced_site_symmetry(site_sym, disp1, symprec) # Searching orbits (second atoms) with respect to # the first atom and its reduced site symmetry. - second_atoms = get_least_orbits(atom1, - cell, - reduced_site_sym, - symprec) + second_atoms = get_least_orbits(atom1, cell, reduced_site_sym, symprec) for atom2 in second_atoms: - dds_atom2 = _get_next_displacements(atom1, - atom2, - reduced_site_sym, - lattice, - positions, - symprec, - is_diagonal) + dds_atom2 = _get_next_displacements( + atom1, atom2, reduced_site_sym, lattice, positions, symprec, is_diagonal + ) - min_vec = get_smallest_vector_of_atom_pair(atom1, - atom2, - cell, - symprec) + min_vec = get_smallest_vector_of_atom_pair(atom1, atom2, cell, symprec) min_distance = np.linalg.norm(np.dot(lattice, min_vec)) - dds_atom2['distance'] = min_distance - dds_atom1['second_atoms'].append(dds_atom2) + dds_atom2["distance"] = min_distance + dds_atom1["second_atoms"].append(dds_atom2) dds.append(dds_atom1) return dds -def _get_next_displacements(atom1, - atom2, - reduced_site_sym, - lattice, - positions, - symprec, - is_diagonal): +def _get_next_displacements( + atom1, atom2, reduced_site_sym, lattice, positions, symprec, is_diagonal +): """Find displacements of second atom.""" # Bond symmetry between first and second atoms. reduced_bond_sym = get_bond_symmetry( - reduced_site_sym, - lattice, - positions, - atom1, - atom2, - symprec) + reduced_site_sym, lattice, positions, atom1, atom2, symprec + ) # Since displacement of first atom breaks translation # symmetry, the crystal symmetry is reduced to point @@ -237,11 +223,11 @@ def _get_next_displacements(atom1, disps_second = get_displacement(reduced_bond_sym) else: disps_second = get_displacement(reduced_bond_sym, directions_axis) - dds_atom2 = {'number': atom2, 'directions': []} + dds_atom2 = {"number": atom2, "directions": []} for disp2 in disps_second: - dds_atom2['directions'].append(list(disp2)) + dds_atom2["directions"].append(list(disp2)) if is_minus_displacement(disp2, reduced_bond_sym): - dds_atom2['directions'].append(list(-disp2)) + dds_atom2["directions"].append(list(-disp2)) return dds_atom2 @@ -252,15 +238,12 @@ def get_reduced_site_symmetry(site_sym, direction, symprec=1e-5): for rot in site_sym: if (abs(direction - np.dot(direction, rot.T)) < symprec).all(): reduced_site_sym.append(rot) - return np.array(reduced_site_sym, dtype='intc') + return np.array(reduced_site_sym, dtype="intc") -def get_bond_symmetry(site_symmetry, - lattice, - positions, - atom_center, - atom_disp, - symprec=1e-5): +def get_bond_symmetry( + site_symmetry, lattice, positions, atom_center, atom_disp, symprec=1e-5 +): """Return bond symmetry. Bond symmetry is the symmetry operations that keep the symmetry @@ -270,8 +253,7 @@ def get_bond_symmetry(site_symmetry, bond_sym = [] pos = positions for rot in site_symmetry: - rot_pos = (np.dot(pos[atom_disp] - pos[atom_center], rot.T) + - pos[atom_center]) + rot_pos = np.dot(pos[atom_disp] - pos[atom_center], rot.T) + pos[atom_center] diff = pos[atom_disp] - rot_pos diff -= np.rint(diff) dist = np.linalg.norm(np.dot(lattice, diff)) @@ -294,17 +276,18 @@ def get_least_orbits(atom_index, cell, site_symmetry, symprec=1e-5): return np.unique(mapping) -def get_smallest_vector_of_atom_pair(atom_number_supercell, - atom_number_primitive, - supercell, - symprec): +def get_smallest_vector_of_atom_pair( + atom_number_supercell, atom_number_primitive, supercell, symprec +): """Return smallest vectors of an atom pair in supercell.""" s_pos = supercell.scaled_positions - svecs, multi = get_smallest_vectors(supercell.cell, - [s_pos[atom_number_supercell]], - [s_pos[atom_number_primitive]], - store_dense_svecs=True, - symprec=symprec) + svecs, multi = get_smallest_vectors( + supercell.cell, + [s_pos[atom_number_supercell]], + [s_pos[atom_number_primitive]], + store_dense_svecs=True, + symprec=symprec, + ) return svecs[0] @@ -347,43 +330,47 @@ def _find_duplicates(direction_dataset): # This id is stamped in direction_to_displacement by the sequence of # the loops. Therefore the same system of the loops should be used here. for direction1 in direction_dataset: - n1 = direction1['number'] - d1 = direction1['direction'] - for directions2 in direction1['second_atoms']: - n2 = directions2['number'] + n1 = direction1["number"] + d1 = direction1["direction"] + for directions2 in direction1["second_atoms"]: + n2 = directions2["number"] if (n1, n2) not in direction_sets: direction_sets[(n1, n2)] = [] pair_idx[(n1, n2)] = [] - for i, d2 in enumerate(directions2['directions']): + for i, d2 in enumerate(directions2["directions"]): direction_sets[(n1, n2)].append(d1 + d2) pair_idx[(n1, n2)].append(idx + i) - idx += len(directions2['directions']) + idx += len(directions2["directions"]) duplucates = [] done = [] for i, direction1 in enumerate(direction_dataset): - n1 = direction1['number'] - for directions2 in direction1['second_atoms']: - n2 = directions2['number'] - if (n2 > n1 and (n2, n1) not in done and - (n2, n1) in direction_sets): # noqa E129 + n1 = direction1["number"] + for directions2 in direction1["second_atoms"]: + n2 = directions2["number"] + if ( + n2 > n1 and (n2, n1) not in done and (n2, n1) in direction_sets + ): # noqa E129 done.append((n2, n1)) duplucates += _compare( - n1, n2, - direction_sets[(n1, n2)], direction_sets[(n2, n1)], - pair_idx[(n1, n2)], pair_idx[(n2, n1)]) + n1, + n2, + direction_sets[(n1, n2)], + direction_sets[(n2, n1)], + pair_idx[(n1, n2)], + pair_idx[(n2, n1)], + ) done = [] for i, direction1 in enumerate(direction_dataset): - n1 = direction1['number'] - for directions2 in direction1['second_atoms']: - n2 = directions2['number'] + n1 = direction1["number"] + for directions2 in direction1["second_atoms"]: + n2 = directions2["number"] if n1 == n2 and n1 not in done: done.append(n1) duplucates += _compare_opposite( - n1, - direction_sets[(n1, n1)], - pair_idx[(n1, n1)]) + n1, direction_sets[(n1, n1)], pair_idx[(n1, n1)] + ) return duplucates diff --git a/phono3py/phonon3/fc3.py b/phono3py/phonon3/fc3.py index e17ee857..f91c717f 100644 --- a/phono3py/phonon3/fc3.py +++ b/phono3py/phonon3/fc3.py @@ -43,39 +43,39 @@ from phonopy.harmonic.force_constants import ( solve_force_constants, get_rotated_displacement, get_positions_sent_by_rot_inv, - get_nsym_list_and_s2pp) + get_nsym_list_and_s2pp, +) from phono3py.phonon3.displacement_fc3 import ( get_reduced_site_symmetry, get_bond_symmetry, - get_smallest_vector_of_atom_pair) + get_smallest_vector_of_atom_pair, +) from phonopy.structure.cells import compute_all_sg_permutations logger = logging.getLogger(__name__) -def get_fc3(supercell, - primitive, - disp_dataset, - symmetry, - is_compact_fc=False, - verbose=False): +def get_fc3( + supercell, primitive, disp_dataset, symmetry, is_compact_fc=False, verbose=False +): """Calculate fc3.""" # fc2 has to be full matrix to compute delta-fc2 # p2s_map elements are extracted if is_compact_fc=True at the last part. fc2 = get_fc2(supercell, symmetry, disp_dataset) - fc3 = _get_fc3_least_atoms(supercell, - primitive, - disp_dataset, - fc2, - symmetry, - is_compact_fc=is_compact_fc, - verbose=verbose) + fc3 = _get_fc3_least_atoms( + supercell, + primitive, + disp_dataset, + fc2, + symmetry, + is_compact_fc=is_compact_fc, + verbose=verbose, + ) if verbose: print("Expanding fc3.") - first_disp_atoms = np.unique( - [x['number'] for x in disp_dataset['first_atoms']]) - rotations = symmetry.get_symmetry_operations()['rotations'] + first_disp_atoms = np.unique([x["number"] for x in disp_dataset["first_atoms"]]) + rotations = symmetry.get_symmetry_operations()["rotations"] lattice = supercell.cell.T permutations = symmetry.atomic_permutations @@ -83,51 +83,53 @@ def get_fc3(supercell, s2p_map = primitive.s2p_map p2s_map = primitive.p2s_map p2p_map = primitive.p2p_map - s2compact = np.array([p2p_map[i] for i in s2p_map], dtype='int_') + s2compact = np.array([p2p_map[i] for i in s2p_map], dtype="int_") for i in first_disp_atoms: assert i in p2s_map target_atoms = [i for i in p2s_map if i not in first_disp_atoms] else: - s2compact = np.arange(len(supercell), dtype='int_') + s2compact = np.arange(len(supercell), dtype="int_") target_atoms = [i for i in s2compact if i not in first_disp_atoms] - distribute_fc3(fc3, - first_disp_atoms, - target_atoms, - lattice, - rotations, - permutations, - s2compact, - verbose=verbose) + distribute_fc3( + fc3, + first_disp_atoms, + target_atoms, + lattice, + rotations, + permutations, + s2compact, + verbose=verbose, + ) - if 'cutoff_distance' in disp_dataset: + if "cutoff_distance" in disp_dataset: if verbose: - print("Cutting-off fc3 (cut-off distance: %f)" % - disp_dataset['cutoff_distance']) + print( + "Cutting-off fc3 (cut-off distance: %f)" + % disp_dataset["cutoff_distance"] + ) if is_compact_fc: print("cutoff_fc3 doesn't support compact-fc3 yet.") raise ValueError - _cutoff_fc3(fc3, - supercell, - disp_dataset, - symmetry, - verbose=verbose) + _cutoff_fc3(fc3, supercell, disp_dataset, symmetry, verbose=verbose) if is_compact_fc: p2s_map = primitive.p2s_map - fc2 = np.array(fc2[p2s_map], dtype='double', order='C') + fc2 = np.array(fc2[p2s_map], dtype="double", order="C") return fc2, fc3 -def distribute_fc3(fc3, - first_disp_atoms, - target_atoms, - lattice, - rotations, - permutations, - s2compact, - verbose=False): +def distribute_fc3( + fc3, + first_disp_atoms, + target_atoms, + lattice, + rotations, + permutations, + s2compact, + verbose=False, +): """Distribute fc3. fc3[i, :, :, 0:3, 0:3, 0:3] where i=indices done are distributed to @@ -155,12 +157,11 @@ def distribute_fc3(fc3, for i_done in first_disp_atoms: rot_indices = np.where(permutations[:, i_target] == i_done)[0] if len(rot_indices) > 0: - atom_mapping = np.array(permutations[rot_indices[0]], - dtype='int_') + atom_mapping = np.array(permutations[rot_indices[0]], dtype="int_") rot = rotations[rot_indices[0]] rot_cart_inv = np.array( - similarity_transformation(lattice, rot).T, - dtype='double', order='C') + similarity_transformation(lattice, rot).T, dtype="double", order="C" + ) break if len(rot_indices) == 0: @@ -168,17 +169,15 @@ def distribute_fc3(fc3, raise RuntimeError if verbose > 2: - print(" [ %d, x, x ] to [ %d, x, x ]" % - (i_done + 1, i_target + 1)) + print(" [ %d, x, x ] to [ %d, x, x ]" % (i_done + 1, i_target + 1)) sys.stdout.flush() try: import phono3py._phono3py as phono3c - phono3c.distribute_fc3(fc3, - s2compact[i_target], - s2compact[i_done], - atom_mapping, - rot_cart_inv) + + phono3c.distribute_fc3( + fc3, s2compact[i_target], s2compact[i_done], atom_mapping, rot_cart_inv + ) except ImportError: print("Phono3py C-routine is not compiled correctly.") for j in range(n_satom): @@ -186,13 +185,15 @@ def distribute_fc3(fc3, for k in range(n_satom): k_rot = atom_mapping[k] fc3[i_target, j, k] = _third_rank_tensor_rotation( - rot_cart_inv, fc3[i_done, j_rot, k_rot]) + rot_cart_inv, fc3[i_done, j_rot, k_rot] + ) def set_permutation_symmetry_fc3(fc3): """Enforce permutation symmetry to full fc3.""" try: import phono3py._phono3py as phono3c + phono3c.permutation_symmetry_fc3(fc3) except ImportError: print("Phono3py C-routine is not compiled correctly.") @@ -208,22 +209,24 @@ def set_permutation_symmetry_compact_fc3(fc3, primitive): """Enforce permulation symmetry to compact fc3.""" try: import phono3py._phono3py as phono3c + s2p_map = primitive.s2p_map p2s_map = primitive.p2s_map p2p_map = primitive.p2p_map permutations = primitive.atomic_permutations - s2pp_map, nsym_list = get_nsym_list_and_s2pp(s2p_map, - p2p_map, - permutations) + s2pp_map, nsym_list = get_nsym_list_and_s2pp(s2p_map, p2p_map, permutations) phono3c.permutation_symmetry_compact_fc3( fc3, - np.array(permutations, dtype='int_', order='C'), - np.array(s2pp_map, dtype='int_'), - np.array(p2s_map, dtype='int_'), - np.array(nsym_list, dtype='int_')) + np.array(permutations, dtype="int_", order="C"), + np.array(s2pp_map, dtype="int_"), + np.array(p2s_map, dtype="int_"), + np.array(nsym_list, dtype="int_"), + ) except ImportError: - text = ("Import error at phono3c.permutation_symmetry_compact_fc3. " - "Corresponding python code is not implemented.") + text = ( + "Import error at phono3c.permutation_symmetry_compact_fc3. " + "Corresponding python code is not implemented." + ) raise RuntimeError(text) @@ -238,14 +241,16 @@ def _copy_permutation_symmetry_fc3_elem(fc3, fc3_elem, a, b, c): def _set_permutation_symmetry_fc3_elem(fc3, a, b, c, divisor=6): - tensor3 = np.zeros((3, 3, 3), dtype='double') + tensor3 = np.zeros((3, 3, 3), dtype="double") for (i, j, k) in list(np.ndindex(3, 3, 3)): - tensor3[i, j, k] = (fc3[a, b, c, i, j, k] + - fc3[c, a, b, k, i, j] + - fc3[b, c, a, j, k, i] + - fc3[a, c, b, i, k, j] + - fc3[b, a, c, j, i, k] + - fc3[c, b, a, k, j, i]) / divisor + tensor3[i, j, k] = ( + fc3[a, b, c, i, j, k] + + fc3[c, a, b, k, i, j] + + fc3[b, c, a, j, k, i] + + fc3[a, c, b, i, k, j] + + fc3[b, a, c, j, i, k] + + fc3[c, b, a, k, j, i] + ) / divisor return tensor3 @@ -259,39 +264,32 @@ def set_translational_invariance_compact_fc3(fc3, primitive): """Enforce translational symmetry to compact fc3.""" try: import phono3py._phono3py as phono3c + s2p_map = primitive.s2p_map p2s_map = primitive.p2s_map p2p_map = primitive.p2p_map permutations = primitive.atomic_permutations - s2pp_map, nsym_list = get_nsym_list_and_s2pp(s2p_map, - p2p_map, - permutations) + s2pp_map, nsym_list = get_nsym_list_and_s2pp(s2p_map, p2p_map, permutations) - permutations = np.array(permutations, dtype='int_', order='C') - s2pp_map = np.array(s2pp_map, dtype='int_') - p2s_map = np.array(p2s_map, dtype='int_') - nsym_list = np.array(nsym_list, dtype='int_') + permutations = np.array(permutations, dtype="int_", order="C") + s2pp_map = np.array(s2pp_map, dtype="int_") + p2s_map = np.array(p2s_map, dtype="int_") + nsym_list = np.array(nsym_list, dtype="int_") phono3c.transpose_compact_fc3( - fc3, - permutations, - s2pp_map, - p2s_map, - nsym_list, - 0) # dim[0] <--> dim[1] + fc3, permutations, s2pp_map, p2s_map, nsym_list, 0 + ) # dim[0] <--> dim[1] _set_translational_invariance_fc3_per_index(fc3, index=1) phono3c.transpose_compact_fc3( - fc3, - permutations, - s2pp_map, - p2s_map, - nsym_list, - 0) # dim[0] <--> dim[1] + fc3, permutations, s2pp_map, p2s_map, nsym_list, 0 + ) # dim[0] <--> dim[1] _set_translational_invariance_fc3_per_index(fc3, index=1) _set_translational_invariance_fc3_per_index(fc3, index=2) except ImportError: - text = ("Import error at phono3c.tranpose_compact_fc3. " - "Corresponding python code is not implemented.") + text = ( + "Import error at phono3c.tranpose_compact_fc3. " + "Corresponding python code is not implemented." + ) raise RuntimeError(text) @@ -300,49 +298,43 @@ def _set_translational_invariance_fc3_per_index(fc3, index=0): for j in range(fc3.shape[(2 + index) % 3]): for k, l, m in list(np.ndindex(3, 3, 3)): if index == 0: - fc3[:, i, j, k, l, m] -= np.sum( - fc3[:, i, j, k, l, m]) / fc3.shape[0] + fc3[:, i, j, k, l, m] -= ( + np.sum(fc3[:, i, j, k, l, m]) / fc3.shape[0] + ) elif index == 1: - fc3[j, :, i, k, l, m] -= np.sum( - fc3[j, :, i, k, l, m]) / fc3.shape[1] + fc3[j, :, i, k, l, m] -= ( + np.sum(fc3[j, :, i, k, l, m]) / fc3.shape[1] + ) elif index == 2: - fc3[i, j, :, k, l, m] -= np.sum( - fc3[i, j, :, k, l, m]) / fc3.shape[2] + fc3[i, j, :, k, l, m] -= ( + np.sum(fc3[i, j, :, k, l, m]) / fc3.shape[2] + ) def _third_rank_tensor_rotation(rot_cart, tensor): - rot_tensor = np.zeros((3, 3, 3), dtype='double') + rot_tensor = np.zeros((3, 3, 3), dtype="double") for i in (0, 1, 2): for j in (0, 1, 2): for k in (0, 1, 2): rot_tensor[i, j, k] = _third_rank_tensor_rotation_elem( - rot_cart, tensor, i, j, k) + rot_cart, tensor, i, j, k + ) return rot_tensor -def _get_delta_fc2(dataset_second_atoms, - atom1, - forces1, - fc2, - supercell, - reduced_site_sym, - symprec): +def _get_delta_fc2( + dataset_second_atoms, atom1, forces1, fc2, supercell, reduced_site_sym, symprec +): logger.debug("get_delta_fc2") - disp_fc2 = _get_constrained_fc2(supercell, - dataset_second_atoms, - atom1, - forces1, - reduced_site_sym, - symprec) + disp_fc2 = _get_constrained_fc2( + supercell, dataset_second_atoms, atom1, forces1, reduced_site_sym, symprec + ) return disp_fc2 - fc2 -def _get_constrained_fc2(supercell, - dataset_second_atoms, - atom1, - forces1, - reduced_site_sym, - symprec): +def _get_constrained_fc2( + supercell, dataset_second_atoms, atom1, forces1, reduced_site_sym, symprec +): """Return fc2 under reduced (broken) site symmetry by first displacement. dataset_second_atoms: [{'number': 7, @@ -354,60 +346,47 @@ def _get_constrained_fc2(supercell, positions = supercell.get_scaled_positions() num_atom = supercell.get_number_of_atoms() - fc2 = np.zeros((num_atom, num_atom, 3, 3), dtype='double') - atom_list = np.unique([x['number'] for x in dataset_second_atoms]) + fc2 = np.zeros((num_atom, num_atom, 3, 3), dtype="double") + atom_list = np.unique([x["number"] for x in dataset_second_atoms]) for atom2 in atom_list: disps2 = [] sets_of_forces = [] for disps_second in dataset_second_atoms: - if atom2 != disps_second['number']: + if atom2 != disps_second["number"]: continue bond_sym = get_bond_symmetry( - reduced_site_sym, - lattice, - positions, - atom1, - atom2, - symprec) + reduced_site_sym, lattice, positions, atom1, atom2, symprec + ) - disps2.append(disps_second['displacement']) - sets_of_forces.append(disps_second['forces'] - forces1) + disps2.append(disps_second["displacement"]) + sets_of_forces.append(disps_second["forces"] - forces1) - solve_force_constants(fc2, - atom2, - disps2, - sets_of_forces, - supercell, - bond_sym, - symprec) + solve_force_constants( + fc2, atom2, disps2, sets_of_forces, supercell, bond_sym, symprec + ) # Shift positions according to set atom1 is at origin pos_center = positions[atom1].copy() positions -= pos_center - rotations = np.array(reduced_site_sym, dtype='intc', order='C') - translations = np.zeros((len(reduced_site_sym), 3), - dtype='double', order='C') - permutations = compute_all_sg_permutations(positions, - rotations, - translations, - lattice, - symprec) - distribute_force_constants(fc2, - atom_list, - lattice, - rotations, - permutations) + rotations = np.array(reduced_site_sym, dtype="intc", order="C") + translations = np.zeros((len(reduced_site_sym), 3), dtype="double", order="C") + permutations = compute_all_sg_permutations( + positions, rotations, translations, lattice, symprec + ) + distribute_force_constants(fc2, atom_list, lattice, rotations, permutations) return fc2 -def _solve_fc3(first_atom_num, - supercell, - site_symmetry, - displacements_first, - delta_fc2s, - symprec, - pinv_solver="numpy", - verbose=False): +def _solve_fc3( + first_atom_num, + supercell, + site_symmetry, + displacements_first, + delta_fc2s, + symprec, + pinv_solver="numpy", + verbose=False, +): logger.debug("solve_fc3") if pinv_solver == "numpy": @@ -415,14 +394,14 @@ def _solve_fc3(first_atom_num, else: try: import phono3py._lapackepy as lapackepy + solver = "lapacke-dgesvd" except ImportError: print("Phono3py C-routine is not compiled correctly.") solver = "numpy.linalg.pinv" if verbose: - text = ("Computing fc3[ %d, x, x ] using %s with " % - (first_atom_num + 1, solver)) + text = "Computing fc3[ %d, x, x ] using %s with " % (first_atom_num + 1, solver) if len(displacements_first) > 1: text += "displacements:" else: @@ -434,15 +413,17 @@ def _solve_fc3(first_atom_num, if verbose > 2: print(" Site symmetry:") for i, v in enumerate(site_symmetry): - print(" [%2d %2d %2d] #%2d" % tuple(list(v[0])+[i + 1])) + print(" [%2d %2d %2d] #%2d" % tuple(list(v[0]) + [i + 1])) print(" [%2d %2d %2d]" % tuple(v[1])) print(" [%2d %2d %2d]\n" % tuple(v[2])) sys.stdout.flush() lattice = supercell.get_cell().T - site_sym_cart = np.array([similarity_transformation(lattice, sym) - for sym in site_symmetry], - dtype='double', order='C') + site_sym_cart = np.array( + [similarity_transformation(lattice, sym) for sym in site_symmetry], + dtype="double", + order="C", + ) num_atom = supercell.get_number_of_atoms() positions = supercell.get_scaled_positions() pos_center = positions[first_atom_num].copy() @@ -450,47 +431,40 @@ def _solve_fc3(first_atom_num, logger.debug("get_positions_sent_by_rot_inv") - rot_map_syms = get_positions_sent_by_rot_inv(lattice, - positions, - site_symmetry, - symprec) - rot_map_syms = np.array(rot_map_syms, dtype='int_', order='C') + rot_map_syms = get_positions_sent_by_rot_inv( + lattice, positions, site_symmetry, symprec + ) + rot_map_syms = np.array(rot_map_syms, dtype="int_", order="C") rot_disps = get_rotated_displacement(displacements_first, site_sym_cart) logger.debug("pinv") if "numpy" in solver: - inv_U = np.array(np.linalg.pinv(rot_disps), dtype='double', order='C') + inv_U = np.array(np.linalg.pinv(rot_disps), dtype="double", order="C") else: - inv_U = np.zeros((rot_disps.shape[1], rot_disps.shape[0]), - dtype='double', order='C') + inv_U = np.zeros( + (rot_disps.shape[1], rot_disps.shape[0]), dtype="double", order="C" + ) lapackepy.pinv(inv_U, rot_disps, 1e-13) - fc3 = np.zeros((num_atom, num_atom, 3, 3, 3), dtype='double', order='C') + fc3 = np.zeros((num_atom, num_atom, 3, 3, 3), dtype="double", order="C") logger.debug("rotate_delta_fc2s") try: import phono3py._phono3py as phono3c - phono3c.rotate_delta_fc2s(fc3, - delta_fc2s, - inv_U, - site_sym_cart, - rot_map_syms) + + phono3c.rotate_delta_fc2s(fc3, delta_fc2s, inv_U, site_sym_cart, rot_map_syms) except ImportError: for i, j in np.ndindex(num_atom, num_atom): - fc3[i, j] = np.dot(inv_U, _get_rotated_fc2s( - i, j, delta_fc2s, rot_map_syms, site_sym_cart) + fc3[i, j] = np.dot( + inv_U, _get_rotated_fc2s(i, j, delta_fc2s, rot_map_syms, site_sym_cart) ).reshape(3, 3, 3) return fc3 -def _cutoff_fc3(fc3, - supercell, - disp_dataset, - symmetry, - verbose=False): +def _cutoff_fc3(fc3, supercell, disp_dataset, symmetry, verbose=False): if verbose: print("Building atom mapping table...") fc3_done = _get_fc3_done(supercell, disp_dataset, symmetry, fc3.shape[:3]) @@ -502,7 +476,8 @@ def _cutoff_fc3(fc3, for j in range(i, num_atom): for k in range(j, num_atom): ave_fc3 = _set_permutation_symmetry_fc3_elem_with_cutoff( - fc3, fc3_done, i, j, k) + fc3, fc3_done, i, j, k + ) _copy_permutation_symmetry_fc3_elem(fc3, ave_fc3, i, j, k) @@ -510,12 +485,14 @@ def cutoff_fc3_by_zero(fc3, supercell, cutoff_distance, symprec=1e-5): """Set zero in fc3 elements where pair distances are larger than cutoff.""" num_atom = len(supercell) lattice = supercell.cell.T - min_distances = np.zeros((num_atom, num_atom), dtype='double') + min_distances = np.zeros((num_atom, num_atom), dtype="double") for i in range(num_atom): # run in supercell for j in range(num_atom): # run in primitive min_distances[i, j] = np.linalg.norm( - np.dot(lattice, get_smallest_vector_of_atom_pair( - i, j, supercell, symprec))) + np.dot( + lattice, get_smallest_vector_of_atom_pair(i, j, supercell, symprec) + ) + ) for i, j, k in np.ndindex(num_atom, num_atom, num_atom): for pair in ((i, j), (j, k), (k, i)): @@ -524,9 +501,7 @@ def cutoff_fc3_by_zero(fc3, supercell, cutoff_distance, symprec=1e-5): break -def show_drift_fc3(fc3, - primitive=None, - name="fc3"): +def show_drift_fc3(fc3, primitive=None, name="fc3"): """Show drift of fc3.""" if fc3.shape[0] == fc3.shape[1]: num_atom = fc3.shape[0] @@ -552,17 +527,16 @@ def show_drift_fc3(fc3, else: try: import phono3py._phono3py as phono3c + s2p_map = primitive.s2p_map p2s_map = primitive.p2s_map p2p_map = primitive.p2p_map permutations = primitive.atomic_permutations - s2pp_map, nsym_list = get_nsym_list_and_s2pp(s2p_map, - p2p_map, - permutations) - permutations = np.array(permutations, dtype='int_', order='C') - s2pp_map = np.array(s2pp_map, dtype='int_') - p2s_map = np.array(p2s_map, dtype='int_') - nsym_list = np.array(nsym_list, dtype='int_') + s2pp_map, nsym_list = get_nsym_list_and_s2pp(s2p_map, p2p_map, permutations) + permutations = np.array(permutations, dtype="int_", order="C") + s2pp_map = np.array(s2pp_map, dtype="int_") + p2s_map = np.array(p2s_map, dtype="int_") + nsym_list = np.array(nsym_list, dtype="int_") num_patom = fc3.shape[0] num_satom = fc3.shape[1] maxval1 = 0 @@ -571,23 +545,17 @@ def show_drift_fc3(fc3, klm1 = [0, 0, 0] klm2 = [0, 0, 0] klm3 = [0, 0, 0] - phono3c.transpose_compact_fc3(fc3, - permutations, - s2pp_map, - p2s_map, - nsym_list, - 0) # dim[0] <--> dim[1] + phono3c.transpose_compact_fc3( + fc3, permutations, s2pp_map, p2s_map, nsym_list, 0 + ) # dim[0] <--> dim[1] for i, j, k, l, m in np.ndindex((num_patom, num_satom, 3, 3, 3)): val1 = fc3[i, :, j, k, l, m].sum() if abs(val1) > abs(maxval1): maxval1 = val1 klm1 = [k, l, m] - phono3c.transpose_compact_fc3(fc3, - permutations, - s2pp_map, - p2s_map, - nsym_list, - 0) # dim[0] <--> dim[1] + phono3c.transpose_compact_fc3( + fc3, permutations, s2pp_map, p2s_map, nsym_list, 0 + ) # dim[0] <--> dim[1] for i, j, k, l, m in np.ndindex((num_patom, num_satom, 3, 3, 3)): val2 = fc3[i, :, j, k, l, m].sum() val3 = fc3[i, j, :, k, l, m].sum() @@ -598,51 +566,51 @@ def show_drift_fc3(fc3, maxval3 = val3 klm3 = [k, l, m] except ImportError: - text = ("Import error at phono3c.tranpose_compact_fc3. " - "Corresponding python code is not implemented.") + text = ( + "Import error at phono3c.tranpose_compact_fc3. " + "Corresponding python code is not implemented." + ) raise RuntimeError(text) text = "Max drift of %s: " % name - text += "%f (%s%s%s) " % (maxval1, - "xyz"[klm1[0]], "xyz"[klm1[1]], "xyz"[klm1[2]]) - text += "%f (%s%s%s) " % (maxval2, - "xyz"[klm2[0]], "xyz"[klm2[1]], "xyz"[klm2[2]]) - text += "%f (%s%s%s)" % (maxval3, - "xyz"[klm3[0]], "xyz"[klm3[1]], "xyz"[klm3[2]]) + text += "%f (%s%s%s) " % (maxval1, "xyz"[klm1[0]], "xyz"[klm1[1]], "xyz"[klm1[2]]) + text += "%f (%s%s%s) " % (maxval2, "xyz"[klm2[0]], "xyz"[klm2[1]], "xyz"[klm2[2]]) + text += "%f (%s%s%s)" % (maxval3, "xyz"[klm3[0]], "xyz"[klm3[1]], "xyz"[klm3[2]]) print(text) def _set_permutation_symmetry_fc3_elem_with_cutoff(fc3, fc3_done, a, b, c): - sum_done = (fc3_done[a, b, c] + - fc3_done[c, a, b] + - fc3_done[b, c, a] + - fc3_done[b, a, c] + - fc3_done[c, b, a] + - fc3_done[a, c, b]) - tensor3 = np.zeros((3, 3, 3), dtype='double') + sum_done = ( + fc3_done[a, b, c] + + fc3_done[c, a, b] + + fc3_done[b, c, a] + + fc3_done[b, a, c] + + fc3_done[c, b, a] + + fc3_done[a, c, b] + ) + tensor3 = np.zeros((3, 3, 3), dtype="double") if sum_done > 0: for (i, j, k) in list(np.ndindex(3, 3, 3)): - tensor3[i, j, k] = (fc3[a, b, c, i, j, k] * fc3_done[a, b, c] + - fc3[c, a, b, k, i, j] * fc3_done[c, a, b] + - fc3[b, c, a, j, k, i] * fc3_done[b, c, a] + - fc3[a, c, b, i, k, j] * fc3_done[a, c, b] + - fc3[b, a, c, j, i, k] * fc3_done[b, a, c] + - fc3[c, b, a, k, j, i] * fc3_done[c, b, a]) + tensor3[i, j, k] = ( + fc3[a, b, c, i, j, k] * fc3_done[a, b, c] + + fc3[c, a, b, k, i, j] * fc3_done[c, a, b] + + fc3[b, c, a, j, k, i] * fc3_done[b, c, a] + + fc3[a, c, b, i, k, j] * fc3_done[a, c, b] + + fc3[b, a, c, j, i, k] * fc3_done[b, a, c] + + fc3[c, b, a, k, j, i] * fc3_done[c, b, a] + ) tensor3[i, j, k] /= sum_done return tensor3 -def _get_fc3_least_atoms(supercell, - primitive, - disp_dataset, - fc2, - symmetry, - is_compact_fc=False, - verbose=True): +def _get_fc3_least_atoms( + supercell, primitive, disp_dataset, fc2, symmetry, is_compact_fc=False, verbose=True +): symprec = symmetry.tolerance num_satom = len(supercell) unique_first_atom_nums = np.unique( - [x['number'] for x in disp_dataset['first_atoms']]) + [x["number"] for x in disp_dataset["first_atoms"]] + ) if is_compact_fc: num_patom = primitive.get_number_of_atoms() @@ -655,45 +623,55 @@ def _get_fc3_least_atoms(supercell, raise RuntimeError else: first_atom_nums.append(i) - fc3 = np.zeros((num_patom, num_satom, num_satom, 3, 3, 3), - dtype='double', order='C') + fc3 = np.zeros( + (num_patom, num_satom, num_satom, 3, 3, 3), dtype="double", order="C" + ) else: first_atom_nums = unique_first_atom_nums - fc3 = np.zeros((num_satom, num_satom, num_satom, 3, 3, 3), - dtype='double', order='C') + fc3 = np.zeros( + (num_satom, num_satom, num_satom, 3, 3, 3), dtype="double", order="C" + ) for first_atom_num in first_atom_nums: site_symmetry = symmetry.get_site_symmetry(first_atom_num) displacements_first = [] delta_fc2s = [] - for dataset_first_atom in disp_dataset['first_atoms']: - if first_atom_num != dataset_first_atom['number']: + for dataset_first_atom in disp_dataset["first_atoms"]: + if first_atom_num != dataset_first_atom["number"]: continue - displacements_first.append(dataset_first_atom['displacement']) - if 'delta_fc2' in dataset_first_atom: - delta_fc2s.append(dataset_first_atom['delta_fc2']) + displacements_first.append(dataset_first_atom["displacement"]) + if "delta_fc2" in dataset_first_atom: + delta_fc2s.append(dataset_first_atom["delta_fc2"]) else: - direction = np.dot(dataset_first_atom['displacement'], - np.linalg.inv(supercell.get_cell())) + direction = np.dot( + dataset_first_atom["displacement"], + np.linalg.inv(supercell.get_cell()), + ) reduced_site_sym = get_reduced_site_symmetry( - site_symmetry, direction, symprec) - delta_fc2s.append(_get_delta_fc2( - dataset_first_atom['second_atoms'], - dataset_first_atom['number'], - dataset_first_atom['forces'], - fc2, - supercell, - reduced_site_sym, - symprec)) + site_symmetry, direction, symprec + ) + delta_fc2s.append( + _get_delta_fc2( + dataset_first_atom["second_atoms"], + dataset_first_atom["number"], + dataset_first_atom["forces"], + fc2, + supercell, + reduced_site_sym, + symprec, + ) + ) - fc3_first = _solve_fc3(first_atom_num, - supercell, - site_symmetry, - displacements_first, - np.array(delta_fc2s, dtype='double', order='C'), - symprec, - verbose=verbose) + fc3_first = _solve_fc3( + first_atom_num, + supercell, + site_symmetry, + displacements_first, + np.array(delta_fc2s, dtype="double", order="C"), + symprec, + verbose=verbose, + ) if is_compact_fc: fc3[p2p_map[s2p_map[first_atom_num]]] = fc3_first else: @@ -712,71 +690,68 @@ def _get_rotated_fc2s(i, j, fc2s, rot_map_syms, site_sym_cart): def _third_rank_tensor_rotation_elem(rot, tensor, ll, m, n): - sum_elems = 0. + sum_elems = 0.0 for i in (0, 1, 2): for j in (0, 1, 2): for k in (0, 1, 2): - sum_elems += (rot[ll, i] * rot[m, j] * rot[n, k] - * tensor[i, j, k]) + sum_elems += rot[ll, i] * rot[m, j] * rot[n, k] * tensor[i, j, k] return sum_elems def _get_fc3_done(supercell, disp_dataset, symmetry, array_shape): num_atom = len(supercell) - fc3_done = np.zeros(array_shape, dtype='byte') + fc3_done = np.zeros(array_shape, dtype="byte") symprec = symmetry.tolerance lattice = supercell.cell.T positions = supercell.scaled_positions - rotations = symmetry.get_symmetry_operations()['rotations'] - translations = symmetry.get_symmetry_operations()['translations'] + rotations = symmetry.get_symmetry_operations()["rotations"] + translations = symmetry.get_symmetry_operations()["translations"] atom_mapping = [] for rot, trans in zip(rotations, translations): atom_indices = [ - _get_atom_by_symmetry(lattice, - positions, - rot, - trans, - i, - symprec) for i in range(num_atom)] + _get_atom_by_symmetry(lattice, positions, rot, trans, i, symprec) + for i in range(num_atom) + ] atom_mapping.append(atom_indices) - for dataset_first_atom in disp_dataset['first_atoms']: - first_atom_num = dataset_first_atom['number'] + for dataset_first_atom in disp_dataset["first_atoms"]: + first_atom_num = dataset_first_atom["number"] site_symmetry = symmetry.get_site_symmetry(first_atom_num) - direction = np.dot(dataset_first_atom['displacement'], - np.linalg.inv(supercell.get_cell())) - reduced_site_sym = get_reduced_site_symmetry( - site_symmetry, direction, symprec) + direction = np.dot( + dataset_first_atom["displacement"], np.linalg.inv(supercell.get_cell()) + ) + reduced_site_sym = get_reduced_site_symmetry(site_symmetry, direction, symprec) least_second_atom_nums = [] - for second_atoms in dataset_first_atom['second_atoms']: - if 'included' in second_atoms: - if second_atoms['included']: - least_second_atom_nums.append(second_atoms['number']) - elif 'cutoff_distance' in disp_dataset: + for second_atoms in dataset_first_atom["second_atoms"]: + if "included" in second_atoms: + if second_atoms["included"]: + least_second_atom_nums.append(second_atoms["number"]) + elif "cutoff_distance" in disp_dataset: min_vec = get_smallest_vector_of_atom_pair( - first_atom_num, - second_atoms['number'], - supercell, - symprec) + first_atom_num, second_atoms["number"], supercell, symprec + ) min_distance = np.linalg.norm(np.dot(lattice, min_vec)) - if 'pair_distance' in second_atoms: - assert (abs(min_distance - second_atoms['pair_distance']) - < 1e-4) - if min_distance < disp_dataset['cutoff_distance']: - least_second_atom_nums.append(second_atoms['number']) + if "pair_distance" in second_atoms: + assert abs(min_distance - second_atoms["pair_distance"]) < 1e-4 + if min_distance < disp_dataset["cutoff_distance"]: + least_second_atom_nums.append(second_atoms["number"]) positions_shifted = positions - positions[first_atom_num] least_second_atom_nums = np.unique(least_second_atom_nums) for red_rot in reduced_site_sym: second_atom_nums = [ - _get_atom_by_symmetry(lattice, - positions_shifted, - red_rot, - np.zeros(3, dtype='double'), - i, - symprec) for i in least_second_atom_nums] + _get_atom_by_symmetry( + lattice, + positions_shifted, + red_rot, + np.zeros(3, dtype="double"), + i, + symprec, + ) + for i in least_second_atom_nums + ] second_atom_nums = np.unique(second_atom_nums) for i in range(len(rotations)): @@ -787,12 +762,7 @@ def _get_fc3_done(supercell, disp_dataset, symmetry, array_shape): return fc3_done -def _get_atom_by_symmetry(lattice, - positions, - rotation, - trans, - atom_number, - symprec): +def _get_atom_by_symmetry(lattice, positions, rotation, trans, atom_number, symprec): rot_pos = np.dot(positions[atom_number], rotation.T) + trans diffs = positions - rot_pos diffs -= np.rint(diffs) diff --git a/phono3py/phonon3/gruneisen.py b/phono3py/phonon3/gruneisen.py index 423c72bb..6b71fd0a 100644 --- a/phono3py/phonon3/gruneisen.py +++ b/phono3py/phonon3/gruneisen.py @@ -41,21 +41,23 @@ from phonopy.structure.grid_points import get_qpoints from phonopy.structure.cells import sparse_to_dense_svecs -def run_gruneisen_parameters(fc2, - fc3, - supercell, - primitive, - band_paths, - mesh, - rotations, - qpoints, - nac_params=None, - nac_q_direction=None, - ion_clamped=False, - factor=None, - symprec=1e-5, - output_filename=None, - log_level=1): +def run_gruneisen_parameters( + fc2, + fc3, + supercell, + primitive, + band_paths, + mesh, + rotations, + qpoints, + nac_params=None, + nac_q_direction=None, + ion_clamped=False, + factor=None, + symprec=1e-5, + output_filename=None, + log_level=1, +): """Run mode Grueneisen parameter calculation. The results is written into files. @@ -68,32 +70,34 @@ def run_gruneisen_parameters(fc2, elif band_paths is not None: print("Paths in reciprocal reduced coordinates:") for path in band_paths: - print("[%5.2f %5.2f %5.2f] --> [%5.2f %5.2f %5.2f]" % - (tuple(path[0]) + tuple(path[-1]))) + print( + "[%5.2f %5.2f %5.2f] --> [%5.2f %5.2f %5.2f]" + % (tuple(path[0]) + tuple(path[-1])) + ) if ion_clamped: print("To be calculated with ion clamped.") sys.stdout.flush() - gruneisen = Gruneisen(fc2, - fc3, - supercell, - primitive, - nac_params=nac_params, - nac_q_direction=nac_q_direction, - ion_clamped=ion_clamped, - factor=factor, - symprec=symprec) + gruneisen = Gruneisen( + fc2, + fc3, + supercell, + primitive, + nac_params=nac_params, + nac_q_direction=nac_q_direction, + ion_clamped=ion_clamped, + factor=factor, + symprec=symprec, + ) if log_level > 0: dm = gruneisen.dynamical_matrix - if (dm.is_nac() and dm.nac_method == 'gonze'): + if dm.is_nac() and dm.nac_method == "gonze": dm.show_Gonze_nac_message() if mesh is not None: - gruneisen.set_sampling_mesh(mesh, - rotations=rotations, - is_gamma_center=True) + gruneisen.set_sampling_mesh(mesh, rotations=rotations, is_gamma_center=True) filename_ext = ".hdf5" elif band_paths is not None: gruneisen.set_band_structure(band_paths) @@ -105,29 +109,30 @@ def run_gruneisen_parameters(fc2, gruneisen.run() if output_filename is None: - filename = 'gruneisen' + filename = "gruneisen" else: - filename = 'gruneisen.' + output_filename + filename = "gruneisen." + output_filename gruneisen.write(filename=filename) if log_level: - print("Gruneisen parameters are written in %s" % - (filename + filename_ext)) + print("Gruneisen parameters are written in %s" % (filename + filename_ext)) class Gruneisen(object): """Calculat mode Grueneisen parameters from fc3.""" - def __init__(self, - fc2, - fc3, - supercell, - primitive, - nac_params=None, - nac_q_direction=None, - ion_clamped=False, - factor=VaspToTHz, - symprec=1e-5): + def __init__( + self, + fc2, + fc3, + supercell, + primitive, + nac_params=None, + nac_q_direction=None, + ion_clamped=False, + factor=VaspToTHz, + symprec=1e-5, + ): """Init method.""" self._fc2 = fc2 self._fc3 = fc3 @@ -136,11 +141,13 @@ class Gruneisen(object): self._ion_clamped = ion_clamped self._factor = factor self._symprec = symprec - self._dm = get_dynamical_matrix(self._fc2, - self._scell, - self._pcell, - nac_params=nac_params, - symprec=self._symprec) + self._dm = get_dynamical_matrix( + self._fc2, + self._scell, + self._pcell, + nac_params=nac_params, + symprec=self._symprec, + ) self._nac_q_direction = nac_q_direction svecs, multi = self._pcell.get_smallest_vectors() @@ -168,14 +175,18 @@ class Gruneisen(object): def run(self): """Run mode Grueneisen parameter calculation.""" - if self._run_mode == 'band': - (self._gruneisen_parameters, - self._frequencies) = self._calculate_band_paths() - elif self._run_mode == 'qpoints' or self._run_mode == 'mesh': - (self._gruneisen_parameters, - self._frequencies) = self._calculate_at_qpoints(self._qpoints) + if self._run_mode == "band": + ( + self._gruneisen_parameters, + self._frequencies, + ) = self._calculate_band_paths() + elif self._run_mode == "qpoints" or self._run_mode == "mesh": + ( + self._gruneisen_parameters, + self._frequencies, + ) = self._calculate_at_qpoints(self._qpoints) else: - sys.stderr.write('Q-points are not specified.\n') + sys.stderr.write("Q-points are not specified.\n") @property def dynamical_matrix(self): @@ -188,60 +199,58 @@ class Gruneisen(object): def set_qpoints(self, qpoints): """Set q-points.""" - self._run_mode = 'qpoints' + self._run_mode = "qpoints" self._qpoints = qpoints - def set_sampling_mesh(self, - mesh, - rotations=None, - shift=None, - is_gamma_center=False): + def set_sampling_mesh( + self, mesh, rotations=None, shift=None, is_gamma_center=False + ): """Set sampling mesh.""" - self._run_mode = 'mesh' - self._mesh = np.array(mesh, dtype='intc') + self._run_mode = "mesh" + self._mesh = np.array(mesh, dtype="intc") self._qpoints, self._weights = get_qpoints( self._mesh, np.linalg.inv(self._pcell.cell), q_mesh_shift=shift, is_gamma_center=is_gamma_center, - rotations=rotations) + rotations=rotations, + ) def set_band_structure(self, paths): """Set band structure paths.""" - self._run_mode = 'band' + self._run_mode = "band" self._band_paths = paths rec_lattice = np.linalg.inv(self._pcell.get_cell()) self._band_distances = [] for path in paths: - distances_at_path = [0.] + distances_at_path = [0.0] for i in range(len(path) - 1): - distances_at_path.append(np.linalg.norm( - np.dot(rec_lattice, path[i + 1] - path[i])) + - distances_at_path[-1]) + distances_at_path.append( + np.linalg.norm(np.dot(rec_lattice, path[i + 1] - path[i])) + + distances_at_path[-1] + ) self._band_distances.append(distances_at_path) def write(self, filename="gruneisen"): """Write result in a file.""" if self._gruneisen_parameters is not None: - if self._run_mode == 'band': + if self._run_mode == "band": self._write_band_yaml(filename + ".yaml") - elif self._run_mode == 'qpoints': + elif self._run_mode == "qpoints": self._write_mesh_yaml(filename + ".yaml") - elif self._run_mode == 'mesh': + elif self._run_mode == "mesh": self._write_mesh_hdf5(filename + ".hdf5") def _write_mesh_yaml(self, filename): - with open(filename, 'w') as f: - if self._run_mode == 'mesh': + with open(filename, "w") as f: + if self._run_mode == "mesh": f.write("mesh: [ %5d, %5d, %5d ]\n" % tuple(self._mesh)) f.write("nqpoint: %d\n" % len(self._qpoints)) f.write("phonon:\n") for i, (q, g_at_q, freqs_at_q) in enumerate( - zip(self._qpoints, - self._gruneisen_parameters, - self._frequencies)): - f.write("- q-position: [ %10.7f, %10.7f, %10.7f ]\n" - % tuple(q)) + zip(self._qpoints, self._gruneisen_parameters, self._frequencies) + ): + f.write("- q-position: [ %10.7f, %10.7f, %10.7f ]\n" % tuple(q)) if self._weights is not None: f.write(" multiplicity: %d\n" % self._weights[i]) f.write(" band:\n") @@ -251,22 +260,23 @@ class Gruneisen(object): f.write(" gruneisen: %15.10f\n" % (g.trace() / 3)) f.write(" gruneisen_tensor:\n") for g_xyz in g: - f.write(" - [ %10.7f, %10.7f, %10.7f ]\n" % - tuple(g_xyz)) + f.write(" - [ %10.7f, %10.7f, %10.7f ]\n" % tuple(g_xyz)) def _write_band_yaml(self, filename): - with open(filename, 'w') as f: + with open(filename, "w") as f: f.write("path:\n\n") - for path, distances, gs, fs in zip(self._band_paths, - self._band_distances, - self._gruneisen_parameters, - self._frequencies): + for path, distances, gs, fs in zip( + self._band_paths, + self._band_distances, + self._gruneisen_parameters, + self._frequencies, + ): f.write("- nqpoint: %d\n" % len(path)) f.write(" phonon:\n") for i, (q, d, g_at_q, freqs_at_q) in enumerate( - zip(path, distances, gs, fs)): # noqa E125 - f.write(" - q-position: [ %10.7f, %10.7f, %10.7f ]\n" - % tuple(q)) + zip(path, distances, gs, fs) + ): # noqa E125 + f.write(" - q-position: [ %10.7f, %10.7f, %10.7f ]\n" % tuple(q)) f.write(" distance: %10.7f\n" % d) f.write(" band:\n") for j, (g, freq) in enumerate(zip(g_at_q, freqs_at_q)): @@ -275,8 +285,9 @@ class Gruneisen(object): f.write(" gruneisen: %15.10f\n" % (g.trace() / 3)) f.write(" gruneisen_tensor:\n") for g_xyz in g: - f.write(" - [ %10.7f, %10.7f, %10.7f ]\n" % - tuple(g_xyz)) + f.write( + " - [ %10.7f, %10.7f, %10.7f ]\n" % tuple(g_xyz) + ) f.write("\n") def _write_mesh_hdf5(self, filename="gruneisen.hdf5"): @@ -285,16 +296,17 @@ class Gruneisen(object): g = self._gruneisen_parameters gruneisen = np.array( (g[:, :, 0, 0] + g[:, :, 1, 1] + g[:, :, 2, 2]) / 3, - dtype='double', order='C') + dtype="double", + order="C", + ) - with h5py.File(filename, 'w') as w: - w.create_dataset('mesh', data=self._mesh) - w.create_dataset('gruneisen', data=gruneisen) - w.create_dataset('gruneisen_tensor', - data=self._gruneisen_parameters) - w.create_dataset('weight', data=self._weights) - w.create_dataset('frequency', data=self._frequencies) - w.create_dataset('qpoint', data=self._qpoints) + with h5py.File(filename, "w") as w: + w.create_dataset("mesh", data=self._mesh) + w.create_dataset("gruneisen", data=gruneisen) + w.create_dataset("gruneisen_tensor", data=self._gruneisen_parameters) + w.create_dataset("weight", data=self._weights) + w.create_dataset("frequency", data=self._frequencies) + w.create_dataset("qpoint", data=self._qpoints) def _calculate_at_qpoints(self, qpoints): gruneisen_parameters = [] @@ -302,7 +314,7 @@ class Gruneisen(object): for i, q in enumerate(qpoints): if self._dm.is_nac(): if (np.abs(q) < 1e-5).all(): # If q is almost at Gamma - if self._run_mode == 'band': + if self._run_mode == "band": # Direction estimated from neighboring point if i > 0: q_dir = qpoints[i] - qpoints[i - 1] @@ -310,29 +322,28 @@ class Gruneisen(object): q_dir = qpoints[i + 1] - qpoints[i] else: q_dir = None - g, omega2 = self._get_gruneisen_tensor( - q, nac_q_direction=q_dir) + g, omega2 = self._get_gruneisen_tensor(q, nac_q_direction=q_dir) else: # Specified q-vector g, omega2 = self._get_gruneisen_tensor( - q, nac_q_direction=self._nac_q_direction) + q, nac_q_direction=self._nac_q_direction + ) else: # If q is away from Gamma-point, then q-vector - g, omega2 = self._get_gruneisen_tensor( - q, nac_q_direction=q) + g, omega2 = self._get_gruneisen_tensor(q, nac_q_direction=q) else: # Without NAC g, omega2 = self._get_gruneisen_tensor(q) gruneisen_parameters.append(g) - frequencies.append( - np.sqrt(abs(omega2)) * np.sign(omega2) * self._factor) + frequencies.append(np.sqrt(abs(omega2)) * np.sign(omega2) * self._factor) - return (np.array(gruneisen_parameters, dtype='double', order='C'), - np.array(frequencies, dtype='double', order='C')) + return ( + np.array(gruneisen_parameters, dtype="double", order="C"), + np.array(frequencies, dtype="double", order="C"), + ) def _calculate_band_paths(self): gruneisen_parameters = [] frequencies = [] for path in self._band_paths: - (gruneisen_at_path, - frequencies_at_path) = self._calculate_at_qpoints(path) + (gruneisen_at_path, frequencies_at_path) = self._calculate_at_qpoints(path) gruneisen_parameters.append(gruneisen_at_path) frequencies.append(frequencies_at_path) @@ -355,9 +366,11 @@ class Gruneisen(object): for j in range(3): for nu in range(num_atom_prim): for pi in range(num_atom_prim): - g[s] += (w[nu * 3 + i, s].conjugate() * - dDdu[nu, pi, i, j] * w[pi * 3 + j, s] - ).real + g[s] += ( + w[nu * 3 + i, s].conjugate() + * dDdu[nu, pi, i, j] + * w[pi * 3 + j, s] + ).real g[s] *= -1.0 / 2 / omega2[s] @@ -365,13 +378,11 @@ class Gruneisen(object): def _get_dDdu(self, q): num_atom_prim = len(self._pcell) - num_atom_super = len(self._scell) p2s = self._pcell.p2s_map s2p = self._pcell.s2p_map m = self._pcell.masses dPhidu = self._dPhidu - dDdu = np.zeros((num_atom_prim, num_atom_prim, 3, 3, 3, 3), - dtype=complex) + dDdu = np.zeros((num_atom_prim, num_atom_prim, 3, 3, 3, 3), dtype=complex) for nu in range(num_atom_prim): for pi, p in enumerate(p2s): @@ -380,9 +391,14 @@ class Gruneisen(object): continue adrs = self._multi[Ppi, nu][1] multi = self._multi[Ppi, nu][0] - phase = np.exp(2j * np.pi * np.dot( - self._svecs[adrs:(adrs + multi), :], q) - ).sum() / multi + phase = ( + np.exp( + 2j + * np.pi + * np.dot(self._svecs[adrs : (adrs + multi), :], q) + ).sum() + / multi + ) dDdu[nu, pi] += phase * dPhidu[nu, Ppi] dDdu[nu, pi] /= np.sqrt(m[nu] * m[pi]) @@ -393,8 +409,7 @@ class Gruneisen(object): num_atom_prim = len(self._pcell) num_atom_super = len(self._scell) p2s = self._pcell.p2s_map - dPhidu = np.zeros((num_atom_prim, num_atom_super, 3, 3, 3, 3), - dtype=float) + dPhidu = np.zeros((num_atom_prim, num_atom_super, 3, 3, 3, 3), dtype=float) for nu in range(num_atom_prim): Y = self._get_Y(nu) @@ -405,20 +420,18 @@ class Gruneisen(object): for ll in range(3): for m in range(3): dPhidu[nu, pi, i, j, k, ll] = ( - fc3[p2s[nu], pi, :, i, j, :] * - Y[:, :, k, ll]).sum() + fc3[p2s[nu], pi, :, i, j, :] * Y[:, :, k, ll] + ).sum() # Symmetrization? # (Y[:,:,k,l] + Y[:,:,l,k]) / 2).sum() return dPhidu def _get_Y(self, nu): - P = self._fc2 X = self._X lat = self._pcell.cell num_atom_super = len(self._scell) R = self._get_R(num_atom_super, nu, lat) - p2s = self._pcell.p2s_map s2p = self._pcell.s2p_map p2p = self._pcell.p2p_map @@ -447,8 +460,9 @@ class Gruneisen(object): for j in range(3): for k in range(3): for ll in range(3): - X[mu, i, j, k] -= G[mu, nu, i, ll] * \ - np.dot(P[p2s[nu], :, ll, j], R[:, k]) + X[mu, i, j, k] -= G[mu, nu, i, ll] * np.dot( + P[p2s[nu], :, ll, j], R[:, k] + ) return X @@ -457,8 +471,9 @@ class Gruneisen(object): for Npi in range(num_atom_super): adrs = self._multi[Npi, nu][1] multi = self._multi[Npi, nu][0] - R.append(np.dot(self._svecs[adrs:(adrs + multi), :].sum(axis=0) / - multi, lat)) + R.append( + np.dot(self._svecs[adrs : (adrs + multi), :].sum(axis=0) / multi, lat) + ) return np.array(R) def _get_Gamma(self): @@ -475,7 +490,10 @@ class Gruneisen(object): # Eigenvectors are real. # 3: means optical modes G[pi, mu, k, i] = ( - 1.0 / np.sqrt(m[pi] * m[mu]) * - (vecs[pi * 3 + k, 3:] * vecs[mu * 3 + i, 3:] / - vals[3:]).sum()) + 1.0 + / np.sqrt(m[pi] * m[mu]) + * ( + vecs[pi * 3 + k, 3:] * vecs[mu * 3 + i, 3:] / vals[3:] + ).sum() + ) return G diff --git a/phono3py/phonon3/imag_self_energy.py b/phono3py/phonon3/imag_self_energy.py index 1b856f11..84bdb35a 100644 --- a/phono3py/phonon3/imag_self_energy.py +++ b/phono3py/phonon3/imag_self_energy.py @@ -1,3 +1,4 @@ +"""Calculation of imaginary-part of self-energy of bubble diagram.""" # Copyright (C) 2020 Atsushi Togo # All rights reserved. # @@ -33,32 +34,38 @@ # POSSIBILITY OF SUCH DAMAGE. import sys +from typing import List, Optional import numpy as np from phonopy.units import Hbar, EV, THz from phonopy.phonon.degeneracy import degenerate_sets +from phono3py.phonon3.interaction import Interaction from phono3py.phonon3.triplets import get_triplets_integration_weights from phono3py.phonon.func import bose_einstein -from phono3py.file_IO import (write_gamma_detail_to_hdf5, - write_imag_self_energy_at_grid_point) +from phono3py.file_IO import ( + write_gamma_detail_to_hdf5, + write_imag_self_energy_at_grid_point, +) -def get_imag_self_energy(interaction, - grid_points, - temperatures, - sigmas=None, - frequency_points=None, - frequency_step=None, - num_frequency_points=None, - frequency_points_at_bands=False, - num_points_in_batch=None, - scattering_event_class=None, # class 1 or 2 - write_gamma_detail=False, - return_gamma_detail=False, - output_filename=None, - log_level=0): - """Imaginary part of self energy at frequency points +def get_imag_self_energy( + interaction: Interaction, + grid_points, + temperatures, + sigmas=None, + frequency_points=None, + frequency_step=None, + num_frequency_points=None, + frequency_points_at_bands=False, + num_points_in_batch=None, + scattering_event_class=None, # class 1 or 2 + write_gamma_detail=False, + return_gamma_detail=False, + output_filename=None, + log_level=0, +): + """Imaginary-part of self-energy at frequency points. - Band indices to be calculated at are kept in Interaction instance. + Band indices to be calculated at are found in Interaction instance. Parameters ---------- @@ -136,9 +143,10 @@ def get_imag_self_energy(interaction, band_indices, num_band, num_band) """ - if sigmas is None: - _sigmas = [None, ] + _sigmas = [ + None, + ] else: _sigmas = sigmas @@ -150,29 +158,41 @@ def get_imag_self_energy(interaction, frequencies = interaction.get_phonons()[0] max_phonon_freq = np.amax(frequencies) num_band0 = len(interaction.band_indices) - mesh = interaction.mesh_numbers if frequency_points_at_bands: _frequency_points = None _num_frequency_points = num_band0 - gamma = np.zeros((len(_sigmas), len(temperatures), len(grid_points), - _num_frequency_points), dtype='double', order='C') + gamma = np.zeros( + (len(_sigmas), len(temperatures), len(grid_points), _num_frequency_points), + dtype="double", + order="C", + ) else: _frequency_points = get_frequency_points( max_phonon_freq=max_phonon_freq, sigmas=_sigmas, frequency_points=frequency_points, frequency_step=frequency_step, - num_frequency_points=num_frequency_points) + num_frequency_points=num_frequency_points, + ) _num_frequency_points = len(_frequency_points) gamma = np.zeros( - (len(_sigmas), len(temperatures), len(grid_points), - num_band0, _num_frequency_points), dtype='double', order='C') + ( + len(_sigmas), + len(temperatures), + len(grid_points), + num_band0, + _num_frequency_points, + ), + dtype="double", + order="C", + ) - detailed_gamma = [] + detailed_gamma: List[Optional[np.ndarray]] = [] ise = ImagSelfEnergy( - interaction, with_detail=(write_gamma_detail or return_gamma_detail)) + interaction, with_detail=(write_gamma_detail or return_gamma_detail) + ) for i, gp in enumerate(grid_points): ise.set_grid_point(gp) @@ -180,42 +200,46 @@ def get_imag_self_energy(interaction, bz_grid = interaction.bz_grid weights = interaction.get_triplets_at_q()[1] if len(grid_points) > 1: - print("---------------- Imaginary part of self energy -o- (%d/%d) " - "----------------" % (i + 1, len(grid_points))) + print( + "---------------- Imaginary part of self energy -o- (%d/%d) " + "----------------" % (i + 1, len(grid_points)) + ) else: - print("-------------------- Imaginary part of self energy -o- " - "--------------------") + print( + "-------------------- Imaginary part of self energy -o- " + "--------------------" + ) print("Grid point: %d" % gp) - print("Number of ir-triplets: " - "%d / %d" % (len(weights), weights.sum())) + print("Number of ir-triplets: " "%d / %d" % (len(weights), weights.sum())) ise.run_interaction() frequencies = interaction.get_phonons()[0][gp] if log_level: qpoint = np.dot(bz_grid.QDinv, bz_grid.addresses[gp]) - print("Phonon frequencies at (%4.2f, %4.2f, %4.2f):" - % tuple(qpoint)) + print("Phonon frequencies at (%4.2f, %4.2f, %4.2f):" % tuple(qpoint)) for bi, freq in enumerate(frequencies): print("%3d %f" % (bi + 1, freq)) sys.stdout.flush() - _get_imag_self_energy_at_gp(gamma, - detailed_gamma, - i, - gp, - _sigmas, - temperatures, - _frequency_points, - _num_frequency_points, - scattering_event_class, - num_points_in_batch, - interaction, - ise, - write_gamma_detail, - return_gamma_detail, - output_filename, - log_level) + _get_imag_self_energy_at_gp( + gamma, + detailed_gamma, + i, + gp, + _sigmas, + temperatures, + _frequency_points, + _num_frequency_points, + scattering_event_class, + num_points_in_batch, + interaction, + ise, + write_gamma_detail, + return_gamma_detail, + output_filename, + log_level, + ) if return_gamma_detail: return _frequency_points, gamma, detailed_gamma @@ -223,22 +247,24 @@ def get_imag_self_energy(interaction, return _frequency_points, gamma -def _get_imag_self_energy_at_gp(gamma, - detailed_gamma, - i, - gp, - _sigmas, - temperatures, - _frequency_points, - _num_frequency_points, - scattering_event_class, - num_points_in_batch, - interaction, - ise, - write_gamma_detail, - return_gamma_detail, - output_filename, - log_level): +def _get_imag_self_energy_at_gp( + gamma, + detailed_gamma, + i, + gp, + _sigmas, + temperatures, + _frequency_points, + _num_frequency_points, + scattering_event_class, + num_points_in_batch, + interaction, + ise, + write_gamma_detail, + return_gamma_detail, + output_filename, + log_level, +): num_band0 = len(interaction.band_indices) frequencies = interaction.get_phonons()[0] mesh = interaction.mesh_numbers @@ -248,14 +274,29 @@ def _get_imag_self_energy_at_gp(gamma, num_band = frequencies.shape[1] if _frequency_points is None: detailed_gamma_at_gp = np.zeros( - (len(_sigmas), len(temperatures), - len(weights), num_band0, num_band, num_band), - dtype='double') + ( + len(_sigmas), + len(temperatures), + len(weights), + num_band0, + num_band, + num_band, + ), + dtype="double", + ) else: detailed_gamma_at_gp = np.zeros( - (len(_sigmas), len(temperatures), _num_frequency_points, - len(weights), num_band0, num_band, num_band), - dtype='double') + ( + len(_sigmas), + len(temperatures), + _num_frequency_points, + len(weights), + num_band0, + num_band, + num_band, + ), + dtype="double", + ) else: detailed_gamma_at_gp = None @@ -267,18 +308,20 @@ def _get_imag_self_energy_at_gp(gamma, print("Tetrahedron method is used for BZ integration.") ise.set_sigma(sigma) - _get_imag_self_energy_at_sigma(gamma, - detailed_gamma_at_gp, - i, - j, - temperatures, - _frequency_points, - scattering_event_class, - num_points_in_batch, - ise, - write_gamma_detail, - return_gamma_detail, - log_level) + _get_imag_self_energy_at_sigma( + gamma, + detailed_gamma_at_gp, + i, + j, + temperatures, + _frequency_points, + scattering_event_class, + num_points_in_batch, + ise, + write_gamma_detail, + return_gamma_detail, + log_level, + ) if write_gamma_detail: full_filename = write_gamma_detail_to_hdf5( @@ -290,28 +333,33 @@ def _get_imag_self_energy_at_gp(gamma, weight=weights, sigma=sigma, frequency_points=_frequency_points, - filename=output_filename) + filename=output_filename, + ) if log_level: - print("Contribution of each triplet to imaginary part of " - "self energy is written in\n\"%s\"." % full_filename) + print( + "Contribution of each triplet to imaginary part of " + 'self energy is written in\n"%s".' % full_filename + ) if return_gamma_detail: detailed_gamma.append(detailed_gamma_at_gp) -def _get_imag_self_energy_at_sigma(gamma, - detailed_gamma_at_gp, - i, - j, - temperatures, - _frequency_points, - scattering_event_class, - num_points_in_batch, - ise, - write_gamma_detail, - return_gamma_detail, - log_level): +def _get_imag_self_energy_at_sigma( + gamma, + detailed_gamma_at_gp, + i, + j, + temperatures, + _frequency_points, + scattering_event_class, + num_points_in_batch, + ise, + write_gamma_detail, + return_gamma_detail, + log_level, +): # Run one by one at frequency points if detailed_gamma_at_gp is None: detailed_gamma_at_gp_at_j = None @@ -319,15 +367,13 @@ def _get_imag_self_energy_at_sigma(gamma, detailed_gamma_at_gp_at_j = detailed_gamma_at_gp[j] if _frequency_points is None: - ise.set_integration_weights( - scattering_event_class=scattering_event_class) + ise.set_integration_weights(scattering_event_class=scattering_event_class) for k, t in enumerate(temperatures): ise.set_temperature(t) ise.run() gamma[j, k, i] = ise.get_imag_self_energy() if write_gamma_detail or return_gamma_detail: - detailed_gamma_at_gp[k] = ( - ise.get_detailed_imag_self_energy()) + detailed_gamma_at_gp[k] = ise.get_detailed_imag_self_energy() else: run_ise_at_frequency_points_batch( i, @@ -341,14 +387,23 @@ def _get_imag_self_energy_at_sigma(gamma, detailed_gamma_at_gp=detailed_gamma_at_gp_at_j, scattering_event_class=scattering_event_class, nelems_in_batch=num_points_in_batch, - log_level=log_level) + log_level=log_level, + ) -def get_frequency_points(max_phonon_freq=None, - sigmas=None, - frequency_points=None, - frequency_step=None, - num_frequency_points=None): +def get_frequency_points( + max_phonon_freq=None, + sigmas=None, + frequency_points=None, + frequency_step=None, + num_frequency_points=None, +): + """Generate frequency points. + + This function may be mostly used for the phonon frequency axis of + spectrum-like calculations. + + """ if frequency_points is None: if sigmas is not None: sigma_vals = [sigma for sigma in sigmas if sigma is not None] @@ -364,42 +419,44 @@ def get_frequency_points(max_phonon_freq=None, fmin, fmax, frequency_step=frequency_step, - num_frequency_points=num_frequency_points) + num_frequency_points=num_frequency_points, + ) else: - _frequency_points = np.array(frequency_points, dtype='double') + _frequency_points = np.array(frequency_points, dtype="double") return _frequency_points -def _sample_frequency_points(f_min, - f_max, - frequency_step=None, - num_frequency_points=None): +def _sample_frequency_points( + f_min, f_max, frequency_step=None, num_frequency_points=None +): if num_frequency_points is None: if frequency_step is not None: - frequency_points = np.arange( - f_min, f_max, frequency_step, dtype='double') + frequency_points = np.arange(f_min, f_max, frequency_step, dtype="double") else: - frequency_points = np.array(np.linspace( - f_min, f_max, 201), dtype='double') + frequency_points = np.array(np.linspace(f_min, f_max, 201), dtype="double") else: - frequency_points = np.array(np.linspace( - f_min, f_max, num_frequency_points), dtype='double') + frequency_points = np.array( + np.linspace(f_min, f_max, num_frequency_points), dtype="double" + ) return frequency_points -def write_imag_self_energy(imag_self_energy, - mesh, - grid_points, - band_indices, - frequency_points, - temperatures, - sigmas, - scattering_event_class=None, - output_filename=None, - is_mesh_symmetry=True, - log_level=0): +def write_imag_self_energy( + imag_self_energy, + mesh, + grid_points, + band_indices, + frequency_points, + temperatures, + sigmas, + scattering_event_class=None, + output_filename=None, + is_mesh_symmetry=True, + log_level=0, +): + """Write imaginary-part of self-energies into text files.""" for sigma, ise_temps in zip(sigmas, imag_self_energy): for t, ise_gps in zip(temperatures, ise_temps): for gp, ise in zip(grid_points, ise_gps): @@ -412,18 +469,22 @@ def write_imag_self_energy(imag_self_energy, bi, mesh, frequency_points, - ise[pos:(pos + len(bi))].sum(axis=0) / len(bi), + ise[pos : (pos + len(bi))].sum(axis=0) / len(bi), sigma=sigma, temperature=t, scattering_event_class=scattering_event_class, filename=output_filename, - is_mesh_symmetry=is_mesh_symmetry) + is_mesh_symmetry=is_mesh_symmetry, + ) if log_level: - print("Imaginary parts of self-energies were " - "written to \"%s\"." % filename) + print( + "Imaginary part of self-energies were " + 'written to "%s".' % filename + ) def average_by_degeneracy(imag_self_energy, band_indices, freqs_at_gp): + """Take averages of values of energetically degenerated bands.""" deg_sets = degenerate_sets(freqs_at_gp) imag_se = np.zeros_like(imag_self_energy) for dset in deg_sets: @@ -433,32 +494,97 @@ def average_by_degeneracy(imag_self_energy, band_indices, freqs_at_gp): bi_set.append(i) for i in bi_set: if imag_self_energy.ndim == 1: - imag_se[i] = (imag_self_energy[bi_set].sum() / - len(bi_set)) + imag_se[i] = imag_self_energy[bi_set].sum() / len(bi_set) else: - imag_se[:, i] = ( - imag_self_energy[:, bi_set].sum(axis=1) / - len(bi_set)) + imag_se[:, i] = imag_self_energy[:, bi_set].sum(axis=1) / len(bi_set) return imag_se -class ImagSelfEnergy(object): - def __init__(self, - interaction, - frequency_points=None, - temperature=None, - sigma=None, - sigma_cutoff=None, - with_detail=False, - unit_conversion=None, - lang='C'): +def run_ise_at_frequency_points_batch( + i, + j, + _frequency_points, + ise, + temperatures, + gamma, + write_gamma_detail=False, + return_gamma_detail=False, + detailed_gamma_at_gp=None, + scattering_event_class=None, + nelems_in_batch=50, + log_level=0, +): + """Run calculations at frequency points batch by batch. + + See the details about batch in docstring of ``get_imag_self_energy``. + + """ + if nelems_in_batch is None: + _nelems_in_batch = 10 + else: + _nelems_in_batch = nelems_in_batch + + batches = _get_batches(len(_frequency_points), _nelems_in_batch) + + if log_level: + print( + "Calculations at %d frequency points are devided into " + "%d batches." % (len(_frequency_points), len(batches)) + ) + + for bi, fpts_batch in enumerate(batches): + if log_level: + print("%d/%d: %s" % (bi + 1, len(batches), fpts_batch + 1)) + sys.stdout.flush() + + ise.set_frequency_points(_frequency_points[fpts_batch]) + ise.set_integration_weights(scattering_event_class=scattering_event_class) + for ll, t in enumerate(temperatures): + ise.set_temperature(t) + ise.run() + gamma[j, ll, i, :, fpts_batch] = ise.get_imag_self_energy() + if write_gamma_detail or return_gamma_detail: + detailed_gamma_at_gp[ + ll, fpts_batch + ] = ise.get_detailed_imag_self_energy() + + +def _get_batches(tot_nelems, nelems=10): + nbatch = tot_nelems // nelems + batches = [np.arange(i * nelems, (i + 1) * nelems) for i in range(nbatch)] + if tot_nelems % nelems > 0: + batches.append(np.arange(nelems * nbatch, tot_nelems)) + return batches + + +class ImagSelfEnergy: + """Class for imaginary-part of self-energy of bubble diagram.""" + + def __init__( + self, + interaction: Interaction, + with_detail=False, + lang="C", + ): + """Init method. + + Band indices to be calculated at are kept in Interaction instance. + + Parameters + ---------- + interaction : Interaction + Class instance of ph-ph interaction. + with_detail : bool, optional + Contributions to gammas for each triplets are computed. Default is + False. + lang : str, optional + This is used for debugging purpose. + + """ self._pp = interaction self._sigma = None - self.set_sigma(sigma, sigma_cutoff=sigma_cutoff) self._temperature = None - self.set_temperature(temperature) self._frequency_points = None - self.set_frequency_points(frequency_points) self._grid_point = None self._lang = lang @@ -469,51 +595,50 @@ class ImagSelfEnergy(object): self._triplets_at_q = None self._weights_at_q = None self._with_detail = with_detail - self._unit_conversion = None self._cutoff_frequency = interaction.cutoff_frequency self._g = None # integration weights self._g_zero = None # Necessary elements of interaction strength self._g_zero_frequency_points = None - self._g_zero_zeros = None # always zeros for frequency sampling mode + self._g_zero_zeros = None # always zeros for frequency sampling mode self._is_collision_matrix = False # Unit to THz of Gamma - if unit_conversion is None: - self._unit_conversion = (18 * np.pi / (Hbar * EV) ** 2 - / (2 * np.pi * THz) ** 2 - * EV ** 2) - else: - self._unit_conversion = unit_conversion + self._unit_conversion = ( + 18 * np.pi / (Hbar * EV) ** 2 / (2 * np.pi * THz) ** 2 * EV ** 2 + ) def run(self): + """Calculate imaginary-part of self-energies.""" if self._pp_strength is None: self.run_interaction() num_band0 = self._pp_strength.shape[1] if self._frequency_points is None: - self._imag_self_energy = np.zeros(num_band0, dtype='double') + self._imag_self_energy = np.zeros(num_band0, dtype="double") if self._with_detail: - self._detailed_imag_self_energy = np.empty_like( - self._pp_strength) + self._detailed_imag_self_energy = np.empty_like(self._pp_strength) self._detailed_imag_self_energy[:] = 0 self._ise_N = np.zeros_like(self._imag_self_energy) self._ise_U = np.zeros_like(self._imag_self_energy) self._run_with_band_indices() else: self._imag_self_energy = np.zeros( - (len(self._frequency_points), num_band0), - order='C', dtype='double') + (len(self._frequency_points), num_band0), order="C", dtype="double" + ) if self._with_detail: self._detailed_imag_self_energy = np.zeros( (len(self._frequency_points),) + self._pp_strength.shape, - order='C', dtype='double') + order="C", + dtype="double", + ) self._ise_N = np.zeros_like(self._imag_self_energy) self._ise_U = np.zeros_like(self._imag_self_energy) self._run_with_frequency_points() def run_interaction(self, is_full_pp=True): + """Calculate ph-ph interaction.""" if is_full_pp or self._frequency_points is not None: self._pp.run(lang=self._lang) else: @@ -521,6 +646,7 @@ class ImagSelfEnergy(object): self._pp_strength = self._pp.interaction_strength def set_integration_weights(self, scattering_event_class=None): + """Compute integration weights at grid points.""" if self._frequency_points is None: bi = self._pp.band_indices f_points = self._frequencies[self._grid_point][bi] @@ -529,10 +655,11 @@ class ImagSelfEnergy(object): self._g, _g_zero = get_triplets_integration_weights( self._pp, - np.array(f_points, dtype='double'), + np.array(f_points, dtype="double"), self._sigma, self._sigma_cutoff, - is_collision_matrix=self._is_collision_matrix) + is_collision_matrix=self._is_collision_matrix, + ) if self._frequency_points is None: self._g_zero = _g_zero else: @@ -541,46 +668,64 @@ class ImagSelfEnergy(object): # shape = [num_triplets, num_band0, num_band, num_band] shape = list(self._g.shape[1:]) shape[1] = len(self._pp.band_indices) - self._g_zero_zeros = np.zeros(shape=shape, dtype='byte', order='C') + self._g_zero_zeros = np.zeros(shape=shape, dtype="byte", order="C") self._g_zero_frequency_points = _g_zero if scattering_event_class == 1 or scattering_event_class == 2: self._g[scattering_event_class - 1] = 0 def get_imag_self_energy(self): + """Return calculated imaginary-part of self-energies.""" if self._cutoff_frequency is None: return self._imag_self_energy else: return self._average_by_degeneracy(self._imag_self_energy) def get_imag_self_energy_N_and_U(self): + """Return normal and Umklapp contributions. + + Three-phonon scatterings are categorized into normal and Umklapp and + the contributions of the triplets to imaginary-part of self-energies + are returned. + + """ if self._cutoff_frequency is None: return self._ise_N, self._ise_U else: - return (self._average_by_degeneracy(self._ise_N), - self._average_by_degeneracy(self._ise_U)) + return ( + self._average_by_degeneracy(self._ise_N), + self._average_by_degeneracy(self._ise_U), + ) def get_detailed_imag_self_energy(self): + """Return triplets contributions to imaginary-part of self-energies.""" return self._detailed_imag_self_energy def get_integration_weights(self): + """Return integration weights. + + See the details of returns at ``get_triplets_integration_weights``. + + """ return self._g, self._g_zero def get_unit_conversion_factor(self): + """Return unit conversion factor of gamma.""" return self._unit_conversion def set_grid_point(self, grid_point=None): + """Set a grid point at which calculation will be performed.""" if grid_point is None: self._grid_point = None else: self._pp.set_grid_point(grid_point) self._pp_strength = None - (self._triplets_at_q, - self._weights_at_q) = self._pp.get_triplets_at_q()[:2] + (self._triplets_at_q, self._weights_at_q) = self._pp.get_triplets_at_q()[:2] self._grid_point = grid_point self._frequencies, self._eigenvectors, _ = self._pp.get_phonons() def set_sigma(self, sigma, sigma_cutoff=None): + """Set sigma value. None means tetrahedron method.""" if sigma is None: self._sigma = None else: @@ -594,40 +739,52 @@ class ImagSelfEnergy(object): self.delete_integration_weights() def set_frequency_points(self, frequency_points): + """Set frequency points where spectrum calculation will be performed.""" if frequency_points is None: self._frequency_points = None else: - self._frequency_points = np.array(frequency_points, dtype='double') + self._frequency_points = np.array(frequency_points, dtype="double") def set_temperature(self, temperature): + """Set temperatures where calculation will be peformed.""" if temperature is None: self._temperature = None else: self._temperature = float(temperature) def set_averaged_pp_interaction(self, ave_pp): + """Set averaged ph-ph interactions. + + This is used for analysis of the calculated results by introducing + averaged value as an approximation. + Setting this, ph-ph interaction calculation will not be executed. + + """ num_triplets = len(self._triplets_at_q) num_band = len(self._pp.primitive) * 3 num_grid = np.prod(self._pp.mesh_numbers) bi = self._pp.get_band_indices() self._pp_strength = np.zeros( - (num_triplets, len(bi), num_band, num_band), dtype='double') + (num_triplets, len(bi), num_band, num_band), dtype="double" + ) for i, v_ave in enumerate(ave_pp): self._pp_strength[:, i, :, :] = v_ave / num_grid def set_interaction_strength(self, pp_strength): + """Set ph-ph interaction strengths.""" self._pp_strength = pp_strength self._pp.set_interaction_strength(pp_strength, g_zero=self._g_zero) def delete_integration_weights(self): + """Delete large ndarray's.""" self._g = None self._g_zero = None self._pp_strength = None def _run_with_band_indices(self): if self._g is not None: - if self._lang == 'C': + if self._lang == "C": if self._with_detail: # self._detailed_imag_self_energy.shape = # (num_triplets, num_band0, num_band, num_band) @@ -641,14 +798,17 @@ class ImagSelfEnergy(object): print("This routine is super slow and only for the test.") self._run_py_with_band_indices_with_g() else: - print("get_triplets_integration_weights must be executed " - "before calling this method.") + print( + "get_triplets_integration_weights must be executed " + "before calling this method." + ) import sys + sys.exit(1) def _run_with_frequency_points(self): if self._g is not None: - if self._lang == 'C': + if self._lang == "C": if self._with_detail: self._run_c_detailed_with_frequency_points_with_g() else: @@ -658,38 +818,41 @@ class ImagSelfEnergy(object): print("This routine is super slow and only for the test.") self._run_py_with_frequency_points_with_g() else: - print("get_triplets_integration_weights must be executed " - "before calling this method.") + print( + "get_triplets_integration_weights must be executed " + "before calling this method." + ) import sys + sys.exit(1) def _run_c_with_band_indices_with_g(self): import phono3py._phono3py as phono3c if self._g_zero is None: - _g_zero = np.zeros(self._pp_strength.shape, - dtype='byte', order='C') + _g_zero = np.zeros(self._pp_strength.shape, dtype="byte", order="C") else: _g_zero = self._g_zero - phono3c.imag_self_energy_with_g(self._imag_self_energy, - self._pp_strength, - self._triplets_at_q, - self._weights_at_q, - self._frequencies, - self._temperature, - self._g, - _g_zero, - self._cutoff_frequency, - -1) + phono3c.imag_self_energy_with_g( + self._imag_self_energy, + self._pp_strength, + self._triplets_at_q, + self._weights_at_q, + self._frequencies, + self._temperature, + self._g, + _g_zero, + self._cutoff_frequency, + -1, + ) self._imag_self_energy *= self._unit_conversion def _run_c_detailed_with_band_indices_with_g(self): import phono3py._phono3py as phono3c if self._g_zero is None: - _g_zero = np.zeros(self._pp_strength.shape, - dtype='byte', order='C') + _g_zero = np.zeros(self._pp_strength.shape, dtype="byte", order="C") else: _g_zero = self._g_zero @@ -705,7 +868,8 @@ class ImagSelfEnergy(object): self._temperature, self._g, _g_zero, - self._cutoff_frequency) + self._cutoff_frequency, + ) self._detailed_imag_self_energy *= self._unit_conversion self._ise_N *= self._unit_conversion @@ -714,35 +878,39 @@ class ImagSelfEnergy(object): def _run_c_with_frequency_points_with_g(self): import phono3py._phono3py as phono3c + num_band0 = self._pp_strength.shape[1] - ise_at_f = np.zeros(num_band0, dtype='double') + ise_at_f = np.zeros(num_band0, dtype="double") for i in range(len(self._frequency_points)): - phono3c.imag_self_energy_with_g(ise_at_f, - self._pp_strength, - self._triplets_at_q, - self._weights_at_q, - self._frequencies, - self._temperature, - self._g, - self._g_zero_frequency_points, - self._cutoff_frequency, - i) + phono3c.imag_self_energy_with_g( + ise_at_f, + self._pp_strength, + self._triplets_at_q, + self._weights_at_q, + self._frequencies, + self._temperature, + self._g, + self._g_zero_frequency_points, + self._cutoff_frequency, + i, + ) self._imag_self_energy[i] = ise_at_f self._imag_self_energy *= self._unit_conversion def _run_c_detailed_with_frequency_points_with_g(self): import phono3py._phono3py as phono3c + num_band0 = self._pp_strength.shape[1] g_shape = list(self._g.shape) g_shape[2] = num_band0 - g = np.zeros((2,) + self._pp_strength.shape, order='C', dtype='double') + g = np.zeros((2,) + self._pp_strength.shape, order="C", dtype="double") detailed_ise_at_f = np.zeros( - self._detailed_imag_self_energy.shape[1:5], - order='C', dtype='double') - ise_at_f_N = np.zeros(num_band0, dtype='double') - ise_at_f_U = np.zeros(num_band0, dtype='double') - _g_zero = np.zeros(g_shape, dtype='byte', order='C') + self._detailed_imag_self_energy.shape[1:5], order="C", dtype="double" + ) + ise_at_f_N = np.zeros(num_band0, dtype="double") + ise_at_f_U = np.zeros(num_band0, dtype="double") + _g_zero = np.zeros(g_shape, dtype="byte", order="C") for i in range(len(self._frequency_points)): for j in range(g.shape[2]): @@ -759,9 +927,11 @@ class ImagSelfEnergy(object): self._temperature, g, _g_zero, - self._cutoff_frequency) - self._detailed_imag_self_energy[i] = (detailed_ise_at_f * - self._unit_conversion) + self._cutoff_frequency, + ) + self._detailed_imag_self_energy[i] = ( + detailed_ise_at_f * self._unit_conversion + ) self._ise_N[i] = ise_at_f_N * self._unit_conversion self._ise_U[i] = ise_at_f_U * self._unit_conversion self._imag_self_energy[i] = self._ise_N[i] + self._ise_U[i] @@ -776,27 +946,29 @@ class ImagSelfEnergy(object): freqs = self._frequencies[self._triplets_at_q[:, [1, 2]]] freqs = np.where(freqs > self._cutoff_frequency, freqs, 1) n = bose_einstein(freqs, self._temperature) - for i, (tp, w, interaction) in enumerate(zip(self._triplets_at_q, - self._weights_at_q, - self._pp_strength)): + for i, (tp, w, interaction) in enumerate( + zip(self._triplets_at_q, self._weights_at_q, self._pp_strength) + ): for j, k in list(np.ndindex(interaction.shape[1:])): f1 = self._frequencies[tp[1]][j] f2 = self._frequencies[tp[2]][k] - if (f1 > self._cutoff_frequency and - f2 > self._cutoff_frequency): + if f1 > self._cutoff_frequency and f2 > self._cutoff_frequency: n2 = n[i, 0, j] n3 = n[i, 1, k] g1 = self._g[0, i, :, j, k] g2_g3 = self._g[1, i, :, j, k] # g2 - g3 self._imag_self_energy[:] += ( - (n2 + n3 + 1) * g1 + - (n2 - n3) * (g2_g3)) * interaction[:, j, k] * w + ((n2 + n3 + 1) * g1 + (n2 - n3) * (g2_g3)) + * interaction[:, j, k] + * w + ) self._imag_self_energy *= self._unit_conversion def _ise_thm_with_band_indices_0K(self): - for i, (w, interaction) in enumerate(zip(self._weights_at_q, - self._pp_strength)): + for i, (w, interaction) in enumerate( + zip(self._weights_at_q, self._pp_strength) + ): for j, k in list(np.ndindex(interaction.shape[1:])): g1 = self._g[0, i, :, j, k] self._imag_self_energy[:] += g1 * interaction[:, j, k] * w @@ -810,86 +982,38 @@ class ImagSelfEnergy(object): self._ise_thm_with_frequency_points_0K() def _ise_thm_with_frequency_points(self): - for i, (tp, w, interaction) in enumerate(zip(self._triplets_at_q, - self._weights_at_q, - self._pp_strength)): + for i, (tp, w, interaction) in enumerate( + zip(self._triplets_at_q, self._weights_at_q, self._pp_strength) + ): for j, k in list(np.ndindex(interaction.shape[1:])): f1 = self._frequencies[tp[1]][j] f2 = self._frequencies[tp[2]][k] - if (f1 > self._cutoff_frequency and - f2 > self._cutoff_frequency): + if f1 > self._cutoff_frequency and f2 > self._cutoff_frequency: n2 = bose_einstein(f1, self._temperature) n3 = bose_einstein(f2, self._temperature) g1 = self._g[0, i, :, j, k] g2_g3 = self._g[1, i, :, j, k] # g2 - g3 - for l in range(len(interaction)): - self._imag_self_energy[:, l] += ( - (n2 + n3 + 1) * g1 + - (n2 - n3) * (g2_g3)) * interaction[l, j, k] * w + for ll in range(len(interaction)): + self._imag_self_energy[:, ll] += ( + ((n2 + n3 + 1) * g1 + (n2 - n3) * (g2_g3)) + * interaction[ll, j, k] + * w + ) self._imag_self_energy *= self._unit_conversion def _ise_thm_with_frequency_points_0K(self): - for i, (w, interaction) in enumerate(zip(self._weights_at_q, - self._pp_strength)): + for i, (w, interaction) in enumerate( + zip(self._weights_at_q, self._pp_strength) + ): for j, k in list(np.ndindex(interaction.shape[1:])): g1 = self._g[0, i, :, j, k] - for l in range(len(interaction)): - self._imag_self_energy[:, l] += g1 * interaction[l, j, k] * w + for ll in range(len(interaction)): + self._imag_self_energy[:, ll] += g1 * interaction[ll, j, k] * w self._imag_self_energy *= self._unit_conversion def _average_by_degeneracy(self, imag_self_energy): - return average_by_degeneracy(imag_self_energy, - self._pp.band_indices, - self._frequencies[self._grid_point]) - - -def run_ise_at_frequency_points_batch( - i, - j, - _frequency_points, - ise, - temperatures, - gamma, - write_gamma_detail=False, - return_gamma_detail=False, - detailed_gamma_at_gp=None, - scattering_event_class=None, - nelems_in_batch=50, - log_level=0): - if nelems_in_batch is None: - _nelems_in_batch = 10 - else: - _nelems_in_batch = nelems_in_batch - - batches = _get_batches(len(_frequency_points), _nelems_in_batch) - - if log_level: - print("Calculations at %d frequency points are devided into " - "%d batches." % (len(_frequency_points), len(batches))) - - for bi, fpts_batch in enumerate(batches): - if log_level: - print("%d/%d: %s" % (bi + 1, len(batches), fpts_batch + 1)) - sys.stdout.flush() - - ise.set_frequency_points(_frequency_points[fpts_batch]) - ise.set_integration_weights( - scattering_event_class=scattering_event_class) - for l, t in enumerate(temperatures): - ise.set_temperature(t) - ise.run() - gamma[j, l, i, :, fpts_batch] = ise.get_imag_self_energy() - if write_gamma_detail or return_gamma_detail: - detailed_gamma_at_gp[l, fpts_batch] = ( - ise.get_detailed_imag_self_energy()) - - -def _get_batches(tot_nelems, nelems=10): - nbatch = tot_nelems // nelems - batches = [np.arange(i * nelems, (i + 1) * nelems) - for i in range(nbatch)] - if tot_nelems % nelems > 0: - batches.append(np.arange(nelems * nbatch, tot_nelems)) - return batches + return average_by_degeneracy( + imag_self_energy, self._pp.band_indices, self._frequencies[self._grid_point] + ) diff --git a/phono3py/phonon3/interaction.py b/phono3py/phonon3/interaction.py index 93d234a5..13078a8d 100644 --- a/phono3py/phonon3/interaction.py +++ b/phono3py/phonon3/interaction.py @@ -34,7 +34,6 @@ # POSSIBILITY OF SUCH DAMAGE. import warnings -from typing import Union import numpy as np from phonopy.harmonic.dynamical_matrix import get_dynamical_matrix from phonopy.structure.cells import Primitive, sparse_to_dense_svecs @@ -42,12 +41,14 @@ from phonopy.structure.symmetry import Symmetry from phonopy.units import VaspToTHz, Hbar, EV, Angstrom, THz, AMU from phonopy.structure.cells import compute_all_sg_permutations from phono3py.phonon.grid import ( - get_ir_grid_points, get_grid_points_by_rotations, BZGrid) + get_ir_grid_points, + get_grid_points_by_rotations, + BZGrid, +) from phono3py.phonon.solver import run_phonon_solver_c, run_phonon_solver_py from phono3py.phonon3.real_to_reciprocal import RealToReciprocal from phono3py.phonon3.reciprocal_to_normal import ReciprocalToNormal -from phono3py.phonon3.triplets import (get_triplets_at_q, - get_nosym_triplets_at_q) +from phono3py.phonon3.triplets import get_triplets_at_q, get_nosym_triplets_at_q class Interaction(object): @@ -81,20 +82,22 @@ class Interaction(object): """ - def __init__(self, - primitive: Primitive, - bz_grid: BZGrid, - primitive_symmetry: Symmetry, - fc3=None, - band_indices=None, - constant_averaged_interaction=None, - frequency_factor_to_THz=VaspToTHz, - frequency_scale_factor=None, - unit_conversion=None, - is_mesh_symmetry=True, - symmetrize_fc3q=False, - cutoff_frequency=None, - lapack_zheev_uplo='L'): + def __init__( + self, + primitive: Primitive, + bz_grid: BZGrid, + primitive_symmetry: Symmetry, + fc3=None, + band_indices=None, + constant_averaged_interaction=None, + frequency_factor_to_THz=VaspToTHz, + frequency_scale_factor=None, + unit_conversion=None, + is_mesh_symmetry=True, + symmetrize_fc3q=False, + cutoff_frequency=None, + lapack_zheev_uplo="L", + ): """Init method.""" self._primitive = primitive self._bz_grid = bz_grid @@ -112,11 +115,17 @@ class Interaction(object): # Unit to eV^2 if unit_conversion is None: num_grid = np.prod(self.mesh_numbers) - self._unit_conversion = ((Hbar * EV) ** 3 / 36 / 8 - * EV ** 2 / Angstrom ** 6 - / (2 * np.pi * THz) ** 3 - / AMU ** 3 / num_grid - / EV ** 2) + self._unit_conversion = ( + (Hbar * EV) ** 3 + / 36 + / 8 + * EV ** 2 + / Angstrom ** 6 + / (2 * np.pi * THz) ** 3 + / AMU ** 3 + / num_grid + / EV ** 2 + ) else: self._unit_conversion = unit_conversion if cutoff_frequency is None: @@ -152,11 +161,11 @@ class Interaction(object): else: self._svecs, self._multi = sparse_to_dense_svecs(svecs, multi) - self._masses = np.array(self._primitive.masses, dtype='double') - self._p2s = np.array(self._primitive.p2s_map, dtype='int_') - self._s2p = np.array(self._primitive.s2p_map, dtype='int_') + self._masses = np.array(self._primitive.masses, dtype="double") + self._p2s = np.array(self._primitive.p2s_map, dtype="int_") + self._s2p = np.array(self._primitive.s2p_map, dtype="int_") - def run(self, lang='C', g_zero=None): + def run(self, lang="C", g_zero=None): """Run ph-ph interaction calculation.""" if (self._phonon_done == 0).any(): self.run_phonon_solver() @@ -165,18 +174,19 @@ class Interaction(object): num_triplets = len(self._triplets_at_q) self._interaction_strength = np.empty( - (num_triplets, len(self._band_indices), num_band, num_band), - dtype='double') + (num_triplets, len(self._band_indices), num_band, num_band), dtype="double" + ) if self._constant_averaged_interaction is None: self._interaction_strength[:] = 0 - if lang == 'C': + if lang == "C": self._run_c(g_zero) else: self._run_py() else: num_grid = np.prod(self.mesh_numbers) self._interaction_strength[:] = ( - self._constant_averaged_interaction / num_grid) + self._constant_averaged_interaction / num_grid + ) @property def interaction_strength(self): @@ -193,9 +203,11 @@ class Interaction(object): def get_interaction_strength(self): """Return ph-ph interaction strength.""" - warnings.warn("Use attribute, Interaction.interaction_strength " - "instead of Interaction.get_interaction_strength().", - DeprecationWarning) + warnings.warn( + "Use attribute, Interaction.interaction_strength " + "instead of Interaction.get_interaction_strength().", + DeprecationWarning, + ) return self.interaction_strength @property @@ -212,9 +224,11 @@ class Interaction(object): def get_mesh_numbers(self): """Return mesh numbers.""" - warnings.warn("Use attribute, Interaction.mesh_numbers " - "instead of Interaction.get_mesh_numbers().", - DeprecationWarning) + warnings.warn( + "Use attribute, Interaction.mesh_numbers " + "instead of Interaction.get_mesh_numbers().", + DeprecationWarning, + ) return self.mesh_numbers @property @@ -229,9 +243,10 @@ class Interaction(object): def get_fc3(self): """Return fc3.""" - warnings.warn("Use attribute, Interaction.fc3 " - "instead of Interaction.get_fc3().", - DeprecationWarning) + warnings.warn( + "Use attribute, Interaction.fc3 " "instead of Interaction.get_fc3().", + DeprecationWarning, + ) return self.fc3 @property @@ -241,9 +256,11 @@ class Interaction(object): def get_dynamical_matrix(self): """Return DynamicalMatrix class instance.""" - warnings.warn("Use attribute, Interaction.dynamical_matrix " - "instead of Interaction.get_dynamical_matrix().", - DeprecationWarning) + warnings.warn( + "Use attribute, Interaction.dynamical_matrix " + "instead of Interaction.get_dynamical_matrix().", + DeprecationWarning, + ) return self.dynamical_matrix @property @@ -253,9 +270,11 @@ class Interaction(object): def get_primitive(self): """Return Primitive class instance.""" - warnings.warn("Use attribute, Interaction.primitive " - "instead of Interaction.get_primitive().", - DeprecationWarning) + warnings.warn( + "Use attribute, Interaction.primitive " + "instead of Interaction.get_primitive().", + DeprecationWarning, + ) return self.primitive @property @@ -265,10 +284,12 @@ class Interaction(object): def get_triplets_at_q(self): """Return grid point triplets information.""" - return (self._triplets_at_q, - self._weights_at_q, - self._triplets_map_at_q, - self._ir_map_at_q) + return ( + self._triplets_at_q, + self._weights_at_q, + self._triplets_map_at_q, + self._ir_map_at_q, + ) @property def bz_grid(self): @@ -289,9 +310,11 @@ class Interaction(object): def get_band_indices(self): """Return band indices.""" - warnings.warn("Use attribute, Interaction.band_indices " - "instead of Interaction.get_band_indices().", - DeprecationWarning) + warnings.warn( + "Use attribute, Interaction.band_indices " + "instead of Interaction.get_band_indices().", + DeprecationWarning, + ) return self.band_indices @property @@ -318,20 +341,24 @@ class Interaction(object): if nac_q_direction is None: self._nac_q_direction = None else: - self._nac_q_direction = np.array(nac_q_direction, dtype='double') + self._nac_q_direction = np.array(nac_q_direction, dtype="double") def get_nac_q_direction(self): """Return q-direction used for NAC at q->0.""" - warnings.warn("Use attribute, Interaction.nac_q_direction " - "instead of Interaction.get_nac_q_direction().", - DeprecationWarning) + warnings.warn( + "Use attribute, Interaction.nac_q_direction " + "instead of Interaction.get_nac_q_direction().", + DeprecationWarning, + ) return self.nac_q_direction def set_nac_q_direction(self, nac_q_direction=None): """Set NAC q-point direction valid at q->0.""" - warnings.warn("Use attribute, Interaction.nac_q_direction " - "instead of Interaction.set_nac_q_direction().", - DeprecationWarning) + warnings.warn( + "Use attribute, Interaction.nac_q_direction " + "instead of Interaction.set_nac_q_direction().", + DeprecationWarning, + ) self.nac_q_direction = nac_q_direction @property @@ -347,9 +374,11 @@ class Interaction(object): def get_zero_value_positions(self): """Return zero ph-ph interaction elements information.""" - warnings.warn("Use attribute, Interaction.zero_value_positions " - "instead of Interaction.get_zero_value_positions().", - DeprecationWarning) + warnings.warn( + "Use attribute, Interaction.zero_value_positions " + "instead of Interaction.get_zero_value_positions().", + DeprecationWarning, + ) return self.zero_value_positions def get_phonons(self): @@ -379,9 +408,11 @@ class Interaction(object): def get_frequency_factor_to_THz(self): """Return phonon frequency conversion factor to THz.""" - warnings.warn("Use attribute, Interaction.frequency_factor_to_THz ", - "instead of Interaction.get_frequency_factor_to_THz().", - DeprecationWarning) + warnings.warn( + "Use attribute, Interaction.frequency_factor_to_THz ", + "instead of Interaction.get_frequency_factor_to_THz().", + DeprecationWarning, + ) return self.frequency_factor_to_THz @property @@ -391,9 +422,11 @@ class Interaction(object): def get_lapack_zheev_uplo(self): """Return U or L for lapack zheev solver.""" - warnings.warn("Use attribute, Interaction.lapack_zheev_uplo " - "instead of Interaction.get_lapack_zheev_uplo().", - DeprecationWarning) + warnings.warn( + "Use attribute, Interaction.lapack_zheev_uplo " + "instead of Interaction.get_lapack_zheev_uplo().", + DeprecationWarning, + ) return self.lapack_zheev_uplo @property @@ -403,9 +436,11 @@ class Interaction(object): def get_cutoff_frequency(self): """Return cutoff phonon frequency to judge imaginary phonon.""" - warnings.warn("Use attribute, Interaction.cutoff_frequency " - "instead of Interaction.get_cutoff_frequency().", - DeprecationWarning) + warnings.warn( + "Use attribute, Interaction.cutoff_frequency " + "instead of Interaction.get_cutoff_frequency().", + DeprecationWarning, + ) return self.cutoff_frequency def get_averaged_interaction(self): @@ -422,11 +457,7 @@ class Interaction(object): def get_primitive_and_supercell_correspondence(self): """Return atomic pair information.""" - return (self._svecs, - self._multi, - self._p2s, - self._s2p, - self._masses) + return (self._svecs, self._multi, self._p2s, self._s2p, self._masses) def get_unit_conversion_factor(self): """Return unit conversion factor.""" @@ -445,40 +476,51 @@ class Interaction(object): """Set grid point and prepare grid point triplets.""" reciprocal_lattice = np.linalg.inv(self._primitive.cell) if not self._is_mesh_symmetry: - (triplets_at_q, - weights_at_q, - triplets_map_at_q, - ir_map_at_q) = get_nosym_triplets_at_q( - grid_point, self._bz_grid) + ( + triplets_at_q, + weights_at_q, + triplets_map_at_q, + ir_map_at_q, + ) = get_nosym_triplets_at_q(grid_point, self._bz_grid) else: - (triplets_at_q, - weights_at_q, - triplets_map_at_q, - ir_map_at_q) = get_triplets_at_q(grid_point, self._bz_grid) + ( + triplets_at_q, + weights_at_q, + triplets_map_at_q, + ir_map_at_q, + ) = get_triplets_at_q(grid_point, self._bz_grid) # Special treatment of symmetry is applied when q_direction is # used. if self._nac_q_direction is not None: if (self._bz_grid.addresses[grid_point] == 0).all(): self._phonon_done[grid_point] = 0 - self.run_phonon_solver(np.array([grid_point, ], - dtype='int_')) + self.run_phonon_solver( + np.array( + [ + grid_point, + ], + dtype="int_", + ) + ) rotations = [] - for i, r in enumerate( - self._bz_grid.reciprocal_operations): + for i, r in enumerate(self._bz_grid.reciprocal_operations): dq = self._nac_q_direction dq /= np.linalg.norm(dq) diff = np.dot(r, dq) - dq if (abs(diff) < 1e-5).all(): rotations.append(self._bz_grid.rotations[i]) - (triplets_at_q, - weights_at_q, - triplets_map_at_q, - ir_map_at_q) = get_triplets_at_q( - grid_point, - self._bz_grid, - reciprocal_rotations=rotations, - is_time_reversal=False) + ( + triplets_at_q, + weights_at_q, + triplets_map_at_q, + ir_map_at_q, + ) = get_triplets_at_q( + grid_point, + self._bz_grid, + reciprocal_rotations=rotations, + is_time_reversal=False, + ) for triplet in triplets_at_q: sum_q = (self._bz_grid.addresses[triplet]).sum(axis=0) @@ -486,12 +528,19 @@ class Interaction(object): print("============= Warning ==================") print("%s" % triplet) for tp in triplet: - print("%s %s" % - (self._bz_grid.addresses[tp], - np.linalg.norm( - np.dot(reciprocal_lattice, - self._bz_grid.addresses[tp] / - self.mesh_numbers.astype('double'))))) + print( + "%s %s" + % ( + self._bz_grid.addresses[tp], + np.linalg.norm( + np.dot( + reciprocal_lattice, + self._bz_grid.addresses[tp] + / self.mesh_numbers.astype("double"), + ) + ), + ) + ) print("%s" % sum_q) print("============= Warning ==================") @@ -502,13 +551,15 @@ class Interaction(object): self._triplets_map_at_q = triplets_map_at_q self._ir_map_at_q = ir_map_at_q - def init_dynamical_matrix(self, - fc2, - supercell, - primitive, - nac_params=None, - solve_dynamical_matrices=True, - decimals=None): + def init_dynamical_matrix( + self, + fc2, + supercell, + primitive, + nac_params=None, + solve_dynamical_matrices=True, + decimals=None, + ): """Prepare for phonon calculation on grid. solve_dynamical_matrices : bool @@ -524,13 +575,14 @@ class Interaction(object): nac_params=nac_params, frequency_scale_factor=self._frequency_scale_factor, decimals=decimals, - symprec=self._symprec) + symprec=self._symprec, + ) self._phonon_done[0] = 0 if solve_dynamical_matrices: self.run_phonon_solver() else: - self.run_phonon_solver(np.array([0], dtype='int_')) + self.run_phonon_solver(np.array([0], dtype="int_")) if (self._bz_grid.addresses[0] == 0).all(): if np.sum(self._frequencies[0] < self._cutoff_frequency) < 3: @@ -538,20 +590,24 @@ class Interaction(object): if not (f < self._cutoff_frequency): self._frequencies[0, i] = 0 print("=" * 26 + " Warning " + "=" * 26) - print(" Phonon frequency of band index %d at Gamma " - "is calculated to be %f." % (i + 1, f)) + print( + " Phonon frequency of band index %d at Gamma " + "is calculated to be %f." % (i + 1, f) + ) print(" But this frequency is forced to be zero.") print("=" * 61) def set_phonon_data(self, frequencies, eigenvectors, bz_grid_addresses): """Set phonons on grid.""" if bz_grid_addresses.shape != self._bz_grid.addresses.shape: - raise RuntimeError("Input grid address size is inconsistent. " - "Setting phonons faild.") + raise RuntimeError( + "Input grid address size is inconsistent. " "Setting phonons faild." + ) if (self._bz_grid.addresses - bz_grid_addresses).all(): - raise RuntimeError("Input grid addresses are inconsistent. " - "Setting phonons faild.") + raise RuntimeError( + "Input grid addresses are inconsistent. " "Setting phonons faild." + ) else: self._phonon_done[:] = 1 self._frequencies[:] = frequencies @@ -570,7 +626,7 @@ class Interaction(object): if expand_phonons: self._expand_phonons() else: - grid_points = np.arange(len(self._bz_grid.addresses), dtype='int_') + grid_points = np.arange(len(self._bz_grid.addresses), dtype="int_") self._run_phonon_solver_c(grid_points) def _expand_phonons(self): @@ -593,29 +649,32 @@ class Interaction(object): # perms.shape = (len(spg_ops), len(primitive)), dtype='intc' perms = compute_all_sg_permutations( self._primitive.scaled_positions, - self._bz_grid.symmetry_dataset['rotations'], - self._bz_grid.symmetry_dataset['translations'], - np.array(self._primitive.cell.T, dtype='double', order='C'), - symprec=self._symprec) + self._bz_grid.symmetry_dataset["rotations"], + self._bz_grid.symmetry_dataset["translations"], + np.array(self._primitive.cell.T, dtype="double", order="C"), + symprec=self._symprec, + ) for d_i, r_i in enumerate(d2r_map): r = self._bz_grid.rotations[r_i] r_cart = self._bz_grid.rotations_cartesian[r_i] for irgp in ir_bz_grid_points: - bzgp = get_grid_points_by_rotations(irgp, - self._bz_grid, - reciprocal_rotations=[r, ], - with_surface=True)[0] + bzgp = get_grid_points_by_rotations( + irgp, + self._bz_grid, + reciprocal_rotations=[ + r, + ], + with_surface=True, + )[0] if self._phonon_done[bzgp]: continue - self._rotate_eigvecs( - irgp, bzgp, r_cart, perms[d_i], d_i) + self._rotate_eigvecs(irgp, bzgp, r_cart, perms[d_i], d_i) bz_grid_points_solved = self._get_phonons_at_minus_q() if bz_grid_points_solved: - print("DEBUG: BZ-grid points additionally solved " - "than ir-grid-points.") + print("DEBUG: BZ-grid points additionally solved " "than ir-grid-points.") print(bz_grid_points_solved) def _get_reciprocal_rotations_in_space_group_operations(self): @@ -630,13 +689,13 @@ class Interaction(object): """ d2r_map = [] - for r in self._bz_grid.symmetry_dataset['rotations']: + for r in self._bz_grid.symmetry_dataset["rotations"]: for i, rec_r in enumerate(self._bz_grid.reciprocal_operations): if (rec_r.T == r).all(): d2r_map.append(i) break - assert len(d2r_map) == len(self._bz_grid.symmetry_dataset['rotations']) + assert len(d2r_map) == len(self._bz_grid.symmetry_dataset["rotations"]) return d2r_map @@ -647,7 +706,7 @@ class Interaction(object): """ Rq = np.dot(self._bz_grid.QDinv, self._bz_grid.addresses[bzgp]) - tau = self._bz_grid.symmetry_dataset['translations'][t_i] + tau = self._bz_grid.symmetry_dataset["translations"][t_i] phase_factor = np.exp(-2j * np.pi * np.dot(Rq, tau)) self._phonon_done[bzgp] = 1 self._frequencies[bzgp, :] = self._frequencies[orig_gp, :] @@ -669,7 +728,7 @@ class Interaction(object): in this method. """ - r_inv = -np.eye(3, dtype='int_') + r_inv = -np.eye(3, dtype="int_") bz_grid_points_solved = [] for bzgp, done in enumerate(self._phonon_done): if done: @@ -679,17 +738,26 @@ class Interaction(object): bzgp_mq = get_grid_points_by_rotations( bzgp, self._bz_grid, - reciprocal_rotations=[r_inv, ], - with_surface=True)[0] + reciprocal_rotations=[ + r_inv, + ], + with_surface=True, + )[0] if self._phonon_done[bzgp_mq] == 0: - self._run_phonon_solver_c(np.array([bzgp_mq, ], dtype='int_')) + self._run_phonon_solver_c( + np.array( + [ + bzgp_mq, + ], + dtype="int_", + ) + ) bz_grid_points_solved.append(bzgp_mq) self._phonon_done[bzgp] = 1 self._frequencies[bzgp, :] = self._frequencies[bzgp_mq, :] - self._eigenvectors[bzgp, :, :] = np.conj( - self._eigenvectors[bzgp_mq, :, :]) + self._eigenvectors[bzgp, :, :] = np.conj(self._eigenvectors[bzgp_mq, :, :]) return bz_grid_points_solved @@ -704,52 +772,58 @@ class Interaction(object): self._g_zero = None def _set_fc3(self, fc3): - if (type(fc3) == np.ndarray and - fc3.dtype == np.dtype('double') and - fc3.flags.aligned and - fc3.flags.owndata and - fc3.flags.c_contiguous and - self._frequency_scale_factor is None): # noqa E129 + if ( + type(fc3) == np.ndarray + and fc3.dtype == np.dtype("double") + and fc3.flags.aligned + and fc3.flags.owndata + and fc3.flags.c_contiguous + and self._frequency_scale_factor is None + ): # noqa E129 self._fc3 = fc3 elif self._frequency_scale_factor is None: - self._fc3 = np.array(fc3, dtype='double', order='C') + self._fc3 = np.array(fc3, dtype="double", order="C") else: - self._fc3 = np.array(fc3 * self._frequency_scale_factor ** 2, - dtype='double', order='C') + self._fc3 = np.array( + fc3 * self._frequency_scale_factor ** 2, dtype="double", order="C" + ) def _set_band_indices(self, band_indices): num_band = len(self._primitive) * 3 if band_indices is None: - self._band_indices = np.arange(num_band, dtype='int_') + self._band_indices = np.arange(num_band, dtype="int_") else: - self._band_indices = np.array(band_indices, dtype='int_') + self._band_indices = np.array(band_indices, dtype="int_") def _run_c(self, g_zero): import phono3py._phono3py as phono3c if g_zero is None or self._symmetrize_fc3q: - _g_zero = np.zeros(self._interaction_strength.shape, - dtype='byte', order='C') + _g_zero = np.zeros( + self._interaction_strength.shape, dtype="byte", order="C" + ) else: _g_zero = g_zero - phono3c.interaction(self._interaction_strength, - _g_zero, - self._frequencies, - self._eigenvectors, - self._triplets_at_q, - self._bz_grid.addresses, - self._bz_grid.D_diag, - self._bz_grid.Q, - self._fc3, - self._svecs, - self._multi, - self._masses, - self._p2s, - self._s2p, - self._band_indices, - self._symmetrize_fc3q, - self._cutoff_frequency) + phono3c.interaction( + self._interaction_strength, + _g_zero, + self._frequencies, + self._eigenvectors, + self._triplets_at_q, + self._bz_grid.addresses, + self._bz_grid.D_diag, + self._bz_grid.Q, + self._fc3, + self._svecs, + self._multi, + self._masses, + self._p2s, + self._s2p, + self._band_indices, + self._symmetrize_fc3q, + self._cutoff_frequency, + ) self._interaction_strength *= self._unit_conversion self._g_zero = g_zero @@ -764,18 +838,20 @@ class Interaction(object): self._bz_grid.QDinv, frequency_conversion_factor=self._frequency_factor_to_THz, nac_q_direction=self._nac_q_direction, - lapack_zheev_uplo=self._lapack_zheev_uplo) + lapack_zheev_uplo=self._lapack_zheev_uplo, + ) def _run_py(self): - r2r = RealToReciprocal(self._fc3, - self._primitive, - self.mesh_numbers, - symprec=self._symprec) - r2n = ReciprocalToNormal(self._primitive, - self._frequencies, - self._eigenvectors, - self._band_indices, - cutoff_frequency=self._cutoff_frequency) + r2r = RealToReciprocal( + self._fc3, self._primitive, self.mesh_numbers, symprec=self._symprec + ) + r2n = ReciprocalToNormal( + self._primitive, + self._frequencies, + self._eigenvectors, + self._band_indices, + cutoff_frequency=self._cutoff_frequency, + ) for i, grid_triplet in enumerate(self._triplets_at_q): print("%d / %d" % (i + 1, len(self._triplets_at_q))) @@ -784,27 +860,29 @@ class Interaction(object): for gp in grid_triplet: self._run_phonon_solver_py(gp) r2n.run(fc3_reciprocal, grid_triplet) - self._interaction_strength[i] = np.abs( - r2n.get_reciprocal_to_normal()) ** 2 * self._unit_conversion + self._interaction_strength[i] = ( + np.abs(r2n.get_reciprocal_to_normal()) ** 2 * self._unit_conversion + ) def _run_phonon_solver_py(self, grid_point): - run_phonon_solver_py(grid_point, - self._phonon_done, - self._frequencies, - self._eigenvectors, - self._bz_grid.addresses, - self._bz_grid.QDinv, - self._dm, - self._frequency_factor_to_THz, - self._lapack_zheev_uplo) + run_phonon_solver_py( + grid_point, + self._phonon_done, + self._frequencies, + self._eigenvectors, + self._bz_grid.addresses, + self._bz_grid.QDinv, + self._dm, + self._frequency_factor_to_THz, + self._lapack_zheev_uplo, + ) def _allocate_phonon(self): num_band = len(self._primitive) * 3 num_grid = len(self._bz_grid.addresses) - self._phonon_done = np.zeros(num_grid, dtype='byte') - self._frequencies = np.zeros((num_grid, num_band), - dtype='double', order='C') + self._phonon_done = np.zeros(num_grid, dtype="byte") + self._frequencies = np.zeros((num_grid, num_band), dtype="double", order="C") itemsize = self._frequencies.itemsize - self._eigenvectors = np.zeros((num_grid, num_band, num_band), - dtype=("c%d" % (itemsize * 2)), - order='C') + self._eigenvectors = np.zeros( + (num_grid, num_band, num_band), dtype=("c%d" % (itemsize * 2)), order="C" + ) diff --git a/phono3py/phonon3/joint_dos.py b/phono3py/phonon3/joint_dos.py index 3efc26a1..319d1b31 100644 --- a/phono3py/phonon3/joint_dos.py +++ b/phono3py/phonon3/joint_dos.py @@ -1,3 +1,4 @@ +"""Joint-density of states calculation.""" # Copyright (C) 2020 Atsushi Togo # All rights reserved. # @@ -36,39 +37,48 @@ import warnings import sys import numpy as np from phonopy.units import VaspToTHz -from phono3py.phonon3.triplets import (get_triplets_at_q, - get_nosym_triplets_at_q, - get_tetrahedra_vertices, - get_triplets_integration_weights) +from phonopy.structure.cells import Primitive +from phonopy.harmonic.dynamical_matrix import DynamicalMatrix +from phono3py.phonon3.triplets import ( + get_triplets_at_q, + get_nosym_triplets_at_q, + get_tetrahedra_vertices, + get_triplets_integration_weights, +) from phono3py.phonon.solver import run_phonon_solver_c from phono3py.phonon.func import bose_einstein +from phono3py.phonon.grid import BZGrid from phono3py.phonon3.imag_self_energy import get_frequency_points from phonopy.harmonic.dynamical_matrix import get_dynamical_matrix from phonopy.structure.tetrahedron_method import TetrahedronMethod class JointDos(object): - def __init__(self, - primitive, - supercell, - bz_grid, - fc2, - nac_params=None, - nac_q_direction=None, - sigma=None, - cutoff_frequency=None, - frequency_step=None, - num_frequency_points=None, - temperatures=None, - frequency_factor_to_THz=VaspToTHz, - frequency_scale_factor=1.0, - is_mesh_symmetry=True, - store_dense_gp_map=False, - symprec=1e-5, - filename=None, - log_level=False, - lapack_zheev_uplo='L'): + """Calculate joint-density-of-states.""" + def __init__( + self, + primitive, + supercell, + bz_grid, + fc2, + nac_params=None, + nac_q_direction=None, + sigma=None, + cutoff_frequency=None, + frequency_step=None, + num_frequency_points=None, + temperatures=None, + frequency_factor_to_THz=VaspToTHz, + frequency_scale_factor=1.0, + is_mesh_symmetry=True, + store_dense_gp_map=False, + symprec=1e-5, + filename=None, + log_level=False, + lapack_zheev_uplo="L", + ): + """Init method.""" self._grid_point = None self._primitive = primitive self._supercell = supercell @@ -108,60 +118,72 @@ class JointDos(object): self._frequency_points = None def run(self): - self.run_phonon_solver( - np.arange(len(self._bz_grid.addresses), dtype='int_')) + """Calculate joint-density-of-states.""" + self.run_phonon_solver(np.arange(len(self._bz_grid.addresses), dtype="int_")) try: - import phono3py._phono3py as phono3c + import phono3py._phono3py as phono3c # noqa F401 + self._run_c() except ImportError: print("Joint density of states in python is not implemented.") return None, None @property - def dynamical_matrix(self): + def dynamical_matrix(self) -> DynamicalMatrix: + """Return dynamical matrix class instance.""" return self._dm @property def joint_dos(self): + """Return joint-density-of-states.""" return self._joint_dos def get_joint_dos(self): + """Return joint-density-of-states.""" warnings.warn("Use attribute, joint_dos", DeprecationWarning) return self.joint_dos @property def frequency_points(self): + """Getter and setter of frequency points.""" return self._frequency_points @frequency_points.setter def frequency_points(self, frequency_points): - self._frequency_points = np.array(frequency_points, dtype='double') + self._frequency_points = np.array(frequency_points, dtype="double") def get_frequency_points(self): + """Return frequency points.""" warnings.warn("Use attribute, frequency_points", DeprecationWarning) return self.frequency_points def get_phonons(self): + """Return phonon calculation results.""" return self._frequencies, self._eigenvectors, self._phonon_done @property - def primitive(self): + def primitive(self) -> Primitive: + """Return primitive cell.""" return self._primitive def get_primitive(self): + """Return primitive cell.""" warnings.warn("Use attribute, primitive", DeprecationWarning) return self.primitive @property def mesh_numbers(self): + """Return mesh numbers by three integer values.""" return self._bz_grid.D_diag def get_mesh_numbers(self): + """Return mesh numbers by three integer values.""" warnings.warn("Use attribute, mesh_numbers", DeprecationWarning) return self.mesh @property def nac_q_direction(self): + """Getter and setter of q-direction for NAC.""" return self._nac_q_direction @nac_q_direction.setter @@ -169,19 +191,22 @@ class JointDos(object): if nac_q_direction is None: self._nac_q_direction = None else: - self._nac_q_direction = np.array(nac_q_direction, dtype='double') + self._nac_q_direction = np.array(nac_q_direction, dtype="double") def set_nac_q_direction(self, nac_q_direction=None): + """Set q-direction for NAC.""" warnings.warn("Use attribute, nac_q_direction", DeprecationWarning) self.nac_q_direction = nac_q_direction def set_sigma(self, sigma): + """Set sigma value. None means tetrahedron method.""" if sigma is None: self._sigma = None else: self._sigma = float(sigma) def set_grid_point(self, grid_point): + """Set a grid point at which joint-DOS is calculated.""" self._grid_point = grid_point self._set_triplets() if self._phonon_done is None: @@ -189,41 +214,47 @@ class JointDos(object): self._joint_dos = None self._frequency_points = None self._phonon_done[0] = 0 - self.run_phonon_solver(np.array([grid_point], dtype='int_')) + self.run_phonon_solver(np.array([grid_point], dtype="int_")) def get_triplets_at_q(self): + """Return triplets information.""" return self._triplets_at_q, self._weights_at_q @property - def bz_grid(self): + def bz_grid(self) -> BZGrid: + """Return BZGrid.""" return self._bz_grid def run_phonon_solver(self, grid_points): - """Calculate phonons at grid_points + """Calculate phonons at grid_points. This method is used in get_triplets_integration_weights by this method name. So this name is not allowed to change. """ - run_phonon_solver_c(self._dm, - self._frequencies, - self._eigenvectors, - self._phonon_done, - grid_points, - self._bz_grid.addresses, - self._bz_grid.QDinv, - self._frequency_factor_to_THz, - self._nac_q_direction, - self._lapack_zheev_uplo) + run_phonon_solver_c( + self._dm, + self._frequencies, + self._eigenvectors, + self._phonon_done, + grid_points, + self._bz_grid.addresses, + self._bz_grid.QDinv, + self._frequency_factor_to_THz, + self._nac_q_direction, + self._lapack_zheev_uplo, + ) - def _run_c(self, lang='C'): + def _run_c(self, lang="C"): if self._sigma is None: - if lang == 'C': + if lang == "C": self._run_c_with_g() else: if self._temperatures is not None: - print("JDOS with phonon occupation numbers doesn't work " - "in this option.") + print( + "JDOS with phonon occupation numbers doesn't work " + "in this option." + ) self._run_py_tetrahedron_method() else: self._run_c_with_g() @@ -233,57 +264,68 @@ class JointDos(object): max_phonon_freq = np.max(self._frequencies) self._frequency_points = get_frequency_points( max_phonon_freq=max_phonon_freq, - sigmas=[self._sigma, ], + sigmas=[ + self._sigma, + ], frequency_points=None, frequency_step=self._frequency_step, - num_frequency_points=self._num_frequency_points) + num_frequency_points=self._num_frequency_points, + ) num_freq_points = len(self._frequency_points) if self._temperatures is None: - jdos = np.zeros((num_freq_points, 2), dtype='double') + jdos = np.zeros((num_freq_points, 2), dtype="double") else: num_temps = len(self._temperatures) - jdos = np.zeros((num_temps, num_freq_points, 2), dtype='double') + jdos = np.zeros((num_temps, num_freq_points, 2), dtype="double") occ_phonons = [] for t in self._temperatures: freqs = self._frequencies[self._triplets_at_q[:, 1:]] - occ_phonons.append(np.where(freqs > self._cutoff_frequency, - bose_einstein(freqs, t), 0)) + occ_phonons.append( + np.where(freqs > self._cutoff_frequency, bose_einstein(freqs, t), 0) + ) for i, freq_point in enumerate(self._frequency_points): g, _ = get_triplets_integration_weights( self, - np.array([freq_point], dtype='double'), + np.array([freq_point], dtype="double"), self._sigma, is_collision_matrix=True, - neighboring_phonons=(i == 0)) + neighboring_phonons=(i == 0), + ) if self._temperatures is None: jdos[i, 1] = np.sum( - np.tensordot(g[0, :, 0], self._weights_at_q, axes=(0, 0))) + np.tensordot(g[0, :, 0], self._weights_at_q, axes=(0, 0)) + ) gx = g[2] - g[0] jdos[i, 0] = np.sum( - np.tensordot(gx[:, 0], self._weights_at_q, axes=(0, 0))) + np.tensordot(gx[:, 0], self._weights_at_q, axes=(0, 0)) + ) else: for j, n in enumerate(occ_phonons): for k, l in list(np.ndindex(g.shape[3:])): jdos[j, i, 1] += np.dot( - (n[:, 0, k] + n[:, 1, l] + 1) * - g[0, :, 0, k, l], self._weights_at_q) - jdos[j, i, 0] += np.dot((n[:, 0, k] - n[:, 1, l]) * - g[1, :, 0, k, l], - self._weights_at_q) + (n[:, 0, k] + n[:, 1, l] + 1) * g[0, :, 0, k, l], + self._weights_at_q, + ) + jdos[j, i, 0] += np.dot( + (n[:, 0, k] - n[:, 1, l]) * g[1, :, 0, k, l], + self._weights_at_q, + ) self._joint_dos = jdos / np.prod(self._bz_grid.D_diag) def _run_py_tetrahedron_method(self): thm = TetrahedronMethod(self._bz_grid.microzone_lattice) self._vertices = get_tetrahedra_vertices( - np.array(np.dot(thm.get_tetrahedra(), self._bz_grid.P.T), - dtype='int_', order='C'), + np.array( + np.dot(thm.get_tetrahedra(), self._bz_grid.P.T), dtype="int_", order="C" + ), self._bz_grid.D_diag, self._triplets_at_q, - self._bz_grid) + self._bz_grid, + ) self.run_phonon_solver(self._vertices.ravel()) f_max = np.max(self._frequencies) * 2 f_max *= 1.005 @@ -291,7 +333,7 @@ class JointDos(object): self._set_uniform_frequency_points(f_min, f_max) num_freq_points = len(self._frequency_points) - jdos = np.zeros((num_freq_points, 2), dtype='double') + jdos = np.zeros((num_freq_points, 2), dtype="double") for vertices, w in zip(self._vertices, self._weights_at_q): for i, j in list(np.ndindex(self._num_band, self._num_band)): f1 = self._frequencies[vertices[0], i] @@ -320,7 +362,8 @@ class JointDos(object): self._primitive, nac_params=self._nac_params, frequency_scale_factor=self._frequency_scale_factor, - symprec=self._symprec) + symprec=self._symprec, + ) def _set_triplets(self): if not self._is_mesh_symmetry: @@ -328,22 +371,20 @@ class JointDos(object): print("Triplets at q without considering symmetry") sys.stdout.flush() - (self._triplets_at_q, - self._weights_at_q, - _, - _) = get_nosym_triplets_at_q( - self._grid_point, self._bz_grid) + (self._triplets_at_q, self._weights_at_q, _, _) = get_nosym_triplets_at_q( + self._grid_point, self._bz_grid + ) else: - (self._triplets_at_q, - self._weights_at_q, - _, - _) = get_triplets_at_q(self._grid_point, self._bz_grid) + (self._triplets_at_q, self._weights_at_q, _, _) = get_triplets_at_q( + self._grid_point, self._bz_grid + ) def _allocate_phonons(self): num_grid = len(self._bz_grid.addresses) num_band = self._num_band - self._phonon_done = np.zeros(num_grid, dtype='byte') - self._frequencies = np.zeros((num_grid, num_band), dtype='double') + self._phonon_done = np.zeros(num_grid, dtype="byte") + self._frequencies = np.zeros((num_grid, num_band), dtype="double") itemsize = self._frequencies.itemsize - self._eigenvectors = np.zeros((num_grid, num_band, num_band), - dtype=("c%d" % (itemsize * 2))) + self._eigenvectors = np.zeros( + (num_grid, num_band, num_band), dtype=("c%d" % (itemsize * 2)) + ) diff --git a/phono3py/phonon3/real_self_energy.py b/phono3py/phonon3/real_self_energy.py index f567acc0..8f248232 100644 --- a/phono3py/phonon3/real_self_energy.py +++ b/phono3py/phonon3/real_self_energy.py @@ -38,21 +38,25 @@ from phonopy.units import Hbar, EV, THz from phonopy.phonon.degeneracy import degenerate_sets from phono3py.phonon.func import bose_einstein from phono3py.file_IO import ( - write_real_self_energy_at_grid_point, write_real_self_energy_to_hdf5) + write_real_self_energy_at_grid_point, + write_real_self_energy_to_hdf5, +) from phono3py.phonon3.imag_self_energy import get_frequency_points -def get_real_self_energy(interaction, - grid_points, - temperatures, - epsilons=None, - frequency_points=None, - frequency_step=None, - num_frequency_points=None, - frequency_points_at_bands=False, - write_hdf5=True, - output_filename=None, - log_level=0): +def get_real_self_energy( + interaction, + grid_points, + temperatures, + epsilons=None, + frequency_points=None, + frequency_step=None, + num_frequency_points=None, + frequency_points_at_bands=False, + write_hdf5=True, + output_filename=None, + log_level=0, +): """Real part of self energy at frequency points Band indices to be calculated at are kept in Interaction instance. @@ -113,11 +117,13 @@ def get_real_self_energy(interaction, """ if epsilons is None: - _epsilons = [None, ] + _epsilons = [ + None, + ] else: _epsilons = epsilons - _temperatures = np.array(temperatures, dtype='double') + _temperatures = np.array(temperatures, dtype="double") if (interaction.get_phonons()[2] == 0).any(): if log_level: @@ -132,20 +138,30 @@ def get_real_self_energy(interaction, if frequency_points_at_bands: _frequency_points = None - all_deltas = np.zeros((len(_epsilons), len(_temperatures), - len(grid_points), len(band_indices)), - dtype='double', order='C') + all_deltas = np.zeros( + (len(_epsilons), len(_temperatures), len(grid_points), len(band_indices)), + dtype="double", + order="C", + ) else: _frequency_points = get_frequency_points( max_phonon_freq=max_phonon_freq, sigmas=epsilons, frequency_points=frequency_points, frequency_step=frequency_step, - num_frequency_points=num_frequency_points) - all_deltas = np.zeros((len(_epsilons), len(_temperatures), - len(grid_points), len(band_indices), - len(_frequency_points)), - dtype='double', order='C') + num_frequency_points=num_frequency_points, + ) + all_deltas = np.zeros( + ( + len(_epsilons), + len(_temperatures), + len(grid_points), + len(band_indices), + len(_frequency_points), + ), + dtype="double", + order="C", + ) fst.frequency_points = _frequency_points for j, gp in enumerate(grid_points): @@ -153,14 +169,17 @@ def get_real_self_energy(interaction, if log_level: weights = interaction.get_triplets_at_q()[1] if len(grid_points) > 1: - print("------------------- Real part of self energy -o- (%d/%d) " - "-------------------" % (j + 1, len(grid_points))) + print( + "------------------- Real part of self energy -o- (%d/%d) " + "-------------------" % (j + 1, len(grid_points)) + ) else: - print("----------------------- Real part of self energy -o- " - "-----------------------") + print( + "----------------------- Real part of self energy -o- " + "-----------------------" + ) print("Grid point: %d" % gp) - print("Number of ir-triplets: %d / %d" - % (len(weights), weights.sum())) + print("Number of ir-triplets: %d / %d" % (len(weights), weights.sum())) fst.run_interaction() frequencies = interaction.get_phonons()[0][gp] @@ -168,8 +187,7 @@ def get_real_self_energy(interaction, if log_level: bz_grid = interaction.bz_grid qpoint = np.dot(bz_grid.QDinv, bz_grid.addresses[gp]) - print("Phonon frequencies at (%4.2f, %4.2f, %4.2f):" - % tuple(qpoint)) + print("Phonon frequencies at (%4.2f, %4.2f, %4.2f):" % tuple(qpoint)) for bi, freq in enumerate(frequencies): print("%3d %f" % (bi + 1, freq)) sys.stdout.flush() @@ -210,28 +228,32 @@ def get_real_self_energy(interaction, fst.epsilon, frequency_points=_frequency_points, frequencies=frequencies, - filename=output_filename) + filename=output_filename, + ) if log_level: - print("Real part of self energies were stored in \"%s\"." - % filename) + print('Real part of self energies were stored in "%s".' % filename) sys.stdout.flush() return _frequency_points, all_deltas -def write_real_self_energy(real_self_energy, - mesh, - grid_points, - band_indices, - frequency_points, - temperatures, - epsilons, - output_filename=None, - is_mesh_symmetry=True, - log_level=0): +def write_real_self_energy( + real_self_energy, + mesh, + grid_points, + band_indices, + frequency_points, + temperatures, + epsilons, + output_filename=None, + is_mesh_symmetry=True, + log_level=0, +): if epsilons is None: - _epsilons = [RealSelfEnergy.default_epsilon, ] + _epsilons = [ + RealSelfEnergy.default_epsilon, + ] else: _epsilons = epsilons @@ -246,15 +268,18 @@ def write_real_self_energy(real_self_energy, gp, bi, frequency_points, - rse[pos:(pos + len(bi))].sum(axis=0) / len(bi), + rse[pos : (pos + len(bi))].sum(axis=0) / len(bi), mesh, epsilon, t, filename=output_filename, - is_mesh_symmetry=is_mesh_symmetry) + is_mesh_symmetry=is_mesh_symmetry, + ) if log_level: - print("Real parts of self-energies were " - "written to \"%s\"." % filename) + print( + "Real parts of self-energies were " + 'written to "%s".' % filename + ) class RealSelfEnergy(object): @@ -280,12 +305,9 @@ class RealSelfEnergy(object): """ - def __init__(self, - interaction, - grid_point=None, - temperature=None, - epsilon=None, - lang='C'): + def __init__( + self, interaction, grid_point=None, temperature=None, epsilon=None, lang="C" + ): """ Parameters @@ -323,9 +345,7 @@ class RealSelfEnergy(object): self._real_self_energies = None # Unit to THz of Delta - self._unit_conversion = (18 / (Hbar * EV) ** 2 - / (2 * np.pi * THz) ** 2 - * EV ** 2) + self._unit_conversion = 18 / (Hbar * EV) ** 2 / (2 * np.pi * THz) ** 2 * EV ** 2 def run(self): if self._pp_strength is None: @@ -333,20 +353,19 @@ class RealSelfEnergy(object): num_band0 = len(self._pp.band_indices) if self._frequency_points is None: - self._real_self_energies = np.zeros(num_band0, dtype='double') + self._real_self_energies = np.zeros(num_band0, dtype="double") self._run_with_band_indices() else: self._real_self_energies = np.zeros( - (len(self._frequency_points), num_band0), dtype='double') + (len(self._frequency_points), num_band0), dtype="double" + ) self._run_with_frequency_points() def run_interaction(self): self._pp.run(lang=self._lang) self._pp_strength = self._pp.interaction_strength - (self._frequencies, - self._eigenvectors) = self._pp.get_phonons()[:2] - (self._triplets_at_q, - self._weights_at_q) = self._pp.get_triplets_at_q()[:2] + (self._frequencies, self._eigenvectors) = self._pp.get_phonons()[:2] + (self._triplets_at_q, self._weights_at_q) = self._pp.get_triplets_at_q()[:2] self._band_indices = self._pp.band_indices @property @@ -365,13 +384,13 @@ class RealSelfEnergy(object): if len(bi_set) > 0: for i in bi_set: if self._frequency_points is None: - shifts[i] = ( - self._real_self_energies[bi_set].sum() - / len(bi_set)) + shifts[i] = self._real_self_energies[bi_set].sum() / len( + bi_set + ) else: - shifts[:, i] = ( - self._real_self_energies[:, bi_set].sum(axis=1) - / len(bi_set)) + shifts[:, i] = self._real_self_energies[:, bi_set].sum( + axis=1 + ) / len(bi_set) return shifts @property @@ -385,8 +404,7 @@ class RealSelfEnergy(object): else: self._pp.set_grid_point(grid_point) self._pp_strength = None - (self._triplets_at_q, - self._weights_at_q) = self._pp.get_triplets_at_q()[:2] + (self._triplets_at_q, self._weights_at_q) = self._pp.get_triplets_at_q()[:2] self._grid_point = self._triplets_at_q[0, 0] @property @@ -417,58 +435,60 @@ class RealSelfEnergy(object): @frequency_points.setter def frequency_points(self, frequency_points): - self._frequency_points = np.array(frequency_points, dtype='double') + self._frequency_points = np.array(frequency_points, dtype="double") def _run_with_band_indices(self): - if self._lang == 'C': + if self._lang == "C": self._run_c_with_band_indices() else: self._run_py_with_band_indices() def _run_with_frequency_points(self): - if self._lang == 'C': + if self._lang == "C": self._run_c_with_frequency_points() else: self._run_py_with_frequency_points() def _run_c_with_band_indices(self): import phono3py._phono3py as phono3c - phono3c.real_self_energy_at_bands(self._real_self_energies, - self._pp_strength, - self._triplets_at_q, - self._weights_at_q, - self._frequencies, - self._band_indices, - self._temperature, - self._epsilon, - self._unit_conversion, - self._cutoff_frequency) + + phono3c.real_self_energy_at_bands( + self._real_self_energies, + self._pp_strength, + self._triplets_at_q, + self._weights_at_q, + self._frequencies, + self._band_indices, + self._temperature, + self._epsilon, + self._unit_conversion, + self._cutoff_frequency, + ) def _run_py_with_band_indices(self): for i, (triplet, w, interaction) in enumerate( - zip(self._triplets_at_q, - self._weights_at_q, - self._pp_strength)): + zip(self._triplets_at_q, self._weights_at_q, self._pp_strength) + ): freqs = self._frequencies[triplet] for j, bi in enumerate(self._band_indices): fpoint = freqs[0, bi] if self._temperature > 0: - self._real_self_energies[j] += ( - self._real_self_energies_at_bands( - j, fpoint, freqs, interaction, w)) + self._real_self_energies[j] += self._real_self_energies_at_bands( + j, fpoint, freqs, interaction, w + ) else: - self._real_self_energies[j] += ( - self._real_self_energies_at_bands_0K( - j, fpoint, freqs, interaction, w)) + self._real_self_energies[j] += self._real_self_energies_at_bands_0K( + j, fpoint, freqs, interaction, w + ) self._real_self_energies *= self._unit_conversion def _run_c_with_frequency_points(self): import phono3py._phono3py as phono3c + for i, fpoint in enumerate(self._frequency_points): - shifts = np.zeros(self._real_self_energies.shape[1], - dtype='double') + shifts = np.zeros(self._real_self_energies.shape[1], dtype="double") phono3c.real_self_energy_at_frequency_point( shifts, fpoint, @@ -480,31 +500,34 @@ class RealSelfEnergy(object): self._temperature, self._epsilon, self._unit_conversion, - self._cutoff_frequency) + self._cutoff_frequency, + ) self._real_self_energies[i][:] = shifts def _run_py_with_frequency_points(self): for k, fpoint in enumerate(self._frequency_points): for i, (triplet, w, interaction) in enumerate( - zip(self._triplets_at_q, - self._weights_at_q, - self._pp_strength)): + zip(self._triplets_at_q, self._weights_at_q, self._pp_strength) + ): freqs = self._frequencies[triplet] for j, bi in enumerate(self._band_indices): if self._temperature > 0: - self._real_self_energies[k, j] += ( - self._real_self_energies_at_bands( - j, fpoint, freqs, interaction, w)) + self._real_self_energies[ + k, j + ] += self._real_self_energies_at_bands( + j, fpoint, freqs, interaction, w + ) else: - self._real_self_energies[k, j] += ( - self._real_self_energies_at_bands_0K( - j, fpoint, freqs, interaction, w)) + self._real_self_energies[ + k, j + ] += self._real_self_energies_at_bands_0K( + j, fpoint, freqs, interaction, w + ) self._real_self_energies *= self._unit_conversion - def _real_self_energies_at_bands(self, i, fpoint, freqs, - interaction, weight): + def _real_self_energies_at_bands(self, i, fpoint, freqs, interaction, weight): if fpoint < self._cutoff_frequency: return 0 @@ -513,8 +536,10 @@ class RealSelfEnergy(object): if fpoint < self._cutoff_frequency: continue - if (freqs[1, j] > self._cutoff_frequency and - freqs[2, k] > self._cutoff_frequency): + if ( + freqs[1, j] > self._cutoff_frequency + and freqs[2, k] > self._cutoff_frequency + ): d = 0.0 n2 = bose_einstein(freqs[1, j], self._temperature) n3 = bose_einstein(freqs[2, k], self._temperature) @@ -539,15 +564,16 @@ class RealSelfEnergy(object): sum_d += d * interaction[i, j, k] * weight return sum_d - def _real_self_energies_at_bands_0K(self, i, fpoint, freqs, - interaction, weight): + def _real_self_energies_at_bands_0K(self, i, fpoint, freqs, interaction, weight): if fpoint < self._cutoff_frequency: return 0 sum_d = 0 for (j, k) in list(np.ndindex(interaction.shape[1:])): - if (freqs[1, j] > self._cutoff_frequency and - freqs[2, k] > self._cutoff_frequency): + if ( + freqs[1, j] > self._cutoff_frequency + and freqs[2, k] > self._cutoff_frequency + ): d = 0.0 f1 = fpoint + freqs[1, j] + freqs[2, k] f2 = fpoint - freqs[1, j] - freqs[2, k] @@ -572,10 +598,7 @@ def imag_to_real(im_part, frequency_points): class ImagToReal(object): """Calculate real part of self-energy using Kramers-Kronig relation""" - def __init__(self, - im_part, - frequency_points, - diagram='bubble'): + def __init__(self, im_part, frequency_points, diagram="bubble"): """ Parameters @@ -593,10 +616,12 @@ class ImagToReal(object): """ - if diagram == 'bubble': - (self._im_part, - self._all_frequency_points, - self._df) = self._expand_bubble_im_part(im_part, frequency_points) + if diagram == "bubble": + ( + self._im_part, + self._all_frequency_points, + self._df, + ) = self._expand_bubble_im_part(im_part, frequency_points) else: raise RuntimeError("Only daigram='bubble' is implemented.") @@ -611,10 +636,10 @@ class ImagToReal(object): def frequency_points(self): return self._frequency_points - def run(self, method='pick_one'): - if method == 'pick_one': + def run(self, method="pick_one"): + if method == "pick_one": self._re_part, self._frequency_points = self._pick_one() - elif method == 'half_shift': + elif method == "half_shift": self._re_part, self._frequency_points = self._half_shift() else: raise RuntimeError("No method is found.") @@ -633,8 +658,7 @@ class ImagToReal(object): val = ((self._im_part / freqs).sum() - im_part_at_i) * coef re_part.append(val) fpoints.append(fpoint) - return (np.array(re_part, dtype='double'), - np.array(fpoints, dtype='double')) + return (np.array(re_part, dtype="double"), np.array(fpoints, dtype="double")) def _half_shift(self): re_part = [] @@ -649,24 +673,20 @@ class ImagToReal(object): val = (self._im_part / freqs).sum() * coef re_part.append(val) fpoints.append(fpoint) - return (np.array(re_part, dtype='double'), - np.array(fpoints, dtype='double')) + return (np.array(re_part, dtype="double"), np.array(fpoints, dtype="double")) def _expand_bubble_im_part(self, im_part, frequency_points): if (np.abs(frequency_points[0]) > 1e-8).any(): - raise RuntimeError( - "The first element of frequency_points is not zero.") + raise RuntimeError("The first element of frequency_points is not zero.") all_df = np.subtract(frequency_points[1:], frequency_points[:-1]) df = np.mean(all_df) if (np.abs(all_df - df) > 1e-6).any(): print(all_df) - raise RuntimeError( - "Frequency interval of frequency_points is not uniform.") + raise RuntimeError("Frequency interval of frequency_points is not uniform.") # im_part is inverted at omega < 0. _im_part = np.hstack([-im_part[::-1], im_part[1:]]) - _frequency_points = np.hstack([-frequency_points[::-1], - frequency_points[1:]]) + _frequency_points = np.hstack([-frequency_points[::-1], frequency_points[1:]]) return _im_part, _frequency_points, df diff --git a/phono3py/phonon3/real_to_reciprocal.py b/phono3py/phonon3/real_to_reciprocal.py index 9eef15cc..8b0f3dff 100644 --- a/phono3py/phonon3/real_to_reciprocal.py +++ b/phono3py/phonon3/real_to_reciprocal.py @@ -40,11 +40,7 @@ from phonopy.structure.cells import sparse_to_dense_svecs class RealToReciprocal(object): """Transform fc3 in real space to reciprocal space.""" - def __init__(self, - fc3, - primitive, - mesh, - symprec=1e-5): + def __init__(self, fc3, primitive, mesh, symprec=1e-5): """Init method.""" self._fc3 = fc3 self._primitive = primitive @@ -66,9 +62,10 @@ class RealToReciprocal(object): """Run at each triplet of q-vectors.""" self._triplet = triplet num_patom = len(self._primitive) - dtype = "c%d" % (np.dtype('double').itemsize * 2) + dtype = "c%d" % (np.dtype("double").itemsize * 2) self._fc3_reciprocal = np.zeros( - (num_patom, num_patom, num_patom, 3, 3, 3), dtype=dtype) + (num_patom, num_patom, num_patom, 3, 3, 3), dtype=dtype + ) self._real_to_reciprocal() def get_fc3_reciprocal(self): @@ -78,13 +75,15 @@ class RealToReciprocal(object): def _real_to_reciprocal(self): num_patom = len(self._primitive) sum_triplets = np.where( - np.all(self._triplet != 0, axis=0), self._triplet.sum(axis=0), 0) - sum_q = sum_triplets.astype('double') / self._mesh + np.all(self._triplet != 0, axis=0), self._triplet.sum(axis=0), 0 + ) + sum_q = sum_triplets.astype("double") / self._mesh for i in range(num_patom): for j in range(num_patom): for k in range(num_patom): - self._fc3_reciprocal[ - i, j, k] = self._real_to_reciprocal_elements((i, j, k)) + self._fc3_reciprocal[i, j, k] = self._real_to_reciprocal_elements( + (i, j, k) + ) prephase = self._get_prephase(sum_q, i) self._fc3_reciprocal[i] *= prephase @@ -93,7 +92,7 @@ class RealToReciprocal(object): num_satom = len(self._s2p_map) pi = patom_indices i = self._p2s_map[pi[0]] - dtype = "c%d" % (np.dtype('double').itemsize * 2) + dtype = "c%d" % (np.dtype("double").itemsize * 2) fc3_reciprocal = np.zeros((3, 3, 3), dtype=dtype) for j in range(num_satom): if self._s2p_map[j] != self._p2s_map[pi[1]]: @@ -112,12 +111,17 @@ class RealToReciprocal(object): def _get_phase(self, satom_indices, patom0_index): si = satom_indices p0 = patom0_index - phase = 1+0j + phase = 1 + 0j for i in (0, 1): svecs_adrs = self._multi[si[i], p0, 1] multi = self._multi[si[i], p0, 0] - vs = self._svecs[svecs_adrs:(svecs_adrs + multi)] - phase *= (np.exp(2j * np.pi * np.dot( - vs, self._triplet[i + 1].astype('double') / - self._mesh)).sum() / multi) + vs = self._svecs[svecs_adrs : (svecs_adrs + multi)] + phase *= ( + np.exp( + 2j + * np.pi + * np.dot(vs, self._triplet[i + 1].astype("double") / self._mesh) + ).sum() + / multi + ) return phase diff --git a/phono3py/phonon3/reciprocal_to_normal.py b/phono3py/phonon3/reciprocal_to_normal.py index 6c70cb4f..ea1e08e9 100644 --- a/phono3py/phonon3/reciprocal_to_normal.py +++ b/phono3py/phonon3/reciprocal_to_normal.py @@ -1,3 +1,4 @@ +"""Transform fc3 in reciprocal space to phonon space.""" # Copyright (C) 2020 Atsushi Togo # All rights reserved. # @@ -35,33 +36,42 @@ import numpy as np -class ReciprocalToNormal(object): - def __init__(self, - primitive, - frequencies, - eigenvectors, - band_indices, - cutoff_frequency=0): +class ReciprocalToNormal: + """Class to transform fc3 in reciprocal space to phonon space. + + This is an implementation in python for prototyping and the test. + Equivalent routine is implementated in C, and this is what usually + we use. + + """ + + def __init__( + self, primitive, frequencies, eigenvectors, band_indices, cutoff_frequency=0 + ): + """Init method.""" self._primitive = primitive self._frequencies = frequencies self._eigenvectors = eigenvectors self._band_indices = band_indices self._cutoff_frequency = cutoff_frequency - self._masses = self._primitive.get_masses() + self._masses = self._primitive.masses self._fc3_normal = None self._fc3_reciprocal = None def run(self, fc3_reciprocal, grid_triplet): - num_band = self._primitive.get_number_of_atoms() * 3 + """Calculate fc3 in phonon coordinates.""" + num_band = len(self._primitive) * 3 self._fc3_reciprocal = fc3_reciprocal - dtype = "c%d" % (np.dtype('double').itemsize * 2) + dtype = "c%d" % (np.dtype("double").itemsize * 2) self._fc3_normal = np.zeros( - (len(self._band_indices), num_band, num_band), dtype=dtype) + (len(self._band_indices), num_band, num_band), dtype=dtype + ) self._reciprocal_to_normal(grid_triplet) def get_reciprocal_to_normal(self): + """Return fc3 in phonon coordinates.""" return self._fc3_normal def _reciprocal_to_normal(self, grid_triplet): @@ -69,8 +79,7 @@ class ReciprocalToNormal(object): f1, f2, f3 = self._frequencies[grid_triplet] num_band = len(f1) cutoff = self._cutoff_frequency - for (i, j, k) in list(np.ndindex( - len(self._band_indices), num_band, num_band)): + for (i, j, k) in list(np.ndindex(len(self._band_indices), num_band, num_band)): bi = self._band_indices[i] if f1[bi] > cutoff and f2[j] > cutoff and f3[k] > cutoff: fc3_elem = self._sum_in_atoms((bi, j, k), (e1, e2, e3)) @@ -86,10 +95,12 @@ class ReciprocalToNormal(object): for (i, j, k) in list(np.ndindex((num_atom,) * 3)): sum_fc3_cart = 0 for (l, m, n) in list(np.ndindex((3, 3, 3))): - sum_fc3_cart += (e1[i * 3 + l, b1] * - e2[j * 3 + m, b2] * - e3[k * 3 + n, b3] * - self._fc3_reciprocal[i, j, k, l, m, n]) + sum_fc3_cart += ( + e1[i * 3 + l, b1] + * e2[j * 3 + m, b2] + * e3[k * 3 + n, b3] + * self._fc3_reciprocal[i, j, k, l, m, n] + ) mass_sqrt = np.sqrt(np.prod(self._masses[[i, j, k]])) sum_fc3 += sum_fc3_cart / mass_sqrt diff --git a/phono3py/phonon3/spectral_function.py b/phono3py/phonon3/spectral_function.py index 3f9e82cc..d9e7b298 100644 --- a/phono3py/phonon3/spectral_function.py +++ b/phono3py/phonon3/spectral_function.py @@ -35,25 +35,32 @@ import sys import numpy as np from phono3py.phonon3.imag_self_energy import ( - run_ise_at_frequency_points_batch, get_frequency_points, ImagSelfEnergy) + run_ise_at_frequency_points_batch, + get_frequency_points, + ImagSelfEnergy, +) from phono3py.phonon3.real_self_energy import imag_to_real from phono3py.file_IO import ( - write_spectral_function_at_grid_point, write_spectral_function_to_hdf5) + write_spectral_function_at_grid_point, + write_spectral_function_to_hdf5, +) -def run_spectral_function(interaction, - grid_points, - temperatures=None, - sigmas=None, - frequency_points=None, - frequency_step=None, - num_frequency_points=None, - num_points_in_batch=None, - band_indices=None, - write_txt=False, - write_hdf5=False, - output_filename=None, - log_level=0): +def run_spectral_function( + interaction, + grid_points, + temperatures=None, + sigmas=None, + frequency_points=None, + frequency_step=None, + num_frequency_points=None, + num_points_in_batch=None, + band_indices=None, + write_txt=False, + write_hdf5=False, + output_filename=None, + log_level=0, +): """Spectral function of self energy at frequency points Band indices to be calculated at are kept in Interaction instance. @@ -106,20 +113,21 @@ def run_spectral_function(interaction, """ - spf = SpectralFunction(interaction, - grid_points, - frequency_points=frequency_points, - frequency_step=frequency_step, - num_frequency_points=num_frequency_points, - num_points_in_batch=num_points_in_batch, - sigmas=sigmas, - temperatures=temperatures, - log_level=log_level) + spf = SpectralFunction( + interaction, + grid_points, + frequency_points=frequency_points, + frequency_step=frequency_step, + num_frequency_points=num_frequency_points, + num_points_in_batch=num_points_in_batch, + sigmas=sigmas, + temperatures=temperatures, + log_level=log_level, + ) for i, gp in enumerate(spf): frequencies = interaction.get_phonons()[0] for sigma_i, sigma in enumerate(spf.sigmas): - for t, spf_at_t in zip( - temperatures, spf.spectral_functions[sigma_i, :, i]): + for t, spf_at_t in zip(temperatures, spf.spectral_functions[sigma_i, :, i]): for j, bi in enumerate(band_indices): pos = 0 for k in range(j): @@ -128,15 +136,16 @@ def run_spectral_function(interaction, gp, bi, spf.frequency_points, - spf_at_t[pos:(pos + len(bi))].sum(axis=0) / len(bi), + spf_at_t[pos : (pos + len(bi))].sum(axis=0) / len(bi), interaction.mesh_numbers, t, sigma=sigma, filename=output_filename, - is_mesh_symmetry=interaction.is_mesh_symmetry) + is_mesh_symmetry=interaction.is_mesh_symmetry, + ) if log_level: print("Spectral functions were written to") - print("\"%s\"." % filename) + print('"%s".' % filename) filename = write_spectral_function_to_hdf5( gp, @@ -149,10 +158,11 @@ def run_spectral_function(interaction, sigma=sigma, frequency_points=spf.frequency_points, frequencies=frequencies[gp], - filename=output_filename) + filename=output_filename, + ) if log_level: - print("Spectral functions were stored in \"%s\"." % filename) + print('Spectral functions were stored in "%s".' % filename) sys.stdout.flush() return spf @@ -161,16 +171,18 @@ def run_spectral_function(interaction, class SpectralFunction(object): """Calculate spectral function""" - def __init__(self, - interaction, - grid_points, - frequency_points=None, - frequency_step=None, - num_frequency_points=None, - num_points_in_batch=None, - sigmas=None, - temperatures=None, - log_level=0): + def __init__( + self, + interaction, + grid_points, + frequency_points=None, + frequency_step=None, + num_frequency_points=None, + num_points_in_batch=None, + sigmas=None, + temperatures=None, + log_level=0, + ): self._interaction = interaction self._grid_points = grid_points self._frequency_points_in = frequency_points @@ -181,7 +193,9 @@ class SpectralFunction(object): self._log_level = log_level if sigmas is None: - self._sigmas = [None, ] + self._sigmas = [ + None, + ] else: self._sigmas = sigmas self._frequency_points = None @@ -209,8 +223,10 @@ class SpectralFunction(object): raise StopIteration if self._log_level: - print(("-" * 24 + " Spectral function (%d/%d) " + "-" * 24) - % (self._gp_index + 1, len(self._grid_points))) + print( + ("-" * 24 + " Spectral function (%d/%d) " + "-" * 24) + % (self._gp_index + 1, len(self._grid_points)) + ) gp = self._grid_points[self._gp_index] ise = ImagSelfEnergy(self._interaction) @@ -257,10 +273,16 @@ class SpectralFunction(object): def _prepare(self): self._set_frequency_points() self._gammas = np.zeros( - (len(self._sigmas), len(self._temperatures), - len(self._grid_points), len(self._interaction.band_indices), - len(self._frequency_points)), - dtype='double', order='C') + ( + len(self._sigmas), + len(self._temperatures), + len(self._grid_points), + len(self._interaction.band_indices), + len(self._frequency_points), + ), + dtype="double", + order="C", + ) self._deltas = np.zeros_like(self._gammas) self._spectral_functions = np.zeros_like(self._gammas) self._gp_index = 0 @@ -278,7 +300,8 @@ class SpectralFunction(object): self._temperatures, self._gammas, nelems_in_batch=self._num_points_in_batch, - log_level=self._log_level) + log_level=self._log_level, + ) def _run_delta(self, i, sigma_i): if self._log_level: @@ -288,7 +311,8 @@ class SpectralFunction(object): for j, temp in enumerate(self._temperatures): for k, bi in enumerate(self._interaction.band_indices): re_part, fpoints = imag_to_real( - self._gammas[sigma_i, j, i, k], self._frequency_points) + self._gammas[sigma_i, j, i, k], self._frequency_points + ) self._deltas[sigma_i, j, i, k] = -re_part assert (np.abs(self._frequency_points - fpoints) < 1e-8).all() @@ -323,8 +347,9 @@ class SpectralFunction(object): def _get_spectral_function(self, gammas, deltas, freq): fpoints = self._frequency_points nums = 4 * freq ** 2 * gammas / np.pi - denoms = ((fpoints ** 2 - freq ** 2 - 2 * freq * deltas) ** 2 - + (2 * freq * gammas) ** 2) + denoms = (fpoints ** 2 - freq ** 2 - 2 * freq * deltas) ** 2 + ( + 2 * freq * gammas + ) ** 2 vals = np.where(denoms > 0, nums / denoms, 0) return vals @@ -339,4 +364,5 @@ class SpectralFunction(object): sigmas=self._sigmas, frequency_points=self._frequency_points_in, frequency_step=self._frequency_step, - num_frequency_points=self._num_frequency_points) + num_frequency_points=self._num_frequency_points, + ) diff --git a/phono3py/phonon3/triplets.py b/phono3py/phonon3/triplets.py index 7f9d62a7..90a9f2c6 100644 --- a/phono3py/phonon3/triplets.py +++ b/phono3py/phonon3/triplets.py @@ -1,3 +1,4 @@ +"""Utilities to handle q-point triplets.""" # Copyright (C) 2020 Atsushi Togo # All rights reserved. # @@ -37,12 +38,16 @@ from phonopy.structure.tetrahedron_method import TetrahedronMethod from phono3py.phonon.func import gaussian -def get_triplets_at_q(grid_point, - bz_grid, - reciprocal_rotations=None, - is_time_reversal=True, - swappable=True): - """Parameters +def get_triplets_at_q( + grid_point, + bz_grid, + reciprocal_rotations=None, + is_time_reversal=True, + swappable=True, +): + """Generate q-point triplets. + + Parameters ---------- grid_point : int A grid point in the grid type chosen by `store_dense_gp_map`. @@ -82,7 +87,6 @@ def get_triplets_at_q(grid_point, shape=(prod(mesh),), dtype='int_' """ - if reciprocal_rotations is None: rotations = bz_grid.rotations else: @@ -93,53 +97,54 @@ def get_triplets_at_q(grid_point, bz_grid.D_diag, rotations, is_time_reversal=is_time_reversal, - swappable=swappable) - triplets_at_q, weights = _get_BZ_triplets_at_q( - grid_point, - bz_grid, - map_triplets) + swappable=swappable, + ) + triplets_at_q, weights = _get_BZ_triplets_at_q(grid_point, bz_grid, map_triplets) - assert np.prod(bz_grid.D_diag) == weights.sum(), \ - "Num grid points %d, sum of weight %d" % ( - np.prod(bz_grid.D_diag), weights.sum()) + assert ( + np.prod(bz_grid.D_diag) == weights.sum() + ), "Num grid points %d, sum of weight %d" % (np.prod(bz_grid.D_diag), weights.sum()) return triplets_at_q, weights, map_triplets, map_q def get_all_triplets(grid_point, bz_grid): + """Return all triplets of a grid point. + + Almost equivalent to ``get_nosym_triplets_at_q``. + Symmetry reduced set of triplets is obtained by ``get_triplets_at_q``. + + """ triplets_at_q, _ = _get_BZ_triplets_at_q( - grid_point, - bz_grid, - np.arange(np.prod(bz_grid.D_diag), dtype='int_')) + grid_point, bz_grid, np.arange(np.prod(bz_grid.D_diag), dtype="int_") + ) return triplets_at_q def get_nosym_triplets_at_q(grid_point, bz_grid): - """Returns triplets information without imposing mesh symmetry + """Return triplets information without imposing mesh symmetry. See the docstring of get_triplets_at_q. """ - - map_triplets = np.arange(np.prod(bz_grid.D_diag), dtype='int_') - triplets_at_q, weights = _get_BZ_triplets_at_q( - grid_point, - bz_grid, - map_triplets) + map_triplets = np.arange(np.prod(bz_grid.D_diag), dtype="int_") + triplets_at_q, weights = _get_BZ_triplets_at_q(grid_point, bz_grid, map_triplets) map_q = map_triplets.copy() return triplets_at_q, weights, map_triplets, map_q -def get_triplets_integration_weights(interaction, - frequency_points, - sigma, - sigma_cutoff=None, - is_collision_matrix=False, - neighboring_phonons=False, - lang='C'): - """Calculate triplets integration weights +def get_triplets_integration_weights( + interaction, + frequency_points, + sigma, + sigma_cutoff=None, + is_collision_matrix=False, + neighboring_phonons=False, + lang="C", +): + """Calculate triplets integration weights. Returns ------- @@ -151,7 +156,6 @@ def get_triplets_integration_weights(interaction, shape=(triplets, ), dtype='byte' """ - triplets = interaction.get_triplets_at_q()[0] frequencies = interaction.get_phonons()[0] num_band = frequencies.shape[1] @@ -160,30 +164,30 @@ def get_triplets_integration_weights(interaction, if is_collision_matrix: g = np.empty( (3, len(triplets), len(frequency_points), num_band, num_band), - dtype='double', order='C') + dtype="double", + order="C", + ) else: g = np.empty( (2, len(triplets), len(frequency_points), num_band, num_band), - dtype='double', order='C') + dtype="double", + order="C", + ) g[:] = 0 if sigma: - if lang == 'C': + if lang == "C": import phono3py._phono3py as phono3c - g_zero = np.zeros(g.shape[1:], dtype='byte', order='C') + + g_zero = np.zeros(g.shape[1:], dtype="byte", order="C") if sigma_cutoff is None: cutoff = -1 else: cutoff = float(sigma_cutoff) # cutoff < 0 disables g_zero feature. phono3c.triplets_integration_weights_with_sigma( - g, - g_zero, - frequency_points, - triplets, - frequencies, - sigma, - cutoff) + g, g_zero, frequency_points, triplets, frequencies, sigma, cutoff + ) else: for i, tp in enumerate(triplets): f1s = frequencies[tp[1]] @@ -199,33 +203,35 @@ def get_triplets_integration_weights(interaction, if len(g) == 3: g[2, i, :, j, k] = g0 + g1 + g2 else: - if lang == 'C': - g_zero = np.zeros(g.shape[1:], dtype='byte', order='C') + if lang == "C": + g_zero = np.zeros(g.shape[1:], dtype="byte", order="C") _set_triplets_integration_weights_c( g, g_zero, interaction, frequency_points, - neighboring_phonons=neighboring_phonons) + neighboring_phonons=neighboring_phonons, + ) else: - _set_triplets_integration_weights_py( - g, interaction, frequency_points) + _set_triplets_integration_weights_py(g, interaction, frequency_points) return g, g_zero -def get_tetrahedra_vertices(relative_address, - mesh, - triplets_at_q, - bz_grid): +def get_tetrahedra_vertices(relative_address, mesh, triplets_at_q, bz_grid): + """Return vertices of tetrahedra used for tetrahedron method. + + Equivalent function is implemented in C and this python version exists + only for the test and assumes q1+q2+q3=G. + + """ bzmesh = mesh * 2 grid_order = [1, mesh[0], mesh[0] * mesh[1]] bz_grid_order = [1, bzmesh[0], bzmesh[0] * bzmesh[1]] num_triplets = len(triplets_at_q) - vertices = np.zeros((num_triplets, 2, 24, 4), dtype='int_') + vertices = np.zeros((num_triplets, 2, 24, 4), dtype="int_") for i, tp in enumerate(triplets_at_q): - for j, adrs_shift in enumerate( - (relative_address, -relative_address)): + for j, adrs_shift in enumerate((relative_address, -relative_address)): adrs = bz_grid.addresses[tp[j + 1]] + adrs_shift bz_gp = np.dot(adrs % bzmesh, bz_grid_order) gp = np.dot(adrs % mesh, grid_order) @@ -234,12 +240,10 @@ def get_tetrahedra_vertices(relative_address, return vertices -def _get_triplets_reciprocal_mesh_at_q(fixed_grid_number, - D_diag, - rec_rotations, - is_time_reversal=True, - swappable=True): - """Search symmetry reduced triplets fixing one q-point +def _get_triplets_reciprocal_mesh_at_q( + fixed_grid_number, D_diag, rec_rotations, is_time_reversal=True, swappable=True +): + """Search symmetry reduced triplets fixing one q-point. Triplets of (q0, q1, q2) are searched. This method doesn't consider translationally equivalent points on BZ surface. @@ -276,20 +280,20 @@ def _get_triplets_reciprocal_mesh_at_q(fixed_grid_number, shape=(prod(mesh),), dtype='int_' """ - import phono3py._phono3py as phono3c - map_triplets = np.zeros(np.prod(D_diag), dtype='int_') - map_q = np.zeros(np.prod(D_diag), dtype='int_') + map_triplets = np.zeros(np.prod(D_diag), dtype="int_") + map_q = np.zeros(np.prod(D_diag), dtype="int_") phono3c.triplets_reciprocal_mesh_at_q( map_triplets, map_q, fixed_grid_number, - np.array(D_diag, dtype='int_'), + np.array(D_diag, dtype="int_"), is_time_reversal * 1, - np.array(rec_rotations, dtype='int_', order='C'), - swappable * 1) + np.array(rec_rotations, dtype="int_", order="C"), + swappable * 1, + ) return map_triplets, map_q @@ -328,64 +332,63 @@ def _get_BZ_triplets_at_q(grid_point, bz_grid, map_triplets): shape=(n_triplets,), dtype='int_' """ - import phono3py._phono3py as phono3c - weights = np.zeros(len(map_triplets), dtype='int_') + weights = np.zeros(len(map_triplets), dtype="int_") for g in map_triplets: weights[g] += 1 ir_weights = np.extract(weights > 0, weights) - triplets = -np.ones((len(ir_weights), 3), dtype='int_') - Q = np.eye(3, dtype='int_', order='C') + triplets = -np.ones((len(ir_weights), 3), dtype="int_") + Q = np.eye(3, dtype="int_", order="C") num_ir_ret = phono3c.BZ_triplets_at_q( triplets, grid_point, bz_grid.addresses, bz_grid.gp_map, map_triplets, - np.array(bz_grid.D_diag, dtype='int_'), + np.array(bz_grid.D_diag, dtype="int_"), Q, - bz_grid.store_dense_gp_map * 1 + 1) + bz_grid.store_dense_gp_map * 1 + 1, + ) assert num_ir_ret == len(ir_weights) - return triplets, np.array(ir_weights, dtype='int_') + return triplets, np.array(ir_weights, dtype="int_") -def _set_triplets_integration_weights_c(g, - g_zero, - pp, - frequency_points, - neighboring_phonons=False): +def _set_triplets_integration_weights_c( + g, g_zero, pp, frequency_points, neighboring_phonons=False +): import phono3py._phono3py as phono3c thm = TetrahedronMethod(pp.bz_grid.microzone_lattice) triplets_at_q = pp.get_triplets_at_q()[0] if neighboring_phonons: - unique_vertices = np.dot( - thm.get_unique_tetrahedra_vertices(), pp.bz_grid.P.T) + unique_vertices = np.dot(thm.get_unique_tetrahedra_vertices(), pp.bz_grid.P.T) for i, j in zip((1, 2), (1, -1)): neighboring_grid_points = np.zeros( - len(unique_vertices) * len(triplets_at_q), dtype='int_') + len(unique_vertices) * len(triplets_at_q), dtype="int_" + ) phono3c.neighboring_grid_points( neighboring_grid_points, - np.array(triplets_at_q[:, i], dtype='int_').ravel(), - np.array(j * unique_vertices, dtype='int_', order='C'), + np.array(triplets_at_q[:, i], dtype="int_").ravel(), + np.array(j * unique_vertices, dtype="int_", order="C"), pp.bz_grid.D_diag, pp.bz_grid.addresses, pp.bz_grid.gp_map, - pp.bz_grid.store_dense_gp_map * 1 + 1) + pp.bz_grid.store_dense_gp_map * 1 + 1, + ) pp.run_phonon_solver( - np.array(np.unique(neighboring_grid_points), dtype='int_')) + np.array(np.unique(neighboring_grid_points), dtype="int_") + ) frequencies = pp.get_phonons()[0] phono3c.triplets_integration_weights( g, g_zero, frequency_points, # f0 - np.array(np.dot(thm.get_tetrahedra(), pp.bz_grid.P.T), - dtype='int_', order='C'), + np.array(np.dot(thm.get_tetrahedra(), pp.bz_grid.P.T), dtype="int_", order="C"), pp.bz_grid.D_diag, triplets_at_q, frequencies, # f1 @@ -393,20 +396,20 @@ def _set_triplets_integration_weights_c(g, pp.bz_grid.addresses, pp.bz_grid.gp_map, pp.bz_grid.store_dense_gp_map * 1 + 1, - g.shape[0]) + g.shape[0], + ) def _set_triplets_integration_weights_py(g, pp, frequency_points): thm = TetrahedronMethod(pp.bz_grid.microzone_lattice) triplets_at_q = pp.get_triplets_at_q()[0] tetrahedra_vertices = get_tetrahedra_vertices( - np.array(np.dot(thm.get_tetrahedra(), pp.bz_grid.P.T), - dtype='int_', order='C'), + np.array(np.dot(thm.get_tetrahedra(), pp.bz_grid.P.T), dtype="int_", order="C"), pp.bz_grid.D_diag, triplets_at_q, - pp.bz_grid) - pp.run_phonon_solver( - np.array(np.unique(tetrahedra_vertices), dtype='int_')) + pp.bz_grid, + ) + pp.run_phonon_solver(np.array(np.unique(tetrahedra_vertices), dtype="int_")) frequencies = pp.get_phonons()[0] num_band = frequencies.shape[1] for i, vertices in enumerate(tetrahedra_vertices): diff --git a/phono3py/sscha/__init__.py b/phono3py/sscha/__init__.py index e69de29b..b3fbc75c 100644 --- a/phono3py/sscha/__init__.py +++ b/phono3py/sscha/__init__.py @@ -0,0 +1 @@ +"""Routines for SSCHA.""" diff --git a/phono3py/sscha/sscha.py b/phono3py/sscha/sscha.py index 9a440200..dfdae2bc 100644 --- a/phono3py/sscha/sscha.py +++ b/phono3py/sscha/sscha.py @@ -32,7 +32,7 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -"""SSCHA calculation +"""SSCHA calculation. Formulae implemented are based on these papers: @@ -47,8 +47,8 @@ from phonopy.harmonic.dynmat_to_fc import DynmatToForceConstants from phono3py.phonon.func import mode_length -class SupercellPhonon(object): - """Supercell phonon class +class SupercellPhonon: + """Supercell phonon class. Dynamical matrix is created for supercell atoms and solved in real. All phonons at commensurate points are folded to those at Gamma point. @@ -75,11 +75,8 @@ class SupercellPhonon(object): """ - def __init__(self, - supercell, - force_constants, - frequency_factor_to_THz=VaspToTHz): - """ + def __init__(self, supercell, force_constants, frequency_factor_to_THz=VaspToTHz): + """Init method. Parameters ---------- @@ -92,47 +89,53 @@ class SupercellPhonon(object): Frequency conversion factor to THz. """ - self._supercell = supercell N = len(supercell) - _fc2 = np.array(np.transpose(force_constants, axes=[0, 2, 1, 3]), - dtype='double', order='C') + _fc2 = np.array( + np.transpose(force_constants, axes=[0, 2, 1, 3]), dtype="double", order="C" + ) _fc2 = _fc2.reshape((3 * N, 3 * N)) - _fc2 = np.array(_fc2, dtype='double', order='C') + _fc2 = np.array(_fc2, dtype="double", order="C") inv_sqrt_masses = 1.0 / np.repeat(np.sqrt(supercell.masses), 3) - dynmat = np.array(inv_sqrt_masses * (inv_sqrt_masses * _fc2).T, - dtype='double', order='C') + dynmat = np.array( + inv_sqrt_masses * (inv_sqrt_masses * _fc2).T, dtype="double", order="C" + ) eigvals, eigvecs = np.linalg.eigh(dynmat) freqs = np.sqrt(np.abs(eigvals)) * np.sign(eigvals) freqs *= frequency_factor_to_THz - self._eigenvalues = np.array(eigvals, dtype='double', order='C') - self._eigenvectors = np.array(eigvecs, dtype='double', order='C') - self._frequencies = np.array(freqs, dtype='double', order='C') + self._eigenvalues = np.array(eigvals, dtype="double", order="C") + self._eigenvectors = np.array(eigvecs, dtype="double", order="C") + self._frequencies = np.array(freqs, dtype="double", order="C") self._force_constants = _fc2 @property def eigenvalues(self): + """Return eigenvalues.""" return self._eigenvalues @property def eigenvectors(self): + """Return eigenvectors.""" return self._eigenvectors @property def frequencies(self): + """Return frequencies.""" return self._frequencies @property def force_constants(self): + """Return harmonic force cosntants.""" return self._force_constants @property def supercell(self): + """Return supercell.""" return self._supercell -class DispCorrMatrix(object): - """Calculate displacement correlation matrix +class DispCorrMatrix: + """Calculate displacement correlation matrix from supercell phonon. Attributes ---------- @@ -150,10 +153,8 @@ class DispCorrMatrix(object): """ - def __init__(self, - supercell_phonon, - cutoff_frequency=1e-5): - """ + def __init__(self, supercell_phonon, cutoff_frequency=1e-5): + """Init method. Parameters ---------- @@ -164,7 +165,6 @@ class DispCorrMatrix(object): Phonons are ignored if they have frequencies less than this value. """ - self._supercell_phonon = supercell_phonon self._cutoff_frequency = cutoff_frequency self._psi_matrix = None @@ -172,12 +172,13 @@ class DispCorrMatrix(object): self._determinant = None def run(self, T): + """Calculate displacement correlation matrix from supercell phonon.""" freqs = self._supercell_phonon.frequencies eigvecs = self._supercell_phonon.eigenvectors - sqrt_masses = np.repeat( - np.sqrt(self._supercell_phonon.supercell.masses), 3) + sqrt_masses = np.repeat(np.sqrt(self._supercell_phonon.supercell.masses), 3) inv_sqrt_masses = np.repeat( - 1.0 / np.sqrt(self._supercell_phonon.supercell.masses), 3) + 1.0 / np.sqrt(self._supercell_phonon.supercell.masses), 3 + ) # ignore zero and imaginary frequency modes condition = freqs > self._cutoff_frequency @@ -188,35 +189,39 @@ class DispCorrMatrix(object): matrix = np.dot(a2 * eigvecs, eigvecs.T) self._psi_matrix = np.array( - inv_sqrt_masses * (inv_sqrt_masses * matrix).T, - dtype='double', order='C') + inv_sqrt_masses * (inv_sqrt_masses * matrix).T, dtype="double", order="C" + ) matrix = np.dot(a2_inv * eigvecs, eigvecs.T) self._upsilon_matrix = np.array( - sqrt_masses * (sqrt_masses * matrix).T, - dtype='double', order='C') + sqrt_masses * (sqrt_masses * matrix).T, dtype="double", order="C" + ) self._determinant = np.prod(2 * np.pi * np.extract(condition, a2)) @property def upsilon_matrix(self): + """Return Upsilon matrix.""" return self._upsilon_matrix @property def psi_matrix(self): + """Return Psi matrix.""" return self._psi_matrix @property def supercell_phonon(self): + """Return SupercellPhonon class instance.""" return self._supercell_phonon @property def determinant(self): + """Return determinant.""" return self._determinant -class DispCorrMatrixMesh(object): - """Calculate upsilon and psi matrix +class DispCorrMatrixMesh: + """Calculate upsilon and psi matrix from normal phonon. This calculation is similar to the transformation from dynamical matrices to force constants. Instead of creating @@ -238,12 +243,9 @@ class DispCorrMatrixMesh(object): """ - def __init__(self, - primitive, - supercell, - cutoff_frequency=1e-5): - self._d2f = DynmatToForceConstants( - primitive, supercell, is_full_fc=True) + def __init__(self, primitive, supercell, cutoff_frequency=1e-5): + """Init method.""" + self._d2f = DynmatToForceConstants(primitive, supercell, is_full_fc=True) self._masses = supercell.masses self._cutoff_frequency = cutoff_frequency @@ -252,10 +254,11 @@ class DispCorrMatrixMesh(object): @property def commensurate_points(self): + """Return commensurate points.""" return self._d2f.commensurate_points def run(self, frequencies, eigenvectors, T): - """ + """Calculate displacement correlation matrix from normal phonon results. Parameters ---------- @@ -280,7 +283,7 @@ class DispCorrMatrixMesh(object): self._d2f.run() matrix = self._d2f.force_constants matrix = np.transpose(matrix, axes=[0, 2, 1, 3]).reshape(shape) - self._upsilon_matrix = np.array(matrix, dtype='double', order='C') + self._upsilon_matrix = np.array(matrix, dtype="double", order="C") self._d2f.create_dynamical_matrices(a2, eigenvectors) self._d2f.run() @@ -289,19 +292,21 @@ class DispCorrMatrixMesh(object): for j, m_j in enumerate(self._masses): matrix[i, j] /= m_i * m_j matrix = np.transpose(matrix, axes=[0, 2, 1, 3]).reshape(shape) - self._psi_matrix = np.array(matrix, dtype='double', order='C') + self._psi_matrix = np.array(matrix, dtype="double", order="C") @property def upsilon_matrix(self): + """Return Upsilon matrix.""" return self._upsilon_matrix @property def psi_matrix(self): + """Return Psi matrix.""" return self._psi_matrix class SecondOrderFC(object): - r"""SSCHA second order force constants by ensemble average + r"""SSCHA second order force constants by ensemble average. This class is made just for the test of the ensemble average in Ref. 1, and will not be used for usual fc2 calculation. @@ -320,13 +325,15 @@ class SecondOrderFC(object): """ - def __init__(self, - displacements, - forces, - supercell_phonon, - cutoff_frequency=1e-5, - log_level=0): - """ + def __init__( + self, + displacements, + forces, + supercell_phonon, + cutoff_frequency=1e-5, + log_level=0, + ): + """Init method. Parameters ---------- @@ -342,34 +349,34 @@ class SecondOrderFC(object): """ - assert (displacements.shape == forces.shape) + assert displacements.shape == forces.shape shape = displacements.shape - u = np.array(displacements.reshape(shape[0], -1), - dtype='double', order='C') - f = np.array(forces.reshape(shape[0], -1), - dtype='double', order='C') + u = np.array(displacements.reshape(shape[0], -1), dtype="double", order="C") + f = np.array(forces.reshape(shape[0], -1), dtype="double", order="C") self._displacements = u self._forces = f - self._uu = DispCorrMatrix( - supercell_phonon, cutoff_frequency=cutoff_frequency) + self._uu = DispCorrMatrix(supercell_phonon, cutoff_frequency=cutoff_frequency) self._force_constants = supercell_phonon.force_constants self._cutoff_frequency = cutoff_frequency self._log_level = log_level @property def displacements(self): + """Return input displacements.""" return self._displacements @property def forces(self): + """Return input forces.""" return self._forces @property def fc2(self): + """Return fc2 calculated stochastically.""" return self._fc2 def run(self, T=300.0): - """Calculate fc2 stochastically + """Calculate fc2 stochastically. As displacement correlation matrix ^-1, two choices exist. @@ -385,7 +392,6 @@ class SecondOrderFC(object): condition. """ - u = self._displacements f = self._forces Y = np.linalg.pinv(np.dot(u.T, u) / u.shape[0]) @@ -401,15 +407,17 @@ class SecondOrderFC(object): # print("drift forces:", # self._forces.sum(axis=0) / self._forces.shape[0]) - fc2 = - np.dot(u_inv.T, f) / f.shape[0] + fc2 = -np.dot(u_inv.T, f) / f.shape[0] N = Y.shape[0] // 3 self._fc2 = np.array( np.transpose(fc2.reshape(N, 3, N, 3), axes=[0, 2, 1, 3]), - dtype='double', order='C') + dtype="double", + order="C", + ) class ThirdOrderFC(object): - r"""SSCHA third order force constants + r"""SSCHA third order force constants. Eq. 45a in Ref.1 (See top docstring of this file) @@ -431,13 +439,15 @@ class ThirdOrderFC(object): """ - def __init__(self, - displacements, - forces, - supercell_phonon, - cutoff_frequency=1e-5, - log_level=0): - """ + def __init__( + self, + displacements, + forces, + supercell_phonon, + cutoff_frequency=1e-5, + log_level=0, + ): + """Init method. Parameters ---------- @@ -451,17 +461,13 @@ class ThirdOrderFC(object): Phonons are ignored if they have frequencies less than this value. """ - - assert (displacements.shape == forces.shape) + assert displacements.shape == forces.shape shape = displacements.shape - u = np.array(displacements.reshape(shape[0], -1), - dtype='double', order='C') - f = np.array(forces.reshape(shape[0], -1), - dtype='double', order='C') + u = np.array(displacements.reshape(shape[0], -1), dtype="double", order="C") + f = np.array(forces.reshape(shape[0], -1), dtype="double", order="C") self._displacements = u self._forces = f - self._uu = DispCorrMatrix( - supercell_phonon, cutoff_frequency=cutoff_frequency) + self._uu = DispCorrMatrix(supercell_phonon, cutoff_frequency=cutoff_frequency) self._force_constants = supercell_phonon.force_constants self._cutoff_frequency = cutoff_frequency self._log_level = log_level @@ -472,21 +478,26 @@ class ThirdOrderFC(object): @property def displacements(self): + """Return input displacements.""" return self._displacements @property def forces(self): + """Return input forces""" return self._forces @property def fc3(self): + """Return fc3 calculated stochastically.""" return self._fc3 @property def ff(self): + """Return force matrix.""" return self._fmat def run(self, T=300.0): + """Calculate fc3 stochastically.""" if self._fmat is None: self._fmat = self._run_fmat() @@ -494,8 +505,8 @@ class ThirdOrderFC(object): N = fc3.shape[0] // 3 fc3 = fc3.reshape((N, 3, N, 3, N, 3)) self._fc3 = np.array( - np.transpose(fc3, axes=[0, 2, 4, 1, 3, 5]), - dtype='double', order='C') + np.transpose(fc3, axes=[0, 2, 4, 1, 3, 5]), dtype="double", order="C" + ) def _run_fmat(self): f = self._forces @@ -521,4 +532,4 @@ class ThirdOrderFC(object): print("rms forces:", np.sqrt((self._forces ** 2).sum() / N)) print("rms f:", np.sqrt((f ** 2).sum() / N)) - return - np.einsum('li,lj,lk->ijk', u_inv, u_inv, f) / f.shape[0] + return -np.einsum("li,lj,lk->ijk", u_inv, u_inv, f) / f.shape[0] diff --git a/pyproject.toml b/pyproject.toml index 8b88f611..55cd9ace 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,9 @@ [build-system] requires = ["setuptools", "wheel", "numpy"] + +[tool.flake8] +max-line-length = 88 +extend-ignore = "E203,W503" + +[tool.black] +line-length = 88 diff --git a/scripts/phono3py b/scripts/phono3py index 7b7801ba..dda1d230 100755 --- a/scripts/phono3py +++ b/scripts/phono3py @@ -36,8 +36,10 @@ from phono3py.cui.phono3py_script import main -if __name__ == '__main__': - argparse_control = {'fc_symmetry': False, - 'is_nac': False, - 'load_phono3py_yaml': False} +if __name__ == "__main__": + argparse_control = { + "fc_symmetry": False, + "is_nac": False, + "load_phono3py_yaml": False, + } main(**argparse_control) diff --git a/scripts/phono3py-coleigplot b/scripts/phono3py-coleigplot index 92e17949..7d9929a1 100755 --- a/scripts/phono3py-coleigplot +++ b/scripts/phono3py-coleigplot @@ -11,12 +11,15 @@ epsilon = 1.0e-8 def get_options(): # Arg-parser - parser = argparse.ArgumentParser( - description="Plot collision matrix eigenvalues") + parser = argparse.ArgumentParser(description="Plot collision matrix eigenvalues") parser.add_argument( - '--temperature', type=float, default=300.0, dest='temperature', - help='Temperature to output data at') - parser.add_argument('filenames', nargs='*') + "--temperature", + type=float, + default=300.0, + dest="temperature", + help="Temperature to output data at", + ) + parser.add_argument("filenames", nargs="*") args = parser.parse_args() return args @@ -24,9 +27,9 @@ def get_options(): def main(args): filename = args.filenames[0] if os.path.isfile(filename): - with h5py.File(filename, 'r') as f: - coleigs = f['collision_eigenvalues'][:] - temperatures = f['temperature'][:] + with h5py.File(filename, "r") as f: + coleigs = f["collision_eigenvalues"][:] + temperatures = f["temperature"][:] else: print("File %s doens't exist." % filename) sys.exit(1) @@ -34,10 +37,10 @@ def main(args): import matplotlib.pyplot as plt fig, ax = plt.subplots() - ax.xaxis.set_ticks_position('bottom') - ax.yaxis.set_ticks_position('left') - ax.xaxis.set_tick_params(which='both', direction='in') - ax.yaxis.set_tick_params(which='both', direction='in') + ax.xaxis.set_ticks_position("bottom") + ax.yaxis.set_ticks_position("left") + ax.xaxis.set_tick_params(which="both", direction="in") + ax.yaxis.set_tick_params(which="both", direction="in") if len(temperatures) > 29: t_index = 30 @@ -53,8 +56,8 @@ def main(args): coleigs_p[coleigs_p < 0] = np.nan coleigs_n[coleigs_n >= 0] = np.nan - ax.semilogy(coleigs_p, 'b.', markersize=1) - ax.semilogy(-coleigs_n, 'r.', markersize=1) + ax.semilogy(coleigs_p, "b.", markersize=1) + ax.semilogy(-coleigs_n, "r.", markersize=1) ax.set_xlim(0, len(coleigs_p)) plt.show() diff --git a/scripts/phono3py-kaccum b/scripts/phono3py-kaccum index 477ffe67..0cfa3211 100755 --- a/scripts/phono3py-kaccum +++ b/scripts/phono3py-kaccum @@ -36,5 +36,5 @@ from phono3py.cui.kaccum import main -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/scripts/phono3py-kdeplot b/scripts/phono3py-kdeplot index 98edf3c3..7df30629 100755 --- a/scripts/phono3py-kdeplot +++ b/scripts/phono3py-kdeplot @@ -9,10 +9,10 @@ import argparse epsilon = 1.0e-8 + def collect_data(gamma, weights, frequencies, cutoff, max_freq): freqs = [] mode_prop = [] - mode_weights = [] for w, freq, g in zip(weights, frequencies, gamma): tau = 1.0 / np.where(g > 0, g, -1) / (2 * 2 * np.pi) @@ -35,9 +35,9 @@ def collect_data(gamma, weights, frequencies, cutoff, max_freq): return x, y + def run_KDE(x, y, nbins, x_max=None, y_max=None, density_ratio=0.1): - """Running Gaussian-KDE by scipy - """ + """Running Gaussian-KDE by scipy""" x_min = 0 if x_max is None: @@ -52,7 +52,7 @@ def run_KDE(x, y, nbins, x_max=None, y_max=None, density_ratio=0.1): values = np.vstack([x.ravel(), y.ravel()]) kernel = stats.gaussian_kde(values) - xi, yi = np.mgrid[x_min:_x_max:nbins*1j, y_min:_y_max:nbins*1j] + xi, yi = np.mgrid[x_min : _x_max : nbins * 1j, y_min : _y_max : nbins * 1j] positions = np.vstack([xi.ravel(), yi.ravel()]) zi = np.reshape(kernel(positions).T, xi.shape) @@ -67,7 +67,7 @@ def run_KDE(x, y, nbins, x_max=None, y_max=None, density_ratio=0.1): short_nbinds = len(indices) ynbins = nbins ** 2 // short_nbinds - xi, yi = np.mgrid[x_min:_x_max:nbins*1j, y_min:_y_max:ynbins*1j] + xi, yi = np.mgrid[x_min : _x_max : nbins * 1j, y_min : _y_max : ynbins * 1j] positions = np.vstack([xi.ravel(), yi.ravel()]) zi = np.reshape(kernel(positions).T, xi.shape) else: @@ -75,52 +75,67 @@ def run_KDE(x, y, nbins, x_max=None, y_max=None, density_ratio=0.1): return xi, yi, zi, short_nbinds -def plot(plt, xi, yi, zi, x, y, short_nbinds, nbins, - y_max=None, z_max=None, cmap=None, aspect=None, - flip=False, no_points=False, show_colorbar=True, - point_size=5, title=None): + +def plot( + plt, + xi, + yi, + zi, + x, + y, + short_nbinds, + nbins, + y_max=None, + z_max=None, + cmap=None, + aspect=None, + flip=False, + no_points=False, + show_colorbar=True, + point_size=5, + title=None, +): xmax = np.max(x) ymax = np.max(y) x_cut = [] y_cut = [] threshold = ymax / nbins * short_nbinds / nbins * (nbins - 1) for _x, _y in zip(x, y): - if (epsilon < _y and _y < threshold and - epsilon < _x and _x < xmax - epsilon): + if epsilon < _y and _y < threshold and epsilon < _x and _x < xmax - epsilon: x_cut.append(_x) y_cut.append(_y) fig, ax = plt.subplots() - ax.xaxis.set_ticks_position('bottom') - ax.yaxis.set_ticks_position('left') - ax.xaxis.set_tick_params(which='both', direction='out') - ax.yaxis.set_tick_params(which='both', direction='out') + ax.xaxis.set_ticks_position("bottom") + ax.yaxis.set_ticks_position("left") + ax.xaxis.set_tick_params(which="both", direction="out") + ax.yaxis.set_tick_params(which="both", direction="out") if flip: # Start Flip - plt.pcolormesh(yi[:,:nbins], xi[:,:nbins], zi[:,:nbins], - vmax=z_max, cmap=cmap) + plt.pcolormesh( + yi[:, :nbins], xi[:, :nbins], zi[:, :nbins], vmax=z_max, cmap=cmap + ) if show_colorbar: plt.colorbar() if not no_points: - plt.scatter(y_cut, x_cut, s=point_size, - c='k', marker='.', linewidth=0) + plt.scatter(y_cut, x_cut, s=point_size, c="k", marker=".", linewidth=0) plt.ylim(ymin=0, ymax=xi.max()) if y_max is None: plt.xlim(xmin=0, xmax=(np.max(y_cut) + epsilon)) else: plt.xlim(xmin=0, xmax=(y_max + epsilon)) - plt.xlabel('Lifetime (ps)', fontsize=18) - plt.ylabel('Phonon frequency (THz)', fontsize=18) + plt.xlabel("Lifetime (ps)", fontsize=18) + plt.ylabel("Phonon frequency (THz)", fontsize=18) # End Flip else: - plt.pcolormesh(xi[:,:nbins], yi[:,:nbins], zi[:,:nbins], - vmax=z_max, cmap=cmap) + plt.pcolormesh( + xi[:, :nbins], yi[:, :nbins], zi[:, :nbins], vmax=z_max, cmap=cmap + ) if show_colorbar: plt.colorbar() if not no_points: - plt.scatter(x_cut, y_cut, s=point_size, - c='k', marker='.', linewidth=0) + plt.scatter(x_cut, y_cut, s=point_size, c="k", marker=".", linewidth=0) plt.xlim(xmin=0, xmax=xi.max()) if y_max is None: plt.ylim(ymin=0, ymax=(np.max(y_cut) + epsilon)) @@ -128,8 +143,8 @@ def plot(plt, xi, yi, zi, x, y, short_nbinds, nbins, plt.ylim(ymin=0, ymax=(y_max + epsilon)) if title: plt.title(title, fontsize=20) - plt.xlabel('Phonon frequency (THz)', fontsize=18) - plt.ylabel('Lifetime (ps)', fontsize=18) + plt.xlabel("Phonon frequency (THz)", fontsize=18) + plt.ylabel("Lifetime (ps)", fontsize=18) if aspect is not None: xlim = ax.get_xlim() @@ -142,88 +157,115 @@ def plot(plt, xi, yi, zi, x, y, short_nbinds, nbins, return fig + def get_options(): # Arg-parser parser = argparse.ArgumentParser( - description="Plot property density with gaussian KDE") + description="Plot property density with gaussian KDE" + ) parser.add_argument( - "--aspect", type=float, default=None, - help="The ration, height/width of canvas") + "--aspect", type=float, default=None, help="The ration, height/width of canvas" + ) + parser.add_argument("--cmap", dest="cmap", default=None, help="Matplotlib cmap") parser.add_argument( - "--cmap", dest="cmap", default=None, - help="Matplotlib cmap") + "--cutoff", + type=float, + default=None, + help=( + "Property (y-axis) below this value is included in " + "data before running Gaussian-KDE" + ), + ) parser.add_argument( - "--cutoff", type=float, default=None, - help=("Property (y-axis) below this value is included in " - "data before running Gaussian-KDE")) - parser.add_argument( - "--dr", "--density-ratio", dest="density_ratio", type=float, + "--dr", + "--density-ratio", + dest="density_ratio", + type=float, default=0.1, - help=("Minimum density ratio with respect to maximum " - "density used to determine drawing region")) + help=( + "Minimum density ratio with respect to maximum " + "density used to determine drawing region" + ), + ) + parser.add_argument("--flip", action="store_true", help="Flip x and y.") parser.add_argument( - "--flip", action='store_true', - help='Flip x and y.') + "--fmax", type=float, default=None, help="Max frequency to plot" + ) parser.add_argument( - "--fmax", type=float, default=None, - help="Max frequency to plot") + "--hc", + "--hide-colorbar", + dest="hide_colorbar", + action="store_true", + help="Do not show colorbar", + ) parser.add_argument( - "--hc", "--hide-colorbar", dest="hide_colorbar", action='store_true', - help='Do not show colorbar') + "--nbins", + type=int, + default=100, + help=( + "Number of bins in which data are assigned, " + "i.e., determining resolution of plot" + ), + ), parser.add_argument( - "--nbins", type=int, default=100, - help=("Number of bins in which data are assigned, " - "i.e., determining resolution of plot")), + "--no-points", dest="no_points", action="store_true", help="Do not show points" + ) + parser.add_argument("--nu", action="store_true", help="Plot N and U.") parser.add_argument( - "--no-points", dest="no_points", action='store_true', - help='Do not show points') + "-o", + "--output", + dest="output_filename", + default=None, + help="Output filename, e.g., to PDF", + ) parser.add_argument( - "--nu", action='store_true', - help="Plot N and U.") + "--point-size", + dest="point_size", + type=float, + default=5, + help="Point size (default=5)", + ) parser.add_argument( - "-o", "--output", dest="output_filename", default=None, - help="Output filename, e.g., to PDF") + "--temperature", + type=float, + default=300.0, + dest="temperature", + help="Temperature to output data at", + ) + parser.add_argument("--title", dest="title", default=None, help="Plot title") parser.add_argument( - '--point-size', dest="point_size", type=float, default=5, - help='Point size (default=5)') + "--xmax", type=float, default=None, help="Set maximum x of draw area" + ) parser.add_argument( - '--temperature', type=float, default=300.0, dest='temperature', - help='Temperature to output data at') - parser.add_argument( - "--title", dest="title", default=None, - help="Plot title") - parser.add_argument( - "--xmax", type=float, default=None, - help="Set maximum x of draw area") - parser.add_argument( - "--ymax", type=float, default=None, - help="Set maximum y of draw area") - parser.add_argument( - "--zmax", type=float, default=None, - help="Set maximum indisity") - parser.add_argument('filenames', nargs='*') + "--ymax", type=float, default=None, help="Set maximum y of draw area" + ) + parser.add_argument("--zmax", type=float, default=None, help="Set maximum indisity") + parser.add_argument("filenames", nargs="*") args = parser.parse_args() return args + def main(args): # # Matplotlib setting # import matplotlib - matplotlib.use('Agg') + + matplotlib.use("Agg") import matplotlib.pyplot as plt from matplotlib import rc - rc('text', usetex=True) - rc('font', family='serif') + + rc("text", usetex=True) + rc("font", family="serif") # rc('font', serif='Times New Roman') - rc('font', serif='Liberation Serif') + rc("font", serif="Liberation Serif") # plt.rcParams['pdf.fonttype'] = 42 # # Initial setting # if os.path.isfile(args.filenames[0]): - f = h5py.File(args.filenames[0], 'r') + f = h5py.File(args.filenames[0], "r") else: print("File %s doens't exist." % args.filenames[0]) sys.exit(1) @@ -236,7 +278,7 @@ def main(args): # # Set temperature # - temperatures = f['temperature'][:] + temperatures = f["temperature"][:] if len(temperatures) > 29: t_index = 30 else: @@ -246,40 +288,62 @@ def main(args): t_index = i break - print("Temperature at which lifetime density is drawn: %7.3f" - % temperatures[t_index]) + print( + "Temperature at which lifetime density is drawn: %7.3f" % temperatures[t_index] + ) # # Set data # - weights = f['weight'][:] - frequencies = f['frequency'][:] - symbols = ['',] + weights = f["weight"][:] + frequencies = f["frequency"][:] + symbols = [ + "", + ] - gammas = [f['gamma'][t_index],] + gammas = [ + f["gamma"][t_index], + ] if args.nu: - if 'gamma_N' in f: - gammas.append(f['gamma_N'][t_index]) - symbols.append('N') - if 'gamma_U' in f: - gammas.append(f['gamma_U'][t_index]) - symbols.append('U') + if "gamma_N" in f: + gammas.append(f["gamma_N"][t_index]) + symbols.append("N") + if "gamma_U" in f: + gammas.append(f["gamma_U"][t_index]) + symbols.append("U") # # Run # for gamma, s in zip(gammas, symbols): x, y = collect_data(gamma, weights, frequencies, args.cutoff, args.fmax) - xi, yi, zi, short_nbinds = run_KDE(x, y, args.nbins, - x_max=args.xmax, - y_max=args.ymax, - density_ratio=args.density_ratio) - fig = plot(plt, xi, yi, zi, x, y, short_nbinds, args.nbins, - y_max=args.ymax, z_max=args.zmax, cmap=args.cmap, - aspect=args.aspect, flip=args.flip, - no_points=args.no_points, - show_colorbar=(not args.hide_colorbar), - point_size=args.point_size, title=title) + xi, yi, zi, short_nbinds = run_KDE( + x, + y, + args.nbins, + x_max=args.xmax, + y_max=args.ymax, + density_ratio=args.density_ratio, + ) + fig = plot( + plt, + xi, + yi, + zi, + x, + y, + short_nbinds, + args.nbins, + y_max=args.ymax, + z_max=args.zmax, + cmap=args.cmap, + aspect=args.aspect, + flip=args.flip, + no_points=args.no_points, + show_colorbar=(not args.hide_colorbar), + point_size=args.point_size, + title=title, + ) if args.output_filename: fig.savefig(args.output_filename) @@ -290,5 +354,6 @@ def main(args): fig.savefig("lifetime.png") plt.close(fig) + if __name__ == "__main__": main(get_options()) diff --git a/scripts/phono3py-load b/scripts/phono3py-load index 4e362d28..9dc5a633 100755 --- a/scripts/phono3py-load +++ b/scripts/phono3py-load @@ -36,8 +36,6 @@ from phono3py.cui.phono3py_script import main -if __name__ == '__main__': - argparse_control = {'fc_symmetry': True, - 'is_nac': True, - 'load_phono3py_yaml': True} +if __name__ == "__main__": + argparse_control = {"fc_symmetry": True, "is_nac": True, "load_phono3py_yaml": True} main(**argparse_control) diff --git a/setup.py b/setup.py index d115bc74..3066e9de 100644 --- a/setup.py +++ b/setup.py @@ -7,10 +7,12 @@ import sysconfig try: from setuptools import setup, Extension + use_setuptools = True print("setuptools is used.") except ImportError: from distutils.core import setup, Extension + use_setuptools = False print("distutils is used.") @@ -19,10 +21,10 @@ try: except ImportError: git_num = None -if 'setuptools_scm' in sys.modules.keys(): +if "setuptools_scm" in sys.modules.keys(): try: git_ver = get_version() - git_num = int(git_ver.split('.')[3].split('+')[0].replace("dev", "")) + git_num = int(git_ver.split(".")[3].split("+")[0].replace("dev", "")) except Exception: git_num = None @@ -30,19 +32,27 @@ include_dirs_numpy = [numpy.get_include()] extra_link_args = [] # Workaround Python issue 21121 config_var = sysconfig.get_config_var("CFLAGS") -if (config_var is not None and - "-Werror=declaration-after-statement" in config_var): # noqa E129 - os.environ['CFLAGS'] = config_var.replace( - "-Werror=declaration-after-statement", "") +if ( + config_var is not None and "-Werror=declaration-after-statement" in config_var +): # noqa E129 + os.environ["CFLAGS"] = config_var.replace("-Werror=declaration-after-statement", "") -extra_compile_args = ['-fopenmp', ] -include_dirs = ['c', ] + include_dirs_numpy +extra_compile_args = [ + "-fopenmp", +] +include_dirs = [ + "c", +] + include_dirs_numpy define_macros = [] if use_setuptools: - extra_compile_args += ['-DPHPYOPENMP', ] + extra_compile_args += [ + "-DPHPYOPENMP", + ] else: - define_macros += [('PHPYOPENMP', None), ] + define_macros += [ + ("PHPYOPENMP", None), + ] use_mkl = False @@ -94,11 +104,9 @@ if os.path.isfile("setup_mkl.py"): include_dirs_lapacke = mkl_include_dirs_lapacke if use_setuptools: - extra_compile_args += ['-DMKL_LAPACKE', - '-DMULTITHREADED_BLAS'] + extra_compile_args += ["-DMKL_LAPACKE", "-DMULTITHREADED_BLAS"] else: - define_macros += [('MKL_LAPACKE', None), - ('MULTITHREADED_BLAS', None)] + define_macros += [("MKL_LAPACKE", None), ("MULTITHREADED_BLAS", None)] elif os.path.isfile("libopenblas.py"): # This supposes that multithread openBLAS is used. # This is invoked when libopenblas.py exists on the current directory. @@ -108,66 +116,72 @@ elif os.path.isfile("libopenblas.py"): from libopenblas import ( extra_link_args_lapacke as obl_extra_link_args_lapacke, - include_dirs_lapacke as obl_include_dirs_lapacke) + include_dirs_lapacke as obl_include_dirs_lapacke, + ) + extra_link_args_lapacke = obl_extra_link_args_lapacke include_dirs_lapacke = obl_include_dirs_lapacke if use_setuptools: - extra_compile_args += ['-DMULTITHREADED_BLAS'] + extra_compile_args += ["-DMULTITHREADED_BLAS"] else: - define_macros += [('MULTITHREADED_BLAS', None)] -elif (platform.system() == 'Darwin' and - os.path.isfile('/opt/local/lib/libopenblas.a')): + define_macros += [("MULTITHREADED_BLAS", None)] +elif platform.system() == "Darwin" and os.path.isfile("/opt/local/lib/libopenblas.a"): # This supposes lapacke with single-thread openBLAS provided by MacPort is # used. # % sudo port install gcc6 # % sudo port select --set gcc mp-gcc # % sudo port install OpenBLAS +gcc6 - extra_link_args_lapacke = ['/opt/local/lib/libopenblas.a'] - include_dirs_lapacke = ['/opt/local/include'] -elif ('CONDA_PREFIX' in os.environ and - (os.path.isfile(os.path.join(os.environ['CONDA_PREFIX'], - 'lib', 'liblapacke.dylib')) or - os.path.isfile(os.path.join(os.environ['CONDA_PREFIX'], - 'lib', 'liblapacke.so')))): + extra_link_args_lapacke = ["/opt/local/lib/libopenblas.a"] + include_dirs_lapacke = ["/opt/local/include"] +elif "CONDA_PREFIX" in os.environ and ( + os.path.isfile(os.path.join(os.environ["CONDA_PREFIX"], "lib", "liblapacke.dylib")) + or os.path.isfile(os.path.join(os.environ["CONDA_PREFIX"], "lib", "liblapacke.so")) +): # This is for the system prepared with conda openblas. - extra_link_args_lapacke = ['-llapacke'] + extra_link_args_lapacke = ["-llapacke"] include_dirs_lapacke = [ - os.path.join(os.environ['CONDA_PREFIX'], 'include'), ] - if os.path.isfile(os.path.join(os.environ['CONDA_PREFIX'], - 'include', 'mkl.h')): + os.path.join(os.environ["CONDA_PREFIX"], "include"), + ] + if os.path.isfile(os.path.join(os.environ["CONDA_PREFIX"], "include", "mkl.h")): use_mkl = True if use_setuptools: - extra_compile_args += ['-DMKL_LAPACKE', - '-DMULTITHREADED_BLAS'] + extra_compile_args += ["-DMKL_LAPACKE", "-DMULTITHREADED_BLAS"] else: - define_macros += [('MKL_LAPACKE', None), - ('MULTITHREADED_BLAS', None)] + define_macros += [("MKL_LAPACKE", None), ("MULTITHREADED_BLAS", None)] else: if use_setuptools: - extra_compile_args += ['-DMULTITHREADED_BLAS'] + extra_compile_args += ["-DMULTITHREADED_BLAS"] else: - define_macros += [('MULTITHREADED_BLAS', None)] -elif ('CONDA_PREFIX' in os.environ and - (os.path.isfile(os.path.join(os.environ['CONDA_PREFIX'], - 'lib', 'libmkl_rt.dylib')) or - os.path.isfile(os.path.join(os.environ['CONDA_PREFIX'], - 'lib', 'libmkl_rt.so'))) and - (os.path.isfile(os.path.join(os.environ['CONDA_PREFIX'], - 'include', 'mkl_lapacke.h')))): + define_macros += [("MULTITHREADED_BLAS", None)] +elif ( + "CONDA_PREFIX" in os.environ + and ( + os.path.isfile( + os.path.join(os.environ["CONDA_PREFIX"], "lib", "libmkl_rt.dylib") + ) + or os.path.isfile( + os.path.join(os.environ["CONDA_PREFIX"], "lib", "libmkl_rt.so") + ) + ) + and ( + os.path.isfile( + os.path.join(os.environ["CONDA_PREFIX"], "include", "mkl_lapacke.h") + ) + ) +): include_dirs_lapacke = [ - os.path.join(os.environ['CONDA_PREFIX'], 'include'), ] - extra_link_args_lapacke = ['-lmkl_rt'] + os.path.join(os.environ["CONDA_PREFIX"], "include"), + ] + extra_link_args_lapacke = ["-lmkl_rt"] if use_setuptools: - extra_compile_args += ['-DMKL_LAPACKE', - '-DMULTITHREADED_BLAS'] + extra_compile_args += ["-DMKL_LAPACKE", "-DMULTITHREADED_BLAS"] else: - define_macros += [('MKL_LAPACKE', None), - ('MULTITHREADED_BLAS', None)] -elif os.path.isfile('/usr/lib/liblapacke.so'): + define_macros += [("MKL_LAPACKE", None), ("MULTITHREADED_BLAS", None)] +elif os.path.isfile("/usr/lib/liblapacke.so"): # This supposes that lapacke with single-thread BLAS is installed on # system. - extra_link_args_lapacke = ['-llapacke', '-llapack', '-lblas'] + extra_link_args_lapacke = ["-llapacke", "-llapack", "-lblas"] include_dirs_lapacke = [] else: # Here is the default lapacke linkage setting. @@ -183,41 +197,51 @@ else: # # For conda: Try installing with dynamic link library of openblas by # % conda install numpy scipy h5py pyyaml matplotlib openblas libgfortran - extra_link_args_lapacke = ['-lopenblas', '-lgfortran'] - if 'CONDA_PREFIX' in os.environ: + extra_link_args_lapacke = ["-lopenblas", "-lgfortran"] + if "CONDA_PREFIX" in os.environ: include_dirs_lapacke = [ - os.path.join(os.environ['CONDA_PREFIX'], 'include'), ] + os.path.join(os.environ["CONDA_PREFIX"], "include"), + ] if use_setuptools: - extra_compile_args += ['-DMULTITHREADED_BLAS'] + extra_compile_args += ["-DMULTITHREADED_BLAS"] else: - define_macros += [('MULTITHREADED_BLAS', None)] + define_macros += [("MULTITHREADED_BLAS", None)] cc = None lib_omp = None -if 'CC' in os.environ: - if 'clang' in os.environ['CC']: - cc = 'clang' +if "CC" in os.environ: + if "clang" in os.environ["CC"]: + cc = "clang" if not use_mkl: - lib_omp = '-lomp' + lib_omp = "-lomp" # lib_omp = '-liomp5' - if 'gcc' in os.environ['CC'] or 'gnu-cc' in os.environ['CC']: - cc = 'gcc' -if cc == 'gcc' or cc is None: - lib_omp = '-lgomp' + if "gcc" in os.environ["CC"] or "gnu-cc" in os.environ["CC"]: + cc = "gcc" +if cc == "gcc" or cc is None: + lib_omp = "-lgomp" - if 'CC' in os.environ and 'gcc-' in os.environ['CC']: + if "CC" in os.environ and "gcc-" in os.environ["CC"]: # For macOS & homebrew gcc: # Using conda's gcc is more recommended though. Suppose using # homebrew gcc whereas conda is used as general environment. # This is to avoid linking conda libgomp that is incompatible # with homebrew gcc. try: - v = int(os.environ['CC'].split('-')[1]) + v = int(os.environ["CC"].split("-")[1]) except ValueError: pass else: - ary = [os.sep, "usr", "local", "opt", "gcc@%d" % v, "lib", "gcc", - "%d" % v, "libgomp.a"] + ary = [ + os.sep, + "usr", + "local", + "opt", + "gcc@%d" % v, + "lib", + "gcc", + "%d" % v, + "libgomp.a", + ] libgomp_a = os.path.join(*ary) if os.path.isfile(libgomp_a): lib_omp = libgomp_a @@ -232,87 +256,96 @@ extra_link_args += extra_link_args_lapacke include_dirs += include_dirs_lapacke print("extra_link_args", extra_link_args) -sources_phono3py = ['c/_phono3py.c', - 'c/bzgrid.c', - 'c/collision_matrix.c', - 'c/fc3.c', - 'c/grgrid.c', - 'c/imag_self_energy_with_g.c', - 'c/interaction.c', - 'c/isotope.c', - 'c/lagrid.c', - 'c/lapack_wrapper.c', - 'c/phono3py.c', - 'c/phonoc_utils.c', - 'c/pp_collision.c', - 'c/real_self_energy.c', - 'c/real_to_reciprocal.c', - 'c/reciprocal_to_normal.c', - 'c/snf3x3.c', - 'c/tetrahedron_method.c', - 'c/triplet.c', - 'c/triplet_grid.c', - 'c/triplet_iw.c'] +sources_phono3py = [ + "c/_phono3py.c", + "c/bzgrid.c", + "c/collision_matrix.c", + "c/fc3.c", + "c/grgrid.c", + "c/imag_self_energy_with_g.c", + "c/interaction.c", + "c/isotope.c", + "c/lagrid.c", + "c/lapack_wrapper.c", + "c/phono3py.c", + "c/phonoc_utils.c", + "c/pp_collision.c", + "c/real_self_energy.c", + "c/real_to_reciprocal.c", + "c/reciprocal_to_normal.c", + "c/snf3x3.c", + "c/tetrahedron_method.c", + "c/triplet.c", + "c/triplet_grid.c", + "c/triplet_iw.c", +] extension_phono3py = Extension( - 'phono3py._phono3py', + "phono3py._phono3py", include_dirs=include_dirs, extra_compile_args=extra_compile_args, extra_link_args=extra_link_args, define_macros=define_macros, - sources=sources_phono3py) + sources=sources_phono3py, +) -sources_phononmod = ['c/_phononmod.c', - 'c/dynmat.c', - 'c/lapack_wrapper.c', - 'c/phonon.c', - 'c/phononmod.c'] +sources_phononmod = [ + "c/_phononmod.c", + "c/dynmat.c", + "c/lapack_wrapper.c", + "c/phonon.c", + "c/phononmod.c", +] extension_phononmod = Extension( - 'phono3py._phononmod', + "phono3py._phononmod", include_dirs=include_dirs, extra_compile_args=extra_compile_args, extra_link_args=extra_link_args, - sources=sources_phononmod) + sources=sources_phononmod, +) -sources_lapackepy = ['c/_lapackepy.c', - 'c/lapack_wrapper.c'] +sources_lapackepy = ["c/_lapackepy.c", "c/lapack_wrapper.c"] extension_lapackepy = Extension( - 'phono3py._lapackepy', + "phono3py._lapackepy", extra_compile_args=extra_compile_args, extra_link_args=extra_link_args, include_dirs=include_dirs, - sources=sources_lapackepy) + sources=sources_lapackepy, +) -packages_phono3py = ['phono3py', - 'phono3py.cui', - 'phono3py.interface', - 'phono3py.other', - 'phono3py.phonon', - 'phono3py.phonon3', - 'phono3py.sscha'] -scripts_phono3py = ['scripts/phono3py', - 'scripts/phono3py-load', - 'scripts/phono3py-kaccum', - 'scripts/phono3py-kdeplot', - 'scripts/phono3py-coleigplot'] +packages_phono3py = [ + "phono3py", + "phono3py.cui", + "phono3py.interface", + "phono3py.other", + "phono3py.phonon", + "phono3py.phonon3", + "phono3py.sscha", +] +scripts_phono3py = [ + "scripts/phono3py", + "scripts/phono3py-load", + "scripts/phono3py-kaccum", + "scripts/phono3py-kdeplot", + "scripts/phono3py-coleigplot", +] ######################## # _lapackepy extension # ######################## -if __name__ == '__main__': +if __name__ == "__main__": version_nums = [None, None, None] with open("phono3py/version.py") as w: for line in w: if "__version__" in line: - for i, num in enumerate( - line.split()[2].strip('\"').split('.')): + for i, num in enumerate(line.split()[2].strip('"').split(".")): version_nums[i] = num break # To deploy to pypi by travis-CI if os.path.isfile("__nanoversion__.txt"): nanoversion = 0 - with open('__nanoversion__.txt') as nv: + with open("__nanoversion__.txt") as nv: try: for line in nv: nanoversion = int(line.strip()) @@ -333,33 +366,47 @@ if __name__ == '__main__': version += "-%d" % version_nums[3] if use_setuptools: - setup(name='phono3py', - version=version, - description='This is the phono3py module.', - author='Atsushi Togo', - author_email='atz.togo@gmail.com', - url='http://phonopy.github.io/phono3py/', - packages=packages_phono3py, - python_requires='>=3.5', - install_requires=['numpy', 'scipy', 'PyYAML', 'matplotlib', - 'h5py', 'spglib', 'phonopy>=2.11,<2.12'], - provides=['phono3py'], - scripts=scripts_phono3py, - ext_modules=[extension_phono3py, - extension_lapackepy, - extension_phononmod]) + setup( + name="phono3py", + version=version, + description="This is the phono3py module.", + author="Atsushi Togo", + author_email="atz.togo@gmail.com", + url="http://phonopy.github.io/phono3py/", + packages=packages_phono3py, + python_requires=">=3.5", + install_requires=[ + "numpy", + "scipy", + "PyYAML", + "matplotlib", + "h5py", + "spglib", + "phonopy>=2.11,<2.12", + ], + provides=["phono3py"], + scripts=scripts_phono3py, + ext_modules=[extension_phono3py, extension_lapackepy, extension_phononmod], + ) else: - setup(name='phono3py', - version=version, - description='This is the phono3py module.', - author='Atsushi Togo', - author_email='atz.togo@gmail.com', - url='http://phonopy.github.io/phono3py/', - packages=packages_phono3py, - requires=['numpy', 'scipy', 'PyYAML', 'matplotlib', 'h5py', - 'phonopy', 'spglib'], - provides=['phono3py'], - scripts=scripts_phono3py, - ext_modules=[extension_phono3py, - extension_lapackepy, - extension_phononmod]) + setup( + name="phono3py", + version=version, + description="This is the phono3py module.", + author="Atsushi Togo", + author_email="atz.togo@gmail.com", + url="http://phonopy.github.io/phono3py/", + packages=packages_phono3py, + requires=[ + "numpy", + "scipy", + "PyYAML", + "matplotlib", + "h5py", + "phonopy", + "spglib", + ], + provides=["phono3py"], + scripts=scripts_phono3py, + ext_modules=[extension_phono3py, extension_lapackepy, extension_phononmod], + ) diff --git a/test/FORCES_FC3_si_pbesol b/test/FORCES_FC3_si_pbesol index 9fe6ca7b..a6db2bb8 100644 --- a/test/FORCES_FC3_si_pbesol +++ b/test/FORCES_FC3_si_pbesol @@ -1,4 +1,4 @@ -# File: 1 +# File: 1 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3968201400 0.0000000000 0.0000000000 0.0005878300 0.0000000000 0.0000000000 @@ -64,7 +64,7 @@ -0.0003760000 0.0009874300 -0.0009874300 -0.0014775900 0.0009712500 -0.0011918000 0.0006882300 0.0007423100 -0.0007584100 -# File: 2 +# File: 2 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 1 0.0212132034355964 0.0212132034355964 0.0000000000000000 -0.6772678900 -0.2819277000 -0.0358889800 @@ -131,7 +131,7 @@ 0.0000464900 0.0006116300 -0.0025198500 -0.0018160900 0.0013707700 -0.0027515600 0.0017720700 0.0018204600 -0.0018547700 -# File: 3 +# File: 3 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 1 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 -0.1163652300 0.2806988700 0.0061513100 @@ -198,7 +198,7 @@ -0.0008199100 0.0013657300 0.0005330100 -0.0011352000 0.0005498300 0.0003556500 -0.0003131800 -0.0002539400 0.0002896400 -# File: 4 +# File: 4 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 2 0.0212132034355964 0.0212132034355964 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -265,7 +265,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 5 +# File: 5 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 2 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -332,7 +332,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 6 +# File: 6 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 3 0.0212132034355964 0.0212132034355964 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -399,7 +399,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 7 +# File: 7 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 3 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -466,7 +466,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 8 +# File: 8 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 3 0.0000000000000000 0.0000000000000000 0.0300000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -533,7 +533,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 9 +# File: 9 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 4 0.0212132034355964 0.0212132034355964 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -600,7 +600,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 10 +# File: 10 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 4 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -667,7 +667,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 11 +# File: 11 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 4 0.0000000000000000 0.0000000000000000 0.0300000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -734,7 +734,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 12 +# File: 12 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 7 0.0212132034355964 0.0212132034355964 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -801,7 +801,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 13 +# File: 13 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 7 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -868,7 +868,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 14 +# File: 14 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 8 0.0212132034355964 0.0212132034355964 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -935,7 +935,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 15 +# File: 15 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 8 -0.0212132034355964 -0.0212132034355964 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -1002,7 +1002,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 16 +# File: 16 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3939519800 0.0058183400 0.0055670600 @@ -1069,7 +1069,7 @@ -0.0011158200 0.0071295100 -0.0017236700 -0.0021824700 0.0016148900 -0.0018983100 -0.0000840200 0.0001823900 -0.0015351500 -# File: 17 +# File: 17 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3995693700 -0.0056732700 -0.0054537400 @@ -1136,7 +1136,7 @@ 0.0003523300 -0.0050800000 -0.0002632500 -0.0007213000 0.0002821600 -0.0004471400 0.0014498900 0.0013010900 0.0000075200 -# File: 18 +# File: 18 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 9 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4096762700 -0.0027672400 -0.0027672400 @@ -1203,7 +1203,7 @@ 0.0003150300 0.0002352300 -0.0002470100 0.0045852800 0.0002387800 -0.0004704200 0.0001221800 -0.0000216700 0.0000057500 -# File: 19 +# File: 19 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 9 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3840574800 0.0026527000 0.0026527000 @@ -1270,7 +1270,7 @@ -0.0010215900 0.0016873400 -0.0016892500 -0.0076171900 0.0017148000 -0.0019246100 0.0012551900 0.0015167100 -0.0015331800 -# File: 20 +# File: 20 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0000000000000000 0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -1337,7 +1337,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 21 +# File: 21 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0000000000000000 -0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -1404,7 +1404,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 22 +# File: 22 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 10 0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -1471,7 +1471,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 23 +# File: 23 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 10 -0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -1538,7 +1538,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 24 +# File: 24 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 11 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3942721300 0.0055232600 -0.0055693500 @@ -1605,7 +1605,7 @@ -0.0011499800 0.0004245700 -0.0017635200 -0.0026397000 -0.0005482000 -0.0022072200 -0.0000416200 0.0068803000 -0.0014963400 -# File: 25 +# File: 25 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 11 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3994511000 -0.0056719200 0.0056871700 @@ -1672,7 +1672,7 @@ 0.0003878200 0.0015493200 -0.0002221700 -0.0002819400 0.0024461600 -0.0002141500 0.0014056300 -0.0053204600 -0.0000317000 -# File: 26 +# File: 26 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 11 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4094040500 -0.0026590200 0.0026590200 @@ -1739,7 +1739,7 @@ -0.0009416200 0.0002241800 -0.0002241800 -0.0029449200 -0.0002196900 -0.0002196900 0.0013761300 -0.0000185400 -0.0000185400 -# File: 27 +# File: 27 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 11 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3841483200 0.0027636500 -0.0027636500 @@ -1806,7 +1806,7 @@ 0.0001909600 0.0017614800 -0.0017614800 0.0000339600 0.0021291800 -0.0022017700 0.0000443400 0.0014513300 -0.0014599500 -# File: 28 +# File: 28 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 12 0.0000000000000000 0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -1873,7 +1873,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 29 +# File: 29 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 12 0.0000000000000000 -0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -1940,7 +1940,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 30 +# File: 30 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 12 0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -2007,7 +2007,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 31 +# File: 31 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 12 -0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -2074,7 +2074,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 32 +# File: 32 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3912195600 0.0028279300 0.0054555400 @@ -2141,7 +2141,7 @@ 0.0002656400 0.0002862400 -0.0016890300 0.0046556100 0.0002316900 -0.0019368100 0.0001290900 -0.0000268600 -0.0015301000 -# File: 33 +# File: 33 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4022598900 -0.0027286100 -0.0053310000 @@ -2208,7 +2208,7 @@ -0.0010619900 0.0017406700 -0.0002478100 -0.0075354300 0.0016990100 -0.0004580200 0.0012456800 0.0015011500 0.0000026100 -# File: 34 +# File: 34 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3994687700 -0.0127760000 -0.0027506100 @@ -2275,7 +2275,7 @@ -0.0011004300 0.0070552500 -0.0002603300 -0.0022238500 0.0016535300 -0.0004484400 -0.0000694700 0.0001870000 -0.0000080800 -# File: 35 +# File: 35 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3942633300 0.0126801700 0.0026584600 @@ -2342,7 +2342,7 @@ 0.0003603700 -0.0051557700 -0.0017261500 -0.0007833600 0.0003330800 -0.0018971100 0.0014562500 0.0012990700 -0.0015190500 -# File: 36 +# File: 36 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3913025800 0.0026982300 0.0055713200 @@ -2409,7 +2409,7 @@ -0.0011172800 0.0017446000 -0.0003033800 -0.0022495100 0.0017173300 -0.0004984200 -0.0000734500 0.0015063600 -0.0013129100 -# File: 37 +# File: 37 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 17 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.4022123900 -0.0025993400 -0.0054154600 @@ -2476,7 +2476,7 @@ 0.0003277600 0.0002820900 -0.0016269400 -0.0007572900 0.0002624200 -0.0018406900 0.0014602000 -0.0000321000 -0.0002026000 -# File: 38 +# File: 38 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3910727700 0.0025787300 -0.0056932700 @@ -2543,7 +2543,7 @@ -0.0018978800 -0.0001687600 -0.0019961700 -0.0020425100 0.0001951200 -0.0019656400 0.0068282400 -0.0000010700 -0.0014910300 -# File: 39 +# File: 39 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4026992700 -0.0026814200 0.0057988800 @@ -2610,7 +2610,7 @@ 0.0011020100 0.0021762000 -0.0000163700 -0.0009140200 0.0017362800 -0.0004283900 -0.0053761900 0.0014741000 -0.0000373600 -# File: 40 +# File: 40 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3995611300 -0.0126866900 0.0026337500 @@ -2677,7 +2677,7 @@ -0.0015659200 -0.0004928900 -0.0000141500 -0.0022390100 0.0004112000 -0.0004265700 -0.0000770100 0.0014263300 -0.0000135700 -# File: 41 +# File: 41 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3939515700 0.0127725200 -0.0027612100 @@ -2744,7 +2744,7 @@ 0.0007814900 0.0025119400 -0.0019984800 -0.0007057500 0.0015317400 -0.0019676600 0.0014017500 0.0001028200 -0.0014650400 -# File: 42 +# File: 42 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.4025581500 -0.0028185000 0.0059146900 @@ -2811,7 +2811,7 @@ -0.0013599000 0.0019795600 -0.0013599000 -0.0022392200 0.0017345700 -0.0017501200 -0.0000726800 0.0014863900 -0.0000726800 -# File: 43 +# File: 43 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 18 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.3911868900 0.0027150800 -0.0057777000 @@ -2878,7 +2878,7 @@ 0.0006137700 -0.0000098100 -0.0006209000 -0.0007054500 0.0001968400 -0.0006323400 0.0013966300 0.0000364600 -0.0013995100 -# File: 44 +# File: 44 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -2945,7 +2945,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 45 +# File: 45 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 -0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -3012,7 +3012,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 46 +# File: 46 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -3079,7 +3079,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 47 +# File: 47 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 -0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -3146,7 +3146,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 48 +# File: 48 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 0.0000000000000000 0.0300000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -3213,7 +3213,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 49 +# File: 49 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 19 0.0000000000000000 0.0000000000000000 -0.0300000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -3280,7 +3280,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 50 +# File: 50 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -3347,7 +3347,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 51 +# File: 51 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 -0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -3414,7 +3414,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 52 +# File: 52 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -3481,7 +3481,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 53 +# File: 53 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 -0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -3548,7 +3548,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 54 +# File: 54 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 0.0000000000000000 0.0300000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -3615,7 +3615,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 55 +# File: 55 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 20 0.0000000000000000 0.0000000000000000 -0.0300000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -3682,7 +3682,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 56 +# File: 56 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 33 0.0000000000000000 0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -3749,7 +3749,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 57 +# File: 57 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 33 0.0000000000000000 -0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -3816,7 +3816,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 58 +# File: 58 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 33 0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -3883,7 +3883,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 59 +# File: 59 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 33 -0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -3950,7 +3950,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 60 +# File: 60 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 34 0.0000000000000000 0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -4017,7 +4017,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 61 +# File: 61 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 34 0.0000000000000000 -0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -4084,7 +4084,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 62 +# File: 62 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 34 0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -4151,7 +4151,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 63 +# File: 63 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 34 -0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -4218,7 +4218,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 64 +# File: 64 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -4285,7 +4285,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 65 +# File: 65 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 -0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -4352,7 +4352,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 66 +# File: 66 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -4419,7 +4419,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 67 +# File: 67 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 -0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -4486,7 +4486,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 68 +# File: 68 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 0.0000000000000000 0.0300000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -4553,7 +4553,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 69 +# File: 69 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 35 0.0000000000000000 0.0000000000000000 -0.0300000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -4620,7 +4620,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 70 +# File: 70 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3983412100 0.0012465100 0.0009906200 @@ -4687,7 +4687,7 @@ 0.0006894700 0.0028241900 -0.0007455800 -0.0004142700 0.0028222400 -0.0014325600 0.0017550100 -0.0010964100 -0.0009985600 -# File: 71 +# File: 71 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3952542700 -0.0012124900 -0.0010290400 @@ -4754,7 +4754,7 @@ -0.0014370900 -0.0008636900 -0.0012297100 -0.0025449300 -0.0008658100 -0.0009514600 -0.0003748500 0.0025960700 -0.0005177300 -# File: 72 +# File: 72 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3956611600 -0.0014223600 0.0009709800 @@ -4821,7 +4821,7 @@ 0.0014767500 0.0020501100 -0.0012302400 0.0003607500 0.0020380100 -0.0009486600 -0.0011486200 0.0018093900 -0.0010012400 -# File: 73 +# File: 73 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3979468600 0.0014677600 -0.0010099800 @@ -4888,7 +4888,7 @@ -0.0022135500 -0.0000793100 -0.0007448500 -0.0033301500 -0.0000922000 -0.0014350500 0.0025393600 -0.0003204400 -0.0005152800 -# File: 74 +# File: 74 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3957947400 0.0009494800 -0.0003788600 @@ -4955,7 +4955,7 @@ -0.0006146600 0.0012267600 -0.0010249800 -0.0012401100 0.0007324300 -0.0012281200 0.0009333200 0.0009868900 -0.0007684300 -# File: 75 +# File: 75 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 36 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.3978485800 -0.0009568600 0.0003728800 @@ -5022,7 +5022,7 @@ -0.0001307100 0.0007419500 -0.0009746000 -0.0017211600 0.0012155700 -0.0011800900 0.0004491400 0.0005042700 -0.0007237000 -# File: 76 +# File: 76 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 39 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3958428300 -0.0014597800 0.0011913500 @@ -5089,7 +5089,7 @@ 0.0051363000 0.0065841100 0.0016759800 0.0041531900 0.0067145400 -0.0039459300 -0.0049390600 0.0064864900 0.0020007300 -# File: 77 +# File: 77 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 39 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3978331200 0.0015031600 -0.0011598500 @@ -5156,7 +5156,7 @@ -0.0060033500 -0.0047559900 -0.0037523000 -0.0069926400 -0.0046258300 0.0014612500 0.0061995600 -0.0048546800 -0.0034162600 -# File: 78 +# File: 78 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 39 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3971898300 0.0009842300 0.0009842300 @@ -5223,7 +5223,7 @@ 0.0052211100 0.0064986700 0.0016718500 0.0042657900 0.0065951800 -0.0039506000 0.0062829300 -0.0047702600 -0.0034153900 -# File: 79 +# File: 79 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 39 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3964552900 -0.0009894900 -0.0009894900 @@ -5290,7 +5290,7 @@ -0.0061194500 -0.0046397000 -0.0037478200 -0.0070741500 -0.0045377600 0.0014659400 -0.0050535900 0.0063708400 0.0019997700 -# File: 80 +# File: 80 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 40 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3259103400 0.1011996400 0.0731806400 @@ -5357,7 +5357,7 @@ -0.0058795400 0.0065857300 -0.0036704000 -0.0071339400 0.0067334700 0.0015759200 0.0063148700 0.0065112900 -0.0035701800 -# File: 81 +# File: 81 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 40 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.4734658100 -0.1040813600 -0.0791169700 @@ -5424,7 +5424,7 @@ 0.0052433600 -0.0047589300 0.0017964300 0.0040636400 -0.0046444700 -0.0038603700 -0.0048236300 -0.0048780500 0.0019509300 -# File: 82 +# File: 82 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 40 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.2984766100 0.0710577600 0.0710577600 @@ -5491,7 +5491,7 @@ 0.0053588800 -0.0046358300 0.0017625400 0.0041196900 -0.0045453800 -0.0038215100 0.0063960300 0.0063885700 -0.0034945400 -# File: 83 +# File: 83 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 40 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4976123500 -0.0766133800 -0.0766133800 @@ -5558,7 +5558,7 @@ -0.0059625600 0.0064947800 -0.0036361700 -0.0072202000 0.0066026400 0.0015382500 -0.0048723100 -0.0047884200 0.0018754700 -# File: 84 +# File: 84 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3982967000 -0.0009912600 0.0011047900 @@ -5625,7 +5625,7 @@ -0.0003861000 0.0012296000 -0.0007420400 -0.0142556800 0.0037332000 -0.0039533800 0.0006523100 0.0009814200 -0.0009941000 -# File: 85 +# File: 85 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3953871700 0.0009543800 -0.0011362300 @@ -5692,7 +5692,7 @@ -0.0003409200 0.0007513500 -0.0012266200 0.0112097700 -0.0016815100 0.0014600600 0.0006993500 0.0004973300 -0.0005166000 -# File: 86 +# File: 86 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3977680500 -0.0003737100 -0.0010249400 @@ -5759,7 +5759,7 @@ -0.0006158000 0.0020540300 -0.0028240100 -0.0041367100 0.0065638900 -0.0067019100 0.0004458700 0.0018036100 0.0010909200 -# File: 87 +# File: 87 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3958649400 0.0003677000 0.0010280600 @@ -5826,7 +5826,7 @@ -0.0001354800 -0.0000752000 0.0008634600 0.0012823500 -0.0047689200 0.0044337500 0.0009299700 -0.0003226500 -0.0025931000 -# File: 88 +# File: 88 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 0.0000000000000000 0.0300000000000000 -0.3956283600 -0.0010072400 -0.0015755800 @@ -5893,7 +5893,7 @@ -0.0006164800 -0.0008500300 0.0000787900 0.0012815900 -0.0046546400 0.0045491100 0.0009292800 0.0025766100 0.0003078600 -# File: 89 +# File: 89 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 49 0.0000000000000000 0.0000000000000000 -0.0300000000000000 -0.3980447900 0.0009709500 0.0015326000 @@ -5960,7 +5960,7 @@ -0.0001347700 0.0028393800 -0.0020496500 -0.0041361100 0.0064811000 -0.0067859400 0.0004465800 -0.0011061500 -0.0018207500 -# File: 90 +# File: 90 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -6027,7 +6027,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 91 +# File: 91 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 -0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -6094,7 +6094,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 92 +# File: 92 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -6161,7 +6161,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 93 +# File: 93 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 -0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -6228,7 +6228,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 94 +# File: 94 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 0.0000000000000000 0.0300000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -6295,7 +6295,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 95 +# File: 95 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 50 0.0000000000000000 0.0000000000000000 -0.0300000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -6362,7 +6362,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 96 +# File: 96 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 51 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.4571417700 0.0903113000 -0.0584047600 @@ -6429,7 +6429,7 @@ -0.0006199600 0.0020587400 0.0008626400 -0.0042382900 0.0067158000 0.0044205900 0.0004377500 0.0018017100 -0.0025776600 -# File: 97 +# File: 97 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 51 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3313446300 -0.0929414100 0.0633816100 @@ -6496,7 +6496,7 @@ -0.0001322600 -0.0000878000 -0.0028235700 0.0011829100 -0.0046276200 -0.0066884100 0.0009391500 -0.0003134200 0.0010745000 -# File: 98 +# File: 98 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 51 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3012259200 -0.0654834700 0.0654834700 @@ -6563,7 +6563,7 @@ -0.0004016400 0.0012272000 -0.0012272000 -0.0141716700 0.0036370400 0.0014766100 0.0006679400 0.0009776600 -0.0005061300 -# File: 99 +# File: 99 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 51 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.4893953100 0.0601783600 -0.0601783600 @@ -6630,7 +6630,7 @@ -0.0003750300 0.0007416000 -0.0007416000 0.0113051700 -0.0018040000 -0.0039688600 0.0007326300 0.0005130700 -0.0010050100 -# File: 100 +# File: 100 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 52 0.0000000000000000 0.0300000000000000 0.0000000000000000 -0.3977851900 -0.0014959500 -0.0011912300 @@ -6697,7 +6697,7 @@ -0.0030341100 0.0065870500 -0.0064997600 -0.0017166400 0.0020374900 -0.0030292900 -0.0020709400 0.0064873400 0.0048654500 -# File: 101 +# File: 101 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 52 0.0000000000000000 -0.0300000000000000 0.0000000000000000 -0.3958154300 0.0015410800 0.0011570700 @@ -6764,7 +6764,7 @@ 0.0023835100 -0.0047589600 0.0046404200 -0.0012382300 -0.0000916700 0.0006601800 0.0033463000 -0.0048550600 -0.0062665500 -# File: 102 +# File: 102 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 52 0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3971955700 -0.0009945400 0.0009945400 @@ -6831,7 +6831,7 @@ -0.0131484300 0.0037489900 -0.0037489900 -0.0014878100 0.0012141900 -0.0009478800 -0.0120006500 0.0034003000 0.0018962100 -# File: 103 +# File: 103 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 52 -0.0300000000000000 0.0000000000000000 0.0000000000000000 -0.3964374700 0.0009893800 -0.0009893800 @@ -6898,7 +6898,7 @@ 0.0123058700 -0.0016643900 0.0016643900 -0.0014426300 0.0007341800 -0.0014293800 0.0134673900 -0.0020249000 -0.0035227600 -# File: 104 +# File: 104 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 53 0.0000000000000000 0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -6965,7 +6965,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 105 +# File: 105 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 53 0.0000000000000000 -0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -7032,7 +7032,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 106 +# File: 106 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 53 0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -7099,7 +7099,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 107 +# File: 107 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 53 -0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -7166,7 +7166,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 108 +# File: 108 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 54 0.0000000000000000 0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -7233,7 +7233,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 109 +# File: 109 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 54 0.0000000000000000 -0.0300000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -7300,7 +7300,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 110 +# File: 110 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 54 0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 @@ -7367,7 +7367,7 @@ 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 -# File: 111 +# File: 111 # 1 0.0300000000000000 0.0000000000000000 0.0000000000000000 # 54 -0.0300000000000000 0.0000000000000000 0.0000000000000000 0.0000000000 0.0000000000 0.0000000000 diff --git a/test/conftest.py b/test/conftest.py index 545839e6..aa9a3c2d 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -13,19 +13,21 @@ store_dense_gp_map = True def pytest_addoption(parser): """Activate v1 emulation with --v1 option.""" parser.addoption( - "--v1", action="store_false", default=True, - help="Run with phono3py v1.x emulation." + "--v1", + action="store_false", + default=True, + help="Run with phono3py v1.x emulation.", ) -@pytest.fixture(scope='session') +@pytest.fixture(scope="session") def agno2_cell(): """Return AgNO2 cell (Imm2).""" cell = read_cell_yaml(os.path.join(current_dir, "AgNO2_cell.yaml")) return cell -@pytest.fixture(scope='session') +@pytest.fixture(scope="session") def si_pbesol(request): """Return Phono3py instance of Si 2x2x2. @@ -35,15 +37,17 @@ def si_pbesol(request): """ yaml_filename = os.path.join(current_dir, "phono3py_si_pbesol.yaml") forces_fc3_filename = os.path.join(current_dir, "FORCES_FC3_si_pbesol") - enable_v2 = request.config.getoption('--v1') - return phono3py.load(yaml_filename, - forces_fc3_filename=forces_fc3_filename, - store_dense_gp_map=enable_v2, - store_dense_svecs=enable_v2, - log_level=1) + enable_v2 = request.config.getoption("--v1") + return phono3py.load( + yaml_filename, + forces_fc3_filename=forces_fc3_filename, + store_dense_gp_map=enable_v2, + store_dense_svecs=enable_v2, + log_level=1, + ) -@pytest.fixture(scope='session') +@pytest.fixture(scope="session") def si_pbesol_nosym(request): """Return Phono3py instance of Si 2x2x2. @@ -53,17 +57,19 @@ def si_pbesol_nosym(request): """ yaml_filename = os.path.join(current_dir, "phono3py_si_pbesol.yaml") forces_fc3_filename = os.path.join(current_dir, "FORCES_FC3_si_pbesol") - enable_v2 = request.config.getoption('--v1') - return phono3py.load(yaml_filename, - forces_fc3_filename=forces_fc3_filename, - is_symmetry=False, - produce_fc=False, - store_dense_gp_map=enable_v2, - store_dense_svecs=enable_v2, - log_level=1) + enable_v2 = request.config.getoption("--v1") + return phono3py.load( + yaml_filename, + forces_fc3_filename=forces_fc3_filename, + is_symmetry=False, + produce_fc=False, + store_dense_gp_map=enable_v2, + store_dense_svecs=enable_v2, + log_level=1, + ) -@pytest.fixture(scope='session') +@pytest.fixture(scope="session") def si_pbesol_nomeshsym(request): """Return Phono3py instance of Si 2x2x2. @@ -73,17 +79,19 @@ def si_pbesol_nomeshsym(request): """ yaml_filename = os.path.join(current_dir, "phono3py_si_pbesol.yaml") forces_fc3_filename = os.path.join(current_dir, "FORCES_FC3_si_pbesol") - enable_v2 = request.config.getoption('--v1') - return phono3py.load(yaml_filename, - forces_fc3_filename=forces_fc3_filename, - is_mesh_symmetry=False, - produce_fc=False, - store_dense_gp_map=enable_v2, - store_dense_svecs=enable_v2, - log_level=1) + enable_v2 = request.config.getoption("--v1") + return phono3py.load( + yaml_filename, + forces_fc3_filename=forces_fc3_filename, + is_mesh_symmetry=False, + produce_fc=False, + store_dense_gp_map=enable_v2, + store_dense_svecs=enable_v2, + log_level=1, + ) -@pytest.fixture(scope='session') +@pytest.fixture(scope="session") def si_pbesol_compact_fc(request): """Return Phono3py instance of Si 2x2x2. @@ -93,16 +101,18 @@ def si_pbesol_compact_fc(request): """ yaml_filename = os.path.join(current_dir, "phono3py_si_pbesol.yaml") forces_fc3_filename = os.path.join(current_dir, "FORCES_FC3_si_pbesol") - enable_v2 = request.config.getoption('--v1') - return phono3py.load(yaml_filename, - forces_fc3_filename=forces_fc3_filename, - is_compact_fc=True, - store_dense_gp_map=enable_v2, - store_dense_svecs=enable_v2, - log_level=1) + enable_v2 = request.config.getoption("--v1") + return phono3py.load( + yaml_filename, + forces_fc3_filename=forces_fc3_filename, + is_compact_fc=True, + store_dense_gp_map=enable_v2, + store_dense_svecs=enable_v2, + log_level=1, + ) -@pytest.fixture(scope='session') +@pytest.fixture(scope="session") def si_pbesol_111(request): """Return Phono3py instance of Si 1x1x1. @@ -111,14 +121,16 @@ def si_pbesol_111(request): """ yaml_filename = os.path.join(current_dir, "phono3py_params_Si111.yaml") - enable_v2 = request.config.getoption('--v1') - return phono3py.load(yaml_filename, - store_dense_gp_map=enable_v2, - store_dense_svecs=enable_v2, - log_level=1) + enable_v2 = request.config.getoption("--v1") + return phono3py.load( + yaml_filename, + store_dense_gp_map=enable_v2, + store_dense_svecs=enable_v2, + log_level=1, + ) -@pytest.fixture(scope='session') +@pytest.fixture(scope="session") def si_pbesol_iterha_111(): """Return Phono3py instance of Si 1x1x1. @@ -126,14 +138,11 @@ def si_pbesol_iterha_111(): * no fc """ - yaml_filename = os.path.join(current_dir, - "phonopy_params-Si111-iterha.yaml.gz") - return phonopy.load(yaml_filename, - log_level=1, - produce_fc=False) + yaml_filename = os.path.join(current_dir, "phonopy_params-Si111-iterha.yaml.gz") + return phonopy.load(yaml_filename, log_level=1, produce_fc=False) -@pytest.fixture(scope='session') +@pytest.fixture(scope="session") def nacl_pbe(request): """Return Phono3py instance of NaCl 2x2x2. @@ -141,47 +150,49 @@ def nacl_pbe(request): * compact fc """ - yaml_filename = os.path.join(current_dir, - "phono3py_params_NaCl222.yaml.xz") - enable_v2 = request.config.getoption('--v1') - return phono3py.load(yaml_filename, - store_dense_gp_map=enable_v2, - store_dense_svecs=enable_v2, - log_level=1) + yaml_filename = os.path.join(current_dir, "phono3py_params_NaCl222.yaml.xz") + enable_v2 = request.config.getoption("--v1") + return phono3py.load( + yaml_filename, + store_dense_gp_map=enable_v2, + store_dense_svecs=enable_v2, + log_level=1, + ) -@pytest.fixture(scope='session') +@pytest.fixture(scope="session") def nacl_pbe_cutoff_fc3(request): """Return Phono3py instance of NaCl 2x2x2. * cutoff pair with 5 """ - yaml_filename = os.path.join(current_dir, - "phono3py_params_NaCl222.yaml.xz") - enable_v2 = request.config.getoption('--v1') - ph3 = phono3py.load(yaml_filename, - store_dense_gp_map=enable_v2, - store_dense_svecs=enable_v2, - produce_fc=False, - log_level=1) + yaml_filename = os.path.join(current_dir, "phono3py_params_NaCl222.yaml.xz") + enable_v2 = request.config.getoption("--v1") + ph3 = phono3py.load( + yaml_filename, + store_dense_gp_map=enable_v2, + store_dense_svecs=enable_v2, + produce_fc=False, + log_level=1, + ) forces = ph3.forces ph3.generate_displacements(cutoff_pair_distance=5) dataset = ph3.dataset - dataset['first_atoms'][0]['forces'] = forces[0] - dataset['first_atoms'][1]['forces'] = forces[1] + dataset["first_atoms"][0]["forces"] = forces[0] + dataset["first_atoms"][1]["forces"] = forces[1] count = 2 - for first_atoms in dataset['first_atoms']: - for second_atoms in first_atoms['second_atoms']: - assert second_atoms['id'] == count + 1 - second_atoms['forces'] = forces[count] + for first_atoms in dataset["first_atoms"]: + for second_atoms in first_atoms["second_atoms"]: + assert second_atoms["id"] == count + 1 + second_atoms["forces"] = forces[count] count += 1 ph3.dataset = dataset ph3.produce_fc3(symmetrize_fc3r=True) return ph3 -@pytest.fixture(scope='session') +@pytest.fixture(scope="session") def aln_lda(request): """Return Phono3py instance of AlN 3x3x2. @@ -189,10 +200,11 @@ def aln_lda(request): * full fc. """ - yaml_filename = os.path.join(current_dir, - "phono3py_params_AlN332.yaml.xz") - enable_v2 = request.config.getoption('--v1') - return phono3py.load(yaml_filename, - store_dense_gp_map=enable_v2, - store_dense_svecs=enable_v2, - log_level=1) + yaml_filename = os.path.join(current_dir, "phono3py_params_AlN332.yaml.xz") + enable_v2 = request.config.getoption("--v1") + return phono3py.load( + yaml_filename, + store_dense_gp_map=enable_v2, + store_dense_svecs=enable_v2, + log_level=1, + ) diff --git a/test/cui/test_kaccum.py b/test/cui/test_kaccum.py index 014e8ab8..9723adfe 100644 --- a/test/cui/test_kaccum.py +++ b/test/cui/test_kaccum.py @@ -1,69 +1,200 @@ """Test for kaccum.py.""" import numpy as np -from phono3py.cui.kaccum import ( - KappaDOS, _get_mfp) +from phono3py.cui.kaccum import KappaDOS, _get_mfp from phono3py.phonon.grid import get_ir_grid_points -kappados_si = [-0.0000002, 0.0000000, 0.0000000, - 1.6966400, 2.1977566, 5.1814323, - 3.3932803, 25.8022392, 15.5096766, - 5.0899206, 56.6994259, 19.4995156, - 6.7865608, 68.7759426, 3.2465477, - 8.4832011, 72.8398965, 1.6583881, - 10.1798413, 74.8143686, 0.7945952, - 11.8764816, 77.2489625, 5.4385183, - 13.5731219, 80.9162245, 0.5998735, - 15.2697621, 81.4303646, 0.0000000] -mfpdos_si = [0.0000000, 0.0000000, 0.0000000, - 806.8089241, 33.7703552, 0.0225548, - 1613.6178483, 45.0137786, 0.0103479, - 2420.4267724, 53.3456168, 0.0106724, - 3227.2356966, 62.4915811, 0.0107850, - 4034.0446207, 69.8839011, 0.0075919, - 4840.8535449, 74.8662085, 0.0049228, - 5647.6624690, 78.2273252, 0.0035758, - 6454.4713932, 80.5493065, 0.0020836, - 7261.2803173, 81.4303646, 0.0000000] -gammados_si = [-0.0000002, 0.0000000, 0.0000000, - 1.6966400, 0.0000063, 0.0000149, - 3.3932803, 0.0004133, 0.0012312, - 5.0899206, 0.0071709, 0.0057356, - 6.7865608, 0.0099381, 0.0006492, - 8.4832011, 0.0133390, 0.0049604, - 10.1798413, 0.0394030, 0.0198106, - 11.8764816, 0.0495160, 0.0044113, - 13.5731219, 0.0560223, 0.0050103, - 15.2697621, 0.1300596, 0.0000000] -kappados_nacl = [-0.0000002, 0.0000000, 0.0000000, - 0.8051732, 0.0366488, 0.1820668, - 1.6103466, 0.7748514, 1.5172957, - 2.4155199, 2.0165794, 2.0077744, - 3.2206933, 4.6670801, 2.8357892, - 4.0258667, 6.6123781, 32.8560281, - 4.8310401, 7.7105916, 0.6136893, - 5.6362134, 7.9112790, 0.2391300, - 6.4413868, 8.0272187, 0.0604842, - 7.2465602, 8.0430831, 0.0000000] -mfpdos_nacl = [0.0000000, 0.0000000, 0.0000000, - 117.4892903, 3.1983595, 0.0266514, - 234.9785806, 5.7974129, 0.0153383, - 352.4678709, 7.2012603, 0.0075057, - 469.9571612, 7.5964440, 0.0017477, - 587.4464515, 7.7823291, 0.0013915, - 704.9357418, 7.9195460, 0.0009363, - 822.4250321, 8.0024702, 0.0004844, - 939.9143223, 8.0375053, 0.0001382, - 1057.4036126, 8.0430831, 0.0000000] -gammados_nacl = [-0.0000002, 0.0000000, 0.0000000, - 0.8051732, 0.0000822, 0.0004081, - 1.6103466, 0.0018975, 0.0053389, - 2.4155199, 0.0114668, 0.0182495, - 3.2206933, 0.0353621, 0.0329440, - 4.0258667, 0.0604996, 0.1138884, - 4.8310401, 0.1038315, 0.0716216, - 5.6362134, 0.1481243, 0.0468421, - 6.4413868, 0.1982823, 0.0662494, - 7.2465602, 0.2429551, 0.0000000] +kappados_si = [ + -0.0000002, + 0.0000000, + 0.0000000, + 1.6966400, + 2.1977566, + 5.1814323, + 3.3932803, + 25.8022392, + 15.5096766, + 5.0899206, + 56.6994259, + 19.4995156, + 6.7865608, + 68.7759426, + 3.2465477, + 8.4832011, + 72.8398965, + 1.6583881, + 10.1798413, + 74.8143686, + 0.7945952, + 11.8764816, + 77.2489625, + 5.4385183, + 13.5731219, + 80.9162245, + 0.5998735, + 15.2697621, + 81.4303646, + 0.0000000, +] +mfpdos_si = [ + 0.0000000, + 0.0000000, + 0.0000000, + 806.8089241, + 33.7703552, + 0.0225548, + 1613.6178483, + 45.0137786, + 0.0103479, + 2420.4267724, + 53.3456168, + 0.0106724, + 3227.2356966, + 62.4915811, + 0.0107850, + 4034.0446207, + 69.8839011, + 0.0075919, + 4840.8535449, + 74.8662085, + 0.0049228, + 5647.6624690, + 78.2273252, + 0.0035758, + 6454.4713932, + 80.5493065, + 0.0020836, + 7261.2803173, + 81.4303646, + 0.0000000, +] +gammados_si = [ + -0.0000002, + 0.0000000, + 0.0000000, + 1.6966400, + 0.0000063, + 0.0000149, + 3.3932803, + 0.0004133, + 0.0012312, + 5.0899206, + 0.0071709, + 0.0057356, + 6.7865608, + 0.0099381, + 0.0006492, + 8.4832011, + 0.0133390, + 0.0049604, + 10.1798413, + 0.0394030, + 0.0198106, + 11.8764816, + 0.0495160, + 0.0044113, + 13.5731219, + 0.0560223, + 0.0050103, + 15.2697621, + 0.1300596, + 0.0000000, +] +kappados_nacl = [ + -0.0000002, + 0.0000000, + 0.0000000, + 0.8051732, + 0.0366488, + 0.1820668, + 1.6103466, + 0.7748514, + 1.5172957, + 2.4155199, + 2.0165794, + 2.0077744, + 3.2206933, + 4.6670801, + 2.8357892, + 4.0258667, + 6.6123781, + 32.8560281, + 4.8310401, + 7.7105916, + 0.6136893, + 5.6362134, + 7.9112790, + 0.2391300, + 6.4413868, + 8.0272187, + 0.0604842, + 7.2465602, + 8.0430831, + 0.0000000, +] +mfpdos_nacl = [ + 0.0000000, + 0.0000000, + 0.0000000, + 117.4892903, + 3.1983595, + 0.0266514, + 234.9785806, + 5.7974129, + 0.0153383, + 352.4678709, + 7.2012603, + 0.0075057, + 469.9571612, + 7.5964440, + 0.0017477, + 587.4464515, + 7.7823291, + 0.0013915, + 704.9357418, + 7.9195460, + 0.0009363, + 822.4250321, + 8.0024702, + 0.0004844, + 939.9143223, + 8.0375053, + 0.0001382, + 1057.4036126, + 8.0430831, + 0.0000000, +] +gammados_nacl = [ + -0.0000002, + 0.0000000, + 0.0000000, + 0.8051732, + 0.0000822, + 0.0004081, + 1.6103466, + 0.0018975, + 0.0053389, + 2.4155199, + 0.0114668, + 0.0182495, + 3.2206933, + 0.0353621, + 0.0329440, + 4.0258667, + 0.0604996, + 0.1138884, + 4.8310401, + 0.1038315, + 0.0716216, + 5.6362134, + 0.1481243, + 0.0468421, + 6.4413868, + 0.1982823, + 0.0662494, + 7.2465602, + 0.2429551, + 0.0000000, +] def test_kappados_si(si_pbesol): @@ -77,33 +208,36 @@ def test_kappados_si(si_pbesol): ph3 = si_pbesol ph3.mesh_numbers = [7, 7, 7] ph3.init_phph_interaction() - ph3.run_thermal_conductivity(temperatures=[300, ]) + ph3.run_thermal_conductivity( + temperatures=[ + 300, + ] + ) tc = ph3.thermal_conductivity freq_points_in = np.array(kappados_si).reshape(-1, 3)[:, 0] freq_points, kdos = _calculate_kappados( - ph3, tc.mode_kappa[0], freq_points=freq_points_in) + ph3, tc.mode_kappa[0], freq_points=freq_points_in + ) for f, (jval, ival) in zip(freq_points, kdos): print("%.7f, %.7f, %.7f," % (f, jval, ival)) np.testing.assert_allclose( - kappados_si, - np.vstack((freq_points, kdos.T)).T.ravel(), - rtol=0, atol=0.5) + kappados_si, np.vstack((freq_points, kdos.T)).T.ravel(), rtol=0, atol=0.5 + ) freq_points, kdos = _calculate_kappados( - ph3, tc.gamma[0, :, :, :, None], freq_points=freq_points_in) + ph3, tc.gamma[0, :, :, :, None], freq_points=freq_points_in + ) np.testing.assert_allclose( - gammados_si, - np.vstack((freq_points, kdos.T)).T.ravel(), - rtol=0, atol=0.5) + gammados_si, np.vstack((freq_points, kdos.T)).T.ravel(), rtol=0, atol=0.5 + ) mfp_points_in = np.array(mfpdos_si).reshape(-1, 3)[:, 0] mfp_points, mfpdos = _calculate_mfpdos(ph3, mfp_points_in) # for f, (jval, ival) in zip(freq_points, mfpdos): # print("%.7f, %.7f, %.7f," % (f, jval, ival)) np.testing.assert_allclose( - mfpdos_si, - np.vstack((mfp_points, mfpdos.T)).T.ravel(), - rtol=0, atol=0.5) + mfpdos_si, np.vstack((mfp_points, mfpdos.T)).T.ravel(), rtol=0, atol=0.5 + ) def test_kappados_nacl(nacl_pbe): @@ -117,33 +251,36 @@ def test_kappados_nacl(nacl_pbe): ph3 = nacl_pbe ph3.mesh_numbers = [7, 7, 7] ph3.init_phph_interaction() - ph3.run_thermal_conductivity(temperatures=[300, ]) + ph3.run_thermal_conductivity( + temperatures=[ + 300, + ] + ) tc = ph3.thermal_conductivity freq_points_in = np.array(kappados_nacl).reshape(-1, 3)[:, 0] freq_points, kdos = _calculate_kappados( - ph3, tc.mode_kappa[0], freq_points=freq_points_in) + ph3, tc.mode_kappa[0], freq_points=freq_points_in + ) # for f, (jval, ival) in zip(freq_points, kdos): # print("%.7f, %.7f, %.7f," % (f, jval, ival)) np.testing.assert_allclose( - kappados_nacl, - np.vstack((freq_points, kdos.T)).T.ravel(), - rtol=0, atol=0.5) + kappados_nacl, np.vstack((freq_points, kdos.T)).T.ravel(), rtol=0, atol=0.5 + ) freq_points, kdos = _calculate_kappados( - ph3, tc.gamma[0, :, :, :, None], freq_points=freq_points_in) + ph3, tc.gamma[0, :, :, :, None], freq_points=freq_points_in + ) np.testing.assert_allclose( - gammados_nacl, - np.vstack((freq_points, kdos.T)).T.ravel(), - rtol=0, atol=0.5) + gammados_nacl, np.vstack((freq_points, kdos.T)).T.ravel(), rtol=0, atol=0.5 + ) mfp_points_in = np.array(mfpdos_nacl).reshape(-1, 3)[:, 0] mfp_points, mfpdos = _calculate_mfpdos(ph3, mfp_points_in) # for f, (jval, ival) in zip(freq_points, mfpdos): # print("%.7f, %.7f, %.7f," % (f, jval, ival)) np.testing.assert_allclose( - mfpdos_nacl, - np.vstack((mfp_points, mfpdos.T)).T.ravel(), - rtol=0, atol=0.5) + mfpdos_nacl, np.vstack((mfp_points, mfpdos.T)).T.ravel(), rtol=0, atol=0.5 + ) def _calculate_kappados(ph3, mode_prop, freq_points=None): @@ -151,11 +288,8 @@ def _calculate_kappados(ph3, mode_prop, freq_points=None): bz_grid = ph3.grid frequencies, _, _ = ph3.get_phonon_data() kappados = KappaDOS( - mode_prop, - frequencies, - bz_grid, - tc.grid_points, - frequency_points=freq_points) + mode_prop, frequencies, bz_grid, tc.grid_points, frequency_points=freq_points + ) freq_points, kdos = kappados.get_kdos() ir_grid_points, _, ir_grid_map = get_ir_grid_points(bz_grid) @@ -165,7 +299,8 @@ def _calculate_kappados(ph3, mode_prop, freq_points=None): bz_grid, tc.grid_points, ir_grid_map=ir_grid_map, - frequency_points=freq_points) + frequency_points=freq_points, + ) ir_freq_points, ir_kdos = kappados.get_kdos() np.testing.assert_equal(bz_grid.bzg2grg[tc.grid_points], ir_grid_points) np.testing.assert_allclose(ir_freq_points, freq_points, rtol=0, atol=1e-5) @@ -185,7 +320,8 @@ def _calculate_mfpdos(ph3, mfp_points=None): tc.grid_points, ir_grid_map=ir_grid_map, frequency_points=mfp_points, - num_sampling_points=10) + num_sampling_points=10, + ) freq_points, kdos = mfpdos.get_kdos() return freq_points, kdos[0, :, :, 0] diff --git a/test/other/test_isotope.py b/test/other/test_isotope.py index 9dce0774..01e1e710 100644 --- a/test/other/test_isotope.py +++ b/test/other/test_isotope.py @@ -1,46 +1,81 @@ +"""Tests for isotope scatterings.""" import numpy as np from phono3py import Phono3pyIsotope si_pbesol_iso = [ - [8.32325038e-07, 9.45389739e-07, 1.57942189e-05, 1.28121297e-03, - 1.13842605e-03, 3.84915211e-04], - [2.89457649e-05, 1.57841863e-04, 3.97462227e-04, 1.03489892e-02, - 4.45981554e-03, 2.67184355e-03]] + [ + 8.32325038e-07, + 9.45389739e-07, + 1.57942189e-05, + 1.28121297e-03, + 1.13842605e-03, + 3.84915211e-04, + ], + [ + 2.89457649e-05, + 1.57841863e-04, + 3.97462227e-04, + 1.03489892e-02, + 4.45981554e-03, + 2.67184355e-03, + ], +] si_pbesol_iso_sigma = [ - [1.57262391e-06, 1.64031282e-06, 2.02007165e-05, 1.41999212e-03, - 1.26361419e-03, 7.91243161e-04], - [3.10266472e-05, 1.53059329e-04, 3.80963936e-04, 1.05238031e-02, - 6.72552880e-03, 3.21592329e-03]] + [ + 1.57262391e-06, + 1.64031282e-06, + 2.02007165e-05, + 1.41999212e-03, + 1.26361419e-03, + 7.91243161e-04, + ], + [ + 3.10266472e-05, + 1.53059329e-04, + 3.80963936e-04, + 1.05238031e-02, + 6.72552880e-03, + 3.21592329e-03, + ], +] def test_Phono3pyIsotope(si_pbesol): + """Phono3pyIsotope with tetrahedron method.""" si_pbesol.mesh_numbers = [21, 21, 21] iso = Phono3pyIsotope( si_pbesol.mesh_numbers, si_pbesol.phonon_primitive, - symprec=si_pbesol.symmetry.tolerance) + symprec=si_pbesol.symmetry.tolerance, + ) iso.init_dynamical_matrix( si_pbesol.fc2, si_pbesol.phonon_supercell, si_pbesol.phonon_primitive, - nac_params=si_pbesol.nac_params) + nac_params=si_pbesol.nac_params, + ) iso.run([23, 103]) # print(iso.gamma[0]) np.testing.assert_allclose(si_pbesol_iso, iso.gamma[0], atol=3e-4) def test_Phono3pyIsotope_with_sigma(si_pbesol): + """Phono3pyIsotope with smearing method.""" si_pbesol.mesh_numbers = [21, 21, 21] iso = Phono3pyIsotope( si_pbesol.mesh_numbers, si_pbesol.phonon_primitive, - sigmas=[0.1, ], - symprec=si_pbesol.symmetry.tolerance) + sigmas=[ + 0.1, + ], + symprec=si_pbesol.symmetry.tolerance, + ) iso.init_dynamical_matrix( si_pbesol.fc2, si_pbesol.phonon_supercell, si_pbesol.phonon_primitive, - nac_params=si_pbesol.nac_params) + nac_params=si_pbesol.nac_params, + ) iso.run([23, 103]) # print(iso.gamma[0]) np.testing.assert_allclose(si_pbesol_iso_sigma, iso.gamma[0], atol=3e-4) diff --git a/test/phonon/__init__.py b/test/phonon/__init__.py index e69de29b..1f598a8a 100644 --- a/test/phonon/__init__.py +++ b/test/phonon/__init__.py @@ -0,0 +1 @@ +"""Tests for harmonic phonon level properties.""" diff --git a/test/phonon/test_grid.py b/test/phonon/test_grid.py index e93b6145..ec9d5f66 100644 --- a/test/phonon/test_grid.py +++ b/test/phonon/test_grid.py @@ -1,9 +1,13 @@ import numpy as np from phonopy.structure.tetrahedron_method import TetrahedronMethod from phono3py.phonon.grid import ( - get_grid_point_from_address, get_grid_point_from_address_py, BZGrid, - _get_grid_points_by_rotations, _get_grid_points_by_bz_rotations_c, - _get_grid_points_by_bz_rotations_py) + get_grid_point_from_address, + get_grid_point_from_address_py, + BZGrid, + _get_grid_points_by_rotations, + _get_grid_points_by_bz_rotations_c, + _get_grid_points_by_bz_rotations_py, +) def test_get_grid_point_from_address(agno2_cell): @@ -30,16 +34,78 @@ def test_BZGrid(si_pbesol_111): reclat = np.linalg.inv(lat) mesh = [4, 4, 4] - gp_map2 = [0, 1, 2, 4, 5, 6, 7, 8, 9, 11, 12, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 34, 35, - 36, 40, 41, 43, 44, 46, 47, 48, 49, 50, 54, 56, 57, 59, - 60, 61, 65, 66, 67, 68, 69, 70, 71, 72, 73, 77, 78, 79, - 83, 84, 85, 86, 87, 88, 89] + gp_map2 = [ + 0, + 1, + 2, + 4, + 5, + 6, + 7, + 8, + 9, + 11, + 12, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 34, + 35, + 36, + 40, + 41, + 43, + 44, + 46, + 47, + 48, + 49, + 50, + 54, + 56, + 57, + 59, + 60, + 61, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 77, + 78, + 79, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + ] bzgrid1 = BZGrid(mesh, lattice=lat, store_dense_gp_map=False) bzgrid2 = BZGrid(mesh, lattice=lat, store_dense_gp_map=True) - adrs1 = bzgrid1.addresses[:np.prod(mesh)] + adrs1 = bzgrid1.addresses[: np.prod(mesh)] adrs2 = bzgrid2.addresses[bzgrid2.gp_map[:-1]] assert ((adrs1 - adrs2) % mesh == 0).all() np.testing.assert_equal(bzgrid1.addresses.shape, bzgrid2.addresses.shape) @@ -78,18 +144,22 @@ def test_BZGrid_SNF(si_pbesol_111): """SNF in BZGrid""" lat = si_pbesol_111.primitive.cell mesh = 10 - bzgrid1 = BZGrid(mesh, - lattice=lat, - symmetry_dataset=si_pbesol_111.primitive_symmetry.dataset, - use_grg=True, - store_dense_gp_map=False) + bzgrid1 = BZGrid( + mesh, + lattice=lat, + symmetry_dataset=si_pbesol_111.primitive_symmetry.dataset, + use_grg=True, + store_dense_gp_map=False, + ) _test_BZGrid_SNF(bzgrid1) - bzgrid2 = BZGrid(mesh, - lattice=lat, - symmetry_dataset=si_pbesol_111.primitive_symmetry.dataset, - use_grg=True, - store_dense_gp_map=True) + bzgrid2 = BZGrid( + mesh, + lattice=lat, + symmetry_dataset=si_pbesol_111.primitive_symmetry.dataset, + use_grg=True, + store_dense_gp_map=True, + ) _test_BZGrid_SNF(bzgrid2) @@ -117,43 +187,543 @@ def _test_BZGrid_SNF(bzgrid): # for line in gr_addresses.reshape(-1, 12): # print("".join(["%d, " % i for i in line])) - ref = [0, 0, 0, -1, 0, 0, 0, 1, 0, 1, 1, 0, - 0, -2, 0, -1, -2, 0, 0, -1, 0, -1, -1, 0, - 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, - 0, 2, 1, 1, 2, 1, 0, -1, 1, -1, -1, 1, - 0, 0, -2, -1, 0, -2, 0, 1, 2, 1, 1, 2, - 0, -2, -2, -1, -2, -2, 0, -1, -2, -1, -1, -2, - 0, 0, -1, -1, 0, -1, 0, 1, -1, -1, 1, -1, - 0, -2, -1, -1, -2, -1, 0, -1, -1, -1, -1, -1] + ref = [ + 0, + 0, + 0, + -1, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + -2, + 0, + -1, + -2, + 0, + 0, + -1, + 0, + -1, + -1, + 0, + 0, + 0, + 1, + 1, + 0, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 2, + 1, + 1, + 2, + 1, + 0, + -1, + 1, + -1, + -1, + 1, + 0, + 0, + -2, + -1, + 0, + -2, + 0, + 1, + 2, + 1, + 1, + 2, + 0, + -2, + -2, + -1, + -2, + -2, + 0, + -1, + -2, + -1, + -1, + -2, + 0, + 0, + -1, + -1, + 0, + -1, + 0, + 1, + -1, + -1, + 1, + -1, + 0, + -2, + -1, + -1, + -2, + -1, + 0, + -1, + -1, + -1, + -1, + -1, + ] - assert (((np.reshape(ref, (-1, 3)) - gr_addresses) - % bzgrid.D_diag).ravel() == 0).all() + assert ( + ((np.reshape(ref, (-1, 3)) - gr_addresses) % bzgrid.D_diag).ravel() == 0 + ).all() ref_rots = [ - 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 2, 1, -1, 2, 2, -1, - 1, 0, 0, 2, -1, 0, 4, 0, -1, 1, 0, 0, 0, -1, 1, 2, -2, 1, - -1, 0, 0, 0, -1, 0, -2, -2, 1, -1, 0, 0, 0, 1, -1, 0, 0, -1, - -1, 0, 0, -2, 1, 0, -2, 2, -1, -1, 0, 0, -2, -1, 1, -4, 0, 1, - -1, -1, 1, 0, -1, 1, -2, -1, 2, -1, -1, 1, 0, -2, 1, 0, -3, 2, - -1, -1, 1, -2, -1, 1, -2, -3, 2, -1, -1, 1, -2, 0, 1, -4, -1, 2, - 1, 1, -1, 0, 1, -1, 0, 3, -2, 1, 1, -1, 2, 0, -1, 2, 1, -2, - 1, 1, -1, 2, 1, -1, 4, 1, -2, 1, 1, -1, 0, 2, -1, 2, 3, -2, - -1, 1, 0, -2, 0, 1, -2, 1, 1, -1, 1, 0, -2, 1, 0, -4, 1, 1, - -1, 1, 0, 0, 2, -1, -2, 3, -1, -1, 1, 0, 0, 1, 0, 0, 3, -1, - 1, -1, 0, 2, 0, -1, 4, -1, -1, 1, -1, 0, 0, -1, 0, 2, -1, -1, - 1, -1, 0, 0, -2, 1, 0, -3, 1, 1, -1, 0, 2, -1, 0, 2, -3, 1, - -1, 0, 0, 0, -1, 0, 0, 0, -1, -1, 0, 0, -2, -1, 1, -2, -2, 1, - -1, 0, 0, -2, 1, 0, -4, 0, 1, -1, 0, 0, 0, 1, -1, -2, 2, -1, - 1, 0, 0, 0, 1, 0, 2, 2, -1, 1, 0, 0, 0, -1, 1, 0, 0, 1, - 1, 0, 0, 2, -1, 0, 2, -2, 1, 1, 0, 0, 2, 1, -1, 4, 0, -1, - 1, 1, -1, 0, 1, -1, 2, 1, -2, 1, 1, -1, 0, 2, -1, 0, 3, -2, - 1, 1, -1, 2, 1, -1, 2, 3, -2, 1, 1, -1, 2, 0, -1, 4, 1, -2, - -1, -1, 1, 0, -1, 1, 0, -3, 2, -1, -1, 1, -2, 0, 1, -2, -1, 2, - -1, -1, 1, -2, -1, 1, -4, -1, 2, -1, -1, 1, 0, -2, 1, -2, -3, 2, - 1, -1, 0, 2, 0, -1, 2, -1, -1, 1, -1, 0, 2, -1, 0, 4, -1, -1, - 1, -1, 0, 0, -2, 1, 2, -3, 1, 1, -1, 0, 0, -1, 0, 0, -3, 1, - -1, 1, 0, -2, 0, 1, -4, 1, 1, -1, 1, 0, 0, 1, 0, -2, 1, 1, - -1, 1, 0, 0, 2, -1, 0, 3, -1, -1, 1, 0, -2, 1, 0, -2, 3, -1] + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 2, + 1, + -1, + 2, + 2, + -1, + 1, + 0, + 0, + 2, + -1, + 0, + 4, + 0, + -1, + 1, + 0, + 0, + 0, + -1, + 1, + 2, + -2, + 1, + -1, + 0, + 0, + 0, + -1, + 0, + -2, + -2, + 1, + -1, + 0, + 0, + 0, + 1, + -1, + 0, + 0, + -1, + -1, + 0, + 0, + -2, + 1, + 0, + -2, + 2, + -1, + -1, + 0, + 0, + -2, + -1, + 1, + -4, + 0, + 1, + -1, + -1, + 1, + 0, + -1, + 1, + -2, + -1, + 2, + -1, + -1, + 1, + 0, + -2, + 1, + 0, + -3, + 2, + -1, + -1, + 1, + -2, + -1, + 1, + -2, + -3, + 2, + -1, + -1, + 1, + -2, + 0, + 1, + -4, + -1, + 2, + 1, + 1, + -1, + 0, + 1, + -1, + 0, + 3, + -2, + 1, + 1, + -1, + 2, + 0, + -1, + 2, + 1, + -2, + 1, + 1, + -1, + 2, + 1, + -1, + 4, + 1, + -2, + 1, + 1, + -1, + 0, + 2, + -1, + 2, + 3, + -2, + -1, + 1, + 0, + -2, + 0, + 1, + -2, + 1, + 1, + -1, + 1, + 0, + -2, + 1, + 0, + -4, + 1, + 1, + -1, + 1, + 0, + 0, + 2, + -1, + -2, + 3, + -1, + -1, + 1, + 0, + 0, + 1, + 0, + 0, + 3, + -1, + 1, + -1, + 0, + 2, + 0, + -1, + 4, + -1, + -1, + 1, + -1, + 0, + 0, + -1, + 0, + 2, + -1, + -1, + 1, + -1, + 0, + 0, + -2, + 1, + 0, + -3, + 1, + 1, + -1, + 0, + 2, + -1, + 0, + 2, + -3, + 1, + -1, + 0, + 0, + 0, + -1, + 0, + 0, + 0, + -1, + -1, + 0, + 0, + -2, + -1, + 1, + -2, + -2, + 1, + -1, + 0, + 0, + -2, + 1, + 0, + -4, + 0, + 1, + -1, + 0, + 0, + 0, + 1, + -1, + -2, + 2, + -1, + 1, + 0, + 0, + 0, + 1, + 0, + 2, + 2, + -1, + 1, + 0, + 0, + 0, + -1, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 2, + -1, + 0, + 2, + -2, + 1, + 1, + 0, + 0, + 2, + 1, + -1, + 4, + 0, + -1, + 1, + 1, + -1, + 0, + 1, + -1, + 2, + 1, + -2, + 1, + 1, + -1, + 0, + 2, + -1, + 0, + 3, + -2, + 1, + 1, + -1, + 2, + 1, + -1, + 2, + 3, + -2, + 1, + 1, + -1, + 2, + 0, + -1, + 4, + 1, + -2, + -1, + -1, + 1, + 0, + -1, + 1, + 0, + -3, + 2, + -1, + -1, + 1, + -2, + 0, + 1, + -2, + -1, + 2, + -1, + -1, + 1, + -2, + -1, + 1, + -4, + -1, + 2, + -1, + -1, + 1, + 0, + -2, + 1, + -2, + -3, + 2, + 1, + -1, + 0, + 2, + 0, + -1, + 2, + -1, + -1, + 1, + -1, + 0, + 2, + -1, + 0, + 4, + -1, + -1, + 1, + -1, + 0, + 0, + -2, + 1, + 2, + -3, + 1, + 1, + -1, + 0, + 0, + -1, + 0, + 0, + -3, + 1, + -1, + 1, + 0, + -2, + 0, + 1, + -4, + 1, + 1, + -1, + 1, + 0, + 0, + 1, + 0, + -2, + 1, + 1, + -1, + 1, + 0, + 0, + 2, + -1, + 0, + 3, + -1, + -1, + 1, + 0, + -2, + 1, + 0, + -2, + 3, + -1, + ] np.testing.assert_equal(ref_rots, bzgrid.rotations.ravel()) @@ -183,7 +753,8 @@ def test_SNF_tetrahedra_relative_grid(aln_lda): np.testing.assert_allclose( np.dot(mtet, mlat.T), np.dot(np.dot(ptet, bz_grid.QDinv.T), plat.T), - atol=1e-8) + atol=1e-8, + ) # print(np.dot(mtet, mlat.T)) # print(np.dot(np.dot(ptet, bz_grid.QDinv.T), plat.T)) @@ -198,25 +769,207 @@ def test_get_grid_points_by_bz_rotations(si_pbesol_111): _get_grid_points_by_bz_rotations_py """ - ref10_type1 = [10, 26, 10, 26, 26, 10, 26, 10, 88, 80, 200, 208, - 200, 208, 88, 80, 208, 88, 80, 200, 208, 88, 80, 200, - 26, 10, 26, 10, 10, 26, 10, 26, 200, 208, 88, 80, - 88, 80, 200, 208, 80, 200, 208, 88, 80, 200, 208, 88] - ref12_type2 = [12, 39, 12, 39, 39, 12, 39, 12, 122, 109, 265, 278, - 265, 278, 122, 109, 278, 122, 109, 265, 278, 122, 109, 265, - 39, 12, 39, 12, 12, 39, 12, 39, 265, 278, 122, 109, - 122, 109, 265, 278, 109, 265, 278, 122, 109, 265, 278, 122] + ref10_type1 = [ + 10, + 26, + 10, + 26, + 26, + 10, + 26, + 10, + 88, + 80, + 200, + 208, + 200, + 208, + 88, + 80, + 208, + 88, + 80, + 200, + 208, + 88, + 80, + 200, + 26, + 10, + 26, + 10, + 10, + 26, + 10, + 26, + 200, + 208, + 88, + 80, + 88, + 80, + 200, + 208, + 80, + 200, + 208, + 88, + 80, + 200, + 208, + 88, + ] + ref12_type2 = [ + 12, + 39, + 12, + 39, + 39, + 12, + 39, + 12, + 122, + 109, + 265, + 278, + 265, + 278, + 122, + 109, + 278, + 122, + 109, + 265, + 278, + 122, + 109, + 265, + 39, + 12, + 39, + 12, + 12, + 39, + 12, + 39, + 265, + 278, + 122, + 109, + 122, + 109, + 265, + 278, + 109, + 265, + 278, + 122, + 109, + 265, + 278, + 122, + ] ref10_bz_type1 = [ - 10, 26, 260, 270, 269, 258, 271, 259, 88, 285, 200, 328, - 322, 208, 291, 286, 327, 292, 287, 321, 326, 290, 80, 323, - 269, 258, 271, 259, 10, 26, 260, 270, 200, 328, 88, 285, - 291, 286, 322, 208, 80, 323, 326, 290, 287, 321, 327, 292] + 10, + 26, + 260, + 270, + 269, + 258, + 271, + 259, + 88, + 285, + 200, + 328, + 322, + 208, + 291, + 286, + 327, + 292, + 287, + 321, + 326, + 290, + 80, + 323, + 269, + 258, + 271, + 259, + 10, + 26, + 260, + 270, + 200, + 328, + 88, + 285, + 291, + 286, + 322, + 208, + 80, + 323, + 326, + 290, + 287, + 321, + 327, + 292, + ] ref12_bz_type2 = [ - 12, 39, 15, 41, 40, 13, 42, 14, 122, 110, 265, 281, - 267, 278, 124, 111, 280, 125, 112, 266, 279, 123, 109, 268, - 40, 13, 42, 14, 12, 39, 15, 41, 265, 281, 122, 110, - 124, 111, 267, 278, 109, 268, 279, 123, 112, 266, 280, 125] + 12, + 39, + 15, + 41, + 40, + 13, + 42, + 14, + 122, + 110, + 265, + 281, + 267, + 278, + 124, + 111, + 280, + 125, + 112, + 266, + 279, + 123, + 109, + 268, + 40, + 13, + 42, + 14, + 12, + 39, + 15, + 41, + 265, + 281, + 122, + 110, + 124, + 111, + 267, + 278, + 109, + 268, + 279, + 123, + 112, + 266, + 280, + 125, + ] lat = si_pbesol_111.primitive.cell mesh = 20 @@ -226,46 +979,53 @@ def test_get_grid_points_by_bz_rotations(si_pbesol_111): lattice=lat, symmetry_dataset=si_pbesol_111.primitive_symmetry.dataset, use_grg=True, - store_dense_gp_map=False) + store_dense_gp_map=False, + ) bz_grid_type2 = BZGrid( mesh, lattice=lat, symmetry_dataset=si_pbesol_111.primitive_symmetry.dataset, use_grg=True, - store_dense_gp_map=True) + store_dense_gp_map=True, + ) # Check data consistency by reducing to GR-grid. # Grid point 10 in type-1 and 12 in type-2 are the same points in GR-grid. assert bz_grid_type1.bzg2grg[10] == bz_grid_type2.bzg2grg[12] - np.testing.assert_equal(bz_grid_type1.bzg2grg[ref10_type1], - bz_grid_type2.bzg2grg[ref12_type2]) - np.testing.assert_equal(bz_grid_type1.bzg2grg[ref10_type1], - bz_grid_type1.bzg2grg[ref10_bz_type1]) - np.testing.assert_equal(bz_grid_type1.bzg2grg[ref10_type1], - bz_grid_type2.bzg2grg[ref12_bz_type2]) + np.testing.assert_equal( + bz_grid_type1.bzg2grg[ref10_type1], bz_grid_type2.bzg2grg[ref12_type2] + ) + np.testing.assert_equal( + bz_grid_type1.bzg2grg[ref10_type1], bz_grid_type1.bzg2grg[ref10_bz_type1] + ) + np.testing.assert_equal( + bz_grid_type1.bzg2grg[ref10_type1], bz_grid_type2.bzg2grg[ref12_bz_type2] + ) - bzgps = _get_grid_points_by_rotations( - 10, bz_grid_type1, bz_grid_type1.rotations) + bzgps = _get_grid_points_by_rotations(10, bz_grid_type1, bz_grid_type1.rotations) np.testing.assert_equal(bzgps, ref10_type1) - bzgps = _get_grid_points_by_rotations( - 12, bz_grid_type2, bz_grid_type2.rotations) + bzgps = _get_grid_points_by_rotations(12, bz_grid_type2, bz_grid_type2.rotations) np.testing.assert_equal(bzgps, ref12_type2) bzgps = _get_grid_points_by_bz_rotations_c( - 10, bz_grid_type1, bz_grid_type1.rotations) + 10, bz_grid_type1, bz_grid_type1.rotations + ) np.testing.assert_equal(bzgps, ref10_bz_type1) bzgps = _get_grid_points_by_bz_rotations_c( - 12, bz_grid_type2, bz_grid_type2.rotations) + 12, bz_grid_type2, bz_grid_type2.rotations + ) np.testing.assert_equal(bzgps, ref12_bz_type2) bzgps = _get_grid_points_by_bz_rotations_py( - 10, bz_grid_type1, bz_grid_type1.rotations) + 10, bz_grid_type1, bz_grid_type1.rotations + ) np.testing.assert_equal(bzgps, ref10_bz_type1) bzgps = _get_grid_points_by_bz_rotations_py( - 12, bz_grid_type2, bz_grid_type2.rotations) + 12, bz_grid_type2, bz_grid_type2.rotations + ) np.testing.assert_equal(bzgps, ref12_bz_type2) # Exhaustive consistency check among methods @@ -275,34 +1035,54 @@ def test_get_grid_points_by_bz_rotations(si_pbesol_111): rot_grgps = bz_grid_type1.bzg2grg[ _get_grid_points_by_rotations( - bzgp_type1, bz_grid_type1, bz_grid_type1.rotations)] + bzgp_type1, bz_grid_type1, bz_grid_type1.rotations + ) + ] np.testing.assert_equal( rot_grgps, - bz_grid_type2.bzg2grg[_get_grid_points_by_rotations( - bzgp_type2, bz_grid_type2, bz_grid_type2.rotations)]) + bz_grid_type2.bzg2grg[ + _get_grid_points_by_rotations( + bzgp_type2, bz_grid_type2, bz_grid_type2.rotations + ) + ], + ) np.testing.assert_equal( _get_grid_points_by_bz_rotations_c( - bzgp_type1, bz_grid_type1, bz_grid_type1.rotations), + bzgp_type1, bz_grid_type1, bz_grid_type1.rotations + ), _get_grid_points_by_bz_rotations_py( - bzgp_type1, bz_grid_type1, bz_grid_type1.rotations)) + bzgp_type1, bz_grid_type1, bz_grid_type1.rotations + ), + ) np.testing.assert_equal( _get_grid_points_by_bz_rotations_c( - bzgp_type2, bz_grid_type2, bz_grid_type2.rotations), + bzgp_type2, bz_grid_type2, bz_grid_type2.rotations + ), _get_grid_points_by_bz_rotations_py( - bzgp_type2, bz_grid_type2, bz_grid_type2.rotations)) + bzgp_type2, bz_grid_type2, bz_grid_type2.rotations + ), + ) np.testing.assert_equal( rot_grgps, - bz_grid_type1.bzg2grg[_get_grid_points_by_bz_rotations_c( - bzgp_type1, bz_grid_type1, bz_grid_type1.rotations)]) + bz_grid_type1.bzg2grg[ + _get_grid_points_by_bz_rotations_c( + bzgp_type1, bz_grid_type1, bz_grid_type1.rotations + ) + ], + ) np.testing.assert_equal( rot_grgps, - bz_grid_type2.bzg2grg[_get_grid_points_by_bz_rotations_c( - bzgp_type2, bz_grid_type2, bz_grid_type2.rotations)]) + bz_grid_type2.bzg2grg[ + _get_grid_points_by_bz_rotations_c( + bzgp_type2, bz_grid_type2, bz_grid_type2.rotations + ) + ], + ) # for gps in bzgps.reshape(-1, 12): # print("".join(["%d, " % gp for gp in gps])) diff --git a/test/phonon3/test_displacements.py b/test/phonon3/test_displacements.py index 5682a2b9..ba109cb2 100644 --- a/test/phonon3/test_displacements.py +++ b/test/phonon3/test_displacements.py @@ -5,31 +5,95 @@ from phono3py.phonon3.displacement_fc3 import get_smallest_vector_of_atom_pair distances_NaCl = [ - 0.0000000, 5.6903015, 5.6903015, 8.0473015, 5.6903015, - 8.0473015, 8.0473015, 9.8558913, 4.0236508, 6.9691675, - 4.0236508, 6.9691675, 4.0236508, 6.9691675, 4.0236508, - 6.9691675, 4.0236508, 4.0236508, 6.9691675, 6.9691675, - 4.0236508, 4.0236508, 6.9691675, 6.9691675, 4.0236508, - 4.0236508, 4.0236508, 4.0236508, 6.9691675, 6.9691675, - 6.9691675, 6.9691675, 4.9279456, 4.9279456, 4.9279456, - 4.9279456, 4.9279456, 4.9279456, 4.9279456, 4.9279456, - 2.8451507, 2.8451507, 6.3619505, 6.3619505, 6.3619505, - 6.3619505, 8.5354522, 8.5354522, 2.8451507, 6.3619505, - 2.8451507, 6.3619505, 6.3619505, 8.5354522, 6.3619505, - 8.5354522, 2.8451507, 6.3619505, 6.3619505, 8.5354522, - 2.8451507, 6.3619505, 6.3619505, 8.5354522] + 0.0000000, + 5.6903015, + 5.6903015, + 8.0473015, + 5.6903015, + 8.0473015, + 8.0473015, + 9.8558913, + 4.0236508, + 6.9691675, + 4.0236508, + 6.9691675, + 4.0236508, + 6.9691675, + 4.0236508, + 6.9691675, + 4.0236508, + 4.0236508, + 6.9691675, + 6.9691675, + 4.0236508, + 4.0236508, + 6.9691675, + 6.9691675, + 4.0236508, + 4.0236508, + 4.0236508, + 4.0236508, + 6.9691675, + 6.9691675, + 6.9691675, + 6.9691675, + 4.9279456, + 4.9279456, + 4.9279456, + 4.9279456, + 4.9279456, + 4.9279456, + 4.9279456, + 4.9279456, + 2.8451507, + 2.8451507, + 6.3619505, + 6.3619505, + 6.3619505, + 6.3619505, + 8.5354522, + 8.5354522, + 2.8451507, + 6.3619505, + 2.8451507, + 6.3619505, + 6.3619505, + 8.5354522, + 6.3619505, + 8.5354522, + 2.8451507, + 6.3619505, + 6.3619505, + 8.5354522, + 2.8451507, + 6.3619505, + 6.3619505, + 8.5354522, +] def test_duplicates_agno2(agno2_cell): """Test duplicated pairs of displacements.""" - ph3 = phono3py.load(unitcell=agno2_cell, - supercell_matrix=[1, 1, 1]) + ph3 = phono3py.load(unitcell=agno2_cell, supercell_matrix=[1, 1, 1]) ph3.generate_displacements() duplicates_ref = [ - [106, 22], [220, 80], [252, 81], [221, 96], [253, 97], - [290, 142], [348, 244], [364, 245], [349, 276], [365, 277], - [119, 0], [261, 0], [229, 0], [260, 0], [228, 0]] - np.testing.assert_equal(duplicates_ref, ph3.dataset['duplicates']) + [106, 22], + [220, 80], + [252, 81], + [221, 96], + [253, 97], + [290, 142], + [348, 244], + [364, 245], + [349, 276], + [365, 277], + [119, 0], + [261, 0], + [229, 0], + [260, 0], + [228, 0], + ] + np.testing.assert_equal(duplicates_ref, ph3.dataset["duplicates"]) def test_nacl_pbe(nacl_pbe): @@ -37,24 +101,113 @@ def test_nacl_pbe(nacl_pbe): ph3 = nacl_pbe ph3.generate_displacements() duplicates_ref = [[77, 41]] - ph3.dataset['duplicates'] - np.testing.assert_equal(duplicates_ref, ph3.dataset['duplicates']) + ph3.dataset["duplicates"] + np.testing.assert_equal(duplicates_ref, ph3.dataset["duplicates"]) - pairs_ref = [0, 0, 0, 1, 0, 2, 0, 3, 0, 6, - 0, 7, 0, 8, 0, 9, 0, 16, 0, 17, - 0, 18, 0, 19, 0, 32, 0, 33, 0, 40, - 0, 41, 0, 42, 0, 43, 0, 46, 0, 47, - 0, 48, 0, 49, 0, 52, 0, 53, 32, 0, - 32, 1, 32, 8, 32, 9, 32, 10, 32, 11, - 32, 14, 32, 15, 32, 16, 32, 17, 32, 20, - 32, 21, 32, 32, 32, 33, 32, 34, 32, 35, - 32, 38, 32, 39, 32, 40, 32, 41, 32, 48, - 32, 49, 32, 50, 32, 51] + pairs_ref = [ + 0, + 0, + 0, + 1, + 0, + 2, + 0, + 3, + 0, + 6, + 0, + 7, + 0, + 8, + 0, + 9, + 0, + 16, + 0, + 17, + 0, + 18, + 0, + 19, + 0, + 32, + 0, + 33, + 0, + 40, + 0, + 41, + 0, + 42, + 0, + 43, + 0, + 46, + 0, + 47, + 0, + 48, + 0, + 49, + 0, + 52, + 0, + 53, + 32, + 0, + 32, + 1, + 32, + 8, + 32, + 9, + 32, + 10, + 32, + 11, + 32, + 14, + 32, + 15, + 32, + 16, + 32, + 17, + 32, + 20, + 32, + 21, + 32, + 32, + 32, + 33, + 32, + 34, + 32, + 35, + 32, + 38, + 32, + 39, + 32, + 40, + 32, + 41, + 32, + 48, + 32, + 49, + 32, + 50, + 32, + 51, + ] pairs = [] - for first_atoms in ph3.dataset['first_atoms']: - n1 = first_atoms['number'] - n2s = np.unique([second_atoms['number'] - for second_atoms in first_atoms['second_atoms']]) + for first_atoms in ph3.dataset["first_atoms"]: + n1 = first_atoms["number"] + n2s = np.unique( + [second_atoms["number"] for second_atoms in first_atoms["second_atoms"]] + ) pairs += [[n1, n2] for n2 in n2s] # print("".join(["%d, " % i for i in np.array(pairs).ravel()])) @@ -66,8 +219,7 @@ def test_get_smallest_vector_of_atom_pair(nacl_pbe): ph3 = nacl_pbe distances = [] for i in range(len(ph3.supercell)): - vec = get_smallest_vector_of_atom_pair( - i, 0, ph3.supercell, 1e-5) + vec = get_smallest_vector_of_atom_pair(i, 0, ph3.supercell, 1e-5) if vec.ndim == 2: vec = vec[0] distances.append(np.linalg.norm(np.dot(vec, ph3.supercell.cell))) diff --git a/test/phonon3/test_fc3.py b/test/phonon3/test_fc3.py index 69815575..ecac88a8 100644 --- a/test/phonon3/test_fc3.py +++ b/test/phonon3/test_fc3.py @@ -1,8 +1,10 @@ +"""Tests for fc3.""" import numpy as np from phono3py.phonon3.fc3 import cutoff_fc3_by_zero def test_cutoff_fc3(nacl_pbe_cutoff_fc3, nacl_pbe): + """Test for cutoff pair option.""" fc3_cut = nacl_pbe_cutoff_fc3.fc3 fc3 = nacl_pbe.fc3 abs_delta = np.abs(fc3_cut - fc3).sum() @@ -10,6 +12,7 @@ def test_cutoff_fc3(nacl_pbe_cutoff_fc3, nacl_pbe): def test_cutoff_fc3_zero(nacl_pbe): + """Test for abrupt cut of fc3 by distance.""" ph = nacl_pbe fc3 = ph.fc3.copy() cutoff_fc3_by_zero(fc3, ph.supercell, 5) diff --git a/test/phonon3/test_imag_self_energy.py b/test/phonon3/test_imag_self_energy.py index f5e73141..d691e8ce 100644 --- a/test/phonon3/test_imag_self_energy.py +++ b/test/phonon3/test_imag_self_energy.py @@ -1,138 +1,740 @@ """Test for imag_free_energy.py.""" -import pytest import numpy as np gammas = [ - 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, - 0.0005412, 0.0005412, 0.0008843, 0.0191694, 0.0206316, 0.0206316, - 0.0019424, 0.0019424, 0.0067566, 0.0548967, 0.0506115, 0.0506115, - 0.0062204, 0.0062204, 0.0088148, 0.0426150, 0.0417223, 0.0417223, - 0.0016263, 0.0016263, 0.0017293, 0.0279509, 0.0289259, 0.0289259, - 0.0097926, 0.0097926, 0.0170092, 0.0438828, 0.0523105, 0.0523105, - 0.0035542, 0.0035542, 0.0135109, 0.0623533, 0.0343746, 0.0343746, - 0.0073140, 0.0073140, 0.0289659, 0.5006760, 0.5077932, 0.5077932, - 0.0016144, 0.0016144, 0.0126326, 0.2731933, 0.2791702, 0.2791702, - 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, - 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, - 0.0023304, 0.0026469, 0.0052513, 0.0209641, 0.0220092, 0.0234752, - 0.0035532, 0.0038158, 0.0087882, 0.0276654, 0.0315055, 0.0286975, - 0.0345193, 0.0277533, 0.0495734, 0.0511798, 0.0465938, 0.0436605, - 0.0071705, 0.0081615, 0.0139063, 0.0204058, 0.0307320, 0.0237855, - 0.0202095, 0.0197716, 0.0316074, 0.0402461, 0.0438103, 0.0394924, - 0.0171448, 0.0176446, 0.0567310, 0.0930479, 0.0570520, 0.0622142, - 0.0292639, 0.0328821, 0.0667957, 0.2541887, 0.4592188, 0.4234131, - 0.0104887, 0.0179753, 0.0827533, 0.2659557, 0.3242633, 0.3189804, - 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000] + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0005412, + 0.0005412, + 0.0008843, + 0.0191694, + 0.0206316, + 0.0206316, + 0.0019424, + 0.0019424, + 0.0067566, + 0.0548967, + 0.0506115, + 0.0506115, + 0.0062204, + 0.0062204, + 0.0088148, + 0.0426150, + 0.0417223, + 0.0417223, + 0.0016263, + 0.0016263, + 0.0017293, + 0.0279509, + 0.0289259, + 0.0289259, + 0.0097926, + 0.0097926, + 0.0170092, + 0.0438828, + 0.0523105, + 0.0523105, + 0.0035542, + 0.0035542, + 0.0135109, + 0.0623533, + 0.0343746, + 0.0343746, + 0.0073140, + 0.0073140, + 0.0289659, + 0.5006760, + 0.5077932, + 0.5077932, + 0.0016144, + 0.0016144, + 0.0126326, + 0.2731933, + 0.2791702, + 0.2791702, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0023304, + 0.0026469, + 0.0052513, + 0.0209641, + 0.0220092, + 0.0234752, + 0.0035532, + 0.0038158, + 0.0087882, + 0.0276654, + 0.0315055, + 0.0286975, + 0.0345193, + 0.0277533, + 0.0495734, + 0.0511798, + 0.0465938, + 0.0436605, + 0.0071705, + 0.0081615, + 0.0139063, + 0.0204058, + 0.0307320, + 0.0237855, + 0.0202095, + 0.0197716, + 0.0316074, + 0.0402461, + 0.0438103, + 0.0394924, + 0.0171448, + 0.0176446, + 0.0567310, + 0.0930479, + 0.0570520, + 0.0622142, + 0.0292639, + 0.0328821, + 0.0667957, + 0.2541887, + 0.4592188, + 0.4234131, + 0.0104887, + 0.0179753, + 0.0827533, + 0.2659557, + 0.3242633, + 0.3189804, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, +] gammas_sigma = [ - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00046029, 0.00046029, 0.00071545, 0.02242054, 0.01975435, 0.01975435, - 0.00143860, 0.00143860, 0.00715263, 0.05481156, 0.04396936, 0.04396936, - 0.00826301, 0.00826301, 0.00950813, 0.04304817, 0.04400210, 0.04400210, - 0.00203560, 0.00203560, 0.00207048, 0.02226551, 0.03531839, 0.03531839, - 0.00746195, 0.00746195, 0.01268396, 0.02380441, 0.03074892, 0.03074892, - 0.00389360, 0.00389360, 0.01154058, 0.05602348, 0.04034627, 0.04034627, - 0.00642767, 0.00642767, 0.02338437, 0.43710790, 0.48306584, 0.48306584, - 0.00291728, 0.00291728, 0.11718631, 0.84620157, 0.80881708, 0.80881708, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00224835, 0.00288498, 0.00554574, 0.02261273, 0.02349047, 0.02647988, - 0.00330612, 0.00430468, 0.00975355, 0.02954525, 0.03242621, 0.03052183, - 0.03210358, 0.02583317, 0.04906091, 0.04609366, 0.04064508, 0.04250035, - 0.00888799, 0.00936948, 0.01541312, 0.02079095, 0.03001210, 0.02721119, - 0.02593986, 0.02559304, 0.04760672, 0.04958274, 0.04942973, 0.03703768, - 0.01005313, 0.01125217, 0.05423798, 0.10135670, 0.06021902, 0.09005459, - 0.02358822, 0.03737522, 0.06633807, 0.22190369, 0.41562743, 0.32601504, - 0.01240071, 0.02372173, 0.20217767, 0.49239981, 0.52883866, 0.50769018, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000] + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00046029, + 0.00046029, + 0.00071545, + 0.02242054, + 0.01975435, + 0.01975435, + 0.00143860, + 0.00143860, + 0.00715263, + 0.05481156, + 0.04396936, + 0.04396936, + 0.00826301, + 0.00826301, + 0.00950813, + 0.04304817, + 0.04400210, + 0.04400210, + 0.00203560, + 0.00203560, + 0.00207048, + 0.02226551, + 0.03531839, + 0.03531839, + 0.00746195, + 0.00746195, + 0.01268396, + 0.02380441, + 0.03074892, + 0.03074892, + 0.00389360, + 0.00389360, + 0.01154058, + 0.05602348, + 0.04034627, + 0.04034627, + 0.00642767, + 0.00642767, + 0.02338437, + 0.43710790, + 0.48306584, + 0.48306584, + 0.00291728, + 0.00291728, + 0.11718631, + 0.84620157, + 0.80881708, + 0.80881708, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00224835, + 0.00288498, + 0.00554574, + 0.02261273, + 0.02349047, + 0.02647988, + 0.00330612, + 0.00430468, + 0.00975355, + 0.02954525, + 0.03242621, + 0.03052183, + 0.03210358, + 0.02583317, + 0.04906091, + 0.04609366, + 0.04064508, + 0.04250035, + 0.00888799, + 0.00936948, + 0.01541312, + 0.02079095, + 0.03001210, + 0.02721119, + 0.02593986, + 0.02559304, + 0.04760672, + 0.04958274, + 0.04942973, + 0.03703768, + 0.01005313, + 0.01125217, + 0.05423798, + 0.10135670, + 0.06021902, + 0.09005459, + 0.02358822, + 0.03737522, + 0.06633807, + 0.22190369, + 0.41562743, + 0.32601504, + 0.01240071, + 0.02372173, + 0.20217767, + 0.49239981, + 0.52883866, + 0.50769018, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, +] gammas_class1 = [ - 0.00000000, 0.00000000, 0.00000000, -0.00000000, 0.00000000, 0.00000000, - 0.00053387, 0.00053387, 0.00086230, 0.01894313, 0.02034210, 0.02034210, - 0.00155506, 0.00155506, 0.00260125, 0.01821681, 0.01820381, 0.01820381, - 0.00571765, 0.00571765, 0.00544460, 0.01325570, 0.01118428, 0.01118428, - 0.00016153, 0.00016153, 0.00032679, 0.00020002, 0.00020927, 0.00020927, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00233036, 0.00264690, 0.00525130, 0.02096414, 0.02200915, 0.02347515, - 0.00297698, 0.00348529, 0.00638118, 0.01776255, 0.02740917, 0.02217207, - 0.03234423, 0.02580162, 0.03682891, 0.03904463, 0.01942315, 0.02072384, - 0.00004097, 0.00005101, 0.00007457, 0.00003508, 0.00004210, 0.00003803, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000] + 0.00000000, + 0.00000000, + 0.00000000, + -0.00000000, + 0.00000000, + 0.00000000, + 0.00053387, + 0.00053387, + 0.00086230, + 0.01894313, + 0.02034210, + 0.02034210, + 0.00155506, + 0.00155506, + 0.00260125, + 0.01821681, + 0.01820381, + 0.01820381, + 0.00571765, + 0.00571765, + 0.00544460, + 0.01325570, + 0.01118428, + 0.01118428, + 0.00016153, + 0.00016153, + 0.00032679, + 0.00020002, + 0.00020927, + 0.00020927, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00233036, + 0.00264690, + 0.00525130, + 0.02096414, + 0.02200915, + 0.02347515, + 0.00297698, + 0.00348529, + 0.00638118, + 0.01776255, + 0.02740917, + 0.02217207, + 0.03234423, + 0.02580162, + 0.03682891, + 0.03904463, + 0.01942315, + 0.02072384, + 0.00004097, + 0.00005101, + 0.00007457, + 0.00003508, + 0.00004210, + 0.00003803, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, +] gammas_class2 = [ - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00000728, 0.00000728, 0.00002201, 0.00022624, 0.00028946, 0.00028946, - 0.00038736, 0.00038736, 0.00415534, 0.03667993, 0.03240766, 0.03240766, - 0.00050274, 0.00050274, 0.00337024, 0.02935928, 0.03053801, 0.03053801, - 0.00146473, 0.00146473, 0.00140248, 0.02775086, 0.02871662, 0.02871662, - 0.00979262, 0.00979262, 0.01700920, 0.04388280, 0.05231049, 0.05231049, - 0.00355424, 0.00355424, 0.01351094, 0.06235333, 0.03437465, 0.03437465, - 0.00731397, 0.00731397, 0.02896588, 0.50067605, 0.50779324, 0.50779324, - 0.00161440, 0.00161440, 0.01263256, 0.27319333, 0.27917018, 0.27917018, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00057618, 0.00033051, 0.00240702, 0.00990280, 0.00409632, 0.00652547, - 0.00217505, 0.00195163, 0.01274449, 0.01213516, 0.02717067, 0.02293662, - 0.00712953, 0.00811051, 0.01383178, 0.02037067, 0.03068992, 0.02374747, - 0.02020952, 0.01977157, 0.03160744, 0.04024612, 0.04381027, 0.03949241, - 0.01714475, 0.01764459, 0.05673104, 0.09304789, 0.05705200, 0.06221421, - 0.02926385, 0.03288210, 0.06679574, 0.25418868, 0.45921877, 0.42341309, - 0.01048868, 0.01797532, 0.08275328, 0.26595568, 0.32426329, 0.31898043, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000] -freq_points = [0.0, 3.41024688, 6.82049376, 10.23074063, 13.64098751, - 17.05123439, 20.46148127, 23.87172814, 27.28197502, 30.6922219] + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000728, + 0.00000728, + 0.00002201, + 0.00022624, + 0.00028946, + 0.00028946, + 0.00038736, + 0.00038736, + 0.00415534, + 0.03667993, + 0.03240766, + 0.03240766, + 0.00050274, + 0.00050274, + 0.00337024, + 0.02935928, + 0.03053801, + 0.03053801, + 0.00146473, + 0.00146473, + 0.00140248, + 0.02775086, + 0.02871662, + 0.02871662, + 0.00979262, + 0.00979262, + 0.01700920, + 0.04388280, + 0.05231049, + 0.05231049, + 0.00355424, + 0.00355424, + 0.01351094, + 0.06235333, + 0.03437465, + 0.03437465, + 0.00731397, + 0.00731397, + 0.02896588, + 0.50067605, + 0.50779324, + 0.50779324, + 0.00161440, + 0.00161440, + 0.01263256, + 0.27319333, + 0.27917018, + 0.27917018, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00057618, + 0.00033051, + 0.00240702, + 0.00990280, + 0.00409632, + 0.00652547, + 0.00217505, + 0.00195163, + 0.01274449, + 0.01213516, + 0.02717067, + 0.02293662, + 0.00712953, + 0.00811051, + 0.01383178, + 0.02037067, + 0.03068992, + 0.02374747, + 0.02020952, + 0.01977157, + 0.03160744, + 0.04024612, + 0.04381027, + 0.03949241, + 0.01714475, + 0.01764459, + 0.05673104, + 0.09304789, + 0.05705200, + 0.06221421, + 0.02926385, + 0.03288210, + 0.06679574, + 0.25418868, + 0.45921877, + 0.42341309, + 0.01048868, + 0.01797532, + 0.08275328, + 0.26595568, + 0.32426329, + 0.31898043, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, +] +freq_points = [ + 0.0, + 3.41024688, + 6.82049376, + 10.23074063, + 13.64098751, + 17.05123439, + 20.46148127, + 23.87172814, + 27.28197502, + 30.6922219, +] freq_points_sigma = [ - 0.0, 3.45491354, 6.90982709, 10.36474063, 13.81965418, - 17.27456772, 20.72948127, 24.18439481, 27.63930835, 31.09422190] + 0.0, + 3.45491354, + 6.90982709, + 10.36474063, + 13.81965418, + 17.27456772, + 20.72948127, + 24.18439481, + 27.63930835, + 31.09422190, +] -detailed_gamma = [0.00000000, 0.00653193, 0.02492913, 0.01682092, 0.01001680, - 0.02181888, 0.01858641, 0.16208762, 0.09598706, 0.00000000] +detailed_gamma = [ + 0.00000000, + 0.00653193, + 0.02492913, + 0.01682092, + 0.01001680, + 0.02181888, + 0.01858641, + 0.16208762, + 0.09598706, + 0.00000000, +] gammas_nacl = [ - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.03396688, 0.03396688, 0.00687452, 0.21001764, 0.21001764, 0.12310439, - 0.00297385, 0.00297385, 0.00227915, 0.10673763, 0.10673763, 0.06918881, - 0.01003326, 0.01003326, 0.00996780, 0.03414868, 0.03414868, 0.02258494, - 0.04027592, 0.04027592, 0.03603612, 0.57995646, 0.57995646, 0.39737731, - 0.12705253, 0.12705253, 0.09246595, 0.88750309, 0.88750309, 0.60334780, - 0.29968747, 0.29968747, 0.14257862, 0.22134950, 0.22134950, 0.09606896, - 0.03941985, 0.03941985, 0.01632766, 0.00222574, 0.00222574, 0.00627294, - 0.00240808, 0.00240808, 0.00688951, 0.00008074, 0.00008074, 0.00003641, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.02850846, 0.09000833, 0.19582553, 0.13715943, 0.19892888, 0.14203618, - 0.00861856, 0.02747203, 0.05000735, 0.04441740, 0.11080545, 0.04172184, - 0.00738182, 0.01722875, 0.03273830, 0.04517923, 0.02441539, 0.03277688, - 0.03233818, 0.08459289, 0.19264167, 0.11281266, 0.45667245, 0.18491212, - 0.10846241, 0.47768641, 1.04554356, 0.64678566, 0.83834225, 0.61795504, - 0.19485590, 0.43708391, 0.24896003, 0.35882984, 0.30654914, 0.22471014, - 0.03624311, 0.13350831, 0.12479592, 0.06750776, 0.02503182, 0.04543786, - 0.00155614, 0.01088453, 0.00064712, 0.00392933, 0.00058749, 0.00022448, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000] + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.03396688, + 0.03396688, + 0.00687452, + 0.21001764, + 0.21001764, + 0.12310439, + 0.00297385, + 0.00297385, + 0.00227915, + 0.10673763, + 0.10673763, + 0.06918881, + 0.01003326, + 0.01003326, + 0.00996780, + 0.03414868, + 0.03414868, + 0.02258494, + 0.04027592, + 0.04027592, + 0.03603612, + 0.57995646, + 0.57995646, + 0.39737731, + 0.12705253, + 0.12705253, + 0.09246595, + 0.88750309, + 0.88750309, + 0.60334780, + 0.29968747, + 0.29968747, + 0.14257862, + 0.22134950, + 0.22134950, + 0.09606896, + 0.03941985, + 0.03941985, + 0.01632766, + 0.00222574, + 0.00222574, + 0.00627294, + 0.00240808, + 0.00240808, + 0.00688951, + 0.00008074, + 0.00008074, + 0.00003641, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.02850846, + 0.09000833, + 0.19582553, + 0.13715943, + 0.19892888, + 0.14203618, + 0.00861856, + 0.02747203, + 0.05000735, + 0.04441740, + 0.11080545, + 0.04172184, + 0.00738182, + 0.01722875, + 0.03273830, + 0.04517923, + 0.02441539, + 0.03277688, + 0.03233818, + 0.08459289, + 0.19264167, + 0.11281266, + 0.45667245, + 0.18491212, + 0.10846241, + 0.47768641, + 1.04554356, + 0.64678566, + 0.83834225, + 0.61795504, + 0.19485590, + 0.43708391, + 0.24896003, + 0.35882984, + 0.30654914, + 0.22471014, + 0.03624311, + 0.13350831, + 0.12479592, + 0.06750776, + 0.02503182, + 0.04543786, + 0.00155614, + 0.01088453, + 0.00064712, + 0.00392933, + 0.00058749, + 0.00022448, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, +] freq_points_nacl = [ - 0.0, 1.63223063, 3.26446125, 4.89669188, 6.5289225, - 8.16115313, 9.79338375, 11.42561438, 13.057845, 14.69007563] + 0.0, + 1.63223063, + 3.26446125, + 4.89669188, + 6.5289225, + 8.16115313, + 9.79338375, + 11.42561438, + 13.057845, + 14.69007563, +] gammas_nacl_nac = [ - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00000000, 0.00000000, 0.00000000, 0.20104463, 0.20104463, 0.12311129, - 0.00000000, 0.00000000, 0.00000000, 0.10448465, 0.10448465, 0.06445738, - 0.00000000, 0.00000000, 0.00000000, 0.03814089, 0.03814089, 0.02351398, - 0.00000000, 0.00000000, 0.00000000, 0.79562828, 0.79562828, 0.49265042, - 0.00000000, 0.00000000, 0.00000000, 0.71487838, 0.71487838, 0.44811019, - 0.00000000, 0.00000000, 0.00000000, 0.29194862, 0.29194862, 0.18098946, - 0.00000000, 0.00000000, 0.00000000, 0.00006218, 0.00006218, 0.00004024, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000] + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.20104463, + 0.20104463, + 0.12311129, + 0.00000000, + 0.00000000, + 0.00000000, + 0.10448465, + 0.10448465, + 0.06445738, + 0.00000000, + 0.00000000, + 0.00000000, + 0.03814089, + 0.03814089, + 0.02351398, + 0.00000000, + 0.00000000, + 0.00000000, + 0.79562828, + 0.79562828, + 0.49265042, + 0.00000000, + 0.00000000, + 0.00000000, + 0.71487838, + 0.71487838, + 0.44811019, + 0.00000000, + 0.00000000, + 0.00000000, + 0.29194862, + 0.29194862, + 0.18098946, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00006218, + 0.00006218, + 0.00004024, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, +] freq_points_nacl_nac = [ - 0.0, 1.65531064, 3.31062129, 4.96593193, 6.62124257, 8.27655322, - 9.93186386, 11.58717451, 13.24248515, 14.89779579] + 0.0, + 1.65531064, + 3.31062129, + 4.96593193, + 6.62124257, + 8.27655322, + 9.93186386, + 11.58717451, + 13.24248515, + 14.89779579, +] def test_imag_self_energy_at_bands(si_pbesol): @@ -143,17 +745,33 @@ def test_imag_self_energy_at_bands(si_pbesol): """ si_pbesol.mesh_numbers = [9, 9, 9] si_pbesol.init_phph_interaction() - gammas_ref = np.reshape([ - 0.00021553, 0.00021553, 0.00084329, - 0.04693498, 0.04388354, 0.04388354, - 0.00383646, 0.00494357, 0.02741665, - 0.01407101, 0.04133322, 0.03013125], - (2, -1)) + gammas_ref = np.reshape( + [ + 0.00021553, + 0.00021553, + 0.00084329, + 0.04693498, + 0.04388354, + 0.04388354, + 0.00383646, + 0.00494357, + 0.02741665, + 0.01407101, + 0.04133322, + 0.03013125, + ], + (2, -1), + ) for i, grgp in enumerate((1, 103)): _fpoints, _gammas = si_pbesol.run_imag_self_energy( - [si_pbesol.grid.grg2bzg[grgp], ], - [300, ], - frequency_points_at_bands=True) + [ + si_pbesol.grid.grg2bzg[grgp], + ], + [ + 300, + ], + frequency_points_at_bands=True, + ) np.testing.assert_allclose(_gammas.ravel(), gammas_ref[i], atol=1e-2) @@ -168,27 +786,110 @@ def test_imag_self_energy_at_bands_detailed(si_pbesol): si_pbesol.init_phph_interaction() _fpoints, _gammas, _detailed_gammas = si_pbesol.run_imag_self_energy( si_pbesol.grid.grg2bzg[[1, 103]], - [300, ], + [ + 300, + ], frequency_points_at_bands=True, - keep_gamma_detail=True) + keep_gamma_detail=True, + ) - weights_1 = [2, 2, 2, 2, 1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 12, 12, 12, 12, 6, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 6, 12, 12, 12, 12, 12, 12, 12, - 12, 6, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 6] - weights_103 = [2, ] * 364 + [1, ] + weights_1 = [ + 2, + 2, + 2, + 2, + 1, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 12, + 12, + 12, + 12, + 6, + 12, + 12, + 12, + 12, + 12, + 12, + 12, + 12, + 12, + 12, + 12, + 12, + 12, + 12, + 12, + 12, + 12, + 12, + 6, + 12, + 12, + 12, + 12, + 12, + 12, + 12, + 12, + 6, + 12, + 12, + 12, + 12, + 12, + 12, + 12, + 12, + 12, + 12, + 6, + ] + weights_103 = [2] * 364 + [1] gammas_1_ref = _gammas[:, :, 0].ravel() gammas_103_ref = _gammas[:, :, 1].ravel() - gammas_1 = np.dot(weights_1, - _detailed_gammas[0][0, 0].sum(axis=-1).sum(axis=-1)) - gammas_103 = np.dot(weights_103, - _detailed_gammas[1][0, 0].sum(axis=-1).sum(axis=-1)) - np.testing.assert_allclose(gammas_1[:2].sum(), gammas_1_ref[:2].sum(), - atol=1e-2) - np.testing.assert_allclose(gammas_1[-2:].sum(), gammas_1_ref[-2:].sum(), - atol=1e-2) + gammas_1 = np.dot(weights_1, _detailed_gammas[0][0, 0].sum(axis=-1).sum(axis=-1)) + gammas_103 = np.dot( + weights_103, _detailed_gammas[1][0, 0].sum(axis=-1).sum(axis=-1) + ) + np.testing.assert_allclose(gammas_1[:2].sum(), gammas_1_ref[:2].sum(), atol=1e-2) + np.testing.assert_allclose(gammas_1[-2:].sum(), gammas_1_ref[-2:].sum(), atol=1e-2) np.testing.assert_allclose(gammas_1[2:4], gammas_1_ref[2:4], atol=1e-2) np.testing.assert_allclose(gammas_103, gammas_103_ref, atol=1e-2) @@ -203,12 +904,13 @@ def test_imag_self_energy_npoints(si_pbesol): si_pbesol.init_phph_interaction() _fpoints, _gammas = si_pbesol.run_imag_self_energy( si_pbesol.grid.grg2bzg[[1, 103]], - [300, ], - num_frequency_points=10) - np.testing.assert_allclose( - gammas, np.swapaxes(_gammas, -1, -2).ravel(), atol=1e-2) - np.testing.assert_allclose( - freq_points, _fpoints.ravel(), atol=1e-5) + [ + 300, + ], + num_frequency_points=10, + ) + np.testing.assert_allclose(gammas, np.swapaxes(_gammas, -1, -2).ravel(), atol=1e-2) + np.testing.assert_allclose(freq_points, _fpoints.ravel(), atol=1e-5) def test_imag_self_energy_npoints_with_sigma(si_pbesol): @@ -218,20 +920,25 @@ def test_imag_self_energy_npoints_with_sigma(si_pbesol): * with smearing method """ - si_pbesol.sigmas = [0.1, ] + si_pbesol.sigmas = [ + 0.1, + ] si_pbesol.mesh_numbers = [9, 9, 9] si_pbesol.init_phph_interaction() _fpoints, _gammas = si_pbesol.run_imag_self_energy( si_pbesol.grid.grg2bzg[[1, 103]], - [300, ], - num_frequency_points=10) + [ + 300, + ], + num_frequency_points=10, + ) # for _g_line in np.swapaxes(_gammas, -1, -2).reshape(-1, 6): # print("".join(["%.8f, " % g for g in _g_line])) # print("".join(["%.8f, " % f for f in _fpoints])) np.testing.assert_allclose( - gammas_sigma, np.swapaxes(_gammas, -1, -2).ravel(), atol=1e-2) - np.testing.assert_allclose( - freq_points_sigma, _fpoints.ravel(), atol=1e-5) + gammas_sigma, np.swapaxes(_gammas, -1, -2).ravel(), atol=1e-2 + ) + np.testing.assert_allclose(freq_points_sigma, _fpoints.ravel(), atol=1e-5) si_pbesol.sigmas = None @@ -245,12 +952,13 @@ def test_imag_self_energy_freq_points(si_pbesol): si_pbesol.init_phph_interaction() _fpoints, _gammas = si_pbesol.run_imag_self_energy( si_pbesol.grid.grg2bzg[[1, 103]], - [300, ], - frequency_points=freq_points) - np.testing.assert_allclose( - gammas, np.swapaxes(_gammas, -1, -2).ravel(), atol=1e-2) - np.testing.assert_allclose( - freq_points, _fpoints.ravel(), atol=1e-5) + [ + 300, + ], + frequency_points=freq_points, + ) + np.testing.assert_allclose(gammas, np.swapaxes(_gammas, -1, -2).ravel(), atol=1e-2) + np.testing.assert_allclose(freq_points, _fpoints.ravel(), atol=1e-5) def test_imag_self_energy_detailed(si_pbesol): @@ -263,14 +971,20 @@ def test_imag_self_energy_detailed(si_pbesol): si_pbesol.mesh_numbers = [9, 9, 9] si_pbesol.init_phph_interaction() _fpoints, _gammas, _detailed_gammas = si_pbesol.run_imag_self_energy( - si_pbesol.grid.grg2bzg[[1, ]], - [300, ], + si_pbesol.grid.grg2bzg[ + [ + 1, + ] + ], + [ + 300, + ], frequency_points=freq_points, - keep_gamma_detail=True) + keep_gamma_detail=True, + ) np.testing.assert_allclose( - detailed_gamma, - _detailed_gammas[0][0, 0].sum(axis=(1, 2, 3, 4)), - atol=1e-2) + detailed_gamma, _detailed_gammas[0][0, 0].sum(axis=(1, 2, 3, 4)), atol=1e-2 + ) def test_imag_self_energy_scat_class1(si_pbesol): @@ -284,13 +998,17 @@ def test_imag_self_energy_scat_class1(si_pbesol): si_pbesol.init_phph_interaction() _fpoints, _gammas = si_pbesol.run_imag_self_energy( si_pbesol.grid.grg2bzg[[1, 103]], - [300, ], + [ + 300, + ], frequency_points=freq_points, - scattering_event_class=1) + scattering_event_class=1, + ) # for line in si_pbesol.gammas.reshape(-1, 6): # print(("%10.8f, " * 6) % tuple(line)) np.testing.assert_allclose( - gammas_class1, np.swapaxes(_gammas, -1, -2).ravel(), atol=1e-2) + gammas_class1, np.swapaxes(_gammas, -1, -2).ravel(), atol=1e-2 + ) def test_imag_self_energy_scat_class2(si_pbesol): @@ -304,13 +1022,17 @@ def test_imag_self_energy_scat_class2(si_pbesol): si_pbesol.init_phph_interaction() _fpoints, _gammas = si_pbesol.run_imag_self_energy( si_pbesol.grid.grg2bzg[[1, 103]], - [300, ], + [ + 300, + ], frequency_points=freq_points, - scattering_event_class=2) + scattering_event_class=2, + ) # for line in si_pbesol.gammas.reshape(-1, 6): # print(("%10.8f, " * 6) % tuple(line)) np.testing.assert_allclose( - gammas_class2, np.swapaxes(_gammas, -1, -2).ravel(), atol=1e-2) + gammas_class2, np.swapaxes(_gammas, -1, -2).ravel(), atol=1e-2 + ) def test_imag_self_energy_nacl_npoints(nacl_pbe): @@ -323,15 +1045,18 @@ def test_imag_self_energy_nacl_npoints(nacl_pbe): nacl_pbe.init_phph_interaction() _fpoints, _gammas = nacl_pbe.run_imag_self_energy( nacl_pbe.grid.grg2bzg[[1, 103]], - [300, ], - num_frequency_points=10) + [ + 300, + ], + num_frequency_points=10, + ) # for line in np.swapaxes(_gammas, -1, -2).ravel().reshape(-1, 6): # print(("%10.8f, " * 6) % tuple(line)) # print(_fpoints.ravel()) np.testing.assert_allclose( - gammas_nacl, np.swapaxes(_gammas, -1, -2).ravel(), atol=1e-2) - np.testing.assert_allclose( - freq_points_nacl, _fpoints.ravel(), atol=1e-5) + gammas_nacl, np.swapaxes(_gammas, -1, -2).ravel(), atol=1e-2 + ) + np.testing.assert_allclose(freq_points_nacl, _fpoints.ravel(), atol=1e-5) def test_imag_self_energy_nacl_nac_npoints(nacl_pbe): @@ -344,13 +1069,20 @@ def test_imag_self_energy_nacl_nac_npoints(nacl_pbe): nacl_pbe.mesh_numbers = [9, 9, 9] nacl_pbe.init_phph_interaction(nac_q_direction=[1, 0, 0]) _fpoints, _gammas = nacl_pbe.run_imag_self_energy( - nacl_pbe.grid.grg2bzg[[0, ]], - [300, ], - num_frequency_points=10) + nacl_pbe.grid.grg2bzg[ + [ + 0, + ] + ], + [ + 300, + ], + num_frequency_points=10, + ) # for line in np.swapaxes(_gammas, -1, -2).ravel().reshape(-1, 6): # print(("%10.8f, " * 6) % tuple(line)) # print(_fpoints.ravel()) np.testing.assert_allclose( - gammas_nacl_nac, np.swapaxes(_gammas, -1, -2).ravel(), atol=1e-2) - np.testing.assert_allclose( - freq_points_nacl_nac, _fpoints.ravel(), atol=1e-5) + gammas_nacl_nac, np.swapaxes(_gammas, -1, -2).ravel(), atol=1e-2 + ) + np.testing.assert_allclose(freq_points_nacl_nac, _fpoints.ravel(), atol=1e-5) diff --git a/test/phonon3/test_interaction.py b/test/phonon3/test_interaction.py index 409f7423..9819d796 100644 --- a/test/phonon3/test_interaction.py +++ b/test/phonon3/test_interaction.py @@ -4,23 +4,84 @@ import numpy as np from phono3py.phonon3.interaction import Interaction itr_RTA_Si = [ - 4.522052e-08, 4.896362e-08, 4.614211e-08, 4.744361e-08, 4.832248e-08, - 4.698535e-08, 4.597876e-08, 4.645423e-08, 4.659572e-08, 4.730222e-08] + 4.522052e-08, + 4.896362e-08, + 4.614211e-08, + 4.744361e-08, + 4.832248e-08, + 4.698535e-08, + 4.597876e-08, + 4.645423e-08, + 4.659572e-08, + 4.730222e-08, +] itr_RTA_AlN = [ - 7.456796e-08, 7.242121e-08, 7.068141e-08, 7.059521e-08, 7.289497e-08, - 7.127172e-08, 7.082734e-08, 7.394367e-08, 7.084351e-08, 7.083299e-08, - 7.085792e-08, 7.124150e-08, 7.048386e-08, 7.062840e-08, 7.036795e-08, - 7.043995e-08, 7.366440e-08, 7.136803e-08, 6.988469e-08, 6.989518e-08, - 7.179516e-08, 7.038043e-08, 7.011416e-08, 7.278196e-08, 6.999028e-08, - 7.009615e-08, 7.018236e-08, 7.025054e-08, 6.977425e-08, 6.993095e-08, - 6.962119e-08, 6.964423e-08, 7.121739e-08, 6.939940e-08, 6.834705e-08, - 6.847351e-08, 6.977063e-08, 6.872065e-08, 6.863218e-08, 7.055696e-08, - 6.836064e-08, 6.854052e-08, 6.864199e-08, 6.849059e-08, 6.826958e-08, - 6.837379e-08, 6.808307e-08, 6.804480e-08, 6.961289e-08, 6.816170e-08, - 6.730028e-08, 6.746055e-08, 6.851460e-08, 6.764892e-08, 6.754060e-08, - 6.913662e-08, 6.729303e-08, 6.736722e-08, 6.734663e-08, 6.743441e-08, - 6.713107e-08, 6.710084e-08, 6.698233e-08, 6.694871e-08] + 7.456796e-08, + 7.242121e-08, + 7.068141e-08, + 7.059521e-08, + 7.289497e-08, + 7.127172e-08, + 7.082734e-08, + 7.394367e-08, + 7.084351e-08, + 7.083299e-08, + 7.085792e-08, + 7.124150e-08, + 7.048386e-08, + 7.062840e-08, + 7.036795e-08, + 7.043995e-08, + 7.366440e-08, + 7.136803e-08, + 6.988469e-08, + 6.989518e-08, + 7.179516e-08, + 7.038043e-08, + 7.011416e-08, + 7.278196e-08, + 6.999028e-08, + 7.009615e-08, + 7.018236e-08, + 7.025054e-08, + 6.977425e-08, + 6.993095e-08, + 6.962119e-08, + 6.964423e-08, + 7.121739e-08, + 6.939940e-08, + 6.834705e-08, + 6.847351e-08, + 6.977063e-08, + 6.872065e-08, + 6.863218e-08, + 7.055696e-08, + 6.836064e-08, + 6.854052e-08, + 6.864199e-08, + 6.849059e-08, + 6.826958e-08, + 6.837379e-08, + 6.808307e-08, + 6.804480e-08, + 6.961289e-08, + 6.816170e-08, + 6.730028e-08, + 6.746055e-08, + 6.851460e-08, + 6.764892e-08, + 6.754060e-08, + 6.913662e-08, + 6.729303e-08, + 6.736722e-08, + 6.734663e-08, + 6.743441e-08, + 6.713107e-08, + 6.710084e-08, + 6.698233e-08, + 6.694871e-08, +] @pytest.mark.parametrize("lang", ["C", "Py"]) @@ -32,8 +93,8 @@ def test_interaction_RTA_si(si_pbesol, lang): # _show(itr) # (10, 6, 6, 6) np.testing.assert_allclose( - itr.interaction_strength.sum(axis=(1, 2, 3)), - itr_RTA_Si, rtol=0, atol=1e-6) + itr.interaction_strength.sum(axis=(1, 2, 3)), itr_RTA_Si, rtol=0, atol=1e-6 + ) def test_interaction_RTA_AlN(aln_lda): @@ -43,21 +104,16 @@ def test_interaction_RTA_AlN(aln_lda): itr.run() # _show(itr) np.testing.assert_allclose( - itr.interaction_strength.sum(axis=(1, 2, 3)), - itr_RTA_AlN, rtol=0, atol=1e-6) + itr.interaction_strength.sum(axis=(1, 2, 3)), itr_RTA_AlN, rtol=0, atol=1e-6 + ) def _get_irt(ph3, mesh): ph3.mesh_numbers = mesh - itr = Interaction(ph3.primitive, - ph3.grid, - ph3.primitive_symmetry, - ph3.fc3, - cutoff_frequency=1e-4) - itr.init_dynamical_matrix( - ph3.fc2, - ph3.phonon_supercell, - ph3.phonon_primitive) + itr = Interaction( + ph3.primitive, ph3.grid, ph3.primitive_symmetry, ph3.fc3, cutoff_frequency=1e-4 + ) + itr.init_dynamical_matrix(ph3.fc2, ph3.phonon_supercell, ph3.phonon_primitive) return itr diff --git a/test/phonon3/test_joint_dos.py b/test/phonon3/test_joint_dos.py index 73652897..3a34b62b 100644 --- a/test/phonon3/test_joint_dos.py +++ b/test/phonon3/test_joint_dos.py @@ -1,68 +1,166 @@ import numpy as np from phono3py.api_jointdos import Phono3pyJointDos -si_freq_points = [0.0000000, 3.4102469, 6.8204938, 10.2307406, 13.6409875, - 17.0512344, 20.4614813, 23.8717281, 27.2819750, 30.6922219] -si_jdos_12 = [10.8993284, 0.0000000, - 1.9825862, 0.0000000, - 1.6458638, 0.4147573, - 3.7550744, 0.8847213, - 0.0176267, 1.0774414, - 0.0000000, 2.1981098, - 0.0000000, 1.4959386, - 0.0000000, 2.0987108, - 0.0000000, 1.1648722, - 0.0000000, 0.0000000] -si_jdos_nomeshsym_12 = [10.9478722, 0.0000000, - 1.9825862, 0.0000000, - 1.6458638, 0.4147573, - 3.7550744, 0.8847213, - 0.0176267, 1.0774414, - 0.0000000, 2.1981098, - 0.0000000, 1.4959386, - 0.0000000, 2.0987108, - 0.0000000, 1.1648722, - 0.0000000, 0.0000000] +si_freq_points = [ + 0.0000000, + 3.4102469, + 6.8204938, + 10.2307406, + 13.6409875, + 17.0512344, + 20.4614813, + 23.8717281, + 27.2819750, + 30.6922219, +] +si_jdos_12 = [ + 10.8993284, + 0.0000000, + 1.9825862, + 0.0000000, + 1.6458638, + 0.4147573, + 3.7550744, + 0.8847213, + 0.0176267, + 1.0774414, + 0.0000000, + 2.1981098, + 0.0000000, + 1.4959386, + 0.0000000, + 2.0987108, + 0.0000000, + 1.1648722, + 0.0000000, + 0.0000000, +] +si_jdos_nomeshsym_12 = [ + 10.9478722, + 0.0000000, + 1.9825862, + 0.0000000, + 1.6458638, + 0.4147573, + 3.7550744, + 0.8847213, + 0.0176267, + 1.0774414, + 0.0000000, + 2.1981098, + 0.0000000, + 1.4959386, + 0.0000000, + 2.0987108, + 0.0000000, + 1.1648722, + 0.0000000, + 0.0000000, +] -nacl_freq_points = [0.0000000, 1.6322306, 3.2644613, 4.8966919, 6.5289225, - 8.1611531, 9.7933838, 11.4256144, 13.0578450, 14.6900756] -nacl_jdos_12 = [20.5529946, 0.0000000, - 11.3095088, 0.0000000, - 2.3068141, 0.1854566, - 0.2624358, 1.1781852, - 0.0000000, 4.9673048, - 0.0000000, 8.0794774, - 0.0000000, 5.3993210, - 0.0000000, 1.3717314, - 0.0000000, 0.1144440, - 0.0000000, 0.0000000] +nacl_freq_points = [ + 0.0000000, + 1.6322306, + 3.2644613, + 4.8966919, + 6.5289225, + 8.1611531, + 9.7933838, + 11.4256144, + 13.0578450, + 14.6900756, +] +nacl_jdos_12 = [ + 20.5529946, + 0.0000000, + 11.3095088, + 0.0000000, + 2.3068141, + 0.1854566, + 0.2624358, + 1.1781852, + 0.0000000, + 4.9673048, + 0.0000000, + 8.0794774, + 0.0000000, + 5.3993210, + 0.0000000, + 1.3717314, + 0.0000000, + 0.1144440, + 0.0000000, + 0.0000000, +] nacl_freq_points_gamma = [ - 0.0000000, 1.6553106, 3.3106213, 4.9659319, 6.6212426, - 8.2765532, 9.9318639, 11.5871745, 13.2424851, 14.8977958] -nacl_jdos_12_gamma = [1742452844146884.7500000, 0.0000000, - 8.8165476, 0.0415488, - 1.4914142, 0.3104766, - 0.3679421, 1.0509976, - 0.0358263, 5.8578016, - 0.0000000, 7.2272898, - 0.0000000, 5.7740314, - 0.0000000, 0.6663207, - 0.0000000, 0.1348658, - 0.0000000, 0.0000000] + 0.0000000, + 1.6553106, + 3.3106213, + 4.9659319, + 6.6212426, + 8.2765532, + 9.9318639, + 11.5871745, + 13.2424851, + 14.8977958, +] +nacl_jdos_12_gamma = [ + 1742452844146884.7500000, + 0.0000000, + 8.8165476, + 0.0415488, + 1.4914142, + 0.3104766, + 0.3679421, + 1.0509976, + 0.0358263, + 5.8578016, + 0.0000000, + 7.2272898, + 0.0000000, + 5.7740314, + 0.0000000, + 0.6663207, + 0.0000000, + 0.1348658, + 0.0000000, + 0.0000000, +] nacl_freq_points_at_300K = [ - 0.0000000, 1.6322306, 3.2644613, 4.8966919, 6.5289225, - 8.1611531, 9.7933838, 11.4256144, 13.0578450, 14.6900756] -nacl_jdos_12_at_300K = [0.0000000, 0.0000000, - 8.4625631, 0.0000000, - 4.1076174, 1.5151176, - 0.7992725, 6.7993659, - 0.0000000, 21.2271309, - 0.0000000, 26.9803907, - 0.0000000, 14.9103483, - 0.0000000, 3.2833064, - 0.0000000, 0.2398336, - 0.0000000, 0.0000000] + 0.0000000, + 1.6322306, + 3.2644613, + 4.8966919, + 6.5289225, + 8.1611531, + 9.7933838, + 11.4256144, + 13.0578450, + 14.6900756, +] +nacl_jdos_12_at_300K = [ + 0.0000000, + 0.0000000, + 8.4625631, + 0.0000000, + 4.1076174, + 1.5151176, + 0.7992725, + 6.7993659, + 0.0000000, + 21.2271309, + 0.0000000, + 26.9803907, + 0.0000000, + 14.9103483, + 0.0000000, + 3.2833064, + 0.0000000, + 0.2398336, + 0.0000000, + 0.0000000, +] def test_jdos_si(si_pbesol): @@ -73,14 +171,15 @@ def test_jdos_si(si_pbesol): si_pbesol.fc2, mesh=si_pbesol.mesh_numbers, num_frequency_points=10, - log_level=1) + log_level=1, + ) jdos.run([103]) # print(", ".join(["%.7f" % fp for fp in jdos.frequency_points])) - np.testing.assert_allclose(si_freq_points, jdos.frequency_points, - atol=1e-5) + np.testing.assert_allclose(si_freq_points, jdos.frequency_points, atol=1e-5) # print(", ".join(["%.7f" % jd for jd in jdos.joint_dos.ravel()])) - np.testing.assert_allclose(si_jdos_12[2:], jdos.joint_dos.ravel()[2:], - rtol=1e-2, atol=1e-5) + np.testing.assert_allclose( + si_jdos_12[2:], jdos.joint_dos.ravel()[2:], rtol=1e-2, atol=1e-5 + ) def test_jdso_si_nomeshsym(si_pbesol): @@ -92,14 +191,15 @@ def test_jdso_si_nomeshsym(si_pbesol): mesh=si_pbesol.mesh_numbers, num_frequency_points=10, is_mesh_symmetry=False, - log_level=1) + log_level=1, + ) jdos.run([103]) # print(", ".join(["%.7f" % fp for fp in jdos.frequency_points])) - np.testing.assert_allclose(si_freq_points, jdos.frequency_points, - atol=1e-5) + np.testing.assert_allclose(si_freq_points, jdos.frequency_points, atol=1e-5) # print(", ".join(["%.7f" % jd for jd in jdos.joint_dos.ravel()])) - np.testing.assert_allclose(si_jdos_nomeshsym_12[2:], jdos.joint_dos.ravel()[2:], - rtol=1e-2, atol=1e-5) + np.testing.assert_allclose( + si_jdos_nomeshsym_12[2:], jdos.joint_dos.ravel()[2:], rtol=1e-2, atol=1e-5 + ) def test_jdos_nacl(nacl_pbe): @@ -111,14 +211,15 @@ def test_jdos_nacl(nacl_pbe): mesh=nacl_pbe.mesh_numbers, nac_params=nacl_pbe.nac_params, num_frequency_points=10, - log_level=1) + log_level=1, + ) jdos.run([103]) # print(", ".join(["%.7f" % fp for fp in jdos.frequency_points])) - np.testing.assert_allclose(nacl_freq_points, jdos.frequency_points, - atol=1e-5) + np.testing.assert_allclose(nacl_freq_points, jdos.frequency_points, atol=1e-5) # print(", ".join(["%.7f" % jd for jd in jdos.joint_dos.ravel()])) - np.testing.assert_allclose(nacl_jdos_12[2:], jdos.joint_dos.ravel()[2:], - rtol=1e-2, atol=1e-5) + np.testing.assert_allclose( + nacl_jdos_12[2:], jdos.joint_dos.ravel()[2:], rtol=1e-2, atol=1e-5 + ) def test_jdos_nacl_gamma(nacl_pbe): @@ -131,15 +232,15 @@ def test_jdos_nacl_gamma(nacl_pbe): nac_params=nacl_pbe.nac_params, nac_q_direction=[1, 0, 0], num_frequency_points=10, - log_level=1) + log_level=1, + ) jdos.run([0]) # print(", ".join(["%.7f" % fp for fp in jdos.frequency_points])) - np.testing.assert_allclose(nacl_freq_points_gamma, jdos.frequency_points, - atol=1e-5) + np.testing.assert_allclose(nacl_freq_points_gamma, jdos.frequency_points, atol=1e-5) # print(", ".join(["%.7f" % jd for jd in jdos.joint_dos.ravel()])) np.testing.assert_allclose( - nacl_jdos_12_gamma[2:], jdos.joint_dos.ravel()[2:], - rtol=1e-2, atol=1e-5) + nacl_jdos_12_gamma[2:], jdos.joint_dos.ravel()[2:], rtol=1e-2, atol=1e-5 + ) def test_jdos_nacl_at_300K(nacl_pbe): @@ -151,14 +252,17 @@ def test_jdos_nacl_at_300K(nacl_pbe): mesh=nacl_pbe.mesh_numbers, nac_params=nacl_pbe.nac_params, num_frequency_points=10, - temperatures=[300, ], - log_level=1) + temperatures=[ + 300, + ], + log_level=1, + ) jdos.run([103]) # print(", ".join(["%.7f" % fp for fp in jdos.frequency_points])) np.testing.assert_allclose( - nacl_freq_points_at_300K, jdos.frequency_points, - atol=1e-5) + nacl_freq_points_at_300K, jdos.frequency_points, atol=1e-5 + ) # print(", ".join(["%.7f" % jd for jd in jdos.joint_dos.ravel()])) np.testing.assert_allclose( - nacl_jdos_12_at_300K[2:], jdos.joint_dos.ravel()[2:], - rtol=1e-2, atol=1e-5) + nacl_jdos_12_at_300K[2:], jdos.joint_dos.ravel()[2:], rtol=1e-2, atol=1e-5 + ) diff --git a/test/phonon3/test_kappa_LBTE.py b/test/phonon3/test_kappa_LBTE.py index b1483ea5..3924e5b7 100644 --- a/test/phonon3/test_kappa_LBTE.py +++ b/test/phonon3/test_kappa_LBTE.py @@ -1,3 +1,4 @@ +"""Tests for direct solution of LBTE.""" import numpy as np si_pbesol_kappa_LBTE = [111.802, 111.802, 111.802, 0, 0, 0] @@ -5,19 +6,29 @@ si_pbesol_kappa_LBTE_redcol = [61.3504328, 61.3504328, 61.3504328, 0, 0, 0] def test_kappa_LBTE(si_pbesol): + """Test for symmetry reduced collision matrix.""" si_pbesol.mesh_numbers = [9, 9, 9] si_pbesol.init_phph_interaction() - si_pbesol.run_thermal_conductivity(is_LBTE=True, temperatures=[300, ]) + si_pbesol.run_thermal_conductivity( + is_LBTE=True, + temperatures=[ + 300, + ], + ) kappa = si_pbesol.thermal_conductivity.kappa.ravel() np.testing.assert_allclose(si_pbesol_kappa_LBTE, kappa, atol=0.5) def test_kappa_LBTE_full_colmat(si_pbesol): + """Test for full collision matrix.""" si_pbesol.mesh_numbers = [5, 5, 5] si_pbesol.init_phph_interaction() si_pbesol.run_thermal_conductivity( is_LBTE=True, - temperatures=[300, ], - is_reducible_collision_matrix=True) + temperatures=[ + 300, + ], + is_reducible_collision_matrix=True, + ) kappa = si_pbesol.thermal_conductivity.kappa.ravel() np.testing.assert_allclose(si_pbesol_kappa_LBTE_redcol, kappa, atol=0.5) diff --git a/test/phonon3/test_kappa_RTA.py b/test/phonon3/test_kappa_RTA.py index 47fb7706..60e09c04 100644 --- a/test/phonon3/test_kappa_RTA.py +++ b/test/phonon3/test_kappa_RTA.py @@ -5,8 +5,14 @@ si_pbesol_kappa_RTA = [107.991, 107.991, 107.991, 0, 0, 0] si_pbesol_kappa_RTA_with_sigmas = [109.6985, 109.6985, 109.6985, 0, 0, 0] 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] -si_pbesol_kappa_RTA_si_nosym = [38.242347, 38.700219, 39.198018, - 0.3216, 0.207731, 0.283] +si_pbesol_kappa_RTA_si_nosym = [ + 38.242347, + 38.700219, + 39.198018, + 0.3216, + 0.207731, + 0.283, +] si_pbesol_kappa_RTA_si_nomeshsym = [38.90918, 38.90918, 38.90918, 0, 0, 0] nacl_pbe_kappa_RTA = [7.72798252, 7.72798252, 7.72798252, 0, 0, 0] nacl_pbe_kappa_RTA_with_sigma = [7.71913708, 7.71913708, 7.71913708, 0, 0, 0] @@ -32,27 +38,30 @@ def test_kappa_RTA_si_iso(si_pbesol): def test_kappa_RTA_si_with_sigma(si_pbesol): - si_pbesol.sigmas = [0.1, ] + si_pbesol.sigmas = [ + 0.1, + ] kappa = _get_kappa(si_pbesol, [9, 9, 9]).ravel() - np.testing.assert_allclose( - si_pbesol_kappa_RTA_with_sigmas, kappa, atol=0.5) + np.testing.assert_allclose(si_pbesol_kappa_RTA_with_sigmas, kappa, atol=0.5) si_pbesol.sigmas = None def test_kappa_RTA_si_with_sigma_full_pp(si_pbesol): - si_pbesol.sigmas = [0.1, ] + si_pbesol.sigmas = [ + 0.1, + ] kappa = _get_kappa(si_pbesol, [9, 9, 9], is_full_pp=True).ravel() print(kappa) - np.testing.assert_allclose( - si_pbesol_kappa_RTA_with_sigmas, kappa, atol=0.5) + np.testing.assert_allclose(si_pbesol_kappa_RTA_with_sigmas, kappa, atol=0.5) si_pbesol.sigmas = None def test_kappa_RTA_si_with_sigma_iso(si_pbesol): - si_pbesol.sigmas = [0.1, ] + si_pbesol.sigmas = [ + 0.1, + ] kappa = _get_kappa(si_pbesol, [9, 9, 9], is_isotope=True).ravel() - np.testing.assert_allclose( - si_pbesol_kappa_RTA_with_sigmas_iso, kappa, atol=0.5) + np.testing.assert_allclose(si_pbesol_kappa_RTA_with_sigmas_iso, kappa, atol=0.5) si_pbesol.sigmas = None @@ -83,35 +92,119 @@ def test_kappa_RTA_si_N_U(si_pbesol): is_N_U = True ph3.mesh_numbers = mesh ph3.init_phph_interaction() - ph3.run_thermal_conductivity(temperatures=[300, ], is_N_U=is_N_U) + ph3.run_thermal_conductivity( + temperatures=[ + 300, + ], + is_N_U=is_N_U, + ) gN, gU = ph3.thermal_conductivity.get_gamma_N_U() gN_ref = [ - 0.00000000, 0.00000000, 0.00000000, 0.07402084, 0.07402084, - 0.07402084, 0.00078535, 0.00078535, 0.00917995, 0.02178049, - 0.04470075, 0.04470075, 0.00173337, 0.00173337, 0.01240191, - 0.00198981, 0.03165195, 0.03165195, 0.00224713, 0.00224713, - 0.00860026, 0.03083611, 0.03083611, 0.02142118, 0.00277534, - 0.00330170, 0.02727451, 0.00356415, 0.01847744, 0.01320643, - 0.00155072, 0.00365611, 0.01641919, 0.00650083, 0.02576069, - 0.01161589, 0.00411969, 0.00411969, 0.00168211, 0.00168211, - 0.01560092, 0.01560092, 0.00620091, 0.00620091, 0.03764912, - 0.03764912, 0.02668523, 0.02668523] + 0.00000000, + 0.00000000, + 0.00000000, + 0.07402084, + 0.07402084, + 0.07402084, + 0.00078535, + 0.00078535, + 0.00917995, + 0.02178049, + 0.04470075, + 0.04470075, + 0.00173337, + 0.00173337, + 0.01240191, + 0.00198981, + 0.03165195, + 0.03165195, + 0.00224713, + 0.00224713, + 0.00860026, + 0.03083611, + 0.03083611, + 0.02142118, + 0.00277534, + 0.00330170, + 0.02727451, + 0.00356415, + 0.01847744, + 0.01320643, + 0.00155072, + 0.00365611, + 0.01641919, + 0.00650083, + 0.02576069, + 0.01161589, + 0.00411969, + 0.00411969, + 0.00168211, + 0.00168211, + 0.01560092, + 0.01560092, + 0.00620091, + 0.00620091, + 0.03764912, + 0.03764912, + 0.02668523, + 0.02668523, + ] gU_ref = [ - 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, - 0.00000000, 0.00015178, 0.00015178, 0.00076936, 0.00727539, - 0.00113112, 0.00113112, 0.00022696, 0.00022696, 0.00072558, - 0.00000108, 0.00021968, 0.00021968, 0.00079397, 0.00079397, - 0.00111068, 0.00424761, 0.00424761, 0.00697760, 0.00221593, - 0.00259510, 0.01996296, 0.00498962, 0.01258375, 0.00513825, - 0.00148802, 0.00161955, 0.01589219, 0.00646134, 0.00577275, - 0.00849711, 0.00313208, 0.00313208, 0.00036610, 0.00036610, - 0.01135335, 0.01135335, 0.00000000, 0.00000000, 0.00000000, - 0.00000000, 0.00000000, 0.00000000] + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00015178, + 0.00015178, + 0.00076936, + 0.00727539, + 0.00113112, + 0.00113112, + 0.00022696, + 0.00022696, + 0.00072558, + 0.00000108, + 0.00021968, + 0.00021968, + 0.00079397, + 0.00079397, + 0.00111068, + 0.00424761, + 0.00424761, + 0.00697760, + 0.00221593, + 0.00259510, + 0.01996296, + 0.00498962, + 0.01258375, + 0.00513825, + 0.00148802, + 0.00161955, + 0.01589219, + 0.00646134, + 0.00577275, + 0.00849711, + 0.00313208, + 0.00313208, + 0.00036610, + 0.00036610, + 0.01135335, + 0.01135335, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + 0.00000000, + ] # print(np.sum(gN), np.sum(gU)) - np.testing.assert_allclose(np.sum([gN_ref, gU_ref], axis=0), - gN.ravel() + gU.ravel(), atol=1e-2) + np.testing.assert_allclose( + np.sum([gN_ref, gU_ref], axis=0), gN.ravel() + gU.ravel(), atol=1e-2 + ) np.testing.assert_allclose(gN_ref, gN.ravel(), atol=1e-2) np.testing.assert_allclose(gU_ref, gU.ravel(), atol=1e-2) @@ -122,7 +215,9 @@ def test_kappa_RTA_nacl(nacl_pbe): def test_kappa_RTA_nacl_with_sigma(nacl_pbe): - nacl_pbe.sigmas = [0.1, ] + nacl_pbe.sigmas = [ + 0.1, + ] nacl_pbe.sigma_cutoff = 3 kappa = _get_kappa(nacl_pbe, [9, 9, 9]).ravel() np.testing.assert_allclose(nacl_pbe_kappa_RTA_with_sigma, kappa, atol=0.5) @@ -136,7 +231,9 @@ def test_kappa_RTA_aln(aln_lda): def test_kappa_RTA_aln_with_sigma(aln_lda): - aln_lda.sigmas = [0.1, ] + aln_lda.sigmas = [ + 0.1, + ] aln_lda.sigma_cutoff = 3 kappa = _get_kappa(aln_lda, [7, 7, 5]).ravel() np.testing.assert_allclose(aln_lda_kappa_RTA_with_sigmas, kappa, atol=0.5) @@ -147,7 +244,11 @@ def test_kappa_RTA_aln_with_sigma(aln_lda): def _get_kappa(ph3, mesh, is_isotope=False, is_full_pp=False): ph3.mesh_numbers = mesh ph3.init_phph_interaction() - ph3.run_thermal_conductivity(temperatures=[300, ], - is_isotope=is_isotope, - is_full_pp=is_full_pp) + ph3.run_thermal_conductivity( + temperatures=[ + 300, + ], + is_isotope=is_isotope, + is_full_pp=is_full_pp, + ) return ph3.thermal_conductivity.kappa diff --git a/test/phonon3/test_real_self_energy.py b/test/phonon3/test_real_self_energy.py index bede25c5..20a87af1 100644 --- a/test/phonon3/test_real_self_energy.py +++ b/test/phonon3/test_real_self_energy.py @@ -3,23 +3,64 @@ import numpy as np from phono3py.phonon3.real_self_energy import ImagToReal si_pbesol_Delta = [ - [-0.0057666, -0.0057666, -0.01639729, -0.14809965, - -0.15091765, -0.15091765], - [-0.02078728, -0.02102094, -0.06573269, -0.11432603, - -0.1366966, -0.14371315]] + [-0.0057666, -0.0057666, -0.01639729, -0.14809965, -0.15091765, -0.15091765], + [-0.02078728, -0.02102094, -0.06573269, -0.11432603, -0.1366966, -0.14371315], +] -si_pbesol_Delta_fps = [[-0.00576660, -0.00594616, -0.00840087, -0.00960344, - -0.00576660, -0.00594616, -0.00840087, -0.00960344, - -0.01493508, -0.01639729, -0.01997820, -0.02070427, - -0.15511645, -0.14747203, -0.14809966, -0.14230763, - -0.15674925, -0.15684992, -0.15983868, -0.15091767, - -0.15674925, -0.15684992, -0.15983868, -0.15091767], - [-0.01990306, -0.02077094, -0.01798066, -0.01935581, - -0.02158076, -0.02190634, -0.02195633, -0.01882258, - -0.05740055, -0.05240406, -0.06252644, -0.05651015, - -0.13072273, -0.11929265, -0.13472599, -0.13105120, - -0.15191900, -0.14202698, -0.14371246, -0.14168892, - -0.14760248, -0.13907618, -0.14275290, -0.14100562]] +si_pbesol_Delta_fps = [ + [ + -0.00576660, + -0.00594616, + -0.00840087, + -0.00960344, + -0.00576660, + -0.00594616, + -0.00840087, + -0.00960344, + -0.01493508, + -0.01639729, + -0.01997820, + -0.02070427, + -0.15511645, + -0.14747203, + -0.14809966, + -0.14230763, + -0.15674925, + -0.15684992, + -0.15983868, + -0.15091767, + -0.15674925, + -0.15684992, + -0.15983868, + -0.15091767, + ], + [ + -0.01990306, + -0.02077094, + -0.01798066, + -0.01935581, + -0.02158076, + -0.02190634, + -0.02195633, + -0.01882258, + -0.05740055, + -0.05240406, + -0.06252644, + -0.05651015, + -0.13072273, + -0.11929265, + -0.13472599, + -0.13105120, + -0.15191900, + -0.14202698, + -0.14371246, + -0.14168892, + -0.14760248, + -0.13907618, + -0.14275290, + -0.14100562, + ], +] # imag-self-energy Si-PBEsol 50x50x50 gp=5, bi=4, 101 points, 300K im_part = [ @@ -123,7 +164,8 @@ im_part = [ [29.7714552, 0.2258269, 29.7714552, 0.6147208, 29.9249163, 0.6117702], [30.0783775, 0.1397870, 30.0783775, 0.5578788, 30.2318386, 0.5591731], [30.3852997, 0.0468188, 30.3852997, 0.4941608, 30.5387608, 0.4706733], - [30.6922219, 0.0000000, 30.6922219, 0.4173657, 30.8456830, 0.3821416]] + [30.6922219, 0.0000000, 30.6922219, 0.4173657, 30.8456830, 0.3821416], +] def test_real_self_energy_with_band_indices(si_pbesol): @@ -136,9 +178,12 @@ def test_real_self_energy_with_band_indices(si_pbesol): si_pbesol.init_phph_interaction() _, delta = si_pbesol.run_real_self_energy( si_pbesol.grid.grg2bzg[[1, 103]], - [300, ], + [ + 300, + ], write_hdf5=False, - frequency_points_at_bands=True) + frequency_points_at_bands=True, + ) np.testing.assert_allclose(si_pbesol_Delta, delta[0, 0, :], atol=0.01) @@ -153,16 +198,21 @@ def test_real_self_energy_with_frequency_points(si_pbesol): frequency_points = [1.469947, 3.085309, 14.997187, 15.129080] fps, delta = si_pbesol.run_real_self_energy( si_pbesol.grid.grg2bzg[[1, 103]], - [300, ], + [ + 300, + ], frequency_points=frequency_points, write_hdf5=False, - frequency_points_at_bands=False) + frequency_points_at_bands=False, + ) np.testing.assert_allclose(frequency_points, fps, atol=1e-5) np.testing.assert_allclose( - si_pbesol_Delta_fps[0], delta[0, 0, 0].ravel(), atol=0.01) + si_pbesol_Delta_fps[0], delta[0, 0, 0].ravel(), atol=0.01 + ) np.testing.assert_allclose( - si_pbesol_Delta_fps[1], delta[0, 0, 1].ravel(), atol=0.01) + si_pbesol_Delta_fps[1], delta[0, 0, 1].ravel(), atol=0.01 + ) # for b in delta[0, 0, 0]: # print("".join("%.8f, " % s for s in b)) @@ -177,7 +227,7 @@ def test_ImagToReal(): i2r.run() pick_one_vals = -1 * i2r.re_part # -1 to make it freq-shift pick_one_freqs = i2r.frequency_points - i2r.run(method='half_shift') + i2r.run(method="half_shift") half_shift_vals = -1 * i2r.re_part # -1 to make it freq-shift half_shift_freqs = i2r.frequency_points # for f, im, f1, re1, f2, re2, in zip( diff --git a/test/phonon3/test_spectral_function.py b/test/phonon3/test_spectral_function.py index 8c9a1253..000f4f7c 100644 --- a/test/phonon3/test_spectral_function.py +++ b/test/phonon3/test_spectral_function.py @@ -3,59 +3,265 @@ import numpy as np from phono3py.phonon3.spectral_function import SpectralFunction shifts = [ - -0.0049592, -0.0049592, -0.0120983, -0.1226471, -0.1214069, -0.1214069, - -0.0051678, -0.0051678, -0.0128471, -0.1224616, -0.1200362, -0.1200362, - -0.0055308, -0.0055308, -0.0122157, -0.1093754, -0.1077399, -0.1077399, - -0.0037992, -0.0037992, -0.0089979, -0.0955525, -0.0958995, -0.0958995, - -0.0034397, -0.0034397, -0.0107575, -0.1068741, -0.1067815, -0.1067815, - -0.0017800, -0.0017800, -0.0102865, -0.1348585, -0.1275650, -0.1275650, - 0.0006728, 0.0006728, -0.0065349, -0.2011702, -0.2015991, -0.2015991, - 0.0021133, 0.0021133, 0.0020353, -0.0740009, -0.0833644, -0.0833644, - 0.0037739, 0.0037739, 0.0121357, 0.1597195, 0.1585307, 0.1585307, - 0.0026257, 0.0026257, 0.0103523, 0.1626420, 0.1634832, 0.1634832, - -0.0189694, -0.0188985, -0.0415773, -0.0955391, -0.1180182, -0.1126508, - -0.0194533, -0.0191057, -0.0420358, -0.0913521, -0.1140995, -0.1075009, - -0.0233933, -0.0219600, -0.0466734, -0.0865867, -0.1086070, -0.1014454, - -0.0140271, -0.0150165, -0.0344515, -0.0755416, -0.1018518, -0.0951606, - -0.0058780, -0.0089457, -0.0256867, -0.0775726, -0.1070427, -0.1018654, - -0.0069737, -0.0092857, -0.0333909, -0.1014042, -0.1320678, -0.1288315, - -0.0030075, -0.0060858, -0.0245855, -0.1186313, -0.1963719, -0.1857004, - 0.0058243, 0.0030539, -0.0049966, -0.0583228, -0.0921850, -0.0893692, - 0.0141517, 0.0149365, 0.0312156, 0.0898626, 0.1454759, 0.1347802, - 0.0110954, 0.0137260, 0.0427527, 0.1280421, 0.1715647, 0.1648037] + -0.0049592, + -0.0049592, + -0.0120983, + -0.1226471, + -0.1214069, + -0.1214069, + -0.0051678, + -0.0051678, + -0.0128471, + -0.1224616, + -0.1200362, + -0.1200362, + -0.0055308, + -0.0055308, + -0.0122157, + -0.1093754, + -0.1077399, + -0.1077399, + -0.0037992, + -0.0037992, + -0.0089979, + -0.0955525, + -0.0958995, + -0.0958995, + -0.0034397, + -0.0034397, + -0.0107575, + -0.1068741, + -0.1067815, + -0.1067815, + -0.0017800, + -0.0017800, + -0.0102865, + -0.1348585, + -0.1275650, + -0.1275650, + 0.0006728, + 0.0006728, + -0.0065349, + -0.2011702, + -0.2015991, + -0.2015991, + 0.0021133, + 0.0021133, + 0.0020353, + -0.0740009, + -0.0833644, + -0.0833644, + 0.0037739, + 0.0037739, + 0.0121357, + 0.1597195, + 0.1585307, + 0.1585307, + 0.0026257, + 0.0026257, + 0.0103523, + 0.1626420, + 0.1634832, + 0.1634832, + -0.0189694, + -0.0188985, + -0.0415773, + -0.0955391, + -0.1180182, + -0.1126508, + -0.0194533, + -0.0191057, + -0.0420358, + -0.0913521, + -0.1140995, + -0.1075009, + -0.0233933, + -0.0219600, + -0.0466734, + -0.0865867, + -0.1086070, + -0.1014454, + -0.0140271, + -0.0150165, + -0.0344515, + -0.0755416, + -0.1018518, + -0.0951606, + -0.0058780, + -0.0089457, + -0.0256867, + -0.0775726, + -0.1070427, + -0.1018654, + -0.0069737, + -0.0092857, + -0.0333909, + -0.1014042, + -0.1320678, + -0.1288315, + -0.0030075, + -0.0060858, + -0.0245855, + -0.1186313, + -0.1963719, + -0.1857004, + 0.0058243, + 0.0030539, + -0.0049966, + -0.0583228, + -0.0921850, + -0.0893692, + 0.0141517, + 0.0149365, + 0.0312156, + 0.0898626, + 0.1454759, + 0.1347802, + 0.0110954, + 0.0137260, + 0.0427527, + 0.1280421, + 0.1715647, + 0.1648037, +] spec_funcs = [ - 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, - 0.0000520, 0.0000520, 0.0070211, 0.0003925, 0.0004139, 0.0004139, - 0.0000085, 0.0000085, 0.0001872, 0.0016104, 0.0014443, 0.0014443, - 0.0000051, 0.0000051, 0.0000370, 0.0027822, 0.0025951, 0.0025951, - 0.0000004, 0.0000004, 0.0000021, 0.0197933, 0.0168956, 0.0168956, - 0.0000010, 0.0000010, 0.0000082, 0.0080833, 0.0110838, 0.0110838, - 0.0000002, 0.0000002, 0.0000031, 0.0014052, 0.0008202, 0.0008202, - 0.0000002, 0.0000002, 0.0000035, 0.0037304, 0.0039325, 0.0039325, - 0.0000000, 0.0000000, 0.0000009, 0.0009279, 0.0009800, 0.0009800, - 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, - 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, - 0.0101136, 0.0017460, 0.0004489, 0.0005850, 0.0005048, 0.0005229, - 0.0002283, 0.0006942, 0.0050470, 0.0012772, 0.0010867, 0.0009498, - 0.0002702, 0.0004036, 0.0106017, 0.0086169, 0.0041489, 0.0035906, - 0.0000154, 0.0000295, 0.0002803, 0.0434066, 0.1278558, 0.0549209, - 0.0000166, 0.0000264, 0.0001776, 0.0018060, 0.0042557, 0.0043927, - 0.0000066, 0.0000108, 0.0001284, 0.0010011, 0.0009471, 0.0011088, - 0.0000059, 0.0000105, 0.0000738, 0.0010751, 0.0027300, 0.0026490, - 0.0000012, 0.0000033, 0.0000504, 0.0005539, 0.0009128, 0.0009358, - 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000] + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000520, + 0.0000520, + 0.0070211, + 0.0003925, + 0.0004139, + 0.0004139, + 0.0000085, + 0.0000085, + 0.0001872, + 0.0016104, + 0.0014443, + 0.0014443, + 0.0000051, + 0.0000051, + 0.0000370, + 0.0027822, + 0.0025951, + 0.0025951, + 0.0000004, + 0.0000004, + 0.0000021, + 0.0197933, + 0.0168956, + 0.0168956, + 0.0000010, + 0.0000010, + 0.0000082, + 0.0080833, + 0.0110838, + 0.0110838, + 0.0000002, + 0.0000002, + 0.0000031, + 0.0014052, + 0.0008202, + 0.0008202, + 0.0000002, + 0.0000002, + 0.0000035, + 0.0037304, + 0.0039325, + 0.0039325, + 0.0000000, + 0.0000000, + 0.0000009, + 0.0009279, + 0.0009800, + 0.0009800, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0101136, + 0.0017460, + 0.0004489, + 0.0005850, + 0.0005048, + 0.0005229, + 0.0002283, + 0.0006942, + 0.0050470, + 0.0012772, + 0.0010867, + 0.0009498, + 0.0002702, + 0.0004036, + 0.0106017, + 0.0086169, + 0.0041489, + 0.0035906, + 0.0000154, + 0.0000295, + 0.0002803, + 0.0434066, + 0.1278558, + 0.0549209, + 0.0000166, + 0.0000264, + 0.0001776, + 0.0018060, + 0.0042557, + 0.0043927, + 0.0000066, + 0.0000108, + 0.0001284, + 0.0010011, + 0.0009471, + 0.0011088, + 0.0000059, + 0.0000105, + 0.0000738, + 0.0010751, + 0.0027300, + 0.0026490, + 0.0000012, + 0.0000033, + 0.0000504, + 0.0005539, + 0.0009128, + 0.0009358, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, + 0.0000000, +] def test_SpectralFunction(si_pbesol): """Spectral function of Si.""" si_pbesol.mesh_numbers = [9, 9, 9] si_pbesol.init_phph_interaction() - sf = SpectralFunction(si_pbesol.phph_interaction, - si_pbesol.grid.grg2bzg[[1, 103]], - temperatures=[300, ], - num_frequency_points=10, - log_level=1) + sf = SpectralFunction( + si_pbesol.phph_interaction, + si_pbesol.grid.grg2bzg[[1, 103]], + temperatures=[ + 300, + ], + num_frequency_points=10, + log_level=1, + ) sf.run() # for line in np.swapaxes(sf.spectral_functions, -2, -1).reshape(-1, 6): @@ -63,7 +269,11 @@ def test_SpectralFunction(si_pbesol): # raise np.testing.assert_allclose( - shifts, np.swapaxes(sf.shifts, -2, -1).ravel(), atol=1e-2) + shifts, np.swapaxes(sf.shifts, -2, -1).ravel(), atol=1e-2 + ) np.testing.assert_allclose( - spec_funcs, np.swapaxes(sf.spectral_functions * np.pi, -2, -1).ravel(), - atol=1e-2, rtol=1e-2) + spec_funcs, + np.swapaxes(sf.spectral_functions * np.pi, -2, -1).ravel(), + atol=1e-2, + rtol=1e-2, + ) diff --git a/test/phonon3/test_triplets.py b/test/phonon3/test_triplets.py index d2699fe4..af00e136 100644 --- a/test/phonon3/test_triplets.py +++ b/test/phonon3/test_triplets.py @@ -12,14 +12,45 @@ def test_get_triplets_at_q_type1(si_pbesol_111): grid_point = 1 mesh = [4, 4, 4] - bz_grid = BZGrid(mesh, - lattice=pcell.cell, - symmetry_dataset=psym.dataset, - store_dense_gp_map=False) + bz_grid = BZGrid( + mesh, + lattice=pcell.cell, + symmetry_dataset=psym.dataset, + store_dense_gp_map=False, + ) triplets, weights = get_triplets_at_q(grid_point, bz_grid)[:2] - triplets_ref = [1, 0, 3, 1, 1, 2, 1, 4, 15, 1, - 5, 14, 1, 6, 13, 1, 7, 12, 1, 65, - 11, 1, 9, 10, 1, 24, 59, 1, 26, 88] + triplets_ref = [ + 1, + 0, + 3, + 1, + 1, + 2, + 1, + 4, + 15, + 1, + 5, + 14, + 1, + 6, + 13, + 1, + 7, + 12, + 1, + 65, + 11, + 1, + 9, + 10, + 1, + 24, + 59, + 1, + 26, + 88, + ] weights_ref = [2, 2, 6, 6, 6, 6, 6, 6, 12, 12] # print("".join(["%d, " % i for i in triplets.ravel()])) # print("".join(["%d, " % i for i in weights])) @@ -36,14 +67,43 @@ def test_get_triplets_at_q_type2(si_pbesol_111): grid_point = 1 mesh = [4, 4, 4] - bz_grid = BZGrid(mesh, - lattice=pcell.cell, - symmetry_dataset=psym.dataset, - store_dense_gp_map=True) + bz_grid = BZGrid( + mesh, lattice=pcell.cell, symmetry_dataset=psym.dataset, store_dense_gp_map=True + ) triplets, weights = get_triplets_at_q(grid_point, bz_grid)[:2] - triplets_ref = [1, 0, 4, 1, 1, 2, 1, 5, 18, 1, 6, 17, 1, 7, 16, 1, - 8, 15, 1, 10, 14, 1, 11, 12, 1, 27, 84, 1, 29, 82] + triplets_ref = [ + 1, + 0, + 4, + 1, + 1, + 2, + 1, + 5, + 18, + 1, + 6, + 17, + 1, + 7, + 16, + 1, + 8, + 15, + 1, + 10, + 14, + 1, + 11, + 12, + 1, + 27, + 84, + 1, + 29, + 82, + ] weights_ref = [2, 2, 6, 6, 6, 6, 6, 6, 12, 12] _show_triplets_info(mesh, bz_grid, triplets, np.linalg.inv(pcell.cell)) @@ -54,8 +114,9 @@ def test_get_triplets_at_q_type2(si_pbesol_111): np.testing.assert_equal(weights, weights_ref) -def _show_triplets_info(mesh: list, bz_grid: BZGrid, triplets: np.ndarray, - reclat: np.ndarray) -> None: +def _show_triplets_info( + mesh: list, bz_grid: BZGrid, triplets: np.ndarray, reclat: np.ndarray +) -> None: """Show triplets details in grid type-1 and 2.""" shift = np.prod(mesh) double_shift = np.prod(mesh) * 8 @@ -69,12 +130,18 @@ def _show_triplets_info(mesh: list, bz_grid: BZGrid, triplets: np.ndarray, adrs.append(bz_grid.addresses[bzgp + j].tolist()) else: bzgp = i - multi = (bz_grid.gp_map[double_shift + i + 1] - - bz_grid.gp_map[double_shift + i] + 1) + multi = ( + bz_grid.gp_map[double_shift + i + 1] + - bz_grid.gp_map[double_shift + i] + + 1 + ) adrs.append(bz_grid.addresses[bzgp].tolist()) for j in range(multi - 1): - adrs.append(bz_grid.addresses[ - shift + bz_grid.gp_map[double_shift + i] + j].tolist()) + adrs.append( + bz_grid.addresses[ + shift + bz_grid.gp_map[double_shift + i] + j + ].tolist() + ) print(bzgp, adrs, multi) for tp in triplets: @@ -85,10 +152,10 @@ def _show_triplets_info(mesh: list, bz_grid: BZGrid, triplets: np.ndarray, multis.append(bz_grid.gp_map[gp + 1] - bz_grid.gp_map[gp]) else: shift = np.prod(mesh) * 8 - multis.append(bz_grid.gp_map[shift + gp + 1] - - bz_grid.gp_map[shift + gp] + 1) + multis.append( + bz_grid.gp_map[shift + gp + 1] - bz_grid.gp_map[shift + gp] + 1 + ) bztp = bz_grid.addresses[tp] gadrs = bz_grid.addresses[tp].sum(axis=0) / mesh d = np.sqrt(np.linalg.norm(np.dot(reclat, gadrs))) - print(tp, "[", bztp[0], bztp[1], bztp[2], "]", multis, - bztp.sum(axis=0), d) + print(tp, "[", bztp[0], bztp[1], bztp[2], "]", multis, bztp.sum(axis=0), d) diff --git a/test/sscha/test_sscha.py b/test/sscha/test_sscha.py index b0739ced..f9c1e060 100644 --- a/test/sscha/test_sscha.py +++ b/test/sscha/test_sscha.py @@ -1,9 +1,12 @@ -import sys +"""Tests for SSCHA routines.""" import pytest import numpy as np from phono3py.sscha.sscha import ( - DispCorrMatrix, DispCorrMatrixMesh, - SupercellPhonon, ThirdOrderFC) + DispCorrMatrix, + DispCorrMatrixMesh, + SupercellPhonon, + ThirdOrderFC, +) from phonopy.phonon.qpoints import QpointsPhonon from phonopy.phonon.random_displacements import RandomDisplacements @@ -12,20 +15,42 @@ try: except NameError: ModuleNotFoundError = ImportError -si_pbesol_upsilon0_0 = [[3.849187e+02, 0, 0], - [0, 3.849187e+02, 0], - [0, 0, 3.849187e+02]] -si_pbesol_upsilon1_34 = [[1.886404, -1.549705, -1.126055], - [-1.549705, 1.886404, -1.126055], - [-1.126055, -1.126055, -0.006187]] +si_pbesol_upsilon0_0 = [[3.849187e02, 0, 0], [0, 3.849187e02, 0], [0, 0, 3.849187e02]] +si_pbesol_upsilon1_34 = [ + [1.886404, -1.549705, -1.126055], + [-1.549705, 1.886404, -1.126055], + [-1.126055, -1.126055, -0.006187], +] si_pbesol_111_freqs = [ - 0.00000, 0.00000, 0.00000, 4.02839, 4.02839, 4.02839, - 4.02839, 4.02839, 4.02839, 12.13724, 12.13724, 12.13724, - 12.13724, 12.13724, 12.13724, 13.71746, 13.71746, 13.71746, - 13.71746, 13.71746, 13.71746, 15.24974, 15.24974, 15.24974] + 0.00000, + 0.00000, + 0.00000, + 4.02839, + 4.02839, + 4.02839, + 4.02839, + 4.02839, + 4.02839, + 12.13724, + 12.13724, + 12.13724, + 12.13724, + 12.13724, + 12.13724, + 13.71746, + 13.71746, + 13.71746, + 13.71746, + 13.71746, + 13.71746, + 15.24974, + 15.24974, + 15.24974, +] def get_supercell_phonon(ph3): + """Return SupercellPhonon class instance.""" ph3.mesh_numbers = [1, 1, 1] ph3.init_phph_interaction() fc2 = ph3.dynamical_matrix.force_constants @@ -35,37 +60,43 @@ def get_supercell_phonon(ph3): def mass_sand(matrix, mass): + """Calculate mass sandwich.""" return ((matrix * mass).T * mass).T def mass_inv(matrix, mass): + """Calculate inverse mass sandwich.""" bare = mass_sand(matrix, mass) inv_bare = np.linalg.pinv(bare) return mass_sand(inv_bare, mass) def test_SupercellPhonon(si_pbesol_111): + """Test of SupercellPhonon class.""" sph = get_supercell_phonon(si_pbesol_111) - np.testing.assert_allclose( - si_pbesol_111_freqs, sph.frequencies, atol=1e-4) + np.testing.assert_allclose(si_pbesol_111_freqs, sph.frequencies, atol=1e-4) def test_disp_corr_matrix_mesh(si_pbesol): + """Test of DispCorrMatrixMesh class.""" si_pbesol.mesh_numbers = [9, 9, 9] si_pbesol.init_phph_interaction() dynmat = si_pbesol.dynamical_matrix uu = DispCorrMatrixMesh(dynmat.primitive, dynmat.supercell) - qpoints_phonon = QpointsPhonon(uu.commensurate_points, - dynmat, - with_eigenvectors=True) + qpoints_phonon = QpointsPhonon( + uu.commensurate_points, dynmat, with_eigenvectors=True + ) freqs = qpoints_phonon.frequencies eigvecs = qpoints_phonon.eigenvectors uu.run(freqs, eigvecs, 300.0) np.testing.assert_allclose( - si_pbesol_upsilon0_0, uu.upsilon_matrix[0:3, 0:3], atol=1e-4) + si_pbesol_upsilon0_0, uu.upsilon_matrix[0:3, 0:3], atol=1e-4 + ) np.testing.assert_allclose( - si_pbesol_upsilon1_34, uu.upsilon_matrix[1 * 3: 2 * 3, 34 * 3: 35 * 3], - atol=1e-4) + si_pbesol_upsilon1_34, + uu.upsilon_matrix[1 * 3 : 2 * 3, 34 * 3 : 35 * 3], + atol=1e-4, + ) sqrt_masses = np.repeat(np.sqrt(si_pbesol.supercell.masses), 3) uu_inv = mass_inv(uu.psi_matrix, sqrt_masses) @@ -73,22 +104,27 @@ def test_disp_corr_matrix_mesh(si_pbesol): def test_disp_corr_matrix(si_pbesol): + """Test of DispCorrMatrix class.""" supercell_phonon = get_supercell_phonon(si_pbesol) uu = DispCorrMatrix(supercell_phonon) uu.run(300.0) np.testing.assert_allclose( - si_pbesol_upsilon0_0, uu.upsilon_matrix[0:3, 0:3], atol=1e-4) + si_pbesol_upsilon0_0, uu.upsilon_matrix[0:3, 0:3], atol=1e-4 + ) np.testing.assert_allclose( si_pbesol_upsilon1_34, - uu.upsilon_matrix[1 * 3: 2 * 3, 34 * 3: 35 * 3], - atol=1e-4) + uu.upsilon_matrix[1 * 3 : 2 * 3, 34 * 3 : 35 * 3], + atol=1e-4, + ) def test_disp_corr_matrix_si(si_pbesol): + """Test of DispCorrMatrix class with Si.""" _test_disp_corr_matrix(si_pbesol) def test_disp_corr_matrix_nacl(nacl_pbe): + """Test of DispCorrMatrix class with NaCl.""" _test_disp_corr_matrix(nacl_pbe) @@ -99,30 +135,27 @@ def _test_disp_corr_matrix(ph3): sqrt_masses = np.repeat(np.sqrt(ph3.supercell.masses), 3) uu_inv = mass_inv(uu.psi_matrix, sqrt_masses) - np.testing.assert_allclose( - uu.upsilon_matrix, uu_inv, atol=1e-8, rtol=0) + np.testing.assert_allclose(uu.upsilon_matrix, uu_inv, atol=1e-8, rtol=0) - rd = RandomDisplacements(ph3.supercell, - ph3.primitive, - ph3.fc2) + rd = RandomDisplacements(ph3.supercell, ph3.primitive, ph3.fc2) rd.run_correlation_matrix(300) - rd_uu_inv = np.transpose(rd.uu_inv, - axes=[0, 2, 1, 3]).reshape(uu_inv.shape) - np.testing.assert_allclose( - uu.upsilon_matrix, rd_uu_inv, atol=1e-8, rtol=0) + rd_uu_inv = np.transpose(rd.uu_inv, axes=[0, 2, 1, 3]).reshape(uu_inv.shape) + np.testing.assert_allclose(uu.upsilon_matrix, rd_uu_inv, atol=1e-8, rtol=0) def test_fc3(si_pbesol_iterha_111): + """Test of ThirdOrderFC class.""" try: - import alm + import alm # noqa F401 except ModuleNotFoundError: pytest.skip("Skip this test because ALM module was not found.") ph = si_pbesol_iterha_111 - ph.produce_force_constants(calculate_full_force_constants=True, - fc_calculator='alm') + ph.produce_force_constants(calculate_full_force_constants=True, fc_calculator="alm") supercell_phonon = SupercellPhonon( - ph.supercell, ph.force_constants, - frequency_factor_to_THz=ph.unit_conversion_factor) + ph.supercell, + ph.force_constants, + frequency_factor_to_THz=ph.unit_conversion_factor, + ) fc3 = ThirdOrderFC(ph.displacements, ph.forces, supercell_phonon) fc3.run(T=300) From 994bda2f364f75a4d8332d86ef5232c570a9125d Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Fri, 15 Oct 2021 19:30:08 +0900 Subject: [PATCH 15/34] Refactoring using pre-commit setting --- .../launch_phono3py_ZnTe_PBEsol_222.py | 2 + phono3py/api_isotope.py | 12 +++++- phono3py/api_jointdos.py | 11 +++++- phono3py/cui/show_log.py | 6 +++ phono3py/cui/triplets_info.py | 3 ++ phono3py/interface/calculator.py | 4 ++ phono3py/interface/fc_calculator.py | 2 +- phono3py/other/__init__.py | 1 + phono3py/other/isotope.py | 2 +- phono3py/phonon/__init__.py | 1 + phono3py/phonon3/__init__.py | 1 + phono3py/phonon3/dataset.py | 4 +- phono3py/phonon3/real_self_energy.py | 39 +++++++++++++------ phono3py/phonon3/spectral_function.py | 22 +++++++---- phono3py/sscha/sscha.py | 4 +- test/other/__init__.py | 1 + test/phonon/test_grid.py | 12 +++--- test/phonon3/__init__.py | 1 + test/phonon3/test_joint_dos.py | 6 +++ test/phonon3/test_kappa_RTA.py | 14 +++++++ test/sscha/__init__.py | 1 + 21 files changed, 113 insertions(+), 36 deletions(-) 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 d15d2341..136a6a49 100644 --- a/example/zb-ZnTe-PBEsol/launch_phono3py_ZnTe_PBEsol_222.py +++ b/example/zb-ZnTe-PBEsol/launch_phono3py_ZnTe_PBEsol_222.py @@ -12,6 +12,7 @@ Dict = DataFactory("dict") def get_settings(cutoff_energy, is_nac=False): + """Set up parameters.""" unitcell_str = """ Zn Te 1.0 6.0653118499999996 0.0000000000000000 0.0000000000000000 @@ -99,6 +100,7 @@ Direct def launch_phono3py(cutoff_energy=350, is_nac=False): + """Launch calculation.""" structure, forces_config, nac_config, phonon_settings = get_settings( cutoff_energy, is_nac ) diff --git a/phono3py/api_isotope.py b/phono3py/api_isotope.py index 7741876b..d1d828e4 100644 --- a/phono3py/api_isotope.py +++ b/phono3py/api_isotope.py @@ -1,3 +1,4 @@ +"""API for isotope scattering.""" # Copyright (C) 2019 Atsushi Togo # All rights reserved. # @@ -37,7 +38,9 @@ from phonopy.units import VaspToTHz from phono3py.other.isotope import Isotope -class Phono3pyIsotope(object): +class Phono3pyIsotope: + """Class to calculate isotope scattering.""" + def __init__( self, mesh, @@ -51,6 +54,7 @@ class Phono3pyIsotope(object): cutoff_frequency=None, lapack_zheev_uplo="L", ): + """Init method.""" if sigmas is None: self._sigmas = [ None, @@ -72,13 +76,16 @@ class Phono3pyIsotope(object): @property def dynamical_matrix(self): + """Return dynamical matrix class instance.""" return self._iso.dynamical_matrix @property def grid(self): + """Return BZGrid class instance.""" return self._iso.bz_grid def run(self, grid_points): + """Calculate isotope scattering.""" gamma = np.zeros( (len(self._sigmas), len(grid_points), len(self._iso.band_indices)), dtype="double", @@ -121,6 +128,7 @@ class Phono3pyIsotope(object): frequency_scale_factor=None, decimals=None, ): + """Initialize dynamical matrix.""" self._primitive = primitive self._iso.init_dynamical_matrix( fc2, @@ -132,8 +140,10 @@ class Phono3pyIsotope(object): ) def set_sigma(self, sigma): + """Set sigma. None means tetrahedron method.""" self._iso.set_sigma(sigma) @property def gamma(self): + """Return calculated isotope scattering.""" return self._gamma diff --git a/phono3py/api_jointdos.py b/phono3py/api_jointdos.py index 8564c1a1..54fb1a15 100644 --- a/phono3py/api_jointdos.py +++ b/phono3py/api_jointdos.py @@ -1,3 +1,4 @@ +"""API for joint-density-of-states calculation.""" # Copyright (C) 2019 Atsushi Togo # All rights reserved. # @@ -41,7 +42,9 @@ from phono3py.phonon.grid import BZGrid from phono3py.file_IO import write_joint_dos -class Phono3pyJointDos(object): +class Phono3pyJointDos: + """Class to calculate joint-density-of-states.""" + def __init__( self, supercell, @@ -63,6 +66,7 @@ class Phono3pyJointDos(object): output_filename=None, log_level=0, ): + """Init method.""" if sigmas is None: self._sigmas = [None] else: @@ -104,9 +108,11 @@ class Phono3pyJointDos(object): @property def grid(self): + """Return BZGrid class instance.""" return self._bz_grid def run(self, grid_points, write_jdos=False): + """Calculate joint-density-of-states.""" if self._log_level: print( "--------------------------------- Joint DOS " @@ -151,14 +157,17 @@ class Phono3pyJointDos(object): @property def dynamical_matrix(self): + """Return DynamicalMatrix class instance.""" return self._jdos.dynamical_matrix @property def frequency_points(self): + """Return frequency points.""" return self._jdos.frequency_points @property def joint_dos(self): + """Return calculated joint-density-of-states.""" return self._jdos.joint_dos def _write(self, gp, sigma=None): diff --git a/phono3py/cui/show_log.py b/phono3py/cui/show_log.py index 50fc8432..62a49f44 100644 --- a/phono3py/cui/show_log.py +++ b/phono3py/cui/show_log.py @@ -1,3 +1,4 @@ +"""Utilities to show various logs for main CUI script.""" # Copyright (C) 2015 Atsushi Togo # All rights reserved. # @@ -40,6 +41,7 @@ from phonopy.structure.cells import print_cell def show_general_settings( settings, run_mode, phono3py, cell_filename, input_filename, output_filename ): + """Show general setting information.""" is_primitive_axes_auto = ( type(phono3py.primitive_matrix) is str and phono3py.primitive_matrix == "auto" ) @@ -84,6 +86,7 @@ def show_general_settings( def show_phono3py_cells(phono3py, settings): + """Show crystal structures.""" symmetry = phono3py.symmetry primitive = phono3py.primitive supercell = phono3py.supercell @@ -104,6 +107,7 @@ def show_phono3py_cells(phono3py, settings): def show_phono3py_force_constants_settings(settings): + """Show force constants settings.""" read_fc3 = settings.read_fc3 read_fc2 = settings.read_fc2 symmetrize_fc3r = settings.is_symmetrize_fc3_r or settings.fc_symmetry @@ -138,6 +142,7 @@ def show_phono3py_force_constants_settings(settings): def show_phono3py_settings(phono3py, settings, updated_settings, log_level): + """Show general calculation settings.""" sigmas = updated_settings["sigmas"] temperatures = updated_settings["temperatures"] temperature_points = updated_settings["temperature_points"] @@ -227,6 +232,7 @@ def show_phono3py_settings(phono3py, settings, updated_settings, log_level): def show_grid_points(grid_points): + """Show grid point list.""" text = "Grid point to be calculated: " if len(grid_points) > 8: for i, gp in enumerate(grid_points): diff --git a/phono3py/cui/triplets_info.py b/phono3py/cui/triplets_info.py index d18c0394..e94bc1bd 100644 --- a/phono3py/cui/triplets_info.py +++ b/phono3py/cui/triplets_info.py @@ -1,3 +1,4 @@ +"""Show and write triplets information.""" # Copyright (C) 2015 Atsushi Togo # All rights reserved. # @@ -49,6 +50,7 @@ def write_grid_points( compression="gzip", filename=None, ): + """Write grid points into files.""" ir_grid_points, ir_grid_weights = _get_ir_grid_points( bz_grid, is_kappa_star=is_kappa_star ) @@ -101,6 +103,7 @@ def write_grid_points( def show_num_triplets( primitive, bz_grid, band_indices=None, grid_points=None, is_kappa_star=True ): + """Show numbers of triplets at grid points.""" tp_nums = _TripletsNumbers(bz_grid, is_kappa_star=is_kappa_star) num_band = len(primitive) * 3 if band_indices is None: diff --git a/phono3py/interface/calculator.py b/phono3py/interface/calculator.py index a62da670..f5161a04 100644 --- a/phono3py/interface/calculator.py +++ b/phono3py/interface/calculator.py @@ -1,3 +1,4 @@ +"""Utilities of calculator interfaces.""" # Copyright (C) 2020 Atsushi Togo # All rights reserved. # @@ -55,6 +56,7 @@ calculator_info = { def get_default_displacement_distance(interface_mode): + """Return default displacement distances for calculators.""" if interface_mode in ("qe", "abinit", "turbomole"): displacement_distance = 0.06 elif interface_mode == "crystal": @@ -65,6 +67,7 @@ def get_default_displacement_distance(interface_mode): def get_additional_info_to_write_supercells(interface_mode, supercell_matrix): + """Return additional information to write supercells for calculators.""" additional_info = {} if interface_mode == "crystal": additional_info["template_file"] = "TEMPLATE3" @@ -75,6 +78,7 @@ def get_additional_info_to_write_supercells(interface_mode, supercell_matrix): def get_additional_info_to_write_fc2_supercells( interface_mode, phonon_supercell_matrix ): + """Return additional information to write fc2-supercells for calculators.""" additional_info = {} if interface_mode == "qe": additional_info["pre_filename"] = "supercell_fc2" diff --git a/phono3py/interface/fc_calculator.py b/phono3py/interface/fc_calculator.py index 8bfeff7f..c80cf1ce 100644 --- a/phono3py/interface/fc_calculator.py +++ b/phono3py/interface/fc_calculator.py @@ -1,3 +1,4 @@ +"""Interfaces for force constants calculators.""" # Copyright (C) 2019 Atsushi Togo # All rights reserved. # @@ -83,7 +84,6 @@ def get_fc3( for supercell. """ - if fc_calculator == "alm": from phono3py.interface.alm import get_fc3 diff --git a/phono3py/other/__init__.py b/phono3py/other/__init__.py index e69de29b..2cea0f50 100644 --- a/phono3py/other/__init__.py +++ b/phono3py/other/__init__.py @@ -0,0 +1 @@ +"""Routines for various scatterings.""" diff --git a/phono3py/other/isotope.py b/phono3py/other/isotope.py index 1d99b7b7..b529113a 100644 --- a/phono3py/other/isotope.py +++ b/phono3py/other/isotope.py @@ -180,7 +180,7 @@ class Isotope(object): @property def bz_grid(self): - """Return BZ grid.""" + """Return BZgrid class instance.""" return self._bz_grid @property diff --git a/phono3py/phonon/__init__.py b/phono3py/phonon/__init__.py index e69de29b..f2e13216 100644 --- a/phono3py/phonon/__init__.py +++ b/phono3py/phonon/__init__.py @@ -0,0 +1 @@ +"""Routines for harmonic phonon related properties.""" diff --git a/phono3py/phonon3/__init__.py b/phono3py/phonon3/__init__.py index e69de29b..9f1a03af 100644 --- a/phono3py/phonon3/__init__.py +++ b/phono3py/phonon3/__init__.py @@ -0,0 +1 @@ +"""Ph-ph interaction related routines.""" diff --git a/phono3py/phonon3/dataset.py b/phono3py/phonon3/dataset.py index 93ce3a92..e896056b 100644 --- a/phono3py/phonon3/dataset.py +++ b/phono3py/phonon3/dataset.py @@ -1,3 +1,4 @@ +"""Parse displacement dataset.""" # Copyright (C) 2020 Atsushi Togo # All rights reserved. # @@ -36,7 +37,7 @@ import numpy as np def get_displacements_and_forces_fc3(disp_dataset): - """Returns displacements and forces from disp_dataset + """Return displacements and forces from disp_dataset. Note ---- @@ -59,7 +60,6 @@ def get_displacements_and_forces_fc3(disp_dataset): None is returned when forces don't exist. """ - if "first_atoms" in disp_dataset: natom = disp_dataset["natom"] ndisp = len(disp_dataset["first_atoms"]) diff --git a/phono3py/phonon3/real_self_energy.py b/phono3py/phonon3/real_self_energy.py index 8f248232..2e2b4a5c 100644 --- a/phono3py/phonon3/real_self_energy.py +++ b/phono3py/phonon3/real_self_energy.py @@ -1,3 +1,4 @@ +"""Calculate real-part of self-energy of bubble diagram.""" # Copyright (C) 2020 Atsushi Togo # All rights reserved. # @@ -57,7 +58,7 @@ def get_real_self_energy( output_filename=None, log_level=0, ): - """Real part of self energy at frequency points + """Real part of self energy at frequency points. Band indices to be calculated at are kept in Interaction instance. @@ -115,7 +116,6 @@ def get_real_self_energy( band_indices, frequency_points) """ - if epsilons is None: _epsilons = [ None, @@ -250,6 +250,7 @@ def write_real_self_energy( is_mesh_symmetry=True, log_level=0, ): + """Write real-part of self-energies into files.""" if epsilons is None: _epsilons = [ RealSelfEnergy.default_epsilon, @@ -282,11 +283,8 @@ def write_real_self_energy( ) -class RealSelfEnergy(object): - - default_epsilon = 0.05 - - """ +class RealSelfEnergy: + """Class to calculate real-part of self-energy of bubble diagram. About the parameter epsilon --------------------------- @@ -305,10 +303,12 @@ class RealSelfEnergy(object): """ + default_epsilon = 0.05 + def __init__( self, interaction, grid_point=None, temperature=None, epsilon=None, lang="C" ): - """ + """Init method. Parameters ---------- @@ -323,7 +323,6 @@ class RealSelfEnergy(object): Parameter explained above. The unit is consisered as THz. """ - self._pp = interaction self.epsilon = epsilon if temperature is None: @@ -348,6 +347,7 @@ class RealSelfEnergy(object): self._unit_conversion = 18 / (Hbar * EV) ** 2 / (2 * np.pi * THz) ** 2 * EV ** 2 def run(self): + """Calculate real-part of self-energies.""" if self._pp_strength is None: self.run_interaction() @@ -362,6 +362,7 @@ class RealSelfEnergy(object): self._run_with_frequency_points() def run_interaction(self): + """Calculate ph-ph interaction strength.""" self._pp.run(lang=self._lang) self._pp_strength = self._pp.interaction_strength (self._frequencies, self._eigenvectors) = self._pp.get_phonons()[:2] @@ -370,6 +371,7 @@ class RealSelfEnergy(object): @property def real_self_energy(self): + """Return calculated real-part of self-energies.""" if self._cutoff_frequency is None: return self._real_self_energies else: # Averaging frequency shifts by degenerate bands @@ -395,6 +397,7 @@ class RealSelfEnergy(object): @property def grid_point(self): + """Setter and getter of a grid point.""" return self._grid_point @grid_point.setter @@ -409,6 +412,11 @@ class RealSelfEnergy(object): @property def epsilon(self): + """Setter and getter of epsilon. + + See the detail about epsilon at docstring of this class. + + """ return self._epsilon @epsilon.setter @@ -420,6 +428,7 @@ class RealSelfEnergy(object): @property def temperature(self): + """Setter and getter of a temperature point.""" return self._temperature @temperature.setter @@ -431,6 +440,7 @@ class RealSelfEnergy(object): @property def frequency_points(self): + """Setter and getter of frequency points.""" return self._frequency_points @frequency_points.setter @@ -590,16 +600,17 @@ class RealSelfEnergy(object): def imag_to_real(im_part, frequency_points): + """Calculate real-part of self-energy from the imaginary-part.""" i2r = ImagToReal(im_part, frequency_points) i2r.run() return i2r.re_part, i2r.frequency_points class ImagToReal(object): - """Calculate real part of self-energy using Kramers-Kronig relation""" + """Calculate real part of self-energy using Kramers-Kronig relation.""" def __init__(self, im_part, frequency_points, diagram="bubble"): - """ + """Init method. Parameters ---------- @@ -615,7 +626,6 @@ class ImagToReal(object): Only bubble diagram is implemented currently. """ - if diagram == "bubble": ( self._im_part, @@ -630,13 +640,16 @@ class ImagToReal(object): @property def re_part(self): + """Return real part.""" return self._re_part @property def frequency_points(self): + """Return frequency points.""" return self._frequency_points def run(self, method="pick_one"): + """Calculate real part.""" if method == "pick_one": self._re_part, self._frequency_points = self._pick_one() elif method == "half_shift": @@ -645,6 +658,7 @@ class ImagToReal(object): raise RuntimeError("No method is found.") def _pick_one(self): + """Calculate real-part with same frequency points excluding one point.""" re_part = [] fpoints = [] coef = self._df / np.pi @@ -661,6 +675,7 @@ class ImagToReal(object): return (np.array(re_part, dtype="double"), np.array(fpoints, dtype="double")) def _half_shift(self): + """Calculate real-part with half-shifted frequency points.""" re_part = [] fpoints = [] coef = self._df / np.pi diff --git a/phono3py/phonon3/spectral_function.py b/phono3py/phonon3/spectral_function.py index d9e7b298..aefe6abf 100644 --- a/phono3py/phonon3/spectral_function.py +++ b/phono3py/phonon3/spectral_function.py @@ -1,3 +1,4 @@ +"""Calculate spectral function due to bubble diagram.""" # Copyright (C) 2020 Atsushi Togo # All rights reserved. # @@ -61,7 +62,7 @@ def run_spectral_function( output_filename=None, log_level=0, ): - """Spectral function of self energy at frequency points + """Spectral function of self energy at frequency points. Band indices to be calculated at are kept in Interaction instance. @@ -112,7 +113,6 @@ def run_spectral_function( spf.half_linewidths, spf.shifts have the same shape as above. """ - spf = SpectralFunction( interaction, grid_points, @@ -169,7 +169,7 @@ def run_spectral_function( class SpectralFunction(object): - """Calculate spectral function""" + """Calculate spectral function due to bubble diagram.""" def __init__( self, @@ -183,6 +183,7 @@ class SpectralFunction(object): temperatures=None, log_level=0, ): + """Init method.""" self._interaction = interaction self._grid_points = grid_points self._frequency_points_in = frequency_points @@ -205,18 +206,18 @@ class SpectralFunction(object): self._gp_index = None def run(self): + """Calculate spectral function over grid points.""" for gp_index in self: pass def __iter__(self): + """Initialize iterator.""" self._prepare() return self - def next(self): - return self.__next__() - def __next__(self): + """Calculate at next grid point.""" if self._gp_index >= len(self._grid_points): if self._log_level: print("-" * 74) @@ -248,26 +249,32 @@ class SpectralFunction(object): @property def spectral_functions(self): + """Return calculated spectral functions.""" return self._spectral_functions @property def shifts(self): + """Return real part of self energies.""" return self._deltas @property def half_linewidths(self): + """Return imaginary part of self energies.""" return self._gammas @property def frequency_points(self): + """Return frequency points.""" return self._frequency_points @property def grid_points(self): + """Return grid points.""" return self._grid_points @property def sigmas(self): + """Return sigmas.""" return self._sigmas def _prepare(self): @@ -317,7 +324,7 @@ class SpectralFunction(object): assert (np.abs(self._frequency_points - fpoints) < 1e-8).all() def _run_spectral_function(self, i, grid_point, sigma_i): - """Compute spectral functions from self-energies + """Compute spectral functions from self-energies. Note ---- @@ -332,7 +339,6 @@ class SpectralFunction(object): approximately 1 for each phonon mode. """ - if self._log_level: print("* Spectral function") frequencies = self._interaction.get_phonons()[0] diff --git a/phono3py/sscha/sscha.py b/phono3py/sscha/sscha.py index dfdae2bc..60e4b422 100644 --- a/phono3py/sscha/sscha.py +++ b/phono3py/sscha/sscha.py @@ -270,7 +270,6 @@ class DispCorrMatrixMesh: shape=(grid_point, band, band), dtype='double', order='C' """ - condition = frequencies > self._cutoff_frequency _freqs = np.where(condition, frequencies, 1) _a = mode_length(_freqs, T) @@ -348,7 +347,6 @@ class SecondOrderFC(object): Phonons are ignored if they have frequencies less than this value. """ - assert displacements.shape == forces.shape shape = displacements.shape u = np.array(displacements.reshape(shape[0], -1), dtype="double", order="C") @@ -483,7 +481,7 @@ class ThirdOrderFC(object): @property def forces(self): - """Return input forces""" + """Return input forces.""" return self._forces @property diff --git a/test/other/__init__.py b/test/other/__init__.py index e69de29b..4c09bb81 100644 --- a/test/other/__init__.py +++ b/test/other/__init__.py @@ -0,0 +1 @@ +"""Tests for various scatterings.""" diff --git a/test/phonon/test_grid.py b/test/phonon/test_grid.py index ec9d5f66..baa54d2e 100644 --- a/test/phonon/test_grid.py +++ b/test/phonon/test_grid.py @@ -1,3 +1,4 @@ +"""Tests for grids.""" import numpy as np from phonopy.structure.tetrahedron_method import TetrahedronMethod from phono3py.phonon.grid import ( @@ -11,13 +12,12 @@ from phono3py.phonon.grid import ( def test_get_grid_point_from_address(agno2_cell): - """ + """Test for get_grid_point_from_address. Compare get_grid_point_from_address from spglib and that written in python with mesh numbers. """ - mesh = (10, 10, 10) for address in list(np.ndindex(mesh)): @@ -28,8 +28,7 @@ def test_get_grid_point_from_address(agno2_cell): def test_BZGrid(si_pbesol_111): - """Basis test of BZGrid type1 and type2""" - + """Tests of BZGrid type1 and type2.""" lat = si_pbesol_111.primitive.cell reclat = np.linalg.inv(lat) mesh = [4, 4, 4] @@ -118,13 +117,12 @@ def test_BZGrid(si_pbesol_111): def test_BZGrid_bzg2grg(si_pbesol_111): - """BZGrid to GRGrid + """Test of mapping of BZGrid to GRGrid. This mapping table is stored in BZGrid, but also determined by get_grid_point_from_address. This test checks the consistency. """ - lat = si_pbesol_111.primitive.cell mesh = [4, 4, 4] bzgrid1 = BZGrid(mesh, lattice=lat, store_dense_gp_map=False) @@ -141,7 +139,7 @@ def test_BZGrid_bzg2grg(si_pbesol_111): def test_BZGrid_SNF(si_pbesol_111): - """SNF in BZGrid""" + """Test of SNF in BZGrid.""" lat = si_pbesol_111.primitive.cell mesh = 10 bzgrid1 = BZGrid( diff --git a/test/phonon3/__init__.py b/test/phonon3/__init__.py index e69de29b..8349aa86 100644 --- a/test/phonon3/__init__.py +++ b/test/phonon3/__init__.py @@ -0,0 +1 @@ +"""Tests for ph-ph interaction routines.""" diff --git a/test/phonon3/test_joint_dos.py b/test/phonon3/test_joint_dos.py index 3a34b62b..b969758b 100644 --- a/test/phonon3/test_joint_dos.py +++ b/test/phonon3/test_joint_dos.py @@ -1,3 +1,4 @@ +"""Tests for joint-density-of-states.""" import numpy as np from phono3py.api_jointdos import Phono3pyJointDos @@ -164,6 +165,7 @@ nacl_jdos_12_at_300K = [ def test_jdos_si(si_pbesol): + """Test joint-DOS by Si.""" si_pbesol.mesh_numbers = [9, 9, 9] jdos = Phono3pyJointDos( si_pbesol.phonon_supercell, @@ -183,6 +185,7 @@ def test_jdos_si(si_pbesol): def test_jdso_si_nomeshsym(si_pbesol): + """Test joint-DOS without considering mesh symmetry by Si.""" si_pbesol.mesh_numbers = [9, 9, 9] jdos = Phono3pyJointDos( si_pbesol.phonon_supercell, @@ -203,6 +206,7 @@ def test_jdso_si_nomeshsym(si_pbesol): def test_jdos_nacl(nacl_pbe): + """Test joint-DOS by NaCl.""" nacl_pbe.mesh_numbers = [9, 9, 9] jdos = Phono3pyJointDos( nacl_pbe.phonon_supercell, @@ -223,6 +227,7 @@ def test_jdos_nacl(nacl_pbe): def test_jdos_nacl_gamma(nacl_pbe): + """Test joint-DOS at Gamma-point by NaCl.""" nacl_pbe.mesh_numbers = [9, 9, 9] jdos = Phono3pyJointDos( nacl_pbe.phonon_supercell, @@ -244,6 +249,7 @@ def test_jdos_nacl_gamma(nacl_pbe): def test_jdos_nacl_at_300K(nacl_pbe): + """Test joint-DOS at 300K by NaCl.""" nacl_pbe.mesh_numbers = [9, 9, 9] jdos = Phono3pyJointDos( nacl_pbe.phonon_supercell, diff --git a/test/phonon3/test_kappa_RTA.py b/test/phonon3/test_kappa_RTA.py index 60e09c04..11de97cf 100644 --- a/test/phonon3/test_kappa_RTA.py +++ b/test/phonon3/test_kappa_RTA.py @@ -23,21 +23,25 @@ aln_lda_kappa_RTA_with_sigmas = [213.820000, 213.820000, 224.800121, 0, 0, 0] def test_kappa_RTA_si(si_pbesol): + """Test RTA by Si.""" 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_si_full_pp(si_pbesol): + """Test RTA with full-pp by Si.""" 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_si_iso(si_pbesol): + """Test RTA with isotope scattering by Si.""" 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_si_with_sigma(si_pbesol): + """Test RTA with smearing method by Si.""" si_pbesol.sigmas = [ 0.1, ] @@ -47,6 +51,7 @@ def test_kappa_RTA_si_with_sigma(si_pbesol): def test_kappa_RTA_si_with_sigma_full_pp(si_pbesol): + """Test RTA with smearing method and full-pp by Si.""" si_pbesol.sigmas = [ 0.1, ] @@ -57,6 +62,7 @@ def test_kappa_RTA_si_with_sigma_full_pp(si_pbesol): def test_kappa_RTA_si_with_sigma_iso(si_pbesol): + """Test RTA with smearing method and isotope scattering by Si.""" si_pbesol.sigmas = [ 0.1, ] @@ -66,11 +72,13 @@ def test_kappa_RTA_si_with_sigma_iso(si_pbesol): def test_kappa_RTA_si_compact_fc(si_pbesol_compact_fc): + """Test RTA with compact-fc by Si.""" kappa = _get_kappa(si_pbesol_compact_fc, [9, 9, 9]).ravel() np.testing.assert_allclose(si_pbesol_kappa_RTA, kappa, atol=0.5) def test_kappa_RTA_si_nosym(si_pbesol, si_pbesol_nosym): + """Test RTA without considering symmetry by Si.""" si_pbesol_nosym.fc2 = si_pbesol.fc2 si_pbesol_nosym.fc3 = si_pbesol.fc3 kappa = _get_kappa(si_pbesol_nosym, [4, 4, 4]).reshape(-1, 3).sum(axis=1) @@ -79,6 +87,7 @@ def test_kappa_RTA_si_nosym(si_pbesol, si_pbesol_nosym): def test_kappa_RTA_si_nomeshsym(si_pbesol, si_pbesol_nomeshsym): + """Test RTA without considering mesh symmetry by Si.""" si_pbesol_nomeshsym.fc2 = si_pbesol.fc2 si_pbesol_nomeshsym.fc3 = si_pbesol.fc3 kappa = _get_kappa(si_pbesol_nomeshsym, [4, 4, 4]).ravel() @@ -87,6 +96,7 @@ def test_kappa_RTA_si_nomeshsym(si_pbesol, si_pbesol_nomeshsym): def test_kappa_RTA_si_N_U(si_pbesol): + """Test RTA with N and U scatterings by Si.""" ph3 = si_pbesol mesh = [4, 4, 4] is_N_U = True @@ -210,11 +220,13 @@ def test_kappa_RTA_si_N_U(si_pbesol): def test_kappa_RTA_nacl(nacl_pbe): + """Test RTA by NaCl.""" kappa = _get_kappa(nacl_pbe, [9, 9, 9]).ravel() np.testing.assert_allclose(nacl_pbe_kappa_RTA, kappa, atol=0.5) def test_kappa_RTA_nacl_with_sigma(nacl_pbe): + """Test RTA with smearing method by NaCl.""" nacl_pbe.sigmas = [ 0.1, ] @@ -226,11 +238,13 @@ def test_kappa_RTA_nacl_with_sigma(nacl_pbe): def test_kappa_RTA_aln(aln_lda): + """Test RTA by AlN.""" kappa = _get_kappa(aln_lda, [7, 7, 5]).ravel() np.testing.assert_allclose(aln_lda_kappa_RTA, kappa, atol=0.5) def test_kappa_RTA_aln_with_sigma(aln_lda): + """Test RTA with smearing method by AlN.""" aln_lda.sigmas = [ 0.1, ] diff --git a/test/sscha/__init__.py b/test/sscha/__init__.py index e69de29b..90db4b31 100644 --- a/test/sscha/__init__.py +++ b/test/sscha/__init__.py @@ -0,0 +1 @@ +"""Tests for SSCHA.""" From bf2cfe00332a1d24500de2ce02276432ad0b9477 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Sat, 16 Oct 2021 14:47:45 +0900 Subject: [PATCH 16/34] Set tests on python versions --- .github/workflows/phono3py-pytest-conda-rc.yml | 9 +++++---- .github/workflows/phono3py-pytest-conda.yml | 11 ++++++----- .github/workflows/publish-to-test-pypi.yml | 13 +++++++++---- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/phono3py-pytest-conda-rc.yml b/.github/workflows/phono3py-pytest-conda-rc.yml index 765f4a4d..99630dc0 100644 --- a/.github/workflows/phono3py-pytest-conda-rc.yml +++ b/.github/workflows/phono3py-pytest-conda-rc.yml @@ -9,21 +9,22 @@ jobs: build-linux: runs-on: ubuntu-latest strategy: - max-parallel: 5 + matrix: + python-version: [3.7, 3.8, 3.9] steps: - uses: actions/checkout@v2 - - name: Set up Python 3.8 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: ${{ matrix.python-version }} - name: Add conda to system path run: | # $CONDA is an environment variable pointing to the root of the miniconda directory echo $CONDA/bin >> $GITHUB_PATH - name: Install dependencies run: | - conda install --yes -c conda-forge python=3.8 + conda install --yes -c conda-forge python=${{ matrix.python-version }} conda install --yes -c conda-forge matplotlib-base pyyaml openblas libgfortran gcc_linux-64 gxx_linux-64 "h5py=3.1" scipy pytest codecov pytest-cov spglib pip install https://github.com/phonopy/phonopy/archive/rc.zip --user - name: Set up phono3py diff --git a/.github/workflows/phono3py-pytest-conda.yml b/.github/workflows/phono3py-pytest-conda.yml index cd037b33..c7827faa 100644 --- a/.github/workflows/phono3py-pytest-conda.yml +++ b/.github/workflows/phono3py-pytest-conda.yml @@ -10,22 +10,23 @@ jobs: build-linux: runs-on: ubuntu-latest strategy: - max-parallel: 5 + matrix: + python-version: [3.7, 3.8, 3.9] steps: - uses: actions/checkout@v2 - - name: Set up Python 3.8 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: ${{ matrix.python-version }} - name: Add conda to system path run: | # $CONDA is an environment variable pointing to the root of the miniconda directory echo $CONDA/bin >> $GITHUB_PATH - name: Install dependencies run: | - conda install --yes -c conda-forge python=3.8 - conda install --yes -c conda-forge matplotlib-base pyyaml openblas libgfortran gcc_linux-64 gxx_linux-64 "h5py=3.1.0" scipy pytest codecov pytest-cov spglib + conda install --yes -c conda-forge python=${{ matrix.python-version }} + conda install --yes -c conda-forge matplotlib-base pyyaml openblas libgfortran gcc_linux-64 gxx_linux-64 h5py scipy pytest codecov pytest-cov spglib pip install https://github.com/phonopy/phonopy/archive/develop.zip --user - name: Set up phono3py run: | diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index 54ef0297..01fb7feb 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -1,19 +1,24 @@ name: publish PyPI and TestPyPI -on: push +on: + push: + branches: + - master + - rc jobs: build-linux: runs-on: ubuntu-latest strategy: - max-parallel: 5 + matrix: + python-version: [3.9, ] steps: - uses: actions/checkout@v2 - - name: Set up Python 3.8 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: ${{ matrix.python-version }} - name: Make sdist run: | ./get_nanoversion.sh From da13eaf2a4c57c4ea1f37a8710508b609c67f78b Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Sun, 17 Oct 2021 12:24:02 +0900 Subject: [PATCH 17/34] Update README.md to explain pre-commit. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index d3d698cb..34f68de9 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,12 @@ phono3py repository. "python.formatting.provider": "black", ``` +- Use of pre-commit (https://pre-commit.com/) is encouraged. + - Installed by `pip install pre-commit`, `conda install pre_commit` or see + https://pre-commit.com/#install. + - pre-commit hook is installed by `pre-commit install`. + - pre-commit hook is run by `pre-commit run --all-files`. + ## Documentation Phono3py user documentation is written using python sphinx. The source files are From a7da15fc5a013c4be332acabbc76893576ac8c13 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 18 Oct 2021 19:52:21 +0000 Subject: [PATCH 18/34] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pycqa/pydocstyle: 6.0.0 → 6.1.1](https://github.com/pycqa/pydocstyle/compare/6.0.0...6.1.1) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6a044c56..8139a821 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,6 +26,6 @@ repos: - --line-length=88 - repo: https://github.com/pycqa/pydocstyle - rev: 6.0.0 + rev: 6.1.1 hooks: - id: pydocstyle From 923487c2bcaa8d37e51cd526e349e5f48c9fa92d Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Fri, 22 Oct 2021 10:04:47 +0900 Subject: [PATCH 19/34] Minor refactorings --- phono3py/api_phono3py.py | 4 +- phono3py/phonon3/conductivity.py | 105 +- phono3py/phonon3/conductivity_LBTE.py | 2349 +++++++++++++------------ phono3py/phonon3/conductivity_RTA.py | 901 +++++----- phono3py/phonon3/displacement_fc3.py | 13 +- phono3py/phonon3/fc3.py | 23 +- phono3py/phonon3/interaction.py | 2 +- 7 files changed, 1714 insertions(+), 1683 deletions(-) diff --git a/phono3py/api_phono3py.py b/phono3py/api_phono3py.py index d942ebe6..0c2f67c2 100644 --- a/phono3py/api_phono3py.py +++ b/phono3py/api_phono3py.py @@ -2375,8 +2375,8 @@ class Phono3py(object): self._primitive_symmetry = Symmetry( self._primitive, self._symprec, self._is_symmetry ) - if len(self._symmetry.get_pointgroup_operations()) != len( - self._primitive_symmetry.get_pointgroup_operations() + if len(self._symmetry.pointgroup_operations) != len( + self._primitive_symmetry.pointgroup_operations ): # noqa E129 print( "Warning: point group symmetries of supercell and primitive" diff --git a/phono3py/phonon3/conductivity.py b/phono3py/phonon3/conductivity.py index 817af536..23273f70 100644 --- a/phono3py/phonon3/conductivity.py +++ b/phono3py/phonon3/conductivity.py @@ -35,6 +35,7 @@ import warnings import textwrap +from typing import Optional, List import numpy as np from phonopy.phonon.group_velocity import GroupVelocity from phonopy.harmonic.force_constants import similarity_transformation @@ -42,6 +43,7 @@ from phonopy.phonon.thermal_properties import mode_cv as get_mode_cv from phonopy.units import THzToEv, EV, THz, Angstrom from phono3py.file_IO import write_pp_to_hdf5 from phono3py.phonon3.triplets import get_all_triplets +from phono3py.phonon3.interaction import Interaction from phono3py.other.isotope import Isotope from phono3py.phonon.grid import get_ir_grid_points, get_grid_points_by_rotations @@ -50,49 +52,15 @@ unit_to_WmK = ( ) # 2pi comes from definition of lifetime. -def all_bands_exist(interaction): - """Return if all bands are selected or not.""" - band_indices = interaction.band_indices - num_band = len(interaction.primitive) * 3 - if len(band_indices) == num_band: - if (band_indices - np.arange(num_band) == 0).all(): - return True - return False - - -def write_pp(conductivity, pp, i, filename=None, compression="gzip"): - """Write ph-ph interaction strength in hdf5 file.""" - grid_point = conductivity.grid_points[i] - sigmas = conductivity.sigmas - sigma_cutoff = conductivity.sigma_cutoff_width - mesh = conductivity.mesh_numbers - triplets, weights, _, _ = pp.get_triplets_at_q() - all_triplets = get_all_triplets(grid_point, pp.bz_grid) - - if len(sigmas) > 1: - print("Multiple smearing parameters were given. The last one in ") - print("ph-ph interaction calculations was written in the file.") - - write_pp_to_hdf5( - mesh, - pp=pp.interaction_strength, - g_zero=pp.zero_value_positions, - grid_point=grid_point, - triplet=triplets, - weight=weights, - triplet_all=all_triplets, - sigma=sigmas[-1], - sigma_cutoff=sigma_cutoff, - filename=filename, - compression=compression, - ) - - class ConductivityBase: """Base class of Conductivity classes.""" def __init__( - self, interaction, grid_points=None, is_kappa_star=True, gv_delta_q=None + self, + interaction: Interaction, + grid_points=None, + is_kappa_star=True, + gv_delta_q=None, ): """Init method. @@ -112,7 +80,7 @@ class ConductivityBase: See phonopy's GroupVelocity class. Default is None. """ - self._pp = interaction + self._pp: Interaction = interaction self._is_kappa_star = is_kappa_star self._rotations_cartesian = None @@ -184,10 +152,10 @@ class Conductivity(ConductivityBase): def __init__( self, - interaction, + interaction: Interaction, grid_points=None, temperatures=None, - sigmas=None, + sigmas: Optional[List] = None, sigma_cutoff=None, is_isotope=False, mass_variances=None, @@ -198,15 +166,15 @@ class Conductivity(ConductivityBase): log_level=0, ): """Init method.""" - self._pp = None + self._pp: Interaction + self._qpoints: np.ndarray + self._gv_obj: GroupVelocity self._is_kappa_star = None self._grid_points = None self._grid_weights = None self._ir_grid_points = None self._ir_grid_weights = None - self._qpoints = None self._point_operations = None - self._gv_obj = None super().__init__( interaction, @@ -218,7 +186,8 @@ class Conductivity(ConductivityBase): self._is_full_pp = is_full_pp self._log_level = log_level - self._grid_point_count = 0 + self._grid_point_count: int = 0 + self._sigmas: Optional[List] if sigmas is None: self._sigmas = [] else: @@ -784,3 +753,47 @@ class Conductivity(ConductivityBase): ) % tuple(self._mass_variances) ) + + +def all_bands_exist(interaction: Interaction): + """Return if all bands are selected or not.""" + band_indices = interaction.band_indices + num_band = len(interaction.primitive) * 3 + if len(band_indices) == num_band: + if (band_indices - np.arange(num_band) == 0).all(): + return True + return False + + +def write_pp( + conductivity: Conductivity, + pp: Interaction, + i, + filename=None, + compression="gzip", +): + """Write ph-ph interaction strength in hdf5 file.""" + grid_point = conductivity.grid_points[i] + sigmas = conductivity.sigmas + sigma_cutoff = conductivity.sigma_cutoff_width + mesh = conductivity.mesh_numbers + triplets, weights, _, _ = pp.get_triplets_at_q() + all_triplets = get_all_triplets(grid_point, pp.bz_grid) + + if len(sigmas) > 1: + print("Multiple smearing parameters were given. The last one in ") + print("ph-ph interaction calculations was written in the file.") + + write_pp_to_hdf5( + mesh, + pp=pp.interaction_strength, + g_zero=pp.zero_value_positions, + grid_point=grid_point, + triplet=triplets, + weight=weights, + triplet_all=all_triplets, + sigma=sigmas[-1], + sigma_cutoff=sigma_cutoff, + filename=filename, + compression=compression, + ) diff --git a/phono3py/phonon3/conductivity_LBTE.py b/phono3py/phonon3/conductivity_LBTE.py index 76673af6..2b2fde4f 100644 --- a/phono3py/phonon3/conductivity_LBTE.py +++ b/phono3py/phonon3/conductivity_LBTE.py @@ -36,10 +36,13 @@ import sys import time import warnings +from typing import List import numpy as np from phonopy.phonon.degeneracy import degenerate_sets +from phonopy.phonon.group_velocity import GroupVelocity from phono3py.phonon3.conductivity import Conductivity, all_bands_exist, unit_to_WmK from phono3py.phonon3.conductivity import write_pp as _write_pp +from phono3py.phonon3.interaction import Interaction from phono3py.phonon3.collision_matrix import CollisionMatrix from phono3py.phonon.grid import get_grid_points_by_rotations from phono3py.file_IO import ( @@ -53,6 +56,1179 @@ from phono3py.file_IO import ( from phonopy.units import THzToEv, Kb +class Conductivity_LBTE(Conductivity): + """Lattice thermal conductivity calculation by direct solution.""" + + def __init__( + self, + interaction: Interaction, + grid_points=None, + temperatures=None, + sigmas=None, + sigma_cutoff=None, + is_isotope=False, + mass_variances=None, + boundary_mfp=None, # in micrometre + solve_collective_phonon=False, + is_reducible_collision_matrix=False, + is_kappa_star=True, + gv_delta_q=None, # finite difference for group veolocity + is_full_pp=False, + read_pp=False, + pp_filename=None, + pinv_cutoff=1.0e-8, + pinv_solver=0, + log_level=0, + ): + """Init method.""" + self._pp: Interaction + self._gv_obj: GroupVelocity + self._sigmas: List + self._grid_point_count: int + self._temperatures = None + self._sigma_cutoff = None + self._is_kappa_star = None + self._is_full_pp = None + self._log_level = None + self._boundary_mfp = None + + self._point_operations = None + self._rotations_cartesian = None + + self._grid_points = None + self._grid_weights = None + self._ir_grid_points = None + self._ir_grid_weights = None + + self._kappa = None + self._mode_kappa = None + self._kappa_RTA = None + self._mode_kappa_RTA = None + + self._read_gamma = False + self._read_gamma_iso = False + + self._frequencies = None + self._cv = None + self._gv = None + self._f_vectors = None + self._gv_sum2 = None + self._mfp = None + self._gamma = None + self._gamma_iso = None + self._averaged_pp_interaction = None + + self._conversion_factor = None + + self._is_isotope = None + self._isotope = None + self._mass_variances = None + + self._collision_eigenvalues = None + + Conductivity.__init__( + self, + interaction, + grid_points=grid_points, + temperatures=temperatures, + sigmas=sigmas, + sigma_cutoff=sigma_cutoff, + is_isotope=is_isotope, + mass_variances=mass_variances, + boundary_mfp=boundary_mfp, + is_kappa_star=is_kappa_star, + gv_delta_q=gv_delta_q, + is_full_pp=is_full_pp, + log_level=log_level, + ) + + self._is_reducible_collision_matrix = is_reducible_collision_matrix + self._solve_collective_phonon = solve_collective_phonon + if not self._is_kappa_star: + self._is_reducible_collision_matrix = True + self._collision_matrix = None + self._read_pp = read_pp + self._pp_filename = pp_filename + self._pinv_cutoff = pinv_cutoff + self._pinv_solver = pinv_solver + + if grid_points is None: + self._all_grid_points = True + else: + self._all_grid_points = False + + if self._temperatures is not None: + self._allocate_values() + + def set_kappa_at_sigmas(self): + """Calculate lattice thermal conductivity from collision matrix.""" + if len(self._grid_points) != len(self._ir_grid_points): + print("Collision matrix is not well created.") + import sys + + sys.exit(1) + else: + weights = self._prepare_collision_matrix() + self._set_kappa_at_sigmas(weights) + + def get_f_vectors(self): + """Return f vectors.""" + return self._f_vectors + + @property + def collision_matrix(self): + """Setter and getter of collision matrix.""" + return self._collision_matrix + + @collision_matrix.setter + def collision_matrix(self, collision_matrix): + self._collision_matrix = collision_matrix + + def get_collision_matrix(self): + """Return collision matrix.""" + warnings.warn( + "Use attribute, Conductivity_LBTE.collision_matrix " + "instead of Conductivity_LBTE.get_collision_matrix().", + DeprecationWarning, + ) + return self.collision_matrix + + def set_collision_matrix(self, collision_matrix): + """Set collision matrix.""" + warnings.warn( + "Use attribute, Conductivity_LBTE.collision_matrix " + "instead of Conductivity_LBTE.set_collision_matrix().", + DeprecationWarning, + ) + self.collision_matrix = collision_matrix + + def get_collision_eigenvalues(self): + """Return eigenvalues of collision matrix.""" + return self._collision_eigenvalues + + def get_mean_free_path(self): + """Return mean free path.""" + return self._mfp + + def get_frequencies_all(self): + """Return phonon frequencies on GR-grid.""" + return self._frequencies[self._pp.bz_grid.grg2bzg] + + def get_kappa_RTA(self): + """Return RTA lattice thermal conductivity.""" + return self._kappa_RTA + + def get_mode_kappa_RTA(self): + """Return RTA mode lattice thermal conductivities.""" + return self._mode_kappa_RTA + + def delete_gp_collision_and_pp(self): + """Deallocate large arrays.""" + self._collision.delete_integration_weights() + self._pp.delete_interaction_strength() + + def _run_at_grid_point(self): + """Calculate properties at a grid point.""" + i = self._grid_point_count + self._show_log_header(i) + gp = self._grid_points[i] + + if not self._all_grid_points: + self._collision_matrix[:] = 0 + + if not self._read_gamma: + self._collision.set_grid_point(gp) + + if self._log_level: + print("Number of triplets: %d" % len(self._pp.get_triplets_at_q()[0])) + + self._set_collision_matrix_at_sigmas(i) + + if self._is_reducible_collision_matrix: + i_data = self._pp.bz_grid.bzg2grg[gp] + else: + i_data = i + self._set_harmonic_properties(i, i_data) + self._set_gv_by_gv(i, i_data) + if self._isotope is not None: + gamma_iso = self._get_gamma_isotope_at_sigmas(i) + band_indices = self._pp.band_indices + self._gamma_iso[:, i_data, :] = gamma_iso[:, band_indices] + + if self._log_level: + self._show_log(i) + + def _allocate_values(self): + """Allocate arrays.""" + num_band0 = len(self._pp.band_indices) + num_band = len(self._pp.primitive) * 3 + num_temp = len(self._temperatures) + + if self._is_reducible_collision_matrix: + self._allocate_reducible_colmat_values(num_temp, num_band0, num_band) + else: + self._allocate_ir_colmat_values(num_temp, num_band0, num_band) + + def _allocate_local_values(self, num_temp, num_band0, num_grid_points): + """Allocate grid point local arrays.""" + self._kappa = np.zeros( + (len(self._sigmas), num_temp, 6), dtype="double", order="C" + ) + self._kappa_RTA = np.zeros( + (len(self._sigmas), num_temp, 6), dtype="double", order="C" + ) + self._gv = np.zeros((num_grid_points, num_band0, 3), dtype="double", order="C") + self._f_vectors = np.zeros( + (num_grid_points, num_band0, 3), dtype="double", order="C" + ) + self._gv_sum2 = np.zeros( + (num_grid_points, num_band0, 6), dtype="double", order="C" + ) + self._mfp = np.zeros( + (len(self._sigmas), num_temp, num_grid_points, num_band0, 3), + dtype="double", + order="C", + ) + self._cv = np.zeros( + (num_temp, num_grid_points, num_band0), dtype="double", order="C" + ) + if self._is_full_pp: + self._averaged_pp_interaction = np.zeros( + (num_grid_points, num_band0), dtype="double", order="C" + ) + + if self._gamma is None: + self._gamma = np.zeros( + (len(self._sigmas), num_temp, num_grid_points, num_band0), + dtype="double", + order="C", + ) + if self._isotope is not None: + self._gamma_iso = np.zeros( + (len(self._sigmas), num_grid_points, num_band0), + dtype="double", + order="C", + ) + + self._mode_kappa = np.zeros( + (len(self._sigmas), num_temp, num_grid_points, num_band0, 6), dtype="double" + ) + self._mode_kappa_RTA = np.zeros( + (len(self._sigmas), num_temp, num_grid_points, num_band0, 6), dtype="double" + ) + + def _allocate_reducible_colmat_values(self, num_temp, num_band0, num_band): + """Allocate arrays for reducilble collision matrix.""" + num_mesh_points = np.prod(self._pp.mesh_numbers) + if self._all_grid_points: + num_stored_grid_points = num_mesh_points + else: + num_stored_grid_points = 1 + self._allocate_local_values(num_temp, num_band0, num_mesh_points) + self._collision = CollisionMatrix( + self._pp, is_reducible_collision_matrix=True, log_level=self._log_level + ) + if self._collision_matrix is None: + self._collision_matrix = np.empty( + ( + len(self._sigmas), + num_temp, + num_stored_grid_points, + num_band0, + num_mesh_points, + num_band, + ), + dtype="double", + order="C", + ) + self._collision_matrix[:] = 0 + self._collision_eigenvalues = np.zeros( + (len(self._sigmas), num_temp, num_mesh_points * num_band), + dtype="double", + order="C", + ) + + def _allocate_ir_colmat_values(self, num_temp, num_band0, num_band): + """Allocate arrays for ir collision matrix.""" + num_ir_grid_points = len(self._ir_grid_points) + num_grid_points = len(self._grid_points) + if self._all_grid_points: + num_stored_grid_points = num_grid_points + else: + num_stored_grid_points = 1 + + self._allocate_local_values(num_temp, num_band0, num_grid_points) + self._rot_grid_points = np.zeros( + (num_ir_grid_points, len(self._point_operations)), dtype="int_" + ) + for i, ir_gp in enumerate(self._ir_grid_points): + self._rot_grid_points[i] = get_grid_points_by_rotations( + ir_gp, self._pp.bz_grid + ) + self._collision = CollisionMatrix( + self._pp, + rotations_cartesian=self._rotations_cartesian, + num_ir_grid_points=num_ir_grid_points, + rot_grid_points=self._rot_grid_points, + log_level=self._log_level, + ) + if self._collision_matrix is None: + self._collision_matrix = np.empty( + ( + len(self._sigmas), + num_temp, + num_stored_grid_points, + num_band0, + 3, + num_ir_grid_points, + num_band, + 3, + ), + dtype="double", + order="C", + ) + self._collision_matrix[:] = 0 + self._collision_eigenvalues = np.zeros( + (len(self._sigmas), num_temp, num_ir_grid_points * num_band * 3), + dtype="double", + order="C", + ) + + def _set_collision_matrix_at_sigmas(self, i): + """Calculate collision matrices at grid point. + + i : int + Grid point count. + + """ + for j, sigma in enumerate(self._sigmas): + if self._log_level: + text = "Calculating collision matrix with " + if sigma is None: + text += "tetrahedron method." + else: + text += "sigma=%s" % sigma + if self._sigma_cutoff is None: + text += "." + else: + text += "(%4.2f SD)." % self._sigma_cutoff + print(text) + + self._collision.set_sigma(sigma, sigma_cutoff=self._sigma_cutoff) + self._collision.set_integration_weights() + + if self._read_pp: + pp, _g_zero = read_pp_from_hdf5( + self._pp.mesh_numbers, + grid_point=self._grid_points[i], + sigma=sigma, + sigma_cutoff=self._sigma_cutoff, + filename=self._pp_filename, + verbose=(self._log_level > 0), + ) + _, g_zero = self._collision.get_integration_weights() + if self._log_level: + if len(self._sigmas) > 1: + print( + "Multiple sigmas or mixing smearing and " + "tetrahedron method is not supported." + ) + if _g_zero is not None and (_g_zero != g_zero).any(): + raise ValueError("Inconsistency found in g_zero.") + self._collision.set_interaction_strength(pp) + elif j != 0 and (self._is_full_pp or self._sigma_cutoff is None): + if self._log_level: + print("Existing ph-ph interaction is used.") + else: + if self._log_level: + print("Calculating ph-ph interaction...") + self._collision.run_interaction(is_full_pp=self._is_full_pp) + + if self._is_full_pp and j == 0: + self._averaged_pp_interaction[i] = self._pp.get_averaged_interaction() + + for k, t in enumerate(self._temperatures): + self._collision.set_temperature(t) + self._collision.run() + if self._all_grid_points: + if self._is_reducible_collision_matrix: + i_data = self._pp.bz_grid.bzg2grg[self._grid_points[i]] + else: + i_data = i + else: + i_data = 0 + self._gamma[j, k, i_data] = self._collision.get_imag_self_energy() + self._collision_matrix[ + j, k, i_data + ] = self._collision.get_collision_matrix() + + def _prepare_collision_matrix(self): + """Prepare collision matrix to be solved.""" + if self._is_reducible_collision_matrix: + if self._is_kappa_star: + self._average_collision_matrix_by_degeneracy() + num_mesh_points = np.prod(self._pp.mesh_numbers) + num_rot = len(self._point_operations) + rot_grid_points = np.zeros((num_rot, num_mesh_points), dtype="int_") + # 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_" + ) + for i in range(num_mesh_points): + rot_grid_points[:, i] = self._pp.bz_grid.bzg2grg[ + get_grid_points_by_rotations( + self._pp.bz_grid.grg2bzg[i], self._pp.bz_grid + ) + ] + self._expand_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_") + self._symmetrize_collision_matrix() + else: + self._combine_collisions() + weights = self._get_weights() + for i, w_i in enumerate(weights): + for j, w_j in enumerate(weights): + self._collision_matrix[:, :, i, :, :, j, :, :] *= w_i * w_j + self._average_collision_matrix_by_degeneracy() + self._symmetrize_collision_matrix() + + return weights + + def _set_kappa_at_sigmas(self, weights): + """Calculate thermal conductivity from collision matrix.""" + for j, sigma in enumerate(self._sigmas): + if self._log_level: + text = "----------- Thermal conductivity (W/m-k) " + if sigma: + text += "for sigma=%s -----------" % sigma + else: + text += "with tetrahedron method -----------" + print(text) + sys.stdout.flush() + + for k, t in enumerate(self._temperatures): + if t > 0: + self._set_kappa_RTA(j, k, weights) + + w = diagonalize_collision_matrix( + self._collision_matrix, + i_sigma=j, + i_temp=k, + pinv_solver=self._pinv_solver, + log_level=self._log_level, + ) + self._collision_eigenvalues[j, k] = w + + self._set_kappa(j, k, weights) + + if self._log_level: + print( + ("#%6s " + " %-10s" * 6) + % ("T(K)", "xx", "yy", "zz", "yz", "xz", "xy") + ) + print( + ("%7.1f " + " %10.3f" * 6) + % ((t,) + tuple(self._kappa[j, k])) + ) + print( + (" %6s " + " %10.3f" * 6) + % (("(RTA)",) + tuple(self._kappa_RTA[j, k])) + ) + print("-" * 76) + sys.stdout.flush() + + if self._log_level: + print("") + + def _combine_collisions(self): + """Include diagonal elements into collision matrix.""" + num_band = len(self._pp.primitive) * 3 + for j, k in list(np.ndindex((len(self._sigmas), len(self._temperatures)))): + for i, ir_gp in enumerate(self._ir_grid_points): + for r, r_gp in zip(self._rotations_cartesian, self._rot_grid_points[i]): + if ir_gp != r_gp: + continue + + main_diagonal = self._get_main_diagonal(i, j, k) + for ll in range(num_band): + self._collision_matrix[j, k, i, ll, :, i, ll, :] += ( + main_diagonal[ll] * r + ) + + def _combine_reducible_collisions(self): + """Include diagonal elements into collision matrix.""" + num_band = len(self._pp.primitive) * 3 + num_mesh_points = np.prod(self._pp.mesh_numbers) + + for j, k in list(np.ndindex((len(self._sigmas), len(self._temperatures)))): + for i in range(num_mesh_points): + main_diagonal = self._get_main_diagonal(i, j, k) + for ll in range(num_band): + self._collision_matrix[j, k, i, ll, i, ll] += main_diagonal[ll] + + def _expand_collisions(self, ir_gr_grid_points, rot_grid_points): + """Fill elements of full collision matrix by symmetry.""" + start = time.time() + if self._log_level: + sys.stdout.write("- Expanding properties to all grid points ") + sys.stdout.flush() + + try: + import phono3py._phono3py as phono3c + + phono3c.expand_collision_matrix( + self._collision_matrix, ir_gr_grid_points, rot_grid_points + ) + except ImportError: + print("Phono3py C-routine is not compiled correctly.") + num_mesh_points = np.prod(self._pp.mesh_numbers) + colmat = self._collision_matrix + for i, ir_gp in enumerate(ir_gr_grid_points): + multi = (rot_grid_points[:, ir_gp] == ir_gp).sum() + colmat_irgp = colmat[:, :, ir_gp, :, :, :].copy() + colmat_irgp /= multi + colmat[:, :, ir_gp, :, :, :] = 0 + for j, r in enumerate(self._rotations_cartesian): + gp_r = rot_grid_points[j, ir_gp] + for k in range(num_mesh_points): + gp_c = rot_grid_points[j, k] + colmat[:, :, gp_r, :, gp_c, :] += colmat_irgp[:, :, :, k, :] + + if self._log_level: + print("[%.3fs]" % (time.time() - start)) + sys.stdout.flush() + + def _expand_local_values(self, ir_gr_grid_points, rot_grid_points): + """Fill elements of local properties at grid points.""" + for i, ir_gp in enumerate(ir_gr_grid_points): + gv_irgp = self._gv[ir_gp].copy() + self._gv[ir_gp] = 0 + cv_irgp = self._cv[:, ir_gp, :].copy() + self._cv[:, ir_gp, :] = 0 + gamma_irgp = self._gamma[:, :, ir_gp, :].copy() + self._gamma[:, :, ir_gp, :] = 0 + multi = (rot_grid_points[:, ir_gp] == ir_gp).sum() + if self._gamma_iso is not None: + gamma_iso_irgp = self._gamma_iso[:, ir_gp, :].copy() + self._gamma_iso[:, ir_gp, :] = 0 + for j, r in enumerate(self._rotations_cartesian): + gp_r = rot_grid_points[j, ir_gp] + self._gamma[:, :, gp_r, :] += gamma_irgp / multi + if self._gamma_iso is not None: + self._gamma_iso[:, gp_r, :] += gamma_iso_irgp / multi + self._gv[gp_r] += np.dot(gv_irgp, r.T) / multi + self._cv[:, gp_r, :] += cv_irgp / multi + + def _get_weights(self): + """Return weights used for collision matrix and |X> and |f>. + + self._rot_grid_points : ndarray + shape=(ir_grid_points, point_operations), dtype='int_' + + r_gps : grid points of arms of k-star with duplicates + len(r_gps) == order of crystallographic point group + len(unique(r_gps)) == number of arms of the k-star + + Returns + ------- + weights : list + sqrt(g_k)/|g|, where g is the crystallographic point group and + g_k is the number of arms of k-star. + + """ + weights = [] + n = float(self._rot_grid_points.shape[1]) + for r_gps in self._rot_grid_points: + weights.append(np.sqrt(len(np.unique(r_gps)) / n)) + + sym_broken = False + for gp in np.unique(r_gps): + if len(np.where(r_gps == gp)[0]) != self._rot_grid_points.shape[ + 1 + ] // len(np.unique(r_gps)): + sym_broken = True + + if sym_broken: + print("=" * 26 + " Warning " + "=" * 26) + print("Symmetry of grid is broken.") + + return weights + + def _symmetrize_collision_matrix(self): + r"""Symmetrize collision matrix. + + (\Omega + \Omega^T) / 2. + + """ + start = time.time() + + try: + import phono3py._phono3py as phono3c + + if self._log_level: + sys.stdout.write("- Making collision matrix symmetric " "(built-in) ") + sys.stdout.flush() + phono3c.symmetrize_collision_matrix(self._collision_matrix) + except ImportError: + if self._log_level: + sys.stdout.write("- Making collision matrix symmetric " "(numpy) ") + sys.stdout.flush() + + if self._is_reducible_collision_matrix: + size = np.prod(self._collision_matrix.shape[2:4]) + else: + size = np.prod(self._collision_matrix.shape[2:5]) + for i in range(self._collision_matrix.shape[0]): + for j in range(self._collision_matrix.shape[1]): + col_mat = self._collision_matrix[i, j].reshape(size, size) + col_mat += col_mat.T + col_mat /= 2 + + if self._log_level: + print("[%.3fs]" % (time.time() - start)) + sys.stdout.flush() + + def _average_collision_matrix_by_degeneracy(self): + """Average symmetrically equivalent elemetns of collision matrix.""" + start = time.time() + + # Average matrix elements belonging to degenerate bands + if self._log_level: + sys.stdout.write( + "- Averaging collision matrix elements " "by phonon degeneracy " + ) + sys.stdout.flush() + + col_mat = self._collision_matrix + for i, gp in enumerate(self._ir_grid_points): + freqs = self._frequencies[gp] + deg_sets = degenerate_sets(freqs) + for dset in deg_sets: + bi_set = [] + for j in range(len(freqs)): + if j in dset: + bi_set.append(j) + + if self._is_reducible_collision_matrix: + i_data = self._pp.bz_grid.bzg2grg[gp] + sum_col = col_mat[:, :, i_data, bi_set, :, :].sum(axis=2) / len( + bi_set + ) + for j in bi_set: + col_mat[:, :, i_data, j, :, :] = sum_col + else: + sum_col = col_mat[:, :, i, bi_set, :, :, :, :].sum(axis=2) / len( + bi_set + ) + for j in bi_set: + col_mat[:, :, i, j, :, :, :, :] = sum_col + + for i, gp in enumerate(self._ir_grid_points): + freqs = self._frequencies[gp] + deg_sets = degenerate_sets(freqs) + for dset in deg_sets: + bi_set = [] + for j in range(len(freqs)): + if j in dset: + bi_set.append(j) + if self._is_reducible_collision_matrix: + i_data = self._pp.bz_grid.bzg2grg[gp] + sum_col = col_mat[:, :, :, :, i_data, bi_set].sum(axis=4) / len( + bi_set + ) + for j in bi_set: + col_mat[:, :, :, :, i_data, j] = sum_col + else: + sum_col = col_mat[:, :, :, :, :, i, bi_set, :].sum(axis=5) / len( + bi_set + ) + for j in bi_set: + col_mat[:, :, :, :, :, i, j, :] = sum_col + + if self._log_level: + print("[%.3fs]" % (time.time() - start)) + sys.stdout.flush() + + def _get_X(self, i_temp, weights): + """Calculate X in Chaput's paper.""" + num_band = len(self._pp.primitive) * 3 + X = self._gv.copy() + if self._is_reducible_collision_matrix: + freqs = self._frequencies[self._pp.bz_grid.grg2bzg] + else: + freqs = self._frequencies[self._ir_grid_points] + + t = self._temperatures[i_temp] + sinh = np.where( + freqs > self._pp.cutoff_frequency, + np.sinh(freqs * THzToEv / (2 * Kb * t)), + -1.0, + ) + inv_sinh = np.where(sinh > 0, 1.0 / sinh, 0) + freqs_sinh = freqs * THzToEv * inv_sinh / (4 * Kb * t ** 2) + + for i, f in enumerate(freqs_sinh): + X[i] *= weights[i] + for j in range(num_band): + X[i, j] *= f[j] + + if t > 0: + return X.reshape(-1, 3) + else: + return np.zeros_like(X.reshape(-1, 3)) + + def _get_Y(self, i_sigma, i_temp, weights, X): + r"""Calculate Y = (\Omega^-1, X).""" + solver = _select_solver(self._pinv_solver) + num_band = len(self._pp.primitive) * 3 + + if self._is_reducible_collision_matrix: + num_grid_points = np.prod(self._pp.mesh_numbers) + size = num_grid_points * num_band + else: + num_grid_points = len(self._ir_grid_points) + size = num_grid_points * num_band * 3 + v = self._collision_matrix[i_sigma, i_temp].reshape(size, size) + # Transpose eigvecs because colmat was solved by column major order + if solver in [1, 2, 4, 5]: + v = v.T + + start = time.time() + + if solver in [0, 1, 2, 3, 4, 5]: + if self._log_level: + sys.stdout.write( + "Calculating pseudo-inv with cutoff=%-.1e " + "(np.dot) " % self._pinv_cutoff + ) + sys.stdout.flush() + + e = self._get_eigvals_pinv(i_sigma, i_temp) + if self._is_reducible_collision_matrix: + X1 = np.dot(v.T, X) + for i in range(3): + X1[:, i] *= e + Y = np.dot(v, X1) + else: + Y = np.dot(v, e * np.dot(v.T, X.ravel())).reshape(-1, 3) + else: # solver=6 This is slower as far as tested. + import phono3py._phono3py as phono3c + + if self._log_level: + sys.stdout.write( + "Calculating pseudo-inv with cutoff=%-.1e " + "(built-in) " % self._pinv_cutoff + ) + sys.stdout.flush() + + w = self._collision_eigenvalues[i_sigma, i_temp] + phono3c.pinv_from_eigensolution( + self._collision_matrix, w, i_sigma, i_temp, self._pinv_cutoff, 0 + ) + if self._is_reducible_collision_matrix: + Y = np.dot(v, X) + else: + Y = np.dot(v, X.ravel()).reshape(-1, 3) + + self._set_f_vectors(Y, num_grid_points, weights) + + if self._log_level: + print("[%.3fs]" % (time.time() - start)) + sys.stdout.flush() + + return Y + + def _set_f_vectors(self, Y, num_grid_points, weights): + """Calculate f-vectors. + + Collision matrix is half of that defined in Chaput's paper. + Therefore Y is divided by 2. + + """ + num_band = len(self._pp.primitive) * 3 + self._f_vectors[:] = ( + (Y / 2).reshape(num_grid_points, num_band * 3).T / weights + ).T.reshape(self._f_vectors.shape) + + def _get_eigvals_pinv(self, i_sigma, i_temp): + """Return inverse eigenvalues of eigenvalues > epsilon.""" + w = self._collision_eigenvalues[i_sigma, i_temp] + e = np.zeros_like(w) + for ll, val in enumerate(w): + if abs(val) > self._pinv_cutoff: + e[ll] = 1 / val + return e + + def _get_I(self, a, b, size, plus_transpose=True): + """Return I matrix in Chaput's PRL paper. + + None is returned if I is zero matrix. + + """ + r_sum = np.zeros((3, 3), dtype="double", order="C") + for r in self._rotations_cartesian: + for i in range(3): + for j in range(3): + r_sum[i, j] += r[a, i] * r[b, j] + if plus_transpose: + r_sum += r_sum.T + + # Return None not to consume computer for diagonalization + if (np.abs(r_sum) < 1e-10).all(): + return None + + # Same as np.kron(np.eye(size), r_sum), but writen as below + # to be sure the values in memory C-congiguous with 'double'. + I_mat = np.zeros((3 * size, 3 * size), dtype="double", order="C") + for i in range(size): + I_mat[(i * 3) : ((i + 1) * 3), (i * 3) : ((i + 1) * 3)] = r_sum + + return I_mat + + def _set_kappa(self, i_sigma, i_temp, weights): + """Calculate direct solution thermal conductivity. + + Either ir or full colmat. + + """ + if self._is_reducible_collision_matrix: + self._set_kappa_reducible_colmat(i_sigma, i_temp, weights) + else: + self._set_kappa_ir_colmat(i_sigma, i_temp, weights) + + def _set_kappa_ir_colmat(self, i_sigma, i_temp, weights): + """Calculate direct solution thermal conductivity of ir colmat.""" + if self._solve_collective_phonon: + self._set_mode_kappa_Chaput(i_sigma, i_temp, weights) + else: + N = self._num_sampling_grid_points + X = self._get_X(i_temp, weights) + num_ir_grid_points = len(self._ir_grid_points) + Y = self._get_Y(i_sigma, i_temp, weights, X) + self._set_mean_free_path(i_sigma, i_temp, weights, Y) + self._set_mode_kappa( + self._mode_kappa, + X, + Y, + num_ir_grid_points, + self._rotations_cartesian, + i_sigma, + i_temp, + ) + # self._set_mode_kappa_from_mfp(weights, + # num_ir_grid_points, + # self._rotations_cartesian, + # i_sigma, + # i_temp) + + self._kappa[i_sigma, i_temp] = ( + self._mode_kappa[i_sigma, i_temp].sum(axis=0).sum(axis=0) / N + ) + + def _set_kappa_reducible_colmat(self, i_sigma, i_temp, weights): + """Calculate direct solution thermal conductivity of full colmat.""" + N = self._num_sampling_grid_points + X = self._get_X(i_temp, weights) + num_mesh_points = np.prod(self._pp.mesh_numbers) + Y = self._get_Y(i_sigma, i_temp, weights, X) + self._set_mean_free_path(i_sigma, i_temp, weights, Y) + # Putting self._rotations_cartesian is to symmetrize kappa. + # None can be put instead for watching pure information. + self._set_mode_kappa( + self._mode_kappa, + X, + Y, + num_mesh_points, + self._rotations_cartesian, + i_sigma, + i_temp, + ) + self._mode_kappa[i_sigma, i_temp] /= len(self._rotations_cartesian) + self._kappa[i_sigma, i_temp] = ( + self._mode_kappa[i_sigma, i_temp].sum(axis=0).sum(axis=0) / N + ) + + def _set_kappa_RTA(self, i_sigma, i_temp, weights): + """Calculate RTA thermal conductivity with either ir or full colmat.""" + if self._is_reducible_collision_matrix: + self._set_kappa_RTA_reducible_colmat(i_sigma, i_temp, weights) + else: + self._set_kappa_RTA_ir_colmat(i_sigma, i_temp, weights) + + def _set_kappa_RTA_ir_colmat(self, i_sigma, i_temp, weights): + """Calculate RTA thermal conductivity. + + This RTA is supposed to be the same as conductivity_RTA. + + """ + N = self._num_sampling_grid_points + num_band = len(self._pp.primitive) * 3 + X = self._get_X(i_temp, weights) + Y = np.zeros_like(X) + num_ir_grid_points = len(self._ir_grid_points) + for i, gp in enumerate(self._ir_grid_points): + g = self._get_main_diagonal(i, i_sigma, i_temp) + frequencies = self._frequencies[gp] + for j, f in enumerate(frequencies): + if f > self._pp.cutoff_frequency: + i_mode = i * num_band + j + old_settings = np.seterr(all="raise") + try: + Y[i_mode, :] = X[i_mode, :] / g[j] + except Exception: + print("=" * 26 + " Warning " + "=" * 26) + print( + " Unexpected physical condition of ph-ph " + "interaction calculation was found." + ) + print( + " g[j]=%f at gp=%d, band=%d, freq=%f" % (g[j], gp, j + 1, f) + ) + print("=" * 61) + np.seterr(**old_settings) + + self._set_mode_kappa( + self._mode_kappa_RTA, + X, + Y, + num_ir_grid_points, + self._rotations_cartesian, + i_sigma, + i_temp, + ) + self._kappa_RTA[i_sigma, i_temp] = ( + self._mode_kappa_RTA[i_sigma, i_temp].sum(axis=0).sum(axis=0) / N + ) + + def _set_kappa_RTA_reducible_colmat(self, i_sigma, i_temp, weights): + """Calculate RTA thermal conductivity. + + This RTA is not equivalent to conductivity_RTA. + The lifetime is defined from the diagonal part of + collision matrix. + + """ + N = self._num_sampling_grid_points + num_band = len(self._pp.primitive) * 3 + X = self._get_X(i_temp, weights) + Y = np.zeros_like(X) + + num_mesh_points = np.prod(self._pp.mesh_numbers) + size = num_mesh_points * num_band + v_diag = np.diagonal( + self._collision_matrix[i_sigma, i_temp].reshape(size, size) + ) + + for gp in range(num_mesh_points): + frequencies = self._frequencies[gp] + for j, f in enumerate(frequencies): + if f > self._pp.cutoff_frequency: + i_mode = gp * num_band + j + Y[i_mode, :] = X[i_mode, :] / v_diag[i_mode] + # Putting self._rotations_cartesian is to symmetrize kappa. + # None can be put instead for watching pure information. + self._set_mode_kappa( + self._mode_kappa_RTA, + X, + Y, + num_mesh_points, + self._rotations_cartesian, + i_sigma, + i_temp, + ) + g = len(self._rotations_cartesian) + self._mode_kappa_RTA[i_sigma, i_temp] /= g + self._kappa_RTA[i_sigma, i_temp] = ( + self._mode_kappa_RTA[i_sigma, i_temp].sum(axis=0).sum(axis=0) / N + ) + + def _set_mode_kappa( + self, mode_kappa, X, Y, num_grid_points, rotations_cartesian, i_sigma, i_temp + ): + """Calculate mode thermal conductivity. + + The first parameter, mode_kappa, is overwritten. + + """ + num_band = len(self._pp.primitive) * 3 + for i, (v_gp, f_gp) in enumerate( + zip( + X.reshape(num_grid_points, num_band, 3), + Y.reshape(num_grid_points, num_band, 3), + ) + ): + + for j, (v, f) in enumerate(zip(v_gp, f_gp)): + # Do not consider three lowest modes at Gamma-point + # It is assumed that there are no imaginary modes. + if (self._pp.bz_grid.addresses[i] == 0).all() and j < 3: + continue + + if rotations_cartesian is None: + sum_k = np.outer(v, f) + else: + sum_k = np.zeros((3, 3), dtype="double") + for r in rotations_cartesian: + sum_k += np.outer(np.dot(r, v), np.dot(r, f)) + sum_k = sum_k + sum_k.T + for k, vxf in enumerate( + ((0, 0), (1, 1), (2, 2), (1, 2), (0, 2), (0, 1)) + ): + mode_kappa[i_sigma, i_temp, i, j, k] = sum_k[vxf] + + t = self._temperatures[i_temp] + # Collision matrix is defined as a half of that in Chaput's paper. + # Therefore here 2 is not necessary multiplied. + # sum_k = sum_k + sum_k.T is equivalent to I(a,b) + I(b,a). + mode_kappa[i_sigma, i_temp] *= self._conversion_factor * Kb * t ** 2 + + def _set_mode_kappa_Chaput(self, i_sigma, i_temp, weights): + """Calculate mode kappa by the way in Laurent Chaput's PRL paper. + + This gives the different result from _set_mode_kappa and requires more + memory space. + + """ + X = self._get_X(i_temp, weights).ravel() + num_ir_grid_points = len(self._ir_grid_points) + num_band = len(self._pp.primitive) * 3 + size = num_ir_grid_points * num_band * 3 + v = self._collision_matrix[i_sigma, i_temp].reshape(size, size) + solver = _select_solver(self._pinv_solver) + if solver in [1, 2, 4, 5]: + v = v.T + e = self._get_eigvals_pinv(i_sigma, i_temp) + t = self._temperatures[i_temp] + + omega_inv = np.empty(v.shape, dtype="double", order="C") + np.dot(v, (e * v).T, out=omega_inv) + Y = np.dot(omega_inv, X) + self._set_f_vectors(Y, num_ir_grid_points, weights) + elems = ((0, 0), (1, 1), (2, 2), (1, 2), (0, 2), (0, 1)) + for i, vxf in enumerate(elems): + mat = self._get_I(vxf[0], vxf[1], num_ir_grid_points * num_band) + self._mode_kappa[i_sigma, i_temp, :, :, i] = 0 + if mat is not None: + np.dot(mat, omega_inv, out=mat) + # vals = (X ** 2 * np.diag(mat)).reshape(-1, 3).sum(axis=1) + # vals = vals.reshape(num_ir_grid_points, num_band) + # self._mode_kappa[i_sigma, i_temp, :, :, i] = vals + w = diagonalize_collision_matrix( + mat, pinv_solver=self._pinv_solver, log_level=self._log_level + ) + if solver in [1, 2, 4, 5]: + mat = mat.T + spectra = np.dot(mat.T, X) ** 2 * w + for s, eigvec in zip(spectra, mat.T): + vals = s * (eigvec ** 2).reshape(-1, 3).sum(axis=1) + vals = vals.reshape(num_ir_grid_points, num_band) + self._mode_kappa[i_sigma, i_temp, :, :, i] += vals + + factor = self._conversion_factor * Kb * t ** 2 + self._mode_kappa[i_sigma, i_temp] *= factor + + def _set_mode_kappa_from_mfp( + self, weights, num_grid_points, rotations_cartesian, i_sigma, i_temp + ): + for i, (v_gp, mfp_gp, cv_gp) in enumerate( + zip(self._gv, self._mfp[i_sigma, i_temp], self._cv[i_temp]) + ): + for j, (v, mfp, cv) in enumerate(zip(v_gp, mfp_gp, cv_gp)): + sum_k = np.zeros((3, 3), dtype="double") + for r in rotations_cartesian: + sum_k += np.outer(np.dot(r, v), np.dot(r, mfp)) + sum_k = (sum_k + sum_k.T) / 2 * cv * weights[i] ** 2 * 2 * np.pi + for k, vxf in enumerate( + ((0, 0), (1, 1), (2, 2), (1, 2), (0, 2), (0, 1)) + ): + self._mode_kappa[i_sigma, i_temp, i, j, k] = sum_k[vxf] + self._mode_kappa *= -self._conversion_factor + + def _set_mean_free_path(self, i_sigma, i_temp, weights, Y): + t = self._temperatures[i_temp] + # shape = (num_grid_points, num_band, 3), + for i, f_gp in enumerate(self._f_vectors): + for j, f in enumerate(f_gp): + cv = self._cv[i_temp, i, j] + if cv < 1e-10: + continue + self._mfp[i_sigma, i_temp, i, j] = ( + -2 * t * np.sqrt(Kb / cv) * f / (2 * np.pi) + ) + + def _show_log(self, i): + gp = self._grid_points[i] + frequencies = self._frequencies[gp] + if self._is_reducible_collision_matrix: + gv = self._gv[self._pp.bz_grid.bzg2grg[gp]] + else: + gv = self._gv[i] + if self._is_full_pp: + ave_pp = self._averaged_pp_interaction[i] + text = "Frequency group velocity (x, y, z) |gv| Pqj" + else: + text = "Frequency group velocity (x, y, z) |gv|" + + if self._gv_obj.q_length is None: + pass + else: + text += " (dq=%3.1e)" % self._gv_obj.q_length + print(text) + if self._is_full_pp: + for f, v, pp in zip(frequencies, gv, ave_pp): + print( + "%8.3f (%8.3f %8.3f %8.3f) %8.3f %11.3e" + % (f, v[0], v[1], v[2], np.linalg.norm(v), pp) + ) + else: + for f, v in zip(frequencies, gv): + print( + "%8.3f (%8.3f %8.3f %8.3f) %8.3f" + % (f, v[0], v[1], v[2], np.linalg.norm(v)) + ) + + sys.stdout.flush() + + def _py_symmetrize_collision_matrix(self): + num_band = len(self._pp.primitive) * 3 + num_ir_grid_points = len(self._ir_grid_points) + for i in range(num_ir_grid_points): + for j in range(num_band): + for k in range(3): + for ll in range(num_ir_grid_points): + for m in range(num_band): + for n in range(3): + self._py_set_symmetrized_element(i, j, k, ll, m, n) + + def _py_set_symmetrized_element(self, i, j, k, ll, m, n): + sym_val = ( + self._collision_matrix[:, :, i, j, k, ll, m, n] + + self._collision_matrix[:, :, ll, m, n, i, j, k] + ) / 2 + self._collision_matrix[:, :, i, j, k, ll, m, n] = sym_val + self._collision_matrix[:, :, ll, m, n, i, j, k] = sym_val + + def _py_symmetrize_collision_matrix_no_kappa_stars(self): + num_band = len(self._pp.primitive) * 3 + num_ir_grid_points = len(self._ir_grid_points) + for i in range(num_ir_grid_points): + for j in range(num_band): + for k in range(num_ir_grid_points): + for ll in range(num_band): + self._py_set_symmetrized_element_no_kappa_stars(i, j, k, ll) + + def _py_set_symmetrized_element_no_kappa_stars(self, i, j, k, ll): + sym_val = ( + self._collision_matrix[:, :, i, j, k, ll] + + self._collision_matrix[:, :, k, ll, i, j] + ) / 2 + self._collision_matrix[:, :, i, j, k, ll] = sym_val + self._collision_matrix[:, :, k, ll, i, j] = sym_val + + def get_thermal_conductivity_LBTE( interaction, temperatures=None, @@ -797,1176 +1973,3 @@ def diagonalize_collision_matrix( sys.stdout.flush() return w - - -class Conductivity_LBTE(Conductivity): - """Lattice thermal conductivity calculation by direct solution.""" - - def __init__( - self, - interaction, - grid_points=None, - temperatures=None, - sigmas=None, - sigma_cutoff=None, - is_isotope=False, - mass_variances=None, - boundary_mfp=None, # in micrometre - solve_collective_phonon=False, - is_reducible_collision_matrix=False, - is_kappa_star=True, - gv_delta_q=None, # finite difference for group veolocity - is_full_pp=False, - read_pp=False, - pp_filename=None, - pinv_cutoff=1.0e-8, - pinv_solver=0, - log_level=0, - ): - """Init method.""" - self._pp = None - self._gv_obj = None - self._temperatures = None - self._sigmas = None - self._sigma_cutoff = None - self._is_kappa_star = None - self._is_full_pp = None - self._log_level = None - self._boundary_mfp = None - - self._point_operations = None - self._rotations_cartesian = None - - self._grid_points = None - self._grid_weights = None - self._ir_grid_points = None - self._ir_grid_weights = None - - self._kappa = None - self._mode_kappa = None - self._kappa_RTA = None - self._mode_kappa_RTA = None - - self._read_gamma = False - self._read_gamma_iso = False - - self._frequencies = None - self._cv = None - self._gv = None - self._f_vectors = None - self._gv_sum2 = None - self._mfp = None - self._gamma = None - self._gamma_iso = None - self._averaged_pp_interaction = None - - self._conversion_factor = None - - self._is_isotope = None - self._isotope = None - self._mass_variances = None - self._grid_point_count = None - - self._collision_eigenvalues = None - - Conductivity.__init__( - self, - interaction, - grid_points=grid_points, - temperatures=temperatures, - sigmas=sigmas, - sigma_cutoff=sigma_cutoff, - is_isotope=is_isotope, - mass_variances=mass_variances, - boundary_mfp=boundary_mfp, - is_kappa_star=is_kappa_star, - gv_delta_q=gv_delta_q, - is_full_pp=is_full_pp, - log_level=log_level, - ) - - self._is_reducible_collision_matrix = is_reducible_collision_matrix - self._solve_collective_phonon = solve_collective_phonon - if not self._is_kappa_star: - self._is_reducible_collision_matrix = True - self._collision_matrix = None - self._read_pp = read_pp - self._pp_filename = pp_filename - self._pinv_cutoff = pinv_cutoff - self._pinv_solver = pinv_solver - - if grid_points is None: - self._all_grid_points = True - else: - self._all_grid_points = False - - if self._temperatures is not None: - self._allocate_values() - - def set_kappa_at_sigmas(self): - """Calculate lattice thermal conductivity from collision matrix.""" - if len(self._grid_points) != len(self._ir_grid_points): - print("Collision matrix is not well created.") - import sys - - sys.exit(1) - else: - weights = self._prepare_collision_matrix() - self._set_kappa_at_sigmas(weights) - - def get_f_vectors(self): - """Return f vectors.""" - return self._f_vectors - - @property - def collision_matrix(self): - """Setter and getter of collision matrix.""" - return self._collision_matrix - - @collision_matrix.setter - def collision_matrix(self, collision_matrix): - self._collision_matrix = collision_matrix - - def get_collision_matrix(self): - """Return collision matrix.""" - warnings.warn( - "Use attribute, Conductivity_LBTE.collision_matrix " - "instead of Conductivity_LBTE.get_collision_matrix().", - DeprecationWarning, - ) - return self.collision_matrix - - def set_collision_matrix(self, collision_matrix): - """Set collision matrix.""" - warnings.warn( - "Use attribute, Conductivity_LBTE.collision_matrix " - "instead of Conductivity_LBTE.set_collision_matrix().", - DeprecationWarning, - ) - self.collision_matrix = collision_matrix - - def get_collision_eigenvalues(self): - """Return eigenvalues of collision matrix.""" - return self._collision_eigenvalues - - def get_mean_free_path(self): - """Return mean free path.""" - return self._mfp - - def get_frequencies_all(self): - """Return phonon frequencies on GR-grid.""" - return self._frequencies[self._pp.bz_grid.grg2bzg] - - def get_kappa_RTA(self): - """Return RTA lattice thermal conductivity.""" - return self._kappa_RTA - - def get_mode_kappa_RTA(self): - """Return RTA mode lattice thermal conductivities.""" - return self._mode_kappa_RTA - - def delete_gp_collision_and_pp(self): - """Deallocate large arrays.""" - self._collision.delete_integration_weights() - self._pp.delete_interaction_strength() - - def _run_at_grid_point(self): - """Calculate properties at a grid point.""" - i = self._grid_point_count - self._show_log_header(i) - gp = self._grid_points[i] - - if not self._all_grid_points: - self._collision_matrix[:] = 0 - - if not self._read_gamma: - self._collision.set_grid_point(gp) - - if self._log_level: - print("Number of triplets: %d" % len(self._pp.get_triplets_at_q()[0])) - - self._set_collision_matrix_at_sigmas(i) - - if self._is_reducible_collision_matrix: - i_data = self._pp.bz_grid.bzg2grg[gp] - else: - i_data = i - self._set_harmonic_properties(i, i_data) - self._set_gv_by_gv(i, i_data) - if self._isotope is not None: - gamma_iso = self._get_gamma_isotope_at_sigmas(i) - band_indices = self._pp.band_indices - self._gamma_iso[:, i_data, :] = gamma_iso[:, band_indices] - - if self._log_level: - self._show_log(i) - - def _allocate_values(self): - """Allocate arrays.""" - num_band0 = len(self._pp.band_indices) - num_band = len(self._pp.primitive) * 3 - num_temp = len(self._temperatures) - - if self._is_reducible_collision_matrix: - self._allocate_reducible_colmat_values(num_temp, num_band0, num_band) - else: - self._allocate_ir_colmat_values(num_temp, num_band0, num_band) - - def _allocate_local_values(self, num_temp, num_band0, num_grid_points): - """Allocate grid point local arrays.""" - self._kappa = np.zeros( - (len(self._sigmas), num_temp, 6), dtype="double", order="C" - ) - self._kappa_RTA = np.zeros( - (len(self._sigmas), num_temp, 6), dtype="double", order="C" - ) - self._gv = np.zeros((num_grid_points, num_band0, 3), dtype="double", order="C") - self._f_vectors = np.zeros( - (num_grid_points, num_band0, 3), dtype="double", order="C" - ) - self._gv_sum2 = np.zeros( - (num_grid_points, num_band0, 6), dtype="double", order="C" - ) - self._mfp = np.zeros( - (len(self._sigmas), num_temp, num_grid_points, num_band0, 3), - dtype="double", - order="C", - ) - self._cv = np.zeros( - (num_temp, num_grid_points, num_band0), dtype="double", order="C" - ) - if self._is_full_pp: - self._averaged_pp_interaction = np.zeros( - (num_grid_points, num_band0), dtype="double", order="C" - ) - - if self._gamma is None: - self._gamma = np.zeros( - (len(self._sigmas), num_temp, num_grid_points, num_band0), - dtype="double", - order="C", - ) - if self._isotope is not None: - self._gamma_iso = np.zeros( - (len(self._sigmas), num_grid_points, num_band0), - dtype="double", - order="C", - ) - - self._mode_kappa = np.zeros( - (len(self._sigmas), num_temp, num_grid_points, num_band0, 6), dtype="double" - ) - self._mode_kappa_RTA = np.zeros( - (len(self._sigmas), num_temp, num_grid_points, num_band0, 6), dtype="double" - ) - - def _allocate_reducible_colmat_values(self, num_temp, num_band0, num_band): - """Allocate arrays for reducilble collision matrix.""" - num_mesh_points = np.prod(self._pp.mesh_numbers) - if self._all_grid_points: - num_stored_grid_points = num_mesh_points - else: - num_stored_grid_points = 1 - self._allocate_local_values(num_temp, num_band0, num_mesh_points) - self._collision = CollisionMatrix( - self._pp, is_reducible_collision_matrix=True, log_level=self._log_level - ) - if self._collision_matrix is None: - self._collision_matrix = np.empty( - ( - len(self._sigmas), - num_temp, - num_stored_grid_points, - num_band0, - num_mesh_points, - num_band, - ), - dtype="double", - order="C", - ) - self._collision_matrix[:] = 0 - self._collision_eigenvalues = np.zeros( - (len(self._sigmas), num_temp, num_mesh_points * num_band), - dtype="double", - order="C", - ) - - def _allocate_ir_colmat_values(self, num_temp, num_band0, num_band): - """Allocate arrays for ir collision matrix.""" - num_ir_grid_points = len(self._ir_grid_points) - num_grid_points = len(self._grid_points) - if self._all_grid_points: - num_stored_grid_points = num_grid_points - else: - num_stored_grid_points = 1 - - self._allocate_local_values(num_temp, num_band0, num_grid_points) - self._rot_grid_points = np.zeros( - (num_ir_grid_points, len(self._point_operations)), dtype="int_" - ) - for i, ir_gp in enumerate(self._ir_grid_points): - self._rot_grid_points[i] = get_grid_points_by_rotations( - ir_gp, self._pp.bz_grid - ) - self._collision = CollisionMatrix( - self._pp, - rotations_cartesian=self._rotations_cartesian, - num_ir_grid_points=num_ir_grid_points, - rot_grid_points=self._rot_grid_points, - log_level=self._log_level, - ) - if self._collision_matrix is None: - self._collision_matrix = np.empty( - ( - len(self._sigmas), - num_temp, - num_stored_grid_points, - num_band0, - 3, - num_ir_grid_points, - num_band, - 3, - ), - dtype="double", - order="C", - ) - self._collision_matrix[:] = 0 - self._collision_eigenvalues = np.zeros( - (len(self._sigmas), num_temp, num_ir_grid_points * num_band * 3), - dtype="double", - order="C", - ) - - def _set_collision_matrix_at_sigmas(self, i): - """Calculate collision matrices at grid point. - - i : int - Grid point count. - - """ - for j, sigma in enumerate(self._sigmas): - if self._log_level: - text = "Calculating collision matrix with " - if sigma is None: - text += "tetrahedron method." - else: - text += "sigma=%s" % sigma - if self._sigma_cutoff is None: - text += "." - else: - text += "(%4.2f SD)." % self._sigma_cutoff - print(text) - - self._collision.set_sigma(sigma, sigma_cutoff=self._sigma_cutoff) - self._collision.set_integration_weights() - - if self._read_pp: - pp, _g_zero = read_pp_from_hdf5( - self._pp.mesh_numbers, - grid_point=self._grid_points[i], - sigma=sigma, - sigma_cutoff=self._sigma_cutoff, - filename=self._pp_filename, - verbose=(self._log_level > 0), - ) - _, g_zero = self._collision.get_integration_weights() - if self._log_level: - if len(self._sigmas) > 1: - print( - "Multiple sigmas or mixing smearing and " - "tetrahedron method is not supported." - ) - if _g_zero is not None and (_g_zero != g_zero).any(): - raise ValueError("Inconsistency found in g_zero.") - self._collision.set_interaction_strength(pp) - elif j != 0 and (self._is_full_pp or self._sigma_cutoff is None): - if self._log_level: - print("Existing ph-ph interaction is used.") - else: - if self._log_level: - print("Calculating ph-ph interaction...") - self._collision.run_interaction(is_full_pp=self._is_full_pp) - - if self._is_full_pp and j == 0: - self._averaged_pp_interaction[i] = self._pp.get_averaged_interaction() - - for k, t in enumerate(self._temperatures): - self._collision.set_temperature(t) - self._collision.run() - if self._all_grid_points: - if self._is_reducible_collision_matrix: - i_data = self._pp.bz_grid.bzg2grg[self._grid_points[i]] - else: - i_data = i - else: - i_data = 0 - self._gamma[j, k, i_data] = self._collision.get_imag_self_energy() - self._collision_matrix[ - j, k, i_data - ] = self._collision.get_collision_matrix() - - def _prepare_collision_matrix(self): - """Prepare collision matrix to be solved.""" - if self._is_reducible_collision_matrix: - if self._is_kappa_star: - self._average_collision_matrix_by_degeneracy() - num_mesh_points = np.prod(self._pp.mesh_numbers) - num_rot = len(self._point_operations) - rot_grid_points = np.zeros((num_rot, num_mesh_points), dtype="int_") - # 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_" - ) - for i in range(num_mesh_points): - rot_grid_points[:, i] = self._pp.bz_grid.bzg2grg[ - get_grid_points_by_rotations( - self._pp.bz_grid.grg2bzg[i], self._pp.bz_grid - ) - ] - self._expand_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_") - self._symmetrize_collision_matrix() - else: - self._combine_collisions() - weights = self._get_weights() - for i, w_i in enumerate(weights): - for j, w_j in enumerate(weights): - self._collision_matrix[:, :, i, :, :, j, :, :] *= w_i * w_j - self._average_collision_matrix_by_degeneracy() - self._symmetrize_collision_matrix() - - return weights - - def _set_kappa_at_sigmas(self, weights): - """Calculate thermal conductivity from collision matrix.""" - for j, sigma in enumerate(self._sigmas): - if self._log_level: - text = "----------- Thermal conductivity (W/m-k) " - if sigma: - text += "for sigma=%s -----------" % sigma - else: - text += "with tetrahedron method -----------" - print(text) - sys.stdout.flush() - - for k, t in enumerate(self._temperatures): - if t > 0: - self._set_kappa_RTA(j, k, weights) - - w = diagonalize_collision_matrix( - self._collision_matrix, - i_sigma=j, - i_temp=k, - pinv_solver=self._pinv_solver, - log_level=self._log_level, - ) - self._collision_eigenvalues[j, k] = w - - self._set_kappa(j, k, weights) - - if self._log_level: - print( - ("#%6s " + " %-10s" * 6) - % ("T(K)", "xx", "yy", "zz", "yz", "xz", "xy") - ) - print( - ("%7.1f " + " %10.3f" * 6) - % ((t,) + tuple(self._kappa[j, k])) - ) - print( - (" %6s " + " %10.3f" * 6) - % (("(RTA)",) + tuple(self._kappa_RTA[j, k])) - ) - print("-" * 76) - sys.stdout.flush() - - if self._log_level: - print("") - - def _combine_collisions(self): - """Include diagonal elements into collision matrix.""" - num_band = len(self._pp.primitive) * 3 - for j, k in list(np.ndindex((len(self._sigmas), len(self._temperatures)))): - for i, ir_gp in enumerate(self._ir_grid_points): - for r, r_gp in zip(self._rotations_cartesian, self._rot_grid_points[i]): - if ir_gp != r_gp: - continue - - main_diagonal = self._get_main_diagonal(i, j, k) - for ll in range(num_band): - self._collision_matrix[j, k, i, ll, :, i, ll, :] += ( - main_diagonal[ll] * r - ) - - def _combine_reducible_collisions(self): - """Include diagonal elements into collision matrix.""" - num_band = len(self._pp.primitive) * 3 - num_mesh_points = np.prod(self._pp.mesh_numbers) - - for j, k in list(np.ndindex((len(self._sigmas), len(self._temperatures)))): - for i in range(num_mesh_points): - main_diagonal = self._get_main_diagonal(i, j, k) - for ll in range(num_band): - self._collision_matrix[j, k, i, ll, i, ll] += main_diagonal[ll] - - def _expand_collisions(self, ir_gr_grid_points, rot_grid_points): - """Fill elements of full collision matrix by symmetry.""" - start = time.time() - if self._log_level: - sys.stdout.write("- Expanding properties to all grid points ") - sys.stdout.flush() - - try: - import phono3py._phono3py as phono3c - - phono3c.expand_collision_matrix( - self._collision_matrix, ir_gr_grid_points, rot_grid_points - ) - except ImportError: - print("Phono3py C-routine is not compiled correctly.") - num_mesh_points = np.prod(self._pp.mesh_numbers) - colmat = self._collision_matrix - for i, ir_gp in enumerate(ir_gr_grid_points): - multi = (rot_grid_points[:, ir_gp] == ir_gp).sum() - colmat_irgp = colmat[:, :, ir_gp, :, :, :].copy() - colmat_irgp /= multi - colmat[:, :, ir_gp, :, :, :] = 0 - for j, r in enumerate(self._rotations_cartesian): - gp_r = rot_grid_points[j, ir_gp] - for k in range(num_mesh_points): - gp_c = rot_grid_points[j, k] - colmat[:, :, gp_r, :, gp_c, :] += colmat_irgp[:, :, :, k, :] - - if self._log_level: - print("[%.3fs]" % (time.time() - start)) - sys.stdout.flush() - - def _expand_local_values(self, ir_gr_grid_points, rot_grid_points): - """Fill elements of local properties at grid points.""" - for i, ir_gp in enumerate(ir_gr_grid_points): - gv_irgp = self._gv[ir_gp].copy() - self._gv[ir_gp] = 0 - cv_irgp = self._cv[:, ir_gp, :].copy() - self._cv[:, ir_gp, :] = 0 - gamma_irgp = self._gamma[:, :, ir_gp, :].copy() - self._gamma[:, :, ir_gp, :] = 0 - multi = (rot_grid_points[:, ir_gp] == ir_gp).sum() - if self._gamma_iso is not None: - gamma_iso_irgp = self._gamma_iso[:, ir_gp, :].copy() - self._gamma_iso[:, ir_gp, :] = 0 - for j, r in enumerate(self._rotations_cartesian): - gp_r = rot_grid_points[j, ir_gp] - self._gamma[:, :, gp_r, :] += gamma_irgp / multi - if self._gamma_iso is not None: - self._gamma_iso[:, gp_r, :] += gamma_iso_irgp / multi - self._gv[gp_r] += np.dot(gv_irgp, r.T) / multi - self._cv[:, gp_r, :] += cv_irgp / multi - - def _get_weights(self): - """Return weights used for collision matrix and |X> and |f>. - - self._rot_grid_points : ndarray - shape=(ir_grid_points, point_operations), dtype='int_' - - r_gps : grid points of arms of k-star with duplicates - len(r_gps) == order of crystallographic point group - len(unique(r_gps)) == number of arms of the k-star - - Returns - ------- - weights : list - sqrt(g_k)/|g|, where g is the crystallographic point group and - g_k is the number of arms of k-star. - - """ - weights = [] - n = float(self._rot_grid_points.shape[1]) - for r_gps in self._rot_grid_points: - weights.append(np.sqrt(len(np.unique(r_gps)) / n)) - - sym_broken = False - for gp in np.unique(r_gps): - if len(np.where(r_gps == gp)[0]) != self._rot_grid_points.shape[ - 1 - ] // len(np.unique(r_gps)): - sym_broken = True - - if sym_broken: - print("=" * 26 + " Warning " + "=" * 26) - print("Symmetry of grid is broken.") - - return weights - - def _symmetrize_collision_matrix(self): - r"""Symmetrize collision matrix. - - (\Omega + \Omega^T) / 2. - - """ - start = time.time() - - try: - import phono3py._phono3py as phono3c - - if self._log_level: - sys.stdout.write("- Making collision matrix symmetric " "(built-in) ") - sys.stdout.flush() - phono3c.symmetrize_collision_matrix(self._collision_matrix) - except ImportError: - if self._log_level: - sys.stdout.write("- Making collision matrix symmetric " "(numpy) ") - sys.stdout.flush() - - if self._is_reducible_collision_matrix: - size = np.prod(self._collision_matrix.shape[2:4]) - else: - size = np.prod(self._collision_matrix.shape[2:5]) - for i in range(self._collision_matrix.shape[0]): - for j in range(self._collision_matrix.shape[1]): - col_mat = self._collision_matrix[i, j].reshape(size, size) - col_mat += col_mat.T - col_mat /= 2 - - if self._log_level: - print("[%.3fs]" % (time.time() - start)) - sys.stdout.flush() - - def _average_collision_matrix_by_degeneracy(self): - """Average symmetrically equivalent elemetns of collision matrix.""" - start = time.time() - - # Average matrix elements belonging to degenerate bands - if self._log_level: - sys.stdout.write( - "- Averaging collision matrix elements " "by phonon degeneracy " - ) - sys.stdout.flush() - - col_mat = self._collision_matrix - for i, gp in enumerate(self._ir_grid_points): - freqs = self._frequencies[gp] - deg_sets = degenerate_sets(freqs) - for dset in deg_sets: - bi_set = [] - for j in range(len(freqs)): - if j in dset: - bi_set.append(j) - - if self._is_reducible_collision_matrix: - i_data = self._pp.bz_grid.bzg2grg[gp] - sum_col = col_mat[:, :, i_data, bi_set, :, :].sum(axis=2) / len( - bi_set - ) - for j in bi_set: - col_mat[:, :, i_data, j, :, :] = sum_col - else: - sum_col = col_mat[:, :, i, bi_set, :, :, :, :].sum(axis=2) / len( - bi_set - ) - for j in bi_set: - col_mat[:, :, i, j, :, :, :, :] = sum_col - - for i, gp in enumerate(self._ir_grid_points): - freqs = self._frequencies[gp] - deg_sets = degenerate_sets(freqs) - for dset in deg_sets: - bi_set = [] - for j in range(len(freqs)): - if j in dset: - bi_set.append(j) - if self._is_reducible_collision_matrix: - i_data = self._pp.bz_grid.bzg2grg[gp] - sum_col = col_mat[:, :, :, :, i_data, bi_set].sum(axis=4) / len( - bi_set - ) - for j in bi_set: - col_mat[:, :, :, :, i_data, j] = sum_col - else: - sum_col = col_mat[:, :, :, :, :, i, bi_set, :].sum(axis=5) / len( - bi_set - ) - for j in bi_set: - col_mat[:, :, :, :, :, i, j, :] = sum_col - - if self._log_level: - print("[%.3fs]" % (time.time() - start)) - sys.stdout.flush() - - def _get_X(self, i_temp, weights, gv): - """Calculate X in Chaput's paper.""" - num_band = len(self._pp.primitive) * 3 - X = gv.copy() - if self._is_reducible_collision_matrix: - freqs = self._frequencies[self._pp.bz_grid.grg2bzg] - else: - freqs = self._frequencies[self._ir_grid_points] - - t = self._temperatures[i_temp] - sinh = np.where( - freqs > self._pp.cutoff_frequency, - np.sinh(freqs * THzToEv / (2 * Kb * t)), - -1.0, - ) - inv_sinh = np.where(sinh > 0, 1.0 / sinh, 0) - freqs_sinh = freqs * THzToEv * inv_sinh / (4 * Kb * t ** 2) - - for i, f in enumerate(freqs_sinh): - X[i] *= weights[i] - for j in range(num_band): - X[i, j] *= f[j] - - if t > 0: - return X.reshape(-1, 3) - else: - return np.zeros_like(X.reshape(-1, 3)) - - def _get_Y(self, i_sigma, i_temp, weights, X): - r"""Calculate Y = (\Omega^-1, X).""" - solver = _select_solver(self._pinv_solver) - num_band = len(self._pp.primitive) * 3 - - if self._is_reducible_collision_matrix: - num_grid_points = np.prod(self._pp.mesh_numbers) - size = num_grid_points * num_band - else: - num_grid_points = len(self._ir_grid_points) - size = num_grid_points * num_band * 3 - v = self._collision_matrix[i_sigma, i_temp].reshape(size, size) - # Transpose eigvecs because colmat was solved by column major order - if solver in [1, 2, 4, 5]: - v = v.T - - start = time.time() - - if solver in [0, 1, 2, 3, 4, 5]: - if self._log_level: - sys.stdout.write( - "Calculating pseudo-inv with cutoff=%-.1e " - "(np.dot) " % self._pinv_cutoff - ) - sys.stdout.flush() - - e = self._get_eigvals_pinv(i_sigma, i_temp) - if self._is_reducible_collision_matrix: - X1 = np.dot(v.T, X) - for i in range(3): - X1[:, i] *= e - Y = np.dot(v, X1) - else: - Y = np.dot(v, e * np.dot(v.T, X.ravel())).reshape(-1, 3) - else: # solver=6 This is slower as far as tested. - import phono3py._phono3py as phono3c - - if self._log_level: - sys.stdout.write( - "Calculating pseudo-inv with cutoff=%-.1e " - "(built-in) " % self._pinv_cutoff - ) - sys.stdout.flush() - - w = self._collision_eigenvalues[i_sigma, i_temp] - phono3c.pinv_from_eigensolution( - self._collision_matrix, w, i_sigma, i_temp, self._pinv_cutoff, 0 - ) - if self._is_reducible_collision_matrix: - Y = np.dot(v, X) - else: - Y = np.dot(v, X.ravel()).reshape(-1, 3) - - self._set_f_vectors(Y, num_grid_points, weights) - - if self._log_level: - print("[%.3fs]" % (time.time() - start)) - sys.stdout.flush() - - return Y - - def _set_f_vectors(self, Y, num_grid_points, weights): - """Calculate f-vectors. - - Collision matrix is half of that defined in Chaput's paper. - Therefore Y is divided by 2. - - """ - num_band = len(self._pp.primitive) * 3 - self._f_vectors[:] = ( - (Y / 2).reshape(num_grid_points, num_band * 3).T / weights - ).T.reshape(self._f_vectors.shape) - - def _get_eigvals_pinv(self, i_sigma, i_temp): - """Return inverse eigenvalues of eigenvalues > epsilon.""" - w = self._collision_eigenvalues[i_sigma, i_temp] - e = np.zeros_like(w) - for ll, val in enumerate(w): - if abs(val) > self._pinv_cutoff: - e[ll] = 1 / val - return e - - def _get_I(self, a, b, size, plus_transpose=True): - """Return I matrix in Chaput's PRL paper. - - None is returned if I is zero matrix. - - """ - r_sum = np.zeros((3, 3), dtype="double", order="C") - for r in self._rotations_cartesian: - for i in range(3): - for j in range(3): - r_sum[i, j] += r[a, i] * r[b, j] - if plus_transpose: - r_sum += r_sum.T - - # Return None not to consume computer for diagonalization - if (np.abs(r_sum) < 1e-10).all(): - return None - - # Same as np.kron(np.eye(size), r_sum), but writen as below - # to be sure the values in memory C-congiguous with 'double'. - I_mat = np.zeros((3 * size, 3 * size), dtype="double", order="C") - for i in range(size): - I_mat[(i * 3) : ((i + 1) * 3), (i * 3) : ((i + 1) * 3)] = r_sum - - return I_mat - - def _set_kappa(self, i_sigma, i_temp, weights): - """Calculate direct solution thermal conductivity. - - Either ir or full colmat. - - """ - if self._is_reducible_collision_matrix: - self._set_kappa_reducible_colmat(i_sigma, i_temp, weights) - else: - self._set_kappa_ir_colmat(i_sigma, i_temp, weights) - - def _set_kappa_ir_colmat(self, i_sigma, i_temp, weights): - """Calculate direct solution thermal conductivity of ir colmat.""" - if self._solve_collective_phonon: - self._set_mode_kappa_Chaput(i_sigma, i_temp, weights) - else: - N = self._num_sampling_grid_points - X = self._get_X(i_temp, weights, self._gv) - num_ir_grid_points = len(self._ir_grid_points) - Y = self._get_Y(i_sigma, i_temp, weights, X) - self._set_mean_free_path(i_sigma, i_temp, weights, Y) - self._set_mode_kappa( - self._mode_kappa, - X, - Y, - num_ir_grid_points, - self._rotations_cartesian, - i_sigma, - i_temp, - ) - # self._set_mode_kappa_from_mfp(weights, - # num_ir_grid_points, - # self._rotations_cartesian, - # i_sigma, - # i_temp) - - self._kappa[i_sigma, i_temp] = ( - self._mode_kappa[i_sigma, i_temp].sum(axis=0).sum(axis=0) / N - ) - - def _set_kappa_reducible_colmat(self, i_sigma, i_temp, weights): - """Calculate direct solution thermal conductivity of full colmat.""" - N = self._num_sampling_grid_points - X = self._get_X(i_temp, weights, self._gv) - num_mesh_points = np.prod(self._pp.mesh_numbers) - Y = self._get_Y(i_sigma, i_temp, weights, X) - self._set_mean_free_path(i_sigma, i_temp, weights, Y) - # Putting self._rotations_cartesian is to symmetrize kappa. - # None can be put instead for watching pure information. - self._set_mode_kappa( - self._mode_kappa, - X, - Y, - num_mesh_points, - self._rotations_cartesian, - i_sigma, - i_temp, - ) - self._mode_kappa[i_sigma, i_temp] /= len(self._rotations_cartesian) - self._kappa[i_sigma, i_temp] = ( - self._mode_kappa[i_sigma, i_temp].sum(axis=0).sum(axis=0) / N - ) - - def _set_kappa_RTA(self, i_sigma, i_temp, weights): - """Calculate RTA thermal conductivity with either ir or full colmat.""" - if self._is_reducible_collision_matrix: - self._set_kappa_RTA_reducible_colmat(i_sigma, i_temp, weights) - else: - self._set_kappa_RTA_ir_colmat(i_sigma, i_temp, weights) - - def _set_kappa_RTA_ir_colmat(self, i_sigma, i_temp, weights): - """Calculate RTA thermal conductivity. - - This RTA is supposed to be the same as conductivity_RTA. - - """ - N = self._num_sampling_grid_points - num_band = len(self._pp.primitive) * 3 - X = self._get_X(i_temp, weights, self._gv) - Y = np.zeros_like(X) - num_ir_grid_points = len(self._ir_grid_points) - for i, gp in enumerate(self._ir_grid_points): - g = self._get_main_diagonal(i, i_sigma, i_temp) - frequencies = self._frequencies[gp] - for j, f in enumerate(frequencies): - if f > self._pp.cutoff_frequency: - i_mode = i * num_band + j - old_settings = np.seterr(all="raise") - try: - Y[i_mode, :] = X[i_mode, :] / g[j] - except Exception: - print("=" * 26 + " Warning " + "=" * 26) - print( - " Unexpected physical condition of ph-ph " - "interaction calculation was found." - ) - print( - " g[j]=%f at gp=%d, band=%d, freq=%f" % (g[j], gp, j + 1, f) - ) - print("=" * 61) - np.seterr(**old_settings) - - self._set_mode_kappa( - self._mode_kappa_RTA, - X, - Y, - num_ir_grid_points, - self._rotations_cartesian, - i_sigma, - i_temp, - ) - self._kappa_RTA[i_sigma, i_temp] = ( - self._mode_kappa_RTA[i_sigma, i_temp].sum(axis=0).sum(axis=0) / N - ) - - def _set_kappa_RTA_reducible_colmat(self, i_sigma, i_temp, weights): - """Calculate RTA thermal conductivity. - - This RTA is not equivalent to conductivity_RTA. - The lifetime is defined from the diagonal part of - collision matrix. - - """ - N = self._num_sampling_grid_points - num_band = len(self._pp.primitive) * 3 - X = self._get_X(i_temp, weights, self._gv) - Y = np.zeros_like(X) - - num_mesh_points = np.prod(self._pp.mesh_numbers) - size = num_mesh_points * num_band - v_diag = np.diagonal( - self._collision_matrix[i_sigma, i_temp].reshape(size, size) - ) - - for gp in range(num_mesh_points): - frequencies = self._frequencies[gp] - for j, f in enumerate(frequencies): - if f > self._pp.cutoff_frequency: - i_mode = gp * num_band + j - Y[i_mode, :] = X[i_mode, :] / v_diag[i_mode] - # Putting self._rotations_cartesian is to symmetrize kappa. - # None can be put instead for watching pure information. - self._set_mode_kappa( - self._mode_kappa_RTA, - X, - Y, - num_mesh_points, - self._rotations_cartesian, - i_sigma, - i_temp, - ) - g = len(self._rotations_cartesian) - self._mode_kappa_RTA[i_sigma, i_temp] /= g - self._kappa_RTA[i_sigma, i_temp] = ( - self._mode_kappa_RTA[i_sigma, i_temp].sum(axis=0).sum(axis=0) / N - ) - - def _set_mode_kappa( - self, mode_kappa, X, Y, num_grid_points, rotations_cartesian, i_sigma, i_temp - ): - """Calculate mode thermal conductivity. - - The first parameter, mode_kappa, is overwritten. - - """ - num_band = len(self._pp.primitive) * 3 - for i, (v_gp, f_gp) in enumerate( - zip( - X.reshape(num_grid_points, num_band, 3), - Y.reshape(num_grid_points, num_band, 3), - ) - ): - - for j, (v, f) in enumerate(zip(v_gp, f_gp)): - # Do not consider three lowest modes at Gamma-point - # It is assumed that there are no imaginary modes. - if (self._pp.bz_grid.addresses[i] == 0).all() and j < 3: - continue - - if rotations_cartesian is None: - sum_k = np.outer(v, f) - else: - sum_k = np.zeros((3, 3), dtype="double") - for r in rotations_cartesian: - sum_k += np.outer(np.dot(r, v), np.dot(r, f)) - sum_k = sum_k + sum_k.T - for k, vxf in enumerate( - ((0, 0), (1, 1), (2, 2), (1, 2), (0, 2), (0, 1)) - ): - mode_kappa[i_sigma, i_temp, i, j, k] = sum_k[vxf] - - t = self._temperatures[i_temp] - # Collision matrix is defined as a half of that in Chaput's paper. - # Therefore here 2 is not necessary multiplied. - # sum_k = sum_k + sum_k.T is equivalent to I(a,b) + I(b,a). - mode_kappa[i_sigma, i_temp] *= self._conversion_factor * Kb * t ** 2 - - def _set_mode_kappa_Chaput(self, i_sigma, i_temp, weights): - """Calculate mode kappa by the way in Laurent Chaput's PRL paper. - - This gives the different result from _set_mode_kappa and requires more - memory space. - - """ - X = self._get_X(i_temp, weights, self._gv).ravel() - num_ir_grid_points = len(self._ir_grid_points) - num_band = len(self._pp.primitive) * 3 - size = num_ir_grid_points * num_band * 3 - v = self._collision_matrix[i_sigma, i_temp].reshape(size, size) - solver = _select_solver(self._pinv_solver) - if solver in [1, 2, 4, 5]: - v = v.T - e = self._get_eigvals_pinv(i_sigma, i_temp) - t = self._temperatures[i_temp] - - omega_inv = np.empty(v.shape, dtype="double", order="C") - np.dot(v, (e * v).T, out=omega_inv) - Y = np.dot(omega_inv, X) - self._set_f_vectors(Y, num_ir_grid_points, weights) - elems = ((0, 0), (1, 1), (2, 2), (1, 2), (0, 2), (0, 1)) - for i, vxf in enumerate(elems): - mat = self._get_I(vxf[0], vxf[1], num_ir_grid_points * num_band) - self._mode_kappa[i_sigma, i_temp, :, :, i] = 0 - if mat is not None: - np.dot(mat, omega_inv, out=mat) - # vals = (X ** 2 * np.diag(mat)).reshape(-1, 3).sum(axis=1) - # vals = vals.reshape(num_ir_grid_points, num_band) - # self._mode_kappa[i_sigma, i_temp, :, :, i] = vals - w = diagonalize_collision_matrix( - mat, pinv_solver=self._pinv_solver, log_level=self._log_level - ) - if solver in [1, 2, 4, 5]: - mat = mat.T - spectra = np.dot(mat.T, X) ** 2 * w - for s, eigvec in zip(spectra, mat.T): - vals = s * (eigvec ** 2).reshape(-1, 3).sum(axis=1) - vals = vals.reshape(num_ir_grid_points, num_band) - self._mode_kappa[i_sigma, i_temp, :, :, i] += vals - - factor = self._conversion_factor * Kb * t ** 2 - self._mode_kappa[i_sigma, i_temp] *= factor - - def _set_mode_kappa_from_mfp( - self, weights, num_grid_points, rotations_cartesian, i_sigma, i_temp - ): - for i, (v_gp, mfp_gp, cv_gp) in enumerate( - zip(self._gv, self._mfp[i_sigma, i_temp], self._cv[i_temp]) - ): - for j, (v, mfp, cv) in enumerate(zip(v_gp, mfp_gp, cv_gp)): - sum_k = np.zeros((3, 3), dtype="double") - for r in rotations_cartesian: - sum_k += np.outer(np.dot(r, v), np.dot(r, mfp)) - sum_k = (sum_k + sum_k.T) / 2 * cv * weights[i] ** 2 * 2 * np.pi - for k, vxf in enumerate( - ((0, 0), (1, 1), (2, 2), (1, 2), (0, 2), (0, 1)) - ): - self._mode_kappa[i_sigma, i_temp, i, j, k] = sum_k[vxf] - self._mode_kappa *= -self._conversion_factor - - def _set_mean_free_path(self, i_sigma, i_temp, weights, Y): - t = self._temperatures[i_temp] - # shape = (num_grid_points, num_band, 3), - for i, f_gp in enumerate(self._f_vectors): - for j, f in enumerate(f_gp): - cv = self._cv[i_temp, i, j] - if cv < 1e-10: - continue - self._mfp[i_sigma, i_temp, i, j] = ( - -2 * t * np.sqrt(Kb / cv) * f / (2 * np.pi) - ) - - def _show_log(self, i): - gp = self._grid_points[i] - frequencies = self._frequencies[gp] - if self._is_reducible_collision_matrix: - gv = self._gv[self._pp.bz_grid.bzg2grg[gp]] - else: - gv = self._gv[i] - if self._is_full_pp: - ave_pp = self._averaged_pp_interaction[i] - text = "Frequency group velocity (x, y, z) |gv| Pqj" - else: - text = "Frequency group velocity (x, y, z) |gv|" - - if self._gv_obj.q_length is None: - pass - else: - text += " (dq=%3.1e)" % self._gv_obj.q_length - print(text) - if self._is_full_pp: - for f, v, pp in zip(frequencies, gv, ave_pp): - print( - "%8.3f (%8.3f %8.3f %8.3f) %8.3f %11.3e" - % (f, v[0], v[1], v[2], np.linalg.norm(v), pp) - ) - else: - for f, v in zip(frequencies, gv): - print( - "%8.3f (%8.3f %8.3f %8.3f) %8.3f" - % (f, v[0], v[1], v[2], np.linalg.norm(v)) - ) - - sys.stdout.flush() - - def _py_symmetrize_collision_matrix(self): - num_band = len(self._pp.primitive) * 3 - num_ir_grid_points = len(self._ir_grid_points) - for i in range(num_ir_grid_points): - for j in range(num_band): - for k in range(3): - for ll in range(num_ir_grid_points): - for m in range(num_band): - for n in range(3): - self._py_set_symmetrized_element(i, j, k, ll, m, n) - - def _py_set_symmetrized_element(self, i, j, k, ll, m, n): - sym_val = ( - self._collision_matrix[:, :, i, j, k, ll, m, n] - + self._collision_matrix[:, :, ll, m, n, i, j, k] - ) / 2 - self._collision_matrix[:, :, i, j, k, ll, m, n] = sym_val - self._collision_matrix[:, :, ll, m, n, i, j, k] = sym_val - - def _py_symmetrize_collision_matrix_no_kappa_stars(self): - num_band = len(self._pp.primitive) * 3 - num_ir_grid_points = len(self._ir_grid_points) - for i in range(num_ir_grid_points): - for j in range(num_band): - for k in range(num_ir_grid_points): - for ll in range(num_band): - self._py_set_symmetrized_element_no_kappa_stars(i, j, k, ll) - - def _py_set_symmetrized_element_no_kappa_stars(self, i, j, k, ll): - sym_val = ( - self._collision_matrix[:, :, i, j, k, ll] - + self._collision_matrix[:, :, k, ll, i, j] - ) / 2 - self._collision_matrix[:, :, i, j, k, ll] = sym_val - self._collision_matrix[:, :, k, ll, i, j] = sym_val diff --git a/phono3py/phonon3/conductivity_RTA.py b/phono3py/phonon3/conductivity_RTA.py index 89046975..d76c4d1d 100644 --- a/phono3py/phonon3/conductivity_RTA.py +++ b/phono3py/phonon3/conductivity_RTA.py @@ -36,6 +36,7 @@ import sys import numpy as np from phonopy.structure.tetrahedron_method import TetrahedronMethod +from phonopy.phonon.group_velocity import GroupVelocity from phono3py.file_IO import ( write_kappa_to_hdf5, read_gamma_from_hdf5, @@ -44,460 +45,18 @@ from phono3py.file_IO import ( ) from phono3py.phonon3.conductivity import Conductivity, all_bands_exist, unit_to_WmK from phono3py.phonon3.conductivity import write_pp as _write_pp +from phono3py.phonon3.interaction import Interaction from phono3py.phonon3.imag_self_energy import ImagSelfEnergy, average_by_degeneracy from phono3py.phonon3.triplets import get_all_triplets from phono3py.phonon.grid import get_grid_points_by_rotations -def get_thermal_conductivity_RTA( - interaction, - temperatures=None, - sigmas=None, - sigma_cutoff=None, - mass_variances=None, - grid_points=None, - is_isotope=False, - boundary_mfp=None, # in micrometre - use_ave_pp=False, - is_kappa_star=True, - gv_delta_q=None, - is_full_pp=False, - write_gamma=False, - read_gamma=False, - is_N_U=False, - write_kappa=False, - write_pp=False, - read_pp=False, - write_gamma_detail=False, - compression="gzip", - input_filename=None, - output_filename=None, - log_level=0, -): - """Run RTA thermal conductivity calculation.""" - if temperatures is None: - _temperatures = np.arange(0, 1001, 10, dtype="double") - else: - _temperatures = temperatures - - if log_level: - print( - "-------------------- Lattice thermal conducitivity (RTA) " - "--------------------" - ) - br = Conductivity_RTA( - interaction, - grid_points=grid_points, - temperatures=_temperatures, - sigmas=sigmas, - sigma_cutoff=sigma_cutoff, - is_isotope=is_isotope, - mass_variances=mass_variances, - boundary_mfp=boundary_mfp, - use_ave_pp=use_ave_pp, - is_kappa_star=is_kappa_star, - gv_delta_q=gv_delta_q, - is_full_pp=is_full_pp, - read_pp=read_pp, - store_pp=write_pp, - pp_filename=input_filename, - is_N_U=is_N_U, - is_gamma_detail=write_gamma_detail, - log_level=log_level, - ) - - if read_gamma: - if not _set_gamma_from_file(br, filename=input_filename): - print("Reading collisions failed.") - return False - - for i in br: - if write_pp: - _write_pp( - br, interaction, i, compression=compression, filename=output_filename - ) - if write_gamma: - _write_gamma( - br, - interaction, - i, - compression=compression, - filename=output_filename, - verbose=log_level, - ) - if write_gamma_detail: - _write_gamma_detail( - br, - interaction, - i, - compression=compression, - filename=output_filename, - verbose=log_level, - ) - - if grid_points is None and all_bands_exist(interaction): - br.set_kappa_at_sigmas() - if log_level: - _show_kappa(br, log_level) - if write_kappa: - _write_kappa( - br, - interaction.primitive.volume, - compression=compression, - filename=output_filename, - log_level=log_level, - ) - - return br - - -def _write_gamma_detail( - br, interaction, i, compression="gzip", filename=None, verbose=True -): - gamma_detail = br.get_gamma_detail_at_q() - temperatures = br.get_temperatures() - mesh = br.get_mesh_numbers() - grid_points = br.get_grid_points() - gp = grid_points[i] - sigmas = br.get_sigmas() - sigma_cutoff = br.get_sigma_cutoff_width() - triplets, weights, _, _ = interaction.get_triplets_at_q() - all_triplets = get_all_triplets(gp, interaction.bz_grid) - - if all_bands_exist(interaction): - for j, sigma in enumerate(sigmas): - write_gamma_detail_to_hdf5( - temperatures, - mesh, - gamma_detail=gamma_detail, - grid_point=gp, - triplet=triplets, - weight=weights, - triplet_all=all_triplets, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - compression=compression, - filename=filename, - verbose=verbose, - ) - else: - for j, sigma in enumerate(sigmas): - for k, bi in enumerate(interaction.get_band_indices()): - write_gamma_detail_to_hdf5( - temperatures, - mesh, - gamma_detail=gamma_detail[:, :, k, :, :], - grid_point=gp, - triplet=triplets, - weight=weights, - band_index=bi, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - compression=compression, - filename=filename, - verbose=verbose, - ) - - -def _write_gamma(br, interaction, i, compression="gzip", filename=None, verbose=True): - """Write mode kappa related properties into a hdf5 file.""" - grid_points = br.grid_points - group_velocities = br.group_velocities - gv_by_gv = br.gv_by_gv - mode_heat_capacities = br.mode_heat_capacities - ave_pp = br.averaged_pp_interaction - mesh = br.mesh_numbers - temperatures = br.temperatures - gamma = br.gamma - gamma_isotope = br.gamma_isotope - sigmas = br.sigmas - sigma_cutoff = br.sigma_cutoff_width - volume = interaction.primitive.volume - gamma_N, gamma_U = br.get_gamma_N_U() - - gp = grid_points[i] - if all_bands_exist(interaction): - if ave_pp is None: - ave_pp_i = None - else: - ave_pp_i = ave_pp[i] - frequencies = interaction.get_phonons()[0][gp] - for j, sigma in enumerate(sigmas): - if gamma_isotope is not None: - gamma_isotope_at_sigma = gamma_isotope[j, i] - else: - gamma_isotope_at_sigma = None - if gamma_N is None: - gamma_N_at_sigma = None - else: - gamma_N_at_sigma = gamma_N[j, :, i] - if gamma_U is None: - gamma_U_at_sigma = None - else: - gamma_U_at_sigma = gamma_U[j, :, i] - - write_kappa_to_hdf5( - temperatures, - mesh, - frequency=frequencies, - group_velocity=group_velocities[i], - gv_by_gv=gv_by_gv[i], - heat_capacity=mode_heat_capacities[:, i], - gamma=gamma[j, :, i], - gamma_isotope=gamma_isotope_at_sigma, - gamma_N=gamma_N_at_sigma, - gamma_U=gamma_U_at_sigma, - averaged_pp_interaction=ave_pp_i, - grid_point=gp, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - kappa_unit_conversion=unit_to_WmK / volume, - compression=compression, - filename=filename, - verbose=verbose, - ) - else: - for j, sigma in enumerate(sigmas): - for k, bi in enumerate(interaction.band_indices): - if ave_pp is None: - ave_pp_ik = None - else: - ave_pp_ik = ave_pp[i, k] - frequencies = interaction.get_phonons()[0][gp, bi] - if gamma_isotope is not None: - gamma_isotope_at_sigma = gamma_isotope[j, i, k] - else: - gamma_isotope_at_sigma = None - if gamma_N is None: - gamma_N_at_sigma = None - else: - gamma_N_at_sigma = gamma_N[j, :, i, k] - if gamma_U is None: - gamma_U_at_sigma = None - else: - gamma_U_at_sigma = gamma_U[j, :, i, k] - write_kappa_to_hdf5( - temperatures, - mesh, - frequency=frequencies, - group_velocity=group_velocities[i, k], - gv_by_gv=gv_by_gv[i, k], - heat_capacity=mode_heat_capacities[:, i, k], - gamma=gamma[j, :, i, k], - gamma_isotope=gamma_isotope_at_sigma, - gamma_N=gamma_N_at_sigma, - gamma_U=gamma_U_at_sigma, - averaged_pp_interaction=ave_pp_ik, - grid_point=gp, - band_index=bi, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - kappa_unit_conversion=unit_to_WmK / volume, - compression=compression, - filename=filename, - verbose=verbose, - ) - - -def _show_kappa(br, log_level): - temperatures = br.temperatures - sigmas = br.sigmas - kappa = br.kappa - num_ignored_phonon_modes = br.get_number_of_ignored_phonon_modes() - num_band = br.frequencies.shape[1] - num_phonon_modes = br.get_number_of_sampling_grid_points() * num_band - for i, sigma in enumerate(sigmas): - text = "----------- Thermal conductivity (W/m-k) " - if sigma: - text += "for sigma=%s -----------" % sigma - else: - text += "with tetrahedron method -----------" - print(text) - if log_level > 1: - print( - ("#%6s " + " %-10s" * 6 + "#ipm") - % ("T(K)", "xx", "yy", "zz", "yz", "xz", "xy") - ) - for j, (t, k) in enumerate(zip(temperatures, kappa[i])): - print( - ("%7.1f" + " %10.3f" * 6 + " %d/%d") - % ( - (t,) - + tuple(k) - + (num_ignored_phonon_modes[i, j], num_phonon_modes) - ) - ) - else: - print( - ("#%6s " + " %-10s" * 6) - % ("T(K)", "xx", "yy", "zz", "yz", "xz", "xy") - ) - for j, (t, k) in enumerate(zip(temperatures, kappa[i])): - print(("%7.1f " + " %10.3f" * 6) % ((t,) + tuple(k))) - print("") - - -def _write_kappa(br, volume, compression="gzip", filename=None, log_level=0): - temperatures = br.temperatures - sigmas = br.sigmas - sigma_cutoff = br.sigma_cutoff_width - gamma = br.gamma - gamma_isotope = br.gamma_isotope - gamma_N, gamma_U = br.get_gamma_N_U() - mesh = br.mesh_numbers - frequencies = br.frequencies - gv = br.group_velocities - gv_by_gv = br.gv_by_gv - mode_cv = br.mode_heat_capacities - ave_pp = br.averaged_pp_interaction - qpoints = br.qpoints - weights = br.grid_weights - kappa = br.kappa - mode_kappa = br.mode_kappa - - for i, sigma in enumerate(sigmas): - kappa_at_sigma = kappa[i] - if gamma_isotope is not None: - gamma_isotope_at_sigma = gamma_isotope[i] - else: - gamma_isotope_at_sigma = None - if gamma_N is None: - gamma_N_at_sigma = None - else: - gamma_N_at_sigma = gamma_N[i] - if gamma_U is None: - gamma_U_at_sigma = None - else: - gamma_U_at_sigma = gamma_U[i] - - write_kappa_to_hdf5( - temperatures, - mesh, - frequency=frequencies, - group_velocity=gv, - gv_by_gv=gv_by_gv, - heat_capacity=mode_cv, - kappa=kappa_at_sigma, - mode_kappa=mode_kappa[i], - gamma=gamma[i], - gamma_isotope=gamma_isotope_at_sigma, - gamma_N=gamma_N_at_sigma, - gamma_U=gamma_U_at_sigma, - averaged_pp_interaction=ave_pp, - qpoint=qpoints, - weight=weights, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - kappa_unit_conversion=unit_to_WmK / volume, - compression=compression, - filename=filename, - verbose=log_level, - ) - - -def _set_gamma_from_file(br, filename=None, verbose=True): - """Read kappa-*.hdf5 files for thermal conductivity calculation.""" - sigmas = br.get_sigmas() - sigma_cutoff = br.get_sigma_cutoff_width() - mesh = br.get_mesh_numbers() - grid_points = br.get_grid_points() - temperatures = br.get_temperatures() - num_band = br.get_frequencies().shape[1] - - gamma = np.zeros( - (len(sigmas), len(temperatures), len(grid_points), num_band), dtype="double" - ) - gamma_N = np.zeros_like(gamma) - gamma_U = np.zeros_like(gamma) - gamma_iso = np.zeros((len(sigmas), len(grid_points), num_band), dtype="double") - ave_pp = np.zeros((len(grid_points), num_band), dtype="double") - - is_gamma_N_U_in = False - is_ave_pp_in = False - read_succeeded = True - - for j, sigma in enumerate(sigmas): - data = read_gamma_from_hdf5( - mesh, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - filename=filename, - verbose=verbose, - ) - if data: - gamma[j] = data["gamma"] - if "gamma_isotope" in data: - gamma_iso[j] = data["gamma_isotope"] - if "gamma_N" in data: - is_gamma_N_U_in = True - gamma_N[j] = data["gamma_N"] - gamma_U[j] = data["gamma_U"] - if "ave_pp" in data: - is_ave_pp_in = True - ave_pp[:] = data["ave_pp"] - else: - for i, gp in enumerate(grid_points): - data_gp = read_gamma_from_hdf5( - mesh, - grid_point=gp, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - filename=filename, - verbose=verbose, - ) - if data_gp: - gamma[j, :, i] = data_gp["gamma"] - if "gamma_iso" in data_gp: - gamma_iso[j, i] = data_gp["gamma_iso"] - if "gamma_N" in data_gp: - is_gamma_N_U_in = True - gamma_N[j, :, i] = data_gp["gamma_N"] - gamma_U[j, :, i] = data_gp["gamma_U"] - if "ave_pp" in data_gp: - is_ave_pp_in = True - ave_pp[i] = data_gp["ave_pp"] - else: - for bi in range(num_band): - data_band = read_gamma_from_hdf5( - mesh, - grid_point=gp, - band_index=bi, - sigma=sigma, - sigma_cutoff=sigma_cutoff, - filename=filename, - verbose=verbose, - ) - if data_band: - gamma[j, :, i, bi] = data_band["gamma"] - if "gamma_iso" in data_band: - gamma_iso[j, i, bi] = data_band["gamma_iso"] - if "gamma_N" in data_band: - is_gamma_N_U_in = True - gamma_N[j, :, i, bi] = data_band["gamma_N"] - gamma_U[j, :, i, bi] = data_band["gamma_U"] - if "ave_pp" in data_band: - is_ave_pp_in = True - ave_pp[i, bi] = data_band["ave_pp"] - else: - read_succeeded = False - - if read_succeeded: - br.set_gamma(gamma) - if is_ave_pp_in: - br.set_averaged_pp_interaction(ave_pp) - if is_gamma_N_U_in: - br.set_gamma_N_U(gamma_N, gamma_U) - return True - else: - return False - - class Conductivity_RTA(Conductivity): """Lattice thermal conductivity calculation with RTA.""" def __init__( self, - interaction, + interaction: Interaction, grid_points=None, temperatures=None, sigmas=None, @@ -518,8 +77,10 @@ class Conductivity_RTA(Conductivity): log_level=0, ): """Init method.""" - self._pp = None - self._gv_obj = None + self._pp: Interaction + self._grid_point_count: int + self._num_sampling_grid_points: int + self._gv_obj: GroupVelocity self._temperatures = None self._sigmas = None self._sigma_cutoff = None @@ -553,17 +114,14 @@ class Conductivity_RTA(Conductivity): self._use_const_ave_pp = None self._averaged_pp_interaction = None self._num_ignored_phonon_modes = None - self._num_sampling_grid_points = None self._conversion_factor = None self._is_isotope = None self._isotope = None self._mass_variances = None - self._grid_point_count = None - Conductivity.__init__( - self, + super().__init__( interaction, grid_points=grid_points, temperatures=temperatures, @@ -1010,3 +568,446 @@ class Conductivity_RTA(Conductivity): else: text += " (dq=%3.1e)" % self._gv_obj.q_length print(text) + + +def get_thermal_conductivity_RTA( + interaction: Interaction, + temperatures=None, + sigmas=None, + sigma_cutoff=None, + mass_variances=None, + grid_points=None, + is_isotope=False, + boundary_mfp=None, # in micrometre + use_ave_pp=False, + is_kappa_star=True, + gv_delta_q=None, + is_full_pp=False, + write_gamma=False, + read_gamma=False, + is_N_U=False, + write_kappa=False, + write_pp=False, + read_pp=False, + write_gamma_detail=False, + compression="gzip", + input_filename=None, + output_filename=None, + log_level=0, +): + """Run RTA thermal conductivity calculation.""" + if temperatures is None: + _temperatures = np.arange(0, 1001, 10, dtype="double") + else: + _temperatures = temperatures + + if log_level: + print( + "-------------------- Lattice thermal conducitivity (RTA) " + "--------------------" + ) + br = Conductivity_RTA( + interaction, + grid_points=grid_points, + temperatures=_temperatures, + sigmas=sigmas, + sigma_cutoff=sigma_cutoff, + is_isotope=is_isotope, + mass_variances=mass_variances, + boundary_mfp=boundary_mfp, + use_ave_pp=use_ave_pp, + is_kappa_star=is_kappa_star, + gv_delta_q=gv_delta_q, + is_full_pp=is_full_pp, + read_pp=read_pp, + store_pp=write_pp, + pp_filename=input_filename, + is_N_U=is_N_U, + is_gamma_detail=write_gamma_detail, + log_level=log_level, + ) + + if read_gamma: + if not _set_gamma_from_file(br, filename=input_filename): + print("Reading collisions failed.") + return False + + for i in br: + if write_pp: + _write_pp( + br, interaction, i, compression=compression, filename=output_filename + ) + if write_gamma: + _write_gamma( + br, + interaction, + i, + compression=compression, + filename=output_filename, + verbose=log_level, + ) + if write_gamma_detail: + _write_gamma_detail( + br, + interaction, + i, + compression=compression, + filename=output_filename, + verbose=log_level, + ) + + if grid_points is None and all_bands_exist(interaction): + br.set_kappa_at_sigmas() + if log_level: + _show_kappa(br, log_level) + if write_kappa: + _write_kappa( + br, + interaction.primitive.volume, + compression=compression, + filename=output_filename, + log_level=log_level, + ) + + return br + + +def _write_gamma_detail( + br, interaction, i, compression="gzip", filename=None, verbose=True +): + gamma_detail = br.get_gamma_detail_at_q() + temperatures = br.get_temperatures() + mesh = br.get_mesh_numbers() + grid_points = br.get_grid_points() + gp = grid_points[i] + sigmas = br.get_sigmas() + sigma_cutoff = br.get_sigma_cutoff_width() + triplets, weights, _, _ = interaction.get_triplets_at_q() + all_triplets = get_all_triplets(gp, interaction.bz_grid) + + if all_bands_exist(interaction): + for j, sigma in enumerate(sigmas): + write_gamma_detail_to_hdf5( + temperatures, + mesh, + gamma_detail=gamma_detail, + grid_point=gp, + triplet=triplets, + weight=weights, + triplet_all=all_triplets, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + compression=compression, + filename=filename, + verbose=verbose, + ) + else: + for j, sigma in enumerate(sigmas): + for k, bi in enumerate(interaction.get_band_indices()): + write_gamma_detail_to_hdf5( + temperatures, + mesh, + gamma_detail=gamma_detail[:, :, k, :, :], + grid_point=gp, + triplet=triplets, + weight=weights, + band_index=bi, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + compression=compression, + filename=filename, + verbose=verbose, + ) + + +def _write_gamma(br, interaction, i, compression="gzip", filename=None, verbose=True): + """Write mode kappa related properties into a hdf5 file.""" + grid_points = br.grid_points + group_velocities = br.group_velocities + gv_by_gv = br.gv_by_gv + mode_heat_capacities = br.mode_heat_capacities + ave_pp = br.averaged_pp_interaction + mesh = br.mesh_numbers + temperatures = br.temperatures + gamma = br.gamma + gamma_isotope = br.gamma_isotope + sigmas = br.sigmas + sigma_cutoff = br.sigma_cutoff_width + volume = interaction.primitive.volume + gamma_N, gamma_U = br.get_gamma_N_U() + + gp = grid_points[i] + if all_bands_exist(interaction): + if ave_pp is None: + ave_pp_i = None + else: + ave_pp_i = ave_pp[i] + frequencies = interaction.get_phonons()[0][gp] + for j, sigma in enumerate(sigmas): + if gamma_isotope is not None: + gamma_isotope_at_sigma = gamma_isotope[j, i] + else: + gamma_isotope_at_sigma = None + if gamma_N is None: + gamma_N_at_sigma = None + else: + gamma_N_at_sigma = gamma_N[j, :, i] + if gamma_U is None: + gamma_U_at_sigma = None + else: + gamma_U_at_sigma = gamma_U[j, :, i] + + write_kappa_to_hdf5( + temperatures, + mesh, + frequency=frequencies, + group_velocity=group_velocities[i], + gv_by_gv=gv_by_gv[i], + heat_capacity=mode_heat_capacities[:, i], + gamma=gamma[j, :, i], + gamma_isotope=gamma_isotope_at_sigma, + gamma_N=gamma_N_at_sigma, + gamma_U=gamma_U_at_sigma, + averaged_pp_interaction=ave_pp_i, + grid_point=gp, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + kappa_unit_conversion=unit_to_WmK / volume, + compression=compression, + filename=filename, + verbose=verbose, + ) + else: + for j, sigma in enumerate(sigmas): + for k, bi in enumerate(interaction.band_indices): + if ave_pp is None: + ave_pp_ik = None + else: + ave_pp_ik = ave_pp[i, k] + frequencies = interaction.get_phonons()[0][gp, bi] + if gamma_isotope is not None: + gamma_isotope_at_sigma = gamma_isotope[j, i, k] + else: + gamma_isotope_at_sigma = None + if gamma_N is None: + gamma_N_at_sigma = None + else: + gamma_N_at_sigma = gamma_N[j, :, i, k] + if gamma_U is None: + gamma_U_at_sigma = None + else: + gamma_U_at_sigma = gamma_U[j, :, i, k] + write_kappa_to_hdf5( + temperatures, + mesh, + frequency=frequencies, + group_velocity=group_velocities[i, k], + gv_by_gv=gv_by_gv[i, k], + heat_capacity=mode_heat_capacities[:, i, k], + gamma=gamma[j, :, i, k], + gamma_isotope=gamma_isotope_at_sigma, + gamma_N=gamma_N_at_sigma, + gamma_U=gamma_U_at_sigma, + averaged_pp_interaction=ave_pp_ik, + grid_point=gp, + band_index=bi, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + kappa_unit_conversion=unit_to_WmK / volume, + compression=compression, + filename=filename, + verbose=verbose, + ) + + +def _show_kappa(br, log_level): + temperatures = br.temperatures + sigmas = br.sigmas + kappa = br.kappa + num_ignored_phonon_modes = br.get_number_of_ignored_phonon_modes() + num_band = br.frequencies.shape[1] + num_phonon_modes = br.get_number_of_sampling_grid_points() * num_band + for i, sigma in enumerate(sigmas): + text = "----------- Thermal conductivity (W/m-k) " + if sigma: + text += "for sigma=%s -----------" % sigma + else: + text += "with tetrahedron method -----------" + print(text) + if log_level > 1: + print( + ("#%6s " + " %-10s" * 6 + "#ipm") + % ("T(K)", "xx", "yy", "zz", "yz", "xz", "xy") + ) + for j, (t, k) in enumerate(zip(temperatures, kappa[i])): + print( + ("%7.1f" + " %10.3f" * 6 + " %d/%d") + % ( + (t,) + + tuple(k) + + (num_ignored_phonon_modes[i, j], num_phonon_modes) + ) + ) + else: + print( + ("#%6s " + " %-10s" * 6) + % ("T(K)", "xx", "yy", "zz", "yz", "xz", "xy") + ) + for j, (t, k) in enumerate(zip(temperatures, kappa[i])): + print(("%7.1f " + " %10.3f" * 6) % ((t,) + tuple(k))) + print("") + + +def _write_kappa(br, volume, compression="gzip", filename=None, log_level=0): + temperatures = br.temperatures + sigmas = br.sigmas + sigma_cutoff = br.sigma_cutoff_width + gamma = br.gamma + gamma_isotope = br.gamma_isotope + gamma_N, gamma_U = br.get_gamma_N_U() + mesh = br.mesh_numbers + frequencies = br.frequencies + gv = br.group_velocities + gv_by_gv = br.gv_by_gv + mode_cv = br.mode_heat_capacities + ave_pp = br.averaged_pp_interaction + qpoints = br.qpoints + weights = br.grid_weights + kappa = br.kappa + mode_kappa = br.mode_kappa + + for i, sigma in enumerate(sigmas): + kappa_at_sigma = kappa[i] + if gamma_isotope is not None: + gamma_isotope_at_sigma = gamma_isotope[i] + else: + gamma_isotope_at_sigma = None + if gamma_N is None: + gamma_N_at_sigma = None + else: + gamma_N_at_sigma = gamma_N[i] + if gamma_U is None: + gamma_U_at_sigma = None + else: + gamma_U_at_sigma = gamma_U[i] + + write_kappa_to_hdf5( + temperatures, + mesh, + frequency=frequencies, + group_velocity=gv, + gv_by_gv=gv_by_gv, + heat_capacity=mode_cv, + kappa=kappa_at_sigma, + mode_kappa=mode_kappa[i], + gamma=gamma[i], + gamma_isotope=gamma_isotope_at_sigma, + gamma_N=gamma_N_at_sigma, + gamma_U=gamma_U_at_sigma, + averaged_pp_interaction=ave_pp, + qpoint=qpoints, + weight=weights, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + kappa_unit_conversion=unit_to_WmK / volume, + compression=compression, + filename=filename, + verbose=log_level, + ) + + +def _set_gamma_from_file(br, filename=None, verbose=True): + """Read kappa-*.hdf5 files for thermal conductivity calculation.""" + sigmas = br.get_sigmas() + sigma_cutoff = br.get_sigma_cutoff_width() + mesh = br.get_mesh_numbers() + grid_points = br.get_grid_points() + temperatures = br.get_temperatures() + num_band = br.get_frequencies().shape[1] + + gamma = np.zeros( + (len(sigmas), len(temperatures), len(grid_points), num_band), dtype="double" + ) + gamma_N = np.zeros_like(gamma) + gamma_U = np.zeros_like(gamma) + gamma_iso = np.zeros((len(sigmas), len(grid_points), num_band), dtype="double") + ave_pp = np.zeros((len(grid_points), num_band), dtype="double") + + is_gamma_N_U_in = False + is_ave_pp_in = False + read_succeeded = True + + for j, sigma in enumerate(sigmas): + data = read_gamma_from_hdf5( + mesh, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + filename=filename, + verbose=verbose, + ) + if data: + gamma[j] = data["gamma"] + if "gamma_isotope" in data: + gamma_iso[j] = data["gamma_isotope"] + if "gamma_N" in data: + is_gamma_N_U_in = True + gamma_N[j] = data["gamma_N"] + gamma_U[j] = data["gamma_U"] + if "ave_pp" in data: + is_ave_pp_in = True + ave_pp[:] = data["ave_pp"] + else: + for i, gp in enumerate(grid_points): + data_gp = read_gamma_from_hdf5( + mesh, + grid_point=gp, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + filename=filename, + verbose=verbose, + ) + if data_gp: + gamma[j, :, i] = data_gp["gamma"] + if "gamma_iso" in data_gp: + gamma_iso[j, i] = data_gp["gamma_iso"] + if "gamma_N" in data_gp: + is_gamma_N_U_in = True + gamma_N[j, :, i] = data_gp["gamma_N"] + gamma_U[j, :, i] = data_gp["gamma_U"] + if "ave_pp" in data_gp: + is_ave_pp_in = True + ave_pp[i] = data_gp["ave_pp"] + else: + for bi in range(num_band): + data_band = read_gamma_from_hdf5( + mesh, + grid_point=gp, + band_index=bi, + sigma=sigma, + sigma_cutoff=sigma_cutoff, + filename=filename, + verbose=verbose, + ) + if data_band: + gamma[j, :, i, bi] = data_band["gamma"] + if "gamma_iso" in data_band: + gamma_iso[j, i, bi] = data_band["gamma_iso"] + if "gamma_N" in data_band: + is_gamma_N_U_in = True + gamma_N[j, :, i, bi] = data_band["gamma_N"] + gamma_U[j, :, i, bi] = data_band["gamma_U"] + if "ave_pp" in data_band: + is_ave_pp_in = True + ave_pp[i, bi] = data_band["ave_pp"] + else: + read_succeeded = False + + if read_succeeded: + br.set_gamma(gamma) + if is_ave_pp_in: + br.set_averaged_pp_interaction(ave_pp) + if is_gamma_N_U_in: + br.set_gamma_N_U(gamma_N, gamma_U) + return True + else: + return False diff --git a/phono3py/phonon3/displacement_fc3.py b/phono3py/phonon3/displacement_fc3.py index c48ba4d8..ab9f2d8b 100644 --- a/phono3py/phonon3/displacement_fc3.py +++ b/phono3py/phonon3/displacement_fc3.py @@ -40,11 +40,16 @@ from phonopy.harmonic.displacement import ( get_displacement, is_minus_displacement, ) +from phonopy.structure.atoms import PhonopyAtoms +from phonopy.structure.symmetry import Symmetry from phonopy.structure.cells import get_smallest_vectors def direction_to_displacement( - direction_dataset, displacement_distance, supercell, cutoff_distance=None + direction_dataset, + displacement_distance, + supercell: PhonopyAtoms, + cutoff_distance=None, ): """Convert displacement directions to those in Cartesian coordinates. @@ -125,7 +130,7 @@ def direction_to_displacement( def get_third_order_displacements( - cell, symmetry, is_plusminus="auto", is_diagonal=False + cell: PhonopyAtoms, symmetry: Symmetry, is_plusminus="auto", is_diagonal=False ): """Create dispalcement dataset. @@ -277,11 +282,11 @@ def get_least_orbits(atom_index, cell, site_symmetry, symprec=1e-5): def get_smallest_vector_of_atom_pair( - atom_number_supercell, atom_number_primitive, supercell, symprec + atom_number_supercell, atom_number_primitive, supercell: PhonopyAtoms, symprec ): """Return smallest vectors of an atom pair in supercell.""" s_pos = supercell.scaled_positions - svecs, multi = get_smallest_vectors( + svecs, _ = get_smallest_vectors( supercell.cell, [s_pos[atom_number_supercell]], [s_pos[atom_number_primitive]], diff --git a/phono3py/phonon3/fc3.py b/phono3py/phonon3/fc3.py index f91c717f..cbd41a79 100644 --- a/phono3py/phonon3/fc3.py +++ b/phono3py/phonon3/fc3.py @@ -50,13 +50,20 @@ from phono3py.phonon3.displacement_fc3 import ( get_bond_symmetry, get_smallest_vector_of_atom_pair, ) -from phonopy.structure.cells import compute_all_sg_permutations +from phonopy.structure.atoms import PhonopyAtoms +from phonopy.structure.cells import compute_all_sg_permutations, Primitive +from phonopy.structure.symmetry import Symmetry logger = logging.getLogger(__name__) def get_fc3( - supercell, primitive, disp_dataset, symmetry, is_compact_fc=False, verbose=False + supercell: PhonopyAtoms, + primitive: Primitive, + disp_dataset, + symmetry: Symmetry, + is_compact_fc=False, + verbose=False, ): """Calculate fc3.""" # fc2 has to be full matrix to compute delta-fc2 @@ -75,7 +82,7 @@ def get_fc3( print("Expanding fc3.") first_disp_atoms = np.unique([x["number"] for x in disp_dataset["first_atoms"]]) - rotations = symmetry.get_symmetry_operations()["rotations"] + rotations = symmetry.symmetry_operations["rotations"] lattice = supercell.cell.T permutations = symmetry.atomic_permutations @@ -698,14 +705,16 @@ def _third_rank_tensor_rotation_elem(rot, tensor, ll, m, n): return sum_elems -def _get_fc3_done(supercell, disp_dataset, symmetry, array_shape): +def _get_fc3_done( + supercell: PhonopyAtoms, disp_dataset, symmetry: Symmetry, array_shape +): num_atom = len(supercell) fc3_done = np.zeros(array_shape, dtype="byte") symprec = symmetry.tolerance lattice = supercell.cell.T positions = supercell.scaled_positions - rotations = symmetry.get_symmetry_operations()["rotations"] - translations = symmetry.get_symmetry_operations()["translations"] + rotations = symmetry.symmetry_operations["rotations"] + translations = symmetry.symmetry_operations["translations"] atom_mapping = [] for rot, trans in zip(rotations, translations): @@ -719,7 +728,7 @@ def _get_fc3_done(supercell, disp_dataset, symmetry, array_shape): first_atom_num = dataset_first_atom["number"] site_symmetry = symmetry.get_site_symmetry(first_atom_num) direction = np.dot( - dataset_first_atom["displacement"], np.linalg.inv(supercell.get_cell()) + dataset_first_atom["displacement"], np.linalg.inv(supercell.cell) ) reduced_site_sym = get_reduced_site_symmetry(site_symmetry, direction, symprec) least_second_atom_nums = [] diff --git a/phono3py/phonon3/interaction.py b/phono3py/phonon3/interaction.py index 13078a8d..de8df5f3 100644 --- a/phono3py/phonon3/interaction.py +++ b/phono3py/phonon3/interaction.py @@ -51,7 +51,7 @@ from phono3py.phonon3.reciprocal_to_normal import ReciprocalToNormal from phono3py.phonon3.triplets import get_triplets_at_q, get_nosym_triplets_at_q -class Interaction(object): +class Interaction: """Calculate ph-ph interaction and phonons on grid. This class instance is the heart of phono3py calculation. From 73548808c573b7dd818c594ee24f6387f8ebd68a Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Fri, 22 Oct 2021 12:23:04 +0900 Subject: [PATCH 20/34] Minor refactorings --- phono3py/phonon/grid.py | 6 ++- phono3py/phonon3/collision_matrix.py | 9 +++-- phono3py/phonon3/conductivity.py | 57 ++++++++++++++++----------- phono3py/phonon3/conductivity_LBTE.py | 39 ++++++++++-------- phono3py/phonon3/conductivity_RTA.py | 23 +++++------ phono3py/phonon3/interaction.py | 9 ++++- 6 files changed, 85 insertions(+), 58 deletions(-) diff --git a/phono3py/phonon/grid.py b/phono3py/phonon/grid.py index 550c9d39..86a5502c 100644 --- a/phono3py/phonon/grid.py +++ b/phono3py/phonon/grid.py @@ -324,7 +324,9 @@ class BZGrid(object): def rotations(self): """Return rotation matrices for grid points. - Rotation matrices for GR-grid addresses (g) defined as g'=Rg. + Rotation matrices for GR-grid addresses (g) defined as g'=Rg. This can + be different from ``reciprocal_operations`` when GR-grid is used because + grid addresses are defined on an oblique lattice. shape=(rotations, 3, 3), dtype='int_', order='C'. """ @@ -591,7 +593,7 @@ def get_ir_grid_points(bz_grid): def get_grid_points_by_rotations( - bz_gp, bz_grid, reciprocal_rotations=None, with_surface=False + bz_gp, bz_grid: BZGrid, reciprocal_rotations=None, with_surface=False ): """Return BZ-grid point indices rotated from a BZ-grid point index. diff --git a/phono3py/phonon3/collision_matrix.py b/phono3py/phonon3/collision_matrix.py index 7da6a0fc..30cd50af 100644 --- a/phono3py/phonon3/collision_matrix.py +++ b/phono3py/phonon3/collision_matrix.py @@ -36,6 +36,7 @@ import numpy as np from phonopy.units import THzToEv, Kb from phono3py.phonon3.imag_self_energy import ImagSelfEnergy +from phono3py.phonon3.interaction import Interaction class CollisionMatrix(ImagSelfEnergy): @@ -48,7 +49,7 @@ class CollisionMatrix(ImagSelfEnergy): def __init__( self, - interaction, + interaction: Interaction, rotations_cartesian=None, num_ir_grid_points=None, rot_grid_points=None, @@ -57,7 +58,8 @@ class CollisionMatrix(ImagSelfEnergy): lang="C", ): """Init method.""" - self._pp = None + self._pp: Interaction + self._is_collision_matrix: bool self._sigma = None self._frequency_points = None self._temperature = None @@ -74,11 +76,10 @@ class CollisionMatrix(ImagSelfEnergy): self._unit_conversion = None self._cutoff_frequency = None self._g = None - self._is_collision_matrix = None self._unit_conversion = None self._log_level = log_level - ImagSelfEnergy.__init__(self, interaction, lang=lang) + super().__init__(interaction, lang=lang) self._is_reducible_collision_matrix = is_reducible_collision_matrix self._is_collision_matrix = True diff --git a/phono3py/phonon3/conductivity.py b/phono3py/phonon3/conductivity.py index 23273f70..6d954581 100644 --- a/phono3py/phonon3/conductivity.py +++ b/phono3py/phonon3/conductivity.py @@ -67,7 +67,7 @@ class ConductivityBase: interaction : Interaction Interaction class instance. grid_points : array_like or None, optional - Grid point indices. When None, ir-grid points are searched + Grid point indices in BZgrid. When None, ir-grid points are searched internally. Default is None. shape=(grid_points, ), dtype='int_'. is_kappa_star : bool, optional @@ -94,9 +94,7 @@ class ConductivityBase: self._set_grid_properties(grid_points) self._qpoints = np.array( - np.dot( - self._pp.bz_grid.addresses[self._grid_points], self._pp.bz_grid.QDinv.T - ), + self._get_qpoint_from_gp_index(self._grid_points), dtype="double", order="C", ) @@ -146,6 +144,9 @@ class ConductivityBase: ) return ir_grid_points, ir_grid_weights + def _get_qpoint_from_gp_index(self, i_gps): + return np.dot(self._pp.bz_grid.addresses[i_gps], self._pp.bz_grid.QDinv.T) + class Conductivity(ConductivityBase): """Thermal conductivity base class.""" @@ -624,20 +625,10 @@ class Conductivity(ConductivityBase): ) self._mass_variances = self._isotope.mass_variances - def _set_harmonic_properties(self, i_irgp, i_data): - """Set group velocity and mode heat capacity.""" + def _set_cv(self, i_irgp, i_data): + """Set mode heat capacity.""" grid_point = self._grid_points[i_irgp] freqs = self._frequencies[grid_point][self._pp.band_indices] - self._cv[:, i_data, :] = self._get_cv(freqs) - self._gv_obj.run( - [ - self._qpoints[i_irgp], - ] - ) - gv = self._gv_obj.group_velocities[0, self._pp.band_indices, :] - self._gv[i_data] = gv - - def _get_cv(self, freqs): cv = np.zeros((len(self._temperatures), len(freqs)), dtype="double") # T/freq has to be large enough to avoid divergence. # Otherwise just set 0. @@ -651,7 +642,27 @@ class Conductivity(ConductivityBase): ), 0, ) - return cv + self._cv[:, i_data, :] = cv + + def _set_gv(self, i_irgp, i_data): + """Set group velocity.""" + irgp = self._grid_points[i_irgp] + if self._is_kappa_star: + gps_rotated = get_grid_points_by_rotations( + irgp, self._pp.bz_grid, with_surface=True + ) + else: + gps_rotated = get_grid_points_by_rotations( + irgp, + self._pp.bz_grid, + reciprocal_rotations=self._point_operations, + ) + unique_gps = np.unique(gps_rotated) + gvs = {} + for bz_gp in unique_gps: + self._gv_obj.run([self._get_qpoint_from_gp_index(bz_gp)]) + gvs[bz_gp] = self._gv_obj.group_velocities[0, self._pp.band_indices, :] + self._gv[i_data] = gvs[irgp] def _set_gv_by_gv(self, i_irgp, i_data): """Outer product of group velocities. @@ -714,26 +725,26 @@ class Conductivity(ConductivityBase): main_diagonal += self._get_boundary_scattering(i) return main_diagonal - def _get_boundary_scattering(self, i): + def _get_boundary_scattering(self, i_gp): num_band = len(self._pp.primitive) * 3 g_boundary = np.zeros(num_band, dtype="double") for ll in range(num_band): g_boundary[ll] = ( - np.linalg.norm(self._gv[i, ll]) + np.linalg.norm(self._gv[i_gp, ll]) * Angstrom * 1e6 / (4 * np.pi * self._boundary_mfp) ) return g_boundary - def _show_log_header(self, i): + def _show_log_header(self, i_gp): if self._log_level: - gp = self._grid_points[i] + gp = self._grid_points[i_gp] print( "======================= Grid point %d (%d/%d) " - "=======================" % (gp, i + 1, len(self._grid_points)) + "=======================" % (gp, i_gp + 1, len(self._grid_points)) ) - print("q-point: (%5.2f %5.2f %5.2f)" % tuple(self._qpoints[i])) + print("q-point: (%5.2f %5.2f %5.2f)" % tuple(self._qpoints[i_gp])) if self._boundary_mfp is not None: if self._boundary_mfp > 1000: print( diff --git a/phono3py/phonon3/conductivity_LBTE.py b/phono3py/phonon3/conductivity_LBTE.py index 2b2fde4f..c8c2540f 100644 --- a/phono3py/phonon3/conductivity_LBTE.py +++ b/phono3py/phonon3/conductivity_LBTE.py @@ -126,8 +126,7 @@ class Conductivity_LBTE(Conductivity): self._collision_eigenvalues = None - Conductivity.__init__( - self, + super().__init__( interaction, grid_points=grid_points, temperatures=temperatures, @@ -229,9 +228,9 @@ class Conductivity_LBTE(Conductivity): def _run_at_grid_point(self): """Calculate properties at a grid point.""" - i = self._grid_point_count - self._show_log_header(i) - gp = self._grid_points[i] + i_gp = self._grid_point_count + self._show_log_header(i_gp) + gp = self._grid_points[i_gp] if not self._all_grid_points: self._collision_matrix[:] = 0 @@ -242,21 +241,22 @@ class Conductivity_LBTE(Conductivity): if self._log_level: print("Number of triplets: %d" % len(self._pp.get_triplets_at_q()[0])) - self._set_collision_matrix_at_sigmas(i) + self._set_collision_matrix_at_sigmas(i_gp) if self._is_reducible_collision_matrix: i_data = self._pp.bz_grid.bzg2grg[gp] else: - i_data = i - self._set_harmonic_properties(i, i_data) - self._set_gv_by_gv(i, i_data) + i_data = i_gp + self._set_cv(i_gp, i_data) + self._set_gv(i_gp, i_data) + self._set_gv_by_gv(i_gp, i_data) if self._isotope is not None: - gamma_iso = self._get_gamma_isotope_at_sigmas(i) + gamma_iso = self._get_gamma_isotope_at_sigmas(i_gp) band_indices = self._pp.band_indices self._gamma_iso[:, i_data, :] = gamma_iso[:, band_indices] if self._log_level: - self._show_log(i) + self._show_log(i_gp) def _allocate_values(self): """Allocate arrays.""" @@ -394,10 +394,10 @@ class Conductivity_LBTE(Conductivity): order="C", ) - def _set_collision_matrix_at_sigmas(self, i): + def _set_collision_matrix_at_sigmas(self, i_gp): """Calculate collision matrices at grid point. - i : int + i_gp : int Grid point count. """ @@ -420,7 +420,7 @@ class Conductivity_LBTE(Conductivity): if self._read_pp: pp, _g_zero = read_pp_from_hdf5( self._pp.mesh_numbers, - grid_point=self._grid_points[i], + grid_point=self._grid_points[i_gp], sigma=sigma, sigma_cutoff=self._sigma_cutoff, filename=self._pp_filename, @@ -445,16 +445,18 @@ class Conductivity_LBTE(Conductivity): self._collision.run_interaction(is_full_pp=self._is_full_pp) if self._is_full_pp and j == 0: - self._averaged_pp_interaction[i] = self._pp.get_averaged_interaction() + self._averaged_pp_interaction[ + i_gp + ] = self._pp.get_averaged_interaction() for k, t in enumerate(self._temperatures): self._collision.set_temperature(t) self._collision.run() if self._all_grid_points: if self._is_reducible_collision_matrix: - i_data = self._pp.bz_grid.bzg2grg[self._grid_points[i]] + i_data = self._pp.bz_grid.bzg2grg[self._grid_points[i_gp]] else: - i_data = i + i_data = i_gp else: i_data = 0 self._gamma[j, k, i_data] = self._collision.get_imag_self_energy() @@ -625,7 +627,10 @@ class Conductivity_LBTE(Conductivity): def _get_weights(self): """Return weights used for collision matrix and |X> and |f>. + For symmetry compressed collision matrix. + 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_' r_gps : grid points of arms of k-star with duplicates diff --git a/phono3py/phonon3/conductivity_RTA.py b/phono3py/phonon3/conductivity_RTA.py index d76c4d1d..2ad7fdd4 100644 --- a/phono3py/phonon3/conductivity_RTA.py +++ b/phono3py/phonon3/conductivity_RTA.py @@ -210,16 +210,17 @@ class Conductivity_RTA(Conductivity): self._averaged_pp_interaction = ave_pp def _run_at_grid_point(self): - i = self._grid_point_count - self._show_log_header(i) - grid_point = self._grid_points[i] - self._set_harmonic_properties(i, i) - self._set_gv_by_gv(i, i) + i_gp = self._grid_point_count + self._show_log_header(i_gp) + grid_point = self._grid_points[i_gp] + self._set_cv(i_gp, i_gp) + self._set_gv(i_gp, i_gp) + self._set_gv_by_gv(i_gp, i_gp) if self._read_gamma: if self._use_ave_pp: self._collision.set_grid_point(grid_point) - self._set_gamma_at_sigmas(i) + self._set_gamma_at_sigmas(i_gp) else: self._collision.set_grid_point(grid_point) num_triplets = len(self._pp.get_triplets_at_q()[0]) @@ -234,16 +235,16 @@ class Conductivity_RTA(Conductivity): or self._use_const_ave_pp or self._is_gamma_detail ): - self._set_gamma_at_sigmas(i) + self._set_gamma_at_sigmas(i_gp) else: # can save memory space - self._set_gamma_at_sigmas_lowmem(i) + self._set_gamma_at_sigmas_lowmem(i_gp) if self._isotope is not None and not self._read_gamma_iso: - gamma_iso = self._get_gamma_isotope_at_sigmas(i) - self._gamma_iso[:, i, :] = gamma_iso[:, self._pp.band_indices] + gamma_iso = self._get_gamma_isotope_at_sigmas(i_gp) + self._gamma_iso[:, i_gp, :] = gamma_iso[:, self._pp.band_indices] if self._log_level: - self._show_log(self._qpoints[i], i) + self._show_log(self._qpoints[i_gp], i_gp) def _allocate_values(self): num_band0 = len(self._pp.band_indices) diff --git a/phono3py/phonon3/interaction.py b/phono3py/phonon3/interaction.py index de8df5f3..45070b3c 100644 --- a/phono3py/phonon3/interaction.py +++ b/phono3py/phonon3/interaction.py @@ -283,7 +283,14 @@ class Interaction: return self._primitive_symmetry def get_triplets_at_q(self): - """Return grid point triplets information.""" + """Return grid point triplets information. + + triplets_at_q is in BZ-grid. + triplets_map_at_q is in GR-grid. + ir_map_at_q is in GR-grid. + See details at ``get_triplets_at_q``. + + """ return ( self._triplets_at_q, self._weights_at_q, From 239965e961d436a321416eeb5a231f5897cbeb32 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Fri, 22 Oct 2021 17:56:34 +0900 Subject: [PATCH 21/34] Group velocity avaraging in conductivity --- phono3py/api_phono3py.py | 1 + phono3py/phonon/grid.py | 2 +- phono3py/phonon3/conductivity.py | 37 +++++++++++++++++++++----------- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/phono3py/api_phono3py.py b/phono3py/api_phono3py.py index 0c2f67c2..4bbb34ee 100644 --- a/phono3py/api_phono3py.py +++ b/phono3py/api_phono3py.py @@ -2533,6 +2533,7 @@ class Phono3py(object): mesh, lattice=self._primitive.cell, symmetry_dataset=self._primitive_symmetry.dataset, + is_time_reversal=self._is_symmetry, use_grg=self._use_grg, store_dense_gp_map=self._store_dense_gp_map, ) diff --git a/phono3py/phonon/grid.py b/phono3py/phonon/grid.py index 86a5502c..c0b171f7 100644 --- a/phono3py/phonon/grid.py +++ b/phono3py/phonon/grid.py @@ -43,7 +43,7 @@ from phonopy.structure.cells import ( from phonopy.structure.grid_points import length2mesh, extract_ir_grid_points -class BZGrid(object): +class BZGrid: """Data structure of BZ grid. GR-grid and BZ-grid diff --git a/phono3py/phonon3/conductivity.py b/phono3py/phonon3/conductivity.py index 6d954581..873cb3aa 100644 --- a/phono3py/phonon3/conductivity.py +++ b/phono3py/phonon3/conductivity.py @@ -145,12 +145,22 @@ class ConductivityBase: return ir_grid_points, ir_grid_weights def _get_qpoint_from_gp_index(self, i_gps): + """Return q-point(s) in reduced coordinates of grid point(s). + + Parameters + ---------- + i_gps : int or ndarray + BZ-grid index (int) or indices (ndarray). + + """ return np.dot(self._pp.bz_grid.addresses[i_gps], self._pp.bz_grid.QDinv.T) class Conductivity(ConductivityBase): """Thermal conductivity base class.""" + _average_gv_over_kstar = False + def __init__( self, interaction: Interaction, @@ -647,22 +657,25 @@ class Conductivity(ConductivityBase): def _set_gv(self, i_irgp, i_data): """Set group velocity.""" irgp = self._grid_points[i_irgp] - if self._is_kappa_star: + if self._average_gv_over_kstar and len(self._point_operations) > 1: gps_rotated = get_grid_points_by_rotations( irgp, self._pp.bz_grid, with_surface=True ) + assert len(gps_rotated) == len(self._point_operations) + + unique_gps = np.unique(gps_rotated) + gvs = {} + for bz_gp in unique_gps.tolist(): # To conver to int type. + self._gv_obj.run([self._get_qpoint_from_gp_index(bz_gp)]) + gvs[bz_gp] = self._gv_obj.group_velocities[0, self._pp.band_indices, :] + gv = np.zeros_like(gvs[irgp]) + for bz_gp, r in zip(gps_rotated, self._rotations_cartesian): + gv += np.dot(gvs[bz_gp], r) # = dot(r_inv, gv) + self._gv[i_data] = gv / len(self._point_operations) else: - gps_rotated = get_grid_points_by_rotations( - irgp, - self._pp.bz_grid, - reciprocal_rotations=self._point_operations, - ) - unique_gps = np.unique(gps_rotated) - gvs = {} - for bz_gp in unique_gps: - self._gv_obj.run([self._get_qpoint_from_gp_index(bz_gp)]) - gvs[bz_gp] = self._gv_obj.group_velocities[0, self._pp.band_indices, :] - self._gv[i_data] = gvs[irgp] + self._gv_obj.run([self._get_qpoint_from_gp_index(irgp)]) + gv = self._gv_obj.group_velocities[0, self._pp.band_indices, :] + self._gv[i_data] = gv def _set_gv_by_gv(self, i_irgp, i_data): """Outer product of group velocities. From 53c90add93277f1b386834aec76ca7638fa3d62c Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Sat, 23 Oct 2021 11:35:40 +0900 Subject: [PATCH 22/34] Introduce isort --- .pre-commit-config.yaml | 6 ++ README.md | 7 ++ example/Si-PBEsol/Si.py | 3 +- .../launch_phono3py_ZnTe_PBEsol_222.py | 8 +- phono3py/__init__.py | 6 +- phono3py/api_isotope.py | 1 + phono3py/api_jointdos.py | 6 +- phono3py/api_phono3py.py | 80 ++++++++++--------- phono3py/cui/create_force_constants.py | 22 ++--- phono3py/cui/create_supercells.py | 5 +- phono3py/cui/kaccum.py | 17 ++-- phono3py/cui/load.py | 14 ++-- phono3py/cui/phono3py_argparse.py | 17 ++-- phono3py/cui/phono3py_script.py | 69 ++++++++-------- phono3py/cui/settings.py | 2 +- phono3py/cui/show_log.py | 10 +-- phono3py/cui/triplets_info.py | 3 +- phono3py/file_IO.py | 6 +- phono3py/interface/phono3py_yaml.py | 2 +- phono3py/other/isotope.py | 10 ++- phono3py/phonon/func.py | 2 +- phono3py/phonon/grid.py | 4 +- phono3py/phonon/solver.py | 2 +- phono3py/phonon3/collision_matrix.py | 3 +- phono3py/phonon3/conductivity.py | 16 ++-- phono3py/phonon3/conductivity_LBTE.py | 22 ++--- phono3py/phonon3/conductivity_RTA.py | 10 ++- phono3py/phonon3/displacement_fc3.py | 4 +- phono3py/phonon3/fc3.py | 26 +++--- phono3py/phonon3/gruneisen.py | 5 +- phono3py/phonon3/imag_self_energy.py | 10 ++- phono3py/phonon3/interaction.py | 25 +++--- phono3py/phonon3/joint_dos.py | 17 ++-- phono3py/phonon3/real_self_energy.py | 6 +- phono3py/phonon3/spectral_function.py | 14 ++-- phono3py/phonon3/triplets.py | 1 + phono3py/sscha/sscha.py | 3 +- pyproject.toml | 3 + scripts/phono3py-coleigplot | 3 +- scripts/phono3py-kdeplot | 11 +-- setup.py | 15 ++-- test/conftest.py | 5 +- test/cui/test_kaccum.py | 1 + test/other/test_isotope.py | 1 + test/phonon/test_grid.py | 7 +- test/phonon3/test_displacements.py | 4 +- test/phonon3/test_fc3.py | 1 + test/phonon3/test_interaction.py | 3 +- test/phonon3/test_joint_dos.py | 1 + test/phonon3/test_real_self_energy.py | 1 + test/phonon3/test_spectral_function.py | 1 + test/sscha/test_sscha.py | 7 +- 52 files changed, 300 insertions(+), 228 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8139a821..d48971cd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,3 +29,9 @@ repos: rev: 6.1.1 hooks: - id: pydocstyle + +- repo: https://github.com/pycqa/isort + rev: 5.8.0 + hooks: + - id: isort + name: isort (python) diff --git a/README.md b/README.md index 34f68de9..cc84eccc 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,13 @@ phono3py repository. "python.linting.pycodestyleEnabled": false, "python.linting.pydocstyleEnabled": true, "python.formatting.provider": "black", + "python.formatting.blackArgs": ["--line-length=88"], + "python.sortImports.args": ["--profile", "black"], + "[python]": { + "editor.codeActionsOnSave": { + "source.organizeImports": true + }, + } ``` - Use of pre-commit (https://pre-commit.com/) is encouraged. diff --git a/example/Si-PBEsol/Si.py b/example/Si-PBEsol/Si.py index 6e359605..763ddc8f 100644 --- a/example/Si-PBEsol/Si.py +++ b/example/Si-PBEsol/Si.py @@ -1,8 +1,9 @@ """Example to run thermal conductivity of Si.""" import numpy as np from phonopy.interface.vasp import read_vasp -from phono3py import Phono3py + import phono3py +from phono3py import Phono3py def run_thermal_conductivity(): 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 136a6a49..9ab45e18 100644 --- a/example/zb-ZnTe-PBEsol/launch_phono3py_ZnTe_PBEsol_222.py +++ b/example/zb-ZnTe-PBEsol/launch_phono3py_ZnTe_PBEsol_222.py @@ -1,10 +1,10 @@ """Launch script of ZnTe AiiDA calculation using aiida-phononpy.""" -from phonopy.interface.vasp import read_vasp_from_strings -from aiida.manage.configuration import load_profile -from aiida.orm import Float, Bool, Str -from aiida.plugins import DataFactory, WorkflowFactory from aiida.engine import submit +from aiida.manage.configuration import load_profile +from aiida.orm import Bool, Float, Str +from aiida.plugins import DataFactory, WorkflowFactory from aiida_phonopy.common.utils import phonopy_atoms_to_structure +from phonopy.interface.vasp import read_vasp_from_strings load_profile() diff --git a/phono3py/__init__.py b/phono3py/__init__.py index 058516ff..d1e566cf 100644 --- a/phono3py/__init__.py +++ b/phono3py/__init__.py @@ -33,8 +33,8 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -from phono3py.version import __version__ # noqa F401 -from phono3py.api_phono3py import Phono3py # noqa F401 -from phono3py.api_jointdos import Phono3pyJointDos # noqa F401 from phono3py.api_isotope import Phono3pyIsotope # noqa F401 +from phono3py.api_jointdos import Phono3pyJointDos # noqa F401 +from phono3py.api_phono3py import Phono3py # noqa F401 from phono3py.cui.load import load # noqa F401 +from phono3py.version import __version__ # noqa F401 diff --git a/phono3py/api_isotope.py b/phono3py/api_isotope.py index d1d828e4..de53f289 100644 --- a/phono3py/api_isotope.py +++ b/phono3py/api_isotope.py @@ -35,6 +35,7 @@ import numpy as np from phonopy.units import VaspToTHz + from phono3py.other.isotope import Isotope diff --git a/phono3py/api_jointdos.py b/phono3py/api_jointdos.py index 54fb1a15..05fccd2d 100644 --- a/phono3py/api_jointdos.py +++ b/phono3py/api_jointdos.py @@ -34,12 +34,12 @@ # POSSIBILITY OF SUCH DAMAGE. import numpy as np -from phonopy.units import VaspToTHz from phonopy.structure.symmetry import Symmetry -from phono3py.phonon3.joint_dos import JointDos -from phono3py.phonon.grid import BZGrid +from phonopy.units import VaspToTHz from phono3py.file_IO import write_joint_dos +from phono3py.phonon3.joint_dos import JointDos +from phono3py.phonon.grid import BZGrid class Phono3pyJointDos: diff --git a/phono3py/api_phono3py.py b/phono3py/api_phono3py.py index 4bbb34ee..dc48c972 100644 --- a/phono3py/api_phono3py.py +++ b/phono3py/api_phono3py.py @@ -34,59 +34,61 @@ # POSSIBILITY OF SUCH DAMAGE. import warnings + import numpy as np -from phonopy.structure.symmetry import Symmetry -from phonopy.structure.cells import ( - get_supercell, - get_primitive, - guess_primitive_matrix, - shape_supercell_matrix, - get_primitive_matrix, -) -from phonopy.structure.atoms import PhonopyAtoms -from phonopy.structure.dataset import get_displacements_and_forces -from phonopy.units import VaspToTHz -from phonopy.harmonic.force_constants import ( - symmetrize_force_constants, - symmetrize_compact_force_constants, - set_translational_invariance, - set_permutation_symmetry, +from phonopy.harmonic.displacement import ( + directions_to_displacement_dataset, + get_least_displacements, ) from phonopy.harmonic.force_constants import get_fc2 as get_phonopy_fc2 -from phonopy.interface.fc_calculator import get_fc2 -from phonopy.harmonic.displacement import ( - get_least_displacements, - directions_to_displacement_dataset, +from phonopy.harmonic.force_constants import ( + set_permutation_symmetry, + set_translational_invariance, + symmetrize_compact_force_constants, + symmetrize_force_constants, +) +from phonopy.interface.fc_calculator import get_fc2 +from phonopy.structure.atoms import PhonopyAtoms +from phonopy.structure.cells import ( + get_primitive, + get_primitive_matrix, + get_supercell, + guess_primitive_matrix, + shape_supercell_matrix, +) +from phonopy.structure.dataset import get_displacements_and_forces +from phonopy.structure.symmetry import Symmetry +from phonopy.units import VaspToTHz + +from phono3py.interface.fc_calculator import get_fc3 +from phono3py.interface.phono3py_yaml import Phono3pyYaml +from phono3py.phonon3.conductivity_LBTE import get_thermal_conductivity_LBTE +from phono3py.phonon3.conductivity_RTA import get_thermal_conductivity_RTA +from phono3py.phonon3.dataset import get_displacements_and_forces_fc3 +from phono3py.phonon3.displacement_fc3 import ( + direction_to_displacement, + get_third_order_displacements, +) +from phono3py.phonon3.fc3 import cutoff_fc3_by_zero +from phono3py.phonon3.fc3 import get_fc3 as get_phono3py_fc3 +from phono3py.phonon3.fc3 import ( + set_permutation_symmetry_compact_fc3, + set_permutation_symmetry_fc3, + set_translational_invariance_compact_fc3, + set_translational_invariance_fc3, ) -from phono3py.version import __version__ from phono3py.phonon3.imag_self_energy import ( get_imag_self_energy, write_imag_self_energy, ) +from phono3py.phonon3.interaction import Interaction from phono3py.phonon3.real_self_energy import ( get_real_self_energy, write_real_self_energy, ) from phono3py.phonon3.spectral_function import run_spectral_function -from phono3py.phonon3.interaction import Interaction -from phono3py.phonon3.conductivity_RTA import get_thermal_conductivity_RTA -from phono3py.phonon3.conductivity_LBTE import get_thermal_conductivity_LBTE -from phono3py.phonon3.displacement_fc3 import ( - get_third_order_displacements, - direction_to_displacement, -) -from phono3py.phonon3.fc3 import ( - set_permutation_symmetry_fc3, - set_permutation_symmetry_compact_fc3, - set_translational_invariance_fc3, - set_translational_invariance_compact_fc3, - cutoff_fc3_by_zero, -) -from phono3py.phonon3.fc3 import get_fc3 as get_phono3py_fc3 from phono3py.phonon.grid import BZGrid -from phono3py.phonon3.dataset import get_displacements_and_forces_fc3 -from phono3py.interface.phono3py_yaml import Phono3pyYaml -from phono3py.interface.fc_calculator import get_fc3 +from phono3py.version import __version__ class Phono3py(object): diff --git a/phono3py/cui/create_force_constants.py b/phono3py/cui/create_force_constants.py index a54601c0..c1c2b6c8 100644 --- a/phono3py/cui/create_force_constants.py +++ b/phono3py/cui/create_force_constants.py @@ -35,33 +35,35 @@ import os import sys + import numpy as np +from phonopy.cui.phonopy_script import file_exists, print_error +from phonopy.file_IO import get_dataset_type2 from phonopy.harmonic.force_constants import ( show_drift_force_constants, - symmetrize_force_constants, symmetrize_compact_force_constants, + symmetrize_force_constants, ) -from phonopy.file_IO import get_dataset_type2 -from phonopy.cui.phonopy_script import print_error, file_exists from phonopy.interface.calculator import get_default_physical_units -from phono3py.phonon3.fc3 import show_drift_fc3 + +from phono3py.cui.show_log import show_phono3py_force_constants_settings from phono3py.file_IO import ( - parse_disp_fc3_yaml, + get_length_of_first_line, parse_disp_fc2_yaml, + parse_disp_fc3_yaml, parse_FORCES_FC2, parse_FORCES_FC3, - read_fc3_from_hdf5, read_fc2_from_hdf5, - write_fc3_to_hdf5, + read_fc3_from_hdf5, write_fc2_to_hdf5, - get_length_of_first_line, + write_fc3_to_hdf5, ) -from phono3py.cui.show_log import show_phono3py_force_constants_settings +from phono3py.interface.phono3py_yaml import Phono3pyYaml from phono3py.phonon3.fc3 import ( set_permutation_symmetry_fc3, set_translational_invariance_fc3, + show_drift_fc3, ) -from phono3py.interface.phono3py_yaml import Phono3pyYaml def create_phono3py_force_constants( diff --git a/phono3py/cui/create_supercells.py b/phono3py/cui/create_supercells.py index f37c4bd2..5d3f5ecc 100644 --- a/phono3py/cui/create_supercells.py +++ b/phono3py/cui/create_supercells.py @@ -33,14 +33,15 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. +from phonopy.interface.calculator import write_supercells_with_displacements + from phono3py import Phono3py -from phono3py.file_IO import write_disp_fc3_yaml, write_disp_fc2_yaml +from phono3py.file_IO import write_disp_fc2_yaml, write_disp_fc3_yaml from phono3py.interface.calculator import ( get_additional_info_to_write_fc2_supercells, get_additional_info_to_write_supercells, get_default_displacement_distance, ) -from phonopy.interface.calculator import write_supercells_with_displacements def create_phono3py_supercells( diff --git a/phono3py/cui/kaccum.py b/phono3py/cui/kaccum.py index e830921d..9249339b 100644 --- a/phono3py/cui/kaccum.py +++ b/phono3py/cui/kaccum.py @@ -1,16 +1,21 @@ """Phono3py kaccum command line script.""" -import sys import argparse -import numpy as np +import sys + import h5py +import numpy as np from phonopy.cui.settings import fracval -from phonopy.structure.cells import get_primitive -from phonopy.structure.symmetry import Symmetry from phonopy.interface.calculator import read_crystal_structure from phonopy.phonon.dos import NormalDistribution -from phonopy.structure.cells import get_primitive_matrix, guess_primitive_matrix -from phono3py.phonon.grid import BZGrid, get_ir_grid_points +from phonopy.structure.cells import ( + get_primitive, + get_primitive_matrix, + guess_primitive_matrix, +) +from phonopy.structure.symmetry import Symmetry + from phono3py.other.tetrahedron_method import get_integration_weights +from phono3py.phonon.grid import BZGrid, get_ir_grid_points epsilon = 1.0e-8 diff --git a/phono3py/cui/load.py b/phono3py/cui/load.py index e3b7d8ad..48451912 100644 --- a/phono3py/cui/load.py +++ b/phono3py/cui/load.py @@ -35,15 +35,17 @@ import os import typing + import numpy as np -from phono3py import Phono3py -from phono3py.interface.phono3py_yaml import Phono3pyYaml -from phono3py.cui.create_force_constants import parse_forces, forces_in_dataset -from phono3py.file_IO import read_fc3_from_hdf5, read_fc2_from_hdf5 -from phono3py.phonon3.fc3 import show_drift_fc3 +import phonopy.cui.load_helper as load_helper from phonopy.harmonic.force_constants import show_drift_force_constants from phonopy.interface.calculator import get_default_physical_units -import phonopy.cui.load_helper as load_helper + +from phono3py import Phono3py +from phono3py.cui.create_force_constants import forces_in_dataset, parse_forces +from phono3py.file_IO import read_fc2_from_hdf5, read_fc3_from_hdf5 +from phono3py.interface.phono3py_yaml import Phono3pyYaml +from phono3py.phonon3.fc3 import show_drift_fc3 def load( diff --git a/phono3py/cui/phono3py_argparse.py b/phono3py/cui/phono3py_argparse.py index 4e177356..1deeb0e2 100644 --- a/phono3py/cui/phono3py_argparse.py +++ b/phono3py/cui/phono3py_argparse.py @@ -34,6 +34,7 @@ # POSSIBILITY OF SUCH DAMAGE. import sys + from phonopy.cui.phonopy_argparse import fix_deprecated_option_names @@ -41,7 +42,9 @@ def get_parser(fc_symmetry=False, is_nac=False, load_phono3py_yaml=False): """Return ArgumentParser instance.""" deprecated = fix_deprecated_option_names(sys.argv) import argparse + from phonopy.interface.calculator import add_arguments_of_calculators + from phono3py.interface.calculator import calculator_info parser = argparse.ArgumentParser(description="Phono3py command-line-tool") @@ -679,13 +682,13 @@ def get_parser(fc_symmetry=False, is_nac=False, load_phono3py_yaml=False): default=False, help="Symmetrize fc3 in real space by index exchange", ) - parser.add_argument( - "--sym-fc3q", - dest="is_symmetrize_fc3_q", - action="store_true", - default=False, - help="Symmetrize fc3 in reciprocal space by index exchange", - ) + parser.add_argument( + "--sym-fc3q", + dest="is_symmetrize_fc3_q", + action="store_true", + default=False, + help="Symmetrize fc3 in reciprocal space by index exchange", + ) parser.add_argument( "--thm", "--tetrahedron-method", diff --git a/phono3py/cui/phono3py_script.py b/phono3py/cui/phono3py_script.py index 0b3d2ba0..32429618 100644 --- a/phono3py/cui/phono3py_script.py +++ b/phono3py/cui/phono3py_script.py @@ -34,61 +34,62 @@ # POSSIBILITY OF SUCH DAMAGE. import sys + import numpy as np -from phonopy.file_IO import write_FORCE_SETS, parse_FORCE_SETS, is_file_phonopy_yaml -from phonopy.units import VaspToTHz, Bohr, Hartree from phonopy.cui.collect_cell_info import collect_cell_info from phonopy.cui.create_force_sets import check_number_of_force_files -from phonopy.interface.calculator import ( - get_force_sets, - get_default_physical_units, - get_interface_mode, -) from phonopy.cui.phonopy_argparse import show_deprecated_option_warnings -from phonopy.phonon.band_structure import get_band_qpoints from phonopy.cui.phonopy_script import ( - store_nac_params, + file_exists, + files_exist, + get_fc_calculator_params, print_end, print_error, print_error_message, print_version, - file_exists, - files_exist, - get_fc_calculator_params, + store_nac_params, ) +from phonopy.file_IO import is_file_phonopy_yaml, parse_FORCE_SETS, write_FORCE_SETS +from phonopy.interface.calculator import ( + get_default_physical_units, + get_force_sets, + get_interface_mode, +) +from phonopy.phonon.band_structure import get_band_qpoints from phonopy.structure.cells import isclose as cells_isclose -from phono3py.version import __version__ -from phono3py.file_IO import ( - parse_disp_fc2_yaml, - parse_disp_fc3_yaml, - read_phonon_from_hdf5, - write_phonon_to_hdf5, - parse_FORCES_FC2, - write_FORCES_FC2, - write_FORCES_FC3, - get_length_of_first_line, - write_fc3_to_hdf5, - write_fc2_to_hdf5, -) -from phono3py.cui.settings import Phono3pyConfParser +from phonopy.units import Bohr, Hartree, VaspToTHz + +from phono3py import Phono3py, Phono3pyIsotope, Phono3pyJointDos +from phono3py.cui.create_force_constants import create_phono3py_force_constants +from phono3py.cui.create_supercells import create_phono3py_supercells from phono3py.cui.load import set_dataset_and_force_constants -from phono3py import Phono3py, Phono3pyJointDos, Phono3pyIsotope -from phono3py.phonon3.gruneisen import run_gruneisen_parameters -from phono3py.phonon.grid import get_grid_point_from_address from phono3py.cui.phono3py_argparse import get_parser +from phono3py.cui.settings import Phono3pyConfParser from phono3py.cui.show_log import ( show_general_settings, - show_phono3py_settings, show_phono3py_cells, + show_phono3py_settings, +) +from phono3py.cui.triplets_info import show_num_triplets, write_grid_points +from phono3py.file_IO import ( + get_length_of_first_line, + parse_disp_fc2_yaml, + parse_disp_fc3_yaml, + parse_FORCES_FC2, + read_phonon_from_hdf5, + write_fc2_to_hdf5, + write_fc3_to_hdf5, + write_FORCES_FC2, + write_FORCES_FC3, + write_phonon_to_hdf5, ) -from phono3py.cui.triplets_info import write_grid_points, show_num_triplets -from phono3py.cui.create_supercells import create_phono3py_supercells -from phono3py.cui.create_force_constants import create_phono3py_force_constants from phono3py.interface.phono3py_yaml import ( Phono3pyYaml, displacements_yaml_lines_type1, ) - +from phono3py.phonon3.gruneisen import run_gruneisen_parameters +from phono3py.phonon.grid import get_grid_point_from_address +from phono3py.version import __version__ # import logging # logging.basicConfig() diff --git a/phono3py/cui/settings.py b/phono3py/cui/settings.py index 3bd1af75..2a7cf106 100644 --- a/phono3py/cui/settings.py +++ b/phono3py/cui/settings.py @@ -34,7 +34,7 @@ # POSSIBILITY OF SUCH DAMAGE. import numpy as np -from phonopy.cui.settings import Settings, ConfParser, fracval +from phonopy.cui.settings import ConfParser, Settings, fracval class Phono3pySettings(Settings): diff --git a/phono3py/cui/show_log.py b/phono3py/cui/show_log.py index 62a49f44..4565621f 100644 --- a/phono3py/cui/show_log.py +++ b/phono3py/cui/show_log.py @@ -34,9 +34,12 @@ # POSSIBILITY OF SUCH DAMAGE. import sys + import numpy as np from phonopy.structure.cells import print_cell +from phono3py.cui.settings import Phono3pySettings + def show_general_settings( settings, run_mode, phono3py, cell_filename, input_filename, output_filename @@ -106,12 +109,11 @@ def show_phono3py_cells(phono3py, settings): print("-" * 76) -def show_phono3py_force_constants_settings(settings): +def show_phono3py_force_constants_settings(settings: Phono3pySettings): """Show force constants settings.""" read_fc3 = settings.read_fc3 read_fc2 = settings.read_fc2 symmetrize_fc3r = settings.is_symmetrize_fc3_r or settings.fc_symmetry - symmetrize_fc3q = settings.is_symmetrize_fc3_q symmetrize_fc2 = settings.is_symmetrize_fc2 or settings.fc_symmetry print("-" * 29 + " Force constants " + "-" * 30) @@ -132,10 +134,6 @@ def show_phono3py_force_constants_settings(settings): "Imposing translational and index exchange symmetry to fc3: " "%s" % symmetrize_fc3r ) - print( - ("Imposing symmetry of index exchange to fc3 in reciprocal " "space: %s") - % symmetrize_fc3q - ) if settings.cutoff_fc3_distance is not None: print("FC3 cutoff distance: %s" % settings.cutoff_fc3_distance) diff --git a/phono3py/cui/triplets_info.py b/phono3py/cui/triplets_info.py index e94bc1bd..116fa109 100644 --- a/phono3py/cui/triplets_info.py +++ b/phono3py/cui/triplets_info.py @@ -34,7 +34,8 @@ # POSSIBILITY OF SUCH DAMAGE. import numpy as np -from phono3py.file_IO import write_ir_grid_points, write_grid_address_to_hdf5 + +from phono3py.file_IO import write_grid_address_to_hdf5, write_ir_grid_points from phono3py.phonon3.triplets import get_triplets_at_q from phono3py.phonon.grid import get_ir_grid_points diff --git a/phono3py/file_IO.py b/phono3py/file_IO.py index 92244351..2be4be36 100644 --- a/phono3py/file_IO.py +++ b/phono3py/file_IO.py @@ -35,13 +35,15 @@ import os import warnings -import numpy as np + import h5py +import numpy as np +from phonopy.cui.load_helper import read_force_constants_from_hdf5 # This import is deactivated for a while. # from phonopy.file_IO import write_force_constants_to_hdf5 from phonopy.file_IO import check_force_constants_indices, get_cell_from_disp_yaml -from phonopy.cui.load_helper import read_force_constants_from_hdf5 + from phono3py.version import __version__ diff --git a/phono3py/interface/phono3py_yaml.py b/phono3py/interface/phono3py_yaml.py index 5592a3f6..6f34cc66 100644 --- a/phono3py/interface/phono3py_yaml.py +++ b/phono3py/interface/phono3py_yaml.py @@ -33,8 +33,8 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -from phonopy.interface.phonopy_yaml import PhonopyYaml import numpy as np +from phonopy.interface.phonopy_yaml import PhonopyYaml class Phono3pyYaml(PhonopyYaml): diff --git a/phono3py/other/isotope.py b/phono3py/other/isotope.py index b529113a..0d428a7d 100644 --- a/phono3py/other/isotope.py +++ b/phono3py/other/isotope.py @@ -34,20 +34,22 @@ # POSSIBILITY OF SUCH DAMAGE. import warnings + import numpy as np from phonopy.harmonic.dynamical_matrix import get_dynamical_matrix +from phonopy.phonon.tetrahedron_mesh import get_tetrahedra_frequencies +from phonopy.structure.atoms import isotope_data from phonopy.structure.symmetry import Symmetry from phonopy.structure.tetrahedron_method import TetrahedronMethod -from phonopy.phonon.tetrahedron_mesh import get_tetrahedra_frequencies from phonopy.units import VaspToTHz -from phonopy.structure.atoms import isotope_data + from phono3py.other.tetrahedron_method import ( get_integration_weights, get_unique_grid_points, ) -from phono3py.phonon.solver import run_phonon_solver_c, run_phonon_solver_py -from phono3py.phonon.grid import BZGrid from phono3py.phonon.func import gaussian +from phono3py.phonon.grid import BZGrid +from phono3py.phonon.solver import run_phonon_solver_c, run_phonon_solver_py def get_mass_variances(primitive): diff --git a/phono3py/phonon/func.py b/phono3py/phonon/func.py index 066d111c..91246631 100644 --- a/phono3py/phonon/func.py +++ b/phono3py/phonon/func.py @@ -34,7 +34,7 @@ # POSSIBILITY OF SUCH DAMAGE. import numpy as np -from phonopy.units import THzToEv, Kb, Hbar, EV, Angstrom, THz, AMU +from phonopy.units import AMU, EV, Angstrom, Hbar, Kb, THz, THzToEv def gaussian(x, sigma): diff --git a/phono3py/phonon/grid.py b/phono3py/phonon/grid.py index c0b171f7..0330c807 100644 --- a/phono3py/phonon/grid.py +++ b/phono3py/phonon/grid.py @@ -36,11 +36,11 @@ import numpy as np from phonopy.harmonic.force_constants import similarity_transformation from phonopy.structure.cells import ( - get_primitive_matrix_by_centring, estimate_supercell_matrix, + get_primitive_matrix_by_centring, get_reduced_bases, ) -from phonopy.structure.grid_points import length2mesh, extract_ir_grid_points +from phonopy.structure.grid_points import extract_ir_grid_points, length2mesh class BZGrid: diff --git a/phono3py/phonon/solver.py b/phono3py/phonon/solver.py index 43abc355..a8c2efb0 100644 --- a/phono3py/phonon/solver.py +++ b/phono3py/phonon/solver.py @@ -34,8 +34,8 @@ # POSSIBILITY OF SUCH DAMAGE. import numpy as np -from phonopy.units import VaspToTHz from phonopy.structure.cells import sparse_to_dense_svecs +from phonopy.units import VaspToTHz def run_phonon_solver_c( diff --git a/phono3py/phonon3/collision_matrix.py b/phono3py/phonon3/collision_matrix.py index 30cd50af..f39c4fb9 100644 --- a/phono3py/phonon3/collision_matrix.py +++ b/phono3py/phonon3/collision_matrix.py @@ -34,7 +34,8 @@ # POSSIBILITY OF SUCH DAMAGE. import numpy as np -from phonopy.units import THzToEv, Kb +from phonopy.units import Kb, THzToEv + from phono3py.phonon3.imag_self_energy import ImagSelfEnergy from phono3py.phonon3.interaction import Interaction diff --git a/phono3py/phonon3/conductivity.py b/phono3py/phonon3/conductivity.py index 873cb3aa..a7b11b75 100644 --- a/phono3py/phonon3/conductivity.py +++ b/phono3py/phonon3/conductivity.py @@ -33,19 +33,21 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -import warnings import textwrap -from typing import Optional, List +import warnings +from typing import List, Optional + import numpy as np -from phonopy.phonon.group_velocity import GroupVelocity from phonopy.harmonic.force_constants import similarity_transformation +from phonopy.phonon.group_velocity import GroupVelocity from phonopy.phonon.thermal_properties import mode_cv as get_mode_cv -from phonopy.units import THzToEv, EV, THz, Angstrom +from phonopy.units import EV, Angstrom, THz, THzToEv + from phono3py.file_IO import write_pp_to_hdf5 -from phono3py.phonon3.triplets import get_all_triplets -from phono3py.phonon3.interaction import Interaction from phono3py.other.isotope import Isotope -from phono3py.phonon.grid import get_ir_grid_points, get_grid_points_by_rotations +from phono3py.phonon3.interaction import Interaction +from phono3py.phonon3.triplets import get_all_triplets +from phono3py.phonon.grid import get_grid_points_by_rotations, get_ir_grid_points unit_to_WmK = ( (THz * Angstrom) ** 2 / (Angstrom ** 3) * EV / THz / (2 * np.pi) diff --git a/phono3py/phonon3/conductivity_LBTE.py b/phono3py/phonon3/conductivity_LBTE.py index c8c2540f..1edaa3cd 100644 --- a/phono3py/phonon3/conductivity_LBTE.py +++ b/phono3py/phonon3/conductivity_LBTE.py @@ -37,23 +37,25 @@ import sys import time import warnings from typing import List + import numpy as np from phonopy.phonon.degeneracy import degenerate_sets from phonopy.phonon.group_velocity import GroupVelocity +from phonopy.units import Kb, THzToEv + +from phono3py.file_IO import ( + read_collision_from_hdf5, + read_pp_from_hdf5, + write_collision_eigenvalues_to_hdf5, + write_collision_to_hdf5, + write_kappa_to_hdf5, + write_unitary_matrix_to_hdf5, +) +from phono3py.phonon3.collision_matrix import CollisionMatrix from phono3py.phonon3.conductivity import Conductivity, all_bands_exist, unit_to_WmK from phono3py.phonon3.conductivity import write_pp as _write_pp from phono3py.phonon3.interaction import Interaction -from phono3py.phonon3.collision_matrix import CollisionMatrix from phono3py.phonon.grid import get_grid_points_by_rotations -from phono3py.file_IO import ( - write_kappa_to_hdf5, - write_collision_to_hdf5, - read_collision_from_hdf5, - write_collision_eigenvalues_to_hdf5, - write_unitary_matrix_to_hdf5, - read_pp_from_hdf5, -) -from phonopy.units import THzToEv, Kb class Conductivity_LBTE(Conductivity): diff --git a/phono3py/phonon3/conductivity_RTA.py b/phono3py/phonon3/conductivity_RTA.py index 2ad7fdd4..22dc6577 100644 --- a/phono3py/phonon3/conductivity_RTA.py +++ b/phono3py/phonon3/conductivity_RTA.py @@ -34,19 +34,21 @@ # POSSIBILITY OF SUCH DAMAGE. import sys + import numpy as np -from phonopy.structure.tetrahedron_method import TetrahedronMethod from phonopy.phonon.group_velocity import GroupVelocity +from phonopy.structure.tetrahedron_method import TetrahedronMethod + from phono3py.file_IO import ( - write_kappa_to_hdf5, read_gamma_from_hdf5, - write_gamma_detail_to_hdf5, read_pp_from_hdf5, + write_gamma_detail_to_hdf5, + write_kappa_to_hdf5, ) from phono3py.phonon3.conductivity import Conductivity, all_bands_exist, unit_to_WmK from phono3py.phonon3.conductivity import write_pp as _write_pp -from phono3py.phonon3.interaction import Interaction from phono3py.phonon3.imag_self_energy import ImagSelfEnergy, average_by_degeneracy +from phono3py.phonon3.interaction import Interaction from phono3py.phonon3.triplets import get_all_triplets from phono3py.phonon.grid import get_grid_points_by_rotations diff --git a/phono3py/phonon3/displacement_fc3.py b/phono3py/phonon3/displacement_fc3.py index ab9f2d8b..e2218017 100644 --- a/phono3py/phonon3/displacement_fc3.py +++ b/phono3py/phonon3/displacement_fc3.py @@ -35,14 +35,14 @@ import numpy as np from phonopy.harmonic.displacement import ( - get_least_displacements, directions_axis, get_displacement, + get_least_displacements, is_minus_displacement, ) from phonopy.structure.atoms import PhonopyAtoms -from phonopy.structure.symmetry import Symmetry from phonopy.structure.cells import get_smallest_vectors +from phonopy.structure.symmetry import Symmetry def direction_to_displacement( diff --git a/phono3py/phonon3/fc3.py b/phono3py/phonon3/fc3.py index cbd41a79..b0846167 100644 --- a/phono3py/phonon3/fc3.py +++ b/phono3py/phonon3/fc3.py @@ -33,27 +33,29 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -import sys import logging +import sys + import numpy as np from phonopy.harmonic.force_constants import ( - get_fc2, - similarity_transformation, distribute_force_constants, - solve_force_constants, - get_rotated_displacement, - get_positions_sent_by_rot_inv, + get_fc2, get_nsym_list_and_s2pp, -) -from phono3py.phonon3.displacement_fc3 import ( - get_reduced_site_symmetry, - get_bond_symmetry, - get_smallest_vector_of_atom_pair, + get_positions_sent_by_rot_inv, + get_rotated_displacement, + similarity_transformation, + solve_force_constants, ) from phonopy.structure.atoms import PhonopyAtoms -from phonopy.structure.cells import compute_all_sg_permutations, Primitive +from phonopy.structure.cells import Primitive, compute_all_sg_permutations from phonopy.structure.symmetry import Symmetry +from phono3py.phonon3.displacement_fc3 import ( + get_bond_symmetry, + get_reduced_site_symmetry, + get_smallest_vector_of_atom_pair, +) + logger = logging.getLogger(__name__) diff --git a/phono3py/phonon3/gruneisen.py b/phono3py/phonon3/gruneisen.py index 6b71fd0a..bdad36f2 100644 --- a/phono3py/phonon3/gruneisen.py +++ b/phono3py/phonon3/gruneisen.py @@ -34,11 +34,12 @@ # POSSIBILITY OF SUCH DAMAGE. import sys + import numpy as np from phonopy.harmonic.dynamical_matrix import get_dynamical_matrix -from phonopy.units import VaspToTHz -from phonopy.structure.grid_points import get_qpoints from phonopy.structure.cells import sparse_to_dense_svecs +from phonopy.structure.grid_points import get_qpoints +from phonopy.units import VaspToTHz def run_gruneisen_parameters( diff --git a/phono3py/phonon3/imag_self_energy.py b/phono3py/phonon3/imag_self_energy.py index 84bdb35a..ade96881 100644 --- a/phono3py/phonon3/imag_self_energy.py +++ b/phono3py/phonon3/imag_self_energy.py @@ -35,16 +35,18 @@ import sys from typing import List, Optional + import numpy as np -from phonopy.units import Hbar, EV, THz from phonopy.phonon.degeneracy import degenerate_sets -from phono3py.phonon3.interaction import Interaction -from phono3py.phonon3.triplets import get_triplets_integration_weights -from phono3py.phonon.func import bose_einstein +from phonopy.units import EV, Hbar, THz + from phono3py.file_IO import ( write_gamma_detail_to_hdf5, write_imag_self_energy_at_grid_point, ) +from phono3py.phonon3.interaction import Interaction +from phono3py.phonon3.triplets import get_triplets_integration_weights +from phono3py.phonon.func import bose_einstein def get_imag_self_energy( diff --git a/phono3py/phonon3/interaction.py b/phono3py/phonon3/interaction.py index 45070b3c..168de1bd 100644 --- a/phono3py/phonon3/interaction.py +++ b/phono3py/phonon3/interaction.py @@ -34,21 +34,26 @@ # POSSIBILITY OF SUCH DAMAGE. import warnings + import numpy as np from phonopy.harmonic.dynamical_matrix import get_dynamical_matrix -from phonopy.structure.cells import Primitive, sparse_to_dense_svecs -from phonopy.structure.symmetry import Symmetry -from phonopy.units import VaspToTHz, Hbar, EV, Angstrom, THz, AMU -from phonopy.structure.cells import compute_all_sg_permutations -from phono3py.phonon.grid import ( - get_ir_grid_points, - get_grid_points_by_rotations, - BZGrid, +from phonopy.structure.cells import ( + Primitive, + compute_all_sg_permutations, + sparse_to_dense_svecs, ) -from phono3py.phonon.solver import run_phonon_solver_c, run_phonon_solver_py +from phonopy.structure.symmetry import Symmetry +from phonopy.units import AMU, EV, Angstrom, Hbar, THz, VaspToTHz + from phono3py.phonon3.real_to_reciprocal import RealToReciprocal from phono3py.phonon3.reciprocal_to_normal import ReciprocalToNormal -from phono3py.phonon3.triplets import get_triplets_at_q, get_nosym_triplets_at_q +from phono3py.phonon3.triplets import get_nosym_triplets_at_q, get_triplets_at_q +from phono3py.phonon.grid import ( + BZGrid, + get_grid_points_by_rotations, + get_ir_grid_points, +) +from phono3py.phonon.solver import run_phonon_solver_c, run_phonon_solver_py class Interaction: diff --git a/phono3py/phonon3/joint_dos.py b/phono3py/phonon3/joint_dos.py index 319d1b31..6807c7b1 100644 --- a/phono3py/phonon3/joint_dos.py +++ b/phono3py/phonon3/joint_dos.py @@ -33,24 +33,25 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -import warnings import sys +import warnings + import numpy as np -from phonopy.units import VaspToTHz +from phonopy.harmonic.dynamical_matrix import DynamicalMatrix, get_dynamical_matrix from phonopy.structure.cells import Primitive -from phonopy.harmonic.dynamical_matrix import DynamicalMatrix +from phonopy.structure.tetrahedron_method import TetrahedronMethod +from phonopy.units import VaspToTHz + +from phono3py.phonon3.imag_self_energy import get_frequency_points from phono3py.phonon3.triplets import ( - get_triplets_at_q, get_nosym_triplets_at_q, get_tetrahedra_vertices, + get_triplets_at_q, get_triplets_integration_weights, ) -from phono3py.phonon.solver import run_phonon_solver_c from phono3py.phonon.func import bose_einstein from phono3py.phonon.grid import BZGrid -from phono3py.phonon3.imag_self_energy import get_frequency_points -from phonopy.harmonic.dynamical_matrix import get_dynamical_matrix -from phonopy.structure.tetrahedron_method import TetrahedronMethod +from phono3py.phonon.solver import run_phonon_solver_c class JointDos(object): diff --git a/phono3py/phonon3/real_self_energy.py b/phono3py/phonon3/real_self_energy.py index 2e2b4a5c..4dcb1ded 100644 --- a/phono3py/phonon3/real_self_energy.py +++ b/phono3py/phonon3/real_self_energy.py @@ -34,15 +34,17 @@ # POSSIBILITY OF SUCH DAMAGE. import sys + import numpy as np -from phonopy.units import Hbar, EV, THz from phonopy.phonon.degeneracy import degenerate_sets -from phono3py.phonon.func import bose_einstein +from phonopy.units import EV, Hbar, THz + from phono3py.file_IO import ( write_real_self_energy_at_grid_point, write_real_self_energy_to_hdf5, ) from phono3py.phonon3.imag_self_energy import get_frequency_points +from phono3py.phonon.func import bose_einstein def get_real_self_energy( diff --git a/phono3py/phonon3/spectral_function.py b/phono3py/phonon3/spectral_function.py index aefe6abf..2dec8305 100644 --- a/phono3py/phonon3/spectral_function.py +++ b/phono3py/phonon3/spectral_function.py @@ -34,17 +34,19 @@ # POSSIBILITY OF SUCH DAMAGE. import sys + import numpy as np -from phono3py.phonon3.imag_self_energy import ( - run_ise_at_frequency_points_batch, - get_frequency_points, - ImagSelfEnergy, -) -from phono3py.phonon3.real_self_energy import imag_to_real + from phono3py.file_IO import ( write_spectral_function_at_grid_point, write_spectral_function_to_hdf5, ) +from phono3py.phonon3.imag_self_energy import ( + ImagSelfEnergy, + get_frequency_points, + run_ise_at_frequency_points_batch, +) +from phono3py.phonon3.real_self_energy import imag_to_real def run_spectral_function( diff --git a/phono3py/phonon3/triplets.py b/phono3py/phonon3/triplets.py index 90a9f2c6..9f9506b8 100644 --- a/phono3py/phonon3/triplets.py +++ b/phono3py/phonon3/triplets.py @@ -35,6 +35,7 @@ import numpy as np from phonopy.structure.tetrahedron_method import TetrahedronMethod + from phono3py.phonon.func import gaussian diff --git a/phono3py/sscha/sscha.py b/phono3py/sscha/sscha.py index 60e4b422..e354870d 100644 --- a/phono3py/sscha/sscha.py +++ b/phono3py/sscha/sscha.py @@ -42,8 +42,9 @@ Formulae implemented are based on these papers: """ import numpy as np -from phonopy.units import VaspToTHz from phonopy.harmonic.dynmat_to_fc import DynmatToForceConstants +from phonopy.units import VaspToTHz + from phono3py.phonon.func import mode_length diff --git a/pyproject.toml b/pyproject.toml index 55cd9ace..ca0714fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,3 +7,6 @@ extend-ignore = "E203,W503" [tool.black] line-length = 88 + +[tool.isort] +profile = "black" diff --git a/scripts/phono3py-coleigplot b/scripts/phono3py-coleigplot index 7d9929a1..f651d12a 100755 --- a/scripts/phono3py-coleigplot +++ b/scripts/phono3py-coleigplot @@ -1,10 +1,11 @@ #!/usr/bin/env python +import argparse import os import sys + import h5py import numpy as np -import argparse epsilon = 1.0e-8 diff --git a/scripts/phono3py-kdeplot b/scripts/phono3py-kdeplot index 7df30629..9335e86f 100755 --- a/scripts/phono3py-kdeplot +++ b/scripts/phono3py-kdeplot @@ -1,11 +1,12 @@ #!/usr/bin/env python -import numpy as np -import h5py -import sys -import os -from scipy import stats import argparse +import os +import sys + +import h5py +import numpy as np +from scipy import stats epsilon = 1.0e-8 diff --git a/setup.py b/setup.py index 3066e9de..90596529 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,18 @@ """Phono3py setup.py.""" import os -import sys -import numpy import platform +import sys import sysconfig +import numpy + try: - from setuptools import setup, Extension + from setuptools import Extension, setup use_setuptools = True print("setuptools is used.") except ImportError: - from distutils.core import setup, Extension + from distutils.core import Extension, setup use_setuptools = False print("distutils is used.") @@ -114,10 +115,8 @@ elif os.path.isfile("libopenblas.py"): # Example of libopenblas.py # extra_link_args_lapacke += ['-lopenblas'] - from libopenblas import ( - extra_link_args_lapacke as obl_extra_link_args_lapacke, - include_dirs_lapacke as obl_include_dirs_lapacke, - ) + from libopenblas import extra_link_args_lapacke as obl_extra_link_args_lapacke + from libopenblas import include_dirs_lapacke as obl_include_dirs_lapacke extra_link_args_lapacke = obl_extra_link_args_lapacke include_dirs_lapacke = obl_include_dirs_lapacke diff --git a/test/conftest.py b/test/conftest.py index aa9a3c2d..b0b1b362 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -1,10 +1,11 @@ """Pytest conftest.py.""" import os -import pytest + import phonopy -import phono3py +import pytest from phonopy.interface.phonopy_yaml import read_cell_yaml +import phono3py current_dir = os.path.dirname(os.path.abspath(__file__)) store_dense_gp_map = True diff --git a/test/cui/test_kaccum.py b/test/cui/test_kaccum.py index 9723adfe..8e1035bb 100644 --- a/test/cui/test_kaccum.py +++ b/test/cui/test_kaccum.py @@ -1,5 +1,6 @@ """Test for kaccum.py.""" import numpy as np + from phono3py.cui.kaccum import KappaDOS, _get_mfp from phono3py.phonon.grid import get_ir_grid_points diff --git a/test/other/test_isotope.py b/test/other/test_isotope.py index 01e1e710..0c7f58b4 100644 --- a/test/other/test_isotope.py +++ b/test/other/test_isotope.py @@ -1,5 +1,6 @@ """Tests for isotope scatterings.""" import numpy as np + from phono3py import Phono3pyIsotope si_pbesol_iso = [ diff --git a/test/phonon/test_grid.py b/test/phonon/test_grid.py index baa54d2e..2ee80e9b 100644 --- a/test/phonon/test_grid.py +++ b/test/phonon/test_grid.py @@ -1,13 +1,14 @@ """Tests for grids.""" import numpy as np from phonopy.structure.tetrahedron_method import TetrahedronMethod + from phono3py.phonon.grid import ( - get_grid_point_from_address, - get_grid_point_from_address_py, BZGrid, - _get_grid_points_by_rotations, _get_grid_points_by_bz_rotations_c, _get_grid_points_by_bz_rotations_py, + _get_grid_points_by_rotations, + get_grid_point_from_address, + get_grid_point_from_address_py, ) diff --git a/test/phonon3/test_displacements.py b/test/phonon3/test_displacements.py index ba109cb2..978f0222 100644 --- a/test/phonon3/test_displacements.py +++ b/test/phonon3/test_displacements.py @@ -1,8 +1,8 @@ """Tests of displacements.py.""" -import phono3py import numpy as np -from phono3py.phonon3.displacement_fc3 import get_smallest_vector_of_atom_pair +import phono3py +from phono3py.phonon3.displacement_fc3 import get_smallest_vector_of_atom_pair distances_NaCl = [ 0.0000000, diff --git a/test/phonon3/test_fc3.py b/test/phonon3/test_fc3.py index ecac88a8..fdc21cb9 100644 --- a/test/phonon3/test_fc3.py +++ b/test/phonon3/test_fc3.py @@ -1,5 +1,6 @@ """Tests for fc3.""" import numpy as np + from phono3py.phonon3.fc3 import cutoff_fc3_by_zero diff --git a/test/phonon3/test_interaction.py b/test/phonon3/test_interaction.py index 9819d796..371aac6f 100644 --- a/test/phonon3/test_interaction.py +++ b/test/phonon3/test_interaction.py @@ -1,6 +1,7 @@ """Test Interaction class.""" -import pytest import numpy as np +import pytest + from phono3py.phonon3.interaction import Interaction itr_RTA_Si = [ diff --git a/test/phonon3/test_joint_dos.py b/test/phonon3/test_joint_dos.py index b969758b..ba5aeb55 100644 --- a/test/phonon3/test_joint_dos.py +++ b/test/phonon3/test_joint_dos.py @@ -1,5 +1,6 @@ """Tests for joint-density-of-states.""" import numpy as np + from phono3py.api_jointdos import Phono3pyJointDos si_freq_points = [ diff --git a/test/phonon3/test_real_self_energy.py b/test/phonon3/test_real_self_energy.py index 20a87af1..a7b8af1e 100644 --- a/test/phonon3/test_real_self_energy.py +++ b/test/phonon3/test_real_self_energy.py @@ -1,5 +1,6 @@ """Test for real_self_energy.py.""" import numpy as np + from phono3py.phonon3.real_self_energy import ImagToReal si_pbesol_Delta = [ diff --git a/test/phonon3/test_spectral_function.py b/test/phonon3/test_spectral_function.py index 000f4f7c..f5f610e3 100644 --- a/test/phonon3/test_spectral_function.py +++ b/test/phonon3/test_spectral_function.py @@ -1,5 +1,6 @@ """Test spectral_function.py.""" import numpy as np + from phono3py.phonon3.spectral_function import SpectralFunction shifts = [ diff --git a/test/sscha/test_sscha.py b/test/sscha/test_sscha.py index f9c1e060..7a7bd5d1 100644 --- a/test/sscha/test_sscha.py +++ b/test/sscha/test_sscha.py @@ -1,14 +1,15 @@ """Tests for SSCHA routines.""" -import pytest import numpy as np +import pytest +from phonopy.phonon.qpoints import QpointsPhonon +from phonopy.phonon.random_displacements import RandomDisplacements + from phono3py.sscha.sscha import ( DispCorrMatrix, DispCorrMatrixMesh, SupercellPhonon, ThirdOrderFC, ) -from phonopy.phonon.qpoints import QpointsPhonon -from phonopy.phonon.random_displacements import RandomDisplacements try: ModuleNotFoundError From 9a30bff12d6474cfff13c8c662f76fab66aa1162 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Sat, 23 Oct 2021 11:43:35 +0900 Subject: [PATCH 23/34] Minor updates --- phono3py/cui/phono3py_script.py | 3 +++ phono3py/phonon/grid.py | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/phono3py/cui/phono3py_script.py b/phono3py/cui/phono3py_script.py index 32429618..285caee4 100644 --- a/phono3py/cui/phono3py_script.py +++ b/phono3py/cui/phono3py_script.py @@ -920,6 +920,9 @@ def init_phph_interaction( print(" [ %d %d %d ]" % tuple(bz_grid.grid_matrix[1])) print(" [ %d %d %d ]" % tuple(bz_grid.grid_matrix[2])) + if settings.is_symmetrize_fc3_q: + print("Permutation symmetry of ph-ph interaction strengths: True") + ave_pp = settings.constant_averaged_pp_interaction phono3py.init_phph_interaction( nac_q_direction=settings.nac_q_direction, diff --git a/phono3py/phonon/grid.py b/phono3py/phonon/grid.py index 0330c807..319d64b3 100644 --- a/phono3py/phonon/grid.py +++ b/phono3py/phonon/grid.py @@ -565,7 +565,7 @@ def get_grid_point_from_address(address, D_diag): return gps -def get_ir_grid_points(bz_grid): +def get_ir_grid_points(bz_grid: BZGrid): """Return ir-grid-points in generalized regular grid. bz_grid : BZGrid @@ -632,14 +632,14 @@ def get_grid_points_by_rotations( return _get_grid_points_by_rotations(bz_gp, bz_grid, rec_rots) -def _get_grid_points_by_rotations(bz_gp, bz_grid, rotations): +def _get_grid_points_by_rotations(bz_gp, bz_grid: BZGrid, rotations): """Grid point rotations without surface treatment.""" rot_adrs = np.dot(rotations, bz_grid.addresses[bz_gp]) grgps = get_grid_point_from_address(rot_adrs, bz_grid.D_diag) return bz_grid.grg2bzg[grgps] -def _get_grid_points_by_bz_rotations(bz_gp, bz_grid, rotations, lang="C"): +def _get_grid_points_by_bz_rotations(bz_gp, bz_grid: BZGrid, rotations, lang="C"): """Grid point rotations with surface treatment.""" if lang == "C": return _get_grid_points_by_bz_rotations_c(bz_gp, bz_grid, rotations) @@ -647,7 +647,7 @@ def _get_grid_points_by_bz_rotations(bz_gp, bz_grid, rotations, lang="C"): return _get_grid_points_by_bz_rotations_py(bz_gp, bz_grid, rotations) -def _get_grid_points_by_bz_rotations_c(bz_gp, bz_grid, rotations): +def _get_grid_points_by_bz_rotations_c(bz_gp, bz_grid: BZGrid, rotations): import phono3py._phono3py as phono3c bzgps = np.zeros(len(rotations), dtype="int_") @@ -664,7 +664,7 @@ def _get_grid_points_by_bz_rotations_c(bz_gp, bz_grid, rotations): return bzgps -def _get_grid_points_by_bz_rotations_py(bz_gp, bz_grid, rotations): +def _get_grid_points_by_bz_rotations_py(bz_gp, bz_grid: BZGrid, rotations): """Return BZ-grid point indices generated by rotations. Rotated BZ-grid addresses are compared with translationally From 3f804f95e442013a678f8a3874e7af3731c62e4e Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Sat, 23 Oct 2021 14:51:45 +0900 Subject: [PATCH 24/34] Update following the change of phonopy --- phono3py/cui/phono3py_script.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/phono3py/cui/phono3py_script.py b/phono3py/cui/phono3py_script.py index 285caee4..81ed3062 100644 --- a/phono3py/cui/phono3py_script.py +++ b/phono3py/cui/phono3py_script.py @@ -382,9 +382,7 @@ def create_FORCES_FC3_and_FORCES_FC2_then_exit( force_sets = get_force_sets( interface_mode, num_atoms, - num_disps, force_filenames, - disp_filename=disp_filename, verbose=(log_level > 0), ) @@ -394,7 +392,6 @@ def create_FORCES_FC3_and_FORCES_FC2_then_exit( force_set_zero = get_force_sets( interface_mode, num_atoms, - 1, [ force_filename, ], @@ -447,9 +444,7 @@ def create_FORCES_FC3_and_FORCES_FC2_then_exit( force_sets = get_force_sets( interface_mode, num_atoms, - num_disps, force_filenames, - disp_filename, verbose=(log_level > 0), ) @@ -459,7 +454,6 @@ def create_FORCES_FC3_and_FORCES_FC2_then_exit( force_set_zero = get_force_sets( interface_mode, num_atoms, - 1, [ force_filename, ], From b4ce2730e541071d7bb5c473f6377ce105342764 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Sat, 23 Oct 2021 18:22:37 +0900 Subject: [PATCH 25/34] Changed to python3 style classes. --- phono3py/api_phono3py.py | 2 +- phono3py/cui/kaccum.py | 4 ++-- phono3py/cui/settings.py | 6 +++--- phono3py/cui/triplets_info.py | 2 +- phono3py/interface/phono3py_yaml.py | 2 +- phono3py/other/isotope.py | 2 +- phono3py/phonon3/gruneisen.py | 2 +- phono3py/phonon3/joint_dos.py | 2 +- phono3py/phonon3/real_self_energy.py | 2 +- phono3py/phonon3/real_to_reciprocal.py | 2 +- phono3py/phonon3/spectral_function.py | 2 +- phono3py/sscha/sscha.py | 4 ++-- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/phono3py/api_phono3py.py b/phono3py/api_phono3py.py index dc48c972..77672fb2 100644 --- a/phono3py/api_phono3py.py +++ b/phono3py/api_phono3py.py @@ -91,7 +91,7 @@ from phono3py.phonon.grid import BZGrid from phono3py.version import __version__ -class Phono3py(object): +class Phono3py: """Phono3py main class. Attributes diff --git a/phono3py/cui/kaccum.py b/phono3py/cui/kaccum.py index 9249339b..59ced1e8 100644 --- a/phono3py/cui/kaccum.py +++ b/phono3py/cui/kaccum.py @@ -20,7 +20,7 @@ from phono3py.phonon.grid import BZGrid, get_ir_grid_points epsilon = 1.0e-8 -class KappaDOS(object): +class KappaDOS: """Class to calculate thermal conductivity spectram.""" def __init__( @@ -112,7 +112,7 @@ class KappaDOS(object): return bzgp2irgp_map -class GammaDOSsmearing(object): +class GammaDOSsmearing: """Class to calculate Gamma spectram by smearing method.""" def __init__( diff --git a/phono3py/cui/settings.py b/phono3py/cui/settings.py index 2a7cf106..45ae203a 100644 --- a/phono3py/cui/settings.py +++ b/phono3py/cui/settings.py @@ -104,7 +104,7 @@ class Phono3pySettings(Settings): self._v comes from the parent class. """ - Settings.__init__(self) + super().__init__() self._v.update(Phono3pySettings._default.copy()) if default is not None: self._v.update(default) @@ -330,13 +330,13 @@ class Phono3pyConfParser(ConfParser): self._settings = Phono3pySettings(default=default_settings) confs = {} if filename is not None: - ConfParser.__init__(self, filename=filename) + super().__init__(filename=filename) self.read_file() # store .conf file setting in self._confs self._parse_conf() self._set_settings() confs.update(self._confs) if args is not None: - ConfParser.__init__(self, args=args) + super().__init__(args=args) self._read_options() self._parse_conf() self._set_settings() diff --git a/phono3py/cui/triplets_info.py b/phono3py/cui/triplets_info.py index 116fa109..aa9dd4b3 100644 --- a/phono3py/cui/triplets_info.py +++ b/phono3py/cui/triplets_info.py @@ -129,7 +129,7 @@ def show_num_triplets( ) -class _TripletsNumbers(object): +class _TripletsNumbers: def __init__(self, bz_grid, is_kappa_star=True): self._bz_grid = bz_grid ( diff --git a/phono3py/interface/phono3py_yaml.py b/phono3py/interface/phono3py_yaml.py index 6f34cc66..fab42767 100644 --- a/phono3py/interface/phono3py_yaml.py +++ b/phono3py/interface/phono3py_yaml.py @@ -104,7 +104,7 @@ class Phono3pyYaml(PhonopyYaml): self._yaml = None - super(Phono3pyYaml, self).__init__( + super().__init__( configuration=configuration, calculator=calculator, physical_units=physical_units, diff --git a/phono3py/other/isotope.py b/phono3py/other/isotope.py index 0d428a7d..f60414c8 100644 --- a/phono3py/other/isotope.py +++ b/phono3py/other/isotope.py @@ -66,7 +66,7 @@ def get_mass_variances(primitive): return np.array(mass_variances, dtype="double") -class Isotope(object): +class Isotope: """Isotope scattering calculation class.""" def __init__( diff --git a/phono3py/phonon3/gruneisen.py b/phono3py/phonon3/gruneisen.py index bdad36f2..f66c213d 100644 --- a/phono3py/phonon3/gruneisen.py +++ b/phono3py/phonon3/gruneisen.py @@ -119,7 +119,7 @@ def run_gruneisen_parameters( print("Gruneisen parameters are written in %s" % (filename + filename_ext)) -class Gruneisen(object): +class Gruneisen: """Calculat mode Grueneisen parameters from fc3.""" def __init__( diff --git a/phono3py/phonon3/joint_dos.py b/phono3py/phonon3/joint_dos.py index 6807c7b1..5b53b725 100644 --- a/phono3py/phonon3/joint_dos.py +++ b/phono3py/phonon3/joint_dos.py @@ -54,7 +54,7 @@ from phono3py.phonon.grid import BZGrid from phono3py.phonon.solver import run_phonon_solver_c -class JointDos(object): +class JointDos: """Calculate joint-density-of-states.""" def __init__( diff --git a/phono3py/phonon3/real_self_energy.py b/phono3py/phonon3/real_self_energy.py index 4dcb1ded..4676d9ac 100644 --- a/phono3py/phonon3/real_self_energy.py +++ b/phono3py/phonon3/real_self_energy.py @@ -608,7 +608,7 @@ def imag_to_real(im_part, frequency_points): return i2r.re_part, i2r.frequency_points -class ImagToReal(object): +class ImagToReal: """Calculate real part of self-energy using Kramers-Kronig relation.""" def __init__(self, im_part, frequency_points, diagram="bubble"): diff --git a/phono3py/phonon3/real_to_reciprocal.py b/phono3py/phonon3/real_to_reciprocal.py index 8b0f3dff..d80859fa 100644 --- a/phono3py/phonon3/real_to_reciprocal.py +++ b/phono3py/phonon3/real_to_reciprocal.py @@ -37,7 +37,7 @@ import numpy as np from phonopy.structure.cells import sparse_to_dense_svecs -class RealToReciprocal(object): +class RealToReciprocal: """Transform fc3 in real space to reciprocal space.""" def __init__(self, fc3, primitive, mesh, symprec=1e-5): diff --git a/phono3py/phonon3/spectral_function.py b/phono3py/phonon3/spectral_function.py index 2dec8305..83d31953 100644 --- a/phono3py/phonon3/spectral_function.py +++ b/phono3py/phonon3/spectral_function.py @@ -170,7 +170,7 @@ def run_spectral_function( return spf -class SpectralFunction(object): +class SpectralFunction: """Calculate spectral function due to bubble diagram.""" def __init__( diff --git a/phono3py/sscha/sscha.py b/phono3py/sscha/sscha.py index e354870d..92ec77b0 100644 --- a/phono3py/sscha/sscha.py +++ b/phono3py/sscha/sscha.py @@ -305,7 +305,7 @@ class DispCorrMatrixMesh: return self._psi_matrix -class SecondOrderFC(object): +class SecondOrderFC: r"""SSCHA second order force constants by ensemble average. This class is made just for the test of the ensemble average in @@ -415,7 +415,7 @@ class SecondOrderFC(object): ) -class ThirdOrderFC(object): +class ThirdOrderFC: r"""SSCHA third order force constants. Eq. 45a in Ref.1 (See top docstring of this file) From b37af72bafabcf106fcc84c93e4fff455fa1e193 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 Oct 2021 20:14:34 +0000 Subject: [PATCH 26/34] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pycqa/isort: 5.8.0 → 5.9.3](https://github.com/pycqa/isort/compare/5.8.0...5.9.3) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d48971cd..9fdc52e6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,7 +31,7 @@ repos: - id: pydocstyle - repo: https://github.com/pycqa/isort - rev: 5.8.0 + rev: 5.9.3 hooks: - id: isort name: isort (python) From d99dd4d598110944aa40d78e02ef9f55fec8f95f Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Fri, 29 Oct 2021 15:59:55 +0900 Subject: [PATCH 27/34] Update phonopy version dependency --- conda/meta.yaml | 4 ++-- requirements.txt | 2 +- setup.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conda/meta.yaml b/conda/meta.yaml index 0a50024f..aa925e77 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -33,7 +33,7 @@ requirements: - matplotlib-base - pyyaml - h5py - - phonopy>=2.11,<2.12 + - phonopy>=2.12,<2.13 - openblas - libgfortran - spglib @@ -46,7 +46,7 @@ requirements: - matplotlib-base - pyyaml - h5py - - phonopy>=2.10,<2.11 + - phonopy>=2.12,<2.13 - openblas - libgfortran - spglib diff --git a/requirements.txt b/requirements.txt index c0433469..d0f08807 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,4 @@ numpy PyYAML matplotlib h5py -phonopy >=2.11,<2.12 +phonopy >=2.12,<2.13 diff --git a/setup.py b/setup.py index 90596529..d63e22ee 100644 --- a/setup.py +++ b/setup.py @@ -381,7 +381,7 @@ if __name__ == "__main__": "matplotlib", "h5py", "spglib", - "phonopy>=2.11,<2.12", + "phonopy>=2.12,<2.13", ], provides=["phono3py"], scripts=scripts_phono3py, From 694ddd2b9051f22391a8c7a6c14c24240e706820 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Sun, 31 Oct 2021 22:43:12 +0900 Subject: [PATCH 28/34] Minor refactoring --- .vscode/settings.json | 8 --- phono3py/api_phono3py.py | 2 +- phono3py/phonon/grid.py | 8 ++- phono3py/phonon3/collision_matrix.py | 18 +++---- phono3py/phonon3/conductivity_LBTE.py | 64 +++++++++++++---------- phono3py/phonon3/interaction.py | 2 +- phono3py/phonon3/triplets.py | 16 +++--- scripts/phono3py-coleigplot | 75 ++++++++++++++++++++------- 8 files changed, 116 insertions(+), 77 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 5e337ba7..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "python.testing.pytestArgs": [ - "test" - ], - "python.testing.unittestEnabled": false, - "python.testing.nosetestsEnabled": false, - "python.testing.pytestEnabled": true -} diff --git a/phono3py/api_phono3py.py b/phono3py/api_phono3py.py index 77672fb2..a7357f49 100644 --- a/phono3py/api_phono3py.py +++ b/phono3py/api_phono3py.py @@ -2530,13 +2530,13 @@ class Phono3py: def _set_mesh_numbers(self, mesh): # initialization related to mesh self._interaction = None - self._bz_grid = BZGrid( mesh, lattice=self._primitive.cell, symmetry_dataset=self._primitive_symmetry.dataset, is_time_reversal=self._is_symmetry, use_grg=self._use_grg, + force_SNF=False, store_dense_gp_map=self._store_dense_gp_map, ) diff --git a/phono3py/phonon/grid.py b/phono3py/phonon/grid.py index 319d64b3..62337667 100644 --- a/phono3py/phonon/grid.py +++ b/phono3py/phonon/grid.py @@ -126,6 +126,7 @@ class BZGrid: is_shift=None, is_time_reversal=True, use_grg=False, + force_SNF=False, store_dense_gp_map=True, ): """Init method. @@ -151,6 +152,9 @@ class BZGrid: Default is True. use_grg : bool, optional Use generalized regular grid. Default is False. + force_SNF : bool, optional + Enforce Smith normal form even when grid lattice of GR-grid is the same as + the traditional grid lattice. Default is False. store_dense_gp_map : bool, optional See the detail in the docstring of `_relocate_BZ_grid_address`. Default is True. @@ -192,7 +196,7 @@ class BZGrid: np.linalg.inv(lattice), dtype="double", order="C" ) - self._generate_grid(mesh) + self._generate_grid(mesh, force_SNF=force_SNF) @property def D_diag(self): @@ -437,7 +441,7 @@ class BZGrid: self._D_diag = np.array(mesh, dtype="int_") except TypeError: length = float(mesh) - if self._use_grg: + if self._use_grg and "international" in self._symmetry_dataset: self._set_SNF(length, force_SNF=force_SNF) else: self._D_diag = length2mesh(length, self._lattice) diff --git a/phono3py/phonon3/collision_matrix.py b/phono3py/phonon3/collision_matrix.py index f39c4fb9..91533abb 100644 --- a/phono3py/phonon3/collision_matrix.py +++ b/phono3py/phonon3/collision_matrix.py @@ -134,7 +134,6 @@ class CollisionMatrix(ImagSelfEnergy): self._frequencies, self._eigenvectors, _ = self._pp.get_phonons() def _run_collision_matrix(self): - self._run_with_band_indices() if self._temperature > 0: if self._lang == "C": if self._is_reducible_collision_matrix: @@ -185,22 +184,17 @@ class CollisionMatrix(ImagSelfEnergy): num_band0 = self._pp_strength.shape[1] num_band = self._pp_strength.shape[2] gp2tp_map = self._get_gp2tp_map() - for i in range(self._num_ir_grid_points): r_gps = self._rot_grid_points[i] for r, r_gp in zip(self._rotations_cartesian, r_gps): ti = gp2tp_map[self._triplets_map_at_q[r_gp]] inv_sinh = self._get_inv_sinh(r_gp, gp2tp_map) - - for j in range(num_band0): - for k in range(num_band): - collision = ( - self._pp_strength[ti, j, k] - * inv_sinh - * self._g[2, ti, j, k] - ).sum() - collision *= self._unit_conversion - self._collision_matrix[j, :, i, k, :] += collision * r + for j, k in list(np.ndindex((num_band0, num_band))): + collision = ( + self._pp_strength[ti, j, k] * inv_sinh * self._g[2, ti, j, k] + ).sum() + collision *= self._unit_conversion + self._collision_matrix[j, :, i, k, :] += collision * r def _run_py_reducible_collision_matrix(self): num_mesh_points = np.prod(self._pp.mesh_numbers) diff --git a/phono3py/phonon3/conductivity_LBTE.py b/phono3py/phonon3/conductivity_LBTE.py index 1edaa3cd..6026d44d 100644 --- a/phono3py/phonon3/conductivity_LBTE.py +++ b/phono3py/phonon3/conductivity_LBTE.py @@ -81,6 +81,7 @@ class Conductivity_LBTE(Conductivity): pinv_cutoff=1.0e-8, pinv_solver=0, log_level=0, + lang="C", ): """Init method.""" self._pp: Interaction @@ -92,6 +93,7 @@ class Conductivity_LBTE(Conductivity): self._is_kappa_star = None self._is_full_pp = None self._log_level = None + self._lang = lang self._boundary_mfp = None self._point_operations = None @@ -145,8 +147,8 @@ class Conductivity_LBTE(Conductivity): self._is_reducible_collision_matrix = is_reducible_collision_matrix self._solve_collective_phonon = solve_collective_phonon - if not self._is_kappa_star: - self._is_reducible_collision_matrix = True + # if not self._is_kappa_star: + # self._is_reducible_collision_matrix = True self._collision_matrix = None self._read_pp = read_pp self._pp_filename = pp_filename @@ -363,9 +365,14 @@ class Conductivity_LBTE(Conductivity): self._rot_grid_points = np.zeros( (num_ir_grid_points, len(self._point_operations)), dtype="int_" ) + if self._is_kappa_star: + rotations = self._pp.bz_grid.rotations # rotations of GR-grid + else: + rotations = self._point_operations # only identity + for i, ir_gp in enumerate(self._ir_grid_points): self._rot_grid_points[i] = get_grid_points_by_rotations( - ir_gp, self._pp.bz_grid + ir_gp, self._pp.bz_grid, reciprocal_rotations=rotations ) self._collision = CollisionMatrix( self._pp, @@ -467,15 +474,14 @@ class Conductivity_LBTE(Conductivity): ] = self._collision.get_collision_matrix() def _prepare_collision_matrix(self): - """Prepare collision matrix to be solved.""" + """Collect pieces and construct collision matrix.""" if self._is_reducible_collision_matrix: if self._is_kappa_star: self._average_collision_matrix_by_degeneracy() num_mesh_points = np.prod(self._pp.mesh_numbers) num_rot = len(self._point_operations) rot_grid_points = np.zeros((num_rot, num_mesh_points), dtype="int_") - # Ir-grid points and rot_grid_points in generalized regular - # grid + # 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_" ) @@ -580,22 +586,21 @@ class Conductivity_LBTE(Conductivity): sys.stdout.write("- Expanding properties to all grid points ") sys.stdout.flush() - try: + if self._lang == "C": import phono3py._phono3py as phono3c phono3c.expand_collision_matrix( self._collision_matrix, ir_gr_grid_points, rot_grid_points ) - except ImportError: - print("Phono3py C-routine is not compiled correctly.") + else: num_mesh_points = np.prod(self._pp.mesh_numbers) colmat = self._collision_matrix - for i, ir_gp in enumerate(ir_gr_grid_points): + for ir_gp in ir_gr_grid_points: multi = (rot_grid_points[:, ir_gp] == ir_gp).sum() colmat_irgp = colmat[:, :, ir_gp, :, :, :].copy() colmat_irgp /= multi colmat[:, :, ir_gp, :, :, :] = 0 - for j, r in enumerate(self._rotations_cartesian): + for j, _ in enumerate(self._rotations_cartesian): gp_r = rot_grid_points[j, ir_gp] for k in range(num_mesh_points): gp_c = rot_grid_points[j, k] @@ -607,7 +612,7 @@ class Conductivity_LBTE(Conductivity): def _expand_local_values(self, ir_gr_grid_points, rot_grid_points): """Fill elements of local properties at grid points.""" - for i, ir_gp in enumerate(ir_gr_grid_points): + for ir_gp in ir_gr_grid_points: gv_irgp = self._gv[ir_gp].copy() self._gv[ir_gp] = 0 cv_irgp = self._cv[:, ir_gp, :].copy() @@ -632,7 +637,8 @@ class Conductivity_LBTE(Conductivity): For symmetry compressed collision matrix. self._rot_grid_points : ndarray - Grid points generated by applying point group to ir-grid-points in BZ-grid. + Grid points generated by applying point group to ir-grid-points + in BZ-grid. shape=(ir_grid_points, point_operations), dtype='int_' r_gps : grid points of arms of k-star with duplicates @@ -641,15 +647,15 @@ class Conductivity_LBTE(Conductivity): Returns ------- - weights : list - sqrt(g_k)/|g|, where g is the crystallographic point group and - g_k is the number of arms of k-star. + weights : ndarray + sqrt(g_k/|g|), where g is the crystallographic point group and + g_k is the number of arms of k-star at each ir-qpoint. + shape=(ir_grid_points,), dtype='double' """ - weights = [] - n = float(self._rot_grid_points.shape[1]) - for r_gps in self._rot_grid_points: - weights.append(np.sqrt(len(np.unique(r_gps)) / n)) + weights = np.zeros(len(self._rot_grid_points), dtype="double") + for i, r_gps in enumerate(self._rot_grid_points): + weights[i] = np.sqrt(len(np.unique(r_gps))) sym_broken = False for gp in np.unique(r_gps): @@ -662,7 +668,7 @@ class Conductivity_LBTE(Conductivity): print("=" * 26 + " Warning " + "=" * 26) print("Symmetry of grid is broken.") - return weights + return weights / np.sqrt(self._rot_grid_points.shape[1]) def _symmetrize_collision_matrix(self): r"""Symmetrize collision matrix. @@ -908,10 +914,10 @@ class Conductivity_LBTE(Conductivity): def _set_kappa_ir_colmat(self, i_sigma, i_temp, weights): """Calculate direct solution thermal conductivity of ir colmat.""" + N = self._num_sampling_grid_points if self._solve_collective_phonon: self._set_mode_kappa_Chaput(i_sigma, i_temp, weights) else: - N = self._num_sampling_grid_points X = self._get_X(i_temp, weights) num_ir_grid_points = len(self._ir_grid_points) Y = self._get_Y(i_sigma, i_temp, weights, X) @@ -1014,8 +1020,7 @@ class Conductivity_LBTE(Conductivity): """Calculate RTA thermal conductivity. This RTA is not equivalent to conductivity_RTA. - The lifetime is defined from the diagonal part of - collision matrix. + The lifetime is defined from the diagonal part of collision matrix. """ N = self._num_sampling_grid_points @@ -1057,7 +1062,13 @@ class Conductivity_LBTE(Conductivity): ): """Calculate mode thermal conductivity. - The first parameter, mode_kappa, is overwritten. + kappa = A*(RX, RY) = A*(RX, R omega^-1 X), where A = k_B T^2 / V. + + Note + ---- + Collision matrix is defined as a half of that in Chaput's paper. + Therefore here 2 is not necessary multiplied. + sum_k = sum_k + sum_k.T is equivalent to I(a,b) + I(b,a). """ num_band = len(self._pp.primitive) * 3 @@ -1087,9 +1098,6 @@ class Conductivity_LBTE(Conductivity): mode_kappa[i_sigma, i_temp, i, j, k] = sum_k[vxf] t = self._temperatures[i_temp] - # Collision matrix is defined as a half of that in Chaput's paper. - # Therefore here 2 is not necessary multiplied. - # sum_k = sum_k + sum_k.T is equivalent to I(a,b) + I(b,a). mode_kappa[i_sigma, i_temp] *= self._conversion_factor * Kb * t ** 2 def _set_mode_kappa_Chaput(self, i_sigma, i_temp, weights): diff --git a/phono3py/phonon3/interaction.py b/phono3py/phonon3/interaction.py index 168de1bd..ccb5db86 100644 --- a/phono3py/phonon3/interaction.py +++ b/phono3py/phonon3/interaction.py @@ -486,7 +486,6 @@ class Interaction: def set_grid_point(self, grid_point, store_triplets_map=False): """Set grid point and prepare grid point triplets.""" - reciprocal_lattice = np.linalg.inv(self._primitive.cell) if not self._is_mesh_symmetry: ( triplets_at_q, @@ -534,6 +533,7 @@ class Interaction: is_time_reversal=False, ) + reciprocal_lattice = np.linalg.inv(self._primitive.cell) for triplet in triplets_at_q: sum_q = (self._bz_grid.addresses[triplet]).sum(axis=0) if (sum_q % self.mesh_numbers != 0).any(): diff --git a/phono3py/phonon3/triplets.py b/phono3py/phonon3/triplets.py index 9f9506b8..1775b13b 100644 --- a/phono3py/phonon3/triplets.py +++ b/phono3py/phonon3/triplets.py @@ -37,11 +37,12 @@ import numpy as np from phonopy.structure.tetrahedron_method import TetrahedronMethod from phono3py.phonon.func import gaussian +from phono3py.phonon.grid import BZGrid def get_triplets_at_q( grid_point, - bz_grid, + bz_grid: BZGrid, reciprocal_rotations=None, is_time_reversal=True, swappable=True, @@ -123,7 +124,7 @@ def get_all_triplets(grid_point, bz_grid): return triplets_at_q -def get_nosym_triplets_at_q(grid_point, bz_grid): +def get_nosym_triplets_at_q(grid_point, bz_grid: BZGrid): """Return triplets information without imposing mesh symmetry. See the docstring of get_triplets_at_q. @@ -299,12 +300,16 @@ def _get_triplets_reciprocal_mesh_at_q( return map_triplets, map_q -def _get_BZ_triplets_at_q(grid_point, bz_grid, map_triplets): +def _get_BZ_triplets_at_q(grid_point, bz_grid: BZGrid, map_triplets): """Grid point triplets are searched considering BZ surface. Looking for q+q'+q''=G with smallest |G|. In this condition, a pair in (q, q', q'') can be translationally equivalent points. - This is treated an auxiliary grid system (bz_grid). + This is treated on BZ-grid. + + Note + ---- + Symmetry information of triplets is encoded in ``map_triplets``. Parameters ---------- @@ -340,7 +345,6 @@ def _get_BZ_triplets_at_q(grid_point, bz_grid, map_triplets): weights[g] += 1 ir_weights = np.extract(weights > 0, weights) triplets = -np.ones((len(ir_weights), 3), dtype="int_") - Q = np.eye(3, dtype="int_", order="C") num_ir_ret = phono3c.BZ_triplets_at_q( triplets, grid_point, @@ -348,7 +352,7 @@ def _get_BZ_triplets_at_q(grid_point, bz_grid, map_triplets): bz_grid.gp_map, map_triplets, np.array(bz_grid.D_diag, dtype="int_"), - Q, + bz_grid.Q, bz_grid.store_dense_gp_map * 1 + 1, ) diff --git a/scripts/phono3py-coleigplot b/scripts/phono3py-coleigplot index f651d12a..80c3a806 100755 --- a/scripts/phono3py-coleigplot +++ b/scripts/phono3py-coleigplot @@ -25,24 +25,7 @@ def get_options(): return args -def main(args): - filename = args.filenames[0] - if os.path.isfile(filename): - with h5py.File(filename, "r") as f: - coleigs = f["collision_eigenvalues"][:] - temperatures = f["temperature"][:] - else: - print("File %s doens't exist." % filename) - sys.exit(1) - - import matplotlib.pyplot as plt - - fig, ax = plt.subplots() - ax.xaxis.set_ticks_position("bottom") - ax.yaxis.set_ticks_position("left") - ax.xaxis.set_tick_params(which="both", direction="in") - ax.yaxis.set_tick_params(which="both", direction="in") - +def get_t_index(temperatures, args): if len(temperatures) > 29: t_index = 30 else: @@ -51,15 +34,69 @@ def main(args): if np.abs(t - args.temperature) < epsilon: t_index = i break + return t_index + +def plot_one(ax, coleigs, temperatures, args): + t_index = get_t_index(temperatures, args) coleigs_p = coleigs[t_index].copy() coleigs_n = coleigs[t_index].copy() coleigs_p[coleigs_p < 0] = np.nan coleigs_n[coleigs_n >= 0] = np.nan - ax.semilogy(coleigs_p, "b.", markersize=1) ax.semilogy(-coleigs_n, "r.", markersize=1) ax.set_xlim(0, len(coleigs_p)) + + +def plot_one_file(ax, args): + filename = args.filenames[0] + if os.path.isfile(filename): + with h5py.File(filename, "r") as f: + coleigs = f["collision_eigenvalues"][:] + temperatures = f["temperature"][:] + plot_one(ax, coleigs, temperatures, args) + else: + print("File %s doens't exist." % filename) + sys.exit(1) + + +def plot_more(ax, coleigs, temperatures, args): + t_index = get_t_index(temperatures[0], args) + y = [v[t_index] for v in coleigs] + ax.semilogy(np.transpose(y), ".", markersize=5) + ax.set_xlim(0, len(y[0])) + + +def plot_more_files(ax, args): + temperatures = [] + coleigs = [] + for filename in args.filenames: + if os.path.isfile(filename): + with h5py.File(filename, "r") as f: + coleigs.append(f["collision_eigenvalues"][:]) + temperatures.append(f["temperature"][:]) + else: + print("File %s doens't exist." % filename) + sys.exit(1) + plot_more(ax, coleigs, temperatures, args) + + +def main(args: argparse.Namespace): + import matplotlib.pyplot as plt + + fig, ax = plt.subplots() + ax.xaxis.set_ticks_position("bottom") + ax.yaxis.set_ticks_position("left") + ax.xaxis.set_tick_params(which="both", direction="in") + ax.yaxis.set_tick_params(which="both", direction="in") + + if len(args.filenames) == 1: + plot_one_file(ax, args) + else: + plot_more_files(ax, args) + + # for filename in args.filenames: + plt.show() From e7d7bf99c9ae1fe8e8f750ffce174649ac95b1d4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Nov 2021 21:06:16 +0000 Subject: [PATCH 29/34] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 21.9b0 → 21.10b0](https://github.com/psf/black/compare/21.9b0...21.10b0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9fdc52e6..68840beb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: - "--ignore=E203,W503" - repo: https://github.com/psf/black - rev: 21.9b0 + rev: 21.10b0 hooks: - id: black args: From 54d4ddab6f3fbf9435bdfe8b27757be1d5c4ebf6 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Tue, 2 Nov 2021 22:03:26 +0900 Subject: [PATCH 30/34] Fix direct solution This is considered a critical bug of the direct solution. Permutation symmetry of ph-ph intraction strength was considered only between q1 and q2 (among three q-points q0, q1, q2) though it should be between q1-b1 and q2-b2 (b1 and b2 denote their band indices). This was fixed. --- c/collision_matrix.c | 498 +++++++++++---------------- phono3py/phonon3/collision_matrix.py | 138 ++++++-- 2 files changed, 311 insertions(+), 325 deletions(-) diff --git a/c/collision_matrix.c b/c/collision_matrix.c index c628177a..4f6bda6d 100644 --- a/c/collision_matrix.c +++ b/c/collision_matrix.c @@ -32,343 +32,255 @@ /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include -#include "phonoc_array.h" -#include "phonoc_utils.h" #include "collision_matrix.h" -static void get_collision_matrix(double *collision_matrix, - const double *fc3_normal_squared, - const long num_band0, - const long num_band, - const double *frequencies, - const long (*triplets)[3], - const long *triplets_map, - const long num_gp, - const long *map_q, - const long *rot_grid_points, - const long num_ir_gp, - const long num_rot, - const double *rotations_cartesian, - const double *g, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency); -static void -get_reducible_collision_matrix(double *collision_matrix, - const double *fc3_normal_squared, - const long num_band0, - const long num_band, - const double *frequencies, - const long (*triplets)[3], - const long *triplets_map, - const long num_gp, - const long *map_q, - const double *g, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency); -static void get_inv_sinh(double *inv_sinh, - const long gp, - const double temperature, - const double *frequencies, - const long triplet[3], - const long *triplets_map, - const long *map_q, - const long num_band, +#include +#include +#include + +#include "phonoc_array.h" +#include "phonoc_utils.h" + +static void get_collision_matrix( + double *collision_matrix, const double *fc3_normal_squared, + const long num_band0, const long num_band, const double *frequencies, + const long (*triplets)[3], const long *triplets_map, const long num_gp, + const long *map_q, const long *rot_grid_points, const long num_ir_gp, + const long num_rot, const double *rotations_cartesian, const double *g, + const double temperature, const double unit_conversion_factor, + const double cutoff_frequency); +static void get_reducible_collision_matrix( + double *collision_matrix, const double *fc3_normal_squared, + const long num_band0, const long num_band, const double *frequencies, + const long (*triplets)[3], const long *triplets_map, const long num_gp, + const long *map_q, const double *g, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency); +static long get_inv_sinh(double *inv_sinh, const long gp, + const double temperature, const double *frequencies, + const long triplet[3], const long *triplets_map, + const long *map_q, const long num_band, const double cutoff_frequency); -static long *create_gp2tp_map(const long *triplets_map, - const long num_gp); +static long *create_gp2tp_map(const long *triplets_map, const long num_gp); -void col_get_collision_matrix(double *collision_matrix, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplets_map, - const long *map_q, - const long *rot_grid_points, - const double *rotations_cartesian, - const double *g, - const long num_ir_gp, - const long num_gp, - const long num_rot, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency) -{ - long num_triplets, num_band0, num_band; +void col_get_collision_matrix( + double *collision_matrix, const Darray *fc3_normal_squared, + const double *frequencies, const long (*triplets)[3], + const long *triplets_map, const long *map_q, const long *rot_grid_points, + const double *rotations_cartesian, const double *g, const long num_ir_gp, + const long num_gp, const long num_rot, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency) { + long num_triplets, num_band0, num_band; - num_triplets = fc3_normal_squared->dims[0]; - num_band0 = fc3_normal_squared->dims[1]; - num_band = fc3_normal_squared->dims[2]; + num_triplets = fc3_normal_squared->dims[0]; + num_band0 = fc3_normal_squared->dims[1]; + num_band = fc3_normal_squared->dims[2]; - get_collision_matrix( - collision_matrix, - fc3_normal_squared->data, - num_band0, - num_band, - frequencies, - triplets, - triplets_map, - num_gp, - map_q, - rot_grid_points, - num_ir_gp, - num_rot, - rotations_cartesian, - g + 2 * num_triplets * num_band0 * num_band * num_band, - temperature, - unit_conversion_factor, - cutoff_frequency); + get_collision_matrix(collision_matrix, fc3_normal_squared->data, num_band0, + num_band, frequencies, triplets, triplets_map, num_gp, + map_q, rot_grid_points, num_ir_gp, num_rot, + rotations_cartesian, + g + 2 * num_triplets * num_band0 * num_band * num_band, + temperature, unit_conversion_factor, cutoff_frequency); } -void col_get_reducible_collision_matrix(double *collision_matrix, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplets_map, - const long *map_q, - const double *g, - const long num_gp, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency) -{ - long num_triplets, num_band, num_band0; +void col_get_reducible_collision_matrix( + double *collision_matrix, const Darray *fc3_normal_squared, + const double *frequencies, const long (*triplets)[3], + const long *triplets_map, const long *map_q, const double *g, + const long num_gp, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency) { + long num_triplets, num_band, num_band0; - num_triplets = fc3_normal_squared->dims[0]; - num_band0 = fc3_normal_squared->dims[1]; - num_band = fc3_normal_squared->dims[2]; + num_triplets = fc3_normal_squared->dims[0]; + num_band0 = fc3_normal_squared->dims[1]; + num_band = fc3_normal_squared->dims[2]; - get_reducible_collision_matrix( - collision_matrix, - fc3_normal_squared->data, - num_band0, - num_band, - frequencies, - triplets, - triplets_map, - num_gp, - map_q, - g + 2 * num_triplets * num_band0 * num_band * num_band, - temperature, - unit_conversion_factor, - cutoff_frequency); + get_reducible_collision_matrix( + collision_matrix, fc3_normal_squared->data, num_band0, num_band, + frequencies, triplets, triplets_map, num_gp, map_q, + g + 2 * num_triplets * num_band0 * num_band * num_band, temperature, + unit_conversion_factor, cutoff_frequency); } -static void get_collision_matrix(double *collision_matrix, - const double *fc3_normal_squared, - const long num_band0, - const long num_band, - const double *frequencies, - const long (*triplets)[3], - const long *triplets_map, - const long num_gp, - const long *map_q, - const long *rot_grid_points, - const long num_ir_gp, - const long num_rot, - const double *rotations_cartesian, - const double *g, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency) -{ - long i, j, k, l, m, n, ti, r_gp; - long *gp2tp_map; - double collision; - double *inv_sinh; +static void get_collision_matrix( + double *collision_matrix, const double *fc3_normal_squared, + const long num_band0, const long num_band, const double *frequencies, + const long (*triplets)[3], const long *triplets_map, const long num_gp, + const long *map_q, const long *rot_grid_points, const long num_ir_gp, + const long num_rot, const double *rotations_cartesian, const double *g, + const double temperature, const double unit_conversion_factor, + const double cutoff_frequency) { + long i, j, k, l, m, n, ti, r_gp, swapped; + long *gp2tp_map; + double collision; + double *inv_sinh; - gp2tp_map = create_gp2tp_map(triplets_map, num_gp); + gp2tp_map = create_gp2tp_map(triplets_map, num_gp); #ifdef PHPYOPENMP #pragma omp parallel for private(j, k, l, m, n, ti, r_gp, collision, inv_sinh) #endif - for (i = 0; i < num_ir_gp; i++) - { - inv_sinh = (double *)malloc(sizeof(double) * num_band); - for (j = 0; j < num_rot; j++) - { - r_gp = rot_grid_points[i * num_rot + j]; - ti = gp2tp_map[triplets_map[r_gp]]; - get_inv_sinh(inv_sinh, - r_gp, - temperature, - frequencies, - triplets[ti], - triplets_map, - map_q, - num_band, - cutoff_frequency); + for (i = 0; i < num_ir_gp; i++) { + inv_sinh = (double *)malloc(sizeof(double) * num_band); + for (j = 0; j < num_rot; j++) { + r_gp = rot_grid_points[i * num_rot + j]; + ti = gp2tp_map[triplets_map[r_gp]]; + swapped = get_inv_sinh(inv_sinh, r_gp, temperature, frequencies, + triplets[ti], triplets_map, map_q, num_band, + cutoff_frequency); - for (k = 0; k < num_band0; k++) - { - for (l = 0; l < num_band; l++) - { - collision = 0; - for (m = 0; m < num_band; m++) - { - collision += - fc3_normal_squared[ti * num_band0 * num_band * num_band + - k * num_band * num_band + - l * num_band + m] * - g[ti * num_band0 * num_band * num_band + - k * num_band * num_band + - l * num_band + m] * - inv_sinh[m] * unit_conversion_factor; - } - for (m = 0; m < 3; m++) - { - for (n = 0; n < 3; n++) - { - collision_matrix[k * 3 * num_ir_gp * num_band * 3 + - m * num_ir_gp * num_band * 3 + - i * num_band * 3 + l * 3 + n] += - collision * rotations_cartesian[j * 9 + m * 3 + n]; + for (k = 0; k < num_band0; k++) { + for (l = 0; l < num_band; l++) { + collision = 0; + for (m = 0; m < num_band; m++) { + if (swapped) { + collision += + fc3_normal_squared[ti * num_band0 * num_band * + num_band + + k * num_band * num_band + + m * num_band + l] * + g[ti * num_band0 * num_band * num_band + + k * num_band * num_band + m * num_band + l] * + inv_sinh[m] * unit_conversion_factor; + } else { + collision += + fc3_normal_squared[ti * num_band0 * num_band * + num_band + + k * num_band * num_band + + l * num_band + m] * + g[ti * num_band0 * num_band * num_band + + k * num_band * num_band + l * num_band + m] * + inv_sinh[m] * unit_conversion_factor; + } + } + for (m = 0; m < 3; m++) { + for (n = 0; n < 3; n++) { + collision_matrix[k * 3 * num_ir_gp * num_band * 3 + + m * num_ir_gp * num_band * 3 + + i * num_band * 3 + l * 3 + n] += + collision * + rotations_cartesian[j * 9 + m * 3 + n]; + } + } + } } - } } - } + free(inv_sinh); + inv_sinh = NULL; } - free(inv_sinh); - inv_sinh = NULL; - } - free(gp2tp_map); - gp2tp_map = NULL; + free(gp2tp_map); + gp2tp_map = NULL; } -static void -get_reducible_collision_matrix(double *collision_matrix, - const double *fc3_normal_squared, - const long num_band0, - const long num_band, - const double *frequencies, - const long (*triplets)[3], - const long *triplets_map, - const long num_gp, - const long *map_q, - const double *g, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency) -{ - long i, j, k, l, ti; - long *gp2tp_map; - double collision; - double *inv_sinh; +static void get_reducible_collision_matrix( + double *collision_matrix, const double *fc3_normal_squared, + const long num_band0, const long num_band, const double *frequencies, + const long (*triplets)[3], const long *triplets_map, const long num_gp, + const long *map_q, const double *g, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency) { + long i, j, k, l, ti, swapped; + long *gp2tp_map; + double collision; + double *inv_sinh; - gp2tp_map = create_gp2tp_map(triplets_map, num_gp); + gp2tp_map = create_gp2tp_map(triplets_map, num_gp); #ifdef PHPYOPENMP #pragma omp parallel for private(j, k, l, ti, collision, inv_sinh) #endif - for (i = 0; i < num_gp; i++) - { - inv_sinh = (double *)malloc(sizeof(double) * num_band); - ti = gp2tp_map[triplets_map[i]]; - get_inv_sinh(inv_sinh, - i, - temperature, - frequencies, - triplets[ti], - triplets_map, - map_q, - num_band, - cutoff_frequency); + for (i = 0; i < num_gp; i++) { + inv_sinh = (double *)malloc(sizeof(double) * num_band); + ti = gp2tp_map[triplets_map[i]]; + swapped = + get_inv_sinh(inv_sinh, i, temperature, frequencies, triplets[ti], + triplets_map, map_q, num_band, cutoff_frequency); - for (j = 0; j < num_band0; j++) - { - for (k = 0; k < num_band; k++) - { - collision = 0; - for (l = 0; l < num_band; l++) - { - collision += - fc3_normal_squared[ti * num_band0 * num_band * num_band + - j * num_band * num_band + - k * num_band + l] * - g[ti * num_band0 * num_band * num_band + - j * num_band * num_band + - k * num_band + l] * - inv_sinh[l] * unit_conversion_factor; + for (j = 0; j < num_band0; j++) { + for (k = 0; k < num_band; k++) { + collision = 0; + for (l = 0; l < num_band; l++) { + if (swapped) { + collision += + fc3_normal_squared[ti * num_band0 * num_band * + num_band + + j * num_band * num_band + + l * num_band + k] * + g[ti * num_band0 * num_band * num_band + + j * num_band * num_band + l * num_band + k] * + inv_sinh[l] * unit_conversion_factor; + } else { + collision += + fc3_normal_squared[ti * num_band0 * num_band * + num_band + + j * num_band * num_band + + k * num_band + l] * + g[ti * num_band0 * num_band * num_band + + j * num_band * num_band + k * num_band + l] * + inv_sinh[l] * unit_conversion_factor; + } + } + collision_matrix[j * num_gp * num_band + i * num_band + k] += + collision; + } } - collision_matrix[j * num_gp * num_band + i * num_band + k] += collision; - } + + free(inv_sinh); + inv_sinh = NULL; } - free(inv_sinh); - inv_sinh = NULL; - } - - free(gp2tp_map); - gp2tp_map = NULL; + free(gp2tp_map); + gp2tp_map = NULL; } -static void get_inv_sinh(double *inv_sinh, - const long gp, - const double temperature, - const double *frequencies, - const long triplet[3], - const long *triplets_map, - const long *map_q, - const long num_band, - const double cutoff_frequency) -{ - long i, gp2; - double f; +static long get_inv_sinh(double *inv_sinh, const long gp, + const double temperature, const double *frequencies, + const long triplet[3], const long *triplets_map, + const long *map_q, const long num_band, + const double cutoff_frequency) { + long i, gp2, swapped; + double f; - /* This assumes the algorithm of get_ir_triplets_at_q_perm_q1q2, */ - /* where defined triplets_map[gp] == triplets_map[map_q[gp]]. */ - /* If triplets_map[map_q[gp]] != map_q[gp], q1 and q2 are permuted. */ - if (triplets_map[gp] == map_q[gp]) - { - gp2 = triplet[2]; - } - else - { - gp2 = triplet[1]; - } + /* This assumes the algorithm of get_ir_triplets_at_q_perm_q1q2, */ + /* where defined triplets_map[gp] == triplets_map[map_q[gp]]. */ + /* If triplets_map[map_q[gp]] != map_q[gp], q1 and q2 are permuted. */ + if (triplets_map[gp] == map_q[gp]) { + gp2 = triplet[2]; + swapped = 0; + } else { + gp2 = triplet[1]; + swapped = 1; + } - for (i = 0; i < num_band; i++) - { - f = frequencies[gp2 * num_band + i]; - if (f > cutoff_frequency) - { - inv_sinh[i] = phonoc_inv_sinh_occupation(f, temperature); + for (i = 0; i < num_band; i++) { + f = frequencies[gp2 * num_band + i]; + if (f > cutoff_frequency) { + inv_sinh[i] = phonoc_inv_sinh_occupation(f, temperature); + } else { + inv_sinh[i] = 0; + } } - else - { - inv_sinh[i] = 0; - } - } + + return swapped; } /* Symmetrically independent triplets are indexed. */ /* Inverse definition of ir_grid_points in get_BZ_triplets_at_q */ /* in triplet_grid.c. */ -static long *create_gp2tp_map(const long *triplets_map, - const long num_gp) -{ - long i, num_ir; - long *gp2tp_map; +static long *create_gp2tp_map(const long *triplets_map, const long num_gp) { + long i, num_ir; + long *gp2tp_map; - gp2tp_map = (long *)malloc(sizeof(long) * num_gp); - num_ir = 0; - for (i = 0; i < num_gp; i++) - { - if (triplets_map[i] == i) - { - gp2tp_map[i] = num_ir; - num_ir++; + gp2tp_map = (long *)malloc(sizeof(long) * num_gp); + num_ir = 0; + for (i = 0; i < num_gp; i++) { + if (triplets_map[i] == i) { + gp2tp_map[i] = num_ir; + num_ir++; + } else { /* This should not be used. */ + gp2tp_map[i] = -1; + } } - else - { /* This should not be used. */ - gp2tp_map[i] = -1; - } - } - return gp2tp_map; + return gp2tp_map; } diff --git a/phono3py/phonon3/collision_matrix.py b/phono3py/phonon3/collision_matrix.py index 91533abb..86e82557 100644 --- a/phono3py/phonon3/collision_matrix.py +++ b/phono3py/phonon3/collision_matrix.py @@ -181,55 +181,129 @@ class CollisionMatrix(ImagSelfEnergy): ) def _run_py_collision_matrix(self): + r"""Sum over rotations, and q-points and bands for third phonons. + + \Omega' = \sum_R' R' \Omega_{kp,R'k'p'} + + pp_strength.shape = (num_triplets, num_band0, num_band, num_band) + + """ num_band0 = self._pp_strength.shape[1] num_band = self._pp_strength.shape[2] - gp2tp_map = self._get_gp2tp_map() + gp2tp, tp2s, swapped = self._get_gp2tp_map() for i in range(self._num_ir_grid_points): r_gps = self._rot_grid_points[i] for r, r_gp in zip(self._rotations_cartesian, r_gps): - ti = gp2tp_map[self._triplets_map_at_q[r_gp]] - inv_sinh = self._get_inv_sinh(r_gp, gp2tp_map) - for j, k in list(np.ndindex((num_band0, num_band))): - collision = ( - self._pp_strength[ti, j, k] * inv_sinh * self._g[2, ti, j, k] - ).sum() + inv_sinh = self._get_inv_sinh(tp2s[r_gp]) + ti = gp2tp[r_gp] + for j, k in np.ndindex((num_band0, num_band)): + if swapped[r_gp]: + collision = ( + self._pp_strength[ti, j, :, k] + * inv_sinh + * self._g[2, ti, j, :, k] + ).sum() + else: + collision = ( + self._pp_strength[ti, j, k] + * inv_sinh + * self._g[2, ti, j, k] + ).sum() collision *= self._unit_conversion self._collision_matrix[j, :, i, k, :] += collision * r def _run_py_reducible_collision_matrix(self): + r"""Sum over q-points and bands of third phonons. + + This corresponds to the second term of right hand side of + \Omega_{q0p0, q1p1} in Chaput's paper. + + pp_strength.shape = (num_triplets, num_band0, num_band, num_band) + + """ num_mesh_points = np.prod(self._pp.mesh_numbers) num_band0 = self._pp_strength.shape[1] num_band = self._pp_strength.shape[2] - gp2tp_map = self._get_gp2tp_map() - - for i in range(num_mesh_points): - ti = gp2tp_map[self._triplets_map_at_q[i]] - inv_sinh = self._get_inv_sinh(i, gp2tp_map) - for j, k in list(np.ndindex((num_band0, num_band))): - collision = ( - self._pp_strength[ti, j, k] * inv_sinh * self._g[2, ti, j, k] - ).sum() + gp2tp, tp2s, swapped = self._get_gp2tp_map() + for gp1 in range(num_mesh_points): + inv_sinh = self._get_inv_sinh(tp2s[gp1]) + ti = gp2tp[gp1] + for j, k in np.ndindex((num_band0, num_band)): + if swapped[gp1]: + collision = ( + self._pp_strength[ti, j, :, k] + * inv_sinh + * self._g[2, ti, j, :, k] + ).sum() + else: + collision = ( + self._pp_strength[ti, j, k] * inv_sinh * self._g[2, ti, j, k] + ).sum() collision *= self._unit_conversion - self._collision_matrix[j, i, k] += collision + self._collision_matrix[j, gp1, k] += collision def _get_gp2tp_map(self): - gp2tp_map = {} - count = 0 - for i, j in enumerate(self._triplets_map_at_q): - if i == j: - gp2tp_map[i] = count - count += 1 + """Return mapping table from grid point index to triplet index. - return gp2tp_map + triplets_map_at_q contains index mapping of q1 in (q0, q1, q2) to + independet q1 under q0+q1+q2=G with a fixed q0. - def _get_inv_sinh(self, gp, gp2tp_map): - ti = gp2tp_map[self._triplets_map_at_q[gp]] - tp = self._triplets_at_q[ti] - if self._triplets_map_at_q[gp] == self._ir_map_at_q[gp]: - gp2 = tp[2] - else: - gp2 = tp[1] - freqs = self._frequencies[gp2] + Note + ---- + map_q[gp1] <= gp1.: + Symmetry relation of grid poi nts with a stabilizer q0. + map_triplets[gp1] <= gp1 : + map_q[gp1] == gp1 : map_q[gp2] if map_q[gp2] < gp1 otherwise gp1. + map_q[gp1] != gp1 : map_triplets[map_q[gp1]] + + + + As a rule + 1. map_triplets[gp1] == gp1 : [gp0, gp1, gp2] + 2. map_triplets[gp1] != gp1 : [gp0, map_q[gp2], gp1'], + map_triplets[gp1] == map_q[gp2] + + """ + map_triplets = self._triplets_map_at_q + map_q = self._ir_map_at_q + gp2tp = -np.ones(len(map_triplets), dtype="int_") + tp2s = -np.ones(len(map_triplets), dtype="int_") + swapped = np.zeros(len(map_triplets), dtype="bytes") + num_tps = 0 + + bzg2grg = self._pp.bz_grid.bzg2grg + + for gp1, tp_gp1 in enumerate(map_triplets): + if map_q[gp1] == gp1: + if gp1 == tp_gp1: + gp2tp[gp1] = num_tps + tp2s[gp1] = self._triplets_at_q[num_tps][2] + assert bzg2grg[self._triplets_at_q[num_tps][1]] == gp1 + num_tps += 1 + else: # q1 <--> q2 swap if swappable. + gp2tp[gp1] = gp2tp[tp_gp1] + tp2s[gp1] = self._triplets_at_q[gp2tp[gp1]][1] + swapped[gp1] = 1 + assert map_q[bzg2grg[self._triplets_at_q[gp2tp[gp1]][2]]] == gp1 + else: # q1 is not in ir-q1s. + gp2tp[gp1] = gp2tp[map_q[gp1]] + tp2s[gp1] = tp2s[map_q[gp1]] + swapped[gp1] = swapped[map_q[gp1]] + + # Alternative implementation of tp2s + # grg2bzg = self._pp.bz_grid.grg2bzg + # addresses = self._pp.bz_grid.addresses + # q0 = addresses[self._triplets_at_q[0][0]] + # q1 = addresses[grg2bzg[gp1]] + # q2 = -q0 - q1 + # gp2 = get_grid_point_from_address(q2, self._pp.bz_grid.D_diag) + # tp2s[gp1] = self._pp.bz_grid.grg2bzg[gp2] + + return gp2tp, tp2s, swapped + + def _get_inv_sinh(self, gp): + """Return sinh term for bands at a q-point.""" + freqs = self._frequencies[gp] sinh = np.where( freqs > self._cutoff_frequency, np.sinh(freqs * THzToEv / (2 * Kb * self._temperature)), From 69122431e767dc9dde31f213851c271b62ebdb62 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Tue, 2 Nov 2021 22:08:54 +0900 Subject: [PATCH 31/34] Refactoring --- c/_lapackepy.c | 174 +- c/_phono3py.c | 3859 +++++++++++-------------- c/_phononmod.c | 362 +-- c/bzgrid.c | 824 ++---- c/bzgrid.h | 55 +- c/collision_matrix.h | 39 +- c/dynmat.c | 1022 +++---- c/dynmat.h | 68 +- c/fc3.c | 1007 +++---- c/fc3.h | 36 +- c/grgrid.c | 489 ++-- c/grgrid.h | 37 +- c/gridsys.c | 369 +-- c/gridsys.h | 154 +- c/imag_self_energy_with_g.c | 809 +++--- c/imag_self_energy_with_g.h | 65 +- c/interaction.c | 576 ++-- c/interaction.h | 56 +- c/isotope.c | 342 +-- c/isotope.h | 36 +- c/lagrid.c | 405 ++- c/lagrid.h | 26 +- c/lapack_wrapper.c | 309 +- c/lapack_wrapper.h | 30 +- c/phono3py.c | 1382 ++++----- c/phono3py.h | 407 +-- c/phonoc_array.h | 8 +- c/phonoc_utils.c | 21 +- c/phonon.c | 1003 +++---- c/phonon.h | 74 +- c/phononmod.c | 115 +- c/phononmod.h | 41 +- c/pp_collision.c | 615 ++-- c/pp_collision.h | 63 +- c/real_self_energy.c | 390 +-- c/real_self_energy.h | 32 +- c/real_to_reciprocal.c | 484 ++-- c/real_to_reciprocal.h | 14 +- c/reciprocal_to_normal.c | 209 +- c/reciprocal_to_normal.h | 24 +- c/snf3x3.c | 736 +++-- c/snf3x3.h | 2 +- c/tetrahedron_method.c | 1340 ++++----- c/triplet.c | 242 +- c/triplet.h | 61 +- c/triplet_grid.c | 819 +++--- c/triplet_grid.h | 13 +- c/triplet_iw.c | 566 ++-- c/triplet_iw.h | 52 +- phono3py/api_phono3py.py | 1 + phono3py/phonon/grid.py | 7 +- phono3py/phonon3/conductivity.py | 4 - phono3py/phonon3/conductivity_LBTE.py | 52 +- phono3py/phonon3/conductivity_RTA.py | 4 +- phono3py/phonon3/displacement_fc3.py | 4 +- phono3py/phonon3/fc3.py | 14 +- phono3py/phonon3/interaction.py | 2 +- phono3py/phonon3/triplets.py | 2 +- scripts/phono3py-coleigplot | 2 +- 59 files changed, 7984 insertions(+), 11970 deletions(-) diff --git a/c/_lapackepy.c b/c/_lapackepy.c index 6fd9bc60..e166bfb8 100644 --- a/c/_lapackepy.c +++ b/c/_lapackepy.c @@ -33,17 +33,17 @@ /* POSSIBILITY OF SUCH DAMAGE. */ #include -#include #include #include +#include + #include "lapack_wrapper.h" static PyObject *py_phonopy_pinv(PyObject *self, PyObject *args); static PyObject *py_phonopy_zheev(PyObject *self, PyObject *args); -struct module_state -{ - PyObject *error; +struct module_state { + PyObject *error; }; #if PY_MAJOR_VERSION >= 3 @@ -53,50 +53,39 @@ struct module_state static struct module_state _state; #endif -static PyObject * -error_out(PyObject *m) -{ - struct module_state *st = GETSTATE(m); - PyErr_SetString(st->error, "something bad happened"); - return NULL; +static PyObject *error_out(PyObject *m) { + struct module_state *st = GETSTATE(m); + PyErr_SetString(st->error, "something bad happened"); + return NULL; } static PyMethodDef _lapackepy_methods[] = { {"error_out", (PyCFunction)error_out, METH_NOARGS, NULL}, - {"pinv", py_phonopy_pinv, METH_VARARGS, "Pseudo-inverse using Lapack dgesvd"}, + {"pinv", py_phonopy_pinv, METH_VARARGS, + "Pseudo-inverse using Lapack dgesvd"}, {"zheev", py_phonopy_zheev, METH_VARARGS, "Lapack zheev wrapper"}, {NULL, NULL, 0, NULL}}; #if PY_MAJOR_VERSION >= 3 -static int _lapackepy_traverse(PyObject *m, visitproc visit, void *arg) -{ - Py_VISIT(GETSTATE(m)->error); - return 0; +static int _lapackepy_traverse(PyObject *m, visitproc visit, void *arg) { + Py_VISIT(GETSTATE(m)->error); + return 0; } -static int _lapackepy_clear(PyObject *m) -{ - Py_CLEAR(GETSTATE(m)->error); - return 0; +static int _lapackepy_clear(PyObject *m) { + Py_CLEAR(GETSTATE(m)->error); + return 0; } static struct PyModuleDef moduledef = { - PyModuleDef_HEAD_INIT, - "_lapackepy", - NULL, - sizeof(struct module_state), - _lapackepy_methods, - NULL, - _lapackepy_traverse, - _lapackepy_clear, - NULL}; + PyModuleDef_HEAD_INIT, "_lapackepy", NULL, + sizeof(struct module_state), _lapackepy_methods, NULL, + _lapackepy_traverse, _lapackepy_clear, NULL}; #define INITERROR return NULL -PyObject * -PyInit__lapackepy(void) - +PyObject *PyInit__lapackepy(void) #else #define INITERROR return @@ -104,96 +93,83 @@ void init_lapackepy(void) #endif { #if PY_MAJOR_VERSION >= 3 - PyObject *module = PyModule_Create(&moduledef); + PyObject *module = PyModule_Create(&moduledef); #else - PyObject *module = Py_InitModule("_lapackepy", _lapackepy_methods); + PyObject *module = Py_InitModule("_lapackepy", _lapackepy_methods); #endif - struct module_state *st; + struct module_state *st; - if (module == NULL) - INITERROR; - st = GETSTATE(module); + if (module == NULL) INITERROR; + st = GETSTATE(module); - st->error = PyErr_NewException("_lapackepy.Error", NULL, NULL); - if (st->error == NULL) - { - Py_DECREF(module); - INITERROR; - } + st->error = PyErr_NewException("_lapackepy.Error", NULL, NULL); + if (st->error == NULL) { + Py_DECREF(module); + INITERROR; + } #if PY_MAJOR_VERSION >= 3 - return module; + return module; #endif } -static PyObject *py_phonopy_zheev(PyObject *self, PyObject *args) -{ - PyArrayObject *dynamical_matrix; - PyArrayObject *eigenvalues; +static PyObject *py_phonopy_zheev(PyObject *self, PyObject *args) { + PyArrayObject *dynamical_matrix; + PyArrayObject *eigenvalues; - int dimension; - npy_cdouble *dynmat; - double *eigvals; - lapack_complex_double *a; - int i, info; + int dimension; + npy_cdouble *dynmat; + double *eigvals; + lapack_complex_double *a; + int i, info; - if (!PyArg_ParseTuple(args, "OO", - &dynamical_matrix, - &eigenvalues)) - { - return NULL; - } + if (!PyArg_ParseTuple(args, "OO", &dynamical_matrix, &eigenvalues)) { + return NULL; + } - dimension = (int)PyArray_DIMS(dynamical_matrix)[0]; - dynmat = (npy_cdouble *)PyArray_DATA(dynamical_matrix); - eigvals = (double *)PyArray_DATA(eigenvalues); + dimension = (int)PyArray_DIMS(dynamical_matrix)[0]; + dynmat = (npy_cdouble *)PyArray_DATA(dynamical_matrix); + eigvals = (double *)PyArray_DATA(eigenvalues); - a = (lapack_complex_double *)malloc(sizeof(lapack_complex_double) * - dimension * dimension); - for (i = 0; i < dimension * dimension; i++) - { - a[i] = lapack_make_complex_double(dynmat[i].real, dynmat[i].imag); - } + a = (lapack_complex_double *)malloc(sizeof(lapack_complex_double) * + dimension * dimension); + for (i = 0; i < dimension * dimension; i++) { + a[i] = lapack_make_complex_double(dynmat[i].real, dynmat[i].imag); + } - info = phonopy_zheev(eigvals, a, dimension, 'L'); + info = phonopy_zheev(eigvals, a, dimension, 'L'); - for (i = 0; i < dimension * dimension; i++) - { - dynmat[i].real = lapack_complex_double_real(a[i]); - dynmat[i].imag = lapack_complex_double_imag(a[i]); - } + for (i = 0; i < dimension * dimension; i++) { + dynmat[i].real = lapack_complex_double_real(a[i]); + dynmat[i].imag = lapack_complex_double_imag(a[i]); + } - free(a); + free(a); - return PyLong_FromLong((long)info); + return PyLong_FromLong((long)info); } -static PyObject *py_phonopy_pinv(PyObject *self, PyObject *args) -{ - PyArrayObject *data_in_py; - PyArrayObject *data_out_py; - double cutoff; +static PyObject *py_phonopy_pinv(PyObject *self, PyObject *args) { + PyArrayObject *data_in_py; + PyArrayObject *data_out_py; + double cutoff; - int m; - int n; - double *data_in; - double *data_out; - int info; + int m; + int n; + double *data_in; + double *data_out; + int info; - if (!PyArg_ParseTuple(args, "OOd", - &data_out_py, - &data_in_py, - &cutoff)) - { - return NULL; - } + if (!PyArg_ParseTuple(args, "OOd", &data_out_py, &data_in_py, &cutoff)) { + return NULL; + } - m = (int)PyArray_DIMS(data_in_py)[0]; - n = (int)PyArray_DIMS(data_in_py)[1]; - data_in = (double *)PyArray_DATA(data_in_py); - data_out = (double *)PyArray_DATA(data_out_py); + m = (int)PyArray_DIMS(data_in_py)[0]; + n = (int)PyArray_DIMS(data_in_py)[1]; + data_in = (double *)PyArray_DATA(data_in_py); + data_out = (double *)PyArray_DATA(data_out_py); - info = phonopy_pinv(data_out, data_in, m, n, cutoff); + info = phonopy_pinv(data_out, data_in, m, n, cutoff); - return PyLong_FromLong((long)info); + return PyLong_FromLong((long)info); } diff --git a/c/_phono3py.c b/c/_phono3py.c index 894056a8..999952bd 100644 --- a/c/_phono3py.c +++ b/c/_phono3py.c @@ -34,23 +34,22 @@ #include #include -#include -#include -#include #include #include +#include +#include +#include + #include "lapack_wrapper.h" #include "phono3py.h" #include "phonoc_array.h" static PyObject *py_get_interaction(PyObject *self, PyObject *args); static PyObject *py_get_pp_collision(PyObject *self, PyObject *args); -static PyObject * -py_get_pp_collision_with_sigma(PyObject *self, PyObject *args); -static PyObject * -py_get_imag_self_energy_with_g(PyObject *self, PyObject *args); -static PyObject * -py_get_detailed_imag_self_energy_with_g(PyObject *self, PyObject *args); +static PyObject *py_get_pp_collision_with_sigma(PyObject *self, PyObject *args); +static PyObject *py_get_imag_self_energy_with_g(PyObject *self, PyObject *args); +static PyObject *py_get_detailed_imag_self_energy_with_g(PyObject *self, + PyObject *args); static PyObject *py_get_real_self_energy_at_bands(PyObject *self, PyObject *args); static PyObject *py_get_real_self_energy_at_frequency_point(PyObject *self, @@ -58,60 +57,51 @@ static PyObject *py_get_real_self_energy_at_frequency_point(PyObject *self, static PyObject *py_get_collision_matrix(PyObject *self, PyObject *args); static PyObject *py_get_reducible_collision_matrix(PyObject *self, PyObject *args); -static PyObject *py_symmetrize_collision_matrix(PyObject *self, - PyObject *args); +static PyObject *py_symmetrize_collision_matrix(PyObject *self, PyObject *args); static PyObject *py_expand_collision_matrix(PyObject *self, PyObject *args); static PyObject *py_distribute_fc3(PyObject *self, PyObject *args); static PyObject *py_rotate_delta_fc2s(PyObject *self, PyObject *args); static PyObject *py_get_isotope_strength(PyObject *self, PyObject *args); static PyObject *py_get_thm_isotope_strength(PyObject *self, PyObject *args); -static PyObject * -py_get_permutation_symmetry_fc3(PyObject *self, PyObject *args); -static PyObject * -py_get_permutation_symmetry_compact_fc3(PyObject *self, PyObject *args); +static PyObject *py_get_permutation_symmetry_fc3(PyObject *self, + PyObject *args); +static PyObject *py_get_permutation_symmetry_compact_fc3(PyObject *self, + PyObject *args); static PyObject *py_transpose_compact_fc3(PyObject *self, PyObject *args); static PyObject *py_get_neighboring_grid_points(PyObject *self, PyObject *args); -static PyObject * -py_get_thm_integration_weights_at_grid_points(PyObject *self, PyObject *args); -static PyObject * -py_tpl_get_triplets_reciprocal_mesh_at_q(PyObject *self, PyObject *args); +static PyObject *py_get_thm_integration_weights_at_grid_points(PyObject *self, + PyObject *args); +static PyObject *py_tpl_get_triplets_reciprocal_mesh_at_q(PyObject *self, + PyObject *args); static PyObject *py_tpl_get_BZ_triplets_at_q(PyObject *self, PyObject *args); -static PyObject * -py_get_triplets_integration_weights(PyObject *self, PyObject *args); -static PyObject * -py_get_triplets_integration_weights_with_sigma(PyObject *self, PyObject *args); -static PyObject * -py_get_grid_index_from_address(PyObject *self, PyObject *args); -static PyObject * -py_get_gr_grid_addresses(PyObject *self, PyObject *args); +static PyObject *py_get_triplets_integration_weights(PyObject *self, + PyObject *args); +static PyObject *py_get_triplets_integration_weights_with_sigma(PyObject *self, + PyObject *args); +static PyObject *py_get_grid_index_from_address(PyObject *self, PyObject *args); +static PyObject *py_get_gr_grid_addresses(PyObject *self, PyObject *args); static PyObject *py_get_reciprocal_rotations(PyObject *self, PyObject *args); static PyObject *py_transform_rotations(PyObject *self, PyObject *args); -static PyObject * -py_get_snf3x3(PyObject *self, PyObject *args); -static PyObject * -py_get_ir_grid_map(PyObject *self, PyObject *args); +static PyObject *py_get_snf3x3(PyObject *self, PyObject *args); +static PyObject *py_get_ir_grid_map(PyObject *self, PyObject *args); static PyObject *py_get_bz_grid_addresses(PyObject *self, PyObject *args); static PyObject *py_rotate_bz_grid_addresses(PyObject *self, PyObject *args); -static PyObject * -py_diagonalize_collision_matrix(PyObject *self, PyObject *args); +static PyObject *py_diagonalize_collision_matrix(PyObject *self, + PyObject *args); static PyObject *py_pinv_from_eigensolution(PyObject *self, PyObject *args); static PyObject *py_get_default_colmat_solver(PyObject *self, PyObject *args); -static void pinv_from_eigensolution(double *data, - const double *eigvals, - const long size, - const double cutoff, +static void pinv_from_eigensolution(double *data, const double *eigvals, + const long size, const double cutoff, const long pinv_method); static void show_colmat_info(const PyArrayObject *collision_matrix_py, - const long i_sigma, - const long i_temp, + const long i_sigma, const long i_temp, const long adrs_shift); static Larray *convert_to_larray(const PyArrayObject *npyary); static Darray *convert_to_darray(const PyArrayObject *npyary); -struct module_state -{ - PyObject *error; +struct module_state { + PyObject *error; }; #if PY_MAJOR_VERSION >= 3 @@ -121,188 +111,118 @@ struct module_state static struct module_state _state; #endif -static PyObject * -error_out(PyObject *m) -{ - struct module_state *st = GETSTATE(m); - PyErr_SetString(st->error, "something bad happened"); - return NULL; +static PyObject *error_out(PyObject *m) { + struct module_state *st = GETSTATE(m); + PyErr_SetString(st->error, "something bad happened"); + return NULL; } static PyMethodDef _phono3py_methods[] = { {"error_out", (PyCFunction)error_out, METH_NOARGS, NULL}, - {"interaction", - (PyCFunction)py_get_interaction, - METH_VARARGS, + {"interaction", (PyCFunction)py_get_interaction, METH_VARARGS, "Interaction of triplets"}, - {"pp_collision", - (PyCFunction)py_get_pp_collision, - METH_VARARGS, + {"pp_collision", (PyCFunction)py_get_pp_collision, METH_VARARGS, "Collision and ph-ph calculation"}, - {"pp_collision_with_sigma", - (PyCFunction)py_get_pp_collision_with_sigma, - METH_VARARGS, - "Collision and ph-ph calculation for smearing method"}, - {"imag_self_energy_with_g", - (PyCFunction)py_get_imag_self_energy_with_g, - METH_VARARGS, - "Imaginary part of self energy at frequency points with g"}, + {"pp_collision_with_sigma", (PyCFunction)py_get_pp_collision_with_sigma, + METH_VARARGS, "Collision and ph-ph calculation for smearing method"}, + {"imag_self_energy_with_g", (PyCFunction)py_get_imag_self_energy_with_g, + METH_VARARGS, "Imaginary part of self energy at frequency points with g"}, {"detailed_imag_self_energy_with_g", - (PyCFunction)py_get_detailed_imag_self_energy_with_g, - METH_VARARGS, - "Detailed contribution to imaginary part of self energy at frequency points with g"}, - {"real_self_energy_at_bands", - (PyCFunction)py_get_real_self_energy_at_bands, - METH_VARARGS, - "Real part of self energy from third order force constants"}, + (PyCFunction)py_get_detailed_imag_self_energy_with_g, METH_VARARGS, + "Detailed contribution to imaginary part of self energy at frequency " + "points with g"}, + {"real_self_energy_at_bands", (PyCFunction)py_get_real_self_energy_at_bands, + METH_VARARGS, "Real part of self energy from third order force constants"}, {"real_self_energy_at_frequency_point", - (PyCFunction)py_get_real_self_energy_at_frequency_point, - METH_VARARGS, - "Real part of self energy from third order force constants at a frequency point"}, - {"collision_matrix", - (PyCFunction)py_get_collision_matrix, - METH_VARARGS, + (PyCFunction)py_get_real_self_energy_at_frequency_point, METH_VARARGS, + "Real part of self energy from third order force constants at a frequency " + "point"}, + {"collision_matrix", (PyCFunction)py_get_collision_matrix, METH_VARARGS, "Collision matrix with g"}, {"reducible_collision_matrix", - (PyCFunction)py_get_reducible_collision_matrix, - METH_VARARGS, + (PyCFunction)py_get_reducible_collision_matrix, METH_VARARGS, "Collision matrix with g for reducible grid points"}, - {"symmetrize_collision_matrix", - (PyCFunction)py_symmetrize_collision_matrix, - METH_VARARGS, - "Symmetrize collision matrix"}, - {"expand_collision_matrix", - (PyCFunction)py_expand_collision_matrix, - METH_VARARGS, - "Expand collision matrix"}, - {"distribute_fc3", - (PyCFunction)py_distribute_fc3, - METH_VARARGS, + {"symmetrize_collision_matrix", (PyCFunction)py_symmetrize_collision_matrix, + METH_VARARGS, "Symmetrize collision matrix"}, + {"expand_collision_matrix", (PyCFunction)py_expand_collision_matrix, + METH_VARARGS, "Expand collision matrix"}, + {"distribute_fc3", (PyCFunction)py_distribute_fc3, METH_VARARGS, "Distribute least fc3 to full fc3"}, - {"rotate_delta_fc2s", - (PyCFunction)py_rotate_delta_fc2s, - METH_VARARGS, + {"rotate_delta_fc2s", (PyCFunction)py_rotate_delta_fc2s, METH_VARARGS, "Rotate delta fc2s"}, - {"isotope_strength", - (PyCFunction)py_get_isotope_strength, - METH_VARARGS, + {"isotope_strength", (PyCFunction)py_get_isotope_strength, METH_VARARGS, "Isotope scattering strength"}, - {"thm_isotope_strength", - (PyCFunction)py_get_thm_isotope_strength, - METH_VARARGS, - "Isotope scattering strength for tetrahedron_method"}, - {"permutation_symmetry_fc3", - (PyCFunction)py_get_permutation_symmetry_fc3, - METH_VARARGS, - "Set permutation symmetry for fc3"}, + {"thm_isotope_strength", (PyCFunction)py_get_thm_isotope_strength, + METH_VARARGS, "Isotope scattering strength for tetrahedron_method"}, + {"permutation_symmetry_fc3", (PyCFunction)py_get_permutation_symmetry_fc3, + METH_VARARGS, "Set permutation symmetry for fc3"}, {"permutation_symmetry_compact_fc3", - (PyCFunction)py_get_permutation_symmetry_compact_fc3, - METH_VARARGS, + (PyCFunction)py_get_permutation_symmetry_compact_fc3, METH_VARARGS, "Set permutation symmetry for compact-fc3"}, - {"transpose_compact_fc3", - (PyCFunction)py_transpose_compact_fc3, - METH_VARARGS, - "Transpose compact fc3"}, - {"neighboring_grid_points", - (PyCFunction)py_get_neighboring_grid_points, - METH_VARARGS, - "Neighboring grid points by relative grid addresses"}, + {"transpose_compact_fc3", (PyCFunction)py_transpose_compact_fc3, + METH_VARARGS, "Transpose compact fc3"}, + {"neighboring_grid_points", (PyCFunction)py_get_neighboring_grid_points, + METH_VARARGS, "Neighboring grid points by relative grid addresses"}, {"integration_weights_at_grid_points", - (PyCFunction)py_get_thm_integration_weights_at_grid_points, - METH_VARARGS, + (PyCFunction)py_get_thm_integration_weights_at_grid_points, METH_VARARGS, "Integration weights of tetrahedron method at grid points"}, {"triplets_reciprocal_mesh_at_q", - (PyCFunction)py_tpl_get_triplets_reciprocal_mesh_at_q, - METH_VARARGS, + (PyCFunction)py_tpl_get_triplets_reciprocal_mesh_at_q, METH_VARARGS, "Triplets on reciprocal mesh points at a specific q-point"}, - {"BZ_triplets_at_q", - (PyCFunction)py_tpl_get_BZ_triplets_at_q, - METH_VARARGS, - "Triplets in reciprocal primitive lattice are transformed to those in BZ."}, + {"BZ_triplets_at_q", (PyCFunction)py_tpl_get_BZ_triplets_at_q, METH_VARARGS, + "Triplets in reciprocal primitive lattice are transformed to those in " + "BZ."}, {"triplets_integration_weights", - (PyCFunction)py_get_triplets_integration_weights, - METH_VARARGS, + (PyCFunction)py_get_triplets_integration_weights, METH_VARARGS, "Integration weights of tetrahedron method for triplets"}, {"triplets_integration_weights_with_sigma", - (PyCFunction)py_get_triplets_integration_weights_with_sigma, - METH_VARARGS, + (PyCFunction)py_get_triplets_integration_weights_with_sigma, METH_VARARGS, "Integration weights of smearing method for triplets"}, - {"grid_index_from_address", - (PyCFunction)py_get_grid_index_from_address, - METH_VARARGS, - "Grid index from grid address"}, - {"ir_grid_map", - (PyCFunction)py_get_ir_grid_map, - METH_VARARGS, + {"grid_index_from_address", (PyCFunction)py_get_grid_index_from_address, + METH_VARARGS, "Grid index from grid address"}, + {"ir_grid_map", (PyCFunction)py_get_ir_grid_map, METH_VARARGS, "Reciprocal mesh points with ir grid mapping table"}, - {"gr_grid_addresses", - (PyCFunction)py_get_gr_grid_addresses, - METH_VARARGS, + {"gr_grid_addresses", (PyCFunction)py_get_gr_grid_addresses, METH_VARARGS, "Get generalized regular grid addresses"}, - {"reciprocal_rotations", - (PyCFunction)py_get_reciprocal_rotations, - METH_VARARGS, - "Return rotation matrices in reciprocal space"}, - {"transform_rotations", - (PyCFunction)py_transform_rotations, - METH_VARARGS, + {"reciprocal_rotations", (PyCFunction)py_get_reciprocal_rotations, + METH_VARARGS, "Return rotation matrices in reciprocal space"}, + {"transform_rotations", (PyCFunction)py_transform_rotations, METH_VARARGS, "Transform rotations to those in generalized regular grid"}, - {"snf3x3", - (PyCFunction)py_get_snf3x3, - METH_VARARGS, + {"snf3x3", (PyCFunction)py_get_snf3x3, METH_VARARGS, "Get Smith formal form for 3x3 integer matrix"}, - {"bz_grid_addresses", - (PyCFunction)py_get_bz_grid_addresses, - METH_VARARGS, + {"bz_grid_addresses", (PyCFunction)py_get_bz_grid_addresses, METH_VARARGS, "Get grid addresses including Brillouin zone surface"}, - {"rotate_bz_grid_index", - (PyCFunction)py_rotate_bz_grid_addresses, - METH_VARARGS, - "Rotate grid point considering Brillouin zone surface"}, + {"rotate_bz_grid_index", (PyCFunction)py_rotate_bz_grid_addresses, + METH_VARARGS, "Rotate grid point considering Brillouin zone surface"}, {"diagonalize_collision_matrix", - (PyCFunction)py_diagonalize_collision_matrix, - METH_VARARGS, + (PyCFunction)py_diagonalize_collision_matrix, METH_VARARGS, "Diagonalize and optionally pseudo-inverse using Lapack dsyev(d)"}, - {"pinv_from_eigensolution", - (PyCFunction)py_pinv_from_eigensolution, - METH_VARARGS, - "Pseudo-inverse from eigensolution"}, - {"default_colmat_solver", - (PyCFunction)py_get_default_colmat_solver, - METH_VARARGS, - "Return default collison matrix solver by integer value"}, + {"pinv_from_eigensolution", (PyCFunction)py_pinv_from_eigensolution, + METH_VARARGS, "Pseudo-inverse from eigensolution"}, + {"default_colmat_solver", (PyCFunction)py_get_default_colmat_solver, + METH_VARARGS, "Return default collison matrix solver by integer value"}, {NULL, NULL, 0, NULL}}; #if PY_MAJOR_VERSION >= 3 -static int _phono3py_traverse(PyObject *m, visitproc visit, void *arg) -{ - Py_VISIT(GETSTATE(m)->error); - return 0; +static int _phono3py_traverse(PyObject *m, visitproc visit, void *arg) { + Py_VISIT(GETSTATE(m)->error); + return 0; } -static int _phono3py_clear(PyObject *m) -{ - Py_CLEAR(GETSTATE(m)->error); - return 0; +static int _phono3py_clear(PyObject *m) { + Py_CLEAR(GETSTATE(m)->error); + return 0; } static struct PyModuleDef moduledef = { - PyModuleDef_HEAD_INIT, - "_phono3py", - NULL, - sizeof(struct module_state), - _phono3py_methods, - NULL, - _phono3py_traverse, - _phono3py_clear, - NULL}; + PyModuleDef_HEAD_INIT, "_phono3py", NULL, + sizeof(struct module_state), _phono3py_methods, NULL, + _phono3py_traverse, _phono3py_clear, NULL}; #define INITERROR return NULL -PyObject * -PyInit__phono3py(void) - +PyObject *PyInit__phono3py(void) #else #define INITERROR return @@ -310,2158 +230,1637 @@ void init_phono3py(void) #endif { #if PY_MAJOR_VERSION >= 3 - PyObject *module = PyModule_Create(&moduledef); + PyObject *module = PyModule_Create(&moduledef); #else - PyObject *module = Py_InitModule("_phono3py", _phono3py_methods); + PyObject *module = Py_InitModule("_phono3py", _phono3py_methods); #endif - struct module_state *st; + struct module_state *st; - if (module == NULL) - INITERROR; - st = GETSTATE(module); + if (module == NULL) INITERROR; + st = GETSTATE(module); - st->error = PyErr_NewException("_phono3py.Error", NULL, NULL); - if (st->error == NULL) - { - Py_DECREF(module); - INITERROR; - } + st->error = PyErr_NewException("_phono3py.Error", NULL, NULL); + if (st->error == NULL) { + Py_DECREF(module); + INITERROR; + } #if PY_MAJOR_VERSION >= 3 - return module; + return module; #endif } -static PyObject *py_get_interaction(PyObject *self, PyObject *args) -{ - PyArrayObject *py_fc3_normal_squared; - PyArrayObject *py_g_zero; - PyArrayObject *py_frequencies; - PyArrayObject *py_eigenvectors; - PyArrayObject *py_triplets; - PyArrayObject *py_bz_grid_addresses; - PyArrayObject *py_D_diag; - PyArrayObject *py_Q; - PyArrayObject *py_svecs; - PyArrayObject *py_multi; - PyArrayObject *py_fc3; - PyArrayObject *py_masses; - PyArrayObject *py_p2s_map; - PyArrayObject *py_s2p_map; - PyArrayObject *py_band_indices; - double cutoff_frequency; - long symmetrize_fc3_q; +static PyObject *py_get_interaction(PyObject *self, PyObject *args) { + PyArrayObject *py_fc3_normal_squared; + PyArrayObject *py_g_zero; + PyArrayObject *py_frequencies; + PyArrayObject *py_eigenvectors; + PyArrayObject *py_triplets; + PyArrayObject *py_bz_grid_addresses; + PyArrayObject *py_D_diag; + PyArrayObject *py_Q; + PyArrayObject *py_svecs; + PyArrayObject *py_multi; + PyArrayObject *py_fc3; + PyArrayObject *py_masses; + PyArrayObject *py_p2s_map; + PyArrayObject *py_s2p_map; + PyArrayObject *py_band_indices; + double cutoff_frequency; + long symmetrize_fc3_q; - Darray *fc3_normal_squared; - Darray *freqs; - lapack_complex_double *eigvecs; - long(*triplets)[3]; - long num_triplets; - char *g_zero; - long(*bz_grid_addresses)[3]; - long *D_diag; - long(*Q)[3]; - double *fc3; - double(*svecs)[3]; - long(*multi)[2]; - double *masses; - long *p2s; - long *s2p; - long *band_indices; - long multi_dims[2]; - long i; - long is_compact_fc3; + Darray *fc3_normal_squared; + Darray *freqs; + lapack_complex_double *eigvecs; + long(*triplets)[3]; + long num_triplets; + char *g_zero; + long(*bz_grid_addresses)[3]; + long *D_diag; + long(*Q)[3]; + double *fc3; + double(*svecs)[3]; + long(*multi)[2]; + double *masses; + long *p2s; + long *s2p; + long *band_indices; + long multi_dims[2]; + long i; + long is_compact_fc3; - if (!PyArg_ParseTuple(args, "OOOOOOOOOOOOOOOld", - &py_fc3_normal_squared, - &py_g_zero, - &py_frequencies, - &py_eigenvectors, - &py_triplets, - &py_bz_grid_addresses, - &py_D_diag, - &py_Q, - &py_fc3, - &py_svecs, - &py_multi, - &py_masses, - &py_p2s_map, - &py_s2p_map, - &py_band_indices, - &symmetrize_fc3_q, - &cutoff_frequency)) - { - return NULL; - } + if (!PyArg_ParseTuple(args, "OOOOOOOOOOOOOOOld", &py_fc3_normal_squared, + &py_g_zero, &py_frequencies, &py_eigenvectors, + &py_triplets, &py_bz_grid_addresses, &py_D_diag, + &py_Q, &py_fc3, &py_svecs, &py_multi, &py_masses, + &py_p2s_map, &py_s2p_map, &py_band_indices, + &symmetrize_fc3_q, &cutoff_frequency)) { + return NULL; + } - fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); - freqs = convert_to_darray(py_frequencies); - /* npy_cdouble and lapack_complex_double may not be compatible. */ - /* So eigenvectors should not be used in Python side */ - eigvecs = (lapack_complex_double *)PyArray_DATA(py_eigenvectors); - triplets = (long(*)[3])PyArray_DATA(py_triplets); - num_triplets = (long)PyArray_DIMS(py_triplets)[0]; - g_zero = (char *)PyArray_DATA(py_g_zero); - bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); - D_diag = (long *)PyArray_DATA(py_D_diag); - Q = (long(*)[3])PyArray_DATA(py_Q); - fc3 = (double *)PyArray_DATA(py_fc3); - if (PyArray_DIMS(py_fc3)[0] == PyArray_DIMS(py_fc3)[1]) - { - is_compact_fc3 = 0; - } - else - { - is_compact_fc3 = 1; - } - svecs = (double(*)[3])PyArray_DATA(py_svecs); - for (i = 0; i < 2; i++) - { - multi_dims[i] = PyArray_DIMS(py_multi)[i]; - } - multi = (long(*)[2])PyArray_DATA(py_multi); - masses = (double *)PyArray_DATA(py_masses); - p2s = (long *)PyArray_DATA(py_p2s_map); - s2p = (long *)PyArray_DATA(py_s2p_map); - band_indices = (long *)PyArray_DATA(py_band_indices); + fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); + freqs = convert_to_darray(py_frequencies); + /* npy_cdouble and lapack_complex_double may not be compatible. */ + /* So eigenvectors should not be used in Python side */ + eigvecs = (lapack_complex_double *)PyArray_DATA(py_eigenvectors); + triplets = (long(*)[3])PyArray_DATA(py_triplets); + num_triplets = (long)PyArray_DIMS(py_triplets)[0]; + g_zero = (char *)PyArray_DATA(py_g_zero); + bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); + D_diag = (long *)PyArray_DATA(py_D_diag); + Q = (long(*)[3])PyArray_DATA(py_Q); + fc3 = (double *)PyArray_DATA(py_fc3); + if (PyArray_DIMS(py_fc3)[0] == PyArray_DIMS(py_fc3)[1]) { + is_compact_fc3 = 0; + } else { + is_compact_fc3 = 1; + } + svecs = (double(*)[3])PyArray_DATA(py_svecs); + for (i = 0; i < 2; i++) { + multi_dims[i] = PyArray_DIMS(py_multi)[i]; + } + multi = (long(*)[2])PyArray_DATA(py_multi); + masses = (double *)PyArray_DATA(py_masses); + p2s = (long *)PyArray_DATA(py_p2s_map); + s2p = (long *)PyArray_DATA(py_s2p_map); + band_indices = (long *)PyArray_DATA(py_band_indices); - ph3py_get_interaction(fc3_normal_squared, - g_zero, - freqs, - eigvecs, - triplets, - num_triplets, - bz_grid_addresses, - D_diag, - Q, - fc3, - is_compact_fc3, - svecs, - multi_dims, - multi, - masses, - p2s, - s2p, - band_indices, - symmetrize_fc3_q, - cutoff_frequency); + ph3py_get_interaction(fc3_normal_squared, g_zero, freqs, eigvecs, triplets, + num_triplets, bz_grid_addresses, D_diag, Q, fc3, + is_compact_fc3, svecs, multi_dims, multi, masses, p2s, + s2p, band_indices, symmetrize_fc3_q, + cutoff_frequency); - free(fc3_normal_squared); - fc3_normal_squared = NULL; - free(freqs); - freqs = NULL; + free(fc3_normal_squared); + fc3_normal_squared = NULL; + free(freqs); + freqs = NULL; - Py_RETURN_NONE; + Py_RETURN_NONE; } -static PyObject *py_get_pp_collision(PyObject *self, PyObject *args) -{ - PyArrayObject *py_gamma; - PyArrayObject *py_relative_grid_address; - PyArrayObject *py_frequencies; - PyArrayObject *py_eigenvectors; - PyArrayObject *py_triplets; - PyArrayObject *py_triplet_weights; - PyArrayObject *py_bz_grid_addresses; - PyArrayObject *py_bz_map; - PyArrayObject *py_D_diag; - PyArrayObject *py_Q; - PyArrayObject *py_fc3; - PyArrayObject *py_svecs; - PyArrayObject *py_multi; - PyArrayObject *py_masses; - PyArrayObject *py_p2s_map; - PyArrayObject *py_s2p_map; - PyArrayObject *py_band_indices; - PyArrayObject *py_temperatures; - double cutoff_frequency; - long is_NU; - long symmetrize_fc3_q; - long bz_grid_type; +static PyObject *py_get_pp_collision(PyObject *self, PyObject *args) { + PyArrayObject *py_gamma; + PyArrayObject *py_relative_grid_address; + PyArrayObject *py_frequencies; + PyArrayObject *py_eigenvectors; + PyArrayObject *py_triplets; + PyArrayObject *py_triplet_weights; + PyArrayObject *py_bz_grid_addresses; + PyArrayObject *py_bz_map; + PyArrayObject *py_D_diag; + PyArrayObject *py_Q; + PyArrayObject *py_fc3; + PyArrayObject *py_svecs; + PyArrayObject *py_multi; + PyArrayObject *py_masses; + PyArrayObject *py_p2s_map; + PyArrayObject *py_s2p_map; + PyArrayObject *py_band_indices; + PyArrayObject *py_temperatures; + double cutoff_frequency; + long is_NU; + long symmetrize_fc3_q; + long bz_grid_type; - double *gamma; - long(*relative_grid_address)[4][3]; - double *frequencies; - lapack_complex_double *eigenvectors; - long(*triplets)[3]; - long num_triplets; - long *triplet_weights; - long(*bz_grid_addresses)[3]; - long *bz_map; - long *D_diag; - long(*Q)[3]; - double *fc3; - double(*svecs)[3]; - long(*multi)[2]; - double *masses; - long *p2s; - long *s2p; - Larray *band_indices; - Darray *temperatures; - long multi_dims[2]; - long i; - long is_compact_fc3; + double *gamma; + long(*relative_grid_address)[4][3]; + double *frequencies; + lapack_complex_double *eigenvectors; + long(*triplets)[3]; + long num_triplets; + long *triplet_weights; + long(*bz_grid_addresses)[3]; + long *bz_map; + long *D_diag; + long(*Q)[3]; + double *fc3; + double(*svecs)[3]; + long(*multi)[2]; + double *masses; + long *p2s; + long *s2p; + Larray *band_indices; + Darray *temperatures; + long multi_dims[2]; + long i; + long is_compact_fc3; - if (!PyArg_ParseTuple(args, "OOOOOOOOlOOOOOOOOOOlld", - &py_gamma, - &py_relative_grid_address, - &py_frequencies, - &py_eigenvectors, - &py_triplets, - &py_triplet_weights, - &py_bz_grid_addresses, - &py_bz_map, - &bz_grid_type, - &py_D_diag, - &py_Q, - &py_fc3, - &py_svecs, - &py_multi, - &py_masses, - &py_p2s_map, - &py_s2p_map, - &py_band_indices, - &py_temperatures, - &is_NU, - &symmetrize_fc3_q, - &cutoff_frequency)) - { - return NULL; - } + if (!PyArg_ParseTuple( + args, "OOOOOOOOlOOOOOOOOOOlld", &py_gamma, + &py_relative_grid_address, &py_frequencies, &py_eigenvectors, + &py_triplets, &py_triplet_weights, &py_bz_grid_addresses, + &py_bz_map, &bz_grid_type, &py_D_diag, &py_Q, &py_fc3, &py_svecs, + &py_multi, &py_masses, &py_p2s_map, &py_s2p_map, &py_band_indices, + &py_temperatures, &is_NU, &symmetrize_fc3_q, &cutoff_frequency)) { + return NULL; + } - gamma = (double *)PyArray_DATA(py_gamma); - relative_grid_address = (long(*)[4][3])PyArray_DATA(py_relative_grid_address); - frequencies = (double *)PyArray_DATA(py_frequencies); - eigenvectors = (lapack_complex_double *)PyArray_DATA(py_eigenvectors); - triplets = (long(*)[3])PyArray_DATA(py_triplets); - num_triplets = (long)PyArray_DIMS(py_triplets)[0]; - triplet_weights = (long *)PyArray_DATA(py_triplet_weights); - bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); - bz_map = (long *)PyArray_DATA(py_bz_map); - D_diag = (long *)PyArray_DATA(py_D_diag); - Q = (long(*)[3])PyArray_DATA(py_Q); - fc3 = (double *)PyArray_DATA(py_fc3); - if (PyArray_DIMS(py_fc3)[0] == PyArray_DIMS(py_fc3)[1]) - { - is_compact_fc3 = 0; - } - else - { - is_compact_fc3 = 1; - } - svecs = (double(*)[3])PyArray_DATA(py_svecs); - for (i = 0; i < 2; i++) - { - multi_dims[i] = PyArray_DIMS(py_multi)[i]; - } - multi = (long(*)[2])PyArray_DATA(py_multi); - masses = (double *)PyArray_DATA(py_masses); - p2s = (long *)PyArray_DATA(py_p2s_map); - s2p = (long *)PyArray_DATA(py_s2p_map); - band_indices = convert_to_larray(py_band_indices); - temperatures = convert_to_darray(py_temperatures); + gamma = (double *)PyArray_DATA(py_gamma); + relative_grid_address = + (long(*)[4][3])PyArray_DATA(py_relative_grid_address); + frequencies = (double *)PyArray_DATA(py_frequencies); + eigenvectors = (lapack_complex_double *)PyArray_DATA(py_eigenvectors); + triplets = (long(*)[3])PyArray_DATA(py_triplets); + num_triplets = (long)PyArray_DIMS(py_triplets)[0]; + triplet_weights = (long *)PyArray_DATA(py_triplet_weights); + bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); + bz_map = (long *)PyArray_DATA(py_bz_map); + D_diag = (long *)PyArray_DATA(py_D_diag); + Q = (long(*)[3])PyArray_DATA(py_Q); + fc3 = (double *)PyArray_DATA(py_fc3); + if (PyArray_DIMS(py_fc3)[0] == PyArray_DIMS(py_fc3)[1]) { + is_compact_fc3 = 0; + } else { + is_compact_fc3 = 1; + } + svecs = (double(*)[3])PyArray_DATA(py_svecs); + for (i = 0; i < 2; i++) { + multi_dims[i] = PyArray_DIMS(py_multi)[i]; + } + multi = (long(*)[2])PyArray_DATA(py_multi); + masses = (double *)PyArray_DATA(py_masses); + p2s = (long *)PyArray_DATA(py_p2s_map); + s2p = (long *)PyArray_DATA(py_s2p_map); + band_indices = convert_to_larray(py_band_indices); + temperatures = convert_to_darray(py_temperatures); - ph3py_get_pp_collision(gamma, - relative_grid_address, - frequencies, - eigenvectors, - triplets, - num_triplets, - triplet_weights, - bz_grid_addresses, - bz_map, - bz_grid_type, - D_diag, - Q, - fc3, - is_compact_fc3, - svecs, - multi_dims, - multi, - masses, - p2s, - s2p, - band_indices, - temperatures, - is_NU, - symmetrize_fc3_q, - cutoff_frequency); + ph3py_get_pp_collision( + gamma, relative_grid_address, frequencies, eigenvectors, triplets, + num_triplets, triplet_weights, bz_grid_addresses, bz_map, bz_grid_type, + D_diag, Q, fc3, is_compact_fc3, svecs, multi_dims, multi, masses, p2s, + s2p, band_indices, temperatures, is_NU, symmetrize_fc3_q, + cutoff_frequency); - free(band_indices); - band_indices = NULL; - free(temperatures); - temperatures = NULL; + free(band_indices); + band_indices = NULL; + free(temperatures); + temperatures = NULL; - Py_RETURN_NONE; + Py_RETURN_NONE; } -static PyObject *py_get_pp_collision_with_sigma(PyObject *self, PyObject *args) -{ - PyArrayObject *py_gamma; - PyArrayObject *py_frequencies; - PyArrayObject *py_eigenvectors; - PyArrayObject *py_triplets; - PyArrayObject *py_triplet_weights; - PyArrayObject *py_bz_grid_addresses; - PyArrayObject *py_D_diag; - PyArrayObject *py_Q; - PyArrayObject *py_fc3; - PyArrayObject *py_svecs; - PyArrayObject *py_multi; - PyArrayObject *py_masses; - PyArrayObject *py_p2s_map; - PyArrayObject *py_s2p_map; - PyArrayObject *py_band_indices; - PyArrayObject *py_temperatures; - long is_NU; - long symmetrize_fc3_q; - double sigma; - double sigma_cutoff; - double cutoff_frequency; +static PyObject *py_get_pp_collision_with_sigma(PyObject *self, + PyObject *args) { + PyArrayObject *py_gamma; + PyArrayObject *py_frequencies; + PyArrayObject *py_eigenvectors; + PyArrayObject *py_triplets; + PyArrayObject *py_triplet_weights; + PyArrayObject *py_bz_grid_addresses; + PyArrayObject *py_D_diag; + PyArrayObject *py_Q; + PyArrayObject *py_fc3; + PyArrayObject *py_svecs; + PyArrayObject *py_multi; + PyArrayObject *py_masses; + PyArrayObject *py_p2s_map; + PyArrayObject *py_s2p_map; + PyArrayObject *py_band_indices; + PyArrayObject *py_temperatures; + long is_NU; + long symmetrize_fc3_q; + double sigma; + double sigma_cutoff; + double cutoff_frequency; - double *gamma; - double *frequencies; - lapack_complex_double *eigenvectors; - long(*triplets)[3]; - long num_triplets; - long *triplet_weights; - long(*bz_grid_addresses)[3]; - long *D_diag; - long(*Q)[3]; - double *fc3; - double(*svecs)[3]; - long(*multi)[2]; - double *masses; - long *p2s; - long *s2p; - Larray *band_indices; - Darray *temperatures; - long multi_dims[2]; - long i; - long is_compact_fc3; + double *gamma; + double *frequencies; + lapack_complex_double *eigenvectors; + long(*triplets)[3]; + long num_triplets; + long *triplet_weights; + long(*bz_grid_addresses)[3]; + long *D_diag; + long(*Q)[3]; + double *fc3; + double(*svecs)[3]; + long(*multi)[2]; + double *masses; + long *p2s; + long *s2p; + Larray *band_indices; + Darray *temperatures; + long multi_dims[2]; + long i; + long is_compact_fc3; - if (!PyArg_ParseTuple(args, "OddOOOOOOOOOOOOOOOlld", - &py_gamma, - &sigma, - &sigma_cutoff, - &py_frequencies, - &py_eigenvectors, - &py_triplets, - &py_triplet_weights, - &py_bz_grid_addresses, - &py_D_diag, - &py_Q, - &py_fc3, - &py_svecs, - &py_multi, - &py_masses, - &py_p2s_map, - &py_s2p_map, - &py_band_indices, - &py_temperatures, - &is_NU, - &symmetrize_fc3_q, - &cutoff_frequency)) - { - return NULL; - } + if (!PyArg_ParseTuple(args, "OddOOOOOOOOOOOOOOOlld", &py_gamma, &sigma, + &sigma_cutoff, &py_frequencies, &py_eigenvectors, + &py_triplets, &py_triplet_weights, + &py_bz_grid_addresses, &py_D_diag, &py_Q, &py_fc3, + &py_svecs, &py_multi, &py_masses, &py_p2s_map, + &py_s2p_map, &py_band_indices, &py_temperatures, + &is_NU, &symmetrize_fc3_q, &cutoff_frequency)) { + return NULL; + } - gamma = (double *)PyArray_DATA(py_gamma); - frequencies = (double *)PyArray_DATA(py_frequencies); - eigenvectors = (lapack_complex_double *)PyArray_DATA(py_eigenvectors); - triplets = (long(*)[3])PyArray_DATA(py_triplets); - num_triplets = (long)PyArray_DIMS(py_triplets)[0]; - triplet_weights = (long *)PyArray_DATA(py_triplet_weights); - bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); - D_diag = (long *)PyArray_DATA(py_D_diag); - Q = (long(*)[3])PyArray_DATA(py_Q); - fc3 = (double *)PyArray_DATA(py_fc3); - if (PyArray_DIMS(py_fc3)[0] == PyArray_DIMS(py_fc3)[1]) - { - is_compact_fc3 = 0; - } - else - { - is_compact_fc3 = 1; - } - svecs = (double(*)[3])PyArray_DATA(py_svecs); - for (i = 0; i < 2; i++) - { - multi_dims[i] = PyArray_DIMS(py_multi)[i]; - } - multi = (long(*)[2])PyArray_DATA(py_multi); - masses = (double *)PyArray_DATA(py_masses); - p2s = (long *)PyArray_DATA(py_p2s_map); - s2p = (long *)PyArray_DATA(py_s2p_map); - band_indices = convert_to_larray(py_band_indices); - temperatures = convert_to_darray(py_temperatures); + gamma = (double *)PyArray_DATA(py_gamma); + frequencies = (double *)PyArray_DATA(py_frequencies); + eigenvectors = (lapack_complex_double *)PyArray_DATA(py_eigenvectors); + triplets = (long(*)[3])PyArray_DATA(py_triplets); + num_triplets = (long)PyArray_DIMS(py_triplets)[0]; + triplet_weights = (long *)PyArray_DATA(py_triplet_weights); + bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); + D_diag = (long *)PyArray_DATA(py_D_diag); + Q = (long(*)[3])PyArray_DATA(py_Q); + fc3 = (double *)PyArray_DATA(py_fc3); + if (PyArray_DIMS(py_fc3)[0] == PyArray_DIMS(py_fc3)[1]) { + is_compact_fc3 = 0; + } else { + is_compact_fc3 = 1; + } + svecs = (double(*)[3])PyArray_DATA(py_svecs); + for (i = 0; i < 2; i++) { + multi_dims[i] = PyArray_DIMS(py_multi)[i]; + } + multi = (long(*)[2])PyArray_DATA(py_multi); + masses = (double *)PyArray_DATA(py_masses); + p2s = (long *)PyArray_DATA(py_p2s_map); + s2p = (long *)PyArray_DATA(py_s2p_map); + band_indices = convert_to_larray(py_band_indices); + temperatures = convert_to_darray(py_temperatures); - ph3py_get_pp_collision_with_sigma(gamma, - sigma, - sigma_cutoff, - frequencies, - eigenvectors, - triplets, - num_triplets, - triplet_weights, - bz_grid_addresses, - D_diag, - Q, - fc3, - is_compact_fc3, - svecs, - multi_dims, - multi, - masses, - p2s, - s2p, - band_indices, - temperatures, - is_NU, - symmetrize_fc3_q, - cutoff_frequency); + ph3py_get_pp_collision_with_sigma( + gamma, sigma, sigma_cutoff, frequencies, eigenvectors, triplets, + num_triplets, triplet_weights, bz_grid_addresses, D_diag, Q, fc3, + is_compact_fc3, svecs, multi_dims, multi, masses, p2s, s2p, + band_indices, temperatures, is_NU, symmetrize_fc3_q, cutoff_frequency); - free(band_indices); - band_indices = NULL; - free(temperatures); - temperatures = NULL; + free(band_indices); + band_indices = NULL; + free(temperatures); + temperatures = NULL; - Py_RETURN_NONE; + Py_RETURN_NONE; } -static PyObject *py_get_imag_self_energy_with_g(PyObject *self, PyObject *args) -{ - PyArrayObject *py_gamma; - PyArrayObject *py_fc3_normal_squared; - PyArrayObject *py_frequencies; - PyArrayObject *py_triplets; - PyArrayObject *py_triplet_weights; - PyArrayObject *py_g; - PyArrayObject *py_g_zero; - double cutoff_frequency, temperature; - long frequency_point_index; +static PyObject *py_get_imag_self_energy_with_g(PyObject *self, + PyObject *args) { + PyArrayObject *py_gamma; + PyArrayObject *py_fc3_normal_squared; + PyArrayObject *py_frequencies; + PyArrayObject *py_triplets; + PyArrayObject *py_triplet_weights; + PyArrayObject *py_g; + PyArrayObject *py_g_zero; + double cutoff_frequency, temperature; + long frequency_point_index; - Darray *fc3_normal_squared; - double *gamma; - double *g; - char *g_zero; - double *frequencies; - long(*triplets)[3]; - long *triplet_weights; - long num_frequency_points; + Darray *fc3_normal_squared; + double *gamma; + double *g; + char *g_zero; + double *frequencies; + long(*triplets)[3]; + long *triplet_weights; + long num_frequency_points; - if (!PyArg_ParseTuple(args, "OOOOOdOOdl", - &py_gamma, - &py_fc3_normal_squared, - &py_triplets, - &py_triplet_weights, - &py_frequencies, - &temperature, - &py_g, - &py_g_zero, - &cutoff_frequency, - &frequency_point_index)) - { - return NULL; - } + if (!PyArg_ParseTuple(args, "OOOOOdOOdl", &py_gamma, &py_fc3_normal_squared, + &py_triplets, &py_triplet_weights, &py_frequencies, + &temperature, &py_g, &py_g_zero, &cutoff_frequency, + &frequency_point_index)) { + return NULL; + } - fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); - gamma = (double *)PyArray_DATA(py_gamma); - g = (double *)PyArray_DATA(py_g); - g_zero = (char *)PyArray_DATA(py_g_zero); - frequencies = (double *)PyArray_DATA(py_frequencies); - triplets = (long(*)[3])PyArray_DATA(py_triplets); - triplet_weights = (long *)PyArray_DATA(py_triplet_weights); - num_frequency_points = (long)PyArray_DIMS(py_g)[2]; + fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); + gamma = (double *)PyArray_DATA(py_gamma); + g = (double *)PyArray_DATA(py_g); + g_zero = (char *)PyArray_DATA(py_g_zero); + frequencies = (double *)PyArray_DATA(py_frequencies); + triplets = (long(*)[3])PyArray_DATA(py_triplets); + triplet_weights = (long *)PyArray_DATA(py_triplet_weights); + num_frequency_points = (long)PyArray_DIMS(py_g)[2]; - ph3py_get_imag_self_energy_at_bands_with_g(gamma, - fc3_normal_squared, - frequencies, - triplets, - triplet_weights, - g, - g_zero, - temperature, - cutoff_frequency, - num_frequency_points, - frequency_point_index); + ph3py_get_imag_self_energy_at_bands_with_g( + gamma, fc3_normal_squared, frequencies, triplets, triplet_weights, g, + g_zero, temperature, cutoff_frequency, num_frequency_points, + frequency_point_index); - free(fc3_normal_squared); - fc3_normal_squared = NULL; + free(fc3_normal_squared); + fc3_normal_squared = NULL; - Py_RETURN_NONE; + Py_RETURN_NONE; } -static PyObject * -py_get_detailed_imag_self_energy_with_g(PyObject *self, PyObject *args) -{ - PyArrayObject *py_gamma_detail; - PyArrayObject *py_gamma_N; - PyArrayObject *py_gamma_U; - PyArrayObject *py_fc3_normal_squared; - PyArrayObject *py_frequencies; - PyArrayObject *py_triplets; - PyArrayObject *py_triplet_weights; - PyArrayObject *py_bz_grid_addresses; - PyArrayObject *py_g; - PyArrayObject *py_g_zero; - double cutoff_frequency, temperature; +static PyObject *py_get_detailed_imag_self_energy_with_g(PyObject *self, + PyObject *args) { + PyArrayObject *py_gamma_detail; + PyArrayObject *py_gamma_N; + PyArrayObject *py_gamma_U; + PyArrayObject *py_fc3_normal_squared; + PyArrayObject *py_frequencies; + PyArrayObject *py_triplets; + PyArrayObject *py_triplet_weights; + PyArrayObject *py_bz_grid_addresses; + PyArrayObject *py_g; + PyArrayObject *py_g_zero; + double cutoff_frequency, temperature; - Darray *fc3_normal_squared; - double *gamma_detail; - double *gamma_N; - double *gamma_U; - double *g; - char *g_zero; - double *frequencies; - long(*triplets)[3]; - long *triplet_weights; - long(*bz_grid_addresses)[3]; + Darray *fc3_normal_squared; + double *gamma_detail; + double *gamma_N; + double *gamma_U; + double *g; + char *g_zero; + double *frequencies; + long(*triplets)[3]; + long *triplet_weights; + long(*bz_grid_addresses)[3]; - if (!PyArg_ParseTuple(args, "OOOOOOOOdOOd", - &py_gamma_detail, - &py_gamma_N, - &py_gamma_U, - &py_fc3_normal_squared, - &py_triplets, - &py_triplet_weights, - &py_bz_grid_addresses, - &py_frequencies, - &temperature, - &py_g, - &py_g_zero, - &cutoff_frequency)) - { - return NULL; - } + if (!PyArg_ParseTuple(args, "OOOOOOOOdOOd", &py_gamma_detail, &py_gamma_N, + &py_gamma_U, &py_fc3_normal_squared, &py_triplets, + &py_triplet_weights, &py_bz_grid_addresses, + &py_frequencies, &temperature, &py_g, &py_g_zero, + &cutoff_frequency)) { + return NULL; + } - fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); - gamma_detail = (double *)PyArray_DATA(py_gamma_detail); - gamma_N = (double *)PyArray_DATA(py_gamma_N); - gamma_U = (double *)PyArray_DATA(py_gamma_U); - g = (double *)PyArray_DATA(py_g); - g_zero = (char *)PyArray_DATA(py_g_zero); - frequencies = (double *)PyArray_DATA(py_frequencies); - triplets = (long(*)[3])PyArray_DATA(py_triplets); - triplet_weights = (long *)PyArray_DATA(py_triplet_weights); - bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); + fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); + gamma_detail = (double *)PyArray_DATA(py_gamma_detail); + gamma_N = (double *)PyArray_DATA(py_gamma_N); + gamma_U = (double *)PyArray_DATA(py_gamma_U); + g = (double *)PyArray_DATA(py_g); + g_zero = (char *)PyArray_DATA(py_g_zero); + frequencies = (double *)PyArray_DATA(py_frequencies); + triplets = (long(*)[3])PyArray_DATA(py_triplets); + triplet_weights = (long *)PyArray_DATA(py_triplet_weights); + bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); - ph3py_get_detailed_imag_self_energy_at_bands_with_g(gamma_detail, - gamma_N, - gamma_U, - fc3_normal_squared, - frequencies, - triplets, - triplet_weights, - bz_grid_addresses, - g, - g_zero, - temperature, - cutoff_frequency); + ph3py_get_detailed_imag_self_energy_at_bands_with_g( + gamma_detail, gamma_N, gamma_U, fc3_normal_squared, frequencies, + triplets, triplet_weights, bz_grid_addresses, g, g_zero, temperature, + cutoff_frequency); - free(fc3_normal_squared); - fc3_normal_squared = NULL; + free(fc3_normal_squared); + fc3_normal_squared = NULL; - Py_RETURN_NONE; + Py_RETURN_NONE; } static PyObject *py_get_real_self_energy_at_bands(PyObject *self, - PyObject *args) -{ - PyArrayObject *py_shift; - PyArrayObject *py_fc3_normal_squared; - PyArrayObject *py_frequencies; - PyArrayObject *py_triplets; - PyArrayObject *py_triplet_weights; - PyArrayObject *py_band_indices; - double epsilon, unit_conversion_factor, cutoff_frequency, temperature; + PyObject *args) { + PyArrayObject *py_shift; + PyArrayObject *py_fc3_normal_squared; + PyArrayObject *py_frequencies; + PyArrayObject *py_triplets; + PyArrayObject *py_triplet_weights; + PyArrayObject *py_band_indices; + double epsilon, unit_conversion_factor, cutoff_frequency, temperature; - Darray *fc3_normal_squared; - double *shift; - double *frequencies; - long *band_indices; - long(*triplets)[3]; - long *triplet_weights; + Darray *fc3_normal_squared; + double *shift; + double *frequencies; + long *band_indices; + long(*triplets)[3]; + long *triplet_weights; - if (!PyArg_ParseTuple(args, "OOOOOOdddd", - &py_shift, - &py_fc3_normal_squared, - &py_triplets, - &py_triplet_weights, - &py_frequencies, - &py_band_indices, - &temperature, - &epsilon, - &unit_conversion_factor, - &cutoff_frequency)) - { - return NULL; - } + if (!PyArg_ParseTuple(args, "OOOOOOdddd", &py_shift, &py_fc3_normal_squared, + &py_triplets, &py_triplet_weights, &py_frequencies, + &py_band_indices, &temperature, &epsilon, + &unit_conversion_factor, &cutoff_frequency)) { + return NULL; + } - fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); - shift = (double *)PyArray_DATA(py_shift); - frequencies = (double *)PyArray_DATA(py_frequencies); - band_indices = (long *)PyArray_DATA(py_band_indices); - triplets = (long(*)[3])PyArray_DATA(py_triplets); - triplet_weights = (long *)PyArray_DATA(py_triplet_weights); + fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); + shift = (double *)PyArray_DATA(py_shift); + frequencies = (double *)PyArray_DATA(py_frequencies); + band_indices = (long *)PyArray_DATA(py_band_indices); + triplets = (long(*)[3])PyArray_DATA(py_triplets); + triplet_weights = (long *)PyArray_DATA(py_triplet_weights); - ph3py_get_real_self_energy_at_bands(shift, - fc3_normal_squared, - band_indices, - frequencies, - triplets, - triplet_weights, - epsilon, - temperature, - unit_conversion_factor, - cutoff_frequency); + ph3py_get_real_self_energy_at_bands( + shift, fc3_normal_squared, band_indices, frequencies, triplets, + triplet_weights, epsilon, temperature, unit_conversion_factor, + cutoff_frequency); - free(fc3_normal_squared); - fc3_normal_squared = NULL; + free(fc3_normal_squared); + fc3_normal_squared = NULL; - Py_RETURN_NONE; + Py_RETURN_NONE; } static PyObject *py_get_real_self_energy_at_frequency_point(PyObject *self, - PyObject *args) -{ - PyArrayObject *py_shift; - PyArrayObject *py_fc3_normal_squared; - PyArrayObject *py_frequencies; - PyArrayObject *py_triplets; - PyArrayObject *py_triplet_weights; - PyArrayObject *py_band_indices; - double frequency_point, epsilon, unit_conversion_factor, cutoff_frequency; - double temperature; - - Darray *fc3_normal_squared; - double *shift; - double *frequencies; - long *band_indices; - long(*triplets)[3]; - long *triplet_weights; - - if (!PyArg_ParseTuple(args, "OdOOOOOdddd", - &py_shift, - &frequency_point, - &py_fc3_normal_squared, - &py_triplets, - &py_triplet_weights, - &py_frequencies, - &py_band_indices, - &temperature, - &epsilon, - &unit_conversion_factor, - &cutoff_frequency)) - { - return NULL; - } - - fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); - shift = (double *)PyArray_DATA(py_shift); - frequencies = (double *)PyArray_DATA(py_frequencies); - band_indices = (long *)PyArray_DATA(py_band_indices); - triplets = (long(*)[3])PyArray_DATA(py_triplets); - triplet_weights = (long *)PyArray_DATA(py_triplet_weights); - - ph3py_get_real_self_energy_at_frequency_point(shift, - frequency_point, - fc3_normal_squared, - band_indices, - frequencies, - triplets, - triplet_weights, - epsilon, - temperature, - unit_conversion_factor, - cutoff_frequency); - - free(fc3_normal_squared); - fc3_normal_squared = NULL; - - Py_RETURN_NONE; -} - -static PyObject *py_get_collision_matrix(PyObject *self, PyObject *args) -{ - PyArrayObject *py_collision_matrix; - PyArrayObject *py_fc3_normal_squared; - PyArrayObject *py_frequencies; - PyArrayObject *py_triplets; - PyArrayObject *py_triplets_map; - PyArrayObject *py_map_q; - PyArrayObject *py_g; - PyArrayObject *py_rotated_grid_points; - PyArrayObject *py_rotations_cartesian; - double temperature, unit_conversion_factor, cutoff_frequency; - - Darray *fc3_normal_squared; - double *collision_matrix; - double *g; - double *frequencies; - long(*triplets)[3]; - long *triplets_map; - long *map_q; - long *rotated_grid_points; - long num_gp, num_ir_gp, num_rot; - double *rotations_cartesian; - - if (!PyArg_ParseTuple(args, "OOOOOOOOOddd", - &py_collision_matrix, - &py_fc3_normal_squared, - &py_frequencies, - &py_g, - &py_triplets, - &py_triplets_map, - &py_map_q, - &py_rotated_grid_points, - &py_rotations_cartesian, - &temperature, - &unit_conversion_factor, - &cutoff_frequency)) - { - return NULL; - } - - fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); - collision_matrix = (double *)PyArray_DATA(py_collision_matrix); - g = (double *)PyArray_DATA(py_g); - frequencies = (double *)PyArray_DATA(py_frequencies); - triplets = (long(*)[3])PyArray_DATA(py_triplets); - triplets_map = (long *)PyArray_DATA(py_triplets_map); - num_gp = (long)PyArray_DIMS(py_triplets_map)[0]; - map_q = (long *)PyArray_DATA(py_map_q); - rotated_grid_points = (long *)PyArray_DATA(py_rotated_grid_points); - num_ir_gp = (long)PyArray_DIMS(py_rotated_grid_points)[0]; - num_rot = (long)PyArray_DIMS(py_rotated_grid_points)[1]; - rotations_cartesian = (double *)PyArray_DATA(py_rotations_cartesian); - - assert(num_rot == PyArray_DIMS(py_rotations_cartesian)[0]); - assert(num_gp == PyArray_DIMS(py_frequencies)[0]); - - ph3py_get_collision_matrix(collision_matrix, - fc3_normal_squared, - frequencies, - triplets, - triplets_map, - map_q, - rotated_grid_points, - rotations_cartesian, - g, - num_ir_gp, - num_gp, - num_rot, - temperature, - unit_conversion_factor, - cutoff_frequency); - - free(fc3_normal_squared); - fc3_normal_squared = NULL; - - Py_RETURN_NONE; -} - -static PyObject *py_get_reducible_collision_matrix(PyObject *self, PyObject *args) -{ - PyArrayObject *py_collision_matrix; - PyArrayObject *py_fc3_normal_squared; - PyArrayObject *py_frequencies; - PyArrayObject *py_triplets; - PyArrayObject *py_triplets_map; - PyArrayObject *py_map_q; - PyArrayObject *py_g; - double temperature, unit_conversion_factor, cutoff_frequency; - - Darray *fc3_normal_squared; - double *collision_matrix; - double *g; - double *frequencies; - long(*triplets)[3]; - long *triplets_map; - long num_gp; - long *map_q; - - if (!PyArg_ParseTuple(args, "OOOOOOOddd", - &py_collision_matrix, - &py_fc3_normal_squared, - &py_frequencies, - &py_g, - &py_triplets, - &py_triplets_map, - &py_map_q, - &temperature, - &unit_conversion_factor, - &cutoff_frequency)) - { - return NULL; - } - - fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); - collision_matrix = (double *)PyArray_DATA(py_collision_matrix); - g = (double *)PyArray_DATA(py_g); - frequencies = (double *)PyArray_DATA(py_frequencies); - triplets = (long(*)[3])PyArray_DATA(py_triplets); - triplets_map = (long *)PyArray_DATA(py_triplets_map); - num_gp = (long)PyArray_DIMS(py_triplets_map)[0]; - map_q = (long *)PyArray_DATA(py_map_q); - - ph3py_get_reducible_collision_matrix(collision_matrix, - fc3_normal_squared, - frequencies, - triplets, - triplets_map, - map_q, - g, - num_gp, - temperature, - unit_conversion_factor, - cutoff_frequency); - - free(fc3_normal_squared); - fc3_normal_squared = NULL; - - Py_RETURN_NONE; -} - -static PyObject *py_symmetrize_collision_matrix(PyObject *self, PyObject *args) -{ - PyArrayObject *py_collision_matrix; - - double *collision_matrix; - long num_band, num_grid_points, num_temp, num_sigma; - long num_column; - - if (!PyArg_ParseTuple(args, "O", - &py_collision_matrix)) - { - return NULL; - } - - collision_matrix = (double *)PyArray_DATA(py_collision_matrix); - 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]; - - if (PyArray_NDIM(py_collision_matrix) == 8) - { - num_column = num_grid_points * num_band * 3; - } - else - { - num_column = num_grid_points * num_band; - } - - ph3py_symmetrize_collision_matrix(collision_matrix, - num_column, - num_temp, - num_sigma); - - Py_RETURN_NONE; -} - -static PyObject *py_expand_collision_matrix(PyObject *self, PyObject *args) -{ - PyArrayObject *py_collision_matrix; - PyArrayObject *py_ir_grid_points; - PyArrayObject *py_rot_grid_points; - - double *collision_matrix; - long *rot_grid_points; - long *ir_grid_points; - long num_band, num_grid_points, num_temp, num_sigma, num_rot, num_ir_gp; - - if (!PyArg_ParseTuple(args, "OOO", - &py_collision_matrix, - &py_ir_grid_points, - &py_rot_grid_points)) - { - return NULL; - } - - collision_matrix = (double *)PyArray_DATA(py_collision_matrix); - rot_grid_points = (long *)PyArray_DATA(py_rot_grid_points); - ir_grid_points = (long *)PyArray_DATA(py_ir_grid_points); - 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, - ir_grid_points, - num_ir_gp, - num_grid_points, - num_rot, - num_sigma, - num_temp, - num_band); - - Py_RETURN_NONE; -} - -static PyObject *py_get_isotope_strength(PyObject *self, PyObject *args) -{ - PyArrayObject *py_gamma; - PyArrayObject *py_frequencies; - PyArrayObject *py_eigenvectors; - PyArrayObject *py_band_indices; - PyArrayObject *py_mass_variances; - long grid_point; - long num_grid_points; - double cutoff_frequency; - double sigma; - - double *gamma; - double *frequencies; - lapack_complex_double *eigenvectors; - long *band_indices; - double *mass_variances; - long num_band, num_band0; - - if (!PyArg_ParseTuple(args, "OlOOOOldd", - &py_gamma, - &grid_point, - &py_mass_variances, - &py_frequencies, - &py_eigenvectors, - &py_band_indices, - &num_grid_points, - &sigma, - &cutoff_frequency)) - { - return NULL; - } - - gamma = (double *)PyArray_DATA(py_gamma); - frequencies = (double *)PyArray_DATA(py_frequencies); - eigenvectors = (lapack_complex_double *)PyArray_DATA(py_eigenvectors); - band_indices = (long *)PyArray_DATA(py_band_indices); - mass_variances = (double *)PyArray_DATA(py_mass_variances); - num_band = (long)PyArray_DIMS(py_frequencies)[1]; - num_band0 = (long)PyArray_DIMS(py_band_indices)[0]; - - ph3py_get_isotope_scattering_strength(gamma, - grid_point, - mass_variances, - frequencies, - eigenvectors, - num_grid_points, - band_indices, - num_band, - num_band0, - sigma, - cutoff_frequency); - - Py_RETURN_NONE; -} - -static PyObject *py_get_thm_isotope_strength(PyObject *self, PyObject *args) -{ - PyArrayObject *py_gamma; - PyArrayObject *py_frequencies; - PyArrayObject *py_eigenvectors; - PyArrayObject *py_band_indices; - PyArrayObject *py_mass_variances; - PyArrayObject *py_ir_grid_points; - PyArrayObject *py_weights; - PyArrayObject *py_integration_weights; - long grid_point; - double cutoff_frequency; - - double *gamma; - double *frequencies; - long *ir_grid_points; - long *weights; - lapack_complex_double *eigenvectors; - long *band_indices; - double *mass_variances; - long num_band, num_band0, num_ir_grid_points; - double *integration_weights; - - if (!PyArg_ParseTuple(args, "OlOOOOOOOd", - &py_gamma, - &grid_point, - &py_ir_grid_points, - &py_weights, - &py_mass_variances, - &py_frequencies, - &py_eigenvectors, - &py_band_indices, - &py_integration_weights, - &cutoff_frequency)) - { - return NULL; - } - - 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); - eigenvectors = (lapack_complex_double *)PyArray_DATA(py_eigenvectors); - band_indices = (long *)PyArray_DATA(py_band_indices); - mass_variances = (double *)PyArray_DATA(py_mass_variances); - num_band = (long)PyArray_DIMS(py_frequencies)[1]; - num_band0 = (long)PyArray_DIMS(py_band_indices)[0]; - integration_weights = (double *)PyArray_DATA(py_integration_weights); - num_ir_grid_points = (long)PyArray_DIMS(py_ir_grid_points)[0]; - - ph3py_get_thm_isotope_scattering_strength(gamma, - grid_point, - ir_grid_points, - weights, - mass_variances, - frequencies, - eigenvectors, - num_ir_grid_points, - band_indices, - num_band, - num_band0, - integration_weights, - cutoff_frequency); - - Py_RETURN_NONE; -} - -static PyObject *py_distribute_fc3(PyObject *self, PyObject *args) -{ - PyArrayObject *force_constants_third; - long target; - long source; - PyArrayObject *rotation_cart_inv; - PyArrayObject *atom_mapping_py; - - double *fc3; - double *rot_cart_inv; - long *atom_mapping; - long num_atom; - - if (!PyArg_ParseTuple(args, "OllOO", - &force_constants_third, - &target, - &source, - &atom_mapping_py, - &rotation_cart_inv)) - { - return NULL; - } - - fc3 = (double *)PyArray_DATA(force_constants_third); - rot_cart_inv = (double *)PyArray_DATA(rotation_cart_inv); - atom_mapping = (long *)PyArray_DATA(atom_mapping_py); - num_atom = (long)PyArray_DIMS(atom_mapping_py)[0]; - - ph3py_distribute_fc3(fc3, - target, - source, - atom_mapping, - num_atom, - rot_cart_inv); - - Py_RETURN_NONE; -} - -static PyObject *py_rotate_delta_fc2s(PyObject *self, PyObject *args) -{ - PyArrayObject *py_fc3; - PyArrayObject *py_delta_fc2s; - PyArrayObject *py_inv_U; - PyArrayObject *py_site_sym_cart; - PyArrayObject *py_rot_map_syms; - - double(*fc3)[3][3][3]; - double(*delta_fc2s)[3][3]; - double *inv_U; - double(*site_sym_cart)[3][3]; - long *rot_map_syms; - long num_atom, num_disp, num_site_sym; - - if (!PyArg_ParseTuple(args, "OOOOO", - &py_fc3, - &py_delta_fc2s, - &py_inv_U, - &py_site_sym_cart, - &py_rot_map_syms)) - { - return NULL; - } - - /* (num_atom, num_atom, 3, 3, 3) */ - fc3 = (double(*)[3][3][3])PyArray_DATA(py_fc3); - /* (n_u1, num_atom, num_atom, 3, 3) */ - delta_fc2s = (double(*)[3][3])PyArray_DATA(py_delta_fc2s); - /* (3, n_u1 * n_sym) */ - inv_U = (double *)PyArray_DATA(py_inv_U); - /* (n_sym, 3, 3) */ - site_sym_cart = (double(*)[3][3])PyArray_DATA(py_site_sym_cart); - /* (n_sym, natom) */ - rot_map_syms = (long *)PyArray_DATA(py_rot_map_syms); - - num_atom = (long)PyArray_DIMS(py_fc3)[0]; - num_disp = (long)PyArray_DIMS(py_delta_fc2s)[0]; - num_site_sym = (long)PyArray_DIMS(py_site_sym_cart)[0]; - - ph3py_rotate_delta_fc2(fc3, - delta_fc2s, - inv_U, - site_sym_cart, - rot_map_syms, - num_atom, - num_site_sym, - num_disp); - - Py_RETURN_NONE; -} - -static PyObject * -py_get_permutation_symmetry_fc3(PyObject *self, PyObject *args) -{ - PyArrayObject *py_fc3; - - double *fc3; - long num_atom; - - if (!PyArg_ParseTuple(args, "O", &py_fc3)) - { - return NULL; - } - - fc3 = (double *)PyArray_DATA(py_fc3); - num_atom = (long)PyArray_DIMS(py_fc3)[0]; - - ph3py_get_permutation_symmetry_fc3(fc3, num_atom); - - Py_RETURN_NONE; -} - -static PyObject * -py_get_permutation_symmetry_compact_fc3(PyObject *self, PyObject *args) -{ - PyArrayObject *py_fc3; - PyArrayObject *py_permutations; - PyArrayObject *py_s2pp_map; - PyArrayObject *py_p2s_map; - PyArrayObject *py_nsym_list; - - double *fc3; - long *s2pp; - long *p2s; - long *nsym_list; - long *perms; - long n_patom, n_satom; - - if (!PyArg_ParseTuple(args, "OOOOO", - &py_fc3, - &py_permutations, - &py_s2pp_map, - &py_p2s_map, - &py_nsym_list)) - { - return NULL; - } - - fc3 = (double *)PyArray_DATA(py_fc3); - perms = (long *)PyArray_DATA(py_permutations); - s2pp = (long *)PyArray_DATA(py_s2pp_map); - p2s = (long *)PyArray_DATA(py_p2s_map); - nsym_list = (long *)PyArray_DATA(py_nsym_list); - n_patom = (long)PyArray_DIMS(py_fc3)[0]; - n_satom = (long)PyArray_DIMS(py_fc3)[1]; - - ph3py_get_permutation_symmetry_compact_fc3(fc3, - p2s, - s2pp, - nsym_list, - perms, - n_satom, - n_patom); - - Py_RETURN_NONE; -} - -static PyObject *py_transpose_compact_fc3(PyObject *self, PyObject *args) -{ - PyArrayObject *py_fc3; - PyArrayObject *py_permutations; - PyArrayObject *py_s2pp_map; - PyArrayObject *py_p2s_map; - PyArrayObject *py_nsym_list; - long t_type; - - double *fc3; - long *s2pp; - long *p2s; - long *nsym_list; - long *perms; - long n_patom, n_satom; - - if (!PyArg_ParseTuple(args, "OOOOOl", - &py_fc3, - &py_permutations, - &py_s2pp_map, - &py_p2s_map, - &py_nsym_list, - &t_type)) - { - return NULL; - } - - fc3 = (double *)PyArray_DATA(py_fc3); - perms = (long *)PyArray_DATA(py_permutations); - s2pp = (long *)PyArray_DATA(py_s2pp_map); - p2s = (long *)PyArray_DATA(py_p2s_map); - nsym_list = (long *)PyArray_DATA(py_nsym_list); - n_patom = (long)PyArray_DIMS(py_fc3)[0]; - n_satom = (long)PyArray_DIMS(py_fc3)[1]; - - ph3py_transpose_compact_fc3(fc3, - p2s, - s2pp, - nsym_list, - perms, - n_satom, - n_patom, - t_type); - - Py_RETURN_NONE; -} - -static PyObject *py_get_neighboring_grid_points(PyObject *self, PyObject *args) -{ - PyArrayObject *py_relative_grid_points; - PyArrayObject *py_grid_points; - PyArrayObject *py_relative_grid_address; - PyArrayObject *py_D_diag; - PyArrayObject *py_bz_grid_address; - PyArrayObject *py_bz_map; - long bz_grid_type; - - long *relative_grid_points; - long *grid_points; - long num_grid_points, num_relative_grid_address; - long(*relative_grid_address)[3]; - long *D_diag; - long(*bz_grid_address)[3]; - long *bz_map; - - if (!PyArg_ParseTuple(args, "OOOOOOl", - &py_relative_grid_points, - &py_grid_points, - &py_relative_grid_address, - &py_D_diag, - &py_bz_grid_address, - &py_bz_map, - &bz_grid_type)) - { - return NULL; - } - - relative_grid_points = (long *)PyArray_DATA(py_relative_grid_points); - grid_points = (long *)PyArray_DATA(py_grid_points); - num_grid_points = (long)PyArray_DIMS(py_grid_points)[0]; - relative_grid_address = (long(*)[3])PyArray_DATA(py_relative_grid_address); - num_relative_grid_address = (long)PyArray_DIMS(py_relative_grid_address)[0]; - D_diag = (long *)PyArray_DATA(py_D_diag); - bz_grid_address = (long(*)[3])PyArray_DATA(py_bz_grid_address); - bz_map = (long *)PyArray_DATA(py_bz_map); - - ph3py_get_neighboring_gird_points(relative_grid_points, - grid_points, - relative_grid_address, - D_diag, - bz_grid_address, - bz_map, - bz_grid_type, - num_grid_points, - num_relative_grid_address); - - Py_RETURN_NONE; -} - -static PyObject * -py_get_thm_integration_weights_at_grid_points(PyObject *self, PyObject *args) -{ - PyArrayObject *py_iw; - PyArrayObject *py_frequency_points; - PyArrayObject *py_relative_grid_address; - PyArrayObject *py_D_diag; - PyArrayObject *py_grid_points; - PyArrayObject *py_frequencies; - PyArrayObject *py_bz_grid_address; - PyArrayObject *py_gp2irgp_map; - PyArrayObject *py_bz_map; - long bz_grid_type; - char *function; - - double *iw; - double *frequency_points; - long num_frequency_points, num_band, num_gp; - long(*relative_grid_address)[4][3]; - long *D_diag; - long *grid_points; - long(*bz_grid_address)[3]; - long *bz_map; - long *gp2irgp_map; - double *frequencies; - - if (!PyArg_ParseTuple(args, "OOOOOOOOOls", - &py_iw, - &py_frequency_points, - &py_relative_grid_address, - &py_D_diag, - &py_grid_points, - &py_frequencies, - &py_bz_grid_address, - &py_bz_map, - &py_gp2irgp_map, - &bz_grid_type, - &function)) - { - return NULL; - } - - iw = (double *)PyArray_DATA(py_iw); - frequency_points = (double *)PyArray_DATA(py_frequency_points); - num_frequency_points = (long)PyArray_DIMS(py_frequency_points)[0]; - relative_grid_address = (long(*)[4][3])PyArray_DATA(py_relative_grid_address); - D_diag = (long *)PyArray_DATA(py_D_diag); - grid_points = (long *)PyArray_DATA(py_grid_points); - num_gp = (long)PyArray_DIMS(py_grid_points)[0]; - bz_grid_address = (long(*)[3])PyArray_DATA(py_bz_grid_address); - bz_map = (long *)PyArray_DATA(py_bz_map); - gp2irgp_map = (long *)PyArray_DATA(py_gp2irgp_map); - frequencies = (double *)PyArray_DATA(py_frequencies); - num_band = (long)PyArray_DIMS(py_frequencies)[1]; - - ph3py_get_thm_integration_weights_at_grid_points( - iw, - frequency_points, - num_frequency_points, - num_band, - num_gp, - relative_grid_address, - D_diag, - grid_points, - bz_grid_address, - bz_map, - bz_grid_type, - frequencies, - gp2irgp_map, - function[0]); - - Py_RETURN_NONE; -} - -static PyObject * -py_tpl_get_triplets_reciprocal_mesh_at_q(PyObject *self, PyObject *args) -{ - PyArrayObject *py_map_triplets; - PyArrayObject *py_map_q; - PyArrayObject *py_D_diag; - PyArrayObject *py_rotations; - long fixed_grid_number; - long is_time_reversal; - long swappable; - - long *map_triplets; - long *map_q; - long *D_diag; - long(*rot)[3][3]; - long num_rot; - long num_ir; - - if (!PyArg_ParseTuple(args, "OOlOlOl", - &py_map_triplets, - &py_map_q, - &fixed_grid_number, - &py_D_diag, - &is_time_reversal, - &py_rotations, - &swappable)) - { - return NULL; - } - - map_triplets = (long *)PyArray_DATA(py_map_triplets); - map_q = (long *)PyArray_DATA(py_map_q); - D_diag = (long *)PyArray_DATA(py_D_diag); - rot = (long(*)[3][3])PyArray_DATA(py_rotations); - num_rot = (long)PyArray_DIMS(py_rotations)[0]; - num_ir = ph3py_get_triplets_reciprocal_mesh_at_q(map_triplets, - map_q, - fixed_grid_number, - D_diag, - is_time_reversal, - num_rot, - rot, - swappable); - - return PyLong_FromLong(num_ir); -} - -static PyObject *py_tpl_get_BZ_triplets_at_q(PyObject *self, PyObject *args) -{ - PyArrayObject *py_triplets; - PyArrayObject *py_bz_grid_address; - PyArrayObject *py_bz_map; - PyArrayObject *py_map_triplets; - PyArrayObject *py_D_diag; - PyArrayObject *py_Q; - long grid_point; - long bz_grid_type; - - long(*triplets)[3]; - long(*bz_grid_address)[3]; - long *bz_map; - long *map_triplets; - long num_map_triplets; - long *D_diag; - long(*Q)[3]; - long num_ir; - - if (!PyArg_ParseTuple(args, "OlOOOOOl", - &py_triplets, - &grid_point, - &py_bz_grid_address, - &py_bz_map, - &py_map_triplets, - &py_D_diag, - &py_Q, - &bz_grid_type)) - { - return NULL; - } - - triplets = (long(*)[3])PyArray_DATA(py_triplets); - bz_grid_address = (long(*)[3])PyArray_DATA(py_bz_grid_address); - bz_map = (long *)PyArray_DATA(py_bz_map); - map_triplets = (long *)PyArray_DATA(py_map_triplets); - num_map_triplets = (long)PyArray_DIMS(py_map_triplets)[0]; - D_diag = (long *)PyArray_DATA(py_D_diag); - Q = (long(*)[3])PyArray_DATA(py_Q); - - num_ir = ph3py_get_BZ_triplets_at_q(triplets, - grid_point, - bz_grid_address, - bz_map, - map_triplets, - num_map_triplets, - D_diag, - Q, - bz_grid_type); - - return PyLong_FromLong(num_ir); -} - -static PyObject * -py_get_triplets_integration_weights(PyObject *self, PyObject *args) -{ - PyArrayObject *py_iw; - PyArrayObject *py_iw_zero; - PyArrayObject *py_frequency_points; - PyArrayObject *py_relative_grid_address; - PyArrayObject *py_D_diag; - PyArrayObject *py_triplets; - PyArrayObject *py_frequencies1; - PyArrayObject *py_frequencies2; - PyArrayObject *py_bz_grid_addresses; - PyArrayObject *py_bz_map; - long bz_grid_type; - long tp_type; - - double *iw; - char *iw_zero; - double *frequency_points; - long(*relative_grid_address)[4][3]; - long *D_diag; - long(*triplets)[3]; - long(*bz_grid_addresses)[3]; - long *bz_map; - double *frequencies1, *frequencies2; - long num_band0, num_band1, num_band2, num_triplets; - - if (!PyArg_ParseTuple(args, "OOOOOOOOOOll", - &py_iw, - &py_iw_zero, - &py_frequency_points, - &py_relative_grid_address, - &py_D_diag, - &py_triplets, - &py_frequencies1, - &py_frequencies2, - &py_bz_grid_addresses, - &py_bz_map, - &bz_grid_type, - &tp_type)) - { - return NULL; - } - - iw = (double *)PyArray_DATA(py_iw); - iw_zero = (char *)PyArray_DATA(py_iw_zero); - frequency_points = (double *)PyArray_DATA(py_frequency_points); - num_band0 = (long)PyArray_DIMS(py_frequency_points)[0]; - relative_grid_address = (long(*)[4][3])PyArray_DATA(py_relative_grid_address); - D_diag = (long *)PyArray_DATA(py_D_diag); - triplets = (long(*)[3])PyArray_DATA(py_triplets); - num_triplets = (long)PyArray_DIMS(py_triplets)[0]; - bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); - bz_map = (long *)PyArray_DATA(py_bz_map); - frequencies1 = (double *)PyArray_DATA(py_frequencies1); - frequencies2 = (double *)PyArray_DATA(py_frequencies2); - num_band1 = (long)PyArray_DIMS(py_frequencies1)[1]; - num_band2 = (long)PyArray_DIMS(py_frequencies2)[1]; - - ph3py_get_integration_weight(iw, - iw_zero, - frequency_points, - num_band0, - relative_grid_address, - D_diag, - triplets, - num_triplets, - bz_grid_addresses, - bz_map, - bz_grid_type, - frequencies1, - num_band1, - frequencies2, - num_band2, - tp_type, - 1, - 0); - - Py_RETURN_NONE; -} - -static PyObject * -py_get_triplets_integration_weights_with_sigma(PyObject *self, PyObject *args) -{ - PyArrayObject *py_iw; - PyArrayObject *py_iw_zero; - PyArrayObject *py_frequency_points; - PyArrayObject *py_triplets; - PyArrayObject *py_frequencies; - double sigma, sigma_cutoff; - - double *iw; - char *iw_zero; - double *frequency_points; - long(*triplets)[3]; - double *frequencies; - long num_band0, num_band, num_iw, num_triplets; - - if (!PyArg_ParseTuple(args, "OOOOOdd", - &py_iw, - &py_iw_zero, - &py_frequency_points, - &py_triplets, - &py_frequencies, - &sigma, - &sigma_cutoff)) - { - return NULL; - } - - iw = (double *)PyArray_DATA(py_iw); - iw_zero = (char *)PyArray_DATA(py_iw_zero); - frequency_points = (double *)PyArray_DATA(py_frequency_points); - num_band0 = (long)PyArray_DIMS(py_frequency_points)[0]; - triplets = (long(*)[3])PyArray_DATA(py_triplets); - num_triplets = (long)PyArray_DIMS(py_triplets)[0]; - frequencies = (double *)PyArray_DATA(py_frequencies); - num_band = (long)PyArray_DIMS(py_frequencies)[1]; - num_iw = (long)PyArray_DIMS(py_iw)[0]; - - ph3py_get_integration_weight_with_sigma(iw, - iw_zero, - sigma, - sigma_cutoff, - frequency_points, - num_band0, - triplets, - num_triplets, - frequencies, - num_band, - num_iw); - - Py_RETURN_NONE; -} - -static PyObject * -py_get_grid_index_from_address(PyObject *self, PyObject *args) -{ - PyArrayObject *py_address; - PyArrayObject *py_D_diag; - - long *address; - long *D_diag; - long gp; - - if (!PyArg_ParseTuple(args, "OO", - &py_address, - &py_D_diag)) - { - return NULL; - } - - address = (long *)PyArray_DATA(py_address); - D_diag = (long *)PyArray_DATA(py_D_diag); - - gp = ph3py_get_grid_index_from_address(address, D_diag); - - return PyLong_FromLong(gp); -} - -static PyObject * -py_get_gr_grid_addresses(PyObject *self, PyObject *args) -{ - PyArrayObject *py_gr_grid_addresses; - PyArrayObject *py_D_diag; - - long(*gr_grid_addresses)[3]; - long *D_diag; - - if (!PyArg_ParseTuple(args, "OO", - &py_gr_grid_addresses, - &py_D_diag)) - { - return NULL; - } - - gr_grid_addresses = (long(*)[3])PyArray_DATA(py_gr_grid_addresses); - D_diag = (long *)PyArray_DATA(py_D_diag); - - ph3py_get_gr_grid_addresses(gr_grid_addresses, D_diag); - - Py_RETURN_NONE; -} - -static PyObject *py_get_reciprocal_rotations(PyObject *self, PyObject *args) -{ - PyArrayObject *py_rec_rotations; - PyArrayObject *py_rotations; - long is_time_reversal; - - long(*rec_rotations)[3][3]; - long(*rotations)[3][3]; - long num_rot, num_rec_rot; - - if (!PyArg_ParseTuple(args, "OOl", - &py_rec_rotations, - &py_rotations, - &is_time_reversal)) - { - return NULL; - } - - rec_rotations = (long(*)[3][3])PyArray_DATA(py_rec_rotations); - rotations = (long(*)[3][3])PyArray_DATA(py_rotations); - num_rot = (long)PyArray_DIMS(py_rotations)[0]; - - num_rec_rot = ph3py_get_reciprocal_rotations(rec_rotations, - rotations, - num_rot, - is_time_reversal); - - return PyLong_FromLong(num_rec_rot); -} - -static PyObject *py_transform_rotations(PyObject *self, PyObject *args) -{ - PyArrayObject *py_transformed_rotations; - PyArrayObject *py_rotations; - PyArrayObject *py_D_diag; - PyArrayObject *py_Q; - - long(*transformed_rotations)[3][3]; - long(*rotations)[3][3]; - long *D_diag; - long(*Q)[3]; - long num_rot, succeeded; - - if (!PyArg_ParseTuple(args, "OOOO", - &py_transformed_rotations, - &py_rotations, - &py_D_diag, - &py_Q)) - { - return NULL; - } - - transformed_rotations = (long(*)[3][3])PyArray_DATA(py_transformed_rotations); - rotations = (long(*)[3][3])PyArray_DATA(py_rotations); - D_diag = (long *)PyArray_DATA(py_D_diag); - Q = (long(*)[3])PyArray_DATA(py_Q); - num_rot = (long)PyArray_DIMS(py_transformed_rotations)[0]; - - succeeded = ph3py_transform_rotations(transformed_rotations, - rotations, - num_rot, - D_diag, - Q); - if (succeeded) - { - Py_RETURN_TRUE; - } - else - { - Py_RETURN_FALSE; - } -} - -static PyObject *py_get_snf3x3(PyObject *self, PyObject *args) -{ - PyArrayObject *py_D_diag; - PyArrayObject *py_P; - PyArrayObject *py_Q; - PyArrayObject *py_A; - - long *D_diag; - long(*P)[3]; - long(*Q)[3]; - long(*A)[3]; - long succeeded; - - if (!PyArg_ParseTuple(args, "OOOO", - &py_D_diag, - &py_P, - &py_Q, - &py_A)) - { - return NULL; - } - - D_diag = (long *)PyArray_DATA(py_D_diag); - P = (long(*)[3])PyArray_DATA(py_P); - Q = (long(*)[3])PyArray_DATA(py_Q); - A = (long(*)[3])PyArray_DATA(py_A); - - succeeded = ph3py_get_snf3x3(D_diag, P, Q, A); - if (succeeded) - { - Py_RETURN_TRUE; - } - else - { - Py_RETURN_FALSE; - } -} - -static PyObject *py_get_ir_grid_map(PyObject *self, PyObject *args) -{ - PyArrayObject *py_grid_mapping_table; - PyArrayObject *py_D_diag; - PyArrayObject *py_is_shift; - PyArrayObject *py_rotations; - - long *D_diag; - long *is_shift; - long(*rot)[3][3]; - long num_rot; - - long *grid_mapping_table; - long num_ir; - - if (!PyArg_ParseTuple(args, "OOOO", - &py_grid_mapping_table, - &py_D_diag, - &py_is_shift, - &py_rotations)) - { - return NULL; - } - - D_diag = (long *)PyArray_DATA(py_D_diag); - is_shift = (long *)PyArray_DATA(py_is_shift); - rot = (long(*)[3][3])PyArray_DATA(py_rotations); - num_rot = (long)PyArray_DIMS(py_rotations)[0]; - grid_mapping_table = (long *)PyArray_DATA(py_grid_mapping_table); - - num_ir = ph3py_get_ir_grid_map(grid_mapping_table, - D_diag, - is_shift, - rot, - num_rot); - return PyLong_FromLong(num_ir); -} - -static PyObject *py_get_bz_grid_addresses(PyObject *self, PyObject *args) -{ - PyArrayObject *py_bz_grid_addresses; - PyArrayObject *py_bz_map; - PyArrayObject *py_bzg2grg; - PyArrayObject *py_D_diag; - PyArrayObject *py_Q; - PyArrayObject *py_PS; - PyArrayObject *py_reciprocal_lattice; - long type; - - long(*bz_grid_addresses)[3]; - long *bz_map; - long *bzg2grg; - long *D_diag; - long(*Q)[3]; - long *PS; - double(*reciprocal_lattice)[3]; - long num_total_gp; - - if (!PyArg_ParseTuple(args, "OOOOOOOl", - &py_bz_grid_addresses, - &py_bz_map, - &py_bzg2grg, - &py_D_diag, - &py_Q, - &py_PS, - &py_reciprocal_lattice, - &type)) - { - return NULL; - } - - bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); - bz_map = (long *)PyArray_DATA(py_bz_map); - bzg2grg = (long *)PyArray_DATA(py_bzg2grg); - D_diag = (long *)PyArray_DATA(py_D_diag); - Q = (long(*)[3])PyArray_DATA(py_Q); - PS = (long *)PyArray_DATA(py_PS); - reciprocal_lattice = (double(*)[3])PyArray_DATA(py_reciprocal_lattice); - - num_total_gp = ph3py_get_bz_grid_addresses(bz_grid_addresses, - bz_map, - bzg2grg, - D_diag, - Q, - PS, - reciprocal_lattice, - type); - - return PyLong_FromLong(num_total_gp); -} - -static PyObject *py_rotate_bz_grid_addresses(PyObject *self, PyObject *args) -{ - PyArrayObject *py_bz_grid_addresses; - PyArrayObject *py_rotation; - PyArrayObject *py_bz_map; - PyArrayObject *py_D_diag; - PyArrayObject *py_PS; - long bz_grid_index; - long type; - - long(*bz_grid_addresses)[3]; - long(*rotation)[3]; - long *bz_map; - long *D_diag; - long *PS; - long ret_bz_gp; - - if (!PyArg_ParseTuple(args, "lOOOOOl", - &bz_grid_index, - &py_rotation, - &py_bz_grid_addresses, - &py_bz_map, - &py_D_diag, - &py_PS, - &type)) - { - return NULL; - } - - bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); - rotation = (long(*)[3])PyArray_DATA(py_rotation); - bz_map = (long *)PyArray_DATA(py_bz_map); - D_diag = (long *)PyArray_DATA(py_D_diag); - PS = (long *)PyArray_DATA(py_PS); - - ret_bz_gp = ph3py_rotate_bz_grid_index(bz_grid_index, - rotation, - bz_grid_addresses, - bz_map, - D_diag, - PS, - type); - - return PyLong_FromLong(ret_bz_gp); -} - -static PyObject * -py_diagonalize_collision_matrix(PyObject *self, PyObject *args) -{ - PyArrayObject *py_collision_matrix; - PyArrayObject *py_eigenvalues; - double cutoff; - long i_sigma, i_temp, is_pinv, solver; - - double *collision_matrix; - double *eigvals; - long num_temp, num_grid_point, num_band; - long num_column, adrs_shift; - long info; - - if (!PyArg_ParseTuple(args, "OOlldll", - &py_collision_matrix, - &py_eigenvalues, - &i_sigma, - &i_temp, - &cutoff, - &solver, - &is_pinv)) - { - return NULL; - } - - collision_matrix = (double *)PyArray_DATA(py_collision_matrix); - eigvals = (double *)PyArray_DATA(py_eigenvalues); - - if (PyArray_NDIM(py_collision_matrix) == 2) - { - num_temp = 1; - num_column = (long)PyArray_DIM(py_collision_matrix, 1); - } - else - { - num_temp = (long)PyArray_DIM(py_collision_matrix, 1); - num_grid_point = (long)PyArray_DIM(py_collision_matrix, 2); - num_band = (long)PyArray_DIM(py_collision_matrix, 3); - if (PyArray_NDIM(py_collision_matrix) == 8) - { - num_column = num_grid_point * num_band * 3; + PyObject *args) { + PyArrayObject *py_shift; + PyArrayObject *py_fc3_normal_squared; + PyArrayObject *py_frequencies; + PyArrayObject *py_triplets; + PyArrayObject *py_triplet_weights; + PyArrayObject *py_band_indices; + double frequency_point, epsilon, unit_conversion_factor, cutoff_frequency; + double temperature; + + Darray *fc3_normal_squared; + double *shift; + double *frequencies; + long *band_indices; + long(*triplets)[3]; + long *triplet_weights; + + if (!PyArg_ParseTuple(args, "OdOOOOOdddd", &py_shift, &frequency_point, + &py_fc3_normal_squared, &py_triplets, + &py_triplet_weights, &py_frequencies, + &py_band_indices, &temperature, &epsilon, + &unit_conversion_factor, &cutoff_frequency)) { + return NULL; } - else - { - num_column = num_grid_point * num_band; + + fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); + shift = (double *)PyArray_DATA(py_shift); + frequencies = (double *)PyArray_DATA(py_frequencies); + band_indices = (long *)PyArray_DATA(py_band_indices); + triplets = (long(*)[3])PyArray_DATA(py_triplets); + triplet_weights = (long *)PyArray_DATA(py_triplet_weights); + + ph3py_get_real_self_energy_at_frequency_point( + shift, frequency_point, fc3_normal_squared, band_indices, frequencies, + triplets, triplet_weights, epsilon, temperature, unit_conversion_factor, + cutoff_frequency); + + free(fc3_normal_squared); + fc3_normal_squared = NULL; + + Py_RETURN_NONE; +} + +static PyObject *py_get_collision_matrix(PyObject *self, PyObject *args) { + PyArrayObject *py_collision_matrix; + PyArrayObject *py_fc3_normal_squared; + PyArrayObject *py_frequencies; + PyArrayObject *py_triplets; + PyArrayObject *py_triplets_map; + PyArrayObject *py_map_q; + PyArrayObject *py_g; + PyArrayObject *py_rotated_grid_points; + PyArrayObject *py_rotations_cartesian; + double temperature, unit_conversion_factor, cutoff_frequency; + + Darray *fc3_normal_squared; + double *collision_matrix; + double *g; + double *frequencies; + long(*triplets)[3]; + long *triplets_map; + long *map_q; + long *rotated_grid_points; + long num_gp, num_ir_gp, num_rot; + double *rotations_cartesian; + + if (!PyArg_ParseTuple( + args, "OOOOOOOOOddd", &py_collision_matrix, &py_fc3_normal_squared, + &py_frequencies, &py_g, &py_triplets, &py_triplets_map, &py_map_q, + &py_rotated_grid_points, &py_rotations_cartesian, &temperature, + &unit_conversion_factor, &cutoff_frequency)) { + return NULL; } - } - adrs_shift = (i_sigma * num_column * num_column * num_temp + - i_temp * num_column * num_column); - /* show_colmat_info(py_collision_matrix, i_sigma, i_temp, adrs_shift); */ + fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); + collision_matrix = (double *)PyArray_DATA(py_collision_matrix); + g = (double *)PyArray_DATA(py_g); + frequencies = (double *)PyArray_DATA(py_frequencies); + triplets = (long(*)[3])PyArray_DATA(py_triplets); + triplets_map = (long *)PyArray_DATA(py_triplets_map); + num_gp = (long)PyArray_DIMS(py_triplets_map)[0]; + map_q = (long *)PyArray_DATA(py_map_q); + rotated_grid_points = (long *)PyArray_DATA(py_rotated_grid_points); + num_ir_gp = (long)PyArray_DIMS(py_rotated_grid_points)[0]; + num_rot = (long)PyArray_DIMS(py_rotated_grid_points)[1]; + rotations_cartesian = (double *)PyArray_DATA(py_rotations_cartesian); - info = phonopy_dsyev(collision_matrix + adrs_shift, - eigvals, num_column, solver); - if (is_pinv) - { - pinv_from_eigensolution(collision_matrix + adrs_shift, - eigvals, num_column, cutoff, 0); - } + assert(num_rot == PyArray_DIMS(py_rotations_cartesian)[0]); + assert(num_gp == PyArray_DIMS(py_frequencies)[0]); - return PyLong_FromLong(info); + ph3py_get_collision_matrix(collision_matrix, fc3_normal_squared, + frequencies, triplets, triplets_map, map_q, + rotated_grid_points, rotations_cartesian, g, + num_ir_gp, num_gp, num_rot, temperature, + unit_conversion_factor, cutoff_frequency); + + free(fc3_normal_squared); + fc3_normal_squared = NULL; + + Py_RETURN_NONE; } -static PyObject *py_pinv_from_eigensolution(PyObject *self, PyObject *args) -{ - PyArrayObject *py_collision_matrix; - PyArrayObject *py_eigenvalues; - double cutoff; - long i_sigma, i_temp, pinv_method; +static PyObject *py_get_reducible_collision_matrix(PyObject *self, + PyObject *args) { + PyArrayObject *py_collision_matrix; + PyArrayObject *py_fc3_normal_squared; + PyArrayObject *py_frequencies; + PyArrayObject *py_triplets; + PyArrayObject *py_triplets_map; + PyArrayObject *py_map_q; + PyArrayObject *py_g; + double temperature, unit_conversion_factor, cutoff_frequency; - double *collision_matrix; - double *eigvals; - long num_temp, num_grid_point, num_band; - long num_column, adrs_shift; + Darray *fc3_normal_squared; + double *collision_matrix; + double *g; + double *frequencies; + long(*triplets)[3]; + long *triplets_map; + long num_gp; + long *map_q; - if (!PyArg_ParseTuple(args, "OOlldl", - &py_collision_matrix, - &py_eigenvalues, - &i_sigma, - &i_temp, - &cutoff, - &pinv_method)) - { - return NULL; - } + if (!PyArg_ParseTuple( + args, "OOOOOOOddd", &py_collision_matrix, &py_fc3_normal_squared, + &py_frequencies, &py_g, &py_triplets, &py_triplets_map, &py_map_q, + &temperature, &unit_conversion_factor, &cutoff_frequency)) { + return NULL; + } - collision_matrix = (double *)PyArray_DATA(py_collision_matrix); - eigvals = (double *)PyArray_DATA(py_eigenvalues); - num_temp = (long)PyArray_DIMS(py_collision_matrix)[1]; - num_grid_point = (long)PyArray_DIMS(py_collision_matrix)[2]; - num_band = (long)PyArray_DIMS(py_collision_matrix)[3]; + fc3_normal_squared = convert_to_darray(py_fc3_normal_squared); + collision_matrix = (double *)PyArray_DATA(py_collision_matrix); + g = (double *)PyArray_DATA(py_g); + frequencies = (double *)PyArray_DATA(py_frequencies); + triplets = (long(*)[3])PyArray_DATA(py_triplets); + triplets_map = (long *)PyArray_DATA(py_triplets_map); + num_gp = (long)PyArray_DIMS(py_triplets_map)[0]; + map_q = (long *)PyArray_DATA(py_map_q); - if (PyArray_NDIM(py_collision_matrix) == 8) - { - num_column = num_grid_point * num_band * 3; - } - else - { - num_column = num_grid_point * num_band; - } - adrs_shift = (i_sigma * num_column * num_column * num_temp + - i_temp * num_column * num_column); + ph3py_get_reducible_collision_matrix( + collision_matrix, fc3_normal_squared, frequencies, triplets, + triplets_map, map_q, g, num_gp, temperature, unit_conversion_factor, + cutoff_frequency); - /* show_colmat_info(py_collision_matrix, i_sigma, i_temp, adrs_shift); */ + free(fc3_normal_squared); + fc3_normal_squared = NULL; - pinv_from_eigensolution(collision_matrix + adrs_shift, - eigvals, num_column, cutoff, pinv_method); - - Py_RETURN_NONE; + Py_RETURN_NONE; } -static PyObject *py_get_default_colmat_solver(PyObject *self, PyObject *args) -{ - if (!PyArg_ParseTuple(args, "")) - { - return NULL; - } +static PyObject *py_symmetrize_collision_matrix(PyObject *self, + PyObject *args) { + PyArrayObject *py_collision_matrix; + + double *collision_matrix; + long num_band, num_grid_points, num_temp, num_sigma; + long num_column; + + if (!PyArg_ParseTuple(args, "O", &py_collision_matrix)) { + return NULL; + } + + collision_matrix = (double *)PyArray_DATA(py_collision_matrix); + 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]; + + if (PyArray_NDIM(py_collision_matrix) == 8) { + num_column = num_grid_points * num_band * 3; + } else { + num_column = num_grid_points * num_band; + } + + ph3py_symmetrize_collision_matrix(collision_matrix, num_column, num_temp, + num_sigma); + + Py_RETURN_NONE; +} + +static PyObject *py_expand_collision_matrix(PyObject *self, PyObject *args) { + PyArrayObject *py_collision_matrix; + PyArrayObject *py_ir_grid_points; + PyArrayObject *py_rot_grid_points; + + double *collision_matrix; + long *rot_grid_points; + long *ir_grid_points; + long num_band, num_grid_points, num_temp, num_sigma, num_rot, num_ir_gp; + + if (!PyArg_ParseTuple(args, "OOO", &py_collision_matrix, &py_ir_grid_points, + &py_rot_grid_points)) { + return NULL; + } + + collision_matrix = (double *)PyArray_DATA(py_collision_matrix); + rot_grid_points = (long *)PyArray_DATA(py_rot_grid_points); + ir_grid_points = (long *)PyArray_DATA(py_ir_grid_points); + 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, + ir_grid_points, num_ir_gp, num_grid_points, + num_rot, num_sigma, num_temp, num_band); + + Py_RETURN_NONE; +} + +static PyObject *py_get_isotope_strength(PyObject *self, PyObject *args) { + PyArrayObject *py_gamma; + PyArrayObject *py_frequencies; + PyArrayObject *py_eigenvectors; + PyArrayObject *py_band_indices; + PyArrayObject *py_mass_variances; + long grid_point; + long num_grid_points; + double cutoff_frequency; + double sigma; + + double *gamma; + double *frequencies; + lapack_complex_double *eigenvectors; + long *band_indices; + double *mass_variances; + long num_band, num_band0; + + if (!PyArg_ParseTuple(args, "OlOOOOldd", &py_gamma, &grid_point, + &py_mass_variances, &py_frequencies, &py_eigenvectors, + &py_band_indices, &num_grid_points, &sigma, + &cutoff_frequency)) { + return NULL; + } + + gamma = (double *)PyArray_DATA(py_gamma); + frequencies = (double *)PyArray_DATA(py_frequencies); + eigenvectors = (lapack_complex_double *)PyArray_DATA(py_eigenvectors); + band_indices = (long *)PyArray_DATA(py_band_indices); + mass_variances = (double *)PyArray_DATA(py_mass_variances); + num_band = (long)PyArray_DIMS(py_frequencies)[1]; + num_band0 = (long)PyArray_DIMS(py_band_indices)[0]; + + ph3py_get_isotope_scattering_strength( + gamma, grid_point, mass_variances, frequencies, eigenvectors, + num_grid_points, band_indices, num_band, num_band0, sigma, + cutoff_frequency); + + Py_RETURN_NONE; +} + +static PyObject *py_get_thm_isotope_strength(PyObject *self, PyObject *args) { + PyArrayObject *py_gamma; + PyArrayObject *py_frequencies; + PyArrayObject *py_eigenvectors; + PyArrayObject *py_band_indices; + PyArrayObject *py_mass_variances; + PyArrayObject *py_ir_grid_points; + PyArrayObject *py_weights; + PyArrayObject *py_integration_weights; + long grid_point; + double cutoff_frequency; + + double *gamma; + double *frequencies; + long *ir_grid_points; + long *weights; + lapack_complex_double *eigenvectors; + long *band_indices; + double *mass_variances; + long num_band, num_band0, num_ir_grid_points; + double *integration_weights; + + if (!PyArg_ParseTuple(args, "OlOOOOOOOd", &py_gamma, &grid_point, + &py_ir_grid_points, &py_weights, &py_mass_variances, + &py_frequencies, &py_eigenvectors, &py_band_indices, + &py_integration_weights, &cutoff_frequency)) { + return NULL; + } + + 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); + eigenvectors = (lapack_complex_double *)PyArray_DATA(py_eigenvectors); + band_indices = (long *)PyArray_DATA(py_band_indices); + mass_variances = (double *)PyArray_DATA(py_mass_variances); + num_band = (long)PyArray_DIMS(py_frequencies)[1]; + num_band0 = (long)PyArray_DIMS(py_band_indices)[0]; + integration_weights = (double *)PyArray_DATA(py_integration_weights); + num_ir_grid_points = (long)PyArray_DIMS(py_ir_grid_points)[0]; + + ph3py_get_thm_isotope_scattering_strength( + gamma, grid_point, ir_grid_points, weights, mass_variances, frequencies, + eigenvectors, num_ir_grid_points, band_indices, num_band, num_band0, + integration_weights, cutoff_frequency); + + Py_RETURN_NONE; +} + +static PyObject *py_distribute_fc3(PyObject *self, PyObject *args) { + PyArrayObject *force_constants_third; + long target; + long source; + PyArrayObject *rotation_cart_inv; + PyArrayObject *atom_mapping_py; + + double *fc3; + double *rot_cart_inv; + long *atom_mapping; + long num_atom; + + if (!PyArg_ParseTuple(args, "OllOO", &force_constants_third, &target, + &source, &atom_mapping_py, &rotation_cart_inv)) { + return NULL; + } + + fc3 = (double *)PyArray_DATA(force_constants_third); + rot_cart_inv = (double *)PyArray_DATA(rotation_cart_inv); + atom_mapping = (long *)PyArray_DATA(atom_mapping_py); + num_atom = (long)PyArray_DIMS(atom_mapping_py)[0]; + + ph3py_distribute_fc3(fc3, target, source, atom_mapping, num_atom, + rot_cart_inv); + + Py_RETURN_NONE; +} + +static PyObject *py_rotate_delta_fc2s(PyObject *self, PyObject *args) { + PyArrayObject *py_fc3; + PyArrayObject *py_delta_fc2s; + PyArrayObject *py_inv_U; + PyArrayObject *py_site_sym_cart; + PyArrayObject *py_rot_map_syms; + + double(*fc3)[3][3][3]; + double(*delta_fc2s)[3][3]; + double *inv_U; + double(*site_sym_cart)[3][3]; + long *rot_map_syms; + long num_atom, num_disp, num_site_sym; + + if (!PyArg_ParseTuple(args, "OOOOO", &py_fc3, &py_delta_fc2s, &py_inv_U, + &py_site_sym_cart, &py_rot_map_syms)) { + return NULL; + } + + /* (num_atom, num_atom, 3, 3, 3) */ + fc3 = (double(*)[3][3][3])PyArray_DATA(py_fc3); + /* (n_u1, num_atom, num_atom, 3, 3) */ + delta_fc2s = (double(*)[3][3])PyArray_DATA(py_delta_fc2s); + /* (3, n_u1 * n_sym) */ + inv_U = (double *)PyArray_DATA(py_inv_U); + /* (n_sym, 3, 3) */ + site_sym_cart = (double(*)[3][3])PyArray_DATA(py_site_sym_cart); + /* (n_sym, natom) */ + rot_map_syms = (long *)PyArray_DATA(py_rot_map_syms); + + num_atom = (long)PyArray_DIMS(py_fc3)[0]; + num_disp = (long)PyArray_DIMS(py_delta_fc2s)[0]; + num_site_sym = (long)PyArray_DIMS(py_site_sym_cart)[0]; + + ph3py_rotate_delta_fc2(fc3, delta_fc2s, inv_U, site_sym_cart, rot_map_syms, + num_atom, num_site_sym, num_disp); + + Py_RETURN_NONE; +} + +static PyObject *py_get_permutation_symmetry_fc3(PyObject *self, + PyObject *args) { + PyArrayObject *py_fc3; + + double *fc3; + long num_atom; + + if (!PyArg_ParseTuple(args, "O", &py_fc3)) { + return NULL; + } + + fc3 = (double *)PyArray_DATA(py_fc3); + num_atom = (long)PyArray_DIMS(py_fc3)[0]; + + ph3py_get_permutation_symmetry_fc3(fc3, num_atom); + + Py_RETURN_NONE; +} + +static PyObject *py_get_permutation_symmetry_compact_fc3(PyObject *self, + PyObject *args) { + PyArrayObject *py_fc3; + PyArrayObject *py_permutations; + PyArrayObject *py_s2pp_map; + PyArrayObject *py_p2s_map; + PyArrayObject *py_nsym_list; + + double *fc3; + long *s2pp; + long *p2s; + long *nsym_list; + long *perms; + long n_patom, n_satom; + + if (!PyArg_ParseTuple(args, "OOOOO", &py_fc3, &py_permutations, + &py_s2pp_map, &py_p2s_map, &py_nsym_list)) { + return NULL; + } + + fc3 = (double *)PyArray_DATA(py_fc3); + perms = (long *)PyArray_DATA(py_permutations); + s2pp = (long *)PyArray_DATA(py_s2pp_map); + p2s = (long *)PyArray_DATA(py_p2s_map); + nsym_list = (long *)PyArray_DATA(py_nsym_list); + n_patom = (long)PyArray_DIMS(py_fc3)[0]; + n_satom = (long)PyArray_DIMS(py_fc3)[1]; + + ph3py_get_permutation_symmetry_compact_fc3(fc3, p2s, s2pp, nsym_list, perms, + n_satom, n_patom); + + Py_RETURN_NONE; +} + +static PyObject *py_transpose_compact_fc3(PyObject *self, PyObject *args) { + PyArrayObject *py_fc3; + PyArrayObject *py_permutations; + PyArrayObject *py_s2pp_map; + PyArrayObject *py_p2s_map; + PyArrayObject *py_nsym_list; + long t_type; + + double *fc3; + long *s2pp; + long *p2s; + long *nsym_list; + long *perms; + long n_patom, n_satom; + + if (!PyArg_ParseTuple(args, "OOOOOl", &py_fc3, &py_permutations, + &py_s2pp_map, &py_p2s_map, &py_nsym_list, &t_type)) { + return NULL; + } + + fc3 = (double *)PyArray_DATA(py_fc3); + perms = (long *)PyArray_DATA(py_permutations); + s2pp = (long *)PyArray_DATA(py_s2pp_map); + p2s = (long *)PyArray_DATA(py_p2s_map); + nsym_list = (long *)PyArray_DATA(py_nsym_list); + n_patom = (long)PyArray_DIMS(py_fc3)[0]; + n_satom = (long)PyArray_DIMS(py_fc3)[1]; + + ph3py_transpose_compact_fc3(fc3, p2s, s2pp, nsym_list, perms, n_satom, + n_patom, t_type); + + Py_RETURN_NONE; +} + +static PyObject *py_get_neighboring_grid_points(PyObject *self, + PyObject *args) { + PyArrayObject *py_relative_grid_points; + PyArrayObject *py_grid_points; + PyArrayObject *py_relative_grid_address; + PyArrayObject *py_D_diag; + PyArrayObject *py_bz_grid_address; + PyArrayObject *py_bz_map; + long bz_grid_type; + + long *relative_grid_points; + long *grid_points; + long num_grid_points, num_relative_grid_address; + long(*relative_grid_address)[3]; + long *D_diag; + long(*bz_grid_address)[3]; + long *bz_map; + + if (!PyArg_ParseTuple(args, "OOOOOOl", &py_relative_grid_points, + &py_grid_points, &py_relative_grid_address, + &py_D_diag, &py_bz_grid_address, &py_bz_map, + &bz_grid_type)) { + return NULL; + } + + relative_grid_points = (long *)PyArray_DATA(py_relative_grid_points); + grid_points = (long *)PyArray_DATA(py_grid_points); + num_grid_points = (long)PyArray_DIMS(py_grid_points)[0]; + relative_grid_address = (long(*)[3])PyArray_DATA(py_relative_grid_address); + num_relative_grid_address = (long)PyArray_DIMS(py_relative_grid_address)[0]; + D_diag = (long *)PyArray_DATA(py_D_diag); + bz_grid_address = (long(*)[3])PyArray_DATA(py_bz_grid_address); + bz_map = (long *)PyArray_DATA(py_bz_map); + + ph3py_get_neighboring_gird_points( + relative_grid_points, grid_points, relative_grid_address, D_diag, + bz_grid_address, bz_map, bz_grid_type, num_grid_points, + num_relative_grid_address); + + Py_RETURN_NONE; +} + +static PyObject *py_get_thm_integration_weights_at_grid_points(PyObject *self, + PyObject *args) { + PyArrayObject *py_iw; + PyArrayObject *py_frequency_points; + PyArrayObject *py_relative_grid_address; + PyArrayObject *py_D_diag; + PyArrayObject *py_grid_points; + PyArrayObject *py_frequencies; + PyArrayObject *py_bz_grid_address; + PyArrayObject *py_gp2irgp_map; + PyArrayObject *py_bz_map; + long bz_grid_type; + char *function; + + double *iw; + double *frequency_points; + long num_frequency_points, num_band, num_gp; + long(*relative_grid_address)[4][3]; + long *D_diag; + long *grid_points; + long(*bz_grid_address)[3]; + long *bz_map; + long *gp2irgp_map; + double *frequencies; + + if (!PyArg_ParseTuple(args, "OOOOOOOOOls", &py_iw, &py_frequency_points, + &py_relative_grid_address, &py_D_diag, + &py_grid_points, &py_frequencies, &py_bz_grid_address, + &py_bz_map, &py_gp2irgp_map, &bz_grid_type, + &function)) { + return NULL; + } + + iw = (double *)PyArray_DATA(py_iw); + frequency_points = (double *)PyArray_DATA(py_frequency_points); + num_frequency_points = (long)PyArray_DIMS(py_frequency_points)[0]; + relative_grid_address = + (long(*)[4][3])PyArray_DATA(py_relative_grid_address); + D_diag = (long *)PyArray_DATA(py_D_diag); + grid_points = (long *)PyArray_DATA(py_grid_points); + num_gp = (long)PyArray_DIMS(py_grid_points)[0]; + bz_grid_address = (long(*)[3])PyArray_DATA(py_bz_grid_address); + bz_map = (long *)PyArray_DATA(py_bz_map); + gp2irgp_map = (long *)PyArray_DATA(py_gp2irgp_map); + frequencies = (double *)PyArray_DATA(py_frequencies); + num_band = (long)PyArray_DIMS(py_frequencies)[1]; + + ph3py_get_thm_integration_weights_at_grid_points( + iw, frequency_points, num_frequency_points, num_band, num_gp, + relative_grid_address, D_diag, grid_points, bz_grid_address, bz_map, + bz_grid_type, frequencies, gp2irgp_map, function[0]); + + Py_RETURN_NONE; +} + +static PyObject *py_tpl_get_triplets_reciprocal_mesh_at_q(PyObject *self, + PyObject *args) { + PyArrayObject *py_map_triplets; + PyArrayObject *py_map_q; + PyArrayObject *py_D_diag; + PyArrayObject *py_rotations; + long fixed_grid_number; + long is_time_reversal; + long swappable; + + long *map_triplets; + long *map_q; + long *D_diag; + long(*rot)[3][3]; + long num_rot; + long num_ir; + + if (!PyArg_ParseTuple(args, "OOlOlOl", &py_map_triplets, &py_map_q, + &fixed_grid_number, &py_D_diag, &is_time_reversal, + &py_rotations, &swappable)) { + return NULL; + } + + map_triplets = (long *)PyArray_DATA(py_map_triplets); + map_q = (long *)PyArray_DATA(py_map_q); + D_diag = (long *)PyArray_DATA(py_D_diag); + rot = (long(*)[3][3])PyArray_DATA(py_rotations); + num_rot = (long)PyArray_DIMS(py_rotations)[0]; + num_ir = ph3py_get_triplets_reciprocal_mesh_at_q( + map_triplets, map_q, fixed_grid_number, D_diag, is_time_reversal, + num_rot, rot, swappable); + + return PyLong_FromLong(num_ir); +} + +static PyObject *py_tpl_get_BZ_triplets_at_q(PyObject *self, PyObject *args) { + PyArrayObject *py_triplets; + PyArrayObject *py_bz_grid_address; + PyArrayObject *py_bz_map; + PyArrayObject *py_map_triplets; + PyArrayObject *py_D_diag; + PyArrayObject *py_Q; + long grid_point; + long bz_grid_type; + + long(*triplets)[3]; + long(*bz_grid_address)[3]; + long *bz_map; + long *map_triplets; + long num_map_triplets; + long *D_diag; + long(*Q)[3]; + long num_ir; + + if (!PyArg_ParseTuple(args, "OlOOOOOl", &py_triplets, &grid_point, + &py_bz_grid_address, &py_bz_map, &py_map_triplets, + &py_D_diag, &py_Q, &bz_grid_type)) { + return NULL; + } + + triplets = (long(*)[3])PyArray_DATA(py_triplets); + bz_grid_address = (long(*)[3])PyArray_DATA(py_bz_grid_address); + bz_map = (long *)PyArray_DATA(py_bz_map); + map_triplets = (long *)PyArray_DATA(py_map_triplets); + num_map_triplets = (long)PyArray_DIMS(py_map_triplets)[0]; + D_diag = (long *)PyArray_DATA(py_D_diag); + Q = (long(*)[3])PyArray_DATA(py_Q); + + num_ir = ph3py_get_BZ_triplets_at_q(triplets, grid_point, bz_grid_address, + bz_map, map_triplets, num_map_triplets, + D_diag, Q, bz_grid_type); + + return PyLong_FromLong(num_ir); +} + +static PyObject *py_get_triplets_integration_weights(PyObject *self, + PyObject *args) { + PyArrayObject *py_iw; + PyArrayObject *py_iw_zero; + PyArrayObject *py_frequency_points; + PyArrayObject *py_relative_grid_address; + PyArrayObject *py_D_diag; + PyArrayObject *py_triplets; + PyArrayObject *py_frequencies1; + PyArrayObject *py_frequencies2; + PyArrayObject *py_bz_grid_addresses; + PyArrayObject *py_bz_map; + long bz_grid_type; + long tp_type; + + double *iw; + char *iw_zero; + double *frequency_points; + long(*relative_grid_address)[4][3]; + long *D_diag; + long(*triplets)[3]; + long(*bz_grid_addresses)[3]; + long *bz_map; + double *frequencies1, *frequencies2; + long num_band0, num_band1, num_band2, num_triplets; + + if (!PyArg_ParseTuple(args, "OOOOOOOOOOll", &py_iw, &py_iw_zero, + &py_frequency_points, &py_relative_grid_address, + &py_D_diag, &py_triplets, &py_frequencies1, + &py_frequencies2, &py_bz_grid_addresses, &py_bz_map, + &bz_grid_type, &tp_type)) { + return NULL; + } + + iw = (double *)PyArray_DATA(py_iw); + iw_zero = (char *)PyArray_DATA(py_iw_zero); + frequency_points = (double *)PyArray_DATA(py_frequency_points); + num_band0 = (long)PyArray_DIMS(py_frequency_points)[0]; + relative_grid_address = + (long(*)[4][3])PyArray_DATA(py_relative_grid_address); + D_diag = (long *)PyArray_DATA(py_D_diag); + triplets = (long(*)[3])PyArray_DATA(py_triplets); + num_triplets = (long)PyArray_DIMS(py_triplets)[0]; + bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); + bz_map = (long *)PyArray_DATA(py_bz_map); + frequencies1 = (double *)PyArray_DATA(py_frequencies1); + frequencies2 = (double *)PyArray_DATA(py_frequencies2); + num_band1 = (long)PyArray_DIMS(py_frequencies1)[1]; + num_band2 = (long)PyArray_DIMS(py_frequencies2)[1]; + + ph3py_get_integration_weight( + iw, iw_zero, frequency_points, num_band0, relative_grid_address, D_diag, + triplets, num_triplets, bz_grid_addresses, bz_map, bz_grid_type, + frequencies1, num_band1, frequencies2, num_band2, tp_type, 1, 0); + + Py_RETURN_NONE; +} + +static PyObject *py_get_triplets_integration_weights_with_sigma( + PyObject *self, PyObject *args) { + PyArrayObject *py_iw; + PyArrayObject *py_iw_zero; + PyArrayObject *py_frequency_points; + PyArrayObject *py_triplets; + PyArrayObject *py_frequencies; + double sigma, sigma_cutoff; + + double *iw; + char *iw_zero; + double *frequency_points; + long(*triplets)[3]; + double *frequencies; + long num_band0, num_band, num_iw, num_triplets; + + if (!PyArg_ParseTuple(args, "OOOOOdd", &py_iw, &py_iw_zero, + &py_frequency_points, &py_triplets, &py_frequencies, + &sigma, &sigma_cutoff)) { + return NULL; + } + + iw = (double *)PyArray_DATA(py_iw); + iw_zero = (char *)PyArray_DATA(py_iw_zero); + frequency_points = (double *)PyArray_DATA(py_frequency_points); + num_band0 = (long)PyArray_DIMS(py_frequency_points)[0]; + triplets = (long(*)[3])PyArray_DATA(py_triplets); + num_triplets = (long)PyArray_DIMS(py_triplets)[0]; + frequencies = (double *)PyArray_DATA(py_frequencies); + num_band = (long)PyArray_DIMS(py_frequencies)[1]; + num_iw = (long)PyArray_DIMS(py_iw)[0]; + + ph3py_get_integration_weight_with_sigma( + iw, iw_zero, sigma, sigma_cutoff, frequency_points, num_band0, triplets, + num_triplets, frequencies, num_band, num_iw); + + Py_RETURN_NONE; +} + +static PyObject *py_get_grid_index_from_address(PyObject *self, + PyObject *args) { + PyArrayObject *py_address; + PyArrayObject *py_D_diag; + + long *address; + long *D_diag; + long gp; + + if (!PyArg_ParseTuple(args, "OO", &py_address, &py_D_diag)) { + return NULL; + } + + address = (long *)PyArray_DATA(py_address); + D_diag = (long *)PyArray_DATA(py_D_diag); + + gp = ph3py_get_grid_index_from_address(address, D_diag); + + return PyLong_FromLong(gp); +} + +static PyObject *py_get_gr_grid_addresses(PyObject *self, PyObject *args) { + PyArrayObject *py_gr_grid_addresses; + PyArrayObject *py_D_diag; + + long(*gr_grid_addresses)[3]; + long *D_diag; + + if (!PyArg_ParseTuple(args, "OO", &py_gr_grid_addresses, &py_D_diag)) { + return NULL; + } + + gr_grid_addresses = (long(*)[3])PyArray_DATA(py_gr_grid_addresses); + D_diag = (long *)PyArray_DATA(py_D_diag); + + ph3py_get_gr_grid_addresses(gr_grid_addresses, D_diag); + + Py_RETURN_NONE; +} + +static PyObject *py_get_reciprocal_rotations(PyObject *self, PyObject *args) { + PyArrayObject *py_rec_rotations; + PyArrayObject *py_rotations; + long is_time_reversal; + + long(*rec_rotations)[3][3]; + long(*rotations)[3][3]; + long num_rot, num_rec_rot; + + if (!PyArg_ParseTuple(args, "OOl", &py_rec_rotations, &py_rotations, + &is_time_reversal)) { + return NULL; + } + + rec_rotations = (long(*)[3][3])PyArray_DATA(py_rec_rotations); + rotations = (long(*)[3][3])PyArray_DATA(py_rotations); + num_rot = (long)PyArray_DIMS(py_rotations)[0]; + + num_rec_rot = ph3py_get_reciprocal_rotations(rec_rotations, rotations, + num_rot, is_time_reversal); + + return PyLong_FromLong(num_rec_rot); +} + +static PyObject *py_transform_rotations(PyObject *self, PyObject *args) { + PyArrayObject *py_transformed_rotations; + PyArrayObject *py_rotations; + PyArrayObject *py_D_diag; + PyArrayObject *py_Q; + + long(*transformed_rotations)[3][3]; + long(*rotations)[3][3]; + long *D_diag; + long(*Q)[3]; + long num_rot, succeeded; + + if (!PyArg_ParseTuple(args, "OOOO", &py_transformed_rotations, + &py_rotations, &py_D_diag, &py_Q)) { + return NULL; + } + + transformed_rotations = + (long(*)[3][3])PyArray_DATA(py_transformed_rotations); + rotations = (long(*)[3][3])PyArray_DATA(py_rotations); + D_diag = (long *)PyArray_DATA(py_D_diag); + Q = (long(*)[3])PyArray_DATA(py_Q); + num_rot = (long)PyArray_DIMS(py_transformed_rotations)[0]; + + succeeded = ph3py_transform_rotations(transformed_rotations, rotations, + num_rot, D_diag, Q); + if (succeeded) { + Py_RETURN_TRUE; + } else { + Py_RETURN_FALSE; + } +} + +static PyObject *py_get_snf3x3(PyObject *self, PyObject *args) { + PyArrayObject *py_D_diag; + PyArrayObject *py_P; + PyArrayObject *py_Q; + PyArrayObject *py_A; + + long *D_diag; + long(*P)[3]; + long(*Q)[3]; + long(*A)[3]; + long succeeded; + + if (!PyArg_ParseTuple(args, "OOOO", &py_D_diag, &py_P, &py_Q, &py_A)) { + return NULL; + } + + D_diag = (long *)PyArray_DATA(py_D_diag); + P = (long(*)[3])PyArray_DATA(py_P); + Q = (long(*)[3])PyArray_DATA(py_Q); + A = (long(*)[3])PyArray_DATA(py_A); + + succeeded = ph3py_get_snf3x3(D_diag, P, Q, A); + if (succeeded) { + Py_RETURN_TRUE; + } else { + Py_RETURN_FALSE; + } +} + +static PyObject *py_get_ir_grid_map(PyObject *self, PyObject *args) { + PyArrayObject *py_grid_mapping_table; + PyArrayObject *py_D_diag; + PyArrayObject *py_is_shift; + PyArrayObject *py_rotations; + + long *D_diag; + long *is_shift; + long(*rot)[3][3]; + long num_rot; + + long *grid_mapping_table; + long num_ir; + + if (!PyArg_ParseTuple(args, "OOOO", &py_grid_mapping_table, &py_D_diag, + &py_is_shift, &py_rotations)) { + return NULL; + } + + D_diag = (long *)PyArray_DATA(py_D_diag); + is_shift = (long *)PyArray_DATA(py_is_shift); + rot = (long(*)[3][3])PyArray_DATA(py_rotations); + num_rot = (long)PyArray_DIMS(py_rotations)[0]; + grid_mapping_table = (long *)PyArray_DATA(py_grid_mapping_table); + + num_ir = ph3py_get_ir_grid_map(grid_mapping_table, D_diag, is_shift, rot, + num_rot); + return PyLong_FromLong(num_ir); +} + +static PyObject *py_get_bz_grid_addresses(PyObject *self, PyObject *args) { + PyArrayObject *py_bz_grid_addresses; + PyArrayObject *py_bz_map; + PyArrayObject *py_bzg2grg; + PyArrayObject *py_D_diag; + PyArrayObject *py_Q; + PyArrayObject *py_PS; + PyArrayObject *py_reciprocal_lattice; + long type; + + long(*bz_grid_addresses)[3]; + long *bz_map; + long *bzg2grg; + long *D_diag; + long(*Q)[3]; + long *PS; + double(*reciprocal_lattice)[3]; + long num_total_gp; + + if (!PyArg_ParseTuple(args, "OOOOOOOl", &py_bz_grid_addresses, &py_bz_map, + &py_bzg2grg, &py_D_diag, &py_Q, &py_PS, + &py_reciprocal_lattice, &type)) { + return NULL; + } + + bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); + bz_map = (long *)PyArray_DATA(py_bz_map); + bzg2grg = (long *)PyArray_DATA(py_bzg2grg); + D_diag = (long *)PyArray_DATA(py_D_diag); + Q = (long(*)[3])PyArray_DATA(py_Q); + PS = (long *)PyArray_DATA(py_PS); + reciprocal_lattice = (double(*)[3])PyArray_DATA(py_reciprocal_lattice); + + num_total_gp = + ph3py_get_bz_grid_addresses(bz_grid_addresses, bz_map, bzg2grg, D_diag, + Q, PS, reciprocal_lattice, type); + + return PyLong_FromLong(num_total_gp); +} + +static PyObject *py_rotate_bz_grid_addresses(PyObject *self, PyObject *args) { + PyArrayObject *py_bz_grid_addresses; + PyArrayObject *py_rotation; + PyArrayObject *py_bz_map; + PyArrayObject *py_D_diag; + PyArrayObject *py_PS; + long bz_grid_index; + long type; + + long(*bz_grid_addresses)[3]; + long(*rotation)[3]; + long *bz_map; + long *D_diag; + long *PS; + long ret_bz_gp; + + if (!PyArg_ParseTuple(args, "lOOOOOl", &bz_grid_index, &py_rotation, + &py_bz_grid_addresses, &py_bz_map, &py_D_diag, &py_PS, + &type)) { + return NULL; + } + + bz_grid_addresses = (long(*)[3])PyArray_DATA(py_bz_grid_addresses); + rotation = (long(*)[3])PyArray_DATA(py_rotation); + bz_map = (long *)PyArray_DATA(py_bz_map); + D_diag = (long *)PyArray_DATA(py_D_diag); + PS = (long *)PyArray_DATA(py_PS); + + ret_bz_gp = ph3py_rotate_bz_grid_index( + bz_grid_index, rotation, bz_grid_addresses, bz_map, D_diag, PS, type); + + return PyLong_FromLong(ret_bz_gp); +} + +static PyObject *py_diagonalize_collision_matrix(PyObject *self, + PyObject *args) { + PyArrayObject *py_collision_matrix; + PyArrayObject *py_eigenvalues; + double cutoff; + long i_sigma, i_temp, is_pinv, solver; + + double *collision_matrix; + double *eigvals; + long num_temp, num_grid_point, num_band; + long num_column, adrs_shift; + long info; + + if (!PyArg_ParseTuple(args, "OOlldll", &py_collision_matrix, + &py_eigenvalues, &i_sigma, &i_temp, &cutoff, &solver, + &is_pinv)) { + return NULL; + } + + collision_matrix = (double *)PyArray_DATA(py_collision_matrix); + eigvals = (double *)PyArray_DATA(py_eigenvalues); + + if (PyArray_NDIM(py_collision_matrix) == 2) { + num_temp = 1; + num_column = (long)PyArray_DIM(py_collision_matrix, 1); + } else { + num_temp = (long)PyArray_DIM(py_collision_matrix, 1); + num_grid_point = (long)PyArray_DIM(py_collision_matrix, 2); + num_band = (long)PyArray_DIM(py_collision_matrix, 3); + if (PyArray_NDIM(py_collision_matrix) == 8) { + num_column = num_grid_point * num_band * 3; + } else { + num_column = num_grid_point * num_band; + } + } + adrs_shift = (i_sigma * num_column * num_column * num_temp + + i_temp * num_column * num_column); + + /* show_colmat_info(py_collision_matrix, i_sigma, i_temp, adrs_shift); */ + + info = phonopy_dsyev(collision_matrix + adrs_shift, eigvals, num_column, + solver); + if (is_pinv) { + pinv_from_eigensolution(collision_matrix + adrs_shift, eigvals, + num_column, cutoff, 0); + } + + return PyLong_FromLong(info); +} + +static PyObject *py_pinv_from_eigensolution(PyObject *self, PyObject *args) { + PyArrayObject *py_collision_matrix; + PyArrayObject *py_eigenvalues; + double cutoff; + long i_sigma, i_temp, pinv_method; + + double *collision_matrix; + double *eigvals; + long num_temp, num_grid_point, num_band; + long num_column, adrs_shift; + + if (!PyArg_ParseTuple(args, "OOlldl", &py_collision_matrix, &py_eigenvalues, + &i_sigma, &i_temp, &cutoff, &pinv_method)) { + return NULL; + } + + collision_matrix = (double *)PyArray_DATA(py_collision_matrix); + eigvals = (double *)PyArray_DATA(py_eigenvalues); + num_temp = (long)PyArray_DIMS(py_collision_matrix)[1]; + num_grid_point = (long)PyArray_DIMS(py_collision_matrix)[2]; + num_band = (long)PyArray_DIMS(py_collision_matrix)[3]; + + if (PyArray_NDIM(py_collision_matrix) == 8) { + num_column = num_grid_point * num_band * 3; + } else { + num_column = num_grid_point * num_band; + } + adrs_shift = (i_sigma * num_column * num_column * num_temp + + i_temp * num_column * num_column); + + /* show_colmat_info(py_collision_matrix, i_sigma, i_temp, adrs_shift); */ + + pinv_from_eigensolution(collision_matrix + adrs_shift, eigvals, num_column, + cutoff, pinv_method); + + Py_RETURN_NONE; +} + +static PyObject *py_get_default_colmat_solver(PyObject *self, PyObject *args) { + if (!PyArg_ParseTuple(args, "")) { + return NULL; + } #ifdef MKL_LAPACKE - return PyLong_FromLong((long)1); + return PyLong_FromLong((long)1); #else - return PyLong_FromLong((long)4); + return PyLong_FromLong((long)4); #endif } -static void pinv_from_eigensolution(double *data, - const double *eigvals, - const long size, - const double cutoff, - const long pinv_method) -{ - long i, ib, j, k, max_l, i_s, j_s; - double *tmp_data; - double e, sum; - long *l; +static void pinv_from_eigensolution(double *data, const double *eigvals, + const long size, const double cutoff, + const long pinv_method) { + long i, ib, j, k, max_l, i_s, j_s; + double *tmp_data; + double e, sum; + long *l; - l = NULL; - tmp_data = NULL; + l = NULL; + tmp_data = NULL; - tmp_data = (double *)malloc(sizeof(double) * size * size); + tmp_data = (double *)malloc(sizeof(double) * size * size); #ifdef PHPYOPENMP #pragma omp parallel for #endif - for (i = 0; i < size * size; i++) - { - tmp_data[i] = data[i]; - } + for (i = 0; i < size * size; i++) { + tmp_data[i] = data[i]; + } - l = (long *)malloc(sizeof(long) * size); - max_l = 0; - for (i = 0; i < size; i++) - { - if (pinv_method == 0) - { - e = fabs(eigvals[i]); + l = (long *)malloc(sizeof(long) * size); + max_l = 0; + for (i = 0; i < size; i++) { + if (pinv_method == 0) { + e = fabs(eigvals[i]); + } else { + e = eigvals[i]; + } + if (e > cutoff) { + l[max_l] = i; + max_l++; + } } - else - { - e = eigvals[i]; - } - if (e > cutoff) - { - l[max_l] = i; - max_l++; - } - } #ifdef PHPYOPENMP #pragma omp parallel for private(ib, j, k, i_s, j_s, sum) #endif - for (i = 0; i < size / 2; i++) - { - /* from front */ - i_s = i * size; - for (j = i; j < size; j++) - { - j_s = j * size; - sum = 0; - for (k = 0; k < max_l; k++) - { - sum += tmp_data[i_s + l[k]] * tmp_data[j_s + l[k]] / eigvals[l[k]]; - } - data[i_s + j] = sum; - data[j_s + i] = sum; + for (i = 0; i < size / 2; i++) { + /* from front */ + i_s = i * size; + for (j = i; j < size; j++) { + j_s = j * size; + sum = 0; + for (k = 0; k < max_l; k++) { + sum += + tmp_data[i_s + l[k]] * tmp_data[j_s + l[k]] / eigvals[l[k]]; + } + data[i_s + j] = sum; + data[j_s + i] = sum; + } + /* from back */ + ib = size - i - 1; + i_s = ib * size; + for (j = ib; j < size; j++) { + j_s = j * size; + sum = 0; + for (k = 0; k < max_l; k++) { + sum += + tmp_data[i_s + l[k]] * tmp_data[j_s + l[k]] / eigvals[l[k]]; + } + data[i_s + j] = sum; + data[j_s + ib] = sum; + } } - /* from back */ - ib = size - i - 1; - i_s = ib * size; - for (j = ib; j < size; j++) - { - j_s = j * size; - sum = 0; - for (k = 0; k < max_l; k++) - { - sum += tmp_data[i_s + l[k]] * tmp_data[j_s + l[k]] / eigvals[l[k]]; - } - data[i_s + j] = sum; - data[j_s + ib] = sum; + + /* when size is odd */ + if ((size % 2) == 1) { + i = (size - 1) / 2; + i_s = i * size; + for (j = i; j < size; j++) { + j_s = j * size; + sum = 0; + for (k = 0; k < max_l; k++) { + sum += + tmp_data[i_s + l[k]] * tmp_data[j_s + l[k]] / eigvals[l[k]]; + } + data[i_s + j] = sum; + data[j_s + i] = sum; + } } - } - /* when size is odd */ - if ((size % 2) == 1) - { - i = (size - 1) / 2; - i_s = i * size; - for (j = i; j < size; j++) - { - j_s = j * size; - sum = 0; - for (k = 0; k < max_l; k++) - { - sum += tmp_data[i_s + l[k]] * tmp_data[j_s + l[k]] / eigvals[l[k]]; - } - data[i_s + j] = sum; - data[j_s + i] = sum; - } - } + free(l); + l = NULL; - free(l); - l = NULL; - - free(tmp_data); - tmp_data = NULL; + free(tmp_data); + tmp_data = NULL; } static void show_colmat_info(const PyArrayObject *py_collision_matrix, - const long i_sigma, - const long i_temp, - const long adrs_shift) -{ - long i; + const long i_sigma, const long i_temp, + const long adrs_shift) { + long i; - printf(" Array_shape:("); - for (i = 0; i < PyArray_NDIM(py_collision_matrix); i++) - { - printf("%d", (int)PyArray_DIM(py_collision_matrix, i)); - if (i < PyArray_NDIM(py_collision_matrix) - 1) - { - printf(","); + printf(" Array_shape:("); + for (i = 0; i < PyArray_NDIM(py_collision_matrix); i++) { + printf("%d", (int)PyArray_DIM(py_collision_matrix, i)); + if (i < PyArray_NDIM(py_collision_matrix) - 1) { + printf(","); + } else { + printf("), "); + } } - else - { - printf("), "); + printf("Data shift:%lu [%lu, %lu]\n", adrs_shift, i_sigma, i_temp); +} + +static Larray *convert_to_larray(const PyArrayObject *npyary) { + long i; + Larray *ary; + + ary = (Larray *)malloc(sizeof(Larray)); + for (i = 0; i < PyArray_NDIM(npyary); i++) { + ary->dims[i] = PyArray_DIMS(npyary)[i]; } - } - printf("Data shift:%lu [%lu, %lu]\n", adrs_shift, i_sigma, i_temp); + ary->data = (long *)PyArray_DATA(npyary); + return ary; } -static Larray *convert_to_larray(const PyArrayObject *npyary) -{ - long i; - Larray *ary; +static Darray *convert_to_darray(const PyArrayObject *npyary) { + int i; + Darray *ary; - ary = (Larray *)malloc(sizeof(Larray)); - for (i = 0; i < PyArray_NDIM(npyary); i++) - { - ary->dims[i] = PyArray_DIMS(npyary)[i]; - } - ary->data = (long *)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; + 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; } diff --git a/c/_phononmod.c b/c/_phononmod.c index 78f36415..d03c9298 100644 --- a/c/_phononmod.c +++ b/c/_phononmod.c @@ -34,14 +34,14 @@ #include #include + #include "lapack_wrapper.h" #include "phononmod.h" static PyObject *py_get_phonons_at_gridpoints(PyObject *self, PyObject *args); -struct module_state -{ - PyObject *error; +struct module_state { + PyObject *error; }; #if PY_MAJOR_VERSION >= 3 @@ -51,52 +51,38 @@ struct module_state static struct module_state _state; #endif -static PyObject * -error_out(PyObject *m) -{ - struct module_state *st = GETSTATE(m); - PyErr_SetString(st->error, "something bad happened"); - return NULL; +static PyObject *error_out(PyObject *m) { + struct module_state *st = GETSTATE(m); + PyErr_SetString(st->error, "something bad happened"); + return NULL; } static PyMethodDef _phononmod_methods[] = { {"error_out", (PyCFunction)error_out, METH_NOARGS, NULL}, - {"phonons_at_gridpoints", - py_get_phonons_at_gridpoints, - METH_VARARGS, + {"phonons_at_gridpoints", py_get_phonons_at_gridpoints, METH_VARARGS, "Set phonons at grid points"}, {NULL, NULL, 0, NULL}}; #if PY_MAJOR_VERSION >= 3 -static int _phononmod_traverse(PyObject *m, visitproc visit, void *arg) -{ - Py_VISIT(GETSTATE(m)->error); - return 0; +static int _phononmod_traverse(PyObject *m, visitproc visit, void *arg) { + Py_VISIT(GETSTATE(m)->error); + return 0; } -static int _phononmod_clear(PyObject *m) -{ - Py_CLEAR(GETSTATE(m)->error); - return 0; +static int _phononmod_clear(PyObject *m) { + Py_CLEAR(GETSTATE(m)->error); + return 0; } static struct PyModuleDef moduledef = { - PyModuleDef_HEAD_INIT, - "_phononmod", - NULL, - sizeof(struct module_state), - _phononmod_methods, - NULL, - _phononmod_traverse, - _phononmod_clear, - NULL}; + PyModuleDef_HEAD_INIT, "_phononmod", NULL, + sizeof(struct module_state), _phononmod_methods, NULL, + _phononmod_traverse, _phononmod_clear, NULL}; #define INITERROR return NULL -PyObject * -PyInit__phononmod(void) - +PyObject *PyInit__phononmod(void) #else #define INITERROR return @@ -104,205 +90,143 @@ void init_phononmod(void) #endif { #if PY_MAJOR_VERSION >= 3 - PyObject *module = PyModule_Create(&moduledef); + PyObject *module = PyModule_Create(&moduledef); #else - PyObject *module = Py_InitModule("_phononmod", _phononmod_methods); + PyObject *module = Py_InitModule("_phononmod", _phononmod_methods); #endif - struct module_state *st; + struct module_state *st; - if (module == NULL) - INITERROR; - st = GETSTATE(module); + if (module == NULL) INITERROR; + st = GETSTATE(module); - st->error = PyErr_NewException("_phononmod.Error", NULL, NULL); - if (st->error == NULL) - { - Py_DECREF(module); - INITERROR; - } + st->error = PyErr_NewException("_phononmod.Error", NULL, NULL); + if (st->error == NULL) { + Py_DECREF(module); + INITERROR; + } #if PY_MAJOR_VERSION >= 3 - return module; + return module; #endif } -static PyObject *py_get_phonons_at_gridpoints(PyObject *self, PyObject *args) -{ - PyArrayObject *py_frequencies; - PyArrayObject *py_eigenvectors; - PyArrayObject *py_phonon_done; - PyArrayObject *py_grid_points; - PyArrayObject *py_grid_address; - PyArrayObject *py_QDinv; - PyArrayObject *py_shortest_vectors_fc2; - PyArrayObject *py_multiplicity_fc2; - PyArrayObject *py_positions_fc2; - PyArrayObject *py_fc2; - PyArrayObject *py_masses_fc2; - PyArrayObject *py_p2s_map_fc2; - PyArrayObject *py_s2p_map_fc2; - PyArrayObject *py_reciprocal_lattice; - PyArrayObject *py_born_effective_charge; - PyArrayObject *py_q_direction; - PyArrayObject *py_dielectric_constant; - PyArrayObject *py_dd_q0; - PyArrayObject *py_G_list; - double nac_factor; - double unit_conversion_factor; - double lambda; - char *uplo; +static PyObject *py_get_phonons_at_gridpoints(PyObject *self, PyObject *args) { + PyArrayObject *py_frequencies; + PyArrayObject *py_eigenvectors; + PyArrayObject *py_phonon_done; + PyArrayObject *py_grid_points; + PyArrayObject *py_grid_address; + PyArrayObject *py_QDinv; + PyArrayObject *py_shortest_vectors_fc2; + PyArrayObject *py_multiplicity_fc2; + PyArrayObject *py_positions_fc2; + PyArrayObject *py_fc2; + PyArrayObject *py_masses_fc2; + PyArrayObject *py_p2s_map_fc2; + PyArrayObject *py_s2p_map_fc2; + PyArrayObject *py_reciprocal_lattice; + PyArrayObject *py_born_effective_charge; + PyArrayObject *py_q_direction; + PyArrayObject *py_dielectric_constant; + PyArrayObject *py_dd_q0; + PyArrayObject *py_G_list; + double nac_factor; + double unit_conversion_factor; + double lambda; + char *uplo; - double(*born)[3][3]; - double(*dielectric)[3]; - double *q_dir; - double *freqs; - lapack_complex_double *eigvecs; - char *phonon_done; - long *grid_points; - long(*grid_address)[3]; - double(*QDinv)[3]; - double *fc2; - double(*svecs_fc2)[3]; - long(*multi_fc2)[2]; - double(*positions_fc2)[3]; - double *masses_fc2; - long *p2s_fc2; - long *s2p_fc2; - double(*rec_lat)[3]; - double *dd_q0; - double(*G_list)[3]; - long num_patom, num_satom, num_phonons, num_grid_points, num_G_points; + double(*born)[3][3]; + double(*dielectric)[3]; + double *q_dir; + double *freqs; + lapack_complex_double *eigvecs; + char *phonon_done; + long *grid_points; + long(*grid_address)[3]; + double(*QDinv)[3]; + double *fc2; + double(*svecs_fc2)[3]; + long(*multi_fc2)[2]; + double(*positions_fc2)[3]; + double *masses_fc2; + long *p2s_fc2; + long *s2p_fc2; + double(*rec_lat)[3]; + double *dd_q0; + double(*G_list)[3]; + long num_patom, num_satom, num_phonons, num_grid_points, num_G_points; - if (!PyArg_ParseTuple(args, "OOOOOOOOOOOOOdOOOOdOOds", - &py_frequencies, - &py_eigenvectors, - &py_phonon_done, - &py_grid_points, - &py_grid_address, - &py_QDinv, - &py_fc2, - &py_shortest_vectors_fc2, - &py_multiplicity_fc2, - &py_positions_fc2, - &py_masses_fc2, - &py_p2s_map_fc2, - &py_s2p_map_fc2, - &unit_conversion_factor, - &py_born_effective_charge, - &py_dielectric_constant, - &py_reciprocal_lattice, - &py_q_direction, - &nac_factor, - &py_dd_q0, - &py_G_list, - &lambda, - &uplo)) - { - return NULL; - } - - freqs = (double *)PyArray_DATA(py_frequencies); - eigvecs = (lapack_complex_double *)PyArray_DATA(py_eigenvectors); - phonon_done = (char *)PyArray_DATA(py_phonon_done); - grid_points = (long *)PyArray_DATA(py_grid_points); - grid_address = (long(*)[3])PyArray_DATA(py_grid_address); - QDinv = (double(*)[3])PyArray_DATA(py_QDinv); - fc2 = (double *)PyArray_DATA(py_fc2); - svecs_fc2 = (double(*)[3])PyArray_DATA(py_shortest_vectors_fc2); - multi_fc2 = (long(*)[2])PyArray_DATA(py_multiplicity_fc2); - masses_fc2 = (double *)PyArray_DATA(py_masses_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 = (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 - { - born = (double(*)[3][3])PyArray_DATA(py_born_effective_charge); - } - if ((PyObject *)py_dielectric_constant == Py_None) - { - dielectric = NULL; - } - else - { - dielectric = (double(*)[3])PyArray_DATA(py_dielectric_constant); - } - if ((PyObject *)py_q_direction == Py_None) - { - q_dir = NULL; - } - else - { - q_dir = (double *)PyArray_DATA(py_q_direction); - if (fabs(q_dir[0]) < 1e-10 && - fabs(q_dir[1]) < 1e-10 && - fabs(q_dir[2]) < 1e-10) - { - q_dir = NULL; + if (!PyArg_ParseTuple( + args, "OOOOOOOOOOOOOdOOOOdOOds", &py_frequencies, &py_eigenvectors, + &py_phonon_done, &py_grid_points, &py_grid_address, &py_QDinv, + &py_fc2, &py_shortest_vectors_fc2, &py_multiplicity_fc2, + &py_positions_fc2, &py_masses_fc2, &py_p2s_map_fc2, &py_s2p_map_fc2, + &unit_conversion_factor, &py_born_effective_charge, + &py_dielectric_constant, &py_reciprocal_lattice, &py_q_direction, + &nac_factor, &py_dd_q0, &py_G_list, &lambda, &uplo)) { + return NULL; } - } - if ((PyObject *)py_dd_q0 == Py_None) - { - dd_q0 = NULL; - } - else - { - dd_q0 = (double *)PyArray_DATA(py_dd_q0); - } - if ((PyObject *)py_G_list == Py_None) - { - G_list = NULL; - num_G_points = 0; - } - else - { - G_list = (double(*)[3])PyArray_DATA(py_G_list); - num_G_points = (long)PyArray_DIMS(py_G_list)[0]; - } - if ((PyObject *)py_positions_fc2 == Py_None) - { - positions_fc2 = NULL; - } - else - { - positions_fc2 = (double(*)[3])PyArray_DATA(py_positions_fc2); - } - phmod_get_phonons_at_gridpoints(freqs, - eigvecs, - phonon_done, - num_phonons, - grid_points, - num_grid_points, - grid_address, - QDinv, - fc2, - svecs_fc2, - multi_fc2, - positions_fc2, - num_patom, - num_satom, - masses_fc2, - p2s_fc2, - s2p_fc2, - unit_conversion_factor, - born, - dielectric, - rec_lat, - q_dir, - nac_factor, - dd_q0, - G_list, - num_G_points, - lambda, - uplo[0]); + freqs = (double *)PyArray_DATA(py_frequencies); + eigvecs = (lapack_complex_double *)PyArray_DATA(py_eigenvectors); + phonon_done = (char *)PyArray_DATA(py_phonon_done); + grid_points = (long *)PyArray_DATA(py_grid_points); + grid_address = (long(*)[3])PyArray_DATA(py_grid_address); + QDinv = (double(*)[3])PyArray_DATA(py_QDinv); + fc2 = (double *)PyArray_DATA(py_fc2); + svecs_fc2 = (double(*)[3])PyArray_DATA(py_shortest_vectors_fc2); + multi_fc2 = (long(*)[2])PyArray_DATA(py_multiplicity_fc2); + masses_fc2 = (double *)PyArray_DATA(py_masses_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 = (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 { + born = (double(*)[3][3])PyArray_DATA(py_born_effective_charge); + } + if ((PyObject *)py_dielectric_constant == Py_None) { + dielectric = NULL; + } else { + dielectric = (double(*)[3])PyArray_DATA(py_dielectric_constant); + } + if ((PyObject *)py_q_direction == Py_None) { + q_dir = NULL; + } else { + q_dir = (double *)PyArray_DATA(py_q_direction); + if (fabs(q_dir[0]) < 1e-10 && fabs(q_dir[1]) < 1e-10 && + fabs(q_dir[2]) < 1e-10) { + q_dir = NULL; + } + } + if ((PyObject *)py_dd_q0 == Py_None) { + dd_q0 = NULL; + } else { + dd_q0 = (double *)PyArray_DATA(py_dd_q0); + } + if ((PyObject *)py_G_list == Py_None) { + G_list = NULL; + num_G_points = 0; + } else { + G_list = (double(*)[3])PyArray_DATA(py_G_list); + num_G_points = (long)PyArray_DIMS(py_G_list)[0]; + } + if ((PyObject *)py_positions_fc2 == Py_None) { + positions_fc2 = NULL; + } else { + positions_fc2 = (double(*)[3])PyArray_DATA(py_positions_fc2); + } - Py_RETURN_NONE; + phmod_get_phonons_at_gridpoints( + freqs, eigvecs, phonon_done, num_phonons, grid_points, num_grid_points, + grid_address, QDinv, fc2, svecs_fc2, multi_fc2, positions_fc2, + num_patom, num_satom, masses_fc2, p2s_fc2, s2p_fc2, + unit_conversion_factor, born, dielectric, rec_lat, q_dir, nac_factor, + dd_q0, G_list, num_G_points, lambda, uplo[0]); + + Py_RETURN_NONE; } diff --git a/c/bzgrid.c b/c/bzgrid.c index 1e327e8e..fb938e1a 100644 --- a/c/bzgrid.c +++ b/c/bzgrid.c @@ -32,555 +32,373 @@ /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ +#include "bzgrid.h" + +#include #include #include -#include -#include "bzgrid.h" + #include "grgrid.h" #include "lagrid.h" #define BZG_NUM_BZ_SEARCH_SPACE 125 #define GRID_TOLERANCE_FACTOR 0.01 static long bz_search_space[BZG_NUM_BZ_SEARCH_SPACE][3] = { - {0, 0, 0}, - {0, 0, 1}, - {0, 0, 2}, - {0, 0, -2}, - {0, 0, -1}, - {0, 1, 0}, - {0, 1, 1}, - {0, 1, 2}, - {0, 1, -2}, - {0, 1, -1}, - {0, 2, 0}, - {0, 2, 1}, - {0, 2, 2}, - {0, 2, -2}, - {0, 2, -1}, - {0, -2, 0}, - {0, -2, 1}, - {0, -2, 2}, - {0, -2, -2}, - {0, -2, -1}, - {0, -1, 0}, - {0, -1, 1}, - {0, -1, 2}, - {0, -1, -2}, - {0, -1, -1}, - {1, 0, 0}, - {1, 0, 1}, - {1, 0, 2}, - {1, 0, -2}, - {1, 0, -1}, - {1, 1, 0}, - {1, 1, 1}, - {1, 1, 2}, - {1, 1, -2}, - {1, 1, -1}, - {1, 2, 0}, - {1, 2, 1}, - {1, 2, 2}, - {1, 2, -2}, - {1, 2, -1}, - {1, -2, 0}, - {1, -2, 1}, - {1, -2, 2}, - {1, -2, -2}, - {1, -2, -1}, - {1, -1, 0}, - {1, -1, 1}, - {1, -1, 2}, - {1, -1, -2}, - {1, -1, -1}, - {2, 0, 0}, - {2, 0, 1}, - {2, 0, 2}, - {2, 0, -2}, - {2, 0, -1}, - {2, 1, 0}, - {2, 1, 1}, - {2, 1, 2}, - {2, 1, -2}, - {2, 1, -1}, - {2, 2, 0}, - {2, 2, 1}, - {2, 2, 2}, - {2, 2, -2}, - {2, 2, -1}, - {2, -2, 0}, - {2, -2, 1}, - {2, -2, 2}, - {2, -2, -2}, - {2, -2, -1}, - {2, -1, 0}, - {2, -1, 1}, - {2, -1, 2}, - {2, -1, -2}, - {2, -1, -1}, - {-2, 0, 0}, - {-2, 0, 1}, - {-2, 0, 2}, - {-2, 0, -2}, - {-2, 0, -1}, - {-2, 1, 0}, - {-2, 1, 1}, - {-2, 1, 2}, - {-2, 1, -2}, - {-2, 1, -1}, - {-2, 2, 0}, - {-2, 2, 1}, - {-2, 2, 2}, - {-2, 2, -2}, - {-2, 2, -1}, - {-2, -2, 0}, - {-2, -2, 1}, - {-2, -2, 2}, - {-2, -2, -2}, - {-2, -2, -1}, - {-2, -1, 0}, - {-2, -1, 1}, - {-2, -1, 2}, - {-2, -1, -2}, - {-2, -1, -1}, - {-1, 0, 0}, - {-1, 0, 1}, - {-1, 0, 2}, - {-1, 0, -2}, - {-1, 0, -1}, - {-1, 1, 0}, - {-1, 1, 1}, - {-1, 1, 2}, - {-1, 1, -2}, - {-1, 1, -1}, - {-1, 2, 0}, - {-1, 2, 1}, - {-1, 2, 2}, - {-1, 2, -2}, - {-1, 2, -1}, - {-1, -2, 0}, - {-1, -2, 1}, - {-1, -2, 2}, - {-1, -2, -2}, - {-1, -2, -1}, - {-1, -1, 0}, - {-1, -1, 1}, - {-1, -1, 2}, - {-1, -1, -2}, - {-1, -1, -1}}; + {0, 0, 0}, {0, 0, 1}, {0, 0, 2}, {0, 0, -2}, {0, 0, -1}, + {0, 1, 0}, {0, 1, 1}, {0, 1, 2}, {0, 1, -2}, {0, 1, -1}, + {0, 2, 0}, {0, 2, 1}, {0, 2, 2}, {0, 2, -2}, {0, 2, -1}, + {0, -2, 0}, {0, -2, 1}, {0, -2, 2}, {0, -2, -2}, {0, -2, -1}, + {0, -1, 0}, {0, -1, 1}, {0, -1, 2}, {0, -1, -2}, {0, -1, -1}, + {1, 0, 0}, {1, 0, 1}, {1, 0, 2}, {1, 0, -2}, {1, 0, -1}, + {1, 1, 0}, {1, 1, 1}, {1, 1, 2}, {1, 1, -2}, {1, 1, -1}, + {1, 2, 0}, {1, 2, 1}, {1, 2, 2}, {1, 2, -2}, {1, 2, -1}, + {1, -2, 0}, {1, -2, 1}, {1, -2, 2}, {1, -2, -2}, {1, -2, -1}, + {1, -1, 0}, {1, -1, 1}, {1, -1, 2}, {1, -1, -2}, {1, -1, -1}, + {2, 0, 0}, {2, 0, 1}, {2, 0, 2}, {2, 0, -2}, {2, 0, -1}, + {2, 1, 0}, {2, 1, 1}, {2, 1, 2}, {2, 1, -2}, {2, 1, -1}, + {2, 2, 0}, {2, 2, 1}, {2, 2, 2}, {2, 2, -2}, {2, 2, -1}, + {2, -2, 0}, {2, -2, 1}, {2, -2, 2}, {2, -2, -2}, {2, -2, -1}, + {2, -1, 0}, {2, -1, 1}, {2, -1, 2}, {2, -1, -2}, {2, -1, -1}, + {-2, 0, 0}, {-2, 0, 1}, {-2, 0, 2}, {-2, 0, -2}, {-2, 0, -1}, + {-2, 1, 0}, {-2, 1, 1}, {-2, 1, 2}, {-2, 1, -2}, {-2, 1, -1}, + {-2, 2, 0}, {-2, 2, 1}, {-2, 2, 2}, {-2, 2, -2}, {-2, 2, -1}, + {-2, -2, 0}, {-2, -2, 1}, {-2, -2, 2}, {-2, -2, -2}, {-2, -2, -1}, + {-2, -1, 0}, {-2, -1, 1}, {-2, -1, 2}, {-2, -1, -2}, {-2, -1, -1}, + {-1, 0, 0}, {-1, 0, 1}, {-1, 0, 2}, {-1, 0, -2}, {-1, 0, -1}, + {-1, 1, 0}, {-1, 1, 1}, {-1, 1, 2}, {-1, 1, -2}, {-1, 1, -1}, + {-1, 2, 0}, {-1, 2, 1}, {-1, 2, 2}, {-1, 2, -2}, {-1, 2, -1}, + {-1, -2, 0}, {-1, -2, 1}, {-1, -2, 2}, {-1, -2, -2}, {-1, -2, -1}, + {-1, -1, 0}, {-1, -1, 1}, {-1, -1, 2}, {-1, -1, -2}, {-1, -1, -1}}; -static void get_bz_grid_addresses_type1(BZGrid *bzgrid, - const long Qinv[3][3]); -static void get_bz_grid_addresses_type2(BZGrid *bzgrid, - const long Qinv[3][3]); -static void set_bz_address(long address[3], - const long bz_index, - const long grid_address[3], - const long D_diag[3], - const long nint[3], - const long Qinv[3][3]); -static double get_bz_distances(long nint[3], - double distances[], - const BZGrid *bzgrid, - const long grid_address[3], +static void get_bz_grid_addresses_type1(BZGrid *bzgrid, const long Qinv[3][3]); +static void get_bz_grid_addresses_type2(BZGrid *bzgrid, const long Qinv[3][3]); +static void set_bz_address(long address[3], const long bz_index, + const long grid_address[3], const long D_diag[3], + const long nint[3], const long Qinv[3][3]); +static double get_bz_distances(long nint[3], double distances[], + const BZGrid *bzgrid, const long grid_address[3], const double tolerance); -static void multiply_matrix_vector_d3(double v[3], - const double a[3][3], +static void multiply_matrix_vector_d3(double v[3], const double a[3][3], const double b[3]); -static long get_inverse_unimodular_matrix_l3(long m[3][3], - const long a[3][3]); +static long get_inverse_unimodular_matrix_l3(long m[3][3], const long a[3][3]); static double norm_squared_d3(const double a[3]); -long bzg_rotate_grid_index(const long bz_grid_index, - const long rotation[3][3], - const ConstBZGrid *bzgrid) -{ - long i, gp, num_bzgp, num_grgp; - long dadrs[3], dadrs_rot[3], adrs_rot[3]; +long bzg_rotate_grid_index(const long bz_grid_index, const long rotation[3][3], + const ConstBZGrid *bzgrid) { + long i, gp, num_bzgp, num_grgp; + long dadrs[3], dadrs_rot[3], adrs_rot[3]; - grg_get_double_grid_address(dadrs, bzgrid->addresses[bz_grid_index], bzgrid->PS); - lagmat_multiply_matrix_vector_l3(dadrs_rot, rotation, dadrs); - grg_get_grid_address(adrs_rot, dadrs_rot, bzgrid->PS); - gp = grg_get_grid_index(adrs_rot, bzgrid->D_diag); + grg_get_double_grid_address(dadrs, bzgrid->addresses[bz_grid_index], + bzgrid->PS); + lagmat_multiply_matrix_vector_l3(dadrs_rot, rotation, dadrs); + grg_get_grid_address(adrs_rot, dadrs_rot, bzgrid->PS); + gp = grg_get_grid_index(adrs_rot, bzgrid->D_diag); - if (bzgrid->type == 1) - { - if (bzgrid->addresses[gp][0] == adrs_rot[0] && - bzgrid->addresses[gp][1] == adrs_rot[1] && - bzgrid->addresses[gp][2] == adrs_rot[2]) - { - return gp; + if (bzgrid->type == 1) { + if (bzgrid->addresses[gp][0] == adrs_rot[0] && + bzgrid->addresses[gp][1] == adrs_rot[1] && + bzgrid->addresses[gp][2] == adrs_rot[2]) { + return gp; + } + num_grgp = bzgrid->D_diag[0] * bzgrid->D_diag[1] * bzgrid->D_diag[2]; + num_bzgp = num_grgp * 8; + for (i = bzgrid->gp_map[num_bzgp + gp] + num_grgp; + i < bzgrid->gp_map[num_bzgp + gp + 1] + num_grgp; i++) { + if (bzgrid->addresses[i][0] == adrs_rot[0] && + bzgrid->addresses[i][1] == adrs_rot[1] && + bzgrid->addresses[i][2] == adrs_rot[2]) { + return i; + } + } + } else { + for (i = bzgrid->gp_map[gp]; i < bzgrid->gp_map[gp + 1]; i++) { + if (bzgrid->addresses[i][0] == adrs_rot[0] && + bzgrid->addresses[i][1] == adrs_rot[1] && + bzgrid->addresses[i][2] == adrs_rot[2]) { + return i; + } + } } - num_grgp = bzgrid->D_diag[0] * bzgrid->D_diag[1] * bzgrid->D_diag[2]; - num_bzgp = num_grgp * 8; - for (i = bzgrid->gp_map[num_bzgp + gp] + num_grgp; - i < bzgrid->gp_map[num_bzgp + gp + 1] + num_grgp; i++) - { - if (bzgrid->addresses[i][0] == adrs_rot[0] && - bzgrid->addresses[i][1] == adrs_rot[1] && - bzgrid->addresses[i][2] == adrs_rot[2]) - { - return i; - } - } - } - else - { - for (i = bzgrid->gp_map[gp]; i < bzgrid->gp_map[gp + 1]; i++) - { - if (bzgrid->addresses[i][0] == adrs_rot[0] && - bzgrid->addresses[i][1] == adrs_rot[1] && - bzgrid->addresses[i][2] == adrs_rot[2]) - { - return i; - } - } - } - /* This should not happen, but possible when bzgrid is ill-defined. */ - return bzgrid->gp_map[gp]; + /* This should not happen, but possible when bzgrid is ill-defined. */ + return bzgrid->gp_map[gp]; } -long bzg_get_bz_grid_addresses(BZGrid *bzgrid) -{ - long det; - long Qinv[3][3]; +long bzg_get_bz_grid_addresses(BZGrid *bzgrid) { + long det; + long Qinv[3][3]; - det = get_inverse_unimodular_matrix_l3(Qinv, bzgrid->Q); - if (det == 0) - { - return 0; - } + det = get_inverse_unimodular_matrix_l3(Qinv, bzgrid->Q); + if (det == 0) { + return 0; + } - if (bzgrid->type == 1) - { - get_bz_grid_addresses_type1(bzgrid, Qinv); - } - else - { - get_bz_grid_addresses_type2(bzgrid, Qinv); - } + if (bzgrid->type == 1) { + get_bz_grid_addresses_type1(bzgrid, Qinv); + } else { + get_bz_grid_addresses_type2(bzgrid, Qinv); + } - return 1; + return 1; } /* Note: Tolerance in squared distance. */ -double bzg_get_tolerance_for_BZ_reduction(const BZGrid *bzgrid) -{ - long i, j; - double tolerance; - double length[3]; - double reclatQ[3][3]; +double bzg_get_tolerance_for_BZ_reduction(const BZGrid *bzgrid) { + long i, j; + double tolerance; + double length[3]; + double reclatQ[3][3]; - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - reclatQ[i][j] = - bzgrid->reclat[i][0] * bzgrid->Q[0][j] + bzgrid->reclat[i][1] * bzgrid->Q[1][j] + bzgrid->reclat[i][2] * bzgrid->Q[2][j]; - } - } - - for (i = 0; i < 3; i++) - { - length[i] = 0; - for (j = 0; j < 3; j++) - { - length[i] += reclatQ[j][i] * reclatQ[j][i]; - } - length[i] /= bzgrid->D_diag[i] * bzgrid->D_diag[i]; - } - tolerance = length[0]; - for (i = 1; i < 3; i++) - { - if (tolerance < length[i]) - { - tolerance = length[i]; - } - } - tolerance *= GRID_TOLERANCE_FACTOR; - - return tolerance; -} - -RotMats *bzg_alloc_RotMats(const long size) -{ - RotMats *rotmats; - - rotmats = NULL; - - if ((rotmats = (RotMats *)malloc(sizeof(RotMats))) == NULL) - { - warning_print("Memory could not be allocated."); - return NULL; - } - - rotmats->size = size; - if (size > 0) - { - if ((rotmats->mat = (long(*)[3][3])malloc(sizeof(long[3][3]) * size)) == NULL) - { - warning_print("Memory could not be allocated "); - warning_print("(RotMats, line %d, %s).\n", __LINE__, __FILE__); - free(rotmats); - rotmats = NULL; - return NULL; - } - } - return rotmats; -} - -void bzg_free_RotMats(RotMats *rotmats) -{ - if (rotmats->size > 0) - { - free(rotmats->mat); - rotmats->mat = NULL; - } - free(rotmats); -} - -void bzg_multiply_matrix_vector_ld3(double v[3], - const long a[3][3], - const double b[3]) -{ - long i; - double c[3]; - for (i = 0; i < 3; i++) - { - c[i] = a[i][0] * b[0] + a[i][1] * b[1] + a[i][2] * b[2]; - } - for (i = 0; i < 3; i++) - { - v[i] = c[i]; - } -} - -static void get_bz_grid_addresses_type1(BZGrid *bzgrid, - const long Qinv[3][3]) -{ - double tolerance, min_distance; - double distances[BZG_NUM_BZ_SEARCH_SPACE]; - long bzmesh[3], bz_address_double[3], nint[3], gr_adrs[3]; - long i, j, k, boundary_num_gp, total_num_gp, bzgp, gp, num_bzmesh; - long count, id_shift; - - tolerance = bzg_get_tolerance_for_BZ_reduction(bzgrid); - for (j = 0; j < 3; j++) - { - bzmesh[j] = bzgrid->D_diag[j] * 2; - } - - num_bzmesh = bzmesh[0] * bzmesh[1] * bzmesh[2]; - for (i = 0; i < num_bzmesh; i++) - { - bzgrid->gp_map[i] = num_bzmesh; - } - - boundary_num_gp = 0; - total_num_gp = bzgrid->D_diag[0] * bzgrid->D_diag[1] * bzgrid->D_diag[2]; - - /* Multithreading doesn't work for this loop since gp calculated */ - /* with boundary_num_gp is unstable to store bz_grid_address. */ - bzgrid->gp_map[num_bzmesh] = 0; - id_shift = 0; - for (i = 0; i < total_num_gp; i++) - { - grg_get_grid_address_from_index(gr_adrs, i, bzgrid->D_diag); - min_distance = get_bz_distances(nint, distances, bzgrid, - gr_adrs, tolerance); - count = 0; - for (j = 0; j < BZG_NUM_BZ_SEARCH_SPACE; j++) - { - if (distances[j] < min_distance + tolerance) - { - if (count == 0) - { - gp = i; + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + reclatQ[i][j] = bzgrid->reclat[i][0] * bzgrid->Q[0][j] + + bzgrid->reclat[i][1] * bzgrid->Q[1][j] + + bzgrid->reclat[i][2] * bzgrid->Q[2][j]; } - else - { - gp = boundary_num_gp + total_num_gp; - boundary_num_gp++; + } + + for (i = 0; i < 3; i++) { + length[i] = 0; + for (j = 0; j < 3; j++) { + length[i] += reclatQ[j][i] * reclatQ[j][i]; } - count++; - set_bz_address(bzgrid->addresses[gp], - j, - gr_adrs, - bzgrid->D_diag, - nint, - Qinv); - for (k = 0; k < 3; k++) - { - bz_address_double[k] = bzgrid->addresses[gp][k] * 2 + bzgrid->PS[k]; + length[i] /= bzgrid->D_diag[i] * bzgrid->D_diag[i]; + } + tolerance = length[0]; + for (i = 1; i < 3; i++) { + if (tolerance < length[i]) { + tolerance = length[i]; } - bzgp = grg_get_double_grid_index( - bz_address_double, bzmesh, bzgrid->PS); - bzgrid->gp_map[bzgp] = gp; - bzgrid->bzg2grg[gp] = i; - } } - /* This is used in get_BZ_triplets_at_q_type1. */ - /* The first one among those found is treated specially, so */ - /* excluded from the gp_map address shift by -1. */ - id_shift += count - 1; - bzgrid->gp_map[num_bzmesh + i + 1] = id_shift; - } - bzgrid->size = boundary_num_gp + total_num_gp; + tolerance *= GRID_TOLERANCE_FACTOR; + + return tolerance; } -static void get_bz_grid_addresses_type2(BZGrid *bzgrid, - const long Qinv[3][3]) -{ - double tolerance, min_distance; - double distances[BZG_NUM_BZ_SEARCH_SPACE]; - long nint[3], gr_adrs[3]; - long i, j, num_gp; +RotMats *bzg_alloc_RotMats(const long size) { + RotMats *rotmats; - tolerance = bzg_get_tolerance_for_BZ_reduction(bzgrid); - num_gp = 0; - /* The first element of gp_map is always 0. */ - bzgrid->gp_map[0] = 0; + rotmats = NULL; - for (i = 0; - i < bzgrid->D_diag[0] * bzgrid->D_diag[1] * bzgrid->D_diag[2]; i++) - { - grg_get_grid_address_from_index(gr_adrs, i, bzgrid->D_diag); - min_distance = get_bz_distances(nint, distances, bzgrid, - gr_adrs, tolerance); - for (j = 0; j < BZG_NUM_BZ_SEARCH_SPACE; j++) - { - if (distances[j] < min_distance + tolerance) - { - set_bz_address(bzgrid->addresses[num_gp], - j, - gr_adrs, - bzgrid->D_diag, - nint, - Qinv); - bzgrid->bzg2grg[num_gp] = i; - num_gp++; - } + if ((rotmats = (RotMats *)malloc(sizeof(RotMats))) == NULL) { + warning_print("Memory could not be allocated."); + return NULL; } - bzgrid->gp_map[i + 1] = num_gp; - } - bzgrid->size = num_gp; -} - -static void set_bz_address(long address[3], - const long bz_index, - const long grid_address[3], - const long D_diag[3], - const long nint[3], - const long Qinv[3][3]) -{ - long i; - long deltaG[3]; - - for (i = 0; i < 3; i++) - { - deltaG[i] = bz_search_space[bz_index][i] - nint[i]; - } - lagmat_multiply_matrix_vector_l3(deltaG, Qinv, deltaG); - for (i = 0; i < 3; i++) - { - address[i] = grid_address[i] + deltaG[i] * D_diag[i]; - } -} - -static double get_bz_distances(long nint[3], - double distances[], - const BZGrid *bzgrid, - const long grid_address[3], - const double tolerance) -{ - long i, j; - long dadrs[3]; - double min_distance; - double q_vec[3], q_red[3]; - - grg_get_double_grid_address(dadrs, grid_address, bzgrid->PS); - - for (i = 0; i < 3; i++) - { - q_red[i] = dadrs[i] / (2.0 * bzgrid->D_diag[i]); - } - bzg_multiply_matrix_vector_ld3(q_red, bzgrid->Q, q_red); - for (i = 0; i < 3; i++) - { - nint[i] = lagmat_Nint(q_red[i]); - q_red[i] -= nint[i]; - } - - for (i = 0; i < BZG_NUM_BZ_SEARCH_SPACE; i++) - { - for (j = 0; j < 3; j++) - { - q_vec[j] = q_red[j] + bz_search_space[i][j]; + rotmats->size = size; + if (size > 0) { + if ((rotmats->mat = (long(*)[3][3])malloc(sizeof(long[3][3]) * size)) == + NULL) { + warning_print("Memory could not be allocated "); + warning_print("(RotMats, line %d, %s).\n", __LINE__, __FILE__); + free(rotmats); + rotmats = NULL; + return NULL; + } } - multiply_matrix_vector_d3(q_vec, bzgrid->reclat, q_vec); - distances[i] = norm_squared_d3(q_vec); - } + return rotmats; +} - /* Use of tolerance is important to select first one among similar - * distances. Otherwise the choice of bz grid address among - * those translationally equivalent can change by very tiny numerical - * fluctuation. */ - min_distance = distances[0]; - for (i = 1; i < BZG_NUM_BZ_SEARCH_SPACE; i++) - { - if (distances[i] < min_distance - tolerance) - { - min_distance = distances[i]; +void bzg_free_RotMats(RotMats *rotmats) { + if (rotmats->size > 0) { + free(rotmats->mat); + rotmats->mat = NULL; } - } - - return min_distance; + free(rotmats); } -static void multiply_matrix_vector_d3(double v[3], - const double a[3][3], - const double b[3]) -{ - long i; - double c[3]; - for (i = 0; i < 3; i++) - { - c[i] = a[i][0] * b[0] + a[i][1] * b[1] + a[i][2] * b[2]; - } - for (i = 0; i < 3; i++) - { - v[i] = c[i]; - } +void bzg_multiply_matrix_vector_ld3(double v[3], const long a[3][3], + const double b[3]) { + long i; + double c[3]; + for (i = 0; i < 3; i++) { + c[i] = a[i][0] * b[0] + a[i][1] * b[1] + a[i][2] * b[2]; + } + for (i = 0; i < 3; i++) { + v[i] = c[i]; + } } -static long get_inverse_unimodular_matrix_l3(long m[3][3], - const long a[3][3]) -{ - long det; - long c[3][3]; +static void get_bz_grid_addresses_type1(BZGrid *bzgrid, const long Qinv[3][3]) { + double tolerance, min_distance; + double distances[BZG_NUM_BZ_SEARCH_SPACE]; + long bzmesh[3], bz_address_double[3], nint[3], gr_adrs[3]; + long i, j, k, boundary_num_gp, total_num_gp, bzgp, gp, num_bzmesh; + long count, id_shift; - det = lagmat_get_determinant_l3(a); - if (labs(det) != 1) - { - return 0; - } + tolerance = bzg_get_tolerance_for_BZ_reduction(bzgrid); + for (j = 0; j < 3; j++) { + bzmesh[j] = bzgrid->D_diag[j] * 2; + } - c[0][0] = (a[1][1] * a[2][2] - a[1][2] * a[2][1]) / det; - c[1][0] = (a[1][2] * a[2][0] - a[1][0] * a[2][2]) / det; - c[2][0] = (a[1][0] * a[2][1] - a[1][1] * a[2][0]) / det; - c[0][1] = (a[2][1] * a[0][2] - a[2][2] * a[0][1]) / det; - c[1][1] = (a[2][2] * a[0][0] - a[2][0] * a[0][2]) / det; - c[2][1] = (a[2][0] * a[0][1] - a[2][1] * a[0][0]) / det; - c[0][2] = (a[0][1] * a[1][2] - a[0][2] * a[1][1]) / det; - c[1][2] = (a[0][2] * a[1][0] - a[0][0] * a[1][2]) / det; - c[2][2] = (a[0][0] * a[1][1] - a[0][1] * a[1][0]) / det; - lagmat_copy_matrix_l3(m, c); + num_bzmesh = bzmesh[0] * bzmesh[1] * bzmesh[2]; + for (i = 0; i < num_bzmesh; i++) { + bzgrid->gp_map[i] = num_bzmesh; + } - return det; + boundary_num_gp = 0; + total_num_gp = bzgrid->D_diag[0] * bzgrid->D_diag[1] * bzgrid->D_diag[2]; + + /* Multithreading doesn't work for this loop since gp calculated */ + /* with boundary_num_gp is unstable to store bz_grid_address. */ + bzgrid->gp_map[num_bzmesh] = 0; + id_shift = 0; + for (i = 0; i < total_num_gp; i++) { + grg_get_grid_address_from_index(gr_adrs, i, bzgrid->D_diag); + min_distance = + get_bz_distances(nint, distances, bzgrid, gr_adrs, tolerance); + count = 0; + for (j = 0; j < BZG_NUM_BZ_SEARCH_SPACE; j++) { + if (distances[j] < min_distance + tolerance) { + if (count == 0) { + gp = i; + } else { + gp = boundary_num_gp + total_num_gp; + boundary_num_gp++; + } + count++; + set_bz_address(bzgrid->addresses[gp], j, gr_adrs, + bzgrid->D_diag, nint, Qinv); + for (k = 0; k < 3; k++) { + bz_address_double[k] = + bzgrid->addresses[gp][k] * 2 + bzgrid->PS[k]; + } + bzgp = grg_get_double_grid_index(bz_address_double, bzmesh, + bzgrid->PS); + bzgrid->gp_map[bzgp] = gp; + bzgrid->bzg2grg[gp] = i; + } + } + /* This is used in get_BZ_triplets_at_q_type1. */ + /* The first one among those found is treated specially, so */ + /* excluded from the gp_map address shift by -1. */ + id_shift += count - 1; + bzgrid->gp_map[num_bzmesh + i + 1] = id_shift; + } + bzgrid->size = boundary_num_gp + total_num_gp; } -static double norm_squared_d3(const double a[3]) -{ - return a[0] * a[0] + a[1] * a[1] + a[2] * a[2]; +static void get_bz_grid_addresses_type2(BZGrid *bzgrid, const long Qinv[3][3]) { + double tolerance, min_distance; + double distances[BZG_NUM_BZ_SEARCH_SPACE]; + long nint[3], gr_adrs[3]; + long i, j, num_gp; + + tolerance = bzg_get_tolerance_for_BZ_reduction(bzgrid); + num_gp = 0; + /* The first element of gp_map is always 0. */ + bzgrid->gp_map[0] = 0; + + for (i = 0; i < bzgrid->D_diag[0] * bzgrid->D_diag[1] * bzgrid->D_diag[2]; + i++) { + grg_get_grid_address_from_index(gr_adrs, i, bzgrid->D_diag); + min_distance = + get_bz_distances(nint, distances, bzgrid, gr_adrs, tolerance); + for (j = 0; j < BZG_NUM_BZ_SEARCH_SPACE; j++) { + if (distances[j] < min_distance + tolerance) { + set_bz_address(bzgrid->addresses[num_gp], j, gr_adrs, + bzgrid->D_diag, nint, Qinv); + bzgrid->bzg2grg[num_gp] = i; + num_gp++; + } + } + bzgrid->gp_map[i + 1] = num_gp; + } + + bzgrid->size = num_gp; +} + +static void set_bz_address(long address[3], const long bz_index, + const long grid_address[3], const long D_diag[3], + const long nint[3], const long Qinv[3][3]) { + long i; + long deltaG[3]; + + for (i = 0; i < 3; i++) { + deltaG[i] = bz_search_space[bz_index][i] - nint[i]; + } + lagmat_multiply_matrix_vector_l3(deltaG, Qinv, deltaG); + for (i = 0; i < 3; i++) { + address[i] = grid_address[i] + deltaG[i] * D_diag[i]; + } +} + +static double get_bz_distances(long nint[3], double distances[], + const BZGrid *bzgrid, const long grid_address[3], + const double tolerance) { + long i, j; + long dadrs[3]; + double min_distance; + double q_vec[3], q_red[3]; + + grg_get_double_grid_address(dadrs, grid_address, bzgrid->PS); + + for (i = 0; i < 3; i++) { + q_red[i] = dadrs[i] / (2.0 * bzgrid->D_diag[i]); + } + bzg_multiply_matrix_vector_ld3(q_red, bzgrid->Q, q_red); + for (i = 0; i < 3; i++) { + nint[i] = lagmat_Nint(q_red[i]); + q_red[i] -= nint[i]; + } + + for (i = 0; i < BZG_NUM_BZ_SEARCH_SPACE; i++) { + for (j = 0; j < 3; j++) { + q_vec[j] = q_red[j] + bz_search_space[i][j]; + } + multiply_matrix_vector_d3(q_vec, bzgrid->reclat, q_vec); + distances[i] = norm_squared_d3(q_vec); + } + + /* Use of tolerance is important to select first one among similar + * distances. Otherwise the choice of bz grid address among + * those translationally equivalent can change by very tiny numerical + * fluctuation. */ + min_distance = distances[0]; + for (i = 1; i < BZG_NUM_BZ_SEARCH_SPACE; i++) { + if (distances[i] < min_distance - tolerance) { + min_distance = distances[i]; + } + } + + return min_distance; +} + +static void multiply_matrix_vector_d3(double v[3], const double a[3][3], + const double b[3]) { + long i; + double c[3]; + for (i = 0; i < 3; i++) { + c[i] = a[i][0] * b[0] + a[i][1] * b[1] + a[i][2] * b[2]; + } + for (i = 0; i < 3; i++) { + v[i] = c[i]; + } +} + +static long get_inverse_unimodular_matrix_l3(long m[3][3], const long a[3][3]) { + long det; + long c[3][3]; + + det = lagmat_get_determinant_l3(a); + if (labs(det) != 1) { + return 0; + } + + c[0][0] = (a[1][1] * a[2][2] - a[1][2] * a[2][1]) / det; + c[1][0] = (a[1][2] * a[2][0] - a[1][0] * a[2][2]) / det; + c[2][0] = (a[1][0] * a[2][1] - a[1][1] * a[2][0]) / det; + c[0][1] = (a[2][1] * a[0][2] - a[2][2] * a[0][1]) / det; + c[1][1] = (a[2][2] * a[0][0] - a[2][0] * a[0][2]) / det; + c[2][1] = (a[2][0] * a[0][1] - a[2][1] * a[0][0]) / det; + c[0][2] = (a[0][1] * a[1][2] - a[0][2] * a[1][1]) / det; + c[1][2] = (a[0][2] * a[1][0] - a[0][0] * a[1][2]) / det; + c[2][2] = (a[0][0] * a[1][1] - a[0][1] * a[1][0]) / det; + lagmat_copy_matrix_l3(m, c); + + return det; +} + +static double norm_squared_d3(const double a[3]) { + return a[0] * a[0] + a[1] * a[1] + a[2] * a[2]; } diff --git a/c/bzgrid.h b/c/bzgrid.h index 0105fc23..b1e700de 100644 --- a/c/bzgrid.h +++ b/c/bzgrid.h @@ -35,10 +35,9 @@ #ifndef __bzgrid_H__ #define __bzgrid_H__ -typedef struct -{ - long size; - long (*mat)[3][3]; +typedef struct { + long size; + long (*mat)[3][3]; } RotMats; /* Data structure of Brillouin zone grid @@ -68,41 +67,37 @@ typedef struct * shape=(3, 3) * type : long * 1 or 2. */ -typedef struct -{ - long size; - long D_diag[3]; - long Q[3][3]; - long PS[3]; - long *gp_map; - long *bzg2grg; - long (*addresses)[3]; - double reclat[3][3]; - long type; +typedef struct { + long size; + long D_diag[3]; + long Q[3][3]; + long PS[3]; + long *gp_map; + long *bzg2grg; + long (*addresses)[3]; + double reclat[3][3]; + long type; } BZGrid; -typedef struct -{ - long size; - long D_diag[3]; - long Q[3][3]; - long PS[3]; - const long *gp_map; - const long *bzg2grg; - const long (*addresses)[3]; - double reclat[3][3]; - long type; +typedef struct { + long size; + long D_diag[3]; + long Q[3][3]; + long PS[3]; + const long *gp_map; + const long *bzg2grg; + const long (*addresses)[3]; + double reclat[3][3]; + long type; } ConstBZGrid; -long bzg_rotate_grid_index(const long grid_index, - const long rotation[3][3], +long bzg_rotate_grid_index(const long grid_index, const long rotation[3][3], const ConstBZGrid *bzgrid); long bzg_get_bz_grid_addresses(BZGrid *bzgrid); double bzg_get_tolerance_for_BZ_reduction(const BZGrid *bzgrid); RotMats *bzg_alloc_RotMats(const long size); void bzg_free_RotMats(RotMats *rotmats); -void bzg_multiply_matrix_vector_ld3(double v[3], - const long a[3][3], +void bzg_multiply_matrix_vector_ld3(double v[3], const long a[3][3], const double b[3]); #endif diff --git a/c/collision_matrix.h b/c/collision_matrix.h index 1b95ad77..098b2440 100644 --- a/c/collision_matrix.h +++ b/c/collision_matrix.h @@ -37,31 +37,18 @@ #include "phonoc_array.h" -void col_get_collision_matrix(double *collision_matrix, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplets_map, - const long *map_q, - const long *rot_grid_points, - const double *rotations_cartesian, - const double *g, - const long num_ir_gp, - const long num_gp, - const long num_rot, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency); -void col_get_reducible_collision_matrix(double *collision_matrix, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplets_map, - const long *map_q, - const double *g, - const long num_gp, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency); +void col_get_collision_matrix( + double *collision_matrix, const Darray *fc3_normal_squared, + const double *frequencies, const long (*triplets)[3], + const long *triplets_map, const long *map_q, const long *rot_grid_points, + const double *rotations_cartesian, const double *g, const long num_ir_gp, + const long num_gp, const long num_rot, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency); +void col_get_reducible_collision_matrix( + double *collision_matrix, const Darray *fc3_normal_squared, + const double *frequencies, const long (*triplets)[3], + const long *triplets_map, const long *map_q, const double *g, + const long num_gp, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency); #endif diff --git a/c/dynmat.c b/c/dynmat.c index 2701edf3..dc8f991e 100644 --- a/c/dynmat.c +++ b/c/dynmat.c @@ -32,333 +32,238 @@ /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ +#include "dynmat.h" + #include #include -#include "dynmat.h" #define PI 3.14159265358979323846 -static void get_dynmat_ij(double *dynamical_matrix, - const long num_patom, - const long num_satom, - const double *fc, - const double q[3], - const double (*svecs)[3], - const long (*multi)[2], - const double *mass, - const long *s2p_map, - const long *p2s_map, - const double (*charge_sum)[3][3], - const long i, +static void get_dynmat_ij(double *dynamical_matrix, const long num_patom, + const long num_satom, const double *fc, + const double q[3], const double (*svecs)[3], + const long (*multi)[2], const double *mass, + const long *s2p_map, const long *p2s_map, + const double (*charge_sum)[3][3], const long i, const long j); -static void get_dm(double dm_real[3][3], - double dm_imag[3][3], - const long num_patom, - const long num_satom, - const double *fc, - const double q[3], - const double (*svecs)[3], - const long (*multi)[2], - const long *p2s_map, - const double (*charge_sum)[3][3], - const long i, - const long j, +static void get_dm(double dm_real[3][3], double dm_imag[3][3], + const long num_patom, const long num_satom, const double *fc, + const double q[3], const double (*svecs)[3], + const long (*multi)[2], const long *p2s_map, + const double (*charge_sum)[3][3], const long i, const long j, const long k); static double get_dielectric_part(const double q_cart[3], const double dielectric[3][3]); -static void get_KK(double *dd_part, /* [natom, 3, natom, 3, (real,imag)] */ +static void get_KK(double *dd_part, /* [natom, 3, natom, 3, (real,imag)] */ const double (*G_list)[3], /* [num_G, 3] */ - const long num_G, - const long num_patom, - const double q_cart[3], - const double *q_direction_cart, + const long num_G, const long num_patom, + const double q_cart[3], const double *q_direction_cart, const double dielectric[3][3], const double (*pos)[3], /* [num_patom, 3] */ - const double lambda, - const double tolerance); + const double lambda, const double tolerance); static void make_Hermitian(double *mat, const long num_band); -static void multiply_borns(double *dd, - const double *dd_in, - const long num_patom, - const double (*born)[3][3]); +static void multiply_borns(double *dd, const double *dd_in, + const long num_patom, const double (*born)[3][3]); 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], + const long num_patom, const long num_satom, + const double *fc, const double q[3], const double (*svecs)[3], - const long (*multi)[2], - const double *mass, - const long *s2p_map, - const long *p2s_map, + const long (*multi)[2], const double *mass, + const long *s2p_map, const long *p2s_map, const double (*charge_sum)[3][3], - const long with_openmp) -{ - long i, j, ij; + const long with_openmp) { + long i, j, ij; - if (with_openmp) - { + if (with_openmp) { #ifdef PHPYOPENMP #pragma omp parallel for #endif - for (ij = 0; ij < num_patom * num_patom; ij++) - { - get_dynmat_ij(dynamical_matrix, - num_patom, - num_satom, - fc, - q, - svecs, - multi, - mass, - s2p_map, - p2s_map, - charge_sum, - ij / num_patom, /* i */ - ij % num_patom); /* j */ - } - } - else - { - for (i = 0; i < num_patom; i++) - { - for (j = 0; j < num_patom; j++) - { - get_dynmat_ij(dynamical_matrix, - num_patom, - num_satom, - fc, - q, - svecs, - multi, - mass, - s2p_map, - p2s_map, - charge_sum, - i, - j); - } - } - } - - make_Hermitian(dynamical_matrix, num_patom * 3); - - return 0; -} - -void dym_get_recip_dipole_dipole(double *dd, /* [natom, 3, natom, 3, (real,imag)] */ - const double *dd_q0, /* [natom, 3, 3, (real,imag)] */ - const double (*G_list)[3], /* [num_G, 3] */ - const long num_G, - const long num_patom, - const double q_cart[3], - const double *q_direction_cart, /* must be pointer */ - const double (*born)[3][3], - const double dielectric[3][3], - const double (*pos)[3], /* [num_patom, 3] */ - const double factor, /* 4pi/V*unit-conv */ - const double lambda, - const double tolerance) -{ - long i, k, l, adrs, adrs_sum; - double *dd_tmp; - - dd_tmp = NULL; - dd_tmp = (double *)malloc(sizeof(double) * num_patom * num_patom * 18); - - for (i = 0; i < num_patom * num_patom * 18; i++) - { - dd[i] = 0; - dd_tmp[i] = 0; - } - - get_KK(dd_tmp, - G_list, - num_G, - num_patom, - q_cart, - q_direction_cart, - dielectric, - pos, - lambda, - tolerance); - - multiply_borns(dd, dd_tmp, num_patom, born); - - for (i = 0; i < num_patom; i++) - { - for (k = 0; k < 3; k++) - { /* alpha */ - for (l = 0; l < 3; l++) - { /* beta */ - adrs = i * num_patom * 9 + k * num_patom * 3 + i * 3 + l; - adrs_sum = i * 9 + k * 3 + l; - dd[adrs * 2] -= dd_q0[adrs_sum * 2]; - dd[adrs * 2 + 1] -= dd_q0[adrs_sum * 2 + 1]; - } - } - } - - for (i = 0; i < num_patom * num_patom * 18; i++) - { - dd[i] *= factor; - } - - /* This may not be necessary. */ - /* make_Hermitian(dd, num_patom * 3); */ - - free(dd_tmp); - dd_tmp = NULL; -} - -void dym_get_recip_dipole_dipole_q0(double *dd_q0, /* [natom, 3, 3, (real,imag)] */ - const double (*G_list)[3], /* [num_G, 3] */ - const long num_G, - const long num_patom, - const double (*born)[3][3], - const double dielectric[3][3], - const double (*pos)[3], /* [num_patom, 3] */ - const double lambda, - const double tolerance) -{ - long i, j, k, l, adrs_tmp, adrs, adrsT; - double zero_vec[3]; - double *dd_tmp1, *dd_tmp2; - - dd_tmp1 = NULL; - dd_tmp1 = (double *)malloc(sizeof(double) * num_patom * num_patom * 18); - dd_tmp2 = NULL; - dd_tmp2 = (double *)malloc(sizeof(double) * num_patom * num_patom * 18); - - for (i = 0; i < num_patom * num_patom * 18; i++) - { - dd_tmp1[i] = 0; - dd_tmp2[i] = 0; - } - - zero_vec[0] = 0; - zero_vec[1] = 0; - zero_vec[2] = 0; - - get_KK(dd_tmp1, - G_list, - num_G, - num_patom, - zero_vec, - NULL, - dielectric, - pos, - lambda, - tolerance); - - multiply_borns(dd_tmp2, dd_tmp1, num_patom, born); - - for (i = 0; i < num_patom * 18; i++) - { - dd_q0[i] = 0; - } - - for (i = 0; i < num_patom; i++) - { - for (k = 0; k < 3; k++) - { /* alpha */ - for (l = 0; l < 3; l++) - { /* beta */ - adrs = i * 9 + k * 3 + l; - for (j = 0; j < num_patom; j++) - { - adrs_tmp = i * num_patom * 9 + k * num_patom * 3 + j * 3 + l; - dd_q0[adrs * 2] += dd_tmp2[adrs_tmp * 2]; - dd_q0[adrs * 2 + 1] += dd_tmp2[adrs_tmp * 2 + 1]; + for (ij = 0; ij < num_patom * num_patom; ij++) { + get_dynmat_ij(dynamical_matrix, num_patom, num_satom, fc, q, svecs, + multi, mass, s2p_map, p2s_map, charge_sum, + ij / num_patom, /* i */ + ij % num_patom); /* j */ + } + } else { + for (i = 0; i < num_patom; i++) { + for (j = 0; j < num_patom; j++) { + get_dynmat_ij(dynamical_matrix, num_patom, num_satom, fc, q, + svecs, multi, mass, s2p_map, p2s_map, charge_sum, + i, j); + } } - } } - } - /* Summation over another atomic index */ - /* for (j = 0; j < num_patom; j++) { */ - /* for (k = 0; k < 3; k++) { /\* alpha *\/ */ - /* for (l = 0; l < 3; l++) { /\* beta *\/ */ - /* adrs = j * 9 + k * 3 + l; */ - /* for (i = 0; i < num_patom; i++) { */ - /* adrs_tmp = i * num_patom * 9 + k * num_patom * 3 + j * 3 + l ; */ - /* dd_q0[adrs * 2] += dd_tmp2[adrs_tmp * 2]; */ - /* dd_q0[adrs * 2 + 1] += dd_tmp2[adrs_tmp * 2 + 1]; */ - /* } */ - /* } */ - /* } */ - /* } */ + make_Hermitian(dynamical_matrix, num_patom * 3); - for (i = 0; i < num_patom; i++) - { - for (k = 0; k < 3; k++) - { /* alpha */ - for (l = 0; l < 3; l++) - { /* beta */ - adrs = i * 9 + k * 3 + l; - adrsT = i * 9 + l * 3 + k; - dd_q0[adrs * 2] += dd_q0[adrsT * 2]; - dd_q0[adrs * 2] /= 2; - dd_q0[adrsT * 2] = dd_q0[adrs * 2]; - dd_q0[adrs * 2 + 1] -= dd_q0[adrsT * 2 + 1]; - dd_q0[adrs * 2 + 1] /= 2; - dd_q0[adrsT * 2 + 1] = -dd_q0[adrs * 2 + 1]; - } - } - } - - free(dd_tmp1); - dd_tmp1 = NULL; - free(dd_tmp2); - dd_tmp2 = NULL; + return 0; } -void dym_get_charge_sum(double (*charge_sum)[3][3], - const long num_patom, - const double factor, /* 4pi/V*unit-conv and denominator */ - const double q_cart[3], - const double (*born)[3][3]) -{ - long i, j, k, a, b; - double(*q_born)[3]; +void dym_get_recip_dipole_dipole( + double *dd, /* [natom, 3, natom, 3, (real,imag)] */ + const double *dd_q0, /* [natom, 3, 3, (real,imag)] */ + const double (*G_list)[3], /* [num_G, 3] */ + const long num_G, const long num_patom, const double q_cart[3], + const double *q_direction_cart, /* must be pointer */ + const double (*born)[3][3], const double dielectric[3][3], + const double (*pos)[3], /* [num_patom, 3] */ + const double factor, /* 4pi/V*unit-conv */ + const double lambda, const double tolerance) { + long i, k, l, adrs, adrs_sum; + double *dd_tmp; - q_born = (double(*)[3])malloc(sizeof(double[3]) * num_patom); - for (i = 0; i < num_patom; i++) - { - for (j = 0; j < 3; j++) - { - q_born[i][j] = 0; + dd_tmp = NULL; + dd_tmp = (double *)malloc(sizeof(double) * num_patom * num_patom * 18); + + for (i = 0; i < num_patom * num_patom * 18; i++) { + dd[i] = 0; + dd_tmp[i] = 0; } - } - for (i = 0; i < num_patom; i++) - { - for (j = 0; j < 3; j++) - { - for (k = 0; k < 3; k++) - { - q_born[i][j] += q_cart[k] * born[i][k][j]; - } - } - } + get_KK(dd_tmp, G_list, num_G, num_patom, q_cart, q_direction_cart, + dielectric, pos, lambda, tolerance); - for (i = 0; i < num_patom; i++) - { - for (j = 0; j < num_patom; j++) - { - for (a = 0; a < 3; a++) - { - for (b = 0; b < 3; b++) - { - charge_sum[i * num_patom + j][a][b] = - q_born[i][a] * q_born[j][b] * factor; + multiply_borns(dd, dd_tmp, num_patom, born); + + for (i = 0; i < num_patom; i++) { + for (k = 0; k < 3; k++) { /* alpha */ + for (l = 0; l < 3; l++) { /* beta */ + adrs = i * num_patom * 9 + k * num_patom * 3 + i * 3 + l; + adrs_sum = i * 9 + k * 3 + l; + dd[adrs * 2] -= dd_q0[adrs_sum * 2]; + dd[adrs * 2 + 1] -= dd_q0[adrs_sum * 2 + 1]; + } } - } } - } - free(q_born); - q_born = NULL; + for (i = 0; i < num_patom * num_patom * 18; i++) { + dd[i] *= factor; + } + + /* This may not be necessary. */ + /* make_Hermitian(dd, num_patom * 3); */ + + free(dd_tmp); + dd_tmp = NULL; +} + +void dym_get_recip_dipole_dipole_q0( + double *dd_q0, /* [natom, 3, 3, (real,imag)] */ + const double (*G_list)[3], /* [num_G, 3] */ + const long num_G, const long num_patom, const double (*born)[3][3], + const double dielectric[3][3], const double (*pos)[3], /* [num_patom, 3] */ + const double lambda, const double tolerance) { + long i, j, k, l, adrs_tmp, adrs, adrsT; + double zero_vec[3]; + double *dd_tmp1, *dd_tmp2; + + dd_tmp1 = NULL; + dd_tmp1 = (double *)malloc(sizeof(double) * num_patom * num_patom * 18); + dd_tmp2 = NULL; + dd_tmp2 = (double *)malloc(sizeof(double) * num_patom * num_patom * 18); + + for (i = 0; i < num_patom * num_patom * 18; i++) { + dd_tmp1[i] = 0; + dd_tmp2[i] = 0; + } + + zero_vec[0] = 0; + zero_vec[1] = 0; + zero_vec[2] = 0; + + get_KK(dd_tmp1, G_list, num_G, num_patom, zero_vec, NULL, dielectric, pos, + lambda, tolerance); + + multiply_borns(dd_tmp2, dd_tmp1, num_patom, born); + + for (i = 0; i < num_patom * 18; i++) { + dd_q0[i] = 0; + } + + for (i = 0; i < num_patom; i++) { + for (k = 0; k < 3; k++) { /* alpha */ + for (l = 0; l < 3; l++) { /* beta */ + adrs = i * 9 + k * 3 + l; + for (j = 0; j < num_patom; j++) { + adrs_tmp = + i * num_patom * 9 + k * num_patom * 3 + j * 3 + l; + dd_q0[adrs * 2] += dd_tmp2[adrs_tmp * 2]; + dd_q0[adrs * 2 + 1] += dd_tmp2[adrs_tmp * 2 + 1]; + } + } + } + } + + /* Summation over another atomic index */ + /* for (j = 0; j < num_patom; j++) { */ + /* for (k = 0; k < 3; k++) { /\* alpha *\/ */ + /* for (l = 0; l < 3; l++) { /\* beta *\/ */ + /* adrs = j * 9 + k * 3 + l; */ + /* for (i = 0; i < num_patom; i++) { */ + /* adrs_tmp = i * num_patom * 9 + k * num_patom * 3 + j * 3 + l ; */ + /* dd_q0[adrs * 2] += dd_tmp2[adrs_tmp * 2]; */ + /* dd_q0[adrs * 2 + 1] += dd_tmp2[adrs_tmp * 2 + 1]; */ + /* } */ + /* } */ + /* } */ + /* } */ + + for (i = 0; i < num_patom; i++) { + for (k = 0; k < 3; k++) { /* alpha */ + for (l = 0; l < 3; l++) { /* beta */ + adrs = i * 9 + k * 3 + l; + adrsT = i * 9 + l * 3 + k; + dd_q0[adrs * 2] += dd_q0[adrsT * 2]; + dd_q0[adrs * 2] /= 2; + dd_q0[adrsT * 2] = dd_q0[adrs * 2]; + dd_q0[adrs * 2 + 1] -= dd_q0[adrsT * 2 + 1]; + dd_q0[adrs * 2 + 1] /= 2; + dd_q0[adrsT * 2 + 1] = -dd_q0[adrs * 2 + 1]; + } + } + } + + free(dd_tmp1); + dd_tmp1 = NULL; + free(dd_tmp2); + dd_tmp2 = NULL; +} + +void dym_get_charge_sum( + double (*charge_sum)[3][3], const long num_patom, + const double factor, /* 4pi/V*unit-conv and denominator */ + const double q_cart[3], const double (*born)[3][3]) { + long i, j, k, a, b; + double(*q_born)[3]; + + q_born = (double(*)[3])malloc(sizeof(double[3]) * num_patom); + for (i = 0; i < num_patom; i++) { + for (j = 0; j < 3; j++) { + q_born[i][j] = 0; + } + } + + for (i = 0; i < num_patom; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 3; k++) { + q_born[i][j] += q_cart[k] * born[i][k][j]; + } + } + } + + for (i = 0; i < num_patom; i++) { + for (j = 0; j < num_patom; j++) { + for (a = 0; a < 3; a++) { + for (b = 0; b < 3; b++) { + charge_sum[i * num_patom + j][a][b] = + q_born[i][a] * q_born[j][b] * factor; + } + } + } + } + + free(q_born); + q_born = NULL; } /* fc[num_patom, num_satom, 3, 3] */ @@ -366,350 +271,267 @@ void dym_get_charge_sum(double (*charge_sum)[3][3], /* comm_points[num_satom / num_patom, 3] */ /* shortest_vectors[:, 3] */ /* multiplicities[num_satom, num_patom, 2] */ -void dym_transform_dynmat_to_fc(double *fc, - const double *dm, +void dym_transform_dynmat_to_fc(double *fc, const double *dm, const double (*comm_points)[3], const double (*svecs)[3], - const long (*multi)[2], - const double *masses, - const long *s2pp_map, - const long *fc_index_map, - const long num_patom, - const long num_satom) -{ - long i, j, k, l, m, N, adrs, m_pair, i_pair, svecs_adrs; - double coef, phase, cos_phase, sin_phase; + const long (*multi)[2], const double *masses, + const long *s2pp_map, const long *fc_index_map, + const long num_patom, const long num_satom) { + long i, j, k, l, m, N, adrs, m_pair, i_pair, svecs_adrs; + double coef, phase, cos_phase, sin_phase; - N = num_satom / num_patom; - for (i = 0; i < num_patom * num_satom * 9; i++) - { - fc[i] = 0; - } - - for (i = 0; i < num_patom; i++) - { - for (j = 0; j < num_satom; j++) - { - i_pair = j * num_patom + i; - m_pair = multi[i_pair][0]; - svecs_adrs = multi[i_pair][1]; - coef = sqrt(masses[i] * masses[s2pp_map[j]]) / N; - for (k = 0; k < N; k++) - { - cos_phase = 0; - sin_phase = 0; - for (l = 0; l < m_pair; l++) - { - phase = 0; - for (m = 0; m < 3; m++) - { - phase -= comm_points[k][m] * svecs[svecs_adrs + l][m]; - } - cos_phase += cos(phase * 2 * PI); - sin_phase += sin(phase * 2 * PI); - } - cos_phase /= m_pair; - sin_phase /= m_pair; - for (l = 0; l < 3; l++) - { - for (m = 0; m < 3; m++) - { - adrs = k * num_patom * num_patom * 18 + i * num_patom * 18 + - l * num_patom * 6 + s2pp_map[j] * 6 + m * 2; - fc[fc_index_map[i] * num_satom * 9 + j * 9 + l * 3 + m] += - (dm[adrs] * cos_phase - dm[adrs + 1] * sin_phase) * coef; - } - } - } + N = num_satom / num_patom; + for (i = 0; i < num_patom * num_satom * 9; i++) { + fc[i] = 0; + } + + for (i = 0; i < num_patom; i++) { + for (j = 0; j < num_satom; j++) { + i_pair = j * num_patom + i; + m_pair = multi[i_pair][0]; + svecs_adrs = multi[i_pair][1]; + coef = sqrt(masses[i] * masses[s2pp_map[j]]) / N; + for (k = 0; k < N; k++) { + cos_phase = 0; + sin_phase = 0; + for (l = 0; l < m_pair; l++) { + phase = 0; + for (m = 0; m < 3; m++) { + phase -= comm_points[k][m] * svecs[svecs_adrs + l][m]; + } + cos_phase += cos(phase * 2 * PI); + sin_phase += sin(phase * 2 * PI); + } + cos_phase /= m_pair; + sin_phase /= m_pair; + for (l = 0; l < 3; l++) { + for (m = 0; m < 3; m++) { + adrs = k * num_patom * num_patom * 18 + + i * num_patom * 18 + l * num_patom * 6 + + s2pp_map[j] * 6 + m * 2; + fc[fc_index_map[i] * num_satom * 9 + j * 9 + l * 3 + + m] += + (dm[adrs] * cos_phase - dm[adrs + 1] * sin_phase) * + coef; + } + } + } + } } - } } -static void get_dynmat_ij(double *dynamical_matrix, - const long num_patom, - const long num_satom, - const double *fc, - const double q[3], - const double (*svecs)[3], - const long (*multi)[2], - const double *mass, - const long *s2p_map, - const long *p2s_map, - const double (*charge_sum)[3][3], - const long i, - const long j) -{ - long k, l, adrs; - double mass_sqrt; - double dm_real[3][3], dm_imag[3][3]; +static void get_dynmat_ij(double *dynamical_matrix, const long num_patom, + const long num_satom, const double *fc, + const double q[3], const double (*svecs)[3], + const long (*multi)[2], const double *mass, + const long *s2p_map, const long *p2s_map, + const double (*charge_sum)[3][3], const long i, + const long j) { + long k, l, adrs; + double mass_sqrt; + double dm_real[3][3], dm_imag[3][3]; - mass_sqrt = sqrt(mass[i] * mass[j]); + mass_sqrt = sqrt(mass[i] * mass[j]); - for (k = 0; k < 3; k++) - { - for (l = 0; l < 3; l++) - { - dm_real[k][l] = 0; - dm_imag[k][l] = 0; + for (k = 0; k < 3; k++) { + for (l = 0; l < 3; l++) { + dm_real[k][l] = 0; + dm_imag[k][l] = 0; + } } - } - for (k = 0; k < num_satom; k++) - { /* Lattice points of right index of fc */ - if (s2p_map[k] != p2s_map[j]) - { - continue; + for (k = 0; k < num_satom; k++) { /* Lattice points of right index of fc */ + if (s2p_map[k] != p2s_map[j]) { + continue; + } + get_dm(dm_real, dm_imag, num_patom, num_satom, fc, q, svecs, multi, + p2s_map, charge_sum, i, j, k); } - get_dm(dm_real, - dm_imag, - num_patom, - num_satom, - fc, - q, - svecs, - multi, - p2s_map, - charge_sum, - i, - j, - k); - } - for (k = 0; k < 3; k++) - { - for (l = 0; l < 3; l++) - { - adrs = (i * 3 + k) * num_patom * 3 + j * 3 + l; - dynamical_matrix[adrs * 2] = dm_real[k][l] / mass_sqrt; - dynamical_matrix[adrs * 2 + 1] = dm_imag[k][l] / mass_sqrt; + for (k = 0; k < 3; k++) { + for (l = 0; l < 3; l++) { + adrs = (i * 3 + k) * num_patom * 3 + j * 3 + l; + dynamical_matrix[adrs * 2] = dm_real[k][l] / mass_sqrt; + dynamical_matrix[adrs * 2 + 1] = dm_imag[k][l] / mass_sqrt; + } } - } } -static void get_dm(double dm_real[3][3], - double dm_imag[3][3], - const long num_patom, - const long num_satom, - const double *fc, - const double q[3], - const double (*svecs)[3], - const long (*multi)[2], - const long *p2s_map, - const double (*charge_sum)[3][3], - const long i, - const long j, - const long k) -{ - long l, m, i_pair, m_pair, adrs; - double phase, cos_phase, sin_phase, fc_elem; +static void get_dm(double dm_real[3][3], double dm_imag[3][3], + const long num_patom, const long num_satom, const double *fc, + const double q[3], const double (*svecs)[3], + const long (*multi)[2], const long *p2s_map, + const double (*charge_sum)[3][3], const long i, const long j, + const long k) { + long l, m, i_pair, m_pair, adrs; + double phase, cos_phase, sin_phase, fc_elem; - cos_phase = 0; - sin_phase = 0; + cos_phase = 0; + sin_phase = 0; - i_pair = k * num_patom + i; - m_pair = multi[i_pair][0]; - adrs = multi[i_pair][1]; + i_pair = k * num_patom + i; + m_pair = multi[i_pair][0]; + adrs = multi[i_pair][1]; - for (l = 0; l < m_pair; l++) - { - phase = 0; - for (m = 0; m < 3; m++) - { - phase += q[m] * svecs[adrs + l][m]; + for (l = 0; l < m_pair; l++) { + phase = 0; + for (m = 0; m < 3; m++) { + phase += q[m] * svecs[adrs + l][m]; + } + cos_phase += cos(phase * 2 * PI) / m_pair; + sin_phase += sin(phase * 2 * PI) / m_pair; } - cos_phase += cos(phase * 2 * PI) / m_pair; - sin_phase += sin(phase * 2 * PI) / m_pair; - } - for (l = 0; l < 3; l++) - { - for (m = 0; m < 3; m++) - { - if (charge_sum) - { - fc_elem = (fc[p2s_map[i] * num_satom * 9 + k * 9 + l * 3 + m] + - charge_sum[i * num_patom + j][l][m]); - } - else - { - fc_elem = fc[p2s_map[i] * num_satom * 9 + k * 9 + l * 3 + m]; - } - dm_real[l][m] += fc_elem * cos_phase; - dm_imag[l][m] += fc_elem * sin_phase; + for (l = 0; l < 3; l++) { + for (m = 0; m < 3; m++) { + if (charge_sum) { + fc_elem = (fc[p2s_map[i] * num_satom * 9 + k * 9 + l * 3 + m] + + charge_sum[i * num_patom + j][l][m]); + } else { + fc_elem = fc[p2s_map[i] * num_satom * 9 + k * 9 + l * 3 + m]; + } + dm_real[l][m] += fc_elem * cos_phase; + dm_imag[l][m] += fc_elem * sin_phase; + } } - } } static double get_dielectric_part(const double q_cart[3], - const double dielectric[3][3]) -{ - long i, j; - double x[3]; - double sum; + const double dielectric[3][3]) { + long i, j; + double x[3]; + double sum; - for (i = 0; i < 3; i++) - { - x[i] = 0; - for (j = 0; j < 3; j++) - { - x[i] += dielectric[i][j] * q_cart[j]; + for (i = 0; i < 3; i++) { + x[i] = 0; + for (j = 0; j < 3; j++) { + x[i] += dielectric[i][j] * q_cart[j]; + } } - } - sum = 0; - for (i = 0; i < 3; i++) - { - sum += q_cart[i] * x[i]; - } + sum = 0; + for (i = 0; i < 3; i++) { + sum += q_cart[i] * x[i]; + } - return sum; + return sum; } -static void get_KK(double *dd_part, /* [natom, 3, natom, 3, (real,imag)] */ +static void get_KK(double *dd_part, /* [natom, 3, natom, 3, (real,imag)] */ const double (*G_list)[3], /* [num_G, 3] */ - const long num_G, - const long num_patom, - const double q_cart[3], - const double *q_direction_cart, + const long num_G, const long num_patom, + const double q_cart[3], const double *q_direction_cart, const double dielectric[3][3], const double (*pos)[3], /* [num_patom, 3] */ - const double lambda, - const double tolerance) -{ - 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]; + const double lambda, const double tolerance) { + 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]; - L2 = 4 * lambda * lambda; + L2 = 4 * lambda * lambda; - /* sum over K = G + q and over G (i.e. q=0) */ - /* q_direction has values for summation over K at Gamma point. */ - /* q_direction is NULL for summation over G */ - for (g = 0; g < num_G; g++) - { - norm = 0; - for (i = 0; i < 3; i++) - { - q_K[i] = G_list[g][i] + q_cart[i]; - norm += q_K[i] * q_K[i]; - } - - if (sqrt(norm) < tolerance) - { - if (!q_direction_cart) - { - continue; - } - else - { - dielectric_part = get_dielectric_part(q_direction_cart, dielectric); - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - KK[i][j] = - q_direction_cart[i] * q_direction_cart[j] / dielectric_part; - } + /* sum over K = G + q and over G (i.e. q=0) */ + /* q_direction has values for summation over K at Gamma point. */ + /* q_direction is NULL for summation over G */ + for (g = 0; g < num_G; g++) { + norm = 0; + for (i = 0; i < 3; i++) { + q_K[i] = G_list[g][i] + q_cart[i]; + norm += q_K[i] * q_K[i]; } - } - } - else - { - dielectric_part = get_dielectric_part(q_K, dielectric); - exp_damp = exp(-dielectric_part / L2); - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - KK[i][j] = q_K[i] * q_K[j] / dielectric_part * exp_damp; - } - } - } - for (i = 0; i < num_patom; i++) - { - for (j = 0; j < num_patom; j++) - { - phase = 0; - for (k = 0; k < 3; k++) - { - /* For D-type dynamical matrix */ - /* phase += (pos[i][k] - pos[j][k]) * q_K[k]; */ - /* For C-type dynamical matrix */ - phase += (pos[i][k] - pos[j][k]) * G_list[g][k]; - } - phase *= 2 * PI; - cos_phase = cos(phase); - sin_phase = sin(phase); - for (k = 0; k < 3; k++) - { - for (l = 0; l < 3; l++) - { - adrs = i * num_patom * 9 + k * num_patom * 3 + j * 3 + l; - dd_part[adrs * 2] += KK[k][l] * cos_phase; - dd_part[adrs * 2 + 1] += KK[k][l] * sin_phase; - } - } - } - } - } -} - -static void make_Hermitian(double *mat, const long num_band) -{ - long i, j, adrs, adrsT; - - for (i = 0; i < num_band; i++) - { - for (j = i; j < num_band; j++) - { - adrs = i * num_band + j * 1; - adrs *= 2; - adrsT = j * num_band + i * 1; - adrsT *= 2; - /* real part */ - mat[adrs] += mat[adrsT]; - mat[adrs] /= 2; - /* imaginary part */ - mat[adrs + 1] -= mat[adrsT + 1]; - mat[adrs + 1] /= 2; - /* store */ - mat[adrsT] = mat[adrs]; - mat[adrsT + 1] = -mat[adrs + 1]; - } - } -} - -static void multiply_borns(double *dd, - const double *dd_in, - const long num_patom, - const double (*born)[3][3]) -{ - long i, j, k, l, m, n, adrs, adrs_in; - double zz; - - for (i = 0; i < num_patom; i++) - { - for (j = 0; j < num_patom; j++) - { - for (k = 0; k < 3; k++) - { /* alpha */ - for (l = 0; l < 3; l++) - { /* beta */ - adrs = i * num_patom * 9 + k * num_patom * 3 + j * 3 + l; - for (m = 0; m < 3; m++) - { /* alpha' */ - for (n = 0; n < 3; n++) - { /* beta' */ - adrs_in = i * num_patom * 9 + m * num_patom * 3 + j * 3 + n; - zz = born[i][m][k] * born[j][n][l]; - dd[adrs * 2] += dd_in[adrs_in * 2] * zz; - dd[adrs * 2 + 1] += dd_in[adrs_in * 2 + 1] * zz; + if (sqrt(norm) < tolerance) { + if (!q_direction_cart) { + continue; + } else { + dielectric_part = + get_dielectric_part(q_direction_cart, dielectric); + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + KK[i][j] = q_direction_cart[i] * q_direction_cart[j] / + dielectric_part; + } + } + } + } else { + dielectric_part = get_dielectric_part(q_K, dielectric); + exp_damp = exp(-dielectric_part / L2); + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + KK[i][j] = q_K[i] * q_K[j] / dielectric_part * exp_damp; + } + } + } + + for (i = 0; i < num_patom; i++) { + for (j = 0; j < num_patom; j++) { + phase = 0; + for (k = 0; k < 3; k++) { + /* For D-type dynamical matrix */ + /* phase += (pos[i][k] - pos[j][k]) * q_K[k]; */ + /* For C-type dynamical matrix */ + phase += (pos[i][k] - pos[j][k]) * G_list[g][k]; + } + phase *= 2 * PI; + cos_phase = cos(phase); + sin_phase = sin(phase); + for (k = 0; k < 3; k++) { + for (l = 0; l < 3; l++) { + adrs = + i * num_patom * 9 + k * num_patom * 3 + j * 3 + l; + dd_part[adrs * 2] += KK[k][l] * cos_phase; + dd_part[adrs * 2 + 1] += KK[k][l] * sin_phase; + } + } + } + } + } +} + +static void make_Hermitian(double *mat, const long num_band) { + long i, j, adrs, adrsT; + + for (i = 0; i < num_band; i++) { + for (j = i; j < num_band; j++) { + adrs = i * num_band + j * 1; + adrs *= 2; + adrsT = j * num_band + i * 1; + adrsT *= 2; + /* real part */ + mat[adrs] += mat[adrsT]; + mat[adrs] /= 2; + /* imaginary part */ + mat[adrs + 1] -= mat[adrsT + 1]; + mat[adrs + 1] /= 2; + /* store */ + mat[adrsT] = mat[adrs]; + mat[adrsT + 1] = -mat[adrs + 1]; + } + } +} + +static void multiply_borns(double *dd, const double *dd_in, + const long num_patom, const double (*born)[3][3]) { + long i, j, k, l, m, n, adrs, adrs_in; + double zz; + + for (i = 0; i < num_patom; i++) { + for (j = 0; j < num_patom; j++) { + for (k = 0; k < 3; k++) { /* alpha */ + for (l = 0; l < 3; l++) { /* beta */ + adrs = i * num_patom * 9 + k * num_patom * 3 + j * 3 + l; + for (m = 0; m < 3; m++) { /* alpha' */ + for (n = 0; n < 3; n++) { /* beta' */ + adrs_in = i * num_patom * 9 + m * num_patom * 3 + + j * 3 + n; + zz = born[i][m][k] * born[j][n][l]; + dd[adrs * 2] += dd_in[adrs_in * 2] * zz; + dd[adrs * 2 + 1] += dd_in[adrs_in * 2 + 1] * zz; + } + } + } } - } } - } } - } } diff --git a/c/dynmat.h b/c/dynmat.h index db93c55b..9eab08d3 100644 --- a/c/dynmat.h +++ b/c/dynmat.h @@ -36,58 +36,42 @@ #define __dynmat_H__ 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], + const long num_patom, const long num_satom, + const double *fc, const double q[3], const double (*svecs)[3], - const long (*multi)[2], - const double *mass, - const long *s2p_map, - const long *p2s_map, + const long (*multi)[2], const double *mass, + const long *s2p_map, const long *p2s_map, const 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)] */ - const double (*G_list)[3], /* [num_G, 3] */ - const long num_G, - const long num_patom, - const double q_cart[3], - const double *q_direction_cart, /* must be pointer */ - const double (*born)[3][3], - const double dielectric[3][3], - const double (*pos)[3], /* [num_patom, 3] */ - const double factor, /* 4pi/V*unit-conv */ - const double lambda, - const double tolerance); -void dym_get_recip_dipole_dipole_q0(double *dd_q0, /* [natom, 3, 3, (real,imag)] */ - const double (*G_list)[3], /* [num_G, 3] */ - const long num_G, - const long num_patom, - const double (*born)[3][3], - const double dielectric[3][3], - const double (*pos)[3], /* [natom, 3] */ - const double lambda, - const double tolerance); -void dym_get_charge_sum(double (*charge_sum)[3][3], - const long num_patom, - const double factor, - const double q_cart[3], +void dym_get_recip_dipole_dipole( + double *dd, /* [natom, 3, natom, 3, (real,imag)] */ + const double *dd_q0, /* [natom, 3, 3, (real,imag)] */ + const double (*G_list)[3], /* [num_G, 3] */ + const long num_G, const long num_patom, const double q_cart[3], + const double *q_direction_cart, /* must be pointer */ + const double (*born)[3][3], const double dielectric[3][3], + const double (*pos)[3], /* [num_patom, 3] */ + const double factor, /* 4pi/V*unit-conv */ + const double lambda, const double tolerance); +void dym_get_recip_dipole_dipole_q0( + double *dd_q0, /* [natom, 3, 3, (real,imag)] */ + const double (*G_list)[3], /* [num_G, 3] */ + const long num_G, const long num_patom, const double (*born)[3][3], + const double dielectric[3][3], const double (*pos)[3], /* [natom, 3] */ + const double lambda, const double tolerance); +void dym_get_charge_sum(double (*charge_sum)[3][3], const long num_patom, + const double factor, const double q_cart[3], const double (*born)[3][3]); /* fc[num_patom, num_satom, 3, 3] */ /* dm[num_comm_points, num_patom * 3, num_patom *3] */ /* comm_points[num_satom / num_patom, 3] */ /* shortest_vectors[:, 3] */ /* multiplicities[num_satom, num_patom, 2] */ -void dym_transform_dynmat_to_fc(double *fc, - const double *dm, +void dym_transform_dynmat_to_fc(double *fc, const double *dm, const double (*comm_points)[3], const double (*svecs)[3], - const long (*multi)[2], - const double *masses, - const long *s2pp_map, - const long *fc_index_map, - const long num_patom, - const long num_satom); + const long (*multi)[2], const double *masses, + const long *s2pp_map, const long *fc_index_map, + const long num_patom, const long num_satom); #endif diff --git a/c/fc3.c b/c/fc3.c index bc97c61c..c9c112ae 100644 --- a/c/fc3.c +++ b/c/fc3.c @@ -32,673 +32,522 @@ /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ -#include #include "fc3.h" -static void rotate_delta_fc2s(double (*rot_delta_fc2s)[3][3], - const long i_atom, +#include + +static void rotate_delta_fc2s(double (*rot_delta_fc2s)[3][3], const long i_atom, const long j_atom, const double (*delta_fc2s)[3][3], const double (*site_sym_cart)[3][3], - const long *rot_map_sym, - const long num_atom, - const long num_site_sym, - const long num_disp); -static void tensor2_rotation(double rot_tensor[3][3], - const double tensor[3][3], + const long *rot_map_sym, const long num_atom, + const long num_site_sym, const long num_disp); +static void tensor2_rotation(double rot_tensor[3][3], const double tensor[3][3], const double r[3][3]); -static void tensor3_rotation(double *rot_tensor, - const double *tensor, +static void tensor3_rotation(double *rot_tensor, const double *tensor, const double *rot_cartesian); -static double tensor3_rotation_elem(const double *tensor, - const double *r, +static double tensor3_rotation_elem(const double *tensor, const double *r, const long pos); static void copy_permutation_symmetry_fc3_elem(double *fc3, const double fc3_elem[27], - const long a, - const long b, + const long a, const long b, const long c, const long num_atom); static void set_permutation_symmetry_fc3_elem(double *fc3_elem, - const double *fc3, - const long a, - const long b, - const long c, + const double *fc3, const long a, + const long b, const long c, const long num_atom); -static void set_permutation_symmetry_compact_fc3(double *fc3, - const long p2s[], - const long s2pp[], - const long nsym_list[], - const long perms[], - const long n_satom, - const long n_patom); -static void transpose_compact_fc3_type01(double *fc3, - const long p2s[], +static void set_permutation_symmetry_compact_fc3( + double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], + const long perms[], const long n_satom, const long n_patom); +static void transpose_compact_fc3_type01(double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], - const long perms[], - const long n_satom, - const long n_patom, - const long t_type); -static void transpose_compact_fc3_type2(double *fc3, - const long p2s[], + const long perms[], const long n_satom, + const long n_patom, const long t_type); +static void transpose_compact_fc3_type2(double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], - const long perms[], - const long n_satom, + const long perms[], const long n_satom, const long n_patom); -void fc3_distribute_fc3(double *fc3, - const long target, - const long source, - const long *atom_mapping, - const long num_atom, - const double *rot_cart) -{ - long i, j, adrs_out, adrs_in; +void fc3_distribute_fc3(double *fc3, const long target, const long source, + const long *atom_mapping, const long num_atom, + const double *rot_cart) { + long i, j, adrs_out, adrs_in; - for (i = 0; i < num_atom; i++) - { - for (j = 0; j < num_atom; j++) - { - adrs_out = (num_atom * num_atom * target + num_atom * i + j) * 27; - adrs_in = (num_atom * num_atom * source + num_atom * atom_mapping[i] + atom_mapping[j]) * 27; - tensor3_rotation(fc3 + adrs_out, fc3 + adrs_in, rot_cart); + for (i = 0; i < num_atom; i++) { + for (j = 0; j < num_atom; j++) { + adrs_out = (num_atom * num_atom * target + num_atom * i + j) * 27; + adrs_in = (num_atom * num_atom * source + + num_atom * atom_mapping[i] + atom_mapping[j]) * + 27; + tensor3_rotation(fc3 + adrs_out, fc3 + adrs_in, rot_cart); + } } - } } void fc3_rotate_delta_fc2(double (*fc3)[3][3][3], - const double (*delta_fc2s)[3][3], - const double *inv_U, + const double (*delta_fc2s)[3][3], const double *inv_U, const double (*site_sym_cart)[3][3], - const long *rot_map_syms, - const long num_atom, - const long num_site_sym, - const long num_disp) -{ - long i_atoms, i, j, k, l, m, n; - double(*rot_delta_fc2s)[3][3]; + const long *rot_map_syms, const long num_atom, + const long num_site_sym, const long num_disp) { + long i_atoms, i, j, k, l, m, n; + double(*rot_delta_fc2s)[3][3]; - rot_delta_fc2s = (double(*)[3][3])malloc(sizeof(double[3][3]) * num_site_sym * num_disp); - for (i_atoms = 0; i_atoms < num_atom * num_atom; i_atoms++) - { - i = i_atoms / num_atom; - j = i_atoms % num_atom; - rotate_delta_fc2s(rot_delta_fc2s, - i, - j, - delta_fc2s, - site_sym_cart, - rot_map_syms, - num_atom, - num_site_sym, - num_disp); - for (k = 0; k < 3; k++) - { - for (l = 0; l < 3; l++) - { - for (m = 0; m < 3; m++) - { - fc3[i_atoms][k][l][m] = 0; - for (n = 0; n < num_site_sym * num_disp; n++) - { - fc3[i_atoms][k][l][m] += - inv_U[k * num_site_sym * num_disp + n] * rot_delta_fc2s[n][l][m]; - } + rot_delta_fc2s = + (double(*)[3][3])malloc(sizeof(double[3][3]) * num_site_sym * num_disp); + for (i_atoms = 0; i_atoms < num_atom * num_atom; i_atoms++) { + i = i_atoms / num_atom; + j = i_atoms % num_atom; + rotate_delta_fc2s(rot_delta_fc2s, i, j, delta_fc2s, site_sym_cart, + rot_map_syms, num_atom, num_site_sym, num_disp); + for (k = 0; k < 3; k++) { + for (l = 0; l < 3; l++) { + for (m = 0; m < 3; m++) { + fc3[i_atoms][k][l][m] = 0; + for (n = 0; n < num_site_sym * num_disp; n++) { + fc3[i_atoms][k][l][m] += + inv_U[k * num_site_sym * num_disp + n] * + rot_delta_fc2s[n][l][m]; + } + } + } } - } } - } - free(rot_delta_fc2s); - rot_delta_fc2s = NULL; + free(rot_delta_fc2s); + rot_delta_fc2s = NULL; } -void fc3_set_permutation_symmetry_fc3(double *fc3, const long num_atom) -{ - double fc3_elem[27]; - long i, j, k; +void fc3_set_permutation_symmetry_fc3(double *fc3, const long num_atom) { + double fc3_elem[27]; + long i, j, k; #ifdef PHPYOPENMP #pragma omp parallel for private(j, k, fc3_elem) #endif - for (i = 0; i < num_atom; i++) - { - for (j = i; j < num_atom; j++) - { - for (k = j; k < num_atom; k++) - { - set_permutation_symmetry_fc3_elem(fc3_elem, fc3, i, j, k, num_atom); - copy_permutation_symmetry_fc3_elem(fc3, fc3_elem, - i, j, k, num_atom); - } + for (i = 0; i < num_atom; i++) { + for (j = i; j < num_atom; j++) { + for (k = j; k < num_atom; k++) { + set_permutation_symmetry_fc3_elem(fc3_elem, fc3, i, j, k, + num_atom); + copy_permutation_symmetry_fc3_elem(fc3, fc3_elem, i, j, k, + num_atom); + } + } } - } } -void fc3_set_permutation_symmetry_compact_fc3(double *fc3, - const long p2s[], - const long s2pp[], - const long nsym_list[], - const long perms[], - const long n_satom, - const long n_patom) -{ - set_permutation_symmetry_compact_fc3(fc3, - p2s, - s2pp, - nsym_list, - perms, - n_satom, - n_patom); +void fc3_set_permutation_symmetry_compact_fc3( + double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], + const long perms[], const long n_satom, const long n_patom) { + set_permutation_symmetry_compact_fc3(fc3, p2s, s2pp, nsym_list, perms, + n_satom, n_patom); } -void fc3_transpose_compact_fc3(double *fc3, - const long p2s[], - const long s2pp[], - const long nsym_list[], - const long perms[], - const long n_satom, - const long n_patom, - const long t_type) -{ - /* Three types of index permutations */ - /* t_type=0: dim[0] <-> dim[1] */ - /* t_type=1: dim[0] <-> dim[2] */ - /* t_type=2: dim[1] <-> dim[2] */ - if (t_type == 0 || t_type == 1) - { - transpose_compact_fc3_type01(fc3, - p2s, - s2pp, - nsym_list, - perms, - n_satom, - n_patom, - t_type); - } - else - { - if (t_type == 2) - { - transpose_compact_fc3_type2(fc3, - p2s, - s2pp, - nsym_list, - perms, - n_satom, - n_patom); +void fc3_transpose_compact_fc3(double *fc3, const long p2s[], const long s2pp[], + const long nsym_list[], const long perms[], + const long n_satom, const long n_patom, + const long t_type) { + /* Three types of index permutations */ + /* t_type=0: dim[0] <-> dim[1] */ + /* t_type=1: dim[0] <-> dim[2] */ + /* t_type=2: dim[1] <-> dim[2] */ + if (t_type == 0 || t_type == 1) { + transpose_compact_fc3_type01(fc3, p2s, s2pp, nsym_list, perms, n_satom, + n_patom, t_type); + } else { + if (t_type == 2) { + transpose_compact_fc3_type2(fc3, p2s, s2pp, nsym_list, perms, + n_satom, n_patom); + } } - } } -static void rotate_delta_fc2s(double (*rot_delta_fc2s)[3][3], - const long i_atom, +static void rotate_delta_fc2s(double (*rot_delta_fc2s)[3][3], const long i_atom, const long j_atom, const double (*delta_fc2s)[3][3], const double (*site_sym_cart)[3][3], - const long *rot_map_sym, - const long num_atom, - const long num_site_sym, - const long num_disp) -{ - long i, j; + const long *rot_map_sym, const long num_atom, + const long num_site_sym, const long num_disp) { + long i, j; - for (i = 0; i < num_disp; i++) - { - for (j = 0; j < num_site_sym; j++) - { - tensor2_rotation(rot_delta_fc2s[i * num_site_sym + j], - delta_fc2s[i * num_atom * num_atom + rot_map_sym[j * num_atom + i_atom] * num_atom + rot_map_sym[j * num_atom + j_atom]], - site_sym_cart[j]); - } - } -} - -static void tensor2_rotation(double rot_tensor[3][3], - const double tensor[3][3], - const double r[3][3]) -{ - long i, j, k, l; - - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - rot_tensor[i][j] = 0; - } - } - - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - for (k = 0; k < 3; k++) - { - for (l = 0; l < 3; l++) - { - rot_tensor[i][j] += r[i][k] * r[j][l] * tensor[k][l]; + for (i = 0; i < num_disp; i++) { + for (j = 0; j < num_site_sym; j++) { + tensor2_rotation( + rot_delta_fc2s[i * num_site_sym + j], + delta_fc2s[i * num_atom * num_atom + + rot_map_sym[j * num_atom + i_atom] * num_atom + + rot_map_sym[j * num_atom + j_atom]], + site_sym_cart[j]); } - } } - } } -static void tensor3_rotation(double *rot_tensor, - const double *tensor, - const double *rot_cartesian) -{ - long l; +static void tensor2_rotation(double rot_tensor[3][3], const double tensor[3][3], + const double r[3][3]) { + long i, j, k, l; - for (l = 0; l < 27; l++) - { - rot_tensor[l] = tensor3_rotation_elem(tensor, rot_cartesian, l); - } + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + rot_tensor[i][j] = 0; + } + } + + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 3; k++) { + for (l = 0; l < 3; l++) { + rot_tensor[i][j] += r[i][k] * r[j][l] * tensor[k][l]; + } + } + } + } } -static double tensor3_rotation_elem(const double *tensor, - const double *r, - const long pos) -{ - long i, j, k, l, m, n; - double sum; +static void tensor3_rotation(double *rot_tensor, const double *tensor, + const double *rot_cartesian) { + long l; - l = pos / 9; - m = (pos % 9) / 3; - n = pos % 3; - - sum = 0.0; - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - for (k = 0; k < 3; k++) - { - sum += r[l * 3 + i] * r[m * 3 + j] * r[n * 3 + k] * - tensor[i * 9 + j * 3 + k]; - } + for (l = 0; l < 27; l++) { + rot_tensor[l] = tensor3_rotation_elem(tensor, rot_cartesian, l); } - } - return sum; +} + +static double tensor3_rotation_elem(const double *tensor, const double *r, + const long pos) { + long i, j, k, l, m, n; + double sum; + + l = pos / 9; + m = (pos % 9) / 3; + n = pos % 3; + + sum = 0.0; + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 3; k++) { + sum += r[l * 3 + i] * r[m * 3 + j] * r[n * 3 + k] * + tensor[i * 9 + j * 3 + k]; + } + } + } + return sum; } static void copy_permutation_symmetry_fc3_elem(double *fc3, const double fc3_elem[27], - const long a, - const long b, + const long a, const long b, const long c, - const long num_atom) -{ - long i, j, k; + const long num_atom) { + long i, j, k; - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - for (k = 0; k < 3; k++) - { - fc3[a * num_atom * num_atom * 27 + - b * num_atom * 27 + - c * 27 + i * 9 + j * 3 + k] = - fc3_elem[i * 9 + j * 3 + k]; - fc3[a * num_atom * num_atom * 27 + - c * num_atom * 27 + - b * 27 + i * 9 + k * 3 + j] = - fc3_elem[i * 9 + j * 3 + k]; - fc3[b * num_atom * num_atom * 27 + - a * num_atom * 27 + - c * 27 + j * 9 + i * 3 + k] = - fc3_elem[i * 9 + j * 3 + k]; - fc3[b * num_atom * num_atom * 27 + - c * num_atom * 27 + - a * 27 + j * 9 + k * 3 + i] = - fc3_elem[i * 9 + j * 3 + k]; - fc3[c * num_atom * num_atom * 27 + - a * num_atom * 27 + - b * 27 + k * 9 + i * 3 + j] = - fc3_elem[i * 9 + j * 3 + k]; - fc3[c * num_atom * num_atom * 27 + - b * num_atom * 27 + - a * 27 + k * 9 + j * 3 + i] = - fc3_elem[i * 9 + j * 3 + k]; - } + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 3; k++) { + fc3[a * num_atom * num_atom * 27 + b * num_atom * 27 + c * 27 + + i * 9 + j * 3 + k] = fc3_elem[i * 9 + j * 3 + k]; + fc3[a * num_atom * num_atom * 27 + c * num_atom * 27 + b * 27 + + i * 9 + k * 3 + j] = fc3_elem[i * 9 + j * 3 + k]; + fc3[b * num_atom * num_atom * 27 + a * num_atom * 27 + c * 27 + + j * 9 + i * 3 + k] = fc3_elem[i * 9 + j * 3 + k]; + fc3[b * num_atom * num_atom * 27 + c * num_atom * 27 + a * 27 + + j * 9 + k * 3 + i] = fc3_elem[i * 9 + j * 3 + k]; + fc3[c * num_atom * num_atom * 27 + a * num_atom * 27 + b * 27 + + k * 9 + i * 3 + j] = fc3_elem[i * 9 + j * 3 + k]; + fc3[c * num_atom * num_atom * 27 + b * num_atom * 27 + a * 27 + + k * 9 + j * 3 + i] = fc3_elem[i * 9 + j * 3 + k]; + } + } } - } } static void set_permutation_symmetry_fc3_elem(double *fc3_elem, - const double *fc3, - const long a, - const long b, - const long c, - const long num_atom) -{ - long i, j, k; + const double *fc3, const long a, + const long b, const long c, + const long num_atom) { + long i, j, k; - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - for (k = 0; k < 3; k++) - { - fc3_elem[i * 9 + j * 3 + k] = - (fc3[a * num_atom * num_atom * 27 + - b * num_atom * 27 + - c * 27 + i * 9 + j * 3 + k] + - fc3[a * num_atom * num_atom * 27 + - c * num_atom * 27 + - b * 27 + i * 9 + k * 3 + j] + - fc3[b * num_atom * num_atom * 27 + - a * num_atom * 27 + - c * 27 + j * 9 + i * 3 + k] + - fc3[b * num_atom * num_atom * 27 + - c * num_atom * 27 + - a * 27 + j * 9 + k * 3 + i] + - fc3[c * num_atom * num_atom * 27 + - a * num_atom * 27 + - b * 27 + k * 9 + i * 3 + j] + - fc3[c * num_atom * num_atom * 27 + - b * num_atom * 27 + - a * 27 + k * 9 + j * 3 + i]) / - 6; - } + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 3; k++) { + fc3_elem[i * 9 + j * 3 + k] = + (fc3[a * num_atom * num_atom * 27 + b * num_atom * 27 + + c * 27 + i * 9 + j * 3 + k] + + fc3[a * num_atom * num_atom * 27 + c * num_atom * 27 + + b * 27 + i * 9 + k * 3 + j] + + fc3[b * num_atom * num_atom * 27 + a * num_atom * 27 + + c * 27 + j * 9 + i * 3 + k] + + fc3[b * num_atom * num_atom * 27 + c * num_atom * 27 + + a * 27 + j * 9 + k * 3 + i] + + fc3[c * num_atom * num_atom * 27 + a * num_atom * 27 + + b * 27 + k * 9 + i * 3 + j] + + fc3[c * num_atom * num_atom * 27 + b * num_atom * 27 + + a * 27 + k * 9 + j * 3 + i]) / + 6; + } + } } - } } -static void set_permutation_symmetry_compact_fc3(double *fc3, - const long p2s[], - const long s2pp[], - const long nsym_list[], - const long perms[], - const long n_satom, - const long n_patom) -{ - /* fc3 shape=(n_patom, n_satom, n_satom, 3, 3, 3) */ - /* 1D indexing: */ - /* i * n_satom * n_satom * 27 + j * n_satom * 27 + */ - /* k * 27 + l * 9 + m * 3 + n */ - long i, j, k, l, m, n, i_p, j_p, k_p; - long done_any; - long i_trans_j, k_trans_j, i_trans_k, j_trans_k; - long adrs[6]; - double fc3_elem[3][3][3]; - char *done; +static void set_permutation_symmetry_compact_fc3( + double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], + const long perms[], const long n_satom, const long n_patom) { + /* fc3 shape=(n_patom, n_satom, n_satom, 3, 3, 3) */ + /* 1D indexing: */ + /* i * n_satom * n_satom * 27 + j * n_satom * 27 + */ + /* k * 27 + l * 9 + m * 3 + n */ + long i, j, k, l, m, n, i_p, j_p, k_p; + long done_any; + long i_trans_j, k_trans_j, i_trans_k, j_trans_k; + long adrs[6]; + double fc3_elem[3][3][3]; + char *done; - done = NULL; - done = (char *)malloc(sizeof(char) * n_patom * n_satom * n_satom); - for (i = 0; i < n_patom * n_satom * n_satom; i++) - { - done[i] = 0; - } - - for (i_p = 0; i_p < n_patom; i_p++) - { - i = p2s[i_p]; - for (j = 0; j < n_satom; j++) - { - j_p = s2pp[j]; - i_trans_j = perms[nsym_list[j] * n_satom + i]; - for (k = 0; k < n_satom; k++) - { - k_p = s2pp[k]; - k_trans_j = perms[nsym_list[j] * n_satom + k]; - i_trans_k = perms[nsym_list[k] * n_satom + i]; - j_trans_k = perms[nsym_list[k] * n_satom + j]; - - /* ijk, ikj, jik, jki, kij, kji */ - adrs[0] = i_p * n_satom * n_satom + j * n_satom + k; - adrs[1] = i_p * n_satom * n_satom + k * n_satom + j; - adrs[2] = j_p * n_satom * n_satom + i_trans_j * n_satom + k_trans_j; - adrs[3] = j_p * n_satom * n_satom + k_trans_j * n_satom + i_trans_j; - adrs[4] = k_p * n_satom * n_satom + i_trans_k * n_satom + j_trans_k; - adrs[5] = k_p * n_satom * n_satom + j_trans_k * n_satom + i_trans_k; - - done_any = 0; - for (l = 0; l < 6; l++) - { - if (done[adrs[l]]) - { - done_any = 1; - break; - } - } - if (done_any) - { - continue; - } - - for (l = 0; l < 6; l++) - { - done[adrs[l]] = 1; - adrs[l] *= 27; - } - - for (l = 0; l < 3; l++) - { - for (m = 0; m < 3; m++) - { - for (n = 0; n < 3; n++) - { - fc3_elem[l][m][n] = fc3[adrs[0] + l * 9 + m * 3 + n]; - fc3_elem[l][m][n] += fc3[adrs[1] + l * 9 + n * 3 + m]; - fc3_elem[l][m][n] += fc3[adrs[2] + m * 9 + l * 3 + n]; - fc3_elem[l][m][n] += fc3[adrs[3] + m * 9 + n * 3 + l]; - fc3_elem[l][m][n] += fc3[adrs[4] + n * 9 + l * 3 + m]; - fc3_elem[l][m][n] += fc3[adrs[5] + n * 9 + m * 3 + l]; - fc3_elem[l][m][n] /= 6; - } - } - } - for (l = 0; l < 3; l++) - { - for (m = 0; m < 3; m++) - { - for (n = 0; n < 3; n++) - { - fc3[adrs[0] + l * 9 + m * 3 + n] = fc3_elem[l][m][n]; - fc3[adrs[1] + l * 9 + n * 3 + m] = fc3_elem[l][m][n]; - fc3[adrs[2] + m * 9 + l * 3 + n] = fc3_elem[l][m][n]; - fc3[adrs[3] + m * 9 + n * 3 + l] = fc3_elem[l][m][n]; - fc3[adrs[4] + n * 9 + l * 3 + m] = fc3_elem[l][m][n]; - fc3[adrs[5] + n * 9 + m * 3 + l] = fc3_elem[l][m][n]; - } - } - } - } + done = NULL; + done = (char *)malloc(sizeof(char) * n_patom * n_satom * n_satom); + for (i = 0; i < n_patom * n_satom * n_satom; i++) { + done[i] = 0; } - } - free(done); - done = NULL; + for (i_p = 0; i_p < n_patom; i_p++) { + i = p2s[i_p]; + for (j = 0; j < n_satom; j++) { + j_p = s2pp[j]; + i_trans_j = perms[nsym_list[j] * n_satom + i]; + for (k = 0; k < n_satom; k++) { + k_p = s2pp[k]; + k_trans_j = perms[nsym_list[j] * n_satom + k]; + i_trans_k = perms[nsym_list[k] * n_satom + i]; + j_trans_k = perms[nsym_list[k] * n_satom + j]; + + /* ijk, ikj, jik, jki, kij, kji */ + adrs[0] = i_p * n_satom * n_satom + j * n_satom + k; + adrs[1] = i_p * n_satom * n_satom + k * n_satom + j; + adrs[2] = + j_p * n_satom * n_satom + i_trans_j * n_satom + k_trans_j; + adrs[3] = + j_p * n_satom * n_satom + k_trans_j * n_satom + i_trans_j; + adrs[4] = + k_p * n_satom * n_satom + i_trans_k * n_satom + j_trans_k; + adrs[5] = + k_p * n_satom * n_satom + j_trans_k * n_satom + i_trans_k; + + done_any = 0; + for (l = 0; l < 6; l++) { + if (done[adrs[l]]) { + done_any = 1; + break; + } + } + if (done_any) { + continue; + } + + for (l = 0; l < 6; l++) { + done[adrs[l]] = 1; + adrs[l] *= 27; + } + + for (l = 0; l < 3; l++) { + for (m = 0; m < 3; m++) { + for (n = 0; n < 3; n++) { + fc3_elem[l][m][n] = + fc3[adrs[0] + l * 9 + m * 3 + n]; + fc3_elem[l][m][n] += + fc3[adrs[1] + l * 9 + n * 3 + m]; + fc3_elem[l][m][n] += + fc3[adrs[2] + m * 9 + l * 3 + n]; + fc3_elem[l][m][n] += + fc3[adrs[3] + m * 9 + n * 3 + l]; + fc3_elem[l][m][n] += + fc3[adrs[4] + n * 9 + l * 3 + m]; + fc3_elem[l][m][n] += + fc3[adrs[5] + n * 9 + m * 3 + l]; + fc3_elem[l][m][n] /= 6; + } + } + } + for (l = 0; l < 3; l++) { + for (m = 0; m < 3; m++) { + for (n = 0; n < 3; n++) { + fc3[adrs[0] + l * 9 + m * 3 + n] = + fc3_elem[l][m][n]; + fc3[adrs[1] + l * 9 + n * 3 + m] = + fc3_elem[l][m][n]; + fc3[adrs[2] + m * 9 + l * 3 + n] = + fc3_elem[l][m][n]; + fc3[adrs[3] + m * 9 + n * 3 + l] = + fc3_elem[l][m][n]; + fc3[adrs[4] + n * 9 + l * 3 + m] = + fc3_elem[l][m][n]; + fc3[adrs[5] + n * 9 + m * 3 + l] = + fc3_elem[l][m][n]; + } + } + } + } + } + } + + free(done); + done = NULL; } -static void transpose_compact_fc3_type01(double *fc3, - const long p2s[], +static void transpose_compact_fc3_type01(double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], - const long perms[], - const long n_satom, + const long perms[], const long n_satom, const long n_patom, - const long t_type) -{ - /* Three types of index permutations */ - /* t_type=0: dim[0] <-> dim[1] */ - /* t_type=1: dim[0] <-> dim[2] */ - /* t_type=2: dim[1] <-> dim[2] */ - long i, j, k, l, m, n, i_p, j_p, i_trans, k_trans; - long adrs, adrs_t; - double fc3_elem[3][3][3]; - char *done; + const long t_type) { + /* Three types of index permutations */ + /* t_type=0: dim[0] <-> dim[1] */ + /* t_type=1: dim[0] <-> dim[2] */ + /* t_type=2: dim[1] <-> dim[2] */ + long i, j, k, l, m, n, i_p, j_p, i_trans, k_trans; + long adrs, adrs_t; + double fc3_elem[3][3][3]; + char *done; - done = NULL; - done = (char *)malloc(sizeof(char) * n_satom * n_patom); - for (i = 0; i < n_satom * n_patom; i++) - { - done[i] = 0; - } - - for (i_p = 0; i_p < n_patom; i_p++) - { - i = p2s[i_p]; - for (j = 0; j < n_satom; j++) - { - j_p = s2pp[j]; - if (!done[i_p * n_satom + j]) - { - /* (j, i) -- nsym_list[j] --> (j', i') */ - /* nsym_list[j] translates j to j' where j' is in */ - /* primitive cell. The same translation sends i to i' */ - /* where i' is not necessarily to be in primitive cell. */ - /* Thus, i' = perms[nsym_list[j] * n_satom + i] */ - i_trans = perms[nsym_list[j] * n_satom + i]; - done[i_p * n_satom + j] = 1; - done[j_p * n_satom + i_trans] = 1; - for (k = 0; k < n_satom; k++) - { - k_trans = perms[nsym_list[j] * n_satom + k]; - - switch (t_type) - { - case 0: - adrs = (i_p * n_satom * n_satom + j * n_satom + k) * 27; - adrs_t = (j_p * n_satom * n_satom + i_trans * n_satom + k_trans) * 27; - for (l = 0; l < 3; l++) - { - for (m = 0; m < 3; m++) - { - for (n = 0; n < 3; n++) - { - fc3_elem[l][m][n] = fc3[adrs + l * 9 + m * 3 + n]; - } - } - } - if (adrs != adrs_t) - { - for (l = 0; l < 3; l++) - { - for (m = 0; m < 3; m++) - { - for (n = 0; n < 3; n++) - { - fc3[adrs + l * 9 + m * 3 + n] = fc3[adrs_t + m * 9 + l * 3 + n]; - } - } - } - } - for (l = 0; l < 3; l++) - { - for (m = 0; m < 3; m++) - { - for (n = 0; n < 3; n++) - { - fc3[adrs_t + m * 9 + l * 3 + n] = fc3_elem[l][m][n]; - } - } - } - break; - case 1: - adrs = (i_p * n_satom * n_satom + k * n_satom + j) * 27; - adrs_t = (j_p * n_satom * n_satom + k_trans * n_satom + i_trans) * 27; - for (l = 0; l < 3; l++) - { - for (m = 0; m < 3; m++) - { - for (n = 0; n < 3; n++) - { - fc3_elem[l][m][n] = fc3[adrs + l * 9 + m * 3 + n]; - } - } - } - if (adrs != adrs_t) - { - for (l = 0; l < 3; l++) - { - for (m = 0; m < 3; m++) - { - for (n = 0; n < 3; n++) - { - fc3[adrs + l * 9 + m * 3 + n] = fc3[adrs_t + n * 9 + m * 3 + l]; - } - } - } - } - for (l = 0; l < 3; l++) - { - for (m = 0; m < 3; m++) - { - for (n = 0; n < 3; n++) - { - fc3[adrs_t + n * 9 + m * 3 + l] = fc3_elem[l][m][n]; - } - } - } - break; - } /* end switch */ - } - } + done = NULL; + done = (char *)malloc(sizeof(char) * n_satom * n_patom); + for (i = 0; i < n_satom * n_patom; i++) { + done[i] = 0; } - } - free(done); - done = NULL; + for (i_p = 0; i_p < n_patom; i_p++) { + i = p2s[i_p]; + for (j = 0; j < n_satom; j++) { + j_p = s2pp[j]; + if (!done[i_p * n_satom + j]) { + /* (j, i) -- nsym_list[j] --> (j', i') */ + /* nsym_list[j] translates j to j' where j' is in */ + /* primitive cell. The same translation sends i to i' */ + /* where i' is not necessarily to be in primitive cell. */ + /* Thus, i' = perms[nsym_list[j] * n_satom + i] */ + i_trans = perms[nsym_list[j] * n_satom + i]; + done[i_p * n_satom + j] = 1; + done[j_p * n_satom + i_trans] = 1; + for (k = 0; k < n_satom; k++) { + k_trans = perms[nsym_list[j] * n_satom + k]; + + switch (t_type) { + case 0: + adrs = (i_p * n_satom * n_satom + j * n_satom + k) * + 27; + adrs_t = (j_p * n_satom * n_satom + + i_trans * n_satom + k_trans) * + 27; + for (l = 0; l < 3; l++) { + for (m = 0; m < 3; m++) { + for (n = 0; n < 3; n++) { + fc3_elem[l][m][n] = + fc3[adrs + l * 9 + m * 3 + n]; + } + } + } + if (adrs != adrs_t) { + for (l = 0; l < 3; l++) { + for (m = 0; m < 3; m++) { + for (n = 0; n < 3; n++) { + fc3[adrs + l * 9 + m * 3 + n] = + fc3[adrs_t + m * 9 + l * 3 + n]; + } + } + } + } + for (l = 0; l < 3; l++) { + for (m = 0; m < 3; m++) { + for (n = 0; n < 3; n++) { + fc3[adrs_t + m * 9 + l * 3 + n] = + fc3_elem[l][m][n]; + } + } + } + break; + case 1: + adrs = (i_p * n_satom * n_satom + k * n_satom + j) * + 27; + adrs_t = (j_p * n_satom * n_satom + + k_trans * n_satom + i_trans) * + 27; + for (l = 0; l < 3; l++) { + for (m = 0; m < 3; m++) { + for (n = 0; n < 3; n++) { + fc3_elem[l][m][n] = + fc3[adrs + l * 9 + m * 3 + n]; + } + } + } + if (adrs != adrs_t) { + for (l = 0; l < 3; l++) { + for (m = 0; m < 3; m++) { + for (n = 0; n < 3; n++) { + fc3[adrs + l * 9 + m * 3 + n] = + fc3[adrs_t + n * 9 + m * 3 + l]; + } + } + } + } + for (l = 0; l < 3; l++) { + for (m = 0; m < 3; m++) { + for (n = 0; n < 3; n++) { + fc3[adrs_t + n * 9 + m * 3 + l] = + fc3_elem[l][m][n]; + } + } + } + break; + } /* end switch */ + } + } + } + } + + free(done); + done = NULL; } -static void transpose_compact_fc3_type2(double *fc3, - const long p2s[], +static void transpose_compact_fc3_type2(double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], - const long perms[], - const long n_satom, - const long n_patom) -{ - long j, k, l, m, n, i_p; - long adrs, adrs_t; - double fc3_elem[3][3][3]; + const long perms[], const long n_satom, + const long n_patom) { + long j, k, l, m, n, i_p; + long adrs, adrs_t; + double fc3_elem[3][3][3]; - for (i_p = 0; i_p < n_patom; i_p++) - { - for (j = 0; j < n_satom; j++) - { - for (k = j; k < n_satom; k++) - { /* k >= j */ - adrs = (i_p * n_satom * n_satom + j * n_satom + k) * 27; - adrs_t = (i_p * n_satom * n_satom + k * n_satom + j) * 27; - for (l = 0; l < 3; l++) - { - for (m = 0; m < 3; m++) - { - for (n = 0; n < 3; n++) - { - fc3_elem[l][m][n] = fc3[adrs + l * 9 + m * 3 + n]; + for (i_p = 0; i_p < n_patom; i_p++) { + for (j = 0; j < n_satom; j++) { + for (k = j; k < n_satom; k++) { /* k >= j */ + adrs = (i_p * n_satom * n_satom + j * n_satom + k) * 27; + adrs_t = (i_p * n_satom * n_satom + k * n_satom + j) * 27; + for (l = 0; l < 3; l++) { + for (m = 0; m < 3; m++) { + for (n = 0; n < 3; n++) { + fc3_elem[l][m][n] = fc3[adrs + l * 9 + m * 3 + n]; + } + } + } + if (k != j) { + for (l = 0; l < 3; l++) { + for (m = 0; m < 3; m++) { + for (n = 0; n < 3; n++) { + fc3[adrs + l * 9 + m * 3 + n] = + fc3[adrs_t + l * 9 + n * 3 + m]; + } + } + } + } + for (l = 0; l < 3; l++) { + for (m = 0; m < 3; m++) { + for (n = 0; n < 3; n++) { + fc3[adrs_t + l * 9 + n * 3 + m] = fc3_elem[l][m][n]; + } + } + } } - } } - if (k != j) - { - for (l = 0; l < 3; l++) - { - for (m = 0; m < 3; m++) - { - for (n = 0; n < 3; n++) - { - fc3[adrs + l * 9 + m * 3 + n] = fc3[adrs_t + l * 9 + n * 3 + m]; - } - } - } - } - for (l = 0; l < 3; l++) - { - for (m = 0; m < 3; m++) - { - for (n = 0; n < 3; n++) - { - fc3[adrs_t + l * 9 + n * 3 + m] = fc3_elem[l][m][n]; - } - } - } - } } - } } diff --git a/c/fc3.h b/c/fc3.h index 90c1ad03..ec22018f 100644 --- a/c/fc3.h +++ b/c/fc3.h @@ -35,35 +35,21 @@ #ifndef __fc3_H__ #define __fc3_H__ -void fc3_distribute_fc3(double *fc3, - const long target, - const long source, - const long *atom_mapping, - const long num_atom, +void fc3_distribute_fc3(double *fc3, const long target, const long source, + const long *atom_mapping, const long num_atom, const double *rot_cart); void fc3_rotate_delta_fc2(double (*fc3)[3][3][3], - const double (*delta_fc2s)[3][3], - const double *inv_U, + const double (*delta_fc2s)[3][3], const double *inv_U, const double (*site_sym_cart)[3][3], - const long *rot_map_syms, - const long num_atom, - const long num_site_sym, - const long num_disp); + const long *rot_map_syms, const long num_atom, + const long num_site_sym, const long num_disp); void fc3_set_permutation_symmetry_fc3(double *fc3, const long num_atom); -void fc3_set_permutation_symmetry_compact_fc3(double *fc3, - const long p2s[], - const long s2pp[], - const long nsym_list[], - const long perms[], - const long n_satom, - const long n_patom); -void fc3_transpose_compact_fc3(double *fc3, - const long p2s[], - const long s2pp[], - const long nsym_list[], - const long perms[], - const long n_satom, - const long n_patom, +void fc3_set_permutation_symmetry_compact_fc3( + double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], + const long perms[], const long n_satom, const long n_patom); +void fc3_transpose_compact_fc3(double *fc3, const long p2s[], const long s2pp[], + const long nsym_list[], const long perms[], + const long n_satom, const long n_patom, const long t_type); #endif diff --git a/c/grgrid.c b/c/grgrid.c index 6f3b2877..502b6a85 100644 --- a/c/grgrid.c +++ b/c/grgrid.c @@ -32,10 +32,12 @@ /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include #include "grgrid.h" + +#include +#include +#include + #include "lagrid.h" #include "snf3x3.h" @@ -43,62 +45,47 @@ static void reduce_grid_address(long address[3], const long D_diag[3]); static long get_double_grid_index(const long address_double[3], - const long D_diag[3], - const long PS[3]); + const long D_diag[3], const long PS[3]); static long get_grid_index_from_address(const long address[3], const long D_diag[3]); static void get_all_grid_addresses(long grid_address[][3], const long D_diag[3]); -static void get_grid_address_from_index(long address[3], - const long grid_index, +static void get_grid_address_from_index(long address[3], const long grid_index, const long D_diag[3]); -static void get_grid_address(long address[3], - const long address_double[3], +static void get_grid_address(long address[3], const long address_double[3], const long PS[3]); static void get_double_grid_address(long address_double[3], - const long address[3], - const long PS[3]); -static long rotate_grid_index(const long grid_index, - const long rotation[3][3], - const long D_diag[3], - const long PS[3]); -static void get_ir_grid_map(long *ir_grid_map, - const long (*rotations)[3][3], - const long num_rot, - const long D_diag[3], + const long address[3], const long PS[3]); +static long rotate_grid_index(const long grid_index, const long rotation[3][3], + const long D_diag[3], const long PS[3]); +static void get_ir_grid_map(long *ir_grid_map, const long (*rotations)[3][3], + const long num_rot, const long D_diag[3], const long PS[3]); -long grg_get_snf3x3(long D_diag[3], - long P[3][3], - long Q[3][3], - const long A[3][3]) -{ - long i, j, succeeded; - long D[3][3]; +long grg_get_snf3x3(long D_diag[3], long P[3][3], long Q[3][3], + const long A[3][3]) { + long i, j, succeeded; + long D[3][3]; - succeeded = 0; + succeeded = 0; - if (lagmat_get_determinant_l3(A) == 0) - { - goto err; - } - - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - D[i][j] = A[i][j]; + if (lagmat_get_determinant_l3(A) == 0) { + goto err; } - } - succeeded = snf3x3(D, P, Q); - for (i = 0; i < 3; i++) - { - D_diag[i] = D[i][i]; - } + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + D[i][j] = A[i][j]; + } + } + + succeeded = snf3x3(D, P, Q); + for (i = 0; i < 3; i++) { + D_diag[i] = D[i][i]; + } err: - return succeeded; + return succeeded; } /*----------------------------------------*/ @@ -110,40 +97,34 @@ err: /* vectors. */ /* num_rot : Number of rotations */ long grg_transform_rotations(long (*transformed_rots)[3][3], - const long (*rotations)[3][3], - const long num_rot, - const long D_diag[3], - const long Q[3][3]) -{ - long i, j, k; - double r[3][3], Q_double[3][3]; + const long (*rotations)[3][3], const long num_rot, + const long D_diag[3], const long Q[3][3]) { + long i, j, k; + double r[3][3], Q_double[3][3]; - /* Compute D(Q^-1)RQ(D^-1) by three steps */ - /* It is assumed that |det(Q)|=1 and Q^-1 has relatively small round-off */ - /* error, and we want to divide by D carefully. */ - /* 1. Compute (Q^-1)RQ */ - /* 2. Compute D(Q^-1)RQ */ - /* 3. Compute D(Q^-1)RQ(D^-1) */ - lagmat_cast_matrix_3l_to_3d(Q_double, Q); - for (i = 0; i < num_rot; i++) - { - lagmat_get_similar_matrix_ld3(r, rotations[i], Q_double, 0); - for (j = 0; j < 3; j++) - { - for (k = 0; k < 3; k++) - { - r[j][k] *= D_diag[j]; - r[j][k] /= D_diag[k]; - } + /* Compute D(Q^-1)RQ(D^-1) by three steps */ + /* It is assumed that |det(Q)|=1 and Q^-1 has relatively small round-off */ + /* error, and we want to divide by D carefully. */ + /* 1. Compute (Q^-1)RQ */ + /* 2. Compute D(Q^-1)RQ */ + /* 3. Compute D(Q^-1)RQ(D^-1) */ + lagmat_cast_matrix_3l_to_3d(Q_double, Q); + for (i = 0; i < num_rot; i++) { + lagmat_get_similar_matrix_ld3(r, rotations[i], Q_double, 0); + for (j = 0; j < 3; j++) { + for (k = 0; k < 3; k++) { + r[j][k] *= D_diag[j]; + r[j][k] /= D_diag[k]; + } + } + lagmat_cast_matrix_3d_to_3l(transformed_rots[i], r); + if (!lagmat_check_identity_matrix_ld3(transformed_rots[i], r, + IDENTITY_TOL)) { + return 0; + } } - lagmat_cast_matrix_3d_to_3l(transformed_rots[i], r); - if (!lagmat_check_identity_matrix_ld3(transformed_rots[i], r, IDENTITY_TOL)) - { - return 0; - } - } - return 1; + return 1; } /* -------------------------------*/ @@ -151,9 +132,8 @@ long grg_transform_rotations(long (*transformed_rots)[3][3], /* -------------------------------*/ /* address : Single grid address. */ /* D_diag : Diagnal elements of D. */ -void grg_get_all_grid_addresses(long (*grid_address)[3], const long D_diag[3]) -{ - get_all_grid_addresses(grid_address, D_diag); +void grg_get_all_grid_addresses(long (*grid_address)[3], const long D_diag[3]) { + get_all_grid_addresses(grid_address, D_diag); } /* -------------------------------------------------------*/ @@ -164,11 +144,9 @@ void grg_get_all_grid_addresses(long (*grid_address)[3], const long D_diag[3]) /* address_double : Double grid address. */ /* address : Single grid address. */ /* PS : Shifts transformed by P. s_i is 0 or 1. */ -void grg_get_double_grid_address(long address_double[3], - const long address[3], - const long PS[3]) -{ - get_double_grid_address(address_double, address, PS); +void grg_get_double_grid_address(long address_double[3], const long address[3], + const long PS[3]) { + get_double_grid_address(address_double, address, PS); } /* -------------------------------------------------------*/ @@ -179,11 +157,9 @@ void grg_get_double_grid_address(long address_double[3], /* address : Single grid address. */ /* address_double : Double grid address. */ /* PS : Shifts transformed by P. s_i is 0 or 1. */ -void grg_get_grid_address(long address[3], - const long address_double[3], - const long PS[3]) -{ - get_grid_address(address, address_double, PS); +void grg_get_grid_address(long address[3], const long address_double[3], + const long PS[3]) { + get_grid_address(address, address_double, PS); } /* -------------------------------------------------*/ @@ -193,10 +169,8 @@ void grg_get_grid_address(long address[3], /* D_diag : Diagnal elements of D. */ /* PS : Shifts transformed by P. s_i is 0 or 1. */ long grg_get_double_grid_index(const long address_double[3], - const long D_diag[3], - const long PS[3]) -{ - return get_double_grid_index(address_double, D_diag, PS); + const long D_diag[3], const long PS[3]) { + return get_double_grid_index(address_double, D_diag, PS); } /* -------------------------------------------------*/ @@ -204,13 +178,12 @@ long grg_get_double_grid_index(const long address_double[3], /* -------------------------------------------------*/ /* address : Single grid address. */ /* D_diag : Diagnal elements of D. */ -long grg_get_grid_index(const long address[3], const long D_diag[3]) -{ - long red_adrs[3]; +long grg_get_grid_index(const long address[3], const long D_diag[3]) { + long red_adrs[3]; - lagmat_copy_vector_l3(red_adrs, address); - reduce_grid_address(red_adrs, D_diag); - return get_grid_index_from_address(red_adrs, D_diag); + lagmat_copy_vector_l3(red_adrs, address); + reduce_grid_address(red_adrs, D_diag); + return get_grid_index_from_address(red_adrs, D_diag); } /* ---------------------------------------*/ @@ -218,38 +191,26 @@ long grg_get_grid_index(const long address[3], const long D_diag[3]) /* ---------------------------------------*/ /* address : Single grid address. */ /* D_diag : Diagnal elements of D. */ -void grg_get_grid_address_from_index(long address[3], - const long grid_index, - const long D_diag[3]) -{ - get_grid_address_from_index(address, grid_index, D_diag); +void grg_get_grid_address_from_index(long address[3], const long grid_index, + const long D_diag[3]) { + get_grid_address_from_index(address, grid_index, D_diag); } /* ---------------------------*/ /* Rotate grid point by index */ /* ---------------------------*/ -long grg_rotate_grid_index(const long grid_index, - const long rotation[3][3], - const long D_diag[3], - const long PS[3]) -{ - return rotate_grid_index(grid_index, rotation, D_diag, PS); +long grg_rotate_grid_index(const long grid_index, const long rotation[3][3], + const long D_diag[3], const long PS[3]) { + return rotate_grid_index(grid_index, rotation, D_diag, PS); } /* -----------------------------*/ /* Find irreducible grid points */ /* -----------------------------*/ -void grg_get_ir_grid_map(long *ir_grid_map, - const long (*rotations)[3][3], - const long num_rot, - const long D_diag[3], - const long PS[3]) -{ - get_ir_grid_map(ir_grid_map, - rotations, - num_rot, - D_diag, - PS); +void grg_get_ir_grid_map(long *ir_grid_map, const long (*rotations)[3][3], + const long num_rot, const long D_diag[3], + const long PS[3]) { + get_ir_grid_map(ir_grid_map, rotations, num_rot, D_diag, PS); } /* Unique reciprocal rotations are collected from input rotations. */ @@ -267,92 +228,74 @@ long grg_get_reciprocal_point_group(long rec_rotations[48][3][3], const long is_transpose) { - long i, j, num_rot_ret, inv_exist; - const long inversion[3][3] = { - {-1, 0, 0}, - {0, -1, 0}, - {0, 0, -1}}; + long i, j, num_rot_ret, inv_exist; + const long inversion[3][3] = {{-1, 0, 0}, {0, -1, 0}, {0, 0, -1}}; - /* Collect unique rotations */ - num_rot_ret = 0; - for (i = 0; i < num_rot; i++) - { - for (j = 0; j < num_rot_ret; j++) - { - if (lagmat_check_identity_matrix_l3(rotations[i], rec_rotations[j])) - { - goto escape; - } - } - if (num_rot_ret == 48) - { - goto err; - } - lagmat_copy_matrix_l3(rec_rotations[num_rot_ret], rotations[i]); - num_rot_ret++; - escape:; - } - - if (is_transpose) - { - for (i = 0; i < num_rot_ret; i++) - { - lagmat_transpose_matrix_l3(rec_rotations[i], rec_rotations[i]); - } - } - - if (is_time_reversal) - { - inv_exist = 0; - for (i = 0; i < num_rot_ret; i++) - { - if (lagmat_check_identity_matrix_l3(inversion, rec_rotations[i])) - { - inv_exist = 1; - break; - } + /* Collect unique rotations */ + num_rot_ret = 0; + for (i = 0; i < num_rot; i++) { + for (j = 0; j < num_rot_ret; j++) { + if (lagmat_check_identity_matrix_l3(rotations[i], + rec_rotations[j])) { + goto escape; + } + } + if (num_rot_ret == 48) { + goto err; + } + lagmat_copy_matrix_l3(rec_rotations[num_rot_ret], rotations[i]); + num_rot_ret++; + escape:; } - if (!inv_exist) - { - if (num_rot_ret > 24) - { - goto err; - } - - for (i = 0; i < num_rot_ret; i++) - { - lagmat_multiply_matrix_l3(rec_rotations[num_rot_ret + i], - inversion, rec_rotations[i]); - } - num_rot_ret *= 2; + if (is_transpose) { + for (i = 0; i < num_rot_ret; i++) { + lagmat_transpose_matrix_l3(rec_rotations[i], rec_rotations[i]); + } } - } - return num_rot_ret; + if (is_time_reversal) { + inv_exist = 0; + for (i = 0; i < num_rot_ret; i++) { + if (lagmat_check_identity_matrix_l3(inversion, rec_rotations[i])) { + inv_exist = 1; + break; + } + } + + if (!inv_exist) { + if (num_rot_ret > 24) { + goto err; + } + + for (i = 0; i < num_rot_ret; i++) { + lagmat_multiply_matrix_l3(rec_rotations[num_rot_ret + i], + inversion, rec_rotations[i]); + } + num_rot_ret *= 2; + } + } + + return num_rot_ret; err: - return 0; + return 0; } -static void reduce_grid_address(long address[3], const long D_diag[3]) -{ - long i; +static void reduce_grid_address(long address[3], const long D_diag[3]) { + long i; - for (i = 0; i < 3; i++) - { - address[i] = lagmat_modulo_l(address[i], D_diag[i]); - } + for (i = 0; i < 3; i++) { + address[i] = lagmat_modulo_l(address[i], D_diag[i]); + } } static long get_double_grid_index(const long address_double[3], - const long D_diag[3], - const long PS[3]) -{ - long address[3]; + const long D_diag[3], const long PS[3]) { + long address[3]; - get_grid_address(address, address_double, PS); - reduce_grid_address(address, D_diag); - return get_grid_index_from_address(address, D_diag); + get_grid_address(address, address_double, PS); + reduce_grid_address(address, D_diag); + return get_grid_index_from_address(address, D_diag); } /* Here address elements have to be zero or positive. */ @@ -360,133 +303,111 @@ static long get_double_grid_index(const long address_double[3], /* done outside of this function. */ /* See kgrid.h about GRID_ORDER_XYZ information. */ static long get_grid_index_from_address(const long address[3], - const long D_diag[3]) -{ + const long D_diag[3]) { #ifndef GRID_ORDER_XYZ - return (address[2] * D_diag[0] * D_diag[1] + address[1] * D_diag[0] + address[0]); + return (address[2] * D_diag[0] * D_diag[1] + address[1] * D_diag[0] + + address[0]); #else - return (address[0] * D_diag[1] * D_diag[2] + address[1] * D_diag[2] + address[2]); + return (address[0] * D_diag[1] * D_diag[2] + address[1] * D_diag[2] + + address[2]); #endif } static void get_all_grid_addresses(long grid_address[][3], - const long D_diag[3]) -{ - long i, j, k, grid_index; - long address[3]; + const long D_diag[3]) { + long i, j, k, grid_index; + long address[3]; - for (i = 0; i < D_diag[0]; i++) - { - address[0] = i; - for (j = 0; j < D_diag[1]; j++) - { - address[1] = j; - for (k = 0; k < D_diag[2]; k++) - { - address[2] = k; - grid_index = get_grid_index_from_address(address, D_diag); - lagmat_copy_vector_l3(grid_address[grid_index], address); - } + for (i = 0; i < D_diag[0]; i++) { + address[0] = i; + for (j = 0; j < D_diag[1]; j++) { + address[1] = j; + for (k = 0; k < D_diag[2]; k++) { + address[2] = k; + grid_index = get_grid_index_from_address(address, D_diag); + lagmat_copy_vector_l3(grid_address[grid_index], address); + } + } } - } } /* See grg_get_grid_address_from_index */ -static void get_grid_address_from_index(long address[3], - const long grid_index, - const long D_diag[3]) -{ - long nn; +static void get_grid_address_from_index(long address[3], const long grid_index, + const long D_diag[3]) { + long nn; #ifndef GRID_ORDER_XYZ - nn = D_diag[0] * D_diag[1]; - address[0] = grid_index % D_diag[0]; - address[2] = grid_index / nn; - address[1] = (grid_index - address[2] * nn) / D_diag[0]; + nn = D_diag[0] * D_diag[1]; + address[0] = grid_index % D_diag[0]; + address[2] = grid_index / nn; + address[1] = (grid_index - address[2] * nn) / D_diag[0]; #else - nn = D_diag[1] * D_diag[2]; - address[2] = grid_index % D_diag[2]; - address[0] = grid_index / nn; - address[1] = (grid_index - address[0] * nn) / D_diag[2]; + nn = D_diag[1] * D_diag[2]; + address[2] = grid_index % D_diag[2]; + address[0] = grid_index / nn; + address[1] = (grid_index - address[0] * nn) / D_diag[2]; #endif } /* Usually address has to be reduced to [0, D_diag[i]) */ /* by calling reduce_grid_address after this operation. */ -static void get_grid_address(long address[3], - const long address_double[3], - const long PS[3]) -{ - long i; +static void get_grid_address(long address[3], const long address_double[3], + const long PS[3]) { + long i; - for (i = 0; i < 3; i++) - { - address[i] = (address_double[i] - PS[i]) / 2; - } + for (i = 0; i < 3; i++) { + address[i] = (address_double[i] - PS[i]) / 2; + } } /* Usually address_double has to be reduced to [0, 2*D_diag[i]) */ /* by calling reduce_double_grid_address after this operation. */ static void get_double_grid_address(long address_double[3], - const long address[3], - const long PS[3]) -{ - long i; + const long address[3], const long PS[3]) { + long i; - for (i = 0; i < 3; i++) - { - address_double[i] = address[i] * 2 + PS[i]; - } + for (i = 0; i < 3; i++) { + address_double[i] = address[i] * 2 + PS[i]; + } } -static long rotate_grid_index(const long grid_index, - const long rotation[3][3], - const long D_diag[3], - const long PS[3]) -{ - long adrs[3], dadrs[3], dadrs_rot[3]; +static long rotate_grid_index(const long grid_index, const long rotation[3][3], + const long D_diag[3], const long PS[3]) { + long adrs[3], dadrs[3], dadrs_rot[3]; - get_grid_address_from_index(adrs, grid_index, D_diag); - get_double_grid_address(dadrs, adrs, PS); - lagmat_multiply_matrix_vector_l3(dadrs_rot, rotation, dadrs); - return get_double_grid_index(dadrs_rot, D_diag, PS); + get_grid_address_from_index(adrs, grid_index, D_diag); + get_double_grid_address(dadrs, adrs, PS); + lagmat_multiply_matrix_vector_l3(dadrs_rot, rotation, dadrs); + return get_double_grid_index(dadrs_rot, D_diag, PS); } /* Find ir-grid points. */ /* This algorithm relies on the ir-grid index is always smallest */ /* number among symmetrically equivalent grid points. */ -static void get_ir_grid_map(long *ir_grid_map, - const long (*rotations)[3][3], - const long num_rot, - const long D_diag[3], - const long PS[3]) -{ - long gp, num_gp, r_gp; - long i; +static void get_ir_grid_map(long *ir_grid_map, const long (*rotations)[3][3], + const long num_rot, const long D_diag[3], + const long PS[3]) { + long gp, num_gp, r_gp; + long i; - num_gp = D_diag[0] * D_diag[1] * D_diag[2]; + num_gp = D_diag[0] * D_diag[1] * D_diag[2]; - for (gp = 0; gp < num_gp; gp++) - { - ir_grid_map[gp] = num_gp; - } - - /* Do not simply multithreaded this for-loop. */ - /* This algorithm contains race condition in different gp's. */ - for (gp = 0; gp < num_gp; gp++) - { - for (i = 0; i < num_rot; i++) - { - r_gp = rotate_grid_index(gp, rotations[i], D_diag, PS); - if (r_gp < gp) - { - ir_grid_map[gp] = ir_grid_map[r_gp]; - break; - } + for (gp = 0; gp < num_gp; gp++) { + ir_grid_map[gp] = num_gp; } - if (ir_grid_map[gp] == num_gp) - { - ir_grid_map[gp] = gp; + + /* Do not simply multithreaded this for-loop. */ + /* This algorithm contains race condition in different gp's. */ + for (gp = 0; gp < num_gp; gp++) { + for (i = 0; i < num_rot; i++) { + r_gp = rotate_grid_index(gp, rotations[i], D_diag, PS); + if (r_gp < gp) { + ir_grid_map[gp] = ir_grid_map[r_gp]; + break; + } + } + if (ir_grid_map[gp] == num_gp) { + ir_grid_map[gp] = gp; + } } - } } diff --git a/c/grgrid.h b/c/grgrid.h index 4fc3157a..62c968b3 100644 --- a/c/grgrid.h +++ b/c/grgrid.h @@ -37,38 +37,25 @@ #include -long grg_get_snf3x3(long D_diag[3], - long P[3][3], - long Q[3][3], +long grg_get_snf3x3(long D_diag[3], long P[3][3], long Q[3][3], const long A[3][3]); long grg_transform_rotations(long (*transformed_rots)[3][3], - const long (*rotations)[3][3], - const long num_rot, - const long D_diag[3], - const long Q[3][3]); + const long (*rotations)[3][3], const long num_rot, + const long D_diag[3], const long Q[3][3]); void grg_get_all_grid_addresses(long (*grid_address)[3], const long D_diag[3]); -void grg_get_double_grid_address(long address_double[3], - const long address[3], +void grg_get_double_grid_address(long address_double[3], const long address[3], const long PS[3]); -void grg_get_grid_address(long address[3], - const long address_double[3], +void grg_get_grid_address(long address[3], const long address_double[3], const long PS[3]); -long grg_get_grid_index(const long address[3], - const long D_diag[3]); +long grg_get_grid_index(const long address[3], const long D_diag[3]); long grg_get_double_grid_index(const long address_double[3], - const long D_diag[3], - const long PS[3]); -void grg_get_grid_address_from_index(long address[3], - const long grid_index, + const long D_diag[3], const long PS[3]); +void grg_get_grid_address_from_index(long address[3], const long grid_index, const long D_diag[3]); -long grg_rotate_grid_index(const long grid_index, - const long rotations[3][3], - const long D_diag[3], - const long PS[3]); -void grg_get_ir_grid_map(long *ir_grid_map, - const long (*rotations)[3][3], - const long num_rot, - const long D_diag[3], +long grg_rotate_grid_index(const long grid_index, const long rotations[3][3], + const long D_diag[3], const long PS[3]); +void grg_get_ir_grid_map(long *ir_grid_map, const long (*rotations)[3][3], + const long num_rot, const long D_diag[3], const long PS[3]); long grg_get_reciprocal_point_group(long rec_rotations[48][3][3], const long (*rotations)[3][3], diff --git a/c/gridsys.c b/c/gridsys.c index 1d28e77c..2f627e2a 100644 --- a/c/gridsys.c +++ b/c/gridsys.c @@ -34,76 +34,58 @@ #include "gridsys.h" +#include +#include + #include "bzgrid.h" -#include "lagrid.h" #include "grgrid.h" +#include "lagrid.h" #include "tetrahedron_method.h" #include "triplet.h" #include "triplet_iw.h" -#include -#include - void gridsys_get_all_grid_addresses(long (*gr_grid_addresses)[3], - const long D_diag[3]) -{ - grg_get_all_grid_addresses(gr_grid_addresses, D_diag); + const long D_diag[3]) { + grg_get_all_grid_addresses(gr_grid_addresses, D_diag); } void gridsys_get_double_grid_address(long address_double[3], - const long address[3], - const long PS[3]) -{ - grg_get_double_grid_address(address_double, address, PS); + const long address[3], const long PS[3]) { + grg_get_double_grid_address(address_double, address, PS); } -void gridsys_get_grid_address_from_index(long address[3], - const long grid_index, - const long D_diag[3]) -{ - grg_get_grid_address_from_index(address, grid_index, D_diag); +void gridsys_get_grid_address_from_index(long address[3], const long grid_index, + const long D_diag[3]) { + grg_get_grid_address_from_index(address, grid_index, D_diag); } long gridsys_get_double_grid_index(const long address_double[3], - const long D_diag[3], - const long PS[3]) -{ - return grg_get_double_grid_index(address_double, D_diag, PS); + const long D_diag[3], const long PS[3]) { + return grg_get_double_grid_index(address_double, D_diag, PS); } /* From single address to grid index */ long gridsys_get_grid_index_from_address(const long address[3], - const long D_diag[3]) -{ - return grg_get_grid_index(address, D_diag); + const long D_diag[3]) { + return grg_get_grid_index(address, D_diag); } -long gridsys_rotate_grid_index(const long grid_index, - const long rotation[3][3], - const long D_diag[3], - const long PS[3]) -{ - return grg_rotate_grid_index(grid_index, rotation, D_diag, PS); +long gridsys_rotate_grid_index(const long grid_index, const long rotation[3][3], + const long D_diag[3], const long PS[3]) { + return grg_rotate_grid_index(grid_index, rotation, D_diag, PS); } long gridsys_get_reciprocal_point_group(long rec_rotations[48][3][3], const long (*rotations)[3][3], const long num_rot, - const long is_time_reversal) -{ - return grg_get_reciprocal_point_group(rec_rotations, - rotations, - num_rot, - is_time_reversal, - 1); + const long is_time_reversal) { + return grg_get_reciprocal_point_group(rec_rotations, rotations, num_rot, + is_time_reversal, 1); } -long gridsys_get_snf3x3(long D_diag[3], - long P[3][3], - long Q[3][3], - const long A[3][3]) -{ - return grg_get_snf3x3(D_diag, P, Q, A); +long gridsys_get_snf3x3(long D_diag[3], long P[3][3], long Q[3][3], + const long A[3][3]) { + return grg_get_snf3x3(D_diag, P, Q, A); } /* Rotation matrices with respect to reciprocal basis vectors are @@ -111,43 +93,33 @@ long gridsys_get_snf3x3(long D_diag[3], * used always in GRGrid handling. */ long gridsys_transform_rotations(long (*transformed_rots)[3][3], const long (*rotations)[3][3], - const long num_rot, - const long D_diag[3], - const long Q[3][3]) -{ - long succeeded; - succeeded = grg_transform_rotations(transformed_rots, - rotations, - num_rot, - D_diag, - Q); - return succeeded; + const long num_rot, const long D_diag[3], + const long Q[3][3]) { + long succeeded; + succeeded = grg_transform_rotations(transformed_rots, rotations, num_rot, + D_diag, Q); + return succeeded; } double gridsys_get_thm_integration_weight(const double omega, const double tetrahedra_omegas[24][4], - const char function) -{ - return thm_get_integration_weight(omega, tetrahedra_omegas, function); + const char function) { + return thm_get_integration_weight(omega, tetrahedra_omegas, function); } /* Get one dataset of relative grid address used for tetrahedron */ /* method. rec_lattice is used to choose the one. */ /* rec_lattice : microzone basis vectors in column vectors */ -void gridsys_get_thm_relative_grid_address(long relative_grid_addresses[24][4][3], - const double rec_lattice[3][3]) -{ - thm_get_relative_grid_address(relative_grid_addresses, rec_lattice); +void gridsys_get_thm_relative_grid_address( + long relative_grid_addresses[24][4][3], const double rec_lattice[3][3]) { + thm_get_relative_grid_address(relative_grid_addresses, rec_lattice); } /* The rotations are those after proper transformation in GRGrid. */ -void gridsys_get_ir_grid_map(long *ir_grid_map, - const long (*rotations)[3][3], - const long num_rot, - const long D_diag[3], - const long PS[3]) -{ - grg_get_ir_grid_map(ir_grid_map, rotations, num_rot, D_diag, PS); +void gridsys_get_ir_grid_map(long *ir_grid_map, const long (*rotations)[3][3], + const long num_rot, const long D_diag[3], + const long PS[3]) { + grg_get_ir_grid_map(ir_grid_map, rotations, num_rot, D_diag, PS); } /* Find shortest grid points from Gamma considering periodicity of */ @@ -173,197 +145,130 @@ void gridsys_get_ir_grid_map(long *ir_grid_map, /* len(bzg2grg) == len(bz_grid_addresses) <= product(D_diag + 1). */ /* (function return) size : */ /* Number of bz_grid_addresses stored. */ -long gridsys_get_bz_grid_addresses(long (*bz_grid_addresses)[3], - long *bz_map, - long *bzg2grg, - const long D_diag[3], - const long Q[3][3], - const long PS[3], +long gridsys_get_bz_grid_addresses(long (*bz_grid_addresses)[3], long *bz_map, + long *bzg2grg, const long D_diag[3], + const long Q[3][3], const long PS[3], const double rec_lattice[3][3], - const long type) -{ - BZGrid *bzgrid; - long i, j, size; + const long type) { + BZGrid *bzgrid; + long i, j, size; - if ((bzgrid = (BZGrid *)malloc(sizeof(BZGrid))) == NULL) - { - warning_print("Memory could not be allocated."); - return 0; - } - - bzgrid->addresses = bz_grid_addresses; - bzgrid->gp_map = bz_map; - bzgrid->bzg2grg = bzg2grg; - bzgrid->type = type; - for (i = 0; i < 3; i++) - { - bzgrid->D_diag[i] = D_diag[i]; - bzgrid->PS[i] = PS[i]; - for (j = 0; j < 3; j++) - { - bzgrid->Q[i][j] = Q[i][j]; - bzgrid->reclat[i][j] = rec_lattice[i][j]; + if ((bzgrid = (BZGrid *)malloc(sizeof(BZGrid))) == NULL) { + warning_print("Memory could not be allocated."); + return 0; } - } - if (bzg_get_bz_grid_addresses(bzgrid)) - { - size = bzgrid->size; - } - else - { - size = 0; - } + bzgrid->addresses = bz_grid_addresses; + bzgrid->gp_map = bz_map; + bzgrid->bzg2grg = bzg2grg; + bzgrid->type = type; + for (i = 0; i < 3; i++) { + bzgrid->D_diag[i] = D_diag[i]; + bzgrid->PS[i] = PS[i]; + for (j = 0; j < 3; j++) { + bzgrid->Q[i][j] = Q[i][j]; + bzgrid->reclat[i][j] = rec_lattice[i][j]; + } + } - free(bzgrid); - bzgrid = NULL; + if (bzg_get_bz_grid_addresses(bzgrid)) { + size = bzgrid->size; + } else { + size = 0; + } - return size; + free(bzgrid); + bzgrid = NULL; + + return size; } -long gridsys_get_triplets_at_q(long *map_triplets, - long *map_q, - const long grid_point, - const long D_diag[3], - const long is_time_reversal, - const long num_rot, +long gridsys_get_triplets_at_q(long *map_triplets, long *map_q, + const long grid_point, const long D_diag[3], + const long is_time_reversal, const long num_rot, const long (*rec_rotations)[3][3], - const long swappable) -{ - return tpl_get_triplets_reciprocal_mesh_at_q(map_triplets, - map_q, - grid_point, - D_diag, - is_time_reversal, - num_rot, - rec_rotations, - swappable); + const long swappable) { + return tpl_get_triplets_reciprocal_mesh_at_q( + map_triplets, map_q, grid_point, D_diag, is_time_reversal, num_rot, + rec_rotations, swappable); } -long gridsys_get_BZ_triplets_at_q(long (*triplets)[3], - const long grid_point, +long gridsys_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point, const long (*bz_grid_addresses)[3], - const long *bz_map, - const long *map_triplets, + const long *bz_map, const long *map_triplets, const long num_map_triplets, - const long D_diag[3], - const long Q[3][3], - const long bz_grid_type) -{ - ConstBZGrid *bzgrid; - long i, j, num_ir; + const long D_diag[3], const long Q[3][3], + const long bz_grid_type) { + ConstBZGrid *bzgrid; + long i, j, num_ir; - if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) - { - warning_print("Memory could not be allocated."); - return 0; - } - - bzgrid->addresses = bz_grid_addresses; - bzgrid->gp_map = bz_map; - bzgrid->type = bz_grid_type; - for (i = 0; i < 3; i++) - { - bzgrid->D_diag[i] = D_diag[i]; - bzgrid->PS[i] = 0; - for (j = 0; j < 3; j++) - { - bzgrid->Q[i][j] = Q[i][j]; + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) { + warning_print("Memory could not be allocated."); + return 0; } - } - bzgrid->size = num_map_triplets; - num_ir = tpl_get_BZ_triplets_at_q(triplets, - grid_point, - bzgrid, - map_triplets); - free(bzgrid); - bzgrid = NULL; + bzgrid->addresses = bz_grid_addresses; + bzgrid->gp_map = bz_map; + bzgrid->type = bz_grid_type; + for (i = 0; i < 3; i++) { + bzgrid->D_diag[i] = D_diag[i]; + bzgrid->PS[i] = 0; + for (j = 0; j < 3; j++) { + bzgrid->Q[i][j] = Q[i][j]; + } + } + bzgrid->size = num_map_triplets; - return num_ir; + num_ir = + tpl_get_BZ_triplets_at_q(triplets, grid_point, bzgrid, map_triplets); + free(bzgrid); + bzgrid = NULL; + + return num_ir; } /* relative_grid_addresses are given as P multipled with those from */ /* dataset, i.e., */ /* np.dot(relative_grid_addresses, P.T) */ -long gridsys_get_integration_weight(double *iw, - char *iw_zero, - const double *frequency_points, - const long num_band0, - const long relative_grid_address[24][4][3], - const long D_diag[3], - const long (*triplets)[3], - const long num_triplets, - const long (*bz_grid_addresses)[3], - const long *bz_map, - const long bz_grid_type, - const double *frequencies1, - const long num_band1, - const double *frequencies2, - const long num_band2, - const long tp_type, - const long openmp_per_triplets, - const long openmp_per_bands) -{ - ConstBZGrid *bzgrid; - long i; +long gridsys_get_integration_weight( + double *iw, char *iw_zero, const double *frequency_points, + const long num_band0, const long relative_grid_address[24][4][3], + const long D_diag[3], const long (*triplets)[3], const long num_triplets, + const long (*bz_grid_addresses)[3], const long *bz_map, + const long bz_grid_type, const double *frequencies1, const long num_band1, + const double *frequencies2, const long num_band2, const long tp_type, + const long openmp_per_triplets, const long openmp_per_bands) { + ConstBZGrid *bzgrid; + long i; - if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) - { - warning_print("Memory could not be allocated."); - return 0; - } + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) { + warning_print("Memory could not be allocated."); + return 0; + } - bzgrid->addresses = bz_grid_addresses; - bzgrid->gp_map = bz_map; - bzgrid->type = bz_grid_type; - for (i = 0; i < 3; i++) - { - bzgrid->D_diag[i] = D_diag[i]; - } + bzgrid->addresses = bz_grid_addresses; + bzgrid->gp_map = bz_map; + bzgrid->type = bz_grid_type; + for (i = 0; i < 3; i++) { + bzgrid->D_diag[i] = D_diag[i]; + } - tpl_get_integration_weight(iw, - iw_zero, - frequency_points, - num_band0, - relative_grid_address, - triplets, - num_triplets, - bzgrid, - frequencies1, - num_band1, - frequencies2, - num_band2, - tp_type, - openmp_per_triplets, - openmp_per_bands); - free(bzgrid); - bzgrid = NULL; + tpl_get_integration_weight( + iw, iw_zero, frequency_points, num_band0, relative_grid_address, + triplets, num_triplets, bzgrid, frequencies1, num_band1, frequencies2, + num_band2, tp_type, openmp_per_triplets, openmp_per_bands); + free(bzgrid); + bzgrid = NULL; - return 1; + return 1; } -void gridsys_get_integration_weight_with_sigma(double *iw, - char *iw_zero, - const double sigma, - const double sigma_cutoff, - const double *frequency_points, - const long num_band0, - const long (*triplets)[3], - const long num_triplets, - const double *frequencies, - const long num_band, - const long tp_type) -{ - tpl_get_integration_weight_with_sigma(iw, - iw_zero, - sigma, - sigma_cutoff, - frequency_points, - num_band0, - triplets, - num_triplets, - frequencies, - num_band, - tp_type); +void gridsys_get_integration_weight_with_sigma( + double *iw, char *iw_zero, const double sigma, const double sigma_cutoff, + const double *frequency_points, const long num_band0, + const long (*triplets)[3], const long num_triplets, + const double *frequencies, const long num_band, const long tp_type) { + tpl_get_integration_weight_with_sigma( + iw, iw_zero, sigma, sigma_cutoff, frequency_points, num_band0, triplets, + num_triplets, frequencies, num_band, tp_type); } diff --git a/c/gridsys.h b/c/gridsys.h index 2d78d742..f96869e4 100644 --- a/c/gridsys.h +++ b/c/gridsys.h @@ -36,104 +36,68 @@ #define __gridsys_H__ #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif - void gridsys_get_all_grid_addresses(long (*gr_grid_addresses)[3], - const long D_diag[3]); - void gridsys_get_double_grid_address(long address_double[3], - const long address[3], - const long PS[3]); - void gridsys_get_grid_address_from_index(long address[3], - const long grid_index, - const long D_diag[3]); - long gridsys_get_double_grid_index(const long address_double[3], - const long D_diag[3], - const long PS[3]); - long gridsys_get_grid_index_from_address(const long address[3], - const long D_diag[3]); - long gridsys_rotate_grid_index(const long grid_index, - const long rotation[3][3], - const long D_diag[3], - const long PS[3]); - long gridsys_get_reciprocal_point_group(long rec_rotations[48][3][3], - const long (*rotations)[3][3], - const long num_rot, - const long is_time_reversal); - long gridsys_get_snf3x3(long D_diag[3], - long P[3][3], - long Q[3][3], - const long A[3][3]); - long gridsys_transform_rotations(long (*transformed_rots)[3][3], - const long (*rotations)[3][3], - const long num_rot, - const long D_diag[3], - const long Q[3][3]); - double gridsys_get_thm_integration_weight(const double omega, - const double tetrahedra_omegas[24][4], - const char function); - void gridsys_get_thm_relative_grid_address(long relative_grid_addresses[24][4][3], - const double rec_lattice[3][3]); - void gridsys_get_ir_grid_map(long *ir_grid_map, +void gridsys_get_all_grid_addresses(long (*gr_grid_addresses)[3], + const long D_diag[3]); +void gridsys_get_double_grid_address(long address_double[3], + const long address[3], const long PS[3]); +void gridsys_get_grid_address_from_index(long address[3], const long grid_index, + const long D_diag[3]); +long gridsys_get_double_grid_index(const long address_double[3], + const long D_diag[3], const long PS[3]); +long gridsys_get_grid_index_from_address(const long address[3], + const long D_diag[3]); +long gridsys_rotate_grid_index(const long grid_index, const long rotation[3][3], + const long D_diag[3], const long PS[3]); +long gridsys_get_reciprocal_point_group(long rec_rotations[48][3][3], + const long (*rotations)[3][3], + const long num_rot, + const long is_time_reversal); +long gridsys_get_snf3x3(long D_diag[3], long P[3][3], long Q[3][3], + const long A[3][3]); +long gridsys_transform_rotations(long (*transformed_rots)[3][3], const long (*rotations)[3][3], - const long num_rot, - const long D_diag[3], - const long PS[3]); - long gridsys_get_bz_grid_addresses(long (*bz_grid_addresses)[3], - long *bz_map, - long *bzg2grg, - const long D_diag[3], - const long Q[3][3], - const long PS[3], - const double rec_lattice[3][3], - const long type); - long gridsys_get_triplets_at_q(long *map_triplets, - long *map_q, - const long grid_point, - const long D_diag[3], - const long is_time_reversal, - const long num_rot, - const long (*rec_rotations)[3][3], - const long swappable); - long gridsys_get_BZ_triplets_at_q(long (*triplets)[3], - const long grid_point, - const long (*bz_grid_addresses)[3], - const long *bz_map, - const long *map_triplets, - const long num_map_triplets, - const long D_diag[3], - const long Q[3][3], - const long bz_grid_type); - long gridsys_get_integration_weight(double *iw, - char *iw_zero, - const double *frequency_points, - const long num_band0, - const long relative_grid_address[24][4][3], - const long D_diag[3], - const long (*triplets)[3], - const long num_triplets, - const long (*bz_grid_addresses)[3], - const long *bz_map, - const long bz_grid_type, - const double *frequencies1, - const long num_band1, - const double *frequencies2, - const long num_band2, - const long tp_type, - const long openmp_per_triplets, - const long openmp_per_bands); - void gridsys_get_integration_weight_with_sigma(double *iw, - char *iw_zero, - const double sigma, - const double sigma_cutoff, - const double *frequency_points, - const long num_band0, - const long (*triplets)[3], - const long num_triplets, - const double *frequencies, - const long num_band, - const long tp_type); + const long num_rot, const long D_diag[3], + const long Q[3][3]); +double gridsys_get_thm_integration_weight(const double omega, + const double tetrahedra_omegas[24][4], + const char function); +void gridsys_get_thm_relative_grid_address( + long relative_grid_addresses[24][4][3], const double rec_lattice[3][3]); +void gridsys_get_ir_grid_map(long *ir_grid_map, const long (*rotations)[3][3], + const long num_rot, const long D_diag[3], + const long PS[3]); +long gridsys_get_bz_grid_addresses(long (*bz_grid_addresses)[3], long *bz_map, + long *bzg2grg, const long D_diag[3], + const long Q[3][3], const long PS[3], + const double rec_lattice[3][3], + const long type); +long gridsys_get_triplets_at_q(long *map_triplets, long *map_q, + const long grid_point, const long D_diag[3], + const long is_time_reversal, const long num_rot, + const long (*rec_rotations)[3][3], + const long swappable); +long gridsys_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point, + const long (*bz_grid_addresses)[3], + const long *bz_map, const long *map_triplets, + const long num_map_triplets, + const long D_diag[3], const long Q[3][3], + const long bz_grid_type); +long gridsys_get_integration_weight( + double *iw, char *iw_zero, const double *frequency_points, + const long num_band0, const long relative_grid_address[24][4][3], + const long D_diag[3], const long (*triplets)[3], const long num_triplets, + const long (*bz_grid_addresses)[3], const long *bz_map, + const long bz_grid_type, const double *frequencies1, const long num_band1, + const double *frequencies2, const long num_band2, const long tp_type, + const long openmp_per_triplets, const long openmp_per_bands); +void gridsys_get_integration_weight_with_sigma( + double *iw, char *iw_zero, const double sigma, const double sigma_cutoff, + const double *frequency_points, const long num_band0, + const long (*triplets)[3], const long num_triplets, + const double *frequencies, const long num_band, const long tp_type); #ifdef __cplusplus } diff --git a/c/imag_self_energy_with_g.c b/c/imag_self_energy_with_g.c index 1ff938d1..7da3888b 100644 --- a/c/imag_self_energy_with_g.c +++ b/c/imag_self_energy_with_g.c @@ -32,568 +32,411 @@ /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ +#include "imag_self_energy_with_g.h" + +#include #include #include -#include + #include "lagrid.h" #include "phonoc_array.h" #include "phonoc_utils.h" -#include "imag_self_energy_with_g.h" #include "triplet.h" static long ise_set_g_pos_frequency_point(long (*g_pos)[4], const long num_band0, const long num_band, const char *g_zero); -static void -detailed_imag_self_energy_at_triplet(double *detailed_imag_self_energy, - double *imag_self_energy, - const long num_band0, - const long num_band, - const double *fc3_normal_squared, - const double *frequencies, - const long triplet[3], - const double *g1, - const double *g2_3, - const char *g_zero, - const double *temperatures, - const long num_temps, - const double cutoff_frequency); -static double -collect_detailed_imag_self_energy(double *imag_self_energy, - const long num_band, - const double *fc3_normal_squared, - const double *n1, - const double *n2, - const double *g1, - const double *g2_3, - const char *g_zero); -static double -collect_detailed_imag_self_energy_0K(double *imag_self_energy, - const long num_band, - const double *fc3_normal_squared, - const double *n1, - const double *n2, - const double *g, - const char *g_zero); -static void set_occupations(double *n1, - double *n2, - const long num_band, - const double temperature, - const long triplet[3], +static void detailed_imag_self_energy_at_triplet( + double *detailed_imag_self_energy, double *imag_self_energy, + const long num_band0, const long num_band, const double *fc3_normal_squared, + const double *frequencies, const long triplet[3], const double *g1, + const double *g2_3, const char *g_zero, const double *temperatures, + const long num_temps, const double cutoff_frequency); +static double collect_detailed_imag_self_energy( + double *imag_self_energy, const long num_band, + const double *fc3_normal_squared, const double *n1, const double *n2, + const double *g1, const double *g2_3, const char *g_zero); +static double collect_detailed_imag_self_energy_0K( + double *imag_self_energy, const long num_band, + const double *fc3_normal_squared, const double *n1, const double *n2, + const double *g, const char *g_zero); +static void set_occupations(double *n1, double *n2, const long num_band, + const double temperature, const long triplet[3], const double *frequencies, const double cutoff_frequency); -void ise_get_imag_self_energy_at_bands_with_g(double *imag_self_energy, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double *g, - const char *g_zero, - const double temperature, - const double cutoff_frequency, - const long num_frequency_points, - const long frequency_point_index) -{ - long i, j, num_triplets, num_band0, num_band, num_band_prod; - long num_g_pos, g_index_dims, g_index_shift; - long(*g_pos)[4]; - double *ise; - long at_a_frequency_point; +void ise_get_imag_self_energy_at_bands_with_g( + double *imag_self_energy, const Darray *fc3_normal_squared, + const double *frequencies, const long (*triplets)[3], + const long *triplet_weights, const double *g, const char *g_zero, + const double temperature, const double cutoff_frequency, + const long num_frequency_points, const long frequency_point_index) { + long i, j, num_triplets, num_band0, num_band, num_band_prod; + long num_g_pos, g_index_dims, g_index_shift; + long(*g_pos)[4]; + double *ise; + long at_a_frequency_point; - g_pos = NULL; - ise = NULL; + g_pos = NULL; + ise = NULL; - num_triplets = fc3_normal_squared->dims[0]; - num_band0 = fc3_normal_squared->dims[1]; - num_band = fc3_normal_squared->dims[2]; - num_band_prod = num_band0 * num_band * num_band; - ise = (double *)malloc(sizeof(double) * num_triplets * num_band0); + num_triplets = fc3_normal_squared->dims[0]; + num_band0 = fc3_normal_squared->dims[1]; + num_band = fc3_normal_squared->dims[2]; + num_band_prod = num_band0 * num_band * num_band; + ise = (double *)malloc(sizeof(double) * num_triplets * num_band0); - if (frequency_point_index < 0) - { - /* frequency_points == frequencies at bands */ - at_a_frequency_point = 0; - g_index_dims = num_band_prod; - g_index_shift = 0; - } - else - { - /* At an arbitrary frequency point. */ - at_a_frequency_point = 1; - g_index_dims = num_frequency_points * num_band * num_band; - g_index_shift = frequency_point_index * num_band * num_band; - } + if (frequency_point_index < 0) { + /* frequency_points == frequencies at bands */ + at_a_frequency_point = 0; + g_index_dims = num_band_prod; + g_index_shift = 0; + } else { + /* At an arbitrary frequency point. */ + at_a_frequency_point = 1; + g_index_dims = num_frequency_points * num_band * num_band; + g_index_shift = frequency_point_index * num_band * num_band; + } #ifdef PHPYOPENMP #pragma omp parallel for private(num_g_pos, j, g_pos) #endif - for (i = 0; i < num_triplets; i++) - { - g_pos = (long(*)[4])malloc(sizeof(long[4]) * num_band_prod); - /* ise_set_g_pos only works for the case of frquency points at */ - /* bands. For frequency sampling mode, g_zero is assumed all */ - /* with the array shape of (num_triplets, num_band0, num_band, */ - /* num_band). */ - if (at_a_frequency_point) - { - num_g_pos = ise_set_g_pos_frequency_point( - g_pos, - num_band0, - num_band, - g_zero + i * g_index_dims + g_index_shift); - } - else - { - num_g_pos = ise_set_g_pos(g_pos, - num_band0, - num_band, - g_zero + i * num_band_prod); + for (i = 0; i < num_triplets; i++) { + g_pos = (long(*)[4])malloc(sizeof(long[4]) * num_band_prod); + /* ise_set_g_pos only works for the case of frquency points at */ + /* bands. For frequency sampling mode, g_zero is assumed all */ + /* with the array shape of (num_triplets, num_band0, num_band, */ + /* num_band). */ + if (at_a_frequency_point) { + num_g_pos = ise_set_g_pos_frequency_point( + g_pos, num_band0, num_band, + g_zero + i * g_index_dims + g_index_shift); + } else { + num_g_pos = ise_set_g_pos(g_pos, num_band0, num_band, + g_zero + i * num_band_prod); + } + + ise_imag_self_energy_at_triplet( + ise + i * num_band0, num_band0, num_band, + fc3_normal_squared->data + i * num_band_prod, frequencies, + triplets[i], triplet_weights[i], + g + i * g_index_dims + g_index_shift, + g + (i + num_triplets) * g_index_dims + g_index_shift, g_pos, + num_g_pos, &temperature, 1, cutoff_frequency, 0, + at_a_frequency_point); + + free(g_pos); + g_pos = NULL; } - ise_imag_self_energy_at_triplet( - ise + i * num_band0, - num_band0, - num_band, - fc3_normal_squared->data + i * num_band_prod, - frequencies, - triplets[i], - triplet_weights[i], - g + i * g_index_dims + g_index_shift, - g + (i + num_triplets) * g_index_dims + g_index_shift, - g_pos, - num_g_pos, - &temperature, - 1, - cutoff_frequency, - 0, - at_a_frequency_point); - - free(g_pos); - g_pos = NULL; - } - - for (i = 0; i < num_band0; i++) - { - imag_self_energy[i] = 0; - } - - for (i = 0; i < num_triplets; i++) - { - for (j = 0; j < num_band0; j++) - { - imag_self_energy[j] += ise[i * num_band0 + j]; + for (i = 0; i < num_band0; i++) { + imag_self_energy[i] = 0; } - } - free(ise); - ise = NULL; + for (i = 0; i < num_triplets; i++) { + for (j = 0; j < num_band0; j++) { + imag_self_energy[j] += ise[i * num_band0 + j]; + } + } + + free(ise); + ise = NULL; } -void ise_get_detailed_imag_self_energy_at_bands_with_g(double *detailed_imag_self_energy, - double *imag_self_energy_N, - double *imag_self_energy_U, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const long (*bz_grid_addresses)[3], - const double *g, - const char *g_zero, - const double temperature, - const double cutoff_frequency) -{ - double *ise; - long i, j, num_triplets, num_band0, num_band, num_band_prod; - long *is_N; - double ise_tmp, N, U; +void ise_get_detailed_imag_self_energy_at_bands_with_g( + double *detailed_imag_self_energy, double *imag_self_energy_N, + double *imag_self_energy_U, const Darray *fc3_normal_squared, + const double *frequencies, const long (*triplets)[3], + const long *triplet_weights, const long (*bz_grid_addresses)[3], + const double *g, const char *g_zero, const double temperature, + const double cutoff_frequency) { + double *ise; + long i, j, num_triplets, num_band0, num_band, num_band_prod; + long *is_N; + double ise_tmp, N, U; - ise = NULL; - is_N = NULL; + ise = NULL; + is_N = NULL; - num_triplets = fc3_normal_squared->dims[0]; - num_band0 = fc3_normal_squared->dims[1]; - num_band = fc3_normal_squared->dims[2]; - num_band_prod = num_band0 * num_band * num_band; - ise = (double *)malloc(sizeof(double) * num_triplets * num_band0); + num_triplets = fc3_normal_squared->dims[0]; + num_band0 = fc3_normal_squared->dims[1]; + num_band = fc3_normal_squared->dims[2]; + num_band_prod = num_band0 * num_band * num_band; + ise = (double *)malloc(sizeof(double) * num_triplets * num_band0); - /* detailed_imag_self_energy has the same shape as fc3_normal_squared. */ + /* detailed_imag_self_energy has the same shape as fc3_normal_squared. */ #ifdef PHPYOPENMP #pragma omp parallel for #endif - for (i = 0; i < num_triplets; i++) - { - detailed_imag_self_energy_at_triplet(detailed_imag_self_energy + i * num_band_prod, - ise + i * num_band0, - num_band0, - num_band, - fc3_normal_squared->data + i * num_band_prod, - frequencies, - triplets[i], - g + i * num_band_prod, - g + (i + num_triplets) * num_band_prod, - g_zero + i * num_band_prod, - &temperature, - 1, - cutoff_frequency); - } - - is_N = (long *)malloc(sizeof(long) * num_triplets); - for (i = 0; i < num_triplets; i++) - { - is_N[i] = tpl_is_N(triplets[i], bz_grid_addresses); - } - - for (i = 0; i < num_band0; i++) - { - N = 0; - U = 0; - /* #ifdef PHPYOPENMP */ - /* #pragma omp parallel for private(ise_tmp) reduction(+:N,U) */ - /* #endif */ - for (j = 0; j < num_triplets; j++) - { - ise_tmp = ise[j * num_band0 + i] * triplet_weights[j]; - if (is_N[j]) - { - N += ise_tmp; - } - else - { - U += ise_tmp; - } + for (i = 0; i < num_triplets; i++) { + detailed_imag_self_energy_at_triplet( + detailed_imag_self_energy + i * num_band_prod, ise + i * num_band0, + num_band0, num_band, fc3_normal_squared->data + i * num_band_prod, + frequencies, triplets[i], g + i * num_band_prod, + g + (i + num_triplets) * num_band_prod, g_zero + i * num_band_prod, + &temperature, 1, cutoff_frequency); } - imag_self_energy_N[i] = N; - imag_self_energy_U[i] = U; - } - free(is_N); - is_N = NULL; - free(ise); - ise = NULL; + is_N = (long *)malloc(sizeof(long) * num_triplets); + for (i = 0; i < num_triplets; i++) { + is_N[i] = tpl_is_N(triplets[i], bz_grid_addresses); + } + + for (i = 0; i < num_band0; i++) { + N = 0; + U = 0; + /* #ifdef PHPYOPENMP */ + /* #pragma omp parallel for private(ise_tmp) reduction(+:N,U) */ + /* #endif */ + for (j = 0; j < num_triplets; j++) { + ise_tmp = ise[j * num_band0 + i] * triplet_weights[j]; + if (is_N[j]) { + N += ise_tmp; + } else { + U += ise_tmp; + } + } + imag_self_energy_N[i] = N; + imag_self_energy_U[i] = U; + } + + free(is_N); + is_N = NULL; + free(ise); + ise = NULL; } -void ise_imag_self_energy_at_triplet(double *imag_self_energy, - const long num_band0, - const long num_band, - const double *fc3_normal_squared, - const double *frequencies, - const long triplet[3], - const long triplet_weight, - const double *g1, - const double *g2_3, - const long (*g_pos)[4], - const long num_g_pos, - const double *temperatures, - const long num_temps, - const double cutoff_frequency, - const long openmp_at_bands, - const long at_a_frequency_point) -{ - long i, j; - double *n1, *n2; - long g_pos_3; +void ise_imag_self_energy_at_triplet( + double *imag_self_energy, const long num_band0, const long num_band, + const double *fc3_normal_squared, const double *frequencies, + const long triplet[3], const long triplet_weight, const double *g1, + const double *g2_3, const long (*g_pos)[4], const long num_g_pos, + const double *temperatures, const long num_temps, + const double cutoff_frequency, const long openmp_at_bands, + const long at_a_frequency_point) { + long i, j; + double *n1, *n2; + long g_pos_3; - n1 = (double *)malloc(sizeof(double) * num_temps * num_band); - n2 = (double *)malloc(sizeof(double) * num_temps * num_band); - for (i = 0; i < num_temps; i++) - { - set_occupations(n1 + i * num_band, - n2 + i * num_band, - num_band, - temperatures[i], - triplet, - frequencies, - cutoff_frequency); - } - - for (i = 0; i < num_band0 * num_temps; i++) - { - imag_self_energy[i] = 0; - } - - /* Do not use OpenMP here!! */ - /* g_pos[i][0] takes value 0 <= x < num_band0 only, */ - /* which causes race condition. */ - for (i = 0; i < num_g_pos; i++) - { - if (at_a_frequency_point) - { - /* At an arbitrary frequency point */ - g_pos_3 = g_pos[i][3] % (num_band * num_band); + n1 = (double *)malloc(sizeof(double) * num_temps * num_band); + n2 = (double *)malloc(sizeof(double) * num_temps * num_band); + for (i = 0; i < num_temps; i++) { + set_occupations(n1 + i * num_band, n2 + i * num_band, num_band, + temperatures[i], triplet, frequencies, + cutoff_frequency); } - else - { - /* frequency_points == frequencies at bands */ - g_pos_3 = g_pos[i][3]; + + for (i = 0; i < num_band0 * num_temps; i++) { + imag_self_energy[i] = 0; } - for (j = 0; j < num_temps; j++) - { - if (n1[j * num_band + g_pos[i][1]] < 0 || - n2[j * num_band + g_pos[i][2]] < 0) - { - ; - } - else - { - if (temperatures[j] > 0) - { - imag_self_energy[j * num_band0 + g_pos[i][0]] += - ((n1[j * num_band + g_pos[i][1]] + - n2[j * num_band + g_pos[i][2]] + 1) * - g1[g_pos_3] + - (n1[j * num_band + g_pos[i][1]] - - n2[j * num_band + g_pos[i][2]]) * - g2_3[g_pos_3]) * - fc3_normal_squared[g_pos[i][3]] * triplet_weight; + + /* Do not use OpenMP here!! */ + /* g_pos[i][0] takes value 0 <= x < num_band0 only, */ + /* which causes race condition. */ + for (i = 0; i < num_g_pos; i++) { + if (at_a_frequency_point) { + /* At an arbitrary frequency point */ + g_pos_3 = g_pos[i][3] % (num_band * num_band); + } else { + /* frequency_points == frequencies at bands */ + g_pos_3 = g_pos[i][3]; } - else - { - imag_self_energy[j * num_band0 + g_pos[i][0]] += - g1[g_pos_3] * fc3_normal_squared[g_pos[i][3]] * triplet_weight; + for (j = 0; j < num_temps; j++) { + if (n1[j * num_band + g_pos[i][1]] < 0 || + n2[j * num_band + g_pos[i][2]] < 0) { + ; + } else { + if (temperatures[j] > 0) { + imag_self_energy[j * num_band0 + g_pos[i][0]] += + ((n1[j * num_band + g_pos[i][1]] + + n2[j * num_band + g_pos[i][2]] + 1) * + g1[g_pos_3] + + (n1[j * num_band + g_pos[i][1]] - + n2[j * num_band + g_pos[i][2]]) * + g2_3[g_pos_3]) * + fc3_normal_squared[g_pos[i][3]] * triplet_weight; + } else { + imag_self_energy[j * num_band0 + g_pos[i][0]] += + g1[g_pos_3] * fc3_normal_squared[g_pos[i][3]] * + triplet_weight; + } + } } - } } - } - free(n1); - n1 = NULL; - free(n2); - n2 = NULL; + free(n1); + n1 = NULL; + free(n2); + n2 = NULL; } -long ise_set_g_pos(long (*g_pos)[4], - const long num_band0, - const long num_band, - const char *g_zero) -{ - long num_g_pos, j, k, l, jkl; +long ise_set_g_pos(long (*g_pos)[4], const long num_band0, const long num_band, + const char *g_zero) { + long num_g_pos, j, k, l, jkl; - num_g_pos = 0; - jkl = 0; - for (j = 0; j < num_band0; j++) - { - for (k = 0; k < num_band; k++) - { - for (l = 0; l < num_band; l++) - { - if (!g_zero[jkl]) - { - g_pos[num_g_pos][0] = j; - g_pos[num_g_pos][1] = k; - g_pos[num_g_pos][2] = l; - g_pos[num_g_pos][3] = jkl; - num_g_pos++; + num_g_pos = 0; + jkl = 0; + for (j = 0; j < num_band0; j++) { + for (k = 0; k < num_band; k++) { + for (l = 0; l < num_band; l++) { + if (!g_zero[jkl]) { + g_pos[num_g_pos][0] = j; + g_pos[num_g_pos][1] = k; + g_pos[num_g_pos][2] = l; + g_pos[num_g_pos][3] = jkl; + num_g_pos++; + } + jkl++; + } } - jkl++; - } } - } - return num_g_pos; + return num_g_pos; } static long ise_set_g_pos_frequency_point(long (*g_pos)[4], const long num_band0, const long num_band, - const char *g_zero) -{ - long num_g_pos, j, k, l, kl, jkl; + const char *g_zero) { + long num_g_pos, j, k, l, kl, jkl; - num_g_pos = 0; - jkl = 0; - for (j = 0; j < num_band0; j++) - { - kl = 0; - for (k = 0; k < num_band; k++) - { - for (l = 0; l < num_band; l++) - { - if (!g_zero[kl]) - { - g_pos[num_g_pos][0] = j; - g_pos[num_g_pos][1] = k; - g_pos[num_g_pos][2] = l; - g_pos[num_g_pos][3] = jkl; - num_g_pos++; + num_g_pos = 0; + jkl = 0; + for (j = 0; j < num_band0; j++) { + kl = 0; + for (k = 0; k < num_band; k++) { + for (l = 0; l < num_band; l++) { + if (!g_zero[kl]) { + g_pos[num_g_pos][0] = j; + g_pos[num_g_pos][1] = k; + g_pos[num_g_pos][2] = l; + g_pos[num_g_pos][3] = jkl; + num_g_pos++; + } + jkl++; + kl++; + } } - jkl++; - kl++; - } } - } - return num_g_pos; + return num_g_pos; } -static void -detailed_imag_self_energy_at_triplet(double *detailed_imag_self_energy, - double *imag_self_energy, - const long num_band0, - const long num_band, - const double *fc3_normal_squared, - const double *frequencies, - const long triplet[3], - const double *g1, - const double *g2_3, - const char *g_zero, - const double *temperatures, - const long num_temps, - const double cutoff_frequency) -{ - long i, j, adrs_shift; - double *n1, *n2; +static void detailed_imag_self_energy_at_triplet( + double *detailed_imag_self_energy, double *imag_self_energy, + const long num_band0, const long num_band, const double *fc3_normal_squared, + const double *frequencies, const long triplet[3], const double *g1, + const double *g2_3, const char *g_zero, const double *temperatures, + const long num_temps, const double cutoff_frequency) { + long i, j, adrs_shift; + double *n1, *n2; - n1 = NULL; - n2 = NULL; + n1 = NULL; + n2 = NULL; - n1 = (double *)malloc(sizeof(double) * num_band); - n2 = (double *)malloc(sizeof(double) * num_band); + n1 = (double *)malloc(sizeof(double) * num_band); + n2 = (double *)malloc(sizeof(double) * num_band); - for (i = 0; i < num_temps; i++) - { - set_occupations(n1, - n2, - num_band, - temperatures[i], - triplet, - frequencies, - cutoff_frequency); + for (i = 0; i < num_temps; i++) { + set_occupations(n1, n2, num_band, temperatures[i], triplet, frequencies, + cutoff_frequency); - for (j = 0; j < num_band0; j++) - { - adrs_shift = j * num_band * num_band; - if (temperatures[i] > 0) - { - imag_self_energy[i * num_band0 + j] = - collect_detailed_imag_self_energy(detailed_imag_self_energy + adrs_shift, - num_band, - fc3_normal_squared + adrs_shift, - n1, - n2, - g1 + adrs_shift, - g2_3 + adrs_shift, - g_zero + adrs_shift); - } - else - { - imag_self_energy[i * num_band0 + j] = - collect_detailed_imag_self_energy_0K(detailed_imag_self_energy + adrs_shift, - num_band, - fc3_normal_squared + adrs_shift, - n1, - n2, - g1 + adrs_shift, - g_zero + adrs_shift); - } + for (j = 0; j < num_band0; j++) { + adrs_shift = j * num_band * num_band; + if (temperatures[i] > 0) { + imag_self_energy[i * num_band0 + j] = + collect_detailed_imag_self_energy( + detailed_imag_self_energy + adrs_shift, num_band, + fc3_normal_squared + adrs_shift, n1, n2, + g1 + adrs_shift, g2_3 + adrs_shift, + g_zero + adrs_shift); + } else { + imag_self_energy[i * num_band0 + j] = + collect_detailed_imag_self_energy_0K( + detailed_imag_self_energy + adrs_shift, num_band, + fc3_normal_squared + adrs_shift, n1, n2, + g1 + adrs_shift, g_zero + adrs_shift); + } + } } - } - free(n1); - n1 = NULL; - free(n2); - n2 = NULL; + free(n1); + n1 = NULL; + free(n2); + n2 = NULL; } -static double -collect_detailed_imag_self_energy(double *imag_self_energy, - const long num_band, - const double *fc3_normal_squared, - const double *n1, - const double *n2, - const double *g1, - const double *g2_3, - const char *g_zero) -{ - long ij, i, j; - double sum_g; +static double collect_detailed_imag_self_energy( + double *imag_self_energy, const long num_band, + const double *fc3_normal_squared, const double *n1, const double *n2, + const double *g1, const double *g2_3, const char *g_zero) { + long ij, i, j; + double sum_g; - sum_g = 0; - for (ij = 0; ij < num_band * num_band; ij++) - { - imag_self_energy[ij] = 0; - if (g_zero[ij]) - { - continue; + sum_g = 0; + for (ij = 0; ij < num_band * num_band; ij++) { + imag_self_energy[ij] = 0; + if (g_zero[ij]) { + continue; + } + i = ij / num_band; + j = ij % num_band; + if (n1[i] < 0 || n2[j] < 0) { + continue; + } + imag_self_energy[ij] = + (((n1[i] + n2[j] + 1) * g1[ij] + (n1[i] - n2[j]) * g2_3[ij]) * + fc3_normal_squared[ij]); + sum_g += imag_self_energy[ij]; } - i = ij / num_band; - j = ij % num_band; - if (n1[i] < 0 || n2[j] < 0) - { - continue; - } - imag_self_energy[ij] = (((n1[i] + n2[j] + 1) * g1[ij] + - (n1[i] - n2[j]) * g2_3[ij]) * - fc3_normal_squared[ij]); - sum_g += imag_self_energy[ij]; - } - return sum_g; + return sum_g; } -static double -collect_detailed_imag_self_energy_0K(double *imag_self_energy, - const long num_band, - const double *fc3_normal_squared, - const double *n1, - const double *n2, - const double *g1, - const char *g_zero) -{ - long ij, i, j; - double sum_g; +static double collect_detailed_imag_self_energy_0K( + double *imag_self_energy, const long num_band, + const double *fc3_normal_squared, const double *n1, const double *n2, + const double *g1, const char *g_zero) { + long ij, i, j; + double sum_g; - sum_g = 0; - for (ij = 0; ij < num_band * num_band; ij++) - { - imag_self_energy[ij] = 0; - if (g_zero[ij]) - { - continue; + sum_g = 0; + for (ij = 0; ij < num_band * num_band; ij++) { + imag_self_energy[ij] = 0; + if (g_zero[ij]) { + continue; + } + i = ij / num_band; + j = ij % num_band; + if (n1[i] < 0 || n2[j] < 0) { + continue; + } + imag_self_energy[ij] = g1[ij] * fc3_normal_squared[ij]; + sum_g += imag_self_energy[ij]; } - i = ij / num_band; - j = ij % num_band; - if (n1[i] < 0 || n2[j] < 0) - { - continue; - } - imag_self_energy[ij] = g1[ij] * fc3_normal_squared[ij]; - sum_g += imag_self_energy[ij]; - } - return sum_g; + return sum_g; } -static void set_occupations(double *n1, - double *n2, - const long num_band, - const double temperature, - const long triplet[3], +static void set_occupations(double *n1, double *n2, const long num_band, + const double temperature, const long triplet[3], const double *frequencies, - const double cutoff_frequency) -{ - long j; - double f1, f2; + const double cutoff_frequency) { + long j; + double f1, f2; - for (j = 0; j < num_band; j++) - { - f1 = frequencies[triplet[1] * num_band + j]; - f2 = frequencies[triplet[2] * num_band + j]; - if (f1 > cutoff_frequency) - { - n1[j] = phonoc_bose_einstein(f1, temperature); + for (j = 0; j < num_band; j++) { + f1 = frequencies[triplet[1] * num_band + j]; + f2 = frequencies[triplet[2] * num_band + j]; + if (f1 > cutoff_frequency) { + n1[j] = phonoc_bose_einstein(f1, temperature); + } else { + n1[j] = -1; + } + if (f2 > cutoff_frequency) { + n2[j] = phonoc_bose_einstein(f2, temperature); + } else { + n2[j] = -1; + } } - else - { - n1[j] = -1; - } - if (f2 > cutoff_frequency) - { - n2[j] = phonoc_bose_einstein(f2, temperature); - } - else - { - n2[j] = -1; - } - } } diff --git a/c/imag_self_energy_with_g.h b/c/imag_self_energy_with_g.h index 57e6a480..b9ab1794 100644 --- a/c/imag_self_energy_with_g.h +++ b/c/imag_self_energy_with_g.h @@ -36,50 +36,31 @@ #define __imag_self_energy_with_g_H__ #include + #include "phonoc_array.h" -void ise_get_imag_self_energy_at_bands_with_g(double *imag_self_energy, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double *g, - const char *g_zero, - const double temperature, - const double cutoff_frequency, - const long num_frequency_points, - const long frequency_point_index); -void ise_get_detailed_imag_self_energy_at_bands_with_g(double *detailed_imag_self_energy, - double *imag_self_energy_N, - double *imag_self_energy_U, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const long (*bz_grid_addresses)[3], - const double *g, - const char *g_zero, - const double temperature, - const double cutoff_frequency); -void ise_imag_self_energy_at_triplet(double *imag_self_energy, - const long num_band0, - const long num_band, - const double *fc3_normal_squared, - const double *frequencies, - const long triplet[3], - const long triplet_weight, - const double *g1, - const double *g2_3, - const long (*g_pos)[4], - const long num_g_pos, - const double *temperatures, - const long num_temps, - const double cutoff_frequency, - const long openmp_at_bands, - const long at_a_frequency_point); -long ise_set_g_pos(long (*g_pos)[4], - const long num_band0, - const long num_band, +void ise_get_imag_self_energy_at_bands_with_g( + double *imag_self_energy, const Darray *fc3_normal_squared, + const double *frequencies, const long (*triplets)[3], + const long *triplet_weights, const double *g, const char *g_zero, + const double temperature, const double cutoff_frequency, + const long num_frequency_points, const long frequency_point_index); +void ise_get_detailed_imag_self_energy_at_bands_with_g( + double *detailed_imag_self_energy, double *imag_self_energy_N, + double *imag_self_energy_U, const Darray *fc3_normal_squared, + const double *frequencies, const long (*triplets)[3], + const long *triplet_weights, const long (*bz_grid_addresses)[3], + const double *g, const char *g_zero, const double temperature, + const double cutoff_frequency); +void ise_imag_self_energy_at_triplet( + double *imag_self_energy, const long num_band0, const long num_band, + const double *fc3_normal_squared, const double *frequencies, + const long triplet[3], const long triplet_weight, const double *g1, + const double *g2_3, const long (*g_pos)[4], const long num_g_pos, + const double *temperatures, const long num_temps, + const double cutoff_frequency, const long openmp_at_bands, + const long at_a_frequency_point); +long ise_set_g_pos(long (*g_pos)[4], const long num_band0, const long num_band, const char *g_zero); #endif diff --git a/c/interaction.c b/c/interaction.c index 9a9ab813..57a3443c 100644 --- a/c/interaction.c +++ b/c/interaction.c @@ -32,418 +32,250 @@ /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ +#include "interaction.h" + #include #include + #include "bzgrid.h" -#include "interaction.h" #include "imag_self_energy_with_g.h" +#include "lapack_wrapper.h" #include "phonoc_array.h" #include "real_to_reciprocal.h" #include "reciprocal_to_normal.h" -#include "lapack_wrapper.h" -static const long index_exchange[6][3] = {{0, 1, 2}, - {2, 0, 1}, - {1, 2, 0}, - {2, 1, 0}, - {0, 2, 1}, - {1, 0, 2}}; -static void real_to_normal(double *fc3_normal_squared, - const long (*g_pos)[4], - const long num_g_pos, - const double *freqs0, - const double *freqs1, - const double *freqs2, - const lapack_complex_double *eigvecs0, - const lapack_complex_double *eigvecs1, - const lapack_complex_double *eigvecs2, - const double *fc3, - const long is_compact_fc3, - const double q_vecs[3][3], /* q0, q1, q2 */ - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const long *band_indices, - const long num_band, - const double cutoff_frequency, - const long triplet_index, - const long num_triplets, - const long openmp_at_bands); -static void real_to_normal_sym_q(double *fc3_normal_squared, - const long (*g_pos)[4], - const long num_g_pos, - double *const freqs[3], - lapack_complex_double *const eigvecs[3], - const double *fc3, - const long is_compact_fc3, - const double q_vecs[3][3], /* q0, q1, q2 */ - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const long *band_indices, - const long num_band0, - const long num_band, - const double cutoff_frequency, - const long triplet_index, - const long num_triplets, - const long openmp_at_bands); +static const long index_exchange[6][3] = {{0, 1, 2}, {2, 0, 1}, {1, 2, 0}, + {2, 1, 0}, {0, 2, 1}, {1, 0, 2}}; +static void real_to_normal( + double *fc3_normal_squared, const long (*g_pos)[4], const long num_g_pos, + const double *freqs0, const double *freqs1, const double *freqs2, + const lapack_complex_double *eigvecs0, + const lapack_complex_double *eigvecs1, + const lapack_complex_double *eigvecs2, const double *fc3, + const long is_compact_fc3, const double q_vecs[3][3], /* q0, q1, q2 */ + const double (*svecs)[3], const long multi_dims[2], + const long (*multiplicity)[2], const double *masses, const long *p2s_map, + const long *s2p_map, const long *band_indices, const long num_band, + const double cutoff_frequency, const long triplet_index, + const long num_triplets, const long openmp_at_bands); +static void real_to_normal_sym_q( + double *fc3_normal_squared, const long (*g_pos)[4], const long num_g_pos, + double *const freqs[3], lapack_complex_double *const eigvecs[3], + const double *fc3, const long is_compact_fc3, + const double q_vecs[3][3], /* q0, q1, q2 */ + const double (*svecs)[3], const long multi_dims[2], + const long (*multiplicity)[2], const double *masses, const long *p2s_map, + const long *s2p_map, const long *band_indices, const long num_band0, + const long num_band, const double cutoff_frequency, + const long triplet_index, const long num_triplets, + const long openmp_at_bands); /* fc3_normal_squared[num_triplets, num_band0, num_band, num_band] */ -void itr_get_interaction(Darray *fc3_normal_squared, - const char *g_zero, +void itr_get_interaction(Darray *fc3_normal_squared, const char *g_zero, const Darray *frequencies, const lapack_complex_double *eigenvectors, - const long (*triplets)[3], - const long num_triplets, - const ConstBZGrid *bzgrid, - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], + const long (*triplets)[3], const long num_triplets, + const ConstBZGrid *bzgrid, const double *fc3, + const long is_compact_fc3, const double (*svecs)[3], const long multi_dims[2], - const long (*multiplicity)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const long *band_indices, - const long symmetrize_fc3_q, - const double cutoff_frequency) -{ - long openmp_per_triplets; - long(*g_pos)[4]; - long i; - long num_band, num_band0, num_band_prod, num_g_pos; + const long (*multiplicity)[2], const double *masses, + const long *p2s_map, const long *s2p_map, + const long *band_indices, const long symmetrize_fc3_q, + const double cutoff_frequency) { + long openmp_per_triplets; + long(*g_pos)[4]; + long i; + long num_band, num_band0, num_band_prod, num_g_pos; - g_pos = NULL; + g_pos = NULL; - num_band0 = fc3_normal_squared->dims[1]; - num_band = frequencies->dims[1]; - num_band_prod = num_band0 * num_band * num_band; + num_band0 = fc3_normal_squared->dims[1]; + num_band = frequencies->dims[1]; + num_band_prod = num_band0 * num_band * num_band; - if (num_triplets > num_band) - { - openmp_per_triplets = 1; - } - else - { - openmp_per_triplets = 0; - } + if (num_triplets > num_band) { + openmp_per_triplets = 1; + } else { + openmp_per_triplets = 0; + } #ifdef PHPYOPENMP -#pragma omp parallel for schedule(guided) private(num_g_pos, g_pos) if (openmp_per_triplets) +#pragma omp parallel for schedule(guided) private( \ + num_g_pos, g_pos) if (openmp_per_triplets) #endif - for (i = 0; i < num_triplets; i++) - { - g_pos = (long(*)[4])malloc(sizeof(long[4]) * num_band_prod); - num_g_pos = ise_set_g_pos(g_pos, - num_band0, - num_band, - g_zero + i * num_band_prod); + for (i = 0; i < num_triplets; i++) { + g_pos = (long(*)[4])malloc(sizeof(long[4]) * num_band_prod); + num_g_pos = ise_set_g_pos(g_pos, num_band0, num_band, + g_zero + i * num_band_prod); - itr_get_interaction_at_triplet( - fc3_normal_squared->data + i * num_band_prod, - num_band0, - num_band, - g_pos, - num_g_pos, - frequencies->data, - eigenvectors, - triplets[i], - bzgrid, - fc3, - is_compact_fc3, - svecs, - multi_dims, - multiplicity, - masses, - p2s_map, - s2p_map, - band_indices, - symmetrize_fc3_q, - cutoff_frequency, - i, - num_triplets, - 1 - openmp_per_triplets); + itr_get_interaction_at_triplet( + fc3_normal_squared->data + i * num_band_prod, num_band0, num_band, + g_pos, num_g_pos, frequencies->data, eigenvectors, triplets[i], + bzgrid, fc3, is_compact_fc3, svecs, multi_dims, multiplicity, + masses, p2s_map, s2p_map, band_indices, symmetrize_fc3_q, + cutoff_frequency, i, num_triplets, 1 - openmp_per_triplets); - free(g_pos); - g_pos = NULL; - } + free(g_pos); + g_pos = NULL; + } } -void itr_get_interaction_at_triplet(double *fc3_normal_squared, - const long num_band0, - const long num_band, - const long (*g_pos)[4], - const long num_g_pos, - const double *frequencies, - const lapack_complex_double *eigenvectors, - const long triplet[3], - const ConstBZGrid *bzgrid, - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const long *band_indices, - const long symmetrize_fc3_q, - const double cutoff_frequency, - const long triplet_index, /* only for print */ - const long num_triplets, /* only for print */ - const long openmp_at_bands) -{ - long j, k; - double *freqs[3]; - lapack_complex_double *eigvecs[3]; - double q_vecs[3][3]; +void itr_get_interaction_at_triplet( + double *fc3_normal_squared, const long num_band0, const long num_band, + const long (*g_pos)[4], const long num_g_pos, const double *frequencies, + const lapack_complex_double *eigenvectors, const long triplet[3], + const ConstBZGrid *bzgrid, const double *fc3, const long is_compact_fc3, + const double (*svecs)[3], const long multi_dims[2], + const long (*multiplicity)[2], const double *masses, const long *p2s_map, + const long *s2p_map, const long *band_indices, const long symmetrize_fc3_q, + const double cutoff_frequency, + const long triplet_index, /* only for print */ + const long num_triplets, /* only for print */ + const long openmp_at_bands) { + long j, k; + double *freqs[3]; + lapack_complex_double *eigvecs[3]; + double q_vecs[3][3]; - for (j = 0; j < 3; j++) - { - for (k = 0; k < 3; k++) - { - q_vecs[j][k] = ((double)bzgrid->addresses[triplet[j]][k]) / bzgrid->D_diag[k]; + for (j = 0; j < 3; j++) { + for (k = 0; k < 3; k++) { + q_vecs[j][k] = + ((double)bzgrid->addresses[triplet[j]][k]) / bzgrid->D_diag[k]; + } + bzg_multiply_matrix_vector_ld3(q_vecs[j], bzgrid->Q, q_vecs[j]); } - bzg_multiply_matrix_vector_ld3(q_vecs[j], bzgrid->Q, q_vecs[j]); - } - if (symmetrize_fc3_q) - { - for (j = 0; j < 3; j++) - { - freqs[j] = (double *)malloc(sizeof(double) * num_band); - eigvecs[j] = (lapack_complex_double *) - malloc(sizeof(lapack_complex_double) * num_band * num_band); - for (k = 0; k < num_band; k++) - { - freqs[j][k] = frequencies[triplet[j] * num_band + k]; - } - for (k = 0; k < num_band * num_band; k++) - { - eigvecs[j][k] = eigenvectors[triplet[j] * num_band * num_band + k]; - } + if (symmetrize_fc3_q) { + for (j = 0; j < 3; j++) { + freqs[j] = (double *)malloc(sizeof(double) * num_band); + eigvecs[j] = (lapack_complex_double *)malloc( + sizeof(lapack_complex_double) * num_band * num_band); + for (k = 0; k < num_band; k++) { + freqs[j][k] = frequencies[triplet[j] * num_band + k]; + } + for (k = 0; k < num_band * num_band; k++) { + eigvecs[j][k] = + eigenvectors[triplet[j] * num_band * num_band + k]; + } + } + real_to_normal_sym_q( + fc3_normal_squared, g_pos, num_g_pos, freqs, eigvecs, fc3, + is_compact_fc3, q_vecs, /* q0, q1, q2 */ + svecs, multi_dims, multiplicity, masses, p2s_map, s2p_map, + band_indices, num_band0, num_band, cutoff_frequency, triplet_index, + num_triplets, openmp_at_bands); + for (j = 0; j < 3; j++) { + free(freqs[j]); + freqs[j] = NULL; + free(eigvecs[j]); + eigvecs[j] = NULL; + } + } else { + real_to_normal(fc3_normal_squared, g_pos, num_g_pos, + frequencies + triplet[0] * num_band, + frequencies + triplet[1] * num_band, + frequencies + triplet[2] * num_band, + eigenvectors + triplet[0] * num_band * num_band, + eigenvectors + triplet[1] * num_band * num_band, + eigenvectors + triplet[2] * num_band * num_band, fc3, + is_compact_fc3, q_vecs, /* q0, q1, q2 */ + svecs, multi_dims, multiplicity, masses, p2s_map, + s2p_map, band_indices, num_band, cutoff_frequency, + triplet_index, num_triplets, openmp_at_bands); } - real_to_normal_sym_q(fc3_normal_squared, - g_pos, - num_g_pos, - freqs, - eigvecs, - fc3, - is_compact_fc3, - q_vecs, /* q0, q1, q2 */ - svecs, - multi_dims, - multiplicity, - masses, - p2s_map, - s2p_map, - band_indices, - num_band0, - num_band, - cutoff_frequency, - triplet_index, - num_triplets, - openmp_at_bands); - for (j = 0; j < 3; j++) - { - free(freqs[j]); - freqs[j] = NULL; - free(eigvecs[j]); - eigvecs[j] = NULL; - } - } - else - { - real_to_normal(fc3_normal_squared, - g_pos, - num_g_pos, - frequencies + triplet[0] * num_band, - frequencies + triplet[1] * num_band, - frequencies + triplet[2] * num_band, - eigenvectors + triplet[0] * num_band * num_band, - eigenvectors + triplet[1] * num_band * num_band, - eigenvectors + triplet[2] * num_band * num_band, - fc3, - is_compact_fc3, - q_vecs, /* q0, q1, q2 */ - svecs, - multi_dims, - multiplicity, - masses, - p2s_map, - s2p_map, - band_indices, - num_band, - cutoff_frequency, - triplet_index, - num_triplets, - openmp_at_bands); - } } -static void real_to_normal(double *fc3_normal_squared, - const long (*g_pos)[4], - const long num_g_pos, - const double *freqs0, - const double *freqs1, - const double *freqs2, - const lapack_complex_double *eigvecs0, - const lapack_complex_double *eigvecs1, - const lapack_complex_double *eigvecs2, - const double *fc3, - const long is_compact_fc3, - const double q_vecs[3][3], /* q0, q1, q2 */ - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const long *band_indices, - const long num_band, - const double cutoff_frequency, - const long triplet_index, - const long num_triplets, - const long openmp_at_bands) -{ - lapack_complex_double *fc3_reciprocal; +static void real_to_normal( + double *fc3_normal_squared, const long (*g_pos)[4], const long num_g_pos, + const double *freqs0, const double *freqs1, const double *freqs2, + const lapack_complex_double *eigvecs0, + const lapack_complex_double *eigvecs1, + const lapack_complex_double *eigvecs2, const double *fc3, + const long is_compact_fc3, const double q_vecs[3][3], /* q0, q1, q2 */ + const double (*svecs)[3], const long multi_dims[2], + const long (*multiplicity)[2], const double *masses, const long *p2s_map, + const long *s2p_map, const long *band_indices, const long num_band, + const double cutoff_frequency, const long triplet_index, + const long num_triplets, const long openmp_at_bands) { + lapack_complex_double *fc3_reciprocal; - fc3_reciprocal = - (lapack_complex_double *)malloc(sizeof(lapack_complex_double) * - num_band * num_band * num_band); - r2r_real_to_reciprocal(fc3_reciprocal, - q_vecs, - fc3, - is_compact_fc3, - svecs, - multi_dims, - multiplicity, - p2s_map, - s2p_map, - openmp_at_bands); + fc3_reciprocal = (lapack_complex_double *)malloc( + sizeof(lapack_complex_double) * num_band * num_band * num_band); + r2r_real_to_reciprocal(fc3_reciprocal, q_vecs, fc3, is_compact_fc3, svecs, + multi_dims, multiplicity, p2s_map, s2p_map, + openmp_at_bands); #ifdef MEASURE_R2N - if (openmp_at_bands && num_triplets > 0) - { - printf("At triplet %d/%d (# of bands=%d):\n", - triplet_index, num_triplets, num_band0); - } + if (openmp_at_bands && num_triplets > 0) { + printf("At triplet %d/%d (# of bands=%d):\n", triplet_index, + num_triplets, num_band0); + } #endif - reciprocal_to_normal_squared(fc3_normal_squared, - g_pos, - num_g_pos, - fc3_reciprocal, - freqs0, - freqs1, - freqs2, - eigvecs0, - eigvecs1, - eigvecs2, - masses, - band_indices, - num_band, - cutoff_frequency, - openmp_at_bands); + reciprocal_to_normal_squared( + fc3_normal_squared, g_pos, num_g_pos, fc3_reciprocal, freqs0, freqs1, + freqs2, eigvecs0, eigvecs1, eigvecs2, masses, band_indices, num_band, + cutoff_frequency, openmp_at_bands); - free(fc3_reciprocal); - fc3_reciprocal = NULL; + free(fc3_reciprocal); + fc3_reciprocal = NULL; } -static void real_to_normal_sym_q(double *fc3_normal_squared, - const long (*g_pos)[4], - const long num_g_pos, - double *const freqs[3], - lapack_complex_double *const eigvecs[3], - const double *fc3, - const long is_compact_fc3, - const double q_vecs[3][3], /* q0, q1, q2 */ - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const long *band_indices, - const long num_band0, - const long num_band, - const double cutoff_frequency, - const long triplet_index, - const long num_triplets, - const long openmp_at_bands) -{ - long i, j, k, l; - long band_ex[3]; - double q_vecs_ex[3][3]; - double *fc3_normal_squared_ex; +static void real_to_normal_sym_q( + double *fc3_normal_squared, const long (*g_pos)[4], const long num_g_pos, + double *const freqs[3], lapack_complex_double *const eigvecs[3], + const double *fc3, const long is_compact_fc3, + const double q_vecs[3][3], /* q0, q1, q2 */ + const double (*svecs)[3], const long multi_dims[2], + const long (*multiplicity)[2], const double *masses, const long *p2s_map, + const long *s2p_map, const long *band_indices, const long num_band0, + const long num_band, const double cutoff_frequency, + const long triplet_index, const long num_triplets, + const long openmp_at_bands) { + long i, j, k, l; + long band_ex[3]; + double q_vecs_ex[3][3]; + double *fc3_normal_squared_ex; - fc3_normal_squared_ex = - (double *)malloc(sizeof(double) * num_band * num_band * num_band); + fc3_normal_squared_ex = + (double *)malloc(sizeof(double) * num_band * num_band * num_band); - for (i = 0; i < num_band0 * num_band * num_band; i++) - { - fc3_normal_squared[i] = 0; - } - - for (i = 0; i < 6; i++) - { - for (j = 0; j < 3; j++) - { - for (k = 0; k < 3; k++) - { - q_vecs_ex[j][k] = q_vecs[index_exchange[i][j]][k]; - } + for (i = 0; i < num_band0 * num_band * num_band; i++) { + fc3_normal_squared[i] = 0; } - real_to_normal(fc3_normal_squared_ex, - g_pos, - num_g_pos, - freqs[index_exchange[i][0]], - freqs[index_exchange[i][1]], - freqs[index_exchange[i][2]], - eigvecs[index_exchange[i][0]], - eigvecs[index_exchange[i][1]], - eigvecs[index_exchange[i][2]], - fc3, - is_compact_fc3, - q_vecs_ex, /* q0, q1, q2 */ - svecs, - multi_dims, - multiplicity, - masses, - p2s_map, - s2p_map, - band_indices, - num_band, - cutoff_frequency, - triplet_index, - num_triplets, - openmp_at_bands); - for (j = 0; j < num_band0; j++) - { - for (k = 0; k < num_band; k++) - { - for (l = 0; l < num_band; l++) - { - band_ex[0] = band_indices[j]; - band_ex[1] = k; - band_ex[2] = l; - fc3_normal_squared[j * num_band * num_band + - k * num_band + - l] += - fc3_normal_squared_ex[band_ex[index_exchange[i][0]] * - num_band * num_band + - band_ex[index_exchange[i][1]] * num_band + - band_ex[index_exchange[i][2]]] / - 6; + + for (i = 0; i < 6; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 3; k++) { + q_vecs_ex[j][k] = q_vecs[index_exchange[i][j]][k]; + } + } + real_to_normal( + fc3_normal_squared_ex, g_pos, num_g_pos, + freqs[index_exchange[i][0]], freqs[index_exchange[i][1]], + freqs[index_exchange[i][2]], eigvecs[index_exchange[i][0]], + eigvecs[index_exchange[i][1]], eigvecs[index_exchange[i][2]], fc3, + is_compact_fc3, q_vecs_ex, /* q0, q1, q2 */ + svecs, multi_dims, multiplicity, masses, p2s_map, s2p_map, + band_indices, num_band, cutoff_frequency, triplet_index, + num_triplets, openmp_at_bands); + for (j = 0; j < num_band0; j++) { + for (k = 0; k < num_band; k++) { + for (l = 0; l < num_band; l++) { + band_ex[0] = band_indices[j]; + band_ex[1] = k; + band_ex[2] = l; + fc3_normal_squared[j * num_band * num_band + k * num_band + + l] += + fc3_normal_squared_ex[band_ex[index_exchange[i][0]] * + num_band * num_band + + band_ex[index_exchange[i][1]] * + num_band + + band_ex[index_exchange[i][2]]] / + 6; + } + } } - } } - } - free(fc3_normal_squared_ex); + free(fc3_normal_squared_ex); } diff --git a/c/interaction.h b/c/interaction.h index cd3b3699..bdc47e3c 100644 --- a/c/interaction.h +++ b/c/interaction.h @@ -39,46 +39,28 @@ #include "lapack_wrapper.h" #include "phonoc_array.h" -void itr_get_interaction(Darray *fc3_normal_squared, - const char *g_zero, +void itr_get_interaction(Darray *fc3_normal_squared, const char *g_zero, const Darray *frequencies, const lapack_complex_double *eigenvectors, - const long (*triplets)[3], - const long num_triplets, - const ConstBZGrid *bzgrid, - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], + const long (*triplets)[3], const long num_triplets, + const ConstBZGrid *bzgrid, const double *fc3, + const long is_compact_fc3, const double (*svecs)[3], const long multi_dims[2], - const long (*multiplicity)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const long *band_indices, - const long symmetrize_fc3_q, + const long (*multiplicity)[2], const double *masses, + const long *p2s_map, const long *s2p_map, + const long *band_indices, const long symmetrize_fc3_q, const double cutoff_frequency); -void itr_get_interaction_at_triplet(double *fc3_normal_squared, - const long num_band0, - const long num_band, - const long (*g_pos)[4], - const long num_g_pos, - const double *frequencies, - const lapack_complex_double *eigenvectors, - const long triplet[3], - const ConstBZGrid *bzgrid, - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const long *band_indices, - const long symmetrize_fc3_q, - const double cutoff_frequency, - const long triplet_index, /* only for print */ - const long num_triplets, /* only for print */ - const long openmp_at_bands); +void itr_get_interaction_at_triplet( + double *fc3_normal_squared, const long num_band0, const long num_band, + const long (*g_pos)[4], const long num_g_pos, const double *frequencies, + const lapack_complex_double *eigenvectors, const long triplet[3], + const ConstBZGrid *bzgrid, const double *fc3, const long is_compact_fc3, + const double (*svecs)[3], const long multi_dims[2], + const long (*multiplicity)[2], const double *masses, const long *p2s_map, + const long *s2p_map, const long *band_indices, const long symmetrize_fc3_q, + const double cutoff_frequency, + const long triplet_index, /* only for print */ + const long num_triplets, /* only for print */ + const long openmp_at_bands); #endif diff --git a/c/isotope.c b/c/isotope.c index 38784673..c32f3c59 100644 --- a/c/isotope.c +++ b/c/isotope.c @@ -32,224 +32,196 @@ /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ +#include "isotope.h" + #include + +#include "lapack_wrapper.h" #include "phonoc_const.h" #include "phonoc_utils.h" -#include "isotope.h" -#include "lapack_wrapper.h" -void iso_get_isotope_scattering_strength(double *gamma, - const long grid_point, - const double *mass_variances, - const double *frequencies, - const lapack_complex_double *eigenvectors, - const long num_grid_points, - const long *band_indices, - const long num_band, - const long num_band0, - const double sigma, - const double cutoff_frequency) -{ - long i, j, k, l, m; - double *e0_r, *e0_i, e1_r, e1_i, a, b, f, *f0, dist, sum_g, sum_g_k; +void iso_get_isotope_scattering_strength( + double *gamma, const long grid_point, const double *mass_variances, + const double *frequencies, const lapack_complex_double *eigenvectors, + const long num_grid_points, const long *band_indices, const long num_band, + const long num_band0, const double sigma, const double cutoff_frequency) { + long i, j, k, l, m; + double *e0_r, *e0_i, e1_r, e1_i, a, b, f, *f0, dist, sum_g, sum_g_k; - e0_r = (double *)malloc(sizeof(double) * num_band * num_band0); - e0_i = (double *)malloc(sizeof(double) * num_band * num_band0); - f0 = (double *)malloc(sizeof(double) * num_band0); + e0_r = (double *)malloc(sizeof(double) * num_band * num_band0); + e0_i = (double *)malloc(sizeof(double) * num_band * num_band0); + f0 = (double *)malloc(sizeof(double) * num_band0); - for (i = 0; i < num_band0; i++) - { - f0[i] = frequencies[grid_point * num_band + band_indices[i]]; - for (j = 0; j < num_band; j++) - { - e0_r[i * num_band + j] = lapack_complex_double_real(eigenvectors[grid_point * num_band * num_band + - j * num_band + band_indices[i]]); - e0_i[i * num_band + j] = lapack_complex_double_imag(eigenvectors[grid_point * num_band * num_band + - j * num_band + band_indices[i]]); + for (i = 0; i < num_band0; i++) { + f0[i] = frequencies[grid_point * num_band + band_indices[i]]; + for (j = 0; j < num_band; j++) { + e0_r[i * num_band + j] = lapack_complex_double_real( + eigenvectors[grid_point * num_band * num_band + j * num_band + + band_indices[i]]); + e0_i[i * num_band + j] = lapack_complex_double_imag( + eigenvectors[grid_point * num_band * num_band + j * num_band + + band_indices[i]]); + } } - } - for (i = 0; i < num_band0; i++) - { - gamma[i] = 0; - } - - for (i = 0; i < num_band0; i++) - { /* band index0 */ - if (f0[i] < cutoff_frequency) - { - continue; + for (i = 0; i < num_band0; i++) { + gamma[i] = 0; } - sum_g = 0; + + for (i = 0; i < num_band0; i++) { /* band index0 */ + if (f0[i] < cutoff_frequency) { + continue; + } + sum_g = 0; #ifdef PHPYOPENMP #pragma omp parallel for private(k, l, m, f, e1_r, e1_i, a, b, dist, sum_g_k) reduction(+ \ : sum_g) #endif - for (j = 0; j < num_grid_points; j++) - { - sum_g_k = 0; - for (k = 0; k < num_band; k++) - { /* band index */ - f = frequencies[j * num_band + k]; - if (f < cutoff_frequency) - { - continue; + for (j = 0; j < num_grid_points; j++) { + sum_g_k = 0; + for (k = 0; k < num_band; k++) { /* band index */ + f = frequencies[j * num_band + k]; + if (f < cutoff_frequency) { + continue; + } + dist = phonoc_gaussian(f - f0[i], sigma); + for (l = 0; l < num_band / 3; l++) { /* elements */ + a = 0; + b = 0; + for (m = 0; m < 3; m++) { + e1_r = lapack_complex_double_real( + eigenvectors[j * num_band * num_band + + (l * 3 + m) * num_band + k]); + e1_i = lapack_complex_double_imag( + eigenvectors[j * num_band * num_band + + (l * 3 + m) * num_band + k]); + a += (e0_r[i * num_band + l * 3 + m] * e1_r + + e0_i[i * num_band + l * 3 + m] * e1_i); + b += (e0_i[i * num_band + l * 3 + m] * e1_r - + e0_r[i * num_band + l * 3 + m] * e1_i); + } + sum_g_k += (a * a + b * b) * mass_variances[l] * dist; + } + } + sum_g += sum_g_k; } - dist = phonoc_gaussian(f - f0[i], sigma); - for (l = 0; l < num_band / 3; l++) - { /* elements */ - a = 0; - b = 0; - for (m = 0; m < 3; m++) - { - e1_r = lapack_complex_double_real(eigenvectors[j * num_band * num_band + - (l * 3 + m) * num_band + k]); - e1_i = lapack_complex_double_imag(eigenvectors[j * num_band * num_band + - (l * 3 + m) * num_band + k]); - a += (e0_r[i * num_band + l * 3 + m] * e1_r + - e0_i[i * num_band + l * 3 + m] * e1_i); - b += (e0_i[i * num_band + l * 3 + m] * e1_r - - e0_r[i * num_band + l * 3 + m] * e1_i); - } - sum_g_k += (a * a + b * b) * mass_variances[l] * dist; - } - } - sum_g += sum_g_k; + gamma[i] = sum_g; } - gamma[i] = sum_g; - } - for (i = 0; i < num_band0; i++) - { - /* Frequency unit to ang-freq: *(2pi)**2/(2pi) */ - /* Ang-freq to freq unit (for lifetime): /2pi */ - /* gamma = 1/2t */ - gamma[i] *= M_2PI / 4 * f0[i] * f0[i] / 2; - } + for (i = 0; i < num_band0; i++) { + /* Frequency unit to ang-freq: *(2pi)**2/(2pi) */ + /* Ang-freq to freq unit (for lifetime): /2pi */ + /* gamma = 1/2t */ + gamma[i] *= M_2PI / 4 * f0[i] * f0[i] / 2; + } - free(f0); - f0 = NULL; - free(e0_r); - e0_r = NULL; - free(e0_i); - e0_i = NULL; + free(f0); + f0 = NULL; + free(e0_r); + e0_r = NULL; + free(e0_i); + e0_i = NULL; } -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 *frequencies, - const lapack_complex_double *eigenvectors, - const long num_grid_points, - const long *band_indices, - const long num_band, - const long num_band0, - const double *integration_weights, - const double cutoff_frequency) -{ - long i, j, k, l, m, gp; - double *e0_r, *e0_i, *f0, *gamma_ij; - double e1_r, e1_i, a, b, f, dist, sum_g_k; +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 *frequencies, const lapack_complex_double *eigenvectors, + const long num_grid_points, const long *band_indices, const long num_band, + const long num_band0, const double *integration_weights, + const double cutoff_frequency) { + long i, j, k, l, m, gp; + double *e0_r, *e0_i, *f0, *gamma_ij; + double e1_r, e1_i, a, b, f, dist, sum_g_k; - e0_r = (double *)malloc(sizeof(double) * num_band * num_band0); - e0_i = (double *)malloc(sizeof(double) * num_band * num_band0); - f0 = (double *)malloc(sizeof(double) * num_band0); + e0_r = (double *)malloc(sizeof(double) * num_band * num_band0); + e0_i = (double *)malloc(sizeof(double) * num_band * num_band0); + f0 = (double *)malloc(sizeof(double) * num_band0); - for (i = 0; i < num_band0; i++) - { - f0[i] = frequencies[grid_point * num_band + band_indices[i]]; - for (j = 0; j < num_band; j++) - { - e0_r[i * num_band + j] = lapack_complex_double_real(eigenvectors[grid_point * num_band * num_band + - j * num_band + band_indices[i]]); - e0_i[i * num_band + j] = lapack_complex_double_imag(eigenvectors[grid_point * num_band * num_band + - j * num_band + band_indices[i]]); + for (i = 0; i < num_band0; i++) { + f0[i] = frequencies[grid_point * num_band + band_indices[i]]; + for (j = 0; j < num_band; j++) { + e0_r[i * num_band + j] = lapack_complex_double_real( + eigenvectors[grid_point * num_band * num_band + j * num_band + + band_indices[i]]); + e0_i[i * num_band + j] = lapack_complex_double_imag( + eigenvectors[grid_point * num_band * num_band + j * num_band + + band_indices[i]]); + } } - } - gamma_ij = (double *)malloc(sizeof(double) * num_grid_points * num_band0); + gamma_ij = (double *)malloc(sizeof(double) * num_grid_points * num_band0); #ifdef PHPYOPENMP #pragma omp parallel for #endif - for (i = 0; i < num_grid_points * num_band0; i++) - { - gamma_ij[i] = 0; - } + for (i = 0; i < num_grid_points * num_band0; i++) { + gamma_ij[i] = 0; + } #ifdef PHPYOPENMP -#pragma omp parallel for private(j, k, l, m, f, gp, e1_r, e1_i, a, b, dist, sum_g_k) +#pragma omp parallel for private(j, k, l, m, f, gp, e1_r, e1_i, a, b, dist, \ + sum_g_k) #endif - for (i = 0; i < num_grid_points; i++) - { - gp = ir_grid_points[i]; - for (j = 0; j < num_band0; j++) - { /* band index0 */ - if (f0[j] < cutoff_frequency) - { - continue; - } - sum_g_k = 0; - for (k = 0; k < num_band; k++) - { /* band index */ - f = frequencies[gp * num_band + k]; - if (f < cutoff_frequency) - { - continue; + for (i = 0; i < num_grid_points; i++) { + gp = ir_grid_points[i]; + for (j = 0; j < num_band0; j++) { /* band index0 */ + if (f0[j] < cutoff_frequency) { + continue; + } + sum_g_k = 0; + for (k = 0; k < num_band; k++) { /* band index */ + f = frequencies[gp * num_band + k]; + if (f < cutoff_frequency) { + continue; + } + dist = integration_weights[gp * num_band0 * num_band + + j * num_band + k]; + for (l = 0; l < num_band / 3; l++) { /* elements */ + a = 0; + b = 0; + for (m = 0; m < 3; m++) { + e1_r = lapack_complex_double_real( + eigenvectors[gp * num_band * num_band + + (l * 3 + m) * num_band + k]); + e1_i = lapack_complex_double_imag( + eigenvectors[gp * num_band * num_band + + (l * 3 + m) * num_band + k]); + a += (e0_r[j * num_band + l * 3 + m] * e1_r + + e0_i[j * num_band + l * 3 + m] * e1_i); + b += (e0_i[j * num_band + l * 3 + m] * e1_r - + e0_r[j * num_band + l * 3 + m] * e1_i); + } + sum_g_k += (a * a + b * b) * mass_variances[l] * dist; + } + } + gamma_ij[gp * num_band0 + j] = sum_g_k * weights[gp]; } - dist = integration_weights[gp * num_band0 * num_band + - j * num_band + k]; - for (l = 0; l < num_band / 3; l++) - { /* elements */ - a = 0; - b = 0; - for (m = 0; m < 3; m++) - { - e1_r = lapack_complex_double_real(eigenvectors - [gp * num_band * num_band + (l * 3 + m) * num_band + k]); - e1_i = lapack_complex_double_imag(eigenvectors - [gp * num_band * num_band + (l * 3 + m) * num_band + k]); - a += (e0_r[j * num_band + l * 3 + m] * e1_r + - e0_i[j * num_band + l * 3 + m] * e1_i); - b += (e0_i[j * num_band + l * 3 + m] * e1_r - - e0_r[j * num_band + l * 3 + m] * e1_i); - } - sum_g_k += (a * a + b * b) * mass_variances[l] * dist; + } + + for (i = 0; i < num_band0; i++) { + gamma[i] = 0; + } + + 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_ij[gp * num_band0 + j] = sum_g_k * weights[gp]; } - } - for (i = 0; i < num_band0; i++) - { - gamma[i] = 0; - } - - 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]; + for (i = 0; i < num_band0; i++) { + /* Frequency unit to ang-freq: *(2pi)**2/(2pi) */ + /* Ang-freq to freq unit (for lifetime): /2pi */ + /* gamma = 1/2t */ + gamma[i] *= M_2PI / 4 * f0[i] * f0[i] / 2; } - } - for (i = 0; i < num_band0; i++) - { - /* Frequency unit to ang-freq: *(2pi)**2/(2pi) */ - /* Ang-freq to freq unit (for lifetime): /2pi */ - /* gamma = 1/2t */ - gamma[i] *= M_2PI / 4 * f0[i] * f0[i] / 2; - } - - free(gamma_ij); - gamma_ij = NULL; - free(f0); - f0 = NULL; - free(e0_r); - e0_r = NULL; - free(e0_i); - e0_i = NULL; + free(gamma_ij); + gamma_ij = NULL; + free(f0); + f0 = NULL; + free(e0_r); + e0_r = NULL; + free(e0_i); + e0_i = NULL; } diff --git a/c/isotope.h b/c/isotope.h index 3438bc03..276b5421 100644 --- a/c/isotope.h +++ b/c/isotope.h @@ -37,28 +37,16 @@ #include "lapack_wrapper.h" -void iso_get_isotope_scattering_strength(double *gamma, - const long grid_point, - 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 *frequencies, - const lapack_complex_double *eigenvectors, - const long num_grid_points, - const long *band_indices, - const long num_band, - const long num_band0, - const double *integration_weights, - const double cutoff_frequency); +void iso_get_isotope_scattering_strength( + double *gamma, const long grid_point, 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 *frequencies, const lapack_complex_double *eigenvectors, + const long num_grid_points, const long *band_indices, const long num_band, + const long num_band0, const double *integration_weights, + const double cutoff_frequency); #endif diff --git a/c/lagrid.c b/c/lagrid.c index b463ae59..0d602348 100644 --- a/c/lagrid.c +++ b/c/lagrid.c @@ -34,265 +34,216 @@ #include "lagrid.h" -long lagmat_get_determinant_l3(const long a[3][3]) -{ - return a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) + a[0][1] * (a[1][2] * a[2][0] - a[1][0] * a[2][2]) + a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]); +long lagmat_get_determinant_l3(const long a[3][3]) { + return a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) + + a[0][1] * (a[1][2] * a[2][0] - a[1][0] * a[2][2]) + + a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]); } -double lagmat_get_determinant_d3(const double a[3][3]) -{ - return a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) + a[0][1] * (a[1][2] * a[2][0] - a[1][0] * a[2][2]) + a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]); +double lagmat_get_determinant_d3(const double a[3][3]) { + return a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) + + a[0][1] * (a[1][2] * a[2][0] - a[1][0] * a[2][2]) + + a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]); } -void lagmat_cast_matrix_3l_to_3d(double m[3][3], const long a[3][3]) -{ - m[0][0] = a[0][0]; - m[0][1] = a[0][1]; - m[0][2] = a[0][2]; - m[1][0] = a[1][0]; - m[1][1] = a[1][1]; - m[1][2] = a[1][2]; - m[2][0] = a[2][0]; - m[2][1] = a[2][1]; - m[2][2] = a[2][2]; +void lagmat_cast_matrix_3l_to_3d(double m[3][3], const long a[3][3]) { + m[0][0] = a[0][0]; + m[0][1] = a[0][1]; + m[0][2] = a[0][2]; + m[1][0] = a[1][0]; + m[1][1] = a[1][1]; + m[1][2] = a[1][2]; + m[2][0] = a[2][0]; + m[2][1] = a[2][1]; + m[2][2] = a[2][2]; } -void lagmat_cast_matrix_3d_to_3l(long m[3][3], const double a[3][3]) -{ - m[0][0] = lagmat_Nint(a[0][0]); - m[0][1] = lagmat_Nint(a[0][1]); - m[0][2] = lagmat_Nint(a[0][2]); - m[1][0] = lagmat_Nint(a[1][0]); - m[1][1] = lagmat_Nint(a[1][1]); - m[1][2] = lagmat_Nint(a[1][2]); - m[2][0] = lagmat_Nint(a[2][0]); - m[2][1] = lagmat_Nint(a[2][1]); - m[2][2] = lagmat_Nint(a[2][2]); +void lagmat_cast_matrix_3d_to_3l(long m[3][3], const double a[3][3]) { + m[0][0] = lagmat_Nint(a[0][0]); + m[0][1] = lagmat_Nint(a[0][1]); + m[0][2] = lagmat_Nint(a[0][2]); + m[1][0] = lagmat_Nint(a[1][0]); + m[1][1] = lagmat_Nint(a[1][1]); + m[1][2] = lagmat_Nint(a[1][2]); + m[2][0] = lagmat_Nint(a[2][0]); + m[2][1] = lagmat_Nint(a[2][1]); + m[2][2] = lagmat_Nint(a[2][2]); } -long lagmat_get_similar_matrix_ld3(double m[3][3], - const long a[3][3], +long lagmat_get_similar_matrix_ld3(double m[3][3], const long a[3][3], const double b[3][3], - const double precision) -{ - double c[3][3]; - if (!lagmat_inverse_matrix_d3(c, b, precision)) - { - warning_print("No similar matrix due to 0 determinant.\n"); - return 0; - } - lagmat_multiply_matrix_ld3(m, a, b); - lagmat_multiply_matrix_d3(m, c, m); - return 1; -} - -long lagmat_check_identity_matrix_l3(const long a[3][3], - const long b[3][3]) -{ - if (a[0][0] - b[0][0] || - a[0][1] - b[0][1] || - a[0][2] - b[0][2] || - a[1][0] - b[1][0] || - a[1][1] - b[1][1] || - a[1][2] - b[1][2] || - a[2][0] - b[2][0] || - a[2][1] - b[2][1] || - a[2][2] - b[2][2]) - { - return 0; - } - else - { + const double precision) { + double c[3][3]; + if (!lagmat_inverse_matrix_d3(c, b, precision)) { + warning_print("No similar matrix due to 0 determinant.\n"); + return 0; + } + lagmat_multiply_matrix_ld3(m, a, b); + lagmat_multiply_matrix_d3(m, c, m); return 1; - } } -long lagmat_check_identity_matrix_ld3(const long a[3][3], - const double b[3][3], - const double symprec) -{ - if (lagmat_Dabs(a[0][0] - b[0][0]) > symprec || - lagmat_Dabs(a[0][1] - b[0][1]) > symprec || - lagmat_Dabs(a[0][2] - b[0][2]) > symprec || - lagmat_Dabs(a[1][0] - b[1][0]) > symprec || - lagmat_Dabs(a[1][1] - b[1][1]) > symprec || - lagmat_Dabs(a[1][2] - b[1][2]) > symprec || - lagmat_Dabs(a[2][0] - b[2][0]) > symprec || - lagmat_Dabs(a[2][1] - b[2][1]) > symprec || - lagmat_Dabs(a[2][2] - b[2][2]) > symprec) - { - return 0; - } - else - { +long lagmat_check_identity_matrix_l3(const long a[3][3], const long b[3][3]) { + if (a[0][0] - b[0][0] || a[0][1] - b[0][1] || a[0][2] - b[0][2] || + a[1][0] - b[1][0] || a[1][1] - b[1][1] || a[1][2] - b[1][2] || + a[2][0] - b[2][0] || a[2][1] - b[2][1] || a[2][2] - b[2][2]) { + return 0; + } else { + return 1; + } +} + +long lagmat_check_identity_matrix_ld3(const long a[3][3], const double b[3][3], + const double symprec) { + if (lagmat_Dabs(a[0][0] - b[0][0]) > symprec || + lagmat_Dabs(a[0][1] - b[0][1]) > symprec || + lagmat_Dabs(a[0][2] - b[0][2]) > symprec || + lagmat_Dabs(a[1][0] - b[1][0]) > symprec || + lagmat_Dabs(a[1][1] - b[1][1]) > symprec || + lagmat_Dabs(a[1][2] - b[1][2]) > symprec || + lagmat_Dabs(a[2][0] - b[2][0]) > symprec || + lagmat_Dabs(a[2][1] - b[2][1]) > symprec || + lagmat_Dabs(a[2][2] - b[2][2]) > symprec) { + return 0; + } else { + return 1; + } +} + +long lagmat_inverse_matrix_d3(double m[3][3], const double a[3][3], + const double precision) { + double det; + double c[3][3]; + det = lagmat_get_determinant_d3(a); + if (lagmat_Dabs(det) < precision) { + warning_print("No inverse matrix (det=%f)\n", det); + return 0; + } + + c[0][0] = (a[1][1] * a[2][2] - a[1][2] * a[2][1]) / det; + c[1][0] = (a[1][2] * a[2][0] - a[1][0] * a[2][2]) / det; + c[2][0] = (a[1][0] * a[2][1] - a[1][1] * a[2][0]) / det; + c[0][1] = (a[2][1] * a[0][2] - a[2][2] * a[0][1]) / det; + c[1][1] = (a[2][2] * a[0][0] - a[2][0] * a[0][2]) / det; + c[2][1] = (a[2][0] * a[0][1] - a[2][1] * a[0][0]) / det; + c[0][2] = (a[0][1] * a[1][2] - a[0][2] * a[1][1]) / det; + c[1][2] = (a[0][2] * a[1][0] - a[0][0] * a[1][2]) / det; + c[2][2] = (a[0][0] * a[1][1] - a[0][1] * a[1][0]) / det; + lagmat_copy_matrix_d3(m, c); return 1; - } } -long lagmat_inverse_matrix_d3(double m[3][3], - const double a[3][3], - const double precision) -{ - double det; - double c[3][3]; - det = lagmat_get_determinant_d3(a); - if (lagmat_Dabs(det) < precision) - { - warning_print("No inverse matrix (det=%f)\n", det); - return 0; - } - - c[0][0] = (a[1][1] * a[2][2] - a[1][2] * a[2][1]) / det; - c[1][0] = (a[1][2] * a[2][0] - a[1][0] * a[2][2]) / det; - c[2][0] = (a[1][0] * a[2][1] - a[1][1] * a[2][0]) / det; - c[0][1] = (a[2][1] * a[0][2] - a[2][2] * a[0][1]) / det; - c[1][1] = (a[2][2] * a[0][0] - a[2][0] * a[0][2]) / det; - c[2][1] = (a[2][0] * a[0][1] - a[2][1] * a[0][0]) / det; - c[0][2] = (a[0][1] * a[1][2] - a[0][2] * a[1][1]) / det; - c[1][2] = (a[0][2] * a[1][0] - a[0][0] * a[1][2]) / det; - c[2][2] = (a[0][0] * a[1][1] - a[0][1] * a[1][0]) / det; - lagmat_copy_matrix_d3(m, c); - return 1; +void lagmat_transpose_matrix_l3(long a[3][3], const long b[3][3]) { + long c[3][3]; + c[0][0] = b[0][0]; + c[0][1] = b[1][0]; + c[0][2] = b[2][0]; + c[1][0] = b[0][1]; + c[1][1] = b[1][1]; + c[1][2] = b[2][1]; + c[2][0] = b[0][2]; + c[2][1] = b[1][2]; + c[2][2] = b[2][2]; + lagmat_copy_matrix_l3(a, c); } -void lagmat_transpose_matrix_l3(long a[3][3], const long b[3][3]) -{ - long c[3][3]; - c[0][0] = b[0][0]; - c[0][1] = b[1][0]; - c[0][2] = b[2][0]; - c[1][0] = b[0][1]; - c[1][1] = b[1][1]; - c[1][2] = b[2][1]; - c[2][0] = b[0][2]; - c[2][1] = b[1][2]; - c[2][2] = b[2][2]; - lagmat_copy_matrix_l3(a, c); -} - -void lagmat_multiply_matrix_vector_l3(long v[3], - const long a[3][3], - const long b[3]) -{ - long i; - long c[3]; - for (i = 0; i < 3; i++) - { - c[i] = a[i][0] * b[0] + a[i][1] * b[1] + a[i][2] * b[2]; - } - for (i = 0; i < 3; i++) - { - v[i] = c[i]; - } -} - -void lagmat_multiply_matrix_l3(long m[3][3], - const long a[3][3], - const long b[3][3]) -{ - long i, j; /* a_ij */ - long c[3][3]; - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - c[i][j] = - a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; +void lagmat_multiply_matrix_vector_l3(long v[3], const long a[3][3], + const long b[3]) { + long i; + long c[3]; + for (i = 0; i < 3; i++) { + c[i] = a[i][0] * b[0] + a[i][1] * b[1] + a[i][2] * b[2]; } - } - lagmat_copy_matrix_l3(m, c); -} - -void lagmat_multiply_matrix_ld3(double m[3][3], - const long a[3][3], - const double b[3][3]) -{ - long i, j; /* a_ij */ - double c[3][3]; - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - c[i][j] = - a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; + for (i = 0; i < 3; i++) { + v[i] = c[i]; } - } - lagmat_copy_matrix_d3(m, c); } -void lagmat_multiply_matrix_d3(double m[3][3], - const double a[3][3], - const double b[3][3]) -{ - long i, j; /* a_ij */ - double c[3][3]; - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - c[i][j] = - a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; +void lagmat_multiply_matrix_l3(long m[3][3], const long a[3][3], + const long b[3][3]) { + long i, j; /* a_ij */ + long c[3][3]; + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + c[i][j] = a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; + } } - } - lagmat_copy_matrix_d3(m, c); + lagmat_copy_matrix_l3(m, c); } -void lagmat_copy_matrix_l3(long a[3][3], const long b[3][3]) -{ - a[0][0] = b[0][0]; - a[0][1] = b[0][1]; - a[0][2] = b[0][2]; - a[1][0] = b[1][0]; - a[1][1] = b[1][1]; - a[1][2] = b[1][2]; - a[2][0] = b[2][0]; - a[2][1] = b[2][1]; - a[2][2] = b[2][2]; +void lagmat_multiply_matrix_ld3(double m[3][3], const long a[3][3], + const double b[3][3]) { + long i, j; /* a_ij */ + double c[3][3]; + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + c[i][j] = a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; + } + } + lagmat_copy_matrix_d3(m, c); } -void lagmat_copy_matrix_d3(double a[3][3], const double b[3][3]) -{ - a[0][0] = b[0][0]; - a[0][1] = b[0][1]; - a[0][2] = b[0][2]; - a[1][0] = b[1][0]; - a[1][1] = b[1][1]; - a[1][2] = b[1][2]; - a[2][0] = b[2][0]; - a[2][1] = b[2][1]; - a[2][2] = b[2][2]; +void lagmat_multiply_matrix_d3(double m[3][3], const double a[3][3], + const double b[3][3]) { + long i, j; /* a_ij */ + double c[3][3]; + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + c[i][j] = a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; + } + } + lagmat_copy_matrix_d3(m, c); } -void lagmat_copy_vector_l3(long a[3], const long b[3]) -{ - a[0] = b[0]; - a[1] = b[1]; - a[2] = b[2]; +void lagmat_copy_matrix_l3(long a[3][3], const long b[3][3]) { + a[0][0] = b[0][0]; + a[0][1] = b[0][1]; + a[0][2] = b[0][2]; + a[1][0] = b[1][0]; + a[1][1] = b[1][1]; + a[1][2] = b[1][2]; + a[2][0] = b[2][0]; + a[2][1] = b[2][1]; + a[2][2] = b[2][2]; } -long lagmat_modulo_l(const long a, const long b) -{ - long c; - c = a % b; - if (c < 0) - { - c += b; - } - return c; +void lagmat_copy_matrix_d3(double a[3][3], const double b[3][3]) { + a[0][0] = b[0][0]; + a[0][1] = b[0][1]; + a[0][2] = b[0][2]; + a[1][0] = b[1][0]; + a[1][1] = b[1][1]; + a[1][2] = b[1][2]; + a[2][0] = b[2][0]; + a[2][1] = b[2][1]; + a[2][2] = b[2][2]; } -long lagmat_Nint(const double a) -{ - if (a < 0.0) - return (long)(a - 0.5); - else - return (long)(a + 0.5); +void lagmat_copy_vector_l3(long a[3], const long b[3]) { + a[0] = b[0]; + a[1] = b[1]; + a[2] = b[2]; } -double lagmat_Dabs(const double a) -{ - if (a < 0.0) - return -a; - else - return a; +long lagmat_modulo_l(const long a, const long b) { + long c; + c = a % b; + if (c < 0) { + c += b; + } + return c; +} + +long lagmat_Nint(const double a) { + if (a < 0.0) + return (long)(a - 0.5); + else + return (long)(a + 0.5); +} + +double lagmat_Dabs(const double a) { + if (a < 0.0) + return -a; + else + return a; } diff --git a/c/lagrid.h b/c/lagrid.h index e97e05af..91ecf243 100644 --- a/c/lagrid.h +++ b/c/lagrid.h @@ -36,7 +36,7 @@ #define __lagrid_H__ #ifdef LAGWARNING -#define warning_print(...) fprintf(stderr,__VA_ARGS__) +#define warning_print(...) fprintf(stderr, __VA_ARGS__) #else #define warning_print(...) #endif @@ -45,30 +45,22 @@ long lagmat_get_determinant_l3(const long a[3][3]); double lagmat_get_determinant_d3(const double a[3][3]); void lagmat_cast_matrix_3l_to_3d(double m[3][3], const long a[3][3]); void lagmat_cast_matrix_3d_to_3l(long m[3][3], const double a[3][3]); -long lagmat_get_similar_matrix_ld3(double m[3][3], - const long a[3][3], +long lagmat_get_similar_matrix_ld3(double m[3][3], const long a[3][3], const double b[3][3], const double precision); -long lagmat_check_identity_matrix_l3(const long a[3][3], - const long b[3][3]); -long lagmat_check_identity_matrix_ld3(const long a[3][3], - const double b[3][3], +long lagmat_check_identity_matrix_l3(const long a[3][3], const long b[3][3]); +long lagmat_check_identity_matrix_ld3(const long a[3][3], const double b[3][3], const double symprec); -long lagmat_inverse_matrix_d3(double m[3][3], - const double a[3][3], +long lagmat_inverse_matrix_d3(double m[3][3], const double a[3][3], const double precision); void lagmat_transpose_matrix_l3(long a[3][3], const long b[3][3]); -void lagmat_multiply_matrix_vector_l3(long v[3], - const long a[3][3], +void lagmat_multiply_matrix_vector_l3(long v[3], const long a[3][3], const long b[3]); -void lagmat_multiply_matrix_l3(long m[3][3], - const long a[3][3], +void lagmat_multiply_matrix_l3(long m[3][3], const long a[3][3], const long b[3][3]); -void lagmat_multiply_matrix_ld3(double m[3][3], - const long a[3][3], +void lagmat_multiply_matrix_ld3(double m[3][3], const long a[3][3], const double b[3][3]); -void lagmat_multiply_matrix_d3(double m[3][3], - const double a[3][3], +void lagmat_multiply_matrix_d3(double m[3][3], const double a[3][3], const double b[3][3]); void lagmat_copy_matrix_l3(long a[3][3], const long b[3][3]); void lagmat_copy_matrix_d3(double a[3][3], const double b[3][3]); diff --git a/c/lapack_wrapper.c b/c/lapack_wrapper.c index 1eaa3cea..11dcff2d 100644 --- a/c/lapack_wrapper.c +++ b/c/lapack_wrapper.c @@ -37,12 +37,11 @@ #define min(a, b) ((a) > (b) ? (b) : (a)) #ifdef MKL_LAPACKE -MKL_Complex16 lapack_make_complex_double(double re, double im) -{ - MKL_Complex16 z; - z.real = re; - z.imag = im; - return z; +MKL_Complex16 lapack_make_complex_double(double re, double im) { + MKL_Complex16 z; + z.real = re; + z.imag = im; + return z; } #ifndef LAPACKE_malloc #define LAPACKE_malloc(size) malloc(size) @@ -52,204 +51,146 @@ MKL_Complex16 lapack_make_complex_double(double re, double im) #endif #endif -int phonopy_zheev(double *w, - lapack_complex_double *a, - const int n, - const char uplo) -{ - lapack_int info; - info = LAPACKE_zheev(LAPACK_ROW_MAJOR, 'V', uplo, - (lapack_int)n, a, (lapack_int)n, w); - return (int)info; +int phonopy_zheev(double *w, lapack_complex_double *a, const int n, + const char uplo) { + lapack_int info; + info = LAPACKE_zheev(LAPACK_ROW_MAJOR, 'V', uplo, (lapack_int)n, a, + (lapack_int)n, w); + return (int)info; } -int phonopy_pinv(double *data_out, - const double *data_in, - const int m, - const int n, - const double cutoff) -{ - int i, j, k; - lapack_int info; - double *s, *a, *u, *vt, *superb; +int phonopy_pinv(double *data_out, const double *data_in, const int m, + const int n, const double cutoff) { + int i, j, k; + lapack_int info; + double *s, *a, *u, *vt, *superb; - a = (double *)malloc(sizeof(double) * m * n); - s = (double *)malloc(sizeof(double) * min(m, n)); - u = (double *)malloc(sizeof(double) * m * m); - vt = (double *)malloc(sizeof(double) * n * n); - superb = (double *)malloc(sizeof(double) * (min(m, n) - 1)); + a = (double *)malloc(sizeof(double) * m * n); + s = (double *)malloc(sizeof(double) * min(m, n)); + u = (double *)malloc(sizeof(double) * m * m); + vt = (double *)malloc(sizeof(double) * n * n); + superb = (double *)malloc(sizeof(double) * (min(m, n) - 1)); - for (i = 0; i < m * n; i++) - { - a[i] = data_in[i]; - } - - info = LAPACKE_dgesvd(LAPACK_ROW_MAJOR, - 'A', - 'A', - (lapack_int)m, - (lapack_int)n, - a, - (lapack_int)n, - s, - u, - (lapack_int)m, - vt, - (lapack_int)n, - superb); - - for (i = 0; i < n * m; i++) - { - data_out[i] = 0; - } - - for (i = 0; i < m; i++) - { - for (j = 0; j < n; j++) - { - for (k = 0; k < min(m, n); k++) - { - if (s[k] > cutoff) - { - data_out[j * m + i] += u[i * m + k] / s[k] * vt[k * n + j]; - } - } + for (i = 0; i < m * n; i++) { + a[i] = data_in[i]; } - } - free(a); - free(s); - free(u); - free(vt); - free(superb); + info = LAPACKE_dgesvd(LAPACK_ROW_MAJOR, 'A', 'A', (lapack_int)m, + (lapack_int)n, a, (lapack_int)n, s, u, (lapack_int)m, + vt, (lapack_int)n, superb); - return (int)info; + for (i = 0; i < n * m; i++) { + data_out[i] = 0; + } + + for (i = 0; i < m; i++) { + for (j = 0; j < n; j++) { + for (k = 0; k < min(m, n); k++) { + if (s[k] > cutoff) { + data_out[j * m + i] += u[i * m + k] / s[k] * vt[k * n + j]; + } + } + } + } + + free(a); + free(s); + free(u); + free(vt); + free(superb); + + return (int)info; } -void phonopy_pinv_mt(double *data_out, - int *info_out, - const double *data_in, - const int num_thread, - const int *row_nums, - const int max_row_num, - const int column_num, - const double cutoff) -{ - int i; +void phonopy_pinv_mt(double *data_out, int *info_out, const double *data_in, + const int num_thread, const int *row_nums, + const int max_row_num, const int column_num, + const double cutoff) { + int i; #ifdef PHPYOPENMP #pragma omp parallel for #endif - for (i = 0; i < num_thread; i++) - { - info_out[i] = phonopy_pinv(data_out + i * max_row_num * column_num, - data_in + i * max_row_num * column_num, - row_nums[i], - column_num, - cutoff); - } + for (i = 0; i < num_thread; i++) { + info_out[i] = phonopy_pinv(data_out + i * max_row_num * column_num, + data_in + i * max_row_num * column_num, + row_nums[i], column_num, cutoff); + } } -int phonopy_dsyev(double *data, - double *eigvals, - const int size, - const int algorithm) -{ - lapack_int info; +int phonopy_dsyev(double *data, double *eigvals, const int size, + const int algorithm) { + lapack_int info; - lapack_int liwork; - long lwork; - lapack_int *iwork; - double *work; - lapack_int iwork_query; - double work_query; + lapack_int liwork; + long lwork; + lapack_int *iwork; + double *work; + lapack_int iwork_query; + double work_query; - info = 0; - liwork = -1; - lwork = -1; - iwork = NULL; - work = NULL; + info = 0; + liwork = -1; + lwork = -1; + iwork = NULL; + work = NULL; - switch (algorithm) - { - case 0: /* dsyev */ - info = LAPACKE_dsyev(LAPACK_COL_MAJOR, - 'V', - 'U', - (lapack_int)size, - data, - (lapack_int)size, - eigvals); - break; - case 1: /* dsyevd */ - info = LAPACKE_dsyevd_work(LAPACK_COL_MAJOR, - 'V', - 'U', - (lapack_int)size, - data, - (lapack_int)size, - eigvals, - &work_query, - lwork, - &iwork_query, - liwork); - liwork = iwork_query; - lwork = (long)work_query; - /* printf("liwork %d, lwork %ld\n", liwork, lwork); */ - if ((iwork = (lapack_int *)LAPACKE_malloc(sizeof(lapack_int) * liwork)) == NULL) - { - goto end; - }; - if ((work = (double *)LAPACKE_malloc(sizeof(double) * lwork)) == NULL) - { - goto end; + switch (algorithm) { + case 0: /* dsyev */ + info = LAPACKE_dsyev(LAPACK_COL_MAJOR, 'V', 'U', (lapack_int)size, + data, (lapack_int)size, eigvals); + break; + case 1: /* dsyevd */ + info = LAPACKE_dsyevd_work(LAPACK_COL_MAJOR, 'V', 'U', + (lapack_int)size, data, (lapack_int)size, + eigvals, &work_query, lwork, + &iwork_query, liwork); + liwork = iwork_query; + lwork = (long)work_query; + /* printf("liwork %d, lwork %ld\n", liwork, lwork); */ + if ((iwork = (lapack_int *)LAPACKE_malloc(sizeof(lapack_int) * + liwork)) == NULL) { + goto end; + }; + if ((work = (double *)LAPACKE_malloc(sizeof(double) * lwork)) == + NULL) { + goto end; + } + + info = LAPACKE_dsyevd_work(LAPACK_COL_MAJOR, 'V', 'U', + (lapack_int)size, data, (lapack_int)size, + eigvals, work, lwork, iwork, liwork); + + end: + if (iwork) { + LAPACKE_free(iwork); + iwork = NULL; + } + if (work) { + LAPACKE_free(work); + work = NULL; + } + + /* info = LAPACKE_dsyevd(LAPACK_COL_MAJOR, */ + /* 'V', */ + /* 'U', */ + /* (lapack_int)size, */ + /* data, */ + /* (lapack_int)size, */ + /* eigvals); */ + break; } - info = LAPACKE_dsyevd_work(LAPACK_COL_MAJOR, - 'V', - 'U', - (lapack_int)size, - data, - (lapack_int)size, - eigvals, - work, - lwork, - iwork, - liwork); - - end: - if (iwork) - { - LAPACKE_free(iwork); - iwork = NULL; - } - if (work) - { - LAPACKE_free(work); - work = NULL; - } - - /* info = LAPACKE_dsyevd(LAPACK_COL_MAJOR, */ - /* 'V', */ - /* 'U', */ - /* (lapack_int)size, */ - /* data, */ - /* (lapack_int)size, */ - /* eigvals); */ - break; - } - - return (int)info; + return (int)info; } -lapack_complex_double -phonoc_complex_prod(const lapack_complex_double a, - const lapack_complex_double b) -{ - lapack_complex_double c; - c = lapack_make_complex_double(lapack_complex_double_real(a) * lapack_complex_double_real(b) - - lapack_complex_double_imag(a) * lapack_complex_double_imag(b), - lapack_complex_double_imag(a) * lapack_complex_double_real(b) + - lapack_complex_double_real(a) * lapack_complex_double_imag(b)); - return c; +lapack_complex_double phonoc_complex_prod(const lapack_complex_double a, + const lapack_complex_double b) { + lapack_complex_double c; + c = lapack_make_complex_double( + lapack_complex_double_real(a) * lapack_complex_double_real(b) - + lapack_complex_double_imag(a) * lapack_complex_double_imag(b), + lapack_complex_double_imag(a) * lapack_complex_double_real(b) + + lapack_complex_double_real(a) * lapack_complex_double_imag(b)); + return c; } diff --git a/c/lapack_wrapper.h b/c/lapack_wrapper.h index 3051bcd9..94b9ea28 100644 --- a/c/lapack_wrapper.h +++ b/c/lapack_wrapper.h @@ -45,30 +45,18 @@ MKL_Complex16 lapack_make_complex_double(double re, double im); #include #endif -int phonopy_zheev(double *w, - lapack_complex_double *a, - const int n, +int phonopy_zheev(double *w, lapack_complex_double *a, const int n, const char uplo); -int phonopy_pinv(double *data_out, - const double *data_in, - const int m, - const int n, - const double cutoff); -void phonopy_pinv_mt(double *data_out, - int *info_out, - const double *data_in, - const int num_thread, - const int *row_nums, - const int max_row_num, - const int column_num, +int phonopy_pinv(double *data_out, const double *data_in, const int m, + const int n, const double cutoff); +void phonopy_pinv_mt(double *data_out, int *info_out, const double *data_in, + const int num_thread, const int *row_nums, + const int max_row_num, const int column_num, const double cutoff); -int phonopy_dsyev(double *data, - double *eigvals, - const int size, +int phonopy_dsyev(double *data, double *eigvals, const int size, const int algorithm); -lapack_complex_double -phonoc_complex_prod(const lapack_complex_double a, - const lapack_complex_double b); +lapack_complex_double phonoc_complex_prod(const lapack_complex_double a, + const lapack_complex_double b); #endif diff --git a/c/phono3py.c b/c/phono3py.c index b1a15e3c..9700c2c2 100644 --- a/c/phono3py.c +++ b/c/phono3py.c @@ -33,703 +33,389 @@ /* POSSIBILITY OF SUCH DAMAGE. */ #include "phono3py.h" -#include "lapack_wrapper.h" -#include "phonoc_array.h" - -#include "bzgrid.h" -#include "collision_matrix.h" -#include "fc3.h" -#include "interaction.h" -#include "imag_self_energy_with_g.h" -#include "isotope.h" -#include "lagrid.h" -#include "pp_collision.h" -#include "real_self_energy.h" -#include "grgrid.h" -#include "tetrahedron_method.h" -#include "triplet.h" -#include "triplet_iw.h" #include #include -long ph3py_get_interaction(Darray *fc3_normal_squared, - const char *g_zero, - const Darray *frequencies, - const lapack_complex_double *eigenvectors, - const long (*triplets)[3], - const long num_triplets, - const long (*bz_grid_addresses)[3], - const long D_diag[3], - const long Q[3][3], - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const long *band_indices, - const long symmetrize_fc3_q, - const double cutoff_frequency) -{ - ConstBZGrid *bzgrid; - long i, j; +#include "bzgrid.h" +#include "collision_matrix.h" +#include "fc3.h" +#include "grgrid.h" +#include "imag_self_energy_with_g.h" +#include "interaction.h" +#include "isotope.h" +#include "lagrid.h" +#include "lapack_wrapper.h" +#include "phonoc_array.h" +#include "pp_collision.h" +#include "real_self_energy.h" +#include "tetrahedron_method.h" +#include "triplet.h" +#include "triplet_iw.h" - if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) - { - warning_print("Memory could not be allocated."); - return 0; - } +long ph3py_get_interaction( + Darray *fc3_normal_squared, const char *g_zero, const Darray *frequencies, + const lapack_complex_double *eigenvectors, const long (*triplets)[3], + const long num_triplets, const long (*bz_grid_addresses)[3], + const long D_diag[3], const long Q[3][3], const double *fc3, + const long is_compact_fc3, const double (*svecs)[3], + const long multi_dims[2], const long (*multiplicity)[2], + const double *masses, const long *p2s_map, const long *s2p_map, + const long *band_indices, const long symmetrize_fc3_q, + const double cutoff_frequency) { + ConstBZGrid *bzgrid; + long i, j; - bzgrid->addresses = bz_grid_addresses; - for (i = 0; i < 3; i++) - { - bzgrid->D_diag[i] = D_diag[i]; - bzgrid->PS[i] = 0; - for (j = 0; j < 3; j++) - { - bzgrid->Q[i][j] = Q[i][j]; + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) { + warning_print("Memory could not be allocated."); + return 0; } - } - itr_get_interaction(fc3_normal_squared, - g_zero, - frequencies, - eigenvectors, - triplets, - num_triplets, - bzgrid, - fc3, - is_compact_fc3, - svecs, - multi_dims, - multiplicity, - masses, - p2s_map, - s2p_map, - band_indices, - symmetrize_fc3_q, - cutoff_frequency); - free(bzgrid); - bzgrid = NULL; + bzgrid->addresses = bz_grid_addresses; + for (i = 0; i < 3; i++) { + bzgrid->D_diag[i] = D_diag[i]; + bzgrid->PS[i] = 0; + for (j = 0; j < 3; j++) { + bzgrid->Q[i][j] = Q[i][j]; + } + } - return 1; + itr_get_interaction(fc3_normal_squared, g_zero, frequencies, eigenvectors, + triplets, num_triplets, bzgrid, fc3, is_compact_fc3, + svecs, multi_dims, multiplicity, masses, p2s_map, + s2p_map, band_indices, symmetrize_fc3_q, + cutoff_frequency); + free(bzgrid); + bzgrid = NULL; + + return 1; } -long ph3py_get_pp_collision(double *imag_self_energy, - const long relative_grid_address[24][4][3], /* thm */ - const double *frequencies, - const lapack_complex_double *eigenvectors, - const long (*triplets)[3], - const long num_triplets, - const long *triplet_weights, - const long (*bz_grid_addresses)[3], /* thm */ - const long *bz_map, /* thm */ - const long bz_grid_type, - const long D_diag[3], - const long Q[3][3], - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const Larray *band_indices, - const Darray *temperatures, - const long is_NU, - const long symmetrize_fc3_q, - const double cutoff_frequency) -{ - ConstBZGrid *bzgrid; - long i, j; +long ph3py_get_pp_collision( + double *imag_self_energy, + const long relative_grid_address[24][4][3], /* thm */ + const double *frequencies, const lapack_complex_double *eigenvectors, + const long (*triplets)[3], const long num_triplets, + const long *triplet_weights, const long (*bz_grid_addresses)[3], /* thm */ + const long *bz_map, /* thm */ + const long bz_grid_type, const long D_diag[3], const long Q[3][3], + const double *fc3, const long is_compact_fc3, const double (*svecs)[3], + const long multi_dims[2], const long (*multiplicity)[2], + const double *masses, const long *p2s_map, const long *s2p_map, + const Larray *band_indices, const Darray *temperatures, const long is_NU, + const long symmetrize_fc3_q, const double cutoff_frequency) { + ConstBZGrid *bzgrid; + long i, j; - if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) - { - warning_print("Memory could not be allocated."); - return 0; - } - - bzgrid->addresses = bz_grid_addresses; - bzgrid->gp_map = bz_map; - bzgrid->type = bz_grid_type; - for (i = 0; i < 3; i++) - { - bzgrid->D_diag[i] = D_diag[i]; - bzgrid->PS[i] = 0; - for (j = 0; j < 3; j++) - { - bzgrid->Q[i][j] = Q[i][j]; + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) { + warning_print("Memory could not be allocated."); + return 0; } - } - ppc_get_pp_collision(imag_self_energy, - relative_grid_address, - frequencies, - eigenvectors, - triplets, - num_triplets, - triplet_weights, - bzgrid, - fc3, - is_compact_fc3, - svecs, - multi_dims, - multiplicity, - masses, - p2s_map, - s2p_map, - band_indices, - temperatures, - is_NU, - symmetrize_fc3_q, - cutoff_frequency); + bzgrid->addresses = bz_grid_addresses; + bzgrid->gp_map = bz_map; + bzgrid->type = bz_grid_type; + for (i = 0; i < 3; i++) { + bzgrid->D_diag[i] = D_diag[i]; + bzgrid->PS[i] = 0; + for (j = 0; j < 3; j++) { + bzgrid->Q[i][j] = Q[i][j]; + } + } - free(bzgrid); - bzgrid = NULL; + ppc_get_pp_collision( + imag_self_energy, relative_grid_address, frequencies, eigenvectors, + triplets, num_triplets, triplet_weights, bzgrid, fc3, is_compact_fc3, + svecs, multi_dims, multiplicity, masses, p2s_map, s2p_map, band_indices, + temperatures, is_NU, symmetrize_fc3_q, cutoff_frequency); - return 1; + free(bzgrid); + bzgrid = NULL; + + return 1; } long ph3py_get_pp_collision_with_sigma( - double *imag_self_energy, - const double sigma, - const double sigma_cutoff, - const double *frequencies, - const lapack_complex_double *eigenvectors, - const long (*triplets)[3], - const long num_triplets, - const long *triplet_weights, - const long (*bz_grid_addresses)[3], - const long D_diag[3], - const long Q[3][3], - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const Larray *band_indices, - const Darray *temperatures, - const long is_NU, - const long symmetrize_fc3_q, - const double cutoff_frequency) -{ - ConstBZGrid *bzgrid; - long i, j; + double *imag_self_energy, const double sigma, const double sigma_cutoff, + const double *frequencies, const lapack_complex_double *eigenvectors, + const long (*triplets)[3], const long num_triplets, + const long *triplet_weights, const long (*bz_grid_addresses)[3], + const long D_diag[3], const long Q[3][3], const double *fc3, + const long is_compact_fc3, const double (*svecs)[3], + const long multi_dims[2], const long (*multiplicity)[2], + const double *masses, const long *p2s_map, const long *s2p_map, + const Larray *band_indices, const Darray *temperatures, const long is_NU, + const long symmetrize_fc3_q, const double cutoff_frequency) { + ConstBZGrid *bzgrid; + long i, j; - if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) - { - warning_print("Memory could not be allocated."); - return 0; - } - - bzgrid->addresses = bz_grid_addresses; - for (i = 0; i < 3; i++) - { - bzgrid->D_diag[i] = D_diag[i]; - bzgrid->PS[i] = 0; - for (j = 0; j < 3; j++) - { - bzgrid->Q[i][j] = Q[i][j]; + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) { + warning_print("Memory could not be allocated."); + return 0; } - } - ppc_get_pp_collision_with_sigma(imag_self_energy, - sigma, - sigma_cutoff, - frequencies, - eigenvectors, - triplets, - num_triplets, - triplet_weights, - bzgrid, - fc3, - is_compact_fc3, - svecs, - multi_dims, - multiplicity, - masses, - p2s_map, - s2p_map, - band_indices, - temperatures, - is_NU, - symmetrize_fc3_q, - cutoff_frequency); + bzgrid->addresses = bz_grid_addresses; + for (i = 0; i < 3; i++) { + bzgrid->D_diag[i] = D_diag[i]; + bzgrid->PS[i] = 0; + for (j = 0; j < 3; j++) { + bzgrid->Q[i][j] = Q[i][j]; + } + } - free(bzgrid); - bzgrid = NULL; + ppc_get_pp_collision_with_sigma( + imag_self_energy, sigma, sigma_cutoff, frequencies, eigenvectors, + triplets, num_triplets, triplet_weights, bzgrid, fc3, is_compact_fc3, + svecs, multi_dims, multiplicity, masses, p2s_map, s2p_map, band_indices, + temperatures, is_NU, symmetrize_fc3_q, cutoff_frequency); - return 1; + free(bzgrid); + bzgrid = NULL; + + return 1; } void ph3py_get_imag_self_energy_at_bands_with_g( - double *imag_self_energy, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double *g, - const char *g_zero, - const double temperature, - const double cutoff_frequency, - const long num_frequency_points, - const long frequency_point_index) -{ - ise_get_imag_self_energy_at_bands_with_g(imag_self_energy, - fc3_normal_squared, - frequencies, - triplets, - triplet_weights, - g, - g_zero, - temperature, - cutoff_frequency, - num_frequency_points, - frequency_point_index); + double *imag_self_energy, const Darray *fc3_normal_squared, + const double *frequencies, const long (*triplets)[3], + const long *triplet_weights, const double *g, const char *g_zero, + const double temperature, const double cutoff_frequency, + const long num_frequency_points, const long frequency_point_index) { + ise_get_imag_self_energy_at_bands_with_g( + imag_self_energy, fc3_normal_squared, frequencies, triplets, + triplet_weights, g, g_zero, temperature, cutoff_frequency, + num_frequency_points, frequency_point_index); } void ph3py_get_detailed_imag_self_energy_at_bands_with_g( - double *detailed_imag_self_energy, - double *imag_self_energy_N, - double *imag_self_energy_U, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const long (*bz_grid_addresses)[3], - const double *g, - const char *g_zero, - const double temperature, - const double cutoff_frequency) -{ - ise_get_detailed_imag_self_energy_at_bands_with_g(detailed_imag_self_energy, - imag_self_energy_N, - imag_self_energy_U, - fc3_normal_squared, - frequencies, - triplets, - triplet_weights, - bz_grid_addresses, - g, - g_zero, - temperature, - cutoff_frequency); + double *detailed_imag_self_energy, double *imag_self_energy_N, + double *imag_self_energy_U, const Darray *fc3_normal_squared, + const double *frequencies, const long (*triplets)[3], + const long *triplet_weights, const long (*bz_grid_addresses)[3], + const double *g, const char *g_zero, const double temperature, + const double cutoff_frequency) { + ise_get_detailed_imag_self_energy_at_bands_with_g( + detailed_imag_self_energy, imag_self_energy_N, imag_self_energy_U, + fc3_normal_squared, frequencies, triplets, triplet_weights, + bz_grid_addresses, g, g_zero, temperature, cutoff_frequency); } -void ph3py_get_real_self_energy_at_bands(double *real_self_energy, - const Darray *fc3_normal_squared, - const long *band_indices, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double epsilon, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency) -{ - rse_get_real_self_energy_at_bands(real_self_energy, - fc3_normal_squared, - band_indices, - frequencies, - triplets, - triplet_weights, - epsilon, - temperature, - unit_conversion_factor, - cutoff_frequency); +void ph3py_get_real_self_energy_at_bands( + double *real_self_energy, const Darray *fc3_normal_squared, + const long *band_indices, const double *frequencies, + const long (*triplets)[3], const long *triplet_weights, + const double epsilon, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency) { + rse_get_real_self_energy_at_bands(real_self_energy, fc3_normal_squared, + band_indices, frequencies, triplets, + triplet_weights, epsilon, temperature, + unit_conversion_factor, cutoff_frequency); } void ph3py_get_real_self_energy_at_frequency_point( - double *real_self_energy, - const double frequency_point, - const Darray *fc3_normal_squared, - const long *band_indices, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double epsilon, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency) -{ - rse_get_real_self_energy_at_frequency_point(real_self_energy, - frequency_point, - fc3_normal_squared, - band_indices, - frequencies, - triplets, - triplet_weights, - epsilon, - temperature, - unit_conversion_factor, - cutoff_frequency); + double *real_self_energy, const double frequency_point, + const Darray *fc3_normal_squared, const long *band_indices, + const double *frequencies, const long (*triplets)[3], + const long *triplet_weights, const double epsilon, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency) { + rse_get_real_self_energy_at_frequency_point( + real_self_energy, frequency_point, fc3_normal_squared, band_indices, + frequencies, triplets, triplet_weights, epsilon, temperature, + unit_conversion_factor, cutoff_frequency); } -void ph3py_get_collision_matrix(double *collision_matrix, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplets_map, - const long *map_q, - const long *rotated_grid_points, - const double *rotations_cartesian, - const double *g, - const long num_ir_gp, - const long num_gp, - const long num_rot, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency) -{ - col_get_collision_matrix(collision_matrix, - fc3_normal_squared, - frequencies, - triplets, - triplets_map, - map_q, - rotated_grid_points, - rotations_cartesian, - g, - num_ir_gp, - num_gp, - num_rot, - temperature, - unit_conversion_factor, - cutoff_frequency); +void ph3py_get_collision_matrix( + double *collision_matrix, const Darray *fc3_normal_squared, + const double *frequencies, const long (*triplets)[3], + const long *triplets_map, const long *map_q, + const long *rotated_grid_points, const double *rotations_cartesian, + const double *g, const long num_ir_gp, const long num_gp, + const long num_rot, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency) { + col_get_collision_matrix(collision_matrix, fc3_normal_squared, frequencies, + triplets, triplets_map, map_q, rotated_grid_points, + rotations_cartesian, g, num_ir_gp, num_gp, num_rot, + temperature, unit_conversion_factor, + cutoff_frequency); } -void ph3py_get_reducible_collision_matrix(double *collision_matrix, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplets_map, - const long *map_q, - const double *g, - const long num_gp, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency) -{ - col_get_reducible_collision_matrix(collision_matrix, - fc3_normal_squared, - frequencies, - triplets, - triplets_map, - map_q, - g, - num_gp, - temperature, - unit_conversion_factor, - cutoff_frequency); +void ph3py_get_reducible_collision_matrix( + double *collision_matrix, const Darray *fc3_normal_squared, + const double *frequencies, const long (*triplets)[3], + const long *triplets_map, const long *map_q, const double *g, + const long num_gp, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency) { + col_get_reducible_collision_matrix( + collision_matrix, fc3_normal_squared, frequencies, triplets, + triplets_map, map_q, g, num_gp, temperature, unit_conversion_factor, + cutoff_frequency); } void ph3py_get_isotope_scattering_strength( - double *gamma, - const long grid_point, - 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) -{ - iso_get_isotope_scattering_strength(gamma, - grid_point, - mass_variances, - frequencies, - eigenvectors, - num_grid_points, - band_indices, - num_band, - num_band0, - sigma, - cutoff_frequency); + double *gamma, const long grid_point, 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) { + iso_get_isotope_scattering_strength(gamma, grid_point, mass_variances, + frequencies, eigenvectors, + num_grid_points, band_indices, num_band, + num_band0, sigma, 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 *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 *integration_weights, - const double cutoff_frequency) -{ - iso_get_thm_isotope_scattering_strength(gamma, - grid_point, - ir_grid_points, - weights, - mass_variances, - frequencies, - eigenvectors, - num_ir_grid_points, - band_indices, - num_band, - num_band0, - integration_weights, - 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 *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 *integration_weights, const double cutoff_frequency) { + iso_get_thm_isotope_scattering_strength( + gamma, grid_point, ir_grid_points, weights, mass_variances, frequencies, + eigenvectors, num_ir_grid_points, band_indices, num_band, num_band0, + integration_weights, cutoff_frequency); } -void ph3py_distribute_fc3(double *fc3, - const long target, - const long source, - const long *atom_mapping, - const long num_atom, - const double *rot_cart) -{ - fc3_distribute_fc3(fc3, - target, - source, - atom_mapping, - num_atom, - rot_cart); +void ph3py_distribute_fc3(double *fc3, const long target, const long source, + const long *atom_mapping, const long num_atom, + const double *rot_cart) { + fc3_distribute_fc3(fc3, target, source, atom_mapping, num_atom, rot_cart); } void ph3py_rotate_delta_fc2(double (*fc3)[3][3][3], const double (*delta_fc2s)[3][3], const double *inv_U, const double (*site_sym_cart)[3][3], - const long *rot_map_syms, - const long num_atom, - const long num_site_sym, - const long num_disp) -{ - fc3_rotate_delta_fc2(fc3, - delta_fc2s, - inv_U, - site_sym_cart, - rot_map_syms, - num_atom, - num_site_sym, - num_disp); + const long *rot_map_syms, const long num_atom, + const long num_site_sym, const long num_disp) { + fc3_rotate_delta_fc2(fc3, delta_fc2s, inv_U, site_sym_cart, rot_map_syms, + num_atom, num_site_sym, num_disp); } -void ph3py_get_permutation_symmetry_fc3(double *fc3, const long num_atom) -{ - fc3_set_permutation_symmetry_fc3(fc3, num_atom); +void ph3py_get_permutation_symmetry_fc3(double *fc3, const long num_atom) { + fc3_set_permutation_symmetry_fc3(fc3, num_atom); } -void ph3py_get_permutation_symmetry_compact_fc3(double *fc3, - const long p2s[], - const long s2pp[], - const long nsym_list[], - const long perms[], - const long n_satom, - const long n_patom) -{ - fc3_set_permutation_symmetry_compact_fc3(fc3, - p2s, - s2pp, - nsym_list, - perms, - n_satom, - n_patom); +void ph3py_get_permutation_symmetry_compact_fc3( + double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], + const long perms[], const long n_satom, const long n_patom) { + fc3_set_permutation_symmetry_compact_fc3(fc3, p2s, s2pp, nsym_list, perms, + n_satom, n_patom); } -void ph3py_transpose_compact_fc3(double *fc3, - const long p2s[], - const long s2pp[], - const long nsym_list[], - const long perms[], - const long n_satom, - const long n_patom, - const long t_type) -{ - fc3_transpose_compact_fc3(fc3, - p2s, - s2pp, - nsym_list, - perms, - n_satom, - n_patom, - t_type); +void ph3py_transpose_compact_fc3(double *fc3, const long p2s[], + const long s2pp[], const long nsym_list[], + const long perms[], const long n_satom, + const long n_patom, const long t_type) { + fc3_transpose_compact_fc3(fc3, p2s, s2pp, nsym_list, perms, n_satom, + n_patom, t_type); } -long ph3py_get_triplets_reciprocal_mesh_at_q(long *map_triplets, - long *map_q, - const long grid_point, - const long D_diag[3], - const long is_time_reversal, - const long num_rot, - const long (*rec_rotations)[3][3], - const long swappable) -{ - return tpl_get_triplets_reciprocal_mesh_at_q(map_triplets, - map_q, - grid_point, - D_diag, - is_time_reversal, - num_rot, - rec_rotations, - swappable); +long ph3py_get_triplets_reciprocal_mesh_at_q( + long *map_triplets, long *map_q, const long grid_point, + const long D_diag[3], const long is_time_reversal, const long num_rot, + const long (*rec_rotations)[3][3], const long swappable) { + return tpl_get_triplets_reciprocal_mesh_at_q( + map_triplets, map_q, grid_point, D_diag, is_time_reversal, num_rot, + rec_rotations, swappable); } -long ph3py_get_BZ_triplets_at_q(long (*triplets)[3], - const long grid_point, +long ph3py_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point, const long (*bz_grid_addresses)[3], - const long *bz_map, - const long *map_triplets, + const long *bz_map, const long *map_triplets, const long num_map_triplets, - const long D_diag[3], - const long Q[3][3], - const long bz_grid_type) -{ - ConstBZGrid *bzgrid; - long i, j, num_ir; + const long D_diag[3], const long Q[3][3], + const long bz_grid_type) { + ConstBZGrid *bzgrid; + long i, j, num_ir; - if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) - { - warning_print("Memory could not be allocated."); - return 0; - } - - bzgrid->addresses = bz_grid_addresses; - bzgrid->gp_map = bz_map; - bzgrid->type = bz_grid_type; - for (i = 0; i < 3; i++) - { - bzgrid->D_diag[i] = D_diag[i]; - bzgrid->PS[i] = 0; - for (j = 0; j < 3; j++) - { - bzgrid->Q[i][j] = Q[i][j]; + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) { + warning_print("Memory could not be allocated."); + return 0; } - } - bzgrid->size = num_map_triplets; - num_ir = tpl_get_BZ_triplets_at_q(triplets, - grid_point, - bzgrid, - map_triplets); - free(bzgrid); - bzgrid = NULL; + bzgrid->addresses = bz_grid_addresses; + bzgrid->gp_map = bz_map; + bzgrid->type = bz_grid_type; + for (i = 0; i < 3; i++) { + bzgrid->D_diag[i] = D_diag[i]; + bzgrid->PS[i] = 0; + for (j = 0; j < 3; j++) { + bzgrid->Q[i][j] = Q[i][j]; + } + } + bzgrid->size = num_map_triplets; - return num_ir; + num_ir = + tpl_get_BZ_triplets_at_q(triplets, grid_point, bzgrid, map_triplets); + free(bzgrid); + bzgrid = NULL; + + return num_ir; } /* relative_grid_addresses are given as P multipled with those from dataset, * i.e., * np.dot(relative_grid_addresses, P.T) */ -long ph3py_get_integration_weight(double *iw, - char *iw_zero, - const double *frequency_points, - const long num_band0, - const long relative_grid_address[24][4][3], - const long D_diag[3], - const long (*triplets)[3], - const long num_triplets, - const long (*bz_grid_addresses)[3], - const long *bz_map, - const long bz_grid_type, - const double *frequencies1, - const long num_band1, - const double *frequencies2, - const long num_band2, - const long tp_type, - const long openmp_per_triplets, - const long openmp_per_bands) -{ - ConstBZGrid *bzgrid; - long i; +long ph3py_get_integration_weight( + double *iw, char *iw_zero, const double *frequency_points, + const long num_band0, const long relative_grid_address[24][4][3], + const long D_diag[3], const long (*triplets)[3], const long num_triplets, + const long (*bz_grid_addresses)[3], const long *bz_map, + const long bz_grid_type, const double *frequencies1, const long num_band1, + const double *frequencies2, const long num_band2, const long tp_type, + const long openmp_per_triplets, const long openmp_per_bands) { + ConstBZGrid *bzgrid; + long i; - if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) - { - warning_print("Memory could not be allocated."); - return 0; - } + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) { + warning_print("Memory could not be allocated."); + return 0; + } - bzgrid->addresses = bz_grid_addresses; - bzgrid->gp_map = bz_map; - bzgrid->type = bz_grid_type; - for (i = 0; i < 3; i++) - { - bzgrid->D_diag[i] = D_diag[i]; - } + bzgrid->addresses = bz_grid_addresses; + bzgrid->gp_map = bz_map; + bzgrid->type = bz_grid_type; + for (i = 0; i < 3; i++) { + bzgrid->D_diag[i] = D_diag[i]; + } - tpl_get_integration_weight(iw, - iw_zero, - frequency_points, - num_band0, - relative_grid_address, - triplets, - num_triplets, - bzgrid, - frequencies1, - num_band1, - frequencies2, - num_band2, - tp_type, - openmp_per_triplets, - openmp_per_bands); - free(bzgrid); - bzgrid = NULL; + tpl_get_integration_weight( + iw, iw_zero, frequency_points, num_band0, relative_grid_address, + triplets, num_triplets, bzgrid, frequencies1, num_band1, frequencies2, + num_band2, tp_type, openmp_per_triplets, openmp_per_bands); + free(bzgrid); + bzgrid = NULL; - return 1; + return 1; } -void ph3py_get_integration_weight_with_sigma(double *iw, - char *iw_zero, - const double sigma, - const double sigma_cutoff, - const double *frequency_points, - const long num_band0, - const long (*triplets)[3], - const long num_triplets, - const double *frequencies, - const long num_band, - const long tp_type) -{ - tpl_get_integration_weight_with_sigma(iw, - iw_zero, - sigma, - sigma_cutoff, - frequency_points, - num_band0, - triplets, - num_triplets, - frequencies, - num_band, - tp_type); +void ph3py_get_integration_weight_with_sigma( + double *iw, char *iw_zero, const double sigma, const double sigma_cutoff, + const double *frequency_points, const long num_band0, + const long (*triplets)[3], const long num_triplets, + const double *frequencies, const long num_band, const long tp_type) { + tpl_get_integration_weight_with_sigma( + iw, iw_zero, sigma, sigma_cutoff, frequency_points, num_band0, triplets, + num_triplets, frequencies, num_band, tp_type); } /* From single address to grid index */ long ph3py_get_grid_index_from_address(const long address[3], - const long D_diag[3]) -{ - return grg_get_grid_index(address, D_diag); + const long D_diag[3]) { + return grg_get_grid_index(address, D_diag); } void ph3py_get_gr_grid_addresses(long gr_grid_addresses[][3], - const long D_diag[3]) -{ - grg_get_all_grid_addresses(gr_grid_addresses, D_diag); + const long D_diag[3]) { + grg_get_all_grid_addresses(gr_grid_addresses, D_diag); } long ph3py_get_reciprocal_rotations(long rec_rotations[48][3][3], const long (*rotations)[3][3], const long num_rot, - const long is_time_reversal) -{ - return grg_get_reciprocal_point_group(rec_rotations, - rotations, - num_rot, - is_time_reversal, - 1); + const long is_time_reversal) { + return grg_get_reciprocal_point_group(rec_rotations, rotations, num_rot, + is_time_reversal, 1); } /* Rotation matrices with respect to reciprocal basis vectors are @@ -737,161 +423,128 @@ long ph3py_get_reciprocal_rotations(long rec_rotations[48][3][3], * used always in GRGrid handling. */ long ph3py_transform_rotations(long (*transformed_rots)[3][3], const long (*rotations)[3][3], - const long num_rot, - const long D_diag[3], - const long Q[3][3]) -{ - return grg_transform_rotations(transformed_rots, - rotations, - num_rot, - D_diag, - Q); + const long num_rot, const long D_diag[3], + const long Q[3][3]) { + return grg_transform_rotations(transformed_rots, rotations, num_rot, D_diag, + Q); } -long ph3py_get_snf3x3(long D_diag[3], - long P[3][3], - long Q[3][3], - const long A[3][3]) -{ - return grg_get_snf3x3(D_diag, P, Q, A); +long ph3py_get_snf3x3(long D_diag[3], long P[3][3], long Q[3][3], + const long A[3][3]) { + return grg_get_snf3x3(D_diag, P, Q, A); } /* The rotations are those after proper transformation in GRGrid. */ -long ph3py_get_ir_grid_map(long *ir_grid_map, - const long D_diag[3], - const long PS[3], - const long (*grg_rotations)[3][3], - const long num_rot) -{ - long num_ir, i; +long ph3py_get_ir_grid_map(long *ir_grid_map, const long D_diag[3], + const long PS[3], const long (*grg_rotations)[3][3], + const long num_rot) { + long num_ir, i; - grg_get_ir_grid_map(ir_grid_map, grg_rotations, num_rot, D_diag, PS); + grg_get_ir_grid_map(ir_grid_map, grg_rotations, num_rot, D_diag, PS); - num_ir = 0; - for (i = 0; i < D_diag[0] * D_diag[1] * D_diag[2]; i++) - { - if (ir_grid_map[i] == i) - { - num_ir++; + num_ir = 0; + for (i = 0; i < D_diag[0] * D_diag[1] * D_diag[2]; i++) { + if (ir_grid_map[i] == i) { + num_ir++; + } } - } - return num_ir; + return num_ir; } -long ph3py_get_bz_grid_addresses(long (*bz_grid_addresses)[3], - long *bz_map, - long *bzg2grg, - const long D_diag[3], - const long Q[3][3], - const long PS[3], +long ph3py_get_bz_grid_addresses(long (*bz_grid_addresses)[3], long *bz_map, + long *bzg2grg, const long D_diag[3], + const long Q[3][3], const long PS[3], const double rec_lattice[3][3], - const long type) -{ - BZGrid *bzgrid; - long i, j, size; + const long type) { + BZGrid *bzgrid; + long i, j, size; - if ((bzgrid = (BZGrid *)malloc(sizeof(BZGrid))) == NULL) - { - warning_print("Memory could not be allocated."); - return 0; - } - - bzgrid->addresses = bz_grid_addresses; - bzgrid->gp_map = bz_map; - bzgrid->bzg2grg = bzg2grg; - bzgrid->type = type; - for (i = 0; i < 3; i++) - { - bzgrid->D_diag[i] = D_diag[i]; - bzgrid->PS[i] = PS[i]; - for (j = 0; j < 3; j++) - { - bzgrid->Q[i][j] = Q[i][j]; - bzgrid->reclat[i][j] = rec_lattice[i][j]; + if ((bzgrid = (BZGrid *)malloc(sizeof(BZGrid))) == NULL) { + warning_print("Memory could not be allocated."); + return 0; } - } - if (bzg_get_bz_grid_addresses(bzgrid)) - { - size = bzgrid->size; - } - else - { - size = 0; - } + bzgrid->addresses = bz_grid_addresses; + bzgrid->gp_map = bz_map; + bzgrid->bzg2grg = bzg2grg; + bzgrid->type = type; + for (i = 0; i < 3; i++) { + bzgrid->D_diag[i] = D_diag[i]; + bzgrid->PS[i] = PS[i]; + for (j = 0; j < 3; j++) { + bzgrid->Q[i][j] = Q[i][j]; + bzgrid->reclat[i][j] = rec_lattice[i][j]; + } + } - free(bzgrid); - bzgrid = NULL; + if (bzg_get_bz_grid_addresses(bzgrid)) { + size = bzgrid->size; + } else { + size = 0; + } - return size; + free(bzgrid); + bzgrid = NULL; + + return size; } long ph3py_rotate_bz_grid_index(const long bz_grid_index, const long rotation[3][3], const long (*bz_grid_addresses)[3], - const long *bz_map, - const long D_diag[3], - const long PS[3], - const long bz_grid_type) -{ - ConstBZGrid *bzgrid; - long i, rot_bz_gp; + const long *bz_map, const long D_diag[3], + const long PS[3], const long bz_grid_type) { + ConstBZGrid *bzgrid; + long i, rot_bz_gp; - if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) - { - warning_print("Memory could not be allocated."); - return 0; - } + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) { + warning_print("Memory could not be allocated."); + return 0; + } - bzgrid->addresses = bz_grid_addresses; - bzgrid->gp_map = bz_map; - bzgrid->type = bz_grid_type; - for (i = 0; i < 3; i++) - { - bzgrid->D_diag[i] = D_diag[i]; - bzgrid->PS[i] = 0; - } + bzgrid->addresses = bz_grid_addresses; + bzgrid->gp_map = bz_map; + bzgrid->type = bz_grid_type; + for (i = 0; i < 3; i++) { + bzgrid->D_diag[i] = D_diag[i]; + bzgrid->PS[i] = 0; + } - rot_bz_gp = bzg_rotate_grid_index(bz_grid_index, rotation, bzgrid); + rot_bz_gp = bzg_rotate_grid_index(bz_grid_index, rotation, bzgrid); - free(bzgrid); - bzgrid = NULL; + free(bzgrid); + bzgrid = NULL; - return rot_bz_gp; + return rot_bz_gp; } void ph3py_symmetrize_collision_matrix(double *collision_matrix, const long num_column, const long num_temp, - const long num_sigma) -{ - double val; - long i, j, k, l, adrs_shift; + const long num_sigma) { + double val; + long i, j, k, l, adrs_shift; - for (i = 0; i < num_sigma; i++) - { - for (j = 0; j < num_temp; j++) - { - adrs_shift = (i * num_column * num_column * num_temp + - j * num_column * num_column); - /* show_colmat_info(py_collision_matrix, i, j, adrs_shift); */ + for (i = 0; i < num_sigma; i++) { + for (j = 0; j < num_temp; j++) { + adrs_shift = (i * num_column * num_column * num_temp + + j * num_column * num_column); + /* show_colmat_info(py_collision_matrix, i, j, adrs_shift); */ #ifdef PHPYOPENMP #pragma omp parallel for schedule(guided) private(l, val) #endif - for (k = 0; k < num_column; k++) - { - for (l = k + 1; l < num_column; l++) - { - val = (collision_matrix[adrs_shift + k * num_column + l] + - collision_matrix[adrs_shift + l * num_column + k]) / - 2; - collision_matrix[adrs_shift + k * num_column + l] = val; - collision_matrix[adrs_shift + l * num_column + k] = val; + for (k = 0; k < num_column; k++) { + for (l = k + 1; l < num_column; l++) { + val = (collision_matrix[adrs_shift + k * num_column + l] + + collision_matrix[adrs_shift + l * num_column + k]) / + 2; + collision_matrix[adrs_shift + k * num_column + l] = val; + collision_matrix[adrs_shift + l * num_column + k] = val; + } + } } - } } - } } void ph3py_expand_collision_matrix(double *collision_matrix, @@ -899,81 +552,76 @@ void ph3py_expand_collision_matrix(double *collision_matrix, const long *ir_grid_points, const long num_ir_gp, const long num_grid_points, - const long num_rot, - const long num_sigma, - const long num_temp, - const long num_band) + const long num_rot, const long num_sigma, + const long num_temp, const long num_band) { - long i, j, k, l, m, n, p, adrs_shift, adrs_shift_plus, ir_gp, gp_r; - long num_column, num_bgb; - long *multi; - double *colmat_copy; + long i, j, k, l, m, n, p, adrs_shift, adrs_shift_plus, ir_gp, gp_r; + long num_column, num_bgb; + long *multi; + double *colmat_copy; - multi = (long *)malloc(sizeof(long) * num_ir_gp); - colmat_copy = NULL; + multi = (long *)malloc(sizeof(long) * num_ir_gp); + colmat_copy = NULL; - num_column = num_grid_points * num_band; - num_bgb = num_band * num_grid_points * num_band; + num_column = num_grid_points * num_band; + num_bgb = num_band * num_grid_points * num_band; #ifdef PHPYOPENMP #pragma omp parallel for schedule(guided) private(j, ir_gp) #endif - for (i = 0; i < num_ir_gp; i++) - { - ir_gp = ir_grid_points[i]; - multi[i] = 0; - for (j = 0; j < num_rot; j++) - { - if (rot_grid_points[j * num_grid_points + ir_gp] == ir_gp) - { - multi[i]++; - } - } - } - - for (i = 0; i < num_sigma; i++) - { - for (j = 0; j < num_temp; j++) - { - adrs_shift = (i * num_column * num_column * num_temp + - j * num_column * num_column); -#ifdef PHPYOPENMP -#pragma omp parallel for private(ir_gp, adrs_shift_plus, colmat_copy, l, gp_r, m, n, p) -#endif - for (k = 0; k < num_ir_gp; k++) - { - ir_gp = ir_grid_points[k]; - adrs_shift_plus = adrs_shift + ir_gp * num_bgb; - colmat_copy = (double *)malloc(sizeof(double) * num_bgb); - for (l = 0; l < num_bgb; l++) - { - colmat_copy[l] = collision_matrix[adrs_shift_plus + l] / multi[k]; - collision_matrix[adrs_shift_plus + l] = 0; - } - for (l = 0; l < num_rot; l++) - { - gp_r = rot_grid_points[l * num_grid_points + ir_gp]; - for (m = 0; m < num_band; m++) - { - for (n = 0; n < num_grid_points; n++) - { - for (p = 0; p < num_band; p++) - { - collision_matrix[adrs_shift + gp_r * num_bgb + m * num_grid_points * num_band + rot_grid_points[l * num_grid_points + n] * num_band + p] += - colmat_copy[m * num_grid_points * num_band + n * num_band + p]; - } + for (i = 0; i < num_ir_gp; i++) { + ir_gp = ir_grid_points[i]; + multi[i] = 0; + for (j = 0; j < num_rot; j++) { + if (rot_grid_points[j * num_grid_points + ir_gp] == ir_gp) { + multi[i]++; } - } } - free(colmat_copy); - colmat_copy = NULL; - } } - } - free(multi); - multi = NULL; + for (i = 0; i < num_sigma; i++) { + for (j = 0; j < num_temp; j++) { + adrs_shift = (i * num_column * num_column * num_temp + + j * num_column * num_column); +#ifdef PHPYOPENMP +#pragma omp parallel for private(ir_gp, adrs_shift_plus, colmat_copy, l, gp_r, \ + m, n, p) +#endif + for (k = 0; k < num_ir_gp; k++) { + ir_gp = ir_grid_points[k]; + adrs_shift_plus = adrs_shift + ir_gp * num_bgb; + colmat_copy = (double *)malloc(sizeof(double) * num_bgb); + for (l = 0; l < num_bgb; l++) { + colmat_copy[l] = + collision_matrix[adrs_shift_plus + l] / multi[k]; + collision_matrix[adrs_shift_plus + l] = 0; + } + for (l = 0; l < num_rot; l++) { + gp_r = rot_grid_points[l * num_grid_points + ir_gp]; + for (m = 0; m < num_band; m++) { + for (n = 0; n < num_grid_points; n++) { + for (p = 0; p < num_band; p++) { + collision_matrix + [adrs_shift + gp_r * num_bgb + + m * num_grid_points * num_band + + rot_grid_points[l * num_grid_points + n] * + num_band + + p] += + colmat_copy[m * num_grid_points * num_band + + n * num_band + p]; + } + } + } + } + free(colmat_copy); + colmat_copy = NULL; + } + } + } + + free(multi); + multi = NULL; } /* tpi_get_neighboring_grid_points around multiple grid points for using openmp @@ -981,49 +629,41 @@ void ph3py_expand_collision_matrix(double *collision_matrix, * relative_grid_addresses are given as P multipled with those from dataset, * i.e., * np.dot(relative_grid_addresses, P.T) */ -long ph3py_get_neighboring_gird_points(long *relative_grid_points, - const long *grid_points, - const long (*relative_grid_address)[3], - const long D_diag[3], - const long (*bz_grid_addresses)[3], - const long *bz_map, - const long bz_grid_type, - const long num_grid_points, - const long num_relative_grid_address) -{ - long i; - ConstBZGrid *bzgrid; +long ph3py_get_neighboring_gird_points( + long *relative_grid_points, const long *grid_points, + const long (*relative_grid_address)[3], const long D_diag[3], + const long (*bz_grid_addresses)[3], const long *bz_map, + const long bz_grid_type, const long num_grid_points, + const long num_relative_grid_address) { + long i; + ConstBZGrid *bzgrid; - if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) - { - warning_print("Memory could not be allocated."); - return 0; - } + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) { + warning_print("Memory could not be allocated."); + return 0; + } - bzgrid->addresses = bz_grid_addresses; - bzgrid->gp_map = bz_map; - bzgrid->type = bz_grid_type; - for (i = 0; i < 3; i++) - { - bzgrid->D_diag[i] = D_diag[i]; - } + bzgrid->addresses = bz_grid_addresses; + bzgrid->gp_map = bz_map; + bzgrid->type = bz_grid_type; + for (i = 0; i < 3; i++) { + bzgrid->D_diag[i] = D_diag[i]; + } #ifdef PHPYOPENMP #pragma omp parallel for #endif - for (i = 0; i < num_grid_points; i++) - { - tpi_get_neighboring_grid_points(relative_grid_points + i * num_relative_grid_address, - grid_points[i], - relative_grid_address, - num_relative_grid_address, - bzgrid); - } + for (i = 0; i < num_grid_points; i++) { + tpi_get_neighboring_grid_points( + relative_grid_points + i * num_relative_grid_address, + grid_points[i], relative_grid_address, num_relative_grid_address, + bzgrid); + } - free(bzgrid); - bzgrid = NULL; + free(bzgrid); + bzgrid = NULL; - return 1; + return 1; } /* thm_get_integration_weight at multiple grid points for using openmp @@ -1032,72 +672,56 @@ long ph3py_get_neighboring_gird_points(long *relative_grid_points, * i.e., * np.dot(relative_grid_addresses, P.T) */ long ph3py_get_thm_integration_weights_at_grid_points( - double *iw, - const double *frequency_points, - const long num_frequency_points, - const long num_band, - const long num_gp, - const long (*relative_grid_address)[4][3], - const long D_diag[3], - const long *grid_points, - const long (*bz_grid_addresses)[3], - const long *bz_map, - const long bz_grid_type, - const double *frequencies, - const long *gp2irgp_map, - const char function) -{ - long i, j, k, bi; - long vertices[24][4]; - double freq_vertices[24][4]; - ConstBZGrid *bzgrid; + double *iw, const double *frequency_points, const long num_frequency_points, + const long num_band, const long num_gp, + const long (*relative_grid_address)[4][3], const long D_diag[3], + const long *grid_points, const long (*bz_grid_addresses)[3], + const long *bz_map, const long bz_grid_type, const double *frequencies, + const long *gp2irgp_map, const char function) { + long i, j, k, bi; + long vertices[24][4]; + double freq_vertices[24][4]; + ConstBZGrid *bzgrid; - if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) - { - warning_print("Memory could not be allocated."); - return 0; - } + if ((bzgrid = (ConstBZGrid *)malloc(sizeof(ConstBZGrid))) == NULL) { + warning_print("Memory could not be allocated."); + return 0; + } - bzgrid->addresses = bz_grid_addresses; - bzgrid->gp_map = bz_map; - bzgrid->type = bz_grid_type; - for (i = 0; i < 3; i++) - { - bzgrid->D_diag[i] = D_diag[i]; - } + bzgrid->addresses = bz_grid_addresses; + bzgrid->gp_map = bz_map; + bzgrid->type = bz_grid_type; + for (i = 0; i < 3; i++) { + bzgrid->D_diag[i] = D_diag[i]; + } #ifdef PHPYOPENMP #pragma omp parallel for private(j, k, bi, vertices, freq_vertices) #endif - for (i = 0; i < num_gp; i++) - { - for (j = 0; j < 24; j++) - { - tpi_get_neighboring_grid_points(vertices[j], - grid_points[i], - relative_grid_address[j], - 4, - bzgrid); - } - for (bi = 0; bi < num_band; bi++) - { - for (j = 0; j < 24; j++) - { - for (k = 0; k < 4; k++) - { - freq_vertices[j][k] = frequencies[gp2irgp_map[vertices[j][k]] * num_band + bi]; + for (i = 0; i < num_gp; i++) { + for (j = 0; j < 24; j++) { + tpi_get_neighboring_grid_points(vertices[j], grid_points[i], + relative_grid_address[j], 4, + bzgrid); + } + for (bi = 0; bi < num_band; bi++) { + for (j = 0; j < 24; j++) { + for (k = 0; k < 4; k++) { + freq_vertices[j][k] = + frequencies[gp2irgp_map[vertices[j][k]] * num_band + + bi]; + } + } + for (j = 0; j < num_frequency_points; j++) { + iw[i * num_frequency_points * num_band + j * num_band + bi] = + thm_get_integration_weight(frequency_points[j], + freq_vertices, function); + } } - } - for (j = 0; j < num_frequency_points; j++) - { - iw[i * num_frequency_points * num_band + j * num_band + bi] = - thm_get_integration_weight(frequency_points[j], freq_vertices, function); - } } - } - free(bzgrid); - bzgrid = NULL; + free(bzgrid); + bzgrid = NULL; - return 1; + return 1; } diff --git a/c/phono3py.h b/c/phono3py.h index fc0e6e2f..da7028c7 100644 --- a/c/phono3py.h +++ b/c/phono3py.h @@ -42,251 +42,130 @@ #endif #include "phonoc_array.h" -long ph3py_get_interaction(Darray *fc3_normal_squared, - const char *g_zero, - const Darray *frequencies, - const lapack_complex_double *eigenvectors, - const long (*triplets)[3], - const long num_triplets, - const long (*bz_grid_addresses)[3], - const long D_diag[3], - const long Q[3][3], - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multi)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const long *band_indices, - const long symmetrize_fc3_q, - const double cutoff_frequency); -long ph3py_get_pp_collision(double *imag_self_energy, - const long relative_grid_address[24][4][3], /* thm */ - const double *frequencies, - const lapack_complex_double *eigenvectors, - const long (*triplets)[3], - const long num_triplets, - const long *triplet_weights, - const long (*bz_grid_addresses)[3], /* thm */ - const long *bz_map, /* thm */ - const long bz_grid_type, - const long D_diag[3], - const long Q[3][3], - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multi)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const Larray *band_indices, - const Darray *temperatures, - const long is_NU, - const long symmetrize_fc3_q, - const double cutoff_frequency); -long ph3py_get_pp_collision_with_sigma( +long ph3py_get_interaction( + Darray *fc3_normal_squared, const char *g_zero, const Darray *frequencies, + const lapack_complex_double *eigenvectors, const long (*triplets)[3], + const long num_triplets, const long (*bz_grid_addresses)[3], + const long D_diag[3], const long Q[3][3], const double *fc3, + const long is_compact_fc3, const double (*svecs)[3], + const long multi_dims[2], const long (*multi)[2], const double *masses, + const long *p2s_map, const long *s2p_map, const long *band_indices, + const long symmetrize_fc3_q, const double cutoff_frequency); +long ph3py_get_pp_collision( double *imag_self_energy, - const double sigma, - const double sigma_cutoff, - const double *frequencies, - const lapack_complex_double *eigenvectors, - const long (*triplets)[3], - const long num_triplets, - const long *triplet_weights, - const long (*bz_grid_addresses)[3], - const long D_diag[3], - const long Q[3][3], - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multi)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const Larray *band_indices, - const Darray *temperatures, - const long is_NU, - const long symmetrize_fc3_q, + const long relative_grid_address[24][4][3], /* thm */ + const double *frequencies, const lapack_complex_double *eigenvectors, + const long (*triplets)[3], const long num_triplets, + const long *triplet_weights, const long (*bz_grid_addresses)[3], /* thm */ + const long *bz_map, /* thm */ + const long bz_grid_type, const long D_diag[3], const long Q[3][3], + const double *fc3, const long is_compact_fc3, const double (*svecs)[3], + const long multi_dims[2], const long (*multi)[2], const double *masses, + const long *p2s_map, const long *s2p_map, const Larray *band_indices, + const Darray *temperatures, const long is_NU, const long symmetrize_fc3_q, + const double cutoff_frequency); +long ph3py_get_pp_collision_with_sigma( + double *imag_self_energy, const double sigma, const double sigma_cutoff, + const double *frequencies, const lapack_complex_double *eigenvectors, + const long (*triplets)[3], const long num_triplets, + const long *triplet_weights, const long (*bz_grid_addresses)[3], + const long D_diag[3], const long Q[3][3], const double *fc3, + const long is_compact_fc3, const double (*svecs)[3], + const long multi_dims[2], const long (*multi)[2], const double *masses, + const long *p2s_map, const long *s2p_map, const Larray *band_indices, + const Darray *temperatures, const long is_NU, const long symmetrize_fc3_q, const double cutoff_frequency); void ph3py_get_imag_self_energy_at_bands_with_g( - double *imag_self_energy, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double *g, - const char *g_zero, - const double temperature, - const double cutoff_frequency, - const long num_frequency_points, - const long frequency_point_index); + double *imag_self_energy, const Darray *fc3_normal_squared, + const double *frequencies, const long (*triplets)[3], + const long *triplet_weights, const double *g, const char *g_zero, + const double temperature, const double cutoff_frequency, + const long num_frequency_points, const long frequency_point_index); void ph3py_get_detailed_imag_self_energy_at_bands_with_g( - double *detailed_imag_self_energy, - double *imag_self_energy_N, - double *imag_self_energy_U, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const long (*bz_grid_addresses)[3], - const double *g, - const char *g_zero, - const double temperature, + double *detailed_imag_self_energy, double *imag_self_energy_N, + double *imag_self_energy_U, const Darray *fc3_normal_squared, + const double *frequencies, const long (*triplets)[3], + const long *triplet_weights, const long (*bz_grid_addresses)[3], + const double *g, const char *g_zero, const double temperature, const double cutoff_frequency); -void ph3py_get_real_self_energy_at_bands(double *real_self_energy, - const Darray *fc3_normal_squared, - const long *band_indices, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double epsilon, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency); +void ph3py_get_real_self_energy_at_bands( + double *real_self_energy, const Darray *fc3_normal_squared, + const long *band_indices, const double *frequencies, + const long (*triplets)[3], const long *triplet_weights, + const double epsilon, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency); void ph3py_get_real_self_energy_at_frequency_point( - double *real_self_energy, - const double frequency_point, - const Darray *fc3_normal_squared, - const long *band_indices, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double epsilon, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency); -void ph3py_get_collision_matrix(double *collision_matrix, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplets_map, - const long *map_q, - const long *rotated_grid_points, - const double *rotations_cartesian, - const double *g, - const long num_ir_gp, - const long num_gp, - const long num_rot, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency); -void ph3py_get_reducible_collision_matrix(double *collision_matrix, - const Darray *fc3_normal_squared, - const double *frequencies, - const long (*triplets)[3], - const long *triplets_map, - const long *map_q, - const double *g, - const long num_gp, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency); + double *real_self_energy, const double frequency_point, + const Darray *fc3_normal_squared, const long *band_indices, + const double *frequencies, const long (*triplets)[3], + const long *triplet_weights, const double epsilon, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency); +void ph3py_get_collision_matrix( + double *collision_matrix, const Darray *fc3_normal_squared, + const double *frequencies, const long (*triplets)[3], + const long *triplets_map, const long *map_q, + const long *rotated_grid_points, const double *rotations_cartesian, + const double *g, const long num_ir_gp, const long num_gp, + const long num_rot, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency); +void ph3py_get_reducible_collision_matrix( + double *collision_matrix, const Darray *fc3_normal_squared, + const double *frequencies, const long (*triplets)[3], + const long *triplets_map, const long *map_q, const double *g, + const long num_gp, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency); void ph3py_get_isotope_scattering_strength( - double *gamma, - const long grid_point, - 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); + double *gamma, const long grid_point, 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 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 *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 *integration_weights, - const double cutoff_frequency); -void ph3py_distribute_fc3(double *fc3, - const long target, - const long source, - const long *atom_mapping, - const long num_atom, + double *gamma, const long grid_point, const long *ir_grid_points, + const long *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 *integration_weights, const double cutoff_frequency); +void ph3py_distribute_fc3(double *fc3, const long target, const long source, + const long *atom_mapping, const long num_atom, const double *rot_cart); void ph3py_rotate_delta_fc2(double (*fc3)[3][3][3], const double (*delta_fc2s)[3][3], const double *inv_U, const double (*site_sym_cart)[3][3], - const long *rot_map_syms, - const long num_atom, - const long num_site_sym, - const long num_disp); + const long *rot_map_syms, const long num_atom, + const long num_site_sym, const long num_disp); void ph3py_get_permutation_symmetry_fc3(double *fc3, const long num_atom); -void ph3py_get_permutation_symmetry_compact_fc3(double *fc3, - const long p2s[], - const long s2pp[], - const long nsym_list[], - const long perms[], - const long n_satom, - const long n_patom); -void ph3py_transpose_compact_fc3(double *fc3, - const long p2s[], - const long s2pp[], - const long nsym_list[], - const long perms[], - const long n_satom, - const long n_patom, - const long t_type); -long ph3py_get_triplets_reciprocal_mesh_at_q(long *map_triplets, - long *map_q, - const long grid_point, - const long mesh[3], - const long is_time_reversal, - const long num_rot, - const long (*rec_rotations)[3][3], - const long swappable); -long ph3py_get_BZ_triplets_at_q(long (*triplets)[3], - const long grid_point, +void ph3py_get_permutation_symmetry_compact_fc3( + double *fc3, const long p2s[], const long s2pp[], const long nsym_list[], + const long perms[], const long n_satom, const long n_patom); +void ph3py_transpose_compact_fc3(double *fc3, const long p2s[], + const long s2pp[], const long nsym_list[], + const long perms[], const long n_satom, + const long n_patom, const long t_type); +long ph3py_get_triplets_reciprocal_mesh_at_q( + long *map_triplets, long *map_q, const long grid_point, const long mesh[3], + const long is_time_reversal, const long num_rot, + const long (*rec_rotations)[3][3], const long swappable); +long ph3py_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point, const long (*bz_grid_addresses)[3], - const long *bz_map, - const long *map_triplets, + const long *bz_map, const long *map_triplets, const long num_map_triplets, - const long D_diag[3], - const long Q[3][3], + const long D_diag[3], const long Q[3][3], const long bz_grid_type); -long ph3py_get_integration_weight(double *iw, - char *iw_zero, - const double *frequency_points, - const long num_band0, - const long relative_grid_address[24][4][3], - const long mesh[3], - const long (*triplets)[3], - const long num_triplets, - const long (*bz_grid_addresses)[3], - const long *bz_map, - const long bz_grid_type, - const double *frequencies1, - const long num_band1, - const double *frequencies2, - const long num_band2, - const long tp_type, - const long openmp_per_triplets, - const long openmp_per_bands); -void ph3py_get_integration_weight_with_sigma(double *iw, - char *iw_zero, - const double sigma, - const double sigma_cutoff, - const double *frequency_points, - const long num_band0, - const long (*triplets)[3], - const long num_triplets, - const double *frequencies, - const long num_band, - const long tp_type); +long ph3py_get_integration_weight( + double *iw, char *iw_zero, const double *frequency_points, + const long num_band0, const long relative_grid_address[24][4][3], + const long mesh[3], const long (*triplets)[3], const long num_triplets, + const long (*bz_grid_addresses)[3], const long *bz_map, + const long bz_grid_type, const double *frequencies1, const long num_band1, + const double *frequencies2, const long num_band2, const long tp_type, + const long openmp_per_triplets, const long openmp_per_bands); +void ph3py_get_integration_weight_with_sigma( + double *iw, char *iw_zero, const double sigma, const double sigma_cutoff, + const double *frequency_points, const long num_band0, + const long (*triplets)[3], const long num_triplets, + const double *frequencies, const long num_band, const long tp_type); long ph3py_get_grid_index_from_address(const long address[3], const long mesh[3]); void ph3py_get_gr_grid_addresses(long gr_grid_addresses[][3], @@ -297,38 +176,27 @@ long ph3py_get_reciprocal_rotations(long rec_rotations[48][3][3], const long is_time_reversal); long ph3py_transform_rotations(long (*transformed_rots)[3][3], const long (*rotations)[3][3], - const long num_rot, - const long D_diag[3], + const long num_rot, const long D_diag[3], const long Q[3][3]); -long ph3py_get_snf3x3(long D_diag[3], - long P[3][3], - long Q[3][3], +long ph3py_get_snf3x3(long D_diag[3], long P[3][3], long Q[3][3], const long A[3][3]); long ph3py_transform_rotations(long (*transformed_rots)[3][3], const long (*rotations)[3][3], - const long num_rot, - const long D_diag[3], + const long num_rot, const long D_diag[3], const long Q[3][3]); -long ph3py_get_ir_grid_map(long *ir_grid_map, - const long D_diag[3], - const long PS[3], - const long (*grg_rotations)[3][3], +long ph3py_get_ir_grid_map(long *ir_grid_map, const long D_diag[3], + const long PS[3], const long (*grg_rotations)[3][3], const long num_rot); -long ph3py_get_bz_grid_addresses(long (*bz_grid_addresses)[3], - long *bz_map, - long *bzg2grg, - const long D_diag[3], - const long Q[3][3], - const long PS[3], +long ph3py_get_bz_grid_addresses(long (*bz_grid_addresses)[3], long *bz_map, + long *bzg2grg, const long D_diag[3], + const long Q[3][3], const long PS[3], const double rec_lattice[3][3], const long type); long ph3py_rotate_bz_grid_index(const long bz_grid_index, const long rotation[3][3], const long (*bz_grid_addresses)[3], - const long *bz_map, - const long D_diag[3], - const long PS[3], - const long bz_grid_type); + const long *bz_map, const long D_diag[3], + const long PS[3], const long bz_grid_type); void ph3py_symmetrize_collision_matrix(double *collision_matrix, const long num_column, const long num_temp, @@ -338,33 +206,20 @@ void ph3py_expand_collision_matrix(double *collision_matrix, const long *ir_grid_points, const long num_ir_gp, const long num_grid_points, - const long num_rot, - const long num_sigma, - const long num_temp, - const long num_band); -long ph3py_get_neighboring_gird_points(long *relative_grid_points, - const long *grid_points, - const long (*relative_grid_address)[3], - const long mesh[3], - const long (*bz_grid_addresses)[3], - const long *bz_map, - const long bz_grid_type, - const long num_grid_points, - const long num_relative_grid_address); + const long num_rot, const long num_sigma, + const long num_temp, const long num_band); +long ph3py_get_neighboring_gird_points( + long *relative_grid_points, const long *grid_points, + const long (*relative_grid_address)[3], const long mesh[3], + const long (*bz_grid_addresses)[3], const long *bz_map, + const long bz_grid_type, const long num_grid_points, + const long num_relative_grid_address); long ph3py_get_thm_integration_weights_at_grid_points( - double *iw, - const double *frequency_points, - const long num_band0, - const long num_band, - const long num_gp, - const long (*relative_grid_address)[4][3], - const long D_diag[3], - const long *grid_points, - const long (*bz_grid_addresses)[3], - const long *bz_map, - const long bz_grid_type, - const double *frequencies, - const long *gp2irgp_map, - const char function); + double *iw, const double *frequency_points, const long num_band0, + const long num_band, const long num_gp, + const long (*relative_grid_address)[4][3], const long D_diag[3], + const long *grid_points, const long (*bz_grid_addresses)[3], + const long *bz_map, const long bz_grid_type, const double *frequencies, + const long *gp2irgp_map, const char function); #endif diff --git a/c/phonoc_array.h b/c/phonoc_array.h index 359987af..193df880 100644 --- a/c/phonoc_array.h +++ b/c/phonoc_array.h @@ -39,13 +39,13 @@ /* It is assumed that number of dimensions is known for each array. */ typedef struct { - long dims[MAX_NUM_DIM]; - long *data; + long dims[MAX_NUM_DIM]; + long *data; } Larray; typedef struct { - int dims[MAX_NUM_DIM]; - double *data; + int dims[MAX_NUM_DIM]; + double *data; } Darray; #endif diff --git a/c/phonoc_utils.c b/c/phonoc_utils.c index 7c101746..f86236bd 100644 --- a/c/phonoc_utils.c +++ b/c/phonoc_utils.c @@ -32,24 +32,23 @@ /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ -#include -#include "phonoc_const.h" #include "phonoc_utils.h" +#include + +#include "phonoc_const.h" + #define THZTOEVPARKB 47.992398658977166 #define INVSQRT2PI 0.3989422804014327 -double phonoc_bose_einstein(const double x, const double t) -{ - return 1.0 / (exp(THZTOEVPARKB * x / t) - 1); +double phonoc_bose_einstein(const double x, const double t) { + return 1.0 / (exp(THZTOEVPARKB * x / t) - 1); } -double phonoc_gaussian(const double x, const double sigma) -{ - return INVSQRT2PI / sigma * exp(-x * x / 2 / sigma / sigma); +double phonoc_gaussian(const double x, const double sigma) { + return INVSQRT2PI / sigma * exp(-x * x / 2 / sigma / sigma); } -double phonoc_inv_sinh_occupation(const double x, const double t) -{ - return 1.0 / sinh(x * THZTOEVPARKB / 2 / t); +double phonoc_inv_sinh_occupation(const double x, const double t) { + return 1.0 / sinh(x * THZTOEVPARKB / 2 / t); } diff --git a/c/phonon.c b/c/phonon.c index 8b51ef16..20f31a6e 100644 --- a/c/phonon.c +++ b/c/phonon.c @@ -32,342 +32,186 @@ /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include -#include "dynmat.h" #include "phonon.h" + +#include +#include +#include + +#include "dynmat.h" #include "lapack_wrapper.h" -static long collect_undone_grid_points(long *undone, - char *phonon_done, +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 long *undone_grid_points, - const long num_undone_grid_points, - const long (*grid_address)[3], - const double QDinv[3][3], - const double *fc2, - const double (*svecs_fc2)[3], - const long (*multi_fc2)[2], - const long num_patom, - const long num_satom, - const double *masses_fc2, - const long *p2s_fc2, - const long *s2p_fc2, - const double unit_conversion_factor, - const double (*born)[3][3], - const double dielectric[3][3], - const double reciprocal_lattice[3][3], - const double *q_direction, - const double nac_factor, - const char uplo); -static void get_gonze_undone_phonons(double *frequencies, - lapack_complex_double *eigenvectors, - const long *undone_grid_points, - const long num_undone_grid_points, - const long (*grid_address)[3], - const double QDinv[3][3], - const double *fc2, - const double (*svecs_fc2)[3], - const long (*multi_fc2)[2], - const double (*positions)[3], - const long num_patom, - const long num_satom, - const double *masses_fc2, - const long *p2s_fc2, - const long *s2p_fc2, - const double unit_conversion_factor, - const double (*born)[3][3], - const double dielectric[3][3], - const double reciprocal_lattice[3][3], - const double *q_direction, - const double nac_factor, - const double *dd_q0, - const double (*G_list)[3], - 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 long *p2s, - const long *s2p, - const long (*multi)[2], - const long num_patom, - const long num_satom, - const double (*svecs)[3], - const long is_nac, - const double (*born)[3][3], +static void get_undone_phonons( + double *frequencies, lapack_complex_double *eigenvectors, + const long *undone_grid_points, const long num_undone_grid_points, + const long (*grid_address)[3], const double QDinv[3][3], const double *fc2, + const double (*svecs_fc2)[3], const long (*multi_fc2)[2], + const long num_patom, const long num_satom, const double *masses_fc2, + const long *p2s_fc2, const long *s2p_fc2, + const double unit_conversion_factor, const double (*born)[3][3], + const double dielectric[3][3], const double reciprocal_lattice[3][3], + const double *q_direction, const double nac_factor, const char uplo); +static void get_gonze_undone_phonons( + double *frequencies, lapack_complex_double *eigenvectors, + const long *undone_grid_points, const long num_undone_grid_points, + const long (*grid_address)[3], const double QDinv[3][3], const double *fc2, + const double (*svecs_fc2)[3], const long (*multi_fc2)[2], + const double (*positions)[3], const long num_patom, const long num_satom, + const double *masses_fc2, const long *p2s_fc2, const long *s2p_fc2, + const double unit_conversion_factor, const double (*born)[3][3], + const double dielectric[3][3], const double reciprocal_lattice[3][3], + const double *q_direction, const double nac_factor, const double *dd_q0, + const double (*G_list)[3], 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 long *p2s, const long *s2p, + const long (*multi)[2], const long num_patom, + const long num_satom, const double (*svecs)[3], + const long is_nac, const double (*born)[3][3], const double dielectric[3][3], const double reciprocal_lattice[3][3], - const double *q_direction, - const double nac_factor, + const double *q_direction, const double nac_factor, const double unit_conversion_factor); -static void get_gonze_phonons(lapack_complex_double *eigvecs, - const double q[3], - const double *fc2, - const double *masses, - const long *p2s, - const long *s2p, - const long (*multi)[2], - const double (*positions)[3], - const long num_patom, - const long num_satom, - const double (*svecs)[3], - const long is_nac, - const double (*born)[3][3], - const double dielectric[3][3], - const double reciprocal_lattice[3][3], - const double *q_direction, - const double nac_factor, - const double *dd_q0, - const double (*G_list)[3], - 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 long *p2s, - const long *s2p, - const long (*multi)[2], - const long num_patom, - const long num_satom, - const double (*svecs)[3], - const long is_nac, - const double (*born)[3][3], /* Wang NAC unless NULL */ - const double dielectric[3][3], - const double reciprocal_lattice[3][3], - const double *q_direction, - const double nac_factor); -static void get_charge_sum(double (*charge_sum)[3][3], - const long num_patom, - const long num_satom, - const double q[3], +static void get_gonze_phonons( + lapack_complex_double *eigvecs, const double q[3], const double *fc2, + const double *masses, const long *p2s, const long *s2p, + const long (*multi)[2], const double (*positions)[3], const long num_patom, + const long num_satom, const double (*svecs)[3], const long is_nac, + const double (*born)[3][3], const double dielectric[3][3], + const double reciprocal_lattice[3][3], const double *q_direction, + const double nac_factor, const double *dd_q0, const double (*G_list)[3], + 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 long *p2s, const long *s2p, + const long (*multi)[2], const long num_patom, const long num_satom, + const double (*svecs)[3], const long is_nac, + const double (*born)[3][3], /* Wang NAC unless NULL */ + const double dielectric[3][3], const double reciprocal_lattice[3][3], + const double *q_direction, const double nac_factor); +static void get_charge_sum(double (*charge_sum)[3][3], const long num_patom, + const long num_satom, const double q[3], const double (*born)[3][3], const double dielectric[3][3], const double reciprocal_lattice[3][3], - const double *q_direction, - const double nac_factor); -static long needs_nac(const double (*born)[3][3], - const long (*grid_address)[3], - const long gp, - const double *q_direction); + const double *q_direction, const double nac_factor); +static long needs_nac(const double (*born)[3][3], const long (*grid_address)[3], + const long gp, const double *q_direction); -void phn_get_phonons_at_gridpoints(double *frequencies, - lapack_complex_double *eigenvectors, - char *phonon_done, - const long num_phonons, - const long *grid_points, - const long num_grid_points, - const long (*grid_address)[3], - const double QDinv[3][3], - const double *fc2, - const double (*svecs_fc2)[3], - const long (*multi_fc2)[2], - const long num_patom, - const long num_satom, - const double *masses_fc2, - const long *p2s_fc2, - const long *s2p_fc2, - const double unit_conversion_factor, - const double (*born)[3][3], - const double dielectric[3][3], - const double reciprocal_lattice[3][3], - const double *q_direction, /* must be pointer */ - const double nac_factor, - const char uplo) -{ - long num_undone; - long *undone; +void phn_get_phonons_at_gridpoints( + double *frequencies, lapack_complex_double *eigenvectors, char *phonon_done, + const long num_phonons, const long *grid_points, const long num_grid_points, + const long (*grid_address)[3], const double QDinv[3][3], const double *fc2, + const double (*svecs_fc2)[3], const long (*multi_fc2)[2], + const long num_patom, const long num_satom, const double *masses_fc2, + const long *p2s_fc2, const long *s2p_fc2, + const double unit_conversion_factor, const double (*born)[3][3], + const double dielectric[3][3], const double reciprocal_lattice[3][3], + const double *q_direction, /* must be pointer */ + const double nac_factor, const char uplo) { + long num_undone; + long *undone; - undone = (long *)malloc(sizeof(long) * num_phonons); - num_undone = collect_undone_grid_points(undone, - phonon_done, - num_grid_points, - grid_points); + undone = (long *)malloc(sizeof(long) * num_phonons); + num_undone = collect_undone_grid_points(undone, phonon_done, + num_grid_points, grid_points); - get_undone_phonons(frequencies, - eigenvectors, - undone, - num_undone, - grid_address, - QDinv, - fc2, - svecs_fc2, - multi_fc2, - num_patom, - num_satom, - masses_fc2, - p2s_fc2, - s2p_fc2, - unit_conversion_factor, - born, - dielectric, - reciprocal_lattice, - q_direction, - nac_factor, - uplo); + get_undone_phonons(frequencies, eigenvectors, undone, num_undone, + grid_address, QDinv, fc2, svecs_fc2, multi_fc2, + num_patom, num_satom, masses_fc2, p2s_fc2, s2p_fc2, + unit_conversion_factor, born, dielectric, + reciprocal_lattice, q_direction, nac_factor, uplo); - free(undone); - undone = NULL; + free(undone); + undone = NULL; } -void phn_get_gonze_phonons_at_gridpoints(double *frequencies, - lapack_complex_double *eigenvectors, - char *phonon_done, - const long num_phonons, - const long *grid_points, - const long num_grid_points, - const long (*grid_address)[3], - const double QDinv[3][3], - const double *fc2, - const double (*svecs_fc2)[3], - const long (*multi_fc2)[2], - const double (*positions)[3], - const long num_patom, - const long num_satom, - const double *masses_fc2, - const long *p2s_fc2, - const long *s2p_fc2, - const double unit_conversion_factor, - const double (*born)[3][3], - const double dielectric[3][3], - const double reciprocal_lattice[3][3], - const double *q_direction, /* pointer */ - const double nac_factor, - const double *dd_q0, - const double (*G_list)[3], - const long num_G_points, - const double lambda, - const char uplo) -{ - long num_undone; - long *undone; +void phn_get_gonze_phonons_at_gridpoints( + double *frequencies, lapack_complex_double *eigenvectors, char *phonon_done, + const long num_phonons, const long *grid_points, const long num_grid_points, + const long (*grid_address)[3], const double QDinv[3][3], const double *fc2, + const double (*svecs_fc2)[3], const long (*multi_fc2)[2], + const double (*positions)[3], const long num_patom, const long num_satom, + const double *masses_fc2, const long *p2s_fc2, const long *s2p_fc2, + const double unit_conversion_factor, const double (*born)[3][3], + const double dielectric[3][3], const double reciprocal_lattice[3][3], + const double *q_direction, /* pointer */ + const double nac_factor, const double *dd_q0, const double (*G_list)[3], + const long num_G_points, const double lambda, const char uplo) { + long num_undone; + long *undone; - undone = (long *)malloc(sizeof(long) * num_phonons); - num_undone = collect_undone_grid_points(undone, - phonon_done, - num_grid_points, - grid_points); + undone = (long *)malloc(sizeof(long) * num_phonons); + num_undone = collect_undone_grid_points(undone, phonon_done, + num_grid_points, grid_points); - get_gonze_undone_phonons(frequencies, - eigenvectors, - undone, - num_undone, - grid_address, - QDinv, - fc2, - svecs_fc2, - multi_fc2, - positions, - num_patom, - num_satom, - masses_fc2, - p2s_fc2, - s2p_fc2, - unit_conversion_factor, - born, - dielectric, - reciprocal_lattice, - q_direction, - nac_factor, - dd_q0, - G_list, - num_G_points, - lambda, - uplo); + get_gonze_undone_phonons( + frequencies, eigenvectors, undone, num_undone, grid_address, QDinv, fc2, + svecs_fc2, multi_fc2, positions, num_patom, num_satom, masses_fc2, + p2s_fc2, s2p_fc2, unit_conversion_factor, born, dielectric, + reciprocal_lattice, q_direction, nac_factor, dd_q0, G_list, + num_G_points, lambda, uplo); - free(undone); - undone = NULL; + free(undone); + undone = NULL; } -static long collect_undone_grid_points(long *undone, - char *phonon_done, +static long collect_undone_grid_points(long *undone, char *phonon_done, const long num_grid_points, - const long *grid_points) -{ - long i, gp, num_undone; + const long *grid_points) { + long i, gp, num_undone; - num_undone = 0; - for (i = 0; i < num_grid_points; i++) - { - gp = grid_points[i]; - if (phonon_done[gp] == 0) - { - undone[num_undone] = gp; - num_undone++; - phonon_done[gp] = 1; + num_undone = 0; + for (i = 0; i < num_grid_points; i++) { + gp = grid_points[i]; + if (phonon_done[gp] == 0) { + undone[num_undone] = gp; + num_undone++; + phonon_done[gp] = 1; + } } - } - return num_undone; + return num_undone; } -static void get_undone_phonons(double *frequencies, - lapack_complex_double *eigenvectors, - const long *undone_grid_points, - const long num_undone_grid_points, - const long (*grid_address)[3], - const double QDinv[3][3], - const double *fc2, - const double (*svecs_fc2)[3], - const long (*multi_fc2)[2], - const long num_patom, - const long num_satom, - const double *masses_fc2, - const long *p2s_fc2, - const long *s2p_fc2, - const double unit_conversion_factor, - const double (*born)[3][3], - const double dielectric[3][3], - const double reciprocal_lattice[3][3], - const double *q_direction, - const double nac_factor, - const char uplo) -{ - long i, j, gp, num_band; - long is_nac, info; - double q[3]; - double *freqs_tmp; +static void get_undone_phonons( + double *frequencies, lapack_complex_double *eigenvectors, + const long *undone_grid_points, const long num_undone_grid_points, + const long (*grid_address)[3], const double QDinv[3][3], const double *fc2, + const double (*svecs_fc2)[3], const long (*multi_fc2)[2], + const long num_patom, const long num_satom, const double *masses_fc2, + const long *p2s_fc2, const long *s2p_fc2, + const double unit_conversion_factor, const double (*born)[3][3], + const double dielectric[3][3], const double reciprocal_lattice[3][3], + const double *q_direction, const double nac_factor, const char uplo) { + long i, j, gp, num_band; + long is_nac, info; + double q[3]; + double *freqs_tmp; - num_band = num_patom * 3; + num_band = num_patom * 3; #ifdef PHPYOPENMP #pragma omp parallel for private(j, q, gp, is_nac) #endif - for (i = 0; i < num_undone_grid_points; i++) - { - gp = undone_grid_points[i]; - for (j = 0; j < 3; j++) - { - q[j] = QDinv[j][0] * grid_address[gp][0] + QDinv[j][1] * grid_address[gp][1] + QDinv[j][2] * grid_address[gp][2]; - } + for (i = 0; i < num_undone_grid_points; i++) { + gp = undone_grid_points[i]; + for (j = 0; j < 3; j++) { + q[j] = QDinv[j][0] * grid_address[gp][0] + + QDinv[j][1] * grid_address[gp][1] + + QDinv[j][2] * grid_address[gp][2]; + } - is_nac = needs_nac(born, grid_address, gp, q_direction); - get_phonons(eigenvectors + num_band * num_band * gp, - q, - fc2, - masses_fc2, - p2s_fc2, - s2p_fc2, - multi_fc2, - num_patom, - num_satom, - svecs_fc2, - is_nac, - born, - dielectric, - reciprocal_lattice, - q_direction, - nac_factor, - unit_conversion_factor); - } + is_nac = needs_nac(born, grid_address, gp, q_direction); + get_phonons(eigenvectors + num_band * num_band * gp, q, fc2, masses_fc2, + p2s_fc2, s2p_fc2, multi_fc2, num_patom, num_satom, + svecs_fc2, is_nac, born, dielectric, reciprocal_lattice, + q_direction, nac_factor, unit_conversion_factor); + } /* To avoid multithreaded BLAS in OpenMP loop */ #ifdef PHPYOPENMP @@ -375,93 +219,59 @@ static void get_undone_phonons(double *frequencies, #pragma omp parallel for private(j, gp, freqs_tmp, info) #endif #endif - for (i = 0; i < num_undone_grid_points; i++) - { - gp = undone_grid_points[i]; - freqs_tmp = frequencies + num_band * gp; - /* Store eigenvalues in freqs array. */ - /* Eigenvectors are overwritten on eigvecs array. */ - info = phonopy_zheev(freqs_tmp, - eigenvectors + num_band * num_band * gp, - num_band, - uplo); + for (i = 0; i < num_undone_grid_points; i++) { + gp = undone_grid_points[i]; + freqs_tmp = frequencies + num_band * gp; + /* Store eigenvalues in freqs array. */ + /* Eigenvectors are overwritten on eigvecs array. */ + info = phonopy_zheev(freqs_tmp, eigenvectors + num_band * num_band * gp, + num_band, uplo); - /* Sqrt of eigenvalues are re-stored in freqs array.*/ - for (j = 0; j < num_band; j++) - { - freqs_tmp[j] = sqrt(fabs(freqs_tmp[j])) * - ((freqs_tmp[j] > 0) - (freqs_tmp[j] < 0)) * unit_conversion_factor; + /* Sqrt of eigenvalues are re-stored in freqs array.*/ + for (j = 0; j < num_band; j++) { + freqs_tmp[j] = sqrt(fabs(freqs_tmp[j])) * + ((freqs_tmp[j] > 0) - (freqs_tmp[j] < 0)) * + unit_conversion_factor; + } } - } } -static void get_gonze_undone_phonons(double *frequencies, - lapack_complex_double *eigenvectors, - const long *undone_grid_points, - const long num_undone_grid_points, - const long (*grid_address)[3], - const double QDinv[3][3], - const double *fc2, - const double (*svecs_fc2)[3], - const long (*multi_fc2)[2], - const double (*positions)[3], - const long num_patom, - const long num_satom, - const double *masses_fc2, - const long *p2s_fc2, - const long *s2p_fc2, - const double unit_conversion_factor, - const double (*born)[3][3], - const double dielectric[3][3], - const double reciprocal_lattice[3][3], - const double *q_direction, - const double nac_factor, - const double *dd_q0, - const double (*G_list)[3], - const long num_G_points, - const double lambda, - const char uplo) -{ - long i, j, gp, num_band; - long is_nac, info; - double q[3]; - double *freqs_tmp; +static void get_gonze_undone_phonons( + double *frequencies, lapack_complex_double *eigenvectors, + const long *undone_grid_points, const long num_undone_grid_points, + const long (*grid_address)[3], const double QDinv[3][3], const double *fc2, + const double (*svecs_fc2)[3], const long (*multi_fc2)[2], + const double (*positions)[3], const long num_patom, const long num_satom, + const double *masses_fc2, const long *p2s_fc2, const long *s2p_fc2, + const double unit_conversion_factor, const double (*born)[3][3], + const double dielectric[3][3], const double reciprocal_lattice[3][3], + const double *q_direction, const double nac_factor, const double *dd_q0, + const double (*G_list)[3], const long num_G_points, const double lambda, + const char uplo) { + long i, j, gp, num_band; + long is_nac, info; + double q[3]; + double *freqs_tmp; - num_band = num_patom * 3; + num_band = num_patom * 3; #ifdef PHPYOPENMP #pragma omp parallel for private(j, q, gp, is_nac) #endif - for (i = 0; i < num_undone_grid_points; i++) - { - gp = undone_grid_points[i]; - for (j = 0; j < 3; j++) - { - q[j] = QDinv[j][0] * grid_address[gp][0] + QDinv[j][1] * grid_address[gp][1] + QDinv[j][2] * grid_address[gp][2]; + for (i = 0; i < num_undone_grid_points; i++) { + gp = undone_grid_points[i]; + for (j = 0; j < 3; j++) { + q[j] = QDinv[j][0] * grid_address[gp][0] + + QDinv[j][1] * grid_address[gp][1] + + QDinv[j][2] * grid_address[gp][2]; + } + is_nac = needs_nac(born, grid_address, gp, q_direction); + get_gonze_phonons(eigenvectors + num_band * num_band * gp, q, fc2, + masses_fc2, p2s_fc2, s2p_fc2, multi_fc2, positions, + num_patom, num_satom, svecs_fc2, is_nac, born, + dielectric, reciprocal_lattice, q_direction, + nac_factor, dd_q0, G_list, num_G_points, lambda); } - is_nac = needs_nac(born, grid_address, gp, q_direction); - get_gonze_phonons(eigenvectors + num_band * num_band * gp, - q, - fc2, - masses_fc2, - p2s_fc2, - s2p_fc2, - multi_fc2, - positions, - num_patom, - num_satom, - svecs_fc2, - is_nac, - born, - dielectric, - reciprocal_lattice, - q_direction, - nac_factor, - dd_q0, - G_list, - num_G_points, - lambda); - } /* To avoid multithreaded BLAS in OpenMP loop */ #ifdef PHPYOPENMP @@ -469,315 +279,192 @@ static void get_gonze_undone_phonons(double *frequencies, #pragma omp parallel for private(j, gp, freqs_tmp, info) #endif #endif - for (i = 0; i < num_undone_grid_points; i++) - { - gp = undone_grid_points[i]; - /* Store eigenvalues in freqs array. */ - /* Eigenvectors are overwritten on eigvecs array. */ - freqs_tmp = frequencies + num_band * gp; - info = phonopy_zheev(freqs_tmp, - eigenvectors + num_band * num_band * gp, - num_band, - uplo); + for (i = 0; i < num_undone_grid_points; i++) { + gp = undone_grid_points[i]; + /* Store eigenvalues in freqs array. */ + /* Eigenvectors are overwritten on eigvecs array. */ + freqs_tmp = frequencies + num_band * gp; + info = phonopy_zheev(freqs_tmp, eigenvectors + num_band * num_band * gp, + num_band, uplo); - /* Sqrt of eigenvalues are re-stored in freqs array.*/ - for (j = 0; j < num_band; j++) - { - freqs_tmp[j] = sqrt(fabs(freqs_tmp[j])) * - ((freqs_tmp[j] > 0) - (freqs_tmp[j] < 0)) * unit_conversion_factor; + /* Sqrt of eigenvalues are re-stored in freqs array.*/ + for (j = 0; j < num_band; j++) { + freqs_tmp[j] = sqrt(fabs(freqs_tmp[j])) * + ((freqs_tmp[j] > 0) - (freqs_tmp[j] < 0)) * + unit_conversion_factor; + } } - } } -static void get_phonons(lapack_complex_double *eigvecs, - const double q[3], - const double *fc2, - const double *masses, - const long *p2s, - const long *s2p, - const long (*multi)[2], - const long num_patom, - const long num_satom, - const double (*svecs)[3], - const long is_nac, - const double (*born)[3][3], +static void get_phonons(lapack_complex_double *eigvecs, const double q[3], + const double *fc2, const double *masses, + const long *p2s, const long *s2p, + const long (*multi)[2], const long num_patom, + const long num_satom, const double (*svecs)[3], + const long is_nac, const double (*born)[3][3], const double dielectric[3][3], const double reciprocal_lattice[3][3], - const double *q_direction, - const double nac_factor, - const double unit_conversion_factor) -{ - /* Store dynamical matrix in eigvecs array. */ - get_dynamical_matrix(eigvecs, - q, - fc2, - masses, - p2s, - s2p, - multi, - num_patom, - num_satom, - svecs, - is_nac, - born, - dielectric, - reciprocal_lattice, - q_direction, - nac_factor); + const double *q_direction, const double nac_factor, + const double unit_conversion_factor) { + /* Store dynamical matrix in eigvecs array. */ + get_dynamical_matrix(eigvecs, q, fc2, masses, p2s, s2p, multi, num_patom, + num_satom, svecs, is_nac, born, dielectric, + reciprocal_lattice, q_direction, nac_factor); } -static void get_gonze_phonons(lapack_complex_double *eigvecs, - const double q[3], - const double *fc2, - const double *masses, - const long *p2s, - const long *s2p, - const long (*multi)[2], - const double (*positions)[3], - const long num_patom, - const long num_satom, - const double (*svecs)[3], - const long is_nac, - const double (*born)[3][3], - const double dielectric[3][3], - const double reciprocal_lattice[3][3], - const double *q_direction, - const double nac_factor, - const double *dd_q0, - const double (*G_list)[3], - const long num_G_points, - const double lambda) -{ - long i, j, k, l, adrs, num_band; - double mm; - double q_cart[3]; - double *q_dir_cart; - lapack_complex_double *dd; +static void get_gonze_phonons( + lapack_complex_double *eigvecs, const double q[3], const double *fc2, + const double *masses, const long *p2s, const long *s2p, + const long (*multi)[2], const double (*positions)[3], const long num_patom, + const long num_satom, const double (*svecs)[3], const long is_nac, + const double (*born)[3][3], const double dielectric[3][3], + const double reciprocal_lattice[3][3], const double *q_direction, + const double nac_factor, const double *dd_q0, const double (*G_list)[3], + const long num_G_points, const double lambda) { + long i, j, k, l, adrs, num_band; + double mm; + double q_cart[3]; + double *q_dir_cart; + lapack_complex_double *dd; - dd = NULL; - q_dir_cart = NULL; - num_band = num_patom * 3; - - dym_get_dynamical_matrix_at_q((double *)eigvecs, - num_patom, - num_satom, - fc2, - q, - svecs, - multi, - masses, - s2p, - p2s, - NULL, - 0); - - dd = (lapack_complex_double *) - malloc(sizeof(lapack_complex_double) * num_band * num_band); - for (i = 0; i < 3; i++) - { - q_cart[i] = 0; - for (j = 0; j < 3; j++) - { - q_cart[i] += reciprocal_lattice[i][j] * q[j]; - } - } - - if (q_direction) - { - q_dir_cart = (double *)malloc(sizeof(double) * 3); - for (i = 0; i < 3; i++) - { - q_dir_cart[i] = 0; - for (j = 0; j < 3; j++) - { - q_dir_cart[i] += reciprocal_lattice[i][j] * q_direction[j]; - } - } - } - - dym_get_recip_dipole_dipole((double *)dd, - dd_q0, - G_list, - num_G_points, - num_patom, - q_cart, - q_dir_cart, - born, - dielectric, - positions, - nac_factor, - lambda, - 1e-5); - - if (q_direction) - { - free(q_dir_cart); + dd = NULL; q_dir_cart = NULL; - } + num_band = num_patom * 3; - for (i = 0; i < num_patom; i++) - { - for (j = 0; j < num_patom; j++) - { - mm = sqrt(masses[i] * masses[j]); - for (k = 0; k < 3; k++) - { - for (l = 0; l < 3; l++) - { - adrs = i * num_patom * 9 + k * num_patom * 3 + j * 3 + l; - eigvecs[adrs] = lapack_make_complex_double( - lapack_complex_double_real(eigvecs[adrs]) + - lapack_complex_double_real(dd[adrs]) / mm, - lapack_complex_double_imag(eigvecs[adrs]) + - lapack_complex_double_imag(dd[adrs]) / mm); + dym_get_dynamical_matrix_at_q((double *)eigvecs, num_patom, num_satom, fc2, + q, svecs, multi, masses, s2p, p2s, NULL, 0); + + dd = (lapack_complex_double *)malloc(sizeof(lapack_complex_double) * + num_band * num_band); + for (i = 0; i < 3; i++) { + q_cart[i] = 0; + for (j = 0; j < 3; j++) { + q_cart[i] += reciprocal_lattice[i][j] * q[j]; } - } } - } - free(dd); - dd = NULL; + if (q_direction) { + q_dir_cart = (double *)malloc(sizeof(double) * 3); + for (i = 0; i < 3; i++) { + q_dir_cart[i] = 0; + for (j = 0; j < 3; j++) { + q_dir_cart[i] += reciprocal_lattice[i][j] * q_direction[j]; + } + } + } + + dym_get_recip_dipole_dipole((double *)dd, dd_q0, G_list, num_G_points, + num_patom, q_cart, q_dir_cart, born, dielectric, + positions, nac_factor, lambda, 1e-5); + + if (q_direction) { + free(q_dir_cart); + q_dir_cart = NULL; + } + + for (i = 0; i < num_patom; i++) { + for (j = 0; j < num_patom; j++) { + mm = sqrt(masses[i] * masses[j]); + for (k = 0; k < 3; k++) { + for (l = 0; l < 3; l++) { + adrs = i * num_patom * 9 + k * num_patom * 3 + j * 3 + l; + eigvecs[adrs] = lapack_make_complex_double( + lapack_complex_double_real(eigvecs[adrs]) + + lapack_complex_double_real(dd[adrs]) / mm, + lapack_complex_double_imag(eigvecs[adrs]) + + lapack_complex_double_imag(dd[adrs]) / mm); + } + } + } + } + + free(dd); + dd = NULL; } -static void -get_dynamical_matrix(lapack_complex_double *dynmat, - const double q[3], - const double *fc2, - const double *masses, - const long *p2s, - const long *s2p, - const long (*multi)[2], - const long num_patom, - const long num_satom, - const double (*svecs)[3], - const long is_nac, - const double (*born)[3][3], /* Wang NAC unless NULL */ - const double dielectric[3][3], - const double reciprocal_lattice[3][3], - const double *q_direction, - const double nac_factor) -{ - double(*charge_sum)[3][3]; +static void get_dynamical_matrix( + lapack_complex_double *dynmat, const double q[3], const double *fc2, + const double *masses, const long *p2s, const long *s2p, + const long (*multi)[2], const long num_patom, const long num_satom, + const double (*svecs)[3], const long is_nac, + const double (*born)[3][3], /* Wang NAC unless NULL */ + const double dielectric[3][3], const double reciprocal_lattice[3][3], + const double *q_direction, const double nac_factor) { + double(*charge_sum)[3][3]; - charge_sum = NULL; - - if (is_nac) - { - charge_sum = (double(*)[3][3]) - malloc(sizeof(double[3][3]) * num_patom * num_patom * 9); - get_charge_sum(charge_sum, - num_patom, - num_satom, - q, - born, - dielectric, - reciprocal_lattice, - q_direction, - nac_factor); - } - - dym_get_dynamical_matrix_at_q((double *)dynmat, - num_patom, - num_satom, - fc2, - q, - svecs, - multi, - masses, - s2p, - p2s, - charge_sum, - 0); - if (is_nac) - { - free(charge_sum); charge_sum = NULL; - } + + if (is_nac) { + charge_sum = (double(*)[3][3])malloc(sizeof(double[3][3]) * num_patom * + num_patom * 9); + get_charge_sum(charge_sum, num_patom, num_satom, q, born, dielectric, + reciprocal_lattice, q_direction, nac_factor); + } + + dym_get_dynamical_matrix_at_q((double *)dynmat, num_patom, num_satom, fc2, + q, svecs, multi, masses, s2p, p2s, charge_sum, + 0); + if (is_nac) { + free(charge_sum); + charge_sum = NULL; + } } -static void get_charge_sum(double (*charge_sum)[3][3], - const long num_patom, - const long num_satom, - const double q[3], +static void get_charge_sum(double (*charge_sum)[3][3], const long num_patom, + const long num_satom, const double q[3], const double (*born)[3][3], const double dielectric[3][3], const double reciprocal_lattice[3][3], - const double *q_direction, - const double nac_factor) -{ - long i, j; - double inv_dielectric_factor, dielectric_factor, tmp_val; - double q_cart[3]; + const double *q_direction, const double nac_factor) { + long i, j; + double inv_dielectric_factor, dielectric_factor, tmp_val; + double q_cart[3]; - if (q_direction) - { - for (i = 0; i < 3; i++) - { - q_cart[i] = 0.0; - for (j = 0; j < 3; j++) - { - q_cart[i] += reciprocal_lattice[i][j] * q_direction[j]; - } + if (q_direction) { + for (i = 0; i < 3; i++) { + q_cart[i] = 0.0; + for (j = 0; j < 3; j++) { + q_cart[i] += reciprocal_lattice[i][j] * q_direction[j]; + } + } + } else { + for (i = 0; i < 3; i++) { + q_cart[i] = 0.0; + for (j = 0; j < 3; j++) { + q_cart[i] += reciprocal_lattice[i][j] * q[j]; + } + } } - } - else - { - for (i = 0; i < 3; i++) - { - q_cart[i] = 0.0; - for (j = 0; j < 3; j++) - { - q_cart[i] += reciprocal_lattice[i][j] * q[j]; - } - } - } - inv_dielectric_factor = 0.0; - for (i = 0; i < 3; i++) - { - tmp_val = 0.0; - for (j = 0; j < 3; j++) - { - tmp_val += dielectric[i][j] * q_cart[j]; + inv_dielectric_factor = 0.0; + for (i = 0; i < 3; i++) { + tmp_val = 0.0; + for (j = 0; j < 3; j++) { + tmp_val += dielectric[i][j] * q_cart[j]; + } + inv_dielectric_factor += tmp_val * q_cart[i]; } - inv_dielectric_factor += tmp_val * q_cart[i]; - } - /* N = num_satom / num_patom = number of prim-cell in supercell */ - /* N is used for Wang's method. */ - dielectric_factor = nac_factor / - inv_dielectric_factor / num_satom * num_patom; - dym_get_charge_sum(charge_sum, - num_patom, - dielectric_factor, - q_cart, - born); + /* N = num_satom / num_patom = number of prim-cell in supercell */ + /* N is used for Wang's method. */ + dielectric_factor = + nac_factor / inv_dielectric_factor / num_satom * num_patom; + dym_get_charge_sum(charge_sum, num_patom, dielectric_factor, q_cart, born); } -static long needs_nac(const double (*born)[3][3], - const long (*grid_address)[3], - const long gp, - const double *q_direction) -{ - long is_nac; +static long needs_nac(const double (*born)[3][3], const long (*grid_address)[3], + const long gp, const double *q_direction) { + long is_nac; - if (born) - { - if (grid_address[gp][0] == 0 && - grid_address[gp][1] == 0 && - grid_address[gp][2] == 0 && - q_direction == NULL) - { - is_nac = 0; + if (born) { + if (grid_address[gp][0] == 0 && grid_address[gp][1] == 0 && + grid_address[gp][2] == 0 && q_direction == NULL) { + is_nac = 0; + } else { + is_nac = 1; + } + } else { + is_nac = 0; } - else - { - is_nac = 1; - } - } - else - { - is_nac = 0; - } - return is_nac; + return is_nac; } diff --git a/c/phonon.h b/c/phonon.h index 1693f253..22ead002 100644 --- a/c/phonon.h +++ b/c/phonon.h @@ -38,55 +38,27 @@ #include "dynmat.h" #include "lapack_wrapper.h" -void phn_get_phonons_at_gridpoints(double *frequencies, - lapack_complex_double *eigenvectors, - char *phonon_done, - const long num_phonons, - const long *grid_points, - const long num_grid_points, - const long (*grid_address)[3], - const double QDinv[3][3], - const double *fc2, - const double (*svecs_fc2)[3], - const long (*multi_fc2)[2], - const long num_patom, - const long num_satom, - const double *masses_fc2, - const long *p2s_fc2, - const long *s2p_fc2, - const double unit_conversion_factor, - const double (*born)[3][3], - const double dielectric[3][3], - const double reciprocal_lattice[3][3], - const double *q_direction, /* must be pointer */ - const double nac_factor, - const char uplo); -void phn_get_gonze_phonons_at_gridpoints(double *frequencies, - lapack_complex_double *eigenvectors, - char *phonon_done, - const long num_phonons, - const long *grid_points, - const long num_grid_points, - const long (*grid_address)[3], - const double QDinv[3][3], - const double *fc2, - const double (*svecs_fc2)[3], - const long (*multi_fc2)[2], - const double (*positions)[3], - const long num_patom, - const long num_satom, - const double *masses_fc2, - const long *p2s_fc2, - const long *s2p_fc2, - const double unit_conversion_factor, - const double (*born)[3][3], - const double dielectric[3][3], - const double reciprocal_lattice[3][3], - const double *q_direction, /* pointer */ - const double nac_factor, - const double *dd_q0, - const double (*G_list)[3], - const long num_G_points, - const double lambda, - const char uplo); +void phn_get_phonons_at_gridpoints( + double *frequencies, lapack_complex_double *eigenvectors, char *phonon_done, + const long num_phonons, const long *grid_points, const long num_grid_points, + const long (*grid_address)[3], const double QDinv[3][3], const double *fc2, + const double (*svecs_fc2)[3], const long (*multi_fc2)[2], + const long num_patom, const long num_satom, const double *masses_fc2, + const long *p2s_fc2, const long *s2p_fc2, + const double unit_conversion_factor, const double (*born)[3][3], + const double dielectric[3][3], const double reciprocal_lattice[3][3], + const double *q_direction, /* must be pointer */ + const double nac_factor, const char uplo); +void phn_get_gonze_phonons_at_gridpoints( + double *frequencies, lapack_complex_double *eigenvectors, char *phonon_done, + const long num_phonons, const long *grid_points, const long num_grid_points, + const long (*grid_address)[3], const double QDinv[3][3], const double *fc2, + const double (*svecs_fc2)[3], const long (*multi_fc2)[2], + const double (*positions)[3], const long num_patom, const long num_satom, + const double *masses_fc2, const long *p2s_fc2, const long *s2p_fc2, + const double unit_conversion_factor, const double (*born)[3][3], + const double dielectric[3][3], const double reciprocal_lattice[3][3], + const double *q_direction, /* pointer */ + const double nac_factor, const double *dd_q0, const double (*G_list)[3], + const long num_G_points, const double lambda, const char uplo); #endif diff --git a/c/phononmod.c b/c/phononmod.c index ccdc5746..5ba9aa13 100644 --- a/c/phononmod.c +++ b/c/phononmod.c @@ -33,93 +33,36 @@ /* POSSIBILITY OF SUCH DAMAGE. */ #include "phononmod.h" + #include "lapack_wrapper.h" #include "phonon.h" -void phmod_get_phonons_at_gridpoints(double *frequencies, - lapack_complex_double *eigenvectors, - char *phonon_done, - const long num_phonons, - const long *grid_points, - const long num_grid_points, - const long (*grid_address)[3], - const double QDinv[3][3], - const double *fc2, - const double (*svecs_fc2)[3], - const long (*multi_fc2)[2], - const double (*positions_fc2)[3], - const long num_patom, - const long num_satom, - const double *masses_fc2, - const long *p2s_fc2, - const long *s2p_fc2, - const double unit_conversion_factor, - const double (*born)[3][3], - const double dielectric[3][3], - const double reciprocal_lattice[3][3], - const double *q_direction, /* pointer */ - const double nac_factor, - const double *dd_q0, - const double (*G_list)[3], - const long num_G_points, - const double lambda, - const char uplo) -{ - if (!dd_q0) - { - phn_get_phonons_at_gridpoints(frequencies, - eigenvectors, - phonon_done, - num_phonons, - grid_points, - num_grid_points, - grid_address, - QDinv, - fc2, - svecs_fc2, - multi_fc2, - num_patom, - num_satom, - masses_fc2, - p2s_fc2, - s2p_fc2, - unit_conversion_factor, - born, - dielectric, - reciprocal_lattice, - q_direction, - nac_factor, - uplo); - } - else - { - phn_get_gonze_phonons_at_gridpoints(frequencies, - eigenvectors, - phonon_done, - num_phonons, - grid_points, - num_grid_points, - grid_address, - QDinv, - fc2, - svecs_fc2, - multi_fc2, - positions_fc2, - num_patom, - num_satom, - masses_fc2, - p2s_fc2, - s2p_fc2, - unit_conversion_factor, - born, - dielectric, - reciprocal_lattice, - q_direction, - nac_factor, - dd_q0, - G_list, - num_G_points, - lambda, - uplo); - } +void phmod_get_phonons_at_gridpoints( + double *frequencies, lapack_complex_double *eigenvectors, char *phonon_done, + const long num_phonons, const long *grid_points, const long num_grid_points, + const long (*grid_address)[3], const double QDinv[3][3], const double *fc2, + const double (*svecs_fc2)[3], const long (*multi_fc2)[2], + const double (*positions_fc2)[3], const long num_patom, + const long num_satom, const double *masses_fc2, const long *p2s_fc2, + const long *s2p_fc2, const double unit_conversion_factor, + const double (*born)[3][3], const double dielectric[3][3], + const double reciprocal_lattice[3][3], + const double *q_direction, /* pointer */ + const double nac_factor, const double *dd_q0, const double (*G_list)[3], + const long num_G_points, const double lambda, const char uplo) { + if (!dd_q0) { + phn_get_phonons_at_gridpoints( + frequencies, eigenvectors, phonon_done, num_phonons, grid_points, + num_grid_points, grid_address, QDinv, fc2, svecs_fc2, multi_fc2, + num_patom, num_satom, masses_fc2, p2s_fc2, s2p_fc2, + unit_conversion_factor, born, dielectric, reciprocal_lattice, + q_direction, nac_factor, uplo); + } else { + phn_get_gonze_phonons_at_gridpoints( + frequencies, eigenvectors, phonon_done, num_phonons, grid_points, + num_grid_points, grid_address, QDinv, fc2, svecs_fc2, multi_fc2, + positions_fc2, num_patom, num_satom, masses_fc2, p2s_fc2, s2p_fc2, + unit_conversion_factor, born, dielectric, reciprocal_lattice, + q_direction, nac_factor, dd_q0, G_list, num_G_points, lambda, uplo); + } } diff --git a/c/phononmod.h b/c/phononmod.h index 82807b8f..4550e7eb 100644 --- a/c/phononmod.h +++ b/c/phononmod.h @@ -37,33 +37,18 @@ #include "lapack_wrapper.h" -void phmod_get_phonons_at_gridpoints(double *frequencies, - lapack_complex_double *eigenvectors, - char *phonon_done, - const long num_phonons, - const long *grid_points, - const long num_grid_points, - const long (*grid_address)[3], - const double QDinv[3][3], - const double *fc2, - const double (*svecs_fc2)[3], - const long (*multi_fc2)[2], - const double (*positions_fc2)[3], - const long num_patom, - const long num_satom, - const double *masses_fc2, - const long *p2s_fc2, - const long *s2p_fc2, - const double unit_conversion_factor, - const double (*born)[3][3], - const double dielectric[3][3], - const double reciprocal_lattice[3][3], - const double *q_direction, /* pointer */ - const double nac_factor, - const double *dd_q0, - const double (*G_list)[3], - const long num_G_points, - const double lambda, - const char uplo); +void phmod_get_phonons_at_gridpoints( + double *frequencies, lapack_complex_double *eigenvectors, char *phonon_done, + const long num_phonons, const long *grid_points, const long num_grid_points, + const long (*grid_address)[3], const double QDinv[3][3], const double *fc2, + const double (*svecs_fc2)[3], const long (*multi_fc2)[2], + const double (*positions_fc2)[3], const long num_patom, + const long num_satom, const double *masses_fc2, const long *p2s_fc2, + const long *s2p_fc2, const double unit_conversion_factor, + const double (*born)[3][3], const double dielectric[3][3], + const double reciprocal_lattice[3][3], + const double *q_direction, /* pointer */ + const double nac_factor, const double *dd_q0, const double (*G_list)[3], + const long num_G_points, const double lambda, const char uplo); #endif diff --git a/c/pp_collision.c b/c/pp_collision.c index 07c63a72..90708742 100644 --- a/c/pp_collision.c +++ b/c/pp_collision.c @@ -32,454 +32,277 @@ /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ +#include "pp_collision.h" + #include #include + #include "imag_self_energy_with_g.h" #include "interaction.h" +#include "lapack_wrapper.h" #include "phonoc_array.h" #include "phonoc_utils.h" -#include "pp_collision.h" #include "triplet.h" #include "triplet_iw.h" -#include "lapack_wrapper.h" -static void get_collision(double *ise, - const long num_band0, - const long num_band, - const long num_temps, - const double *temperatures, - const double *g, - const char *g_zero, - const double *frequencies, - const lapack_complex_double *eigenvectors, - const long triplet[3], - const long triplet_weight, - const ConstBZGrid *bzgrid, - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const long *band_indices, - const long symmetrize_fc3_q, - const double cutoff_frequency, - const long openmp_per_triplets); -static void finalize_ise(double *imag_self_energy, - const double *ise, +static void get_collision( + double *ise, const long num_band0, const long num_band, + const long num_temps, const double *temperatures, const double *g, + const char *g_zero, const double *frequencies, + const lapack_complex_double *eigenvectors, const long triplet[3], + const long triplet_weight, const ConstBZGrid *bzgrid, const double *fc3, + const long is_compact_fc3, const double (*svecs)[3], + const long multi_dims[2], const long (*multiplicity)[2], + const double *masses, const long *p2s_map, const long *s2p_map, + const long *band_indices, const long symmetrize_fc3_q, + const double cutoff_frequency, const long openmp_per_triplets); +static void finalize_ise(double *imag_self_energy, const double *ise, const long (*bz_grid_address)[3], - const long (*triplets)[3], - const long num_triplets, - const long num_temps, - const long num_band0, + const long (*triplets)[3], const long num_triplets, + const long num_temps, const long num_band0, const long is_NU); -void ppc_get_pp_collision(double *imag_self_energy, - const long relative_grid_address[24][4][3], /* thm */ - const double *frequencies, - const lapack_complex_double *eigenvectors, - const long (*triplets)[3], - const long num_triplets, - const long *triplet_weights, - const ConstBZGrid *bzgrid, - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const Larray *band_indices, - const Darray *temperatures, - const long is_NU, - const long symmetrize_fc3_q, - const double cutoff_frequency) -{ - long i; - long num_band, num_band0, num_band_prod, num_temps; - long openmp_per_triplets; - double *ise, *freqs_at_gp, *g; - char *g_zero; - long tp_relative_grid_address[2][24][4][3]; +void ppc_get_pp_collision( + double *imag_self_energy, + const long relative_grid_address[24][4][3], /* thm */ + const double *frequencies, const lapack_complex_double *eigenvectors, + const long (*triplets)[3], const long num_triplets, + const long *triplet_weights, const ConstBZGrid *bzgrid, const double *fc3, + const long is_compact_fc3, const double (*svecs)[3], + const long multi_dims[2], const long (*multiplicity)[2], + const double *masses, const long *p2s_map, const long *s2p_map, + const Larray *band_indices, const Darray *temperatures, const long is_NU, + const long symmetrize_fc3_q, const double cutoff_frequency) { + long i; + long num_band, num_band0, num_band_prod, num_temps; + long openmp_per_triplets; + double *ise, *freqs_at_gp, *g; + char *g_zero; + long tp_relative_grid_address[2][24][4][3]; - ise = NULL; - freqs_at_gp = NULL; - g = NULL; - g_zero = NULL; + ise = NULL; + freqs_at_gp = NULL; + g = NULL; + g_zero = NULL; - num_band0 = band_indices->dims[0]; - num_band = multi_dims[1] * 3; - num_band_prod = num_band0 * num_band * num_band; - num_temps = temperatures->dims[0]; - ise = (double *)malloc(sizeof(double) * num_triplets * num_temps * num_band0); - freqs_at_gp = (double *)malloc(sizeof(double) * num_band0); - for (i = 0; i < num_band0; i++) - { - freqs_at_gp[i] = frequencies[triplets[0][0] * num_band + band_indices->data[i]]; - } + num_band0 = band_indices->dims[0]; + num_band = multi_dims[1] * 3; + num_band_prod = num_band0 * num_band * num_band; + num_temps = temperatures->dims[0]; + ise = + (double *)malloc(sizeof(double) * num_triplets * num_temps * num_band0); + freqs_at_gp = (double *)malloc(sizeof(double) * num_band0); + for (i = 0; i < num_band0; i++) { + freqs_at_gp[i] = + frequencies[triplets[0][0] * num_band + band_indices->data[i]]; + } - if (num_triplets > num_band) - { - openmp_per_triplets = 1; - } - else - { - openmp_per_triplets = 0; - } + if (num_triplets > num_band) { + openmp_per_triplets = 1; + } else { + openmp_per_triplets = 0; + } - tpl_set_relative_grid_address(tp_relative_grid_address, - relative_grid_address, - 2); + tpl_set_relative_grid_address(tp_relative_grid_address, + relative_grid_address, 2); #ifdef PHPYOPENMP -#pragma omp parallel for schedule(guided) private(g, g_zero) if (openmp_per_triplets) +#pragma omp parallel for schedule(guided) private( \ + g, g_zero) if (openmp_per_triplets) #endif - for (i = 0; i < num_triplets; i++) - { - g = (double *)malloc(sizeof(double) * 2 * num_band_prod); - g_zero = (char *)malloc(sizeof(char) * num_band_prod); - tpi_get_integration_weight(g, - g_zero, - freqs_at_gp, /* used as f0 */ - num_band0, - tp_relative_grid_address, - triplets[i], - 1, - bzgrid, - frequencies, /* used as f1 */ - num_band, - frequencies, /* used as f2 */ - num_band, - 2, - 1 - openmp_per_triplets); + for (i = 0; i < num_triplets; i++) { + g = (double *)malloc(sizeof(double) * 2 * num_band_prod); + g_zero = (char *)malloc(sizeof(char) * num_band_prod); + tpi_get_integration_weight(g, g_zero, freqs_at_gp, /* used as f0 */ + num_band0, tp_relative_grid_address, + triplets[i], 1, bzgrid, + frequencies, /* used as f1 */ + num_band, frequencies, /* used as f2 */ + num_band, 2, 1 - openmp_per_triplets); - get_collision(ise + i * num_temps * num_band0, - num_band0, - num_band, - num_temps, - temperatures->data, - g, - g_zero, - frequencies, - eigenvectors, - triplets[i], - triplet_weights[i], - bzgrid, - fc3, - is_compact_fc3, - svecs, - multi_dims, - multiplicity, - masses, - p2s_map, - s2p_map, - band_indices->data, - symmetrize_fc3_q, - cutoff_frequency, - openmp_per_triplets); + get_collision(ise + i * num_temps * num_band0, num_band0, num_band, + num_temps, temperatures->data, g, g_zero, frequencies, + eigenvectors, triplets[i], triplet_weights[i], bzgrid, + fc3, is_compact_fc3, svecs, multi_dims, multiplicity, + masses, p2s_map, s2p_map, band_indices->data, + symmetrize_fc3_q, cutoff_frequency, openmp_per_triplets); - free(g_zero); - g_zero = NULL; - free(g); - g = NULL; - } + free(g_zero); + g_zero = NULL; + free(g); + g = NULL; + } - finalize_ise(imag_self_energy, - ise, - bzgrid->addresses, - triplets, - num_triplets, - num_temps, - num_band0, - is_NU); + finalize_ise(imag_self_energy, ise, bzgrid->addresses, triplets, + num_triplets, num_temps, num_band0, is_NU); - free(freqs_at_gp); - freqs_at_gp = NULL; - free(ise); - ise = NULL; + free(freqs_at_gp); + freqs_at_gp = NULL; + free(ise); + ise = NULL; } void ppc_get_pp_collision_with_sigma( - double *imag_self_energy, - const double sigma, - const double sigma_cutoff, - const double *frequencies, - const lapack_complex_double *eigenvectors, - const long (*triplets)[3], - const long num_triplets, - const long *triplet_weights, - const ConstBZGrid *bzgrid, - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const Larray *band_indices, - const Darray *temperatures, - const long is_NU, - const long symmetrize_fc3_q, - const double cutoff_frequency) -{ - long i; - long num_band, num_band0, num_band_prod, num_temps; - long openmp_per_triplets, const_adrs_shift; - double cutoff; - double *ise, *freqs_at_gp, *g; - char *g_zero; + double *imag_self_energy, const double sigma, const double sigma_cutoff, + const double *frequencies, const lapack_complex_double *eigenvectors, + const long (*triplets)[3], const long num_triplets, + const long *triplet_weights, const ConstBZGrid *bzgrid, const double *fc3, + const long is_compact_fc3, const double (*svecs)[3], + const long multi_dims[2], const long (*multiplicity)[2], + const double *masses, const long *p2s_map, const long *s2p_map, + const Larray *band_indices, const Darray *temperatures, const long is_NU, + const long symmetrize_fc3_q, const double cutoff_frequency) { + long i; + long num_band, num_band0, num_band_prod, num_temps; + long openmp_per_triplets, const_adrs_shift; + double cutoff; + double *ise, *freqs_at_gp, *g; + char *g_zero; - ise = NULL; - freqs_at_gp = NULL; - g = NULL; - g_zero = NULL; + ise = NULL; + freqs_at_gp = NULL; + g = NULL; + g_zero = NULL; - num_band0 = band_indices->dims[0]; - num_band = multi_dims[1] * 3; - num_band_prod = num_band0 * num_band * num_band; - num_temps = temperatures->dims[0]; - const_adrs_shift = num_band_prod; + num_band0 = band_indices->dims[0]; + num_band = multi_dims[1] * 3; + num_band_prod = num_band0 * num_band * num_band; + num_temps = temperatures->dims[0]; + const_adrs_shift = num_band_prod; - ise = (double *)malloc(sizeof(double) * num_triplets * num_temps * num_band0); - freqs_at_gp = (double *)malloc(sizeof(double) * num_band0); - for (i = 0; i < num_band0; i++) - { - freqs_at_gp[i] = frequencies[triplets[0][0] * num_band + - band_indices->data[i]]; - } + ise = + (double *)malloc(sizeof(double) * num_triplets * num_temps * num_band0); + freqs_at_gp = (double *)malloc(sizeof(double) * num_band0); + for (i = 0; i < num_band0; i++) { + freqs_at_gp[i] = + frequencies[triplets[0][0] * num_band + band_indices->data[i]]; + } - if (num_triplets > num_band) - { - openmp_per_triplets = 1; - } - else - { - openmp_per_triplets = 0; - } + if (num_triplets > num_band) { + openmp_per_triplets = 1; + } else { + openmp_per_triplets = 0; + } - cutoff = sigma * sigma_cutoff; + cutoff = sigma * sigma_cutoff; #ifdef PHPYOPENMP -#pragma omp parallel for schedule(guided) private(g, g_zero) if (openmp_per_triplets) +#pragma omp parallel for schedule(guided) private( \ + g, g_zero) if (openmp_per_triplets) #endif - for (i = 0; i < num_triplets; i++) - { - g = (double *)malloc(sizeof(double) * 2 * num_band_prod); - g_zero = (char *)malloc(sizeof(char) * num_band_prod); - tpi_get_integration_weight_with_sigma(g, - g_zero, - sigma, - cutoff, - freqs_at_gp, - num_band0, - triplets[i], - const_adrs_shift, - frequencies, - num_band, - 2, - 0); + for (i = 0; i < num_triplets; i++) { + g = (double *)malloc(sizeof(double) * 2 * num_band_prod); + g_zero = (char *)malloc(sizeof(char) * num_band_prod); + tpi_get_integration_weight_with_sigma( + g, g_zero, sigma, cutoff, freqs_at_gp, num_band0, triplets[i], + const_adrs_shift, frequencies, num_band, 2, 0); - get_collision(ise + i * num_temps * num_band0, - num_band0, - num_band, - num_temps, - temperatures->data, - g, - g_zero, - frequencies, - eigenvectors, - triplets[i], - triplet_weights[i], - bzgrid, - fc3, - is_compact_fc3, - svecs, - multi_dims, - multiplicity, - masses, - p2s_map, - s2p_map, - band_indices->data, - symmetrize_fc3_q, - cutoff_frequency, - openmp_per_triplets); + get_collision(ise + i * num_temps * num_band0, num_band0, num_band, + num_temps, temperatures->data, g, g_zero, frequencies, + eigenvectors, triplets[i], triplet_weights[i], bzgrid, + fc3, is_compact_fc3, svecs, multi_dims, multiplicity, + masses, p2s_map, s2p_map, band_indices->data, + symmetrize_fc3_q, cutoff_frequency, openmp_per_triplets); - free(g_zero); - g_zero = NULL; - free(g); - g = NULL; - } + free(g_zero); + g_zero = NULL; + free(g); + g = NULL; + } - finalize_ise(imag_self_energy, - ise, - bzgrid->addresses, - triplets, - num_triplets, - num_temps, - num_band0, - is_NU); + finalize_ise(imag_self_energy, ise, bzgrid->addresses, triplets, + num_triplets, num_temps, num_band0, is_NU); - free(freqs_at_gp); - freqs_at_gp = NULL; - free(ise); - ise = NULL; + free(freqs_at_gp); + freqs_at_gp = NULL; + free(ise); + ise = NULL; } -static void get_collision(double *ise, - const long num_band0, - const long num_band, - const long num_temps, - const double *temperatures, - const double *g, - const char *g_zero, - const double *frequencies, - const lapack_complex_double *eigenvectors, - const long triplet[3], - const long triplet_weight, - const ConstBZGrid *bzgrid, - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const long *band_indices, - const long symmetrize_fc3_q, - const double cutoff_frequency, - const long openmp_per_triplets) -{ - long i; - long num_band_prod, num_g_pos; - double *fc3_normal_squared; - long(*g_pos)[4]; +static void get_collision( + double *ise, const long num_band0, const long num_band, + const long num_temps, const double *temperatures, const double *g, + const char *g_zero, const double *frequencies, + const lapack_complex_double *eigenvectors, const long triplet[3], + const long triplet_weight, const ConstBZGrid *bzgrid, const double *fc3, + const long is_compact_fc3, const double (*svecs)[3], + const long multi_dims[2], const long (*multiplicity)[2], + const double *masses, const long *p2s_map, const long *s2p_map, + const long *band_indices, const long symmetrize_fc3_q, + const double cutoff_frequency, const long openmp_per_triplets) { + long i; + long num_band_prod, num_g_pos; + double *fc3_normal_squared; + long(*g_pos)[4]; - fc3_normal_squared = NULL; - g_pos = NULL; + fc3_normal_squared = NULL; + g_pos = NULL; - num_band_prod = num_band0 * num_band * num_band; - fc3_normal_squared = (double *)malloc(sizeof(double) * num_band_prod); - g_pos = (long(*)[4])malloc(sizeof(long[4]) * num_band_prod); + num_band_prod = num_band0 * num_band * num_band; + fc3_normal_squared = (double *)malloc(sizeof(double) * num_band_prod); + g_pos = (long(*)[4])malloc(sizeof(long[4]) * num_band_prod); - for (i = 0; i < num_band_prod; i++) - { - fc3_normal_squared[i] = 0; - } + for (i = 0; i < num_band_prod; i++) { + fc3_normal_squared[i] = 0; + } - num_g_pos = ise_set_g_pos(g_pos, - num_band0, - num_band, - g_zero); + num_g_pos = ise_set_g_pos(g_pos, num_band0, num_band, g_zero); - itr_get_interaction_at_triplet( - fc3_normal_squared, - num_band0, - num_band, - g_pos, - num_g_pos, - frequencies, - eigenvectors, - triplet, - bzgrid, - fc3, - is_compact_fc3, - svecs, - multi_dims, - multiplicity, - masses, - p2s_map, - s2p_map, - band_indices, - symmetrize_fc3_q, - cutoff_frequency, - 0, - 0, - 1 - openmp_per_triplets); + itr_get_interaction_at_triplet( + fc3_normal_squared, num_band0, num_band, g_pos, num_g_pos, frequencies, + eigenvectors, triplet, bzgrid, fc3, is_compact_fc3, svecs, multi_dims, + multiplicity, masses, p2s_map, s2p_map, band_indices, symmetrize_fc3_q, + cutoff_frequency, 0, 0, 1 - openmp_per_triplets); - ise_imag_self_energy_at_triplet( - ise, - num_band0, - num_band, - fc3_normal_squared, - frequencies, - triplet, - triplet_weight, - g, - g + num_band_prod, - g_pos, - num_g_pos, - temperatures, - num_temps, - cutoff_frequency, - 1 - openmp_per_triplets, - 0); + ise_imag_self_energy_at_triplet( + ise, num_band0, num_band, fc3_normal_squared, frequencies, triplet, + triplet_weight, g, g + num_band_prod, g_pos, num_g_pos, temperatures, + num_temps, cutoff_frequency, 1 - openmp_per_triplets, 0); - free(fc3_normal_squared); - fc3_normal_squared = NULL; - free(g_pos); - g_pos = NULL; + free(fc3_normal_squared); + fc3_normal_squared = NULL; + free(g_pos); + g_pos = NULL; } -static void finalize_ise(double *imag_self_energy, - const double *ise, +static void finalize_ise(double *imag_self_energy, const double *ise, const long (*bz_grid_addresses)[3], - const long (*triplets)[3], - const long num_triplets, - const long num_temps, - const long num_band0, - const long is_NU) -{ - long i, j, k; - long is_N; + const long (*triplets)[3], const long num_triplets, + const long num_temps, const long num_band0, + const long is_NU) { + long i, j, k; + long is_N; - if (is_NU) - { - for (i = 0; i < 2 * num_temps * num_band0; i++) - { - imag_self_energy[i] = 0; - } - for (i = 0; i < num_triplets; i++) - { - is_N = tpl_is_N(triplets[i], bz_grid_addresses); - for (j = 0; j < num_temps; j++) - { - for (k = 0; k < num_band0; k++) - { - if (is_N) - { - imag_self_energy[j * num_band0 + k] += - ise[i * num_temps * num_band0 + j * num_band0 + k]; - } - else - { - imag_self_energy[num_temps * num_band0 + j * num_band0 + k] += - ise[i * num_temps * num_band0 + j * num_band0 + k]; - } + if (is_NU) { + for (i = 0; i < 2 * num_temps * num_band0; i++) { + imag_self_energy[i] = 0; } - } - } - } - else - { - for (i = 0; i < num_temps * num_band0; i++) - { - imag_self_energy[i] = 0; - } - for (i = 0; i < num_triplets; i++) - { - for (j = 0; j < num_temps; j++) - { - for (k = 0; k < num_band0; k++) - { - imag_self_energy[j * num_band0 + k] += - ise[i * num_temps * num_band0 + j * num_band0 + k]; + for (i = 0; i < num_triplets; i++) { + is_N = tpl_is_N(triplets[i], bz_grid_addresses); + for (j = 0; j < num_temps; j++) { + for (k = 0; k < num_band0; k++) { + if (is_N) { + imag_self_energy[j * num_band0 + k] += + ise[i * num_temps * num_band0 + j * num_band0 + k]; + } else { + imag_self_energy[num_temps * num_band0 + j * num_band0 + + k] += + ise[i * num_temps * num_band0 + j * num_band0 + k]; + } + } + } + } + } else { + for (i = 0; i < num_temps * num_band0; i++) { + imag_self_energy[i] = 0; + } + for (i = 0; i < num_triplets; i++) { + for (j = 0; j < num_temps; j++) { + for (k = 0; k < num_band0; k++) { + imag_self_energy[j * num_band0 + k] += + ise[i * num_temps * num_band0 + j * num_band0 + k]; + } + } } - } } - } } diff --git a/c/pp_collision.h b/c/pp_collision.h index 38ee0f78..c03efdd6 100644 --- a/c/pp_collision.h +++ b/c/pp_collision.h @@ -39,49 +39,26 @@ #include "lapack_wrapper.h" #include "phonoc_array.h" -void ppc_get_pp_collision(double *imag_self_energy, - const long relative_grid_address[24][4][3], /* thm */ - const double *frequencies, - const lapack_complex_double *eigenvectors, - const long (*triplets)[3], - const long num_triplets, - const long *triplet_weights, - const ConstBZGrid *bzgrid, - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const Larray *band_indices, - const Darray *temperatures, - const long is_NU, - const long symmetrize_fc3_q, - const double cutoff_frequency); +void ppc_get_pp_collision( + double *imag_self_energy, + const long relative_grid_address[24][4][3], /* thm */ + const double *frequencies, const lapack_complex_double *eigenvectors, + const long (*triplets)[3], const long num_triplets, + const long *triplet_weights, const ConstBZGrid *bzgrid, const double *fc3, + const long is_compact_fc3, const double (*svecs)[3], + const long multi_dims[2], const long (*multiplicity)[2], + const double *masses, const long *p2s_map, const long *s2p_map, + const Larray *band_indices, const Darray *temperatures, const long is_NU, + const long symmetrize_fc3_q, const double cutoff_frequency); void ppc_get_pp_collision_with_sigma( - double *imag_self_energy, - const double sigma, - const double sigma_cutoff, - const double *frequencies, - const lapack_complex_double *eigenvectors, - const long (*triplets)[3], - const long num_triplets, - const long *triplet_weights, - const ConstBZGrid *bzgrid, - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const double *masses, - const long *p2s_map, - const long *s2p_map, - const Larray *band_indices, - const Darray *temperatures, - const long is_NU, - const long symmetrize_fc3_q, - const double cutoff_frequency); + double *imag_self_energy, const double sigma, const double sigma_cutoff, + const double *frequencies, const lapack_complex_double *eigenvectors, + const long (*triplets)[3], const long num_triplets, + const long *triplet_weights, const ConstBZGrid *bzgrid, const double *fc3, + const long is_compact_fc3, const double (*svecs)[3], + const long multi_dims[2], const long (*multiplicity)[2], + const double *masses, const long *p2s_map, const long *s2p_map, + const Larray *band_indices, const Darray *temperatures, const long is_NU, + const long symmetrize_fc3_q, const double cutoff_frequency); #endif diff --git a/c/real_self_energy.c b/c/real_self_energy.c index eb911e37..e162fa9b 100644 --- a/c/real_self_energy.c +++ b/c/real_self_energy.c @@ -32,263 +32,191 @@ /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ -#include +#include "real_self_energy.h" + #include +#include + #include "phonoc_array.h" #include "phonoc_utils.h" -#include "real_self_energy.h" #include "real_to_reciprocal.h" -static double get_real_self_energy_at_band(const long band_index, - const Darray *fc3_normal_squared, - const double fpoint, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double epsilon, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency); -static double sum_real_self_energy_at_band(const long num_band, - const double *fc3_normal_squared, - const double fpoint, - const double *freqs1, - const double *freqs2, - const double epsilon, - const double temperature, - const double cutoff_frequency); -static double sum_real_self_energy_at_band_0K(const long num_band, - const double *fc3_normal_squared, - const double fpoint, - const double *freqs1, - const double *freqs2, - const double epsilon, - const double cutoff_frequency); +static double get_real_self_energy_at_band( + const long band_index, const Darray *fc3_normal_squared, + const double fpoint, const double *frequencies, const long (*triplets)[3], + const long *triplet_weights, const double epsilon, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency); +static double sum_real_self_energy_at_band( + const long num_band, const double *fc3_normal_squared, const double fpoint, + const double *freqs1, const double *freqs2, const double epsilon, + const double temperature, const double cutoff_frequency); +static double sum_real_self_energy_at_band_0K( + const long num_band, const double *fc3_normal_squared, const double fpoint, + const double *freqs1, const double *freqs2, const double epsilon, + const double cutoff_frequency); -void rse_get_real_self_energy_at_bands(double *real_self_energy, - const Darray *fc3_normal_squared, - const long *band_indices, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double epsilon, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency) -{ - long i, num_band0, num_band, gp0; - double fpoint; +void rse_get_real_self_energy_at_bands( + double *real_self_energy, const Darray *fc3_normal_squared, + const long *band_indices, const double *frequencies, + const long (*triplets)[3], const long *triplet_weights, + const double epsilon, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency) { + long i, num_band0, num_band, gp0; + double fpoint; - num_band0 = fc3_normal_squared->dims[1]; - num_band = fc3_normal_squared->dims[2]; - gp0 = triplets[0][0]; + num_band0 = fc3_normal_squared->dims[1]; + num_band = fc3_normal_squared->dims[2]; + gp0 = triplets[0][0]; - /* num_band0 and num_band_indices have to be same. */ - for (i = 0; i < num_band0; i++) - { - fpoint = frequencies[gp0 * num_band + band_indices[i]]; - if (fpoint < cutoff_frequency) - { - real_self_energy[i] = 0; + /* num_band0 and num_band_indices have to be same. */ + for (i = 0; i < num_band0; i++) { + fpoint = frequencies[gp0 * num_band + band_indices[i]]; + if (fpoint < cutoff_frequency) { + real_self_energy[i] = 0; + } else { + real_self_energy[i] = get_real_self_energy_at_band( + i, fc3_normal_squared, fpoint, frequencies, triplets, + triplet_weights, epsilon, temperature, unit_conversion_factor, + cutoff_frequency); + } } - else - { - real_self_energy[i] = - get_real_self_energy_at_band(i, - fc3_normal_squared, - fpoint, - frequencies, - triplets, - triplet_weights, - epsilon, - temperature, - unit_conversion_factor, - cutoff_frequency); - } - } } void rse_get_real_self_energy_at_frequency_point( - double *real_self_energy, - const double frequency_point, - const Darray *fc3_normal_squared, - const long *band_indices, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double epsilon, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency) -{ - long i, num_band0; + double *real_self_energy, const double frequency_point, + const Darray *fc3_normal_squared, const long *band_indices, + const double *frequencies, const long (*triplets)[3], + const long *triplet_weights, const double epsilon, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency) { + long i, num_band0; - num_band0 = fc3_normal_squared->dims[1]; + num_band0 = fc3_normal_squared->dims[1]; - /* num_band0 and num_band_indices have to be same. */ - for (i = 0; i < num_band0; i++) - { - if (frequency_point < cutoff_frequency) - { - real_self_energy[i] = 0; + /* num_band0 and num_band_indices have to be same. */ + for (i = 0; i < num_band0; i++) { + if (frequency_point < cutoff_frequency) { + real_self_energy[i] = 0; + } else { + real_self_energy[i] = get_real_self_energy_at_band( + i, fc3_normal_squared, frequency_point, frequencies, triplets, + triplet_weights, epsilon, temperature, unit_conversion_factor, + cutoff_frequency); + } } - else - { - real_self_energy[i] = - get_real_self_energy_at_band(i, - fc3_normal_squared, - frequency_point, - frequencies, - triplets, - triplet_weights, - epsilon, - temperature, - unit_conversion_factor, - cutoff_frequency); - } - } } -static double get_real_self_energy_at_band(const long band_index, - const Darray *fc3_normal_squared, - const double fpoint, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double epsilon, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency) -{ - long i, num_triplets, num_band0, num_band, gp1, gp2; - double shift; +static double get_real_self_energy_at_band( + const long band_index, const Darray *fc3_normal_squared, + const double fpoint, const double *frequencies, const long (*triplets)[3], + const long *triplet_weights, const double epsilon, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency) { + long i, num_triplets, num_band0, num_band, gp1, gp2; + double shift; - num_triplets = fc3_normal_squared->dims[0]; - num_band0 = fc3_normal_squared->dims[1]; - num_band = fc3_normal_squared->dims[2]; + num_triplets = fc3_normal_squared->dims[0]; + num_band0 = fc3_normal_squared->dims[1]; + num_band = fc3_normal_squared->dims[2]; - shift = 0; + shift = 0; #ifdef PHPYOPENMP -#pragma omp parallel for private(gp1, gp2) reduction(+ \ - : shift) +#pragma omp parallel for private(gp1, gp2) reduction(+ : shift) #endif - for (i = 0; i < num_triplets; i++) - { - gp1 = triplets[i][1]; - gp2 = triplets[i][2]; - if (temperature > 0) - { - shift += - sum_real_self_energy_at_band(num_band, - fc3_normal_squared->data + - i * num_band0 * num_band * num_band + - band_index * num_band * num_band, - fpoint, - frequencies + gp1 * num_band, - frequencies + gp2 * num_band, - epsilon, - temperature, - cutoff_frequency) * - triplet_weights[i] * unit_conversion_factor; - } - else - { - shift += - sum_real_self_energy_at_band_0K(num_band, - fc3_normal_squared->data + - i * num_band0 * num_band * num_band + - band_index * num_band * num_band, - fpoint, - frequencies + gp1 * num_band, - frequencies + gp2 * num_band, - epsilon, - cutoff_frequency) * - triplet_weights[i] * unit_conversion_factor; - } - } - return shift; -} - -static double sum_real_self_energy_at_band(const long num_band, - const double *fc3_normal_squared, - const double fpoint, - const double *freqs1, - const double *freqs2, - const double epsilon, - const double temperature, - const double cutoff_frequency) -{ - long i, j; - double n1, n2, f1, f2, f3, f4, shift; - /* double sum; */ - - shift = 0; - for (i = 0; i < num_band; i++) - { - if (freqs1[i] > cutoff_frequency) - { - n1 = phonoc_bose_einstein(freqs1[i], temperature); - for (j = 0; j < num_band; j++) - { - if (freqs2[j] > cutoff_frequency) - { - n2 = phonoc_bose_einstein(freqs2[j], temperature); - f1 = fpoint + freqs1[i] + freqs2[j]; - f2 = fpoint - freqs1[i] - freqs2[j]; - f3 = fpoint - freqs1[i] + freqs2[j]; - f4 = fpoint + freqs1[i] - freqs2[j]; - - /* sum = 0; - * if (fabs(f1) > epsilon) { - * sum -= (n1 + n2 + 1) / f1; - * } - * if (fabs(f2) > epsilon) { - * sum += (n1 + n2 + 1) / f2; - * } - * if (fabs(f3) > epsilon) { - * sum -= (n1 - n2) / f3; - * } - * if (fabs(f4) > epsilon) { - * sum += (n1 - n2) / f4; - * } - * shift += sum * fc3_normal_squared[i * num_band + j]; */ - - shift += (-(n1 + n2 + 1) * f1 / (f1 * f1 + epsilon * epsilon) + (n1 + n2 + 1) * f2 / (f2 * f2 + epsilon * epsilon) - (n1 - n2) * f3 / (f3 * f3 + epsilon * epsilon) + (n1 - n2) * f4 / (f4 * f4 + epsilon * epsilon)) * - fc3_normal_squared[i * num_band + j]; + for (i = 0; i < num_triplets; i++) { + gp1 = triplets[i][1]; + gp2 = triplets[i][2]; + if (temperature > 0) { + shift += sum_real_self_energy_at_band( + num_band, + fc3_normal_squared->data + + i * num_band0 * num_band * num_band + + band_index * num_band * num_band, + fpoint, frequencies + gp1 * num_band, + frequencies + gp2 * num_band, epsilon, temperature, + cutoff_frequency) * + triplet_weights[i] * unit_conversion_factor; + } else { + shift += + sum_real_self_energy_at_band_0K( + num_band, + fc3_normal_squared->data + + i * num_band0 * num_band * num_band + + band_index * num_band * num_band, + fpoint, frequencies + gp1 * num_band, + frequencies + gp2 * num_band, epsilon, cutoff_frequency) * + triplet_weights[i] * unit_conversion_factor; } - } } - } - return shift; + return shift; } -static double sum_real_self_energy_at_band_0K(const long num_band, - const double *fc3_normal_squared, - const double fpoint, - const double *freqs1, - const double *freqs2, - const double epsilon, - const double cutoff_frequency) -{ - long i, j; - double f1, f2, shift; +static double sum_real_self_energy_at_band( + const long num_band, const double *fc3_normal_squared, const double fpoint, + const double *freqs1, const double *freqs2, const double epsilon, + const double temperature, const double cutoff_frequency) { + long i, j; + double n1, n2, f1, f2, f3, f4, shift; + /* double sum; */ - shift = 0; - for (i = 0; i < num_band; i++) - { - if (freqs1[i] > cutoff_frequency) - { - for (j = 0; j < num_band; j++) - { - if (freqs2[j] > cutoff_frequency) - { - f1 = fpoint + freqs1[i] + freqs2[j]; - f2 = fpoint - freqs1[i] - freqs2[j]; - shift += (-1 * f1 / (f1 * f1 + epsilon * epsilon) + 1 * f2 / (f2 * f2 + epsilon * epsilon)) * - fc3_normal_squared[i * num_band + j]; + shift = 0; + for (i = 0; i < num_band; i++) { + if (freqs1[i] > cutoff_frequency) { + n1 = phonoc_bose_einstein(freqs1[i], temperature); + for (j = 0; j < num_band; j++) { + if (freqs2[j] > cutoff_frequency) { + n2 = phonoc_bose_einstein(freqs2[j], temperature); + f1 = fpoint + freqs1[i] + freqs2[j]; + f2 = fpoint - freqs1[i] - freqs2[j]; + f3 = fpoint - freqs1[i] + freqs2[j]; + f4 = fpoint + freqs1[i] - freqs2[j]; + + /* sum = 0; + * if (fabs(f1) > epsilon) { + * sum -= (n1 + n2 + 1) / f1; + * } + * if (fabs(f2) > epsilon) { + * sum += (n1 + n2 + 1) / f2; + * } + * if (fabs(f3) > epsilon) { + * sum -= (n1 - n2) / f3; + * } + * if (fabs(f4) > epsilon) { + * sum += (n1 - n2) / f4; + * } + * shift += sum * fc3_normal_squared[i * num_band + j]; */ + + shift += + (-(n1 + n2 + 1) * f1 / (f1 * f1 + epsilon * epsilon) + + (n1 + n2 + 1) * f2 / (f2 * f2 + epsilon * epsilon) - + (n1 - n2) * f3 / (f3 * f3 + epsilon * epsilon) + + (n1 - n2) * f4 / (f4 * f4 + epsilon * epsilon)) * + fc3_normal_squared[i * num_band + j]; + } + } } - } } - } - return shift; + return shift; +} + +static double sum_real_self_energy_at_band_0K( + const long num_band, const double *fc3_normal_squared, const double fpoint, + const double *freqs1, const double *freqs2, const double epsilon, + const double cutoff_frequency) { + long i, j; + double f1, f2, shift; + + shift = 0; + for (i = 0; i < num_band; i++) { + if (freqs1[i] > cutoff_frequency) { + for (j = 0; j < num_band; j++) { + if (freqs2[j] > cutoff_frequency) { + f1 = fpoint + freqs1[i] + freqs2[j]; + f2 = fpoint - freqs1[i] - freqs2[j]; + shift += (-1 * f1 / (f1 * f1 + epsilon * epsilon) + + 1 * f2 / (f2 * f2 + epsilon * epsilon)) * + fc3_normal_squared[i * num_band + j]; + } + } + } + } + return shift; } diff --git a/c/real_self_energy.h b/c/real_self_energy.h index 44b20aef..96c7a587 100644 --- a/c/real_self_energy.h +++ b/c/real_self_energy.h @@ -39,25 +39,15 @@ #endif -void rse_get_real_self_energy_at_bands(double *real_self_energy, - const Darray *fc3_normal_squared, - const long *band_indices, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double epsilon, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency); +void rse_get_real_self_energy_at_bands( + double *real_self_energy, const Darray *fc3_normal_squared, + const long *band_indices, const double *frequencies, + const long (*triplets)[3], const long *triplet_weights, + const double epsilon, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency); void rse_get_real_self_energy_at_frequency_point( - double *real_self_energy, - const double frequency_point, - const Darray *fc3_normal_squared, - const long *band_indices, - const double *frequencies, - const long (*triplets)[3], - const long *triplet_weights, - const double epsilon, - const double temperature, - const double unit_conversion_factor, - const double cutoff_frequency); + double *real_self_energy, const double frequency_point, + const Darray *fc3_normal_squared, const long *band_indices, + const double *frequencies, const long (*triplets)[3], + const long *triplet_weights, const double epsilon, const double temperature, + const double unit_conversion_factor, const double cutoff_frequency); diff --git a/c/real_to_reciprocal.c b/c/real_to_reciprocal.c index ea9322f1..c62c7552 100644 --- a/c/real_to_reciprocal.c +++ b/c/real_to_reciprocal.c @@ -32,337 +32,241 @@ /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ +#include "real_to_reciprocal.h" + #include +#include #include #include -#include + +#include "lapack_wrapper.h" #include "phonoc_array.h" #include "phonoc_const.h" -#include "real_to_reciprocal.h" -#include "lapack_wrapper.h" -static void -real_to_reciprocal_single_thread(lapack_complex_double *fc3_reciprocal, - const double q_vecs[3][3], - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const long *p2s_map, - const long *s2p_map); -static void -real_to_reciprocal_openmp(lapack_complex_double *fc3_reciprocal, - const double q_vecs[3][3], - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const long *p2s_map, - const long *s2p_map); -static void real_to_reciprocal_elements(lapack_complex_double *fc3_rec_elem, - const double q_vecs[3][3], - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const long *p2s, - const long *s2p, - const long pi0, - const long pi1, - const long pi2); +static void real_to_reciprocal_single_thread( + lapack_complex_double *fc3_reciprocal, const double q_vecs[3][3], + const double *fc3, const long is_compact_fc3, const double (*svecs)[3], + const long multi_dims[2], const long (*multiplicity)[2], + const long *p2s_map, const long *s2p_map); +static void real_to_reciprocal_openmp( + lapack_complex_double *fc3_reciprocal, const double q_vecs[3][3], + const double *fc3, const long is_compact_fc3, const double (*svecs)[3], + const long multi_dims[2], const long (*multiplicity)[2], + const long *p2s_map, const long *s2p_map); +static void real_to_reciprocal_elements( + lapack_complex_double *fc3_rec_elem, const double q_vecs[3][3], + const double *fc3, const long is_compact_fc3, const double (*svecs)[3], + const long multi_dims[2], const long (*multiplicity)[2], const long *p2s, + const long *s2p, const long pi0, const long pi1, const long pi2); static lapack_complex_double get_phase_factor(const double q[3][3], const long qi, const double (*svecs)[3], const long multi[2]); -static lapack_complex_double -get_pre_phase_factor(const long i_patom, - const double q_vecs[3][3], - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const long *p2s_map); +static lapack_complex_double get_pre_phase_factor(const long i_patom, + const double q_vecs[3][3], + const double (*svecs)[3], + const long multi_dims[2], + const long (*multiplicity)[2], + const long *p2s_map); /* fc3_reciprocal[num_patom, num_patom, num_patom, 3, 3, 3] */ void r2r_real_to_reciprocal(lapack_complex_double *fc3_reciprocal, - const double q_vecs[3][3], - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], + const double q_vecs[3][3], const double *fc3, + const long is_compact_fc3, const double (*svecs)[3], const long multi_dims[2], - const long (*multiplicity)[2], - const long *p2s_map, - const long *s2p_map, - const long openmp_at_bands) -{ - if (openmp_at_bands) - { - real_to_reciprocal_openmp(fc3_reciprocal, - q_vecs, - fc3, - is_compact_fc3, - svecs, - multi_dims, - multiplicity, - p2s_map, - s2p_map); - } - else - { - real_to_reciprocal_single_thread(fc3_reciprocal, - q_vecs, - fc3, - is_compact_fc3, - svecs, - multi_dims, - multiplicity, - p2s_map, - s2p_map); - } -} - -static void -real_to_reciprocal_single_thread(lapack_complex_double *fc3_reciprocal, - const double q_vecs[3][3], - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const long *p2s_map, - const long *s2p_map) -{ - long i, j, k, l, m, n; - long num_patom, num_band; - lapack_complex_double pre_phase_factor, fc3_rec_elem[27]; - - num_patom = multi_dims[1]; - num_band = num_patom * 3; - - for (i = 0; i < num_patom; i++) - { - pre_phase_factor = get_pre_phase_factor( - i, q_vecs, svecs, multi_dims, multiplicity, p2s_map); - for (j = 0; j < num_patom; j++) - { - for (k = 0; k < num_patom; k++) - { - real_to_reciprocal_elements(fc3_rec_elem, - q_vecs, - fc3, - is_compact_fc3, - svecs, - multi_dims, - multiplicity, - p2s_map, - s2p_map, - i, j, k); - for (l = 0; l < 3; l++) - { - for (m = 0; m < 3; m++) - { - for (n = 0; n < 3; n++) - { - fc3_reciprocal[(i * 3 + l) * num_band * num_band + (j * 3 + m) * num_band + k * 3 + n] = - phonoc_complex_prod(fc3_rec_elem[l * 9 + m * 3 + n], pre_phase_factor); - } - } - } - } + const long (*multiplicity)[2], const long *p2s_map, + const long *s2p_map, const long openmp_at_bands) { + if (openmp_at_bands) { + real_to_reciprocal_openmp(fc3_reciprocal, q_vecs, fc3, is_compact_fc3, + svecs, multi_dims, multiplicity, p2s_map, + s2p_map); + } else { + real_to_reciprocal_single_thread(fc3_reciprocal, q_vecs, fc3, + is_compact_fc3, svecs, multi_dims, + multiplicity, p2s_map, s2p_map); } - } } -static void -real_to_reciprocal_openmp(lapack_complex_double *fc3_reciprocal, - const double q_vecs[3][3], - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const long *p2s_map, - const long *s2p_map) -{ - long i, j, k, l, m, n, jk; - long num_patom, num_band; - lapack_complex_double pre_phase_factor, fc3_rec_elem[27]; +static void real_to_reciprocal_single_thread( + lapack_complex_double *fc3_reciprocal, const double q_vecs[3][3], + const double *fc3, const long is_compact_fc3, const double (*svecs)[3], + const long multi_dims[2], const long (*multiplicity)[2], + const long *p2s_map, const long *s2p_map) { + long i, j, k, l, m, n; + long num_patom, num_band; + lapack_complex_double pre_phase_factor, fc3_rec_elem[27]; - num_patom = multi_dims[1]; - num_band = num_patom * 3; + num_patom = multi_dims[1]; + num_band = num_patom * 3; - for (i = 0; i < num_patom; i++) - { - pre_phase_factor = get_pre_phase_factor( - i, q_vecs, svecs, multi_dims, multiplicity, p2s_map); + for (i = 0; i < num_patom; i++) { + pre_phase_factor = get_pre_phase_factor(i, q_vecs, svecs, multi_dims, + multiplicity, p2s_map); + for (j = 0; j < num_patom; j++) { + for (k = 0; k < num_patom; k++) { + real_to_reciprocal_elements( + fc3_rec_elem, q_vecs, fc3, is_compact_fc3, svecs, + multi_dims, multiplicity, p2s_map, s2p_map, i, j, k); + for (l = 0; l < 3; l++) { + for (m = 0; m < 3; m++) { + for (n = 0; n < 3; n++) { + fc3_reciprocal[(i * 3 + l) * num_band * num_band + + (j * 3 + m) * num_band + k * 3 + n] = + phonoc_complex_prod( + fc3_rec_elem[l * 9 + m * 3 + n], + pre_phase_factor); + } + } + } + } + } + } +} + +static void real_to_reciprocal_openmp( + lapack_complex_double *fc3_reciprocal, const double q_vecs[3][3], + const double *fc3, const long is_compact_fc3, const double (*svecs)[3], + const long multi_dims[2], const long (*multiplicity)[2], + const long *p2s_map, const long *s2p_map) { + long i, j, k, l, m, n, jk; + long num_patom, num_band; + lapack_complex_double pre_phase_factor, fc3_rec_elem[27]; + + num_patom = multi_dims[1]; + num_band = num_patom * 3; + + for (i = 0; i < num_patom; i++) { + pre_phase_factor = get_pre_phase_factor(i, q_vecs, svecs, multi_dims, + multiplicity, p2s_map); #ifdef PHPYOPENMP #pragma omp parallel for private(j, k, l, m, n, fc3_rec_elem) #endif - for (jk = 0; jk < num_patom * num_patom; jk++) - { - j = jk / num_patom; - k = jk % num_patom; - real_to_reciprocal_elements(fc3_rec_elem, - q_vecs, - fc3, - is_compact_fc3, - svecs, - multi_dims, - multiplicity, - p2s_map, - s2p_map, - i, j, k); - for (l = 0; l < 3; l++) - { - for (m = 0; m < 3; m++) - { - for (n = 0; n < 3; n++) - { - fc3_reciprocal[(i * 3 + l) * num_band * num_band + (j * 3 + m) * num_band + k * 3 + n] = - phonoc_complex_prod(fc3_rec_elem[l * 9 + m * 3 + n], pre_phase_factor); - } + for (jk = 0; jk < num_patom * num_patom; jk++) { + j = jk / num_patom; + k = jk % num_patom; + real_to_reciprocal_elements( + fc3_rec_elem, q_vecs, fc3, is_compact_fc3, svecs, multi_dims, + multiplicity, p2s_map, s2p_map, i, j, k); + for (l = 0; l < 3; l++) { + for (m = 0; m < 3; m++) { + for (n = 0; n < 3; n++) { + fc3_reciprocal[(i * 3 + l) * num_band * num_band + + (j * 3 + m) * num_band + k * 3 + n] = + phonoc_complex_prod(fc3_rec_elem[l * 9 + m * 3 + n], + pre_phase_factor); + } + } + } } - } } - } } -static void real_to_reciprocal_elements(lapack_complex_double *fc3_rec_elem, - const double q_vecs[3][3], - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const long *p2s, - const long *s2p, - const long pi0, - const long pi1, - const long pi2) -{ - long i, j, k, l; - long num_satom, adrs_shift, adrs_vec1, adrs_vec2; - lapack_complex_double phase_factor, phase_factor1, phase_factor2; - double fc3_rec_real[27], fc3_rec_imag[27]; +static void real_to_reciprocal_elements( + lapack_complex_double *fc3_rec_elem, const double q_vecs[3][3], + const double *fc3, const long is_compact_fc3, const double (*svecs)[3], + const long multi_dims[2], const long (*multiplicity)[2], const long *p2s, + const long *s2p, const long pi0, const long pi1, const long pi2) { + long i, j, k, l; + long num_satom, adrs_shift, adrs_vec1, adrs_vec2; + lapack_complex_double phase_factor, phase_factor1, phase_factor2; + double fc3_rec_real[27], fc3_rec_imag[27]; - for (i = 0; i < 27; i++) - { - fc3_rec_real[i] = 0; - fc3_rec_imag[i] = 0; - } - - num_satom = multi_dims[0]; - - if (is_compact_fc3) - { - i = pi0; - } - else - { - i = p2s[pi0]; - } - - for (j = 0; j < num_satom; j++) - { - if (s2p[j] != p2s[pi1]) - { - continue; + for (i = 0; i < 27; i++) { + fc3_rec_real[i] = 0; + fc3_rec_imag[i] = 0; } - adrs_vec1 = j * multi_dims[1] + pi0; - phase_factor1 = get_phase_factor(q_vecs, - 1, - svecs, - multiplicity[adrs_vec1]); - for (k = 0; k < num_satom; k++) - { - if (s2p[k] != p2s[pi2]) - { - continue; - } - adrs_vec2 = k * multi_dims[1] + pi0; - phase_factor2 = get_phase_factor(q_vecs, - 2, - svecs, - multiplicity[adrs_vec2]); - adrs_shift = i * 27 * num_satom * num_satom + j * 27 * num_satom + k * 27; - phase_factor = phonoc_complex_prod(phase_factor1, phase_factor2); - for (l = 0; l < 27; l++) - { - fc3_rec_real[l] += - lapack_complex_double_real(phase_factor) * fc3[adrs_shift + l]; - fc3_rec_imag[l] += - lapack_complex_double_imag(phase_factor) * fc3[adrs_shift + l]; - } - } - } + num_satom = multi_dims[0]; - for (i = 0; i < 27; i++) - { - fc3_rec_elem[i] = - lapack_make_complex_double(fc3_rec_real[i], fc3_rec_imag[i]); - } + if (is_compact_fc3) { + i = pi0; + } else { + i = p2s[pi0]; + } + + for (j = 0; j < num_satom; j++) { + if (s2p[j] != p2s[pi1]) { + continue; + } + + adrs_vec1 = j * multi_dims[1] + pi0; + phase_factor1 = + get_phase_factor(q_vecs, 1, svecs, multiplicity[adrs_vec1]); + for (k = 0; k < num_satom; k++) { + if (s2p[k] != p2s[pi2]) { + continue; + } + adrs_vec2 = k * multi_dims[1] + pi0; + phase_factor2 = + get_phase_factor(q_vecs, 2, svecs, multiplicity[adrs_vec2]); + adrs_shift = + i * 27 * num_satom * num_satom + j * 27 * num_satom + k * 27; + phase_factor = phonoc_complex_prod(phase_factor1, phase_factor2); + for (l = 0; l < 27; l++) { + fc3_rec_real[l] += lapack_complex_double_real(phase_factor) * + fc3[adrs_shift + l]; + fc3_rec_imag[l] += lapack_complex_double_imag(phase_factor) * + fc3[adrs_shift + l]; + } + } + } + + for (i = 0; i < 27; i++) { + fc3_rec_elem[i] = + lapack_make_complex_double(fc3_rec_real[i], fc3_rec_imag[i]); + } } -static lapack_complex_double -get_pre_phase_factor(const long i_patom, - const double q_vecs[3][3], - const double (*svecs)[3], - const long multi_dims[2], - const long (*multiplicity)[2], - const long *p2s_map) -{ - long i, j, svecs_adrs; - double pre_phase, sum_real, sum_imag; - lapack_complex_double pre_phase_factor; +static lapack_complex_double get_pre_phase_factor(const long i_patom, + const double q_vecs[3][3], + const double (*svecs)[3], + const long multi_dims[2], + const long (*multiplicity)[2], + const long *p2s_map) { + long i, j, svecs_adrs; + double pre_phase, sum_real, sum_imag; + lapack_complex_double pre_phase_factor; - svecs_adrs = p2s_map[i_patom] * multi_dims[1]; - sum_real = 0; - sum_imag = 0; - for (i = 0; i < multiplicity[svecs_adrs][0]; i++) - { - pre_phase = 0; - for (j = 0; j < 3; j++) - { - pre_phase += svecs[multiplicity[svecs_adrs][1] + i][j] * - (q_vecs[0][j] + q_vecs[1][j] + q_vecs[2][j]); + svecs_adrs = p2s_map[i_patom] * multi_dims[1]; + sum_real = 0; + sum_imag = 0; + for (i = 0; i < multiplicity[svecs_adrs][0]; i++) { + pre_phase = 0; + for (j = 0; j < 3; j++) { + pre_phase += svecs[multiplicity[svecs_adrs][1] + i][j] * + (q_vecs[0][j] + q_vecs[1][j] + q_vecs[2][j]); + } + pre_phase *= M_2PI; + sum_real += cos(pre_phase); + sum_imag += sin(pre_phase); } - pre_phase *= M_2PI; - sum_real += cos(pre_phase); - sum_imag += sin(pre_phase); - } - sum_real /= multiplicity[svecs_adrs][0]; - sum_imag /= multiplicity[svecs_adrs][0]; - pre_phase_factor = lapack_make_complex_double(sum_real, sum_imag); - return pre_phase_factor; + sum_real /= multiplicity[svecs_adrs][0]; + sum_imag /= multiplicity[svecs_adrs][0]; + pre_phase_factor = lapack_make_complex_double(sum_real, sum_imag); + return pre_phase_factor; } static lapack_complex_double get_phase_factor(const double q[3][3], const long qi, const double (*svecs)[3], - const long multi[2]) -{ - long i, j; - double sum_real, sum_imag, phase; + const long multi[2]) { + long i, j; + double sum_real, sum_imag, phase; - sum_real = 0; - sum_imag = 0; - for (i = 0; i < multi[0]; i++) - { - phase = 0; - for (j = 0; j < 3; j++) - { - phase += q[qi][j] * svecs[multi[1] + i][j]; + sum_real = 0; + sum_imag = 0; + for (i = 0; i < multi[0]; i++) { + phase = 0; + for (j = 0; j < 3; j++) { + phase += q[qi][j] * svecs[multi[1] + i][j]; + } + phase *= M_2PI; + sum_real += cos(phase); + sum_imag += sin(phase); } - phase *= M_2PI; - sum_real += cos(phase); - sum_imag += sin(phase); - } - sum_real /= multi[0]; - sum_imag /= multi[0]; + sum_real /= multi[0]; + sum_imag /= multi[0]; - return lapack_make_complex_double(sum_real, sum_imag); + return lapack_make_complex_double(sum_real, sum_imag); } diff --git a/c/real_to_reciprocal.h b/c/real_to_reciprocal.h index b3ae1965..450f5cdf 100644 --- a/c/real_to_reciprocal.h +++ b/c/real_to_reciprocal.h @@ -35,17 +35,13 @@ #ifndef __real_to_reciprocal_H__ #define __real_to_reciprocal_H__ -#include "phonoc_array.h" #include "lapack_wrapper.h" +#include "phonoc_array.h" void r2r_real_to_reciprocal(lapack_complex_double *fc3_reciprocal, - const double q_vecs[3][3], - const double *fc3, - const long is_compact_fc3, - const double (*svecs)[3], + const double q_vecs[3][3], const double *fc3, + const long is_compact_fc3, const double (*svecs)[3], const long multi_dims[2], - const long (*multiplicity)[2], - const long *p2s_map, - const long *s2p_map, - const long openmp_at_bands); + const long (*multiplicity)[2], const long *p2s_map, + const long *s2p_map, const long openmp_at_bands); #endif diff --git a/c/reciprocal_to_normal.c b/c/reciprocal_to_normal.c index 2b38e5e5..2a391225 100644 --- a/c/reciprocal_to_normal.c +++ b/c/reciprocal_to_normal.c @@ -32,14 +32,16 @@ /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ -#include -#include #include "reciprocal_to_normal.h" + +#include +#include + #include "lapack_wrapper.h" #ifdef MEASURE_R2N -#include #include +#include #endif static double get_fc3_sum(const lapack_complex_double *e0, @@ -48,144 +50,125 @@ static double get_fc3_sum(const lapack_complex_double *e0, const lapack_complex_double *fc3_reciprocal, const long num_band); -void reciprocal_to_normal_squared(double *fc3_normal_squared, - const long (*g_pos)[4], - const long num_g_pos, - const lapack_complex_double *fc3_reciprocal, - const double *freqs0, - const double *freqs1, - const double *freqs2, - const lapack_complex_double *eigvecs0, - const lapack_complex_double *eigvecs1, - const lapack_complex_double *eigvecs2, - const double *masses, - const long *band_indices, - const long num_band, - const double cutoff_frequency, - const long openmp_at_bands) -{ - long i, j, k, num_atom; - double real, imag; - double *inv_sqrt_masses; - lapack_complex_double *e0, *e1, *e2; +void reciprocal_to_normal_squared( + double *fc3_normal_squared, const long (*g_pos)[4], const long num_g_pos, + const lapack_complex_double *fc3_reciprocal, const double *freqs0, + const double *freqs1, const double *freqs2, + const lapack_complex_double *eigvecs0, + const lapack_complex_double *eigvecs1, + const lapack_complex_double *eigvecs2, const double *masses, + const long *band_indices, const long num_band, + const double cutoff_frequency, const long openmp_at_bands) { + long i, j, k, num_atom; + double real, imag; + double *inv_sqrt_masses; + lapack_complex_double *e0, *e1, *e2; - /* Transpose eigenvectors for the better data alignment in memory. */ - /* Memory space for three eigenvector matrices is allocated at once */ - /* to make it contiguous. */ - e0 = (lapack_complex_double *) - malloc(sizeof(lapack_complex_double) * 3 * num_band * num_band); - e1 = e0 + num_band * num_band; - e2 = e1 + num_band * num_band; + /* Transpose eigenvectors for the better data alignment in memory. */ + /* Memory space for three eigenvector matrices is allocated at once */ + /* to make it contiguous. */ + e0 = (lapack_complex_double *)malloc(sizeof(lapack_complex_double) * 3 * + num_band * num_band); + e1 = e0 + num_band * num_band; + e2 = e1 + num_band * num_band; - for (i = 0; i < num_band; i++) - { - for (j = 0; j < num_band; j++) - { - e0[j * num_band + i] = eigvecs0[i * num_band + j]; - e1[j * num_band + i] = eigvecs1[i * num_band + j]; - e2[j * num_band + i] = eigvecs2[i * num_band + j]; + for (i = 0; i < num_band; i++) { + for (j = 0; j < num_band; j++) { + e0[j * num_band + i] = eigvecs0[i * num_band + j]; + e1[j * num_band + i] = eigvecs1[i * num_band + j]; + e2[j * num_band + i] = eigvecs2[i * num_band + j]; + } } - } - /* Inverse sqrt mass is multipled with eigenvectors to reduce number of */ - /* operations in get_fc3_sum. Three eigenvector matrices are looped by */ - /* first loop leveraging contiguous memory layout of [e0, e1, e2]. */ - num_atom = num_band / 3; - inv_sqrt_masses = (double *)malloc(sizeof(double) * num_atom); - for (i = 0; i < num_atom; i++) - { - inv_sqrt_masses[i] = 1.0 / sqrt(masses[i]); - } - - for (i = 0; i < 3 * num_band; i++) - { - for (j = 0; j < num_atom; j++) - { - for (k = 0; k < 3; k++) - { - real = lapack_complex_double_real(e0[i * num_band + j * 3 + k]); - imag = lapack_complex_double_imag(e0[i * num_band + j * 3 + k]); - e0[i * num_band + j * 3 + k] = lapack_make_complex_double(real * inv_sqrt_masses[j], imag * inv_sqrt_masses[j]); - } + /* Inverse sqrt mass is multipled with eigenvectors to reduce number of */ + /* operations in get_fc3_sum. Three eigenvector matrices are looped by */ + /* first loop leveraging contiguous memory layout of [e0, e1, e2]. */ + num_atom = num_band / 3; + inv_sqrt_masses = (double *)malloc(sizeof(double) * num_atom); + for (i = 0; i < num_atom; i++) { + inv_sqrt_masses[i] = 1.0 / sqrt(masses[i]); } - } - free(inv_sqrt_masses); - inv_sqrt_masses = NULL; + for (i = 0; i < 3 * num_band; i++) { + for (j = 0; j < num_atom; j++) { + for (k = 0; k < 3; k++) { + real = lapack_complex_double_real(e0[i * num_band + j * 3 + k]); + imag = lapack_complex_double_imag(e0[i * num_band + j * 3 + k]); + e0[i * num_band + j * 3 + k] = lapack_make_complex_double( + real * inv_sqrt_masses[j], imag * inv_sqrt_masses[j]); + } + } + } + + free(inv_sqrt_masses); + inv_sqrt_masses = NULL; #ifdef MEASURE_R2N - double loopTotalCPUTime, - loopTotalWallTime; - time_t loopStartWallTime; - clock_t loopStartCPUTime; + double loopTotalCPUTime, loopTotalWallTime; + time_t loopStartWallTime; + clock_t loopStartCPUTime; #endif #ifdef MEASURE_R2N - loopStartWallTime = time(NULL); - loopStartCPUTime = clock(); + loopStartWallTime = time(NULL); + loopStartCPUTime = clock(); #endif #ifdef PHPYOPENMP #pragma omp parallel for if (openmp_at_bands) #endif - for (i = 0; i < num_g_pos; i++) - { - if (freqs0[band_indices[g_pos[i][0]]] > cutoff_frequency && - freqs1[g_pos[i][1]] > cutoff_frequency && - freqs2[g_pos[i][2]] > cutoff_frequency) - { - fc3_normal_squared[g_pos[i][3]] = - get_fc3_sum(e0 + band_indices[g_pos[i][0]] * num_band, - e1 + g_pos[i][1] * num_band, - e2 + g_pos[i][2] * num_band, - fc3_reciprocal, - num_band) / - (freqs0[band_indices[g_pos[i][0]]] * freqs1[g_pos[i][1]] * freqs2[g_pos[i][2]]); + for (i = 0; i < num_g_pos; i++) { + if (freqs0[band_indices[g_pos[i][0]]] > cutoff_frequency && + freqs1[g_pos[i][1]] > cutoff_frequency && + freqs2[g_pos[i][2]] > cutoff_frequency) { + fc3_normal_squared[g_pos[i][3]] = + get_fc3_sum(e0 + band_indices[g_pos[i][0]] * num_band, + e1 + g_pos[i][1] * num_band, + e2 + g_pos[i][2] * num_band, fc3_reciprocal, + num_band) / + (freqs0[band_indices[g_pos[i][0]]] * freqs1[g_pos[i][1]] * + freqs2[g_pos[i][2]]); + } else { + fc3_normal_squared[g_pos[i][3]] = 0; + } } - else - { - fc3_normal_squared[g_pos[i][3]] = 0; - } - } #ifdef MEASURE_R2N - loopTotalCPUTime = (double)(clock() - loopStartCPUTime) / CLOCKS_PER_SEC; - loopTotalWallTime = difftime(time(NULL), loopStartWallTime); - printf(" %1.3fs (%1.3fs CPU)\n", loopTotalWallTime, loopTotalCPUTime); + loopTotalCPUTime = (double)(clock() - loopStartCPUTime) / CLOCKS_PER_SEC; + loopTotalWallTime = difftime(time(NULL), loopStartWallTime); + printf(" %1.3fs (%1.3fs CPU)\n", loopTotalWallTime, loopTotalCPUTime); #endif - free(e0); - e0 = NULL; - e1 = NULL; - e2 = NULL; + free(e0); + e0 = NULL; + e1 = NULL; + e2 = NULL; } static double get_fc3_sum(const lapack_complex_double *e0, const lapack_complex_double *e1, const lapack_complex_double *e2, const lapack_complex_double *fc3_reciprocal, - const long num_band) -{ - long i, j, k; - double sum_real, sum_imag; - lapack_complex_double e_01, e_012, e_012_fc3; + const long num_band) { + long i, j, k; + double sum_real, sum_imag; + lapack_complex_double e_01, e_012, e_012_fc3; - sum_real = 0; - sum_imag = 0; + sum_real = 0; + sum_imag = 0; - for (i = 0; i < num_band; i++) - { - for (j = 0; j < num_band; j++) - { - e_01 = phonoc_complex_prod(e0[i], e1[j]); - for (k = 0; k < num_band; k++) - { - e_012 = phonoc_complex_prod(e_01, e2[k]); - e_012_fc3 = phonoc_complex_prod(e_012, fc3_reciprocal[i * num_band * num_band + j * num_band + k]); - sum_real += lapack_complex_double_real(e_012_fc3); - sum_imag += lapack_complex_double_imag(e_012_fc3); - } + for (i = 0; i < num_band; i++) { + for (j = 0; j < num_band; j++) { + e_01 = phonoc_complex_prod(e0[i], e1[j]); + for (k = 0; k < num_band; k++) { + e_012 = phonoc_complex_prod(e_01, e2[k]); + e_012_fc3 = phonoc_complex_prod( + e_012, + fc3_reciprocal[i * num_band * num_band + j * num_band + k]); + sum_real += lapack_complex_double_real(e_012_fc3); + sum_imag += lapack_complex_double_imag(e_012_fc3); + } + } } - } - return (sum_real * sum_real + sum_imag * sum_imag); + return (sum_real * sum_real + sum_imag * sum_imag); } diff --git a/c/reciprocal_to_normal.h b/c/reciprocal_to_normal.h index 3b2f9aef..22bfa070 100644 --- a/c/reciprocal_to_normal.h +++ b/c/reciprocal_to_normal.h @@ -37,20 +37,14 @@ #include "lapack_wrapper.h" -void reciprocal_to_normal_squared(double *fc3_normal_squared, - const long (*g_pos)[4], - const long num_g_pos, - const lapack_complex_double *fc3_reciprocal, - const double *freqs0, - const double *freqs1, - const double *freqs2, - const lapack_complex_double *eigvecs0, - const lapack_complex_double *eigvecs1, - const lapack_complex_double *eigvecs2, - const double *masses, - const long *band_indices, - const long num_band, - const double cutoff_frequency, - const long openmp_at_bands); +void reciprocal_to_normal_squared( + double *fc3_normal_squared, const long (*g_pos)[4], const long num_g_pos, + const lapack_complex_double *fc3_reciprocal, const double *freqs0, + const double *freqs1, const double *freqs2, + const lapack_complex_double *eigvecs0, + const lapack_complex_double *eigvecs1, + const lapack_complex_double *eigvecs2, const double *masses, + const long *band_indices, const long num_band, + const double cutoff_frequency, const long openmp_at_bands); #endif diff --git a/c/snf3x3.c b/c/snf3x3.c index c39534d1..5e8c079f 100644 --- a/c/snf3x3.c +++ b/c/snf3x3.c @@ -20,21 +20,21 @@ static void zero_second_column(long L[3][3], SNF3x3CONST long A[3][3]); static void second_finalize(long L[3][3], SNF3x3CONST long A[3][3]); static void finalize(long A[3][3], long P[3][3], long Q[3][3]); static void finalize_sort(long A[3][3], long P[3][3], long Q[3][3]); -static void finalize_disturb(long A[3][3], long Q[3][3], const int i, const int j); +static void finalize_disturb(long A[3][3], long Q[3][3], const int i, + const int j); static void disturb_rows(long L[3][3], const int i, const int j); -static void swap_diag_elems(long A[3][3], long P[3][3], long Q[3][3], const int i, const int j); +static void swap_diag_elems(long A[3][3], long P[3][3], long Q[3][3], + const int i, const int j); static void make_diagA_positive(long A[3][3], long P[3][3]); static void flip_PQ(long P[3][3], long Q[3][3]); static void swap_rows(long L[3][3], const int i, const int j); -static void set_zero(long L[3][3], - const int i, const int j, const long a, const long b, - const long r, const long s, const long t); +static void set_zero(long L[3][3], const int i, const int j, const long a, + const long b, const long r, const long s, const long t); static void extended_gcd(long retvals[3], const long a, const long b); static void extended_gcd_step(long vals[6]); static void flip_sign_row(long L[3][3], const int i); static void transpose(long m[3][3]); -static void matmul(long m[3][3], - SNF3x3CONST long a[3][3], +static void matmul(long m[3][3], SNF3x3CONST long a[3][3], SNF3x3CONST long b[3][3]); static long det(SNF3x3CONST long m[3][3]); @@ -51,487 +51,421 @@ static long det(SNF3x3CONST long m[3][3]); * static void test_second_one_loop(void); * static void test_second(void); */ -int snf3x3(long A[3][3], long P[3][3], long Q[3][3]) -{ - int i; - initialize_PQ(P, Q); +int snf3x3(long A[3][3], long P[3][3], long Q[3][3]) { + int i; + initialize_PQ(P, Q); - for (i = 0; i < 100; i++) - { - if (first(A, P, Q)) - { - if (second(A, P, Q)) - { - finalize(A, P, Q); - transpose(Q); - goto succeeded; - } + for (i = 0; i < 100; i++) { + if (first(A, P, Q)) { + if (second(A, P, Q)) { + finalize(A, P, Q); + transpose(Q); + goto succeeded; + } + } } - } - return 0; + return 0; succeeded: - return 1; + return 1; } -static void initialize_PQ(long P[3][3], long Q[3][3]) -{ - int i, j; +static void initialize_PQ(long P[3][3], long Q[3][3]) { + int i, j; - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - if (i == j) - { - P[i][j] = 1; - Q[i][j] = 1; - } - else - { - P[i][j] = 0; - Q[i][j] = 0; - } + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + if (i == j) { + P[i][j] = 1; + Q[i][j] = 1; + } else { + P[i][j] = 0; + Q[i][j] = 0; + } + } } - } } -static int first(long A[3][3], long P[3][3], long Q[3][3]) -{ - long L[3][3]; +static int first(long A[3][3], long P[3][3], long Q[3][3]) { + long L[3][3]; - first_one_loop(A, P, Q); + first_one_loop(A, P, Q); - /* rows and columns are all zero except for the pivot */ - if ((A[1][0] == 0) && (A[2][0] == 0)) - { - return 1; - } + /* rows and columns are all zero except for the pivot */ + if ((A[1][0] == 0) && (A[2][0] == 0)) { + return 1; + } - /* columns of the pivot are assumed zero because of first_one_loop. */ - /* rows of the pivot are non-zero, but divisible by the pivot. */ - /* first_finalize makes the rows be zero. */ - if ((A[1][0] % A[0][0] == 0) && (A[2][0] % A[0][0] == 0)) - { - first_finalize(L, A); - matmul(A, L, A); - matmul(P, L, P); - return 1; - } - return 0; + /* columns of the pivot are assumed zero because of first_one_loop. */ + /* rows of the pivot are non-zero, but divisible by the pivot. */ + /* first_finalize makes the rows be zero. */ + if ((A[1][0] % A[0][0] == 0) && (A[2][0] % A[0][0] == 0)) { + first_finalize(L, A); + matmul(A, L, A); + matmul(P, L, P); + return 1; + } + return 0; } -static void first_one_loop(long A[3][3], long P[3][3], long Q[3][3]) -{ - first_column(A, P); - transpose(A); - first_column(A, Q); - transpose(A); +static void first_one_loop(long A[3][3], long P[3][3], long Q[3][3]) { + first_column(A, P); + transpose(A); + first_column(A, Q); + transpose(A); } -static void first_column(long A[3][3], long P[3][3]) -{ - int i; - long L[3][3]; +static void first_column(long A[3][3], long P[3][3]) { + int i; + long L[3][3]; - i = search_first_pivot(A); - if (i > 0) - { - swap_rows(L, 0, i); - matmul(A, L, A); - matmul(P, L, P); - } - if (i < 0) - { - goto err; - } + i = search_first_pivot(A); + if (i > 0) { + swap_rows(L, 0, i); + matmul(A, L, A); + matmul(P, L, P); + } + if (i < 0) { + goto err; + } - if (A[1][0] != 0) - { - zero_first_column(L, 1, A); - matmul(A, L, A); - matmul(P, L, P); - } - if (A[2][0] != 0) - { - zero_first_column(L, 2, A); - matmul(A, L, A); - matmul(P, L, P); - } + if (A[1][0] != 0) { + zero_first_column(L, 1, A); + matmul(A, L, A); + matmul(P, L, P); + } + if (A[2][0] != 0) { + zero_first_column(L, 2, A); + matmul(A, L, A); + matmul(P, L, P); + } err:; } static void zero_first_column(long L[3][3], const int j, - SNF3x3CONST long A[3][3]) -{ - long vals[3]; + SNF3x3CONST long A[3][3]) { + long vals[3]; - extended_gcd(vals, A[0][0], A[j][0]); - set_zero(L, 0, j, A[0][0], A[j][0], vals[0], vals[1], vals[2]); + extended_gcd(vals, A[0][0], A[j][0]); + set_zero(L, 0, j, A[0][0], A[j][0], vals[0], vals[1], vals[2]); } -static int search_first_pivot(SNF3x3CONST long A[3][3]) -{ - int i; +static int search_first_pivot(SNF3x3CONST long A[3][3]) { + int i; - for (i = 0; i < 3; i++) - { - if (A[i][0] != 0) - { - return i; + for (i = 0; i < 3; i++) { + if (A[i][0] != 0) { + return i; + } } - } - return -1; + return -1; } -static void first_finalize(long L[3][3], SNF3x3CONST long A[3][3]) -{ - L[0][0] = 1; - L[0][1] = 0; - L[0][2] = 0; - L[1][0] = -A[1][0] / A[0][0]; - L[1][1] = 1; - L[1][2] = 0; - L[2][0] = -A[2][0] / A[0][0]; - L[2][1] = 0; - L[2][2] = 1; +static void first_finalize(long L[3][3], SNF3x3CONST long A[3][3]) { + L[0][0] = 1; + L[0][1] = 0; + L[0][2] = 0; + L[1][0] = -A[1][0] / A[0][0]; + L[1][1] = 1; + L[1][2] = 0; + L[2][0] = -A[2][0] / A[0][0]; + L[2][1] = 0; + L[2][2] = 1; } -static int second(long A[3][3], long P[3][3], long Q[3][3]) -{ - long L[3][3]; +static int second(long A[3][3], long P[3][3], long Q[3][3]) { + long L[3][3]; - second_one_loop(A, P, Q); + second_one_loop(A, P, Q); - if (A[2][1] == 0) - { - return 1; - } + if (A[2][1] == 0) { + return 1; + } - if (A[2][1] % A[1][1] == 0) - { - second_finalize(L, A); - matmul(A, L, A); - matmul(P, L, P); - return 1; - } + if (A[2][1] % A[1][1] == 0) { + second_finalize(L, A); + matmul(A, L, A); + matmul(P, L, P); + return 1; + } - return 0; + return 0; } -static void second_one_loop(long A[3][3], long P[3][3], long Q[3][3]) -{ - second_column(A, P); - transpose(A); - second_column(A, Q); - transpose(A); -} - -static void second_column(long A[3][3], long P[3][3]) -{ - long L[3][3]; - - if ((A[1][1] == 0) && (A[2][1] != 0)) - { - swap_rows(L, 1, 2); - matmul(A, L, A); - matmul(P, L, P); - } - - if (A[2][1] != 0) - { - zero_second_column(L, A); - matmul(A, L, A); - matmul(P, L, P); - } -} - -static void zero_second_column(long L[3][3], SNF3x3CONST long A[3][3]) -{ - long vals[3]; - - extended_gcd(vals, A[1][1], A[2][1]); - set_zero(L, 1, 2, A[1][1], A[2][1], vals[0], vals[1], vals[2]); -} - -static void second_finalize(long L[3][3], SNF3x3CONST long A[3][3]) -{ - L[0][0] = 1; - L[0][1] = 0; - L[0][2] = 0; - L[1][0] = 0; - L[1][1] = 1; - L[1][2] = 0; - L[2][0] = 0; - L[2][1] = -A[2][1] / A[1][1]; - L[2][2] = 1; -} - -static void finalize(long A[3][3], long P[3][3], long Q[3][3]) -{ - make_diagA_positive(A, P); - - finalize_sort(A, P, Q); - finalize_disturb(A, Q, 0, 1); - first(A, P, Q); - finalize_sort(A, P, Q); - finalize_disturb(A, Q, 1, 2); - second(A, P, Q); - flip_PQ(P, Q); -} - -static void finalize_sort(long A[3][3], long P[3][3], long Q[3][3]) -{ - if (A[0][0] > A[1][1]) - { - swap_diag_elems(A, P, Q, 0, 1); - } - if (A[1][1] > A[2][2]) - { - swap_diag_elems(A, P, Q, 1, 2); - } - if (A[0][0] > A[1][1]) - { - swap_diag_elems(A, P, Q, 0, 1); - } -} - -static void finalize_disturb(long A[3][3], long Q[3][3], const int i, const int j) -{ - long L[3][3]; - - if (A[j][j] % A[i][i] != 0) - { +static void second_one_loop(long A[3][3], long P[3][3], long Q[3][3]) { + second_column(A, P); transpose(A); - disturb_rows(L, i, j); + second_column(A, Q); + transpose(A); +} + +static void second_column(long A[3][3], long P[3][3]) { + long L[3][3]; + + if ((A[1][1] == 0) && (A[2][1] != 0)) { + swap_rows(L, 1, 2); + matmul(A, L, A); + matmul(P, L, P); + } + + if (A[2][1] != 0) { + zero_second_column(L, A); + matmul(A, L, A); + matmul(P, L, P); + } +} + +static void zero_second_column(long L[3][3], SNF3x3CONST long A[3][3]) { + long vals[3]; + + extended_gcd(vals, A[1][1], A[2][1]); + set_zero(L, 1, 2, A[1][1], A[2][1], vals[0], vals[1], vals[2]); +} + +static void second_finalize(long L[3][3], SNF3x3CONST long A[3][3]) { + L[0][0] = 1; + L[0][1] = 0; + L[0][2] = 0; + L[1][0] = 0; + L[1][1] = 1; + L[1][2] = 0; + L[2][0] = 0; + L[2][1] = -A[2][1] / A[1][1]; + L[2][2] = 1; +} + +static void finalize(long A[3][3], long P[3][3], long Q[3][3]) { + make_diagA_positive(A, P); + + finalize_sort(A, P, Q); + finalize_disturb(A, Q, 0, 1); + first(A, P, Q); + finalize_sort(A, P, Q); + finalize_disturb(A, Q, 1, 2); + second(A, P, Q); + flip_PQ(P, Q); +} + +static void finalize_sort(long A[3][3], long P[3][3], long Q[3][3]) { + if (A[0][0] > A[1][1]) { + swap_diag_elems(A, P, Q, 0, 1); + } + if (A[1][1] > A[2][2]) { + swap_diag_elems(A, P, Q, 1, 2); + } + if (A[0][0] > A[1][1]) { + swap_diag_elems(A, P, Q, 0, 1); + } +} + +static void finalize_disturb(long A[3][3], long Q[3][3], const int i, + const int j) { + long L[3][3]; + + if (A[j][j] % A[i][i] != 0) { + transpose(A); + disturb_rows(L, i, j); + matmul(A, L, A); + matmul(Q, L, Q); + transpose(A); + } +} + +static void disturb_rows(long L[3][3], const int i, const int j) { + L[0][0] = 1; + L[0][1] = 0; + L[0][2] = 0; + L[1][0] = 0; + L[1][1] = 1; + L[1][2] = 0; + L[2][0] = 0; + L[2][1] = 0; + L[2][2] = 1; + L[i][i] = 1; + L[i][j] = 1; + L[j][i] = 0; + L[j][j] = 1; +} + +static void swap_diag_elems(long A[3][3], long P[3][3], long Q[3][3], + const int i, const int j) { + long L[3][3]; + + swap_rows(L, i, j); + matmul(A, L, A); + matmul(P, L, P); + transpose(A); + swap_rows(L, i, j); matmul(A, L, A); matmul(Q, L, Q); transpose(A); - } } -static void disturb_rows(long L[3][3], const int i, const int j) -{ - L[0][0] = 1; - L[0][1] = 0; - L[0][2] = 0; - L[1][0] = 0; - L[1][1] = 1; - L[1][2] = 0; - L[2][0] = 0; - L[2][1] = 0; - L[2][2] = 1; - L[i][i] = 1; - L[i][j] = 1; - L[j][i] = 0; - L[j][j] = 1; -} +static void make_diagA_positive(long A[3][3], long P[3][3]) { + int i; + long L[3][3]; -static void swap_diag_elems(long A[3][3], long P[3][3], long Q[3][3], const int i, const int j) -{ - long L[3][3]; - - swap_rows(L, i, j); - matmul(A, L, A); - matmul(P, L, P); - transpose(A); - swap_rows(L, i, j); - matmul(A, L, A); - matmul(Q, L, Q); - transpose(A); -} - -static void make_diagA_positive(long A[3][3], long P[3][3]) -{ - int i; - long L[3][3]; - - for (i = 0; i < 3; i++) - { - if (A[i][i] < 0) - { - flip_sign_row(L, i); - matmul(A, L, A); - matmul(P, L, P); + for (i = 0; i < 3; i++) { + if (A[i][i] < 0) { + flip_sign_row(L, i); + matmul(A, L, A); + matmul(P, L, P); + } } - } } -static void flip_PQ(long P[3][3], long Q[3][3]) -{ - int i, j; +static void flip_PQ(long P[3][3], long Q[3][3]) { + int i, j; - if (det(P) < 0) - { - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - P[i][j] *= -1; - Q[i][j] *= -1; - } + if (det(P) < 0) { + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + P[i][j] *= -1; + Q[i][j] *= -1; + } + } } - } } -static void swap_rows(long L[3][3], const int r1, const int r2) -{ - L[0][0] = 1; - L[0][1] = 0; - L[0][2] = 0; - L[1][0] = 0; - L[1][1] = 1; - L[1][2] = 0; - L[2][0] = 0; - L[2][1] = 0; - L[2][2] = 1; - L[r1][r1] = 0; - L[r2][r2] = 0; - L[r1][r2] = 1; - L[r2][r1] = 1; +static void swap_rows(long L[3][3], const int r1, const int r2) { + L[0][0] = 1; + L[0][1] = 0; + L[0][2] = 0; + L[1][0] = 0; + L[1][1] = 1; + L[1][2] = 0; + L[2][0] = 0; + L[2][1] = 0; + L[2][2] = 1; + L[r1][r1] = 0; + L[r2][r2] = 0; + L[r1][r2] = 1; + L[r2][r1] = 1; } -static void set_zero(long L[3][3], - const int i, const int j, const long a, const long b, - const long r, const long s, const long t) -{ - L[0][0] = 1; - L[0][1] = 0; - L[0][2] = 0; - L[1][0] = 0; - L[1][1] = 1; - L[1][2] = 0; - L[2][0] = 0; - L[2][1] = 0; - L[2][2] = 1; - L[i][i] = s; - L[i][j] = t; - L[j][i] = -b / r; - L[j][j] = a / r; +static void set_zero(long L[3][3], const int i, const int j, const long a, + const long b, const long r, const long s, const long t) { + L[0][0] = 1; + L[0][1] = 0; + L[0][2] = 0; + L[1][0] = 0; + L[1][1] = 1; + L[1][2] = 0; + L[2][0] = 0; + L[2][1] = 0; + L[2][2] = 1; + L[i][i] = s; + L[i][j] = t; + L[j][i] = -b / r; + L[j][j] = a / r; } /** * Extended Euclidean algorithm * See https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm */ -static void extended_gcd(long retvals[3], const long a, const long b) -{ - int i; - long vals[6]; +static void extended_gcd(long retvals[3], const long a, const long b) { + int i; + long vals[6]; - vals[0] = a; /* r0 */ - vals[1] = b; /* r1 */ - vals[2] = 1; /* s0 */ - vals[3] = 0; /* s1 */ - vals[4] = 0; /* t0 */ - vals[5] = 1; /* t1 */ + vals[0] = a; /* r0 */ + vals[1] = b; /* r1 */ + vals[2] = 1; /* s0 */ + vals[3] = 0; /* s1 */ + vals[4] = 0; /* t0 */ + vals[5] = 1; /* t1 */ - for (i = 0; i < 1000; i++) - { - extended_gcd_step(vals); - if (vals[1] == 0) - { - break; + for (i = 0; i < 1000; i++) { + extended_gcd_step(vals); + if (vals[1] == 0) { + break; + } } - } - retvals[0] = vals[0]; - retvals[1] = vals[2]; - retvals[2] = vals[4]; + retvals[0] = vals[0]; + retvals[1] = vals[2]; + retvals[2] = vals[4]; - assert(vals[0] == a * vals[2] + b * vals[4]); + assert(vals[0] == a * vals[2] + b * vals[4]); } -static void extended_gcd_step(long vals[6]) -{ - long q, r2, s2, t2; +static void extended_gcd_step(long vals[6]) { + long q, r2, s2, t2; - q = vals[0] / vals[1]; - r2 = vals[0] % vals[1]; - if (r2 < 0) - { - if (vals[1] > 0) - { - r2 += vals[1]; - q -= 1; + q = vals[0] / vals[1]; + r2 = vals[0] % vals[1]; + if (r2 < 0) { + if (vals[1] > 0) { + r2 += vals[1]; + q -= 1; + } + if (vals[1] < 0) { + r2 -= vals[1]; + q += 1; + } } - if (vals[1] < 0) - { - r2 -= vals[1]; - q += 1; - } - } - s2 = vals[2] - q * vals[3]; - t2 = vals[4] - q * vals[5]; - vals[0] = vals[1]; - vals[1] = r2; - vals[2] = vals[3]; - vals[3] = s2; - vals[4] = vals[5]; - vals[5] = t2; + s2 = vals[2] - q * vals[3]; + t2 = vals[4] - q * vals[5]; + vals[0] = vals[1]; + vals[1] = r2; + vals[2] = vals[3]; + vals[3] = s2; + vals[4] = vals[5]; + vals[5] = t2; } -static void flip_sign_row(long L[3][3], const int i) -{ - L[0][0] = 1; - L[0][1] = 0; - L[0][2] = 0; - L[1][0] = 0; - L[1][1] = 1; - L[1][2] = 0; - L[2][0] = 0; - L[2][1] = 0; - L[2][2] = 1; - L[i][i] = -1; +static void flip_sign_row(long L[3][3], const int i) { + L[0][0] = 1; + L[0][1] = 0; + L[0][2] = 0; + L[1][0] = 0; + L[1][1] = 1; + L[1][2] = 0; + L[2][0] = 0; + L[2][1] = 0; + L[2][2] = 1; + L[i][i] = -1; } /** * Matrix operation utils */ -static void transpose(long m[3][3]) -{ - long tmp; - int i, j; +static void transpose(long m[3][3]) { + long tmp; + int i, j; - for (i = 0; i < 3; i++) - { - for (j = i; j < 3; j++) - { - tmp = m[i][j]; - m[i][j] = m[j][i]; - m[j][i] = tmp; + for (i = 0; i < 3; i++) { + for (j = i; j < 3; j++) { + tmp = m[i][j]; + m[i][j] = m[j][i]; + m[j][i] = tmp; + } } - } } -static void matmul(long m[3][3], - SNF3x3CONST long a[3][3], - SNF3x3CONST long b[3][3]) -{ - int i, j; - long c[3][3]; +static void matmul(long m[3][3], SNF3x3CONST long a[3][3], + SNF3x3CONST long b[3][3]) { + int i, j; + long c[3][3]; - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - c[i][j] = a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + c[i][j] = a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; + } } - } - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - m[i][j] = c[i][j]; + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + m[i][j] = c[i][j]; + } } - } } -static long det(SNF3x3CONST long m[3][3]) -{ - return m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) + m[0][1] * (m[1][2] * m[2][0] - m[1][0] * m[2][2]) + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]); +static long det(SNF3x3CONST long m[3][3]) { + return m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) + + m[0][1] * (m[1][2] * m[2][0] - m[1][0] * m[2][2]) + + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]); } /* int main() diff --git a/c/snf3x3.h b/c/snf3x3.h index 87bb1d7d..3f05ed6d 100644 --- a/c/snf3x3.h +++ b/c/snf3x3.h @@ -9,7 +9,7 @@ extern "C" { #define SNF3X3_MINOR_VERSION 1 #define SNF3X3_MICRO_VERSION 0 - int snf3x3(long A[3][3], long P[3][3], long Q[3][3]); +int snf3x3(long A[3][3], long P[3][3], long Q[3][3]); #ifdef __cplusplus } diff --git a/c/tetrahedron_method.c b/c/tetrahedron_method.c index abf33873..ce74c20a 100644 --- a/c/tetrahedron_method.c +++ b/c/tetrahedron_method.c @@ -34,9 +34,10 @@ /* tetrahedron_method.c */ /* Copyright (C) 2014 Atsushi Togo */ -#include #include "tetrahedron_method.h" +#include + #ifdef THMWARNING #include #define warning_print(...) fprintf(stderr, __VA_ARGS__) @@ -655,936 +656,691 @@ static long db_relative_grid_address[4][24][4][3] = { }, }; -static double -get_integration_weight(const double omega, - const double tetrahedra_omegas[24][4], - double (*gn)(const long, - const double, - const double[4]), - double (*IJ)(const long, - const long, - const double, - const double[4])); +static double get_integration_weight( + const double omega, const double tetrahedra_omegas[24][4], + double (*gn)(const long, const double, const double[4]), + double (*IJ)(const long, const long, const double, const double[4])); static long get_main_diagonal(const double rec_lattice[3][3]); static long sort_omegas(double v[4]); static double norm_squared_d3(const double a[3]); -static void multiply_matrix_vector_dl3(double v[3], - const double a[3][3], +static void multiply_matrix_vector_dl3(double v[3], const double a[3][3], const long b[3]); -static double _f(const long n, - const long m, - const double omega, +static double _f(const long n, const long m, const double omega, const double vertices_omegas[4]); -static double _J(const long i, - const long ci, - const double omega, +static double _J(const long i, const long ci, const double omega, const double vertices_omegas[4]); -static double _I(const long i, - const long ci, - const double omega, +static double _I(const long i, const long ci, const double omega, const double vertices_omegas[4]); -static double _n(const long i, - const double omega, +static double _n(const long i, const double omega, const double vertices_omegas[4]); -static double _g(const long i, - const double omega, +static double _g(const long i, const double omega, const double vertices_omegas[4]); static double _n_0(void); -static double _n_1(const double omega, - const double vertices_omegas[4]); -static double _n_2(const double omega, - const double vertices_omegas[4]); -static double _n_3(const double omega, - const double vertices_omegas[4]); +static double _n_1(const double omega, const double vertices_omegas[4]); +static double _n_2(const double omega, const double vertices_omegas[4]); +static double _n_3(const double omega, const double vertices_omegas[4]); static double _n_4(void); static double _g_0(void); -static double _g_1(const double omega, - const double vertices_omegas[4]); -static double _g_2(const double omega, - const double vertices_omegas[4]); -static double _g_3(const double omega, - const double vertices_omegas[4]); +static double _g_1(const double omega, const double vertices_omegas[4]); +static double _g_2(const double omega, const double vertices_omegas[4]); +static double _g_3(const double omega, const double vertices_omegas[4]); static double _g_4(void); static double _J_0(void); -static double _J_10(const double omega, - const double vertices_omegas[4]); -static double _J_11(const double omega, - const double vertices_omegas[4]); -static double _J_12(const double omega, - const double vertices_omegas[4]); -static double _J_13(const double omega, - const double vertices_omegas[4]); -static double _J_20(const double omega, - const double vertices_omegas[4]); -static double _J_21(const double omega, - const double vertices_omegas[4]); -static double _J_22(const double omega, - const double vertices_omegas[4]); -static double _J_23(const double omega, - const double vertices_omegas[4]); -static double _J_30(const double omega, - const double vertices_omegas[4]); -static double _J_31(const double omega, - const double vertices_omegas[4]); -static double _J_32(const double omega, - const double vertices_omegas[4]); -static double _J_33(const double omega, - const double vertices_omegas[4]); +static double _J_10(const double omega, const double vertices_omegas[4]); +static double _J_11(const double omega, const double vertices_omegas[4]); +static double _J_12(const double omega, const double vertices_omegas[4]); +static double _J_13(const double omega, const double vertices_omegas[4]); +static double _J_20(const double omega, const double vertices_omegas[4]); +static double _J_21(const double omega, const double vertices_omegas[4]); +static double _J_22(const double omega, const double vertices_omegas[4]); +static double _J_23(const double omega, const double vertices_omegas[4]); +static double _J_30(const double omega, const double vertices_omegas[4]); +static double _J_31(const double omega, const double vertices_omegas[4]); +static double _J_32(const double omega, const double vertices_omegas[4]); +static double _J_33(const double omega, const double vertices_omegas[4]); static double _J_4(void); static double _I_0(void); -static double _I_10(const double omega, - const double vertices_omegas[4]); -static double _I_11(const double omega, - const double vertices_omegas[4]); -static double _I_12(const double omega, - const double vertices_omegas[4]); -static double _I_13(const double omega, - const double vertices_omegas[4]); -static double _I_20(const double omega, - const double vertices_omegas[4]); -static double _I_21(const double omega, - const double vertices_omegas[4]); -static double _I_22(const double omega, - const double vertices_omegas[4]); -static double _I_23(const double omega, - const double vertices_omegas[4]); -static double _I_30(const double omega, - const double vertices_omegas[4]); -static double _I_31(const double omega, - const double vertices_omegas[4]); -static double _I_32(const double omega, - const double vertices_omegas[4]); -static double _I_33(const double omega, - const double vertices_omegas[4]); +static double _I_10(const double omega, const double vertices_omegas[4]); +static double _I_11(const double omega, const double vertices_omegas[4]); +static double _I_12(const double omega, const double vertices_omegas[4]); +static double _I_13(const double omega, const double vertices_omegas[4]); +static double _I_20(const double omega, const double vertices_omegas[4]); +static double _I_21(const double omega, const double vertices_omegas[4]); +static double _I_22(const double omega, const double vertices_omegas[4]); +static double _I_23(const double omega, const double vertices_omegas[4]); +static double _I_30(const double omega, const double vertices_omegas[4]); +static double _I_31(const double omega, const double vertices_omegas[4]); +static double _I_32(const double omega, const double vertices_omegas[4]); +static double _I_33(const double omega, const double vertices_omegas[4]); static double _I_4(void); void thm_get_relative_grid_address(long relative_grid_address[24][4][3], - const double rec_lattice[3][3]) -{ - long i, j, k, main_diag_index; + const double rec_lattice[3][3]) { + long i, j, k, main_diag_index; - main_diag_index = get_main_diagonal(rec_lattice); + main_diag_index = get_main_diagonal(rec_lattice); - for (i = 0; i < 24; i++) - { - for (j = 0; j < 4; j++) - { - for (k = 0; k < 3; k++) - { - relative_grid_address[i][j][k] = - db_relative_grid_address[main_diag_index][i][j][k]; - } + for (i = 0; i < 24; i++) { + for (j = 0; j < 4; j++) { + for (k = 0; k < 3; k++) { + relative_grid_address[i][j][k] = + db_relative_grid_address[main_diag_index][i][j][k]; + } + } } - } } -void thm_get_all_relative_grid_address(long relative_grid_address[4][24][4][3]) -{ - long i, j, k, main_diag_index; +void thm_get_all_relative_grid_address( + long relative_grid_address[4][24][4][3]) { + long i, j, k, main_diag_index; - for (main_diag_index = 0; main_diag_index < 4; main_diag_index++) - { - for (i = 0; i < 24; i++) - { - for (j = 0; j < 4; j++) - { - for (k = 0; k < 3; k++) - { - relative_grid_address[main_diag_index][i][j][k] = - db_relative_grid_address[main_diag_index][i][j][k]; + for (main_diag_index = 0; main_diag_index < 4; main_diag_index++) { + for (i = 0; i < 24; i++) { + for (j = 0; j < 4; j++) { + for (k = 0; k < 3; k++) { + relative_grid_address[main_diag_index][i][j][k] = + db_relative_grid_address[main_diag_index][i][j][k]; + } + } } - } } - } } double thm_get_integration_weight(const double omega, const double tetrahedra_omegas[24][4], - const char function) -{ - if (function == 'I') - { - return get_integration_weight(omega, - tetrahedra_omegas, - _g, _I); - } - else - { - return get_integration_weight(omega, - tetrahedra_omegas, - _n, _J); - } + const char function) { + if (function == 'I') { + return get_integration_weight(omega, tetrahedra_omegas, _g, _I); + } else { + return get_integration_weight(omega, tetrahedra_omegas, _n, _J); + } } -long thm_in_tetrahedra(const double f0, const double freq_vertices[24][4]) -{ - long i, j; - double fmin, fmax; +long thm_in_tetrahedra(const double f0, const double freq_vertices[24][4]) { + long i, j; + double fmin, fmax; - fmin = freq_vertices[0][0]; - fmax = freq_vertices[0][0]; + fmin = freq_vertices[0][0]; + fmax = freq_vertices[0][0]; - for (i = 0; i < 24; i++) - { - for (j = 0; j < 4; j++) - { - if (fmin > freq_vertices[i][j]) - { - fmin = freq_vertices[i][j]; - } - if (fmax < freq_vertices[i][j]) - { - fmax = freq_vertices[i][j]; - } - } - } - - if (fmin > f0 || fmax < f0) - { - return 0; - } - else - { - return 1; - } -} - -static double -get_integration_weight(const double omega, - const double tetrahedra_omegas[24][4], - double (*gn)(const long, - const double, - const double[4]), - double (*IJ)(const long, - const long, - const double, - const double[4])) -{ - long i, j, ci; - double sum; - double v[4]; - - sum = 0; - for (i = 0; i < 24; i++) - { - for (j = 0; j < 4; j++) - { - v[j] = tetrahedra_omegas[i][j]; - } - ci = sort_omegas(v); - if (omega < v[0]) - { - sum += IJ(0, ci, omega, v) * gn(0, omega, v); - } - else - { - if (v[0] < omega && omega < v[1]) - { - sum += IJ(1, ci, omega, v) * gn(1, omega, v); - } - else - { - if (v[1] < omega && omega < v[2]) - { - sum += IJ(2, ci, omega, v) * gn(2, omega, v); - } - else - { - if (v[2] < omega && omega < v[3]) - { - sum += IJ(3, ci, omega, v) * gn(3, omega, v); - } - else - { - if (v[3] < omega) - { - sum += IJ(4, ci, omega, v) * gn(4, omega, v); + for (i = 0; i < 24; i++) { + for (j = 0; j < 4; j++) { + if (fmin > freq_vertices[i][j]) { + fmin = freq_vertices[i][j]; + } + if (fmax < freq_vertices[i][j]) { + fmax = freq_vertices[i][j]; } - } } - } } - } - return sum / 6; + + if (fmin > f0 || fmax < f0) { + return 0; + } else { + return 1; + } } -static long sort_omegas(double v[4]) -{ - long i; - double w[4]; +static double get_integration_weight( + const double omega, const double tetrahedra_omegas[24][4], + double (*gn)(const long, const double, const double[4]), + double (*IJ)(const long, const long, const double, const double[4])) { + long i, j, ci; + double sum; + double v[4]; - i = 0; - - if (v[0] > v[1]) - { - w[0] = v[1]; - w[1] = v[0]; - i = 1; - } - else - { - w[0] = v[0]; - w[1] = v[1]; - } - - if (v[2] > v[3]) - { - w[2] = v[3]; - w[3] = v[2]; - } - else - { - w[2] = v[2]; - w[3] = v[3]; - } - - if (w[0] > w[2]) - { - v[0] = w[2]; - v[1] = w[0]; - if (i == 0) - { - i = 4; + sum = 0; + for (i = 0; i < 24; i++) { + for (j = 0; j < 4; j++) { + v[j] = tetrahedra_omegas[i][j]; + } + ci = sort_omegas(v); + if (omega < v[0]) { + sum += IJ(0, ci, omega, v) * gn(0, omega, v); + } else { + if (v[0] < omega && omega < v[1]) { + sum += IJ(1, ci, omega, v) * gn(1, omega, v); + } else { + if (v[1] < omega && omega < v[2]) { + sum += IJ(2, ci, omega, v) * gn(2, omega, v); + } else { + if (v[2] < omega && omega < v[3]) { + sum += IJ(3, ci, omega, v) * gn(3, omega, v); + } else { + if (v[3] < omega) { + sum += IJ(4, ci, omega, v) * gn(4, omega, v); + } + } + } + } + } } - } - else - { - v[0] = w[0]; - v[1] = w[2]; - } - - if (w[1] > w[3]) - { - v[3] = w[1]; - v[2] = w[3]; - if (i == 1) - { - i = 3; - } - } - else - { - v[3] = w[3]; - v[2] = w[1]; - if (i == 1) - { - i = 5; - } - } - - if (v[1] > v[2]) - { - w[1] = v[1]; - v[1] = v[2]; - v[2] = w[1]; - if (i == 4) - { - i = 2; - } - if (i == 5) - { - i = 1; - } - } - else - { - if (i == 4) - { - i = 1; - } - if (i == 5) - { - i = 2; - } - } - return i; + return sum / 6; } -static long get_main_diagonal(const double rec_lattice[3][3]) -{ - long i, shortest; - double length, min_length; - double main_diag[3]; +static long sort_omegas(double v[4]) { + long i; + double w[4]; - shortest = 0; - multiply_matrix_vector_dl3(main_diag, rec_lattice, main_diagonals[0]); - min_length = norm_squared_d3(main_diag); - for (i = 1; i < 4; i++) - { - multiply_matrix_vector_dl3(main_diag, rec_lattice, main_diagonals[i]); - length = norm_squared_d3(main_diag); - if (min_length > length) - { - min_length = length; - shortest = i; + i = 0; + + if (v[0] > v[1]) { + w[0] = v[1]; + w[1] = v[0]; + i = 1; + } else { + w[0] = v[0]; + w[1] = v[1]; } - } - return shortest; + + if (v[2] > v[3]) { + w[2] = v[3]; + w[3] = v[2]; + } else { + w[2] = v[2]; + w[3] = v[3]; + } + + if (w[0] > w[2]) { + v[0] = w[2]; + v[1] = w[0]; + if (i == 0) { + i = 4; + } + } else { + v[0] = w[0]; + v[1] = w[2]; + } + + if (w[1] > w[3]) { + v[3] = w[1]; + v[2] = w[3]; + if (i == 1) { + i = 3; + } + } else { + v[3] = w[3]; + v[2] = w[1]; + if (i == 1) { + i = 5; + } + } + + if (v[1] > v[2]) { + w[1] = v[1]; + v[1] = v[2]; + v[2] = w[1]; + if (i == 4) { + i = 2; + } + if (i == 5) { + i = 1; + } + } else { + if (i == 4) { + i = 1; + } + if (i == 5) { + i = 2; + } + } + return i; } -static double norm_squared_d3(const double a[3]) -{ - return a[0] * a[0] + a[1] * a[1] + a[2] * a[2]; +static long get_main_diagonal(const double rec_lattice[3][3]) { + long i, shortest; + double length, min_length; + double main_diag[3]; + + shortest = 0; + multiply_matrix_vector_dl3(main_diag, rec_lattice, main_diagonals[0]); + min_length = norm_squared_d3(main_diag); + for (i = 1; i < 4; i++) { + multiply_matrix_vector_dl3(main_diag, rec_lattice, main_diagonals[i]); + length = norm_squared_d3(main_diag); + if (min_length > length) { + min_length = length; + shortest = i; + } + } + return shortest; } -static void multiply_matrix_vector_dl3(double v[3], - const double a[3][3], - const long b[3]) -{ - long i; - double c[3]; - - for (i = 0; i < 3; i++) - { - c[i] = a[i][0] * b[0] + a[i][1] * b[1] + a[i][2] * b[2]; - } - - for (i = 0; i < 3; i++) - { - v[i] = c[i]; - } +static double norm_squared_d3(const double a[3]) { + return a[0] * a[0] + a[1] * a[1] + a[2] * a[2]; } -static double _f(const long n, - const long m, - const double omega, - const double vertices_omegas[4]) -{ - return ((omega - vertices_omegas[m]) / - (vertices_omegas[n] - vertices_omegas[m])); +static void multiply_matrix_vector_dl3(double v[3], const double a[3][3], + const long b[3]) { + long i; + double c[3]; + + for (i = 0; i < 3; i++) { + c[i] = a[i][0] * b[0] + a[i][1] * b[1] + a[i][2] * b[2]; + } + + for (i = 0; i < 3; i++) { + v[i] = c[i]; + } } -static double _J(const long i, - const long ci, - const double omega, - const double vertices_omegas[4]) -{ - switch (i) - { - case 0: - return _J_0(); - case 1: - switch (ci) - { - case 0: - return _J_10(omega, vertices_omegas); - case 1: - return _J_11(omega, vertices_omegas); - case 2: - return _J_12(omega, vertices_omegas); - case 3: - return _J_13(omega, vertices_omegas); - } - case 2: - switch (ci) - { - case 0: - return _J_20(omega, vertices_omegas); - case 1: - return _J_21(omega, vertices_omegas); - case 2: - return _J_22(omega, vertices_omegas); - case 3: - return _J_23(omega, vertices_omegas); - } - case 3: - switch (ci) - { - case 0: - return _J_30(omega, vertices_omegas); - case 1: - return _J_31(omega, vertices_omegas); - case 2: - return _J_32(omega, vertices_omegas); - case 3: - return _J_33(omega, vertices_omegas); - } - case 4: - return _J_4(); - } - - warning_print("******* Warning *******\n"); - warning_print(" J is something wrong. \n"); - warning_print("******* Warning *******\n"); - warning_print("(line %d, %s).\n", __LINE__, __FILE__); - - return 0; +static double _f(const long n, const long m, const double omega, + const double vertices_omegas[4]) { + return ((omega - vertices_omegas[m]) / + (vertices_omegas[n] - vertices_omegas[m])); } -static double _I(const long i, - const long ci, - const double omega, - const double vertices_omegas[4]) -{ - switch (i) - { - case 0: - return _I_0(); - case 1: - switch (ci) - { - case 0: - return _I_10(omega, vertices_omegas); - case 1: - return _I_11(omega, vertices_omegas); - case 2: - return _I_12(omega, vertices_omegas); - case 3: - return _I_13(omega, vertices_omegas); +static double _J(const long i, const long ci, const double omega, + const double vertices_omegas[4]) { + switch (i) { + case 0: + return _J_0(); + case 1: + switch (ci) { + case 0: + return _J_10(omega, vertices_omegas); + case 1: + return _J_11(omega, vertices_omegas); + case 2: + return _J_12(omega, vertices_omegas); + case 3: + return _J_13(omega, vertices_omegas); + } + case 2: + switch (ci) { + case 0: + return _J_20(omega, vertices_omegas); + case 1: + return _J_21(omega, vertices_omegas); + case 2: + return _J_22(omega, vertices_omegas); + case 3: + return _J_23(omega, vertices_omegas); + } + case 3: + switch (ci) { + case 0: + return _J_30(omega, vertices_omegas); + case 1: + return _J_31(omega, vertices_omegas); + case 2: + return _J_32(omega, vertices_omegas); + case 3: + return _J_33(omega, vertices_omegas); + } + case 4: + return _J_4(); } - case 2: - switch (ci) - { - case 0: - return _I_20(omega, vertices_omegas); - case 1: - return _I_21(omega, vertices_omegas); - case 2: - return _I_22(omega, vertices_omegas); - case 3: - return _I_23(omega, vertices_omegas); - } - case 3: - switch (ci) - { - case 0: - return _I_30(omega, vertices_omegas); - case 1: - return _I_31(omega, vertices_omegas); - case 2: - return _I_32(omega, vertices_omegas); - case 3: - return _I_33(omega, vertices_omegas); - } - case 4: - return _I_4(); - } - warning_print("******* Warning *******\n"); - warning_print(" I is something wrong. \n"); - warning_print("******* Warning *******\n"); - warning_print("(line %d, %s).\n", __LINE__, __FILE__); + warning_print("******* Warning *******\n"); + warning_print(" J is something wrong. \n"); + warning_print("******* Warning *******\n"); + warning_print("(line %d, %s).\n", __LINE__, __FILE__); - return 0; + return 0; } -static double _n(const long i, - const double omega, - const double vertices_omegas[4]) -{ - switch (i) - { - case 0: - return _n_0(); - case 1: - return _n_1(omega, vertices_omegas); - case 2: - return _n_2(omega, vertices_omegas); - case 3: - return _n_3(omega, vertices_omegas); - case 4: - return _n_4(); - } +static double _I(const long i, const long ci, const double omega, + const double vertices_omegas[4]) { + switch (i) { + case 0: + return _I_0(); + case 1: + switch (ci) { + case 0: + return _I_10(omega, vertices_omegas); + case 1: + return _I_11(omega, vertices_omegas); + case 2: + return _I_12(omega, vertices_omegas); + case 3: + return _I_13(omega, vertices_omegas); + } + case 2: + switch (ci) { + case 0: + return _I_20(omega, vertices_omegas); + case 1: + return _I_21(omega, vertices_omegas); + case 2: + return _I_22(omega, vertices_omegas); + case 3: + return _I_23(omega, vertices_omegas); + } + case 3: + switch (ci) { + case 0: + return _I_30(omega, vertices_omegas); + case 1: + return _I_31(omega, vertices_omegas); + case 2: + return _I_32(omega, vertices_omegas); + case 3: + return _I_33(omega, vertices_omegas); + } + case 4: + return _I_4(); + } - warning_print("******* Warning *******\n"); - warning_print(" n is something wrong. \n"); - warning_print("******* Warning *******\n"); - warning_print("(line %d, %s).\n", __LINE__, __FILE__); + warning_print("******* Warning *******\n"); + warning_print(" I is something wrong. \n"); + warning_print("******* Warning *******\n"); + warning_print("(line %d, %s).\n", __LINE__, __FILE__); - return 0; + return 0; } -static double _g(const long i, - const double omega, - const double vertices_omegas[4]) -{ - switch (i) - { - case 0: - return _g_0(); - case 1: - return _g_1(omega, vertices_omegas); - case 2: - return _g_2(omega, vertices_omegas); - case 3: - return _g_3(omega, vertices_omegas); - case 4: - return _g_4(); - } +static double _n(const long i, const double omega, + const double vertices_omegas[4]) { + switch (i) { + case 0: + return _n_0(); + case 1: + return _n_1(omega, vertices_omegas); + case 2: + return _n_2(omega, vertices_omegas); + case 3: + return _n_3(omega, vertices_omegas); + case 4: + return _n_4(); + } - warning_print("******* Warning *******\n"); - warning_print(" g is something wrong. \n"); - warning_print("******* Warning *******\n"); - warning_print("(line %d, %s).\n", __LINE__, __FILE__); + warning_print("******* Warning *******\n"); + warning_print(" n is something wrong. \n"); + warning_print("******* Warning *******\n"); + warning_print("(line %d, %s).\n", __LINE__, __FILE__); - return 0; + return 0; +} + +static double _g(const long i, const double omega, + const double vertices_omegas[4]) { + switch (i) { + case 0: + return _g_0(); + case 1: + return _g_1(omega, vertices_omegas); + case 2: + return _g_2(omega, vertices_omegas); + case 3: + return _g_3(omega, vertices_omegas); + case 4: + return _g_4(); + } + + warning_print("******* Warning *******\n"); + warning_print(" g is something wrong. \n"); + warning_print("******* Warning *******\n"); + warning_print("(line %d, %s).\n", __LINE__, __FILE__); + + return 0; } /* omega < omega1 */ -static double _n_0(void) -{ - return 0.0; -} +static double _n_0(void) { return 0.0; } /* omega1 < omega < omega2 */ -static double _n_1(const double omega, - const double vertices_omegas[4]) -{ - return (_f(1, 0, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) * - _f(3, 0, omega, vertices_omegas)); +static double _n_1(const double omega, const double vertices_omegas[4]) { + return (_f(1, 0, omega, vertices_omegas) * + _f(2, 0, omega, vertices_omegas) * + _f(3, 0, omega, vertices_omegas)); } /* omega2 < omega < omega3 */ -static double _n_2(const double omega, - const double vertices_omegas[4]) -{ - return (_f(3, 1, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) + - _f(3, 0, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) + - _f(3, 0, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) * - _f(1, 2, omega, vertices_omegas)); +static double _n_2(const double omega, const double vertices_omegas[4]) { + return ( + _f(3, 1, omega, vertices_omegas) * _f(2, 1, omega, vertices_omegas) + + _f(3, 0, omega, vertices_omegas) * _f(1, 3, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) + + _f(3, 0, omega, vertices_omegas) * _f(2, 0, omega, vertices_omegas) * + _f(1, 2, omega, vertices_omegas)); } /* omega2 < omega < omega3 */ -static double _n_3(const double omega, - const double vertices_omegas[4]) -{ - return (1.0 - - _f(0, 3, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 3, omega, vertices_omegas)); +static double _n_3(const double omega, const double vertices_omegas[4]) { + return (1.0 - _f(0, 3, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas) * + _f(2, 3, omega, vertices_omegas)); } /* omega4 < omega */ -static double _n_4(void) -{ - return 1.0; -} +static double _n_4(void) { return 1.0; } /* omega < omega1 */ -static double _g_0(void) -{ - return 0.0; -} +static double _g_0(void) { return 0.0; } /* omega1 < omega < omega2 */ -static double _g_1(const double omega, - const double vertices_omegas[4]) -{ - return (3 * - _f(1, 0, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) / - (vertices_omegas[3] - vertices_omegas[0])); +static double _g_1(const double omega, const double vertices_omegas[4]) { + return (3 * _f(1, 0, omega, vertices_omegas) * + _f(2, 0, omega, vertices_omegas) / + (vertices_omegas[3] - vertices_omegas[0])); } /* omega2 < omega < omega3 */ -static double _g_2(const double omega, - const double vertices_omegas[4]) -{ - return (3 / - (vertices_omegas[3] - vertices_omegas[0]) * - (_f(1, 2, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) + - _f(2, 1, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas))); +static double _g_2(const double omega, const double vertices_omegas[4]) { + return ( + 3 / (vertices_omegas[3] - vertices_omegas[0]) * + (_f(1, 2, omega, vertices_omegas) * _f(2, 0, omega, vertices_omegas) + + _f(2, 1, omega, vertices_omegas) * _f(1, 3, omega, vertices_omegas))); } /* omega3 < omega < omega4 */ -static double _g_3(const double omega, - const double vertices_omegas[4]) -{ - return (3 * - _f(1, 3, omega, vertices_omegas) * - _f(2, 3, omega, vertices_omegas) / - (vertices_omegas[3] - vertices_omegas[0])); +static double _g_3(const double omega, const double vertices_omegas[4]) { + return (3 * _f(1, 3, omega, vertices_omegas) * + _f(2, 3, omega, vertices_omegas) / + (vertices_omegas[3] - vertices_omegas[0])); } /* omega4 < omega */ -static double _g_4(void) -{ - return 0.0; +static double _g_4(void) { return 0.0; } + +static double _J_0(void) { return 0.0; } + +static double _J_10(const double omega, const double vertices_omegas[4]) { + return (1.0 + _f(0, 1, omega, vertices_omegas) + + _f(0, 2, omega, vertices_omegas) + + _f(0, 3, omega, vertices_omegas)) / + 4; } -static double _J_0(void) -{ - return 0.0; +static double _J_11(const double omega, const double vertices_omegas[4]) { + return _f(1, 0, omega, vertices_omegas) / 4; } -static double _J_10(const double omega, - const double vertices_omegas[4]) -{ - return (1.0 + - _f(0, 1, omega, vertices_omegas) + - _f(0, 2, omega, vertices_omegas) + - _f(0, 3, omega, vertices_omegas)) / - 4; +static double _J_12(const double omega, const double vertices_omegas[4]) { + return _f(2, 0, omega, vertices_omegas) / 4; } -static double _J_11(const double omega, - const double vertices_omegas[4]) -{ - return _f(1, 0, omega, vertices_omegas) / 4; +static double _J_13(const double omega, const double vertices_omegas[4]) { + return _f(3, 0, omega, vertices_omegas) / 4; } -static double _J_12(const double omega, - const double vertices_omegas[4]) -{ - return _f(2, 0, omega, vertices_omegas) / 4; +static double _J_20(const double omega, const double vertices_omegas[4]) { + return (_f(3, 1, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) + + _f(3, 0, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) * + (1.0 + _f(0, 3, omega, vertices_omegas)) + + _f(3, 0, omega, vertices_omegas) * + _f(2, 0, omega, vertices_omegas) * + _f(1, 2, omega, vertices_omegas) * + (1.0 + _f(0, 3, omega, vertices_omegas) + + _f(0, 2, omega, vertices_omegas))) / + 4 / _n_2(omega, vertices_omegas); } -static double _J_13(const double omega, - const double vertices_omegas[4]) -{ - return _f(3, 0, omega, vertices_omegas) / 4; +static double _J_21(const double omega, const double vertices_omegas[4]) { + return (_f(3, 1, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) * + (1.0 + _f(1, 3, omega, vertices_omegas) + + _f(1, 2, omega, vertices_omegas)) + + _f(3, 0, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) * + (_f(1, 3, omega, vertices_omegas) + + _f(1, 2, omega, vertices_omegas)) + + _f(3, 0, omega, vertices_omegas) * + _f(2, 0, omega, vertices_omegas) * + _f(1, 2, omega, vertices_omegas) * + _f(1, 2, omega, vertices_omegas)) / + 4 / _n_2(omega, vertices_omegas); } -static double _J_20(const double omega, - const double vertices_omegas[4]) -{ - return (_f(3, 1, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) + - _f(3, 0, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) * - (1.0 + - _f(0, 3, omega, vertices_omegas)) + - _f(3, 0, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) * - _f(1, 2, omega, vertices_omegas) * - (1.0 + - _f(0, 3, omega, vertices_omegas) + - _f(0, 2, omega, vertices_omegas))) / - 4 / _n_2(omega, vertices_omegas); +static double _J_22(const double omega, const double vertices_omegas[4]) { + return (_f(3, 1, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) + + _f(3, 0, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) + + _f(3, 0, omega, vertices_omegas) * + _f(2, 0, omega, vertices_omegas) * + _f(1, 2, omega, vertices_omegas) * + (_f(2, 1, omega, vertices_omegas) + + _f(2, 0, omega, vertices_omegas))) / + 4 / _n_2(omega, vertices_omegas); } -static double _J_21(const double omega, - const double vertices_omegas[4]) -{ - return (_f(3, 1, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) * - (1.0 + - _f(1, 3, omega, vertices_omegas) + - _f(1, 2, omega, vertices_omegas)) + - _f(3, 0, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) * - (_f(1, 3, omega, vertices_omegas) + - _f(1, 2, omega, vertices_omegas)) + - _f(3, 0, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) * - _f(1, 2, omega, vertices_omegas) * - _f(1, 2, omega, vertices_omegas)) / - 4 / _n_2(omega, vertices_omegas); +static double _J_23(const double omega, const double vertices_omegas[4]) { + return (_f(3, 1, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) * + _f(3, 1, omega, vertices_omegas) + + _f(3, 0, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) * + (_f(3, 1, omega, vertices_omegas) + + _f(3, 0, omega, vertices_omegas)) + + _f(3, 0, omega, vertices_omegas) * + _f(2, 0, omega, vertices_omegas) * + _f(1, 2, omega, vertices_omegas) * + _f(3, 0, omega, vertices_omegas)) / + 4 / _n_2(omega, vertices_omegas); } -static double _J_22(const double omega, - const double vertices_omegas[4]) -{ - return (_f(3, 1, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) + - _f(3, 0, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) + - _f(3, 0, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) * - _f(1, 2, omega, vertices_omegas) * - (_f(2, 1, omega, vertices_omegas) + - _f(2, 0, omega, vertices_omegas))) / - 4 / _n_2(omega, vertices_omegas); +static double _J_30(const double omega, const double vertices_omegas[4]) { + return (1.0 - _f(0, 3, omega, vertices_omegas) * + _f(0, 3, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas) * + _f(2, 3, omega, vertices_omegas)) / + 4 / _n_3(omega, vertices_omegas); } -static double _J_23(const double omega, - const double vertices_omegas[4]) -{ - return (_f(3, 1, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) * - _f(3, 1, omega, vertices_omegas) + - _f(3, 0, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) * - (_f(3, 1, omega, vertices_omegas) + - _f(3, 0, omega, vertices_omegas)) + - _f(3, 0, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) * - _f(1, 2, omega, vertices_omegas) * - _f(3, 0, omega, vertices_omegas)) / - 4 / _n_2(omega, vertices_omegas); +static double _J_31(const double omega, const double vertices_omegas[4]) { + return (1.0 - _f(0, 3, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas) * + _f(2, 3, omega, vertices_omegas)) / + 4 / _n_3(omega, vertices_omegas); } -static double _J_30(const double omega, - const double vertices_omegas[4]) -{ - return (1.0 - - _f(0, 3, omega, vertices_omegas) * - _f(0, 3, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 3, omega, vertices_omegas)) / - 4 / _n_3(omega, vertices_omegas); +static double _J_32(const double omega, const double vertices_omegas[4]) { + return (1.0 - _f(0, 3, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas) * + _f(2, 3, omega, vertices_omegas) * + _f(2, 3, omega, vertices_omegas)) / + 4 / _n_3(omega, vertices_omegas); } -static double _J_31(const double omega, - const double vertices_omegas[4]) -{ - return (1.0 - - _f(0, 3, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 3, omega, vertices_omegas)) / - 4 / _n_3(omega, vertices_omegas); +static double _J_33(const double omega, const double vertices_omegas[4]) { + return (1.0 - _f(0, 3, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas) * + _f(2, 3, omega, vertices_omegas) * + (1.0 + _f(3, 0, omega, vertices_omegas) + + _f(3, 1, omega, vertices_omegas) + + _f(3, 2, omega, vertices_omegas))) / + 4 / _n_3(omega, vertices_omegas); } -static double _J_32(const double omega, - const double vertices_omegas[4]) -{ - return (1.0 - - _f(0, 3, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 3, omega, vertices_omegas) * - _f(2, 3, omega, vertices_omegas)) / - 4 / _n_3(omega, vertices_omegas); +static double _J_4(void) { return 0.25; } + +static double _I_0(void) { return 0.0; } + +static double _I_10(const double omega, const double vertices_omegas[4]) { + return (_f(0, 1, omega, vertices_omegas) + + _f(0, 2, omega, vertices_omegas) + + _f(0, 3, omega, vertices_omegas)) / + 3; } -static double _J_33(const double omega, - const double vertices_omegas[4]) -{ - return (1.0 - - _f(0, 3, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 3, omega, vertices_omegas) * - (1.0 + - _f(3, 0, omega, vertices_omegas) + - _f(3, 1, omega, vertices_omegas) + - _f(3, 2, omega, vertices_omegas))) / - 4 / _n_3(omega, vertices_omegas); +static double _I_11(const double omega, const double vertices_omegas[4]) { + return _f(1, 0, omega, vertices_omegas) / 3; } -static double _J_4(void) -{ - return 0.25; +static double _I_12(const double omega, const double vertices_omegas[4]) { + return _f(2, 0, omega, vertices_omegas) / 3; } -static double _I_0(void) -{ - return 0.0; +static double _I_13(const double omega, const double vertices_omegas[4]) { + return _f(3, 0, omega, vertices_omegas) / 3; } -static double _I_10(const double omega, - const double vertices_omegas[4]) -{ - return (_f(0, 1, omega, vertices_omegas) + - _f(0, 2, omega, vertices_omegas) + - _f(0, 3, omega, vertices_omegas)) / - 3; +static double _I_20(const double omega, const double vertices_omegas[4]) { + return (_f(0, 3, omega, vertices_omegas) + + _f(0, 2, omega, vertices_omegas) * + _f(2, 0, omega, vertices_omegas) * + _f(1, 2, omega, vertices_omegas) / + (_f(1, 2, omega, vertices_omegas) * + _f(2, 0, omega, vertices_omegas) + + _f(2, 1, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas))) / + 3; } -static double _I_11(const double omega, - const double vertices_omegas[4]) -{ - return _f(1, 0, omega, vertices_omegas) / 3; +static double _I_21(const double omega, const double vertices_omegas[4]) { + return (_f(1, 2, omega, vertices_omegas) + + _f(1, 3, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) / + (_f(1, 2, omega, vertices_omegas) * + _f(2, 0, omega, vertices_omegas) + + _f(2, 1, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas))) / + 3; } -static double _I_12(const double omega, - const double vertices_omegas[4]) -{ - return _f(2, 0, omega, vertices_omegas) / 3; +static double _I_22(const double omega, const double vertices_omegas[4]) { + return (_f(2, 1, omega, vertices_omegas) + + _f(2, 0, omega, vertices_omegas) * + _f(2, 0, omega, vertices_omegas) * + _f(1, 2, omega, vertices_omegas) / + (_f(1, 2, omega, vertices_omegas) * + _f(2, 0, omega, vertices_omegas) + + _f(2, 1, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas))) / + 3; } -static double _I_13(const double omega, - const double vertices_omegas[4]) -{ - return _f(3, 0, omega, vertices_omegas) / 3; +static double _I_23(const double omega, const double vertices_omegas[4]) { + return (_f(3, 0, omega, vertices_omegas) + + _f(3, 1, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas) * + _f(2, 1, omega, vertices_omegas) / + (_f(1, 2, omega, vertices_omegas) * + _f(2, 0, omega, vertices_omegas) + + _f(2, 1, omega, vertices_omegas) * + _f(1, 3, omega, vertices_omegas))) / + 3; } -static double _I_20(const double omega, - const double vertices_omegas[4]) -{ - return (_f(0, 3, omega, vertices_omegas) + - _f(0, 2, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) * - _f(1, 2, omega, vertices_omegas) / - (_f(1, 2, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) + - _f(2, 1, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas))) / - 3; +static double _I_30(const double omega, const double vertices_omegas[4]) { + return _f(0, 3, omega, vertices_omegas) / 3; } -static double _I_21(const double omega, - const double vertices_omegas[4]) -{ - return (_f(1, 2, omega, vertices_omegas) + - _f(1, 3, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) / - (_f(1, 2, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) + - _f(2, 1, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas))) / - 3; +static double _I_31(const double omega, const double vertices_omegas[4]) { + return _f(1, 3, omega, vertices_omegas) / 3; } -static double _I_22(const double omega, - const double vertices_omegas[4]) -{ - return (_f(2, 1, omega, vertices_omegas) + - _f(2, 0, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) * - _f(1, 2, omega, vertices_omegas) / - (_f(1, 2, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) + - _f(2, 1, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas))) / - 3; +static double _I_32(const double omega, const double vertices_omegas[4]) { + return _f(2, 3, omega, vertices_omegas) / 3; } -static double _I_23(const double omega, - const double vertices_omegas[4]) -{ - return (_f(3, 0, omega, vertices_omegas) + - _f(3, 1, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas) * - _f(2, 1, omega, vertices_omegas) / - (_f(1, 2, omega, vertices_omegas) * - _f(2, 0, omega, vertices_omegas) + - _f(2, 1, omega, vertices_omegas) * - _f(1, 3, omega, vertices_omegas))) / - 3; +static double _I_33(const double omega, const double vertices_omegas[4]) { + return (_f(3, 0, omega, vertices_omegas) + + _f(3, 1, omega, vertices_omegas) + + _f(3, 2, omega, vertices_omegas)) / + 3; } -static double _I_30(const double omega, - const double vertices_omegas[4]) -{ - return _f(0, 3, omega, vertices_omegas) / 3; -} - -static double _I_31(const double omega, - const double vertices_omegas[4]) -{ - return _f(1, 3, omega, vertices_omegas) / 3; -} - -static double _I_32(const double omega, - const double vertices_omegas[4]) -{ - return _f(2, 3, omega, vertices_omegas) / 3; -} - -static double _I_33(const double omega, - const double vertices_omegas[4]) -{ - return (_f(3, 0, omega, vertices_omegas) + - _f(3, 1, omega, vertices_omegas) + - _f(3, 2, omega, vertices_omegas)) / - 3; -} - -static double _I_4(void) -{ - return 0.0; -} +static double _I_4(void) { return 0.0; } diff --git a/c/triplet.c b/c/triplet.c index 7794fe2c..2076308f 100644 --- a/c/triplet.c +++ b/c/triplet.c @@ -34,181 +34,121 @@ /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ -#include "bzgrid.h" #include "triplet.h" -#include "triplet_iw.h" + +#include "bzgrid.h" #include "triplet_grid.h" +#include "triplet_iw.h" -long tpl_get_BZ_triplets_at_q(long (*triplets)[3], - const long grid_point, +long tpl_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point, const ConstBZGrid *bzgrid, - const long *map_triplets) -{ - return tpk_get_BZ_triplets_at_q(triplets, - grid_point, - bzgrid, - map_triplets); + const long *map_triplets) { + return tpk_get_BZ_triplets_at_q(triplets, grid_point, bzgrid, map_triplets); } -long tpl_get_triplets_reciprocal_mesh_at_q(long *map_triplets, - long *map_q, - const long grid_point, - const long mesh[3], - const long is_time_reversal, - const long num_rot, - const long (*rec_rotations)[3][3], - const long swappable) -{ - long num_ir; +long tpl_get_triplets_reciprocal_mesh_at_q( + long *map_triplets, long *map_q, const long grid_point, const long mesh[3], + const long is_time_reversal, const long num_rot, + const long (*rec_rotations)[3][3], const long swappable) { + long num_ir; - num_ir = tpk_get_ir_triplets_at_q(map_triplets, - map_q, - grid_point, - mesh, - is_time_reversal, - rec_rotations, - num_rot, - swappable); - return num_ir; + num_ir = tpk_get_ir_triplets_at_q(map_triplets, map_q, grid_point, mesh, + is_time_reversal, rec_rotations, num_rot, + swappable); + return num_ir; } -void tpl_get_integration_weight(double *iw, - char *iw_zero, - const double *frequency_points, - const long num_band0, - const long relative_grid_address[24][4][3], - const long (*triplets)[3], - const long num_triplets, - const ConstBZGrid *bzgrid, - const double *frequencies1, - const long num_band1, - const double *frequencies2, - const long num_band2, - const long tp_type, - const long openmp_per_triplets, - const long openmp_per_bands) -{ - long i, num_band_prod; - long tp_relative_grid_address[2][24][4][3]; +void tpl_get_integration_weight( + double *iw, char *iw_zero, const double *frequency_points, + const long num_band0, const long relative_grid_address[24][4][3], + const long (*triplets)[3], const long num_triplets, + const ConstBZGrid *bzgrid, const double *frequencies1, const long num_band1, + const double *frequencies2, const long num_band2, const long tp_type, + const long openmp_per_triplets, const long openmp_per_bands) { + long i, num_band_prod; + long tp_relative_grid_address[2][24][4][3]; - tpl_set_relative_grid_address(tp_relative_grid_address, - relative_grid_address, - tp_type); - num_band_prod = num_band0 * num_band1 * num_band2; + tpl_set_relative_grid_address(tp_relative_grid_address, + relative_grid_address, tp_type); + num_band_prod = num_band0 * num_band1 * num_band2; #ifdef PHPYOPENMP #pragma omp parallel for if (openmp_per_triplets) #endif - for (i = 0; i < num_triplets; i++) - { - tpi_get_integration_weight(iw + i * num_band_prod, - iw_zero + i * num_band_prod, - frequency_points, /* f0 */ - num_band0, - tp_relative_grid_address, - triplets[i], - num_triplets, - bzgrid, - frequencies1, /* f1 */ - num_band1, - frequencies2, /* f2 */ - num_band2, - tp_type, - openmp_per_bands); - } + for (i = 0; i < num_triplets; i++) { + tpi_get_integration_weight( + iw + i * num_band_prod, iw_zero + i * num_band_prod, + frequency_points, /* f0 */ + num_band0, tp_relative_grid_address, triplets[i], num_triplets, + bzgrid, frequencies1, /* f1 */ + num_band1, frequencies2, /* f2 */ + num_band2, tp_type, openmp_per_bands); + } } -void tpl_get_integration_weight_with_sigma(double *iw, - char *iw_zero, - const double sigma, - const double sigma_cutoff, - const double *frequency_points, - const long num_band0, - const long (*triplets)[3], - const long num_triplets, - const double *frequencies, - const long num_band, - const long tp_type) -{ - long i, num_band_prod, const_adrs_shift; - double cutoff; +void tpl_get_integration_weight_with_sigma( + double *iw, char *iw_zero, const double sigma, const double sigma_cutoff, + const double *frequency_points, const long num_band0, + const long (*triplets)[3], const long num_triplets, + const double *frequencies, const long num_band, const long tp_type) { + long i, num_band_prod, const_adrs_shift; + double cutoff; - cutoff = sigma * sigma_cutoff; - num_band_prod = num_band0 * num_band * num_band; - const_adrs_shift = num_triplets * num_band0 * num_band * num_band; + cutoff = sigma * sigma_cutoff; + num_band_prod = num_band0 * num_band * num_band; + const_adrs_shift = num_triplets * num_band0 * num_band * num_band; #ifdef PHPYOPENMP #pragma omp parallel for #endif - for (i = 0; i < num_triplets; i++) - { - tpi_get_integration_weight_with_sigma( - iw + i * num_band_prod, - iw_zero + i * num_band_prod, - sigma, - cutoff, - frequency_points, - num_band0, - triplets[i], - const_adrs_shift, - frequencies, - num_band, - tp_type, - 0); - } + for (i = 0; i < num_triplets; i++) { + tpi_get_integration_weight_with_sigma( + iw + i * num_band_prod, iw_zero + i * num_band_prod, sigma, cutoff, + frequency_points, num_band0, triplets[i], const_adrs_shift, + frequencies, num_band, tp_type, 0); + } } -long tpl_is_N(const long triplet[3], const long (*bz_grid_addresses)[3]) -{ - long i, j, sum_q, is_N; +long tpl_is_N(const long triplet[3], const long (*bz_grid_addresses)[3]) { + long i, j, sum_q, is_N; - is_N = 1; - for (i = 0; i < 3; i++) - { - sum_q = 0; - for (j = 0; j < 3; j++) - { /* 1st, 2nd, 3rd triplet */ - sum_q += bz_grid_addresses[triplet[j]][i]; - } - if (sum_q) - { - is_N = 0; - break; - } - } - return is_N; -} - -void tpl_set_relative_grid_address( - long tp_relative_grid_address[2][24][4][3], - const long relative_grid_address[24][4][3], - const long tp_type) -{ - long i, j, k, l; - long signs[2]; - - signs[0] = 1; - signs[1] = 1; - if ((tp_type == 2) || (tp_type == 3)) - { - /* q1+q2+q3=G */ - /* To set q2+1, q3-1 is needed to keep G */ - signs[1] = -1; - } - /* tp_type == 4, q+k_i-k_f=G */ - - for (i = 0; i < 2; i++) - { - for (j = 0; j < 24; j++) - { - for (k = 0; k < 4; k++) - { - for (l = 0; l < 3; l++) - { - tp_relative_grid_address[i][j][k][l] = - relative_grid_address[j][k][l] * signs[i]; + is_N = 1; + for (i = 0; i < 3; i++) { + sum_q = 0; + for (j = 0; j < 3; j++) { /* 1st, 2nd, 3rd triplet */ + sum_q += bz_grid_addresses[triplet[j]][i]; + } + if (sum_q) { + is_N = 0; + break; + } + } + return is_N; +} + +void tpl_set_relative_grid_address(long tp_relative_grid_address[2][24][4][3], + const long relative_grid_address[24][4][3], + const long tp_type) { + long i, j, k, l; + long signs[2]; + + signs[0] = 1; + signs[1] = 1; + if ((tp_type == 2) || (tp_type == 3)) { + /* q1+q2+q3=G */ + /* To set q2+1, q3-1 is needed to keep G */ + signs[1] = -1; + } + /* tp_type == 4, q+k_i-k_f=G */ + + for (i = 0; i < 2; i++) { + for (j = 0; j < 24; j++) { + for (k = 0; k < 4; k++) { + for (l = 0; l < 3; l++) { + tp_relative_grid_address[i][j][k][l] = + relative_grid_address[j][k][l] * signs[i]; + } + } } - } } - } } diff --git a/c/triplet.h b/c/triplet.h index 1f7ed78e..b6489d9c 100644 --- a/c/triplet.h +++ b/c/triplet.h @@ -38,6 +38,7 @@ #define __triplet_H__ #include + #include "bzgrid.h" /* Irreducible triplets of k-points are searched under conservation of */ @@ -46,55 +47,35 @@ /* and map_q[prod(mesh)] are required. rotations are point-group- */ /* operations in real space for which duplicate operations are allowed */ /* in the input. */ -long tpl_get_triplets_reciprocal_mesh_at_q(long *map_triplets, - long *map_q, - const long grid_point, - const long mesh[3], - const long is_time_reversal, - const long num_rot, - const long (*rec_rotations)[3][3], - const long swappable); +long tpl_get_triplets_reciprocal_mesh_at_q( + long *map_triplets, long *map_q, const long grid_point, const long mesh[3], + const long is_time_reversal, const long num_rot, + const long (*rec_rotations)[3][3], const long swappable); /* Irreducible grid-point-triplets in BZ are stored. */ /* triplets are recovered from grid_point and triplet_weights. */ /* BZ boundary is considered in this recovery. Therefore grid addresses */ /* are given not by grid_address, but by bz_grid_address. */ /* triplets[num_ir_triplets][3] = number of non-zero triplets weights*/ /* Number of ir-triplets is returned. */ -long tpl_get_BZ_triplets_at_q(long (*triplets)[3], - const long grid_point, +long tpl_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point, const ConstBZGrid *bzgrid, const long *map_triplets); -void tpl_get_integration_weight(double *iw, - char *iw_zero, - const double *frequency_points, - const long num_band0, - const long relative_grid_address[24][4][3], - const long (*triplets)[3], - const long num_triplets, - const ConstBZGrid *bzgrid, - const double *frequencies1, - const long num_band1, - const double *frequencies2, - const long num_band2, - const long tp_type, - const long openmp_per_triplets, - const long openmp_per_bands); -void tpl_get_integration_weight_with_sigma(double *iw, - char *iw_zero, - const double sigma, - const double sigma_cutoff, - const double *frequency_points, - const long num_band0, - const long (*triplets)[3], - const long num_triplets, - const double *frequencies, - const long num_band, - const long tp_type); +void tpl_get_integration_weight( + double *iw, char *iw_zero, const double *frequency_points, + const long num_band0, const long relative_grid_address[24][4][3], + const long (*triplets)[3], const long num_triplets, + const ConstBZGrid *bzgrid, const double *frequencies1, const long num_band1, + const double *frequencies2, const long num_band2, const long tp_type, + const long openmp_per_triplets, const long openmp_per_bands); +void tpl_get_integration_weight_with_sigma( + double *iw, char *iw_zero, const double sigma, const double sigma_cutoff, + const double *frequency_points, const long num_band0, + const long (*triplets)[3], const long num_triplets, + const double *frequencies, const long num_band, const long tp_type); long tpl_is_N(const long triplet[3], const long (*bz_grid_addresses)[3]); -void tpl_set_relative_grid_address( - long tp_relative_grid_address[2][24][4][3], - const long relative_grid_address[24][4][3], - const long tp_type); +void tpl_set_relative_grid_address(long tp_relative_grid_address[2][24][4][3], + const long relative_grid_address[24][4][3], + const long tp_type); #endif diff --git a/c/triplet_grid.c b/c/triplet_grid.c index d3c72b7b..0a0b45d4 100644 --- a/c/triplet_grid.c +++ b/c/triplet_grid.c @@ -34,33 +34,28 @@ /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ +#include "triplet_grid.h" + #include #include + #include "bzgrid.h" #include "grgrid.h" #include "lagrid.h" #include "triplet.h" -#include "triplet_grid.h" -static long get_ir_triplets_at_q(long *map_triplets, - long *map_q, - const long grid_point, - const long D_diag[3], +static long get_ir_triplets_at_q(long *map_triplets, long *map_q, + const long grid_point, const long D_diag[3], const RotMats *rot_reciprocal, const long swappable); static long get_ir_triplets_at_q_perm_q1q2(long *map_triplets, const long *map_q, const long grid_point, - const long D_diag[3], - const RotMats *rot_reciprocal_q, - const long num_ir_q); -static long get_ir_triplets_at_q_noperm(long *map_triplets, - const long *map_q, + const long D_diag[3]); +static long get_ir_triplets_at_q_noperm(long *map_triplets, const long *map_q, const long grid_point, - const long D_diag[3], - const RotMats *rot_reciprocal_q); -static long get_BZ_triplets_at_q(long (*triplets)[3], - const long grid_point, + const long D_diag[3]); +static long get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point, const ConstBZGrid *bzgrid, const long *map_triplets); static void get_BZ_triplets_at_q_type1(long (*triplets)[3], @@ -73,8 +68,7 @@ static void get_BZ_triplets_at_q_type2(long (*triplets)[3], const ConstBZGrid *bzgrid, const long *ir_q1_gps, const long num_ir); -static double get_squared_distance(const long G[3], - const double LQD_inv[3][3]); +static double get_squared_distance(const long G[3], const double LQD_inv[3][3]); static void get_LQD_inv(double LQD_inv[3][3], const ConstBZGrid *bzgrid); static RotMats *get_reciprocal_point_group_with_q(const RotMats *rot_reciprocal, const long D_diag[3], @@ -84,569 +78,424 @@ static RotMats *get_reciprocal_point_group(const long (*rec_rotations_in)[3][3], const long is_time_reversal, const long is_transpose); -long tpk_get_ir_triplets_at_q(long *map_triplets, - long *map_q, - const long grid_point, - const long D_diag[3], +long tpk_get_ir_triplets_at_q(long *map_triplets, long *map_q, + const long grid_point, const long D_diag[3], const long is_time_reversal, const long (*rec_rotations_in)[3][3], - const long num_rot, - const long swappable) -{ - long num_ir; - RotMats *rotations; + const long num_rot, const long swappable) { + long num_ir; + RotMats *rotations; - rotations = get_reciprocal_point_group(rec_rotations_in, - num_rot, - is_time_reversal, - 0); - if (rotations == NULL) - { - return 0; - } - - num_ir = get_ir_triplets_at_q(map_triplets, - map_q, - grid_point, - D_diag, - rotations, - swappable); - bzg_free_RotMats(rotations); - rotations = NULL; - - return num_ir; -} - -long tpk_get_BZ_triplets_at_q(long (*triplets)[3], - const long grid_point, - const ConstBZGrid *bzgrid, - const long *map_triplets) -{ - return get_BZ_triplets_at_q(triplets, - grid_point, - bzgrid, - map_triplets); -} - -static long get_ir_triplets_at_q(long *map_triplets, - long *map_q, - const long grid_point, - const long D_diag[3], - const RotMats *rot_reciprocal, - const long swappable) -{ - long i, num_ir_q, num_ir_triplets; - long PS[3]; - RotMats *rot_reciprocal_q; - - rot_reciprocal_q = NULL; - - for (i = 0; i < 3; i++) - { - PS[i] = 0; - } - - /* Search irreducible q-points (map_q) with a stabilizer. */ - rot_reciprocal_q = get_reciprocal_point_group_with_q(rot_reciprocal, - D_diag, - grid_point); - - grg_get_ir_grid_map(map_q, - rot_reciprocal_q->mat, - rot_reciprocal_q->size, - D_diag, - PS); - num_ir_q = 0; - for (i = 0; i < D_diag[0] * D_diag[1] * D_diag[2]; i++) - { - if (map_q[i] == i) - { - num_ir_q++; + rotations = get_reciprocal_point_group(rec_rotations_in, num_rot, + is_time_reversal, 0); + if (rotations == NULL) { + return 0; } - } - if (swappable) - { - num_ir_triplets = get_ir_triplets_at_q_perm_q1q2(map_triplets, - map_q, - grid_point, - D_diag, - rot_reciprocal_q, - num_ir_q); - } - else - { - num_ir_triplets = get_ir_triplets_at_q_noperm(map_triplets, - map_q, - grid_point, - D_diag, - rot_reciprocal_q); - } + num_ir = get_ir_triplets_at_q(map_triplets, map_q, grid_point, D_diag, + rotations, swappable); + bzg_free_RotMats(rotations); + rotations = NULL; - bzg_free_RotMats(rot_reciprocal_q); - rot_reciprocal_q = NULL; + return num_ir; +} - return num_ir_triplets; +long tpk_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point, + const ConstBZGrid *bzgrid, + const long *map_triplets) { + return get_BZ_triplets_at_q(triplets, grid_point, bzgrid, map_triplets); +} + +static long get_ir_triplets_at_q(long *map_triplets, long *map_q, + const long grid_point, const long D_diag[3], + const RotMats *rot_reciprocal, + const long swappable) { + long i, num_ir_q, num_ir_triplets; + long PS[3]; + RotMats *rot_reciprocal_q; + + rot_reciprocal_q = NULL; + + for (i = 0; i < 3; i++) { + PS[i] = 0; + } + + /* Search irreducible q-points (map_q) with a stabilizer. */ + rot_reciprocal_q = + get_reciprocal_point_group_with_q(rot_reciprocal, D_diag, grid_point); + + grg_get_ir_grid_map(map_q, rot_reciprocal_q->mat, rot_reciprocal_q->size, + D_diag, PS); + num_ir_q = 0; + for (i = 0; i < D_diag[0] * D_diag[1] * D_diag[2]; i++) { + if (map_q[i] == i) { + num_ir_q++; + } + } + + if (swappable) { + num_ir_triplets = get_ir_triplets_at_q_perm_q1q2(map_triplets, map_q, + grid_point, D_diag); + } else { + num_ir_triplets = get_ir_triplets_at_q_noperm(map_triplets, map_q, + grid_point, D_diag); + } + + bzg_free_RotMats(rot_reciprocal_q); + rot_reciprocal_q = NULL; + + return num_ir_triplets; } static long get_ir_triplets_at_q_perm_q1q2(long *map_triplets, const long *map_q, const long grid_point, - const long D_diag[3], - const RotMats *rot_reciprocal_q, - const long num_ir_q) -{ - long i, j, num_grid, num_ir_triplets, ir_gp, count; - long adrs0[3], adrs1[3], adrs2[3]; - long *ir_gps_at_q, *q_2; + const long D_diag[3]) { + long j, num_grid, num_ir_triplets, gp1, gp2; + long adrs0[3], adrs1[3], adrs2[3]; - ir_gps_at_q = NULL; - q_2 = NULL; - num_ir_triplets = 0; + num_ir_triplets = 0; + num_grid = D_diag[0] * D_diag[1] * D_diag[2]; + grg_get_grid_address_from_index(adrs0, grid_point, D_diag); - num_grid = D_diag[0] * D_diag[1] * D_diag[2]; - - if ((q_2 = (long *)malloc(sizeof(long) * num_ir_q)) == NULL) - { - warning_print("Memory could not be allocated."); - goto ret; - } - - if ((ir_gps_at_q = (long *)malloc(sizeof(long) * num_ir_q)) == NULL) - { - warning_print("Memory could not be allocated."); - goto ret; - } - - count = 0; - for (i = 0; i < num_grid; i++) - { - if (map_q[i] == i) - { - ir_gps_at_q[count] = i; - count++; + // #ifdef PHPYOPENMP + // #pragma omp parallel for private(j, gp2, adrs1, adrs2) + // #endif + for (gp1 = 0; gp1 < num_grid; gp1++) { + if (map_q[gp1] == gp1) { + grg_get_grid_address_from_index(adrs1, gp1, D_diag); + for (j = 0; j < 3; j++) { + adrs2[j] = -adrs0[j] - adrs1[j]; + } + /* If map_q[gp2] is smaller than current gp1, map_q[gp2] should */ + /* equal to a previous gp1 for which map_triplets is already */ + /* filled. So the counter is not incremented. */ + gp2 = grg_get_grid_index(adrs2, D_diag); + if (map_q[gp2] < gp1) { + map_triplets[gp1] = map_q[gp2]; + } else { + map_triplets[gp1] = gp1; + num_ir_triplets++; + } + } } - } - - grg_get_grid_address_from_index(adrs0, grid_point, D_diag); - -#ifdef PHPYOPENMP -#pragma omp parallel for private(j, adrs1, adrs2) -#endif - for (i = 0; i < num_ir_q; i++) - { - grg_get_grid_address_from_index(adrs1, ir_gps_at_q[i], D_diag); - for (j = 0; j < 3; j++) - { /* q'' */ - adrs2[j] = -adrs0[j] - adrs1[j]; - } - q_2[i] = grg_get_grid_index(adrs2, D_diag); - } - - /* map_q[q_2[i]] is in ir_gps_at_q. */ - /* If map_q[q_2[i]] < ir_gps_at_q[i], this should be already */ - /* stored. So the counter is not incremented. */ - for (i = 0; i < num_ir_q; i++) - { - ir_gp = ir_gps_at_q[i]; - if (map_q[q_2[i]] < ir_gp) - { - map_triplets[ir_gp] = map_q[q_2[i]]; - } - else - { - map_triplets[ir_gp] = ir_gp; - num_ir_triplets++; - } - } +/* Fill unfilled elements of map_triplets. */ #ifdef PHPYOPENMP #pragma omp parallel for #endif - for (i = 0; i < num_grid; i++) - { - map_triplets[i] = map_triplets[map_q[i]]; - } + for (gp1 = 0; gp1 < num_grid; gp1++) { + if (map_q[gp1] != gp1) { + /* map_q[gp1] is one of ir-gp1, so it is already filled. */ + map_triplets[gp1] = map_triplets[map_q[gp1]]; + } + } -ret: - if (q_2) - { - free(q_2); - q_2 = NULL; - } - if (ir_gps_at_q) - { - free(ir_gps_at_q); - ir_gps_at_q = NULL; - } - return num_ir_triplets; + return num_ir_triplets; } -static long get_ir_triplets_at_q_noperm(long *map_triplets, - const long *map_q, +static long get_ir_triplets_at_q_noperm(long *map_triplets, const long *map_q, const long grid_point, - const long D_diag[3], - const RotMats *rot_reciprocal_q) -{ - long i, num_grid, num_ir_triplets; + const long D_diag[3]) { + long gp1, num_grid, num_ir_triplets; - num_ir_triplets = 0; - num_grid = D_diag[0] * D_diag[1] * D_diag[2]; + num_ir_triplets = 0; + num_grid = D_diag[0] * D_diag[1] * D_diag[2]; - for (i = 0; i < num_grid; i++) - { - if (map_q[i] == i) - { - map_triplets[i] = i; - num_ir_triplets++; + for (gp1 = 0; gp1 < num_grid; gp1++) { + if (map_q[gp1] == gp1) { + map_triplets[gp1] = gp1; + num_ir_triplets++; + } else { + map_triplets[gp1] = map_triplets[map_q[gp1]]; + } } - else - { - map_triplets[i] = map_triplets[map_q[i]]; - } - } - return num_ir_triplets; + return num_ir_triplets; } -static long get_BZ_triplets_at_q(long (*triplets)[3], - const long grid_point, +static long get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point, const ConstBZGrid *bzgrid, - const long *map_triplets) -{ - long i, num_ir; - long *ir_q1_gps; + const long *map_triplets) { + long gp1, num_ir; + long *ir_q1_gps; - ir_q1_gps = NULL; - num_ir = 0; + ir_q1_gps = NULL; + num_ir = 0; - if ((ir_q1_gps = (long *)malloc(sizeof(long) * bzgrid->size)) == NULL) - { - warning_print("Memory could not be allocated."); - goto ret; - } - - for (i = 0; i < bzgrid->size; i++) - { - if (map_triplets[i] == i) - { - ir_q1_gps[num_ir] = i; - num_ir++; + if ((ir_q1_gps = (long *)malloc(sizeof(long) * bzgrid->size)) == NULL) { + warning_print("Memory could not be allocated."); + goto ret; } - } - if (bzgrid->type == 1) - { - get_BZ_triplets_at_q_type1(triplets, - grid_point, - bzgrid, - ir_q1_gps, - num_ir); - } - else - { - get_BZ_triplets_at_q_type2(triplets, - grid_point, - bzgrid, - ir_q1_gps, - num_ir); - } + for (gp1 = 0; gp1 < bzgrid->size; gp1++) { + if (map_triplets[gp1] == gp1) { + ir_q1_gps[num_ir] = gp1; + num_ir++; + } + } - free(ir_q1_gps); - ir_q1_gps = NULL; + if (bzgrid->type == 1) { + get_BZ_triplets_at_q_type1(triplets, grid_point, bzgrid, ir_q1_gps, + num_ir); + } else { + get_BZ_triplets_at_q_type2(triplets, grid_point, bzgrid, ir_q1_gps, + num_ir); + } + + free(ir_q1_gps); + ir_q1_gps = NULL; ret: - return num_ir; + return num_ir; } static void get_BZ_triplets_at_q_type1(long (*triplets)[3], const long grid_point, const ConstBZGrid *bzgrid, const long *ir_q1_gps, - const long num_ir) -{ - long i, j, gp2, num_gp, num_bzgp, bz0, bz1, bz2; - long bzgp[3], G[3]; - long bz_adrs0[3], bz_adrs1[3], bz_adrs2[3]; - const long *gp_map; - const long(*bz_adrs)[3]; - double d2, min_d2, tolerance; - double LQD_inv[3][3]; + const long num_ir) { + long i, j, gp2, num_gp, num_bzgp, bz0, bz1, bz2; + long bzgp[3], G[3]; + long bz_adrs0[3], bz_adrs1[3], bz_adrs2[3]; + const long *gp_map; + const long(*bz_adrs)[3]; + double d2, min_d2, tolerance; + double LQD_inv[3][3]; - gp_map = bzgrid->gp_map; - bz_adrs = bzgrid->addresses; - get_LQD_inv(LQD_inv, bzgrid); - /* This tolerance is used to be consistent to BZ reduction in bzgrid. */ - tolerance = bzg_get_tolerance_for_BZ_reduction((BZGrid *)bzgrid); + gp_map = bzgrid->gp_map; + bz_adrs = bzgrid->addresses; + get_LQD_inv(LQD_inv, bzgrid); + /* This tolerance is used to be consistent to BZ reduction in bzgrid. */ + tolerance = bzg_get_tolerance_for_BZ_reduction((BZGrid *)bzgrid); - for (i = 0; i < 3; i++) - { - bz_adrs0[i] = bz_adrs[grid_point][i]; - } - num_gp = bzgrid->D_diag[0] * bzgrid->D_diag[1] * bzgrid->D_diag[2]; - num_bzgp = num_gp * 8; + for (i = 0; i < 3; i++) { + bz_adrs0[i] = bz_adrs[grid_point][i]; + } + num_gp = bzgrid->D_diag[0] * bzgrid->D_diag[1] * bzgrid->D_diag[2]; + num_bzgp = num_gp * 8; #ifdef PHPYOPENMP -#pragma omp parallel for private(j, gp2, bzgp, G, bz_adrs1, bz_adrs2, d2, min_d2, bz0, bz1, bz2) +#pragma omp parallel for private(j, gp2, bzgp, G, bz_adrs1, bz_adrs2, d2, \ + min_d2, bz0, bz1, bz2) #endif - for (i = 0; i < num_ir; i++) - { - for (j = 0; j < 3; j++) - { - bz_adrs1[j] = bz_adrs[ir_q1_gps[i]][j]; - bz_adrs2[j] = -bz_adrs0[j] - bz_adrs1[j]; - } - gp2 = grg_get_grid_index(bz_adrs2, bzgrid->D_diag); - /* Negative value is the signal to initialize min_d2 later. */ - min_d2 = -1; - for (bz0 = 0; - bz0 < gp_map[num_bzgp + grid_point + 1] - gp_map[num_bzgp + grid_point] + 1; - bz0++) - { - if (bz0 == 0) - { - bzgp[0] = grid_point; - } - else - { - bzgp[0] = num_gp + gp_map[num_bzgp + grid_point] + bz0 - 1; - } - for (bz1 = 0; - bz1 < gp_map[num_bzgp + ir_q1_gps[i] + 1] - gp_map[num_bzgp + ir_q1_gps[i]] + 1; - bz1++) - { - if (bz1 == 0) - { - bzgp[1] = ir_q1_gps[i]; + for (i = 0; i < num_ir; i++) { + for (j = 0; j < 3; j++) { + bz_adrs1[j] = bz_adrs[ir_q1_gps[i]][j]; + bz_adrs2[j] = -bz_adrs0[j] - bz_adrs1[j]; } - else - { - bzgp[1] = num_gp + gp_map[num_bzgp + ir_q1_gps[i]] + bz1 - 1; - } - for (bz2 = 0; - bz2 < gp_map[num_bzgp + gp2 + 1] - gp_map[num_bzgp + gp2] + 1; - bz2++) - { - if (bz2 == 0) - { - bzgp[2] = gp2; - } - else - { - bzgp[2] = num_gp + gp_map[num_bzgp + gp2] + bz2 - 1; - } - for (j = 0; j < 3; j++) - { - G[j] = bz_adrs[bzgp[0]][j] + bz_adrs[bzgp[1]][j] + bz_adrs[bzgp[2]][j]; - } - if (G[0] == 0 && G[1] == 0 && G[2] == 0) - { - for (j = 0; j < 3; j++) - { - triplets[i][j] = bzgp[j]; + gp2 = grg_get_grid_index(bz_adrs2, bzgrid->D_diag); + /* Negative value is the signal to initialize min_d2 later. */ + min_d2 = -1; + for (bz0 = 0; bz0 < gp_map[num_bzgp + grid_point + 1] - + gp_map[num_bzgp + grid_point] + 1; + bz0++) { + if (bz0 == 0) { + bzgp[0] = grid_point; + } else { + bzgp[0] = num_gp + gp_map[num_bzgp + grid_point] + bz0 - 1; } - goto found; - } - d2 = get_squared_distance(G, LQD_inv); - if (d2 < min_d2 - tolerance || min_d2 < 0) - { - min_d2 = d2; - for (j = 0; j < 3; j++) - { - triplets[i][j] = bzgp[j]; + for (bz1 = 0; bz1 < gp_map[num_bzgp + ir_q1_gps[i] + 1] - + gp_map[num_bzgp + ir_q1_gps[i]] + 1; + bz1++) { + if (bz1 == 0) { + bzgp[1] = ir_q1_gps[i]; + } else { + bzgp[1] = + num_gp + gp_map[num_bzgp + ir_q1_gps[i]] + bz1 - 1; + } + for (bz2 = 0; bz2 < gp_map[num_bzgp + gp2 + 1] - + gp_map[num_bzgp + gp2] + 1; + bz2++) { + if (bz2 == 0) { + bzgp[2] = gp2; + } else { + bzgp[2] = num_gp + gp_map[num_bzgp + gp2] + bz2 - 1; + } + for (j = 0; j < 3; j++) { + G[j] = bz_adrs[bzgp[0]][j] + bz_adrs[bzgp[1]][j] + + bz_adrs[bzgp[2]][j]; + } + if (G[0] == 0 && G[1] == 0 && G[2] == 0) { + for (j = 0; j < 3; j++) { + triplets[i][j] = bzgp[j]; + } + goto found; + } + d2 = get_squared_distance(G, LQD_inv); + if (d2 < min_d2 - tolerance || min_d2 < 0) { + min_d2 = d2; + for (j = 0; j < 3; j++) { + triplets[i][j] = bzgp[j]; + } + } + } } - } } - } + found:; } - found:; - } } static void get_BZ_triplets_at_q_type2(long (*triplets)[3], const long grid_point, const ConstBZGrid *bzgrid, const long *ir_q1_gps, - const long num_ir) -{ - long i, j, gp0, gp2; - long bzgp[3], G[3]; - long bz_adrs0[3], bz_adrs1[3], bz_adrs2[3]; - const long *gp_map; - const long(*bz_adrs)[3]; - double d2, min_d2, tolerance; - double LQD_inv[3][3]; + const long num_ir) { + long i, j, gp0, gp2; + long bzgp[3], G[3]; + long bz_adrs0[3], bz_adrs1[3], bz_adrs2[3]; + const long *gp_map; + const long(*bz_adrs)[3]; + double d2, min_d2, tolerance; + double LQD_inv[3][3]; - gp_map = bzgrid->gp_map; - bz_adrs = bzgrid->addresses; - get_LQD_inv(LQD_inv, bzgrid); - /* This tolerance is used to be consistent to BZ reduction in bzgrid. */ - tolerance = bzg_get_tolerance_for_BZ_reduction((BZGrid *)bzgrid); + gp_map = bzgrid->gp_map; + bz_adrs = bzgrid->addresses; + get_LQD_inv(LQD_inv, bzgrid); + /* This tolerance is used to be consistent to BZ reduction in bzgrid. */ + tolerance = bzg_get_tolerance_for_BZ_reduction((BZGrid *)bzgrid); - for (i = 0; i < 3; i++) - { - bz_adrs0[i] = bz_adrs[grid_point][i]; - } - gp0 = grg_get_grid_index(bz_adrs0, bzgrid->D_diag); + for (i = 0; i < 3; i++) { + bz_adrs0[i] = bz_adrs[grid_point][i]; + } + gp0 = grg_get_grid_index(bz_adrs0, bzgrid->D_diag); #ifdef PHPYOPENMP -#pragma omp parallel for private(j, gp2, bzgp, G, bz_adrs1, bz_adrs2, d2, min_d2) +#pragma omp parallel for private(j, gp2, bzgp, G, bz_adrs1, bz_adrs2, d2, \ + min_d2) #endif - for (i = 0; i < num_ir; i++) - { - for (j = 0; j < 3; j++) - { - bz_adrs1[j] = bz_adrs[gp_map[ir_q1_gps[i]]][j]; - bz_adrs2[j] = -bz_adrs0[j] - bz_adrs1[j]; - } - gp2 = grg_get_grid_index(bz_adrs2, bzgrid->D_diag); - /* Negative value is the signal to initialize min_d2 later. */ - min_d2 = -1; - for (bzgp[0] = gp_map[gp0]; bzgp[0] < gp_map[gp0 + 1]; bzgp[0]++) - { - for (bzgp[1] = gp_map[ir_q1_gps[i]]; - bzgp[1] < gp_map[ir_q1_gps[i] + 1]; bzgp[1]++) - { - for (bzgp[2] = gp_map[gp2]; bzgp[2] < gp_map[gp2 + 1]; bzgp[2]++) - { - for (j = 0; j < 3; j++) - { - G[j] = bz_adrs[bzgp[0]][j] + bz_adrs[bzgp[1]][j] + bz_adrs[bzgp[2]][j]; - } - if (G[0] == 0 && G[1] == 0 && G[2] == 0) - { - for (j = 0; j < 3; j++) - { - triplets[i][j] = bzgp[j]; - } - goto found; - } - d2 = get_squared_distance(G, LQD_inv); - if (d2 < min_d2 - tolerance || min_d2 < 0) - { - min_d2 = d2; - for (j = 0; j < 3; j++) - { - triplets[i][j] = bzgp[j]; - } - } + for (i = 0; i < num_ir; i++) { + for (j = 0; j < 3; j++) { + bz_adrs1[j] = bz_adrs[gp_map[ir_q1_gps[i]]][j]; + bz_adrs2[j] = -bz_adrs0[j] - bz_adrs1[j]; } - } + gp2 = grg_get_grid_index(bz_adrs2, bzgrid->D_diag); + /* Negative value is the signal to initialize min_d2 later. */ + min_d2 = -1; + for (bzgp[0] = gp_map[gp0]; bzgp[0] < gp_map[gp0 + 1]; bzgp[0]++) { + for (bzgp[1] = gp_map[ir_q1_gps[i]]; + bzgp[1] < gp_map[ir_q1_gps[i] + 1]; bzgp[1]++) { + for (bzgp[2] = gp_map[gp2]; bzgp[2] < gp_map[gp2 + 1]; + bzgp[2]++) { + for (j = 0; j < 3; j++) { + G[j] = bz_adrs[bzgp[0]][j] + bz_adrs[bzgp[1]][j] + + bz_adrs[bzgp[2]][j]; + } + if (G[0] == 0 && G[1] == 0 && G[2] == 0) { + for (j = 0; j < 3; j++) { + triplets[i][j] = bzgp[j]; + } + goto found; + } + d2 = get_squared_distance(G, LQD_inv); + if (d2 < min_d2 - tolerance || min_d2 < 0) { + min_d2 = d2; + for (j = 0; j < 3; j++) { + triplets[i][j] = bzgp[j]; + } + } + } + } + } + found:; } - found:; - } } static double get_squared_distance(const long G[3], - const double LQD_inv[3][3]) -{ - double d, d2; - long i; + const double LQD_inv[3][3]) { + double d, d2; + long i; - d2 = 0; - for (i = 0; i < 3; i++) - { - d = LQD_inv[i][0] * G[0] + LQD_inv[i][1] * G[1] + LQD_inv[i][2] * G[2]; - d2 += d * d; - } + d2 = 0; + for (i = 0; i < 3; i++) { + d = LQD_inv[i][0] * G[0] + LQD_inv[i][1] * G[1] + LQD_inv[i][2] * G[2]; + d2 += d * d; + } - return d2; + return d2; } -static void get_LQD_inv(double LQD_inv[3][3], const ConstBZGrid *bzgrid) -{ - long i, j, k; +static void get_LQD_inv(double LQD_inv[3][3], const ConstBZGrid *bzgrid) { + long i, j, k; - /* LQD^-1 */ - for (i = 0; i < 3; i++) - { - for (j = 0; j < 3; j++) - { - for (k = 0; k < 3; k++) - { - LQD_inv[i][k] = bzgrid->reclat[i][j] * bzgrid->Q[j][k] / bzgrid->D_diag[k]; - } + /* LQD^-1 */ + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 3; k++) { + LQD_inv[i][k] = + bzgrid->reclat[i][j] * bzgrid->Q[j][k] / bzgrid->D_diag[k]; + } + } } - } } /* Return NULL if failed */ static RotMats *get_reciprocal_point_group_with_q(const RotMats *rot_reciprocal, const long D_diag[3], - const long grid_point) -{ - long i, num_rot, gp_rot; - long *ir_rot; - long adrs[3], adrs_rot[3]; - RotMats *rot_reciprocal_q; + const long grid_point) { + long i, num_rot, gp_rot; + long *ir_rot; + long adrs[3], adrs_rot[3]; + RotMats *rot_reciprocal_q; - ir_rot = NULL; - rot_reciprocal_q = NULL; - num_rot = 0; + ir_rot = NULL; + rot_reciprocal_q = NULL; + num_rot = 0; - grg_get_grid_address_from_index(adrs, grid_point, D_diag); + grg_get_grid_address_from_index(adrs, grid_point, D_diag); - if ((ir_rot = (long *)malloc(sizeof(long) * rot_reciprocal->size)) == NULL) - { - warning_print("Memory of ir_rot could not be allocated."); - return NULL; - } - - for (i = 0; i < rot_reciprocal->size; i++) - { - ir_rot[i] = -1; - } - for (i = 0; i < rot_reciprocal->size; i++) - { - lagmat_multiply_matrix_vector_l3(adrs_rot, rot_reciprocal->mat[i], adrs); - gp_rot = grg_get_grid_index(adrs_rot, D_diag); - - if (gp_rot == grid_point) - { - ir_rot[num_rot] = i; - num_rot++; + if ((ir_rot = (long *)malloc(sizeof(long) * rot_reciprocal->size)) == + NULL) { + warning_print("Memory of ir_rot could not be allocated."); + return NULL; } - } - if ((rot_reciprocal_q = bzg_alloc_RotMats(num_rot)) != NULL) - { - for (i = 0; i < num_rot; i++) - { - lagmat_copy_matrix_l3(rot_reciprocal_q->mat[i], - rot_reciprocal->mat[ir_rot[i]]); + for (i = 0; i < rot_reciprocal->size; i++) { + ir_rot[i] = -1; } - } + for (i = 0; i < rot_reciprocal->size; i++) { + lagmat_multiply_matrix_vector_l3(adrs_rot, rot_reciprocal->mat[i], + adrs); + gp_rot = grg_get_grid_index(adrs_rot, D_diag); - free(ir_rot); - ir_rot = NULL; + if (gp_rot == grid_point) { + ir_rot[num_rot] = i; + num_rot++; + } + } - return rot_reciprocal_q; + if ((rot_reciprocal_q = bzg_alloc_RotMats(num_rot)) != NULL) { + for (i = 0; i < num_rot; i++) { + lagmat_copy_matrix_l3(rot_reciprocal_q->mat[i], + rot_reciprocal->mat[ir_rot[i]]); + } + } + + free(ir_rot); + ir_rot = NULL; + + return rot_reciprocal_q; } static RotMats *get_reciprocal_point_group(const long (*rec_rotations_in)[3][3], const long num_rot, const long is_time_reversal, - const long is_transpose) -{ - long i, num_rot_out; - long rec_rotations_out[48][3][3]; - RotMats *rec_rotations; + const long is_transpose) { + long i, num_rot_out; + long rec_rotations_out[48][3][3]; + RotMats *rec_rotations; - num_rot_out = grg_get_reciprocal_point_group(rec_rotations_out, - rec_rotations_in, - num_rot, - is_time_reversal, - is_transpose); - if (num_rot_out == 0) - { - return NULL; - } + num_rot_out = + grg_get_reciprocal_point_group(rec_rotations_out, rec_rotations_in, + num_rot, is_time_reversal, is_transpose); + if (num_rot_out == 0) { + return NULL; + } - rec_rotations = bzg_alloc_RotMats(num_rot_out); - for (i = 0; i < num_rot_out; i++) - { - lagmat_copy_matrix_l3(rec_rotations->mat[i], rec_rotations_out[i]); - } + rec_rotations = bzg_alloc_RotMats(num_rot_out); + for (i = 0; i < num_rot_out; i++) { + lagmat_copy_matrix_l3(rec_rotations->mat[i], rec_rotations_out[i]); + } - return rec_rotations; + return rec_rotations; } diff --git a/c/triplet_grid.h b/c/triplet_grid.h index 1c792622..4b22af2c 100644 --- a/c/triplet_grid.h +++ b/c/triplet_grid.h @@ -37,18 +37,15 @@ #ifndef __triplet_grid_H__ #define __triplet_grid_H__ +#include "bzgrid.h" #include "lagrid.h" -long tpk_get_ir_triplets_at_q(long *map_triplets, - long *map_q, - const long grid_point, - const long D_diag[3], +long tpk_get_ir_triplets_at_q(long *map_triplets, long *map_q, + const long grid_point, const long D_diag[3], const long is_time_reversal, const long (*rec_rotations_in)[3][3], - const long num_rot, - const long swappable); -long tpk_get_BZ_triplets_at_q(long (*triplets)[3], - const long grid_point, + const long num_rot, const long swappable); +long tpk_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point, const ConstBZGrid *bzgrid, const long *map_triplets); diff --git a/c/triplet_iw.c b/c/triplet_iw.c index 82983438..51044929 100644 --- a/c/triplet_iw.c +++ b/c/triplet_iw.c @@ -32,270 +32,208 @@ /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ +#include "triplet_iw.h" + #include + #include "grgrid.h" #include "phonoc_utils.h" -#include "triplet.h" -#include "triplet_iw.h" #include "tetrahedron_method.h" +#include "triplet.h" static void set_freq_vertices(double freq_vertices[3][24][4], const double *frequencies1, const double *frequencies2, const long vertices[2][24][4], - const long num_band1, - const long num_band2, - const long b1, - const long b2, - const long tp_type); -static long set_g(double g[3], - const double f0, - const double freq_vertices[3][24][4], - const long max_i); + const long num_band1, const long num_band2, + const long b1, const long b2, const long tp_type); +static long set_g(double g[3], const double f0, + const double freq_vertices[3][24][4], const long max_i); static void get_triplet_tetrahedra_vertices( - long vertices[2][24][4], - const long tp_relative_grid_address[2][24][4][3], - const long triplet[3], - const ConstBZGrid *bzgrid); -static void -get_neighboring_grid_points_type1(long *neighboring_grid_points, - const long grid_point, - const long (*relative_grid_address)[3], - const long num_relative_grid_address, - const ConstBZGrid *bzgrid); -static void -get_neighboring_grid_points_type2(long *neighboring_grid_points, - const long grid_point, - const long (*relative_grid_address)[3], - const long num_relative_grid_address, - const ConstBZGrid *bzgrid); + long vertices[2][24][4], const long tp_relative_grid_address[2][24][4][3], + const long triplet[3], const ConstBZGrid *bzgrid); +static void get_neighboring_grid_points_type1( + long *neighboring_grid_points, const long grid_point, + const long (*relative_grid_address)[3], + const long num_relative_grid_address, const ConstBZGrid *bzgrid); +static void get_neighboring_grid_points_type2( + long *neighboring_grid_points, const long grid_point, + const long (*relative_grid_address)[3], + const long num_relative_grid_address, const ConstBZGrid *bzgrid); -void tpi_get_integration_weight(double *iw, - char *iw_zero, - const double *frequency_points, - const long num_band0, - const long tp_relative_grid_address[2][24][4][3], - const long triplets[3], - const long num_triplets, - const ConstBZGrid *bzgrid, - const double *frequencies1, - const long num_band1, - const double *frequencies2, - const long num_band2, - const long tp_type, - const long openmp_per_bands) -{ - long max_i, j, b1, b2, b12, num_band_prod, adrs_shift; - long vertices[2][24][4]; - double g[3]; - double freq_vertices[3][24][4]; +void tpi_get_integration_weight( + double *iw, char *iw_zero, const double *frequency_points, + const long num_band0, const long tp_relative_grid_address[2][24][4][3], + const long triplets[3], const long num_triplets, const ConstBZGrid *bzgrid, + const double *frequencies1, const long num_band1, + const double *frequencies2, const long num_band2, const long tp_type, + const long openmp_per_bands) { + long max_i, j, b1, b2, b12, num_band_prod, adrs_shift; + long vertices[2][24][4]; + double g[3]; + double freq_vertices[3][24][4]; - get_triplet_tetrahedra_vertices(vertices, - tp_relative_grid_address, - triplets, - bzgrid); + get_triplet_tetrahedra_vertices(vertices, tp_relative_grid_address, + triplets, bzgrid); - num_band_prod = num_triplets * num_band0 * num_band1 * num_band2; + num_band_prod = num_triplets * num_band0 * num_band1 * num_band2; - /* tp_type: Type of integration weights stored */ - /* */ - /* g0 -> \delta(f0 - (-f1 + f2)) */ - /* g1 -> \delta(f0 - (f1 - f2)) */ - /* g2 -> \delta(f0 - (f1 + f2)) */ - /* */ - /* tp_type = 2: (g[2], g[0] - g[1]) mainly for ph-ph */ - /* tp_type = 3: (g[2], g[0] - g[1], g[0] + g[1] + g[2]) mainly for ph-ph */ - /* tp_type = 4: (g[0]) mainly for el-ph phonon decay, */ - /* f0: ph, f1: el_i, f2: el_f */ + /* tp_type: Type of integration weights stored */ + /* */ + /* g0 -> \delta(f0 - (-f1 + f2)) */ + /* g1 -> \delta(f0 - (f1 - f2)) */ + /* g2 -> \delta(f0 - (f1 + f2)) */ + /* */ + /* tp_type = 2: (g[2], g[0] - g[1]) mainly for ph-ph */ + /* tp_type = 3: (g[2], g[0] - g[1], g[0] + g[1] + g[2]) mainly for ph-ph */ + /* tp_type = 4: (g[0]) mainly for el-ph phonon decay, */ + /* f0: ph, f1: el_i, f2: el_f */ - if ((tp_type == 2) || (tp_type == 3)) - { - max_i = 3; - } - if (tp_type == 4) - { - max_i = 1; - } + if ((tp_type == 2) || (tp_type == 3)) { + max_i = 3; + } + if (tp_type == 4) { + max_i = 1; + } #ifdef PHPYOPENMP -#pragma omp parallel for private(j, b1, b2, adrs_shift, g, freq_vertices) if (openmp_per_bands) +#pragma omp parallel for private(j, b1, b2, adrs_shift, g, \ + freq_vertices) if (openmp_per_bands) #endif - for (b12 = 0; b12 < num_band1 * num_band2; b12++) - { - b1 = b12 / num_band2; - b2 = b12 % num_band2; - set_freq_vertices(freq_vertices, frequencies1, frequencies2, - vertices, num_band1, num_band2, b1, b2, tp_type); - for (j = 0; j < num_band0; j++) - { - adrs_shift = j * num_band1 * num_band2 + b1 * num_band2 + b2; - iw_zero[adrs_shift] = set_g(g, frequency_points[j], freq_vertices, max_i); - if (tp_type == 2) - { - iw[adrs_shift] = g[2]; - adrs_shift += num_band_prod; - iw[adrs_shift] = g[0] - g[1]; - } - if (tp_type == 3) - { - iw[adrs_shift] = g[2]; - adrs_shift += num_band_prod; - iw[adrs_shift] = g[0] - g[1]; - adrs_shift += num_band_prod; - iw[adrs_shift] = g[0] + g[1] + g[2]; - } - if (tp_type == 4) - { - iw[adrs_shift] = g[0]; - } + for (b12 = 0; b12 < num_band1 * num_band2; b12++) { + b1 = b12 / num_band2; + b2 = b12 % num_band2; + set_freq_vertices(freq_vertices, frequencies1, frequencies2, vertices, + num_band1, num_band2, b1, b2, tp_type); + for (j = 0; j < num_band0; j++) { + adrs_shift = j * num_band1 * num_band2 + b1 * num_band2 + b2; + iw_zero[adrs_shift] = + set_g(g, frequency_points[j], freq_vertices, max_i); + if (tp_type == 2) { + iw[adrs_shift] = g[2]; + adrs_shift += num_band_prod; + iw[adrs_shift] = g[0] - g[1]; + } + if (tp_type == 3) { + iw[adrs_shift] = g[2]; + adrs_shift += num_band_prod; + iw[adrs_shift] = g[0] - g[1]; + adrs_shift += num_band_prod; + iw[adrs_shift] = g[0] + g[1] + g[2]; + } + if (tp_type == 4) { + iw[adrs_shift] = g[0]; + } + } } - } } -void tpi_get_integration_weight_with_sigma(double *iw, - char *iw_zero, - const double sigma, - const double cutoff, - const double *frequency_points, - const long num_band0, - const long triplet[3], - const long const_adrs_shift, - const double *frequencies, - const long num_band, - const long tp_type, - const long openmp_per_bands) -{ - long j, b12, b1, b2, adrs_shift; - double f0, f1, f2, g0, g1, g2; +void tpi_get_integration_weight_with_sigma( + double *iw, char *iw_zero, const double sigma, const double cutoff, + const double *frequency_points, const long num_band0, const long triplet[3], + const long const_adrs_shift, const double *frequencies, const long num_band, + const long tp_type, const long openmp_per_bands) { + long j, b12, b1, b2, adrs_shift; + double f0, f1, f2, g0, g1, g2; #ifdef PHPYOPENMP -#pragma omp parallel for private(j, b1, b2, f0, f1, f2, g0, g1, g2, adrs_shift) if (openmp_per_bands) +#pragma omp parallel for private(j, b1, b2, f0, f1, f2, g0, g1, g2, \ + adrs_shift) if (openmp_per_bands) #endif - for (b12 = 0; b12 < num_band * num_band; b12++) - { - b1 = b12 / num_band; - b2 = b12 % num_band; - f1 = frequencies[triplet[1] * num_band + b1]; - f2 = frequencies[triplet[2] * num_band + b2]; - for (j = 0; j < num_band0; j++) - { - f0 = frequency_points[j]; - adrs_shift = j * num_band * num_band + b1 * num_band + b2; + for (b12 = 0; b12 < num_band * num_band; b12++) { + b1 = b12 / num_band; + b2 = b12 % num_band; + f1 = frequencies[triplet[1] * num_band + b1]; + f2 = frequencies[triplet[2] * num_band + b2]; + for (j = 0; j < num_band0; j++) { + f0 = frequency_points[j]; + adrs_shift = j * num_band * num_band + b1 * num_band + b2; - if ((tp_type == 2) || (tp_type == 3)) - { - if (cutoff > 0 && - fabs(f0 + f1 - f2) > cutoff && - fabs(f0 - f1 + f2) > cutoff && - fabs(f0 - f1 - f2) > cutoff) - { - iw_zero[adrs_shift] = 1; - g0 = 0; - g1 = 0; - g2 = 0; + if ((tp_type == 2) || (tp_type == 3)) { + if (cutoff > 0 && fabs(f0 + f1 - f2) > cutoff && + fabs(f0 - f1 + f2) > cutoff && + fabs(f0 - f1 - f2) > cutoff) { + iw_zero[adrs_shift] = 1; + g0 = 0; + g1 = 0; + g2 = 0; + } else { + iw_zero[adrs_shift] = 0; + g0 = phonoc_gaussian(f0 + f1 - f2, sigma); + g1 = phonoc_gaussian(f0 - f1 + f2, sigma); + g2 = phonoc_gaussian(f0 - f1 - f2, sigma); + } + if (tp_type == 2) { + iw[adrs_shift] = g2; + adrs_shift += const_adrs_shift; + iw[adrs_shift] = g0 - g1; + } + if (tp_type == 3) { + iw[adrs_shift] = g2; + adrs_shift += const_adrs_shift; + iw[adrs_shift] = g0 - g1; + adrs_shift += const_adrs_shift; + iw[adrs_shift] = g0 + g1 + g2; + } + } + if (tp_type == 4) { + if (cutoff > 0 && fabs(f0 + f1 - f2) > cutoff) { + iw_zero[adrs_shift] = 1; + iw[adrs_shift] = 0; + } else { + iw_zero[adrs_shift] = 0; + iw[adrs_shift] = phonoc_gaussian(f0 + f1 - f2, sigma); + } + } } - else - { - iw_zero[adrs_shift] = 0; - g0 = phonoc_gaussian(f0 + f1 - f2, sigma); - g1 = phonoc_gaussian(f0 - f1 + f2, sigma); - g2 = phonoc_gaussian(f0 - f1 - f2, sigma); - } - if (tp_type == 2) - { - iw[adrs_shift] = g2; - adrs_shift += const_adrs_shift; - iw[adrs_shift] = g0 - g1; - } - if (tp_type == 3) - { - iw[adrs_shift] = g2; - adrs_shift += const_adrs_shift; - iw[adrs_shift] = g0 - g1; - adrs_shift += const_adrs_shift; - iw[adrs_shift] = g0 + g1 + g2; - } - } - if (tp_type == 4) - { - if (cutoff > 0 && fabs(f0 + f1 - f2) > cutoff) - { - iw_zero[adrs_shift] = 1; - iw[adrs_shift] = 0; - } - else - { - iw_zero[adrs_shift] = 0; - iw[adrs_shift] = phonoc_gaussian(f0 + f1 - f2, sigma); - } - } } - } } void tpi_get_neighboring_grid_points(long *neighboring_grid_points, const long grid_point, const long (*relative_grid_address)[3], const long num_relative_grid_address, - const ConstBZGrid *bzgrid) -{ - if (bzgrid->type == 1) - { - get_neighboring_grid_points_type1(neighboring_grid_points, - grid_point, - relative_grid_address, - num_relative_grid_address, - bzgrid); - } - else - { - get_neighboring_grid_points_type2(neighboring_grid_points, - grid_point, - relative_grid_address, - num_relative_grid_address, - bzgrid); - } + const ConstBZGrid *bzgrid) { + if (bzgrid->type == 1) { + get_neighboring_grid_points_type1(neighboring_grid_points, grid_point, + relative_grid_address, + num_relative_grid_address, bzgrid); + } else { + get_neighboring_grid_points_type2(neighboring_grid_points, grid_point, + relative_grid_address, + num_relative_grid_address, bzgrid); + } } static void set_freq_vertices(double freq_vertices[3][24][4], const double *frequencies1, const double *frequencies2, const long vertices[2][24][4], - const long num_band1, - const long num_band2, - const long b1, - const long b2, - const long tp_type) -{ - long i, j; - double f1, f2; + const long num_band1, const long num_band2, + const long b1, const long b2, + const long tp_type) { + long i, j; + double f1, f2; - for (i = 0; i < 24; i++) - { - for (j = 0; j < 4; j++) - { - f1 = frequencies1[vertices[0][i][j] * num_band1 + b1]; - f2 = frequencies2[vertices[1][i][j] * num_band2 + b2]; - if ((tp_type == 2) || (tp_type == 3)) - { - if (f1 < 0) - { - f1 = 0; + for (i = 0; i < 24; i++) { + for (j = 0; j < 4; j++) { + f1 = frequencies1[vertices[0][i][j] * num_band1 + b1]; + f2 = frequencies2[vertices[1][i][j] * num_band2 + b2]; + if ((tp_type == 2) || (tp_type == 3)) { + if (f1 < 0) { + f1 = 0; + } + if (f2 < 0) { + f2 = 0; + } + freq_vertices[0][i][j] = -f1 + f2; + freq_vertices[1][i][j] = f1 - f2; + freq_vertices[2][i][j] = f1 + f2; + } else { + freq_vertices[0][i][j] = -f1 + f2; + } } - if (f2 < 0) - { - f2 = 0; - } - freq_vertices[0][i][j] = -f1 + f2; - freq_vertices[1][i][j] = f1 - f2; - freq_vertices[2][i][j] = f1 + f2; - } - else - { - freq_vertices[0][i][j] = -f1 + f2; - } } - } } /* Integration weight g is calculated. */ @@ -307,113 +245,87 @@ static void set_freq_vertices(double freq_vertices[3][24][4], /* iw_zero=1 information can be used to omit to compute particles */ /* interaction strength that is often heaviest part in throughout */ /* calculation. */ -static long set_g(double g[3], - const double f0, - const double freq_vertices[3][24][4], - const long max_i) -{ - long i, iw_zero; +static long set_g(double g[3], const double f0, + const double freq_vertices[3][24][4], const long max_i) { + long i, iw_zero; - iw_zero = 1; + iw_zero = 1; - for (i = 0; i < max_i; i++) - { - if (thm_in_tetrahedra(f0, freq_vertices[i])) - { - g[i] = thm_get_integration_weight(f0, freq_vertices[i], 'I'); - iw_zero = 0; - } - else - { - g[i] = 0; - } - } - - return iw_zero; -} - -static void get_triplet_tetrahedra_vertices(long vertices[2][24][4], - const long tp_relative_grid_address[2][24][4][3], - const long triplet[3], - const ConstBZGrid *bzgrid) -{ - long i, j; - - for (i = 0; i < 2; i++) - { - for (j = 0; j < 24; j++) - { - tpi_get_neighboring_grid_points(vertices[i][j], - triplet[i + 1], - tp_relative_grid_address[i][j], - 4, - bzgrid); - } - } -} - -static void -get_neighboring_grid_points_type1(long *neighboring_grid_points, - const long grid_point, - const long (*relative_grid_address)[3], - const long num_relative_grid_address, - const ConstBZGrid *bzgrid) -{ - long bzmesh[3], bz_address[3]; - long i, j, bz_gp, prod_bz_mesh; - - for (i = 0; i < 3; i++) - { - bzmesh[i] = bzgrid->D_diag[i] * 2; - } - prod_bz_mesh = bzmesh[0] * bzmesh[1] * bzmesh[2]; - for (i = 0; i < num_relative_grid_address; i++) - { - for (j = 0; j < 3; j++) - { - bz_address[j] = bzgrid->addresses[grid_point][j] + relative_grid_address[i][j]; - } - bz_gp = bzgrid->gp_map[grg_get_grid_index(bz_address, bzmesh)]; - if (bz_gp == prod_bz_mesh) - { - neighboring_grid_points[i] = - grg_get_grid_index(bz_address, bzgrid->D_diag); - } - else - { - neighboring_grid_points[i] = bz_gp; - } - } -} - -static void -get_neighboring_grid_points_type2(long *neighboring_grid_points, - const long grid_point, - const long (*relative_grid_address)[3], - const long num_relative_grid_address, - const ConstBZGrid *bzgrid) -{ - long bz_address[3]; - long i, j, gp; - - for (i = 0; i < num_relative_grid_address; i++) - { - for (j = 0; j < 3; j++) - { - bz_address[j] = bzgrid->addresses[grid_point][j] + relative_grid_address[i][j]; - } - gp = grg_get_grid_index(bz_address, bzgrid->D_diag); - neighboring_grid_points[i] = bzgrid->gp_map[gp]; - if (bzgrid->gp_map[gp + 1] - bzgrid->gp_map[gp] > 1) - { - for (j = bzgrid->gp_map[gp]; j < bzgrid->gp_map[gp + 1]; j++) - { - if (bz_address[0] == bzgrid->addresses[j][0] && bz_address[1] == bzgrid->addresses[j][1] && bz_address[2] == bzgrid->addresses[j][2]) - { - neighboring_grid_points[i] = j; - break; + for (i = 0; i < max_i; i++) { + if (thm_in_tetrahedra(f0, freq_vertices[i])) { + g[i] = thm_get_integration_weight(f0, freq_vertices[i], 'I'); + iw_zero = 0; + } else { + g[i] = 0; + } + } + + return iw_zero; +} + +static void get_triplet_tetrahedra_vertices( + long vertices[2][24][4], const long tp_relative_grid_address[2][24][4][3], + const long triplet[3], const ConstBZGrid *bzgrid) { + long i, j; + + for (i = 0; i < 2; i++) { + for (j = 0; j < 24; j++) { + tpi_get_neighboring_grid_points(vertices[i][j], triplet[i + 1], + tp_relative_grid_address[i][j], 4, + bzgrid); + } + } +} + +static void get_neighboring_grid_points_type1( + long *neighboring_grid_points, const long grid_point, + const long (*relative_grid_address)[3], + const long num_relative_grid_address, const ConstBZGrid *bzgrid) { + long bzmesh[3], bz_address[3]; + long i, j, bz_gp, prod_bz_mesh; + + for (i = 0; i < 3; i++) { + bzmesh[i] = bzgrid->D_diag[i] * 2; + } + prod_bz_mesh = bzmesh[0] * bzmesh[1] * bzmesh[2]; + for (i = 0; i < num_relative_grid_address; i++) { + for (j = 0; j < 3; j++) { + bz_address[j] = + bzgrid->addresses[grid_point][j] + relative_grid_address[i][j]; + } + bz_gp = bzgrid->gp_map[grg_get_grid_index(bz_address, bzmesh)]; + if (bz_gp == prod_bz_mesh) { + neighboring_grid_points[i] = + grg_get_grid_index(bz_address, bzgrid->D_diag); + } else { + neighboring_grid_points[i] = bz_gp; + } + } +} + +static void get_neighboring_grid_points_type2( + long *neighboring_grid_points, const long grid_point, + const long (*relative_grid_address)[3], + const long num_relative_grid_address, const ConstBZGrid *bzgrid) { + long bz_address[3]; + long i, j, gp; + + for (i = 0; i < num_relative_grid_address; i++) { + for (j = 0; j < 3; j++) { + bz_address[j] = + bzgrid->addresses[grid_point][j] + relative_grid_address[i][j]; + } + gp = grg_get_grid_index(bz_address, bzgrid->D_diag); + neighboring_grid_points[i] = bzgrid->gp_map[gp]; + if (bzgrid->gp_map[gp + 1] - bzgrid->gp_map[gp] > 1) { + for (j = bzgrid->gp_map[gp]; j < bzgrid->gp_map[gp + 1]; j++) { + if (bz_address[0] == bzgrid->addresses[j][0] && + bz_address[1] == bzgrid->addresses[j][1] && + bz_address[2] == bzgrid->addresses[j][2]) { + neighboring_grid_points[i] = j; + break; + } + } } - } } - } } diff --git a/c/triplet_iw.h b/c/triplet_iw.h index 45ae2853..a2a6eacb 100644 --- a/c/triplet_iw.h +++ b/c/triplet_iw.h @@ -35,38 +35,24 @@ #ifndef __triplet_iw_H__ #define __triplet_iw_H__ -void -tpi_get_integration_weight(double *iw, - char *iw_zero, - const double *frequency_points, - const long num_band0, - const long tp_relative_grid_address[2][24][4][3], - const long triplets[3], - const long num_triplets, - const ConstBZGrid *bzgrid, - const double *frequencies1, - const long num_band1, - const double *frequencies2, - const long num_band2, - const long tp_type, - const long openmp_per_bands); -void tpi_get_integration_weight_with_sigma(double *iw, - char *iw_zero, - const double sigma, - const double cutoff, - const double *frequency_points, - const long num_band0, - const long triplet[3], - const long const_adrs_shift, - const double *frequencies, - const long num_band, - const long tp_type, - const long openmp_per_bands); -void -tpi_get_neighboring_grid_points(long *neighboring_grid_points, - const long grid_point, - const long (*relative_grid_address)[3], - const long num_relative_grid_address, - const ConstBZGrid *bzgrid); +#include "bzgrid.h" + +void tpi_get_integration_weight( + double *iw, char *iw_zero, const double *frequency_points, + const long num_band0, const long tp_relative_grid_address[2][24][4][3], + const long triplets[3], const long num_triplets, const ConstBZGrid *bzgrid, + const double *frequencies1, const long num_band1, + const double *frequencies2, const long num_band2, const long tp_type, + const long openmp_per_bands); +void tpi_get_integration_weight_with_sigma( + double *iw, char *iw_zero, const double sigma, const double cutoff, + const double *frequency_points, const long num_band0, const long triplet[3], + const long const_adrs_shift, const double *frequencies, const long num_band, + const long tp_type, const long openmp_per_bands); +void tpi_get_neighboring_grid_points(long *neighboring_grid_points, + const long grid_point, + const long (*relative_grid_address)[3], + const long num_relative_grid_address, + const ConstBZGrid *bzgrid); #endif diff --git a/phono3py/api_phono3py.py b/phono3py/api_phono3py.py index a7357f49..9a2838e8 100644 --- a/phono3py/api_phono3py.py +++ b/phono3py/api_phono3py.py @@ -2530,6 +2530,7 @@ class Phono3py: def _set_mesh_numbers(self, mesh): # initialization related to mesh self._interaction = None + self._bz_grid = BZGrid( mesh, lattice=self._primitive.cell, diff --git a/phono3py/phonon/grid.py b/phono3py/phonon/grid.py index 62337667..422a1c26 100644 --- a/phono3py/phonon/grid.py +++ b/phono3py/phonon/grid.py @@ -608,15 +608,16 @@ def get_grid_points_by_rotations( bz_grid : BZGrid Data structure to represent BZ grid. reciprocal_rotations : array_like or None, optional - Rotation matrices {R} with respect to reciprocal basis vectors. - Defined by q'=Rq. + Rotation matrices {R} with respect to basis vectors of GR-grid. + Defined by g'=Rg, where g is the grid point address represented by + three integers in BZ-grid. dtype='int_', shape=(rotations, 3, 3) with_surface : Bool, optional This parameter affects to how to treat grid points on BZ surface. When False, rotated BZ surface points are moved to representative ones among translationally equivalent points to hold one-to-one correspondence to GR grid points. With True, BZ grid point indices - having the rotated grid addresses are returned. Default is False. + having the rotated grid addresses are returned. Default is False. Returns ------- diff --git a/phono3py/phonon3/conductivity.py b/phono3py/phonon3/conductivity.py index a7b11b75..e885b0db 100644 --- a/phono3py/phonon3/conductivity.py +++ b/phono3py/phonon3/conductivity.py @@ -264,10 +264,6 @@ class Conductivity(ConductivityBase): self._grid_point_count += 1 return self._grid_point_count - 1 - def next(self): - """For backward compatibility.""" - return self.__next__() - @property def mesh_numbers(self): """Return mesh numbers of GR-grid.""" diff --git a/phono3py/phonon3/conductivity_LBTE.py b/phono3py/phonon3/conductivity_LBTE.py index 6026d44d..33c93454 100644 --- a/phono3py/phonon3/conductivity_LBTE.py +++ b/phono3py/phonon3/conductivity_LBTE.py @@ -58,7 +58,7 @@ from phono3py.phonon3.interaction import Interaction from phono3py.phonon.grid import get_grid_points_by_rotations -class Conductivity_LBTE(Conductivity): +class ConductivityLBTE(Conductivity): """Lattice thermal conductivity calculation by direct solution.""" def __init__( @@ -164,7 +164,11 @@ class Conductivity_LBTE(Conductivity): self._allocate_values() def set_kappa_at_sigmas(self): - """Calculate lattice thermal conductivity from collision matrix.""" + """Calculate lattice thermal conductivity from collision matrix. + + This method is called after all elements of collision matrix are filled. + + """ if len(self._grid_points) != len(self._ir_grid_points): print("Collision matrix is not well created.") import sys @@ -491,22 +495,26 @@ class Conductivity_LBTE(Conductivity): self._pp.bz_grid.grg2bzg[i], self._pp.bz_grid ) ] - self._expand_collisions(ir_gr_grid_points, rot_grid_points) + 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_") self._symmetrize_collision_matrix() else: self._combine_collisions() - weights = self._get_weights() - for i, w_i in enumerate(weights): - for j, w_j in enumerate(weights): - self._collision_matrix[:, :, i, :, :, j, :, :] *= w_i * w_j + weights = self._multiply_weights_to_collisions() self._average_collision_matrix_by_degeneracy() self._symmetrize_collision_matrix() return weights + def _multiply_weights_to_collisions(self): + weights = self._get_weights() + for i, w_i in enumerate(weights): + for j, w_j in enumerate(weights): + self._collision_matrix[:, :, i, :, :, j, :, :] *= w_i * w_j + return weights + def _set_kappa_at_sigmas(self, weights): """Calculate thermal conductivity from collision matrix.""" for j, sigma in enumerate(self._sigmas): @@ -556,7 +564,7 @@ class Conductivity_LBTE(Conductivity): def _combine_collisions(self): """Include diagonal elements into collision matrix.""" num_band = len(self._pp.primitive) * 3 - for j, k in list(np.ndindex((len(self._sigmas), len(self._temperatures)))): + for j, k in np.ndindex((len(self._sigmas), len(self._temperatures))): for i, ir_gp in enumerate(self._ir_grid_points): for r, r_gp in zip(self._rotations_cartesian, self._rot_grid_points[i]): if ir_gp != r_gp: @@ -573,13 +581,13 @@ class Conductivity_LBTE(Conductivity): num_band = len(self._pp.primitive) * 3 num_mesh_points = np.prod(self._pp.mesh_numbers) - for j, k in list(np.ndindex((len(self._sigmas), len(self._temperatures)))): + for j, k in np.ndindex((len(self._sigmas), len(self._temperatures))): for i in range(num_mesh_points): main_diagonal = self._get_main_diagonal(i, j, k) for ll in range(num_band): self._collision_matrix[j, k, i, ll, i, ll] += main_diagonal[ll] - def _expand_collisions(self, ir_gr_grid_points, rot_grid_points): + def _expand_reducible_collisions(self, ir_gr_grid_points, rot_grid_points): """Fill elements of full collision matrix by symmetry.""" start = time.time() if self._log_level: @@ -866,12 +874,16 @@ class Conductivity_LBTE(Conductivity): (Y / 2).reshape(num_grid_points, num_band * 3).T / weights ).T.reshape(self._f_vectors.shape) - def _get_eigvals_pinv(self, i_sigma, i_temp): + def _get_eigvals_pinv(self, i_sigma, i_temp, take_abs=True): """Return inverse eigenvalues of eigenvalues > epsilon.""" w = self._collision_eigenvalues[i_sigma, i_temp] e = np.zeros_like(w) for ll, val in enumerate(w): - if abs(val) > self._pinv_cutoff: + if take_abs: + _val = abs(val) + else: + _val = val + if _val > self._pinv_cutoff: e[ll] = 1 / val return e @@ -1291,7 +1303,7 @@ def get_thermal_conductivity_LBTE( else: temps = _temperatures - lbte = Conductivity_LBTE( + lbte = ConductivityLBTE( interaction, grid_points=grid_points, temperatures=temps, @@ -1333,6 +1345,7 @@ def get_thermal_conductivity_LBTE( text = (" %.1f " * len(temps_read)) % tuple(temps_read) print("Temperature: " + text) + # This computes pieces of collision matrix sequentially. for i in lbte: if write_pp: _write_pp( @@ -1363,6 +1376,7 @@ def get_thermal_conductivity_LBTE( if grid_points is None and all_bands_exist(interaction): lbte.set_kappa_at_sigmas() + if write_kappa: _write_kappa( lbte, @@ -1379,17 +1393,17 @@ def get_thermal_conductivity_LBTE( def _write_collision( - lbte, - interaction, + lbte: ConductivityLBTE, + interaction: Interaction, i=None, is_reducible_collision_matrix=False, is_one_gp_colmat=False, filename=None, ): - grid_points = lbte.get_grid_points() + grid_points = lbte.grid_points temperatures = lbte.temperatures - sigmas = lbte.get_sigmas() - sigma_cutoff = lbte.get_sigma_cutoff_width() + sigmas = lbte.sigmas + sigma_cutoff = lbte.sigma_cutoff_width gamma = lbte.gamma gamma_isotope = lbte.gamma_isotope collision_matrix = lbte.collision_matrix @@ -1459,7 +1473,7 @@ def _write_collision( def _write_kappa( - lbte, + lbte: ConductivityLBTE, volume, is_reducible_collision_matrix=False, write_LBTE_solution=False, diff --git a/phono3py/phonon3/conductivity_RTA.py b/phono3py/phonon3/conductivity_RTA.py index 22dc6577..ae946410 100644 --- a/phono3py/phonon3/conductivity_RTA.py +++ b/phono3py/phonon3/conductivity_RTA.py @@ -53,7 +53,7 @@ from phono3py.phonon3.triplets import get_all_triplets from phono3py.phonon.grid import get_grid_points_by_rotations -class Conductivity_RTA(Conductivity): +class ConductivityRTA(Conductivity): """Lattice thermal conductivity calculation with RTA.""" def __init__( @@ -609,7 +609,7 @@ def get_thermal_conductivity_RTA( "-------------------- Lattice thermal conducitivity (RTA) " "--------------------" ) - br = Conductivity_RTA( + br = ConductivityRTA( interaction, grid_points=grid_points, temperatures=_temperatures, diff --git a/phono3py/phonon3/displacement_fc3.py b/phono3py/phonon3/displacement_fc3.py index e2218017..f430c099 100644 --- a/phono3py/phonon3/displacement_fc3.py +++ b/phono3py/phonon3/displacement_fc3.py @@ -297,8 +297,8 @@ def get_smallest_vector_of_atom_pair( def _get_orbits(atom_index, cell, site_symmetry, symprec=1e-5): - lattice = cell.get_cell().T - positions = cell.get_scaled_positions() + lattice = cell.cell.T + positions = cell.scaled_positions center = positions[atom_index] # orbits[num_atoms, num_site_sym] diff --git a/phono3py/phonon3/fc3.py b/phono3py/phonon3/fc3.py index b0846167..8781ee3b 100644 --- a/phono3py/phonon3/fc3.py +++ b/phono3py/phonon3/fc3.py @@ -351,9 +351,9 @@ def _get_constrained_fc2( 'forces': []}, ...] """ - lattice = supercell.get_cell().T - positions = supercell.get_scaled_positions() - num_atom = supercell.get_number_of_atoms() + lattice = supercell.cell.T + positions = supercell.scaled_positions + num_atom = len(supercell) fc2 = np.zeros((num_atom, num_atom, 3, 3), dtype="double") atom_list = np.unique([x["number"] for x in dataset_second_atoms]) @@ -427,14 +427,14 @@ def _solve_fc3( print(" [%2d %2d %2d]\n" % tuple(v[2])) sys.stdout.flush() - lattice = supercell.get_cell().T + lattice = supercell.cell.T site_sym_cart = np.array( [similarity_transformation(lattice, sym) for sym in site_symmetry], dtype="double", order="C", ) - num_atom = supercell.get_number_of_atoms() - positions = supercell.get_scaled_positions() + num_atom = len(supercell) + positions = supercell.scaled_positions pos_center = positions[first_atom_num].copy() positions -= pos_center @@ -655,7 +655,7 @@ def _get_fc3_least_atoms( else: direction = np.dot( dataset_first_atom["displacement"], - np.linalg.inv(supercell.get_cell()), + np.linalg.inv(supercell.cell), ) reduced_site_sym = get_reduced_site_symmetry( site_symmetry, direction, symprec diff --git a/phono3py/phonon3/interaction.py b/phono3py/phonon3/interaction.py index ccb5db86..e0097f2d 100644 --- a/phono3py/phonon3/interaction.py +++ b/phono3py/phonon3/interaction.py @@ -499,7 +499,7 @@ class Interaction: weights_at_q, triplets_map_at_q, ir_map_at_q, - ) = get_triplets_at_q(grid_point, self._bz_grid) + ) = get_triplets_at_q(grid_point, self._bz_grid, swappable=True) # Special treatment of symmetry is applied when q_direction is # used. diff --git a/phono3py/phonon3/triplets.py b/phono3py/phonon3/triplets.py index 1775b13b..192f9208 100644 --- a/phono3py/phonon3/triplets.py +++ b/phono3py/phonon3/triplets.py @@ -131,8 +131,8 @@ def get_nosym_triplets_at_q(grid_point, bz_grid: BZGrid): """ map_triplets = np.arange(np.prod(bz_grid.D_diag), dtype="int_") + map_q = np.arange(np.prod(bz_grid.D_diag), dtype="int_") triplets_at_q, weights = _get_BZ_triplets_at_q(grid_point, bz_grid, map_triplets) - map_q = map_triplets.copy() return triplets_at_q, weights, map_triplets, map_q diff --git a/scripts/phono3py-coleigplot b/scripts/phono3py-coleigplot index 80c3a806..4193d7f3 100755 --- a/scripts/phono3py-coleigplot +++ b/scripts/phono3py-coleigplot @@ -62,7 +62,7 @@ def plot_one_file(ax, args): def plot_more(ax, coleigs, temperatures, args): t_index = get_t_index(temperatures[0], args) - y = [v[t_index] for v in coleigs] + y = [np.abs(v[t_index]) for v in coleigs] ax.semilogy(np.transpose(y), ".", markersize=5) ax.set_xlim(0, len(y[0])) From fa83274c2bb9b2b31d51623a2596a2daefff8cb2 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Tue, 2 Nov 2021 22:18:48 +0900 Subject: [PATCH 32/34] Update test_kappa_LBTE.py --- test/phonon3/test_kappa_LBTE.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/phonon3/test_kappa_LBTE.py b/test/phonon3/test_kappa_LBTE.py index 3924e5b7..28fb118a 100644 --- a/test/phonon3/test_kappa_LBTE.py +++ b/test/phonon3/test_kappa_LBTE.py @@ -1,11 +1,13 @@ """Tests for direct solution of LBTE.""" import numpy as np -si_pbesol_kappa_LBTE = [111.802, 111.802, 111.802, 0, 0, 0] -si_pbesol_kappa_LBTE_redcol = [61.3504328, 61.3504328, 61.3504328, 0, 0, 0] +from phono3py.api_phono3py import Phono3py + +si_pbesol_kappa_LBTE = [111.117, 111.117, 111.117, 0, 0, 0] +si_pbesol_kappa_LBTE_redcol = [63.019, 63.019, 63.019, 0, 0, 0] -def test_kappa_LBTE(si_pbesol): +def test_kappa_LBTE(si_pbesol: Phono3py): """Test for symmetry reduced collision matrix.""" si_pbesol.mesh_numbers = [9, 9, 9] si_pbesol.init_phph_interaction() @@ -19,7 +21,7 @@ def test_kappa_LBTE(si_pbesol): np.testing.assert_allclose(si_pbesol_kappa_LBTE, kappa, atol=0.5) -def test_kappa_LBTE_full_colmat(si_pbesol): +def test_kappa_LBTE_full_colmat(si_pbesol: Phono3py): """Test for full collision matrix.""" si_pbesol.mesh_numbers = [5, 5, 5] si_pbesol.init_phph_interaction() From 5fea85e0c6f95a92e6535ff61bc945afa8a71f4a Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Tue, 2 Nov 2021 22:53:53 +0900 Subject: [PATCH 33/34] Update python and package version requirements --- conda/meta.yaml | 8 ++++---- requirements.txt | 4 ++-- setup.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/conda/meta.yaml b/conda/meta.yaml index aa925e77..7616f6e6 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -26,11 +26,11 @@ build: requirements: build: - - python>=3.5 + - python>=3.6 - pip - numpy>=1.11 - scipy - - matplotlib-base + - matplotlib-base>=2.0.0 - pyyaml - h5py - phonopy>=2.12,<2.13 @@ -39,11 +39,11 @@ requirements: - spglib run: - - python>=3.5 + - python>=3.6 - pip - numpy>=1.11 - scipy - - matplotlib-base + - matplotlib-base>=2.0.0 - pyyaml - h5py - phonopy>=2.12,<2.13 diff --git a/requirements.txt b/requirements.txt index d0f08807..05c714ca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -numpy +numpy >= 1.11.0 PyYAML -matplotlib +matplotlib >= 2.0.0 h5py phonopy >=2.12,<2.13 diff --git a/setup.py b/setup.py index d63e22ee..e20eb6ce 100644 --- a/setup.py +++ b/setup.py @@ -373,12 +373,12 @@ if __name__ == "__main__": author_email="atz.togo@gmail.com", url="http://phonopy.github.io/phono3py/", packages=packages_phono3py, - python_requires=">=3.5", + python_requires=">=3.6", install_requires=[ - "numpy", + "numpy>=1.11.0", "scipy", "PyYAML", - "matplotlib", + "matplotlib>=2.0.0", "h5py", "spglib", "phonopy>=2.12,<2.13", From 28dc6efe47ddeb85b8e2dc476f4c5b9af89be49e Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Wed, 3 Nov 2021 09:56:21 +0900 Subject: [PATCH 34/34] Update version number (v2.1.0) and changelog. --- doc/Si-coleigplot.png | Bin 15644 -> 21345 bytes doc/changelog.md | 390 +++++++++++++++++++---------------------- doc/conf.py | 4 +- doc/direct-solution.md | 354 ++++++++++++++++++------------------- phono3py/version.py | 2 +- 5 files changed, 358 insertions(+), 392 deletions(-) diff --git a/doc/Si-coleigplot.png b/doc/Si-coleigplot.png index adfb14a05881829d6bdd0d97557b271786a4d701..41a2734881f3df10a6e741c61f1f3d095a98ac7d 100644 GIT binary patch literal 21345 zcmeIac|4YFxHkHzw;A;|kwT@CWC|rhrNIy~&r>2Z2}P#rjY@b8Q3}b-V<=PRN~H{$ zA2OsuhQ}B(vyZEHt#7TpertdGTi@RQto_^XTR$bweP8!Aoab>K$8p|w&nul}TFbVU zLZL9p$(~ZBP?mX9C=6d$uf%sm>)N~V<&R4z6i-kn&jZ)Zo2Cu23i( zZ^&;3yIN-{d~=nPoZ{(KJ?oZJ_HOr2Pc)-YRM*L!I-!28b*RJDeM?Ww(%8t8z1L+w z$Ui&2)8<7*$$p8OZYmSHJzH%JS_>98H`7wId1>+cEex!-6ko`BI!TL9+V6K~=ZAfd zm%X?ryYb}4501ehSydx}mdr;t9A5Ke&$w%;q3fSNsvaGysdD()^ZC7?V#8*P#HQ@e z{$=?3bz(OKUt1U%Hc%+9%vXEkdxvExe^4ly+m`Lb6IXAbFyP01D61(HW8puJcEb1ih3=&rx}$R=I7_L9kF|&&#$zFLa|`8V4%uq zXgoM<|Ap#Ir}f`jFZFllNFW(AWk503nzr_jWwSpX+h=<&xY>4=7^Lau)K8CfZP~PG zQ?8MrVHEaaY)9eMRD(hnHevJos;a61^hQ(yVQ)Fro*Vz>7 z=Jen=hUF`hl%u60B(A1=j`oU}OJ2$_>F2}lADcb$#-HOV}2N4k|adB~6 z9C-x=y3t;X`BF38n>@y=kGSEtsAIQmj?L#oHqvE+>gwuo)sK%qoS&+(X}@+5!+HjLxVjx zx}m=jE0*KAFngY2Q}^t)dDX+1s;Vm4XzaQ3t9)hFuH-Vf_rc1Mp|;2Iqu~9rn^B!3 z;SK$a{xcF0eSH=S^S#p2KRj<7KaP#s|#Vu8nn9ZwYrJ}Pf zg0ii{Cwju`z0QPu)(lzaJvKIWFEFtAOY!xx+>wq#Eo|?50RicG(Pj||s%mOY&rQo^ zwYF0zZ3hIxWBd5=_zh5x$oaw1*T|xP}IjP@n za&B*#7;C1Lmr<nfWXIuWsBj9cL_?O<5?e;ZD=t>oM-%6wfO+_e+P*!}nfb zxT@OTaD{<(oq@JyaToIhr!TJc(Tf)!G<;$+pirsQ#w#_FiDs2y$=E8MrADPo3nLF6 zJc#$2@8TrO+*cPn`SsR%tM~V}xlMIkeSq>f}0QTMN%>7TU#3@Bm zDX!TY_Q|E`>ZDoNO})PCdUldjI1;y4 zf%(%fD*Kz1)U>TR>=FaaBA!dhwxSA(OzV%9TQM-MjHji=e=AG-+c|rx$@xAlEp4yD zvuDgD8My_z2h`N!-Sj6J6*mAFIJ~hEC|AM8i?N%u>Tk1O|7mqv$Fd%W9Xk?#Ow!mr znRomxFYoC#6VPa-simN;$Z~Py%PPIs0h_y@#ir3-Xr{fPdr~#CUWz5Vj>{T}e%*=8 z^Yu#&T|{Uwpz1Yc1-(b&X;!oCmKt zd_OU?lVyw9ikGys^-@_mF4z15!-GS(JaWC?`(e%wt2f-%6OJ058%d)T)ktNPTot3< z-8whL>8?EfgLY_#Xys)_PP^(4RF%Rl{8EN<}uP)9*wyGQ3*dBo(`H6pWx3J0 z^+wA4tjDJNsHTb!#m3L|2P;sWX)Bq6#ho(0)Hv=q-gSoZhxeIRy;;i)6pvU{54LEe zQg>>_nhSlsdGl6avpCJoF^BtHww&wE{|ZtOr4S)dX$}WsfKop zp8c!qh0AdEGJ~Oa_Y}w9?$c}hLo%^}P5Q{iJCmnww^rVN`%WmAIdeHawIi|BZ#}2= z4gJ#2wKfu0X$$IqwRU9YEH}P9cDE*~`a|YTy&<{H!CMA>m?dBS(jR)->sWVtUCTCx z4aZ}r)S|O=#}|ThzgYPuryQ_mG^qYwR_<1CO3=c&Y%%oR9pOW9EiI#AB@bD7i*hWl zj86NQD86Ss)cy6MUxc_^_74WJL(6u0H>CVnv*ESzbOG?`^xU?MEMJ}k>zuX?aG;!3xZZkD;VwA?a^=K)+GB-g7n$K{FB1WhDy{OhKj zDXC>LDmtJ0z1|PR3|P6Q8Y~{RW#*SU$iC3O(O2qCYC7$#dHu3GoAJ?2nhiYz4%#P1 z>dvO6tMqs4Hdti{UoGPE=KlGli7SUfqgo$v>ifoLe^83?DG!!XEak-^dS!3cK2e*` z7o78l+bwUW)T{E2vJc3nS&Axq_ceZ8>nFOaN{~7vO0QxcnU;*oT1(*$psd~*m-Jzv z!r=KEw@=oB`}y=-M(4N`tz_kc`3uigROg)RsMBrO6NQr>giT?^JF#tZo# zb3uBOhlJDk+at`*91@P#Orw4ce^R9_MzN?`?R|XH7Dipuaavl);!hTO&Aqj}f6&ZX zSCtu7o4z`9i25`<>eJ2Fl-kXIQf}-^NRrhp(w-d@rUUb&rskb-FA_C*rnueuhmG6p z>&)^uuPMgs|2Y2i?&vkDUB_9@91bDP>x@RJn)UBk6!>(tyC&TxgEww^baWlXQ@Ki_awQb*Tc1fW(T6uaoWnKi+64a8X?6&0baU}2kg7Xkt|3(H18}G86 zwX6TQRiBz6uMna;zmkB+U>0K z!%IB440Z#OpP?MPxiB|HpXrTmt`sPxa(c}R)xWz@ov%+Dcb9Mu=D2p;s$pOK-enXK zbAP+7qa_}5*>00ow(T!f08I%*FL0)B%?<1vX|9h~$hr7&Bj6#^_QU6ju~L_xtUoEL zsAgY08K#?K70+)_aH^ofd*0KsSIK&Z@#)iX3d<=LgTMw)j$TP1C^{)={}3?t(W6IA z7=TQRf3;dih&!j?7W*=qQ@075Tm0<)NN&0(IXhc@@7}$>>=MAkJUl$QCGPpTb{#2? z?F!`Rv^0s~udAOND7>n$Vg+s7!?kKV%ZfuYU~;R`llyu?cs4^Y!KP9 zeS7N9pN>Gk{blQ=8|Ow!Gcdt@lg&n2~;mo*Zen#Mo8U;;9Gw?+a7Myipe1 zKQov5R-{@y&%P~JQBF=yK4a2`3eXL>Pf8@NvjOVo&fULo;lhBsmy=U=)b-(`D{h@2 zkn#K5y9M8Twue4`e7&W_$0P|@^zjk2=i)g=8K*dK4tJ#o}bdk?{0l&4LM4Yxd(nzGncy`NI`F zOQor|u`^cOdcDc+fnPuXt;X|L7FP)tM#N=My91Sx37>aza&nLqlf}uDl(@v`upgfu z_%Qi7SyCv9CvX+q-~b<=2Ebj!5qo|)fa9>vk&G$LqYWaYmI+{&I8)GS@uuC*@)d=y z^GZi2h@Xk_l*b~Qp>`(v#QB^{KjrH`Uy4oxP*2m#Q$jfx9M@ABUfJ)ILg%@5Z6N6V z?q!qj`a{$6&lC(CDDYySOvcu&cr`!oZrhqIhy4~_-c^Sk-G~S7>F!RlZOa{KNDQ2v z8p$ANm)Tc_Bk*jE^imOj(dfw>`%bC)cdI-%CWhSQqwgspnQ7$B%<#0WvmT;~vPA=pktB()U_JqQb5;4%7o6_(V;E=`{`xc2RK5I-B{N6tEwL6DU(g-Siw z)6)ZTKoykAj)1c3Sqk#<-DB56|Ni?aO5`pnPdmGG4!6EtID%j(FnXwX)2sPtHxdOI1HPswQk+b>7l4xxT*M zsX_5bKMIv#6V~$iZ5aC9yLW@*1WM;si?2^YD%MS{D<7!e7f` zEF*BR8%WTiQV+`2lT6^$uiA0BoV|R@4)Aqsx9|jNYHE`c4a&R+4#;2aa1KXB%kitA zncno+z9gAL(ycE*V)(p`4Yf7TJ|kWsd|)WAQ?t}_0i**MlbDAOA7)ZmH*Mm|YhxFu zg&TP$KYYkKIncyg-vrJy=?K^eHlG+I2|00Uk8<#@kR zWoTl45N{He7Dtw(25QD;+zCzN!_3Y`E7sR?#lo_MV61`h&z_y!vSmxfhYzdUqHuqY zxnCdYlN`;L3D;3yujqQpcI3Z5X6~9Aj3v6X{)TP#8JDd zEqE*#4+Zj!-8uUB&Zk%j3k1lZ^uyR(m#rrPZwfPV+3Ya9aN*gDtgIY7a_!;hnnXmO z6cq52iz4eAM7TT%&#WXH%jhi?t!$Waq%mGkLt}4r4L8EtlP6S_*fW-2idUiQ zXnbK-neEskkLS}xnEod!oDwbIHwMXv)MtUU2PpQ(R(4vLZ041a&?k!|50Ux+e`dY(L)e==@m-gO{pBDVDPI%0 z$d~`Vj4>f*PXz;9+*rO!-M}ENu~8jq-`8;6%3B8x9#j`(Rd;hM(C62SJ^;4xuNLv9 zgZeMe<0QWzJCU%4y-%(L?BUt4x^Kj5sc`E-?VV+Ujj37!9oM@2O&IUj7xhOvL2PA7r1%_%b(fN4q<=Na^L-HKpZ!Nm1a>KNYU; zcz3vX$`IR`eX8a|MTIJG&gSjgx956PM~I4#R|z+z=^e?jZPSbtcdkd~+U+5absac; zYiJoiKfflPTHLAcsg{w41`eW0MtFEQ{l+Se^BD0y<*0+$jvqs~D@Ug2AGxDL+lFXl zhz{RQZu9xm%?Oj0VOT8UHerEy3h44EVVld~@>R_Habb~R0e*fZj4DWKFYY(_?Dfi5 zfVcXa_MNK@SW1A<81$)ucvK8VSB)1iW`Ax^1one z+Jrz{o4dF$$Gc%QIaCAf`B_N)33eR?>|>V@&=FY)fW*;9_E1LG*j zc|`qe%Z7a&i1W@Iu`Uh}NGurHY$(UVZr)rbYE3(6GjAv_e@~x3eC^t`0d!Vgt@K7e zfs!Ny2CLbL{?;7paJz#3eUZ*Ioq~ya1ySb#^=&>e*nw8Bycv9pJNumw%3KS^KS>~T zooi4Z|4}V^`TME8+}vkpHzS}oCfBWe6*2s|mCpf0Vr>U zz)%@*$USE&jRtP6<2NQ?4Rm*_dI&-{TcTDOeX^o=oJUA#>}9~8oSYfc)6?QcSHyOJ z?>jayxBQ0pnft6U$!dvbW}UE3JMvZ*GM@A2@_$}gUEM^^incauYwnd^C6MdbMZdBi zjMQ#>i=SjNxW(iR68Cqo(@Lk*!6vnGRF-?c0|EMZu~e!G9(5jwEBj{iU55IN5TV&7(QZhN()C;+7wS z_d4e57c4E#H9?kbcI`M$hoIIdbrd+SYbzg_vPQ9``{Lr=cDp2$sK54q^v6BZh}!)5U8+f(szaUTR3e+Mbo z7AZV85p`%(omgO^Bz*keg()G^_kHbGYBWxtzMWq5v!cupqb!Va{jtrTQ`!)UQ--@# z^l*MJhvK6{r%6@-5X`oy+l_Fmz+C=1Y8U_l$-aLeHG{d$GYQ*qp>%0#Dcg12d|^C# zsSzik5m8AtdMkof2+er;zpG3YuKpJ*Q|N1Jy?|yA9{Qbp0&F7^FwMHTHpwWd)s~>N zprCCPU;cH>+ zuF0=;OF9SmDS^#ao`;uLO}6eJNpW$fSo9rkFqYK<&2DB~ zNhAjZj|G(CRy69P#fe1eWQB14e_|z4v2LlS$9_sK&@n;b=H}*c%E-OPBiU>zPWk#j z=N3%({(?lu%E)n*t_S!t!03Ydu;538b->Ib76ua0K*`+jI%|e=ii-Xd{Rl{6&(3V8 z2n!2q;7p*T6t(}NAFQsgf3UREt5vrXF&4FixXU1Ge*=Elp`C61WUXk3FmvSd>%Tr< zN=5F#`B-PG2m0fQQeuJ2kXviT)i|Mh*tJX=w`>`zYHFIntYmx4xwszVAO$O*ZuWU4 zr2y!MsZfKGyp|S!iy%<`#;#4wkJr%OtP@a&^vPx5jvcZx_4UeE8mXF=^>K3llA^wN zOc@aAvtTH<%?TnOFBljC4-?KkdIn+fqaY*Ue~3o;TY>%`SNT@vODDoDcmzf+k&nB< zBV;S%Mw5eCH7PG&YWtY%7Zug8%af=-y$YGG7Mbq8pC1;kU1$oGz9#-LS^uL;ajxTWe0sYL*l?w<_na8m zM19NFdMHcoT^L!C*U_oJ^CxgveQiv=&Lug1B_XBuFU9rT(Xy4{3Y_l73m&7!^xS1& z#6F8h+JGEdxAkBxFv?_B^ujrC6l;n#Ra9bT#(S;Xa&6@m6`M}87{vXke(cNnN+iDf zBF}+}StbMhgV6pabt}W_9}20aYGN1C?1x{9@rX994LHu%)1#{MXkuZizCFMG$8_ZfykDT=UPQ_@uA(kzB&CKO_cr-UueaL+C6%X!K zkfWSsu6puhobno_=f>v`90&#v)RY=;Uz&6B%e^hMsa4F{84AH|whK!!*RS@sTE{;( zB@oSR_ycNR?)48T5pY1SA|}darv!)~=1Kkq(!ar|QK&`#w6A5T~8@O2CUJ@@kaxx>2v?l;a*& znG6oFJdhlNBS`!OAe#PKalAofvei1n61C+3E$wlUVFuC80kEyxUtSK5L%|C;`XBR^ zZ`JpX7iNCBHlLqOb$S_rVsPt^4+jAiSGKIrYpvtx++TmtQ=P3-%`y{`FO6LwBH(F1 zs#HmY`BUgjBOUo_5t41QQc_(fGK;mg28JoVpUx$s7dhgy^ z1J|AhzQtGp7fF;GY|@@Zq#&7bm+FAp9C66(-lwCzI{>gP>z_9*k?##Dulno%UrojxDH^=-iHW>$ zdjz9Q5q2&9B3|iQ)KMKw{i@kOZFmts5gjJ~C;^g%KhME~*}7}j@5qGCVx(=&w3S8g z_4yaGo14=luC+%9-F9~7l8F4HY}0w+ZKl1SZkgDZGt&=k-ol>0H{*G<5}~?rt6;ut5|A7_4Ot)k-38LC>|h1=PeW1DUlS~YzO5wc3{2xei_WqKicLixo$TSg8W z+r-oBDYfTCrzzL={43E-7?gh@y3O&>;w+SmquIQVupMLM^5(QuDF;RC` z+~KSDZ~;C2yut-r@O4=bSP|!B7&1@$ZH)l%3*z>Fa;LT9LyjI}Wo26L&8A`bPn8mm zM}7vdYYJ9XWf$DH-l(9cn;dBsk@?e+K5@{Z1T|mW)m5`*J|^Nw9-DH9U20{n zfrPbRrLNb;2~hKju}uGgKku^hpu=%gfLf^68la%ox!K@qA1liLIz}R{#d2eF z^8`3AG<0;f=|0T|4)823_0;VQxMdlE4JZ;x`eZ zaxNpeC01dH$vRiMsae!VRk*&vd;k56vkRI{n(3h>i@LL;GW5At$dH$>-CCuWm}1Vs zw28_LU<0v7nl zsx3DSm3%C+GkvU_Gra5@yis-IHPRXD1d7fNwdDmmjcrfwv!FkE7o1a{xmjw``Qt|G zu(6vfG_@`(uKQNbsVA3gB;6mTN8Oio|Nfl>?r3EcyK%iyS%+*4x~4HP8L1gzo{Lvf zFNe}3Dc&8TEtHp5O$QVsMC4%2A$kp@gH)hB<-87;$95$%=6hkA3p&eD7s{hXWC$<{ zCS^YT!-XT7#Np-F`LgjoPgO7?DzGP329 z-o)wEde1sS^Rl6rf!m;vbyBR8gNm7NneMrKBk9z50g1)pF|hZtp`_&7$t-I$fzI?g7T>$U*-v;RRR2`3pX*y=hI8 z<@C5H`mX8RbM`~03Wmk|zx&Z8J+^F>A1M`(T*%J(UmcBMExB1J~cV&R)-2rh= zEpK`rJJ~a(XYe|sc;CWYCr#}2(JNH`@75VP@7K_%F^<8sjBvZ+Ch_b}`!qvg_m>mW zOI(p&i?8D$|GpaAMfsk1IiGsMrPxjGNXH&HI_n?X>nc>w_XyCYUqjL4FC2{1U0zuc z$D>BoDOORTaWz3$1LaS>9f1qnHPt?*6i{i#w`sgDw!Y0?!L(d={TqW)!-8)s`)j;% zqt5-@WYfvt;gKg|9X2_&-9Ge3b;xj0$mlA{tB*S=&pcUuM7MSOABihns2*746Ud7g z`Qo+o*Lp40-5r;GK|9e-1wxLuEA5DIud;zKt;Ad^uL4S#dOFd_%V40RZJ-Q;PJ0j$ zsAd-56npGaz?NT_PhEP3;$vAYW{P*h4ayz0STC>srUVx%TrS-SzF`BMJZmZ##+&`$LqeLSFEV6@Tb`vZ)_*W$nZU%4Mr} z?{w5$y{07SBTI{UsL*=Tw;z`EW6`TDZg;rVn5Z1LZaw9A!zs$!{<@OloMTnM+saaw z)e~ZGrI&by+IezpEcparXjWpv2m=|G$C;GH9e?E()n>GGV8yMNaM%R}O0!E!f6DLk zz}`53@wx5c)~kHYxWhtmWZ}nl> s_r?5d$M~FA1$1Yw@_oYZUNC~v?HIj_6^!x;+xky3P>ebM zIDYEP$(x}ODNn!E`w7Ui80>-Zm^SW>?VEfW6VAfUx9}^ko-W)?uRGgG&Ei;FpJQ!d zc^uQYR%qphprFURJwGb8WJfKuJ&zT!+N=y?%vYzc&3wBnMnXL2Ray(R4)6yMg*bDS zF6B>^x;pqpxDA{iH0Ie8kAk=42Fjn8m-?BYLM5&-ct!c2`qguzRt%2MIDLJ^prNJ3 zi;@-q!6akL)~yw=`$dEqv z)|^ztWGPaO3{I1~G#h!P`Eq({1I3sAsEN+VD49J_p9os!si8;gUAQ2 zYs|IPgZ`DK{d{+QBIs&zY5uQ>+yJ7fP!QZ;t<+Fa`SX_>ltqqfUx{Jb8kP>2$Rm!q zzJOE|<^EF+4iY|t0(A^J)Pyx=3alA4Kn23kmwh`g$O;M0q5E&|6wu*s}T$;zoBKZr1@7sRnv5U|JZ|oxHrf zx{eOyTU8?9@7s6gwefjkSI_WTuqL+Y*{RZ{v|Tbjjjs1wUlUhF4AH&UpfTls=>ZT+0&aKmQI6UpP z%FNq^3Rm^kLUmj0+4YlsbzOb8ujZ3Nh>7EvSpBQ)Jq;qxh@DtMVj_Ua-cgKtZgA2~LsfM*2qA1? zUMZ=6<^B;tp_J7s2o%Q+3|Qea)-9PP1+b05%`sWQo6$$lDAj~esIDGLHmvhti%|V( zL~$`oCUMG2*qt6cxUJgC?hpw^xQ2k(+D)*QNci!Px$yZTPQ4b1r;??r? z7Jaob6;P)B-X-G%7K9w%K*?VZzqpSpO3sg#{lnsOr(usmhwQ66%h?2qAs$+VA*=;W z6a5XpVXG8GE21W#_k$=Q+1Vn5FDmGJ=68|xy^z-#7nfY<{Cnldv*+sr-J(>4^ZoqH zIPs+siTKV04-f?;m&25VgoFXy2cSO`6)iuXQOU7EXPESkbh@iax=qxwUu}BQ=5Hh8d^3!_B$Qm;*vqpZ^9sm*@K-dSY1;yL3(MXhDbp;vU1$czU!mIWO zoILyXC46#377^Kpr{qw840GVXfl&1G5@N$NUw&n^nyD0OPXn*WCG+) zl1QwYQXVWWPL-y@GQ-wFIXOX+IsT~6YWFr7sW7mX{SmT3@aDssJ|_(V(v zo}(bC(>S}%RKnqE?OjiD3o@6I?&kphueN`pI>%XL-fN#bIUxxBoYr z4NE2}S=5juNv0upo<4n=m`WZ*My3(_8VWihn`B>jx7NUGVG@*O2rbcuH6qj-A&HmdMy%A&ADl<1y3Qy>Bp%W{Sd ze>%V42I3s;J;AB3r5>>XVc#~&zmwFi-#^ovHrng-Z$AmYT|deiV*w`yV732c2h6Jw zW1{KbcM?+KLDYm{0KNoSmY&d7bcew>#o2%1e0j**g;pmAzQ@dk`jzi}(B=oIh3tu6 z@K?&R^oD*$3QjMXwHj*AN9W+tcp^g*mNkffrSmbl_6)^U%`f^hD|2jYuA$4%qT+Ri z4~%BN?IuQXeva~psHX~6H$LZZC_T)sUzt$G-~8hFE=trNWrDj6{%TMykH|=%CO6k8 zId^;7vb_vb^fgE~GnJtnTa#dUc;;~{|B}OFw}nCVv%}2^H>^K9iM+M8WIYqYS>{!B z#kh5WasCvb1b}UE$^1_R|82qvCpuat-~B@kLat+zaG@f$Kkk-hEfdT(e!WZ%$_Q7I zDc8Gyo;$$j8Xr?xZF~L|(Tg88!1sGa@#oak<;Yd&kTi`*AYj4+Xc6pQ5dSA0Q&t}k zL(6U)f4fu{C6AblMux`+BpQR}a{9mO9%g46)78|{vPOz10QOwtEp}Nn@l*N{>^A>D zOH0>y<9O$miIXq?+Uy#3W9BYEy9ls1F+{=o-0)DyG&DGPWB&zqH9^)!m{GIcXB=S> zRmA;ZsjmO}`W7r>+#lU+YF2T&Kg}pz6c7?|Cm%!PrjRvcgJvG4C@p;&K*{7XF5Fh?X71z>GE z-N*fD8AchPx(N46*nQmZ6N{QCNm5E7pCv-%&_Wi4L4s6JB%u-R z5Qz*m6^xDN134tS9kiLsIo(HZ5Qzi!2$Z4&045s1%Wl60w~gJ%xjr@AWbZk?ofND9 z^e`af0^)RPRwG0NIhsJtcDt7+Akk|%JLiz>W(`k*ILrqpOSRb?*^3P`NZ)Ev(J_1q z`M?UCty|9nt;To-7Qj|*(#QyBc3NB2&Z_eQK=^>uv(-hFAsrPH@x<31;JgA+FFZTvkbi!oKZj= zIC5kvly-UKOEJkHu@LB)Wlptgz}vmK)42(u(F9*obS^nE+FC!Yf9CEKblyK$Zg>(P3i0FyJJ{6J4?OW zopVf+y|SVr8#c9}&Qj@#5vQgU4I(_93FJu2`XsKfig`yZY(?pup3^6gCt(K?46es_l#(@30;1};W=%Rg=PH#eWBV|(1Kq#`$JWAwWtwVJY`vi9>Nw_y<*+g zhX4o(HNC>Asj1cQ+kUS4^yzSK_2Wws36`1~8jtX;eAl_5JkBvOTuZbDO4|7Q?e-#g zzN(az1LN4ghhUGkf}c&azDeXNI*eQfTk71goCEH~DJc~&u<%wx*!X>)&XFUXa1#r2 zbC=IU^JhEFuGk=Q>$PzodV&mvo3;F2r zV{7spSis+pHQZ777~T+vQv<}^as}b#2dsQ1xmHaT^K+d`9KYN=3<@Xd&5zl|odgk< zg7!FMSK!AoN098BJigPIUoW?+ zJ=-!wM?=GGNy}U;RfF`b)|O+wwAI zu;(AWHm;rT4pFW`yr2~cujsQPH3W_pEr@CcCf{wPf z1-YjCx7#cM(^q!ulp|C=LXT*dgwebkuYHTGopf^_VXGOye7mLPAVS z#@=sFz&uY4el`u*Cj7o=ASIQoRD($1g3hM?xh6Z-<=1W!<8=O&UaRg8K?C54P@8%) zEC+?jS&i;6z{&d4$5N)JuQ72->EjUmUD*>1>t&`%S+`?8MEy?RU&4$sK%cEymjb~{ zz|YF=@&seFoEq*R5gJ6wW^@VgroSZaYTW`S%eYjYj{}Df@bIVr8(`Wbn`(5aO&l3UZLHQ!x_a84V_Y z2D};_xEB5GsG`F7izie)kQd0p!0@XgZB2wVRn?7kSoqc6+)2n*NR4Z@&wX_%MB|VI z8i6Ejs2ZlvVFpJ~{%y{iJOMYp=+$9;1DDTc1#n3^SMudql=(2lOcApPa07&?7~B5- zeq_&j2)nxt_R7(wpAn}!j^A_s{O*mCzgkR5W6ec>q2%;*X1e&@z(6gSj_}h7#)3(h znkd&%dTZBYO9u5h5 zwCL5!Is65E zzh7{Hgm_~AvCS+jsc?J^j$^n=c~da$$92*zR+L_}OR5rhN*ZkR2+HemfwIOJ=5 zivT^Gin9w;9svP+!KqY(Q=WUSbD=wf;Pk)#`YUs2&6+hx-u}a0`}J~d>fkvP0k|Q1 zFgWMX0@~J+*KFFC1jU%Zumq*Zl)Ia_2mFtGIgcHHZP?>dSoZ$nOMQOSe4=+Yv_txr zgqSN+FrU@LUjYN#6)*qQP{NCK^H|A@l{uWzw|^=Y32>Z~`=e83UykwLy(*V7xMI z*vs1w188-Y%zpFboWLthtk4>W!|x~_>HMWewD)ODGEc)tLy7Rpy``O;xym~?SU60k zr>E1@lqKVdXA70GNyi*%00ID#@gh0^f64TPVz|87jyhgUitni%ehU&wTq{T&Tim}# zcNoVDupk~@@r2AZnt08{Z1mDhbmsU@Intp-JhgDmiar!C0ku4fmy)Cu4j1rFL{~=~ z+M!z#;T6jtPJb9J3Ry!v(8sOxu&6(Gn#hL##l#-DZQHi}1gFKrvt|hMmQ39ITwGlBO{r>lj|E=TKq{1~s&jI*jZC6YJdk}t zA3Y*(6Turm&Zw0WdkDfZ4(e=1ZPsb}Mo=UKav{(X^CJ2k!JE*FqBm{a_$Exla=+E5 zg^z}XxFELTZT~ieh>UX$j2)aoKc?m;VZ!Z4lVvk$_JSqiSJK=OFy@F|&8U&oL9yeV zFZtLLbUGO5-jrRQh6|xJ5$_%N_F68^&w%!20}m!NB?%Y}hdkckvi%(U62wF05N>4} zLED7bh*=qk7ErT`7cH<{z7J{y8S&@+I8vBVutNUBp0?<*=H8D&hB)tk_EgGrn1U+- z!SMjr*Z8+@-^#L#Jw#{LBp{EW#MR;7FWEpI^eHxM)(%6rhZ5-cY(t_zko*ncfBTmX z6^q|t$}w2K4&HFNfnLX)%@JY zGJ+U%2vdW?h~t;8Es75mcBXx0A|U^vWT9$E1?9Tu<7`g>QaqpmpG{F+zviZk>uojc z0f&qA3o(Z+T84X)U1D*Kj^sIzk`juQw&k4C?@#rCf zxNosbTurL6AnV$zLFrv!&*FgN&Xd=n{I=x?$SX!($E+f56EG7qL>lpsTL{a9cjWAt z%-YApll;0p!{xQOH}?k|d~lc<#lIr37omw5y7liR7F!~*eL6N?g_TJ{NON9Vn4$wW zHQVNOBtRJ0FCd_d9f>1N-Y0`mO``No0p2GjdD8Vp2rw)_L05o8C@A0V?u#S^E=_qY zC1S6V4rv69mv99qq1~Bhux!^xsf7u(>PN!dA~HWwTF^)r2x)gA?K#k1;H^nU^E6?$ zvBaeKLEI)TIS|022t(7rVxq1;FJhM;rrzF%YD+ZXtXpNj@2fB zfV40uOHPK8u1agP`@*{X>^E8B*E=`w96A}iwnFnnOpzUK3&%dvfKC=t1Ap%6u zyIK~de<32_cOw^w=31cB3GyNxghKS;g@FggW+p;z3TV=psqUU0%ZgB**`JjHAd^YQ z5!zexeAAdY*Km4F1d$G4;A_%agCH)xG(YZ)EbTjB0G=L%jv-2wux7dj;2a_TnOFs% zsx&@-kKSb}IZHK?Q~DOW125(rC<3E1TQ0pw-W&$+JEEn*<#$_3WZ{?I z(MTmysgV9m^g<|ElImLon1W9)_Z%V<0x_ba8o-hHrzgo6MF(CdMHCTm`n!-u(O{3} zakN8A&i2IuJ1QR=`%7wWP#E$oMAFF1@3#?kzzM~ek1k#mkzsg!NR;&9;v|um7LiUk z6u776b!okq6ywr+#@aK2fBWdkLELU%6hnHC*iF${F^m2SDl#)^D1rilmY+mL7z-#OED2T-E&ELD+z7s(#&_z-Xy8(a zjI1sk%JHTKm9vY~yKi%jeVNNaLkG4kj+nD2Gt_B9qF^R4+46F7$ypi#8=ViL_uta8 z-(>27V&%o5nn+X~plOWI91pi)S{8HpxXz}#zsn^;)RyhRYta5b{PMv?>4Y_<)uQhE zyYZNNola{zT{Lkr6E}4#8;=)J71%-I=2SGuD%CKWTjP{{VaJTl)Y2 literal 15644 zcmeHuXH-<_w(TYf0)n=!phN|~P>3UUJn+E>#rMdeEen04>r04(gnK*zq%cJv??n5>lJ;i2WJ)D@f|pt zryLOXQJ&Z(SfZ71+pXj7YptV%+bH#uKUziN%{uzh)at!{u~#eS8B1ce6I7G4R+DP_ zN=b3#=_6VtUQVg?sG6!me$MY7=9m4jmL4zt)~bg6*lXi<$2Lnu&BKqt?OZU|esdoF z4II6WP$EbHGdU;x^64-_27e1dXb{9qh*Ay?2s?$4Bgk!fvcm{c_d87>ymegu|9|A) zUNHsgO7i!U-Fl|o@glZegM<0WyR%l6`+M6y(&(xxLw9%gCy|ja+bmfo49Jnd_ks;s zB_%oxq4KE;`b7e*mf=D{=xc)F0ejUMH(tFJ8}`)_5)x9;(7>DSZ|Qw%XxL)i?zKuj z2X7)Ju#b8(Qgad8_cr2b~=qZ$Ey#h9i_8izr8K>*{7Sas(K~#Kh!aFnF|aRk7F7?-=t^ zhrt}u`>U&~r1Oe84&{lvPAElBPftsYYDAw=f1UNCF=~CwWd6=@T-?v7I@QqJS*9>h z=V@q|(9zLRY|--4Bw2u$w`00Hx5Qykf=$Xx({-ZtriVwVjg1X=#RQd6YjXf6MBvy7 zXX(J+-rnXfU*=af)e=OlKRr2?^pGt<%u!ca`EjXzf5!d$fJiPk8E(9!n;t@PWPjX}=gO08)@A>mBxl-rPtB#M4N2g%|c4tug zyX)>d8_p%Ar8(v0x9N^wm|U-Z{P=NU|6G#cl`HR`mOxUBs6>>r*X_NQ^1fwkY^) z58nm_XQRoA~Pkn z%Omk|`%8^}8m%05PoMHrVuI+8G3e0DWMkNK<<^ltyN>4?Dzbad`*^xs_4eJgVy6@$cHeVfK1!~D6S~%?3MOhdcVm=S=U|Iy&!&-| z8hisy*dwPy$M)tu>5q}eK7g{#Wn`RKY!jnxG)t?-6q-GB-@vrSE><`oeA7s7@iam% z_cSNhb+t9-Wo3v7wPbj2_qepI`n2EW63mb|syFaiD4fIp;?sONek&7woa2Sb3h%iX zyWCNRVCiAW3*no#f!(kdlzi)WiIUPvRKb0VuqQ!zN~?{{9Z4w|0(odle$n=7f0^p~ zkk2@tN^X)1Azw_$Op4aUcpT!{;tDplaWLQ%%Vvu_mOVOp>qfZkr2G5(L&Ma_0l55; zLgKo`Of0RPUSXqwV;JN8d}_E9B$yV~RzRTkx7`uyTZ)Y%>uy!AF%HuL!4W4veWyT} zX({FE?xPY62@H4U#qB!A7p5Adgb|uUlyYXlRbHP*WgcS+&QV8mJAidu2$Cz~Y~3-DN`)zHG`6 zOdg#Qx=V*FDj<|sHBH|O@IJ9uLXcR}udQJMD*HRQp0VAxxSJhG%aV-vAu~eG4b(f!Iai5FXiww$l)BCK);@H=TytK_+yhc2z#!svK6k< z-{bP_F*1Z%irh>fl2!aIqwJ0*9TPvjn+_6X-D%{y*ANv;OGjbMg2??wSMjsRLxzj9 zGW6Ps&JES{6XNm>%WOK*l%G6#65Tn~RqMCSKO_AOZJY~rHbCdZVi?DsX62^kRJUGl z^$Enu;wnE*hMN$&lzQ5GF*`az#fzPDcORfeLCAIv>f4yq>+=UA_tZ+#>R#utc^7K=a_jd>~ zjirC8SI`onKPD}I{;YIeLBZtCOduV*&kfY3h4t+1sdcQ?9tUD{aGl`k>RN;+l*I%a zF`5NPNJwbw>u2ZXUBE2EOH6Dm<0LB;6;)1te)l``Mq;k%u8Oy}cTEU3>6fENEz0_( z#X_P+9mU1bi|Zec2FoIKF)TN?k)(fW7xhnT937*^Cm6unoH z4a4Zhhag;^9>r5IA31U=vopJ+;}&KaUfPnRCFM#0ztQlY!c%ztCkT~^Nj&+3nX1&_CCAN6p zbLW%+2M+H{h>3VF-whCjYv6qIHwjm2H?_L?_U-9>lNy7WZ~2|?A5e=}ePOk*vdYcK zXmAY&-~e45mybrPXKEyW%f-~@m^VgFZ7luZ6%f$V*Y9-_VFaA8 zot2VuM~+awIgwD}GB z+_!nF$oYqY{Xn^MT_gV6H3o_Vte{5D$dQD8EDkI{)h@ zxP}h0#V?WzT_Sj+)CDNqCgUX~CGld8Nu=?nt4n)sph8$q1WLuCtSWUKHM^G_PIkXq zV{`IrYKixXC7X=zZO7`R5dW>tWGKaa$X^a^ZM|__QE~f46o;%yXQoChH{{-VQBmDY z^~96&(~vv#kKY{ncTy0yu$q;XrRnKe2C=m3?*NM`N7IM&eEXJBTztvCw=f+~2z&CR z7`18x%~GA3k-h7+xa*6=#Qga9lQ<#uOs#Y0&dHQPSd(?9WM?a{4|*ok($Vd9oPjf$ z2}-mdn^c8Sr?9AK+tbpN#K*^HQnt3Xb{+~ZLliQ&`&4wqngu@% zDB|&#o!<`mEJ!PN^gCknp~3((FoZS56Q?@eC)-nGaL?o7eybXsuc+|hB-Q$x?F?j$ z!EKf+D7)~bb2A#s%F3AWvH_Q{%Bm`A-=w}igHInnda?gC-T1gE%#4g)fB5jh7qxwo zg~bm=6)F$uriZ}J(^#Gor)2&6Mt0l|?%L=o+;x()kFH`A`>GTgjn>uCiTT~!Jm$rV zw4EK_@rel=fE>-AKWpB(lLDh;vCDWf^6ey)%?&DhBo8*#(lUeK3`xmt-CJnU_s%@@ z85w8ndkU_=L<WS#sKMt z9EkeAf+~4uhg7e8k#uhp!B18V@1k+8fWw+wTf3mgU9#`H1UX3cCIs$BzP^xbF^HPI zeFY~wJmcCDD}WC<#NxKGc&BFdn;{I;tP_2tTw-fEQ1|DI3s`(lP0PrLhb-V$hQfDJ z8bx%{``KD3EszW6&ugixN3t@6+KDE3EDX)LwtmYu6tV8$zJC3B)0CUdaIK%e_X3w< zl?=w~1qenD=S7KhiM8(9ud}*^b+e?;n3_deS1NRG6Y8uLQQX^b4toAKC zyF57ki{xa?z<^QPYjLd;Cri7H0r}`O9@UrkU=#WZ?mWoQNJbYHUOdLcbY5IsT<}GlWCs~z2e2J^7p%8EvXdh+gTlJIm0@(k)SPkm zsB9hxxP>=4ucJquXM+fy_L9LSB=A)|68_BxkypocHzp=_Y_6aUo!?!$bN|;PqqHHZ z3d%Qc5|4jKO}q9a%ysv1_{s4t;a8V$_LZnkPdZV_dTy`?E1b@}{f)@`XyLT2$ zte3~=l1EYn;ti%49yTb=&2>JD7q?bf0M)d{rx&%r376_C*5+Jn!K5v+tO{{*?Vqx6W1YvFPC{g zn9^=JQ&ZN?jK>kaC}XO>Pm{Y)*DpHh8F)=+*Of3*h_;iyLb}%uE&KdtYFf{2e6prz z88IqANdVh=1IWnz!$@fJeJUVQ&>Bvjzs=6SEUwO>qb{uPTcw1|Gw0r+fyNTGY9^e?(1HZzu(1)AS{E3o5<)Kf{ z-Y|0*(&73OE(?e^V&6$?84;_i}s44 z#2*~gXuyvfEM)Dpz^cCYfvJ+_XS*zv~u`%Fy*<;s%a zIC4*i38OGnIR3%Q3P*K@Nr3-^r08$hr=E{ijUzipp+@bC=Gj3!dAYimYp!TT)*6;JxksykWfr^f% z=Sb3qz>wr%#8( z%Hc@A{cV3k=H=(f^ogf+usf_mJSk4u-%+Hs$sNb4Y#wm zp@_$cCYY)pL;}Z;AfvMLNp(awyvYT7dp+M~om?X=y7~`kgyhV1=#{{Cf55UbSWnzo zu>bu)Hu_7+BA1jAaF!FhWXOmBr5t_43L#x~w@D;KQYk@HnImAf&qGjVD9W7zsryb7 zxQG?-YZ7tr`5tUb@A-6~zjnasfh`L&@YWoZavP@pwJ+j%joo8r{GT?2Kb!TyA84Ol zr-l>{XKcZ97e-*)qdM=)JH?ruOUb~U4l>pW#upR`L(qsXVqV~ z1M2MV>B$0A;79zbcv9Fh{7bSd=A2f>WSiKqHlRkBRaf!YJsrRvG6ZXD>t}-wdcfsC zCnIl<=9~y+mqU;c^5o&;b7ZWt{?*Vy_?4eTMd?9fQcslNQAPno7jd7~1|i|f*RNmy zkV(k(2iwO$3Doas5l{_fpsIw4^iAj+`hRDJaMWDTxp^}M`Z~{)H*Y@E#hB!~&wQI2dH*0@ z*eVjBjgFSq5AlX6H(nl|PXt{(J%V_~U#AOci<*c>{X2^#mM@9K&RZ^pGwc8!BHkEL zy@tVLc6L@KdAQj6xo+O=l~K^IxuW}lmzs|1+1`k5>0 z9`y92<%37hc&%>ut@T=gc%_Ra*jQUHp;%9x$o~BKv%jhNLAv8gj@UT^%8T}W7Ht%H zxm5)boSoEU$RdUWTmI$bU;nrB$tr4o#&o}OC}7`@P1fHiKR=(BpZ^<-B3sg?zyJPr z)}x9r!I1Lw{HM8I*WU9%)SEE>3L;l}LCkr6RwE}jSM}h*gC^tfVsq~vbG!JE|F-?H zW5>>kh;$2M7aua2v=>`O?kggP8Lu$D7Aa#G24>@*eDAEfko6#)6cKw)~#FG zMn-vKV`FkUCt&iqdwaPmaQETDFO&!;adDIFzAFNt+R5TS5^`x&+}%6Oqbla%z5|XR zM_!aV#;(me4+4POKMCZQS#WNyYkGOLRMRN)V$1S!^#UBY-%jx;MdUMDDpcM8yH|LT z3(7DjIcJEjdgQNcbCqy!SAvj7DJ51>U47Gk`86h%FuhyV+T_c_19UXn2MU=fNY@A5 zc&_TGs)j*i#3v*iJ9_l!E=ON-#bI)t*a?g* zu~S}K0EF#udo#h}B(JMbbkbfP$Kxo9&B&xdprbzq1+CalG&@(d51Wixg@sdsep0-= zlHT+@JxZ3{i4mI4Ez1m2T5WKU9hPqyeQJq&`Qd|6O%O$aWdw1)>gP2Ew32;nZ^3!m zACRugH%s#RaBPp?ycythIXw|MJsHk&wk?5%PEZm-SnWw(00QZT_Y{$j?LOZRPQ9`^ zFpyqm{d{IoEg_`b1hlhX;j3_#&%Y!-PxAASGo2e9ihs@53=IEC=m<4CzIySt_A$EX z*>%lzb)og4meW92g*@S*FtfMM2Rb1Ws^o7XB02y{h~g7r0=1ehE`>nnvjm=u6l4e` zcBoQp*+i)&7;P(5nI1rp9b9y7AWYZ!Z3$wwTf`|FJ3DO@s`5C$QI?Q-gI8qlABsbr zL8M@3hH^`6)%^DRMOayRT(oo`2)`tXfJb?0X$i#0?rg10DIABm%QX)FjTATsa~5x; z6i7n?*b98deG6ju^YpoP7endy$q~U9_b(zZV`9#oJ*x<$r)Yv&mFL2mxFztK@t3Tl z-@bhd+*^s`aP5^EJy0)!SBQy=n>=S&<&jTIOMAdLfOuL!e+I-Y)}$o>_of%N!7^-81( zYKjLKFs(n74Cr9QmE`?uoGTCzUeb}_;o5iaj`8$ci~FpV>yj_@a;0akqdpf~ccjS2 zzUBor87-&zuZf|+FL%PfE|0f}1niNB5|p%_rsf+M3E3n)ZeX{%F)w0c@s1nM)4%}$ zJT5L`^oPvYcm-;IYeS{HQesNg)TNEg2MSp?!Ygq@*!R7)#;6%SJ%zh;fK5Ww|85G6HFT)BJ~%iSE9J1cJWe5D`jZj5#z7Km zmagmR4GZHoq!OS1FhDwRzg~fgKz&M#l9h=mv!FmQd8oFbK_S`X3gs*L(6oRZd0zf` z_w#W{T9l+HI9P%FgEE5o#7cA3uvBSji8S5})rF0XDSiD)L?9Hq{<{S_b|Xoj@;0i{ zZLXxlXQ2W`A#gG9`Ue=586l|uy9Dn6o0j8vysy+!Fixu#G!rwgp72paJ?h-_^y?l~ z#%*nF7s!_$G_t#{?v0NX9HK|eCZVjSNe42&2SB!6Gd8|CyZU{Iy&%e-9I9_}@WAQA z!R2%P#)G~!z8nShqtlz_j3hvGoa}J@c>xUi#92G`ccO@8 z*oxy1b^_ep(c*zMc8m~QJK@Nq(e=f8^e)2T-=hV1Vy5Mas6DM&4H$@Mprj8=E-0Bd zR?hFst{b?0OQS#piMOf3NAWE#!y>k6am>01yv5o>y+~US1%)al6z3Qcc!VYokU8fY znm}g%nprBPGjPuvP<(fmm(wa-)4%Cze4nujxCh&9b%Ff-qU&X&^D=9*&)%k{ug+|q zybO18gzRvT^Ud$B0f$(jx1cEHC>5eU>gk=8UJAZjq`bN5%Opsef5Zc6!r60WMD3$# z>C%}@%ow07*9Wo7QHJ<*hjN>Ln*sda^!ybC4UCkW$Z0`TE16L$-7xuwp9L-oc~m!9 zG5w%sAHGAkmF!yGJ8IGi!r%m~KBTy*o`miC=?fx{JY@#g#Ux)xb2%gssdFOoDwuacoYKh9FxPu!!n*mz zITbav?k|awHAw->O=o{1)mImwEF$W4+>p91jZFQAbNm?86O+_JnHn>vdDUUeo&^-Zm?44`5Coa z+S)IGfLojE7t31D`3srOqinj_tXJ$YX8;sk)2P#A!thSU8I2_0>vMofXwLjkz~Fza zbhV2dhlwt(_r}wIOX)I`BiIA&URJxx2O`xuF)_SWtt&x&Zm>#ELwfZE_ta7&N34(n zqcrg;PTau2;BHyJ4(t~Aoix1f-c38r#U)Uc4_`Q0Aqx~zLX8YIpBqS|?ar@XQ$RTc z9nd?*%EBVMy4qKcAlPsZs$INnK&{@N>Mv-`BmohIhK`{cANSo={JKx=A9dOO&8c4@ zSq@)yIP&>lkb;w}j@aE&5bt5^nto-v@qtd@USF|w<=?1fsR|JtVzo<$z=D)Dyt4WY z!W}uB2TIgm_2=3FmlnQh0KO}m5iDXhKN=z^(5g_2EvlXZr#X4>p8@abN5G>+Nl%c_ zOg--yx!JXA!4Lo{s;V{3s;a6YK5Mf`H*Ku_wud#2oiy_>>s}H64-8C3FRP^%01FD* z-FIP$tMOUq1??=;_YX3k8?Vs5zr?Yh@+Z-3vgvGc7qFlbd8>C%i2p1%3!H}nQ|`+` z-d<%)9zJ#Xr+G>5{|>t&aQJri_T9i*r%iQc+QPQ>)%sNtDxir2TGPAfE_*9{5w`}~DJ~4sD@zrOcCKF5yIsfH=jsGL6y9WmH z;^N|dS__RBWU%R9gV1tsf*(Gdf@%IGHw^abV1{$C8ik?Oc4uQLI&EXa3tWlQUD;YP zBxe`ruT*n~o%HozxwyEDIbFV6)LZPc?vVV`MyUM!%sF0O6%fp}*XFA7)-StGgo8iu zlJoa#Bnutb&sM}UzGil(QhgA<0YM#l8tvYaSK*Y1o9 z%s2*YC&19S`aMiw`s3rHCJSG?y3)WQsR5n}dAueR(mTh0aYgJwsF>?Z2i4oB8T>Wr zz&wB^*QVw1BSOq(>H8;`n9FC^H@-&sr$KR?@fqGu;?AzAF&^IfRt7jKb6{Y=#Pmm! zyr!Yyj7TWw#f!JVj2LSSxgki5qhS6h9k@F+IjL!3kq+#9b#qZ+p|**M%p2F&mz}SI zTo-K=Km#SBa&K#fN4bHS&$QMEJOvBFJF74LklhZQ34|S{k9}%H>GChcJc&lDWWS7K z=XF0bbD4+h<{PAgu=*DBSdeXDribaBDD?%0i{%E6 zjB4kBxf|lm2!c{svfTYc&W>g&^PF9~OiF`_CNK z7&*vb{H{{h&=6XY!_Vzn+08-)$^3SOrjv7N5nQ3i`m7&{hMfKrah5U-R#+{dPi$;$ zMV!BXl+&|P`ipZ@ADmD@=r2#-UH!X{p9r_7Z;&`7hC-kd|JnbYN?{zNIl(UNXm1ZQ zw`!oR@TGydli72wMgR0+H~gpOqLDZXFDjYMv7>59QsV91kgg8|qX~;YVQ>&HPsHD!+vFWA;1K>4i0GG4B&t8W4MD# zJZh(cW%ncAOco7i5&N=IEu;`7vy}xZCAxB&msC$lU*7E}umD4%7B(4t>)Y#LMDTulvmN~`suJs9<+!f^SIHi*mGSM7+8B8Nikr|xr-tkyx9$UX-`}U2 z5W{Xpc!ND!4V3nZ-L-x-Fc`z|nMa7La3#c7S4(M`nl4l%in}(lyP5d`4TqoO46@m9y*nh_h zEa>0G&-C>7^z=-2*MfhItEn2GOG8|HO(d*~CHM*_#$!!Iqg%liSe>-qSYqqoAPVf? z#C+9)Xea~QMFH$i;p50iQPN0DKGXnATAZW*NGHwoHc=Nu0cMY`%d8AVHr+XaWnY=iU-B7RI#kVxVz$IY zM7-IGT*g&|VV|`O3~U%!FPnj%TFt;99*p|Fn#InXbF;m*fI?P)-R$eJ6I}to=o5Kx z%~t#=?ofbHu7=F!M)N|fwW#j?l+Gc!xC?kvV1c3Ub7jwhdVWo>e zxqvg!^UXJmsUtL1lpj27&`%2Wo#j|8@db45FFkV}D-aGW=2ufAn0!FQZyRfRt_BRL zkmX&Y#xPmUUH3V#``bX$h=Wgy5CtDebHOS>MjvsQ*3B-nm=Ep85TNSmra&Dc3f zIF|I8O&~h#!VjWFPYM@+h~gN~-bC<7!{9^9Z|vhVU^?rbpFgGVlBui3*Q3zZRxIFzfTTIt@ z_tyjVJ%NbUB{^#vB3NodI@cD4F)v>H3VvLTULe6q)gH_}cXE9KNTxf0RwT!4b4!bs zxp^v~0wxJ}4-b^FZD@T8d z%K=0MB}u;TOzvpz2!H24PZ5+^x(}?vZ-M~tP%(ZS+-F|RvHZq40N1R+J4bq0f+P@3 zlE4%Id>&<38BkN!#Z7&EecN}~Nr;J%9AE-$S)%&u%P9fdWdWVQaIHeDdrkNByYE2I z@jO&u@#(AaDT7!b`IUT{6+XCE$6?XN@IVE+X3ZekwLCcim_KZ;%ss-F#7-!ac>r7W zej0hHIeayzrlu+<;%$L=T_AC2H-Sh`@>|naMtd0T_>lhc>yaZze#MJ{qhok`X#K_O z*Ll;^HoG&}z1#_0G6oh8yudjrDOcby(&5!6_!Vr~`=N%gU5HX0H@D*X${BvlvS#JW z8b61P8G}`i8&|L1CrM8rJ=g%)mG8a)k32ARd>Y=l6MnGCkwU-3CT4GM9XkW{Elkhb z#3YG8fQ|8+vo-B(eI@KZQbz_;x$5#Ro6`GLpU+>utnEmF`39_k_m;<+wjkzbUfuK0 z{?k5I5R$aOCWhZPjtZXXVG1y+8v61TZ%dJ0RHQ{}Ye0dPxX44iK9762%I;2SpjO(%1U8Ky!RnJNKhL-nxs_o) z>;wafZ{+sQ3hu$$x*&8hcveSEF_LvD@4)yHHv?8L7R5Swiizb!J>6c_xXX$o;&zqk&%4F z;>pj4X^8YG6<}QXlV_!ST&Uq*ca9EfJVuXby1!~ladLVKDr#46@6?n(4xD75BM$kk z8{>qa7@NX4#9E9EU0d_mh2$-Ri&;2ve9oIqQbK|Veb#%LL&bil&Cx#=$$@1U0BRkjT{&`ZWOR0RhO!*9VO-1i%V?WpS()dc%l)K+UKUjbHVH?9zdjDn7A_ zH`Rj@@>-qHuDwHhNkk;OwDg-+0GPWM7o9M+#-^qiFeeSqNQ9`cB>T*ZgC7TmBID&A zv#OV|TLX*u5-`FoZuxI&-+xpQ*!XDh*+;Kkh6^*PCZl9}{o56y7#BUzk}}&mSI6^23A3m%k}$ zTvJp`n4G*<1ljEh3Jy}7LG0a5OfOBn~+e|&GMTPwa{v7_9FNVOIw+LU~SjevHOEi&>F8PD8!RaKpIJU zN&{iNA%Fe$B;6O5ZtLq?Lnp8R@bLJ_lZ$xMfEsHcL&B<3-Ell>F60- zkfJHsoV>R|wWM?Il~t0E9#|Z3GOrtg8%nCX2q8jyRk}Xw^CA%6g0NZ>eYTi6kxM_C td&5s;*n>8S9R4+q#DD!i|ETL8hlg+`$35M4l8qKozOH@^ebwy#{{gn+`nCW7 diff --git a/doc/changelog.md b/doc/changelog.md index 80db176e..5ac182a3 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -1,21 +1,34 @@ (changelog)= + # Change Log +## Nov-3-2021: Version 2.1.0 + +- Fix of a critical bung in the direct solution. See the detail as commit log of + [54d4ddab](https://github.com/phonopy/phono3py/commit/54d4ddab6f3fbf9435bdfe8b27757be1d5c4ebf6). +- Aiming modernizing phono3py code, required python version and package versions + were changed to + + - Python >= 3.6 + - numpy >= 1.11 + - matplotlib >= 2.0 + +- For developers, flake8, black, pydocstyle, and isort were introduced. See + `REAEME.md` and `.pre-commit-config.yaml`. + ## Jul-22-2021: Version 2.0.0 This is a major version release. There are some backword-incompatible changes. -1. Grid point indexing system to address grid points of q-points - is changed. -2. Array data types of most of the integer arrays are changed to - `dtype='int_'` from `dtype='intc'`. +1. Grid point indexing system to address grid points of q-points is changed. +2. Array data types of most of the integer arrays are changed to `dtype='int_'` + from `dtype='intc'`. 3. Python 3.5 or later is required. -To emulate the version 1.x behaviour in `phono3py` command, -try `--v1` option. To emurate the version 1.x behaviour in API, -specify `store_dense_gp_map=False` -and `store_dense_svecs=False` in instatiation of `Phono3py` class -or phon3py loader. +To emulate the version 1.x behaviour in `phono3py` command, try `--v1` option. +To emurate the version 1.x behaviour in API, specify `store_dense_gp_map=False` +and `store_dense_svecs=False` in instatiation of `Phono3py` class or phon3py +loader. ## Mar-17-2021: Version 1.22.3 @@ -37,21 +50,19 @@ or phon3py loader. ## Sep-30-2020: Version 1.21.0 - Maintenance release to follow the change of phonopy at v2.8.1 -- Improvements of phono3py loader (`phono3py.load`), `phono3py-load` - command, API, and `phono3py_disp.yaml`. -- Harmonic phonon calculation on mesh was multithreaded. This is - effective when using very dense mesh with non-analytical term - correction (probably rare case). -- Real and imaginary parts of self energy and spectral function of - bubble diagram at API level +- Improvements of phono3py loader (`phono3py.load`), `phono3py-load` command, + API, and `phono3py_disp.yaml`. +- Harmonic phonon calculation on mesh was multithreaded. This is effective when + using very dense mesh with non-analytical term correction (probably rare + case). +- Real and imaginary parts of self energy and spectral function of bubble + diagram at API level ## Mar-3-2020: Version 1.20.0 -- `phono3py_disp.yaml` is made when creating displacements in - addition to `disp_fc3.yaml` and - `disp_fc2.yaml`. `phono3py_disp.yaml` will be used instead of - `disp_fc3.yaml` and `disp_fc2.yaml` in the future major release - (v2.0). +- `phono3py_disp.yaml` is made when creating displacements in addition to + `disp_fc3.yaml` and `disp_fc2.yaml`. `phono3py_disp.yaml` will be used instead + of `disp_fc3.yaml` and `disp_fc2.yaml` in the future major release (v2.0). ## Mar-3-2020: Version 1.19.1 @@ -60,15 +71,14 @@ or phon3py loader. ## Mar-2-2020: Version 1.19.0 - Improvements of phono3py loader and API. -- Improvement of interfaces to calculators. Now it is expected to be - much easier to implement calculator interface if it exists in - phonopy. +- Improvement of interfaces to calculators. Now it is expected to be much easier + to implement calculator interface if it exists in phonopy. - Fixed dependency to phonopy v2.6.0. ## Dec-22-2019: Version 1.18.2 -- Initial version of phono3py loader (`phono3py.load`) was - implemented. See docstring of `phono3py.load`. +- Initial version of phono3py loader (`phono3py.load`) was implemented. See + docstring of `phono3py.load`. ## Oct-17-2019: Version 1.18.1 @@ -80,59 +90,51 @@ or phon3py loader. ## Apr-18-2019: Version 1.17.0 -- `--cfz` option was made to subtract residual forces. See - {ref}`cfz_option`. -- `--cutoff-pair` was made to override the cutoff pair distance - written in `disp_fc3.yaml` when using on calculating force - constants. This is useful when checking cutoff distance - dependency. So the use case of having fully computed `FORCES_FC3` - is assumed. -- TURBOMOLE interface is provided by Antti Karttunen - (`--turbomole`). -- Compatibility of `fc2.hdf5` and `force_constants.hdf5` was - improved for all calculators to store physical unit information in - the hdf5 file. See {ref}`file_format_compatibility`. +- `--cfz` option was made to subtract residual forces. See {ref}`cfz_option`. +- `--cutoff-pair` was made to override the cutoff pair distance written in + `disp_fc3.yaml` when using on calculating force constants. This is useful when + checking cutoff distance dependency. So the use case of having fully computed + `FORCES_FC3` is assumed. +- TURBOMOLE interface is provided by Antti Karttunen (`--turbomole`). +- Compatibility of `fc2.hdf5` and `force_constants.hdf5` was improved for all + calculators to store physical unit information in the hdf5 file. See + {ref}`file_format_compatibility`. ## Mar-24-2019: Version 1.16.0 - Bug fixes and catching up the updates of phonopy. -- Most of hdf5 output files are compressed by `gzip` as - default. This compression can be set off, see - {ref}`hdf5_compression_option`. -- (Experimental) `phono3py` command accepts `phono3py.yaml` type - file as an input crystal structure by `-c` option. When `DIM` - and any structure file are not given, `phono3py_disp.yaml` - (primary) or `phono3py.yaml` (secondary) is searched in the current - directory. Then `phono3py.yaml` type file is used as the input. - By this, semi-automatic phono3py mode is invocked, which acts as +- Most of hdf5 output files are compressed by `gzip` as default. This + compression can be set off, see {ref}`hdf5_compression_option`. +- (Experimental) `phono3py` command accepts `phono3py.yaml` type file as an + input crystal structure by `-c` option. When `DIM` and any structure file are + not given, `phono3py_disp.yaml` (primary) or `phono3py.yaml` (secondary) is + searched in the current directory. Then `phono3py.yaml` type file is used as + the input. By this, semi-automatic phono3py mode is invocked, which acts as - 1. `supercell_matrix` corresponding to `DIM` in the - `phono3py.yaml` type file is used if it exists. - 2. `phonon_supercell_matrix` corresponding to `DIM_FC2` in the - `phono3py.yaml` type file is used if it exists. - 3. `primitive_matrix` in the `phono3py.yaml` type file - is used if it exists. Otherwise, set `PRIMITIVE_AXES = AUTO` - when `PRIMITIVE_AXES` is not given. - 4. NAC params are read (`NAC = .TRUE.`) if NAC params are - contained (primary) in the `phono3py.yaml` type file or if - `BORN` file exists in the current directory (secondary). + 1. `supercell_matrix` corresponding to `DIM` in the `phono3py.yaml` type file + is used if it exists. + 2. `phonon_supercell_matrix` corresponding to `DIM_FC2` in the `phono3py.yaml` + type file is used if it exists. + 3. `primitive_matrix` in the `phono3py.yaml` type file is used if it exists. + Otherwise, set `PRIMITIVE_AXES = AUTO` when `PRIMITIVE_AXES` is not given. + 4. NAC params are read (`NAC = .TRUE.`) if NAC params are contained (primary) + in the `phono3py.yaml` type file or if `BORN` file exists in the current + directory (secondary). ## Nov-22-2018: version 1.14.3 - Update to work with phonopy v1.14.2. -- Ph-ph interaction can be read (`--read-pp`) and write - (`--write-pp`) in RTA thermal conductivity calculation, too. Mind - that the data stored are different with and without - `--full-pp`. Wihtout `--full-pp` the data are stored in - complicated way to save data side, so it is not considered readable - by usual users. +- Ph-ph interaction can be read (`--read-pp`) and write (`--write-pp`) in RTA + thermal conductivity calculation, too. Mind that the data stored are different + with and without `--full-pp`. Wihtout `--full-pp` the data are stored in + complicated way to save data side, so it is not considered readable by usual + users. ## June-20-2018: version 1.13.3 -- `--lw` (linewidth) option was removed. Use `--br` option and - find 2*gamma values as linewidths in `kappa-xxx.hdf5` file. -- Documentation of `--lbte` option is available at - {ref}`direct_solution`. +- `--lw` (linewidth) option was removed. Use `--br` option and find 2\*gamma + values as linewidths in `kappa-xxx.hdf5` file. +- Documentation of `--lbte` option is available at {ref}`direct_solution`. - This version is dependent on phonopy>=1.13.2. ## May-17-2018: version 1.13.1 @@ -141,58 +143,50 @@ or phon3py loader. ## Mar-16-2018: version 1.12.9 -- Definition of `mode_kappa` values in output hdf5 file is - changed. Previously they were divided by number of grid points, but - now not. Therefore users who compute `kappa` from `mode_kappa` - need to be careful about this change. This does not affect to - `phono3py-kaccum` results. +- Definition of `mode_kappa` values in output hdf5 file is changed. Previously + they were divided by number of grid points, but now not. Therefore users who + compute `kappa` from `mode_kappa` need to be careful about this change. This + does not affect to `phono3py-kaccum` results. ## Feb-1-2018: version 1.12.7 -- `--tsym` option is removed. Now with `--sym-fc3r` and - `--sym-fc2` options, +- `--tsym` option is removed. Now with `--sym-fc3r` and `--sym-fc2` options, translational invariance symmetry is also applied. -- `--sym-fc` option is added. This is just an alias to specify both - `--sym-fc3r` and `--sym-fc2` together. -- Documentation on `--write-phonon` and `--read-phonon` options is - written. These options are used to save harmonic phonon infromation - on strage. +- `--sym-fc` option is added. This is just an alias to specify both `--sym-fc3r` + and `--sym-fc2` together. +- Documentation on `--write-phonon` and `--read-phonon` options is written. + These options are used to save harmonic phonon infromation on strage. ## Nov-22-2017: version 1.12.5 -- Bug fix of RTA thermal conductivity. This bug exists from version - 1.10.11.18 (git e40cd059). This bug exhibits when all the following - conditions are met: +- Bug fix of RTA thermal conductivity. This bug exists from version 1.10.11.18 + (git e40cd059). This bug exhibits when all the following conditions are met: 1. RTA thermal conductivity calculation. 2. Tetrahedron method for Brillouin zone integration is used. 3. Number of triplets is smaller than number of bands at each grid point. 4. Without using `--full-pp`. + (3) happens when the primitive cell is relatively large. Number of triplets + can be shown using `--stp` option. A race condition of OpenMP multithreading + is the source of the bug. Therefore, if it occurs, the same calculation comes + up with the different thermal conductivity value in every run time, for whcih + it behaves like randomly. - (3) happens when the primitive cell is relatively large. Number of - triplets can be shown using `--stp` option. A race condition of - OpenMP multithreading is the source of the bug. Therefore, if it - occurs, the same calculation comes up with the different thermal - conductivity value in every run time, for whcih it behaves like - randomly. - -- RTA thermal conductivity with smearing method (`--sigma`) is made - to run with smaller memory consumption as similar as tetrahedron - method (`--thm`). +- RTA thermal conductivity with smearing method (`--sigma`) is made to run with + smaller memory consumption as similar as tetrahedron method (`--thm`). ## Nov-17-2017: version 1.12.3 -- Command option parser of the phonopy tools is replaced from - `optparse` to `argparse`. +- Command option parser of the phonopy tools is replaced from `optparse` to + `argparse`. - The filenames used with these options were the positional arguments - previously. Now they are the command-line arguments, i.e., filenames - have to be put just after the option name like `-f vasprun.xml-001 - vasprun.xml-002 ...`. -- The names of auxiliary tools (`kdeplot` and `kaccum`) are - changed, for which the prefix phono3py- is added to the old names to - avoid accidental conflict with other script names already existing - under bin directory. + previously. Now they are the command-line arguments, i.e., filenames have to + be put just after the option name like + `-f vasprun.xml-001 vasprun.xml-002 ...`. +- The names of auxiliary tools (`kdeplot` and `kaccum`) are changed, for which + the prefix phono3py- is added to the old names to avoid accidental conflict + with other script names already existing under bin directory. - {ref}`sigma_cutoff_option` option was created. ## Jun-18-2017: version 1.11.13 @@ -204,12 +198,11 @@ or phon3py loader. ## Mar-31-2017: version 1.11.11 - Abinit code interface is implemented and now under the testing. -- Reduction of memory usage in RTA thermal conductivity - calculation. This is especially effective for larger unit cell - case. Currently combinations with --full_pp, --write_gamma_detail, - and --simga(smearing method) are not supported for this. Performance - tuning is under going. In some case, computation can be slower than - the previous versions. +- Reduction of memory usage in RTA thermal conductivity calculation. This is + especially effective for larger unit cell case. Currently combinations with + --full_pp, --write_gamma_detail, and --simga(smearing method) are not + supported for this. Performance tuning is under going. In some case, + computation can be slower than the previous versions. ## Feb-9-2017: version 1.11.9 @@ -218,8 +211,8 @@ or phon3py loader. ## Dec-14-2016: version 1.11.7 -- This is a maintenance release. This version must be used with - phonopy-1.11.6 or later. +- This is a maintenance release. This version must be used with phonopy-1.11.6 + or later. ## Nov-27-2016: version 1.11.5 @@ -233,45 +226,42 @@ or phon3py loader. ## Apr-16-2016: version 1.10.7 -- API example is prepared and it is found in `Si` example. No - doucment yet. +- API example is prepared and it is found in `Si` example. No doucment yet. - Si pwscf example was placed in `example-phono3py` directory. - User interface bug fix. ## Mar-15-2016: version 1.10.5 -- Numbering way of phono3py version was just changed (No big updates - were made against previous version.) The number is given based on - the phonopy version. For example, the harmonic part of - phono3py-1.10.5 is based on the code close to phonopy-1.10.4. +- Numbering way of phono3py version was just changed (No big updates were made + against previous version.) The number is given based on the phonopy version. + For example, the harmonic part of phono3py-1.10.5 is based on the code close + to phonopy-1.10.4. - Python3 support -- For the RTA thermal conductivity calculation mode with using the - linear tetrahedron method, only necessary part of phonon-phonon - interaction strengh among phonons. This improves lifetime - calculation performance, but as the drawback, averaged ph-ph - interaction strength can not be given. See {ref}`full_pp_option`. +- For the RTA thermal conductivity calculation mode with using the linear + tetrahedron method, only necessary part of phonon-phonon interaction strengh + among phonons. This improves lifetime calculation performance, but as the + drawback, averaged ph-ph interaction strength can not be given. See + {ref}`full_pp_option`. - Pwscf interface ({ref}`calculator_interfaces`) ## Oct-10-2015: version 0.9.14 -- Computational performance tuning for phonon-phonon interaction - strength calculation was made by Jonathan Skelton. Depending on - systems, but 10-20% performance improvement may be possible. -- `--stp` option is created to show numbers of q-point triplets to - be calculated. See {ref}`command_options`. -- `--write_gamma` and `--read_gamma` support using with `--bi` - option. Therefore a thermal conductivity calculation can be - distributed over band index, too. This may be useful for the system - whose unit cell is large. +- Computational performance tuning for phonon-phonon interaction strength + calculation was made by Jonathan Skelton. Depending on systems, but 10-20% + performance improvement may be possible. +- `--stp` option is created to show numbers of q-point triplets to be + calculated. See {ref}`command_options`. +- `--write_gamma` and `--read_gamma` support using with `--bi` option. Therefore + a thermal conductivity calculation can be distributed over band index, too. + This may be useful for the system whose unit cell is large. ## Sep-26-2015: version 0.9.13 -- Changed so that `--wgp` option writes `grid_address-mxxx.hdf5` - instead of `grid_address-mxxx.dat`. +- Changed so that `--wgp` option writes `grid_address-mxxx.hdf5` instead of + `grid_address-mxxx.dat`. - `--write_detailed_gamma` is implemented. See {ref}`command_options`. -- When running without setting `--thm` and `--sigma` options, - linear tetrahedron method corresponding to `--thm` is used as the - default behavior. +- When running without setting `--thm` and `--sigma` options, linear tetrahedron + method corresponding to `--thm` is used as the default behavior. - `--ise` options is created. ## Aug-12-2015: version 0.9.12 @@ -285,47 +275,44 @@ or phon3py loader. ## Jun-17-2015: version 0.9.10 -- Fix bug in `kaccum`. When using with `--pa` option, irreducible - q-points were incorrectly indexed. -- `gaccum` is implemented. `gaccum` is very similar to `kaccum`, - but for $\Gamma_\lambda(\omega_\lambda)$. +- Fix bug in `kaccum`. When using with `--pa` option, irreducible q-points were + incorrectly indexed. +- `gaccum` is implemented. `gaccum` is very similar to `kaccum`, but for + $\Gamma_\lambda(\omega_\lambda)$. - spglib update. ## Changes in version 0.9.7 -- The definition of MSPP is modified so as to be averaged ph-ph - interaction defined as $P_{\mathbf{q}j}$ in the arXiv - manuscript. The key in the kappa hdf5 file is changed from `mspp` - to `ave_pp`. The physical unit of $P_{\mathbf{q}j}$ is set - to $\text{eV}^2$. +- The definition of MSPP is modified so as to be averaged ph-ph interaction + defined as $P_{\mathbf{q}j}$ in the arXiv manuscript. The key in the kappa + hdf5 file is changed from `mspp` to `ave_pp`. The physical unit of + $P_{\mathbf{q}j}$ is set to $\text{eV}^2$. ## Changes in version 0.9.6 - Silicon example is put in `example-phono3py` directory. -- Accumulated lattice thermal conductivity is calculated by `kaccum` - script. +- Accumulated lattice thermal conductivity is calculated by `kaccum` script. - JDOS output format was changed. ## Changes in version 0.9.5 -- In `kappa-xxx.hdf5` file, `heat_capacity` format was changed - from `(irreducible q-point, temperature, phonon band)` to - `(temperature, irreducible q-point, phonon band)`. For `gamma`, - previous document was wrong in the array shape. It is +- In `kappa-xxx.hdf5` file, `heat_capacity` format was changed from + `(irreducible q-point, temperature, phonon band)` to + `(temperature, irreducible q-point, phonon band)`. For `gamma`, previous + document was wrong in the array shape. It is `(temperature, irreducible q-point, phonon band)` - ## Changes in version 0.9.4 -- The option of `--cutoff_mfp` is renamed to `--boundary_mfp` and - now it's on the document. -- Detailed contribution of `kappa` at each **q**-point and phonon - mode is output to .hdf5 with the keyword `mode_kappa`. +- The option of `--cutoff_mfp` is renamed to `--boundary_mfp` and now it's on + the document. +- Detailed contribution of `kappa` at each **q**-point and phonon mode is output + to .hdf5 with the keyword `mode_kappa`. ## Changes in version 0.8.11 -- A new option of `--cutoff_mfp` for including effective boundary - mean free path. +- A new option of `--cutoff_mfp` for including effective boundary mean free + path. - The option name `--cutfc3` is changed to `--cutoff_fc3`. - The option name `--cutpair` is changed to `--cutoff_pair`. - A new option `--ga` is created. @@ -333,77 +320,68 @@ or phon3py loader. ## Changes in version 0.8.10 -- Different supercell size of fc2 from fc3 can be specified using - `--dim_fc2` option. -- `--isotope` option is implemented. This is used instead of - `--mass_variances` option without specifying the values. Mass - variance parameters are read from database. +- Different supercell size of fc2 from fc3 can be specified using `--dim_fc2` + option. +- `--isotope` option is implemented. This is used instead of `--mass_variances` + option without specifying the values. Mass variance parameters are read from + database. ## Changes in version 0.8.2 -- Phono3py python interface is rewritten and a lot of changes are - introduced. -- `FORCES_SECOND` and `FORCES_THIRD` are no more used. Instead just - one file of `FORCES_FC3` is used. Now `FORCES_FC3` is generated - by `--cf3` option and the backward compatibility is simple: `cat - FORCES_SECOND FORCES_THIRD > FORCES_FC3`. -- `--multiple_sigmas` is removed. The same behavior is achieved by - `--sigma`. +- Phono3py python interface is rewritten and a lot of changes are introduced. +- `FORCES_SECOND` and `FORCES_THIRD` are no more used. Instead just one file of + `FORCES_FC3` is used. Now `FORCES_FC3` is generated by `--cf3` option and the + backward compatibility is simple: + `cat FORCES_SECOND FORCES_THIRD > FORCES_FC3`. +- `--multiple_sigmas` is removed. The same behavior is achieved by `--sigma`. ## Changes in version 0.8.0 - `--q_direction` didn't work. Fix it. -- Implementation of tetrahedron method whcih is activated by - `--thm`. +- Implementation of tetrahedron method whcih is activated by `--thm`. - Grid addresses are written out by `--wgp` option. ## Changes in version 0.7.6 -- Cut-off distance for fc3 is implemented. This is activated by - `--cutfc3` option. FC3 elements where any atomic pair has larger - distance than cut-off distance are set zero. -- `--cutpair` works only when creating displacements. The cut-off - pair distance is written into `disp_fc3.yaml` and FC3 is created - from `FORCES_THIRD` with this information. Usually sets of pair - displacements are more redundant than that needed for creating fc3 - if index permutation symmetry is considered. Therefore using index - permutation symmetry, some elements of fc3 can be recovered even if - some of supercell force calculations are missing. In paticular, all - pair distances among triplet atoms are larger than cutoff pair - distance, any fc3 elements are not recovered, i.e., the element will - be zero. +- Cut-off distance for fc3 is implemented. This is activated by `--cutfc3` + option. FC3 elements where any atomic pair has larger distance than cut-off + distance are set zero. +- `--cutpair` works only when creating displacements. The cut-off pair distance + is written into `disp_fc3.yaml` and FC3 is created from `FORCES_THIRD` with + this information. Usually sets of pair displacements are more redundant than + that needed for creating fc3 if index permutation symmetry is considered. + Therefore using index permutation symmetry, some elements of fc3 can be + recovered even if some of supercell force calculations are missing. In + paticular, all pair distances among triplet atoms are larger than cutoff pair + distance, any fc3 elements are not recovered, i.e., the element will be zero. ## Changes in version 0.7.2 - Default displacement distance is changed to 0.03. - Files names of displacement supercells now have 5 digits numbering, `POSCAR-xxxxx`. -- Cutoff distance between pair displacements is implemented. This is - triggered by `--cutpair` option. This option works only for - calculating atomic forces in supercells with configurations of pairs - of displacements. +- Cutoff distance between pair displacements is implemented. This is triggered + by `--cutpair` option. This option works only for calculating atomic forces in + supercells with configurations of pairs of displacements. ## Changes in version 0.7.1 -- It is changed to sampling q-points in Brillouin zone. Previously - q-points are sampled in reciprocal primitive lattice. Usually this - change affects very little to the result. -- q-points of phonon triplets are more carefully sampled when a - q-point is on Brillouin zone boundary. Usually this - change affects very little to the result. +- It is changed to sampling q-points in Brillouin zone. Previously q-points are + sampled in reciprocal primitive lattice. Usually this change affects very + little to the result. +- q-points of phonon triplets are more carefully sampled when a q-point is on + Brillouin zone boundary. Usually this change affects very little to the + result. - Isotope effect to thermal conductivity is included. ## Changes in version 0.6.0 -- `disp.yaml` is renamed to `disp_fc3.yaml`. Old calculations with - `disp.yaml` can be used without any problem just by changing the - file name. -- Group velocity is calculated from analytical derivative of dynamical - matrix. -- Group velocities at degenerate phonon modes are better handled. - This improves the accuracy of group velocity and thus for thermal - conductivity. -- Re-implementation of third-order force constants calculation from - supercell forces, which makes the calculation much faster -- When any phonon of triplets can be on the Brillouin zone boundary, i.e., - when a mesh number is an even number, it is more carefully treated. +- `disp.yaml` is renamed to `disp_fc3.yaml`. Old calculations with `disp.yaml` + can be used without any problem just by changing the file name. +- Group velocity is calculated from analytical derivative of dynamical matrix. +- Group velocities at degenerate phonon modes are better handled. This improves + the accuracy of group velocity and thus for thermal conductivity. +- Re-implementation of third-order force constants calculation from supercell + forces, which makes the calculation much faster +- When any phonon of triplets can be on the Brillouin zone boundary, i.e., when + a mesh number is an even number, it is more carefully treated. diff --git a/doc/conf.py b/doc/conf.py index c6f75408..4d23c1f7 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -49,9 +49,9 @@ copyright = u"2015, Atsushi Togo" # built documents. # # The short X.Y version. -version = "2.0" +version = "2.1" # The full version, including alpha/beta/rc tags. -release = "2.0.0" +release = "2.1.0" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/direct-solution.md b/doc/direct-solution.md index 5e9537e2..ee97fe33 100644 --- a/doc/direct-solution.md +++ b/doc/direct-solution.md @@ -1,8 +1,10 @@ (direct_solution)= + # Direct solution of linearized phonon Boltzmann equation This page explains how to use the direct solution of LBTE by -[L. Chaput, Phys. Rev. Lett. 110, 265506 (2013)](https://doi.org/10.1103/PhysRevLett.110.265506) ({ref}`citation `). +[L. Chaput, Phys. Rev. Lett. 110, 265506 (2013)](https://doi.org/10.1103/PhysRevLett.110.265506) +({ref}`citation `). ```{contents} :depth: 2 @@ -11,44 +13,40 @@ This page explains how to use the direct solution of LBTE by ## How to use -As written in the following sections, this calculation requires large -memory space. When running multiple temperature points, simply the -memory space needed is multiplied by the number of the temperature -points. Therefore it is normally recommended to specify {ref}`--ts -option `. An example to run with the direct solution of -LBTE for `example/Si-PBEsol` is as follows: +As written in the following sections, this calculation requires large memory +space. When running multiple temperature points, simply the memory space needed +is multiplied by the number of the temperature points. Therefore it is normally +recommended to specify {ref}`--ts option `. An example to run with +the direct solution of LBTE for `example/Si-PBEsol` is as follows: ```bash -% phono3py --dim="2 2 2" --sym-fc -c POSCAR-unitcell -... - -% phono3py --dim="2 2 2" --pa="F" -c POSCAR-unitcell --mesh="11 11 11" --fc3 --fc2 --lbte --ts=300 +% phono3py-load --mesh 11 11 11 --lbte --ts 300 ... =================== End of collection of collisions =================== -- Averaging collision matrix elements by phonon degeneracy [0.031s] -- Making collision matrix symmetric (built-in) [0.000s] +- Averaging collision matrix elements by phonon degeneracy [0.036s] +- Making collision matrix symmetric (built-in) [0.001s] ----------- Thermal conductivity (W/m-k) with tetrahedron method ----------- -Diagonalizing by lapacke dsyev... [0.111s] +Diagonalizing by lapacke dsyev... [0.141s] Calculating pseudo-inv with cutoff=1.0e-08 (np.dot) [0.001s] # T(K) xx yy zz yz xz xy - 300.0 111.588 111.588 111.588 0.000 0.000 -0.000 - (RTA) 109.009 109.009 109.009 0.000 0.000 -0.000 + 300.0 113.140 113.140 113.140 0.000 0.000 -0.000 + (RTA) 108.982 108.982 108.982 0.000 0.000 -0.000 ---------------------------------------------------------------------------- Thermal conductivity and related properties were written into "kappa-m111111.hdf5". Eigenvalues of collision matrix were written into "coleigs-m111111.hdf5" - ... ``` ## Memory usage -The direct solution of LBTE needs diagonalization of a large collision -matrix, which requires large memory space. This is the largest -limitation of using this method. The memory size needed for one -collision matrix at a temperature point is $(\text{number of +The direct solution of LBTE needs diagonalization of a large collision matrix, +which requires large memory space. This is the largest limitation of using this +method. The memory size needed for one collision matrix at a temperature point +is +$(\text{number of irreducible grid points} \times \text{number of bands} \times 3)^2$ for the symmetrized collision matrix. @@ -58,17 +56,16 @@ for the symmetrized collision matrix. collision matrix. ---> -These collision matrices contain real values and are supposed to be -64bit float symmetric matrices. During the diagonalization of each -collision matrix with LAPACK `dsyev` solver, around 1.2 times more -memory space is consumed in total. +These collision matrices contain real values and are supposed to be 64bit float +symmetric matrices. During the diagonalization of each collision matrix with +LAPACK `dsyev` solver, around 1.2 times more memory space is consumed in total. -When phono3py runs with {ref}`--wgp option ` together with -`--lbte` option, estimated memory space needed for storing collision -matrix is presented. An example for `example/Si-PBEsol` is as follows: +When phono3py runs with {ref}`--wgp option ` together with `--lbte` +option, estimated memory space needed for storing collision matrix is presented. +An example for `example/Si-PBEsol` is as follows: -``` -% phono3py --dim="2 2 2" --pa="F" -c POSCAR-unitcell --mesh="40 40 40" --wgp --lbte +```bash +% phono3py-load --mesh 40 40 40 --lbte --wgp ... Memory requirements: @@ -81,170 +78,166 @@ Memory requirements: ... ``` -With {ref}`--stp option `, estimated -memory space needed for ph-ph interaction strengths is shown. +With {ref}`--stp option `, estimated memory space needed for ph-ph +interaction strengths is shown such as +```bash +% phono3py-load --mesh 40 40 40 --lbte --stp +``` ## Work load distribution -The other difficulty compared with RTA is the workload -distribution. Currently there are two ways to distribute the -calculation: (1) Collision matrix is divided and the pieces are -distributed into computing nodes. (2) Ph-ph interaction strengths at -grid points are distributed into computing nodes. These two can not be -mixed, so one of them has to be chosen. In either case, the -distribution is done simply running a set of phono3py calculations -over grid points and optionally band indices. The data computed on -each computing node are stored in an hdf5 file. Increasing the -calculation size, e.g., larger mesh numbers or larger number of atoms -in the primitive cell, large files are created. +The other difficulty compared with RTA is the workload distribution. Currently +there are two ways to distribute the calculation: (1) Collision matrix is +divided and the pieces are distributed into computing nodes. (2) Ph-ph +interaction strengths at grid points are distributed into computing nodes. These +two can not be mixed, so one of them has to be chosen. In either case, the +distribution is done simply running a set of phono3py calculations over grid +points and optionally band indices. The data computed on each computing node are +stored in an hdf5 file. Increasing the calculation size, e.g., larger mesh +numbers or larger number of atoms in the primitive cell, large files are +created. (distribution_colmat)= + ### Distribution of collision matrix -A full collision matrix is divided into pieces at grid points of -irreducible part of Brillouin zone. Each piece is calculated -independently from the other pieces. After finishing the calculations -of these pieces, the full collision matrix is diagonzalized to obtain -the thermal conductivity. +A full collision matrix is divided into pieces at grid points of irreducible +part of Brillouin zone. Each piece is calculated independently from the other +pieces. After finishing the calculations of these pieces, the full collision +matrix is diagonzalized to obtain the thermal conductivity. -File size of Each piece of the collision matrix can be -large. Therefore it is recommended to use {ref}`--ts option -` to limit the number of temperature points, e.g., -`--ts="100 200 300 400 500`, depending on the memory size installed -on each computing node. To write them into files, -`--write-collision` option must be specified, and to read them from -files, `--read-collision` option is used. These are similarly used -as {ref}`--write-gamma ` and {ref}`--read-gamma ` options for RTA calculation as shown in -{ref}`workload_distribution`. -`--read-collision` option collects the pieces and make one full -collision matrix, then starts to diagonalize it. This option requires -one argument to specify an index to read the collision matrix at one +File size of Each piece of the collision matrix can be large. Therefore it is +recommended to use {ref}`--ts option ` to limit the number of +temperature points, e.g., `--ts "100 200 300 400 500"`, depending on the memory +size installed on each computing node. To write them into files, +`--write-collision` option must be specified, and to read them from files, +`--read-collision` option is used. These are similarly used as +{ref}`--write-gamma ` and +{ref}`--read-gamma ` options for RTA calculation as shown in +{ref}`workload_distribution`. `--read-collision` option collects the pieces and +make one full collision matrix, then starts to diagonalize it. This option +requires one argument to specify an index to read the collision matrix at one temperature point, e.g., the collision matrix at 200K is read with -`--read-collision=1` for the (pieces of) collision matrices created -with `--ts="100 200 300 400 500"` (corresponding to 0, 1, 2, 3, -4). The temperature (e.g. 200K) is also read from the file, so it is -unnecessary to specify {ref}`--ts option ` when reading. +`--read-collision 1` for the (pieces of) collision matrices created with +`--ts "100 200 300 400 500"` (corresponding to 0, 1, 2, 3, 4). The temperature +(e.g. 200K) is also read from the file, so it is unnecessary to specify +{ref}`--ts option ` when reading. The summary of the procedure is as follows: 1. Running at each grid point with {ref}`--gp ` (or - {ref}`--ga `) option and - saving the piece of the collision matrix to an hdf5 file with - `--write-collision` option. It is probably OK to calculate and - store the pieces of the collision matrices at multiple temperatures - though it depends on memory size of the computer node. This + {ref}`--ga `) option and saving the piece of the collision matrix + to an hdf5 file with `--write-collision` option. It is probably OK to + calculate and store the pieces of the collision matrices at multiple + temperatures though it depends on memory size of the computer node. This calculation has to be done at all irreducible grid points. -2. Collecting and creating all necessary pieces of the collision - matrix with `--read-collision=num` (`num`: index of - temperature). By this one full collision matrix at the selected - temperature is created and then diagonalized. An option `-o num` - may be used together with `--read-collision` to distinguish the - file names of the results at different temperatures. +2. Collecting and creating all necessary pieces of the collision matrix with + `--read-collision=num` (`num`: index of temperature). By this one full + collision matrix at the selected temperature is created and then + diagonalized. An option `-o num` may be used together with `--read-collision` + to distinguish the file names of the results at different temperatures. -Examples of command options are shown below using `Si-PBE` example. -Irreducible grid point indices are obtained by {ref}`--wgp option`: +Examples of command options are shown below using `Si-PBE` example. Irreducible +grid point indices are obtained by {ref}`--wgp option`: ```bash -% phono3py --dim="2 2 2" --pa="F" -c POSCAR-unitcell --mesh="19 19 19" --lbte --wgp +% phono3py-load --mesh 19 19 19 --lbte --wgp ``` -and the information is given in `ir_grid_points.yaml`. For -distribution of collision matrix calculation -(see also {ref}`workload_distribution`): +and the information is given in `ir_grid_points.yaml`. For distribution of +collision matrix calculation (see also {ref}`workload_distribution`): -``` -% phono3py --dim="2 2 2" --pa="F" -c POSCAR-unitcell --mesh="19 19 19" --fc3 --fc2 --lbte --ts=300 --write-collision --gp="grid_point_numbers..." +```bash +% phono3py-load --mesh 19 19 19 --lbte --ts 300 --write-collision --gp="grid_point_numbers..." ``` To collect distributed pieces of the collision matrix: ```bash -% phono3py --dim="2 2 2" --pa="F" -c POSCAR-unitcell --mesh="19 19 19" --fc3 --fc2 --lbte --ts=300 --read-collision=0 +% phono3py-load --mesh 19 19 19 --lbte --read-collision 0 ``` +where `--read-collision 0` indicates to read the first result in the list of +temperatures by `--ts` option, i.e., 300K in this case. + ### Distribution of phonon-phonon interaction strengths -The distribution of pieces of collision matrix is straightforward and -is recommended to use if the number of temperature points is -small. However increasing data file size, network communication -becomes to require long time to send the files from a master node to -computation nodes. In this case, the distribution over ph-ph -interaction strengths can be another choice. Since, without using -{ref}`--full-pp option `, the tetrahedron method or -smearing approach with {ref}`--sigma-cutoff option ` -results in the sparse ph-ph interaction -strength data array, i.e., most of the elements are zero, the data -size can be reduced by only storing non-zero elements. Not like the -collision matrix, the ph-ph interaction strengths in phono3py are -independent from temperature though it is not the case if the force -constants provided are temperature dependent. Once -stored, they are used to create the collision matrices at -temperatures. Using `--write-pp` and `--read-pp`, they are written -into and read from hdf5 files at grid points. +The distribution of pieces of collision matrix is straightforward and is +recommended to use if the number of temperature points is small. However +increasing data file size, network communication becomes to require long time to +send the files from a master node to computation nodes. In this case, the +distribution over ph-ph interaction strengths can be another choice. Since, +without using {ref}`--full-pp option `, the tetrahedron method +or smearing approach with {ref}`--sigma-cutoff option ` +results in the sparse ph-ph interaction strength data array, i.e., most of the +elements are zero, the data size can be reduced by only storing non-zero +elements. Not like the collision matrix, the ph-ph interaction strengths in +phono3py are independent from temperature though it is not the case if the force +constants provided are temperature dependent. Once stored, they are used to +create the collision matrices at temperatures. Using `--write-pp` and +`--read-pp`, they are written into and read from hdf5 files at grid points. -It is also recommended to use {ref}`--write-phonon option ` and {ref}`--read-phonon option ` to use identical phonon eigenvectors among the -distributed nodes. +It is also recommended to use {ref}`--write-phonon option ` +and {ref}`--read-phonon option ` to use identical phonon +eigenvectors among the distributed nodes. The summary of the procedure is as follows: 1. Running at each grid point with {ref}`--gp ` (or - {ref}`--ga `) option and storing the ph-ph interaction - strengths to an hdf5 file with `--write-pp` option. This calculation - has to be done at all irreducible grid points. + {ref}`--ga `) option and storing the ph-ph interaction strengths + to an hdf5 file with `--write-pp` option. This calculation has to be done at + all irreducible grid points. 2. Running with `--read-pp` option and without {ref}`--gp ` (or {ref}`--ga `) option. By this one full collision matrix at the - selected temperature is created and then diagonalized. An option - `-o num` may be used together with `--read-collision` to - distinguish the file names of the results at different - temperatures. + selected temperature is created and then diagonalized. An option `-o num` may + be used together with `--read-collision` to distinguish the file names of the + results at different temperatures. -Examples of command options are shown below using `Si-PBE` example. -Irreducible grid point indices are obtained by {ref}`--wgp option` +Examples of command options are shown below using `Si-PBE` example. Irreducible +grid point indices are obtained by {ref}`--wgp option` ```bash -% phono3py --dim="2 2 2" --pa="F" -c POSCAR-unitcell --mesh="19 19 19" --lbte --wgp +% phono3py-load --mesh "19 19 19" --lbte --wgp ``` -and the grid point information is provided in -`ir_grid_points.yaml`. All phonons on mesh grid points are saved -by +and the grid point information is provided in `ir_grid_points.yaml`. All phonons +on mesh grid points are saved by ```bash - % phono3py --dim="2 2 2" --pa="F" -c POSCAR-unitcell --mesh="19 19 19" --fc2 --write-phonon +% phono3py-load --mesh "19 19 19" --write-phonon ``` For distribution of ph-ph interaction strength calculation (see also {ref}`workload_distribution`) ```bash -% phono3py --dim="2 2 2" --pa="F" -c POSCAR-unitcell --mesh="19 19 19" --fc3 --fc2 --lbte --ts=300 --write-pp --gp="grid_point_numbers..." --read-phonon +% phono3py-load --mesh "19 19 19" --lbte --ts 300 --write-pp --gp "grid_point_numbers..." --read-phonon ``` -Here one temperature has to be specified but any one of temperatures -is OK since ph-ph interaction strength computed here is assumed to be -temperature independent. Then the computed ph-ph interaction strengths -are read and used to compute collision matrix and lattice thermal -conductivity at a temperature by +Here one temperature has to be specified but any one of temperatures is OK since +ph-ph interaction strength computed here is assumed to be temperature +independent. Then the computed ph-ph interaction strengths are read and used to +compute collision matrix and lattice thermal conductivity at a temperature by ```bash -% phono3py --dim="2 2 2" --pa="F" -c POSCAR-unitcell --mesh="19 19 19" --fc3 --fc2 --lbte --ts=300 --read-pp --read-phonon +% phono3py-load --mesh "19 19 19" --lbte --ts 300 --read-pp --read-phonon ``` -This last command is repeated at different temperatures to obtain the -properties at multiple temperatures. +This last command is repeated at different temperatures to obtain the properties +at multiple temperatures. (diagonzalization_solver)= + ## Cutoff parameter of pseudo inversion -To achieve a pseudo inversion, a cutoff parameter is used to find null -space, i.e., to select the nearly zero eigenvalues. The default cutoff -value is `1e-8`, and this hopefully works in many cases. But if a -collision matrix is numerically not very accurate, we may have to -carefully choose the value by `--pinv-cutoff` option. It is safer to -plot the absolute values of eigenvalues in log scale to see if there -is clear gap between non-zero eigenvalue and nearly-zero eigenvalues. -After running the direct solution of LBTE, `coleigs-mxxx.hdf5` is +To achieve a pseudo inversion, a cutoff parameter is used to find null space, +i.e., to select the nearly zero eigenvalues. The default cutoff value is `1e-8`, +and this hopefully works in many cases. But if a collision matrix is numerically +not very accurate, we may have to carefully choose the value by `--pinv-cutoff` +option. It is safer to plot the absolute values of eigenvalues in log scale to +see if there is clear gap between non-zero eigenvalue and nearly-zero +eigenvalues. After running the direct solution of LBTE, `coleigs-mxxx.hdf5` is created. This contains the eigenvalues of the collision matrix (either symmetrized or non-symmetrized). The eigenvalues are plotted using `phono3py-coleigplot` in the phono3py package: @@ -253,8 +246,8 @@ symmetrized or non-symmetrized). The eigenvalues are plotted using % phono3py-coleigplot coleigs-mxxx.hdf5 ``` -It is assumed that only one set of eigenvalues at a temperature point -is contained. +It is assumed that only one set of eigenvalues at a temperature point is +contained. ```{figure} Si-coleigplot.png :width: 50% @@ -274,72 +267,67 @@ as null spaces. ## Installation of diagonalization solvers with multithreaded BLAS -Multithreaded BLAS is recommended to use for the calculation of the -direct solution of LBTE since the diagonalization of the collision -matrix is computationally demanding. A few examples of how to install -multithreded BLAS libraries are presented below. +Multithreaded BLAS is recommended to use for the calculation of the direct +solution of LBTE since the diagonalization of the collision matrix is +computationally demanding. A few examples of how to install multithreded BLAS +libraries are presented below. ### MKL linked scipy Scipy (also numpy) has an interface to LAPACK dsyev -(`scipy.linalg.lapack.dsyev`). An MKL LAPACK linked scipy (also -numpy) gives very good computing performance and is easily obtained -using the anaconda package manager. In this choice, usual installation -of LAPACKE is necessary for running `dgesvd` and `zheev`. When -using anaconda, installing OpenBLAS is the easiest way to do. See -{ref}`install_openblas_lapacke` +(`scipy.linalg.lapack.dsyev`). An MKL LAPACK linked scipy (also numpy) gives +very good computing performance and is easily obtained using the anaconda +package manager. In this choice, usual installation of LAPACKE is necessary for +running `dgesvd` and `zheev`. When using anaconda, installing OpenBLAS is the +easiest way to do. See {ref}`install_openblas_lapacke` ### OpenBLAS or MKL via LAPACKE -Using LAPACKE via python C-API is implemented. By this, phono3py can -use LAPACK dsyev. This uses smaller memory space than using MKL linked -scipy. Practically there are two choices, OpenBLAS and MKL. For MKL, -proper installatin of the MKL package is necessary. The MKL -library installed obtained from anaconda can not be used. +Using LAPACKE via python C-API is implemented. By this, phono3py can use LAPACK +dsyev. This uses smaller memory space than using MKL linked scipy. Practically +there are two choices, OpenBLAS and MKL. For MKL, proper installatin of the MKL +package is necessary. The MKL library installed obtained from anaconda can not +be used. #### OpenBLAS -Use of OpenBLAS is an easy choice if the anaconda package is used. -See {ref}`install_openblas_lapacke`. +Use of OpenBLAS is an easy choice if the anaconda package is used. See +{ref}`install_openblas_lapacke`. #### MKL -The BLAS multithread performance may be better in that in MKL. Using -MKL-LAPACK via MKL-LAPACKE via python C-API is also implemented if the -link is succeeded. See {ref}`install_mkl_lapacke`. +The BLAS multithread performance may be better in that in MKL. Using MKL-LAPACK +via MKL-LAPACKE via python C-API is also implemented if the link is succeeded. +See {ref}`install_mkl_lapacke`. ## Solver choice for diagonalization -For larger systems, diagonalization of collision matrix takes longest -time and requires large memory space. Phono3py relies on LAPACK for -the diagonalization and so the performance is dependent on the choice -of the diagonalization solver. +For larger systems, diagonalization of collision matrix takes longest time and +requires large memory space. Phono3py relies on LAPACK for the diagonalization +and so the performance is dependent on the choice of the diagonalization solver. -Using multithreaded BLAS with many-core computing node, computing time -may be well reduced and the calculation can finish in a realistic -time. Currently scipy, numpy and LAPACKE can be used as the LAPACK -wrapper in phono3py. Scipy and numpy distributed by anaconda are MKL -linked, therefore MKL multithread BLAS is used through -them. Multithreaded OpenBLAS is installed by conda and can be used via -LAPACKE in phono3py. MKL LAPACK and BLAS are also able to be used via +Using multithreaded BLAS with many-core computing node, computing time may be +well reduced and the calculation can finish in a realistic time. Currently +scipy, numpy and LAPACKE can be used as the LAPACK wrapper in phono3py. Scipy +and numpy distributed by anaconda are MKL linked, therefore MKL multithread BLAS +is used through them. Multithreaded OpenBLAS is installed by conda and can be +used via LAPACKE in phono3py. MKL LAPACK and BLAS are also able to be used via LAPACKE in phono3py with appropriate setting in `setup.py`. -Using `--pinv-solver=[number]`, one of the following solver is -chosen: +Using `--pinv-solver=[number]`, one of the following solver is chosen: -1. Lapacke `dsyev`: Smaller memory consumption than `dsyevd`, but - slower. This is the default solver when MKL LAPACKE is integrated or - scipy is not installed. -2. Lapacke `dsyevd`: Larger memory consumption than `dsyev`, but - faster. This is not recommended because sometimes a wrong result is - obtained. -3. Numpy's `dsyevd` (`linalg.eigh`). This is not recommended - because sometimes a wrong result is obtained. -4. Scipy's `dsyev`: This is the default solver when scipy is - installed and MKL LAPACKE is not integrated. -5. Scipy's `dsyevd`. This is not recommended because sometimes a +1. Lapacke `dsyev`: Smaller memory consumption than `dsyevd`, but slower. This + is the default solver when MKL LAPACKE is integrated or scipy is not + installed. +2. Lapacke `dsyevd`: Larger memory consumption than `dsyev`, but faster. This is + not as stable as `dsyev` but is useful for solving collision matrix with + dense mesh sampling. So this solver has to be used carefully. +3. Numpy's `dsyevd` (`linalg.eigh`). This is not recommended because sometimes a wrong result is obtained. +4. Scipy's `dsyev`: This is the default solver when scipy is installed and MKL + LAPACKE is not integrated. +5. Scipy's `dsyevd`: Similar to solver (2), this solver should be used + carefully. -The solver choices other than `--pinv-solver=1` and -`--pinv-solver=4` are dangerous and not recommend. They exist just -for the tests. +The solver choices other than `--pinv-solver=1` and `--pinv-solver=4` are +dangerous and not recommend. They exist just for the tests. diff --git a/phono3py/version.py b/phono3py/version.py index 58aa39b2..5f662c4e 100644 --- a/phono3py/version.py +++ b/phono3py/version.py @@ -33,4 +33,4 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -__version__ = "2.0.0" +__version__ = "2.1.0"