# Negative band gap in DFT calculations

I am performing DFT simulation (with Quantum Espresso) for a large number of crystalline materials to estimate their band gap energies. I am getting negative band gap values for many of them (difference between the lowest unoccupied level and the highest occupied level is negative). While I am aware that this is because of overlapping valence and conduction bands which is the case for metals, this also occurs for nonmetals with nonzero ground truth band gap energies. Could this be attributed to the underestimation issue of DFT methods in estimating the band gaps as highlighted by many studies?

An example of the output produced by Quantum Espresso for a crystal.

 highest occupied, lowest unoccupied level (ev):     8.9114    8.5647


As a follow-up, I would also like to know if the number of bands of a crystal, which is an input parameter to DFT (nbnd in Quantum Espresso's pw.x) can be determined analytically for any material. At the moment, I am just using a high value of 256 for all crystals - it works in most cases when compared to lower values. So I was wondering if DFT is very sensitive to this parameter and could lead to more incorrect and negative band gaps if an inexact number of bands is provided.

Some materials erroneously give a metallic state even if it isn’t. Depending on what type of material and exchange-correlation functional you use, this can be more or less likely to happen. With transition metals often you need a Hubbard U or hybrid functional. Other small gap semiconductors might also need hybrid functionals.

In QE it will automatically determine the number of bands, so you usually don’t have to set it. You can find it yourself with the number of electrons / 2 in the spin unpolarized case, or if there’s spin then it’s the number of electrons. This number gives you the number of occupied states, but often a few empty states will be included too so you can get the band gap and also some of the scf convergence algorithms can perform better with some empty states (for instance QE recommends 20% more bands for a metal, so if you use the default number of bands it will usually add some extra ones).