1 Introduction

Magnesium and its alloy materials are extensively utilized in automobile parts, aerospace industries, and biomedical implants due to their lightweight [1,2,3,4]. As their density is ~ 1.74 to 2 g/cm3, magnesium alloys are also a promising degradable biomaterial (the human cortical bone is 1.8 to 2.1 g/cm3). Researchers have developed anodization [5, 6], nickel plating [6], and micro-arc oxidation as surface treatment methods [7, 8] that have been developed to mitigate the corrosion of magnesium alloys in the past few decades [9]. Even though there has been a plethora of corrosion inhibitors in practice to protect magnesium alloys from corrosion, none of them are free from limitations. The limitations associated with the inhibitors that are in practice are non-environmental friendliness, difficulties involved in processing, etc. Therefore, there is a need to bring a simple, easily processable, eco-friendly material to control the corrosion of Mg alloys with the previously mentioned methods. An effective idea is to use a surfactant as an inhibitor due to its exceptional inhibition character, one-step synthesis, and inexpensive raw materials. Usually, electronegative atoms like nitrogen, oxygen, sulphur, and phosporous along with large alkyl chains, conjugated double bonds, and polar functional groups act as an effective inhibitors [10,11,12,13]. These molecules adsorb and form a film-like precipitate by physical or chemical adsorption on the magnesium alloy surface.

Considering EDTA as a superior inhibitor for many other alloys, a novel inhibitor namely 2,2’-(5,14-dibutyl-6,13-dioxo-5,8,11,14-tetraazoctadecane-8,11-diyl)diacetate (DB) is synthesized and studied, herein. In this research work, an attempt to synthesize the novel anionic dimeric surfactant DB as an efficient corrosion mitigant for AZ31 magnesium alloy in NaCl and Na2SO4 media is made. The study of the corrosion behaviour in active media, particularly NaCl and Na2SO4 containing aggressive ions, is important to understand the corrosion mechanism to improve corrosion resistance under various service conditions. Song et al., found that the presence of Cl ions increases the film-free area (film = Mg(OH)2), and increases the electrochemical reaction from Mg to Mg+. Hara et al. [14] worked on the surface film formed in neutral media and studied their influence on the electrochemical behaviour of Mg and Mg alloys. Though many researchers have studied corrosion products and mechanisms in different media, the comparison of both the media and its studies with the inhibitors has not yet been explored and so is this study.

Dimeric surfactants / Gemini surfactants consist of hydrophilic tails and hydrophobic head parts connected through a spacer [15, 16]. Presently, most of the studies are aiming at making such surfactants as inhibitors due to their less toxicity, environmental friendliness, and favorable surface tension properties [17]. Compared to inhibition efficiency (IE(%)) values of other green inhibitors, such as Avacado seeds (85%) [18], Phoenix dactylifera L. (63%) [19, 20], plant-derived cationic dye (78%) [21], and Berberine (80%) [22], the synthesized DB has better IE(%) values.

Herein, the design of simple one-step reaction procedure for synthesizing EDTA-based gemini surfactant (DB) and its corrosion inhibition are reported. The DB is considered to be a potential inhibitor because of the following reasons: a) inexpensive and easy to synthesize; b) contains multiple hetero atoms that act as active centers with different functional groups; c) possesses a good affinity to bind with metal surfaces; d) possesses bulky alkyl chain groups that possess steric hindrance. The corrosion rate of AZ31 Mg alloy was determined by performing potentiodynamic polarization (PDP) and electrochemical impedance spectroscopy (EIS) techniques. The existence of adsorbed inhibitor DB and its morphology on the AZ31 Mg surface was confirmed by surface morphology such as SEM–EDX and XPS. In addition, the quantitive analysis of the inhibitors were also conducted from the results of the same. The theoretical studies were calculated using Turbomole software [23]. The DFT calculations were used to connect the inhibitory strength and molecular structures of the investigated surfactant.

2 Materials and methods

2.1 Materials

The chemicals were purchased and were used without any further purification. The chemicals used are 1,4-dibutyl amine (98% SigmaAldrich) and EDTA anhydride (SigmaAldrich), and Methanol (98%—Alfa aesar).

2.2 Preparation of the substrate

