Introduction

Nowadays, ships are most often built of steel, which is a ferromagnetic material. This causes the occurrence of magnetization, which can be described by two components: permanent and induced1. Permanent magnetization is largely due to the ship’s construction process, including welding. Compasses, sensors, motors, or electric generators are also sources of permanent magnetization. Over time, this component changes through exposure to magnetic fields or temperature change, but these changes occur at a very slow rate. Induced magnetization results from the effect of the Earth’s magnetic field on the vessel and varies depending on its position and orientation. Altogether, magnetization manifests itself by perturbing the Earth’s magnetic field, which can be described using a mathematical apparatus based on Maxwell’s equations, using magnetic fields characteristic to each ship, called magnetic signatures.

In the maritime industry, magnetic signatures of ships are used for tasks such as classification, tracking, or identification2. A ship’s magnetic signature can be used to determine its type or size3. They are also a very important part of the safety issue, since magnetic mines are activated precisely on their basis4, and for this reason a highly important issue from the point of view of ship design is their minimization. To address this, degaussing systems are employed to counteract the ship’s natural signature through the use of coils installed onboard the vessel, generating a magnetic field of opposite polarity5.

A highly effective approach to designing degaussing systems is to develop an appropriate model to study the effects of various factors on the magnetic fields generated by the vessel. Commonly used methods are numerical modeling methods such as the finite element method (FEM) and the boundary element method (BEM)6.

Equally important from the point of view of magnetic signatures is their prediction at the selected course and measurement depth. Using either measured or synthetic data obtained by the aforementioned methods, it is possible to develop a regression model, such as the multi-dipole model7. This model consists of a predetermined number of permanent and induced dipoles, describing the permanent and induced magnetization of the ship, respectively. Each dipole is described by six parameters: three coordinates in a three-dimensional Cartesian system and three components of the magnetic moment vector in each orthogonal direction. These parameters are obtained through an optimization process described in8, which fits the model to the data. The model developed in this way makes it possible to predict the magnetic signature in any other direction and at any depth, but greater than that at which it was fitted to the data9. However, as shown in10,11, the multi-dipole model’s accuracy is highly sensitive to ship positioning errors, with GPS inaccuracies causing shifts and distortions in magnetic flux density measurements. These errors particularly affect the \(B_x\) and \(B_y\) components, sometimes inverting the signature, while \(B_z\) remains more stable. Monte Carlo simulations revealed deviations exceeding 3000 nT, confirming that errors along the ship’s motion direction (N-S, E-W) had the greatest impact. This motivates the search for an alternative modeling technique.

In this article, the authors continue a previously started attempt to model the magnetic signature using a neural network presented in12, where the magnetic field generated by the ship was modeled only as a function of depth, on a northerly course and under its keel. Also, only \(B_x\) and \(B_z\) components were modeled. The goal is to generalize the model to predict all three magnetic field density components at any Cartesian coordinates and ship course, giving it functionality equivalent to a multi-dipole model in that regard (the multi-dipole model also allows to decompose the signature into a permanent and induced part9, but it’s beyond the scope of this study). An important factor in evaluating the model is determining how much training data is needed for accurate predictions, specifically how many directions and measurement depths they must come from. The process of selecting an appropriate network structure and optimizing hyperparameters will be presented. The motivation for addressing this topic lies in the high precision in data analysis and modeling offered by machine learning algorithms, with the goal of improving modeling precision. The use of ANNs improves the scalability of analyses and makes it possible to deal with complex patterns in the data.

The main contributions of this paper are:

  • Development and optimization of a neural network model capable of predicting a full distribution of a ship’s magnetic field at an arbitrary depth and course,

  • Extensive computer simulations determining the impact of the number of data samples on the prediction quality by determining six different quality indicators allowing for a comprehensive assessment,

  • Comparative analysis of the developed method with the multi-dipole model in terms of both the prediction quality using aforementioned indicators and robustness in terms of ability to refute noise in data and position-related errors.

Numerous simulations have been carried out during the writing of this article, all of which were carried out using the computers of Centre of Informatics Tricity Academic Supercomputer & Network.

Related works

