Stability criterion for the magnetic separation of rare-earth ions.