greenWTE.base

Base classes and methods for the greenWTE package.

Functions

N_to_dT(n, material)

Compute \(\Delta T\) from a Wigner distribution.

dT_bte_from_wte(omg_ft, k_ft, phonon_freq, ...)

Eq (9) from Phys Rev.

dT_bte_prb(omg_ft, k_ft, phonon_freq, ...)

Eq (9) from Phys Rev.

dT_to_N_iterative(dT, omg_ft, k_ft, ...[, ...])

Fixed-point mapping \(\Delta T \mapsto n\) using iterative linear solves.

dT_to_N_matmul(dT, material, green, source)

Fixed-point mapping \(\Delta T \mapsto n\) using precomputed Green operators.

estimate_initial_dT(omg_ft, history, complex]])

Estimate the initial guess for \(\Delta T(\omega)\).

flux_from_n(n, material)

Energy flux tensor J computed from n and the velocity operator.

kappa_eff_prb(k_ft, linewidth, ...)

Calculate the effective thermal conductivity that would follow from the BTE.

Classes

AitkenAccelerator()

Delta-squared acceleration for fixed-point iterations.

Material(temperature, velocity_operator, ...)

Container for material-specific properties used by WTE solvers.

SolverBase(omg_ft_array, k_ft, material, source)

Abstract base class for Wigner Transport Equation solvers.

class greenWTE.base.AitkenAccelerator

Bases: object

Delta-squared acceleration for fixed-point iterations.

The accelerator stores the last few iterates of the scalar complex sequence \(\{\Delta T^{(k)}\}\) and applies Aitken’s \(\Delta^2\) formula to propose an improved iterate.

history

A list to store the history of temperature changes dT. The last three entries are used for the acceleration.

Type:

list

Notes

See Wikipedia for details.

__init__() None

Initialize the AitkenAccelerator.

reset() None

Clear the AitkenAccelerator history.

update(dT_new: complex) complex

Update the AitkenAccelerator with a new temperature change.

Parameters:

dT_new (complex) – The new temperature change dT [K] to be added to the history.

Returns:

The accelerated temperature change dT using Aitken’s delta-squared process.

Return type:

complex

class greenWTE.base.Material(temperature: float, velocity_operator: ndarray, phonon_freq: ndarray, linewidth: ndarray, heat_capacity: ndarray, volume: float, qpoint: ndarray | None = None, name: str | None = None)

Bases: object

Container for material-specific properties used by WTE solvers.

A Material holds the arrays and scalars that define a crystalline model at a given temperature, including the velocity operator, phonon frequencies, linewidths, heat capacities and the simulation cell volume. Instances can be created directly from CuPy arrays or loaded from a phono3py result via from_phono3py().

Parameters:
  • temperature (float) – Background temperature [K]

  • velocity_operator (cupy.ndarray) – The velocity operator in m/s, shape (nq, nat3, nat3).

  • phonon_freq (cupy.ndarray) – The phonon frequencies in rad/s, shape (nq, nat3).

  • linewidth (cupy.ndarray) – The linewidths in rad/s, shape (nq, nat3).

  • heat_capacity (cupy.ndarray) – The heat capacities in J/m^3/K, shape (nq, nat3).

  • volume (float) – The volume of the unit cell in m^3.

  • qpoint (cupy.ndarray, optional) – The q-point coordinates, shape (3). Not required to solve the WTE.

  • name (str, optional) – The name of the material.

dtyper

The data type for the real-valued arrays.

Type:

cupy.dtype

dtypec

The data type for the complex-valued arrays.

Type:

cupy.dtype

nq

The number of q-points.

Type:

int

nat3

The number of phonon modes (3 times the number of atoms in the unit cell).

Type:

int

Notes

All array attributes are expected to be cupy.ndarray so that downstream kernels run on the GPU. If you pass NumPy arrays, they should be converted by the caller before construction.

__getitem__(iq: int) Self

Return a single-q-point Material.

Parameters:

iq (int) – The index of the q-point to retrieve.

Returns:

A shallow view where all array attributes are sliced at iq and scalars are preserved.

Return type:

Material