Ferromagnetic signature modeling of ships has its origins in World War II and was aimed at determining their vulnerability to magnetically triggered mines. The same models were also used to evaluate and optimize the performance of signature reduction systems during their design phase, as well as in the development of both offensive and defensive military systems1. Due to the limited computational capabilities of the time, detailed physical-scale models were often used, with signatures measured in laboratories specially made for this purpose, and remained the main method for their prediction until the 1980s6. The development of computers and numerical modeling techniques allowed accurate simulations of magnetic fields using FEM and BEM, making it possible to determine the so-called forward model, a model arising from the structure of an object using analytical methods. Due to the small ratio of sheet thickness to vessel size, numerical modeling requires a dense mesh with a huge number of finite elements. In addition, the presence of permanent magnetization complicates the modeling process and significantly increases the computation time; moreover, when changing course, the model must be recalculated13. Hence, a common simplification of the model is the use of an ellipsoid, which is a widely accepted representation of the ship’s hull14.

Given the above-mentioned limitations, the inverse models, also called semi-empirical or equivalent-source models, are very popular. They are used to reconstruct input parameters based on observed output data either from measurements or from the numerical environment15. Several solutions to the inverse modeling problem can be found in the literature, the most widely used of which are two:

  • The multi-dipole model - approximates the magnetic field using a set of magnetic dipoles. By selecting the moments and positions of the dipoles, it is matched to the observed data16,

  • Prolate Spheroidal Harmonic (PSH) model—a method of representing a vessel’s magnetic field by means of expansion into a series of harmonic functions described by elliptical coordinates17.

These models, using appropriate regression techniques, are able to predict a vessel’s magnetic signature from observed data. In addition, recent analytical and semi-analytical methods have also been developed for magnetic signature modeling. Extended dipole formulations have been proposed in which the ship is represented as a hollow cylinder, allowing analytical determination of the induced magnetic field under local geomagnetic conditions18. Other works address decomposition of the magnetic signature into permanent and induced components using inverse problem regularization based on multiple passages over magnetic ranges19. Composite field models have also been proposed by combining ellipsoidal representations with magnetic dipole arrays, improving conditioning of the problem and computational efficiency without compromising modeling accuracy20. In parallel to these modeling developments, metamaterial structures have been investigated as a means of reducing magnetic signatures, exploring materials and geometries that inherently suppress magnetic response, potentially providing a complementary engineering pathway to signature reduction rather than predictive modeling21. These analytical and material-based approaches provide strong physical interpretability and can achieve high accuracy when well parameterized, but typically still require tailored modeling or experimental characterization for each vessel case.

An alternative modeling technique that has revolutionized the ability to map complex relationships over the past few decades is deep learning based on neural networks, which, thanks to their ability to learn high-abstraction data representations, enable accurate modeling and forecasting in various fields of science, technology, and data analysis.

With the development of artificial intelligence, its applications in the maritime industry are increasingly found in the literature. A comprehensive review of these was done in 202322, where 69 works done in this area in the last ten years were analyzed. It listed works on image-based ship classification using convolutional networks, such as AlexNet23, YOLOv424 and Grid CNN25. Convolutional networks were also used to classify ships based on images from Synthetic Aperture Radar (SAR)26,27 and infrared28. Applications in course optimization using unidirectional networks29,30 and recurrent networks31,32 were also presented. Other applications included issues of ship condition monitoring and maintenance33,34,35, ship autopilot implementation36,37,38, and safety improvement in navigation39,40,41.

In the case of ship magnetic signatures, an example of the use of neural networks is42, where the authors studied the accurate prediction of magnetic signatures in the context of active degaussing, looking at the effect of changes in hull thickness, relative permeability, and object radius. Their work proposed a machine learning method based on multiple linear regression as a more effective alternative to traditional methods. The accuracy, speed, and precision of this method were demonstrated. In43, the authors proposed a method for detecting magnetic anomalies using a multi-objective transfer learning algorithm that simultaneously removes noise and detects magnetic anomalies in data with a limited number of samples. The model simultaneously uses a convolutional autoencoder network and a unidirectional network for adaptive background noise modeling and pattern learning, as well as noise filtering and anomaly detection. The developed model achieved significantly better results compared to traditional methods and showed better performance. Ref.44 presents the use of a hybrid artificial neural network with a genetic algorithm to predict the induced magnetic signature with high efficiency. Magnetic signatures have also been used to classify ships using one-way networks45,46,47. Acoustic signals were also used for46 and47.

To the authors’ knowledge, it is a novelty to employ neural networks to model all three components of a ship’s magnetic signature directly at once for an arbitrary position relative to the hull and also for any course.

Synthetic FEM data