Commercial AZ31 Mg alloy of area 0.69 cm2 with the elemental composition of 3 wt% Al, 1 wt% Zn, 0.1 wt% Mn, and Mg balance was utilized as the specimen of study. 0.69 cm2 is the actual sample size exposed to the corrosion media. Also, the composition of the AZ31 alloy is actual. The polishing of the substrate was done using sandpaper sheets of grit size ranging from 400 to 2000 and then further polished using alumina in a polishing machine until the mirror finishing is achieved. The samples were first cleaned using distilled water, with acetone, and then dried. The inhibitor was tested at five different temperatures ( 30 °C, 35 °C, 40 °C, 45 °C, and 50 °C) and two different corrosion media, which are 0.1 M NaCl and 0.1 M Na2SO4.

2.3 Synthesis of anionic surfactants

The synthesis of anionic surfactant has been discussed in detail in the supplementary information along with its structural characterization. Briefly, a reaction mixture containing dibutylamine (10 mmol) and EDTA anhydride (5 mmol) dissolved in methanol (15 ml), is made to proceed for 24 h at 40–45 °C. As the reaction progressed, the EDTA anhydride was consumed. The unconsumed EDTA anhydride was removed by filtration at room temperature. Evaporation of the reaction mixture yielded a yellowish oily liquid, which upon addition of acetone, formed a white solid precipitate. The precipitate was isolated by filtration and further purified using CHCl3 and acetone precipitation to obtain the intermediate product. Neutralization of the intermediate product with 1 M aqueous sodium hydroxide (2 equivalents) followed by lyophilization resulted in the formation of sodium 2,2’-(5,14-dibutyl-6,13-dioxo-5,8,11,14-tetraazoctadecane-8,11-diyl)diacetate (DB) as a hygroscopic powder.

The results of characterizations using techniques like FT-IR, NMR, and LC–MS are discussed in supplementary information (Figures S1, S2, and S3, respectively).

2.4 Electrolytes

The electrolytes of 0.1 M NaCl and 0.1 M Na2SO4 were prepared by dissolving NaCl and Na2SO4 (Merck) appropriately in distilled water. The stock solutions of NaCl and Na2SO4 prepared were utilized to prepare inhibitor solutions at different inhibitor concentrations.

2.5 Electrochemical measurements

A Gill AC potentiostat which is with ACM instrument software was utilized to analyze EIS (Electrochemical Impedance Spectroscopy). The open circuit potential (OCP) of the alloy sample is attained by dipping the substrate in the corrosive medium for 700 s prior to EIS measurement. An alternate current signal with a frequency variation of 100 kHz to 10 mHz, with an excitation signal of 10 mV sine wave, was applied. The attained spectrums were fittted to an equivalent circuit using Zsimpwin 3.2 version software to attain the magnitudes of corrosion parameters.

Potentiodynamic polarization (PDP) analysis was carried out after the EIS measurement by scanning the working electrode, between -2.5 V (cathodic) to + 2.5 V (anodic) from the equilibrium potential. The linear cathodic slope was utilized to obtain the corrosion kinetic parameters by the tafel extrapolation method.

2.6 Surface morphology investigation: SEM and XPS

The SEM images of the AZ31 Mg alloy were captured using the instrument ZEISS (PREVAC 360° spectrometer attached with magnesium KαX-ray handled with 300W). The EDAX spectra were obtained to evaluate the surface composition and were noted using ZEISS digital program.

2.7 Quantum chemical calculations

The DB inhibitor structure was initially verified using DFT calculations to predict the ability of molecule to act as corrosion inhibitor efficiently. This was done by optimization of DB structure and its frontier molecular energy relation with the software TURBOMOLE 7.2 version at B3LYP/basic set def-TVPP level. The experimental results were compared to the theoretical calculations by quantum parameters of the surfactant, DB. For the considered DB molecules, EHOMO, ELUMO, ΔE, η, χ and ΔN were calculated.

3 Results and discussion

3.1 Potentiodynamic polarization (PDP) study

