Permanent magnets attract and repel
One magnet exerts a force on another. Magnetic field line patterns (see the SPT: Magnetism topic episode 01 for an introduction) also change when you place magnets close to each other. There should be a connection between these two representations, so that interpreting a pattern of field lines will enable you to predict the forces.
Connections between field lines and changes in motion
To explore the connection, start with the simplest situation. Pull a pair of attracting magnets apart and the field lines get stretched – the field lines extend. Release one magnet and it flies back – there is a force acting on that magnet. The force produces a change in motion that shortens the field lines. Of course, it doesn't matter which magnet you let go of – the interaction is represented by a force acting on one magnet and exerted by the other. There is an equal and opposite force on the other magnet of the pair (Newton's third law).
Perhaps situations where movement of the magnets reduces the length of the field lines will always be those where the magnets experience a force that will cause that change in movement. Check out this speculation by pushing together a pair of magnets that are arranged to repel. Now when the magnets are released they fly apart, and the field lines are shortened, mostly by straightening.
There is a general rule: where field lines can be shortened by movement, there will be a force acting on the magnets to cause exactly such a change.
Currents in wires attract and repel
A current-carrying wire is surrounded by a magnetic field. Place two wires close to each other and the field lines will become longer. Your experience with permanent magnets should lead you to expect a pair of forces, one acting on each wire to create movement that shortens the field lines again. There are two simple cases: in both the wires are parallel.
Principles and rules of thumb
If the currents in the wires are in the same direction then the wires attract.
If the currents in the wires are in opposite directions then the wires repel.
The underlying principle – that forces on the wires generate movements that shorten the field lines – is what is valuable here as you can apply it often, and it gets you closer to having a physical model of the field, rather like the model used so effectively by Faraday.
Faraday developed his expectations by reasoning about field lines as if they were special elastic tubes that were under longitudinal tension, so were always trying to shorten. He also thought of them as repelling each other radially. The resulting field patterns that Faraday drew were a result of considering the responses to these two opposing tendencies. The electromagnetic changes that he expected as a result of the rearrangement of the field lines led him to many of his most famous experimental results.
Electromagnets: coils and fields
Coils of wire carrying currents produce magnetic fields, and these field patterns are identical to the field patterns of bar magnets. Just as with bar magnets, placing two current-carrying coils near each other produces changes in the fields of both, lengthening the field lines. Moving the coils can shorten the field lines. The direction in which you move to bring about this shortening shows the direction of the force.
Electromagnets: wires and fields
Placing a current-carrying wire between attracting magnets also lengthens field lines. As the field lines shorten, so the wire is thrown out of the space between the magnets. Again, magnetic forces produce a change in movement that shortens the field lines.
This movement is at right-angles to the current in the wire and to the magnetic field lines between the pair of magnets.