# Force between magnets

Magnets exert forces and torques on each other through the interaction of their magnetic fields. The forces of attraction and repulsion are a result of these interactions. The magnetic field of each magnet is due to microscopic currents of electrically charged electrons orbiting nuclei and the intrinsic magnetism of fundamental particles (such as electrons) that make up the material. Both of these are modeled quite well as tiny loops of current called magnetic dipoles that produce their own magnetic field and are affected by external magnetic fields. The most elementary force between magnets is the magnetic dipole–dipole interaction. If all magnetic dipoles for each magnet are known then the net force on both magnets can be determined by summing all the interactions between the dipoles of the first magnet and the dipoles of the second magnet.
It is often more convenient to model the force between two magnets as being due to forces between magnetic poles having magnetic charges spread over them. Positive and negative magnetic charge is always connected by a string of magnetized material; isolated magnetic charge does not exist. This model works well in predicting the forces between simple magnets where good models of how the magnetic charge is distributed are available.

## Magnetic poles vs. atomic currents

The field of a magnet is the sum of fields from all magnetized volume elements, which consist of small magnetic dipoles on an atomic level. The direct summation of all those dipole fields requires three-dimensional integration to obtain the field of one magnet, which may be intricate.
For homogeneous magnetization, the problem can be simplified in two different ways, using Stokes' theorem. Upon integration along the direction of magnetization, all dipoles along the line of integration cancel each other, except at the magnet's end surface. The field then emerges only from those (mathematical) magnetic charges spread over the magnet's end facets. On the contrary, when integrating over a magnetized area orthogonal to the direction of magnetization, the dipoles within this area cancel each other, except at the magnet's outer surface, where they (mathematically) sum up to a ring current. This is called the Ampèrian loop model. In both models, only two-dimensional distributions over the magnet's surface have to be considered, which is simpler than the original three-dimensional problem.
Magnetic pole model: In the magnetic pole model, the pole surfaces of a permanent magnet are imagined to be covered with so-called magnetic charge, north pole particles on the north pole and south pole particles' on the south pole, that are the source of the magnetic field lines. The field due to magnetic charges is obtained through Coulomb's law with magnetic instead of electric charges. If the magnetic pole distribution is known, then the magnetic pole model gives the exact distribution of the magnetic field intensity H both inside and outside the magnet. The surface charge distribution is uniform, if the magnet is homogeneously magnetized and has flat end facets (such as a cylinder or prism).
Ampèrian loop model: In the Ampèrian loop model, all magnetization is due to the effect of microscopic, or atomic, circular bound currents, also called Ampèrian currents throughout the material. The net effect of these microscopic bound currents is to make the magnet behave as if there is a macroscopic electric current flowing in loops in the magnet with the magnetic field normal to the loops. The field due to such currents is obtained through the Biot–Savart law. The Ampèrian loop model gives the correct magnetic flux density B both inside and outside the magnet. It is sometimes difficult to calculate the Ampèrian currents on the surface of a magnet.

### Magnetic dipole moment

Far away from a magnet, its magnetic field is almost always described (to a good approximation) by a dipole field characterized by its total magnetic dipole moment, m. This is true regardless of the shape of the magnet, so long as the magnetic moment is non-zero. One characteristic of a dipole field is that the strength of the field falls off inversely with the cube of the distance from the magnet's center.
The magnetic moment of a magnet is therefore a measure of its strength and orientation. A loop of electric current, a bar magnet, an electron, a molecule, and a planet all have magnetic moments. More precisely, the term magnetic moment normally refers to a system's magnetic dipole moment, which produces the first term in the multipole expansion of a general magnetic field.
Both the torque and force exerted on a magnet by an external magnetic field are proportional to that magnet's magnetic moment. The magnetic moment is a vector: it has both a magnitude and direction. The direction of the magnetic moment points from the south to north pole of a magnet (inside the magnet). For example, the direction of the magnetic moment of a bar magnet, such as the one in a compass is the direction that the north poles points toward.
In the physically correct Ampèrian loop model, magnetic dipole moments are due to infinitesimally small loops of current. For a sufficiently small loop of current, I, and area, A, the magnetic dipole moment is: $\mathbf {m} =I\mathbf {A} ,$ where the direction of m is normal to the area in a direction determined using the current and the right-hand rule. As such, the SI unit of magnetic dipole moment is ampere meter$^2$. More precisely, to account for solenoids with many turns the unit of magnetic dipole moment is ampere–turn meter$^2$.
In the magnetic pole model, the magnetic dipole moment is due to two equal and opposite magnetic charges that are separated by a distance, d. In this model, m is similar to the electric dipole moment p due to electrical charges: $m=q_{\mathrm {m} }d,$ where q$_m$ is the ‘magnetic charge’. The direction of the magnetic dipole moment points from the negative south pole to the positive north pole of this tiny magnet.

