Ship Magnetic Field Modeling and Extrapolation Based on a Convolutional Neural Network
https://doi.org/10.1007/s11804-025-00783-5
-
Abstract
Accurate modeling of ship magnetic fields is important for predicting their spatial distribution to improve the magnetic stealth effect of ships. This study proposes an extrapolation model for ship magnetic fields based on genetic algorithms and convolutional neural networks (CNNs). The magnetic probe position matrix of the traditional equivalent source is utilized as input, and the three-directional components of the magnetic field measured by the probes are employed as output. The extrapolation model for ship magnetic fields is obtained through iterative training and fitting with CNNs. Variables such as the number of magnetic dipoles, the distance between magnetic dipoles, the size and quantity of convolutional kernels, batch size, learning rate, and L2 regularization coefficient are optimized to boost the accuracy of the extrapolation model for magnetic fields. The fitting accuracy of the extrapolation model for ship magnetic fields is used as the optimization objective. Based on a finite element simulation model of ship magnetic fields, the accuracy and robustness of the CNN algorithm under different magnetic field conditions are validated using the known standard depth plane, the unknown depth at 1.125 times the standard depth plane, and the unknown depth at 1.25 times the standard depth plane. Results show that, after optimization, the fitting error for the magnetic field extrapolation model based on CNN is 1.50% for the standard depth plane, 1.63% for the unknown depth at 1.125 times the standard depth plane, and 2.36% for the unknown depth at 1.25 times the standard depth plane. The error remains below 5% under varying magnetic field conditions. When a random measurement error of 0%–5% is introduced for the magnetic probes, the prediction error at 1.25 times the standard depth plane is 2.30%; with a random error of 0%–10%, the prediction error is 4.95%. This approach significantly improves the accuracy and robustness of magnetic field extrapolation, which makes it an effective and feasible method for ship magnetic field modeling.
Article Highlights
• In order to construct a high-precision magnetic field model of a ship, a magnetic field modeling method based on convolutional neural network is proposed.• Utilizing the matrix of the traditional equivalent source model effectively improves the interpretability of the model.
• Using genetic algorithm to optimize the model parameters improves the fit and applicability of the model.
-
1 Introduction
The ship, as a large-scale ferromagnetic structure with complex geometry, is magnetized by a geomagnetic field and produces a ship magnetic field around it (Sheinker et al., 2021; Birsan, 2021; Lin et al., 2020).
Given that the geomagnetic field is generally decomposed into three orthogonal components, the ship will similarly generate three magnetic field components superimposed on the geomagnetic field. When a ship target enters a certain geomagnetic field region, it will cause abnormality of the magnetic field in the region. This abnormality can be easily detected by magnetic detection equipment and affects the defense capability of the ship. Therefore, the modeling, prediction, and extrapolation method of ship magnetic fields is a vital topic in the field of ship research, and its accuracy will influence the magnetic protection capability of ships (Wang et al., 2024; Jia and Lin, 2018).
High-precision modeling of ship magnetic fields can obtain their accurate spatial distribution characteristics. Typically, ship magnetic field modeling includes the finite element method, the boundary element method, and the equivalent source method. The finite element method needs high-precision modeling of ships, and the computational complexity of the boundary element method is too large and complicated. Therefore, the equivalent source method is relatively popular. The equivalent source method involves measuring the complete magnetic field data on a specific plane of the ship, followed by applying modeling approaches to reconstruct the magnetic field of the ship. However, empirical models without algorithmic optimization often encounter various problems, such as low modeling accuracy, poor stability, and limited applicability. The construction of high-precision and stable ship models remains a key focus of studies on ship magnetic field modeling (Zhang et al., 2018; Zateev et al., 2021).
In the current research, different modeling methods for ship magnetic fields are available: the first is based on strict theoretical derivation, including the large plane method, the boundary element method, and the finite element method (Gao et al., 2006; Zhou et al., 2009; Woloszyn and Jankowski, 2017; Gao et al., 2021). This type of method exhibits high computational accuracy. However, the requirements for the measurement are highly stringent, and a complete measurement envelope is needed, which is difficult to satisfy in practice. The second is the equivalent source model method, which mainly includes the single magnetic dipole model, multi-dipole array, rotating ellipsoid, magnetic dipole, rotating ellipsoid hybrid model, and prolate spherical harmonics (Jakubiuk et al., 2012; Hui, 2010; Hua et al., 2020; Synnes, 2008). Different approaches target distinct types of magnetic field prediction problems. Moreover, many factors affect the fitting and prediction accuracy of the equivalent source model, including the type, location, and number of equivalent sources and the number of magnetic probes and errors. The selection of these parameters depends on design experience in some cases, which leads to obvious fluctuation in the accuracy of the equivalent source magnetic field model. In Jin et al. (2022), a multiple magnetic dipole model is used to simulate ship magnetic fields to achieve demagnetization. In Yan (2020), a simulated annealing algorithm is introduced to optimize the position distribution of the magnetic dipoles, and the accuracy of the magnetic field model is enhanced. Based on the analysis of the test data of the scaled model, Liu et al. (2022) determines the relationship between the cutoff frequency and the maximum energy spectrum, obtains the maximum sampling interval suitable to the magnetic field signal, and finally completes the reconstruction of the magnetic field signal. Dai et al. (2018) regards the number of coefficient matrix conditions of the hybrid model as the objective function, and the simulated annealing algorithm is adopted to adjust the number of coefficient matrix conditions for obtaining the optimal position distribution of the magnetic dipole arrays. Menana (2021) develops a model based on the coupling of the finite element method and the boundary element method for magnetic field computation in thin magnetic shells submitted to external magnetic fields. In Tarnawski et al. (2020), the proposed modernization of the multi-dipole model construction utilizes three-axis magnetometers and improves model flexibility. This method significantly boosts magnetic signature reproduction. Tarnawski et al. (2022) presents a continuation of the study on the 3D multi-dipole model adopted for the reproduction of magnetic signatures of ferromagnetic objects. The model structure is modified to increase its flexibility. As a result, model parameters determined by optimization can be located in the cuboid contour representing the hull of the object. The training data set is expanded to data collected from all four cardinal directions to stiffen the model.
The abovementioned literature indicates that the equivalent source method is the most precise and fastest among the current modeling methods for ship magnetic fields. However, the feature selection of the equivalent source greatly influences the accuracy, which causes difficulty in feature screening. Other methods, including the finite element and boundary element methods, are troubled by complex model modeling, high computational volume, and poor adaptability to model testing.
The continuous development of neural networks has facilitated the further advancement and wide utilization of convolutional neural networks (CNNs) featuring nonlinear regression, dataset training, and image recognition in the electromagnetic field. Khan et al. (2019) investigates the feasibility of a novel data-driven CNN model to predict the solution of Maxwell’s system of equations for low-frequency electromagnetic devices. The focus is on the mapping of magnetic field distributions with different geometries, materials, and excitation complexity topologies. Although a structured CNN is not the ideal architecture for handling an unstructured mesh, as in FEA, the DL field estimator model built on it can serve as an initial estimate for the FEA solver. Another constriction is the amount of simulated (big) data required for training a deep network. Deng et al. (2024) devises a novel deep learning method for permanent magnet structures. The method is based on CNN and aims to inversely predict the properties (magnetization, size, and position) of a single hard magnet from a given 2D magnetic field. It obtains an optimal error of 0.22%. However, the capability of the model to predict coil configurations needs to be improved, and the number of prediction targets should be increased to compare more brain regions. Sasaki et al. (2024) proposes a novel methodology for directly training response surfaces of torque and magnet flux density distributions of interior permanent magnet synchronous motors under specified input conditions. The method is also used to predict the speed–torque characteristics or torque wave with a CNN. In these tasks, the approach achieves an 89.6% increase in accuracy compared with comparative methods. The study needs to further refine the input method for enhancing the prediction of more complex problems and apply the method to other motor characteristics such as iron loss. Peng et al. (2025) constructs a simulation model based on transformer electromagnetic field coupling, parameterizes scanning of key variables, obtains a large amount of magnetic field data under different nonlinear operating conditions through simulation, and constructs a dataset comprising main and leakage magnetic fluxes related to the nonlinear operating conditions of the iron core. Moreover, a dual branch deep learning model integrating CNNs and the long short-term memory network is proposed to train and extract spatial and temporal features of magnetic field data. This model solves the problem of model training caused by large differences in main and leakage magnetic flux. Finally, the nonlinear mapping relationship among input voltage, current, and internal spatial magnetic field distribution is obtained using the model. This derivation accelerates the calculation of spatial dynamic magnetic fields, which provides a fast method for obtaining magnetic field data for the construction of transformer digital twins. Chen et al. (2024) aims to approximate the electromagnetic field distribution in a simplified transformer through 2D finite element analysis and proposes a novel method that establishes datasets incorporating meaningful physical properties, such as magnetic permeability, conductivity, and current excitation matrices, as different channels in the input tensors. The U-Resnet model, which is a hybrid architecture combining the residual blocks of ResNet with the U-net structure, is introduced to enhance estimation. The comparison of the performance of U-net and U-Resnet demonstrates the superiority of the latter over the former. In Peng et al. (2023), a method based on deep neural networks (DNNs) is proposed to rapidly predict the magnetic field distribution of reactors. After the DNN is trained on magnetic field data generated by FEA simulation, it takes the reactor current value as input and obtains the simulation results processed using principal component analysis within 1 s. The trained DNN presents a mean absolute percentage error of 0.012% in predicting the magnetic field distribution of the reactor.
Based on the above mentioned problems and the existing research conclusions, this study proposes a ship magnetic field data-driven model based on high-precision nonlinear fitting of CNNs and the parameter optimization ability of the genetic algorithm (GA). The position information matrix obtained by the traditional magnetic source method is used as the input, and the detected magnetic field values are regarded as the output to train the CNN optimized in real time using the GA to improve the robustness and accuracy of the CNN model. Finally, a high-precision data-driven model for ship magnetic fields is obtained.
2 Magnetic dipole model of ship magnetic fields
In Figure 1, BA, BV, and BLare the three-directional components of the geomagnetic field in the ship coordinate system. XiD, YiD, and ZiD represent the 3D coordinate system of magnetic probe point i.
Assuming the existence of a magnetic dipole at P0(α0, β0, γ0), the magnetic dipole moment is M0 = Mx0i + My0j + Mx0k. In addition, the strength of the magnetic field generated at coordinates (x, y, z) can be expressed in a matrix form, as shown in Equation (1).
$$ \left[\begin{array}{l} H_{x 0} \\ H_{y 0} \\ H_{z 0} \end{array}\right]=\left[\begin{array}{lll} F_{x x} & F_{x y} & F_{x z} \\ F_{y x} & F_{y y} & F_{y z} \\ F_{z x} & F_{z y} & F_{z z} \end{array}\right] \cdot\left[\begin{array}{l} M_{x 0} \\ M_{y 0} \\ M_{z 0} \end{array}\right] $$ (1) where i is a unit vector in the positive direction of x, j is a unit vector in the positive direction of y, k is a unit vector in the positive direction of z, and M0 is the vector of the magnetic moment.
The expression can be simplified, as shown in Equation (2).
$$ \boldsymbol{H}_0=\boldsymbol{F}_0 \cdot \boldsymbol{M}_0 $$ (2) where H0 is the column vector consisting of the three components of the magnetic field strength at the magnetic probe point, F0 is the parameter matrix, and M0 is the column vector of the three-directional magnetic moment of the magnetic dipole.
The calculation of each parameter in Equation (1) is explained in Equations (3)–(7):
$$ \left\{\begin{array}{l} F_{x x}=\frac{3}{4 \mathsf{π} r^5}\left[\left(x-\alpha_0\right)^2-\frac{r^2}{3}\right] \\ F_{x y}=\frac{3}{4 \mathsf{π} r^5}\left(x-\alpha_0\right)\left(y-\beta_0\right) \\ F_{x z}=\frac{3}{4 \mathsf{π} r^5}\left(x-\alpha_0\right)\left(z-\gamma_0\right) \end{array}\right. $$ (3) $$ \left\{\begin{array}{l} F_{y x}=F_{x y} \\ F_{y y}=\frac{3}{4 \mathsf{π} r^5}\left[\left(y-\beta_0\right)^2-\frac{r^2}{3}\right] \\ F_{y z}=\frac{3}{4 \mathsf{π} r^5}\left(y-\beta_0\right)\left(z-\gamma_0\right) \end{array}\right. $$ (4) $$ \left\{\begin{array}{l} F_{z x}=F_{x z} \\ F_{z y}=F_{y z} \\ F_{z z}=\frac{3}{4 \mathsf{π} r^5}\left[\left(z-\gamma_0\right)^2-\frac{r^2}{3}\right] \end{array}\right. $$ (5) $$ \boldsymbol{r}=\left(x-\alpha_0\right) \mathbf{i}+\left(y-\beta_0\right) \mathbf{j}+\left(z-\gamma_0\right) \mathbf{k} $$ (6) $$ r=\sqrt{\left(x-\alpha_0\right)^2+\left(y-\beta_0\right)^2+\left(z-\gamma_0\right)^2} $$ (7) The magnetic dipole array model simulates the ship’s magnetic field using a column of uniformly arranged magnetic dipole sources on the centerline of the ship. The basic unit is a single magnetic dipole model, which preserves the advantages of simple mathematical models and can simulate ship magnetic fields to a large extent. The fitting accuracy of a planar magnetic field increases with the rise in the number of magnetic dipoles. However, too many magnetic dipoles can cause redundancy and even result in a decrease in the fitting accuracy of the model. In general, higher fitting accuracy of the magnetic field on the input plane corresponds to higher extrapolation accuracy of the model.
A reference coordinate system with the center of the ship is established. The coordinate system has the bow pointing in the x-positive direction, the vertical downward direction in the z-positive direction, and the vertical starboard direction in the y-positive direction. The magnetic dipole is uniformly distributed along the x-direction, and the distance between the measurement point and the magnetic dipole is r, as displayed in Figure 2.
The strength of the magnetic field produced by the superposition of n magnetic dipoles in space is shown in Equation (8):
$$ \left\{\begin{array}{l} H_x(x, y, z)=\sum\limits_{j=1}^n\left[F_{x x j} \times M_{x j}+F_{x x j} \times M_{y j}+F_{x z j} \times M_{z j}\right] \\ H_y(x, y, z)=\sum\limits_{j=1}^n\left[F_{y x j} \times M_{x j}+F_{y y j} \times M_{y j}+F_{y z j} \times M_{z j}\right] \\ H_z(x, y, z)=\sum\limits_{j=1}^n\left[F_{x x j} \times M_{x j}+F_{z y j} \times M_{y j}+F_{z z j} \times M_{x j}\right] \end{array}\right. $$ (8) where Hx (x, y, z), Hy (x, y, z), and Hz (x, y, z) are the strength of the three-directional magnetic field of n magnetic dipoles superimposed on the probe point, F**j is the parameter corresponding to the jth magnetic dipole, and M*j is the magnetic moment corresponding to the jth magnetic dipole.
The expression can be simplified, as shown in Equations (9) and (10):
$$ \boldsymbol{H}=\boldsymbol{F} \cdot \boldsymbol{M} $$ (9) $$ \boldsymbol{F}=\left[\begin{array}{lllllllll} F_{x x 1} & \cdots & F_{x x n} & F_{x y 1} & \cdots & F_{x y n} & F_{x z 1} & \cdots & F_{x z n} \\ F_{y x 1} & \cdots & F_{y x n} & F_{y y 1} & \cdots & F_{y y n} & F_{y z 1} & \cdots & F_{y z n} \\ F_{z x 1} & \cdots & F_{z x n} & F_{z y 1} & \cdots & F_{z y n} & F_{z z 1} & \cdots & F_{z z n} \end{array}\right] $$ (10) where H is the column vector of the three-directional magnetic field at the magnetic probe point, F is the parameter matrix corresponding to n magnetic dipoles (3 rows and 3 × n columns), and M is the column vector of magnetic moments corresponding to n magnetic dipoles (3 × 5n rows and 1 column).
If N measurement points are considered, based on the magnetic field information and position information of the N magnetic probes, then the magnetic moment M of the magnetic dipole array can be inverted using the least-square method. Accordingly, an equivalent magnetic field source of the magnetic dipole array is obtained.
When predicting and extrapolating the ship’s magnetic field using the abovementioned method, determining the optimal number and spatial distribution of magnetic dipoles will be difficult. Thus, Equation (8) will become an unstable matrix equation. Furthermore, the inversion process of solving the magnetic moment M of each magnetic dipole results in poor fitting or overfitting, which affects the prediction and extrapolation accuracy of ship magnetic fields.
3 Magnetic field model training method based on convolutional neural networks and genetic algorithms
The extrapolation method for ship magnetic fields proposed in this study mainly adopts a CNN to establish a black-box model, which is combined with a GA to optimize the parameters for improving the fitting accuracy and generalization capability of the model.
3.1 Convolutional neural networks
CNNs are a class of feedforward neural networks containing convolutional computation with deep structure and are a fundamental deep learning architecture. The typical structure is shown in Figure 3.
CNNs differ from general neural networks because they involve convolutional computation. In the convolution process, the neural network is each small pixel region on the image is processed while ignoring the input information for each pixel. The purpose of this practice is to strengthen the continuity of the information in the image. As a result, the neural network can obtain the pixel information related to the graphic rather than a pixel point. The image is actually fed into the CNN for processing in the form of a matrix, which matches the way matrices are computed in traditional equivalent sources.
3.2 Genetic algorithms
The GA, which originated from computer simulations of biological systems, is a stochastic global search optimization method. It simulates the phenomena of replication, crossover, and mutation in natural selection and heredity. It starts from an arbitrary initial population. Then, it conducts random selection, crossover, and mutation operations to produce a group of individuals better suited to the environment. The group moves toward increasingly favorable regions in the search space. Through continuous reproduction and evolution, successive generation improves. Eventually, the process converges on the most suitable group of individuals, which produces a high-quality solution to the problem.
3.3 Model training and optimization
The traditional equivalent source method primarily utilizes the inverse of the ship’s magnetic field at the magnetic probe point to obtain the magnetic moment information of the equivalent simulator. As a result, the magneticmoment information and position information of each equivalent simulator are known.
In this study, each coefficient matrix F0 (Equation (2)) of each magnetic dipole is employed as the input of the CNN, and the ship’s magnetic field H0 is adopted as the output CNN. After several rounds of iterative fitting, a highly fitted implicit equivalent source model is derived. The magnetic moment information is jointly characterized by the convolutional layer, pooling layer, activation function, and fully connected layer of the CNN. The inputmatrix of the CNN, which is obtained from the magnetic source calculation formula, exhibits a nonlinear physical relationship with the magnetic field output values. This condition improves the accuracy and training efficiency of the CNN.
In the traditional magnetic dipole model, the magnetic field H at a probe point is shown in Equation (2). $ \boldsymbol{F}_0 \in \mathbb{R}^{3 \times 53 n}$ represents the parameter matrix encoding spatial relationships between n dipoles and the probe, and $ \boldsymbol{M}_0 \in \mathbb{R}^{3 n \times 51}$ denotes the dipole moment vector. To align with the spatial processing capabilities of the CNN, the F0-matrix is restructured into a 3D tensor $ \boldsymbol{F} \in \mathbb{R}^{3 \times 53 \times 5 n}$. Notably, each 3 × 3 slice corresponds to the contribution of a single dipole. The third dimension (n) represents the number of dipoles, which is analogous to “channels” in image data.
The CNN architecture is designed to mimic the physical principles of magnetic field superposition and nonlinearity.
The convolution operation emulates the spatial summation of dipole contributions. For a kernel $ K \in \mathbb{R}^{m \times m}$,
$$ F_{\mathrm{out}}^{(k)}=\tanh \left(\sum\limits_{i=1}^n F^{(i)} \times K^{(k)}+b^{(k)}\right) $$ (11) where Fout(k) isis the output channel, K(k) denotes the convolution kernel, b(k) represents the bias term corresponding to the convolution kernel, and K(k) signifies the input channel.
Each kernel K(k) learns to detect spatial patterns (e. g., near- vs. far-field effects) akin to the spatial interaction of dipoles. Notably, m × 5m is the size of convolutional kernels, and n represents the number of dipoles.
In this study, the hyperbolic tangent (tanh) function is chosen as the activation function to guarantee that the output is bounded, which reflects the physical reality that magnetic fields are saturated due to material permeability limitations. The tanh function is displayed in Equation (12).
$$ \tanh (x)=\frac{e^x-e^{-x}}{e^x+e^{-x}}=2 \sigma(2 x)-1 $$ (12) where σ is a sigmoid function with output in the range (−1, 1).
When using a CNN to construct nonlinear models, parameters such as convolutional kernel size, activation function, learning rate, and number of iterations are randomly initialized. The unoptimized individual parameters influence the fitting accuracy and convergence speed of the network and are prone to fall into local optimal solutions. Therefore, a GA is applied to optimize the design of the parameters of the CNN with the objective of fitting accuracy. The specific process is illustrated in Figure 4.
The main optimization parameters selected in this study are the number of magnetic dipoles, magnetic dipole spacing, convolutional kernel size, number of convolutions, number of batches, learning rate, and L2 regularization factor.
The magnetic dipoles are arranged equidistantly on the x-axis of the ship coordinate system, as shown in Figure 2, to simplify the optimization process.
The optimization objective is to ensure that the CNN model fits the magnetic field information of the magnetic probe location in a known plane with the minimum error, which is calculated as shown in Equation (13).
$$ e=\frac{\sqrt{\sum\limits_{i=1}^m\left(\left(H_{x i}-H_{x i}^{\prime}\right)^2+\left(H_{y i}-H_{y i}^{\prime}\right)^2+\left(H_{z i}-H_{z i}^{\prime}\right)^2\right)}}{\sqrt{\sum\limits_{i=1}^m\left(H_{x i}^2+H_{y i}^2+H_{z i}^2\right)}} $$ (13) where Hxi, Hyi, and Hzi are the three-directional magnetic field components measured by each magnetic probe on the plane; Hxi′, Hyi′, and Hzi′ are the three-directional magnetic field components predicted by the CNN model at each point on the plane; and m is the number of magnetic probes.
3.4 Training method and structure of the CNN model
The training method and structure of the CNN model in this study are shown in Figure 5. The characteristics and functions of its layers are shown in Table 1.
Table 1 Characteristics and functions of layersLayer Characteristics Functions Input layer 3 × 3 × 15 Corresponds to the magnetic dipole position matrices obtained from the equivalent source method Convolutional layer 648 convolutional kernels of size 9 × 9 Extracts spatial features from the input matrices, which preserves spatial resolution while capturing local correlations Batch normalization layer Batch size of 262 Stabilizes training by normalizing activations between layers Activation layer Hyperbolic tangent (tanh) function Introduces nonlinearity Fully connected layer 3 output nodes Represents the three-directional magnetic field components Regression layer RMSprop Minimizes the mean squared error between predicted and measured magnetic fields The current architecture excludes explicit pooling layers. This design selection stems from the need to retain spatial resolution in the magnetic field matrices. Pooling operations (e. g., max-pooling) can discard fine-grained spatial information important for accurate field extrapolation. Instead, the convolutional layer with “same” padding preserves input dimensions, which guarantees that spatial relationships are maintained throughout the network.
The regression layer uses MSE as the loss function, which is formulated as Equation (13).
The RMSprop optimizer is used with a dynamic learning rate schedule. The following key hyperparameters are considered: initial learning rate, L2 regularization coefficient (prevents overfitting), mini-batch size (balances computational efficiency and gradient accuracy), and learning rate decay (triggered every 30 epochs to improve convergence).
The GA optimizes these hyperparameters, which ensures robust convergence and minimizes training instability.
The CNN framework can be adapted to magnetic field modeling due to the following reasons:
1) Convolutional layers effectively capture local spatial dependencies in the magnetic dipole matrices, which is a process analogous to image processing. This feature aligns with the grid-like arrangement of magnetic probes and dipoles;
2) The input structure (3 × 3 × 15) mimics the magnetic dipole parameter matrices, which enables direct processing without data flattening;
3) The tanh activation and fully connected layer realize nonlinear mapping between dipole configurations and field components. This mapping is critical for modeling complex interactions.
4) GA optimization guarantees hyperparameters (e.g., kernel size, regularization) are tailored to the physical characteristics of ship magnetic fields, which enhances generalizability.
Based on the combination of the literature review and the abovementioned structure, the theoretical basis for the superiority of CNNs over traditional methods is established, as shown in Table 2.
Table 2 Comparison of CNNs with traditional methodsTraditional method Strengths Limitations CNN Advantage Advanced boundary element methods (BEMs) Low computational complexity and high accuracy Require precise knowledge of boundary conditions and complete measurement envelopes CNNs bypass explicit boundary modeling by learning spatial correlations directly from data. Thus, they accommodate incomplete measurements and nonlinear material responses through adaptive feature extraction Physics-informed neural networks (PINNs) Incorporate physical laws as soft constraints and improve generalization with limited data Computationally expensive for large-scale 3D problems due to coupled partial differential equation (PDE) constraints Struggle with sharp field gradients near edges or corners, which are common in ship geometries CNNs focus on data-driven pattern recognition without explicit PDE enforcement, which achieves faster convergence and robustness to localized field anomalies Hybrid analyticalnumerical methods Integrate analytical solutions with numerical discretization for balanced accuracy and efficiency Require domain-specific expertise to obtain analytical approximations, which limits adaptability to novel ship designs. Exhibit poor scalability to multi-scale problems The hierarchical architecture of CNNs inherently captures multi-scale features (via convolutional kernels of varying receptive fields), which enables unified modeling of complex field distributions Other machine learning approaches Data fitting and high efficiency Limited to low-dimensional feature spaces, exhibit poor generalization, and overfit to training data CNNs involve spatial feature learning, regularization, and scalability 4 Arithmetic-based validation
The simulation model of ship magnetic fields constructed based on finite element software is displayed in Figure 6.
The specific parameters of the vessel are illustrated in Table 3. Among these parameters, magnetic fields in the x, y, and z directions are assigned in the simulation to mirror the geomagnetic field.
Table 3 Parameters of the simulation modelSimulation parameters Numerical value Size of the model 95 m × 18 m × 5.5 m Relative permeability 80 Wall thickness 60 mm The positive direction of the virtual ship model is defined as the x-axis, the starboard direction as the y-axis, and the vertical direction as the z-axis. Three depth planes are set up below the virtual ship model: one for the standard depth, one for 1.125 times the standard depth, and another for 1.25 times the standard depth. These planes have a longitudinal length of 39 × 5 m and a transverse width of 4 × 5 m. A total of 200 magnetic field probes are considered, with each probe spaced 5 m longitudinally and 5 m laterally, as depicted in Figure 7.
Among the 200 sets of data, 80% are randomly selected as the training group to train the model, while 20% are utilized as the prediction group to verify the model’s accuracy.
First, the data of the standard submerged depth plane are fitted using the CNN model, and the optimal model is outputted by combining the optimized parameters of the GA (with the fitting accuracy as the target). Then, the position information corresponding to 1.125 and 1.25 times the submerged depth plane is taken as the input. The optimal model is used to extrapolate the magnetic field information of these planes, and the findings are compared with the simulation results.
4.1 Optimized CNN model
Using the fitting accuracy of the CNN as the fitness function, GA optimization is conducted to obtain the parameters of the CNN depicted in Table 4 and the convergence graph illustrated in Figure 8. Among these parameters, the external magnetic field settings are presented in Table 5.
Table 4 Parameters of the optimized CNNParameters Numerical value Number of magnetic dipoles 15 Magnetic dipole spacing (m) 8.69 Size and quantity of convolution kernels 9648 Batch size 262 Learning rate 0.0175 L2 regularization coefficient 1.016 × 10−4 Table 5 Parameters of the simulation modelMagnetic field direction Numerical value (nT) X 34000 × cos(π/6) Y 34000 × sin(π/6) Z −35000 The convergence criterion for CNN training involves testing the loss rate and root mean square error every 30 generations, which avoids overfitting. When the loss rate and root mean square error of five consecutive detections converge, the CNN stops iterating and outputs the final model. As shown in Figure 8, the loss rate and root mean square error of the CNN decrease with the number of generations. At 1 500 iterations, the network converges and satisfies the iteration deadline condition, with a total time of nearly 54 s.
A single-factor analysis is performed for each parameter based on the optimization results to determine the influence of different parameters on the fitting accuracy of the CNN model. The range of single-factor analysis for each factor is presented in Table 6.
Table 6 Study range of single-factor analysis for each factorParameters Range Number of magnetic dipoles 10–20 Magnetic dipole spacing (m) 5.21–12.17 Size of convolution kernels 4–14 Quantity of convolution kernels 389–908 Batch size 157–367 Learning rate 0.0105–0.0245 L2 regularization coefficient 6.09 × 10−5–1.42 × 10−4 The results of the single-factor analysis are displayed in Figure 8.
Figure 9 shows that too small batch sizes will seriously affect the fitting accuracy of the model, but too large batch sizes will saturate the fitting accuracy.
The change in other factors has little influence on the fitting accuracy, which confirms that the result of the optimization algorithm converges to a better solution.
The cross-validation test in this study proceeds as follows: five model training sessions are conducted. In each session, 200 magnetic field messages are randomly divided into the validation group (20%) and the training group (80%) to validate the model’s accuracy. The corresponding results (Table 7) suggest that the proposed model does not suffer from overfitting.
Table 7 Cross-testing resultsFold Training error (%) Validation error (%) 1 1.52 1.65 2 1.48 1.60 3 1.55 1.70 4 1.50 1.62 5 1.53 1.64 Mean + std 1.52 ± 0.03 1.64 ± 0.04 The accuracy results of the extrapolated magnetic field of the optimized model are shown in Figure 10.
4.2 Extrapolation accuracy of different algorithms
Traditional equivalent source methods, feedforward neural networks, and CNN methods are trained based on magnetic field data measured by magnetic probes positioned at the standard depth plane to compare their fitting and extrapolation accuracy. The fitting accuracy of different models on the standard depth plane is compared, as well as the extrapolation accuracy of prediction at 1.125 and 1.25 times the standard depth plane.
The accuracy of the extrapolated magnetic field at 1.25 times the standard depth plane is presented in Figure 11.
Figure 11 and Table 8 indicate that the optimized CNN model has accuracy advantages in fitting magnetic fields in the standard depth plane and predicting magnetic fields at 1.125 times and 1.25 times the standard depth plane.
Table 8 Comparison of magnetic field fitting and extrapolation accuracy of different methodsFit method Fitting error of the standard depth Extrapolation error at 1.125 times the standard depth Extrapolation error at 1.25 times the standard depth Traditional magnetic source method 17.02% 13.77% 12.81% Feedforward neural network 1.13% 14.32% 22.58% CNN 1.50% 1.63% 2.36% Feedforward neural networks have high fitting accuracy for magnetic fields in the standard depth plane. However, their generalization is poor, and their accuracy is small when extrapolating magnetic fields from other planes. The traditional magnetic dipole model depends on experience and presents characteristics of low near-field accuracy and high far-field accuracy.
4.3 Considering the Extrapolation Accuracy of CNN Models in Different Magnetic Field Environments
The extrapolation accuracy of the CNN model under different magnetic field conditions is verified. For this purpose, the magnitude of the geomagnetic field, the relative magnetic permeability of the ship, and the residual magnetism of the ship are adjusted to calculate the extrapolation accuracy of the CNN model under different magnetic field environments.
Changing the geomagnetic field environment while keeping other parameters constant, the geomagnetic field settings are depicted in Table 9.
Table 9 Magnitude of the external magnetic field after changesMagnetic field direction Parameter combination 1 (nT) Parameter combination 2 (nT) X 39000 × sin(π/3) 39000 × sin(π/6) Y 39000 × cos(π/3) 39000 × cos(π/6) Z −19500 −19500 The relative magnetic permeability of the ship is adjusted to 150. The errors in extrapolation at 1.125 times the standard depth plane are 3.43% and 3.12%, and those at 1.25 times the standard depth plane are 3.72% and 3.62%. The z-direction magnetic field at 1.25 times the standard depth plane is illustrated in Figure 12.
The relative magnetic permeability of the ship is adjusted to 15, which further optimizes its residual magnetism setting. The magnetic field value at the magnetic probe is decreased, and the magnetic field of the ship after demagnetization is simulated. The errors in extrapolation at 1.125 times the standard depth plane are 2.53% and 2.63%, and those at 1.25 times the standard depth plane are 2.92% and 2.95%. The z-direction magnetic field at 1.25 times the standard depth plane is displayed in Figure 13.
4.4 Extrapolation accuracy of different algorithms considering magnetic probe errors
Errors are generated in the measurement of the magnetic probe due to the deviation in its position and angle during actual magnetic field detection. Therefore, the magnetic field value measured by the magnetic probe cannot represent the actual magnetic field value at the measurement point. To test the robustness of the three methods under the influence of errors, a random noise array distributed within a certain range is added to each magnetic field component of each magnetic probe. The scaling factor (noise level) can be adjusted by controlling the “intensity” of noise. Lower noise levels imply weaker interference, while higher levels suggest stronger interference.
Each detection (the component of the magnetic field in each of the three directions) is added to a noise array obtained by multiplying a random number from a standard normal distribution using a scaling factor. The expressions are shown in Equations (14) and (15).
$$ H=H_t \times(1+a \times Z) $$ (14) $$ f_z(z)=\frac{1}{\sqrt{2 \mathsf{π}}} \mathrm{e}^{-\frac{z^2}{2}} $$ (15) where H is the detection value of the magnetic probe; Ht 0.7 3.94% denotes the actual value of the magnetic field at the mag1.3 3.67% netic probe; a represents the size of the introduced error, which is chosen as 5% and 10% in this study; and Z obeys the standard normal distribution.
Based on the data training model with introduced errors, the accuracy results of the prediction at 1.125 times and 1.25 times the standard depth plane are depicted in Table 10.
Table 10 Comparison of magnetic field fitting and extrapolation accuracy of different methods with varying levels of errors introducedNoise factor Fitting method Extrapolation error of the 1.125 times the standard depth Extrapolation error of the 1.25 times the standard depth 0%–5% Traditional magnetic source method 15.73% 12.93% Feedforward neural network 18.62% 25.34% CNN 2.20% 2.30% 0%–10% Traditional magnetic source method 16.12% 13.24% Feedforward neural network 20.25% 28.36% CNN 3.93% 4.95% The results in Table 7 reveal that, with the introduction of 0%–5% and 0%–10% error factors, the CNN exhibits good robustness and can still accurately predict the magnetic field size at 1.125 and 1.25 times the standard depth plane.
4.5 Model accuracy with different ship models
The model is scaled down equally (0.7 times vs. 1.3 times) without adjusting the number of magnetic dipoles and the sensor array position to verify its accuracy under different sizes of ships. A comparison of different ship models is presented in Figure 14.
The results in Table 11 are obtained by keeping the parameters in Table 6 unchanged.
Table 11 Magnitude of the external magnetic field after changesShrinkage factor Fitting error at the standard depth Extrapolation error at 1.125 times the standard depth 0.7 3.94% 4.19% 1.3 3.67% 4.01% Notably, the number and spacing of the magnetic dipoles in the traditional equivalent source model considerably affect the model accuracy. Thus, the number and spacing of the magnetic dipoles are adjusted for the two deflation scenarios while keeping the parameters of the CNN unchanged. The optimized model accuracies are presented in Table 12. The optimization of the number and spacing of magnetic dipoles is fast, which reflects the efficiency of model optimization.
Table 12 Magnitude of the external magnetic field after optimizationShrinkage factor Fitting error at the standard depth Extrapolation error at 1.125 times the standard depth 0.7 2.12% 2.23% 1.3 1.96% 2.02% The results in Table 12 suggest that the change in model size has less effect on the accuracy of the CNN model.
4.6 Analysis and outlook
This chapter presents the verification of the accuracy and robustness of the CNN model in constructing the ship magnetic field model based on finite element simulation. However, the following limitations still exist: the validation is based only on simulation. The magnetic field situation of real ships is more complicated, the magnetic field detection is highly difficult, and the magnetic field information is more likely to be disturbed. The accuracy and robustness of the CNN model in this situation need to be validated.
The follow-up work involves the following tasks:
1) Experiments will be conducted on real ships/ship models to obtain magnetic field data that better fit the engineering reality to verify the reliability of the model;
2) The effects of different ship models on the model parameters will be analyzed;
3) The effects of missing magnetic probes, angular errors, and ship attitude changes on model accuracy will be considered.
5 Conclusions
This study proposes an extrapolation prediction method for ship magnetic fields based on CNNs and GAs. The method is validated using a finite element simulation model, and the following conclusions are drawn:
1) Using the position matrix of traditional equivalent sources as input and the magnetic field information of magnetic probe points as output, training a CNN model for ship magnetic fields can better fit and predict these fields in various depth planes. After GA optimization, the characteristics and accuracy of CNN models can be further enhanced. Among these methods, the optimized CNN model has an error of 1.50% in fitting the standard depth plane, 1.63% in extrapolating the magnetic field at 1.125 times the standard depth plane, and 2.36% in extrapolating the magnetic field at 1.25 times the standard depth plane.
2) By comparing different magnetic field extrapolation methods, optimizing different magnetic field environments, and introducing errors, the accuracy, adaptability, and robustness of the CNN model are verified. Among these methods, when a magnetic field detection error of 0%–5% is introduced, the error of the CNN model for extrapolation at 1.25 times the standard depth plane is 2.3%. When a magnetic field detection error of 0%–10% is added, the error of extrapolation at 1.25 times the standard depth plane is 4.95%.
Overall, the extrapolation method for ship magnetic fields proposed in this study is feasible and has its own advantages in accuracy and stability.
Competing interest The authors have no competing interests to declare that are relevant to the content of this article. -
Table 1 Characteristics and functions of layers
Layer Characteristics Functions Input layer 3 × 3 × 15 Corresponds to the magnetic dipole position matrices obtained from the equivalent source method Convolutional layer 648 convolutional kernels of size 9 × 9 Extracts spatial features from the input matrices, which preserves spatial resolution while capturing local correlations Batch normalization layer Batch size of 262 Stabilizes training by normalizing activations between layers Activation layer Hyperbolic tangent (tanh) function Introduces nonlinearity Fully connected layer 3 output nodes Represents the three-directional magnetic field components Regression layer RMSprop Minimizes the mean squared error between predicted and measured magnetic fields Table 2 Comparison of CNNs with traditional methods
Traditional method Strengths Limitations CNN Advantage Advanced boundary element methods (BEMs) Low computational complexity and high accuracy Require precise knowledge of boundary conditions and complete measurement envelopes CNNs bypass explicit boundary modeling by learning spatial correlations directly from data. Thus, they accommodate incomplete measurements and nonlinear material responses through adaptive feature extraction Physics-informed neural networks (PINNs) Incorporate physical laws as soft constraints and improve generalization with limited data Computationally expensive for large-scale 3D problems due to coupled partial differential equation (PDE) constraints Struggle with sharp field gradients near edges or corners, which are common in ship geometries CNNs focus on data-driven pattern recognition without explicit PDE enforcement, which achieves faster convergence and robustness to localized field anomalies Hybrid analyticalnumerical methods Integrate analytical solutions with numerical discretization for balanced accuracy and efficiency Require domain-specific expertise to obtain analytical approximations, which limits adaptability to novel ship designs. Exhibit poor scalability to multi-scale problems The hierarchical architecture of CNNs inherently captures multi-scale features (via convolutional kernels of varying receptive fields), which enables unified modeling of complex field distributions Other machine learning approaches Data fitting and high efficiency Limited to low-dimensional feature spaces, exhibit poor generalization, and overfit to training data CNNs involve spatial feature learning, regularization, and scalability Table 3 Parameters of the simulation model
Simulation parameters Numerical value Size of the model 95 m × 18 m × 5.5 m Relative permeability 80 Wall thickness 60 mm Table 4 Parameters of the optimized CNN
Parameters Numerical value Number of magnetic dipoles 15 Magnetic dipole spacing (m) 8.69 Size and quantity of convolution kernels 9648 Batch size 262 Learning rate 0.0175 L2 regularization coefficient 1.016 × 10−4 Table 5 Parameters of the simulation model
Magnetic field direction Numerical value (nT) X 34000 × cos(π/6) Y 34000 × sin(π/6) Z −35000 Table 6 Study range of single-factor analysis for each factor
Parameters Range Number of magnetic dipoles 10–20 Magnetic dipole spacing (m) 5.21–12.17 Size of convolution kernels 4–14 Quantity of convolution kernels 389–908 Batch size 157–367 Learning rate 0.0105–0.0245 L2 regularization coefficient 6.09 × 10−5–1.42 × 10−4 Table 7 Cross-testing results
Fold Training error (%) Validation error (%) 1 1.52 1.65 2 1.48 1.60 3 1.55 1.70 4 1.50 1.62 5 1.53 1.64 Mean + std 1.52 ± 0.03 1.64 ± 0.04 Table 8 Comparison of magnetic field fitting and extrapolation accuracy of different methods
Fit method Fitting error of the standard depth Extrapolation error at 1.125 times the standard depth Extrapolation error at 1.25 times the standard depth Traditional magnetic source method 17.02% 13.77% 12.81% Feedforward neural network 1.13% 14.32% 22.58% CNN 1.50% 1.63% 2.36% Table 9 Magnitude of the external magnetic field after changes
Magnetic field direction Parameter combination 1 (nT) Parameter combination 2 (nT) X 39000 × sin(π/3) 39000 × sin(π/6) Y 39000 × cos(π/3) 39000 × cos(π/6) Z −19500 −19500 Table 10 Comparison of magnetic field fitting and extrapolation accuracy of different methods with varying levels of errors introduced
Noise factor Fitting method Extrapolation error of the 1.125 times the standard depth Extrapolation error of the 1.25 times the standard depth 0%–5% Traditional magnetic source method 15.73% 12.93% Feedforward neural network 18.62% 25.34% CNN 2.20% 2.30% 0%–10% Traditional magnetic source method 16.12% 13.24% Feedforward neural network 20.25% 28.36% CNN 3.93% 4.95% Table 11 Magnitude of the external magnetic field after changes
Shrinkage factor Fitting error at the standard depth Extrapolation error at 1.125 times the standard depth 0.7 3.94% 4.19% 1.3 3.67% 4.01% Table 12 Magnitude of the external magnetic field after optimization
Shrinkage factor Fitting error at the standard depth Extrapolation error at 1.125 times the standard depth 0.7 2.12% 2.23% 1.3 1.96% 2.02% -
Birsan M (2021) Simulation of a ship’s deperming process using the Jiles-Atherton model. IEEE Transactions on Magnetics 57(6): 7300407. DOI: 10.1109/tmag.2021.3068555 Chen YF, Yang QX, Li YJ, Zhang H, Zhang CG (2024) Data-driven deep convolutional neural networks for electromagnetic field estimation of transformers. IEEE Transactions on Applied Superconductivity 34(8): 5500805. DOI: 10.1109/tasc.2024.3420184 Dai ZH, Zhou SH, Zhang XB (2021) Multi-objective optimization of ship magnetic field modeling method. Acta Physica Sinica 70(16): 164101. DOI: 10.7498/aps.70.20210334 Deng B, Wang J, Xu X, Yi G (2024) Individual prediction of electric field induced by deep-brain magnetic stimulation with CNN-Transformer. IEEE Transactions on Neural Systems and Rehabilitation Engineering 32: 2143–2152. DOI: 10.1109/TNSRE.2024.3408902 Gao JJ, Liu DM, Yao QH, Zhou GH, Yan HC (2006) Verifying the mathematics model of submarine magnetic field extrapolation with boundary element method through experiment. Acta Armamentarii 27(5): 869–872 Gao JJ, Wang PZ, Zhu XL (2021) Calculation and verification of ship magnetic field based on boundary integral-iterative method. 2021 International Conference on Electrical, Computer, Communications and Mechatronics Engineering (ICECCME), 1–5. DOI: 10.1109/ICECCME52200.2021.9590861 Han ZX, Hu JC, Li ZN, Ma PC, Peng QJ, Wang Q, Zheng ZZ, Zhu HW (2023) Magnetic field simulation of reactor based on deep neural networks. IEEE Transactions on Power Delivery 38(3): 2224–2227. DOI: 10.1109/tpwrd.2023.3256122 Hua C, Huang C, Zuo Y, Wang W, Yang J (2020) Research on low frequency magnetic field test and equivalent modeling method of ship equipment. 6th Global Electromagnetic Compatibility Conference (GEMCCON), 1–3. DOI: 10.1109/GEMCCON50979.2020.9456684 Hui Y, Xi C, Ye KQ (2010) The application of recursive algorithm on ship’s magnetic field extrapolation. Acta Armamentarii 31: 1200–1203 Jakubiuk K, Zimny P, Wolszyn M (2012) Multidipoles model of ship’s magnetic field. 15th International Symposium on Applied Eleetromagneties and Meehanies, 45 Jia W, Lin C (2018) Improved Euler method for preventing failure of positioning magnetic target magnetic Gradiometer. Journal of Navigation University of Engineering 30(3): 37–42 Jin HH, Wang H, Zhuang ZH (2022) A new simple method to design degaussing coils using magnetic dipoles. Journal of Marine Science and Engineering 10(10): 1495. DOI: 10.3390/jmse10101495 Khan A, Ghorbanian V, Lowther D (2019) Deep learning for magnetic field estimation. IEEE Transactions on Magnetics 55(6): 7202304. DOI: 10.1109/tmag.2019.2899304 Lin PF, Zhang N, Chang M, Xu L (2020) Research on the model and the location method of ship shaft-rate magnetic field based on rotating magnetic dipole. IEEE Access 8: 162999–163005. DOI: 10.1109/access.2020.3021206 Liu Q, Sun Z, Jiang R, Wu X, Lei Y (2022) A signal reconstruction and conversion method for magnetic field under a ship. Journal of Electrical Engineering 37(15): 3723–3732 Menana H (2021) 3D FEM-BEM coupling for the magnetic field computation in thin shells: Application to the evaluation of ship magnetic signature. IEEE Transactions on Magnetics 57(6): 7402206. DOI: 10.1109/TMAG.2021.3062563 Peng QJ, Sima WX, Sun JQ, Wang JS, Yang M, Zou DX (2025) Calculation method of transformer space dynamic magnetic field acceleration taking into account core nonlinearity. Journal of Electrotechnology 40(5): 1559–1574 Sasaki H, Iwata K, Sato T, Sato Y (2024) Prediction of motor characteristic maps via deep operator networks for topology optimization. IEEE Transactions on Magnetics 60(12): 8206205. DOI: 10.1109/tmag.2024.3477448 Sheinker A, Ginzburg B, Salomonski N, Yaniv A, Persky E (2021) Estimation of ship’s magnetic signature using multi-dipole modeling method. IEEE Transactions on Magnetics 57(5): 6500408. DOI: 10.1109/tmag.2021.3062998 Synnes SA (2008) Representing elongated magnetic sources by prolate spheroidal harmonics developed on an optimized coordinate system. IEEE Transactions on Magnetics 44(10): 2277–2282. DOI: 10.1109/tmag.2008.2001917 Tarnawski J, Cichocki A, Rutkowski TA, Buszman K, Woloszyn M (2020) Improving the quality of magnetic signature reproduction by increasing flexibility of multi-dipole model structure and enriching measurement information. IEEE Access 8: 190448–190462. DOI: 10.1109/access.2020.3031740 Tarnawski J, Rutkowski TA, Woloszyn M, Cichocki A, Buszman K (2022) Magnetic signature description of ellipsoid-shape vessel using 3D multi-dipole model fitted on cardinal directions. IEEE Access 10: 16906–16930. DOI: 10.1109/access.2022.3147138 Wang Y, Wang D, Chi C, Yu ZT, Li JW, Yu L (2024) Ship shaft-rate electric field signal denoising method based on VMD-MSS. Journal of Marine Science and Engineering 12(4): 544. DOI: 10.3390/jmse12040544 Woloszyn M, Jankowski P (2017) Simulation of ship’s deperming process using Opera 3D. 18th International Symposium on Electromagnetic Fields in Mechatronics, Electrical and Electronic Engineering (ISEF) Book of Abstracts, 1–2. DOI: 10.1109/ISEF.2017.8090680 Yan J (2020) Research on magnetic modeling simulation technology of marine target. Master thesis, Harbin Institute of Technology, Harbin, 41–46 Zateev AA, Ivanov YM, Semenov VG (2021) Enhancing the precision of measurements of a ship’s magnetic moment in the far field. Measurement Techniques 64(8): 681–688. DOI: 10.1007/s11018-021-01989-z Zhang Z, Yu W, Yi J (2018) Equivalent source forecast method for bad points’ field on ship’s magnetic field measuring. Journal of Huazhong University of Science and Technology (Natural Science Edition) 46(4): 63–67 Zhou G, Xiao C, Liu S, Gao J (2009) 3D Magnetostatic Field Computation With Hexahedral Surface Integral Equation Method. Diangong Jishu Xuebao 24(3): 1–7