Introduction

Water is an indispensable resource for sustaining life and it holds a crucial position in the socioeconomic advancement of countries, at both the local and national levels. In North Africa, where water scarcity is a major issue, the role of water in economic development is even more critical. However, the efficient management of this resource cannot be achieved without a comprehensive understanding of all the factors that govern its spatial and temporal evolution (Brahmi et al. 2021; Kallel et al. 2018).

Therefore, it is imperative to gather and analyze data related to water usage, availability and distribution, as well as monitor and anticipate changes in climate patterns that affect water supply. By thoroughly understanding this precious resource's complexities, policymakers and stakeholders can develop effective strategies to ensure its sustainable use and support socioeconomic development, particularly in arid environments (Pasha et al. 2023; Thabit et al. 2023).

Water is a fundamental component of sustainable development, as it plays an essential role in the functioning of any ecosystem. Its absence would render life impossible, making it a critical factor in any socioeconomic activity, dating back to the earliest human civilizations. However, in regions with arid or semiarid climates, such as Algeria, meeting the ever-increasing demands for domestic, agricultural and industrial water needs has become increasingly challenging due to population growth and the inadequacy of water supply (UNESCO 2023).

Furthermore, the excessive exploitation of natural resources, coupled with the intensification of human activities, has resulted in severe degradation of groundwater quality (Amadou et al. 2014). This has led to a decline in safe and clean water availability, thereby threatening human health and impeding socioeconomic development.

Therefore, it is crucial to adopt an integrated approach to water management in Algeria that considers the ecological, social and economic dimensions of the problem. This includes the implementation of sustainable practices in water use and allocation, as well as the development of policies and regulations that promote the protection of water resources and the preservation of their quality. Adopting a scientifically sound and holistic approach makes it possible to ensure the sustainable use of water resources in Algeria and support its socioeconomic development (Besser et al. 2021).

The quality of groundwater is determined by multiple factors, including the chemistry of infiltrating water, the geological characteristics of the aquifer, the nature of the casing, recharge and circulation regions, and anthropogenic activities (Frape et al. 1984). Among these factors, the dissolution of aquifer minerals in water is the primary process that controls the chemical composition of groundwater.

The hydrochemical processes that occur within the hydrogeological system include dissolution, precipitation and base exchange, and are responsible for the acquisition of water quality. These processes depend on the groundwater’s residence time, which controls the evolution of its chemical composition (Apodaca et al. 2002).

It is worth noting that human activities, such as the use of fertilizers and pesticides, and improper waste disposal, can significantly impact groundwater quality. These activities introduce pollutants and contaminants that can alter the natural chemical composition of groundwater and compromise its quality. Therefore, it is essential to adopt sustainable practices in land use and management, including the use of environmentally friendly farming practices and proper waste disposal systems, to preserve groundwater quality.

Furthermore, the management of groundwater resources must take into account the complex hydrological and hydrochemical processes that influence water quality. This requires a scientific approach incorporating advanced monitoring techniques and modeling tools to assess groundwater quality and identify potential sources of contamination. By adopting a scientifically sound approach and implementing sustainable practices, it is possible to protect and preserve the quality of groundwater resources, ensuring their sustainable use for future generations.

Numerous techniques have been developed and utilized by researchers to study and characterize the spatiotemporal variation of groundwater physicochemical parameters, including multivariate statistics, geochemical modeling and water quality index (Barkat et al. 2021, 2022, 2023; Bouteraa et al. 2019; Chabour et al. 2021; Chen and Feng 2013; Foued et al. 2017; Hamed et al. 2022; Lekrine et al. 2023; Mohamadi et al. 2021; Derdour et al. 2023).

The primary objectives of the present study are to identify the chemical facies of groundwater, assess their drinkability and suitability for irrigation and determine the dominant geochemical processes and factors controlling the hydrogeochemical characteristics of groundwater in the region of Ain Sefra, located in the heart of the Ksour Mountains in Western Algeria.

The use of various statistical and modeling techniques, such as principal component analysis (PCA), cluster analysis and PHREEQC modeling, will be employed to identify the different geochemical processes that influence the physicochemical properties of groundwater. Additionally, water quality indices, such as the drinking water quality index (DWQI) and the irrigation water quality index (IWQI), will be calculated to assess the drinkability and suitability of groundwater for irrigation purposes.