__init__(temperature: float, velocity_operator: ndarray, phonon_freq: ndarray, linewidth: ndarray, heat_capacity: ndarray, volume: float, qpoint: ndarray | None = None, name: str | None = None) None

Initialize the Material class with physical properties.

__iter__() Self

Allow iteration over the Materials q-points.

classmethod from_phono3py(filename: str, temperature: float, dir_idx: int = 0, exclude_gamma: bool = True, dtyper: dtype = <class 'numpy.float64'>, dtypec: dtype = <class 'numpy.complex128'>) Self

Construct a Material from a phono3py HDF5 output.

Parameters:
  • filename (str) – The path to the phono3py output file.

  • temperature (float) – The temperature at which to load the data.

  • dir_idx (int, optional) – The index of the directory containing the output files. Default is 0, which corresponds to the x-direction.

  • exclude_gamma (bool, optional) – Whether to exclude the gamma point from the calculations. This will skip the loading the first q-point for each quantity. Default is True, because the acoustic phonons have zero frequency at the Gamma point.

  • dtyper (cupy.dtype, optional) – The data type for the real parts of the matrices.

  • dtypec (cupy.dtype, optional) – The data type for the complex matrices.

Returns:

An instance of the Material class with the loaded properties.

Return type:

Material

greenWTE.base.N_to_dT(n: ndarray, material: Material) complex

Compute \(\Delta T\) from a Wigner distribution.

Parameters:
  • n (cupy.ndarray) – Wigner distribution function n, shape (nq, nat3, nat3).

  • material (Material) – Material instance.

Returns:

The temperature change dT.

Return type:

complex

See also

_N_to_dT

Core function that computes dT from n and material properties.

class greenWTE.base.SolverBase(omg_ft_array: ndarray, k_ft: float, material: Material, source: ndarray, source_type: str = 'energy', dT_init: complex = 1 + 1j, max_iter: int = 100, conv_thr_rel: float = 1e-12, conv_thr_abs: float = 0, outer_solver: str = 'root', command_line_args=Namespace(), print_progress: bool = False)

Bases: ABC

Abstract base class for Wigner Transport Equation solvers.

This class defines the common interface, data structures, and solver control logic for computing the Wigner distribution function n and derived transport quantities such as flux and thermal conductivity from a given material model, source term, and temporal Fourier frequency grid.

Concrete subclasses must implement the _dT_to_N() method to perform the actual mapping from a temperature change dT to the Wigner distribution function n for a specific solver implementation.

The class supports multiple outer-solver strategies: - plain: fixed-point iteration - aitken: Aitken’s Δ² acceleration of fixed-point iteration - root: root finding on the complex plane using scipy.optimize.root() - none: single mapping without iteration

Parameters:
  • omg_ft_array (cupy.ndarray) – 1D array of temporal Fourier variables in rad/s for which the WTE will be solved.

  • k_ft (float) – Magnitude of the spatial Fourier variable in rad/m.

  • material (Material) – Material object containing the necessary material properties.

  • source (cupy.ndarray) – Source term of the WTE, with shape (nq, nat3, nat3).

  • source_type (str) – The type of the source term, either “energy” or “gradient”. When injecting energy through the source term, there is no additional factor of dT for the offdiagonals of the source. For the temperature gradient type source terms, the offdiagonal elements are scaled by dT.

  • dT_init (complex, optional) – Initial guess for \(\Delta T\) used by the outer solver.

  • max_iter (int, optional) – Maximum number of iterations for the outer solver.

  • conv_thr_rel (float, optional) – The relative convergence threshold for the solver.

  • conv_thr_abs (float, optional) – The absolute convergence threshold for the solver.

  • outer_solver ({'plain', 'aitken', 'root', 'none'}, optional) – Outer-solver strategy. 'root' uses scipy.optimize.root(), 'plain' is fixed-point, 'aitken' applies AitkenAccelerator, and 'none' performs a single mapping.

  • command_line_args (argparse.Namespace, optional) – Optional namespace of parsed command-line arguments to be added to the results file.

  • print_progress (bool, optional) – If True, prints progress while solving.

dT

Converged complex temperature changes, shape (n_omg_ft,).

