Introduction

From time immemorial, man has exploited a variety of materials to meet his material and symbolic needs. More often than not, they have been transformed by various processes (mechanical, thermal, chemical, and biochemical) for technical, symbolic, or energetic purposes. Unfortunately, these transformations are not eternal. Predicting the long-term behavior of structures, particularly metal structures, i.e. assessing the damage they are likely to sustain over time as a result of corrosion, represents a major economic, scientific, and certainly environmental challenge.

Corrosion is a natural phenomenon that can be seen as the progressive decay or wear of a material, typically a metal, and its characteristics, over time due to exposure to the environment1. Indeed, corrosion, much like other natural hazards such as earthquakes or severe weather events, can cause severe and costly harm to many different objects, vehicles, home furnishings, plumbing, gas and oil lines, highways and airports, and public structures all make use of steel. However, unlike natural disasters, corrosion can be managed. But the question is, at what expense? There are various methods commonly employed to prevent and control corrosion. The choice of method depends on the specific material that needs protection and the environment in which it exists. Some of the most frequently used methods include organic and metallic coatings, cathodic protection, and corrosion inhibitors. These methods find application in closed systems, acid pickling of metals, and even as additives in anti-corrosive paints. One of the most effective ways to prevent corrosion in acid solutions is to prevent metal dissolving and acid consumption by use of inhibitors2. It has been extensively researched in some depth how to use synthetic organic chemicals including oxygen, sulfur, and nitrogen to lessen corrosion attack on steel3. However, these compounds can be costly, hazardous, and difficult to acquire on an industrial scale. The use of inexpensive, powerful substances with little or no environmental damage was the driving force behind the development of "green" or "eco-friendly" technologies in the twenty-first century.

Extracts or essential oils are two examples of green inhibitors that might be used. Different components of plants, such as seeds, leaves, fruits, and flowers, can be processed and employed as corrosion inhibitors. There have been numerous recent studies on the corrosion-inhibiting properties of plant-based natural products, and they have generally demonstrated high levels of inhibition efficiency4. The anti-corrosion activity found in many plant extracts could be attributed to the presence of compounds such as isoprenoids, alkaloids, flavonoids, and others. The existence of organic compounds containing Nitrogen (N), Oxygen (O), Phosphorus (P), and Sulfur (S) atoms, which have a protective effect and potential to inhibit corrosion, is linked to the effectiveness of organic green corrosion inhibitors (OGCIs) in preventing material degradation5. The sequence of corrosion inhibition efficiency for these elements is reported to increase in the following order: oxygen is less efficient than nitrogen, which is less efficient than sulfur, and phosphorus is the most efficient6. Organic green corrosion inhibitors (OGCIs) demonstrate their inhibitory action by either physisorption or chemisorption at the interface between the metal and the solution. This process involves displacing water molecules on the surface to form a dense barrier film7. The formation of a coordinate covalent bond has also been observed, which occurs through the interaction between a lone pair and the π-electrons present in organic green corrosion inhibitors (OGCIs) molecules with the empty d-orbitals of the metal8. The adsorption of compounds on a metal surface is amplified due to the formation of a p-d bond. This occurs when there’s an overlap of π-electrons with the unoccupied 3d orbital of an iron atom9. The presence of N, O, and S atoms, along with their organic structure double bonds, is the reason for this occurrence10. The emphasis on using natural products as inhibitors stems from their properties of being biodegradable, non-toxic, cost-effective, easily accessible, renewable, and environmentally friendly11.

Nitrogen is a key component of alkaloids. It’s well-known that a variety of plants produce different kinds of these compounds12. Studies have been conducted on alkaloids such as papaverine, strychnine, quinine, and nicotine, examining their effectiveness as corrosion inhibitors in an acidic environment13.

The objective of this study is to identify a natural, cost-effective, and eco-friendly substance that can be used to prevent corrosion in steel. The simultaneous achievement of economic and environmental goals is a key consideration. Citrullus colocynthis, a member of the Cucurbitaciae family, is under investigation. This plant, often referred to as the bitter apple or bitter cucumber, is predominantly found in the Sahara deserts, Sudan, and India. The dried pulp of its fruit has been traditionally used as a remedy for various ailments including congestion, colic, constipation, dropsy, fever, worms, sciatica, and scorpion bites14. It has been suggested by numerous researchers that the fruits of colocynthis have properties such as antitumor activity, and antibacterial, and anticandidal effects15. The leaf showed laravacidal activity and antidiabetic activity in humans16 as well, it is packed with a variety of biomolecules, including phenols, fatty acids, glycosides, flavonoids, and alkaloids17. However, its application in inhibiting the corrosion of steel in a 1 M HCl solution has not been previously investigated.

Recent studies have highlighted the use of various plant extracts as eco-friendly corrosion inhibitors. For instance, the bark and leaves alkaloids of Neolamarckia cadamba, were tested in a 1 M HCl medium. The polarization method showed an efficiency of (89%), while the EIS method displayed (83%) efficiency18. Similarly, Rhynchostylus retusa rhizome alkaloids were examined in 1 M H2SO4, achieving (87.51%) efficiency through weight loss measurement and (93.24%) via polarization19. The stem alkaloids of Artemisia vulragis were also tested in 1 M H2SO4, with weight loss and polarization methods yielding efficiencies of (92.58%) and (88.06%) respectively20. Moreover, the whole plant of Geissospermum laeve was subjected to 1 M HCl and showed an efficiency of (92%) through polarization21. The alga alkaloids of Caulerpa racemosa in 1 M HCl demonstrated efficiencies of (83%) in weight loss, (80%) in polarization, and (85%) in EIS22. These studies indicate that plant extracts and their alkaloids can be highly effective as corrosion inhibitors in various acidic mediums.

The objective of this research is to understand the corrosion process of MS in a 1 M HCl environment when alkaloids from the Seed Citrullus Colocynthis plant extract (CSEA) are used as a corrosion inhibitor. The corrosion inhibition mechanism was investigated using polarization curves and electrochemical impedance spectroscopy. The impact of temperature on the electrochemical parameters that define the systems was documented through polarization curves. Additionally, a phytochemical test and gas chromatography-mass spectrometry (GC–MS) were conducted to determine the chemical composition of the Seed Citrullus Colocynthis extract (CSEA).

Experimental

Specimen preparation and solution

Preparation of plant extract

Citrullus colocynthis was collected in Kenitra region in Morocco (Fig. SI1). The plant was identified by Dr Amar Habsaoui (Ibn Tofail University) before being deposited in the herbarium of the university. The plant’s seeds were isolated, cleaned, and oven-dried at 40 °C for 24 h. Following this, an electric grinder was used to pulverize them into a powder with an average particle size of 500 µm.

This extraction was carried out according to Harborne, method17 (Fig. 1). Maceration of 90 g of crushed and degreased colocynth seeds for 16 h under reflux with agitation, using 250 ml of 2% HCl and 110 ml of ethyl acetate. After maceration, the mixture is filteredto collect the filtrate. The acid phase is then treated with NH4OH to adjust the pH to 9.5–10, followed by another filtration to recover the filtrate. This is succeeded by liquid–liquid extraction performed 3 to 4 times with 50 ml of ethyl acetate each, using a separatory funnel until the alkaloids are fully extracted from the aqueous phase. To remove any water present, MgSO4 is added to the organic solvent, followed by filtration. The organic phase is then concentrated to dryness with a rotavapor at a temperature below 40 °C to prevent alkaloid denaturation.

