When a p-doped and an n-doped semiconductor touch, a pn transition is generated. Through diffusion of the majority charge carriers, a space charge zone is generated in the transition zone, resulting in an electrical field. This can separate electron hole pairs.