PAOFLOW.spectrum.sparse_bands#

sparse_bands.py — Sparse on-the-fly Lanczos band structure for EDTB models.

Bypasses dense H(R) storage. For each k-point the Hamiltonian H(k) is assembled as a sparse CSR matrix from a precomputed bond list, then scipy.sparse.linalg.eigsh extracts the requested eigenvalues via implicitly-restarted Lanczos.

Usage#

from sparse_bands import SparseEDTB ham = SparseEDTB(model_dict) result = ham.compute_bands(“K-G-M-K’”, high_sym_pts, nk=100, n_eigs=50)

Classes#

SparseEDTB

Sparse EDTB Hamiltonian for large supercells.

Module Contents#

class PAOFLOW.spectrum.sparse_bands.SparseEDTB(model_dict, verbose=True)[source]#

Sparse EDTB Hamiltonian for large supercells.

Parameters:
  • model_dict (dict) – PAOFLOW-format model dictionary (as produced by EDTBModel.to_model_dict()).

  • verbose (bool) – Print progress messages.

verbose = True[source]#
build_hk(k_frac)[source]#

Build sparse H(k) as a CSR matrix.

Parameters:

k_frac (array_like, shape (3,)) – k-point in fractional coordinates.

Returns:

Hk

Return type:

csr_matrix, shape (nawf, nawf), complex128

eigvals_at_k(k_frac, n_eigs=50, sigma=None, **kwargs)[source]#

Compute selected eigenvalues at one k-point via Lanczos.

Parameters:
  • k_frac (array_like, shape (3,))

  • n_eigs (int) – Number of eigenvalues to compute.

  • sigma (float or None) – Shift-invert target. If provided, eigsh computes eigenvalues nearest to sigma. Much faster convergence for interior eigenvalues but requires a sparse LU factorization. If None, computes the smallest eigenvalues (which=’SM’).

  • **kwargs – Extra arguments passed to scipy.sparse.linalg.eigsh.

Returns:

eigenvalues

Return type:

ndarray, shape (n_eigs,) sorted ascending

compute_bands(band_path, high_sym_points, nk=100, n_eigs=50, sigma=None, outputdir=None, n_workers=1, **kwargs)[source]#

Compute band structure along a k-path.

Parameters:
  • band_path (str) – Path specification, e.g. “K-G-M-K’”.

  • high_sym_points (dict) – {label: [k1, k2, k3]} in fractional coordinates.

  • nk (int) – Total number of k-points along the path.

  • n_eigs (int) – Number of eigenvalues at each k-point.

  • sigma (float or None) – Shift-invert target energy (eV).

  • outputdir (str or None) – If set, write bands_0.dat and kpath_points.txt.

  • n_workers (int) – Number of parallel workers for k-point loop. 1 = serial (default). -1 = all available cores. Requires joblib; falls back to serial if unavailable.

  • **kwargs – Extra arguments for eigsh (e.g. tol, maxiter).

Returns:

result – ‘eigenvalues’ : ndarray (nk, n_eigs) ‘k_dist’ : ndarray (nk,) ‘tick_pos’ : list ‘tick_labels’ : list ‘bands_file’ : str or None

Return type:

dict