Figure 1
figure 1

Diagram showing the extraction of total alkaloids in an acidic medium according to Harborne, method.

The total alkaloids are obtained in the form of a crystallized dry residue, yellow in color, the concentration range of alkaloids plant extract from CSEA employed was 0.5–2.0 g/L in acidic media.

Tests for the alkaloids: Mayer, Wagner and Dragendorff test

In the present work, the presence of alkaloids in the extract of the studied plant was done by use of the following tests;

  1. I.

    The Mayer test, which is done by use of Potassiomercuric iodide.

  2. II.

    The Wagner test, which is conducted by use of Potassium iodide solution.

  3. III.

    The Dragendorff’s test which is effectuated by use of potassium bismuth iodide.

Analysis of the alkaloid

Derivatization protocol of extracts

Alkaloid extracts are typically made up of compounds basic, which include functions such as alcohols and amines, and contain one or more active hydrogen atoms. As a result, a derivatization reaction is required for their analysis via GC–MS. In this study, acetylation was selected as the derivatization method. This approach facilitates the creation of acetylated derivatives that can be more effectively analyzed using gas chromatography. In this context, an ion with a mass-to-charge ratio (m/z) of 43 appears in the mass spectrum, corresponding to the acetyl group of the acetylated compound14.

The procedure outlined in reference23 was adhered Tobin order to carry out the reaction. The procedure was adhered to in order to carry out the reaction. The technique underwent small modifications in the following manner: A solution was prepared by dissolving 10 mg of the material in 1 mL of acetic anhydride. Four drops of pyridine, acting as a catalyst, were added to this. Subsequently, the combination was subjected to 60 °C heating in a water bath for a duration of 20 min. Following heating, the mixture was let to cool for the duration of the night. The hydrolysis process included the addition of 6 mL of cold water, followed by magnetic stirring for a duration of 2 h in an ice water bath. The products obtained were subjected to extraction using chloroform.

The organic phase was neutralized with a saturated solution of (NaHCO3), dried with (Na2SO4) and then evaporated.

GC–MS analysis

The alkaloids analysis was conducted using a combination of gas chromatography and mass spectrometry at The National Center for Scientific and Technical Research CNRST in Morocco, utilizing the GC TRACE 1300 TSQ 8000 evo apparatus. A Thermo TR-5 MS capillary column (30 m × 0.25 mm × 0.25 μm) was employed for the process. The column temperature was initially set at 60 °C for a duration of 10 min, then increased at a rate of 10 °C/min to 80 °C (held for 2 min), and finally raised at a rate of 5 °C/min to 300 °C (held for 5 min). The injector and ion source temperatures were set at 280 °C and 250 °C respectively. The carrier gas, Helium, had a flow rate of 1 mL/min, and the injection volume was set at 1 μL. Mass spectra were obtained at an electron voltage of 70 eV. The structures of the alkaloids were identified by comparing the resulting mass spectra with those of pure compounds, referencing the apparatus’s mass spectra library (NIST 2017), and consulting relevant literature24.

Corrosion tests

Corrosion experiments were conducted on electrodes that were fashioned from MS sheets. The steel strips were composed of 0.36 wt% C, 0.27 wt% Si, 0.66 wt% Mn, 0.02 wt% S, 0.21 wt% Cr, 0.015 wt% P, 0.06 wt% Al, 0.02 wt% Mo, 0.22 wt% Cu, with the remaining being iron, exposing a working area of 1cm2. The exposed surface was then polished using grinding papers of 180 and 1200 grit sizes, and subsequently cleaned with ethanol and distilled water. The testing solutions (1 M HCl) were prepared by diluting a 37% HCl analytical reagent grade with doubly distilled water.

Electrochemical measurements

The 1 M HCl solution was prepared by diluting 37% HCl of analytical grade from Merck with double distilled water25. Electrochemical tests were performed on mild steel immersed in a solution of 1 M hydrochloric acid. Prior to each test, the experimental solutions were prepared by incorporating the extract into the corrosive medium. To ensure the reliability of the results, each test was conducted three times. The concentrations of the extract used in the experiments ranged from 0.5 to 2 g/L.

A Pyrex glass cell was filled with a 40 mL volume of molar HCl, ensuring complete submersion of all three electrodes. All tests, excluding those investigating temperature effects, were carried out at room temperature without any stirring. A PGZ 100 potentiostat workstation, in conjunction with Voltamaster 4 software, was utilized to conduct electrochemical measurements (EIS and potentiodynamic polarization curves). The corrosion behavior of mild steel in a 1 M HCl solution was studied using EIS and potentiodynamic curves, both in the presence and absence of inhibitors in the solution. The MS working electrode area that was fully submerged in the test solution was left undisturbed for 30 min to reach a stable open circuit potential (EOCP), after which electrochemical measurements were taken.

The potential was scanned from − 800 to − 100 mV vs SCE at a rate of 0.5 mV/s to create Tafel graphs. Linear resistance polarization was ascertained by recording the electrode potential ± 10 mV relative to the open circuit potential, beginning with a less positive possibility. After letting the potential at EOCP stabilize for 30 min, all experiments were conducted. The temperature impacts section of the study used test temperatures between 298 and 328 K. The inhibitive performance ηTafel (%) was computed using a specific Eq. (1).

$$\eta {}_{Tafel} = \, \frac{{\left( {i_{corr}^{0} - i_{corr} } \right)}}{{i_{{_{corr} }}^{{^{0} }} }} \times \, 100.$$
(1)

The corrosion current density is represented by \(i_{corr}^{0}\) without the presence of inhibitory compounds, and by \(i_{corr}\) when these compounds are present26. EIS studies were conducted at the EOCP potential using the previously mentioned workstation, with a 10 mV alternating current signal at 105 to 10–1 Hz.

Nyquist plots were utilized to depict EIS diagrams. These plots were adjusted to model the interface between the metal and the solution using an equivalent electrical circuit, aided by ZiveZman 2.3 software programs. Each concentration of inhibitor was studied electrochemically three times, and the most representative data were selected for graphical depiction27.

The EIS inhibiting performance, denoted as ηEIS, was calculated using a specific Eq. (2):

$${\eta }_{EIS}= \left(\frac{{R}_{p}-{R}_{p}^{0}}{{R}_{p}}\right)\times 100,$$
(2)

where \({R}_{p}\) and \({R}_{p}^{0}\) are the polarization resistance values absent and in the presence of molecules that inhibit polarization, respectively.

Surface analysis

Mild Steel (MS) surface morphology with and without CSEA after being exposed to 1 M HCl for 6 h, was analyzed using a Quantra 450 type scanning electron microscope. This analysis was complemented with EDX technical studies. These assessments were conducted by the CNRST Foundation in Rabat.

DFT details

