Adiabatic invariants and the equilibrium of magnetically trapped particles