Ab initio study of K adsorption on a Ag(100) surface