The study of groundwater quality and its suitability for various uses is critical, especially in arid and semiarid regions like Ain Sefra, where groundwater is a primary source of water for domestic and agricultural purposes. The findings of this study will provide useful information for policymakers and water resource managers to develop appropriate measures to protect and manage groundwater resources sustainably.

Study area

The study area is located in southwestern Algeria, more precisely 30 km south of the city of Naâma and is part of the district of Ain Sefra. The latter is an integral part of the Atlas domain, precisely, in the Ksour Mountains, which constitute the western part of the Saharan Atlas (Fig. 1). In UTM coordinates, its boundaries are 681,740 to the west, 769,145 to the east, 3,610,150 to the south and 3,664,120 to the north.

Fig. 1
figure 1

Geological map (Galmier 1972) and cross section of the Ain Sefra region (Rahmani et al. 2017)

The region is characterized by a set of mountain ranges (anticlines), some of which are over 2000 m high, such as Jebel Aïssa (2236 m), which relay to form a topographic and climatic barrier between northern Algeria and the Saharan domain. These elongated mountain ranges, generally SW-NE, are separated by numerous synclines. In the studied area, we note mainly two depressions having a SW-NE orientation parallel to the direction of the Atlasic folds: The first is that of Belhandjir-Aïn Séfra-Tiout and the second is the basin of Garet El Kheil which corresponds to the southern part of the great depression of Tirkount.

The Ain Sefra region experiences a semiarid to arid climate with a strong desert influence, resulting in irregular rainfall patterns from year to year. Rainfall typically occurs between October and May, with an average annual rainfall of around 183mm and an average annual temperature of approximately 17.5 °C.

The Ain Sefra watershed is part of the larger Oued Namous watershed, which empties into the western erg. The basin is bordered to the north and south by mountain ranges characterized by Mesozoic deposits, particularly the Jurassic formations. The region is home to several major wadis, including Wadi Breidj, Wadi Sfissifa, Wadi Tirkount and WadiTiout.

Agriculture and pastoralism have long been the primary socioeconomic activities in the region, and as such, water resources are essential for supporting these activities. Given the semiarid to arid climate and limited rainfall, groundwater is a critical resource for sustaining agricultural and pastoral activities. Therefore, it is important to investigate the quality of groundwater and understand the hydrogeochemical processes that control it to ensure its sustainability for these activities.

Materials and methods

Geological and hydrogeological framework

The stratigraphic series of the Western Saharan Atlas consists of several geological formations that have been defined by several authors (Ait Ouali 1991; Delfault 1984; Douihasni 1976; Kacemi 2005, 2013) in different localities of the Ksour Mountains.

In the Ain Sefra area, this lithostratigraphic suite consists of thick detrital series ranging from the Triassic to the Recent Quaternary with a predominance of Mesozoic formations (Fig. 1).

The Triassic is generally represented by versicolored clays and evaporites, sporadically interrupted by occasional basaltic lava flows (e.g., Aïn Ouarka diapir). The Lower and Middle Jurassic are characterized by a thick series of limestones (e.g., Breccia Formation of Raknet El Kahla), sandstones and marls accumulated during the Lower and Middle Jurassic (Bassoulet 1973; Mekahli 1996). Above this, silicoclastic deposits (3000 m) mainly continental from the Upper Jurassic to the Lower Cretaceous (Djara, Aissa, Tiloula and Tiout Formations) are established. The structuring of the Mesozoic sedimentation took place during the Eocene and Oligocene (Dewey et al. 1973). Jurassic units formed ridges separated by broad synclines composed of formations of Lower Cretaceous date. Cenomanian–Turonian limestone ledges (Rhoundjaia Formation) occupy the tops of the synclines (Benyoucef et al. 2017). The continental Tertiary (Mio-Pliocene) is formed by red clay–sandstone layers with gypsiferous levels. The Quaternary formations are thin and formed by alluvium and dune formations.

The geological and stratigraphic studies of the studied area highlight the presence of two potential aquifer systems which are from bottom to top:

  • The multilayer aquifer of the Upper Jurassic: outcrops at the foot of the Jebels Aissa, Mekter, Hirech and Morhad.

  • The Lower Cretaceous multilayer aquifer and the semipermeable Neocomian formations play the role of a substratum for the Cretaceous aquifer and ensure separation from the Jurassic one.

Sampling analysis

