mstar calculates band-resolved effective mass tensors from density-functional-theory momentum (velocity) matrix elements using degenerate k·p perturbation theory.
Supported electronic-structure codes:
mstar is written in Fortran and is intended for Linux-based systems. The method and its validation for WIEN2k are described in Comp. Phys. Commun. 261, 107648 (2021).
The master branch is the reference version. Every output file records the Git revision of the build in its first header line, and the same revision is printed at the start and end of each run. Please report results together with that revision.
VASP results obtained with versions before November 2026 should be recalculated. Earlier versions read EIGENVAL with a fixed VASP 5 format, which truncated the eigenvalues to 0.01 eV for files written by VASP 6.4.3 (and possibly other VASP 6 versions), and they omitted the couplings of band NBANDS_CDER to all higher bands. WIEN2k results of earlier versions are not affected, apart from rounding in the last digits. See Changes for details.
Clone the repository:
git clone https://github.com/rubel75/mstar
cd mstarThe makefile is set up for the Intel Fortran compiler (ifort) and Intel MKL, and requires the environment variable MKLROOT. Settings for GNU Fortran with MKL or OpenBLAS, and a debugging build, are included as commented lines. With oneAPI 2025 or later, use ifx (make FC=ifx). Compile with:
makeUseful build targets are make clean (object and module files) and make veryclean (also the executable and the generated version_mod.f90). Only a Fortran compiler and a LAPACK library are required.
mstar needs momentum (WIEN2k) or velocity (VASP) matrix elements between all pairs of bands at each k-point, from a calculation with plenty of empty bands. Step-by-step instructions are available on the Wiki:
- Writing of matrix elements is not the default. In
case.inop, changeOFFtoONin the lineON ON/OFF writes MME to unit 4. - Include empty states up to about 5 Ry above the Fermi energy: increase
deincase.in1(c)and, with spin-orbit coupling (SOC),Emaxincase.inso. SetEmaxincase.inopto at least the same value. - The band range of
case.mommat2must start at band 1 (NEMIN = 1). If it does not, there are valence states belowEminofcase.inop. LowerEminin that case (e.g., to -8 Ry). - Only the free format of
case.mommat2written by WIEN2k v20.1 and later is supported. For older WIEN2k versions, use an older release of mstar. - For states with strong d character, high-energy local orbitals (HELOs) may be needed to converge the masses (see the CuI example in the reference).
- Use
LOPTICS = .TRUE.andLPEAD = .FALSE.. WithLPEAD = .TRUE., the derivatives are obtained by finite differences on the k-point mesh, which is usually too coarse for effective masses. - Increase
NBANDS(at least three times the number of occupied bands as a starting point) and test the convergence. - GW PAW potentials are recommended, since they describe the high-energy empty states entering the perturbation sums better.
WAVEDERandEIGENVALmust come from the same calculation and must be in the same directory.
The masses converge slowly with the number of empty bands, in particular for weakly dispersive bands (e.g., the longitudinal conduction-band mass of Si) and for states with d character. The number of bands, the energy range of the matrix elements, and, in WIEN2k, the local orbitals must be convergence-tested for each material.
mstar MATRIX_FILE [TOLERANCE] [--nbmax N]MATRIX_FILEiscase.mommat2,case.mommat2up, orcase.mommat2dnfor WIEN2k, orWAVEDER(orWAVEDERF) for VASP. The file may be given with a path. VASP is recognized by the file name.EIGENVALis read from the same directory asWAVEDER, and the binaryWAVEDERis read whenWAVEDERFis given.TOLERANCE(optional) is the degeneracy energy tolerance in Ha (default1e-6). Adjacent bands whose energies differ by no more than this value are treated as degenerate (see Degenerate bands).--nbmax N(optional, anywhere on the command line) restricts the output to bands 1 to N. In VASP, the output is limited to theNBANDS_CDERbands ofWAVEDERin any case. All bands still enter the perturbation sums, so the masses of the bands written do not change. A degenerate block cut by N is excluded. This avoids writing masses of high-lying bands, which are not converged with respect to the number of empty states.
The built-in help is displayed with mstar --help.
Examples:
# WIEN2k
/path/to/mstar/mstar case.mommat2
/path/to/mstar/mstar case.mommat2up 1e-5 --nbmax 60
# VASP
/path/to/mstar/mstar WAVEDER
/path/to/mstar/mstar /path/to/calculation/WAVEDER 1e-5WIEN2k (v20.1 and later) also includes a version of mstar that is run as x mstar [-up/-dn] [-settol 1.0e-5]. That version does not contain the changes listed under Changes.
In spin-polarized WIEN2k calculations, and in WIEN2k calculations with SOC (which are run as spin-polarized for the OPTIC step, see the Wiki), each case.mommat2up/dn file is processed in a separate run. A spin-polarized VASP WAVEDER is processed in one run.
The inverse effective mass tensor of band n follows from second-order k·p perturbation theory [Eq. (5) of the reference],
where α, β are Cartesian directions,
The general form of the first term is $(m_0/\hbar^2)\langle u_n | \partial^2 \hat{H}\mathbf{k} / \partial k\alpha \partial k_\beta | u_n \rangle$, and the momentum operator in the sum is, more generally, the velocity operator
-
WIEN2k (
OPTIC) provides momentum matrix elements. For a local potential (LDA, GGA, TB-mBJ), momentum and velocity matrix elements coincide, and the first term is exactly$\delta_{\alpha\beta}$ . -
VASP (
WAVEDER) provides derivative overlaps that include the nonlocal PAW terms, so the matrix elements in the sum are velocity matrix elements. The conventions are documented inread_mommat_pij_vasp_mod.f90. The phase of the matrix elements does not affect the effective masses.
See Limitations for the consequences.
For a block D of degenerate bands, mstar constructs for every tensor component αβ the Hermitian matrix [Eq. (6) of the reference]
and the inverse masses of the block are
Bands are grouped into blocks at every k-point by chaining adjacent bands whose energies differ by no more than the tolerance (as in BerryCPT). Eigenvalues of states that are degenerate by symmetry differ slightly for numerical reasons, and treating them as non-degenerate leads to large errors through the energy denominators. Inspect the eigenvalues of the states that should be degenerate (e.g., the top valence bands of GaAs at Γ) and set the tolerance slightly above their spread. The approach is stable as long as the block is well separated from other bands compared with the tolerance.
The six matrices minv_ij.dat then combines values that belong to different states, and a mass tensor cannot be assigned to an individual band (band warping, e.g., heavy and light holes) [Phys. Rev. B 93, 205147 (2016), Sec. III].
For every block, mstar evaluates
where # non-commuting block, and minv_ij.dat also gives r. Which values of a marked block can be used is explained under Limitations.
-
WIEN2k, nonlocal potentials. A nonlocal potential adds
$i[\hat{V}_\mathrm{NL}, \hat{\mathbf{r}}]$ to the velocity operator, which WIEN2k does not provide. Hybrid functionals are therefore not supported (with momentum matrix elements, the masses would be systematically too heavy, by about 25% for YS-PBE0). No problems were observed for DFT+U. - WIEN2k, spin-orbit coupling. With SOC, the matrix elements are taken between spinor states, but the spin-orbit correction to the velocity operator itself is not included.
-
VASP, free-electron term. The VASP PAW Hamiltonian contains nonlocal projectors that depend on k. The velocity matrix elements in
WAVEDERinclude their first derivative. The second derivative $\langle u_n | \partial^2 \hat{V}\mathrm{NL} / \partial k\alpha \partial k_\beta | u_n \rangle$ and the related terms of the PAW overlap operator are not available and are approximated by$\delta_{\alpha\beta}$ [see Phys. Rev. B 93, 205147 (2016)]. Effective masses obtained with VASP have agreed well with WIEN2k results in our comparisons, which suggests that this approximation is minor for the systems studied so far.
Only the bands available in the input enter the sums, and core states are not included. The masses converge slowly with the number of empty bands, in particular for weakly dispersive bands and for states with d character (see Convergence). Masses of bands near the top of the available range are not converged, and --nbmax can be used to omit them.
In a degenerate block, each tensor component αβ has its own effective matrix # non-commuting block (see Band warping). For their records:
- the diagonal components xx, yy, zz in
minv_ij.datare the inverse masses along the Cartesian axes, labelled by ascending order, - the off-diagonal components yz, xz, xy, and the values in
minv_c.dat,minv_pr.dat, andminv_d.dat, are not defined for individual bands. A record ofminv_ij.datmust not be treated as a tensor, e.g., to obtain principal axes, mass ellipsoids, DOS masses, or masses along directions other than x, y, z, since the result depends on the ordering and on the Cartesian frame, - the band index inside a block labels the ascending order of each component, not a state, so following one band index across k does not follow one state.
Well-defined alternatives are the block average of a component,
Degenerate perturbation theory assumes that the degeneracy is not lifted at first order in k, i.e., that the bands of a block have zero velocity at k within the block. At points where bands cross linearly (e.g., Weyl or multifold fermions, such as CoSi at Γ), the dispersion is not quadratic, and the masses of these blocks do not describe it.
The blocks depend on the tolerance. A tolerance that is too small leaves states that are degenerate by symmetry in separate blocks and leads to large errors through the energy denominators. A tolerance that is too large merges states that are split by a small but real amount. Near band crossings, the results may therefore change with the tolerance.
minv_c.dat and minv_d.dat are derived from the tensor of each band. The geometric average in minv_d.dat is of limited use when the principal components have different signs (marked # hyperbolic dispersion).
Output files (with the suffix -up/-dn for spin-polarized calculations):
| File | Content |
|---|---|
minv_ij.dat |
components of the inverse effective mass tensor m0/m*_ij (xx, yy, zz, yz, xz, xy) |
minv_c.dat |
conductivity inverse effective mass m0/m*_c = (1/3) Tr(m0/m*_ij) |
minv_pr.dat |
principal components (eigenvalues) of m0/m*_ij |
minv_d.dat |
density-of-states inverse effective mass m0/m*_d = m0/(m_1 m_2 m_3)^(1/3), signed |
All values are dimensionless inverse masses in units of 1/m0. Each k-point block starts with
# KP: k NBCDER: Nout NEMAX: Nbands
where k is the k-point index in the order of the input file, Nout is the last band written, and Nbands is the number of bands at that k-point. Each record starts with the band index and the ID of the degenerate block (numbered from 1 at each k-point), followed by the values. Annotations follow a # at the end of a record (# non-commuting block, and # hyperbolic dispersion in minv_d.dat when the principal components have different signs, where the geometric average is of limited use). The files can therefore be read directly by gnuplot or numpy.loadtxt. Every file has a header that describes its content.
Before the calculation, mstar prints an estimate of the memory needed for the matrix elements (all k-points for VASP, one k-point for WIEN2k, which is read one k-point at a time). About 2 MiB of program and library overhead come on top of it.
Existing output files are replaced. The input is checked before the output files are opened, so a run that stops on unusable input does not overwrite the results of a previous run. All errors terminate with a nonzero exit status.
The script utils/dat2csv.sh combines band energies along a WIEN2k band-structure path with selected mass components into a CSV file.
The folder test_files contains regression tests for WIEN2k and VASP (CoSi with spin-orbit coupling), including the DFT input files and the calculation details in the etc folders. After compiling, run
test_files/run_tests.shSee test_files/README.md for details. The results agree with the reference outputs up to rounding in the last digits, which depends on the compiler and the LAPACK library (tested with gfortran and reference LAPACK, and with Intel Fortran and MKL).
If you find the results useful and publishable, please cite:
- O. Rubel, F. Tran, X. Rocquefelte, and P. Blaha, "Perturbation approach to ab initio effective mass calculations", Comp. Phys. Commun. 261, 107648 (2021)
together with the Git revision printed by mstar. Examples of applications can be found in the reference (arXiv:2007.03816). Please communicate feedback, support, or feature requests via the WIEN2k mailing list.
Corrections:
- VASP:
EIGENVALwas read with a fixed VASP 5 format. For files written by VASP 6.4.3 (and possibly other VASP 6 versions), with a wider band-index field, the eigenvalues were truncated to 0.01 eV. This corrupted the energy denominators and could merge non-degenerate states into false degenerate groups.EIGENVALis now read in free format. - VASP: the couplings of band
NBANDS_CDER(the last band with derivative matrix elements inWAVEDER) to all higher bands were omitted, which affected that band and the bands degenerate with it. - Errors now terminate with a nonzero exit status.
Numerics:
- The band sums are accumulated in double precision with compensated summation, and all matrices are diagonalized in double precision. Values are written with 7 significant digits. The code no longer uses OpenMP, and the results do not depend on the summation order of a parallel run.
- For numerically near-degenerate states inside a block, the effective matrix uses the average of the inverse energy differences, which keeps it Hermitian. For exactly degenerate states the result is unchanged.
Degenerate bands and output:
- Each record gives the ID of the degenerate block after the band index. Scripts that read the output by column need to account for the extra column (
utils/dat2csv.shis updated). - Blocks are formed by chaining adjacent bands within the tolerance (previously, all bands of a block had to lie within the tolerance of its first band).
- Blocks whose tensor components do not commute are marked
# non-commuting block(see Degenerate bands). - Annotations are written as trailing
#comments (warning: hyperbolic dispersionbecame# hyperbolic dispersion). - The Git revision of the build is written to all output files and to the screen.
Input and interface:
- New option
--nbmax N. - VASP and WIEN2k input is read with the routines of BerryCPT. Only the rows of the target bands are stored. WIEN2k files are read in a single pass. The VASP eigenvalues are kept in double precision.
- The input file may be given with a path. For VASP,
EIGENVALis read from the directory ofWAVEDER. - The input is checked before the output files are opened.
- A memory estimate is printed for WIEN2k as for VASP.
- Regression tests in
test_files.
- October 13, 2021
- March 24, 2021 (gfortran compatibility)