   magnetic force 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? Any ideas?   
  In brief: The movement of your particles is described by a differential equation.  Write it down.  Then use some numerical integrator (the simplest: explicit Euler) to solve it.It sounds like this is different from what you are currently doing; it sounds like you currently have functions of time that return the particles' positions.  In other words, you've written down the analytical solution to some underlying differential equations.  This is very nice when you can do it, but it makes it difficult to add additional forces.  Also, it's generally only possible for reasonably simple differential equations.Now: what is the differential equation?  Write down a sum of forces on each particle, and this gives you its acceleration.Then, you'll want to take this differential equation and put it in "state space form," meaning that you introduce as many variables and equations as you need so that all of your differential equations become first-order.  For physical systems, the state is just the position and the velocity (or, equivalently, position and momentum).Example:Instead of writingyou'd write,This is a first-order differential equation which you can solve using standard numerical methods for the solution of ODEs (ordinary differential equations).Finally, a warning: I mentioned explicit Euler integration because it's easy to understand and implement.  However, it has some problems.  The big one is that it tends to increase the energy in your system rather than conserving it.  A slight modification gives the semi-implicit (or "symplectic") Euler method which does conserve energy (to first order).   