  Although the two-dimensional electron gas (2DEG) in (001)
Zn$_{1-x}$Mg$_x$O/ZnO heterostructures has been discovered for about twenty
years, the origin of the 2DEG is still inconclusive. In the present letter, the
formation mechanisms of 2DEG near the interfaces of (001) Zn$_{1-x}$Mg$_x$O/ZnO
heterostructures were investigated via the first-principles calculations
method. It is found that the polarity discontinuity near the interface can
neither lead to the formation of 2DEG in devices with thick Zn$_{1-x}$Mg$_{x}$O
layers nor in devices with thin Zn$_{1-x}$Mg$_{x}$O layers. For the
heterostructure with thick Zn$_{1-x}$Mg$_{x}$O layers, the oxygen vacancies
near the interface introduce a defect band in the band gap, and the top of the
defect band overlaps with the bottom of the conduction band, leading to the
formation of the 2DEG near the interface of the device. For the heterostructure
with thin Zn$_{1-x}$Mg$_{x}$O layers, the absorption of hydrogen atoms, oxygen
atoms, or OH groups on the surface of Zn$_{1-x}$Mg$_{x}$O film plays a key role
for the formation of 2DEG in the device. Our results manifest the sources of
2DEGs in Zn$_{1-x}$Mg$_x$O/ZnO heterostructures on the electronic structure
level.
