# Open-Source Magnetometer for Characterizing Magnetic Fields in Ultracold Experiments
## 2 General Considerations  
Whenever a field \(\vec{B}\) is measured with a magnetometer, one needs to remember that, in a typical laboratory environment, it is in fact a vector sum of the field generated by the source and of stray fields. The latter ones can be shielded to a large degree with a \(\mu\)-metal enclosure or otherwise compensated with auxiliary coils, but this is rarely completed during characterization of magnetic field sources prior to assembly. As a result, straightforward methods to remove the stray fields during the characterization process increase the quality of the measurement. Let us first consider how one could eliminate stray fields when characterizing a pair of coils. Here, one effectively deals with sets of current-carrying loops. Let us limit our discussion to axially symmetric coils commonly used in magneto-optical traps or in Zeeman slowers, but the conclusions are general. From the Biot-Savart law, we know that the magnetic field vector at a point a distance \(y\) along the center line of the circular loop with radius \(R\) can be expressed as  
\[\vec{B}(y\hat{\mathbf{y}})=\frac{\mu_{0}IR^{2}}{2(y^{2}+R^{2})^{3/2}}\hat{\mathbf{y}}, \tag{1}\]  
where \(I\) is the current, \(\mu_{0}\) is magnetic permeability of free space and \(\hat{\mathbf{y}}\) is the unit vector along the center-line of the loop centered at the origin. From this equation, one can see that the direction of the vector changes when the direction of the current is reversed. A magnetometer measures magnetic field at a given point in space, expressed as \(\vec{B}_{+}=\vec{B}_{\text{source}}+\vec{B}_{\text{stray}}+\vec{B}_{\text{offset}}\), where \(\vec{B}_{+}\) corresponds to the current flowing in (arbitrarily chosen) positive direction, \(\vec{B}_{\text{source}}\) is the magnetic field generated by the coils, \(\vec{B}_{\text{Stray}}\) is the stray magnetic field and \(\vec{B}_{\text{offset}}\) is an internal offset field inherent to most Hall sensors. If we reverse the current in the coils, then the magnetometer will measure a new field value \(\vec{B}_{-}=-\vec{B}_{\text{source}}+\vec{B}_{\text{stray}}+\vec{B}_{\text{ offset}}\). These measurements can then be used to obtain the field created by the source:  
\[\vec{B}_{\text{source}}=\frac{\vec{B}_{+}-\vec{B}_{-}}{2}. \tag{2}\]  
Alternatively, one could measure the field with the source present and with the source removed (or the current turned off). In both scenarios, it is impossible to extract the value of the stray fields without the knowledge of the inherent offset of the magnetic sensor. If the current direction can be changed, then each component of stray fields, for example \(\vec{B}_{\text{stray}}^{x}\), could be determined by physically rotating the sensor by \(180^{\circ}\) around a perpendicular axis such that new values \(\vec{B}_{+}^{\prime,x}=-\vec{B}_{\text{source}}^{x}-\vec{B}_{\text{stray}}^{ x}+\vec{B}_{\text{offset}}^{x}\) and \(\vec{B}_{-}^{\prime,x}=\vec{B}_{\text{source}}^{x}-\vec{B}_{\text{stray}}^{ x}+\vec{B}_{\text{offset}}^{x}\) are additionally measured. From the above relations, one can obtain \(\vec{B}_{\text{stray}}^{x}\) from equations  
\[\vec{B}_{\text{stray}}^{x} =\frac{\vec{B}_{-}^{x}-\vec{B}_{+}^{\prime,x}}{2} \tag{3a}\] \[\vec{B}_{\text{stray}}^{x} =\frac{\vec{B}_{-}^{\prime,x}-\vec{B}_{+}^{x}}{2}. \tag{3b}\]  
This is very cumbersome and, if one is interested in all three components of the magnetic field vector, the complexity of a measurement would become significant. As such, it is rarely conducted because stray field measurements are usually treated as supplementary information of no relevance to the testing process of the coils. In fact, it is rather common to even ignore the presence of the stray fields, and whatever the magnetometer measures is treated as the field created solely by the source. For permanent magnets, the best one can do is to measure the magnetic field when the magnets are present and then repeat the measurement after the magnets are physically removed such that they do not influence the stray field value.