This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org
Viv Python

Engines · dft-bands

Band structure of a crystal, from a POSCAR, a CIF or a pw.x input

Give it a crystal in a format you already have. It finds the primitive cell, writes the same kind of input file the DFT program runs from, and computes the self-consistent LDA band structure in your browser. Silicon takes about eight seconds.

Examples
Drop a file here, or paste one below

What it takes and gives

The engine is engines/dft-bands.viv, 125 lines of Viv that run dft/pwdft_it. Its header says what it takes and gives:

#! engine dft-bands
#! title Band structure of a crystal, from a POSCAR, a CIF or a pw.x input
#! program dft/pwdft_it
#! input crystal: poscar | cif | qe-pw | xyz+cell
#! input settings: ecut, kmesh, smearing, bands (defaults from dft/ref/materials.py)
#! output bands, total-energy
#! limit tab: fcc lattices, up to 8 atoms, an estimated 90 s of compiled wasm; larger runs natively with dft/run.sh
#! validated si: dft/si_it_check.viv
#! validated gaas: dft/gaas_it_check.viv
input
crystal: poscar | cif | qe-pw | xyz+cell
input
settings: ecut, kmesh, smearing, bands (defaults from dft/ref/materials.py)
output
bands, total-energy
limit
tab: fcc lattices, up to 8 atoms, an estimated 90 s of compiled wasm; larger runs natively with dft/run.sh
validated
si: dft/si_it_check.viv
validated
gaas: dft/gaas_it_check.viv

What happens to your file

  1. An input reader parses it (www/src/lib/engines/formats/): a POSCAR’s scale and species line, a CIF’s cell parameters and symmetry operations, a pw.x input’s ibrav, celldm and cards, an extended XYZ’s Lattice. Each gives the same thing, a cell and atoms in it.
  2. The crystal is reduced to the engine’s cell. Every translation that maps the structure onto itself is found, which is how an 8-atom cubic cell or a supercell reveals the 2-atom primitive one. The lattice must be face-centered cubic, because the engine’s k-mesh and band path are. It is rotated into dft/’s orientation and the atoms are centered the way dft/ref/materials.py places them.
  3. The input file is written as dft/ref/make_deck.py writes one: pseudopotentials from CP2K’s table, picked as dft/pseudo/make_pseudo.py picks them, and the cutoff, k-mesh, smearing and band count materials.py measured. Silicon from any of the four formats gives dft/si.viv character for character.
  4. It runs. Compiled, the engine is one WebAssembly module for every input: it was built from the program with silicon’s input in place, plus a loader that replaces every input variable, by name, with the one the page hands it on standard input. Interpreted, viv.wasm reads the program with your input pasted in.

The cost estimate is a model with one constant fitted to the compiled engine on dft/’s five tab-sized materials: time grows with the bands, the FFT grid and the k-points. It lands within 20% of the time measured on those five, and predicts copper at 172 s where the compiled module took 258 s, so treat it as a rough guide. A crystal estimated above 90 s is not offered here.

How it is checked

Every example input is compared with dft/’s own, and when it is identical the run is compared with the numpy reference stored in that material’s check file: the total energy to 10−7 hartree and every band at every one of the 61 path points to 10−5 eV, the tolerances dft/’s tests use. The engine computes the difference itself and prints it. These are the last recorded runs:

inputreference inputenergy error, Haworst band error, eVseconds
si.poscar, compileddft/si.viv1.6e-125.8e-78.6
si.cif, compileddft/si.viv1.6e-125.8e-78.8
si.pw.in, compileddft/si.viv1.6e-125.8e-78.6
si.xyz, compileddft/si.viv1.6e-125.8e-78.3
gaas.poscar, compileddft/gaas.viv9.3e-132.9e-612.1
gaas.cif, compileddft/gaas.viv9.3e-132.9e-611.7
gaas.pw.in, compileddft/gaas.viv9.3e-132.9e-611.9
si.poscar, interpreteddft/si.viv1.6e-125.8e-721.5
gaas.cif, interpreteddft/gaas.viv9.3e-132.9e-636.1

Seconds are timings under Node.js on the machine that ran the tests; a browser tab is usually a little slower. The input readers have their own tests: every example, all six materials of materials.py written as shifted POSCARs, silicon written four other ways, and inputs that must be refused, each with its reason.

The GTH pseudopotential parameters are CP2K's GTH_POTENTIALS table as PySCF ships it (Goedecker, Teter and Hutter 1996; Hartwigsen, Goedecker and Hutter 1998); only the numbers are used, no CP2K or PySCF code.

What it does not do