First-principles study of the structure of Mg/Nb multilayers