First-principles studies on structure stability, segregation and work function of Mg doped different metal elements