Thermodynamic and ab initio calculations of chemisorption energies of ions