greenWTE.precompute_green

CLI to precompute Green’s operators and store them in an on-disk HDF5 container.

This script builds relaxation-time approximation (RTA) Wigner Green’s operators \(\mathcal G(q;\omega,k)\) for a given material, across a grid of temporal frequencies \(\omega\) in rad/s, spatial frequencies \(k\) in rad/m, and temperatures \(T\) in K. Results are written to an HDF5 file per temperature using the GreenContainer layout. Each file stores the 5-D dataset green[Nw, Nk, nq, m, m] with hdf5plugin.Bitshuffle compression.

Typical use (log-spaced frequency grids):

python -m greenWTE.precompute_green input.hdf5 out_dir -t 300 600 2 -k 3 9 7 -w 0 15 16 -d x

Notes

  • Frequencies provided via -k and -w are interpreted in log10 units when three values are supplied, i.e. -k k0 k1 n produces np.logspace(k0, k1, n) in rad/m; likewise for -w in rad/s. If a single value is given, it is treated as \(10^x\) in the corresponding units.

  • When --batch is enabled, the full Brillouin-zone block (all q) is computed and written in one call. This is fastest but can be memory-intensive. Without --batch, each q is processed independently to reduce peak memory.

  • The script installs signal handlers for SIGINT, SIGTERM, and SIGUSR1. Upon the first signal, it flips a global STOP flag, letting the current compute/write finish, then exits gracefully after the current block. A second signal forces an immediate exit.

Functions

get_parser()

Get the argument parser for the CLI.

parse_arguments([argv])

Parse and validate command-line arguments for Green's precomputation.

request_stop(signal, frame)

Handle termination signals (SIGINT, SIGTERM, SIGUSR1) with graceful shutdown.

greenWTE.precompute_green.get_parser() ArgumentParser

Get the argument parser for the CLI.

greenWTE.precompute_green.parse_arguments(argv: Iterable[str] | None = None) Namespace

Parse and validate command-line arguments for Green’s precomputation.

The frequency grids accept either a single number (interpreted as a base-10 exponent) or three numbers start stop num meaning np.logspace(start, stop, num). Temperatures accept either a single integer or three integers start stop num meaning np.linspace(start, stop, num) (rounded to whole kelvin).

Parameters:

argv (Iterable[str] or None, optional) – CLI arguments to parse (defaults to sys.argv[1:] when None).

Returns:

Parsed arguments.

Return type:

argparse.Namespace

Raises:

ValueError – If any of the *_range options are not specified as either 1 value or 3 values.

greenWTE.precompute_green.request_stop(signal: int, frame) None

Handle termination signals (SIGINT, SIGTERM, SIGUSR1) with graceful shutdown.

On first signal, set a global STOP flag so the main loop finishes the current compute/write and flushes the HDF5 file, then exits. On a second signal, exit immediately with non-zero status.

Parameters:
  • signal (int) – The signal that was received.

  • frame (frame) – The current stack frame.

Notes

  • SIGINT usually corresponds to a manual KeyboardInterrupt (Ctrl-C).

  • SIGTERM is commonly used by schedulers (e.g., Slurm) on cancellation or timeout.

  • SIGUSR1 can be set as an early warning signal in Slurm via #SBATCH --signal=[{R|B}:]SIGUSR1[@sig_time]. See Slurm documentation for details.