  Fe$M_2X_4$ spinels, where $M$ is a transition metal and $X$ is oxygen or
sulfur, are candidate materials for spin filters, one of the key devices in
spintronics. We present here a computational study of the inversion
thermodynamics and the electronic structure of these (thio)spinels for $M=$ Cr,
Mn, Co, Ni, using calculations based on the density functional theory with
on-site Hubbard corrections (DFT+$U$). The analysis of the configurational free
energies shows that different behaviour is expected for the equilibrium cation
distributions in these structures: FeCr$_2X_4$ and FeMn$_2$S$_4$ are fully
normal, FeNi$_2X_4$ and FeCo$_2$S$_4$ are intermediate, and FeCo$_2$O$_4$ and
FeMn$_2$O$_4$ are fully inverted. We have analyzed the role played by the size
of the ions and by the crystal field stabilization effects in determining the
equilibrium inversion degree. We also discuss how the electronic and magnetic
structure of these spinels is modified by the degree of inversion, assuming
that this could be varied from the equilibrium value. We have obtained
electronic densities of states for the completely normal and completely inverse
cation distribution of each compound. FeCr$_2X_4$, FeMn$_2X_4$, FeCo$_2$O$_4$
and FeNi$_2$O$_4$ are half-metals in the ferrimagnetic state when Fe is in
tetrahedral positions. When $M$ is filling the tetrahedral positions, the
Cr-containing compounds and FeMn$_2$O$_4$ are half-metallic systems, while the
Co and Ni spinels are insulators. The Co and Ni sulfide counterparts are
metallic for any inversion degree together with the inverse FeMn$_2$S$_4$. Our
calculations suggest that the spin filtering properties of the Fe$M_2X_4$
(thio)spinels could be modified via the control of the cation distribution
through variations in the synthesis conditions.