A numerical model of a corvette-type ship was developed in the Simulia Opera48 computational environment, as shown in Fig. 1. The model was created from plates modeling the ship’s hull and reflecting its geometry and structural properties. The boundary condition for the magnetic potential was taken to be \(H_{ext}=-\nabla \psi _m\), where \(H_{ext}\) is the intensity of the Earth’s magnetic field and \(\psi _m\) is the magnetic scalar potential.

A thin plate boundary condition method was used to introduce the thickness of the plates10,49, which allows the use of fewer nodes connecting the finite elements while maintaining the accuracy of the calculation by taking into account that one of the three dimensions of the plates is significantly smaller than the others. In the end, the model consists of 906,792 nodes and 4,319,341 linear elements. Selected parameters of the model are listed in table 1, where \(\mu _r\) is the relative magnetic permeability and d is the hull’s plates’ width.

Table 1 Ship model’s parameters.

In order to account for the vessel’s permanent magnetization, 13 coils with constant currents were added to the model, as shown in Fig. 2. The inserted set consists of three coils placed flat in the XY plane, three each placed on both sides of the hull in the XZ plane, and four placed flat in the YZ plane. The current flow in the coils generates a magnetic field that models the permanent magnetization in the ship’s structural elements. The current densities in the coils were chosen arbitrarily to noticeably increase the magnetic field generated by the ship.

Fig. 1
figure 1

FEM model of a corvette-type ship.

Fig. 2
figure 2

Coils inside the ship.

In order to simulate the magnetic field produced by the ship, it is necessary to determine its position on the Earth, since it is not uniform on its surface. This position was set as (55\(^{\circ }\)N, 2\(^{\circ }\)E), that is, in the North Sea, where the modulus of the Earth’s magnetic field density \(B_{ext}\) is approximately 50nT. The magnetic inclination \(\delta\) at this location is approximately 70\(^{\circ }\). From here, the magnetic field strength H necessary for the simulation can be determined, specifically its horizontal component \(H_{xy}\) and its vertical component \(H_z\), as described by the Eqs. (1) and (2).

$$\begin{aligned} H_{xy} = \frac{B_{ext}}{\mu _0}cos(\delta ) \end{aligned}$$
(1)
$$\begin{aligned} H_{z} = -\frac{B_{ext}}{\mu _0}sin(\delta ) \end{aligned}$$
(2)

For a complete representation of the spatial distribution of the magnetic field with respect to the movement of the ship, its course \(\phi\) should be taken into account, determined as 0\(^{\circ }\) for the north direction and calculated counterclockwise (Fig. 3).

Fig. 3
figure 3

Orientation of geographic directions in modeling.

In order to train the neural network, a large dataset is required, so magnetic fields were generated for courses 0, 30, 45, 60, 75, 90, 120, 135, 150, 165, 180, 210, 225, 240, 255, 270, 300, 315, 330, and 345 degrees. The generated \(B_x\), \(B_y\), and \(B_z\) components were evaluated on a grid ranging from -300 to 300 m in the X and Y directions and -50 to -10 m in the Z direction, all with 1 m steps.

Training data

The “cubes” of magnetic flux density values generated in Simulia Opera do not reflect the actual measurement of the ship’s magnetic signature, which is usually performed with a magnetometer array placed at some depth50,51. Given this fact, training data for the neural network was created based on three variables: step of the ship’s course (how many passages over the magnetometers were considered), number of sensors in the Y-axis, and number of sensors in the Z-axis. All the data in the X-axis from -300 to 300 m with 1 m steps were acquired, while the other axes were collected as shown in Fig. 4 (with 30 m steps for better visualization, actually 1 m steps were used), where example sensor arrays were depicted.

Fig. 4
figure 4

Visualization of example sensor arrays for training data extraction.

The spacing between the sensors in the Y coordinate is assumed to be 10 m, and in the Z coordinate to be 4 m. This allowed for a simulation of the ship passing over an array of magnetometers.

The calculated vectors of positions are then rotated according to the current ship’s course angle using a 2D rotation matrix, as described in Eq. (3).

$$\begin{aligned} \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} cos \ \phi & -sin \ \phi \\ sin \ \phi & \ cos \ \phi \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} \end{aligned}$$
(3)

This rotation accounts for changes in ship orientation during data collection. When considering the influence of the dataset size on the network’s performance, a term “course step” will be used, meaning the difference between subsequent paths in degrees for extracting training data, as visualized in Fig. 5. The lower the course step, the more data will be used.

Fig. 5
figure 5

Paths extracted from the data for different course steps.

