Are electrons in a p n junction delocalized across the junction? When discussing p n junctions, it is usually said that electrons diffuse from the n side to the p side, hence creating a separation of charges.
However, we know that electrons in a lattice are delocalized. Or more precisely, their state is given by the density operator $\rho = \frac{1}{Z} \sum_{k,n} e^{-\beta E_{k,n}}|\psi_{k,n}\rangle \langle \psi_{k,n}|$, with crystal momenta $k$ and additional quantum numbers $n$.
Even in an inhomogeneous system, the wavefunction should be spread out across the whole crystal.
These two pictures appear to be in conflict. Are electrons really localized at different sides of a p n junction?
Edit: Im looking for a quantum mechanical approach. From the microscopic point of view, we have to solve the stationary Schrödinger equation, and the only difference between the two sites are the different amount of impurity atoms. Im wondering how the density gradient in this system can arise from this microscopic point of view.
 A: The magic words are "semiclassical model" (you can read about it for example in Ashcroft / Mermin, chapter 12), https://www.fzu.cz/~knizek/literatura/Ashcroft_Mermin.pdf).
You are right in that the solution of an electron with crystal momentum $\vec{k}$ for a lattice is itself periodic. You can however superimpose wave functions with differing $\delta k$, and get a localized wave-package.
Under certain conditions, this wave package still has well defined enough $\vec{k}$ and $\vec{x}$ to be useful.
One example for the said condition: When you apply external fields (that is - every field which isn't generated by the electron you want to describe), the wavelength of the external field has to be big compared to the spatial extension of the wave package.
A: As @Quantumwhisp has correctly pointed out, the semiconductor junctions described in the classical textbooks are usually treated within the semiclassical approximation. However, nowadays we are able to fabricate devices where the wave function is coherent across the junction is everyday reality - these range from tunnel diodes (one tunnel junction) to superlattices, cascade lasers (hundreds of tunnel junctions with coherent tunneling along the length of the whole device).
Mean free path
The crucial notion here is the mean free path, $l$, which classically means the distance that electrons travel between collisions (with lattice imperfections, photons, other electrons, impurities). In the context of wave functions and tunneling mean free path really means the coherence length, i.e., the distance on which we can describe electron by a wave function. In classical p-n junctions the mean free path is much smaller than the size of the junction, $l\ll L$, whereas in tunneling devices the inverse is true: $l\gg L$.
Dephasing, decoherence, etc.
A finer point of view on the mean free path requires distinguishing the elastic and inelastic processes, which are sometimes referred to as dephasing and decoherence. As the OP correctly notes, even in an inhomogeneous system (but in absence of inelastic processes, such as electron-phonon or electron-electron collisions) the wave function in principle is coherent. While mathematically one is then tempted to average over all possible impurity configurations and imperfections, this is clearly not the correct approach when dealing with a specific sample with a specific disorder configuration. The subject has been an area of active research a couple of decades ago, and many interesting phenomena such as Anderson localization, weak localization, ballistic conductance were studied. (Note that use of the word *localization, echoing the title of the question.)
Diffusion
To finish with a short comment: diffusion is a process of random motion due to experiencing collisions with the environment particles (which in this case are impurities, photons,a nd other electrons). Diffusion is thus, by definition, an incoherent process, and its mentioning necessarily implies taking the limit of the short coherence length.
References

*

*Beenakker, The random matrix theory of quantum transport

*Joe Imry, Introduction to mesoscopic physics