Figure 1, displays the PDP test results of AZ31 alloy in 0.1 M NaCl (Fig. 1a) and 0.1 M Na2SO4 (Fig. 1b) media in the absence and presence of DB inhibitor at 30 °C, respectively. There is a rise in the icorr (corrosion current) for AZ31 Mg alloy, when the temperature media is raised in the presence of DB inhibitor; however, the change in icorr was maximum when the inhibitor concentration was 2.5 mM. The Tafel slopes, both cathodic and anodic regions decreased at 2.5 mM of DB inhibitor with respect to the blank concentration in each test. Thus, it could be inferred that DB achieves high efficiency by reducing the corrosion rate at lower temperatures as there is a formation of a passive film on the matrix, which provides a better barrier effect that limits oxygen reduction on the intermetallic particles [24]. It is observed in previous studies that temperature-dependent adsorption is seen in the reaction of anionic Gemini surfactant molecules on the substrate. It is seen that there is a change in the adsorption equilibrium towards desorption when there is a rise in temperature, which lowers the coverage and uneven surface assimilation of the molecules on the AZ31 Mg alloy. This shows a temperature rise that leads to the desorption of a layer of the used DB molecule on the surface of the alloy. The efficiency of the DB molecule is observed to be dependent and shows the corrosion rate with a non-linear style on both temperature and concentration.

Fig. 1
figure 1

Potentiodynamic polarization curves in the presence and absence of DB in a) 0.1 M NaCl solution and b) 0.1 M Na2SO4 solution

The performances of different concentrations of novel inhibitor DB in NaCl and Na2SO4 media with its electrochemical behaviour on AZ31 Mg alloy were examined at 30 °C by plotting Tafel plots as shown in Fig. 1. Various parameters that are useful to analyze the rate of corrosion were examined from the obtained plots and are presented in Tables 1 and 2. These parameters include cathodic Tafel slopes (βc), corrosion potential (Ecorr), corrosion current density (icorr), and inhibition efficiency (%).

Table 1 Investigation of electrochemical polarization parameters of AZ31 alloy in 0.10 M NaCl solution, under varying concentrations of DB at different temperatures
Table 2 Investigation of electrochemical polarization parameters of AZ31 alloy in 0.10 M Na2SO4 solution, under varying concentrations of DB at different temperatures

As shown in Tables 1 and 2, the values of icorr for AZ31 Mg alloy in NaCl and Na2SO4 solution decreased when the concentration of the DB is increased in the solution system. The value of θ was between 48 to 86% by changing the concentration of DB inhibitor from 0.8 mM to 0.25 mM in NaCl and 64% to 81% in Na2SO4, respectively at 30 °C.

3.2 Electrochemical Impedance Spectroscopy (EIS)

The Nyquist diagrams of AZ31 Mg alloy in NaCl and Na2SO4 with and without the inhibitor DB are shown in Fig. 2. The semi-circle appearance of the Nyquist plots corresponds to a two-capacitive loop, which is comparable to the charge transfer, and corrosion product resistances at high frequency, diffusion of ions surpassing corrosion products at middle-frequency range, followed by an inductive loop at low frequency [25]. The corrosion mechanism remains unaffected because of the similar shape of Nyquist plots with and without different concentrations of inhibitor DB.

Fig. 2
figure 2

Nyquist plots for the corrosion of AZ31 alloy in the presence of different concentrations of DB in a) 0.1 M NaCl and b) 0.1 M Na2SO4

The capacitor was substituted by CPE (constant phase element), which presents a different frequency response due to the unevenness of the surface. CPE impedance is represented by the following equation (Eq. 1):

$${Z}_{CPE}\left(\omega \right)={Q}^{-1}{(j\omega )}^{-n}$$
(1)

where Q is a constant phase element in Ω−1cm−2S−n, \(\omega\) is the angular frequency in rad/s−1 and n is CPE exponent (-1 < n < 1). ZCPE can represent either an inductance, or a resistance (n = -1, 0, and 0.5, respectively) [17].

Figure 3 presents the equivalent circuit used for fitting the nyquist plots. The electrical circuit contains electrical elements such as the CPE (constant phase element), the Rhf (high-frequency resistance), Rdif (diffusion resistance), Rf, and Rs (solution resistance). The shown equivalent circuit is the same for both with and without DB inhibitor. Due to the presence of the inhibitor DB, the diffusion of corrosive ions to the surface of the Mg alloy is minimized [26]. The values for all the mentioned elements are given in Tables 3 and 4 for the media of NaCl and Na2SO4, respectively. The presence of DB inhibitor increases Rhf and Rf values of the systems. The inhibitor's adsorption over the Mg alloy reduces Cf by exchanging the pre-adsorbed H2O and other ions. The double-layer thickness is maximum as the CPE is decreased. This act is because of the exchange of H2O with the DB inhibitor molecule. It is observed that the surface coverage value (θ) was calculated based on the values of Rhf. Thus, as the concentration of DB inhibitor increases, the inhibition efficiency increases. Similarly, the rise in adsorption of DB increases the coarseness and heterogeneity in the surface of AZ31 Mg alloy.

