Coil calculations

$\require{cancel}$
The complexity of calculating the magnetic field and electrical properties of a coil depends on the desired accuracy[1]. We will start with a simple model to build some intuition on the problem. We will later consider a more sophisticated model to address the intricacies of practical devices. Figure 1 illustrates a coil of wire carrying a current.
An illustration of current carrying solenoid of height $H$ and radius $R$.

Figure 1: An illustration of current carrying solenoid of height \(H\) and radius \(R\).

We will take a deep dive into the physics of coils to compute certain geometrical and electrical properties based on practical considerations such as packing density and insulation thickness.

Magnetic Field

The calculation of the magnetic field is no simple task. We will start with a back of the envelope calculation.

A simple model

To get a feel for the overall magnetic field strength, let us start with a simplified case in which the solenoid is very tall compared to its width, i.e., \(H\gg R\), and has many turns \(N\gg 1.\) We will first be interested in what is going on inside the coil. In the steady state, we can calculate the magnetic field using Ampere’s law:

\[\begin{eqnarray} \mathbf{\nabla}\times\mathbf{B} &=& \mu_0 \mathbf{J} \tag{1}, \end{eqnarray}\] or equivalently the integral version of it:

\[\begin{eqnarray} \int d\mathbf{S} \cdot \mathbf{\nabla}\times\mathbf{B} = \oint d\boldsymbol\ell \cdot \mathbf{B}= \mu_0\int d\mathbf{S} \cdot \mathbf{J} \tag{2}. \end{eqnarray}\] The integration surface \(d\mathbf{S}\) is bounded by the closed loop \(d\boldsymbol\ell\) as shown in red in Figure 2.

At the lowest order approximation, the field outside the coil is negligible. The $z$ component of the field is also constant in this limit.

Figure 2: At the lowest order approximation, the field outside the coil is negligible. The \(z\) component of the field is also constant in this limit.

The magnetic field outside the coil will be zero in this approximation (up to \(1/N\) terms). The amount of current passing through the surface is given by \(I\times\text{Number of of turns in the loop}=I\times \frac{N}{H} l\). Furthermore, the only contribution to the line integral comes from the path inside the coil which gives \(l B_z\). Therefore we get the following simple expression for the magnetic field inside the coil: \[\begin{eqnarray} B_z =\mu_0 I\times \frac{N}{H} =\mu_0 I n \tag{3}, \end{eqnarray}\] where \(n\equiv\frac{N}{H}\) is the number of turns per unit length. Self inductance of a coil is defined as the magnetic flux linkage per unit current in the loop : \[\begin{eqnarray} L_c =\frac{\Phi}{I}= \frac{N \, \text{Area}\, B_z}{I} =\mu_0\frac{ A N^2}{H} \tag{4}, \end{eqnarray}\]

Note that if we had some magnetic material inside the coil, the magnetic field would have been different. If the material is fully inserted, we can simply replace \(\mu_0\) with \(\mu_c\), which is the permeability of the material. In such cases, the magnetic field becomes: \[\begin{eqnarray} B_z =\mu_c I\times \frac{N}{H} =\mu_c I n \tag{5}, \end{eqnarray}\]

A more realistic model

We need a more precise model of the magnetic field created by the solenoid. Let us start simple and look at the magnetic field of a single circular loop with a current as in Fig. 3.
A single loop of current. We are mostly interested in the field on the $z$ axis.

Figure 3: A single loop of current. We are mostly interested in the field on the \(z\) axis.

