A potential well theory for the heat equation with a nonlinear boundary condition