The theory of p-n Junctions in semiconductors and p-n junction transistors