A thermodynamic modeling of GaN was carried out to describe the thermodynamic behavior of native defects, dopants, and carriers (free electrons and holes) in GaN semiconductors. The compound energy model (CEM) was used. An unintentionally doped GaN was taken as an example. Oxygen was introduced into the model as the unintentionally doped impurity, according to the practical experimental phenomena. The energies of component compounds in the model were defined based on the results of the ab initio calculations and adjusted to fit experimental data. The thermodynamic properties of the defects and the oxygen doped were calculated to show the facility of the model.