### Magnetic force due to non-uniform magnetic field

Magnets are drawn along the magnetic field gradient. The simplest example of this is the attraction of opposite poles of two magnets. Every magnet produces a magnetic field that is stronger near its poles. If opposite poles of two separate magnets are facing each other, each of the magnets is drawn into the stronger magnetic field near the pole of the other. If like poles are facing each other, though, they are repulsed from the larger magnetic field.
The magnetic pole model predicts a correct mathematical form for this force and is easier to understand qualitatively. For if a magnet is placed in a uniform magnetic field then both poles will feel the same magnetic force but in opposite directions, since they have opposite magnetic charge. But, when a magnet is placed in the non-uniform field, such as that due to another magnet, the pole experiencing the large magnetic field will experience the large force and there will be a net force on the magnet. If the magnet is aligned with the magnetic field, corresponding to two magnets oriented in the same direction near the poles, then it will be drawn into the larger magnetic field. If it is oppositely aligned, such as the case of two magnets with like poles facing each other, then the magnet will be repelled from the region of higher magnetic field.
In the Ampèrian loop model, there is also a force on a magnetic dipole due to a non-uniform magnetic field, but this is due to Lorentz forces on the current loop that makes up the magnetic dipole. The force obtained in the case of a current loop model is $\mathbf {F} =\nabla \left(\mathbf {m} \cdot \mathbf {B} \right),$ where the gradient ∇ is the change of the quantity m · B per unit distance, and the direction is that of maximum increase of m · B. To understand this equation, note that the dot product m · B = mB cos(θ), where m and B represent the magnitude of the m and B vectors and θ is the angle between them. If m is in the same direction as B then the dot product is positive and the gradient points 'uphill' pulling the magnet into regions of higher B-field (more strictly larger m · B). B represents the strength and direction of the magnetic field. This equation is strictly only valid for magnets of zero size, but is often a good approximation for not too large magnets. The magnetic force on larger magnets is determined by dividing them into smaller regions having their own m then summing up the forces on each of these regions.

## Magnetic pole model

The magnetic pole model assumes that the magnetic forces between magnets are due to magnetic charges near the poles. This model works even close to the magnet when the magnetic field becomes more complicated, and more dependent on the detailed shape and magnetization of the magnet than just the magnetic dipole contribution. Formally, the field can be expressed as a multipole expansion: A dipole field, plus a quadrupole field, plus an octopole field, etc. in the Ampèrian loop model, but this can be very cumbersome mathematically.

### Calculating the magnetic force

Calculating the attractive or repulsive force between two magnets is, in the general case, a very complex operation, as it depends on the shape, magnetization, orientation and separation of the magnets. The magnetic pole model does depend on some knowledge of how the ‘magnetic charge’ is distributed over the magnetic poles. It is only truly useful for simple configurations even then. Fortunately, this restriction covers many useful cases.

#### Force between two magnetic poles

If both poles are small enough to be represented as single points then they can be considered to be point magnetic charges. Classically, the force between two magnetic poles is given by:
$F={{\mu q_{m1}q_{m2}} \over {4\pi r^{2}}}$ where
* F is force (SI unit: newton)
* q$_{m1}$ and q$_{m2}$ are the magnitudes of magnetic charge on magnetic poles (SI unit: ampere-meter)
* μ is the permeability of the intervening medium (SI unit: tesla meter per ampere, henry per meter or newton per ampere squared)
* r is the separation (SI unit: meter).
The pole description is useful to practicing magneticians who design real-world magnets, but real magnets have a pole distribution more complex than a single north and south. Therefore, implementation of the pole idea is not simple. In some cases, one of the more complex formulas given below will be more useful.

#### Force between two nearby magnetized surfaces of area A

The mechanical force between two nearby magnetized surfaces can be calculated with the following equation. The equation is valid only for cases in which the effect of fringing is negligible and the volume of the air gap is much smaller than that of the magnetized material, the force for each magnetized surface is: $F={\frac {\mu _{0}H^{2}A}{2}}={\frac {B^{2}A}{2\mu _{0}}}$ where:
* A is the area of each surface, in m$^2$
* H is their magnetizing field, in A/m.
* μ$_0$ is the permeability of space, which equals 4π×10$^{−7}$ T·m/A
* B is the flux density, in T
The derivation of this equation is analogous to the force between two nearby electrically charged surfaces, which assumes that the field in between the plates is uniform.

#### Force between two bar magnets