Fig. 3
figure 3

Equivalent electrical circuit used in the studies of DB inhibitor

Table 3 Electrochemical impedance parameters for AZ31 alloy in 0.10 M NaCl solution in the absence and presence of different concentrations of DB at different temperatures
Table 4 Electrochemical impedance parameters of AZ31 alloy in 0.10 M Na2SO4 solution in the absence and presence of DB at different temperatures

3.3 Evaluation of thermodynamic and activation parameters

The types of inhibitors and corrosion kinetics in a corrosion reaction are highly influenced by temperature as it is an essential factor. The change in the temperature causes the decomposition of the inhibitor and deoxygenation on the surface of the Mg alloy [27]. In addition, looking at the previous tables, it is observed that there is a continuous decrease in η (%) values, with increase in the temperature, confirming that there is physical adsorption of DB molecule on the Mg alloy’s surface. However, another possibility is that more solubility of the formed Mg-DB precipitate film occurs when there is an increase in the temperature, which leads to the desorption of the DB molecule from the specimen [28].

The activation energy (Ea) is the kinetics of chemical reactions, and the temperature effect on corrosion rates is calculated utilizing the Arrhenius equation (Eq. (2)) [29].

$$\text{ln}\left({\upsilon }_{corr}\right)=B-\frac{{E}_{a}}{RT}$$
(2)

where B corresponds to a constant depending on the used material, T resembles temperature and R is gas constant. The slope = (-Ea/R) of the plot \(\text{ln}\left({\upupsilon }_{corr}\right)\) versus (1/T) gives the value Ea. Arrhenius plots in 0.1 M concentration of NaCl and Na2SO4 media with varying DB concentrations are presented in Fig. 4.

Fig. 4
figure 4

Arrhenius plot for the corrosion of AZ31 magnesium alloy in a) 0.1 M NaCl and b) 0.1 M Na2SO4 media in the presence of different concentrations of DB

By utilizing the ln(\(\upsilon\)corr/T) vs. (1/T) relationship (Eq. (3)), various thermodynamic parameters of AZ31 Mg alloy were computed under both the presence and absence of inhibitor conditions [30].

$${\upsilon }_{corr}=\frac{RT}{Nh}\text{exp}\left(\frac{{\Delta S}^{\#}}{R}\right)\text{exp}\left(\frac{{-\Delta H}^{\#}}{RT}\right)$$
(3)

The values for Planck’s constant h and Avogadro’s number N were obtained by analyzing the plot for the enthalpy of activation (ΔH#) and change in entropy of activation (ΔS#), which was generated from the ln (υcorr/T) versus (1/T) graph (Fig. 5) of the AZ31 Mg alloy in 0.1 M concentration of NaCl and Na2SO4 media. The obtained parameters are compiled in Tables 5 and 6.

Fig. 5
figure 5

The plots of ln(ʋcorr/T) vs (1/T) for the corrosion of AZ31 magnesium alloy in a) 0.1 M NaCl and b) 0.1 M Na2SO4 media in the presence of different concentrations of DB

Table 5 Activation parameters for the corrosion of AZ31 alloy in NaCl solutions with and without DB inhibitor
Table 6 Activation parameters for the corrosion of AZ31 alloy in Na2SO4 solutions with and without DB inhibitor

From the data of Tables 5 and 6, there is an increased surface area coverage of inhibitor molecule DB because of the rise in its concentration which directly shows the enhancement of the energy barrier for the corrosion process [31]. When the value of ΔS# is significantly negative in the DB systems, it suggests that the rate-determining step corresponds to an association process instead of a dissociation process. Thus, the transition shows the activated complex formation leading to the reduction in the randomness at the formation [32, 33].

3.4 Adsorption isotherm

In Eq. (4), the process is a substitution reaction, where there is surface assimilation of the surfactant molecule on the alloy by substituting H2O molecules already adsorbed.

$${Inh}_{(sol)}+\chi {H}_{2}{O}_{(ads)}\leftrightarrow In{h}_{(ads)}+ \chi {H}_{2}{O}_{(sol)}$$
(4)

The parameter χ represents the ratio of water molecules exchanged by a single inhibitor molecule on adsorption.

The surface coverage (θ) of DB on the surface decides the inhibition efficiency. The surface coverage (θ) was calculated using PDP results at different concentrations (Cinh) of the inhibitor. After verifying many different adsorption isotherms, the best fit for the linear relationship of θ and Cinh is found to be Langmuir adsorption isotherm. The following equation (Eq. 5) presents the mathematical representation of Langmuir adsorption isotherm:

$$\frac{{C}_{inh}}{\theta }= {C}_{inh}+ \frac{1}{K}$$
(5)

The Langmuir adsorption isotherms of DB on the surface of AZ31 Mg alloy at different temperatures are depicted in Fig. 6, with K corresponding to the equilibrium constant. The slope is not linear and the R2 is 0.95 for the obtained plots. This deviation is caused because of the differences in the regular behavior that is connected to the mutual interaction of Mg alloy surface and it surface assimilated surfactant molecules [30].

Fig. 6
figure 6

Langmuir adsorption isotherms for the adsorption of DB on AZ31 alloy in a) 0.1 M NaCl medium and b) 0.1 M Na2SO4 medium

