Gradient systems and mechanical systems