Type:

cupy.ndarray

n

Computed Wigner distributions, shape (n_omg_ft, nq, nat3, nat3).

Type:

cupy.ndarray

Notes

  • The solver stores intermediate convergence data in lists during the run. After solving all frequencies, _solution_lists_to_arrays() can be used to convert them into CuPy arrays with NaN padding for easier post-processing.

  • The actual numerical strategy for mapping dT to n is deferred to subclasses via the _dT_to_N() method.

See also

IterativeWTESolver

WTE solver using iterative methods.

GreenWTESolver

WTE solver using precomputed Green’s operators.

__init__(omg_ft_array: ndarray, k_ft: float, material: Material, source: ndarray, source_type: str = 'energy', dT_init: complex = 1 + 1j, max_iter: int = 100, conv_thr_rel: float = 1e-12, conv_thr_abs: float = 0, outer_solver: str = 'root', command_line_args=Namespace(), print_progress: bool = False) None

Initialize SolverBase.

_abc_impl = <_abc._abc_data object>
_dT_converged(dT: complex, dT_new: complex) bool

Check whether two successive \(\Delta T\) iterates meet the thresholds.

Parameters:
  • dT (complex) – The previous and current temperature changes dT.

  • dT_new (complex) – The previous and current temperature changes dT.

Returns:

True absolute and relative convergence criteria are met.

Return type:

bool

abstractmethod _dT_to_N(dT: complex, omg_ft: float, omg_idx: int, sol_guess: ndarray | None = None) tuple[ndarray, list]

Map a temperature change to a Wigner distribution n.

Subclasses must implement this method.

_flux = None
_kappa = None
_kappa_c = None
_kappa_p = None
_run_solver_aitken(omg_idx: int, omg_ft: float) tuple[float, complex, complex, ndarray, int, list[float], list[complex], list[float], list[float]]

Run the WTE solver using Aitken’s delta-squared process for acceleration.

Parameters:
  • omg_idx (int) – The index of the temporal Fourier variable for which the WTE will be solved.

  • omg_ft (float) – The temporal Fourier variable in rad/s for which the WTE will be solved.

Returns:

  • omg_ft (float) – The input temporal Fourier variable in rad/s.

  • dT (complex) – The calculated temperature change dT in K for the given omg_ft.

  • dT_init (complex) – The initial temperature change dT in K estimated for the given omg_ft.

  • n (cupy.ndarray) – The wigner distribution function n for the given omg_ft, shape (nq, nat3, nat3).

  • niter (int) – The number of iterations taken for the outer solver to converge for the given omg_ft.

  • iter_times (list) – A list of iteration times for the outer solver for the given omg_ft.

  • dT_iterates (list) – A list of iteration values for the temperature changes dT for the given omg_ft.

  • n_norms (list) – A list of norms for the wigner distribution function n for the given omg_ft.

  • gmres_residual (list) – A list of GMRES residuals for the given omg_ft. Empty if the inner solver is not GMRES.

_run_solver_none(omg_idx: int, omg_ft: float) tuple[float, complex, complex, ndarray, int, list[float], list[complex], list[float], list[float]]

Run the WTE solver without outer iterations, performing a single mapping from dT to n.

Parameters:
  • omg_idx (int) – The index of the temporal Fourier variable for which the WTE will be solved.

  • omg_ft (float) – The temporal Fourier variable in rad/s for which the WTE will be solved.

Returns:

  • omg_ft (float) – The input temporal Fourier variable in rad/s.

  • dT (complex) – The calculated temperature change dT in K for the given omg_ft.

  • dT_init (complex) – The initial temperature change dT in K estimated for the given omg_ft.

  • n (cupy.ndarray) – The wigner distribution function n for the given omg_ft, shape (nq, nat3, nat3).

  • niter (int) – The number of iterations taken for the outer solver to converge for the given omg_ft.

  • iter_times (list) – A list of iteration times for the outer solver for the given omg_ft.

  • dT_iterates (list) – A list of iteration values for the temperature changes dT for the given omg_ft.

  • n_norms (list) – A list of norms for the wigner distribution function n for the given omg_ft.

  • gmres_residual (list) – A list of GMRES residuals for the given omg_ft. Empty if the inner solver is not GMRES.

