To keep it simple, when it comes to magnetism there are three main types of materials:
- Ferromagnetic: Which are strongly attracted by magnetic fields, and are mainly alloys of iron, nickel and cobalt; note that these three metals are adjacent in the periodic table.
- Paramagnetic: Which are weakly attracted by magnetic fields, such as oxygen.
- Diamagnetic: Which are weakly repelled by magnetic fields, for example aluminum.
This characteristic is defined as “magnetic permeability”. The structure of permeable materials allows magnetic-field lines to pass through the material easier than through a vacuum.
So the high concentration of magnetic-field lines causes the material to be attracted to the magnet. Conversely, when magnetic lines go through a vacuum easier, then the material is repelled.
This is the reason why two magnets of the same polarity repel each other. The magnetic lines of one magnet are prevented from passing through the lines of the second one, so it passes easier through a vacuum, causing equal poles to repel each other.
All substances are affected by the magnetic field, although in most of them the effect is very weak (and can only be detected with precise instruments). Materials attracted by magnets fall into two groups: ferromagnetic materials and ferrimagnetic materials. The other materials not attracted to magnets are classified as paramagnetic, diamagnetic and antiferromagnetic.
At the end of the 19th century, the microscopic causes of the different magnetic behavior of materials began to be investigated. Surprisingly around 1910, it was shown that in the framework of classical statistical mechanics, ferromagnetism was inexplicable within classical physics.
This devastating result became known as the Bohr–van Leeuwen theorem. This was in addition to previous devastating results: the existence of stable atoms was inexplicable within classical mechanics, light behaved as a wave and a particle at the same time. All these problems were related and could only be overcome with the advent and development of quantum mechanics.
Ferromagnetism is, therefore, a phenomenon essentially related to the quantum behavior of electrons within an atom. It turns out that electrons have a special quantum property called spin. This spin is affected by the electromagnetic field and is capable of magnetic attraction (all macroscopic magnetism is due to the presence of this spin in matter). That said, we are in a position to try and explain the difference between ferromagnetic / ferrimagnetic materials and the rest.
It turns out that in this type of material the spins (which can be imagined as vectors that point in different directions) are more or less disordered.
In the presence of a magnetic field these spins are oriented parallel to the magnetic field and together create an angular magnetic moment effective.
It in turn interacts with the original field (as when two wires carrying current are placed next to each other) and the attractive force is produced.
This happens because the structure of ferromagnetic materials includes a partially empty electron shell that allows realignment of spins. In materials that are not attracted by magnets, the outer shells are full and the spins have no possibility of reorienting freely.