
Consider a long solenoid having length, I near the middle, cross-sectional area A and carrying a current i through it. The volume associated with length I will be A.I. The energy stored will be uniformly distributed within the volume, as the magnetic field \(\bar{B}\) is uniform everywhere inside the solenoid.
Thus, the energy stored, per unit volume, in the magnetic field is
\(u_B=\frac{U_B}{A . l}\) .....(1)
We know energy stored in magnetic field is \(u_B=\frac{1}{2} L I^2\)
\(u_B=\frac{1}{2} L I^2 \times \frac{1}{A . l}=\left(\frac{L}{l}\right) \frac{I^2}{2 A}\) .....(2)
For a long solenoid, the inductance (L) per unit length is given by,
\(\left(\frac{L}{l}\right)=\mu_0 n^2 A\)
Equation (2) becomes
\(u_B=\mu_0 n^2 A \cdot \frac{I^2}{2 A}\)
\(=\frac{1}{2} \mu_0 n^2 I^2\) .....(3)
For a solenoid, the magnetic field at the interior points is
\(B=\mu_0 n I \)
\(u_B=\frac{B^2}{2 \mu_0}\) .....(4)
This gives the energy density stored at any point where magnetic field is B.