All computational density functional theory calculations were carried out using the Gaussian W09 software28. Gauss view program24 was used to build up the neutral and protonated form of the 5-Quinolinol (Q1N, Q1P) and N-Acetylcaprolactam (Q2N, Q2P) inhibitors. The protonated atoms were detected using the Marvin Sketch software29. Geometry optimization of all species was performed using the DFT method along with the B3LYP30 method and 6–31 + g(d,p) basis. To meet the corrosion environment, the optimization process was carried out in an aqueous solution using the integral equation formalism polarized continuum model of solvation (IEFPCM)31 (Fig. 2).

Figure 2
figure 2

Schematic representation of the investigated inhibitors.

Harmonic frequency calculation was performed using the same level of theory to confirm that the resulting structure is minimum to potential energy surface with imaginary frequencies. Natural population analysis was used to compute the natural atomic charges by the use of natural bond orbital (NBO analysis)32 as implemented Gaussian 09 program. The highest occupied and lowest unoccupied molecular orbitals (HOMO and LUMO) and their energies, the Mulliken charges, and NPA charges were extracted using the Gauss view program33. Local chemical reactivity descriptors such as condensed Fukui functions and condensed dual descriptors were computed in terms of Fukui Functions using the Multiwfn code in terms of Hirshfeld charges34.

Monte Carlo (MC) and molecular dynamic (MD) simulations

The material studio’s adsorption locator tool was utilized to analyze potential interactions between inhibitor compounds and Fe (110) surface atoms in a hydrochloric acid aqueous corrosion environment (1 inhibitor, 800 water molecules, 10 chloride and 10 hydronium ions). Additionally, a vacuum slab protruding 35 Å from the Fe (110) surface was incorporated into the simulation. The computational protocol involved introducing inhibitor molecules into the cell, along with an aqueous solution containing corrosive species35. Monte Carlo simulations were employed to analyze the solution of the simulated system36. The Adsorption Locator module of Material Studio simulated the impacts of corrosive species, focusing on the uppermost layer of the Fe (110) interface, expected to contain potential sites for inhibitor molecule adsorption37. Various adsorption configurations were systematically investigated. Upon completing the simulations, the equilibrium adsorption configuration with the lowest energy was identified. This analysis played a crucial role in identifying favorable adsorption sites and understanding the energy components associated with the adsorption process. The integration of the Monte Carlo method and the Adsorption Locator tool in Material Studio allowed for a comprehensive examination of potential interactions between inhibitor molecules and Fe (110) surface atoms. The surface of Fe(110) is densely packed; it has a lower surface energy but a higher surface atom coordination number. As a result, this surface was chosen to address the adsorption of 5-Quinolinol largely because it has a greater number of interaction sites with corrosion inhibitor38.

Through a systematic exploration of different adsorption configurations, the equilibrium adsorption configuration, characterized by the least energy, was successfully identified, aligning with prior research findings. To enhance the inhibitory efficacy of inhibitor molecules and understand their preferred adsorption sites, obtaining this vital information was deemed essential. The research focused on the uppermost stratum of the Fe (110) interface due to its particular relevance to inhibitor adsorption. The methodology described facilitated a precise simulation of the adsorption process, incorporating the simulated cell's dimensions and a variety of corrosive species. The study yielded noteworthy results regarding the interaction between the inhibitor and the metallic surface, contributing to the development of corrosion prevention methods. Subsequently, the widely recognized COMPASSII forcefield was applied, and molecular dynamics (MD) simulations were conducted using the Forcite module in Material Studio at a temperature of 298 K. During the MD simulations, all iron atoms (110) were immobilized, except for the two uppermost levels, spanning a simulation duration of 0.800 ns with a time step of 1.0 femtoseconds. To enhance comprehension of the inhibitor molecule's adsorption properties on the metal surface, the radial distribution function (RDF) was computed using MD simulation trajectories39. Monte Carlo calculations were conducted through temperature cycling, ranging from 105 to 102 K over 10 cycles, each consisting of 100,000 steps. This process allowed us to obtain the lowest possible energy configurations at reduced temperatures, employing the same energy convergence criteria and force field as those used in the MD calculation.

IUCN policy statement

The collection of plant material complies with relevant institutional, national, and international guidelines and legislation.

Results and discussion

The corrosion rate of a steel alloy, submerged in a 1 M HCl solution, is assessed using the potentiostatic method. Corrosion inhibitor, in the form of Citrullus Colocynthis seed alkaloid extracts, is added to a battery of tests. The objective is to pinpoint the most effective concentration of this extracted inhibitor. This investigation is conducted under-regulated parameters, when the inhibitor is present and while it is absent. The concentration of HCl and the temperature of the reaction media may be modified. To ascertain the most favorable concentration of inhibitors given the specified parameters, we do comparative analysis of outcomes derived from concentrations spanning from 0.5 to 2 g/L.

Chemical part

Chemical test of alkaloids

A qualitative chemical test was conducted to confirm the extraction of alkaloids from Citrullus Colocynthis seeds. The results of these tests, which involved different reagents, are presented in Table 1.

Table 1 Chemical tests of the CSEA.

GC–MS analysis results

The results of the Alkaloid Extract GC–MS Analysis are depicted in Fig. SI2 and detailed in Table 2. The seeds of Citrullus Colocynthis were determined to possess 85.68% of chemicals that can be directly analyzed, with roughly 62.38% of these compounds being classified as alkaloids. A comprehensive identification of 18 ingredients was conducted, including 7 distinct alkaloids and 11 other chemical compounds that have potential for extraction in an acidic environment. 5-Quinolinol is a member of the quinoline family, which consists of heterocyclic aromatic chemical compounds. In several applications, this molecule has been used as an internal standard for the quantification of morphine content in serum or plasma. The presence of this compound as a significant component in the alkaloid extract derived from the seeds of Citrullus Colocynthis is really intriguing.

Table 2 The chemical makeup of the extracted acetylated alkaloids from Citrullus Colocynthis seed.

Electrochemical studies

Open circuit potential

The variation in the open-circuit electrical potential of mild steel in 1 M HCl in the absence and presence of CSEA at different concentrations, after 30 min immersion is shown in Fig. SI3. For the blank alone, the free potential becomes less and less noble (loss of electrons), anodic dissolution of the metal is easy. The introduction of CSEA inhibitor in the corrosive medium leads the shift of the EOCP towards more negative values, probably due to the adsorption of CSEA on the MS surface , and therefore, the improvement of its corrosion resistance in hydrochloric acid pickling solution. It is, moreover, noteworthy there was no a specific relation between the potential shift of EOCP and inhibitor concentration.

Polarization studies

The same conditions were used to carry out the experiments thrice. The ZiveZman 2.3 software program was utilized to determine the corrosion parameters by analyzing potentiodynamic curves. Figure 3 shows the Tafel graphs of the MS-substrate electrode at various inhibitor doses. Extrapolation characteristics such as anodic slope (a), cathodic slope (c), corrosion potential (Ecorr), and inhibiting performance (%) are listed in detail in Table 3.

Figure 3
figure 3

Tafel plots of MS-substrate in 1 M HCl, both in the absence and presence of varying concentrations of CSEA.

Table 3 The effects of CSEA on MS polarization in 1 M HCl at 298 K.

