1 Introduction

Corrosion is a natural, spontaneous, and thermodynamically balanced mechanism promoted by the environment [1]. In metals, this process occurs whenever there is an interaction of the two reactions of oxidation and reduction at the surface of the material that leads to its progressive deterioration [2]. Artificially, it is produced by acidic media used in industrial cleaning, descaling, and pickling of steel surfaces causing significant dissolution of the metal [3, 4]. In recent years, several methods have been exploited to protect metals from corrosion, such as cathodic protection, plating protection, coating protection, and corrosion inhibitor. The use of inhibitors against dissolution of metals remains an inevitable method [5, 6].

Corrosion inhibitors are divided into organic and inorganic corrosion inhibitors, they are dangerous for humans and the environment. During the last decade, scientific efforts in the field of corrosion inhibition have focused on environmentally friendly and potentially non-toxic corrosion inhibitors known as green corrosion inhibitors. Hence, the study of corrosion prevention based on expired drugs [7,8,9,10,11,12], plastic waste [13, 14], polymer materials [15], surfactant compounds [16, 17], and plants [18]. Corrosion inhibition by plants is closely related to its phytochemical compounds, which have a non-polar, hydrophobic part comprising hydrocarbon molecules and a polar, hydrophilic part that constitutes one or more functional groups [19]. These organic compounds are able to adsorb to the metal surface, blocking the active sites on the surface and thus decreasing the corrosion rate [20].

In recent years, more and more corrosion specialists have started to study green organic corrosion inhibitors, such as Dysphania ambrosioïdes (L.), a wild species from tropical America naturalized in the old world, erect herbaceous, annual or perennial, with a more or less pubescent branching stem. Dysphania ambrosioïdes (L.) is widely used in pharmacological and therapeutic activities as an antimicrobial, antifungal, and also for the treatment of respiratory, urogenital, vascular, and nervous disorders and for metabolic disorders such as diabetes and hypercholesterolemia [21].

The present work is devoted to the study of the chemical composition of Dysphania ambrosioïdes (L.) extract and its capacity as a corrosion inhibitor of mild steel in molar hydrochloric acid medium by applying different experimental techniques: weight loss, potentiodynamic polarization curves, electrochemical impedance spectroscopy (EIS), and the study of the morphology of mild steel by scanning electron microscope coupled to EDX spectrometer. This study was complemented by a complementary theoretical approach using Density functional theory (DFT) at B3LYP/6-31G (d, p).

2 Materials and Methods

2.1 Plant Material

The plant material used during our study is the aerial part of Dysphania ambrosioïdes (L.), harvested in spring 2019, at Ain Orma park (33 °53′36″N 5 °32′50″W), which is located between the cities of Meknes and Khémissat, in the region of Fez-Meknes (Morocco). The plant was dried in a dry and airy place for 1 month, ground with an electric mill and kept in the shade in closed jars.

50 g of plant powder was put in a cartridge, then placed in a siphon attached to a flask containing 250 mL of the extraction solvent (Methanol). The whole was topped with a refrigerator. After 6 h of extraction, the solvent was then evaporated using a rotary evaporator.

2.2 Gas Chromatography/Mass Spectroscopy (GC/MS)

The apparatus used is a Hewlett Packard model 5890 series, equipped with a certain type of detector (HP 5972 mass), the column used is a HP5-MS capillary type column of dimensions (30 m × 0.32 mm), and the carrier gas used is helium (He). The injector temperature is 280 °C, the detector temperature is 300 °C, and the injected volume is 1 µL.

2.3 Preparation of the Materials

The steel used in the present work is mild steel consisting of Fe (99.21), C (0.21), Mn (0.05), Si (0.38), S (0.05), P (0.09), and Al (0.01). Before each test, the mild steel samples were polished with various grades of emery paper (400–1500), cleaned with acetone, rinsed with distilled water, dried, and weighed.

The 1.0 M HCl corrosive test solution was prepared by diluting a stock solution of 37% HCl grade analytical reagent with distilled water. The concentration of the inhibitors studied was in the range (0.25 g/L 1.0 g/L).

