Skip to content

Internal basis workflow

Marco Buongiorno Nardelli edited this page Jun 1, 2026 · 5 revisions

projections() basis-preset overhaul

Branch: develop-marco. Scope: user-facing PAOFLOW.projections(configuration=...) API, the internal basis_presets module, and end-to-end validation against the QE examples shipped with the repository.

1. Summary of the change

PAOFLOW.projections(configuration=...) now accepts three string presets in addition to the legacy dict and None forms:

configuration Basis builder Source of radial functions
"minimal" build_pswfc_basis_all Pseudo-atomic PP_PSWFC from each species' UPF (occupied shells only).
"standard" build_aewfc_basis AE / pseudo-atom radial functions for the minimal valence shells only (no polarization).
"extended" build_aewfc_basis "standard" augmented by a rule-based polarization set.
dict build_aewfc_basis (if internal=True or VASP) else build_pswfc_basis_all Explicit {element: [shells]} mapping (legacy).
None as above Keep whatever is already in arry['configuration'] (legacy).

The radial database backing "standard" / "extended" can come from either:

  • the legacy hand-curated BASIS/<elem>/*.dat distributed with the repo (scalar-relativistic AE radials), or
  • a pseudo-atom basis generated on the fly from the user's UPFs by PAOFLOW.basis_gen (also exposed as the paoflow-genbasis-ps console script). The pseudo-atom path produces j-resolved radials for spin–orbit pseudos and is selected by pointing basispath= at the generated directory (e.g. BASIS_PS/). See basis_generation_from_pseudo.md for the algorithm and CLI.

Behavioural contract:

  • "minimal" reproduces the smooth pseudo basis that QE's projwfc.x uses by default. Spans the valence well; conduction states are under-represented.
  • "standard" swaps the minimal pseudo radials for AE/pseudo-atom ones of the same shells — same nawf, better conditioning at the edges of the valence.
  • "extended" is a pure AE/pseudo-atom basis with a generous shell set chosen to give Löwdin orthogonalization enough variational freedom for conduction states across all common pseudo families (NC, US, PAW).
  • Presets override internal=. Dict and None paths are unchanged.

What was removed

An earlier attempt (Option B) built a mixed basis — UPF PP_PSWFC as the baseline plus AE radial functions for polarization shells. Raw AE orbitals carry core-region oscillations that smooth pseudo Bloch states cannot project onto, producing ill-conditioned overlaps and broken bands. That path (build_mixed_basis in do_atwfc_proj.py) is still present but dormant; re-enabling it requires AE → pseudo pseudization first. See the docstring of resolve_configuration.

2. Files touched

3. The augmentation rule

Implemented in extended_augmentation. Let nmax = max(n) across the occupied UPF shells of an element, and let its periodic-table block be one of s / p / d / f. The augmentation appended to the minimal valence set is:

Channel Principal quantum numbers added
S n ∈ {nmax, nmax+1, nmax+2}
P n ∈ {nmax, nmax+1, nmax+2} (n ≥ 2)
D n ∈ {max(3, nmax−1), …, nmax+1}
F n ∈ {max(4, nmax−1), …, nmax}, f-block only

Shells already in the minimal set are skipped; shells not present in BASIS/<elem>/ are dropped with a RuntimeWarning. Typical sizes: 7–9 shells (s/p elements), 9 (d elements), 12 (f elements). This is intentionally generous: AE radial functions are not orthogonal to each other across n, and Loewdin needs the freedom to span the conduction manifold.

Generality check (94 elements)

Sweeping every directory under BASIS/ and asking the rule which shells it would request yielded zero missing shells for all 94 elements currently shipped. The rule never asks for a shell that isn't on disk for any element it classifies.

4. Validation: cross-pseudo end-to-end runs

Harness (run from outside the repo so no test outputs land here): /Users/marco/Workspace/PAOFLOW/examples/qe_examples/test_extended_preset.py.

For each system the harness runs four schemes — qe (legacy read_atomic_proj_QE), minimal, extended, and (where available) a hand-written manual configuration — computes Pn>0.95 projectability and the band structure on a 400-point path, then overlays the bands.

Pseudo families covered

Example System Pseudopotential family Status
example01 Si Troullier–Martins NC (GIPAW) OK
example02 Al FHI Martin-Trouiller NC, metallic OK
example03 Pt PSL ultrasoft, 5d transition metal OK
example06 AlP FHI NC, two p-block species OK
example10 GaAs PSL PAW, semicore d OK
example15 Si ONCV scalar-relativistic NC OK
example04 Fe (FM) PSL US, fully-relativistic (SO) OK with caveat (see §4.1)
example05 Pt PSL US, fully-relativistic (SO) OK with caveat (see §4.1)

Examples with other relativistic / SO pseudos (07, 08, 09, 11, 14) are not yet covered by the harness.

Summary table (Pn > 0.95 count)

System Pseudo family qe minimal extended manual
Si_TM TM NC GIPAW 9 9 18 —
Al_FHI FHI NC 4 4 7 —
Pt_PSL_US PSL US 6 6 9 —
AlP_FHI FHI NC 10 10 20 —
GaAs_PSL_PAW PSL PAW 9 4 16 18
Si_ONCV ONCV NC — 4 18 10
Fe_PSL_REL PSL US SO 20 20 20 —
Pt_PSL_REL PSL US SO 12 12 18 —

nawf (basis size) corresponding to the same runs:

System qe minimal extended manual
Si_TM 18 18 44 —
Al_FHI 16 16 22 —
Pt_PSL_US 9 9 27 —
AlP_FHI 32 32 44 —
GaAs_PSL_PAW 13 13 54 62
Si_ONCV — 8 44 26
Fe_PSL_REL 26 26 62 —
Pt_PSL_REL 18 18 54 —

Observations:

  • extended strictly improves projectability over both qe and minimal for every scalar-relativistic pseudo family.
  • For Si_ONCV extended (18) beats the hand-tuned manual (10): the rule found a better-conditioned shell set than was used in the original example.
  • For GaAs extended (16) is close to but below manual (18); manual uses 62 vs extended's 54 — the larger explicit set squeezes out two more bands at the cost of conditioning.
  • AlP_FHI doubles the projectable count (10 → 20) with only a modest basis-size increase (32 → 44).
  • Relativistic results carry an important caveat — see §4.1.

4.1 Spin-orbit pseudos: now j-resolved

The original BASIS/<elem>/*.dat files distributed with the repo are scalar-relativistic — one radial per nL shell. For an l ≥ 1 SO channel the dftSO branch of build_aewfc_basis used to fake the doublet by duplicating the same scalar radial for both j = l ± 1/2 values. The two |j, m_j⟩ projectors were then linearly dependent in the radial part, so the Löwdin-orthogonalised subspace was rank-deficient in the upper conduction window (artefact bands near +7 eV for Fe, +12 eV for Pt; see bands_extended_Fe_PSL_REL.png and bands_extended_Pt_PSL_REL.png).

Status: fixed. The new pseudo-atom solver in PAOFLOW.basis_gen integrates the radial Schrödinger equation in a confining box using the pseudopotential's local + nonlocal (KB) channels and a frozen all-electron density (Hartree + LDA-PW92 XC). For a fully-relativistic UPF it produces distinct radials for j = l − 1/2 and j = l + 1/2 on each l ≥ 1 shell, written as BASIS_PS/<elem>/<shell>_j{2J}.dat. build_aewfc_basis picks them up automatically through _resolve_ae_shell_files: when both j-files exist they populate the two |j, m_j⟩ blocks with physically distinct radials. Backward compatibility with the legacy scalar BASIS/ tree is preserved — if no _j* files are present, the scalar radial is duplicated as before.

Fresh end-to-end runs against the same Pt SO pseudo (Pt_ONCV_PBE_fr.upf, example16/Pt_REL/), generating BASIS_PS/ on the fly:

preset nawf Pn>0.95 (scalar BASIS/) Pn>0.95 (j-resolved BASIS_PS/)
minimal 20 18 18
standard 38 14 20
extended 62 24 26

And for Si ONCV (scalar-relativistic, sanity check):

preset nawf Pn>0.95 (BASIS/) Pn>0.95 (BASIS_PS/)
minimal 8 4 4
standard 26 10 12
extended 44 18 18

nawf is identical (basis layout preserved); projectability matches or improves, with the largest gains where j-resolved radials matter. The artefact bands in the SO conduction window are gone:

Pt (SO) — j-resolved pseudo-atom basis (BASIS_PS/)

Pt ONCV SO bands with BASIS_PS

Si ONCV — pseudo-atom basis (BASIS_PS/)

Si ONCV bands with BASIS_PS

See examples/qe_examples/example16/ for the self-contained driver: each main.py calls PAOFLOW.basis_gen.generate_basis_for_pseudo on first run to produce the local BASIS_PS/ tree, then runs all three presets.

4.2 Legacy SO results (scalar BASIS/) — historical reference

The analysis below was produced against the original scalar AE radials in BASIS/<elem>/. It documents the artefact-band behaviour that motivated the j-resolved pseudo-atom path described in §4.1, and is retained here for reference.

Empirically (Fe_PSL_REL, Pt_PSL_REL plots below):

  • Valence bands (occupied + low conduction): reproduced exactly by both minimal and extended, in agreement with the legacy qe curve. SO splittings present in the Bloch states pass through unmodified.
  • Upper conduction window: extended develops spurious oscillatory / flat artefact bands (Fe near +7 eV; Pt near +12 eV) coming from the rank-deficient duplicated channels.
  • The reported Pn > 0.95 counts can mask this: Fe stays at 20 despite the larger basis (62 vs 26 nawf) because the extra states are absorbed by the artefact band.

Practical guidance. On SO pseudos, today's extended is safe for any analysis confined to the valence (DOS, projections, occupied-state properties). Anything that depends on conduction bands (anomalous Hall, spin Hall, Berry curvature, topology, optical response) is not trustworthy until the basis builder gains a proper j-resolved AE path. Prefer minimal (or the legacy qe route) for those workflows.

Band plots

Generated by the harness with all four schemes overlaid.

Si — Troullier–Martins NC (GIPAW)

Si_TM bands

Al — FHI NC (metallic)

Al_FHI bands

Pt — PSL ultrasoft

Pt_PSL_US bands

GaAs — PSL PAW

GaAs_PSL_PAW bands

Si — ONCV scalar-relativistic NC

Si_ONCV bands

AlP — FHI NC

AlP_FHI bands

Fe — PSL US, fully-relativistic (SO)

Valence below ~5 eV reproduces qe/minimal exactly; note the oscillatory artefact band near +7 eV from the duplicated j-channels. Fe_PSL_REL bands

Pt — PSL US, fully-relativistic (SO)

Valence + lower conduction up to ~5 eV match qe/minimal; flat artefact band at the top of the window (+12 eV) and some spurious dispersion above +8 eV. Pt_PSL_REL bands

5. Tests

Unit tests

pytest tests/unit/test_basis_presets.py

37 tests, ~0.13 s on the dev box. Cover:

  • Periodic-table block lookup and BASIS/ catalog parsing.
  • extended_augmentation rule output per block (s, p, d, f).
  • minimal_shells_from_upf against fixture UPFs.
  • resolve_configuration dispatch, error paths, and warning emission when a requested shell is absent from BASIS/.

Cross-pseudo end-to-end harness

# Optionally override the BASIS path (defaults to this repo's BASIS/).
export PAOFLOW_BASISPATH="/path/to/PAOFLOW/BASIS"
python /Users/marco/Workspace/PAOFLOW/examples/qe_examples/test_extended_preset.py

The harness lives outside the repo to avoid polluting examples/ with generated output directories. It expects the QE *.save directories (with wfc*.dat preserved) to be staged under examples/qe_examples/example{01,02,03,04,05,06,10,15}/ in the workspace location.

6. Open follow-ups

  • j-resolved AE radials for SO pseudos. Done — see §4.1 and basis_generation_from_pseudo.md. Implemented as path (a): pseudo-atom solver writes BASIS_PS/<elem>/<shell>_j{2J}.dat; build_aewfc_basis consumes them via _resolve_ae_shell_files.
  • Remaining SO examples (07, 08, 09, 11, 14): add to the harness with BASIS_PS/ regenerated from each pseudo.
  • Mixed pseudo+AE scheme (build_mixed_basis): keep dormant; needs
bands_extended_Si_TM

AE → pseudo pseudization before it can produce well-conditioned overlaps. Track separately if pursued. bands_basis_ps_Pt_ONCV_REL bands_basis_ps_Si_ONCV bands_extended_Al_FHI bands_extended_AlP_FHI bands_extended_Fe_PSL_REL bands_extended_GaAs_PSL_PAW bands_extended_Pt_PSL_REL bands_extended_Pt_PSL_US bands_extended_Si_ONCV

Clone this wiki locally