A reconnaissance and sampling campaign of water points (boreholes, wells, springs) was carried out in the study area. The latter involved 43 water points during the month of May 2022. Of all the structures that were sampled, six samples were taken for the Upper Jurassic water table and thirty-seven (37) for the Lower Cretaceous water table. The choice of sampling locations was based essentially on the spatial distribution of the different water points to cover the entire study area (Fig. 2). These samples were taken at the boreholes after 15 min of pumping and after stabilization of the water temperature to eliminate the groundwater stored in the structure. This was achieved using standard methods as suggested by the American Public Health Association (APHA 2017).

Fig. 2
figure 2

Spatial distribution of the different sampling points with piezometric level in the study area

The physical parameters were measured in the field, using a multi-parameter HACH SL1000, which is the temperature (°C), the potential of hydrogen (pH) and the electrical conductivity (EC). Others were measured in the Algerian Water (ADE) laboratory of Tindouf, from samples that were taken and stored in coolers at a temperature below 4 °C. These are calcium (Ca2+), magnesium (Mg2+), sodium (Na+), potassium (K+), chlorides (Cl), sulfate (SO42−), bicarbonates (HCO3), nitrates (NO3) and the dry residue. The methods used are those recommended by (Rodier et al. 2009). The analysis of the ionic balance between cations and anions was calculated. It is less than 5% for all the data, demonstrating the reliability of the analytical results.

The determination of Ca2+, Mg2+, Cl and HCO3 were measured by the volumetric method. The concentrations of SO42− and NO3 were measured by spectrophotometry (HACH DR6000) and for the elements Na+ and K+ by a photometer method (flame spectrophotometer JENWAY PFP7).

Statistical analysis

The study of the hydrochemistry of groundwater systems provides a means of tracking variations in the physical and chemical characteristics of groundwater, in both time and space. Conventional techniques consider a limited number of hydrochemical variables to interpret hydrochemical processes and classify hydrochemical facies using graphical methods such as (Piper 1944), (Stiff 1951) and (Schoeller 1962) diagrams. More recent methodological approaches include multivariate statistical techniques that assist the classical methods of interpretation of hydrochemical variables. These statistical tools can be divided into two groups: factorial methods/principal component analysis (PCA) and classification methods/hierarchical ascending classification (HAC). These statistical methods can be divided into two main groups:

  • Dimension reduction analysis: This technique reduces the number of variables to be analyzed to a small number that concentrates all the important information by extracting the gradients of maximum variation. Principal component analysis (PCA) belongs to this category.

  • Cluster analysis: This is a method of grouping that consists of reducing the number of observation units by forming the most homogeneous groups possible. Cluster analysis (CA) is classified in this category. In this study, the OriginLab® software (OriginLab 2022) was utilized for performing principal component analysis (PCA) and hierarchical cluster analysis (HCA). Ward’s method was chosen as the distance method for clustering objects, while the Euclidean distance method was employed to measure the distances between clusters.

These multivariate statistical approaches are often the most efficient way to process a large amount of information generated from groundwater hydrochemical data (Join et al. 1997). Over the last decade, the application of these techniques has yielded good results in the interpretation of hydrogeochemical processes worldwide (Foued et al. 2017; Güler et al. 2002; Salman et al. 2015; Tiri et al. 2014). Indeed, principal component analysis (PCA) allows us to look for relationships between chemical variables and to group those that show similar behavior to have an idea of the evolution of groundwater chemistry. The objective of this analysis is to describe or classify the data to allow the interpretation of the hydrochemical functioning of the aquifer. Cluster analysis is another method whose objective is to assemble in the same group (called a cluster) the objects similar (or associated) to each other and which are different (or not associated) from objects belonging to other groups. The quality of the classification is determined both by the level of similarity (or homogeneity) between items in the same cluster and by the level of difference from other clusters (Everitt et al. 2011).

Water quality index

Water quality assessment for drinking water

The water quality index (WQI) is a simple yet valuable mathematical method for assessing the overall quality of groundwater based on several criteria that determine its suitability for drinking or irrigation (Bouteraa et al. 2019; Jena et al. 2013). In general, the characterization of a quality index is defined by its objective. The WQI involves summarizing very large amounts of water quality data in simple terms (excellent, good, poor, very poor and inadequate) to make the information easier to understand (Table 1). In effect, this index provides a complete picture of water quality to decision-makers and the general public.

Table 1 Water quality assessment grid using the water quality index

The WQI was determined using Eqs. (1) through (4)

$${\text{WQI}} = \mathop \sum \limits_{i = 1}^{n} q_{i } W_{i } /\mathop \sum \limits_{i = 1}^{n} W_{i }$$
(1)