2.4 Electrochemical Study

Electrochemical measurements were carried out using a Versa STAT 4 potentiostat, controlled with versa studio software. The electrochemical tests were carried out using a glass cell with three electrodes: Platinum as auxiliary electrode, Ag/AgCl as reference electrode, and mild steel samples as working electrode. The surface area of the steel electrode used for the electrochemical experiments was 1.0 cm2, and the volume of the solutions in the glass cell was 50 mL. To have a stable open circuit potential, before each test, the potential of the working electrode was stabilized for 30 min. The polarization curves were performed with a scan rate of 1.0 mV.S−1 with a potential range of ± 250 mV according to the open circuit potential (OCP). The inhibition efficiency (ɳpp%) was calculated from the corrosion current density values using Eq. (1) [22].

$$\eta_{pp} \% = \left[ {{\raise0.7ex\hbox{${i_{{{\text{corr}}}}^{0} - i_{{{\text{Corr}}}} }$} \!\mathord{\left/ {\vphantom {{i_{{{\text{corr}}}}^{0} - i_{{{\text{Corr}}}} } {i_{{{\text{corr}}}}^{0} }}}\right.\kern-\nulldelimiterspace} \!\lower0.7ex\hbox{${i_{{{\text{corr}}}}^{0} }$}}} \right] \times 100$$
(1)

i0corr is the corrosion current density value in the absence of inhibitor. i0corr is the corrosion current density value in the presence of inhibitor.

The EIS method was performed in the frequency range 100 kHz to 100 kHz with 10 points per decade. Nyquist curves were plotted and analyzed using a suitable equivalent circuit. The inhibition efficiency was calculated using Eq. (2) [23].

$$\mathop \eta \nolimits_{{{\text{imp}}}} \% = \left[ {{\raise0.7ex\hbox{${R^{\prime}_{p} - \mathop R\nolimits_{{_{p} }} }$} \!\mathord{\left/ {\vphantom {{R^{\prime}_{p} - \mathop R\nolimits_{{_{p} }} } {\mathop R\nolimits_{{_{p} }} }}}\right.\kern-\nulldelimiterspace} \!\lower0.7ex\hbox{${\mathop R\nolimits_{{_{p} }} }$}}} \right] \times 100$$
(2)

R′p is the polarization resistance of the mild steel electrode in the presence of inhibitor. Rp is the polarization resistance of the mild steel electrode in the absence of inhibitor.

2.5 The Gravimetric Study

The gravimetric measurements were carried out in a glass cell equipped with a thermostatically cooled condenser to maintain the electrolyte at the desired temperature. The volume of the electrolyte is 100 mL, and the samples are rectangular in shape and size (L = 1.95, l = 1.65, e = 0.65). Before each measurement, the samples were accurately weighed and immersed in beakers containing 100 mL of acid solutions without and with inhibitor (the extract) at different temperatures for 6 h. The inhibitory efficiency was calculated according to the following expression [23]:

$$\eta_{{{\text{WL}}}} \left( \% \right) = \left[ {\frac{{C_{R}^{^\circ } - C_{R} }}{{C_{R}^{^\circ } }}} \right] \times 100$$
(3)

C°R is the weight loss of mass in the absence of the inhibitor. CR is the weight loss of mass in the presence of the inhibitor.

2.6 Scanning Electron Microscope

The surface morphology of the carbon steel samples, before and after immersion in the studied solutions (with and without inhibitor), was examined by the JSM-IT 500 HR SEM connected to an X-ray analysis system (EDX) using 8 kV electron acceleration in order to determine the elemental composition of the sample surface.

2.7 DFT Calculations

The DFT calculations were carried ot using Gaussian 09 and GaussView5.0.8 software. Therefore, DFT method at B3LYP level with the basic set of 6-311G (d, p) was used for the present study [24]. Various quantum chemical descriptors were determined such us EHOMO (ELUMO), energy gap (ΔEgap), global hardness (η), global softness (σ), electronegativity (χ), dipole moment (μ), and the fraction of electrons transferred (ΔN110) using the following equations [25, 26].

