Ensemble equivalence and phase transitions for general models in statistical mechanics and for the Curie -Weiss -Potts model