where qi is the quality subindex for the ith parameter, Wi is the unit weight of each parameter and n is the number of parameters.


Calculation of the value qi

$$qi = \left[ {\frac{{V_{i} - V_{0} }}{{S_{i} - V_{o} }}} \right]$$
(2)

where Vi is the ith parameter’s observed value, V0 is the ith parameter’s ideal value in pure water, V0 is zero for all parameters except pH = 7.0, and Si is the ith parameter’s standard permitted value.


Calculation of the Wi value

The calculation of the unit weight Wi is inversely proportional to the admissible standard value Si for the water quality parameters.

$$W_{i} = \frac{K}{{S_{i} }}$$
(3)

K is proportionality constant given by the relationship (Goher et al. 2014)

$$K = \frac{1}{{\mathop \sum \nolimits_{i = 1}^{n} \frac{1}{{S_{i} }}}}$$
(4)

The WQI standards are divided into five categories given in Table 1.

Water quality assessment for irrigation

The quality and composition of dissolved elements in water determine its suitability for agricultural use. Deterioration in the quality of groundwater used for irrigation can adversely affect crop and plant growth by restricting water uptake by plants or by altering metabolic reactions (Wilson 1982). The concentration of sodium ions in water is one of the most important factors controlling its suitability for irrigation purposes. If groundwater contains a high concentration of Na+, it will have a negative impact on soil texture and permeability (Sujatha and Reddy 2003). The presence of certain salts in groundwater at high concentrations can damage soil properties, including fertility and permeability, and thus limit plant growth (Umar et al. 2001). US Salinity Laboratory (USSL) diagrams and specific parameters such as sodium adsorption ratio (SAR), permeability index (PI), Kelly ratio (KR), magnesium hazard (MH), percent sodium (%Na) and residual sodium carbonate (RSC) are used to assess the suitability of groundwater for irrigation purposes. All these indices are expressed by equations summarized in Table 2.

  • The SAR parameter (Richards 1954) is used in irrigation water with reference to the soil’s ability to release Ca2+ and Mg2+ and absorb Na+ from groundwater, which causes the reduction of soil porosity.

Table 2 Summary of water quality indices for irrigation

Based on SAR, water can be classified into four categories: excellent (< 10%), good (10–18%), allowable (18–26%) and inadequate (< 26%).

  • Permeability index (Doneen 1964) long-term irrigation water impacts soil quality. Sodium, calcium magnesium and bicarbonate ions in the water influence soil permeability (Raghunath 1987). The PI value is determined to evaluate the suitability of groundwater for irrigation purposes according to the following standard: excellent (PI > 75%), good (PI = 75–25%) and unsuitable (PI < 25%).

  • The Kelly ratio (KELLEY 1963) introduced an important parameter to evaluate the quality of irrigation water based on the concentration of Na + versus Ca2+ and Mg2+. If Kelly’s index is greater than 1 (KI > 1), this indicates an excess of sodium in the water, thus unsuitable for irrigation, and therefore, water with a KI less than one (KI < 1) is better suited for irrigation.

  • Magnesium risk (Paliwal 1972) is the excessive amount of Mg2+ over Ca2+. Excess Mg2+ affects soil quality giving low agricultural yields. Water is classified as suitable with an MH value of less than 50% and unsuitable with a value of more than 50%.

  • Sodium percentage (Wilcox 1948) excess sodium in water is often responsible for changing soil properties as well as reducing its permeability. Irrigation water is divided into five classes according to the percentage of sodium which are excellent (< 20%), good (20–40%), permissible (40–60%), doubtful (60–80%) and inadequate (> 80%).

  • Residual sodium carbonate (Eaton 1950) is used to know the adverse consequences of carbonates and bicarbonates on the suitability of water for agricultural purposes. Based on CSR, water can be classified into three categories. Water with CSR greater than 2.5 (> 2.5) is not suitable for irrigation while water is good for irrigation with CSR less than 1.25 (< 1.25) and doubtful between 1.25 and 2.5.

Geochemical modeling

To understand the evolution of water chemistry along the groundwater flow, a simulation using the PHREEQC code (Parkhurst and Appelo 1999) was performed. This simulation was used to calculate saturation indices (SI) of dissolved minerals in water and to address the speciation of these minerals. This also allowed the assessment of the saturation state of water that controls the chemist and equilibrium state with the solid phases (Appelo and Postma 1996; Drever 1997).

