Repository navigation
Input and Script Generators (CLI)
PAOFLOW ships two small, dependency-light command-line generators that automate the repetitive parts of setting up a study. They are installed with the package as console commands:
-
paoflow-gen-qe— build a Quantum ESPRESSOscfinput from an AFLOW database entry, with sensible defaults for smearing, magnetism, spin–orbit coupling, and the number of bands needed for PAOFLOW's extended-basis projections. -
paoflow-gen— interactively generate a PAOFLOW driver script (main.py) from the output of a Quantum ESPRESSO run, and optionally a companion plotting script (plot.py) that visualizes exactly the properties you selected.
Both generators are otherwise dependency-light, using mostly the Python
standard library (urllib, json, argparse, glob, os, re, math).
The only exception is paoflow-gen-qe's automatic ibrav detection, which
relies on NumPy through PAOFLOW.inputs.lattice_format (already a PAOFLOW
dependency); with --ibrav 0 even that path is pure standard library. The
generated PAOFLOW scripts of course require a working PAOFLOW installation.
The generators emit static, heavily-commented scripts that are easy to inspect
and tweak afterwards.
The code lives in the PAOFLOW.gen subpackage
(src/PAOFLOW/gen/aflow_qe.py and src/PAOFLOW/gen/paoflow_driver.py) and is
exposed through the paoflow-gen-qe and paoflow-gen console entry points
defined in pyproject.toml. Once PAOFLOW is installed (pip install -e .),
both commands are available on your PATH; they can also be invoked as
python -m PAOFLOW.gen.aflow_qe and python -m PAOFLOW.gen.paoflow_driver.
Given an AFLOW entry, the tool downloads the structure and metadata and writes a
ready-to-run pw.x scf input file. It chooses energy cutoffs, k-point
density, smearing scheme, magnetic configuration, and the number of bands
(nbnd) appropriate for a subsequent PAOFLOW run that uses the extended
pseudo-atomic basis.
paoflow-gen-qe <AFLOW-entry> -p <pseudo-dir> [options]The <AFLOW-entry> positional argument accepts any of the following forms:
| Form | Example |
|---|---|
| AFLOWDATA URL | https://aflowlib.duke.edu/AFLOWDATA/ICSD_WEB/RHL/Bi1_ICSD_616519/ |
| Material-page URL | https://aflow.org/material/?id=aflow:0a66d228d896a855 |
| Bare AUID token | aflow:0a66d228d896a855 |
Material-page URLs and bare AUID tokens are resolved to their underlying
AFLOWDATA location through the AFLUX API
(https://aflow.org/API/aflux/?auid('aflow:…'),aurl).
| Flag | Default | Description |
|---|---|---|
-p, --pseudo-dir
|
(required) | Directory containing the UPF pseudopotentials |
--soc |
off | Emit a non-collinear, spin–orbit (noncolin, lspinorb) input |
-o, --out
|
stdout | Output file path |
--degauss |
0.05 |
Smearing width (Ry) for metallic systems |
--nbnd |
(auto) | Override the automatically computed number of bands |
--ibrav |
auto |
Lattice mode: auto detects the QE ibrav + celldm; 0 always writes explicit CELL_PARAMETERS
|
--symprec |
1e-4 |
Symmetry tolerance (Bohr) for the ibrav detection |
-
Structure — downloads
CONTCAR.relax.qeand, by default (--ibrav auto), detects the matching Quantum ESPRESSOibravandcelldmfor the cell, emitting a compact symmetric input. When the lattice cannot be classified it falls back to anibrav=0cell with explicitCELL_PARAMETERS. Pass--ibrav 0to force the explicit-cell output (see Automaticibravdetection below). -
Cutoffs — reads recommended wavefunction cutoffs from a bundled
reference.json(converted from Hartree to Rydberg). -
Masses — looks up atomic masses from a bundled periodic-table table.
-
Smearing (metal vs. insulator) — if the AFLOW band gap is essentially zero (≤
1e-6eV) the system is treated as a metal: smearing occupations plus a conservativemixing_beta = 0.2. Otherwise it uses fixed occupations andmixing_beta = 0.7. -
Magnetism — if any per-atom spin moment exceeds
1e-3, the input is made spin-polarized (nspin = 2) with per-typestarting_magnetization. -
Spin–orbit — with
--soc, a non-collinear spin–orbit input is produced. -
Band count for PAOFLOW —
nbndis sized so that the extended basis can be projected. For each atom the number of extended orbitals is(l_max + 2)², wherel_maxis parsed from thePP_CHIchannels of the UPF. These are summed (and doubled for spin–orbit), andnbnd = max(nawf + 2, ceil(nawf × 1.15))An explicit
--nbndalways wins.
paoflow-gen-qe aflow:0a66d228d896a855 \
-p /path/to/PSEUDOS/nc-sr-05_pbe_standard_upf \
-o Bi.scf.inFor the bismuth example above this yields nbnd = 37; adding --soc doubles the
orbital count to nbnd = 74.
By default (--ibrav auto) the generator classifies the Bravais lattice of the
downloaded structure and writes a native Quantum ESPRESSO ibrav + celldm
input instead of a generic ibrav=0 cell. This produces cleaner inputs and lets
QE regenerate the conventional/primitive cell with full symmetry.
How it works:
- The
CONTCAR.relax.qecell (in Å or Bohr) is converted to lattice vectors and passed toqe_ibrav_from_latticeinPAOFLOW.inputs.lattice_format, together with AFLOW's pre-computed symmetry hints (Bravais_lattice_relaxand the space groupsg/spacegroup_relax) to disambiguate centred lattices. - The detector returns the
ibrav, thecelldmslots QE reads for thatibrav, and an integer cell mapMrelating the input cell to the QE convention. -
ATOMIC_POSITIONSare rewritten incrystalcoordinates of the QE cell viaf_qe = f_in · M⁻¹, and theCELL_PARAMETERScard is dropped. Only thecelldm(i)entries meaningful for the detectedibravare emitted (e.g.celldm(1)for cubic,celldm(1,3)for hexagonal). - Each fractional coordinate is wrapped into the minimum-image range
[-0.5, 0.5)rather than[0, 1). This keeps bonded atoms inside the home unit cell — e.g. the primitive-cell Si basis atom is written as-0.25 -0.25 -0.25instead of the equivalent0.75 0.75 0.75. The two are identical for an ordinary scf run, but a later U + V (eACBN0) calculation needs the bonded neighbour to sit in the home cell so its intersite-V neighbour search can find it. - All 20 supported
ibravvalues are covered (cubic1,2,3; hexagonal4; trigonal5; tetragonal6,7; orthorhombic8,9,-9,91,10,11; monoclinic12,-12,13,-13; triclinic14).
The detection is intentionally conservative — it never emits a wrong cell
silently. It falls back to the explicit ibrav=0 path whenever:
- the cell unit is something other than
angstrom/bohr(e.g.alat); - the lattice does not match any
ibravwithin--symprec; - the atom positions cannot be remapped (unsupported position units).
--symprec (default 1e-4) controls the tolerance of the lattice match; loosen
it for noisy/relaxed cells. --ibrav 0 disables detection entirely and restores
the original behaviour (explicit CELL_PARAMETERS copied verbatim).
Note:
-p/--pseudo-dirmust point at the folder containing the UPF files (plusPeriodicTableJSON.jsonandreference.json), not at an individual.upffile.
To help set up a later U + V (eACBN0) run, the generator also computes a
recommended intersite-neighbour cutoff directly from the structure and prints it
both to stderr and as a comment block at the top of the generated input:
! Suggested eACBN0 intersite V cutoff: 3.10 Angstrom
! nearest-neighbour distance: 2.35 Angstrom
! covers the first neighbour shell; use as V_CUTOFF /
! set_intersite_pairs(cutoff=...) in the PAOFLOW U+V driver.
The value is obtained by enumerating periodic-image distances between all atoms,
collapsing them into neighbour shells, and placing the cutoff midway between
the first and second shells so the intersite-V search captures exactly the
nearest-neighbour bonds. Feed it to V_CUTOFF in the generated paoflow-gen
driver (or directly to eACBN0.set_intersite_pairs(cutoff=…)); the value is in
Ångström, matching that API. The leading ! lines are QE comments and are
ignored by pw.x.
Starting from a finished Quantum ESPRESSO run (a <prefix>.save directory plus
the UPF used to produce it), this CLI asks a handful of questions and writes a
minimal, well-commented PAOFLOW main.py. It supports two workflows and can
additionally emit a matching plot.py.
paoflow-gen [-d WORKDIR] [options]The tool auto-detects the <prefix>.save directory, the UPF file, and the
prefix (from scf.in / nscf.in) inside the working directory; every detected
value can be overridden.
| Flag | Default | Description |
|---|---|---|
-d, --workdir
|
. |
Directory scanned for QE artifacts |
--prefix |
(auto) | QE prefix override |
--savedir |
(auto) |
<prefix>.save override |
--upf |
(auto) | Pseudopotential file override |
-o, --out
|
main.py |
Driver-script output path |
--plot |
off | Force generation of a plotting script (run workflow) |
--plot-out |
plot.py |
Plotting-script output path |
-f, --force
|
off | Overwrite existing output files |
Generates a self-consistent Hubbard U (ACBN0) or joint on-site U + intersite V (eACBN0) driver. The PAO projections use the minimal basis, as required by ACBN0. You are prompted for:
- whether to include intersite V (eACBN0) or stay on-site only (ACBN0);
- the projection scheme (default
ortho-atomic); - the U/V convergence threshold;
- one or more Hubbard manifolds and their initial U (e.g.
Si-3p 0.5); - (eACBN0 only) the intersite neighbour cutoff and initial V;
- the parallel launch commands and executable paths for
pw.x, the Python layer, and the Hartree step.
The generated script reconstructs the PAO band structure after convergence and prints the converged U (and V) values.
Generates a property-driver script. You pick properties from a menu:
| # | Property | PAOFLOW call(s) |
|---|---|---|
| 1 | Band structure | bands() |
| 2 | DOS / projected DOS | dos(do_dos, do_pdos) |
| 3 | Boltzmann transport | transport() |
| 4 | Fermi surface | fermi_surface() |
| 5 | Spin texture | spin_texture() |
| 6 | Spin Hall conductivity | spin_Hall() |
| 7 | Anomalous Hall / Berry curvature | anomalous_Hall() |
| 8 | Band topology (Berry, effective mass) | topology() |
| 9 | Optical / dielectric tensor | dielectric_tensor() |
Key behaviours:
-
Standard properties use the basis you choose (
minimal/standard/extended, defaultstandard). -
Optical properties require the non-local velocity correction and the
extended basis, so they are emitted as a separate
run_optical()function (a second PAOFLOW instance) within the same script. - Spin-dependent properties (spin texture, spin Hall) automatically insert the
required
spin_operator()call. - For
ibrav = 0, PAOFLOW needs an explicit band path; the script emitsBAND_PATH/HIGH_SYMTODOstubs for you to fill in.
All tunable quantities (energy windows, k-point density, smearing, FFT
interpolation grid, projectability threshold, …) are written as clearly-labelled
constants at the top of the generated main.py.
When you choose the full-property workflow, the generator offers to also write a
plotting script (or force it with --plot). The plot.py it produces:
-
Mirrors your property selection. Its menu lists only the properties you
selected when generating
main.py. -
Mimics the generator's CLI. It prints a numbered menu and accepts a
comma/space separated list (or
all) of plots to draw. -
Locates output files automatically by globbing the PAOFLOW
output/directory, so it adapts to whatever prefix your run used. -
Uses
PAOFLOW.GPAOfor all plotting.
| Selected property | Plot function | Output file(s) |
|---|---|---|
| Band structure | plot_bands |
*.bands_0.dat, *.kpath_points.txt
|
| DOS |
plot_dos (+ plot_pdos) |
*.dosdk_0.dat, *.pdosdk*
|
| Bands + DOS together | plot_dos_beside_bands |
bands + DOS files |
| Transport |
plot_electrical_conductivity, plot_seebeck
|
*.sigmadk_0.dat, *.Seebeck_0.dat
|
| Spin Hall | plot_shc |
*.shcEf*.dat |
| Anomalous Hall | plot_ahc |
*.ahcEf*.dat |
| Berry / topology |
plot_berry (+ plot_berry_under_bands) |
*.Omega_*.dat |
| Optical / dielectric | plot_dielectric |
epsi_*.dat, epsr_*.dat
|
| Fermi surface | (pointer) |
FermiSurf_*.bxsf → open in XCrySDen |
| Spin texture | (pointer) | spin-texture-bands.dat |
When both band structure and DOS are selected, the plot menu includes a
combined Bands + DOS (side by side) entry that uses
plot_dos_beside_bands, as recommended for this pairing.
Fermi surface and spin texture are not one-dimensional spectra, so rather than
producing a figure the script prints a pointer to the relevant data/BXSF file
(e.g. the XCrySDen command for the Fermi-surface .bxsf).
To support the property menu above, two methods were added to
PAOFLOW.GPAO.GPAO, built on the existing helpers as templates:
-
plot_ahc(fname, …)— anomalous Hall conductivity vs. energy. Accepts a singleahcEf_{ij}.datfile or a list of tensor components to overlay (modeled onplot_shc). -
plot_dielectric(fname, …)— optical/dielectric spectra vs. energy (epsi_*,epsr_*,eels_*,sigmar_*, …). Accepts a single file or a list to overlay several spectra (modeled onplot_dos/plot_shc).
Both follow the existing convention of reading the two-column .dat output with
read_dos_PAO and delegating to the shared plotting primitives.
# 1. Build a QE scf input from an AFLOW entry.
paoflow-gen-qe aflow:0a66d228d896a855 -p ./PSEUDOS -o Si.scf.in
# 2. Run pw.x (scf, then nscf) to produce Si.save/ … (external step)
# 3. Generate a PAOFLOW driver + matching plot script.
paoflow-gen -d . -o main.py --plot-out plot.py
# → choose "run", select e.g. bands, DOS, transport, optical …
# 4. Run PAOFLOW.
mpirun -np 4 python main.py
# 5. Visualize the results.
python plot.py # pick what to plot from the menu