When considering the total number of samples N in the training set based on the number of sensors in Y, the number of sensors in Z, and the course step marked as \(N_Y\), \(N_Z\), and \(\Delta \phi\) respectively, it can be calculated using the formula (4).

$$\begin{aligned} N = 601\cdot N_Y\cdot N_Z\cdot \frac{360^{\circ }}{\Delta \phi } \end{aligned}$$
(4)

Here, 601 refers to the number of samples in the range from \(-300\) to 300 m (single path), with 1 m step.

The dataset, which contains measurements of magnetic field components, is filtered to select data points that match the calculated sensor positions and orientations. For each valid data point, the coordinates (x, y, z) and the sine and cosine of the ship’s heading are paired with the corresponding magnetic field values. Using the sine and cosine here instead of a single 0-360\(^\circ\) or 0-2\(\pi\) angle as inputs to the neural network ensures a more effective representation of directional information. The multi-dipole model also uses this information. This approach addresses the circular nature of the course, where \(0^\circ\) and \(360^\circ\) are equivalent, by providing a continuous and unambiguous representation that avoids discontinuities. Sine and cosine also maintain the geometric relationships between headings, providing the network with more meaningful information about orientation. Additionally, these values are being normalized to the range [\(-1,1\)], which is typical for neural network input preprocessing. While adding an extra input dimension, the sine and cosine representation improves the network’s performance and enhances generalization, particularly for physical phenomena like magnetic fields that depend on orientation. This way, a labeled training dataset is produced where the input consists of measurement positions and orientation, and the output consists of the magnetic flux density values.

Discussion on the network’s type and optimization of the networks’its structure and hyperparameters

The model proposed in this paper consists of five inputs (three spatial coordinates relative to the ship and sine and cosine of its course) and three outputs corresponding to three components of the magnetic flux density. For accurate signature reproduction, the types of layers between inputs and outputs and the networks’ hyperparameters should be optimized. The selection of the appropriate type of neural network for modeling a ship’s magnetic signature is a difficult task, since there are so many to choose from. The choice depends on the problem’s nature, the data characteristics, and the specific goals of the model. In the case of this study, a strongly nonlinear relation between the Cartesian coordinates and the ship’s course and the magnetic flux density generated by that ship is attempted to be mapped. Three main candidates were considered for this task: a multilayer perceptron (MLP), a recurrent neural network (RNN), and a convolutional neural network (CNN). Since the data is magnetostatic and spatial data will not be considered, the MLP is the architecture that was chosen.

For the time of optimization of the network’s structure and hyperparameters, the training set was chosen to be for \(\Delta \phi = 60^\circ\), \(N_Y = 9\), \(N_Z = 5\). The validation data came from the 143.5\(^\circ\) course with \(N_Y = 9\) with 15 m spacing and \(N_Z = 4\) with 4 m spacing. The test data was a set of paths from the 320.5\(^\circ\) course with \(N_Y = 9\) with 12 m spacing and \(N_Z = 4\) sensors with 6 m spacing.

In previous works, the authors used grid search and random search for hyperparameter optimization. This time, it was decided to use the Bayesian optimization procedure, which is a probabilistic model-based approach for optimizing hyperparameters of machine learning models. The decision variables in this case were number of neurons, activation functions, learning rate, batch size, and maximum number of epochs. The number of neurons in each layer was limited to 10 times the number of the network’s outputs, 300. The activation function in each layer was selected from ReLU, Leaky ReLU, ELU, GELU, Swish, and Tanh. Lower boundaries for learning rate, batch size, and number of epochs were selected as \((10^{-5},10^{-1})\), (16, 512), and (10, 50), respectively. The Adam optimizer was chosen for the network training algorithm. The objective function was the network’s performance on the test set calculated via the root mean squared error (RMSE) given by (5) for N samples.

$$\begin{aligned} RMSE\left( {\bf y},\hat {\bf{y}}\right) = \sqrt{\frac{1}{N}\sum _{i=1}^{N}\left( y_i-\hat{y}_i\right) ^2} \end{aligned}$$
(5)

where \(y_i\) is the actual value of the ith sample and \(\hat{y}_i\) is the modeled value of the i-th sample. For each function evaluation, the network was trained on the training set, and the one achieving the best validation performance was selected. Since each network depth corresponds to a different number of decision variables, the optimization was conducted separately for each case from 1 to 12 layers, searching for the optimal number of neurons and activation function in each layer. Additionally, since the results are non-deterministic, the procedure was repeated ten times for each layer. Then, for every best-performing network from each optimization procedure, the training process was repeated once again ten times, and the results were averaged. In the end, the selected model was the one that, on average, performed the best on the test set. Figure 6 shows the distribution of RMSE values for neural networks with 1 to 12 layers. Each box represents 10 training runs for a given number of layers. The RMSE is measured in nT. The network with one hidden layer had big RMSE values, rendering the plot unreadable. Therefore, it was not depicted here.

