Cosmological simulations of the intracluster medium