A computational study of magnesium incorporation in the bulk and surfaces of hydroxyapatite.