The cathodic polarization curve of the MS-substrate electrode in a 1 M hydrochloric acid solution exhibits no significant change in slope subsequent to the introduction of CSEA, as seen in the accompanying image. The absence of any impact of the CSEA inhibitor on the corrosion process is shown by the almost parallel cathodic branch seen in the polarization map. Furthermore, in the realm of the anode. There has been a consistent increase in the polarization potential over a period of time, accompanied by the convergence of the curves. The desorption of inhibitors from the electrode surface is likely attributed to the rapid breakdown of the MS-substrate at elevated polarization potential.

Figure 3 demonstrates that the addition of CSEA to the experimental solution results in a deceleration of hydrogen release in the cathodic zone and a deceleration of metal dissolution in the anodic domain. The reduction in corrosion potential leads to a slight shift towards cathodic values. As anticipated, the introduction of inhibitors into the solution results in a deceleration of MS-substrate breakdown40.

The following equations elucidate the steps involved in the cathodic reduction of hydrogen:

$$Fe \, + \, H^{ + } \to \left( {FeH^{ + } } \right)_{ads} ,$$
(3)
$$\left( {FeH^{ + } } \right)_{ads} + \, e^{ - } \to \left( {FeH} \right)_{ads} ,$$
(4)
$$\left( {FeH} \right)_{ads} + \, H^{ + } + e^{ - } \to Fe \, + \, H_{2} .$$
(5)

The following equations detail the steps for the anodic dissolution reaction:

$$Fe + H_{2} O \leftrightarrow FeOH_{ads} + \, H^{ + } + e^{ - } ,$$
(6)
$$FeOH_{ads} \to FeOH^{ + } + e^{ - } ,$$
(7)
$$FeOH^{ + } + \, H^{ + } \to Fe^{2 + } + H_{2} O.$$
(8)

The data shown in Table 3 suggests that the reduced corrosion current density seen in the MS substrate may be ascribed to the inhibitor solution with the greatest concentration, namely 2 g/L. This phenomenon may be well explained by the probability that, at a significant concentration, the surface of steel is enriched with chemicals that serve as corrosion inhibitors41. However, in a 1 M HCl solution without an inhibitor, the corrosion potential (Ecorr) of the MS-substrate electrode is − 498 mV/ECS, but it reaches − 526 mV/SCE when 2 g/L of CSEA is added. The consensus among scholars is that when the change in the magnitude of the corrosion potential exceeds 85 mV, it may serve as a reliable indicator for distinguishing between anodic and cathodic corrosion inhibitors. Otherwise, it is categorized as a mixed type15. In this particular instance, the introduction of the inhibitor CSEA into a 1 M hydrochloric acid (HCl) solution resulted in a displacement of the corrosion potential towards greater negative values in comparison to the absence of the inhibitor.

The achieved displacement range was 85 mV. As a result, CSEA may be classified as a mixed-type inhibitor that controls the cathodic reaction predominately. The study also found that as the concentration of the investigated CSEA compound rose, slight modifications occurred in the anode and cathode Tafel slopes (βc and βa). Furthermore, the corrosion current density transitioned from 983 µA cm–2 (blank) to 56 µA cm-2 for the optimal concentration of CSEA. These findings are associated with inhibitor adsorption on metal surfaces, where a barrier film might lessen the interaction of the active site with corrosive conditions. As demonstrated in Table 3, the inhibiting efficiencies increase with the concentration of the CSEA, achieving a peak performance of 94.3% at 2 g/L.

EIS studies

To comprehend the protection mechanism (diffusion, adsorption, and charge transfer) of MS by the CSEA extract in a 1 M HCl solution, we carried out electrochemical impedance measurements. The aforementioned measures possess the capacity to provide insights into the underlying mechanisms involved in corrosion and other aspects of protective procedures42. The validity of this technique in defining the mode of activity of the inhibitor is often confirmed by electrochemical impedance investigations of the inhibitory mechanism. It allows for monitoring their advancement using different factors and assists in evaluating the dielectric characteristics of the resulting film, as shown in Fig. 4. The EIS (Nyquist) diagrams for MS are shown, excluding the CSEA. According to the findings shown in Fig. 5, it can be noticed that all plots display a single time constant, and the inclusion of CSEA does not have any impact on the semicircular form43.

Figure 4
figure 4

Nyquist plots for the MS at 298 K and 1 M HCl in water with different CSEA concentrations.

Figure 5
figure 5

Bode graphs of MS at 298 K in the presence and absence of CSEA at concentrations ranging from 0 to 10 mol l1 show that the acidity of the solution is mildly decreasing.

This indicates that the process of corrosion remains consistent and the reaction of corrosion is controlled by the transfer of charge. The Nyquist plot also reveals how the widths of the semicircles grow larger with higher inhibitor concentrations.

The Bode graphs shown in Fig. 4 demonstrate the existence of a stable single-phase component at the interface between the metal and solution inside the analogous circuit. According to the Bode plots, the observed increase in absolute impedance at low frequencies suggests that higher doses of inhibitors result in a greater degree of protection44. Furthermore, an alteration in the phase angle displacement and the emergence of a novel phase angle in the upper and medium frequency ranges were seen when the quantity of inhibitors increased. The phenomenon under consideration arises when the steel surface undergoes the formation of an inhibitor layer, hence altering the interface structure of the electrode. Significantly, it is possible to demonstrate a linear relationship between frequency (f) and logarithm (Z) with a slope that is almost equal to − 1. The aforementioned exhibits the customary attributes of a capacitor, therefore confirming the establishment of a meticulously organized CSEA adsorption layer16.

The impedance parameters have been computed, with Rs representing the solution's resistance, Rp denoting the polarization resistance, and CPE representing the constant phase element. A capacitor has been substituted with a CPE in order to enhance the accuracy of the impedance semicircle data. The formation of a double layer on the metal surface via the inhibitory of adsorption may occasionally exhibit features that are more indicative of a CPE rather than a pure capacitor. The formula supplied45 represents the impedance function of the CPE.

$$ZCPE \, = \, \left[ {Q\left( {j\omega } \right)^{ndl} } \right]^{ - 1} ,$$
(9)

where Q represents the magnitude of the CPE. J Is an imaginary number with the value (j2 =  − 1). ω: the angular frequency.

The different parameter deviation, termed as ndl (where − 1 ≤ ndl ≤  + 1), embodies the concept of a phase shift.

When ndl = 0, it signifies that the CPE represents a pure resistor. For ndl =  − 1, it acts as an inductor and for ndl =  + 1, it behaves like a pure capacitor46.

Simultaneously, the double layer capacitance, Cdl, for a circuit with a CPE was calculated using the following equation provided47.

$$Z_{CPE} = Q^{ - 1} (i\omega )^{{ - n_{dl} }} .$$
(10)

In this case, the largest value of the imaginary component of the impedance spectrum occurs at a frequency fmax, where ωmax = 2fmax. Table 4 displays the calculated impedance parameters. The following conclusions can be drawn from the data.

Table 4 EIS outcomes for the MS/1 M HCl system before and after adding CSEA.

Table 4 demonstrates that the n values are higher in the presence of CSEA compared to the blank, indicating that the presence of a green inhibitor reduces surface inhomogeneity. This phenomenon is shown by the formation of a protective coating on the surface of the steel.