$$\Delta E_{{{\text{gap}}}} = E_{{{\text{LUMO}}}} - E{}_{{{\text{HOMO}}}}$$
(4)
$$\sigma = \frac{1}{\eta }$$
(5)
$$\eta = \frac{1}{2}\left( {E_{{{\text{HOMO}}}} - E_{{{\text{LUMO}}}} } \right)$$
(6)
$$\chi = \frac{1}{2}\left( {E_{{{\text{HOMO}}}} + E_{{{\text{LUMO}}}} } \right)$$
(7)
$$\Delta N_{110} = \frac{{\chi_{{{\text{Fe}}\left( {110} \right)}} - \chi_{{{\text{inh}}}} }}{{2\left( {\eta_{{{\text{Fe}}\left( {110} \right)}} + \eta_{{{\text{inh}}}} } \right)}} = \frac{{\Phi - \chi_{{{\text{inh}}}} }}{{2\eta_{{{\text{inh}}}} }}$$
(8)

The Fukui functions were used to compare the reactive atomic centers within the same molecule. It’s calculated according to Eqs. (9, 10)(9) (10).

$${\text{Electrophilic attack:}}\,P_{k}^{ - } = P_{k} \left( N \right) - P_{k} \left( {N - 1} \right)$$
(9)
$${\text{Nucleophilic attack}}:\,\,P_{k}^{ + } = P_{k} (N + 1) - P_{{_{k} }} (N)$$
(10)

where Pk (N), Pk(N + 1), and Pk(N − 1) are the electronic population of the atom k in the neutral, anionic, and cationic form, respectively [27, 28].

3 Results and Discussion

3.1 Gas Chromatography/Mass Spectroscopy (GC/MS)

The analysis of the extract of Dysphania ambrosioïdes (L.) gave the chromatogram as shown inFig. 1:

Fig. 1
figure 1

Chromatogram of the methanolic extract of Dysphania ambrosioïdes (L.)

The results of the analysis of the methanolic extract of Dysphania ambrosioïdes (L.) by GC/MS are presented in Table 1 and allowed the identification of the major compounds such as ascaridole epoxide (16.53%), thymol (13.25%), n-hexadecanoic acid (9.62%), and o-cymene (6.32%). Other constituents are present in small quantities such as ascaridole (1.65%).

Table 1 Majority molecules of the methanolic extract of Dysphania ambrosioïdes (L.)

The composition of Dysphania ambrosioïdes (L.) has attracted considerable interest. Although the first studies on the oil date back to 1854, many compounds have been identified such as ascaridol, limonene, α-terpinene, and p-cymene [29].

The molecules found in the above chromatogram are presented in Table 1.

3.2 Concentration Effect

The inhibition performance of Dysphania ambrosioïdes (L.) extract was determined by measuring the weight loss after 6 h immersion at different concentrations at 298 K. The corrosion rate and inhibition efficiency for mild steel in 1.0 M HCl are given in Table 2.

Table 2 Corrosion rate and inhibition efficiency of mild steel exposed for 6 h in 1.0 M HCl at different concentrations of Dysphania ambrosioïdes (L.) extract, at 298 K

It can be seen from Table 2 that inhibitory efficiency increases with the concentration of the methanolic extract, reaching 94% at the optimum concentration of 1.0 g/L. This result may be due to the increase in the surface area covered by the molecules adsorbed on the steel surface, which decreases the corrosive environment and their contact with the steel samples [30].

3.3 Potentiodynamic Polarization Study

Typical potentiodynamic polarization curves for mild steel in 1.0 M HCl in the presence and absence of different concentrations of Dysphania ambrosioïdes (L.) extract are shown in Fig. 2 and Tafel parameters including corrosion current density (icorr), corrosion potential (Ecorr), cathodic Tafel slope (βc), and inhibition efficiency (E%) are summarized in Table 3.

Fig. 2
figure 2

Measured polarization curve for mild steel in 1.0 M hydrochloric acid in the absence and presence of different concentrations of Dysphania ambrosioïdes (L.)

