Substituting a small fraction of silicon (group IV, 4 valence electrons) with phosphorus (group V, 5 electrons) leaves one weakly-bound extra electron per dopant — a donor that ionizes at room temperature and jumps to the conduction band, making silicon n-type. Substituting with boron (group III, 3 electrons) leaves a missing bond — an acceptor that captures a valence electron and leaves behind a mobile hole, making it p-type.
For a non-degenerate semiconductor in thermal equilibrium the electron and hole densities always satisfy the mass-action law, regardless of doping:
n · p = n_i(T)²
n_i(T) = C · T^1.5 · exp(−E_g / 2k_BT) (E_g ≈ 1.12 eV for Si)
Adding N_D donors/cm³ (fully ionized at 300 K) shifts the populations via charge neutrality n ≈ N_D + p, so for N_D ≫ n_i: n ≈ N_D and p ≈ n_i²/N_D — electrons become the majority carrier and holes the minority carrier. The acceptor case is the mirror image. The Fermi level tracks this shift:
E_F − E_i = k_B T · ln(n / n_i)
Controls: pick donor or acceptor doping, set the dopant fraction (denser substitution = higher N_D or N_A), raise temperature to watch n_i(T) grow and eventually swamp the extrinsic carriers (the semiconductor turns "intrinsic" again), and adjust how fast the free carriers drift through the lattice for visual clarity. Green spheres are substituted dopant atoms, small orbiting particles are the mobile carriers they release — electrons (cyan) for donors, holes (red) for acceptors — and the right-hand bar sketches the Fermi level moving through the band gap.
This is the foundational mechanism behind every diode, transistor and solar cell: doping is how a p-n junction, and therefore all of modern electronics, is built.