Magnetic Potential Energy
A magnetic dipole moment in a magnetic field will possess potential energy which depends upon its orientation with respect to the magnetic field. Since magnetic sources are inherently dipole sources which can be visualized as a current loop with current I and area A, the energy is usually expressed in terms of the magnetic dipole moment:
The energy is expressed as a scalar product, and implies that the energy is lowest when the magnetic moment is aligned with the magnetic field. The difference in energy between aligned and anti-aligned is
The expression for magnetic potential energy can be developed from the expression for the magnetic torque on a current loop.
Magnetic field concepts
Currents as magnetic sources