Table 3 Polarization parameters in the absence and presence of different concentrations of Dysphania ambrosioïdes (L.) extract

It can be seen that the addition of the methanolic extract decreases the current which can be attributed to the protection of the mild steel against corrosion. The cathodic branch, in the presence and absence of inhibitor are well-defined tafel lines, which shows that the hydrogen evolution reaction is controlled by the activation. The addition of the inhibitor to the corrosive medium obviously decreased the cathodic tafel slope (βc). Furthermore, the decrease in cathodic surface area can be explained by the reduction in hydrogen evolution without influencing the reaction mechanism. When the Ecorr shift is higher than 85 mV, corresponding to that of the uninhibited solution, the inhibitor is considered as a cathodic or anodic type inhibitor. On the other hand, when the displacement is less than 85 mV, the inhibitor is classified as a mixed-type inhibitor [22, 31]. In the present paper, the extract of Dysphania ambrosioïdes (L.) acts as a mixed-type inhibitor.

3.4 Electrochemical Impedance Spectroscopy

Figure 3 shows the Nyquist diagram for mild steel in 1.0 M HCl in the absence and presence of different concentrations of the methanolic extract of Dysphania ambrosioïdes (L.). The parameters associated with the impedance of the diagram such as charge transfer resistance Rct, double-layer capacitance Cdl ,and inhibition efficiency are presented in Table 4, after a good simulation by EC-Lab V10.02 software.

Fig. 3
figure 3

Nyquist diagram for mild steel in 1.0 M HCl in the absence and presence of different concentrations of the methanolic extract of Dysphania ambrosioïdes (L.)

Table 4 Electrochemical impedance parameters in the absence and presence of different concentrations of Dysphania ambrosioïdes (L.)

Figure 3 shows that all fitted Nyquist plots exhibit a single capacitive loop and that the size of these plots increases with increasing inhibitor concentration, meaning that the corrosion reaction is mainly controlled by a charge transfer process [32].

From Table 4, it can be seen that the Rp values increased with increasing inhibitor concentration, and the inhibition efficiency reached 93% at the concentration of 1.0 g/L. In contrast, the Cdl and Q values decreased, indicating adsorption on the mild steel surface.

It can be seen from Bode diagram that the corrosion mechanism process controlled with charge transfer since the phase versus frequency detected one single peak at the mid-frequency range. Therefore, this observation leads us to report that one single time constant was detected for Dysphania ambrosioïdes (L.) extract. Moreover, the absolute impedance at low frequencies was increased with the inhibitor concentration indicating protection of the mild steel used against the corrosion process [23].

On the side, the angles' phase showed for the concentration used is fewer than − 90° which can be due to the equivalent circuit used which contain element phase constant instead of ideal capacitor [23].

3.5 Adsorption Isotherm

In order to explore the adsorption process of Dysphania ambrosioïdes (L.) extract on the surface of mild steel, we used abundant adsorption models to verify the experimental results of the polarization curves. These adsorption isotherms include Langmuir, El-Awady, Temkin, and Freundlich. Their expressions are as follows [33]:

$${\text{Langmuir}}: \, \frac{{C_{{{\text{inh}}}} }}{\theta } = \frac{1}{K} + C_{{{\text{inh}}}}$$
(11)
$${\text{El - Awady}}:\,\,\ln \left( {\frac{\theta }{1 - \theta }} \right)\, = \,y\ln K + y\ln C_{{{\text{inh}}}}$$
(12)
$${\text{Temkin}}: \, \theta = \frac{ - 1}{{2{\text{a}}}}\ln \left( K \right) - \, \frac{1}{{2{\text{a}}}}\ln (C_{{{\text{inh}}}} )$$
(13)
$${\text{Freundlich}}: \, \ln \theta = \ln K + z\ln C_{{{\text{inh}}}}$$
(14)

The results obtained are presented in Fig. 4 in order to explore the type of adsorption of Dysphania ambrosioïdes (L.) leaf extract on mild steel. By comparing the linear regression coefficients (R2) of the studied isotherms, it is found that the R2 value of the Langmuir isotherm is close to one as well as the slope of the plot. This observation shows that the adsorption of Dysphania ambrosioïdes (L.) leaf extract adsorbed on the surface of mild steel with Langmuir monolayer adsorption.

