Magnetic field for orbitted movement

I have a number of particles, moving on an elliptical orbit. What I want to do is this:

When I bring a magnet closer to the orbit, the orbit will be morphed, meaning particles will lean towards the magnetic field. When I put away the magnet, they will go back to the original orbit.

But I have no idea how to approach this. I prepared the elliptic movement, but how would I integrate the magnet into this?

Math & physics & programming is not a problem. do not hesitate to recommend something complex.