When calculating defect formation energies using eq. ( ), the Fermi energy, E F , is determined selfconsistently by solving eqs. (1) and (2) under the constraint of net charge neutrality . The net charge density of a system, ρ, is calculated as a sum over all defect species (X) and their charges (q) plus the charge contributions from free electrons (n 0 ) and holes (p 0 ) that are considered to occupy the conduction and valence bands respectively,