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
-kand-ware interpreted in log10 units when three values are supplied, i.e.-k k0 k1 nproducesnp.logspace(k0, k1, n)in rad/m; likewise for-win rad/s. If a single value is given, it is treated as \(10^x\) in the corresponding units.When
--batchis enabled, the full Brillouin-zone block (allq) is computed and written in one call. This is fastest but can be memory-intensive. Without--batch, eachqis processed independently to reduce peak memory.The script installs signal handlers for
SIGINT,SIGTERM, andSIGUSR1. Upon the first signal, it flips a globalSTOPflag, letting the current compute/write finish, then exits gracefully after the current block. A second signal forces an immediate exit.
Functions
Get the argument parser for the CLI. |
|
|
Parse and validate command-line arguments for Green's precomputation. |
|
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 nummeaningnp.logspace(start, stop, num). Temperatures accept either a single integer or three integersstart stop nummeaningnp.linspace(start, stop, num)(rounded to whole kelvin).- Parameters:
argv (Iterable[str] or None, optional) – CLI arguments to parse (defaults to
sys.argv[1:]whenNone).- Returns:
Parsed arguments.
- Return type:
argparse.Namespace
- Raises:
ValueError – If any of the
*_rangeoptions 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
STOPflag 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
SIGINTusually corresponds to a manualKeyboardInterrupt(Ctrl-C).SIGTERMis commonly used by schedulers (e.g., Slurm) on cancellation or timeout.SIGUSR1can be set as an early warning signal in Slurm via#SBATCH --signal=[{R|B}:]SIGUSR1[@sig_time]. See Slurm documentation for details.