However, due to the adsorption of CSEA molecules, n values change as inhibitor concentration increases. This suggests that CSEA molecules interact with steel morphology, gradually replacing H2O molecules at the steel/solution interface with CSEA compounds.

Furthermore, as inhibitor concentration increases, Rp values increase while Cdl values decrease. This is attributed to enhanced coverage of the MS surface by inhibitor molecules, resulting in a decrease in corrosion rate. The increase in the thickness of the double layer with the rise in CSEA concentration is also associated with the decrease in the value of Cdl. This relationship can be adequately explained by the given equation48.

$$C_{dl} = \left( {\frac{{\varepsilon_{0} \varepsilon }}{d}} \right) \times S.$$
(11)

In this context, ε0 is the permittivity of the area, ε is the local dielectric constant, d is the film thickness, and S is the area morphology. According to the equation, Cdl is directly proportional to ε and inversely proportional to d. As various water molecules are replaced, the local dielectric constant decreases, leading to a reduction in the Cdl value. This is due to the replacement of water molecules (which have a higher ε value) by inhibitor molecules (which have a lower ε value). Furthermore, an increase in CSEA concentration leads to an observed increase in the thickness (d) of the electric double layer. This also significantly contributes to the decrease in the Cdl value49. As the concentration of the inhibitor increases CSEA, the inhibition efficiency (ƞimp%) also increases, reaching a maximum value of 93.6% at a concentration of 2 g/L.

Adsorption isotherms and thermodynamics

Isotherm plots reveal details regarding the inhibitor's adsorption onto the metal surface. Partial surface coverage data (θ) and inhibitor concentration need to be plotted on a line in order to determine the type of isotherm. Using EIS, the values of can be determined by dividing the ηEIS% by 100 (as displayed in Table 4).

In order to empirically find the most suitable isotherm for the adsorption of inhibitors on the surface of the MS-substrate, several adsorption isotherm models, namely Langmuir, Frumkin, Freundlich, and Temkin, have been investigated. The Langmuir isotherm was found to be the most suitable model for describing the adsorption behavior of the molecules under investigation, as shown by Eq. (12).

$$\frac{\theta }{1 - \theta } = K_{ads} \times C_{inh} .$$
(12)

It can be approximated as:

$$\frac{{C_{inh} }}{\theta } = \frac{1}{{K_{ads} }} + C_{inh} .$$
(13)

In this context, Kads refers to the equilibrium constant adsorption and Cinhib represents the molar concentration of the molecule inhibiting. The plot of Cinhib/θ versus Cinhib exhibits a linear shape, as depicted in Fig. 6.

Figure 6
figure 6

CSEA adsorption on an MS-substrate in 1 M HCl: an adsorption isotherm.

The free energy of adsorption (ΔGads) may be determined with the use of Eq. (14) and the adsorption constant (Kads). In this equation, the value 1000 represents the concentration of water in solution in g/L50:

$$\frac{1}{{K_{ads} }} = \frac{1}{1000}\exp \,\left( {\frac{{ - \Delta G_{ads}^{{}} }}{RT}} \right).$$
(14)

Or:

$$\Delta {G}_{ads}^{0}=-RTLn\left(1000\times {K}_{ads}\right).$$
(15)

Figure 9 demonstrates the straight line that results from the relationship between \({\raise0.7ex\hbox{${C_{inh} }$} \!\mathord{\left/ {\vphantom {{C_{inh} } \theta }}\right.\kern-0pt} \!\lower0.7ex\hbox{$\theta $}}\) and Cinh at 298 K, with a correlation coefficient R2 that is nearly equivalent to one \(\approx\) 0.9999 and a slope that is equal to unity. Furthermore, Strong relationship between the adsorbate and the surface is indicated by a high Kads value (Table 5). The observed phenomenon indicates that the adsorption of CSEA on a surface composed of mild metals adheres to the Langmuir adsorption isotherm. Moreover, it is crucial to emphasize that due to the lack of knowledge regarding the molecular masses of the constituents in the extract, it is not feasible to characterize the behavior of the adsorption isotherm when employing natural product extracts as inhibitors based on the conventional free energy of adsorption quantity50

Table 5 In molar hydrochloric acid with and without CSEA at 298 K, the values of the MS-substrate's adsorption Langmuir parameters were measured.

Corrosion activation parameters and temperature effects

The reaction of the steel electrode in the acid medium can be altered by temperature, in the presence and absence of the inhibitors being used49. Investigating the impact of temperature on the rate of corrosion is beneficial for determining the kinetic and thermodynamic parameters of the adsorption process. These parameters are extremely useful in understanding the nature of the adsorption that is taking place51. The impact of temperature on the inhibitor's performance was investigated by the analysis of potentiodynamic curves of Mild Steel (MS) in molar hydrochloric acid. This investigation was carried out under two conditions: with and without the ideal inhibitor concentration of 2 g/L (Fig. 7). The curves shown in Fig. 8 were graphed throughout a temperature range spanning from 298 ± 2 to 328 ± 2 K. The related data is presented in Table 6.

Figure 7
figure 7

The addition of 2 g/L of CSEA at 298–328 K altered the Tafel plots of MS-substrate in molar hydrochloric acid.

Figure 8
figure 8

Comparison of the Arrhenius curves (a) and transition state (b) for mild steel in molar hydrochloric acid at 298–328 K with and without 2 g L–1 CSEA.

Table 6 The optimum concentration of CSEA (2 g/L) in solution and its effect on the MS-substrate potentiodynamic polarization parameters in molar hydrochloric acid.

Based on the Tafel plots acquired in an acidic environment, it was noted that an elevation in temperature led to a concomitant augmentation in the corrosion current (icorr), irrespective of the presence or absence of inhibitory molecules. The rise was most evident at a temperature of 328 K.

Furthermore, slight differences were observed in the anodic and cathodic branches of all Tafel plots. It was inferred from these observations that the rate of corrosion increased with rising temperature in a 1 M HCl solution, irrespective of whether inhibitors were present or not. Consequently, the performance of the inhibitor decreased with increasing temperature. This can be attributed to a decline in the adsorption capacity of the inhibiting compound at elevated temperatures.

In this segment of our research, we observed an Arrhenius-type relationship between the corrosion rate and temperature. This allowed us to calculate the activation energy values for the corrosion process (Ea) at various temperatures. We did this both in the absence and presence of CSEA, according to the given relationship40:

$$i_{corr} = \, Ae^{( - Ea/RT)} ,$$
(16)

Using the transition state equation, we calculated the enthalpy (ΔHa) and entropy (ΔSa) of the corrosion process17:

$$ln\left( {i_{corr} /T} \right) \, = \, \left[ { \, ln\left( {R/hN_{a} } \right) \, + \, \left( {\Delta S_{a} /R} \right) \, } \right] \, {-} \, \Delta Ha/RT,$$
(17)

Corrosion rate (icorr), gas constant (R), Avogadro number (N), pre-exponential factor (h), and Planck constant (h).

