Attraction Force Problem

Hello,

I am trying to create a simulation of charged particles using spheres, I have started with a two particle system, with one positive and one negative and they correctly attract one another. They meet and become stationary, the forces between the two being equal and opposite. After a time however the forces stop being equal and opposite and so the “particles” begin to move.

Is it perhaps because the code for the positive and negative particles is run sequentially? The vector from one particle to the other might be slightly different and so the forces applied end up being different. But why doesn’t this show up when the particles are far from each other, print statements to the console have showed that the forces are identical at the start.

I have attached the blend file, if anyone could have a look and suggest ideas or solutions that would be wonderful.

Thank you,
Andrew

Attachments

charge.blend (557 KB)

I suspected it was some kind of collision issue, and I noticed you had the particles’ physics type set to rigid body. Since they’re spheres and don’t need to roll on the ground, you should just use the dynamic physics type. As far as I could tell, doing so fixed the problem.

Hi :wink:

there a “syntax error”

change this:

object.applyForce([x_force,y_force,z_force], True)
to :
object.applyForce([x_force,y_force,z_force], False)

otherwise you “read global and write local”

it still hidden for a bit until starts some little rotation i guess :wink:

Thank you for both suggestions, they both worked but I have gone with changing the applyForce to global as I may want them to be able to rotate in the future.

Thank you,
Andrew