About topological invariants and statistical mechanics