By plotting ln (icorr) against 1/T, as shown in Fig. 8a, we can calculate the activation energy for metal dissolution both with and without 1 mM of CSEA. This is done by determining the slope of the line, which is equal to -Ea/RT. Furthermore, Fig. 8b shows a plot of ln (icorr/T) versus 1/T. The slope and intercept of this plot allow us to calculate the values of ΔHa and ΔSa52.

The activation data, calculated according to the Arrhenius and transition state plots, are displayed in Table 7. The activation energy values obtained for the solutions containing inhibitors were seen to be greater than those for the solutions without inhibitors, as shown in Table 7. The blank solution exhibited an activation energy value of 21.0 kJ/mol, but the solution containing inhibitors had an activation energy value of 46.7 kJ/mol at a concentration of 2 g/L.

Table 7 Different factors CSEA 2.0 g L–1 activates corrosion of mild steel in 1 M HCl acid media, both alone and in combination with no CSEA.

Upon closer examination of these parameters, it’s clear that the activation energy increases in the presence of CSEA. According to reference53, it may be inferred that the CSEA inhibitor creates a slender barrier layer that effectively hinders the corrosion process. Undoubtedly, it is well acknowledged that the rise in activation energy seen when an inhibitor is present, in contrast to a blank medium, may be ascribed to the electrostatic attraction existing between the metal and the inhibitor. The phenomenon of attraction results in the formation of a protective coating on the surface of the metal, therefore impeding the rate of corrosion54. The dissolution of the MS-substrate has an endothermic nature, as shown by the positive enthalpy value. Conversely, all activation energy (Ea) values are greater than their corresponding enthalpy analogs (ΔHa).

The reduction of proton (H+) is the result of a gaseous reaction involved in the corrosion process, which is indicated by this. When ΔSa takes on negative numbers, it means that the disorder is decreasing. The rate of a reaction is determined by the time it takes for the reagents to transfer to the activated complex and for the activated complex to form an association.

SEM observation

Scanning electron microscopy (SEM) images were captured to examine the interaction between CSEA and the surface of steel. Figure 9a depicts the bare steel surface without CSEA, while Fig. 9b shows the steel surface in the presence of 2 g/L of CSEA.

Figure 9
figure 9

SEM and EDX micrographs of MS (a) after immersion in 1 M HCl without CSEA, (b) after immersion in 1 M HCl solution containing 2 g/L of CSEA.

In Fig. 9a, the steel specimen exhibits a rough texture and a significant degree of porosity, suggesting a quick occurrence of corrosion in the absence of CSEA. Nevertheless, the presence of CSEA, as seen in Fig. 9b, results in a smooth appearance of the specimen. This is attributed to the creation of a protective layer by the components of CSEA. These findings indicate that CSEA hinders the process of iron dissolving, thereby decreasing the rate of corrosion of steel when exposed to a 1 M HCl solution.

Energy-Dispersive X-ray (EDX) spectra were used to identify the elements present on the metal surface before and after exposure to the inhibitor solution. Figure 9a presents the EDX spectrum for a specimen in a 1 M HCl solution, showing characteristic peaks for elements found in a MS-sample. Notably, peaks for oxygen and an additional line indicating the presence of Cl on the surface were detected.

However, when CSEA is present, the EDX spectrum reveals additional peaks for nitrogen and carbon, which are indicative of adsorbed extract species, as shown in Fig. 9b. Furthermore, the signals for O and Cl are significantly reduced. These data show the adsorption of alkaloid molecules on the surface of the steel.

DFT results

In this section, the analysis of the DFT study will be discussed according to frontier molecular orbitals (FMO), including the electron density distribution of the highest occupied and lowest unoccupied molecular orbitals (HOMO and LUMO). Features such as electrophilicity, hardness, softness, the difference between the HOMO and LUMO energies (EHOMO and ELUMO), the proportion of electron transfer, and the exchange energy of donation and return donation are all factors to consider (Fig. SI4).

Frontier molecular orbitals (FMO) and electrostatic potential maps

The optimized molecular structures, the electron distribution of the HOMO and LUMO surfaces, and the electrostatic potential maps, as well as the energy gap diagrams of the investigated neutral inhibitors and their protonated form are shown in Fig. 10. In both forms, the highest occupied molecular orbital (HOMO) and lowest unoccupied molecular orbital (LUMO) include a significant portion of the inhibitors under investigation. This observation indicates the inhibitors' propensity to give and take electrons to and from the metal surface via several active centers. The plotting of the ESP maps, shown in Fig. 10, illustrates the presence of electron-rich areas (red color) and electron-poor regions (blue color), corresponding to electrophilic and nucleophilic assaults, respectively.

Figure 10
figure 10

3D-isosurfaces (isovalue = 0.02) of the electron distribution of the HOMO and LUMO and the energy gap diagrams for inhibitors 2 and 3 in their forms in left: neutral forms and in right: protonated forms. Blue loops correspond to the positive electron density distribution and the yellow loops correspond to the negative electron density distribution.

Furthermore, these results can be well illustrated by plotting the total density at both HOMO and LUMO surfaces (TD-HOMO and TD-LUMO), see Fig. SI1 (supplementary provided).

The energies of HOMO, LUMO and energy gaps

In order to establish a very useful correlation between the molecular structure of the investigated inhibitors and their corrosion inhibition efficacy, the quantum chemical calculations were calculated and discussed. In reliable with Fukui’s theory, transition of electron is due to the interaction between HOMO and LUMO. The higher values of EH and the lower values of EL tend the molecule to denote and accept electrons to and from the surface, respectively35,36,37,38,39,40,41. According to our results it can be deduced that the corrosion inhibition efficiency of the neutral and protonated forms of Q1 inhibitor molecule is higher that of Q2 inhibitor molecule. The results show also that the energy gaps of the neural forms are less than those of the protonated ones, illustrating that the probed inhibitors in their neutral forms have higher efficiencies to protect the metal surface than the protonated forms (Figs. SI5 and SI6).

One of the most useful global quantum chemical descriptors as a function of reactivity of the inhibitor molecule towards the adsorption on the metal surface is the energy gap, which measures the difference between EH and EL of the inhibitor (ΔE = EL–EH)42,43,44,46. The lower the ΔE value the stronger interaction between HOMO and LUMO, the higher chemical reactivity and the lower kinetic stability. According to our results, the corrosion inhibition efficacy of Q1 inhibitor molecule is higher than that of Q2 one. It is also found that the neutral forms are chemical more reactive the protonated form (see Table SD1).

The metal-inhibitor energy interactions can be investigated in terms of the energy gaps between the HOMO and LUMO values of the inhibitors and the metal surface (\(\Delta {{\varvec{E}}}_{1}={E}_{L}-{E}_{H}^{Fe}\) and \(\Delta {{\varvec{E}}}_{2}={E}_{L}^{Fe}-{E}_{H}\))47,48,49. The \({E}_{H}^{Fe}\text{and }{E}_{L}^{Fe}\) are the HOMO and LUMO energies of the Fe, which are taken to be − 7.9024 and − 0.151 eV, respectively. The results of \(\Delta {{\varvec{E}}}_{1}\) and \(\Delta {{\varvec{E}}}_{2}\), together with the energy gap (ΔE) are graphically shown in Fig. SI5. General inspection of Fig. SI6 and Table 8 indicates that ΔE1 and ΔE2 of Q1N (6.111 and 6.062 eV) are less than those of Q2N (6.458 and 7.093 eV), signifying that the electron flow of electrons from HOMO of the metal to the LUMO of the inhibitor is energetically favored compared to reverse process. In contrast, electrons flow from the protonated inhibitor molecule to the unoccupied 3d orbitals of the metal is energetically favored39,40.