The saturation index (SI) is defined as the logarithm of the ratio of ionic activity products (IAP) to the solubility product (Ksp) at a given temperature.

$${\text{SI}} = {\text{log}} \frac{{{\text{IAP}}}}{{{\text{Ksp}}}}$$

Generally, the water–rock equilibrium is reached when IS = 0. If IS > 0, the water is supersaturated, and precipitation of minerals is required to reach equilibrium; on the other hand, if IS < 0, the water is undersaturated, and dissolution of minerals is required to reach equilibrium (Yidana and Yidana 2010); thus, these minerals control the chemistry of these waters.

Results and discussion

Groundwater chemistry and water type

Examination of the chemical analyses (Table 3) reveals that the groundwater in the study area has temperatures ranging from 17.85 to 46 °C. The pH ranges from 6.7 to 8.5, indicating the low alkalinity of the groundwater. Electrical conductivity ranges from 500 to 6380 µs/cm. The hydrochemical data were classified using the hierarchical cluster analysis (HCA) technique in Q mode according to Ward’s method (1963) (Ward 1963) in a space with 11 variables (Ca2+, Mg2+, Na+, K+, Cl, SO42−, HCO3, NO3, EC, T °C and pH) and 43 individuals. The result of such treatment showed according to the dendrogram (Fig. 3) that the waters of the region can be classified into four groups where the electrical conductivity seems to be a major distinguishing factor with increasing concentrations in all groups. The representation of these 04 groups on the Piper diagram allows for comparing the chemistry of the main ions in the order: of group 1, 2, 3 and 4, and makes it possible to classify the analyzed water samples. This visualization tool aids in understanding the relative proportions and relationships between different ion concentrations, facilitating meaningful analysis and interpretation of the data. Additionally, the measurement results of physicochemical parameters, as well as the descriptive statistics of water samples, were compared with the guidelines provided by the World Health Organization (WHO 2011). This comparison helps to assess the compliance of the analyzed water samples with internationally recognized standards and norms for safe and healthy water quality (Fig. 3).

Table 3 Parameter values of the four principal water groups
Fig. 3
figure 3

Dendrogram of Q mode cluster analysis

The increase in temperature in the Aïn Ouarka area can be attributed to a fascinating geological process. Groundwater from the region percolates deep underground, following geological faults, where it undergoes natural heating near a geothermal source. This heated groundwater subsequently contributes to the emergence of a hot thermal spring, as detailed in the study by (Hadjou et al. 2023). This intricate geothermal phenomenon not only provides valuable insights into the local hydrogeology but also offers a unique opportunity for harnessing geothermal energy resources in the area.

Group 1 corresponds to “Cluster 1” in Fig. 3; it is formed by thirty-five sample points (F1, S1, S2, P1, P2, F2, F3, F4, F10, F16, F17, F19, F21, F25, F26, F29, F30, F33, F36, F43, F45, F48, F49, F58, F62, F63, F64, F65, F68, F70, F73, F81, F82, F90 and F111), with a mean EC value equal to 1161.14 µS/cm, indicating low salinity and thus freshwater (EC < 1500 μS/cm). Ca2+ is the dominant cation while SO42− and HCO3 are the dominant anions. Therefore, this group corresponds to the calcic and magnesian sulfate chloride facies (Ca–Mg–SO4–Cl) and calcic and magnesian bicarbonate facies (Ca-Mg-HCO3) (Fig. 4). They correspond to samples taken near the recharge areas, i.e., the wadis for the waters of the Lower Cretaceous and the edge reliefs for that of the Upper Jurassic. Most of the samples exceed the desirable limit of calcium (75 mg/L) (WHO 2011) and bicarbonates (120 mg/L) for drinking water.

Fig. 4
figure 4

Piper diagram for water samples

Fig. 5
figure 5

Water groups spatial distribution

Group 2 corresponds to “Cluster 2” in Fig. 3; it is composed of water points F15, F28, F31 and F32 which characterize waters with medium to intermediate salinity (2276 < EC < 3116 μS/cm, average = 2686.5 μS/cm), Ca2+ and Na+ are the dominant cations, and magnesium shows an increase in these contents. Chloride (Cl) is also abundant, dominating the bicarbonates, and together with sulfates (SO42−), it forms the majority of anions of this group. The members of this group correspond to the Ca–Na–SO4–Cl facies (calcic sulfate and sodium chloride). This group corresponds essentially to samples taken from the Lower Cretaceous aquifer and more precisely near the evaporative zone, hence the influence of evaporation on the increase in salinity in this sector. Another factor that plays an important role is the leaching of clay and marl soils, especially since the region between Ain Sefra and Tiout is marked by an extension of clay formations of the Cretaceous. All the samples exceed the WHO standards for the elements Ca2+, SO42−, Cl and HCO3.

