Energetics of the formation of Cu–Ag core–shell nanoparticles