Fig. 4
figure 4

Plots of Dysphania ambrosioïdes (L.) adsorption isotherm models for a mild steel surface in 1.0 M HCl at 298 K obtained from the EIS data

We used the following formula to calculate the value \({\Delta G}_{ads}^{0}\)= − RT ln (1000*Kads).

R represents the universal gas constant, T represents the thermodynamic temperature [33], and the calculated values of \({\Delta G}_{ads}^{0}\) are inserted in Table 5.

Table 5 Adsorption parameters deduced from different adsorption isotherms of Dysphania ambrosioïdes (L.) at 298 K

Usually, the standard free energy of adsorption values of around − 20 kJ-mol−1 or less negative, involves the interactions between the charged mild steel surface and the charged extract compounds are electrostatic, i.e., physisorption those of − 40 kJ-mol−1 or higher values shows the chemical adsorption, the electron transfer from the inhibitor molecules to the metal surface, i.e., chemisorption [34, 35]. According to the results obtained, the type of adsorption of Dysphania ambrosioïdes (L.) extract is physisorption in nature.

3.6 Immersion Time

In order to study the adsorption kinetics of the inhibitor and to specify the time required to achieve maximum inhibition efficiency. We performed the electrochemical impedance spectroscopy measurements in 1.0 M HCl solution in the absence and presence of the inhibitor for immersion times of 1–12 h at 298 K. The results are presented in Fig. 5 and the parameters listed in Table 6.

Fig. 5
figure 5

Impedance spectra obtained after different immersion times in a 1.0 M HCl solution without a and with b 1.0 g/L Dysphania ambrosioïdes (L.) extract

Table 6 Impedance parameters of mild steel in the absence and presence of 1.0 g/L Dysphania ambrosioïdes (L.) extract at different immersion periods

Table 6 shows that the inhibitory efficiency shows a maximum value of 91.9% after 1 hour of immersion time and then starts to decrease to a value of 86% after 12 h. This observation led us to suggest that the molecules of the tested extract formed a compact film during 1 h immersion time. Afterward, this film started to detach from the electrode surface resulting a decrease in the inhibition efficiency.

3.7 Temperature Effect

In order to study the effect of temperature on the inhibition efficiency of Dysphania ambrosioïdes (L.) extract, the experiments were conducted in the range of 298–328 K using weight loss measurements during 2 h. The corrosion parameters obtained are presented in Table 7.

Table 7 Corrosion parameters obtained from weight loss for mild steel in 1.0 M HCl containing 1.0 g/L Dysphania ambrosioïdes (L.) extract at different temperatures

The results showed that increasing the temperature decreases the corrosion rate in the presence of the inhibitor compared to blank. This increase in the corrosion rate increases slowly compared to the uninhibited solution, i.e., increasing from 0.0602 mg.cm−2.h−1 in 298 K to 0.4213 mg.cm−2.h−1 in the temperature of 328 K. Based on the inhibition efficiency index, the adsorption process of the metal surface is more pronounced which led us to suggest that the addition of the studied extract reduces the dissolution. To obtain information on the adsorption process, the activation parameters can be determined from the Arrhenius Eq. 15 and the transition state Eq. 16.

$$i_{{{\text{corr}}}} = A e^{{(\frac{{ - E_{{\text{a}}} }}{RT})}}$$
(15)
$$i_{{{\text{corr}}}} = \frac{RT}{{Nh}} e^{{\left( {\frac{{\Delta S^{*} }}{R}} \right)}} e^{{\left( {\frac{{ - \Delta H^{*} }}{RT}} \right)}}$$
(16)

A is the Arrhenius pre-exponential constant. Ea is the apparent activation energy. R is the gas constant. T is the absolute temperature. h is the Plank’s constant. N is the Avogadro’s number. ΔH* is the enthalpy of activation and ΔS* is the entropy of activation. Arrhenius plots for the corrosion rate of mild steel are given in Fig. 6. The values of Ea. ΔH* and ΔS* are given in Table 8.