Fig. 6
figure 6

Box plots of RMSE (nT) across 10 training runs for neural networks with varying depth (2–12 layers).

It can be seen that for 7, 8, and 12 layers, the mean RMSE values were the lowest, with the best-performing network being a 7-layered one, a diagram of which is shown in Fig. 7. Its hyperparameters are a learning rate of \(2.23 \times 10^{-4}\), a batch size of 403, and 30 maximum training epochs. This seven-layer neural network structure was used in all subsequent analyses to evaluate the influence of the training set size on the prediction accuracy of the ship’s magnetic signature.

Fig. 7
figure 7

Schematic of a neural network modeling a magnetic signature.

Figure 8 shows the network’s prediction of a magnetic signature for one of the paths in the test set (\(y = 12 \ m\), \(z = -32 \ m\), and \(\phi = 320.5^\circ\)). The training dataset in this case was the same as during the hyperparameters’ optimization. The model fits the data well, as shown by the close alignment between the predicted values and the observed data points on the graph. It took 190 seconds to complete the network’s training.

Fig. 8
figure 8

Prediction of the magnetic signature with the developed neural network model for \(y = 15 \ m\), \(z = -20 \ m\) and \(\phi = 165^\circ\).

Influence of the training dataset size on magnetic signature prediction

Determining the number of data samples necessary for the network’s satisfactory prediction of a ship’s magnetic signature requires assessing the fidelity of the model’s outputs via qualitative measures, such as previously used RMSE. It was decided to also include other indices in order to make the evaluation more comprehensive. These include Mean Absolute Error (MAE) given by (6), Median Absolute Error (MdAE) given by (7), Median Absolute Percentage Error (MdAPE) given by (8), R\(^2\), given by (9), and Inter-quartile Range in Levels (IQLev), given by (10).

$$\begin{aligned} MAE\left( {\bf y},\hat {\bf{y}}\right) = \frac{1}{N}\sum _{i=1}^{N}|y_i-\hat{y}_i| \end{aligned}$$
(6)
$$\begin{aligned} MdAE\left( {\bf y},\hat {\bf{y}}\right) = med\left( |{\bf y}-\hat {\bf{y}}|\right) \end{aligned}$$
(7)
$$\begin{aligned} MdAPE\left( {\bf y},\hat {\bf{y}}\right) = 100\%\cdot med \left( \frac{|{\bf y}-\hat {\bf{y}}|}{|{\bf y}|}\right) \end{aligned}$$
(8)
$$\begin{aligned} R^2\left( {\bf y},\hat {\bf{y}}\right) = 1-\frac{\sum _{i=1}^N\left( y_i-\hat{y}_i\right) ^2}{\sum _{i=1}^N\left( y_i-\bar{{\bf y}}\right) } \end{aligned}$$
(9)

where \(\bar{{\bf y}}\) denotes the average value of the vector \({\bf y}\).

$$\begin{aligned} IQLev\left( {\bf y},\hat {\bf{y}}\right) = \left| {\bf y}-\hat{{\bf y}} \right| _{75}-\left| {\bf y}-\hat{{\bf y}} \right| _{25} \end{aligned}$$
(10)

where \(\left| {\bf y}-\hat{{\bf y}} \right| _{75}\) and \(\left| {\bf y}-\hat{{\bf y}} \right| _{25}\) denote the 75th and 25th percentiles of absolute errors, respectively. The use of the aforementioned indicators allows for a comprehensive assessment of the quality of the model by providing information on every aspect of the error distribution, including central tendency (RMSE, MAE, MdAE), relative error (MdAPE), goodness of fit (\(R^{2}\)), and the variability of the prediction errors (IQLev).

The network developed in previous section was trained for different cases of \(\Delta \phi\) and the number of sensors in the Y and Z directions. Then, for each training, it was evaluated on a test set of data for courses 75, 165, 255, and 345 degrees, for \(N_Y = 10\) and \(N_Z = 4\), also with different spacing between the sensors, 12 m and 5 m for Y and Z, respectively. The results were visualized using heatmaps in Figs. 9 and 10 for the case of \(\Delta \phi = 30^\circ\).

