Can we calculate electron affinity of a semiconductor (e.g., for Si) using density functional theory calculations in VASP? Which calculations are needed to compute electron affinity and band offsets?
This may be a bit of a rough answer, so apologies in advance...
Since the eigenvalues obtained using non-energy-consistent pseudopotentials (i.e. the situation in VASP as far as I know) do not themselves have physical meaning, we typically use a slab system with an explicit vacuum, in order to make reference to vacuum. A more common situation is calculating work function of metal slabs, where you subtract the Fermi energy from the vacuum level to get the work function. In the case of electron affinity, I suppose you would subtract the conduction band minimum from the vacuum level. Here's how you would do this:
Construct a slab with the desired crystal orientation. You will need to converge both the thickness of the slab (so the center is "bulk-like"), and the thickness of the vacuum region. You could probably follow the instructions here for VASP, but use your desired material and subtract the conduction band minimum energy rather than the code's output Fermi energy.
Since you mentioned band offsets, I'm guessing you want to calculate them using the electron affinities. I just want to make sure you're aware that this method (Anderson's rule) does not work in many situations. If you're going to be calculating electron affinities with slabs anyways, you might as well explicitly calculate band offsets with a layered supercell. You can do this by determining the offset of the potentials on each side of the interface, and then using reference bulk calculations to determine the offsets. You can see this paper and the references therein. Another way to do this could be explicitly from layer-resolved projected density of states. This paper does something like that. I also typically have used this method. I know the first method has some theory behind it, I'm not sure of how the second method compares in that regard.
Also keep in mind that band offsets will also be affected by the challenges of calculating band gaps in DFT... It would be worth reading up on this. Good luck!