Numerical simulation of contact and separation of magnetic particles under uniform magnetic field