Table 8 Global quantum reactivity descriptors.

The EH and EL were used to calculated the most representative global chemical reactivity such as ionization potential (I = − EH), electron affinity (A = − EL), energy gap (ΔE = EL–EH), absolute electronegativity (χ = (I + A)/2), global hardness (η = (I–A)/2), softness (σ = 1/η), electrophilicity (ω = χ2/2η), nucleophilicity (ε = 1/ω)and energy change of donation and back-donation (ΔEb–d)41,42,43,46. Inspection of Table 8 shows that the investigated neutral inhibitor Q1N and its protonated form Q1P are characterized by low electronegativity, hardness and nucleophilicity values and high softness and electrophilicity values compared to the Q2N inhibitor and its protonated form Q2P. These results confirm that the inhibition corrosion efficiency of the Q1N inhibitor and its protonated form is higher than that of the Q2N and its protonated form.

In case the inhibitor and the metal surface come closer to each other, electrons flow from the lower χ (inhibitor) to higher χ (metal) until reaching equilibrium (χFe = χinh). Therefore, the number of electron transfer to or from the Fe (110) plan is given by ΔN110 as follow:

$$\Delta {N}_{110}=\frac{{\phi }_{Fe}-{\chi }_{inh}}{2({\eta }_{Fe}+{\eta }_{inh})}.$$
(19)

In the above equation, χinh denotes the electronegativities of inhibitor, ηFe and ηinh are the chemical hardness of Fe metal and inhibitor, respectively, and \({\phi }_{Fe}\) is the work function of Fe110 plan and is given as 4.82 eV. Using of work function is specific for each F plan, where each plan has its own work function. On the other hand, according to Hard and Soft Acids and Bases (HSAB), the fraction of electron transferred (ΔN) was calculated for iron metal, without considering the Fe plans. For this purpose, the χFe was taken to be 7.0 eV. In both cases, the global hardness of ηFe = 0 eV was taken, by assuming that or a metallic bulk I = A because they are softer than the neutral metallic atoms. Previous studies showed that the positive value of \(\Delta {N}_{110}\) indicates that the inhibitors act as an electron acceptor (Lewis acid), while a negative number indicates that the inhibitors act as electron donors (Lewis base). Therefore, the inhibition efficiency of the inhibitors increases with increasing the negative number of \(\Delta {N}_{110}\). Lukovits et al.49 proposed that if ΔN < 3.6, the molecule acts as a good inhibitor and its inhibition efficiency increases with increasing electron donating ability at the metal surface. In this study, it is found that the \(\Delta {N}_{110}\) < 3.6 for all species, indicating the tendency to act as good inhibitors.

Following up the global chemical reactivity descriptors strongly suggests that both inhibitors can act as good inhibitors, and the inhibition efficiency of Q1 inhibitor in its two forms is higher than that of Q2.

Local reactivity indices

The natural atomic charges (NAC) as computed by natural population analysis (NPA) of the neutral form of the investigated inhibitors are summarized in Tables 9 and SD1. For Q1N inhibitor, the most negative atoms are O2, N9, and C4, which are able to donate electrons to the metallic surface. Whereas, the most positive atoms are C1, C5 and C11, respectively, which are responsible to accept electrons from the metal. For Q2N inhibitor, the most positive atoms are, C7, C2 and C5, respectively, and the most negative atoms are C1, O3 and O9, respectively. These results are consistent with obtained by visualizing the HOMO and LUMO surface and ESP maps.

Table 9 Natural atomic charges in elementary charges, NC, Hirshfeld charges for N, N + 1 and N–1 electron systems (\({Q}_{A}^{N}\), \({Q}_{A}^{N+1}\), and \({Q}_{A}^{N-1}\)) in elementary charge, “e”, condensed Fukui functions and condensed dual descriptors (\({f}_{A}^{-}\), \({f}_{A}^{+}\) and \({f}_{A}^{2}\)) in elementary charge, “e”), of Q1 and Q2 inhibitors in their neutral forms (Q1N and Q2N).

Fukui functions

The Fukui functions were used to ascertain the local reactivity descriptors linked to electron density. These functions provided an estimate of the locations responsible for nucleophilic and electrophilic attack centers on the inhibitors under investigation in their neutral state33. Figure SI7 displays the three-dimensional is surfaces of Fukui functions pertaining to electrophilic, nucleophilic assaults, and dual Fukui functions.

The results of Fukui functions confirm those represented by visualizing the FMOs. In this case, it is observed the electrophilic attacks centers simulate the results obtained by electron density distribution of HOMO (\({f}^{-}\left(r\right)\approx {\rho }_{HOMO})\), while the electrophilic attacks centers simulate the results obtained by electron density distribution of LUMO (\({f}^{+}\left(r\right)\approx {\rho }_{LUMO})\). The results of the dual Fukui function accumulate the results obtained by \({f}^{+}\left(r\right)\) and \({f}^{-}\left(r\right)\) in one map.

The condensed Fukui indices for nucleophilic (\({f}_{A}^{+}\)) and electrophilic (\({f}_{A}^{-}\)) attacks and the condensed dual Fukui index (\({f}_{A}^{2}\)) on a atom are defined using the following equations49,50,51:

$${f}_{A}^{+}={q}_{N}^{A}-{q}_{N+1}^{A},{f}_{A}^{-}={q}_{N-1}^{A}-{q}_{N}^{A},\text{ and}{ \Delta f}_{A}= {f}_{A}^{2}={f}_{A}^{+}-{f}_{A}^{-}.$$
(20)

In the above equations, \({q}_{N}^{A}, {q}_{N+1}^{A} and {q}_{N-1}^{A}\) are the Hirshfeld charges over the A atom in the N (neutral), N + 1 (anion) and N-1 (cation) electron systems, respectively. The \(\Delta f\left(r\right)\) is considered as the most accurate representation for, simultaneously, both nucleophilic and electrophilic attack centers. The results of the local reactivity indices of the neutral inhibitors (Q1 and Q2N) are summarized in Table 9, while those of the protonated forms Q1P and Q2P are listed in Table SD1 (supplementary provided). For the Q1N inhibitor, it is found that the most sites that are responsible for electrophilic attacks (\({f}_{A}^{-}\)) are C8, O2 and C1, respectively. Whereas, the sites that most favorable for the nucleophilic attacks are C6, N9 and C11, respectively. In addition, the condensed dual Fukui indices indicate that the most responsible sites for electrophilic attacks (\({f}_{A}^{2}\)<0) are C8, O2 and C4, while those that are responsible for nucleophilic attacks with \({f}_{A}^{2}\)>0 are C6, C11 and N9. Similarly, for Q2N inhibitor, our results show that the most active sites that are responsible for electrophilic attacks (\({f}_{A}^{-}\)) are O3, N4 and O9, respectively. Whereas, the favorite sites for the nucleophilic attacks (\({f}_{A}^{+}\)) O9, C7 and O3. Furthermore, the condensed dual Fukui indices indicates that the most favorite sites for electrophilic attacks (\({f}_{A}^{2}\)<0) are N4, O3 and C5, while the most favorite sites for the nucleophilic attacks with \({f}_{A}^{2}\)>0 are C7, O9 and C2. The same results can be also followed for the protonated forms of the investigated inhibitors as shown in Table SD1 (supplementary provided).