Group 3 corresponds to “Cluster 3” in Fig. 3; it includes three water samples (F6, F24, F56) that characterize waters with high salinity, with an average EC value of 4376 μS/cm. In this group, the dominance of Ca2+ cations was noted over Na+, with an increase in chloride contents compared to groups 1 and 2.

The facies of this group will be SO4–Cl–Na–Ca (calcic chloride). It is influenced by the dissolution and leaching of Triassic saliferous formations (argilo-gypso-saline) located south of the town of Tiout toward Jebel Djaara.

Group 4 corresponds to “Cluster 4” in Fig. 3; it contains only one water sample, from the thermal spring of Ain Ouarka (S9). The groundwater is highly mineralized with an excessively high conductivity EC = 6380 μS/cm. Na+ and Cl are the most dominant ions, indicating a Na-Cl water facies. The physicochemical composition of the water of this group is influenced by the geological nature of the Triassic formations of Ain Ouarka (rock salt and gypsum).

It is to be noted that the hydrochemical evolution is done by a progressive depletion of bicarbonates and by enrichment in sulfates, chlorides, calcium and sodium. The increase in sulfates is related, on the one hand to the change of facies of the lower cretaceous formations which become more clayey and more gypseous and on the other hand to the pollution by fertilizers following the existing agriculture on both sides of the main wadis (Sfissifa, Tirkount, Breidj and Tiout). The increase of chloride contents is due to Triassic injections along the Ras-Touil-Ain-Sefra accident, at the foot of Jebel Mekter, along the Belhandjir fault, south of Tiout locality and in the Ain Ouarka region (Fig. 5).

On the other hand, plotting these groups of samples on the diagram of (Chadha 1999) allows us to describe the different water types and to identify the evolution of hydrochemical processes that control the groundwater chemistry in the study area. Plotting the data on this diagram (Fig. 6) revealed that most of the samples (93.02%) fall in the 6th field (Ca–Mg–Cl/SO4 reverse ion exchange water type), revealing Ca–Mg–Cl type waters, where alkaline earth (Ca2+  + Mg2+) dominate alkalis (Na+  + K+) and strong acids (Cl + SO42−) exceed weak acids (HCO3), confirming the results of Piper diagram. On the other hand, 4.65% are plotted in the 7th field (Na–Cl sea water), indicating that alkalis exceed alkaline earth and strong acids exceed weak acids). The rest of the samples (2.33%) fall in field 5 (Ca-Mg-HCO3 recharge water). The results obtained from the Chadha plot are considered consistent with those from the Piper plot.

Fig. 6
figure 6

Chadha diagram of the groundwater sample

The suitability of the data for FA/CPA was checked using Bartlett’s sphericity and Kaisere–Meyere–Olkin (KMO) tests. The results obtained for the data set are: Bartlett’s Chi-square χ2 = 588.02, degree of freedom 55, significance level 0.000. Kaiser–Meyer–Olkin (KMO) value = 0.63. Thus, we find that our KMO index is between 0.6 and 0.7, so it is an average index, but also highly significant when compared to the Bartlett significance level (< 0.05). These tests therefore indicate that our data are adequate for factor analysis.

Principal component analysis (PCA) was also applied to the processing of these chemical data. The number of components to be retained was based on the (Kaiser 1960) criterion, for which three factors were retained (F1, F2 and F3) that represent 81.68% of the total variance, which is good enough to identify the main variations in the hydrochemistry (Table 4, Fig. 7).

Table 4 Score of PCA after varimax rotation
Fig. 7
figure 7

Projection of variables on the factorial plane F1/ F2 with varimax rotation

The axis of factor 1 represents 57.49% of the total variance and it groups CE, Cl, Na+, SO42−, Ca2+, K+ and T in the positive pole. This factor 1 can be considered as an axis characterizing the mineralization of groundwater in the study area because it is correlated with most elements. Indeed, the elements that define this factor come from a long time of solution following the water–rock contact (Meggiorin et al. 2022).