The standard free energy of adsorption (ΔG°ads) (Eq. 6) is proportional to K as per the equation shown below [30].

$${{\Delta G}^{o}}_{ads}= -RTln\left(55.5\times K\right)$$
(6)

The thermodynamic elements for the surface adsorption of the alloy are summarized in Table 7. The stability and the immediate adsorption of DB on the alloy surface are due to the—ΔGoads values. It is reported that when the ΔGoads values > -20 kJ mol−1 they correspond to a physisorption process and if the values are < -40 kJ mol−1 they correspond to chemisorption processes [17, 34]. Here, the attained \(\Delta {G^\circ }_{ads}\) values is between -27 to -31 kJ mol−1 for both NaCl and Na2SO4 solution, that specifies inhibitor molecule DB showing both physical and chemical adsorption. The rise in the temperature impacts the inhibition effect of DB molecule, as there is a decrease in the values of ΔG°ads and implies predominant physical adsorption. The minimum disorderness on the adsorption of DB on the Mg alloy surface is due to the decrease in the ΔS°ads values  as seen in (Table 8).

Table 7 Evaluation of thermodynamic parameters for the adsorption of DB on AZ31 alloy in NaCl solution
Table 8 Evaluation of thermodynamic parameters for the adsorption of DB on AZ31 alloy in Na2SO4 solution

3.5 Mechanism of corrosion inhibitor

The kind of mechanisms of action of Gemini surfactant upon the metal surface as a corrosion inhibitor that is published in earlier works of literature [3, 35] can be related with the corrosion protection mechanism that DB follows on AZ31 Mg alloy. The alloy surface is attracted to the functional groups of the surfactant molecule and the attraction is increased as the hydrophilic part of DB is attracted to the other adjacent molecule. The physical adsorption of DB inhibitor on the surface of α-Mg matrix occurs due to electrostatic interactions between the anionic head of the inhibitor and the trapped Mg2+ ions present in the uneven/partial film surface. Also, chemisorption could take place since the cathodic phases are composed of Al and Zn elements. Due to the donor–acceptor interactions between electrons of oxygen, nitrogen and the vacant d-orbitals of metal alloy, strong covalent bonds might occur that lead to the chemisorption of inhibitors [36]. The physisorbed DB precipitates on the surface of Mg alloy as sparingly soluble magnesium salts over the α-Mg matrix. This precipitate layer occurred due to the low Ksp of the magnesium-DB molecule. These formed precipitates pack all pores and thicken the surface film. Due to this process, when the concentration of DB increases, the electrolyte cannot easily pass through the alloy thus decreasing the corrosion rate. The four alkyl chains of adsorbed DB molecules consist of Vander Waals interactions between them, which cause slight deviation from ideal Langmuir behavior. This kind of mutual interaction further improves the tight packing of precipitate film. Also, the hydrophobicity of this chain repels the aqueous corrosive medium [37].

