4. Common Keywords

This section discusses several settings that are common for all calculations. Some of them are explained in more detail in later chapters.

4.1. General Settings

4.1.1. JOB

Each Spex run needs a job definition, which defines what Spex should do, e.g., JOB GW 1:(1-5) for a GW calculation of the specified set of bands. The available jobs are

  • GW - GW method
  • HF - Hartree-Fock method
  • PBE0 - PBE0 hybrid functional
  • SX - Screened exchange
  • COSX - Coulomb-hole screened-exchange (COHSEX)
  • GT - GT method
  • GWT - GW and GT combined
  • HFENE - Total Hartree-Fock exchange energy
  • RPAENE - RPA correlation energy
  • SUSCEP - Susceptibility (Polarization function)
  • SUSCEPR - Renormalized susceptibility (RPA or Bethe-Salpeter)
  • DIELEC - Dielectric function
  • SCREEN - Screened interaction
  • SCREENW - Screened interaction projected onto Wannier basis
  • KS - Single-particle energies (e.g., KS energies)

Details of these jobs are explained in subsequent sections. The job definition must not be omitted but may be empty: JOB, in which case Spex will just read the wavefunctions and energies, perform some checks and some elemental calculations (e.g., Wannier interpolation), and stop.

The job KS is included only for convenience. When given, Spex simply writes the single-particle energies (e.g., KS energies), read from the input data, to the output in the standard format, similar to the output of GW or HF values.

In principle, Spex supports multiple jobs such as JOB GW 1:(1-5) DIELEC 1:{0:1,0.01}. This feature is, however, seldom used and is not guaranteed to work correctly in all versions.

JOB COSX 1:(1-5) Perform COHSEX calculation.
JOB COSX 1:(1-5) SCREEN 2:{0:1,0.01} Subsequently, calculate the screened interaction on a frequency mesh.
JOB Just perform some checks and stop.

4.1.2. BZ and WRTKPT

There are only two keywords that must not be omitted from the input file. The first is JOB, the second BZ, which defines the k-point set for the sampling of the Brillouin zone. The keyword requires four integer arguments, BZ l m n, defining an \(l\times m\times n\) k-point set. If the keyword WRTKPT is set (or, alternatively, with the command line option spex -w), Spex uses the BZ definition to construct the irreducible wedge of the k-point set and writes the respective list of k points to a file, which is then read by the DFT code.

BZ 8 4 2. Define a \(8\times 4\times 2\) k-point sampling.

4.1.3. MEM

Calculations based on many-body perturbation theory are costly, not only in terms of computation time but also in terms of memory. Since the problem sizes (e.g., number of atoms) are thus effectively restricted by the memory hardware of the computer, the latter constitutes in some ways a more serious limit than the computation time the user can afford to invest. Therefore, an upper limit for the memory that Spex is allowed to use can be defined with the keyword MEM x with x in MB. The default is MEM 1000. In parallel Spex, the value would correspond to the upper limit per (physical) node. If possible, Spex will divide the work load into packets in such a way that the memory usage stays below the limit. (Actually, Spex might use a bit more memory than specified.)

MEM 2000 Restrict memory usage to 2GB (Default: 1GB).


Spex reads wavefunctions and energies as a first step. In general, these have to be stored for all k vectors in the set (e.g., for all 64 points of a \(4\times 4\times 4\) set), filling up a lot of memory. This can be restricted to the irreducible zone (only eight points in the example) with the keyword STOREIBZ. Spex then regenerates the wavefunctions on equivalent k points on the fly. This might slow down the calculation but is more economical with computer memory.

4.1.5. –enable-load

(*) Another possibility to reduce the memory consumption is to reconfigure (and recompile) the code with the option --enable-load (or recompile with the flag -DLOAD in the Makefile). With this option, Spex stores the wavefunctions in memory only temporarily and rereads them from harddisc whenever they are needed. Obviously, this requires a fast harddisc and network connection. The HDF5 library is used for the data transfer. There is no possibility to set the option in the input file because it strongly affects the way the wavefunction data is handled in the code.

