With the first two normalized wavefunctions and energies computed from the previous step, the HADOKEN code can now proceed to calculate the Fermi level, ϵ F . For both the Ga-and N-face triangular geometries, the Al-GaN/vacuum interface contains a high density of surface states that counterbalance the large spontaneous polarization charge generated at the interface . This results in the Fermi level being pinned in the AlGaN bandgap near -1.65 eV, which sets the upper limit of the r vector in subsequent function calls to pdeeig. For other user-defined geometries with a Fermi-pinning constraint, the Fermi level is specified by the user in the set_input_parameters.m routine.