Fig. 6
figure 6

Arrhenius curves Ln CR and Ln (CR/T) vs. 1000/T in 1.0 M HCl with and without 1.0 g/L of Dysphania ambrosioïdes (L.)

Table 8 The activation parameters Ea, ΔH* and ΔS* of the dissolution of mild steel in 1.0 M HCl solution in the absence and presence of 1.0 g/L Dysphania ambrosioïdes (L.) extract

We notice that the activation energy of the solution in the presence of Dysphania ambrosioïdes (L.) extract is higher than that of the blank. This is due to the interaction between the inhibitor and the mild steel surface. Furthermore, the higher value of activation energy in the presence of Dysphania ambrosioïdes (L.) is compared to the 1.0 M HCl solution which is often interpreted in the literature by the physisorption of the inhibitor on the mild steel surface [36]. The value of ΔH for the dissolution reaction of mild steel in 1.0 M HCl solution in the presence of the inhibitor is higher than that presented in the absence of inhibitor and their positive value explained the endothermic nature of the mild steel. In addition, it can be noted that the high negative value of ΔS* in the presence of Dysphania ambrosioïdes (L.) indicates a decrease in disorder during the formation of the metal/adsorbate complex [37].

3.8 Scanning Electron Microscopy (SEM)/EDX

The morphological characteristics of mild steel before and after immersion in 1.0 M hydrochloric acid for 6 h in the absence and presence of 1.0 g/L of Dysphania ambrosioïdes (L.) extract are shown in Fig. 7. The composition of the mild steel before and after treatment is shown in Fig. 8.

Fig. 7
figure 7

SEM image (20 µm) of the mild steel surface a before and b after 6 h immersion in 1.0 M HCl solution in the absence of inhibitors and c after 6 h immersion in 1.0 M HCl solution in the presence of 1.0 g/L inhibitor

Fig. 8
figure 8

EDX spectra of mild steel before immersion a, after 6 h immersion in 1.0 M HCl b, after immersion in 1.0 g/L Dysphania ambrosioïdes (L.) extract

Figure 7 clearly reveals that the sample immersed in the acidic environment only (b) is deeply corroded compared to the sample before immersion (a). In the presence of the inhibitor (c), the surface was less damaged compared to the samples immersed in 1.0 M HCl containing a large smooth zone. In the other sense, this observation revealed the formation of a protective layer on the steel surface which prevent against the corrosion process.

It can be noticed from the EDX spectra and the weight percentage of elements recorded for the mild steel surface in Table 9 that the studied extract protecting the steel surface. Firstly, the percentage atomic of the iron reduces from 98.52 to 85.74% after immersion in 1.0 M HCl. Also, a new peak of oxygen (O) atom was appeared confirming the presence of iron oxides. Moreover, the iron percentage decreases in the presence of Dysphania ambrosioïdes (L.) extract with a rise in the carbon and the oxygen elements which can be explained by the adsorption of the studied extract components forming a protective layer on the surface [38]. Finally, these results confirmed the inhibition efficiency achieved experimentally.

Table 9 Weight percentage of elements obtained from EDX spectra

3.9 DFT Study

The DFT Theory has been generally useful to understand the inhibition performance of the molecules used, and therefore, the adsorption mechanism is based on the electronic properties [39]. The quantum descriptors were obtained using this method at B3LYP/6-311G (d.p) (Table 10). The optimized geometries of the studied molecules as well as their frontier molecular orbital (LUMO and HOMO) are presented in Fig. 9. The Fukui functions were also carried out using the natural populations to know the most reactive sites of the studied molecules.

Table 10 Quantum chemical descriptors for the studied molecules in aqueous phases
Fig. 9
figure 9

Optimized structures. HOMO & LUMO, and ESP maps for the studied molecules in neutral form