4.1.6. RESTART

This is an important keyword. It enables (a) continuing a calculation that has, for some reason, stopped or crashed and (b) reusing data of a previous calculation. If specified, Spex will store intermediate results in a file or read them if the particular data is already present in the file. Even if RESTART was not specified in the first run, Spex might still be able to reuse data from a previous run with RESTART 2. (This option usually gives less freedom for a change of parameters.) It depends on the particular job definition whether RESTART and/or RESTART 2 are available and how they work. See below for details.

RESTART Read/write restart file.
RESTART 2 Try to reuse data from standard output files.

(*) We will come back to this keyword in the tutorials. Here, we give a more detailed explanation as reference.

Spex writes several files to harddisc during the program run (see Section 3.3 for details): “spex.cor”, “spex.cot”, “spex.ccou”, “spex.mb”, “spex.core”, “spex.sigx”, “spex.sigc”, “spex.sigt”, “spex.wcou”, “spex.uwan”, “spex.kolap”, as well as several files containing spectra (“suscep”, “dielec”, etc.) and a file “<KS>” containing the KS wavefunctions. (The name of the latter depends on the DFT program used.)

In addition to the arguments 1 and 2, described above, the keyword RESTART can be given with a general five-digit integer number, e.g., 32233, which explicitly specifies which files should be read and/or written. (The first digit is optional. It is interpreted as 0 if omitted.) The digits can be 0 (don’t read and don’t write), 1 (read but don’t write), 2 (write but don’t read), and 3 (read and write). The following table shows to which file(s) each digit refers to.

spectra files1
Don’t read, don’t write 0 0 0 0 0
Read but don’t write 1 1 1 1 1
Write but don’t read 2 2 2 2 2
Read and write 3 3 3 3 3

1The spectra files and “spex.core” are always written.

The arguments 1 and 2 correspond to 32233 and 33333, respectively. The default (i.e., without RESTART) is 02200.

When using MPIKPT in a parallel calculation, the restart data is written to multiple files: “spex.sigx”, “spex.sigx.2”, “spex.sigx.3”, etc. (accordingly for “spex.sigc”) as well as “spex.cor.1”, “spex.cor.2”, etc. In the latter case, there is also a directory “spex.cor.map” containing, for each k point, links to the respective cor file. Whenever restart files need to be copied, make sure that all files (including the directory) are copied. Apart from that, Spex will always manage to read the correct data, independently of whether the calculation is in parallel or serial, with or without MPIKPT.


The RESTART option is a powerful tool. It is not only of practical importance due to the possibility of restarting calculations or reusing data of previous calculations. It also gives the user a lot of freedom to taylor calculations, for example, using different k-point sets (or different numbers of bands, etc.) for G and W. However, this freedom comes with the risk that calculations are performed with inconsistent data. Spex has only limited capabilities to catch such inconsistencies. The user should be aware of that.


Most job types require the calculation of the Coulomb matrix (with respect to the mixed product basis). The Coulomb matrix is k dependent. By default, Spex pre-calculates the Coulomb matrices for all k and stores them in memory. However, this can be quite memory-demanding (especially for large k-point sets). Therefore, the keyword NOSTORE (section COULOMB) avoids the storage of all Coulomb matrices. Instead, at any given time, only one Coulomb matrix is stored in memory. This keyword is recommendable in particular for parallel runs (due to a rather inefficient parallelization of calculations without NOSTORE.)

4.2. Input data

Spex needs data from a previous self-consistent solution of a mean-field system (e.g., KS-DFT). Several keywords can be used to analyze, check, and modify the input data.

4.2.1. NBAND

The Green function involves a summation over electronic bands, as do the polarization function [Eq. (5)] and the self-energy. The convergence with respect to the number of bands is a very important aspect in calculations based on many-body perturbation theory. The keyword NBAND n sets the number of bands to n. Obviously, n must not be larger than the number of bands provided by the input data. It should be noted that the actual number of bands can differ from n and also from k point to k point because Spex makes sure that degenerate subspaces are not cut in order to avoid symmetry breaking. If n is a real number (i.e., if it contains a decimal point: 3.0), it is interpreted as the maximal band energy. Then, all bands up to this energy are included. This is helpful if one wants to use a single parameter for calculations with differently sized unit cells. For example, when the unit cell doubles, one would have to include twice as many bands to reach the same accuracy, while the maximal band energy (practically) remains unchanged. If NBAND is unset, all available bands are used.

