First-principles calculations to investigate the interfacial energy and electronic properties of Mg/AlN interface