PAOFLOW.models.band_unfold#
band_unfold.py — General band-unfolding from supercell to primitive cell.
Works with any crystal symmetry. Given the primitive-cell (PC) and supercell (SC) lattice vectors and atomic positions, the module:
Finds the integer transformation matrix M such that A_SC = M · A_PC.
Enumerates the N = \(|\det M|\) primitive-lattice translations inside the supercell.
Builds the atom mapping I(α, ℓ) (SC atom ← PC atom α + translation ℓ).
Extracts the real-space Hamiltonian from a PAOFLOW DataController, Fourier-transforms along an arbitrary k-path in the PC Brillouin zone, and computes the spectral weight w_n(k) for every SC eigenstate.
Public API#
- unfold_bands(pc_model_dict, sc_model_dict, kpath_frac, *,
nk_per_seg=80, verbose=True)
- paoflow_to_model_dict(data_controller) — model dict of a DFT (projection)
run, for the
pc_model_dict/sc_model_dictargumentsUnfoldResult — dataclass returned by unfold_bands() plot_unfolded — convenience plotting function
Real-space Hamiltonian conventions#
The unfolding Fourier-transforms the real-space Hamiltonian with the Bloch
phase \(e^{+2\pi i \mathbf{k}\cdot\mathbf{R}}\), which presumes that
HRs[:, :, R] holds the hopping from an orbital in the home cell to an
orbital at \(\boldsymbol{\tau}_B + \mathbf{R}\). Model Hamiltonians
built by PAOFLOW.models.models (Slater–Koster, EDTB) follow this
convention. The projected DFT Hamiltonian of a PAOFLOW run does not: it is
obtained as HRs = ifftn(Hks), so that \(H(\mathbf{k}) = \sum_R
H(\mathbf{R})\, e^{-2\pi i \mathbf{k}\cdot\mathbf{R}}\) and the hopping is
stored at \(-\mathbf{R}\). Band energies cannot tell the two apart
(with time reversal they give \(H(\mathbf{k})\) and
\(H(-\mathbf{k})\)), but the spectral weights can: the eigenvectors of
\(H(-\mathbf{k})\) projected on the primitive-cell momentum
\(\mathbf{k}\) select the folded branches of the mirror point.
_extract_hamiltonian() therefore brings every Hamiltonian to the
+R convention before the transform, using the fourier_sign entry of
a _paoflow dict when present and _detect_fourier_sign() otherwise.
References
V. Popescu and A. Zunger, Phys. Rev. B 85, 085201 (2012). P. B. Allen et al., Phys. Rev. B 87, 085322 (2013).
Attributes#
Classes#
Container for band-unfolding results. |
Functions#
|
Generate a k-path from a string specification. |
|
Model dict of a DFT (projection) PAOFLOW run for |
|
Unfold supercell bands onto the primitive-cell Brillouin zone. |
|
Unfold bands using EDTBModel objects directly. |
|
Unfold supercell bands using sparse Lanczos for the SC eigenpairs. |
|
Plot unfolded band structure. |
Module Contents#
- class PAOFLOW.models.band_unfold.UnfoldResult[source]#
Container for band-unfolding results.
- Variables:
kpath_cart ((nk, 3) Cartesian k-points (units of 1/alat).)
kdist ((nk,) cumulative k-distance along the path.)
sym_ticks (list of (distance, label) for symmetry-point ticks.)
nawf_pc (int — number of orbitals in the PC.)
nawf_sc (int — number of orbitals in the SC.)
N (int — volume ratio (= \(|\det M|\)).)
R_translations ((N, 3) PC lattice translations inside the SC.)
atom_map ((n_at_pc, N) SC atom index for each (α, ℓ).)
- kpath_cart: numpy.ndarray[source]#
- kdist: numpy.ndarray[source]#
- E_pc: numpy.ndarray[source]#
- E_sc: numpy.ndarray[source]#
- R_translations: numpy.ndarray[source]#
- atom_map: numpy.ndarray[source]#
- a_pc: numpy.ndarray[source]#
- a_sc: numpy.ndarray[source]#
- sum_rule_check()[source]#
Return Σ_n W_n(k) per k-point (should ≈ nawf_pc).
Notes
The unfolded spectral weights obey the completeness (sum) rule
\[\sum_{n} w_n(\mathbf{k}) \approx n_{\mathrm{awf}}^{PC},\]i.e. at every k-point the SC spectral weights add up to the number of orbitals in the primitive cell.
- PAOFLOW.models.band_unfold.make_kpath(sym_points, path_str, a_pc, nk_per_seg=80)[source]#
Generate a k-path from a string specification.
- Parameters:
sym_points (dict mapping label → (3,) fractional coords in PC basis.)
path_str (e.g. 'Γ-X-W-K-Γ-L|U-X'. Use '-' to connect, '|' for breaks.)
a_pc ((3, 3) PC lattice vectors (rows), Cartesian/alat.)
nk_per_seg (number of k-points per linear segment.)
- Returns:
kpath_cart ((nk, 3) Cartesian k-points.)
kdist ((nk,) cumulative distance.)
sym_ticks (list of (distance, label).)
Notes
The PC reciprocal lattice vectors are defined by
\[\mathbf{b}_i \cdot \mathbf{a}_j = \delta_{ij}, \qquad \mathbf{B}_{PC} = \mathbf{A}_{PC}^{-T},\]so a fractional point
fracmaps to Cartesian coordinates asfrac @ b_pc. Each segment between two symmetry points is sampled by linear interpolation\[\mathbf{k}(t) = \mathbf{k}_0 + t\,(\mathbf{k}_1 - \mathbf{k}_0), \qquad t = 0, \tfrac{1}{n_{\rm seg}}, \dots, \tfrac{n_{\rm seg}-1}{n_{\rm seg}}.\]
- PAOFLOW.models.band_unfold.paoflow_to_model_dict(data_controller, label='PAOFLOW')[source]#
Model dict of a DFT (projection) PAOFLOW run for
unfold_bands().- Parameters:
data_controller (PAOFLOW.DataController.DataController) – Data controller of a run that has built the PAO Hamiltonian (after
projections/projectability/pao_hamiltonian, orread_atomic_proj_QE+pao_hamiltonian).label (str) – Label stored in the dict.
- Returns:
{'label', 'alat', 'model': {'a_vectors', 'atoms'}, '_paoflow': {...}}with the real-space HamiltonianHRs(shape(nawf, nawf, nR, nspin)), its lattice gridR(Cartesian, units ofalat),nawf,nspin, the orbital count per atomnorbitalsandfourier_sign = -1.- Return type:
Notes
PAOFLOW stores
a_vectorsin units ofalatandtauin Bohr; the positions are returned in units ofalat,\[\boldsymbol{\tau}_{\mathrm{alat}} = \boldsymbol{\tau}_{\mathrm{Bohr}} / a_{\mathrm{lat}} .\]The lattice grid
Ris the FFT grid ofHRs(built withPAOFLOW.utils.get_R_grid_fft.get_R_grid_fft()if the run has not built it yet). The projected Hamiltonian isHRs = ifftn(Hks), i.e.\[H(\mathbf{k}) = \sum_{\mathbf{R}} H(\mathbf{R})\, e^{-2\pi i \mathbf{k}\cdot\mathbf{R}},\]which
_extract_hamiltonian()converts to the+Rconvention of the unfolding (fourier_sign = -1). The orbital counts per atom are taken fromnawwhen the run provides them and are otherwise assumed uniform (nawf / natoms).
- PAOFLOW.models.band_unfold.unfold_bands(pc_model_dict, sc_model_dict, sym_points, path_str, *, nk_per_seg=80, verbose=True)[source]#
Unfold supercell bands onto the primitive-cell Brillouin zone.
- Parameters:
pc_model_dict (PAOFLOW model dict for the primitive cell.)
sc_model_dict (PAOFLOW model dict for the supercell.)
sym_points (dict of high-symmetry point labels → fractional coords) – in the PC reciprocal basis. Example:
{'Γ': [0,0,0], 'X': [0.5, 0, 0.5], ...}path_str (band-path string, e.g.
'Γ-X-W-K-Γ-L|U-X'.)nk_per_seg (k-points per linear sub-segment.)
verbose (print progress information.)
- Return type:
UnfoldResult dataclass with eigenvalues, spectral weights, and metadata.
Notes
Both model dicts must use the same alat. The PC and SC lattice vectors (
a_vectors) must be given in Cartesian units of alat (the PAOFLOW / EDTB convention). A model dict may come fromEDTBModel.to_model_dict()(tight-binding route) or frompaoflow_to_model_dict()(projected DFT route); the two store the real-space Hamiltonian in opposite Fourier conventions, which_extract_hamiltonian()reconciles (see the module docstring).At every k-point along the path, the PC and SC Bloch Hamiltonians are built from the real-space Hamiltonians by Fourier transform,
\[H(\mathbf{k}) = \sum_{\mathbf{R}} H(\mathbf{R})\, e^{2\pi i \mathbf{k}\cdot\mathbf{R}},\]Hermitized as \(H(\mathbf{k}) \to \tfrac{1}{2}\left(H(\mathbf{k}) + H(\mathbf{k})^\dagger\right)\) to remove round-off asymmetry, and diagonalized,
\[H(\mathbf{k})\, C_n(\mathbf{k}) = E_n(\mathbf{k})\, C_n(\mathbf{k}),\]giving the PC reference eigenvalues
E_pcand the SC eigenvaluesE_sc/eigenvectors used by_compute_spectral_weights()to obtain the spectral weightsW(see that function’sNotesfor the unfolding formula). The completeness sum rule \(\sum_n W_n(\mathbf{k}) \approx n_{\mathrm{awf}}^{PC}\) is checked at every k-point and a warning is issued if the deviation exceeds 0.01.
- PAOFLOW.models.band_unfold.unfold_from_models(pc_model, sc_model, sym_points, path_str, *, nk_per_seg=80, verbose=True)[source]#
Unfold bands using EDTBModel objects directly.
- Parameters:
pc_model (EDTBModel for the primitive cell.)
sc_model (EDTBModel for the supercell.)
sym_points (high-symmetry points in PC fractional coords.)
path_str (band-path string.)
nk_per_seg (k-points per segment.)
verbose (print progress.)
- Return type:
- PAOFLOW.models.band_unfold.unfold_bands_sparse(pc_model_dict, sc_model_dict, sym_points, path_str, *, n_eigs=100, sigma=0.0, nk_per_seg=80, n_workers=1, backend='loky', verbose=True, **eigsh_kwargs)[source]#
Unfold supercell bands using sparse Lanczos for the SC eigenpairs.
Same physics as
unfold_bands(), but the supercell eigenvalues and eigenvectors are obtained with shift-invert Lanczos (PAOFLOW.spectrum.sparse_bands.SparseEDTB.eigh_at_k()) for then_eigsbands nearestsigma. Only that energy window is diagonalised andH(k)is never densified, so the routine scales to large moiré supercells where the denseeighpath is intractable. The primitive-cell reference bands are still built densely (the PC is small).- Parameters:
pc_model_dict (PAOFLOW model dict for the primitive cell.)
sc_model_dict (PAOFLOW model dict for the supercell (must be a) – distance-dependent EDTB model, as required by
SparseEDTB).sym_points (high-symmetry labels → fractional coords in the PC) – reciprocal basis.
path_str (band-path string, e.g.
'G-M-K-G'.)n_eigs (number of SC bands nearest
sigmato unfold.)sigma (shift-invert target energy (eV).)
nk_per_seg (k-points per linear sub-segment.)
n_workers (parallel workers for the k-point loop (1 = serial,) – -1 = all cores). Uses processes (
backend), since ARPACK’s shift-invert solve is GIL-bound and does not parallelize under threads. Capped at this process’ core budget (its share of the node undermpirun; seePAOFLOW.utils.parallel_resources).backend (joblib backend for the k-point loop (default 'loky').)
verbose (print progress.)
**eigsh_kwargs (extra arguments forwarded to
eigsh(e.g.tol).)
- Returns:
E_scandWhave shape(nk, n_eigs)andnawf_scis set ton_eigs. Because only a window of bands is computed the completeness sum rule Σ_n W_n(k) = nawf_pc no longer holds globally, but each returned band’s weight is exact.- Return type:
- PAOFLOW.models.band_unfold.plot_unfolded(result, *, y_lim=(-12, 6), w_thresh=0.02, cmap='Reds', figsize=(10, 6), title=None, show=True, ax=None)[source]#
Plot unfolded band structure.
- Parameters:
result (UnfoldResult from unfold_bands().)
y_lim (energy window.)
w_thresh (minimum spectral weight to display.)
cmap (matplotlib colormap for scatter points.)
figsize (figure size if creating a new figure.)
title (plot title.)
show (call plt.show().)
ax (existing matplotlib Axes (optional).)
- Return type:
fig, ax