Ab initio adiabatic polarisation potentials for Be and Mg