Magnetic energy and electrostatic potential energy are related by Maxwell's equations. The potential energy of a magnet or magnetic moment in a magnetic field is defined as the mechanical work of the magnetic force (actually magnetic torque) on the re-alignment of the vector of the magnetic dipole moment and is equal to: while the energy stored in an inductor (of inductance ) when a current flows through it is given by: This second expression forms the basis for superconducting magnetic energy storage.