The magnetic field at an arbitrary point \(\mathbf{r}\) is given by the Biot-Savart law[2]: \[\begin{eqnarray} \mathbf{B}(\mathbf{r}) &=&\frac{\mu_0 }{4\pi}\int_c \frac{I d\boldsymbol{\ell}' \times ( \mathbf{r}- \mathbf{r}')}{ ( \mathbf {r}- \mathbf {r}')^3}, \tag{6} \end{eqnarray}\] where we use the primed coordinates for the source points.

We will be mostly interested in the \(\mathbf{\hat {z}}\) component of the magnetic field on the \(z\)-axis, and this will simplify our life immensely: \(\mathbf{r}=z\mathbf{\hat {z}}\) , \(d\boldsymbol{\ell}' = d\ell '\mathbf{\hat\phi'}\), and \(\mathbf{r}-\mathbf{r'} =z\mathbf{\hat z}-R \mathbf{\hat r}\) giving \(d\boldsymbol{\ell}' \times (\mathbf{\hat {r}}-\mathbf{\hat {r}'})= d\ell \left(z \mathbf{\hat {r}} + R\mathbf{\hat {z}}\right)\). Furthermore \(|\mathbf{r}-\mathbf{r'}|=\sqrt{R^2+z^2}\), and \(d \ell '=Rd\phi'\). Therefore the magnetic field on the \(z\) axis is the following: \[\begin{eqnarray} \mathbf{B}(\mathbf{r}) &=& \frac{\mu_0 I }{4\pi}\int_c \frac{Rd\phi' \left(z \mathbf{\hat {r}} + R\mathbf{\hat {z}}\right) }{ \left(R^2+z^2\right)^\frac{3}{2}} = \frac{\mu_0 I }{4\pi}\cancelto{0}{\int_c \frac{ Rd\phi' z \mathbf{\hat {r}} }{ \left(R^2+z^2\right)^\frac{3}{2}}}+ \frac{\mu_0 I R^2 }{4\pi}\int_c \frac{ d\phi' \mathbf{\hat {z}} }{ \left(R^2+z^2\right)^\frac{3}{2}} = \frac{ \mu_0 I R^2 }{ 2 \left(R^2+z^2\right)^\frac{3}{2}} \mathbf{\hat {z}} \tag{7}, \end{eqnarray}\] where the component along \(\mathbf{\hat {r}}\) drops off due to symmetry as we integrate over \(\phi'\). The magnetic field in Eq. (7) has its maximum value at \(z=0\), and we can expand it around \(z=0\) for small \(z\) to get the following:

\[\begin{eqnarray} \mathbf{B}(\mathbf{r}) &=& \frac{ \mu_0 I }{ 2 R \left(1+\frac{z^2}{R^2}\right)^\frac{3}{2}} \mathbf{\hat {z}}\simeq \frac{ \mu_0 I }{ 2 R} \left( 1- \frac{3}{2}\frac{z^2}{R^2} \right) \mathbf{\hat {z}} \tag{8}, \end{eqnarray}\] which shows that it can be modeled as a quadratic function around the origin.

Figure 3 shows a single loop sitting at \(z=0\). If the solenoid has a finite height, let’s call it \(H\), it will be many such single loops stacked on top of each other. Let’s label the positions of these loops as \(z'\). If we take a small slice of these loops from \(z'\) to \(z'+dz'\), the current in this slice will be \(dI=N I \frac{dz'}{H}\), which is simply the number turns per length times the length \(dz'\). Now the magnetic field becomes:

\[\begin{eqnarray} \mathbf{B}(\mathbf{r}) &=& \frac{ N \mu_0 I }{ 2 R H} \int_{-H/2}^{H/2} \frac{dz'}{ \left(1+(z-z')^2/R^2\right)^\frac{3}{2}} \mathbf{\hat {z}} =\frac{ N \mu_0 I }{ 2 H} \int_{\frac{z+H/2}{R}}^{\frac{z-H/2}{R}} \frac{d s}{ \left(1+s^2\right)^\frac{3}{2}} \mathbf{\hat {z}} =\frac{ N \mu_0 I }{ 2 H} \int_{\theta_1}^{\theta_2} \frac{\sec^2\theta d\theta }{ \left(1+\tan^2\theta\right)^\frac{3}{2}} \mathbf{\hat {z}}\nonumber\\ &=&\frac{ N \mu_0 I }{ 2 H }\left( \frac{H/2 -z}{\sqrt{ R^2 +(H/2-z)^2}}+\frac{H/2 +z}{\sqrt{ R^2 +(H/2+z)^2} } \right) \mathbf{\hat {z}} \tag{9}. \end{eqnarray}\]

Equation (9) accounts for the finite height of the coil, and expanding it around \(z=0\) gives the quadratic term: \[\begin{eqnarray} \frac{ N \mu_0 I }{ 2 }\left( \frac{48 R^2 }{\left(H^2+ 4R^2\right)^{5/2}} \right) z^2, \tag{10} \end{eqnarray}\] which goes like \(1/H^4\) for large \(H\)1 . In other words, the magnetic field becomes pretty flat inside the solenoid if \(H\) is large. Tall solenoids won’t apply a strong restoring force close to the middle point.

It is interesting to note that if one inserts a permanent magnet with moment \(\mathbf{M}\) close to the center, it will couple to this magnetic fields as \(\propto -\mathbf{M}\cdot \mathbf{B}\propto z^2\), which will be simple harmonic oscillator.

Series expansion

The calculation of the magnetic field off the \(z\) axis is a bit much more involved.
This will scare away faint-hearted people, but we have to do this. Embrace for some fancy math!

Figure 4: This will scare away faint-hearted people, but we have to do this. Embrace for some fancy math!

The complete computation of the magnetic field will result in elliptical integrals[3]. The corresponding inductance will also involve elliptical integrals. We will avoid the elliptic integrals for now by settling for the an approximate solution. We have calculated the magnetic field on the central axis in Eq. (9), and that can enable us to step off the axis. We can start from the Ampere’s law, Eq. (1) in the absence of sources: \[\begin{eqnarray} \mathbf{\nabla}\times\mathbf{B} &=& 0 \tag{11}. \end{eqnarray}\] Since the curl of \(\mathbf{B}\) is \(0\), from the fundamental theorem of vector calculus, we know that \(\mathbf{B}\) can be written as the gradient of a magnetic scalar potential: \[\begin{eqnarray} \mathbf{B} &=& -\mathbf{\nabla} \psi \tag{12}. \end{eqnarray}\] Furthermore, since there are no magnetic monopoles, \(\mathbf{B}\) is also divergence free: \[\begin{eqnarray} \mathbf{\nabla}\cdot\mathbf{B}= -\mathbf{\nabla}^2 \psi=0 \tag{13}. \end{eqnarray}\]

We would like solve the Laplace’s equation in spherical coordinates as illustrated in Fig. 5.
The spherical coordinates.

Figure 5: The spherical coordinates.

In the spherical coordinates, the Laplace equation reads: \[\begin{eqnarray} \nabla ^2\psi = \left[ \frac{1}{r^2}\frac{\partial }{\partial r}\left( {r^2\frac{\partial }{\partial r}} \right)+ \frac{1}{r^2\sin \theta }\frac{\partial }{\partial \theta }\left( {\sin \theta \frac{\partial }{\partial \theta }} \right) +{ \frac{1}{r^2\sin ^2\theta }\frac{\partial ^2 }{\partial \phi ^2}} \right]\psi \tag{14}. \end{eqnarray}\]

We can separate the variables as \(\psi(r,\theta,\phi)=R(r)\Theta(\theta)\Phi(\phi)\): \[\begin{eqnarray} \frac{\Theta\Phi}{r^2}\frac{d}{d r}\left(r^2\frac{d R }{d r}\right) +\frac{R\Phi}{r^2\sin\theta}\frac{d }{d\theta}\left(\sin\theta \frac{ d \Theta}{d\theta}\right)+ \frac{ R\Theta}{r^2\sin ^2\theta }\frac{\partial ^2 \Phi}{\partial \phi ^2}=0 \tag{15}, \end{eqnarray}\] or equivalently \[\begin{eqnarray} \frac{\sin^2\theta}{R}\frac{d}{d r}\left(r^2\frac{d R }{d r}\right) +\frac{\sin\theta}{\Theta}\frac{d }{d\theta}\left(\sin\theta \frac{ d \Theta}{d\theta}\right)=- \frac{ 1}{\Phi }\frac{\partial ^2 \Phi}{\partial \phi ^2}. \tag{16} \end{eqnarray}\] Since the left-hand side of Eq. (16) depends on \(r\) and \(\theta\) only, and the right one depends on \(\phi\) only, overall they can only be equal to a constant, which we will call \(m^2\). This separates out the \(\Phi\) function. Furthermore, since \(\phi\) is the angle, the solutions have to be \(2\pi\) periodic, which gives: \[\begin{eqnarray} \Phi(\phi)=e^{i m\phi} \tag{17}. \end{eqnarray}\] Putting this back in Eq. (16) and dividing the it by \(\sin^2\theta\) we get: \[\begin{eqnarray} \frac{1}{R}\frac{d}{d r}\left(r^2\frac{d R }{d r}\right)= -\frac{1}{\sin\theta \Theta}\frac{d }{d\theta}\left(\sin\theta \frac{ d \Theta}{d\theta}\right) -\frac{m^2}{\sin^2\theta} \tag{18}. \end{eqnarray}\] Similarly, since the left-hand side of Eq. (18) depends on \(r\) only, and the right one depends on \(\theta\) only, overall they can only be equal to a constant, which we will call \(c\).

Radial dependence

The form of the solution for \(R(r)\) is easy to guess since the derivatives are balanced by the powers of \(r\), and therefore, a function of the form \(r^l\) will preserve its form up to a coefficient.

\[\begin{eqnarray} \frac{d}{d r}\left(r^2\frac{d r^l }{d r}\right)-c r^l=\left[ l(l+1)-c\right]r^l=0 \implies c=l(l+1). \tag{19} \end{eqnarray}\] However, notice the unexpected symmetry of \(l(l+1)\) under \(l\to-l-1\). This means, if \(r^l\) is a solution, so is \(r^{-l-1}\). This suggests the following form of solution for \(R\): \[\begin{eqnarray} R(r)=a_l r^l +\frac{b_l}{r^{l+1}}. \tag{20} \end{eqnarray}\]

Angular part

Putting this back in Eq. (18) yields \[\begin{eqnarray} \frac{1}{\sin\theta}\frac{d }{d\theta}\left(\sin\theta \frac{ d \Theta}{d\theta}\right) +\left[l(l+1)-\frac{m^2}{\sin^2\theta} \right]\Theta =0. \tag{21} \end{eqnarray}\] Now define \(\cos\theta=x\), which gives \(\frac{d}{d\theta}=\frac{dx}{d\theta}\frac{d}{dx}=-\sin\theta \frac{d}{dx}\) and insert this back in Eq.(21): \[\begin{eqnarray} (1-x^2)\frac{d^2 \Theta}{dx^2}-2x\frac{d\Theta}{dx} +\left[l(l+1)-\frac{m^2}{1-x^2} \right]\Theta =0. \tag{22} \end{eqnarray}\] Let’s first attempt to solve this for \(m=0\) using power series expansion[4]:

\[\begin{eqnarray} \Theta(x)=\sum_{k=0}^\infty c_k x^k. \tag{23} \end{eqnarray}\] Inserting this back to Eq. (22) we get:

\[\begin{eqnarray} 0&=&\sum_{k=0}^\infty c_k x^{k-2}k(k-1)-\sum_{k=0}^\infty c_k x^{k}k(k-1)+\sum_{k=0}^\infty c_k x^k \left[l(l+1)-2k\right]\nonumber\\ &=&\sum_{k=2}^\infty c_k x^{k-2}k(k-1)-\sum_{k=0}^\infty c_k x^{k}k(k-1)+\sum_{k=0}^\infty c_k x^k \left[l(l+1)-2k\right]\nonumber\\ &=& \sum_{k=0}^\infty c_{k+2} x^{k}(k+2)(k+1)+\sum_{k=0}^\infty c_k x^k \left[l(l+1)-k(k+1)\right]\nonumber\\ &=& \sum_{k=0}^\infty \left\{ c_{k+2} (k+2)(k+1)- c_k \left[k(k+1)-l(l+1)\right]\right\} x^{k} . \tag{24} \end{eqnarray}\] This implies \[\begin{eqnarray} c_{k+2}=\frac{k(k+1)-l(l+1)}{ (k+2)(k+1)} c_k =\frac{(k-l)(l+k+1)}{ (k+2)(k+1)} c_k , \tag{25} \end{eqnarray}\] which is the recurrence equation for the expansion coefficients.

This is a remarkable equation since it has profound consequences. Earlier in this blog, we looked at the Quantum Harmonic Oscillator and showed that for a similar series expansion to converge, we had to have the energy quantized. In this particular problem, until this point, we have no indication of \(l\) being an integer. But now, we see that it has to be an integer so that the series truncates for \(k>l\) (for every other \(k\)). That’s the first observation.

The second observation is associated with the parity symmetry of the original differential Eq. (22), which is invariant under \(x\to-x\) upto the overall sign. This shows that the solutions will also be eigenstates of the parity operator, i.e., odd and even \(k\) terms should not mix.

We have a couple of ways of terminating the series. The first one is what we have discussed above, i.e., settin \(l\) to an integer \(k^*\), which will zero out every other \(c_k\). The \(c_k\)’s, with \(k>l\), not addressed by this truncation need to be eliminated directly by their root coefficient, \(c_0\) or \(c_1\). To be more specific, take an example \(l=1\). The \(c_k\)’s with odd \(k\) quickly terminate after \(k=1\): \(c_1,0,\cdots\). The even ones will keep growing: \(c_0, \alpha c_0,\beta\alpha c_0,\cdots\). The only way to tame this series is by killing it at its root, i.e., by setting it \(a_0=0\) so that all the even terms drop out. This shows that even odd powers of \(x\) will not mix preserving respecting the parity symmetry of the original equation.

From Eq. (25), we can explicitly write the fist few Legendre polynomials: \[\begin{eqnarray} P_0(x)&=&1,\nonumber\\ P_1(x)&=&x,\nonumber\\ P_2(x)&=&\frac{1}{2}(3x^2-1),\nonumber\\ P_3(x)&=&\frac{1}{2}(5x^3-3x),\nonumber\\ P_4(x)&=&\frac{1}{8}(35x^4-30x^2+3). \tag{26} \end{eqnarray}\]

Having shown that Legendre polynomials solve the differential equation (with \(m=0\)), \[\begin{eqnarray} (1-x^2)\frac{d^2 P_l}{dx^2}-2x\frac{dP_l}{dx} +l(l+1)P_l =0. \tag{27} \end{eqnarray}\] We now need to address the full equation with \(m\neq 0\). The idea would be to differentiate \(m\) times to create the \(m^2\) term. For this, we will need the Leibniz’s formula: \[\begin{eqnarray} \frac{d^m}{dx^m}\left[f(x)g(x)\right]=\sum_{k=0}^n {n \choose k} \frac{d^k f}{dx^k}\frac{d^{n-k}g}{dx^{n-k}} \tag{28} \end{eqnarray}\] Let’s dive into the differentiation: \[\begin{eqnarray} 0&=&\frac{d^m}{dx^m}\left[(1-x^2)\frac{d^2 P_l}{dx^2}-2x\frac{dP_l}{dx} +l(l+1) P_l\right]\nonumber\\ &=&(1-x^2)\frac{d^m}{dx^m}\frac{d^2 P_l}{dx^2}+m\frac{d}{dx}(1-x^2)\frac{d^{m-1}}{dx^{m-1 }}\frac{d^2 P_l}{dx^2} +\frac{m(m-1)}{2}\frac{d^2}{dx^2}(1-x^2)\frac{d^{m-2}}{dx^{m-2 }}\frac{d^2 P_l}{dx^2} \nonumber\\ &&-2x\frac{d^m}{dx^m}\frac{dP_l}{dx}-2m\frac{d}{dx}( x) \frac{d^{m-1} }{dx^{m-1} }\frac{dP_l}{dx} +l(l+1) \frac{d^m}{dx^m} P_l\nonumber\\ &=&(1-x^2)u''-2mx u' -m(m-1)u-2xu' -2mu +l(l+1)u\nonumber\\ &=&(1-x^2)u''-2(m+1)x u' - m(m+1)u +l(l+1)u\nonumber\\ &=&(1-x^2)u''-2(m+1)x u' - (l-m)(l+m+1)u \tag{29}, \end{eqnarray}\] where \(u\equiv\frac{d^m P_l}{dx^m}\). We still need to modify the equation further so that it matches Eq.(22). First of all, we note that the equation we want to get at was self-adjoint, and we kind of destroyed it as we acted with \(\frac{d^m}{dx^m}\). Let’s restore it and see where it takes us.

Sturm–Liouville theory

We are going to use some machinery from Sturm–Liouville theory on second order differential equations. Consider the second order differential operator \(\mathcal{L}\)[4]:

\[\begin{eqnarray} \mathcal{L} u=\left(p_0(x)\frac{d^2 }{dx^2}+p_1(x) \frac{d }{dx} +p_2(x)\right)u \tag{30}. \end{eqnarray}\] We are going to define the inner product in the function space as an integral in a range \([a,b]\). \[\begin{eqnarray} \langle u| \mathcal{L}| u\rangle\equiv \int_a^b dx u(x) \mathcal{L} u(x)= \int_a^b dx u(x)\left(p_0\frac{d^2 }{dx^2}+p_1 \frac{d }{dx} +p_2\right)u= \int_a^b dx \left( p_0 u u'' + p_1 u u' +u^2 p_2\right) \tag{31}. \end{eqnarray}\] We can integrate Eq.(31) by parts. Let’s look at each term one by one:

\[\begin{eqnarray} u p_0 u'' &=& u \frac{d^2 }{dx^2}(p_0 u)-\frac{d}{dx}(up'_0 u)+2 u p'_0u' \nonumber\\ u p_1 u' &=& - u \frac{d }{dx}(p_1 u)+\frac{d}{dx}(u p_1 u) \tag{32}. \end{eqnarray}\] Putting this back in Eq.(31) gives:

\[\begin{eqnarray} \langle u| \mathcal{L}| u\rangle &=& \left[u(p_1-p_0')u \right]_a^b+ \int_a^b dx u\left(\frac{d^2 }{dx^2}(p_0 u) -\frac{d }{dx}(p_1 u) +p_2 u\right)\nonumber\\ &=&\left[u(p_1-p_0')u \right]_a^b+ \int_a^b dx u \bar{\mathcal{L}}u, \tag{33} \end{eqnarray}\] where the adjoint operator \(\bar{\mathcal{L}}\) is defined as: \[\begin{eqnarray} \bar{\mathcal{L}}u=\frac{d^2 }{dx^2}(p_0 u) -\frac{d }{dx}(p_1 u) +p_2 u. \tag{34} \end{eqnarray}\] Although \(\bar{\mathcal{L}}u\) looks pretty different from \({\mathcal{L}}u\) in Eq. (30), they can actually be the same if \(p_1=p'_0\). Such \(\mathcal{L}\) operators are self-adjoint. Furthermore, note that the boundary term also drops out for self-adjoint operators.

The good news is that if an equation is not self adjoint, it can be converted into that form if it gets multiplied by the following factor: \[\begin{eqnarray} \frac{1}{p_0(x)}\text{exp}\left\{\int^x dt \frac{p_1(t)}{p_0(t)}\right\}. \tag{35} \end{eqnarray}\]

Let’s revisit Eq. (29) to find the factor that will make the equation self-adjoint: \[\begin{eqnarray} \frac{1}{1-x^2}\text{exp}\left\{-\int^x dt \frac{2(m+1)t}{1-t^2}\right\}= \frac{1}{1-x^2}\text{exp}\left\{(m+1)\int^x \frac{d(1-t^2)}{1-t^2}\right\} =(1-x^2)^{m}. \tag{36} \end{eqnarray}\] We will take this factor, multiply Eq. (29) with it to get:

\[\begin{eqnarray} \frac{d}{dx}\left((1-x^2)^{m+1}u'\right) - (l-m)(l+m+1)u=0 \tag{37}. \end{eqnarray}\] Finally, we will want to absord half power of that coefficient into \(u\) by defining \[\begin{eqnarray} v(x)=(1-x^2)^{\frac{m}{2}} u(x) \iff u(x)=(1-x^2)^{-\frac{m}{2}} v(x) \tag{38}, \end{eqnarray}\] to get \[\begin{eqnarray} u'&=&\left[ v' +\frac{m v x}{1-x^2}\right](1-x^2)^{-\frac{m}{2}},\nonumber\\ u''&=&\left[ v'' +\frac{2m v' x}{1-x^2}+\frac{m x}{1-x^2}+\frac{m (m+2) x^2 v}{(1-x^2)^2} \right](1-x^2)^{-\frac{m}{2}} \tag{39}. \end{eqnarray}\] The new function \(v\) satisfies the following equation:

\[\begin{eqnarray} (1-x^2)\frac{d^2 v}{dx^2}-2x\frac{d v}{dx} +\left(l(l+1)-\frac{m^2}{1-x^2} \right) v =0 \tag{40}, \end{eqnarray}\] which is identical to Eq. (22). In conclusion, the angular part of the solution is given by the associated Legendre polynomials as below: \[\begin{eqnarray} P_l^m(x)=(1-x^2)^{\frac{m}{2}}\frac{d^m }{dx^m} P_l(x) \tag{41}. \end{eqnarray}\]

Full solution

Note that the highest power in \(P_l\) is \(l\), and for \(m>l\), we run out of \(x\)’s to differentiate. This automatically limits \(|m|\) to \(l\). Putting all pieces together, the full solution to the Laplace equation reads:

\[\begin{eqnarray} \psi(r,\theta,\phi)=R(r)\Theta(\theta)\Phi(\phi)= \sum_{l=0}^\infty \sum_{m=-l}^l \left(a_{lm} r^l +\frac{b_{lm}}{r^{l+1}}\right) P_l^m(\cos\theta)e^{im \phi}. \tag{42} \end{eqnarray}\] In the case of symmetric coils, only \(m=0\) will contribute. Furthermore, for the solution inside the coil, we need to set \(b_l=0\) so that the solution stays finite: \[\begin{eqnarray} \psi(r,\theta,\phi)=\sum_{l=0}^\infty a_{l} r^l P_l(\cos\theta). \tag{43} \end{eqnarray}\]

The magneto-static potential becomes a sum of Legendre polynomials[5]: \[\begin{equation} \psi(r,\theta)=a_{0}+a_{1}rP_{1}(\cos \theta)+a_{2}r^{2}P_{2}(\cos \theta)+a_{3}r^{3}P_{3}(\cos \theta)+ \ldots . \tag{44} \end{equation}\] We can evaluate Eq. (44) on the \(z-\)axis, i.e., \(\cos \theta =1\) and \(r=z\), to get: \[\begin{equation} \psi(z)=a_{0}+a_{1}z+a_{2}z^{2}+a_{3}z^{3}+ \cdots , \tag{45} \end{equation}\] which should be a familiar form since it is also the Taylor expansion. The trick here is to calculate the coefficients by matching the corresponding magnetic field with the expression we calculated earlier in Eq. (9). We first need to calculate the vector potential from Eq. (9):

\[\begin{eqnarray} \psi(z)&=&-\int^z d\tilde z B( \tilde z) =-\int^z d\tilde z\frac{ N \mu_0 I }{ 2 H }\left( \frac{H/2 -\tilde z}{\sqrt{ R^2 +(H/2-\tilde z)^2}}+\frac{H/2 +\tilde z}{\sqrt{ R^2 +(H/2+\tilde z)^2} } \right)\nonumber\\ &=&-\frac{ N \mu_0 I }{ 2 H }\left(\sqrt{ R^2 +(H/2+\tilde z)^2} -\sqrt{ R^2 +(H/2-\tilde z)^2}\right) =-\frac{ N \mu_0 I }{ \sqrt{ 4 R^2 +H^2} } z +\frac{8 N R^2 \mu_0 I }{ ( 4 R^2 +H^2)^{5/2} } z^3+\cdots \tag{46}. \end{eqnarray}\] Comparing the expansion above with Eq. (45) we can read \(a_0=0\), \(a_1=-\frac{ N \mu_0 I }{ \sqrt{ 4 R^2 +H^2} }\), \(a_2=0\), and \(a_3=\frac{8 N R^2 \mu_0 I }{ ( 4 R^2 +H^2)^{5/2} }\). Putting these back into Eq. (44) along with the Legendre polynomials from Eq. (26), we get 2:

\[\begin{equation} \psi(r,\theta)\simeq -\frac{ N \mu_0 I }{ \sqrt{ 4 R^2 +H^2} } \cos \theta\, r+\frac{4 N R^2 \mu_0 I }{ ( 4 R^2 +H^2)^{5/2} }(5\cos^3\theta-3\cos\theta)\,r^3. \tag{47} \end{equation}\]

Now we can use Eq.(12) to compute the components of the magnetic field:

\[\begin{eqnarray} B_{r} &=& -\frac{\partial\psi(r,\theta)}{\partial r} \simeq \frac{ N \mu_0 I }{ \sqrt{ 4 R^2 +H^2} } \cos \theta-\frac{12 N R^2 \mu_0 I }{ ( 4 R^2 +H^2)^{5/2} }(5\cos^3\theta-3\cos\theta)\,r^2,\nonumber\\ B_{\theta} &=& -\frac{1}{r}\frac{\partial\psi(r,\theta)}{\partial\theta} \simeq -\frac{ N \mu_0 I }{ \sqrt{ 4 R^2 +H^2} } \sin \theta-\frac{12 N R^2 \mu_0 I }{ ( 4 R^2 +H^2)^{5/2} }(\sin\theta-5\cos^2\theta\sin\theta)\,r^2. \tag{48} \end{eqnarray}\]

If we wanted to switch to cylindrical coordinates we can do that by rotating the vector: \[\begin{eqnarray} \begin{pmatrix} B_z \\ B_\rho \end{pmatrix} = \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix} \begin{pmatrix} B_{r} \\ B_{\theta} \end{pmatrix}. \tag{49} \end{eqnarray}\]

Elliptic Integrals

We will now derive the expression for the magnetic field created by a thin solenoid. While we are here, it will be instructive to solve this problem so that we first get the magnetic field for a compact coil. We can then integrate to get the result for the solenoid. The magnetic field at an arbitrary point \(\mathbf{r}\) is given by the Biot-Savart law integrated over sources: \[\begin{eqnarray} \mathbf{B}(\mathbf{r}) &=& \frac{ \mu_0 I }{ 4 \pi H } \int_c \frac{ d\boldsymbol{\ell}' \times ( \mathbf{r}- \mathbf{r}')}{ ( \mathbf {r}- \mathbf {r}')^3} \tag{50}. \end{eqnarray}\] Equivalently, we can first compute the vector potential and then take its curl. In a generic representation, the vector potential is expressed as follows[1]:

\[\begin{eqnarray} \mathbf{A}(\mathbf{r}) &=& \frac{ \mu_0 }{ 4 \pi } \int d^3 \mathbf{r'} \frac{\mathbf{J}(\mathbf{r'})}{ | \mathbf {r}- \mathbf {r}'|} \tag{51}, \end{eqnarray}\] where \(\mathbf{J}\) is the current density.

Single loop

Let’s take a closer look at the field at a generic point \(\mathbf{r}\) created by a single loop, as illustrated Fig. 6.
A single loop of current. We are now interested in the field at a generic point $\mathbf{r}$.

Figure 6: A single loop of current. We are now interested in the field at a generic point \(\mathbf{r}\).

For a single loop sitting at \(z=0\) with radius \(r=R\), it is convenient to work in spherical coordinates. \[\begin{eqnarray} \mathbf{J}_s(\mathbf{r}') &=& \lambda \delta(r'-R)\delta(\cos \theta')\hat{\mathbf{\varphi}'} =\lambda \delta(r'-R)\delta(\cos \theta')\left(\cos\varphi' \hat{\mathbf{j}}-\sin\varphi'\hat{\mathbf{i}} \right) \tag{52}, \end{eqnarray}\] where \(\lambda\) is the current density. In order to calculate \(\lambda\) for a loop of wire carrying a current \(I\), let’s intercept the loop with an area perpendicular to it. We can do that by selecting an area on, say, positive \(x\) axis ( i.e., \(\varphi'=0\)), pointing along the \(y\) axis, i.e., \(d\mathbf{S}'= dS' \hat{\mathbf{j}}=r'dr'd\theta' \hat{\mathbf{j}}\). Integrating the current density on this area we should get the total current: \[\begin{eqnarray} \int_S d\mathbf{S}' \cdot \mathbf{J}(\mathbf{r}) &=& \int_S r'dr'd\theta' \lambda \delta(r'-R)\delta(\cos \theta')\hat{\mathbf{j}}\cdot\left(\cos\varphi' \hat{\mathbf{j}}-\sin\varphi'\hat{\mathbf{i}} \right)\bigg\rvert_{\varphi'=0}=R\lambda =I \implies \lambda=I/R \tag{53}. \end{eqnarray}\] Therefore, the properly normalized current is \[\begin{eqnarray} \mathbf{J}_s(\mathbf{r}') &=& \frac{I}{R} \delta(r'-R)\delta(z'-z_s)\hat{\mathbf{\varphi}'} =\frac{I}{R}\delta(r'-R)\delta(\cos \theta')\left(\cos\varphi' \hat{\mathbf{j}}-\sin\varphi'\hat{\mathbf{i}} \right) \tag{54}. \end{eqnarray}\] Before we continue the calculation for a generic observation point \(\mathbf{r}\), let me throw you a curve-ball. Consider the vector potential on the \(z\) axis, i.e., \(\mathbf{r}=\mathbf{z}\). In this case, \(| \mathbf {r}- \mathbf {r}'|\) across the integration as can be seen from Fig. 6. Therefore the integration in Eq. (51) becomes: \(\propto \int_0^{2\pi}d\varphi \hat{\mathbf{\varphi}'}=0\). So the vector potential vanishes on the \(z\) axis. Since \(\mathbf{B}=\mathbf{\nabla}\times \mathbf{A}\), the magnetic field should vanish too! But, we calculated the magnetic field on the \(z\) axis in Eq. (8) and it is clearly non-zero. What went wrong? Here is the problem: if you are cooking a function to take the derivative later, that function has to be defined in the vicinity of the points you will take derivatives. More specifically, you can’t compute \(\mathbf{A}\) on only the \(z\) axis and expect to be able to take its curl since curl will by definition take its derivative stepping off of the \(z\) axis.

The integral we have to deal with for a single loop is this: \[\begin{eqnarray} \mathbf{A}_s(\mathbf{r}) &=& \frac{ \mu_0 }{ 4 \pi } \int d^3 \mathbf{r'} \frac{\mathbf{J}(\mathbf{r'})}{ | \mathbf {r}- \mathbf {r}'|}=\frac{ \mu_0 I }{ 4 \pi R } \int d^3 \mathbf{r'}\frac{1 }{ | \mathbf {r}- \mathbf {r}'|} \delta(r'-R)\delta(\cos\theta')\left(\cos\varphi' \hat{\mathbf{j}}-\sin\varphi'\hat{\mathbf{i}} \right) \tag{55}, \end{eqnarray}\] where we put the subscript \(s\) to remind us that this is for a single loop. We will parameterize the points on the loop centered at \(z=0\) as \(\mathbf {r}'= r' (\cos\varphi'\hat{\mathbf{i}}+\sin\varphi'\hat{\mathbf{j}})\), and the observation point as \(\mathbf {r}= r\cos\theta \hat{\mathbf {z}}+ r\sin\theta (\cos\varphi\hat{\mathbf{i}}+\sin\varphi\hat{\mathbf{j}})\)

\[\begin{eqnarray} | \mathbf {r}- \mathbf {r}'|&=& \sqrt{r^2\cos^2\theta +(r\sin\theta\cos\varphi -r'\cos\varphi')^2+(r\sin\theta\sin\varphi -r'\sin\varphi')^2}\nonumber\\ &=&\sqrt{r^2+r'^2 -2 r r'\sin\theta\cos(\varphi'-\varphi)} \tag{56}. \end{eqnarray}\] Note that the problem has rotational symmetry. We can rotate our coordinate system such that the observation point sits on \(y=0\), i.e., \(\varphi=0\). Once we are done with the computations, we can rotate the vectors back to general \(\mathbf{r}\) point. So let’s set \(\varphi=0\) in Eq. (56) and rewrite Eq. (55) :

\[\begin{eqnarray} \mathbf{A}_s(\mathbf{r}) &=& \frac{ \mu_0 I }{ 4 \pi R } \int \sin\theta' r'^2 dr' d\varphi' \frac{1 }{ \sqrt{r^2+r'^2 -2 r r'\sin\theta\cos(\varphi'-\varphi)}} \delta(r'-R)\delta(\cos\theta')\left(\cos\varphi' \hat{\mathbf{j}}-\sin\varphi'\hat{\mathbf{i}} \right)\nonumber\\ &=& \frac{ \mu_0 I R}{ 4 \pi } \int_{0}^{2\pi} d\varphi' \frac{\cos\varphi' \hat{\mathbf{j}} }{ \sqrt{r^2+R^2 -2 r R\sin\theta\cos(\varphi'-\varphi)}} -\cancelto{0}{\frac{ \mu_0 I R}{ 4 \pi } \int_{0}^{2\pi} d\varphi' \frac{\sin\varphi'\hat{\mathbf{i}} }{ \sqrt{r^2+R^2 -2 r R\sin\theta\cos(\varphi'-\varphi)}} } \tag{57}, \end{eqnarray}\] where the second term vanishes since the integrand is odd and the integral is evaluated over the full range. Note that we evaluated the integral at \(\varphi=0\), and the resulting potential points in \(\hat{\mathbf{j}}\) direction. For generic \(\varphi\) we can simply rotate the coordinate system about the \(z\) axis by \(\varphi\). In this rotated coordinate system \(\hat{\mathbf{j}}\rightarrow \hat{\mathbf{\varphi}}\). Therefore the vector potential reads: \[\begin{eqnarray} \mathbf{A}_s(\mathbf{r}) &=& \hat{\mathbf{\varphi}}\frac{ \mu_0 I R}{ 4 \pi } \int_{0}^{2\pi} d\varphi' \frac{\cos\varphi' }{ \sqrt{r^2+R^2 -2 r R\sin\theta\cos\varphi'}} \tag{58}. \end{eqnarray}\] Let’s define \(\phi'=\pi-\varphi'\) to get \(\cos\varphi'=-\cos\phi'\) and rewrite Eq. (58) as: \[\begin{eqnarray} \mathbf{A}_s(\mathbf{r}) &=& -\hat{\mathbf{\varphi}}\frac{ \mu_0 I R}{ 4 \pi } \int_{-\pi}^{\pi} d\phi' \frac{\cos\phi' }{ \sqrt{r^2+R^2 +2 r R\sin\theta\cos\phi'}} \tag{59}. \end{eqnarray}\] Let’s also use the half angle formula: \(\cos\phi'=1-2\sin^2\frac{\phi'}{2}\) and reorganize the integral: \[\begin{eqnarray} \mathbf{A}_s(\mathbf{r}) &=& -\hat{\mathbf{\varphi}}\frac{ \mu_0 I R}{ 4 \pi } \frac{1}{\sqrt{r^2+R^2 +2 r R\sin\theta}}\int_{-\pi}^{\pi} d\phi' \frac{1-2\sin^2\frac{\phi'}{2} }{ \sqrt{1 -\frac{4 r R\sin\theta}{r^2+R^2 +2 r R\sin\theta}\sin^2\frac{\phi'}{2}}}\nonumber\\ &\equiv& -\hat{\mathbf{\varphi}}\frac{ \mu_0 I R}{ 4 \pi } \frac{1}{\sqrt{r^2+R^2 +2 r R\sin\theta}}\int_{-\pi}^{\pi} d\phi' \frac{1-2\sin^2\frac{\phi'}{2} }{ \sqrt{1 -k^2\sin^2\frac{\phi'}{2}}} \nonumber\\ &=& -\hat{\mathbf{\varphi}}\frac{ \mu_0 I R}{ 4 \pi } \frac{1}{\sqrt{r^2+R^2 +2 r R\sin\theta}}\int_{-\pi}^{\pi} d\phi' \left[\frac{1 }{ \sqrt{1 -k^2\sin^2\frac{\phi'}{2}}}-2 \frac{\sin^2\frac{\phi'}{2} }{ \sqrt{1 -k^2\sin^2\frac{\phi'}{2}}}\right] \nonumber\\ &=& -\hat{\mathbf{\varphi}}\frac{ \mu_0 I R}{ 4 \pi } \frac{1}{\sqrt{r^2+R^2 +2 r R\sin\theta}}\int_{-\pi}^{\pi} d\phi' \left[\frac{1 }{ \sqrt{1 -k^2\sin^2\frac{\phi'}{2}}}-\frac{2}{k^2}\left( \frac{1 }{ \sqrt{1 -k^2\sin^2\frac{\phi'}{2}}}- \sqrt{1 -k^2\sin^2\frac{\phi'}{2}}\right) \right] \nonumber\\ &=& -\hat{\mathbf{\varphi}}\frac{ \mu_0 I R}{ 4 \pi } \frac{1}{k^2 \sqrt{r^2+R^2 +2 r R\sin\theta}}\int_{-\pi}^{\pi} d\phi' \left[\frac{k^2-2 }{ \sqrt{1 -k^2\sin^2\frac{\phi'}{2}}}+2 \sqrt{1 -k^2\sin^2\frac{\phi'}{2}} \right] \tag{60}, \end{eqnarray}\] where \(k^2=\frac{4 r R\sin\theta}{r^2+R^2 +2 r R\sin\theta}\). Finally, we define \(\zeta'=\phi'/2\) and split the integration into two pieces to pick an overall factor of \(4\) to get: \[\begin{eqnarray} \mathbf{A}_s(\mathbf{r})=\hat{\mathbf{\varphi}}\frac{ \mu_0 I R}{ \pi \sqrt{r^2+R^2 +2 r R\sin\theta} } \frac{(2-k^2)K(k^2)-2E(k^2)}{k^2} \tag{61}, \end{eqnarray}\] where the elliptic integral are defined as follows: \[\begin{eqnarray} K(k^2)&=&\int_0^{\frac{\pi}{2}}\frac{d\theta}{\sqrt{1-k^2\sin^2\theta}},\nonumber\\ E(k^2)&=&\int_0^{\frac{\pi}{2}}d\theta\sqrt{1-k^2\sin^2\theta} \tag{62}. \end{eqnarray}\] The calculation of the magnetic field is straightforward[6]:

\[\begin{eqnarray} B_r&=&\frac{1}{r\sin\theta}\frac{\partial}{\partial\theta}(\sin\theta A_\varphi)=\frac{ \mu_0 I R^2}{ \pi \sqrt{r^2+R^2 +2 r R\sin\theta} (r^2+R^2 -2 r R\sin\theta)}\cos\theta E(k^2) ,\nonumber\\ B_\theta&=&-\frac{1}{r}\frac{\partial}{\partial r}(r A_\varphi)=\frac{ \mu_0 I }{ 2 \pi \sqrt{r^2+R^2 +2 r R\sin\theta} (r^2+R^2 -2 r R\sin\theta)\sin\theta}\left[(r^2+R^2\cos(2\theta) )E(k^2)-(r^2+R^2 -2 r R\sin\theta)K(k^2)\right] \tag{63}. \end{eqnarray}\]

We can also express the magnetic field in the cylindrical coordinates [6]: \[\begin{eqnarray} B_\rho&=&\frac{ \mu_0 I z}{ 2 \pi \sqrt{R^2+\rho^2+z^2 +2 R \rho} (R^2+\rho^2+z^2 -2 R \rho)\rho}\left[ (R^2+\rho^2+z^2)E(k^2)-(R^2+\rho^2+z^2 -2 R \rho))K(k^2)\right] ,\nonumber\\ B_z&=&\frac{ \mu_0 I }{ 2 \pi \sqrt{R^2+\rho^2+z^2 +2 R } (R^2+\rho^2+z^2 -2 R \rho)\rho}\left[ (R^2-\rho^2-z^2)E(k^2)+(R^2+\rho^2+z^2 -2 R \rho))K(k^2)\right] \tag{64}. \end{eqnarray}\]

Solenoid

Now we need to stack up many single loops and integrate the fields[7]. We choose the cylindrical coordinate system and highlight one of these loops centered at \(z_s\) in Fig. 7.
A loop sitting at $z=z_s$. We will integrate over these loops along the $z$ direction from $-L/2$ to $L/2$.

Figure 7: A loop sitting at \(z=z_s\). We will integrate over these loops along the \(z\) direction from \(-L/2\) to \(L/2\).

For the solenoid of \(H\) centered at \(z=0\), the current on the wires at \(\mathbf{r}'=R\) and \(-\frac{H}{2}<z<\frac{H}{2}\), we can express it as follows: \[\begin{eqnarray} \mathbf{J}_s(\mathbf{r}') &=& \lambda \delta(r'-R)\hat{\mathbf{\varphi}'} =\lambda \delta(r'-R)\left(\cos\varphi' \hat{\mathbf{j}}-\sin\varphi'\hat{\mathbf{i}} \right), \text{ for } -\frac{H}{2}<z<\frac{H}{2} \tag{65}, \end{eqnarray}\] where \(\lambda\) is the current density. In order to calculate \(\lambda\) for a loop of wire carrying a current \(I\), let’s intercept the loop with an area perpendicular to it. The surface is a thin rectangle just around \(\mathbf{r}'=R\) and \(-\frac{H}{2}<z<\frac{H}{2}\). We can still select an area on positive \(x\) axis ( i.e., \(\varphi'=0\)), pointing along the \(y\) axis, i.e., \(d\mathbf{S}'= dS' \hat{\mathbf{j}}=dr' H \hat{\mathbf{j}}\). Integrating the current density on this area we should get the total current: \[\begin{eqnarray} \int_S d\mathbf{S}' \cdot \mathbf{J}(\mathbf{r}) &=& \int_S dr'H \lambda \delta(r'-R)\hat{\mathbf{j}}\cdot\left(\cos\varphi' \hat{\mathbf{j}}-\sin\varphi'\hat{\mathbf{i}} \right)\bigg\rvert_{\varphi'=0}=\lambda H =N I \implies \lambda=\frac{NI}{H} \tag{66}, \end{eqnarray}\] where \(N\) is the total number of turns in the coil. Therefore, the properly normalized current is \[\begin{eqnarray} \mathbf{J}_s(\mathbf{r}') &=& \frac{NI}{H} \delta(r'-R)\hat{\mathbf{\varphi}'} =nI\delta(r'-R)\left(\cos\varphi' \hat{\mathbf{j}}-\sin\varphi'\hat{\mathbf{i}} \right) \tag{67}, \end{eqnarray}\] where \(n=\frac{N}{H}\) is the number of turns per unit length. The integral we have to deal with for the coils reads: \[\begin{eqnarray} \mathbf{A}(\mathbf{r}) &=& \frac{ \mu_0 }{ 4 \pi } \int d^3 \mathbf{r'} \frac{\mathbf{J}(\mathbf{r'})}{ | \mathbf {r}- \mathbf {r}'|}=\frac{ \mu_0 n I }{ 4 \pi } \int_{-\frac{H}{2}}^{\frac{H}{2}} dz' r'dr' d\varphi' \frac{1 }{ | \mathbf {r}- \mathbf {r}'|} \delta(r'-R)\left(\cos\varphi' \hat{\mathbf{j}}-\sin\varphi'\hat{\mathbf{i}} \right) \tag{68}, \end{eqnarray}\] where we put the subscript \(s\) to remind us that this is for a single loop. We will parameterize the points on the loop centered at \(z=z'\) as \(\mathbf {r}'= z'\,\mathbf{k}+ r' (\cos\varphi'\hat{\mathbf{i}}+\sin\varphi'\hat{\mathbf{j}})\), and the observation point as \(\mathbf {r}= \mathbf {z}+ r (\cos\varphi\hat{\mathbf{i}}+\sin\varphi\hat{\mathbf{j}})\)

\[\begin{eqnarray} | \mathbf {r}- \mathbf {r}'|=|\mathbf {z}+ r (\cos\varphi\hat{\mathbf{i}}+\sin\varphi\hat{\mathbf{j}})-z'\,\mathbf{k}- r' (\cos\varphi'\hat{\mathbf{i}}+\sin\varphi'\hat{\mathbf{j}})|= \sqrt{(z-z')^2 +r^2+r'^2-2rr'\cos(\varphi-\varphi')} \tag{69}. \end{eqnarray}\] Note that the problem has rotational symmetry. We can rotate our coordinate system such that the observation point sits on \(y=0\), i.e., \(\varphi=0\). Once we are done with the computations, we can rotate the vectors back to general \(\mathbf{r}\) point. So let’s set \(\varphi=0\) in Eq. (56) and rewrite Eq. (55) :

\[\begin{eqnarray} \mathbf{A}(\mathbf{r}) &=& \frac{ \mu_0 n }{ 4 \pi } \int r'dr' dz' d\varphi' \frac{1 }{ \sqrt{(z-z')^2 +r^2+r'^2-2rr'\cos\varphi'}} \delta(r'-R)\left(\cos\varphi' \hat{\mathbf{j}}-\sin\varphi'\hat{\mathbf{i}} \right)\nonumber\\ &=& \frac{ \mu_0 n R}{ 4 \pi } \int_{-\frac{H}{2}}^{\frac{H}{2}} dz'\int_{0}^{2\pi} d\varphi' \frac{\cos\varphi' \hat{\mathbf{j}} }{ \sqrt{(z-z')^2 +r^2+R^2-2rR\cos\varphi'}} -\frac{ \mu_0 n R}{ 4 \pi }\int_{-\frac{H}{2}}^{\frac{H}{2}} dz'\cancelto{0}{ \int_{0}^{2\pi} d\varphi' \frac{\sin\varphi'\hat{\mathbf{i}} }{ \sqrt{(z-z')^2 +r^2+R^2-2rR\cos\varphi'}} } \tag{70}, \end{eqnarray}\] where the second term vanishes since the integrand is odd and the integral is evaluated over the full range. Note that we evaluated the integral at \(\varphi=0\), and the resulting potential points in \(\hat{\mathbf{j}}\) direction. For generic \(\varphi\) we can simply rotate the coordinate system about the \(z\) axis by \(\varphi\). In this rotated coordinate system \(\hat{\mathbf{j}}\rightarrow \hat{\mathbf{\varphi}}\). Therefore the vector potential reads: \[\begin{eqnarray} \mathbf{A}(\mathbf{r}) &=& \hat{\mathbf{\varphi}}\frac{ \mu_0 n R}{ 2 \pi } \int_{0}^{\pi} d\varphi' \int_{-\frac{H}{2}}^{\frac{H}{2}} dz' \frac{\cos\varphi' }{ \sqrt{(z'-z)^2 +r^2+R^2-2rR\cos\varphi'}}, \tag{71}. \end{eqnarray}\] where the integrand periodic and the range can be set to \([0,\pi]\) by inserting an overall factor of \(2\). We will want to do the the \(z'\) integral first by changing the variable as \(z'-z\equiv\sqrt{r^2+R^2-2rR\cos\varphi'} \tan\alpha\):

\[\begin{eqnarray} \mathcal{I}&=& \int dz' \frac{1}{ \sqrt{(z'-z)^2 +r^2+R^2-2rR\cos\varphi'}}= \int d\alpha \sqrt{r^2+R^2-2rR\cos\varphi'} \sec^2\alpha \frac{1}{ \sqrt{r^2+R^2-2rR\cos\varphi'} \sqrt{\tan^2\theta +1}}\nonumber\\ &=&\int d\alpha \sec\alpha =\int d\alpha \sec\alpha \frac{\sec\alpha+\tan \alpha}{\sec\alpha+\tan \alpha} =\int d\alpha \frac{\sec^2\alpha+\tan \alpha\sec \alpha}{\sec\alpha+\tan \alpha} =\int \frac{d(\sec\alpha+\sec \alpha)}{\sec\alpha+\tan \alpha}=\ln|\sec\alpha+\tan \alpha|\nonumber\\ &=&\ln\left| \frac{z'-z+\sqrt{(z'-z)^2+r^2+R^2-2rR\cos\varphi'}}{\sqrt{r^2+R^2-2rR\cos\varphi'}} \right|\nonumber\\ &=&\ln\left| z'-z+\sqrt{(z'-z)^2+r^2+R^2-2rR\cos\varphi'} \right|-\ln\left|\sqrt{r^2+R^2-2rR\cos\varphi'} \right| \tag{72} \end{eqnarray}\] where we can drop the last term since it has no \(z\) dependence and its values at the upper and lower boundary is the same. Let’s define \(z'-z=\xi\), \(\xi_\pm=z\pm\frac{H}{2}\) and go back to the \(\varphi'\) integral:

\[\begin{eqnarray} \mathbf{A}(\mathbf{r}) &=& \hat{\mathbf{\varphi}}\frac{ \mu_0 n R}{ 2 \pi } \int_{0}^{\pi} d\varphi' \cos\varphi' \ln\left| \xi+\sqrt{\xi^2+r^2+R^2-2rR\cos\varphi'} \right|_{\xi_-}^{\xi_+}\nonumber\\ &=& \hat{\mathbf{\varphi}}\frac{ \mu_0 n R}{ 2 \pi } \int_{0}^{\pi} d\left\{\sin\varphi' \ln\left| \xi+\sqrt{\xi^2+r^2+R^2-2rR\cos\varphi'} \right|_{\xi_-}^{\xi_+}\right\}\nonumber\\ &&- \hat{\mathbf{\varphi}}\frac{ \mu_0 n R}{ 2 \pi } \int_{0}^{\pi} d\varphi' \sin\varphi' \frac{d}{d\varphi'}\left\{\ln\left| \xi+\sqrt{\xi^2+r^2+R^2-2rR\cos\varphi'} \right|_{\xi_-}^{\xi_+}\right\}\nonumber\\ &=&\hat{\mathbf{\varphi}}\frac{ \mu_0 n R}{ 2 \pi } \cancelto{0}{\left.\left\{\sin\varphi' \ln\left| \xi+\sqrt{\xi^2+r^2+R^2-2rR\cos\varphi'} \right|_{\xi_-}^{\xi_+}\right\}\right\rvert_0^\pi}\nonumber\\ &&- \hat{\mathbf{\varphi}}\frac{ \mu_0 n R}{ 2 \pi } \int_{0}^{\pi} d\varphi' \left.\frac{rR\sin^2\varphi'}{ \left(\xi+\sqrt{\xi^2+r^2+R^2-2rR\cos\varphi'}\right)\sqrt{\xi^2+r^2+R^2-2rR\cos\varphi'} }\right\rvert_{\xi_-}^{\xi_+} \nonumber\\ &=&-\hat{\mathbf{\varphi}}\frac{ \mu_0 n R}{ 2 \pi } \int_{0}^{\pi} d\varphi' \left.\frac{rR\sin^2\varphi'}{ \left(\xi+\sqrt{\xi^2+r^2+R^2-2rR\cos\varphi'}\right)\sqrt{\xi^2+r^2+R^2-2rR\cos\varphi'} }\right\rvert_{\xi_-}^{\xi_+} \tag{73}. \end{eqnarray}\]

Multiply and divide by \(\sqrt{\xi^2+r^2+R^2-2rR\cos\varphi'}-\xi\) [7] to get: \[\begin{eqnarray} \mathbf{A}(\mathbf{r}) &=&-\hat{\mathbf{\varphi}}\frac{ \mu_0 n I R}{ 2 \pi } \int_{0}^{\pi} d\varphi' \left.\frac{(\sqrt{\xi^2+r^2+R^2-2rR\cos\varphi'}-\xi)rR\sin^2\varphi'}{ \left(\xi^2+r^2+R^2-2rR\cos\varphi'-\xi^2\right)\sqrt{\xi^2+r^2+R^2-2rR\cos\varphi'} }\right\rvert_{\xi_-}^{\xi_+} \nonumber\\ &=&-\hat{\mathbf{\varphi}}\frac{ \mu_0 n I R}{ 2 \pi } \int_{0}^{\pi} d\varphi' \left.\frac{(\sqrt{\xi^2+r^2+R^2-2rR\cos\varphi'}-\xi)rR\sin^2\varphi'}{ \left(r^2+R^2-2rR\cos\varphi'\right)\sqrt{\xi^2+r^2+R^2-2rR\cos\varphi'} }\right\rvert_{\xi_-}^{\xi_+} \nonumber\\ &=&-\hat{\mathbf{\varphi}}\frac{ \mu_0 n I R}{ 2 \pi } \int_{0}^{\pi} d\varphi' \left[\cancelto{0}{\left.\frac{rR\sin^2\varphi'}{ \left(r^2+R^2-2rR\cos\varphi'\right) }\right\rvert_{\xi_-}^{\xi_+}} -\left.\frac{\xi rR\sin^2\varphi'}{ \left(r^2+R^2-2rR\cos\varphi'\right)\sqrt{\xi^2+r^2+R^2-2rR\cos\varphi'} }\right\rvert_{\xi_-}^{\xi_+}\right] \nonumber\\ &=&\hat{\mathbf{\varphi}}\frac{ \mu_0 n I R^2 r}{ 2 \pi } \int_{0}^{\pi} d\varphi' \left.\frac{\xi \sin^2\varphi'}{ \left(r^2+R^2-2rR\cos\varphi'\right)\sqrt{\xi^2+r^2+R^2-2rR\cos\varphi'} }\right\rvert_{\xi_-}^{\xi_+} \tag{74}, \end{eqnarray}\] where the first term vanishes since it has no \(\xi\) dependence. As we did in the Single loop section, Let’s define \(\phi'=\pi-\varphi'\) to get \(\cos\varphi'=-\cos\phi'\). This will change the integral limits from \([0,\pi]\) to \([\pi,0]\) and the measure from \(d\varphi\) to \(-d\phi\). We can flip the integral limits with the negative sign of the measure to get:

\[\begin{eqnarray} \mathbf{A}(\mathbf{r}) &=&\hat{\mathbf{\varphi}}\frac{ \mu_0 n I R^2 r}{ 2 \pi } \int_{0}^{\pi} d\phi' \left.\frac{\xi \sin^2\phi'}{ \left(r^2+R^2+2rR\cos\phi'\right)\sqrt{\xi^2+r^2+R^2+2rR\cos\phi'} }\right\rvert_{\xi_-}^{\xi_+} \tag{75}. \end{eqnarray}\]

we define \(\zeta'=\frac{\phi'}{2}\). Noting \[\begin{eqnarray} \sin^2\phi'=\sin^2(2\zeta')=[2\sin\zeta'\cos\zeta']^2=4\sin^2\zeta'\cos^2\zeta'=4\sin^2\zeta'-4\sin^4\zeta' \tag{76}, \end{eqnarray}\] we get: \[\begin{eqnarray} \mathbf{A}(\mathbf{r}) &=&\hat{\mathbf{\varphi}}\frac{ \mu_0 n I R^2 r}{ \pi } \int_{0}^{\pi/2} d\zeta' \left.\frac{4\sin^2\zeta'-4\sin^4\zeta'}{ \left(r^2+R^2+2rR\cos(2\zeta')\right)\sqrt{\xi^2+r^2+R^2+2rR\cos(2\zeta')} }\xi\right\rvert_{\xi_-}^{\xi_+}\nonumber\\ &=&\hat{\mathbf{\varphi}}\frac{ 4 \mu_0 n I R^2 r}{ \pi } \int_{0}^{\pi/2} d\zeta' \left.\frac{\sin^2\zeta'-\sin^4\zeta'}{ \left(r^2+R^2+2rR\cos(2\zeta')\right)\sqrt{\xi^2+r^2+R^2+2rR\cos(2\zeta')} }\xi\right\rvert_{\xi_-}^{\xi_+} \nonumber\\ &=&\hat{\mathbf{\varphi}}\frac{ 4 \mu_0 n I R^2 r}{ \pi } \int_{0}^{\pi/2} d\zeta' \left.\frac{\sin^2\zeta'-\sin^4\zeta'}{ \left(r^2+R^2+2rR\cos(2\zeta')\right)\sqrt{\xi^2+r^2+R^2+2rR\cos(2\zeta')} }\xi\right\rvert_{\xi_-}^{\xi_+} \nonumber\\ &=&\hat{\mathbf{\varphi}}\frac{4 \mu_0 n I R^2 r}{ \pi } \int_{0}^{\pi/2} d\zeta' \left.\frac{\sin^2\zeta'-\sin^4\zeta'}{ \left((r+R)^2-4rR\sin^2\zeta'\right)\sqrt{\xi^2+(r+R)^2-4rR\sin^2\zeta'} }\xi\right\rvert_{\xi_-}^{\xi_+} \nonumber\\ &=&\hat{\mathbf{\varphi}}\frac{4 \mu_0 n I R^2 r}{ \pi (r+R)^2 \sqrt{\xi^2+(r+R)^2} } \int_{0}^{\pi/2} d\zeta' \left.\frac{\sin^2\zeta'-\sin^4\zeta'}{ \left(1-\frac{4rR}{(r+R)^2}\sin^2\zeta'\right)\sqrt{1-\frac{4rR}{\xi^2+(r+R)^2}\sin^2\zeta'} }\xi\right\rvert_{\xi_-}^{\xi_+} \nonumber\\ &=&\hat{\mathbf{\varphi}}\frac{4 \mu_0 n I R^2 r}{ \pi (r+R)^2 \sqrt{\xi^2+(r+R)^2} } \int_{0}^{\pi/2} d\zeta' \left.\frac{\sin^2\zeta'-\sin^4\zeta'}{ \left(1-h^2\sin^2\zeta'\right)\sqrt{1-k^2\sin^2\zeta'} }\xi\right\rvert_{\xi_-}^{\xi_+} \tag{77}. \end{eqnarray}\] where \(h^2\equiv\frac{4rR}{(r+R)^2}\) and \(k^2\equiv\frac{4rR}{\xi^2+(r+R)^2}\).

We can do partial fractions:

\[\begin{eqnarray} \mathcal{I} &=& \int_{0}^{\pi/2} d\zeta' \frac{\sin^2\zeta'-\sin^4\zeta'}{ \left(1-h^2\sin^2\zeta'\right)\sqrt{1-k^2\sin^2\zeta'}}\nonumber\\ &=& \int_{0}^{\pi/2} d\zeta' \left\{ \frac{1}{h^2}\left[\frac{1}{(1-h^2\sin^2\zeta')\sqrt{1-k^2\sin^2\zeta'}}- \frac{1}{\sqrt{1-k^2\sin^2\zeta'}} \right]+\frac{1}{h^4}\left[ \frac{1+h^2\sin^2\zeta'}{\sqrt{1-k^2\sin^2\zeta'}}- \frac{1}{(1-h^2\sin^2\zeta')\sqrt{1-k^2\sin^2\zeta'}} \right]\right\}\nonumber\\ &=& \frac{k^2+h^2-h^2k^2}{h^2k^2}K(k^2) -\frac{1}{k^2}E(k^2)- \frac{h^2-1}{h^2}\Pi(h^2,k^2) \tag{78}, \end{eqnarray}\] where \[\begin{eqnarray} K(k^2)&=&\int_0^{\frac{\pi}{2}}\frac{d\theta}{\sqrt{1-k^2\sin^2\theta}},\nonumber\\ E(k^2)&=&\int_0^{\frac{\pi}{2}}d\theta\sqrt{1-k^2\sin^2\theta},\nonumber\\ \Pi(h^2,k^2)&=&\int_0^{\frac{\pi}{2}}\frac{d\theta}{(1-h^2\sin^2\theta)\sqrt{1-k^2\sin^2\theta}} \tag{79}. \end{eqnarray}\] Putting it all together, we get:

\[\begin{eqnarray} \mathbf{A}(\mathbf{r}) &=&\left.\hat{\mathbf{\varphi}}\frac{ \mu_0 n I \sqrt{R}}{ 2 \pi\sqrt{r} } \left[\frac{k^2+h^2-h^2k^2}{h^2k^2}K(k^2) -\frac{1}{k^2}E(k^2)- \frac{1-h^2}{h^2}\Pi(h^2,k^2)\right] \xi k\right\rvert_{\xi_-}^{\xi_+} \tag{80}. \end{eqnarray}\]

We can now compute the magnetic field. This will require derivatives of the elliptic integrals[8]:

\[\begin{eqnarray} \frac{dK}{dk}&=&\frac{E}{k(1-k^2)}-\frac{K}{k},\nonumber\\ \frac{dE}{dk}&=&\frac{E}{k}-\frac{K}{k},\nonumber\\ \frac{d\Pi}{dk}&=&\frac{k \Pi}{k^2-h^2}-\frac{kK}{(1-k^2)(h^2-k^2)} \tag{81}. \end{eqnarray}\] Finally we have[9]:

\[\begin{eqnarray} B_r&=& -\partial_z \mathbf{A}(\mathbf{r})_\varphi =\left.\frac{ \mu_0 n I }{ \pi } \sqrt{\frac{R}{r}} \left[\frac{k^2-2}{k}K(k^2) +\frac{2}{k}E(k^2)\right] \xi k\right\rvert_{\xi_-}^{\xi_+} \tag{82}, \end{eqnarray}\] and, \[\begin{eqnarray} B_z&=& \frac{1}{r}\partial_r\left(r \mathbf{A}(\mathbf{r})_\varphi \right) =\left.\frac{ \mu_0 n I }{ 4 r \pi\sqrt{Rr} } \left[K(k^2) +\frac{R-r}{R+r} \Pi(h^2,k^2)\right] \xi k\right\rvert_{\xi_-}^{\xi_+} \tag{83}. \end{eqnarray}\]

Resistance

For example, we cannot independently change the number of turns in a coil without changing its total resistance and inductance. Similarly, changing the coil dimensions will change the inductance. We need to choose the independent parameters and calculate everything else. From practical perspective, what we need to do is to pick up a wire type from Tab. 1, specified by its AWG number, select a coil holder, specified by its diameter and height. We then wind \(N\) turns as compactly as we can[10]. Once we do this, \(L_c\) and \(R_c\) will be completely determined from first principles. Therefore the free parameters to optimize are the coil height, wire type and the number of turns. The initial position of the the magnet is the last parameter we can tune to optimize the performance.

Consider a coil with \(N\) turns wound from radius \(r_\text{i}\) to \(r_\text{o}\). The resistance of such a coil can be calculated as: \[\begin{eqnarray} \text{R}&=& \frac{N}{r_\text{o}-r_\text{i}} \int_{r_\text{i}}^{r_\text{o}}\lambda 2 \pi r dr = \frac{ 2 \pi N \lambda}{r_\text{o}-r_\text{i}} \frac{r^2}{2} \bigg\vert_{r_\text{i}}^{r_\text{o}}=\frac{ 2 \pi N \lambda}{r_\text{o}-r_\text{i}} \frac{r_\text{o}^2-r_\text{i}^2}{2}=\frac{ 2 \pi N \lambda}{r_\text{o}-r_\text{i}} \frac{(r_\text{o}-r_\text{i})(r_\text{o}+r_\text{i})}{2}\nonumber\\ &=& 2 \pi N \lambda \frac{r_\text{o}+r_\text{i}}{2}, \tag{84} \end{eqnarray}\] where \(\lambda\) is the resistance per unit length. Also note that \(r_\text{o}\) is not really a free parameter. It will be fixed for a given wire type. A coil of height \(H\) will have a total area of \(H\times(r_\text{o}-r_\text{i})\) to fit in \(N\) turns of wire. Assuming a packing density \(\gamma\), and a cross-sectional area \(A_\text{w}\) for the wire, we can write the following relation: \[\begin{eqnarray} \frac{H\times(r_\text{o}-r_\text{i})}{A_\text{w}}\gamma=N \tag{85} \end{eqnarray}\] Solving for \(r_\text{o}\), and putting it back in Eq. (84) gives:

\[\begin{eqnarray} \text{R}= 2 \pi N \lambda \left(r_\text{i}+ \frac{N A_\text{w}}{2 \gamma H} \right). \tag{86} \end{eqnarray}\] The second term accounts for the fact that the radius of the coil will increase as more turns are added, and each turn will get longer and contribute more to the resistance. This shows us that adding more turns adds increasingly more resistance limiting the peak current. On the flip side, more turns will result in more magnetic field at the same current. Another metric we need to consider is the time it takes to reach to the peak current, which can be shown to be \(\propto\frac{1}{\sqrt{L}}\propto \frac{1}{N}\). Therefore, a coil with more turns will take longer to saturate. We will dive deeper into these to see if there is an optimal solution for the value of \(N\).

Table 1: Table of conductor parameters.
nameagegender

Table 1 is convenient for looking up a specific AWG number and locate the properties.

There is a formulation that can give us the same information with a fit function for the wire diameter:

\[\begin{eqnarray} \text{D}_\text{w}=0.127 \, exp\left(\frac{36-\text{AWG}}{8.624889}\right). \tag{87} \end{eqnarray}\] The resistivity per unit length can also be written as: \[\begin{eqnarray} \lambda_\text{w}=\frac{\rho }{\pi \text{D}_\text{w}^2/4}, \tag{88} \end{eqnarray}\] where \(\rho\) is the copper resistivity in the units of \(\Omega m\) with a typical value of \(1.75\times 10^{-8}\Omega m\). It is also important to note that the wire diameters are for the bare copper. The thickness of the insulation should be included in winding calculations. A vendor provides the heavy insulation thickness table for various AWG values. It is rather convenient to work with a formula for the insulation thickness rather than the raw numbers, and their raw data can be conveniently fit with a linear regression: \[\begin{eqnarray} \text{Additional Radius from Insulation[mm]}=0.0676-0.0014\times \text{AWG}, \tag{89} \end{eqnarray}\] The results are shown in Fig. 8.
We take insulation data from [a vendor](https://wire-cable-tubing.wireandcable.com/viewitems/magnet-wire/heavy-polyimide-insulated-round-magnet-wire). They provide the heavy insulation thickness table for various AWG values. Their raw data can be conveniently fit with a linear regression.

Figure 8: We take insulation data from a vendor. They provide the heavy insulation thickness table for various AWG values. Their raw data can be conveniently fit with a linear regression.

Inductance

However, there are certain empirical formulas that approximate the inductance values for a reasonable range of geometrical parameters. The expression for the inductance for the long coil limit, see Eq. (4), can be amended to get the Wheeler’s formula[11]:

\[\begin{eqnarray} L_c = \frac{ 31.6 N^2 r_\text{a}^2}{6 r_\text{a} +9 H +10 (r_\text{o} -r_\text{i}) } \tag{90}, \end{eqnarray}\] where \(r_\text{a}=\frac{r_\text{o}+r_\text{i}}{2}\) is the average value of the radius. There are online calculators, such as this one which uses the Wheeler’s formula. There are also calculators using the full blown elliptical integrals, such as Coil32[12]. They don’t necessarily give the same answer. Wheeler’s formula is convenient for computational reasons, however its is expected to be accurate only when the coil thickness is similar to the coil height. We need to investigate this a bit further and compare the predicted values against measured values.

[1]
J. D. Jackson, Classical electrodynamics, 3rd ed. New York, NY: Wiley, 1999 [Online]. Available: http://cdsweb.cern.ch/record/490457
[2]
D. J. Griffiths, Introduction to electrodynamics. Pearson, 2013.
[3]
E. E. Callaghan and S. H. Maslen, “THE MAGNETIC FIELD OF a FINITE SOLENOID,” Oct. 1960 [Online]. Available: https://www.osti.gov/biblio/4121210
[4]
G. B. Arfken, H.-J. Weber, and F. E. Harris, Mathematical methods for physicists. Oxford: Academic, 2012.
[5]
S. R. Muniz, V. S. Bagnato, and M. Bhattacharya, “Analysis of off-axis solenoid fields using the magnetic scalar potential: An application to a zeeman-slower for cold atoms,” American Journal of Physics, vol. 83, no. 6, pp. 513–517, Jun. 2015, doi: 10.1119/1.4906516. [Online]. Available: http://dx.doi.org/10.1119/1.4906516
[6]
J. C. Simpson, J. E. Lane, C. D. Immer, R. C. Youngquist, and T. Steinrock, “Simple analytic expressions for the magnetic field of a circular current loop,” 2001 [Online]. Available: https://api.semanticscholar.org/CorpusID:30815892
[7]
E. E. Callaghan and S. H. Maslen, “The magnetic field of a finite solenoid,” 1960 [Online]. Available: https://api.semanticscholar.org/CorpusID:116258616
[8]
M. Abramowitz and I. A. Stegun, Handbook of mathematical functions with formulas, graphs, and mathematical tables, Ninth Dover printing, tenth GPO printing. New York: Dover, 1964.
[9]
[10]
H.-C. Chang and L.-C. Wang, A Simple Proof of Thue’s Theorem on Circle Packing.” 2010 [Online]. Available: https://arxiv.org/abs/1009.4322
[11]
H. A. Wheeler, “Simple inductance formulas for radio coils,” Proceedings of the Institute of Radio Engineers, vol. 16, no. 10, pp. 1398–1400, 1928, doi: 10.1109/JRPROC.1928.221309.
[12]

  1. assuming we keep adding turns to keep \(N/H\) constant↩︎

  2. My results differ from those of the ones in [5]- I believe they have an error in their Equation 10↩︎

Related