2.1 — Bands Analyzer (stb-bands)¶
What this tool does¶
stb-bands parses a SIESTA .bands file (band-structure eigenvalues
along a high-symmetry k-path) and reports the Valence Band Maximum
(VBM), Conduction Band Minimum (CBM), whether the gap is direct or
indirect, and whether the material is metallic — no SIESTA re-run
needed. Optionally cross-checks that gap against the full SCF k-mesh
(--eig-file, a .EIG file) in case the path missed the true extrema,
and reports each spin channel (+ half-metallic character) separately for
spin-polarized calculations.
This is the first example for the Analysis category (3.x) — the same guided-walkthrough format 2.x already uses, applied to a tool that analyzes an existing SIESTA output rather than building/transforming a structure.
Why this matters (a bit of theory)¶
The .bands file format¶
Line 1 is the Fermi energy; line 4 is nbands nspin nk; then one block
per k-point (the k value, followed by nbands*nspin energies — wrapped
onto extra lines if there are many bands); a footer lists which of those
k-points are the high-symmetry ones, with labels (e.g. 'GAMMA', 'X').
Spin-up and spin-down values are not interleaved per band — the
first nbands values at each k are the full spin-up channel, the next
nbands (if nspin=2) are spin-down (confirmed against sisl's own
reader).
VBM, CBM, and direct vs. indirect gaps¶
At each k-point, the highest energy at or below the Fermi level is that k-point's local VBM; the lowest energy above it is the local CBM.
- The indirect (fundamental) gap is
CBM - VBMusing the global extrema — the true VBM might be at a completely different k-point than the true CBM. - The direct gap is the smallest
CBM(k) - VBM(k)restricted to the same k-point.
Since the direct gap is the same search with an extra constraint
(same k), indirect gap ≤ direct gap always — example_2.1.sh's first
case shows this on a real 21-band structure (indirect 1.2457 eV, direct
1.4484 eV, so Gap type: Indirect).
Why a "gap" is never negative, and what --gap-tol actually decides¶
If bands cross the Fermi level, the naive CBM - VBM can come out
negative (global CBM below global VBM) — stb-bands clamps this to
exactly 0.0 rather than ever reporting a negative gap. Very small
positive gaps and true metals are otherwise indistinguishable, so
--gap-tol (default 0.01 eV) is the threshold: an indirect gap below
it is classified Metallic. example_2.1.sh's
metallic-threshold/ case proves this is a genuine threshold effect —
the same real ~1.25 eV gap is classified Indirect at a tight
--gap-tol and Metallic at a loose one; the physical gap itself never
moved.
Half-metals: one spin channel with a gap, the other without¶
For a spin-polarized calculation, stb-bands runs the exact same
VBM/CBM search independently on each spin channel. A half-metallic
material has one channel metallic and the other with a real gap — it
conducts current of only one spin orientation, which is exactly why
half-metals matter for spintronics. example_2.1.sh's half_metal.bands
fixture is a purpose-built synthetic example: spin-up channel gap
~0.0068 eV (Metallic, below the default --gap-tol), spin-down channel
gap exactly 2.0 eV (Direct) — a clean, unambiguous half-metal.
Why a k-mesh comparison can only go one direction¶
A .bands file only samples a 1-D path through the Brillouin zone —
the true VBM/CBM could sit anywhere else in the zone, entirely off that
path. A .EIG file (the full SCF k-mesh, --eig-file) samples much
more of the zone, so it can catch this. The key asymmetry: a denser mesh
can only find a fundamental gap smaller than or equal to any 1-D
subset of it (the path is a subset of the mesh in the ideal case),
never larger. So:
- mesh gap smaller than the line gap → expected and informative: the path missed the true extrema, trust the mesh.
- mesh gap larger than the line gap → a red flag: the mesh itself is too coarse to have captured what the path already found.
example_2.1.sh's mesh-vs-line/ case demonstrates the first (smaller)
case directly, with a synthetic 3-point mesh whose extrema are known by
hand (mesh.EIG/mesh.KP).
--shift: which energy reference the plotted bands are drawn against¶
A .bands file's raw eigenvalues are absolute (whatever zero the SCF
calculation happened to use) — not very readable on a plot. --shift
subtracts a reference energy from every eigenvalue before writing
bands_gnuplot.dat/plotting, so the reference itself sits at 0 eV:
fermi— the Fermi energy itself. The most common choice: occupied states end up at negative energy, empty states at positive energy, regardless of whether the material is a metal or an insulator.vbm— the Valence Band Maximum. Common for semiconductors/ insulators specifically, since it puts the top of the occupied manifold exactly at 0 eV — convenient when comparing gaps or band-edge positions across different materials.cbm— the Conduction Band Minimum, the mirror choice ofvbm.manual— any value you choose yourself (--manual-value), e.g. to match a reference used in a paper or a previous plot.
This only affects the plotted/written bands (bands_gnuplot.dat,
bands.gplot) — the VBM/CBM/gap analysis in the report itself is always
computed from the raw, unshifted eigenvalues against the file's own
Fermi energy, so --shift never changes any reported physics, only
where the plot's zero line ends up.
When you'd reach for it¶
- Getting the band gap and its direct/indirect character from a finished SIESTA band-structure calculation, without opening a plotting tool.
- Sanity-checking whether your k-path actually captured the true gap
(
--eig-file), before quoting a gap value from a path alone. - Checking for half-metallic character in a spin-polarized calculation.
Two ways to run it¶
A — direct CLI:
stb-bands --file semiconductor.bands --shift fermi
B — interactive stb-suite menu:
$ stb-suite
Select an option (0-7, or a tool code like 5.1.2): 2.1
example_2.1.sh proves this directly at the end.
What every run does (always on)¶
- A numbered report (
[0] RUN METADATA…[7] SUMMARY & FILES) printed to the console. bands_gnuplot.dat+bands.gplot— the actual plot data (rungnuplot bands.gplotfor a PDF).stb_bands_references.bib— SIESTA (every.bandsfile is SIESTA output).
Optional (off by default)¶
- Report — always saved to
stb_bands_report.txtin the current folder (_1,_2, ... when that name is taken); there is no option for it. --eig-file(+--kp-file) — k-mesh vs. k-path gap comparison.--gap-tol— the Metallic/Indirect-or-Direct threshold (default0.01eV).--label— shorthand for--file <label>.bands, auto-detecting a matching<label>.EIG/<label>.KPif present.
Files in this folder¶
semiconductor.bands— a real 21-band structure, 4 k-points (Γ→X→M→Γ), with a genuine indirect gap. Copied fromtest/2-analysis/1-bands/siesta_edge_nbands21.bands(kept small deliberately — a real.bandsfile for a decent-sized cell is easily 1+ MB, far too heavy for a lightweight example).half_metal.bands— synthetic spin-polarized fixture, purpose-built for the half-metallic demo (fromsiesta_spin2.bands).mesh.EIG/mesh.KP— a tiny synthetic 3-point k-mesh with known-by-hand extrema (frommesh_kxkyz.{EIG,KP}).example_2.1.sh— the guided walkthrough (not an automated test — seetest/2-analysis/1-bands/test.shfor that, which additionally covers the real, ~1.2 MB reference fixture this example deliberately skips)..gitignore— excludesoutput/and every file this tool itself generates on a run (bands_gnuplot.dat,bands.gplot,stb_bands_references.bib,stb_bands_report.txt).
Running the walkthrough¶
cd examples/2.1-stb-bands
./example_2.1.sh
It pauses between sections ([Press Enter to continue]) and always starts
by wiping its own output/. Five self-contained cases are generated:
| Folder | What it shows |
|---|---|
gap-analysis/ |
VBM/CBM and direct-vs-indirect gap on a real (tiny) indirect-gap structure |
metallic-threshold/ |
The same real gap classified Indirect vs. Metallic, only --gap-tol changes |
half-metallic/ |
One spin channel metallic, the other with a 2 eV gap |
mesh-vs-line/ |
--eig-file/--kp-file: the k-mesh catching what the k-path missed |
full-report/ |
The report file (stb_bands_report.txt), stb_bands_references.bib |
Try it yourself¶
# Your own finished SIESTA calculation
stb-bands --label my_calc --shift fermi
# Cross-check the path-based gap against the full SCF mesh
stb-bands --file my_calc.bands --eig-file my_calc.EIG --shift fermi
Flag reference¶
| Flag | Meaning |
|---|---|
--label |
SIESTA label; shorthand for --file <label>.bands + auto-detected .EIG/.KP |
--file |
Explicit path to the .bands file |
--shift |
Energy reference for the plot: vbm/cbm/fermi/manual |
--manual-value |
Custom shift value (required with --shift manual) |
--gap-tol |
Metallic-classification threshold, eV (default 0.01) |
--eig-file |
Full SCF k-mesh eigenvalues, for the mesh-vs-line gap comparison |
--kp-file |
Cartesian k-points matching --eig-file (requires --eig-file) |
-o/--output-dir |
Where to write the plot data |
What's next¶
core/siesta_bands.py's VBM/CBM machinery is shared with stb-fatbands
(orbital-projected bands) and, via select_band_vbm_cbm, with
stb-effmass/stb-wfdensity (finding the VBM/CBM band directly from a
.WFSX with no .bands file at all). stb-dos covers the same
occupied/empty-states question from the density-of-states side instead
of individual bands.
Example folder (input fixtures and guided script) on GitHub: examples/2.1-stb-bands/ · guided script example_2.1.sh
Command reference: stb-bands