A variational approach to the relaxation of single domain magnetic particles based on Brown's model