PAOFLOW.sparse.mesh#
Fused BZ-mesh pass: eigenpairs, velocities, adaptive widths, consumers.
One loop over the local share of the full k-mesh produces everything the band-diagonal property kernels need, without ever storing eigenvectors:
E_k(nk_local, nev, nspin) — lowestneveigenvalues,velkp(nk_local, 3, nev, nspin) — Hellmann-Feynman band-diagonal velocities v_ln = <n| dH/dk_l |n>, with degenerate groups resolved as the ascending eigenvalues of the group block (replicatingutils.perturb_splitas used bydo_momentum),deltakp(nk_local, nev, nspin) — Yates adaptive smearing widthsafac * dk * |v_n|, optionally floored atmin_width(replicatingdo_adaptive_smearing),
stored k-scattered in the dense conventions so do_dos_adaptive and the
Boltzmann transport stack consume them unchanged. Registered consumers
receive (ik, ispin, E, V, vel, delta) per k-point and must not retain
V — the (nawf, nev) eigenvector block is the only dense workspace
and is discarded before the next k-point.
The mesh phase convention is sign=-1 (the dense fftn convention),
and the k ordering matches the dense pipeline’s FFT-grid linearization
n = k + j*nk3 + i*nk2*nk3, so per-k quantities are index-comparable
with the dense arrays.
PAD_ENERGY_OFFSET and PAD_DELTA are the sentinel energy offset and
smearing width used to pad an interior-window solve to a rectangular block;
run_mesh() explains why they take these values.
Attributes#
Classes#
Interface a fused-mesh consumer must implement. |
Functions#
|
Walk the local share of the BZ mesh, producing all band-diagonal data. |
|
Raise if any k-point's computed spectrum stopped below the window. |
Module Contents#
- class PAOFLOW.sparse.mesh.MeshConsumer[source]#
Bases:
ProtocolInterface a fused-mesh consumer must implement.
Notes
A consumer is a property accumulator that needs the eigenvectors, which the mesh pass refuses to store. Instead of returning them, the mesh hands each consumer one k-point’s results while they are still live and then frees the block, so a consumer must extract whatever scalar quantity it needs inside
on_k()and must not keep a reference toV.PdosConsumeris the canonical implementation.
- PAOFLOW.sparse.mesh.run_mesh(data_controller, sparse_h, nev, consumers=(), afac=None, smearing='gauss', min_width=None, max_width=None, verbose=False, hk_solver='auto', ehi=None, interior=None)[source]#
Walk the local share of the BZ mesh, producing all band-diagonal data.
- Parameters:
data_controller (DataController) – Run state. Supplies the mesh dimensions and cell volume, and receives
arrays['E_k'],arrays['velkp']andarrays['deltakp']— this rank’s k-slice, in the dense layout.sparse_h (SparseHamiltonian) – Bond list the Bloch Hamiltonian and its gradient are assembled from at each k-point.
nev (int) – Number of lowest bands per k-point. Ignored when
interioris given.consumers (sequence of MeshConsumer, optional) – Property accumulators fed one k-point at a time and finalized after the loop.
afac (float or None, optional) – Prefactor of the adaptive smearing width. Defaults to the value the dense pipeline uses for the chosen
smearing.smearing (str, optional) – Smearing kernel name; sets the default
afac.min_width (float or None, optional) – Lower bound of the widths (eV), as in
do_adaptive_smearing: a state narrower than the energy grid of a consumer drops out of its sums.None(default) keeps the raw widths.max_width (float or None, optional) – Upper bound of the widths (eV);
Noneleaves them uncapped.verbose (bool, optional) – Log progress every few percent of this rank’s k-points.
hk_solver ({'auto', 'sparse', 'dense'}, optional) – Per-k-point kernel, selected once for the whole loop (see
select_hk_solver()). It depends only on(nawf, nev), so it cannot change from k-point to k-point.ehi (float or None, optional) – Top of the energy window
nevwas sized for (eV). Every k-point whose highest computed band falls below it is counted, and a non-zero global count raises after the loop with thenevneeded to re-run — no silent truncation, and no whole-mesh redo triggered from inside the loop.interior ((float, float) or None, optional) – Energy window
(elo, ehi)in eV. Switches to the interior solver: every state inside the window, none below it.
- Returns:
Results are written into
data_controllerarrays and pushed to the consumers.- Return type:
None
Notes
Every band-diagonal property in the pipeline — density of states, projected DOS, Boltzmann transport — is a Brillouin-zone sum over quantities that depend on one band at one k-point: its energy, its velocity, and the width of the smearing that stands in for the delta function. The dense pipeline computes those in separate passes, each reading a stored eigenvector tensor. Here they are produced in a single fused loop, so the eigenvectors never outlive the k-point that produced them.
Three things come out of each k-point. The eigenvalues are the band energies. The band-diagonal velocities follow from the Hellmann-Feynman theorem (see
_band_diagonal_velocities()) using the same sparse assembly of \(\partial H/\partial k\) that gives \(H(k)\). The adaptive smearing width is the Yates estimateafac * dk * |v_n|: the energy of a band changes by roughly its velocity times the k-point spacing between one mesh point and the next, so a band that disperses steeply must be smeared more widely than a flat one to make a discrete mesh sum approximate a continuous integral.Consecutive mesh points are close in k, so each solve is seeded from its predecessor: the from-the-bottom branch reuses the previous ground state as the starting vector, and the interior branch reuses the previous state count as its Krylov size estimate. Both are convergence aids only and cannot change the converged result.
Which states are computed depends on the mode. From the bottom, each k-point returns exactly
nevstates and the output arrays are rectangular by construction. With aninteriorwindow, the number of states inside the window is k-dependent (a band crossing an edge is in at one k-point and out at the next), so the per-k results are collected and padded to the global maximum afterwards;attr['bnd']is set to that maximum. The padding is deliberately not neutral-looking: the energy sits far outside any plotted range so every smearing kernel evaluates to zero there, the velocity is zero so the state carries no transport weight, and the width isO(1)rather than zero only because the smearing kernels divide by it.solve_interiorguarantees completeness inside the window or raises, so theehideficit counter does not apply there and is skipped.An interior solve also records
attr['sparse_interior_dmax'], the largest real adaptive width over the whole mesh with padding excluded. Consumers need it to know how far a smearing tail reaches past the window edge: a state just belowelostill contributes inside the window, so a DOS plotted too close to the edge is contaminated by states that were never computed. It is recorded here because only the mesh pass knows the widths.Progress logging uses an interval of one tenth of this rank’s k-points, capped at 100. A fixed interval of 100 would print nothing at all on a coarse supercell mesh (216 k-points over four ranks is 54 each), which is exactly the run slow enough to want progress from.
- PAOFLOW.sparse.mesh.check_window_coverage(deficit, nev, ehi, tag)[source]#
Raise if any k-point’s computed spectrum stopped below the window.
- Parameters:
deficit (int) – Number of local k-points whose highest computed band fell below
ehi.nev (int) – Band count the solve was run with, quoted in the message.
ehi (float or None) – Top of the requested energy window (eV).
Nonedisables the check entirely.tag (str) – Name of the calling stage, for the message.
- Return type:
None
- Raises:
RuntimeError – If any rank reported a deficit.
Notes
A from-the-bottom solve returns a fixed number of bands, but how far up in energy those bands reach is k-dependent. If the requested window extends above the highest computed band at some k-point, every property integrated over that window is quietly missing states there — the kind of error that produces a plausible plot with the wrong answer.
The check is collective: the local counts are summed across ranks, so every rank raises together rather than one rank raising while the others hang in a later reduction. The message names the exact
nevto re-run with.