Theoretical study of alloy phase stability in the Cd-Mg system.