Monte Carlo and Molecular dynamic simulations results

The determination of the adsorption energy for a molecule interacting with the Fe(110) surface involves the application of the following equation, denoted by the symbol "Eads."35,40. This equation serves as a tool for quantifying the energy associated with the adsorption process, providing valuable insights into the strength and stability of the molecular interaction on the Fe(110) surface28. By utilizing this equation, one can assess the degree to which a molecule is bound to the surface, offering a quantitative measure of the affinity between the adsorbate and the Fe(110) substrate:

$${E}_{adsorption}={E}_{Fe{\left(110\right)}_{||}inhibitor }-\left({Fe}_{\left(110\right)}+{E}_{inhibitor}\right),$$
(21)

where \({E}_{Fe{\left(110\right)}_{||}inhibitor}\) is the total energy of the simulated system, EFe, and \({E}_{inhibitor}\) is the total energy of the Fe(110) surface and the corresponding free inhibitor molecules.

Following the completion of the Monte Carlo (MC) calculations, an exhaustive analysis was undertaken to scrutinize the adsorption geometry of the inhibitor, aiming to corroborate the outcomes obtained through experimental methods41,42,43,46. In the MC simulation, the equilibrium state was determined by comparing steady-state energy values with initial energy values. The system eventually stabilized in a state of minimal energy, achieved at equidistant intervals throughout the simulation period41,42,43. The components utilized to replicate the corrosive environment are depicted in Fig. 11, showcasing the actual configuration of the adsorbed inhibitor on the simulated Fe(110) plane. The Fe(110) surface featured an array of inhibitors that maintained a nearly parallel orientation during the course of molecular dynamics (MD) simulations, as illustrated46. This meticulous examination not only verified the robustness of the experimental findings but also provided valuable insights into the dynamic behavior and stability of the adsorbed inhibitor under varying conditions.

Figure 11
figure 11

Lowest energy geometries obtained from MC and MD calculations for the inhibitors in the study.

Figure SI7a illustrates that the presence of heteroatoms (O and N) significantly affects the adsorption pattern on the Fe(110) plane. This leads to interactions between the backbone of the inhibitor molecule and the surface atoms. The complex adsorption behavior seen may be attributed to the molecule's intrinsic inclination to leave its electron-rich rings and heteroatoms exposed on the surface. This leads to a dynamic interaction between the inhibitor and the Fe(110) substrate41,42,43,46. The involvement of these electron-filled structural components is crucial in promoting a stable and advantageous adsorption arrangement, demonstrating the complex molecular-level interactions at the interface between the inhibitor and the metal surface41,42.

The outcomes of employing Monte Carlo (MC) computations to elucidate the distribution of adsorption energies (Eads) for the inhibitors utilized in the simulated corrosion environment are visually presented in Fig. SI7a. The inhibitor exhibits a notably high degree of adsorption to the metal surface, signified by its elevated Eads values46. This intensive interaction results in the formation of a protective layer on the metal surface, effectively acting as a barrier to impede further corrosion14. For a more nuanced understanding of the adsorption dynamics, molecular dynamics (MD) simulations, acknowledged as a superior method, provide a comprehensive representation. As illustrated in Fig. SI7b, following several hundred picoseconds of NVT simulation, the inhibitors undergo a structural transformation, adopting a more planar configuration with the molecular ring securely adhering to the Fe surface. To delve deeper into the adsorption mechanisms of corrosion inhibitors on metal surfaces, a critical analysis of the radial distribution function (RDF) derived from the MD trajectory generated during corrosion simulations becomes imperative. This analytical approach ensures a thorough exploration of the spatial arrangement and intermolecular interactions governing the adsorption process, offering valuable insights into the protective capabilities of the inhibitors on the metal surface46.

The radial distribution function (RDF) characterizing the distribution of oxygen within the inhibitors on the Fe(110) surface was derived through a meticulous analysis of the molecular dynamics (MD) trajectory, as depicted in Fig. SI7b. This analytical approach provides a comprehensive depiction of the spatial arrangement and intermolecular interactions governing the adsorption process42. An insightful interpretation of the RDF graph allows for the accurate prediction of the adsorption process by identifying peaks at specific distances from the metal surface. Peaks emerging beyond 3.5 units from the surface suggest physical adsorption processes47, while peaks within the 1 to 3.5 Angstrom range are indicative of chemisorption processes. The RDF analysis revealed prominent peaks at distances below 3.5 Angstrom for the oxygen and nitrogen atoms present on the Fe surface, as illustrated in Fig. SI7b.

The presence of these observed RDF peaks, together with the simultaneous occurrence of significant negative energy values, provides strong evidence for a strong chemisorption-type interaction between the metal surface and the inhibitor. This finding provides evidence for the concept of a significant and enduring connection between the oxygen-containing constituents of the inhibitors and the Fe(110) surface, highlighting the efficacy of the inhibitors in creating a chemically resilient protective coating on the metal surface.

Inhibition mechanism

The bibliographic data confirms that the corrosion inhibition mechanism in acidic conditions is thoroughly established. The text explains that the inhibitor molecule can be adsorbed onto the metal surface through four different types of adsorptions: (1) electrostatic attraction between charged molecules and the charged metal; (2) interaction between unshared electron pairs in the molecule and the metal; (3) interaction between π-electrons and the metal; and (4) a combination of the aforementioned types. In order for the physical adsorption process to occur in an acidic environment, two conditions must be met: there must be a metal surface with empty electron orbitals, and there must be charged species in the solution, such as molecules with loosely attached electrons or heteroatoms with a lone pair of electrons (Fig. SI8).

The 5-Quinolinol molecules that has been adsorbed may build a stronger connection with the metal surface by creating coordinate covalent bonds with the electron pairs of the N atoms in the aromatic rings. The charged oxygen atoms of the 5-Quinolinol moieties further enhance the adsorption capacity. These interactions result in the creation of a protective layer (with a high value of the adsorption energy) on the surface of metal. This layer decreases the rate of corrosion, as shown by the experimental findings. The organic coating that is created serves as a physical barrier, effectively blocking corrosive substances from accessing the metal surface.

Conclusions

Citrullus colocynthis seeds alkaloid-rich extract exhibited promising inhibition properties versus the corrosion of mild steel in 1 M HCl solutions at 298 K. Importantly, the theoretical findings such as DFT, Monte Carlo and molecular dynamics simulations affirmed the experimental results. The observed outcomes not only shed light on the subject of corrosion inhibition but also have the potential to act as a catalyst, inspiring further exploration and investigation within this domain. The confirmation of a stable adsorption geometry and the formation of a protective barrier contribute valuable insights to the field, providing a foundation for future studies aimed at advancing corrosion prevention strategies and materials.