Notes

The lengthy return signature is to maintain compatibility with the other outer solvers.

_run_solver_plain(omg_idx: int, omg_ft: float) tuple[float, complex, complex, ndarray, int, list[float], list[complex], list[float], list[float]]

Run the WTE solver using simple fixed-point iteration.

Parameters:
  • omg_idx (int) – The index of the temporal Fourier variable for which the WTE will be solved.

  • omg_ft (float) – The temporal Fourier variable in rad/s for which the WTE will be solved.

Returns:

  • omg_ft (float) – The input temporal Fourier variable in rad/s.

  • dT (complex) – The calculated temperature change dT in K for the given omg_ft.

  • dT_init (complex) – The initial temperature change dT in K estimated for the given omg_ft.

  • n (cupy.ndarray) – The wigner distribution function n for the given omg_ft, shape (nq, nat3, nat3).

  • niter (int) – The number of iterations taken for the outer solver to converge for the given omg_ft.

  • iter_times (list) – A list of iteration times for the outer solver for the given omg_ft.

  • dT_iterates (list) – A list of iteration values for the temperature changes dT for the given omg_ft.

  • n_norms (list) – A list of norms for the wigner distribution function n for the given omg_ft.

  • gmres_residual (list) – A list of GMRES residuals for the given omg_ft. Empty if the inner solver is not GMRES.

_run_solver_root(omg_idx: int, omg_ft: float) tuple[float, complex, complex, ndarray, int, list[float], list[complex], list[float], list[float]]