NBAND 100 Use 100 bands per k point.
NBAND 3.0 Use all bands up to 3 Hartree.
NBAND 50.0eV Use all bands up to 50 eV.

4.2.2. CORESOC

By default, Spex averages over the SOC-splitted states. For example, the two states 2p1/2 and the four states 2p3/2 are averaged to give the six quasi-non-relativistic states of the 2p shell (or the three spin-up 2p states and the three spin-down 2p states in the case of spin polarization). Then, all core states of a given shell have the same energy and the same radial form of the wavefunction. The averaging procedure can be avoided by specifying CORESOC. The SOC-splitted states and the different energies and wavefunctions are then retained and taken into account in the calculations of the self-energy, polarization function, et cetera. In the case of spin polarization, the Weiss field gives rise to further lifting of degeneracies. Spex calculates the respective new splittings, energies, and wavefunctions. For reference, the core-state energies are written to the output file. Usually, the effect of CORESOC is numerically small, but it still might play an important role for GW calculations in the case of very small band gaps.


(*) The set of wavefunctions read from harddisc can be checked in terms of their orthonormality and continuity (mismatch) at the muffin-tin (MT) boundary with the keywords CHKOLAP and CHKMISM, respectively. The former test gives a value for the deviation from exact orthonormality. The smaller the value, the better the condition of orthonormality is fulfilled. If the deviation is too large, the program stops. The second keyword yields, for each k point, the average and maximal MT mismatch of the wavefunctions. If any of these tests yield too large errors, there could be a problem with the read-in process or with the data written by the DFT code. The developers should be informed in this case.

4.2.4. MTACCUR

(*) The LAPW method relies on a partitioning of space into MT spheres and the interstitial region. The basis functions are defined differently in the two regions, interstitial plane waves in the latter and numerical functions in the spheres with radial parts \({u(r)}, {\dot{u}(r)=\partial u(r)/\partial\epsilon}\), \({u^\mathrm{LO}(r)}\) and spherical harmonics \({Y_{lm}(\hat{\mathbf{r}})}\). The plane waves and the angular part of the MT functions can be converged straightforwardly with the reciprocal cutoff radius \({g_\mathrm{max}}\) and the maximal l quantum number \({l_\mathrm{max}}\), respectively, whereas the radial part of the MT functions is not converged as easily. The standard LAPW basis is restricted to the functions \({u}\) and \({\dot{u}}\). Local orbitals \({u^\mathrm{LO}}\) can be used to extend the basis set, to enable the description of semicore and high-lying conduction states. The accuracy of the radial MT basis can be analyzed with the keyword MTACCUR e1 e2 which gives the MT representation error [Phys. Rev. B 83, 081101] in the energy range between e1 and e2. (If unspecified, e1 and e2 are chosen automatically.) The results are written to the output files “spex.mt.t” where t is the atom type index, or “spex.mt.s.t” with the spin index s(=1 or 2) for spin-polarized calculations. The files contain sets of data for all l quantum numbers, which can be plotted separately with gnuplot (e.g., plot "spex.mt.1" i 3 for \({l=3}\))

MTACCUR -1 2 Calculate MT representation error between -1 and 2 Hartree.
MTACCUR Automatic energy range.


(*) This keyword lets Spex analyze the orbital character of the wavefunctions. The results are given, first, in the form of a table in the output file containing the orbital decomposition for each eigenstate and, second, as projected density-of-states (DOS) plots in the files “spex.dos.NNN” (where NNN is a three-digit running index). As the table can be very large, there is a possibility to choose the atom type index at whose spheres the analysis is to be performed.

BANDINFO Calculate orbital decomposition and DOS plots.
BANDINFO 2 Restrict the orbital-decomposition table to atom type 2.