The adsorption enthalpy threshold of physisorption is immediate to the obtained \(\Delta {H}_{ads}^{o}\) values in the presence of 0.1 M NaCl and 0.1 M Na2SO4. Also, the inhibitor shows physisorption as the η (%) reduces with the increase in temperature. These obtained results show that physisorption is more pronounced than chemisorption, especially at higher temperatures like 50 °C, where the inhibition efficiency (η) is at the least. The cause for this effect may be because of the rise in the mobility of magnesium ions (Mg2+) at high temperatures that can diffuse to cathodic regions which act as the chemisorption sites [36]. Also, at higher temperatures, there is an increase in the involvement of hydrogen in the solution which might hinder the inhibitor adsorption.

The anionic gemini surfactant synthesized demonstrates surface activity and a propensity for self-aggregation. The behavior of surfactant aggregation varies between gaseous-liquid and solid–liquid interfaces. Above the critical micelle concentration (CMC), monomeric surfactants form spherical micelles in gaseous-liquid interfaces, while at solid–liquid interfaces, the transition is from monolayers to bilayers or multilayers. In the aqueous phase, surfactant molecules aggregate upon reaching solubility saturation, aligning their hydrophobic tails with neighboring molecules and their hydrophilic head groups with water or hydrophilic surfaces. The critical micelle concentration (CMC) marks the point of surfactant aggregation onset, typically lower than the surface adsorption concentration (SAC), where optimal corrosion inhibition efficiency is often observed.

Surfaces of Mg and MgO, Mg(OH)2 possess hydrophilic properties, attracting functional groups such as COO and N groups in surfactants. This attraction is reinforced by the hydrophobic segment of the molecule, which is drawn to hydrophobic regions of neighboring surface surfactant molecules. Consequently, a driving force promotes surfactant molecule aggregation on surfaces, potentially forming additional layers when sufficient surfactant is present in the solution, leading to diverse adsorbed structures. Similarly, in solution, surfactants exhibit behavior with aggregate structures, such as micelles forming at moderate concentration levels above the critical micelle concentration (CMC).

The anions in the electrolyte control the mechanism of corrosion inhibition. The anions bring the dissolution of the surface film which acts as a pitting agent. In the absence of an inhibitor i.e., NaCl/Na2SO4 electrolyte, the dissolution of the surface film shows that the alloy surface brings a surge in the attack. Similarly, introducing DB inhibitor, the film will consist of Mg2+ ions which act as the area for adsorption of anionic Gemini surfactants.

3.6 Scanning electron microscopy and EDX analyses

To gain a deeper understanding of corrosion mechanisms, SEM analysis was conducted on the surface of AZ31 Mg alloy immersed in 0.1 M NaCl and 0.1 M Na2SO4 solutions. In Fig. 7, numerous cracks are visible on the alloy surface, indicating corrosion in both NaCl and Na2SO4 environments in the absence of inhibitor, which penetrates through the passive Mg oxide layer. Conversely, Fig. 8 shows the SEM image in the presence of the DB inhibitor leads to the emergence of thin layers or particles on the Mg alloy surfaces, suggesting inhibitor adsorption and the formation of protective films. These particles predominantly consist of DB gemini surfactants, enhancing inhibition efficiency due to denser protective films formed by the alkyl chains.

Fig. 7
figure 7

The SEM image and EDX spectrum of AZ31 Mg alloy surface immersed in a) 0.1 M NaCl and b) 0.1 M Na2SO4 medium for 3 h

Fig. 8
figure 8

The SEM image and EDX spectrum of AZ31 Mg alloy surface immersed in 0.001 M DB a) 0.1 M NaCl and b) 0.1 M Na2SO4 medium in the presence of 0.001 M DB for 3 h

In the inhibited system, the anionic surfactant effectively coats the alloy surface through adsorption, as confirmed by EDS analysis. EDS images captured in both NaCl and Na2SO4 media in the presence of the anionic gemini surfactant DB, which confirmes the effective inhibition [17].

3.7 XPS