Run the WTE solver using SciPy’s root-finding algorithm :py:mod:scipy.optimize.root`.

Parameters:
  • omg_idx (int) – The index of the temporal Fourier variable for which the WTE will be solved.

  • omg_ft (float) – The temporal Fourier variable in rad/s for which the WTE will be solved.

Returns:

  • omg_ft (float) – The input temporal Fourier variable in rad/s.

  • dT (complex) – The calculated temperature change dT in K for the given omg_ft.

  • dT_init (complex) – The initial temperature change dT in K estimated for the given omg_ft.

  • n (cupy.ndarray) – The wigner distribution function n for the given omg_ft, shape (nq, nat3, nat3).

  • niter (int) – The number of iterations taken for the outer solver to converge for the given omg_ft.

  • iter_times (list) – A list of iteration times for the outer solver for the given omg_ft.

  • dT_iterates (list) – A list of iteration values for the temperature changes dT for the given omg_ft.

  • n_norms (list) – A list of norms for the wigner distribution function n for the given omg_ft.

  • gmres_residual (list) – A list of GMRES residuals for the given omg_ft. Empty if the inner solver is not GMRES.

_solution_lists_to_arrays() None

Convert the lists of iteration times, dT iterates, n norms, and GMRES residuals into cupy arrays.

We can only do that after all omg_ft have been solved, since the lengths of the lists can vary. All entries in the lists are padded with NaNs.

property flux: ndarray

Energy flux tensor J computed from n and the velocity operator.

Returns:

The thermal flux in W/m^2 for each omg_ft, shape (n_omg_ft, nq, nat3, nat3).

Return type:

cupy.ndarray

property kappa: ndarray

Total thermal conductivity \(\kappa(\omega)\).

Compute kappa from the Wigner distribution function n and the temperature change dT.

Returns:

The thermal conductivity in W/m/K for each omg_ft, shape (n_omg_ft,).

Return type:

cupy.ndarray

property kappa_c: ndarray

Coherence thermal conductivity \(\kappa_\mathrm{C}(\omega)\).

Compute kappa_C from the Wigner distribution function n and the temperature change dT.

Returns:

The coherence thermal conductivity in W/m/K for each omg_ft, shape (n_omg_ft,).

Return type:

cupy.ndarray

property kappa_p: ndarray

Ppopulation thermal conductivity \(\kappa_\mathrm{P}(\omega)\).

Compute kappa_P from the Wigner distribution function n and the temperature change dT.

Returns:

The population thermal conductivity in W/m/K for each omg_ft, shape (n_omg_ft,).

Return type:

cupy.ndarray

run() None

Run the WTE solver at each \(\omega \in\) omg_ft_array.

The outer iteration chosen by outer_solver is used to find self-consistent solutions for the temperature changes \(\Delta T(\omega)\) and the Wigner distribution. After running, the results are stored in the class attributes dT, dT_init, n, niter, n_norms, iter_time, dT_iterates, and gmres_residual.

greenWTE.base._N_to_dT(n: ndarray, phonon_freq: ndarray, heat_capacity: ndarray, volume: float) complex

Compute \(\Delta T\) from a Wigner distribution.

Parameters:
  • n (cupy.ndarray) – The wigner distribution function n, shape (nq, nat3, nat3).

  • phonon_freq (cupy.ndarray) – The phonon frequencies in rad/s, shape (nq, nat3).

  • heat_capacity (cupy.ndarray) – The heat capacity in J/m^3/K of the phonon modes, shape (nq, nat3).

  • volume (float) – The volume of the cell in m^3.

Returns:

The temperature change dT.

Return type:

complex

See also

N_to_dT

Wrapper function that extracts material properties from a Material instance.

greenWTE.base._dT_to_N_iterative(dT: complex, omg_ft: float, k_ft: float, phonon_freq: ndarray, linewidth: ndarray, velocity_operator: ndarray, heat_capacity: ndarray, volume: float, source: ndarray, source_type='energy', sol_guess=None, dtyper=<class 'numpy.float64'>, dtypec=<class 'numpy.complex128'>, solver='gmres', conv_thr_rel=1e-12, conv_thr_abs=0, progress=False) tuple[ndarray, list]

Fixed-point mapping \(\Delta T \mapsto n\) using iterative linear solves.

This function solves the linear system of equations that arises from the WTE for the wigner distribution function n for a given temperature change dT.

Parameters:
  • dT (complex) – The temperature change dT in K.

  • omg_ft (float) – The temporal Fourier variable in rad/s.

  • k_ft (float) – The thermal grating wavevector in rad/m.

  • phonon_freq (cupy.ndarray) – The phonon frequencies in rad/s, shape (nq, nat3).

  • linewidth (cupy.ndarray) – The linewidths in rad/s, shape (nq, nat3).

  • velocity_operator (cupy.ndarray) – The velocity operator for the phonon modes, shape (nq, nat3, nat3).

  • heat_capacity (cupy.ndarray) – The heat capacity in J/m^3/K of the phonon modes, shape (nq, nat3).

  • volume (float) – The volume of the cell in m^3.

  • source (cupy.ndarray) – The source term of the WTE, shape (nq, nat3, nat3).

  • source_type (str) – The type of the source term, either “energy” or “gradient”. When injecting energy through the source term, there is no additional factor of dT for the offdiagonals of the source. For the temperature gradient type source terms, the offdiagonal elements are scaled by dT.

  • sol_guess (cupy.ndarray, optional) – The initial guess for the solution, shape (nq, nat3, nat3).

  • dtyper (cupy.dtype, optional) – The real dtype to use.

  • dtypec (cupy.dtype, optional) – The complex dtype to use.

  • solver ({'gmres', 'direct'}, optional) – Inner linear solver. 'gmres' uses cupyx.scipy.sparse.linalg.gmres(); 'direct' uses cupy.linalg.solve() to perform a dense factorization on the GPU.

  • conv_thr_rel (float, optional) – The relative convergence threshold for the solver.

  • conv_thr_abs (float, optional) – The absolute convergence threshold for the solver.

  • progress (bool, optional) – If True, a . is printed after each iteration to indicate progress.

Returns:

  • cupy.ndarray – The Wigner distribution function n, shape (nq, nat3, nat3).

  • list – A list of residuals for each iteration of the solver.

greenWTE.base._flux_from_n(n: ndarray, velocity_operator: ndarray, phonon_freq: ndarray, volume: float) ndarray

Energy flux tensor J computed from n and the velocity operator.

It corresponds to Equation (42) in Phys. Rev. X 12, 041011.

Parameters:
  • n (cupy.ndarray) – The wigner distribution function n, shape (nq, nat3, nat3).

  • velocity_operator (cupy.ndarray) – The velocity operator for the phonon modes, shape (nq, nat3, nat3).

  • phonon_freq (cupy.ndarray) – The phonon frequencies [rad/s], shape (nq, nat3).

  • volume (float) – The volume of the cell [m^3].

Returns:

The thermal flux calculated from the Wigner distribution function n, shape (nq, nat3, nat3).

Return type:

cupy.ndarray

See also

flux_from_n

Wrapper function that extracts material properties from a Material instance.

greenWTE.base._safe_divide(num: ndarray, den: ndarray, eps: float = 1e-300) ndarray

Element-wise division with broadcasting and protection against zeros.

Parameters:
  • num (array-like) – Numerator and denominator. Broadcastable to a common shape.

  • den (array-like) – Numerator and denominator. Broadcastable to a common shape.

  • eps (float, optional) – Small real added to |den| to avoid division by zero.

Returns:

The elementwise division result.

Return type:

cupy.ndarray, numpy.ndarray

greenWTE.base.dT_bte_from_wte(omg_ft, k_ft, phonon_freq, linewidth, group_velocity, heat_capacity, weight, heat, volume)

Eq (9) from Phys Rev. B 104, 245424 [https://doi.org/10.1103/PhysRevB.104.245424] for WTE result.

Here we are using the correct normalization factors to match the BTE.

greenWTE.base.dT_bte_prb(omg_ft, k_ft, phonon_freq, linewidth, group_velocity, heat_capacity, weight, heat)

Eq (9) from Phys Rev. B 104, 245424 [https://doi.org/10.1103/PhysRevB.104.245424].

greenWTE.base.dT_to_N_iterative(dT: complex, omg_ft: float, k_ft: float, material: Material, source: ndarray, source_type='energy', sol_guess=None, solver='gmres', conv_thr_rel=1e-12, conv_thr_abs=0, progress=False) tuple[ndarray, list]

Fixed-point mapping \(\Delta T \mapsto n\) using iterative linear solves.

This function solves the linear system of equations that arises from the WTE for the wigner distribution function n for a given temperature change dT.

Parameters:
  • dT (complex) – The temperature change dT in K.

  • omg_ft (float) – The temporal Fourier variable in rad/s.

  • k_ft (float) – The thermal grating wavevector in rad/m.

  • material (Material) – Material instance.

  • source (cupy.ndarray) – The source term of the WTE, shape (nq, nat3, nat3).

  • source_type (str) – The type of the source term, either “energy” or “gradient”. When injecting energy through the source term, there is no additional factor of dT for the offdiagonals of the source. For the temperature gradient type source terms, the offdiagonal elements are scaled by dT.

  • sol_guess (cupy.ndarray, optional) – The initial guess for the solution, shape (nq, nat3, nat3).

  • solver ({'gmres', 'direct'}, optional) – Inner linear solver. 'gmres' uses cupyx.scipy.sparse.linalg.gmres(); 'direct' uses cupy.linalg.solve() to perform a dense factorization on the GPU.

  • conv_thr_rel (float, optional) – The relative convergence threshold for the solver.

  • conv_thr_abs (float, optional) – The absolute convergence threshold for the solver.

  • progress (bool, optional) – If True, a . is printed after each iteration to indicate progress.

Returns:

  • cupy.ndarray – The Wigner distribution function n, shape (nq, nat3, nat3).

  • list – A list of residuals for each iteration of the solver.

See also

_dT_to_N_iterative

Core function that computes n from dT and material properties.

greenWTE.base.dT_to_N_matmul(dT: complex, material: Material, green: ndarray, source: ndarray, source_type: str = 'energy') ndarray

Fixed-point mapping \(\Delta T \mapsto n\) using precomputed Green operators.

This variant assumes a Green operator has been precomputed and can be applied via batched matrix-matrix products.

Parameters:
  • dT (complex) – The temperature change dT in K.

  • material (Material) – Material instance.

  • source (cupy.ndarray) – The source term of the WTE, shape (nq, nat3, nat3).

  • source_type (str) – The type of the source term, either “energy” or “gradient”. When injecting energy through the source term, there is no additional factor of dT for the offdiagonals of the source. For the temperature gradient type source terms, the offdiagonal elements are scaled by dT.

  • green (cupy.ndarray) – The Green’s function, shape (nq, nat3, nat3).

Returns:

The Wigner distribution function n, shape (nq, nat3, nat3).

Return type:

cupy.ndarray

Notes

This function is a vectorized equivalent of the following more legible loop-based implementation:

nq, nat3 = material.nq, material.nat3
n = xp.zeros((nq, nat3, nat3), dtype=material.dtypec)
for iq in range(nq):
    nbar_deltat = (
        material.volume * nq / hbar
        / material.phonon_freq[iq]
        * material.heat_capacity[iq]
        * xp.array(dT, dtype=material.dtypec)
    )
    rhs = xp.copy(source[iq])
    xp.fill_diagonal(
        rhs,
        xp.diag(source[iq]) + material.linewidth[iq] * nbar_deltat
    )
    n[iq] = (green[iq] @ rhs.flatten(order="F")).reshape(nat3, nat3, order="F")
return n

The vectorized form avoids explicit Python loops and uses batched matrix multiplication for improved performance on the GPU.

greenWTE.base.estimate_initial_dT(omg_ft: float, history: ~typing.Sequence[tuple[float, complex]], dtyper=<class 'numpy.float64'>, dtypec=<class 'numpy.complex128'>) complex

Estimate the initial guess for \(\Delta T(\omega)\).

Try to interpolate the values of \(\Delta T(\omega)\) from history of previous values. If no history is available, we return a default of 1.0 + 1.0j.

Parameters:
  • omg_ft (float) – Temporal Fourier variable in rad/s.

  • history (Sequence[tuple[float, complex]]) – Sequence of previously solve (omg_ft, dT) pairs.

  • dtyper (cupy.dtype, optional) – Data type for the real parts of the matrices.

  • dtypec (cupy.dtype, optional) – Data type for the complex matrices.

Returns:

Interpolated guess for \(\Delta T(\omega)\). If fewer than two history points are available, returns 1.0 + 1.0j.

Return type:

complex

Notes

Uses PCHIP interlator from cupyx.scipy.interpolate.PchipInterpolator.

greenWTE.base.flux_from_n(n: ndarray, material: Material) ndarray

Energy flux tensor J computed from n and the velocity operator.

It corresponds to Equation (42) in Phys. Rev. X 12, 041011.

Parameters:
  • n (cupy.ndarray) – The wigner distribution function n, shape (nq, nat3, nat3).

  • material (Material) – Material instance.

Returns:

The thermal flux calculated from the Wigner distribution function n, shape (nq, nat3, nat3).

Return type:

cupy.ndarray

See also

_flux_from_n

Core function that computes the flux from n and material properties.

greenWTE.base.kappa_eff_prb(k_ft, linewidth, group_velocity, heat_capacity)

Calculate the effective thermal conductivity that would follow from the BTE.

This equation is taken from a draft of Phys. Rev. B 104, 245424 [https://doi.org/10.1103/PhysRevB.104.245424]. It was replaced by Eq. (12) in the published version. The version here gives better results.

Parameters:
  • k_ft (float) – The thermal grating wavevector in rad/m.

  • linewidth (array_like) – The linewidth in rad/s, group velocity in m/s, and heat capacity in J/m^3/K of the phonon modes. 2D arrays with shape (nq, nat3). Note that the group velocity is expected to be along the grating wavevector direction.

  • group_velocity (array_like) – The linewidth in rad/s, group velocity in m/s, and heat capacity in J/m^3/K of the phonon modes. 2D arrays with shape (nq, nat3). Note that the group velocity is expected to be along the grating wavevector direction.

  • heat_capacity (array_like) – The linewidth in rad/s, group velocity in m/s, and heat capacity in J/m^3/K of the phonon modes. 2D arrays with shape (nq, nat3). Note that the group velocity is expected to be along the grating wavevector direction.

Returns:

The effective thermal conductivity in W/m/K.

Return type:

float