Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions phono3py/api_phono3py.py
Original file line number Diff line number Diff line change
Expand Up @@ -2248,7 +2248,7 @@ def run_thermal_conductivity(
is_kappa_star: bool = True,
gv_delta_q: float | None = None, # for group velocity
is_full_pp: bool = False,
pinv_cutoff: float = 1.0e-8, # for pseudo-inversion of collision matrix
pinv_cutoff: float | None = None, # for pseudo-inversion of collision matrix
pinv_method: int = 0, # for pseudo-inversion of collision matrix
pinv_solver: int = 0, # solver of pseudo-inversion of collision matrix
write_gamma: bool = False,
Expand Down Expand Up @@ -2320,7 +2320,7 @@ def run_thermal_conductivity(
improve of efficiency is expected.
With smearing method, even if this is set False, full elements
are computed unless `sigma_cutoff` is specified.
pinv_cutoff : float, optional, default is 1.0e-8
pinv_cutoff : float, optional, default is None (usually 1.0e-8)
Direct solution only (`is_LBTE=True`). This is used as a criterion
to judge the eigenvalues are considered as zero or not in
pseudo-inversion of collision matrix. See also `pinv_method`.
Expand Down
3 changes: 0 additions & 3 deletions phono3py/conductivity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
register_variant,
VariantBuildContext,
GridPointAggregates,
GridPointInput,
VelocityResult,
HeatCapacityResult,
ScatteringResult,
Expand All @@ -20,7 +19,6 @@
from phono3py.conductivity.factory import register_variant
from phono3py.conductivity.grid_point_data import (
GridPointAggregates,
GridPointInput,
HeatCapacityResult,
ScatteringResult,
VelocityResult,
Expand All @@ -35,7 +33,6 @@
"register_variant",
"VariantBuildContext",
"GridPointAggregates",
"GridPointInput",
"VelocityResult",
"HeatCapacityResult",
"ScatteringResult",
Expand Down
4 changes: 2 additions & 2 deletions phono3py/conductivity/build_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,10 @@ def _resolve_rta_grid_points(
return np.array(grid_points, dtype="int64"), ir_gps_bzg, gp_weights

if not is_kappa_star:
all_gps = np.array(bz_grid.grg2bzg, dtype="int64")
all_gps = bz_grid.grg2bzg
return all_gps, all_gps, np.ones(len(all_gps), dtype="int64")

return ir_gps_bzg, ir_gps_bzg, np.array(ir_weights, dtype="int64")
return ir_gps_bzg, ir_gps_bzg, ir_weights


def build_rta_base_components(
Expand Down
12 changes: 8 additions & 4 deletions phono3py/conductivity/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def _rta_factory(
cv_provider = (
make_cv_provider(ctx)
if make_cv_provider is not None
else ModeHeatCapacityProvider(interaction)
else ModeHeatCapacityProvider(interaction, base.context.temperatures)
)
accumulator = make_rta_accumulator(ctx)

Expand Down Expand Up @@ -189,7 +189,7 @@ def _lbte_factory(
cv_provider = (
make_cv_provider(ctx)
if make_cv_provider is not None
else ModeHeatCapacityProvider(interaction)
else ModeHeatCapacityProvider(interaction, base.context.temperatures)
)
accumulator = make_lbte_accumulator(ctx)

Expand Down Expand Up @@ -371,11 +371,13 @@ def _make_rta_calculator(
interaction,
point_operations=base.point_ops,
rotations_cartesian=base.rot_cart,
grid_points=base.context.grid_points,
grid_weights=base.context.grid_weights,
is_kappa_star=config.is_kappa_star,
gv_delta_q=config.gv_delta_q,
log_level=config.log_level,
)
cv_provider = ModeHeatCapacityProvider(interaction)
cv_provider = ModeHeatCapacityProvider(interaction, base.context.temperatures)
accumulator = RTAKappaAccumulator(
context=base.context,
conversion_factor=conversion_factor,
Expand Down Expand Up @@ -406,11 +408,13 @@ def _make_lbte_calculator(
interaction,
point_operations=base.point_ops,
rotations_cartesian=base.rot_cart,
grid_points=base.context.ir_grid_points,
grid_weights=base.context.grid_weights,
is_kappa_star=config.is_kappa_star,
gv_delta_q=config.gv_delta_q,
log_level=config.log_level,
)
cv_provider = ModeHeatCapacityProvider(interaction)
cv_provider = ModeHeatCapacityProvider(interaction, base.context.temperatures)
accumulator = LBTEKappaAccumulator(
base.solver, context=base.context, log_level=config.log_level
)
Expand Down
104 changes: 8 additions & 96 deletions phono3py/conductivity/grid_point_data.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Per-grid-point data containers.

This module defines GridPointInput, provider result types
(VelocityResult, HeatCapacityResult, ScatteringResult), and
GridPointAggregates used in the conductivity calculation.
This module defines provider result types (VelocityResult,
HeatCapacityResult, ScatteringResult) and GridPointAggregates used in
the conductivity calculation.

Protocol interfaces (VelocityProvider, HeatCapacityProvider,
ScatteringProvider) are defined in ``phono3py.conductivity.protocols``
Expand All @@ -17,8 +17,6 @@
import numpy as np
from numpy.typing import NDArray

from phono3py.phonon.grid import BZGrid, get_qpoints_from_bz_grid_points

# ---------------------------------------------------------------------------
# Per-grid-point data containers
# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -58,21 +56,21 @@ class VelocityResult:

@dataclass
class HeatCapacityResult:
"""Result from a heat capacity provider at a single grid point.
"""Result from a heat capacity provider (bulk computation).

Parameters
----------
heat_capacities : ndarray of double, shape (num_temp, num_band0)
Mode heat capacities (scalar Cv per mode).
heat_capacities : ndarray of double, shape (num_temp, num_gp, num_band0)
Mode heat capacities (scalar Cv per mode) for all grid points.
heat_capacity_matrix : ndarray of double, optional
Shape (num_temp, num_band0, num_band).
Shape (num_temp, num_gp, num_band0, num_band).
Only set by HeatCapacityMatrixProvider (Kubo).
extra : dict
Plugin-specific data.

"""

heat_capacities: NDArray[np.double] | None = None
heat_capacities: NDArray[np.double]
heat_capacity_matrix: NDArray[np.double] | None = None
extra: dict[str, Any] = field(default_factory=dict)

Expand All @@ -97,42 +95,6 @@ class ScatteringResult:
extra: dict[str, Any] = field(default_factory=dict)


# ---------------------------------------------------------------------------
# Grid-point input / result containers
# ---------------------------------------------------------------------------


@dataclass
class GridPointInput:
"""Phonon quantities at a single irreducible BZ grid point.

All fields are filled before being passed to building blocks.

Parameters
----------
grid_point : int
BZ grid point index.
q_point : ndarray, shape (3,)
q-point coordinates in reduced reciprocal coordinates.
frequencies : ndarray, shape (num_band,)
Phonon frequencies in THz for *all* bands at this grid point.
eigenvectors : ndarray, shape (num_band, num_band), complex
Phonon eigenvectors at this grid point.
grid_weight : int
Symmetry weight for BZ summation (number of arms of the k-star).
band_indices : ndarray of int64, shape (num_band0,)
Selected band indices. num_band0 <= num_band.

"""

grid_point: int
q_point: NDArray[np.double]
frequencies: NDArray[np.double]
eigenvectors: NDArray[np.cdouble]
grid_weight: int
band_indices: NDArray[np.int64]


# ---------------------------------------------------------------------------
# Aggregated per-grid-point data (Calculator -> Accumulator.finalize())
# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -229,54 +191,6 @@ def compute_effective_gamma(
return out


def make_grid_point_input(
grid_point: int,
grid_weight: int,
frequencies: NDArray[np.double],
eigenvectors: NDArray[np.cdouble],
bz_grid: BZGrid,
band_indices: NDArray[np.int64],
) -> GridPointInput:
"""Create a GridPointInput for a single BZ grid point.

Parameters
----------
grid_point : int
BZ grid point index.
grid_weight : int
Symmetry weight for BZ summation.
frequencies : ndarray of double, shape (num_bz_gp, num_band)
Phonon frequencies array indexed by BZ grid point.
eigenvectors : ndarray of cdouble, shape (num_bz_gp, num_band, num_band)
Phonon eigenvectors array indexed by BZ grid point.
bz_grid : BZGrid
Brillouin zone grid object.
band_indices : ndarray of int64, shape (num_band0,)
Selected band indices.

Returns
-------
GridPointInput

"""
return GridPointInput(
grid_point=grid_point,
q_point=np.array(
get_qpoints_from_bz_grid_points(grid_point, bz_grid),
dtype="double",
),
frequencies=frequencies[grid_point],
eigenvectors=eigenvectors[grid_point],
grid_weight=grid_weight,
band_indices=band_indices,
)


# ---------------------------------------------------------------------------
# Building-block Protocol interfaces
# ---------------------------------------------------------------------------


# ---------------------------------------------------------------------------
# Re-export Protocol interfaces for backward compatibility.
# Canonical definitions live in phono3py.conductivity.protocols.
Expand All @@ -290,12 +204,10 @@ def make_grid_point_input(

__all__ = [
"GridPointAggregates",
"GridPointInput",
"HeatCapacityResult",
"ScatteringResult",
"VelocityResult",
"compute_effective_gamma",
"make_grid_point_input",
"VelocityProvider",
"HeatCapacityProvider",
"ScatteringProvider",
Expand Down
Loading
Loading