greenWTE.iterative
Library module for solving the Wigner Transport Equation (WTE) with a source term.
Provides IterativeWTESolver, an outer solver that maps a complex temperature change
dT to the Wigner distribution function n at each temporal Fourier frequency \(\omega\). The inner mapping
is performed by an iterative Krylov method (e.g. cupyx.scipy.sparse.linalg.gmres()) or a direct GPU solve
(cgesv), see dT_to_N_iterative().
See also SolverBase for shared solver infrastructure.
Classes
|
Wigner Transport Equation solver using iterative or direct linear solvers. |
- class greenWTE.iterative.IterativeWTESolver(omg_ft_array: ndarray, k_ft: ndarray, 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 = 'aitken', inner_solver: str = 'gmres', command_line_args: Namespace = Namespace(), print_progress: bool = False)
Bases:
SolverBaseWigner Transport Equation solver using iterative or direct linear solvers.
This solver computes the mapping from a temperature change
dTto the Wigner distribution functionnby solving the underlying linear system for each temporal Fourier frequency. The inner solver can be an iterative Krylov method such as GMRES or a direct solver (cgesv), and residuals from the inner solver are recorded for convergence analysis.- 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'usesscipy.optimize.root(),'plain'is fixed-point,'aitken'appliesAitkenAccelerator, and'none'performs a single mapping.inner_solver ({'gmres', 'cgesv'}, optional) – Inner solver for mapping
dTton. -'gmres': Iterative Krylov solver with residual history tracking. -'cgesv': Direct CuSolver dense complex equation solver. Default is'gmres'.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.
- inner_solver
The chosen inner method for solving the linear system in the
_dT_to_N()step.- Type:
str
See also
SolverBaseParent class that provides the outer-solver infrastructure.
GreenWTESolverWTE solver using a direct linear solver.
- __init__(omg_ft_array: ndarray, k_ft: ndarray, 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 = 'aitken', inner_solver: str = 'gmres', command_line_args: Namespace = Namespace(), print_progress: bool = False) None
Initialize IterativeWTESolver.
- _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:
Trueabsolute and relative convergence criteria are met.- Return type:
bool
- _dT_to_N(dT: complex, omg_ft: float, omg_idx: int, sol_guess: ndarray = 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
nand 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
nand the temperature changedT.- 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
nand the temperature changedT.- 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
nand the temperature changedT.- 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_solveris 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.