The force between two identical cylindrical bar magnets placed end to end at great distance $x\gg R$ is approximately: $F\simeq \left[{\frac {B_{0}^{2}A^{2}\left(L^{2}+R^{2}\right)}{\pi \mu _{0}L^{2}}}\right]\left[{\frac {1}{x^{2}}}+{\frac {1}{(x+2L)^{2}}}-{\frac {2}{(x+L)^{2}}}\right]$ where
* B$_0$ is the flux density very close to each pole, in T,
* A is the area of each pole, in m$^2$,
* L is the length of each magnet, in m,
* R is the radius of each magnet, in m, and
* x is the separation between the two magnets, in m
$B_{0}={\frac {\mu _{0}}{2}}M$ relates the flux density at the pole to the magnetization of the magnet.
Note that these formulations assume point-like magnetic-charge distributions instead of a uniform distribution over the end facets, which is a good approximation only at relatively great distances. For intermediate distances, numerical methods must be used.

#### Force between two cylindrical magnets

For two cylindrical magnets with equal radii $R$, and lengths $L_{1}$ and $L_{2}$, and given a large lateral gap between them, in the limit $x\gg R$, the force can be approximated by
$F(x,r)\simeq {\frac {\pi K_{d}}{2}}R^{4}\sum _{i,j=0}^{1}{\left({\frac {(-1)^{i+j}}{(x+iL_{1}+jL_{2})^{2}}}\left(1-{\frac {3}{2}}{\frac {r^{2}}{(x+iL_{1}+jL_{2})^{2}}}\right)\right)}$
where
* $R$ is the radius of each of the two magnets, under the assumption of equal radii
* $L_{1}$ is the length of the first magnet
* $L_{2}$ is the length of the second magnet
* $K_{d}$ is the maximum energy product in units of J/m$^3$ (Joules per cubic meter)
* $x$ is the normal distance between the two parallel faces of the magnets
* $r$ is the distance between the magnetic dipole axes of the two magnets.
With their magnetic dipole aligned, the force can be computed analytically using elliptic integrals.
$F(x)\simeq {\frac {\pi K_{d}}{2}}R^{4}\left[{\frac {1}{x^{2}}}+{\frac {1}{(x+2L)^{2}}}-{\frac {2}{(x+L)^{2}}}\right]$
This can be rewritten as,
$F(x)\simeq {\frac {\pi \mu _{0}}{4}}M^{2}R^{4}\left[{\frac {1}{x^{2}}}+{\frac {1}{(x+2L)^{2}}}-{\frac {2}{(x+L)^{2}}}\right]$
Where $M$ is the magnetization of the magnets and $x$ is the distance between them. For small values of $x$, the results are erroneous as the force becomes large for close-to-zero distance.
If the magnet is long ($L\gg R$), a measurement of the magnetic flux density very close to the magnet $B_{0}$ is roughly related to $M$ by the formula $B_{0}={\frac {\mu _{0}}{2}}M.$
The effective magnetic dipole moment can be written as $m=MV$ where $V$ is the volume of the magnet. For a cylinder this is $V=\pi R^{2}L$, and $M$ is the magnetisation field of the dipole.
When $L\ll x$ the point dipole approximation is obtained, $F(x)={\frac {3\pi \mu _{0}}{2}}M^{2}R^{4}L^{2}{\frac {1}{x^{4}}}={\frac {3\mu _{0}}{2\pi }}M^{2}V^{2}{\frac {1}{x^{4}}}={\frac {3\mu _{0}}{2\pi }}m_{1}m_{2}{\frac {1}{x^{4}}}$
Which matches the expression of the force between two magnetic dipoles.

## Ampèrian loop model

French scientist André Marie Ampère found that the magnetism produced by permanent magnets and the magnetism produced by electromagnets are the same kind of magnetism. Because of that, the strength of a permanent magnet can be expressed in the same terms as that of an electromagnet.
The strength of magnetism of an electromagnet that is a flat loop of wire through which a current flows, measured at a distance that is great compared to the size of the loop, is proportional to that current and is proportional to the surface area of that loop.
For purpose of expressing the strength of a permanent magnet in same terms as that of an electromagnet, a permanent magnet is thought of as if it contains small current-loops throughout its volume, and then the magnetic strength of that magnet is found to be proportional to the current of each loop (in amperes), and proportional to the surface of each loop (in square meters), and proportional to the density of current-loops in the material (in units per cubic meter), so the dimension of strength of magnetism of a permanent magnet is amperes times square meters per cubic meter, is amperes per meter.
That is why ampere per meter is the correct unit of magnetism, even though these small current loops are not really present in a permanent magnet.
The validity of Ampère's model means that it is allowable to think of the magnetic material as if it consists of current-loops, and the total effect is the sum of the effect of each current-loop, and so the magnetic effect of a real magnet can be computed as the sum of magnetic effects of tiny pieces of magnetic material that are at a distance that is great compared to the size of each piece.
This is very useful for computing magnetic force-field of a real magnet; It involves summing a large amount of small forces and you should not do that by hand, but let your computer do that for you; All that the computer program needs to know is the force between small magnets that are at great distance from each other.
In such computations it is often assumed that each (same-size) small piece of magnetic material has an equally strong magnetism, but this is not always true: a magnet that is placed near another magnet can change the magnetization of that other magnet. For permanent magnets this is usually only a small change, but if you have an electromagnet that consists of a wire wound round an iron core, and you bring a permanent magnet near to that core, then the magnetization of that core can change drastically (for example, if there is no current in the wire, the electromagnet would not be magnetic, but when the permanent magnet is brought near, the core of the electromagnet becomes magnetic).
Thus the Ampère model is suitable for computing the magnetic force-field of a permanent magnet, but for electromagnets it can be better to use a magnetic-circuit approach.

