Currents in wires produce magnetic fields. What produces the magnetic field from a bar magnet, where there are no wires? Why does that field look like the field of a solenoid?
Consider the Bohr model of the atom, where electrons travel in circular orbits around the nucleus. An electron in a circular orbit looks like a current loop, with a current:
I = e/T = ev/2πr
A current loop has a magnetic moment μ, so for the orbiting electron we get:
μ = IA = (ev/2πr) * (πr2) = evr/2
If we multiply top and bottom by m, the electron mass, we get mvr in the numerator. This is the orbital angular momentum of the electron, L.
Therefore, by the Bohr model, μ = eL/2m. The orbital magnetic moment of the electron is proportional to its orbital angular momentum. The orbital angular momentum is quantized in multiples of h_bar = h/2π, where h is Planck's constant. The Bohr model is rather simplistic; an analysis using quantum mechanics shows that the smallest non-zero value of the electron's orbital magnetic moment is:
μ = (2)1/2 e h_bar /2m
Another contribution to an atom's magnetic moment comes from electron spin. The magnetic moment associated with electron spin is:
μspin = e h_bar/2m
This combination of factors is known as the Bohr magneton:
μB = e h_bar/2m = 9.27 x 10-27 J/T
The net magnetic moment of an atom is the vector sum of its orbital and spin magnetic moments. Many materials are not magnetic (i.e., they don't act like bar magnets) because the magnetic moments completely or mostly cancel. In materials you can make bar magnets out of, however, neighboring atoms interact in such a way that their magnetic moments are aligned. In other words, the material acts like one big current loop, producing a magnetic field.