Abstract
A difficult problem concerns the determination of magnetic field components within an experimentally inaccessible region when direct field measurements are not feasible. In this paper, we propose a new method of accessing magnetic field components using non-disruptive magnetic field measurements on a surface enclosing the experimental region. Magnetic field components in the experimental region are predicted by solving a set of partial differential equations (Ampere’s law and Gauss’ law for magnetism) numerically with the aid of physics-informed neural networks (PINNs). Prediction errors due to noisy magnetic field measurements and small number of magnetic field measurements are regularized by the physics information term in the loss function. We benchmark our model by comparing it with an older method. The new method we present will be of broad interest to experiments requiring precise determination of magnetic field components, such as searches for the neutron electric dipole moment.
Similar content being viewed by others
Magnetic field map** is commonly used in many fields of science, medicine and technology such as particle accelerators, nuclear storage experiments1,2,3, cardiac beat detection4, magnetic resonance imaging (MRI)5 and magnetic indoor positioning systems (IPS)6,7. For example, in nuclear and particle physics experiments, with one example being the search for the neutron electric dipole moment, it is often crucial to measure and control the magnetic field components in the experimental region, because these experiments are typically sensitive to perturbations in magnetic fields. An undetected disturbance in a magnetic field may result in systematic uncertainties and cause a limitation for the precision of the measured quantities. To minimize systematic uncertainties, magnetic field components should be monitored in real-time and any unwanted field should be compensated during the operation time of the experiment. Real-time measurement of the magnetic field in an experimental region of space is not always practical or feasible. In most cases, the experimental region is not accessible due to a physical enclosure (e.g., a setup placed in a vacuum chamber), or it could be that placing a magnetic field sensor inside the experimental region is too disruptive to the system.
There exist several approaches in the literature that can be utilized to solve the problems stated above. For instance, Solin et al.8 make use of Gaussian processes (GPs) to interpolate/extrapolate ambient magnetic fields. They train the model using a data set collected by a magnetic field sensor at different locations of space and reconstruct the whole ambient magnetic field. Another method is proposed by Nouri et al.9,10. They introduced a non-disruptive magnetic field map** method using exterior measurements at fixed locations and leverage the multipole expansion of the magnetic field vector. Expanding the magnetic field to some finite degree \(n=N\), they provide a systematic way to optimize sensor locations and fit the unknown coefficients of the multipole expansion using the data from those exterior sensor measurements. This method is susceptible to noise in the data and, since the multipole expansion terms need to be picked to a specific field profile, the coefficients of the expansion terms are not regularized.
In this paper, we propose a robust way of predicting the magnetic field vector in the experimental region. In order to accomplish this, we utilize physics-informed neural networks (PINNs)11. PINNs propose a way to incorporate prior physical knowledge about the system in terms of its partial differential equations, into the deep neural networks while still being able to utilize their universal function approximator property. With PINNs, data and mathematical models of physics are combined in a smooth way, even in situations that are only partially understood, uncertain, and have a lot of dimensions. In noisy and high-dimensional situations, physics-informed learning blends data and mathematical models easily and can solve general inverse problems extremely successfully12,13,14. Unlike the method proposed in Refs.9,10, our method does not require prior knowledge of the multiple expansion terms to be fitted. This special type of neural network regularizes the output function (magnetic field prediction) during the training process by requiring the output to satisfy Maxwell’s equations, specifically Ampere’s law and Gauss’ law for magnetism.
Methods
In this work, we are interested in predicting the magnetic field components inside a three dimensional space enclosed by an external surface S by utilizing the knowledge of the magnetic field in some number of locations on the surface S. Assuming there are no free currents, \(\varvec{J}=0\), and no magnetization, \(\varvec{M}=0\), in the region of interest, the partial differential equations that govern the static magnetic field are quite concise. They are
and
Therefore, it is possible to find a magnetic field that satisfies (1) and (2) together with the knowledge of the magnetic field at some number of locations . We choose those locations on the surface of a closed region S of which we are interested in approximating the magnetic field inside (Fig. 1). Of course, according to the electromagnetism uniqueness theorem, having a finite number of data on a surface does not guarantee a unique solution to equations (1) and (2). However, as we demonstrate later in this paper, our results indicate that one can successfully approximate the true solution by having a sufficient number of data scattered on the surface.
Review of the multipole expansion method
In this section, we review the field monitoring method described in Ref.9. Equation (2) indicates that the magnetic field vector can be written as a gradient of a scalar magnetic potential function
Substituting (3) into Eq. (1) tells us that the magnetic scalar potential satisfies Laplace’s equation
and the solution of Laplace’s equation in spherical coordinates is given by
where \(P_l^m\) are the associated Legendre polynomials, and \(a_{lm}\) and \(b_{lm}\) are expansion coefficients. The magnetic field can be obtained by calculating the gradient of the magnetic scalar potential, \(\varvec{B}= -\nabla \Phi _M(\varvec{r})\). Absorbing \(a_{lm}\) and \(b_{lm}\) in a coefficient \(c_n\), we can write the magnetic field in a compact form
where \(\varvec{f}_n(x,y,z)\) are vector basis functions satisfying \(\nabla \cdot \varvec{f}_n = 0\) and \(\nabla \times \varvec{f}_n = 0\).
To illustrate, the first 10 \(\varvec{f}_n\) basis vector functions are listed in Table 1. The right-hand side of the Eq. (6) is expanded to some finite order \(n=N\) and the magnetic field vector inside the volume can be interpolated using linear regression techniques.
Magnetic field prediction using PINNs
The exact values of the partial derivatives in (1) and (2) can be calculated by automatic differentiation11, which is implemented in some well-known machine learning libraries such as TensorFlow15 and PyTorch16. The neural network we train to approximate the magnetic field inside the region will have the structure as shown in Fig. 2. The hyperbolic tangent is used for the activation of each hidden layer. The other tested activation functions have not performed as well as the hyperbolic tangent for this network architecture. The number of hidden layers are chosen to be 4 and 8 with each having 32 or 64 neurons. The performance of these 4 different-sized networks are discussed later.
Then, the network can be trained by a combined loss function of data, curl and divergence losses
where
and
where the points \(\varvec{r}_{\varvec{B}}^{i}\) and \(\varvec{r}_{d}^{i}\) denote the positions of the magnetic sensors and the collocation points, respectively. \(N_{\varvec{B}}\) is the number of the magnetic field sensors, \(N_f\) is the number of collocation points in the domain and \(\varvec{B}_{s}\) is the measured magnetic field vector at \(\varvec{r}_{d}^{i}\). The parameter \(\lambda\) in Eq. (7) can be adjusted according to the performance of the network. The collocation points, \(\varvec{r}_{d}^{i}\), in Eqs. (9) and (10) are sampled from the volume encapsulated by the surface S (Fig. 1) and can be chosen to be fixed throughout the training process11. However, randomly choosing collocation points in each epoch leads to a quicker convergence as well as more accurate results. This is partly due to being able to choose fewer number of collocation points, and since they are assigned randomly each iteration, they represent the domain better than any fixed collocation points scheme. The ADAM optimizer17, an adaptive method for gradient-based first-order optimization, is what we make use of in order to minimize the loss function 7. The general procedure for training is given in Algorithm 1.
![figure a](http://media.springernature.com/lw685/springer-static/image/art%3A10.1038%2Fs41598-022-15777-4/MediaObjects/41598_2022_15777_Figa_HTML.png)
Experiments
Simulated experiment
In the following example, we will demonstrate the capability of our magnetic field prediction model by placing an arbitrary number of triple-axis magnetic sensors on the surface of a cube. Magnetic field sensors will be placed on the cube randomly and we will generate training and validation data by using Biot–Savart law for circular current loop(s). In the next section, we will give the analytical expression of the three dimensional magnetic field vector of a single circular current loop and then we will construct a higher order asymmetric magnetic field by placing multiple loops with different currents to benchmark our method on.
We begin by demonstrating the ability of our magnetic field reconstruction method by considering the magnetic field of a simple circular current loop (in arbitrary units). The magnetic field components of a circular current loop with radius a are given by18,19
with
where E(k) and K(k) are elliptic integrals, \(\rho ^2 \equiv x^2 + y^2\) , \(\alpha ^2 \equiv a^2 + r^2 -2a\rho\), \(\beta ^2 \equiv a^2 + r^2 +2 a \rho\) and \(r\equiv \sqrt{x^2+y^2+z^2}\) and \(z = r\cos {\theta }\). In this work, we will work in arbitrary units by setting \(C = 1\).
We want to show the potential of the network by comparing it to the multipole expansion method for various sensor counts and different types and levels of noises. To create a non-uniform higher order magnetic field, we positioned 8 circular loops of different current values at positions \((x=\pm 1.01, y=\pm 1,z=\pm 4)\) and the triple-axis magnetic sensors are placed randomly on the surface of a cube with side length \(L=2\) centered at the origin. The configuration is illustrated in Fig. 3. Our goal is to predict the magnetic field in the inner region of the surface.
The number of hidden layers and neurons of the network characterizes the complexity of the function it can approximate. Having more hidden layers and neurons should not negatively affect the performance, training larger networks are slower and may require more care with initialization and regularization of the weights20. In this example, larger network sizes resulted in better performance as shown in Table 2 as expected. Models were trained for less than 2 min for all cases on an NVIDIA RTX 3080 GPU.
Top: Magnitude plot of the predicted magnetic field along with exact magnetic field and the error at snapshot \(z=0.72\), middle: comparison of the predicted and the other method’s solutions’ x, y, z directions with 18 sensor data, bottom: comparison of the predicted and the other method’s solutions’ x, y, z directions with 30 sensor data.
Greater sensor counts gives more information about the magnetic field of the system, and we would expect the network to be able to use that information to predict magnetic field better. As shown in Table 2, having more sensory information has led to a better performance for all network structures. Moreover, fewer sensor counts has not led to a divergence from the exact magnetic field. This is not the case with the multipole expansion method as shown in Table 3. The other method seems to suffer with relatively few sensors and higher order versions overfit the sensor data. Decreasing the order in this case leads to better results but due to lower orders having fewer basis functions, the method is not able to predict the exact magnetic field as well as our network. This can also be seen in Figs. 4 and 5.
Top: Comparison of the predicted and the other method’s solutions’ x, y, z directions with 18 sensor data with Gaussian noise with \(\sigma =1.0\times 10^{-2}\), Bottom: Comparison of the predicted and the other method’s solutions’ x, y, z directions with 30 sensor data with Gaussian noise with \(\sigma =1.0\times 10^{-2}\).
Performance of the network when Gaussian noise is introduced to the sensory information is given in Table 4. This noise has led to a further deterioration of the performance for the multipole expansion method. Our method has also been affected, however, performed better across various sensor counts.
Map** the magnetic field of a square coil system
To demonstrate our methodology using actual data, we conducted an experiment in which a Bartington triple axis magnetic field probe (Mag-13MS1000) was moved to the locations of the training data collection points. In order to generate a non-uniform magnetic field, two rectangular coils are stacked vertically and driven with different current magnitudes in the opposite directions (Fig. 6). Each face of the coils is a printed circuit board (PCB) with dimensions 55 cm \(\times\) 16 cm containing 50 parallel line traces along the long side of the PCB. A current with magnitude 1 A flows counterclockwise and another current with magnitude 0.6 A flows clockwise in the top and bottom coils respectively.
In order to isolate the field generated by the coils, at each measurement location, the data is collected as the difference between the sensor measurements with the coil turned on and off. Then, we trained the network for the magnetic field data collected using the magnetic map** system. The training domain is chosen as a cube with 40 cm side length placed at the center of the coils. Performance benchmarks of our network and the other method on the measurement data is given in Figs. 7 and 8.
Conclusions
In this study, we presented an efficient and practical method for map** the magnetic field of inaccessible locations. We encoded previous knowledge from Maxwell’s equations for magnetostatics into a physics-informed neural network model for magnetic field prediction in regions where direct measurements are not possible.
We provided two experiments that proved the practicability of the proposed method. A simulated experiment proved the value of incorporating extra physics knowledge into the model. Map** the magnetic field of a square coil system illustrated the effectiveness of the approximation technique in real world applications.
Our method compared with the multipole expansion method indicated better performance results across various sensor counts and noise levels both in simulation data and real world measurement data.
Data availability
The datasets generated and/or analysed during the current study are available in the Github repository, https://github.com/ucoskun/bmap**-pinn/tree/main/data.
References
Ahmed, M. et al. A new cryogenic apparatus to search for the neutron electric dipole moment. J. Instrum. 14, P11017–P11017. https://doi.org/10.1088/1748-0221/14/11/p11017 (2019).
Abi, B. et al. Measurement of the positive muon anomalous magnetic moment to 0.46 ppm. Phys. Rev. Lett. 126, 141801. https://doi.org/10.1103/PhysRevLett.126.141801 (2021).
Gonzalez, F. M. et al. Improved neutron lifetime measurement with \(\rm UCN\tau\). Phys. Rev. Lett. 127, 162501. https://doi.org/10.1103/PhysRevLett.127.162501 (2021).
Rondin, L. et al. Nanoscale magnetic field map** with a single spin scanning probe magnetometer. Appl. Phys. Lett. 100, 153118. https://doi.org/10.1063/1.3703128 (2012).
Grover, V. P. B. et al. Magnetic resonance imaging: Principles and techniques: Lessons for clinicians. J. Clin. Exp. Hepatol. 5, 246–255. https://doi.org/10.1016/j.jceh.2015.08.001 (2015).
Le Grand, E. & Thrun, S. 3-axis magnetic field map** and fusion for indoor localization. In 2012 IEEE International Conference on Multisensor Fusion and Integration for Intelligent Systems (MFI), 358–364. https://doi.org/10.1109/MFI.2012.6343024 (2012).
Haverinen, J. & Kemppainen, A. Global indoor self-localization based on the ambient magnetic field. Robot. Auton. Syst. 57, 1028–1035. https://doi.org/10.1016/j.robot.2009.07.018 (2009) (5th International Conference on Computational Intelligence, Robotics and Autonomous Systems (5th CIRAS)).
Solin, A., Kok, M., Wahlström, N., Schön, T. B. & Särkkä, S. Modeling and interpolation of the ambient magnetic field by Gaussian processes. IEEE Trans. Robot. 34, 1112–1127. https://doi.org/10.1109/TRO.2018.2830326 (2018).
Nouri, N. et al. A prototype vector magnetic field monitoring system for a neutron electric dipole moment experiment. J. Instrum. 10, P12003–P12003. https://doi.org/10.1088/1748-0221/10/12/p12003 (2015).
Nouri, N. & Plaster, B. Systematic optimization of exterior measurement locations for the determination of interior magnetic field vector components in inaccessible regions. Nucl. Instrum. Methods Phys. Res. A 767, 92–98. https://doi.org/10.1016/j.nima.2014.08.026 (2014).
Raissi, M., Perdikaris, P. & Karniadakis, G. Physics-informed neural networks: A deep learning framework for solving forward and inverse problems involving nonlinear partial differential equations. J. Comput. Phys. 378, 686–707. https://doi.org/10.1016/j.jcp.2018.10.045 (2019).
Schiassi, E., De Florio, M., D’Ambrosio, A., Mortari, D. & Furfaro, R. Physics-informed neural networks and functional interpolation for data-driven parameters discovery of epidemiological compartmental models. Mathematics.https://doi.org/10.3390/math9172069 (2021).
Schiassi, E. et al. Extreme theory of functional connections: A fast physics-informed neural network method for solving ordinary and partial differential equations. Neurocomputing 457, 334–356. https://doi.org/10.1016/j.neucom.2021.06.015 (2021).
Dwivedi, V. & Srinivasan, B. Physics informed extreme learning machine (PIELM)-a rapid method for the numerical solution of partial differential equations. Neurocomputing 391, 96–118. https://doi.org/10.1016/j.neucom.2019.12.099 (2020).
Abadi, M. et al. TensorFlow: Large-scale machine learning on heterogeneous systems (2015). Software available from tensorflow.org.
Paszke, A. et al. Pytorch: An imperative style, high-performance deep learning library. In Advances in Neural Information Processing Systems 32 (eds. Wallach, H. et al.) 8024–8035 (Curran Associates, Inc., 2019).
Kingma, D. P. & Ba, J. Adam: A method for stochastic optimization. https://doi.org/10.48550/ARXIV.1412.6980 (2014).
Jackson, J. D. Classical Electrodynamics, 3rd ed. (Wiley, 1999).
Bartberger, C. L. The magnetic field of a plane circular loop. J. Appl. Phys. 21, 1108–1114. https://doi.org/10.1063/1.1699551 (1950).
He, K., Zhang, X., Ren, S. & Sun, J. Deep residual learning for image recognition. In Proc. IEEE Comput. Soc. Conf. Comput. Vis. Pattern Recognit. (2016).
Acknowledgements
This material is based upon work supported by the U.S. Department of Energy, Office of Science, Office of Nuclear Physics, under Award Number DE-SC0014622.
Author information
Authors and Affiliations
Contributions
U.H.C. developed the physical concept, simulations and conducted the experiment. B.S. constructed the network model, processed the data and trained the network. B.P. supervised the project. All authors interpreted the results and wrote the manuscript.
Corresponding author
Ethics declarations
Competing interests
The authors declare no competing interests.
Additional information
Publisher's note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Rights and permissions
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.
About this article
Cite this article
Coskun, U.H., Sel, B. & Plaster, B. Magnetic field map** of inaccessible regions using physics-informed neural networks. Sci Rep 12, 12858 (2022). https://doi.org/10.1038/s41598-022-15777-4
Received:
Accepted:
Published:
DOI: https://doi.org/10.1038/s41598-022-15777-4
- Springer Nature Limited
This article is cited by
-
Physics-constrained machine learning for electrodynamics without gauge ambiguity based on Fourier transformed Maxwell’s equations
Scientific Reports (2024)
-
A novel optimization-based physics-informed neural network scheme for solving fractional differential equations
Engineering with Computers (2024)