The axis of factor 2, with a variance expressed of 14.42%. It is defined by Mg2+ and NO3 in the positive pole. The presence of nitrate thus indicates a strong contribution of anthropogenic activities in the mineralization of groundwater.

The axis of factor 3 accounts for 9.77% of the total variance; it is determined by pH in the positive pole and HCO3 in the negative pole. The concentration of HCO3 in groundwater is probably governed by the infiltration of rainwater into the aquifers.

Water quality index

Groundwater quality is very important because it is directly related to human health. The WQI was used to delineate the quality status of the groundwater that is the subject of this study for drinking water use according to World Health Organization standards (WHO 2011). The WQI is used to delineate the quality of the groundwater that is the subject of this study. For this assessment, ten chemical parameters were used, namely pH, electrical conductivity, calcium, magnesium, sodium, potassium, chloride, sulfate, bicarbonate and nitrate.

According to the results obtained in Table 5, 6.98% of groundwater is of excellent quality, 60.47% of groundwater samples are of good quality, 30.23% are of poor quality, but can be suitable for consumption, especially in areas with arid climates where the content of some salts, such as chlorides, sulfates and sodium, are less strict; finally, 2.32% of samples are of very poor quality and less suitable for domestic use in AEP. In this context, it should be noted that all the wells tapping the Upper Jurassic aquifer are of good quality except for the thermal spring of Ain Ouarka (S9) which is less suitable for domestic use in drinking water.

Table 5 Suitability of groundwater for drinking based on WQI

Groundwater quality for irrigation was evaluated using the indices presented in Table 6. The sodium adsorption ratio showed that the groundwater could be classified as excellent at all sampling points (SAR < 10). Similarly, the results obtained for the permeability index classified the water in all samples as good (PI = 75–25%). Similar results were obtained using the Kelly index, of which 95.35% of the samples are considered adequate for irrigation purposes (KR < 1) and 4.65% are unsuitable for irrigation (KR > 1). However, the risk of magnesium was classified as adequate for agriculture at 76.75% (MH < 50) and inadequate at 23.25% of the samples (MH > 50). The percentage of sodium indicated that 25.58% of the samples are excellent (%Na < 20) for irrigation, 62.79% present good quality (20–40), and 11.63% of the samples are eligible for irrigation (40–60). Finally the residual sodium carbonates indicates that 100% of the samples can be accepted for irrigation practice (RSC < 1.25).

Table 6 Groundwater samples class for irrigation purpose based on various indices

The USSL diagram (Richards 1954)), in which EC is considered a risk of salinity and SAR as a risk of alkalinity (Fig. 8), shows that 11.52% of samples are located in class C2S1 (good water, suitable for all plants), 67.44% of samples represent class C3S1 (water eligible for irrigation of salt-tolerant crops, on well-drained or good permeability soils and salinity must be controlled), 16.28% (C4S1, C4S2 class) represent poor highly mineralized waters with higher sodium values that may be suitable for irrigation of some salt-tolerant species and on well-drained and leached soils and 2.33% are not suitable for irrigation.

Fig. 8
figure 8

Classification of irrigation water quality based on EC and SAR (Richards 1954)

The Wilcox diagram (Fig. 9), based on electrical conductivity and sodium content in water, expressed as a percentage (%Na+), shows that 16.28% of the water represents excellent quality for irrigation. 58.14% of the samples are in the classes (good to admissible), 13.95% of the samples fall in the doubtful to the inadequate range and finally, 11.63% of the points are unsuitable for irrigation use. The high values of conductivity and sodium in the waters of the boreholes belonging to the classes (doubtful and inadequate) show large proportions of salinity in the water, which reduces its suitability for irrigation and leads to problems when used.

Fig. 9
figure 9

Classification of irrigation water quality based on EC and % Na (Wilcox 1955)

Hydrogeochemical processes

Origin of mineralization

Groundwater chemistry is characterized by the presence of certain ions that are more abundant in solution than others. The abundance of these elements results from an origin that can be either natural or anthropic. It is then controlled by physical processes such as the interaction with the host, depending on the nature of this host, the time of water transit within the aquifer formation and the chemical processes controlling the solution or precipitation. Anthropogenic influences, such as the return of irrigation water in areas of high agricultural activity, can also contribute significantly to groundwater mineralization. The three mechanisms that control the chemical components of natural waters are atmospheric precipitation, rock weathering and evaporation (Apodaca et al. 2002). Gibbs (1970) and Gaillardet et al. (1999) diagrams have been widely used to represent the control mechanisms of groundwater hydrochemistry.

