D-dimensional cosmology via thermodynamics