The findings of XPS displayed in Figs. 9 and 10 depict the spectra of C 1 s, Mg 1 s, O 1 s, Al 2p, and N 1 s for AZ31 in NaCl and Na2SO4 solutions in the presence of DB inhibitor, respectively. In both graphs, the C 1 s spectra can be deconvoluted into two peaks, a peak at 285.0 eV ascribed to C–C/C-H groups, and another peak at 286.5 eV is corresponding to C-N groups. The Mg 1 s spectrum reveals three deconvoluted peaks centered at 1302.6, 1303.5, and 1303.8 eV, representing Mg(OH)2, metallic Mg, and MgO, respectively, with Mg(OH)2 predominating as the corrosive product. While the presence of the inhibitor impacts peak positions in both NaCl and Na2SO4 media, the intensities of the peaks vary. Magnesium's role appears significant compared to other elements, suggesting a mitigation of the corrosion process.

Fig. 9
figure 9

XPS spectra (Mg 2s, Al 2p, C 1s, O 1s and, N 1s) of AZ31 Mg alloy immersed in 0.10 M NaCl in the presence of 0.001 M DB for 3 h at 30 °C

Fig. 10
figure 10

XPS spectra (Mg 2s, Al 2p, C 1s, O 1s and, N 1s) of AZ31 Mg alloy immersed in 0.1 M Na2SO4 medium in the presence of 0.001 M DB for 3 h at 30 °C

The O 1 s spectrum for both samples displays a predominant peak corresponding to Mg-O at 530.7 eV, mainly originating from Mg(OH)2 and MgO. The Al 2p spectrum at 75.3 eV indicates the presence of the MgAl2O4, indicating the formation of a thin adsorption layer with negligible thickness.

It is crucial to acknowledge potential errors in XPS analysis due to aluminum exposure to atmospheric air, resulting in the formation of a naturally grown Al2O3 passive layer, as well as atmospheric contamination with adventitious carbon. Although efforts were made to minimize these effects by reducing the sample storage duration between corrosion tests and XPS examination, sample etching before XPS measurements was not feasible due to the minimal thickness of the investigated layers [3]. N 1s peak position was related to the N-CH2 bond in the DB inhibitor.

3.8 DFT of DB inhibitor

The optimized structure of DB and its frontier molecular orbital (FMO) density distribution is shown in Fig. 11. The parameters of the highest occupied molecular orbital (EHOMO), the lowest unoccupied molecular orbital (ELUMO), energy gap, dipole moment, electronegativity, chemical hardness, electron affinity, ionization potential, and softness are mentioned in Table 9. Many studies [34, 38,39,40] have claimed that by indicating the electron-donating and electron-receiving capacity of a molecule, the EHOMO and ELUMO values provide valuable insight into the inhibitor’s potency and reflect the reactive sites of electrophilicity and nucleophilicity of inhibitor. In general, a low ELUMO (-4.93) value indicates that the inhibitor molecule will accept electrons from the metal, and a higher EHOMO (-1.04) indicates a strong electron-donating propensity to be a worthy acceptor with an empty molecular orbital. This trend is also evident in the current analysis. Small Energy gap of value 3.88 eV depicts enhanced inhibitor molecule reactivity towards the surface along with higher efficiency [41]. Therefore, herein the mechanism of inhibition includes the Mg2+ ions forming a precipitate film on the Mg surface [42]. The formation of a complex between inhibitors and Mg2+ ions results in the creation of a dense film on the alloy surface, which in turn leads to a reduction in the corrosion rate of AZ31 Mg alloy.

Fig. 11
figure 11

Optimized structure and the frontier molecular orbital density distribution of the DB molecule

Table 9 Calculated DFT parameters for DB inhibitor

4 Conclusion

The novel Gemini surfactant (DB) to protect the surface of AZ31 Mg alloy was synthesized using the precursors of EDTA and dibutyl amine. Its application as a corrosion inhibitor against the corrosion of AZ31 Mg alloy in 0.1 M NaCl and 0.1 M Na2SO4 solutions was investigated. The DB showed effective prevention of the AZ31 Mg alloy from undergoing corrosion in both the studied media. The corrosion efficiency of the DB was found to be increasing up to 86% (IE%) and decreasing with an increase in concentration and temperature. Both the experimental and theoretical outcomes indicated that the inhibition mechanism on AZ31 Mg alloy surface is through physisorption, in accordance with the Langmuir adsorption isotherm. Specifically, the inhibitor DB interacts with Mg2+ ions present in the alloy to form complexes, which subsequently generate a corrosion-inhibiting layer on the surface of Mg. The experimental findings were in agreement with the theoretical calculation conducted to correlate their inhibiting effect and structure, which further clarified the working mechanism of synthesized inhibitor.