Ferromagnetism[1]

Ferromagnetism is the basic mechanism by which certain materials (such as iron) form permanent magnets, or are attracted to magnets. In physics, several different types of magnetism are distinguished. Ferromagnetism (including ferrimagnetism) is the strongest type; it is the only type that creates forces strong enough to be felt, and is responsible for the common phenomena of magnetism encountered in everyday life. Permanent magnets (materials that can be magnetized by an external magnetic field and remain magnetized after the external field is removed) are either ferromagnetic or ferrimagnetic, as are other materials that are noticeably attracted to them. Only a few substances are ferromagnetic. The common ones are iron, nickel, cobalt and most of their alloys, some compounds of rare earth metals, and a few naturally-occurring minerals such as lodestone.

Origin of Magnetism[1]

One of the fundamental properties of an electron (besides that it carries charge) is that it has a magnetic dipole moment, i.e., it behaves itself as a tiny magnet. This dipole moment comes from the more fundamental property of the electron that it has quantum mechanical spin. The quantum mechanical nature of this spin causes the electron to only be able to be in two states, with the magnetic field either pointing "up" or "down" (for any choice of up and down). The spin of the electrons in atoms is the main source of ferromagnetism, although there is also a contribution from the orbital angular momentum of the electron about the nucleus. When these tiny magnetic dipoles are aligned in the same direction, their individual magnetic fields add together to create a measurable macroscopic field.

Calculation of Magnetic Field due to Magnetization[2]

Average macroscopic magnetization or magnetic moment density: $\vec{M}\left(x\right)$
Vector magnetic potential is:
$$A\left(\vec{x}\right)=\frac{\mu_{0}}{4\pi}\int_{V}\frac{J\left(x'\right)+\nabla'\times M\left(x'\right)}{\left|\vec{x}-\vec{x}'\right|}dV'+\frac{\mu_{0}}{4\pi}\oint_{S}\frac{M\left(x'\right)\times n'}{\left|\vec{x}-\vec{x}'\right|}da'$$
When there is no currents $J=0$ and $M=const$ we stay with:
$$A\left(\vec{x}\right)=\frac{\mu_{0}}{4\pi}\oint_{S}\frac{M\left(x'\right)\times n'}{\left|\vec{x}-\vec{x}'\right|}da'$$
Now the magnetic field can be calculated using $\vec{B}=\nabla\times\vec{A}$:
$$B\left(\vec{x}\right)=\frac{\mu_{0}}{4\pi}\oint_{S}\nabla\times\left(\frac{M\left(x'\right)\times n'}{\left|\vec{x}-\vec{x}'\right|}\right)da'$$ The program gets the integrand and performs the integral on two different surfaces and finds the magnetic field in 2D.

Algorithm

1. The program asks you to choose for the geometry of magnetic field you wank to find. (1-for Box 2D magnet 2-for Horseshoe Moon magnet)
2. The program generates 30X30 2D array (x,y coordinates) of structure type variables that will store 2 magnetic field components and the magnitude of the field.
3. Contour of the magnet with constant magnetization is placed in the middle.
4. The program calcualtes the magnetic field outside the contour of the magnet.
5. The program calculates discretized integral on the contour of the magnet with $dx=1$ in units of the grid. Three components of the stucture (two magnetic field components and the magnitude) calculated in every point out of the magnet contour.
6. The program outputs coordinates, magnetic field components and a flag that means the relative magnitude of the field. This flag is a capital letter that can be interpretated as color in Aviz software of other program. The output file is .XYZ file that can be opened by Aviz and than the magnetic field can be illustrated, examples can be seen in "Results" section. For more concrete instructions to Aviz go to "Program".

References

[1] Ferromagnetism
[2] Classical electrodynamics,Chapter 5,John David Jackson