According to Einstein’s theory of relativity electricity and magnetism are interlinked and should actually be thought of as part of the same thing, hence the term “electromagnetism”. The electromagnetic force is one of the four fundamental forces of the universe and is responsible for maintaining the atomic structure. But to understand this it helps to divide the condition into its two terms.
With magnetism we begin with the condition of paired and unpaired electrons in an atomic structure. Stable atoms have paired electrons, whose spins significantly cancel out each other’s magnetic influence beyond the atom itself. However, some materials, notably iron, nickel and cobalt, have unpaired electrons in their atoms, which spin randomly, creating atomic instability and a magnetic influence that significantly extends beyond the atom itself. This condition is known as ferromagnetism. Under normal conditions these substances do not display a uniformed magnetic force because their atoms are arranged in microscopic magnetic domains that are not aligned. However, exposing the substance to a strong enough external magnetic influence causes these magnetic domains to align unidirectionally causing the entire unit to take on a magnetic field and become a magnet with each end of the unit having a magnetic pole.
With electricity, electrons are moving, unidirectionally, through a system, e.g., a wire connected to a battery. This unidirectional movement creates a magnetic field around the substance through which they flow, e.g., the wire. The magnetic poles for this condition are a bit more complex and will be explained later.
Therefore, the key conditions for a magnetic force are 1. Electrons are on their own, whether as part of an atomic structure, or moving freely from one point to another, and 2. There is unidirectional electron orientation, whether as components in a collection of atoms, or as part of a direction of flow.
The interplay between electricity and magnetism, known as Faraday's law of induction, is that a changing electric field generates a magnetic field and conversely a changing magnetic field generates an electric field.
The most familiar example of magnetism is a bar magnet, which is made of a ferromagnetic material, often iron or steel. In a bar magnet the magnetic domains have been unidirectionally aligned by an external magnetic influence.
Electromagnets make use of electricity, where a wire is coiled around a ferromagnetic material. Because a magnetic field is produced when an electrical current is passed through the wire, the material inside the coiled wire takes on the magnetic field and becomes a magnet.
Magnetic Fields and Magnetic Poles
Anything that is magnetized has a magnetic field, from the atomic level to the macroscopic level. The earth itself is actually a huge magnet with a magnetic field that extends out about 60,000 km on the sunward side and much further on the other side.
In a bar magnet the magnetic field runs through the center from negative to positive (south to north) and then sweeps outside in a loop that flows from positive to negative. It behaves the same way for an electromagnet.
Electromagnet Bar magnet
However when a current passes through a wire then the magnetic field revolves around the wire.