Chemical evolution of galaxies – I. A composition‐dependent SPH model for chemical evolution and cooling