# Electromagnetism Simulation

I would like to create a basic electromagnetism simulation in blender; just two separate coils attracting each other (they slide and touch).

I'm good for modelling this, just not sure how to set up the physics.

This can be modeled using blender physics. The animation was generated in Blender 2.76b from the attached .blend file. It uses the built-in physics. It shows attraction (blue-red), followed by repulsion (red-red). 1. Create a scene with a plane and two cylinders above the plane. Add two empties.
2. Parent an empty to each cylinder. The forces will be driven through the empties.
3. Select the plane and go to the physics tab. Enable rigid body physics for the the plane. Specify the plane will be animated. This will prevent movement of the plane, but give the cylinders something to slide on. 1. For each cylinder, on the physics tab, enable rigid body physics. This will let the cylinder collide with the plane and each other. 1. For each empty, enable forces in the physics tab. Set the forces to -100. You may need to adjust the forces depending on the spacing. The negative values indicate that the empties will attract each other. Positive values will cause the empties to push each other apart. 1. Run the animation to see the result.

A blender file illustrating this approach: This solution is similar to the approach described in this question: How to have rigid-bodies and charge fields interact?

• Thank you for be so thorough. Does this simulate the N/S poles of an em coil as well? As in, objects behind the coils are also affected. – Karric Nov 30 '15 at 16:35
• This approach does not simulate N-S attraction. It emulates the effect of N/S attraction using forces. Another approach will be needed to simulate N/S. – Ed Tate Dec 20 '15 at 15:45

I'd suggest using the Limit Distance Constraint. You can set it up reciprocally on both coils (each one set up with the other coil as the target object).

By animating the Distance value you can visualize magnetic attraction between the two objects. If your unfamiliar with constraints, this is a good intro. To add a Limit Distance constraint, select your object, then go to the Constraints (chain icon) tab in the Properties Window, then: Add Object Constraint > Transform > Limit Distance.