Fig. 9
figure 9

Neural network’s RMSE, MAE and MdAE heatmaps for \(\Delta \phi = 30^\circ\), across different sensor configurations.

Fig. 10
figure 10

Neural network’s error MdAPE, R2 and IQLev heatmaps for \(\Delta \phi = 30^\circ\), across different sensor configurations.

Looking at the heatmaps, it can be determined that, unsurprisingly, more than one sensor in each direction is necessary for accurate signature prediction. Also, in every quality indicator, a poor performance can also be seen for two sensors in Y. Then the errors rapidly decrease with increasing the number of Y sensors from 3 to 7. A pattern starts to emerge where the lowest error values depending on the number of Z sensors, are between 3 and 8. After that, there is no significant improvement in any of the indices. An area of minimal errors can be identified for \(NY \ge 13 \wedge 4\le NZ \le 7\).

Presenting heatmaps for every \(\Delta \phi\) would be an exaggeration. Therefore, only RMSE is shown for the other course steps in Fig. 11. Deterioration can be seen in the values of the indices as \(\Delta \phi\) increases, while their distributions according to NY and NZ remain consistent. Other indices showed similar worsening.

Fig. 11
figure 11

Neural network’s error RMSE for \(\Delta \phi \in \{45^\circ , 60^\circ , 90^\circ \}\), across different sensor configurations.

It is clear that \(\Delta \phi\) has a significant influence on the prediction quality. This has been visualized in Figure 12, depicting the signatures predicted for \(y = 7 \ m\), \(z = -23 \ m\)and \(\phi = 255^\circ\) by models that were trained with \(N_Y=4\) and \(N_Z=6\), but with different \(\Delta \phi\).

Fig. 12
figure 12

Magnetic signatures predicted by neural networks trained with different angle step \(\Delta \phi\) for \(N_Y=4\) and \(N_Z=6\).

Comparison with the multi-dipole model

The multi-dipole model is an abstract structure consisting of m permanent and n induced dipoles, described by six parameters: the three components of the magnetic moment vector (mx, my, and mz) and three coordinates in a Cartesian coordinate system. It is created on the principle of inverse modeling, that is, on the basis of regression using data. The detailed description of the model can be found in8,9.

The vector of magnetic field induction B at position (x,y,z) produced by the i-th dipole at position (xi,yi,zi) is described by the relations (11)-(12)52. With the help of such a model, the signature can be reproduced at any depth (provided that it is lower than the one at which the model was trained9) and in any direction.

$$\begin{aligned} {{\bf B}_i}({{\bf M}_i}, {\bf{R}_i})=\frac{\mu _0}{4\pi }\cdot \left( {\bf R}_i^T{\bf M}_i{\bf R}_i\cdot \frac{3}{R_i^5}-\frac{{\bf M}_i}{R_i^2} \right) \end{aligned}$$
(11)

where:

$$\begin{aligned} {\bf B}_i =\begin{bmatrix} B_{x,i} \\ B_{y,i} \\ B_{z,i} \end{bmatrix}, {\bf M}_i =\begin{bmatrix} m_{x,i} \\ m_{y,i} \\ m_{z,i} \end{bmatrix}, {\bf R}_i =\begin{bmatrix} (x-x_i) \\ (y-y_i) \\ (z-z_i) \end{bmatrix}, R_i=|{\bf {R}}_i| \end{aligned}$$
(12)

The total magnetic field \({\bf B}_T\) produced by the model is described by the relation (13) for m permanent and n induced dipoles.

$$\begin{aligned} {\bf B}_T = \sum _{i=1}^{m+n} {\bf{B}_i}( {{\bf M}_i}, {{\bf R}_i}) \end{aligned}$$
(13)

The number of dipoles in the model for the current state of knowledge is chosen arbitrarily52 and is a compromise between accuracy and computational complexity. A multi-dipole model is a regression model determined by optimization through the use of the nonlinear least squares method. The goal is to minimize the squares of the difference between the source data \({\bf {B}}_{l,d}^{ref}(j,k)\) and the model-derived data \({\bf {B}}_{l,d,\Omega }^{model}(j,k)\), depending on the parameters \(\Omega\) (dipole positions and moments), as described by Eqs. (14) and (18).

