PAOFLOW.SparsePAOFLOW#
Sparse driver mirroring the dense PAOFLOW.PAOFLOW API.
SparsePAOFLOW wraps a dense PAOFLOW instance for the input stages
(QE parsing, projectability, base-cell Hamiltonian construction — the one
sanctioned dense stage, at the small pre-doubling nawf) and switches
to the purely sparse backend (PAOFLOW.sparse) from the moment the
bond list exists. Method names and signatures mirror the dense driver so
an example script differs only in the import and constructor.
Dense methods without a sparse counterpart raise NotImplementedError
loudly — there is no silent fallback to dense arrays.
Memory contract (see PAOFLOW.sparse): after pao_hamiltonian
returns, no array of size O(nawf^2 * nk) exists; per-k dense workspace is
limited to one (nawf, nev) eigenvector block.
Classes#
Module Contents#
- class PAOFLOW.SparsePAOFLOW.SparsePAOFLOW(workpath='./', outputdir='output_sparse', inputfile=None, savedir=None, npool=1, smearing='gauss', verbose=False, threshold=0.001, rcut=None, hk_solver='auto', restart=False, dft='QE')[source]#
-
- pao_hamiltonian(shift_type=1, insulator=False, write_binary=False, expand_wedge=True, symmetrize=False, thresh=1e-06, max_iter=16)[source]#
Build the base-cell PAO Hamiltonian (dense, sanctioned input stage) and immediately convert it to the sparse bond list; the dense
HRs/Hksare deleted before returning.
- doubling_Hamiltonian(nx, ny, nz, mem_budget_gb=None, force=False)[source]#
Double the cell
nx/ny/nztimes along each lattice vector by index arithmetic on the bond list (never dense), then Hermitize once — the bond-level equivalent of the per-k Hermitizations the dense pipeline applies downstream.nx/ny/nzare doubling counts, so the cell multiplier is2**(nx+ny+nz). A pre-flight projection refuses sizes that cannot fit rather than letting them OOM part-way; see_preflight_doubling()formem_budget_gbandforce.
- energy_window(emin, emax, margin=1.0, nprobe=16, nev=None)[source]#
Size the per-k solve from the property energy range.
MUST be called after
doubling_Hamiltonian()and beforebands()/dos()/transport(). Setsattr['bnd'], which every downstream band-diagonal consumer reads, so the band path and the mesh both pick the new width up automatically.The window top is
ehi = emax + margin.margin(eV) has to cover the adaptive smearing tail (Yates widths here are <~ 0.22 eV, so 4 sigma is <~ 0.9 eV) and the transport occupation derivative at 300 K (~0.1 eV); 1.0 eV covers both.nevis probed by counting eigenvalues belowehiatnprobedeterministic k-points (Gamma, the supercell-BZ corners, then strided mesh points) and padding bymax(8, 2%). Passnevexplicitly to skip the probe.Caveat, stated because it is easy to misread: this narrows the solve but does not make the workload iterative again. The fraction of the spectrum below a fixed
emaxis scale invariant under folding, sonev/nawfstays put as the cell grows. For a DOS-from-eminrun the dense branch is permanent; only an interior window (shift-invert near E_F, transport only) would change that, and that is a different solver.Note also that
attr['bnd']changes meaning here, from “bands with projectability > pthr, times the cell multiplier” to “bands inside the property window”. The downstream normalizations are unaffected (do_dos_adaptive’s twobndfactors cancel; transport slices arebnd-independent), butbands_*.datgains or loses columns, so band files are not column-comparable across runs with and without a window.
- interior_window(elo, ehi, kT_margin_eV=0.26, smear_margin_eV=0.5)[source]#
Solve inside
[elo, ehi]instead of from the bottom of the spectrum.MUST be called after
doubling_Hamiltonian()and before any property. Mutually exclusive withenergy_window().This is the mode that makes the iterative kernel pay: the count in a narrow interior window is a small fraction of the spectrum, whereas a from-the-bottom window must reach E_F and so is 20-50% of it for any real material. The cost is that the states below
eloare never computed, which permanently removes three things:the total electron count, so anything fixed by charge neutrality (carrier density, the Hall coefficient) cannot be evaluated;
DoS/PDoS outside the window, which is absent, not zero;
band indices, since the number of states in the window varies from k-point to k-point.
Properties that need any of those are skipped with a warning and the run continues to the next one; they are listed again at
finish_execution. Note this is a deliberate exception to the backend’s fail-loud rule, made because an interior run is normally a batch of properties of which only some are supportable.kT_margin_eVis the margin the transport occupation derivative needs on each side of the chemical-potential scan; 0.26 eV is 10 kT at 300 K. Raise it for higher temperatures.smear_margin_eVis the analogous margin for DoS/PDoS. Adaptive smearing gives every state a finite width, so a state just belowelo– one this mode never computes – would still contribute inside the window. Plotted ranges are therefore clamped this far inside each edge. The default 0.5 eV covers the <~0.22 eV Yates widths of a converged mesh at 4 sigma; coarse meshes have wider smearing, so after the mesh runs the measured maximum width is checked against this value and a warning is issued if it was too small.
- bands(ibrav=None, band_path=None, high_sym_points=None, fname='bands', nk=500, nsel=None)[source]#
Band structure along a path; computes only the lowest
nselbands (defaultattr['bnd']) iteratively. Output format matches the densebands_{ispin}.datwithnselvalue columns.
- interpolated_hamiltonian(nfft1=0, nfft2=0, nfft3=0)[source]#
Interpolate onto a finer k-mesh. Zero-padding H(R) adds only zero hoppings, and the bond-list assembly already uses the Hermiticity-preserving Nyquist-split convention of
utils.zero_pad— so sparse interpolation is exact and free: only the mesh dimensions change, no new data is created. Arguments of 0 default to twice the current grid (as dense).
- pao_eigh(bval=0)[source]#
Recorded for API compatibility: the mesh eigensolve is fused with velocities/PDOS into one pass, executed by the first property call that needs it (
dosortransport).
- gradient_and_momenta(**kwargs)[source]#
Recorded for API compatibility: band-diagonal velocities are computed inside the fused mesh pass; the full momentum tensor
pkspis never formed.
- adaptive_smearing(smearing='gauss', afac=None, min_width=None, max_width=None)[source]#
Record the adaptive-smearing prefactor and optional width bounds for the fused mesh pass (Yates widths, floored at
min_widthand capped atmax_widthwhen given, asdo_adaptive_smearing; the interbanddeltakp2is not needed by the sparse pipeline).
- plan_pdos(emin=-10.0, emax=2.0, ne=1000)[source]#
Register PDOS accumulation before the mesh pass runs.
The mesh is fused and streaming, so a PDOS consumer can only join while the pass is executing. Asking for PDOS after some other property already triggered the mesh forces a full second pass. Call this ahead of the first property (or simply call
dos()beforetransport()) to avoid that.
- dos(do_dos=True, do_pdos=True, delta=0.01, emin=-10.0, emax=2.0, ne=1000)[source]#
DOS via the dense
do_dos_adaptive(consumes only band-diagonal arrays); PDOS accumulated streaming inside the mesh pass.
- transport(tmin=300.0, tmax=300.0, nt=1, emin=-2.0, emax=2.0, ne=500, scattering_channels=[], scattering_weights=[], tau_dict={}, do_hall=False, write_to_file=True, save_tensors=False)[source]#
Boltzmann transport via the dense stack (it consumes only the band-diagonal
velkp/E_k/deltakpthe mesh produced).