Reaction of magnesium with carbon dioxide