It can be seen that the studied molecules which had a high percentage in the plant used present an important distribution of the HOMO and LUMO orbitals. The HOMO and LUMO orbital distributions in the molecules thymol, cymene, and ascaridole epoxide were localized principally in the aromatic rings showing that these molecules can create bonds with the vacant d orbital of iron because they have many reactive sites distributed along of the inhibitor’s structures. For the hexadecanoic acid, the HOMO density distribution was localized in the whole structure while the LUMO density was localized in the acid group function. Furthermore, the ESPmap distributions show that the total density in red color located on the oxygen atoms [23, 40]. As a result, it can be suggest that the present inhibitors can support the adsorption phenomenon onto the surface of mild steel.

In the literature, the high value of the HOMO energy and the low value of the LUMO energy can facilitate the tendency of the molecule to give and accept electrons, respectively. Therefore, the small gap energy explains the high reactivity of molecules enhancing their inhibition performance [41]. Compared between the four molecules studied, thymol molecule has the smallest energy gap followed by ascaridole epoxide then cymene and finally hexadecanoic acid. This result confirms the high reactivity of thymol and ascaridole epoxide molecules to adsorb onto the steel surface.

For the dipole moment, there is no general consensus on the correlation between the dipole moment and the effectiveness of corrosion inhibition [22, 42] since some researchers reported that the effectiveness increases with the increase of dipole moment values while others found the contrary. In our case, neither of this theory was confirmed since the hexadecanoic acid molecule showed the high value and cymene molecule showed the small value. It’s known that the molecule with high softness value and small hardness value has a great reactivity which can enhance the inhibition performance [43]. Based on the obtained results, the studied molecules showed the same order presented for the energy gap which confirms that the molecules reactivity follows the order: thymol >  ascaridole epoxide > cymene > hexadecanoic acid. Furthermore, according to Lukovist’s study, the small value of ∆N110 which is smaller than 3.6 indicating the high ability to give electron to the steel surface which can decrease the corrosion rate [38].

The most active sites of Fukui indices for the studied molecules have been extracted in aqueous phase and listed in Table 11. The examination of the Fukui functions calculations showed that the most active sites susceptible to nucleophilic attack are C1, C3, C4, and C6 for thymol molecule; C2, C8, and O13 for ascaridole epoxide molecule; C2, C5, and C3 for cymene molecule; and C1, O2, and O3 for hexadecanoic acid molecule since having the high values of \(f_{k}^{ + }\) [44, 45]. On the other side, the most active sites susceptible to electrophilic attack are C2, C4, C5, and O11 for thymol molecule; C3, O7, O8, and O13 for ascaridole epoxide molecule; C1, C4, C3, and C6 for cymene molecule; O2, O3, C9, and C10 for hexadecanoic acid molecule since having the high values of \(f_{k}^{ - }\)\(f_{k}^{ + }\) [31, 32]. Finally, it can be observed that these responsible sites are suitable to donor–acceptor interactions and thus facilitate the adsorption of these molecules onto the steel surface.

Table 11 Most active sites of \(f_{k}^{ + }\)&\(f_{k}^{ - }\) for studied molecules in aqueous phases

4 Conclusion

In the present study, the characteristic corrosion inhibition and adsorption of Dysphania ambrosioïdes (L.) in 1.0 M HCl solution were investigated by various electrochemical techniques and theoretical approach. The analysis of Dysphania ambrosioïdes (L.) extract by gas chromatography shows the dominance of ascaridole epoxide (16.53%), thymol (13.25%), and n-hexadecanoic acid (9.62%). The inhibition efficiency of Dysphania ambrosioïdes (L.) increases with the rise of extract concentration and reaches 95% at optimum concentration of 1.0 g/L. The potentiodynamic polarization curves indicate that the extract acts as mixed-type inhibitor. The adsorption behavior shows that Dysphania ambrosioïdes (L.) are suitable for Langmuir isothermal models. Moreover, SEM analyzes confirmed the protective capacity of inhibitory molecules. On the other side, DFT calculations provide a good explanation of the relationship between molecular structure and anticorrosion efficiency, using the structural and electronic properties of the molecules presented above as the main components of the extract of Dysphania ambrosioïdes (L.) tested.