The Gibbs semilogarithmic coordinate plot is an important method for analyzing the evolution of chemical constituents in groundwater. In Fig. 10a and b, we plotted total dissolved solids (TDS) versus [(Na+ + K+)/(Na+ + K+ + Ca2+)] and TDS versus [Cl/(Cl + HCO3)] using sample data from the study area. The ratios of (Na+ + K+)/(Na+ + K+ + Ca2+) and Cl/(Cl + HCO3) ranged from 0.2–0.7 and 0.1–0.9, respectively. Most of the groundwater samples were distributed between the rock-dominant and evaporation-dominant zones. According to our results, about 51% of the samples suggest chemical alteration of rock-forming minerals and influence groundwater quality through the dissolution of rock carbonates in recharge areas. All these samples belong to the 1st group only. About 49% of the samples represent the dominance of evaporation or the samples in the groups (1, 2, 3 and 4) are thus influenced by evaporation. The Gibbs diagrams showed that as TDS increases, the ratios of (Na+ + K+)/(Na+ + K+ + Ca2+) and Cl/(Cl + HCO3) also increase, this is due to an increase in groundwater residence time accompanied by rock–water interaction in these multilayered aquifers.

Fig. 10
figure 10

a Gibbs plots for groundwater samples. b Gibbs plots for groundwater samples

The Gaillardet diagram illustrates in Fig. 11a (Ca/Na)/(HCO3/Na) that almost all samples from the four groups fell within the zone of silicate weathering and carbonate dissolution, indicating that weathering of silicate and carbonate rocks was the primary source of groundwater chemistry in the study area. Figure 11b (Ca/Na)/(Mg/Na) also shows that most of the samples from the four groups are clustered between the silicate weathering zone and evaporite dissolution, indicating that silicate and carbonate weathering and combined chemical reactions would control the major component of groundwater in the study area.

Fig. 11
figure 11

a Gaillardet plots for groundwater samples. b Gaillardet plots for groundwater samples

Geochemical modeling

Water chemistry is acquired through the interaction of water with the surrounding rocks. This interaction depends primarily on chemical reactions controlling solution or precipitation. Generally, saturation indices are used to express the tendency of water toward precipitation or dissolution. The PHREEQC geochemical model (Parkhurst and Appelo 1999) was used to calculate the saturation index (SI) for carbonate (calcite, dolomite and aragonite) and evaporate (gypsum, anhydrite and halite) minerals.

Table 7 shows that groundwater is generally oversaturated with respect to most mineral phases and is probably responsible for the hydrochemical composition. On the other hand, the groundwater samples are undersaturated with respect to halite, reflecting a relatively long contact time with this mineral to allow for its dissolution along the groundwater flow path.

Table 7 Statistical summary of saturation indexes of minerals in groundwater using PHREEQC

In the present study, the classification of the groundwaters with respect to the mineral stability diagrams (Drever 1997) illustrates that the three water groups are represented mainly in the Ca-smectite stability field (Fig. 12a, b), indicating that equilibrium with this mineral phase is one of the main processes controlling the chemical composition of the water. Figure 12c) shows that all four water groups are represented in the stability field of Mg-smectite and Kaolinite. On the other hand, the distribution of the samples in these equilibrium diagrams shows a relative dispersion of the point clouds. This dispersion shows that there is a hydrochemical heterogeneity in the acquisition of water mineralization.

Fig. 12
figure 12

(a, b, c) Mineral stability diagrams (Drever 1997)

Conclusion

This study highlights the importance of hydrogeochemical methods, including multivariate statistical techniques, geochemical modeling and water quality indices, in understanding the origin and evolution of groundwater in the Ain Sefra region, and in assessing its suitability for human consumption and irrigation. The analysis revealed the presence of different types of groundwater according to their chemical composition and identified the main processes influencing their quality. The results show that sustainable management measures are needed to control human activities, prevent overexploitation of groundwater and reduce contamination. In addition, future research could explore the impact of climate change on groundwater resources and consider innovative solutions such as artificial recharge and desalination. The integration of remote sensing and GIS techniques is also recommended for a better understanding of the spatial and temporal variability of groundwater quality and availability in the region. Continuous monitoring and sustainable management of groundwater resources are essential to ensure their long-term use, by maintaining their quality and applying best practices, particularly in agriculture and land-use planning.