1 Introduction

Magnetic anomaly interpretation is significantly important in exploring regions with targets under the surface (Nabighian et al. 2005; Abdelrahman et al. 2009; Ekinci et al. 2014). In addition, it can be applied in hydrocarbon exploration (Abubakar et al. 2015; Ivakhnenkoa et al. 2015), in ores and mineral exploration (Farquharson and Craven 2009; Abedi et al. 2013; Abdelrahman et al. 2016), in engineering applications (Dong et al. 2007), in geothermal activity (Bektas et al. 2007; Nyabeze and Gwavava 2016), in archaeological site investigations (Gündoğdu et al. 2017), in weapon inspection (Davis et al. 2010; Yin et al. 2017), and in hydrological investigations (Al-Garni 2011; Araffa et al. 2015). In general, most of magnetic interpretation methods are carried out assuming the subsurface structures are simple geometrical shapes (for example spheres, horizontal cylinders, thin sheets, faults) buried at different depth generated by different minerals, ore bodies and oil deposit (Abo-Ezz and Essa 2016).

Generally, inversion of magnetic data includes estimating the model parameters (depth, amplitude coefficient and the dip angle) of buried geologic structures. Numerous methods have been used to interpret magnetic data such as Werner deconvolution (Ku and Sharp 1983), Euler deconvolution (Thompson 1982) and parametric curves approach (Abdelrahman et al. 2012). In addition, layered-model inversion (Pilkington 2006), gradient methods (Abdelrahman et al. 2003; Essa and Elhussein, 2017a), fair function minimization procedure (Tlas and Asfahani 2011), DEXP (Fedi 2007), linear least squares approach (Abdelrahman et al. 2007; Abo-Ezz and Essa 2016), and simplex algorithm (Tlas and Asfahani 2015) approaches. However, these conventional inversion approaches are that some of them generate large number of invalid solutions because of noise sensitivity, misconception between causative bodies and window sizes. In addition, some of them require initial model parameters that depending on geologic information, utilizing few data points on profile, claim understanding of shape factor and require more time.

These are the disadvantages of above-mentioned conventional inversion methods. For the past two decades, global optimization methods have been used in many areas as an alternative to these geophysical inversion methods such as genetic algorithm (Boschetti et al. 1997; Kaftan 2017), particle swarm optimization (van den Bergh and Engelbrecht 2004; Essa and Elhussein 2017b), differential evolution (Ekinci et al. 2016; Balkaya et al. 2017), simulated annealing (Biswas 2015), ant colony optimization (Colorni et al. 1991; Srivastava et al. 2014) and hybrid genetic-price algorithm (Bresco et al. 2005; Di Maio et al. 2016).

Particle swarm optimization algorithms (PSO) are effective optimization methods for solving difficult problems reliably and accurately. The PSO method is a stochastic developmental computation technique and was first produced by Kennedy and Eberhart (1995). It is primary on the simulation of the plain conduct of birds, fishes and insects in nourishment seeking. In this algorithm, the birds represent the particles or models. Each particle has a location vector which represent the parameters esteem and a speed vector. For example, for a five-dimensional optimization problem, each particle or individual will have a location in five-dimensional spaces which represent a solution (Eberhart and Shi, 2001). The implementations of the particle swarm optimization technique on geophysical data inversion and modeling were carried out (Toushmalani 2013; Peksen et al. 2014; Singh and Biswas 2016; Essa and Elhussein 2017b). Likewise, it is connected to many issues, like machine learning (Juang 2004), model construction (Cedeno and Agrafiotis 2003), biomedical images (Wachowiak et al. 2004), inverse scattering (Donelli et al. 2006), electromagnetic optimizations (Robinson and Rahamat-Samii 2004) and hydrological problems (Chau 2008).

In this study, we applied the PSO algorithm to the inversion of magnetic anomalies over simple causative sources. The model parameters estimated are the depth (z), the location of the origin (xo), shape factor (Sf), index angle (θ) and the amplitude coefficient (K). The use of this study was demonstrated by different synthetic models without and with different levels of random noise (5, 10, 15, and 20%), multi-models and two real examples. The model parameters estimated values compared with the results of the conventional inversion methods used in previous studies and drilling information. The results obtained from this comparison reveal that our algorithm is more stable and resolvable.

