The competition of densification and structure ordering during crystallization of HCP-Mg in the framework of layering