4.2.6. ENERGY

(*) In some cases, it may be necessary to replace the energy eigenvalues, provided by the mean-field (DFT) calculation, by energies (e.g., GW quasiparticle energies) obtained in a previous Spex run, for example, to determine the GW Fermi energy or to perform energy-only self-consistent calculations. This can be achieved with the keyword ENERGY file, where “file” contains the new energies in eV. The format of “file” corresponds to the output of the spex.extr utility: spex.extr g spex.out > file. It must be made sure that “file” contains energy values for the whole irreducible Brillouin zone. Band energies not contained in “file” will be adjusted so that the energies are in ascending order (provided that there is at least one energy value for the particular k point).

ENERGY energy.inp Replace the mean-field energy eigenvalues by the energies provided in the file “energy.inp”.

4.2.7. DELTAEX

(*) This keyword modifies the exchange splitting of a collinear magnetic system, i.e., it shifts spin-up and spin-down energies relative to to each other so as to increase or decrease the exchange splitting. With DELTAEX x, the spin-up (spin-down) energies are lowered (elevated) by x/2. The parameter x can be used to enforce the Goldstone condition in spin-wave calculations [Phys. Rev. B 94, 064433 (2016)]

DELTAEX 0.2eV Increase the exchange splitting by 0.2 eV (spin-up/down energies are decreased/increased by 0.1 eV)

4.2.8. PLUSSOC

(*) With this keyword, Spex adds spin-orbit coupling (SOC) to the mean-field solution using a one-shot second-variation approach and stops, so it is non-iterative but updates the wavefunctions and energies. The new energies are written to standard output and, together with the new wavefunctions, to new input files on the harddisc, thus overwriting the old input data. In the case of Fleur, the modified files are “gwa”, “KS.hdf”, and “spex.sym”. The latter is written only if the system is spin polarized (non-collinear magnetism). It has the same form as “sym.out”. Spex reads the file “spex.sym” if it exists and “sym.out” otherwise. After the PLUSSOC calculation, a subsequent Spex run will read the new input data, now including SOC. (The keyword PLUSSOC must be removed for this new run, otherwise Spex stops with an error, since it cannot add SOC to a solution that contains it already.)

A possible application of this feature is to add SOC corrections to GW quasiparticle energies, already calculated. To this end, store the GW energies to a file using the “spex.extr” utility (example: spex.extr g spex.out > energy.inp). Then, tell Spex to replace the single-particle energies (that it reads from the input data) by the ones from the file (“energy.inp”) with the keyword ENERGY (ENERGY energy.inp, see Section 4.2.6) and add PLUSSOC. In a subsequent run, Spex will apply the SOC operator to the GW quasiparticle energies using a second-variation technique, write the corrected energies to the output, and write the new input data files. The latter can be used in a subsequent Spex run, for example, to calculate a Wannier-interpolated band structure, containing GW quasiparticle and SOC corrections. From a theoretical point of view this approach is a bit inconsistent [Phys. Rev. B 88, 165136 (2013)], but it is considerably faster than running GW with SOC from the start. Besides, the latter approach is currently not applicable to systems with noncollinear magnetism. So, using the present procedure with PLUSSOC is the only viable approach for this case.

4.2.9. ITERATE

(*) If ITERATE is specified, Spex only reads the LAPW basis set from the input data, provided by the mean-field (DFT) code, but performs the diagonalization of the Hamiltonian at the k points itself. This calculation effectively replaces the second run of the DFT code. In this sense, the name of the keyword is a bit misleading, as the calculation is non-iterative. The keyword ITERATE is mostly intended for testing and debugging. It is not available for executables compiled with -DLOAD (configured with --enable-load).

ITERATE NR Diagonalize a non-relativistic Hamiltonian.
ITERATE SR Use scalar-relativity.
ITERATE FR Also include SOC.
ITERATE SR -1 Diagonalize scalar-relativistic Hamiltonian and neglect eigenvalues below -1 htr.
ITERATE FR STOP Diagonalize relativistic Hamiltonian (including SOC), then stop.