2 Methodology

2.1 Two-Dimensional Magnetic Forward Problem

The general new formula of two-dimensional magnetic anomaly (T) profile for simple-geometric bodies was summed up by Abdelrahman and Essa (2015) after careful investigation of magnetic anomaly expressions of the spheres (Rao et al. 1977; Rao and Subrahmanyam 1988), the horizontal cylinders (Rao et al. 1986) and the thin sheets (Gay 1963) which is described as follows:

$$T(x_{i} ,z) = K\frac{{Az^{2} \, + B\left( {x_{i} - x_{\text{o}} } \right)\, + C\left( {x_{i} - x_{\text{o}} } \right)^{2} }}{{\left[ {\left( {x_{i} - x_{\text{o}} } \right)^{2} + z^{2} } \right]^{{S_{\text{f}} }} }},\,\,\,\,\,\,i = 0,\,\,1,\,\,2,\,\,3, \ldots ,\,N$$
(1)

where K is the amplitude coefficient, z is the depth of the buried body, A, B, and C are defined as follows:

$$A = \left\{ \begin{aligned} 3\sin^{2} \theta \, - 1 \hfill \\ 2\sin \theta \hfill \\ - \cos \theta \hfill \\ \cos \theta \hfill \\ \hfill \\ \frac{\cos \theta }{z} \hfill \\ \end{aligned} \right.\,,\,\,B\, = \,\left\{ \begin{aligned} - 3z\sin \theta \hfill \\ - 3z\cos \theta \hfill \\ - 3z\sin \theta \hfill \\ 2z\sin \theta \hfill \\ \hfill \\ - \sin \theta \hfill \\ \end{aligned} \right.\,\,\,,\,\,C = \left\{ \begin{aligned} \,3\cos^{2} \theta \, - 1 \hfill \\ - \sin \theta \hfill \\ \,2\cos \theta \hfill \\ \, - \cos \theta \hfill \\ \hfill \\ 0 \hfill \\ \end{aligned} \right.\,\,,\,\,\,\begin{array}{*{20}c} {\text{for a sphere (total field)}} \\ {\text{for a sphere (vertical field)}} \\ {\text{for a sphere (horizontal field)}} \\ \begin{aligned} {\text{for a horizontal }}\,{\text{cylinder, FHD of thin sheet,}} \hfill \\ {\text{and SHD of geological contact }}\, ( {\text{all fields)}} \hfill \\ \end{aligned} \\ {{\text{for a thin sheet and FHD }}\,{\text{of geological contact (all fields)}} .} \\ \end{array}$$

θ is the angle of effective magnetization which is clearly demonstrated by Rao et al. (1973) and Rao and Subrahmanyam (1988) in case of spheres. In addition, for the case of thin sheets and horizontal cylinders is defined by Gay (1965), xo is the coordinate of the center of the source body, FHD is the first horizontal derivative, SHD is the second horizontal derivative of the magnetic anomaly, respectively, N is the number of data points, and Sf is the shape factor (for sphere Sf = 2.5, for horizontal cylinder Sf = 2, and for thin sheet Sf = 1 (Abdelrahman and Essa 2005).

2.2 Magnetic Inverse Problem

The inversion method in geophysics is an optimization process that finds the model parameters of the buried geologic structures which nicely explains the observed data. The inverse problem solution requires the supposition of an initial model (Lines and Treitel 1984; Zhdanov 2002; Tarantola 2005; Mehanee et al. 2011). A promising initial model could be made by introducing a priori information from geology, drilling or other geophysical techniques (Zhdanov 2002; Mehanee 2014; Mehanee and Essa 2015). The initial model is increasingly polished at every iteration step until a best fit is reached between the estimated and measured data. In every step, the model parameters are changed to get a better fitting between the measured and estimated data. The iteration process is continued until the best model parameters (better data misfit) are executed at the minimum value of the objective function (Eq. 2) ≈ zero.

According to the two-dimensional magnetic formula (Eq. 1), the unknown model parameters are the depth (z), the location of the origin (xo), shape factor (Sf), index angle (θ) and the amplitude coefficient (K).

The particle swarm optimization (PSO) algorithm has been used to solve the inverse problem because it is mathematically robust and numerically stable due to the rapidity of merging fewer operators, and easy to execute because of simplicity of its procedures (Pallero et al. 2018).

To find the best value of the model parameters in a manner that minimizes the differences between the observed field data and the estimated model, we use the following simple objective function:

$$Q = \frac{{2\sum\nolimits_{i = 1}^{N} {\left| {T_{i}^{m} - T_{i}^{c} } \right|} }}{{\sum\nolimits_{i = 1}^{N} {\left| {T_{i}^{m} - T_{i}^{c} } \right| + } \sum\nolimits_{i = 1}^{N} {\left| {T_{i}^{m} + T_{i}^{c} } \right|} }}\,\,,$$
(2)

where N is the number of data points, \(T_{i}^{m}\) is the measured magnetic anomaly at the point xi, \(T_{i}^{c}\) is the estimated magnetic anomaly at the point xi.

2.3 The Particle Swarm Optimization (PSO)

The particle swarm optimization (PSO) method is a global optimization algorithm proposed by Kennedy and Eberhart (1995). It is relied on the simulation of the apparent behavior individuals (called particles) in nature, for example, bird flocking and fish tutoring. In a PSO algorithm, every particle is a competitor solution identical to a point in M-dimensional space. The calculation is randomly introduced and the particles (initial solutions) are set randomly in the inquiry space of the objective function (He and Guo 2013). The PSO algorithm effectively prompts to a global optimum. The fundamental concept of the PSO algorithm is that the potential solutions are quickened towards the best solutions. The simplified flow diagram is shown in Fig. 1.

Fig. 1
figure 1

The work-flow of PSO algorithm applied to magnetic anomalies interpretation

The PSO algorithm starts with initializing each particle of the swarm by relegating an arbitrary speed and position in the issue seek space. The birds representing the particles or models, every particle has a location vector which represents the parameter value and a velocity vector. PSO characterizes a swarm of particles (models) in a M-dimensional space. Each particle keeps up memory of its past best position and velocity. At every iteration step, a velocity adjustment of the particle is resolved jointly by the previous best position which is called the Tbest model occupied by the particle and the best position of the swarm. The new velocity is then used to compute a new position of the particle which is called the Jbest model (Sen and Stoffa 2013). The update is described in the following equations (Sweilam et al. 2007):

$$V_{i}^{k + 1} = c_{3} V_{i}^{k} + c_{1} {\text{rand}}()\left( {T_{\text{best}} - P_{i}^{k + 1} } \right) + c_{2} {\text{rand}}()\left[ {\left( {J_{\text{best}} - P_{i}^{k + 1} } \right)P_{i}^{k + 1} } \right] = P_{i}^{k} + V_{i}^{k + 1} ,\,$$
(3)
$$x_{i}^{k + 1} = x_{i}^{k} + v_{i}^{k + 1} .$$
(4)

where \({\text{v}}_{\text{i}}^{\text{k}}\) is the velocity of the ith particle at the kth iteration, \(P_{i}^{k}\) is the current i model at the kth iteration, rand() is a uniform random number in the rang (0, 1). c1 and c2 are the positive consistent numbers which control the individual and the social behavior (Parsopoulos and Vrahatis 2002). c3 is the inertial coefficient that control the particle velocity. \(x_{i}^{k}\) is the position of the particle i at the kth iteration. Thus, PSO has the main advantage of being very fast in executing the results and shows good balance between exploration and convergence.

The magnetic anomaly from Eq. 1 is calculated every iterative step for each xi using the PSO algorithm. To estimate the quality of data fit at each iteration step of the inversion process, the RMS is defined as

$${\text{RMS}} = \sqrt {\frac{{\sum\nolimits_{i = 1}^{N} {\left[ {T_{i}^{m} \left( {x_{i} } \right) - T_{i}^{c} \left( {x_{i} } \right)} \right]^{2} } }}{N}} .$$
(5)

This is considered as the misfit between the observed and calculated anomalies.

2.4 Processing Time

In the present work, the real time for the entire computation process for a single model structure is almost 30 s for 100 models, while for 1000 model, the estimation process may reach from 8 to 12 min according to the number of iterations. However, for multiple structure models, the computation time increments to around 30%. The used code was developed using MS FORTRAN Developer studio in Window 7 on a simple desktop PC with Intel core i5 Processor.

3 Theoretical Examples

To illustrate the viability of the proposed inversion approach based on PSO algorithm, we have tested the PSO algorithm with three synthetic magnetic anomalies caused by simple geometrical shapes (a sphere, a horizontal cylinder, a thin sheet) without noise, tainted with different level of noise (5, 10, 15 and 20%) and multi-model example to investigate and evaluate whether the models obtained are close enough to the synthetic bodies.

3.1 Synthetic Noise-Free and Noisy Examples

The PSO technique was applied to noise-free synthetic magnetic anomalies due to a sphere model with K = 5000 nT, z = 7 m, θ = 50°, Sf = 2.5, xo = 0 m, and profile length = 80 m, a horizontal cylinder model with K = 3000 nT, z = 11 m, θ = 35°, Sf = 2, xo = 0 m, and profile length = 80 m and a thin sheet model with K = 1000 nT, z = 9 m, θ = − 30°, Sf = 1, xo = 0 m, and profile length = 80 m. The magnetic field anomaly due to these models is computed from Eq. (1).

We started to test our method using 100 particles or models. The best model parameters were reached after 700 iterations, and the ranges of the parameters for sphere model (K from 3000 to 6000 nT, z from 1 to 12 m, θ from 5° to 90°, Sf from 0.2 to 3 and xo from − 50 to 30 m), horizontal cylinder model (K from 1000 to 5000 nT, z from 1 to 16 m, θ from 5° to 90°, Sf from 0.2 to 3 and xo from −50 to 30 m) and thin sheet model (K from 0 to 3000 nT, z from 1 to 16 m, θ from −50° to 60°, Sf from 0.2 to 3 and xo from −50 to 30 m)models. The obtained results for each parameter (K, z, θ, Sf, xo) are in a good and close agreement between exactly known and estimated model parameters, where the error percentages are equal to zero.

In addition, the three forward model anomalies for different source are also contaminated with random error of 5, 10, 15 and 20% (Figs. 2, 3, 4) to get magnetic anomalies as much as possible closer to the real ones and perceive the robustness of the PSO algorithm. The PSO algorithm was then adopted to estimate the model parameters (K, z, θ, Sf, xo) of the simple geometrical shapes, utilizing Eq. (2) as the objective function. Initially, a suitable search range for each model parameters was selected as mentioned above and PSO was executed. Next, a PSO algorithm run was performed and the convergence of each model parameter and reduction of misfit (less RMS) were analyzed. PSO algorithm did not find the true depths, but it gave values close to the true depths.

Fig. 2
figure 2

Noisy and predicted magnetic anomalies of a buried sphere-like geologic structure with K = 5000 nT, z = 7 m, θ = 50°, Sf = 2.5, xo = 0 m, and profile length = 80 m, with a 5%, b 10%, c 15% and d 20% random noise. Error bars represents the standard deviations of the noise add to the noise-free datum

Fig. 3
figure 3

Noisy and predicted magnetic anomaly of a buried horizontal cylinder-like geologic structure with K = 3000 nT, z = 11 m, θ = 35°, Sf = 2, xo = 0 m, and profile length = 80 m, with a 5%, b 10%, c 15% and d 20% random noise

Fig. 4
figure 4

Noisy and predicted magnetic anomaly of a buried thin sheet-like geologic structure with K = 1000 nT, z = 9 m, θ = − 30°, Sf = 1, xo = 0 m, and profile length = 80 m, with a 5%, b 10%, c 15% and d 20% random noise

The results of the proposed technique for sphere, horizontal cylinder and thin sheet models are mentioned in Figs. 2, 3, 4, respectively. According to the parameter values in the figures, the error in the estimated parameters and the RMS increase with increasing the noise on the magnetic field anomaly. In addition, the estimated model parameters do not vary too much, and it is realized that the PSO algorithm solution is not affected by the noise level. It can be observed that the results of model parameter estimation (K, z, θ, Sf, xo) utilizing the PSO algorithm are attractive up to 20% of the random noise. Hence, this exhibits the stability of our newly presented method in light of the PSO algorithm.

3.2 Multi-Model Example

In this section, we produced and studied theoretically multi-model example generated and caused by multiple source bodies having different geometries and depths to test the effectiveness of the PSO algorithm on complicated anomalies.

We used the above-mentioned Eq. (1) to compute the magnetic anomaly (ΔT) for multi-synthetic model consisting of a sphere model with K = 11,000 nT, z = 4 m, θ = 30°, Sf = 2.5, xo = 0 m, and profile length = 120 m and a horizontal cylinder model with K = 5000 nT, z = 6 m, θ = 40°, Sf = 2, xo = 30 m, and profile length = 120 m and the magnetic anomaly is shown in Fig. 5.

Fig. 5
figure 5

Synthetic and predicted magnetic anomalies of multi-model structure which consist of a sphere model with K = 11,000 nT, z = 4 m, θ = 30°, Sf = 2.5, xo = 0 m, and profile length = 120 m and a horizontal cylinder model with K = 5000 nT, z = 6 m, θ = 40°, Sf = 2, xo = 30 m, and profile length = 120 m

The PSO algorithm was applied to the multi-model magnetic profile to appraise the distinctive model parameters in a way similar to the above-mentioned example.

However, in this case, all the structures were modeled altogether. The parameter ranges used as a part of the inversion process of the magnetic anomalies are presented in Table 1 together with the outcomes obtained for the model parameters. The inversion response (RMS of 7.4 nT) is contrasted with the data in Fig. 5. In addition, Fig. 5 shows the modeled magnetic anomaly and the subsurface structures considered for this model. It can be noticed that the parameters are quite well recuperated from the PSO algorithm.

Table 1 Numerical results for a multi-model theoretical example: spherical shape (K = 11,000 nT, z = 4 m, θ = 30°, Sf = 2.5, xo = 0 m, and profile length = 120 m) and a horizontal cylinder (K = 5000 nT, z = 6 m, θ = 40°, Sf = 2, xo = 30 m, and profile length = 120 m)

4 Field Example

To test the validity of developed method on real cases, the PSO algorithm is connected to two field examples taken from the literatures. The results obtained by the proposed technique are compared with the results obtained from other inversion techniques. The two field examples that are utilized for testing the legitimacy of this technique are magnetic anomalies for Pima copper mine, USA and Hamrawein area, Egypt.

4.1 Pima Copper Mine Field Example, USA

The district of Pima mining is considered as one of the biggest porphyry copper in the nineteenth century. The mining area has delivered 4.36 billion pound of copper and other minerals like molybdenum, lead, silver and gold. Mineralization related with Laramide igneous activity was happened in Paleozoic sedimentary rocks, Mesozoic sedimentary and volcanic sequences, and in Paleocene igneous rocks. Post-mineralization, coarse-grained alluvial-clastic deposits accumulated in the fault contact with Precambrian to Paleocene rocks (Shafiqullah and Langlois 1978).

Figure 6 demonstrates the vertical component of magnetic anomaly profile over a thin sheet-like structure in Pima copper mine, Arizona, USA (Gay 1963). The profile length of 696 m was digitized at interim of 8.7 m. The ranges of the parameters utilized as a part of the method are presented in Table 2 which was picked regarding the accessible geologic information. Table 2 demonstrates the assessed result of the model parameters (K = 600 nT, z = 71.08 m, θ = − 47.83°, Sf = 0.92, xo = − 0.49). The comparison between the measured and the predicted anomalies (Fig. 6) indicates the good agreement between them. The inverted parameters (K, z, θ, Sf) are found with a good correspondence with the drilling information and other information from published literatures (Gay 1963; Abdelrahman and Sharafeldin 1996) (Table 3). In addition, we compared our PSO approach results with very fast simulated annealing (VFSA) (Biswas et al. 2017) results (Table 3). This demonstrates that PSO approach has an execution time shorter (30 s) than VFSA approach.

Fig. 6
figure 6

A vertical magnetic anomaly in Pima copper mine, USA (open circle) and the estimated magnetic anomaly (black circle) using PSO algorithm

Table 2 Numerical results for the vertical magnetic anomaly of the Pima copper mine field example, USA
Table 3 Comparison between numerical results of different methods for the vertical magnetic anomaly of the Pima copper mine field example, USA

4.2 Hamrawein Area Field Example, Egypt

The contextual investigation over the Hamrawein area, Egypt, is used for another magnetic data interpretation using the proposed PSO algorithm. The Hamrawein area is situated in the western edge of the Red Sea and spreads metavolcanic and sedimentary rocks (Salem 2005; Salem et al. 2005) (Fig. 7). The magnetic anomaly profile of 15,253.64 m has been taken from magnetic survey data which was led by Salem et al. (1999) (Fig. 8) and it was digitized at 214.844 m testing interval (Fig. 9). Table 4 shows the results of the inverted model parameters (depth, location of the origin, shape factor, index angle and the amplitude coefficient) over the Hamrawein area magnetic anomaly from the present method. It is seen from Fig. 9 that both predicted magnetic anomaly and observed magnetic anomaly curves are well correlated with the optimal RMS of 15.97 nT. The optimum results of the model parameters (K, z, θ, Sf, xo) are K = 507.64 nT, z = 601.56 m, θ = 57.04°, Sf = 0.89, xo = 4255.98 m for the first anomaly, while the parameters of the second anomaly are K = 427.38 nT, z = 515.62 m, θ = 37.27°, Sf = 0.93, xo = 14,823.69 m, respectively. From the above results (Sf = 0.89 and 0.93) we can reason that the two magnetic anomalies are caused by thin sheets. The correlation between the results obtained from our method and that published in the literature is shown in Table 5.

Fig. 7
figure 7

Geological map of the Hamrawein field example, Quseir area, northern Red Sea, Egypt (Salem et al. 2005)

Fig. 8
figure 8

Total magnetic intensity map of the Hamrawein field example, Quseir area, northern Red Sea, Egypt (Salem et al. 2005)

Fig. 9
figure 9

Total magnetic anomaly profile (A–Á) over the Hamrawein area, on the western margin of the Red Sea, Egypt (open circle) and the estimated magnetic anomaly (black circle) using PSO algorithm

Table 4 Numerical results for magnetic anomaly over the Hamrawein area, on the western margin of the Red Sea, Egypt
Table 5 Comparison between the numerical results of different methods for magnetic anomaly over the Hamrawein area, on the western margin of the Red Sea, Egypt

5 Conclusions

In this investigation, we have represented the applicability and the stability of the PSO algorithm (particle swarm optimization) in estimating the distinctive body parameters (K, z, θ, xo, Sf) for various synthetic and real examples. The PSO algorithm has been applied for magnetic anomalies of assuming models, for example, simple bodies (spheres, horizontal cylinders and thin sheets). This technique has been verified and demonstrated on synthetic magnetic anomalies with and without random noise, multi-models and lastly connected to two field examples from USA and Egypt. The evaluated results revealed that this approach is steady, powerful and proficient in tackling such a magnetic problem and solving the quantitative interpretation of magnetic data when comparing it with the results published in the state-of-arts. This technique is not independent on promising initial models. Furthermore, the convergence to the best estimation of the inverted model parameters of the buried structure is quickly reached. This new methodology to invert 2D magnetic data is recommended for quick analysis of magnetic anomaly profiles in an attempt to estimate the best inverted model parameter values related to different bodies such as sphere, horizontal cylinder, and thin sheet-like geologic structures. In addition, the PSO outcomes could be of importance for a gradient-descent method as an initial model.