Inspect the defect identity behind every line
For a real defect, open the relaxed structure and charge or spin density for each charge state, check that the same defect configuration persists, and mark the host band edges and allowed Fermi-level range. Plot the formation-energy lines with chemical-potential and correction conventions stated, then inspect the lower envelope and any skipped state manually. Use visual tools, specialist defect tools, and literature sources.
Optional envelope check: the transition levels and self-consistent Fermi-level example are deliberately synthetic. Use the script only after real charge-state structures and corrections have passed inspection; it contains no defect geometry, localization evidence, or material transition level.
Use this example only after charge-state intercepts and slopes have been assembled and checked. It separates three operations: draw every line, select the thermodynamic lower envelope, and solve one declared charge-neutrality model. All inputs describe an invented defect in an abstract 3 eV gap.
From the repository root, run:
python3 examples/practical-guides/defect_charge_state_envelope.py
Inspect the report for transition levels, lower-envelope membership, and neutrality-root bracketing.
Select only lower-envelope crossings
The four fixture lines have slopes , , , and . The and neutral states cross at above the VBM; the neutral and states cross at . The +1 line intersects other lines but never reaches the lower envelope.
Confirm both thermodynamic_transition_levels_eV_above_vbm and charge_state_plus1_on_lower_envelope in the printed report. A pairwise intersection above a lower third state is not a thermodynamic transition. The skipped +1 state demonstrates negative- envelope geometry in the fixture; it is not evidence for a physical negative- centre without calculated structures, localization, relaxations, and converged corrections.
Solve neutrality as a separate operation
For each trial , the fixture evaluates dilute defect populations, nondegenerate carriers, and a fixed ionized-donor population, then solves
Bisection returns a fixture root near above the VBM. Check that the root is bracketed and the residual meets the script criterion. Do not obtain a Fermi level by selecting the lowest line at one convenient coordinate.
For a real model, record temperature, eligible-site densities, degeneracies, band densities of states, all defect and dopant species, chemical-potential conditions, and any frozen-in populations. Missing defects or a different thermal history can move the solution.
Claim boundary
The thick envelope, dashed excluded q = +1 line, and neutrality marker represent different derived objects. A transition level is not an equilibrium Fermi level.
This fixture verifies line slopes, lower-envelope selection, transition arithmetic, and one bracketed neutrality solve. It does not execute DFT, validate the band gap or VBM, identify a real defect, prove negative- physics, establish a dilute limit, calculate finite-temperature free energies, or predict concentrations.