Maximally-localized Wannier functions (MLWFs) are a powerful and broadly used
tool to characterize the electronic structure of materials, from chemical
bonding to dielectric response to topological properties. Most generally, one
can construct MLWFs that describe isolated band manifolds, e.g. for the valence
bands of insulators, or entangled band manifolds, e.g. in metals or describing
both the valence and the conduction manifolds in insulators. Obtaining MLWFs
that describe a target manifold accurately and with the most compact
representation often requires chemical intuition and trial and error, a
challenging step even for experienced researchers and a roadblock for automated
high-throughput calculations. Here, we present a very natural and powerful
approach that provides automatically MLWFs spanning the occupied bands and
their natural complement for the empty states, resulting in Wannier Hamiltonian
models that provide a tight-binding picture of optimized atomic orbitals in
crystals. Key to the success of the algorithm is the introduction of a
projectability measure for each Bloch state onto atomic orbitals (here, chosen
from the pseudopotential projectors) that determines if that state should be
kept identically, discarded, or mixed into a disentangling algorithm. We
showcase the accuracy of our method by comparing a reference test set of 200
materials against the selected-columns-of-the-density-matrix algorithm, and its
reliability by constructing Wannier Hamiltonians for 21737 materials from the
Materials Cloud