### Magnetic dipole–dipole interaction

If two or more magnets are small enough or sufficiently distant that their shape and size is not important then both magnets can be modeled as being magnetic dipoles having a magnetic moments m$_1$ and m$_2$. In case of uniformly magnetized spherical magnets this model is precise even at finite size and distance, as the outside field of such magnets is exactly a dipole field.
The magnetic field of a magnetic dipole in vector notation is: $\mathbf {B} (\mathbf {m} ,\mathbf {r} )={\frac {\mu _{0}}{4\pi r^{3}}}\left(3(\mathbf {m} \cdot {\hat {\mathbf {r} }}){\hat {\mathbf {r} }}-\mathbf {m} \right)+{\frac {2\mu _{0}}{3}}\mathbf {m} \delta ^{3}(\mathbf {r} )$ where
* B is the field
* r is the vector from the position of the dipole to the position where the field is being measured
* r is the absolute value of r: the distance from the dipole
* ${\hat {\mathbf {r} }}=\mathbf {r} /r$ is the unit vector parallel to r;
* m is the (vector) dipole moment
* μ$_0$ is the permeability of free space
* δ$^3$ is the three-dimensional delta function.
This is exactly the field of a point dipole, exactly the dipole term in the multipole expansion of an arbitrary field, and approximately the field of any dipole-like configuration at large distances.
If the coordinate system is shifted to center it on m$_1$ and rotated such that the x-axis points in the direction of m$_1$ then the previous equation simplifies to ${\begin{aligned}B_{x}(\mathbf {r} )&={\frac {\mu _{0}}{4\pi }}m_{1}\left({\frac {3\cos ^{2}\theta -1}{r^{3}}}\right)\\B_{y}(\mathbf {r} )&={\frac {\mu _{0}}{4\pi }}m_{1}\left({\frac {3\cos \theta \sin \theta }{r^{3}}}\right),\end{aligned}}$ where the variables r and θ are measured in a frame of reference with origin in m$_1$ and oriented such that m$_1$ is at the origin pointing in the x-direction. This frame is called Local coordinates and is shown in the Figure on the right.
The force of one magnetic dipole on another is determined by using the magnetic field of the first dipole given above and determining the force due to the magnetic field on the second dipole using the force equation given above. Using vector notation, the force of a magnetic dipole m$_1$ on the magnetic dipole m$_2$ is: $\mathbf {F} (\mathbf {r} ,\mathbf {m} _{1},\mathbf {m} _{2})={\frac {3\mu _{0}}{4\pi r^{5}}}\left[(\mathbf {m} _{1}\cdot \mathbf {r} )\mathbf {m} _{2}+(\mathbf {m} _{2}\cdot \mathbf {r} )\mathbf {m} _{1}+(\mathbf {m} _{1}\cdot \mathbf {m} _{2})\mathbf {r} -{\frac {5(\mathbf {m} _{1}\cdot \mathbf {r} )(\mathbf {m} _{2}\cdot \mathbf {r} )}{r^{2}}}\mathbf {r} \right]$ where r is the distance-vector from dipole moment m$_1$ to dipole moment m$_2$, with r = ‖r‖. The force acting on m$_1$ is in opposite direction. As an example the magnetic force for two magnets pointing in the z-direction and aligned on the z-axis and separated by the distance z is:
    $\mathbf {F} (z,m_{1},m_{2})=-{\frac {3\mu _{0}m_{1}m_{2}}{2\pi z^{4}}}$, z-direction.
The final formulas are shown next. They are expressed in the global coordinate system, ${\begin{aligned}F_{r}(\mathbf {r} ,\alpha ,\beta )&=-{\frac {3\mu _{0}}{4\pi }}{\frac {m_{2}m_{1}}{r^{4}}}\left[2\cos(\phi -\alpha )\cos(\phi -\beta )-\sin(\phi -\alpha )\sin(\phi -\beta )\right]\\F_{\phi }(\mathbf {r} ,\alpha ,\beta )&=-{\frac {3\mu _{0}}{4\pi }}{\frac {m_{2}m_{1}}{r^{4}}}\sin(2\phi -\alpha -\beta )\end{aligned}}$