$$\begin{aligned} \min _{\Omega \in \{\Omega _1, \dots , \Omega _{n+m}\}} J = \sum _l \sum _{n_y=1}^{N_Y} \sum _{n_z=1}^{N_Z} \sum _{\phi = 0^\circ }^{360^\circ - \Delta \phi } \sum _{j=-300}^{300} \left( {\bf {B}}_{l,\phi }^{ref}(j, n_y, n_z) - {\bf {B}}_{l,\phi }^{model}(j, n_y, n_z, \Omega ) \right) ^2 \end{aligned}$$
(14)

subject to

$$\begin{aligned} \underset{i\in (1,m+n)}{\forall }\ \ \Omega _i^{min}\le \Omega _i\le \Omega _i^{max} \end{aligned}$$
(15)

where

$$\begin{aligned} \underset{i\in (1,m+n)}{\forall }\ \ \Omega _i \in \{m_{x,i}, m_{y,i}, m_{z,i}, x_i, y_i,z_i\}, \end{aligned}$$
(16)
$$\begin{aligned} l \in \{x, y, z\}, \end{aligned}$$
(17)
$$\begin{aligned} \phi = 0^\circ , \Delta \phi , 2\Delta \phi , \dots , 360^\circ - \Delta \phi . \end{aligned}$$
(18)

The model is fit to data using the lsqnonlin function available in MATLAB for \(m = 25\) and \(n = 25\). The maximum number of iterations is set to 106. Also, a validation function was implemented which halted the optimization process if for 500 iterations no improvement was made.

Prediction accuracy and training time

To compare models directly, the same approach was used as previously, where the multi-dipole model was trained with different dataset sizes. The training time, however, is significantly longer than when it comes to training a neural network, therefore the tests were performed only for \(\Delta \phi = 90^\circ\). The RMSE heatmap for the model is shown in Fig. 13.

Fig. 13
figure 13

Multi-dipole model’s RMSE heatmap in nT for \(\Delta \phi = 90^{\circ }\).

It can be seen that while both models are able to achieve low error prediction values, the multi-dipole model needs significantly less training data. Above 5 sensors in the Y plane there was not much improvement gained from increasing the dataset size. The direct impact of dataset size on both models’ training efficiency has been visualized in Fig. 14, where all six considered quality indices are shown in relation to the number of training data samples for both models. While the black-box nature of artificial neural networks makes them require more data to train, it is clear that compared to the multi-dipole model they need less time for this training (by approximately an order of magnitude).

Fig. 14
figure 14

Relations between number of training data samples and prediction errors and computing time for both models.

Robustness

Another aspect of the model, known as robustness, was also tested to evaluate its usefulness in simulated real-world conditions. Three scenarios were assumed here. First scenario was a gaussian white noise of varying power \(P_N\) (0, 1, 2, 5 and 10 nT) added to the training outputs. Second scenario was the errors in positions implemented using a Monte Carlo Markov Chain (MCMC), namely the Metropolis-Hastings (MH) algorithm, where samples from \(\mathcal {N}(0,\delta )\) were drawn using a proposal distribution \(\mathcal {U}(-1,1)\), where \(\delta\) was varied (0, 1, 2, 5 and 10 m). The starting point of the sequence was also drawn from \(\mathcal {N}(0,\delta )\). This method allows to approximate any distribution using samples from a proposal one, as described in11 The influence of this method on the paths in the training inputs (x and y coordinates) was illustrated in Fig. 15 for \(\Delta \phi = 90^{\circ }\). The third method combined the previous two, adding errors to both outputs and positions.

Fig. 15
figure 15

Visualization of position perturbations using MH algorithm.

The reconstruction quality indices described earlier were evaluated for each disturbance case for the training data scenario \(N_Y = 6, N_Z = 4\), but \(\Delta \phi = 90^{\circ }\) for the multi-dipole model and \(\Delta \phi = 30^{\circ }\) to provide a more equal contest. This was repeated ten times for each disturbance case, and the results were averaged. Table 2 shows how all indices’ values were distributed across different disturbance cases for both models, while Tables 3 and 4 present the average (across all indices) percentage increase (or decrease in case of R2) of these indices due to perturbations, relative to the undisturbed prediction errors, for the neural network and multi-dipole model, respectively. This was calculated according to the formula (19).

$$\begin{aligned} D_{\delta ,P_N}= \frac{1}{6}\sum _{k=1}^6\frac{1}{|S|}\sum _{j\in S}\frac{Q_{j,k}-Q_{ref,k}}{Q_{ref,k}}\cdot 100 \% \end{aligned}$$
(19)

