A phase-slip model of switching