We present measurements and calculations of electronic stopping of protons
and deuterons in Mg (gas and solid) in the range 15-650 keV/A. The measurem
ents were performed by transmitting the ion beam through a vapor cell conta
ining solid and gaseous Mg in thermal equilibrium. In order to get absolute
values of the stopping cross section epsilon, the experimental gas data we
re normalized by the requirement that the experimental phase effect Delta e
psilon = epsilon(gas) - epsilon(solid) -with the epsilon for metallic Mg fr
om Bergsmann (1998)- is equal to the theoretical value Delta epsilon(th) at
a reference energy of 400 keV. We have used a Hartree-Fock-Slater descript
ion of the Mg atom and the first Born approximation to calculate excitation
and ionization of Mg in the gas phase and the ionization of the inner shel
ls of solid Mg, while the valence electrons (3s) of solid Mg are described
by a free-electron gas. Charge-exchange processes are explicitly taken into
account to estimate both the equilibrium charge state fractions and the en
ergy loss in charge-exchange processes, as required by our charge state app
roach. We obtain a pronounced phase effect of up to 70% at 20 keV. Theory a
nd experiment: coincide within the experimental uncertainties in a wide ene
rgy range; systematic deviations occur only at low energies where the linea
r model breaks down.