where \(D_{\delta ,P_N}\) is the average deterioration for a given \(\delta\) and noise power \(P_N\), S is the given disturbance case, |S| is the number of occurrences of the disturbance case, \(Q_{j,k}\) represents the k-th quality index for data point j, and \(Q_{ref,k}\) is the k-th quality index for the baseline case (\(\delta = 0\), \(P_N=0\)). Using these three tables, one can see both the absolute and relative impact of the disturbances on the models.

Table 2 Absolute quality indicators’ values for different disturbance cases (legend: light blue: NN RMSE (nT), dark blue: MD RMSE (nT), light orange: NN MAE (nT), dark orange: MD MAE (nT), light green: NN MdAE (nT), dark green: MD MdAE (nT), light yellow: NN MdAPE (%), dark yellow: MD MdAPE (%), light purple: NN R2, dark purple: MD R2, light brown: NN IQLev (nT), dark brown: MD IQLev (nT)).
Table 3 Mean relative disturbance influence on neural network training expressed as a percentage of deterioration of quality indicators.
Table 4 Mean relative disturbance influence on multi-dipole model training expressed as a percentage of deterioration of quality indicators.

It can be inferred from the tables that while both models experience some level of performance deterioration, the neural network generally demonstrates greater robustness, showing smaller average increases in error indices under perturbation. In contrast, the multi-dipole model exhibits higher sensitivity to disturbances, with larger relative error increases observed in most cases. This indicates that the neural network maintains more consistent performance and is less affected by external disturbances compared to the physics-based multi-dipole model.

Figure 16 shows a magnetic signature predicted by both models for \(y = -11 m, z = -37 m, \phi = 345^{\circ }, \delta = 0.5\) and \(P_N = 2\), while Fig. 17 shows the same signature predicted for \(\delta = 5\) and \(P_n = 5\), with RMSE values for each component in the title of the corresponding plot. It can be seen that while with lower values of disturbance the performance of the neural network keeps being poorer than that of the multi-dipole model, it exceeds the latter with higher noise and position error values. It needs to be noted, however, that the magnetic field can be decomposed into the permanent and induced part using the multi-dipole model9, the possibility which the neural network does not offer in this state, as it predicts the whole magnetic field density distribution, which is a superposition of the permanent and induced part.

Fig. 16
figure 16

Models’ prediction comparison for \(\delta = 1\) and \(P_N = 2\).

Fig. 17
figure 17

Models’ prediction comparison for \(\delta = 10\) and \(P_N = 10\).

Conclusions & future research

In this article, the case of using a neural network for modeling a ship’s magnetic signature was presented. By utilizing a FEM environment for the generation of synthetic data of a corvette-type ship’s magnetic field density distribution, a labeled training dataset was created, with position relative to the hull and the ship’s course as the inputs and with three components of the magnetic flux density vector as the outputs. The network’s hyperparameters and structure were optimized using Bayesian optimization and the number of necessary data samples for accurate signature prediction was determined using extensive computer simulations. The results show that the neural network should be trained with data coming from more than just the cardinal directions in order to obtain a good prediction quality. Using these findings, a compromise between the number of data samples and prediction accuracy can be found.

The neural network model presented in this study demonstrates strong potential for predicting a ship’s magnetic signature at arbitrary depths and courses. In comparison to the state-of-the-art multi-dipole model, proposed approach has greater robustness against position-related errors. The results showcased that by disturbing the input data related to the ship’s positioning, the relative deterioration of chosen quality indices was six to seven times lower than in the case of the multi-dipole model. Along with lower computational costs, the neural network’s prediction ability could make it well-suited for real-time signature estimation, that can be used for active degaussing and/or mine activation risk assessment.

When it comes to limitations of the model, one has to name the need for high amount of training data, much larger when compared to the multi-dipole model. Furthermore, the network in this state does not allow for separation of the permanent and induced magnetization, thus when the ambient background field changes significantly, the model needs to be retrained.

For future research, the use of Integral Equation–based solvers such as BEM or Method of Moments (MoM) may offer an efficient alternative to FEM for synthetic data generation. The authors also plan to incorporate real-world data, treating synthetic data as a starting point. Actual measurement data could introduce complexities that cannot be fully captured in simulations, and would be a great source of training data. While on-board measurements, which have been previously conducted with ship Zodiak, provided valuable data, a possibility of using a rotating platform with a scale ship model, which would be a source of what is really an unlimited amount of magnetic field distribution data. Aside from the uncertainty in the track of the vessel along the sensor, the sensor position uncertainty could also be addressed in future work. Additionally, a hybrid approach combining the multi-dipole model with the neural network model could be considered.