Fermi level for semiconductors

Dear support team,

While the Fermi level is defined by the Aufbau principle for metals, how is it defined for semiconductors ? I am presently working on a 2D semiconductor, and its Fermi level oscillates wildly within the gap, when it should be defined around the middle of the gap.

Thank you for your time