An irrigation scheduling algorithm for sustainable energy consumption in pressurised irrigation networks supplied by photovoltaic modules

To meet water demands, pressurised irrigation networks often need pumping devices, whose power demand varies with the pump head, the flow rate delivered and the pump efficiency. To satisfy the energy demand of pumps, solar photovoltaic panels can be used as a renewable energy source. Since the electricity supply of a solar photovoltaics plant depends on irradiance, the energy that powers the pump varies with the time of the day. This study presents a strategy for scheduling water delivery by irrigation pumps, synchronising energy production in solar photovoltaic modules and minimising the installation size. An optimisation algorithm is proposed, which changes the energy required by pumping devices and adjusts them to the available solar energy supply, minimising the number of panels required. This problem applies to a pressurised irrigation network, where the utility manager may irrigate crops at all hours of the day. By adopting the proposed algorithm, irrigation will follow a rigid rotation schedule to follow the new irrigation plan. This approach improves earlier studies by employing a least-square scheduling algorithm with little computing time. This results in a tool for managers and decision-makers when evaluating the possibility of converting their irrigation network into a stand-alone system supplied by photovoltaic panels. A case study handling this issue in the University of Alicante’s pressurised irrigation network in Spain is proposed to find potential energy savings by connecting the recommended scheduling irrigating plan to the present operation.


Graphical abstract
Keywords Irrigation management strategy · Algorithm design · Energy consumption · Solar photovoltaics energy Abbreviations A, B and C (−) Coefficients to represent the head vs flow curve of the i-th pump D, F and G (−) Coefficients to represent the efficiency vs flow curve of the i-th pump E P (t) Energy consumed by the pumps E av (t)(W) The energy produced by PV modules d C −1 Performance decay F −1 n p A function used to invert the relationship flow vs power J, K and L (−) Coefficients to represent the power vs flow curve of the i-th pump H i (m.w.c.) Head pumped by the i-th pump H h kWh m −2 Global irradiance on a horizontal surface I sc W∕m 2 The solar constant I STC W∕m 2 The irradiance standard test conditions k(−) Number of slices in which the total operating hours are divided m (−) Representative day of the month M, N (−) The coefficients achieved from the irradiance for representing Kasten-Czeplak model. The optimal number of solar modules (panels): NOCT (ºC) Nominal operating cell temperature P (kW) Power of the i-th pump PP (W) Peak power PV module P 1 gen (t) (W) Power generated by a generic panel P n s gen (t) (W) Power generated by using n s panels P th (m.w.c.) Threshold pressure Q i (l∕s) Flow rate pumped by the i-th pump Q * (t) (l∕s) The highest available flow for any power Q I (t) (l∕s) Flow delivered at time t Q t k Available flow at t k Q low, th Lower network flow rate threshold Q pump min Minimum flow that can be delivered Q pump max

Maximum flow that can be delivered t (h)
Hour of the day t k (h) Time t w (h) An arbitrary change in time T(−) The greatest value for the index w T avg (°C) Average monthly temperature T p (h) Total operating hours Greek symbols (º) Tilt angle Δt (h) Length of each slice Δ(h) Arbitrary change in time t w N m 3 The specific weight of water Flow assigned at slice k ′ t w Flow assigned at an arbitrary slice w considering a change in it.

am (%)
The motor efficiency η fc (%) The inverter efficiency The i-th pump efficiency z (−) Solar hour angle parameter in a Kasten-Czeplak model

Introduction
The water, energy, and food security nexus play a critical role in the sustainable development and survival of humanity. The growth in demand for all three emerged from the growth in the global population, climate change, and the increasing demand for food. Nowadays, agriculture becomes the largest consumer of water resources in the world, and 72% of all water withdrawals are handled by agriculture (Wada et al. 2012). In the irrigation industry, a large amount of water is consumed daily, and water pumps need an immense amount of electrical energy to deliver the water demanded by crops. Efficient and sustainable management of pressurised irrigation networks (PIN) is a challenge for service managers (Moradi-Jalal and Karney 2008). To mitigate the environmental impact of energy consumption on agriculture, the sector should be more dependent on renewable energy sources. Large-scale integration of renewable energy sources into pressurised water networks demands a more efficient control of water flows and power flows (Torbaghan et al. 2018). Certainly, pumping water for agriculture extends the resilience of the power grid (Kocaman et al. 2020), as water delivery is an energy-intensive procedure and compensation head tanks are a solution for accumulating energy as potential energy. In fact, the works have focused on forecasting wind patterns by adopting water tanks (or reservoirs) as energy storage elements . However, installing a water tank is not always possible. (it requires a slope of the land a topology limitation). In this case the increase in size is required to store all the energy produced, it can be costly, and from the energy standpoint, considered an inefficient regulation technique (Cabrera et al. 2019) because of the energy loss that appears with the depressurisation of the fluid (Pardo et al. 2013).
Hence, in this scenario-where anthropogenic pressure provokes severe effects on the environment-solar photovoltaic (PV) power emerges as the most sustainable and economical choice for reducing energy and emissions. Powering pumps with solar PV is a key solution for the irrigation sector, especially with the price crash of PV panels, which has dropped 89% in 10 years, from $106 per watt in 1976 to $0.38 per watt in 2019 (Roser 2020), and the increase in their power rating and efficiency.
There are two configurations of the solar-powered water system (SPWS). The first is the stand-alone solar system powered solely by solar irradiance. The second one is the hybrid system based on solar power plus a backup power source (e.g. a diesel generator, a battery, or the electricity grid). Some approaches preferred the off-grid configuration as the best from an economic standpoint (Jones et al. 2016), while others identified that the off-grid system must be oversized to cover the peak demands, which leads to higher investment costs (Guzmán et al. 2018). The standalone SPWS should be encouraged over the hybrid system for budgetary reasons, lower energy consumption, and environmental impact. Nevertheless, the major issue with solar energy supply is that energy produced by solar PV modules rests on several factors, such as the solar irradiance level, peak sun hours available, latitude and season of the year. In addition, irrigation is only possible at certain times of the day in off-grid configurations, when solar energy is accessible. Regulating irrigation networks also include special attributes, since, in PIN, water is distributed through a system of pipes (which distributes water to crops more precisely, with minor losses and efficiency). In contrast, in surface irrigation systems, water is delivered through the soil by gravity and with no pumps.
Several related research has been conducted about cutting the energy consumption by pumps. Some approaches addressed reducing energy consumption by grouping intakes (Jiménez-Bello et al. 2010) or by modifying the irrigation schedule (Naval and Yusta 2021) or by examining the hydrological data when selecting an irrigation schedule (Ren et al. 2021). Others diminished energy expenditure by converting the flow into a steady flow injected into the PIN (Pardo et al. 2022b) and other works deal with using floating panels in irrigation tanks to reduce evaporation (Redón Santafé et al. 2014;López et al. 2022).
Much work has been directed towards shifting the supply of pumping power from the grid to a stand-alone SPWS (Mohanty et al. 2018). The major particularity of irrigation networks compared to urban supply networks is that the manager can regulate the water demand and, so, energy consumed. In new words, the crop receives water at the time chosen by the network controller. This regulation capacity allowed adjusting the energy consumed and produced in the PV panels, posed this problem in a network separated into fixed segments grouping all the hydrants (valves) and subunits (Pardo et al. 2018), and also solved with precipitation, soil, crop and hydraulic data to manage the SPWS (Mérida . A segment or sector comprises a set of consumption nodes irrigated by the network manager's decision. This sectoring process has been done for a specific purpose such as reducing energy consumption, stabilising the flow rate injected, etc. Navarro-Gonzalez et al. (Navarro-Gonzalez et al. 2021) further developed the earlier research by converting the hydraulic problem using nonlinear equations. This hydraulic problem requires a set of n n * n l (being n n and n l the number of nodes and links of the PIN) quadratic equations that must satisfy the equation of conservation of mass and energy are solved according to the matrix formulation used by Todini and Rossman (Todini et al. 2013). However, none of the earlier works considered in the optimisation process an individual treatment of each tap and/ or sub-unit (but focused on multiple individual units). The present work treats the valves that supply water to the crops as independent of each other.
This study outlines an optimisation algorithm that changes the energy demand by the pumps in the PIN and adjusts it to the energy provided by PV modules. For this purpose, the relationship between the opening and closing of controlled shut-off valves, which produces a flow rate to circulate through the pump, and the energy absorbed by the pump is established. This work progresses to all those earlier works by employing a least-square scheduling algorithm (proposed here) to find the optimal combination between PV energy production and energy consumption in stand-alone configurations for all months of the year.
This study is limited to PINs supplied by pumps. The user must know the volume of water consumed in each subunit or irrigation hydrant, the hydraulic characteristics of the pumps (H-Q and performance-Q curves) and the number of pumps that can run in parallel. The volume demanded by the crops remains constant to compare cases. This volume of water depends only on the water needs of the crops and is independent of the way energy is produced. Finally, the PV solar panel to be installed and all the physical characteristics of the installation (i.e. latitude, longitude, etc.) must also be known.
This work explores the relationship between the energy provided by a solar PV system and its direct consumption in pumping machinery, convenient for local irrigation network managers who are interested in furthering self-sufficiency from installed PV systems. Therefore, a huge momentum exists in establishing off-grid strategies for many reasons.
These include eliminating cost fluctuation, reducing emissions (from an environmental viewpoint) and minimising the PV power plant size and the investment involved in shifting towards a stand-alone, off-grid operation. As a result, this study aims to reduce potential barriers to the assimilation of PV systems in direct utilisation in PINs organisations by involving PV system operators, stakeholders and other users in the development and application of this energy management process.
The contributions of the paper can be summarised as: • First, this work brings an optimisation algorithm to schedule water delivery in irrigation networks by matching the energy demand of irrigation pumps to the energy generated by PV arrays. • Furthermore, being aware that managing irrigation systems is an energy-hungry procedure, the proposed algorithm allows converting a pumping system from an ongrid into a stand-alone system minimising the PV panel installation size. This study avoids oversizing the installation. • Lastly, the proposed algorithm is efficient to compute and can be applied at every location. Besides, it deals with the seasonal fluctuation of irradiance and water demanded by crops.
This paper is organised as follows: Section "Energy consumption in pumps" shows how to calculate energy consumption in water pumping devices, section "The energy supplied by a PV solar module" calculates the energy produced by a single PV module, section "Optimisation algorithm" presents the scheduling algorithm proposed, and section "Pseudocode" shows the algorithm pseudocode. A real case study is presented in section "Case study", where the energy consumption and PV production data are described in section "Energy consumption data" and "Energy production data". Section "Results and discussion" presents and discusses the numerical results and discussion, and the conclusions are shown in Section "Conclusions".

Methodology
This scheduling issue is planned as an optimisation problem where the overall optimal result is calculated by dividing it into three sub-problems that share the global optimums. These partial problems are determining the flow rate that can be driven by an electrically powered pump with a PV solar panel (in a process that first demands identifying the power and getting the related flow rate), calculating the smallest number of modules that power extracting the total volume of water required by the solar power water system and the scheduling of irrigation at every consumption junction of the network.
The optimisation parameters, which can so be adjusted, are the scheduled irrigation strategy (i.e. selecting which plot is irrigated at what time of the day). To solve this problem, the least-square scheduling algorithm is proposed that changes the pumping system-specific parameters and adapts them to the power supplied by the installed PV modules. These requirements minimise the discrepancy between energy produced and consumed while simultaneously reducing the size of the PV installation. In this way, the utility manager must adopt the irrigation scheduling strategy given by the algorithm.

Energy consumption in pumps
To compute energy consumption in pumping devices, we employ a centrifugal pump whose head-flow relationship is characterised by a polynomial quadratic function (Eq. 1): where H i (metre of water column; m.w.c.) and Q i (l/s) are the head and the flow rate pumped by the i-th pump. The coefficients A, B and C are specific to the selected pumping machinery. These coefficients are presented by the manufacturer, who obtained them by performing laboratory tests. Each centrifugal pump is further characterised by the efficiency curve (Eq. 2): where η i (−) and Q i (l/s) the efficiency and the flow rate pumped by the i-th pump. The coefficients D, F and G are proportioned by the manufacturer when choosing the pump (to the above coefficients).
Finally, the shaft work supplied by the pumps (Eq. 3) is: where N m 3 is the specific weight of water, P(kW ) is the power, and J, K and L are the coefficients given by the pump curve.
With the earlier values, the energy consumption by pumping units is calculated as (Eq. 4): (1) where E P (t) is the energy consumed by N P pumping units that run for a period T p (hours). The energy is computed for a time t and accumulated by a summation. The T p is divided into k(−) slices of Δt (hours). The functioning time can be calculated as the time T p = k ⋅ Δt.

The energy supplied by a PV solar module
Data needed to work out the energy produced are the tilt angle (β), latitude (φ), albedo (ρ), peak power (PP), nominal operating cell temperature (NOCT), the performance decay ( d ), the representative day of the month (m), global irradiance on a horizontal surface ( H h ), average temperature per month ( T avg ), the solar constant ( I sc ) and the irradiance standard test conditions ( I STC ). These rates result in a parabola-shaped plot illustrating the energy produced at every hour of the day. This energy is accessible E av (t) and can be modelled as a Kasten-Czeplak model (Eq. 5): Where M and N the coefficients achieved from the irradiance, and z is a parameter showing the hour angle according to the sun with seasonal variation.
Finally, the energy produced is consumed by the pumping device. Thus, the efficiency of the electric motor driving the pump ( am ) and the inverter efficiency ( fc ) must be considered. Thus, with these efficiencies, the energy produced available to drive the pump (a value lower than the energy produced) has been calculated.

Optimisation algorithm
As commented earlier, the optimisation algorithm decomposes into three sub-problems. We present each sub-problem separately in the following sections. (4)

Calculate flow for a single panel
The first sub-problem is to find the flow given a number n s of solar modules P n s gen (t) , by using the unitary generated power function P 1 gen (t) as the power generated by a generic panel under the standard conditions of operation, using the relation P n s gen (t) = n s ⋅ P 1 gen (t) . This power is consumed by the pumps to provide the needed flow that depends on the relationship between them given by the relationship P = F n p (Q) that correlates the power needed to get a flow Q when n p pumps are working, where n p goes from 1 to N p (the number of pumps in the installation). Note that n s refers to the number of solar modules, while the subscript n p (ranging from 1 to N p ) pertains to the number of pumps running, and these two parameters are completely independent.
The PQ curves of a group of 1, 2 and 3 identical pumps working in parallel are presented in Fig. 1, like other figures presented in earlier approaches as Gasque et al. (2021) who describe procedures for arranging the power generated by a PV pumping unit equipped with two equal pumps operating in parallel. This arrangement assumes that the total flow is equally divided between the pumps and that the head provided by each pumping unit is equal.
As deduced from Fig. 1, for a 5 l/s flow, different combinations exist and, hence, distinct values for the power needed to accomplish this flow (Q). Inverting the relationship between flow and power would allow getting the largest possible flow for any power as described in (Eq. 6): Figure 2 depicts how the algorithm can select among different ratios between the power consumed (Y-axis) and the flow rate injected (X-axis). The parabola (dotted line) shows the power required by the pump as a function of the different flow rates (Eq. 3). In this parabola relationship, for the centrifugal pumps, the same power consumption (3.337 kW) can deliver two different flow rates (Q = 5.6 and 15 l/s). Then, for power ratings above this value (3.337 kW), the highest efficiency point corresponds to the 15 l/s flow rate. Therefore, the software always selects the greatest flow for the same power. In Fig. 2, the solid line (which corresponds partially with the parabola) displays the points to be chosen by the algorithm. The algorithm shall deliver flow rates between 0 and 5.6 (l/s) and the greatest flow rate of 15 l/s. With a single pump, the optimisation causes the best value for power to present a discontinuity in the interval where the inverse function is not single-valued, as shown in Fig. 2. Analogously, this process can be extrapolated to a system with several pumps in parallel. The typical behaviour of the inverse curve (i.e. X-axis power and Y-axis flow) for a system with three pumps (Fig. 3) also exhibits the discontinuities described. Figure 3 shows that low power (< 2.5 kW) supplied to the pump involves a low head added to the flow, and the pump does not get to inject Fig. 1 Example of PQ curves for one to three operating pumps "EVM 32 2-0F5/4.0" running in parallel water into the PIN. In brief, in low flow rates (< 4 l/s), the pump impellers are rotating, but they cannot drive the water because they do not generate enough manometric head. The algorithm tries to work with the largest flow delivered by each pump. And in case a new pump is started, observed that the injected flow (and its demanded power) increases with a discontinuous jump as the new pump operating involves the flow delivered to crops can increase considerably.
Each interval where irrigation occurs is denoted by t k and the flow delivered at every network node (I ∈ PIN) in that interval as Q I t k . At each instant, the next condition Q * (t) ≥ Q I (t) must be satisfied. However, from the PV installation sizing standpoint, the additive version of these constraints given by Eq. (7) is more important. The flow Q * (t)(Eq. 6) is a continuous variable about time since derived from the generated power curve, so the total flow will be obtained from the corresponding integral.
where Q I (t) (l/s) is the flow delivered at a specific time. This flow rate Q I (t) is computed as the sum of the demands supplied at a time (t), therefore, a consequence of the schedule proposed by the algorithm. This inequation highlights that the volume that can be provided at a time t-consequence of the irradiance and the power generated in the modulesmust be higher than the volume demanded by the networkcalculated as a sum of each unit opened.

Calculate the number of panels required for supplying the pressurised irrigation network
Now, the second sub-problem is to figure out the solution to the nonlinear equation (Eq. 8): This will give the optimum number of solar panels, as the nearest greater integer, which will be denoted by N * s . The energy consumed is limited by the total volume of water required for the correct operation of the system. However, depending on the number of pumps connected at any given time, this energy can take different values. The algorithm identifies the minimum value of this energy by maximising the delivered flow rates for the irradiance curves (dependent on the time of day; Fig. 3). These curves also depend on the number of panels, so the algorithm also minimises the size of the installation as long as it delivers the required demands, as described in Eqs. 6, 7 and 8.

Select the scheduled irrigation plan
The last partial optimising task is to find the appropriate schedule to minimise the number of modules. The algorithm builds the scheduling matrix of flows at the different points of the irrigation network at every instant of time. Solving this can be done using several strategies, for example, a random distribution and reassignment, keeping the best combinations in each step. But, to use a deterministic method, it is possible to establish the objective function given by the sum of squares errors (SSE) calculated by comparing the assigned (flow delivered considering the valves opened) and the available flows (maximum flows that can be delivered considering the power produced) at each time slice (Eq. 9): where π(t k ) is the assigned flow at slice k that at the beginning of the algorithm would be initialised with 0 for every t k , and Q t k is the available flow at t k . Let us suppose a change in an arbitrary t w , where � t w = t w + Δ . From Eq. (9), this induces a change in Φ given by (Eq. 10): So, the largest decrease in Φ is achieved when Q t w − t w is the greatest value for the index w going from 1 to T. Once w is fixed, the maximum reduction in Φ is obtained for the highest value of Δ, where the conditions Q t w − t w > 0 (i.e. representing that at every instant, the assigned flow will be smaller than the needed) and Δ < Q t w − t w (i.e. the changed assigned flow also verifies the first condition) are assumed.
According to Eqs. (9) and (10), in each time interval, the largest of the volumes (or flows, given that the size of the intervals is homogeneous) that remain available to be satisfied must be assigned. This value ranges between zero and the highest demand to be delivered. The algorithm ensures that the volumes are delivered in decreasing order by satisfying the restrictions of irrigation times imposed by Eq. (8), by consuming the energy produced to deliver the flow (optimal irradiance conditions, Equations 6, 7 and 8) and by fitting both variables (Eqs. (6-9)).
The pseudocode of the inverse function ( Fig. 4; first subproblem) and the algorithm (second and third sub-problems worked simultaneously) is provided to further clarify this process when identifying the steps that comprise the algorithm.
The "InversePQ" function returns an array of values representing the volumes of water that can be delivered in each time slice from the energy supplied by n s .panels. The corresponding values are obtained at each time by inverting the global PQ function (employing a Newton-Raphson algorithm) for the set of pumps in service. The algorithm checks that the boundary conditions about the limit values for the flows and powers supplied are satisfied.
This function is used in the main section of the code presented in Fig. 5. Lines 14 and 15 get the limits on the power that can be used in the installation from the constraints induced by the flows Q pump min and Q pump max . This is followed by the number of time slices and the volumes (calculated as the injected flows for each time interval ∆t) they deliver to each consumption node.
Between lines 22 and 36, the algorithm calculates the optimal number of panels required to deliver the volume required by crops using the bisection method. Consequently. the inverse function PQ (presented before) is called in each pass. The last part (from line 38 onwards) corresponds to implementing the irrigation plan choice method introduced in "Select the scheduled irrigation plan". On the one hand, the optimal number of solar panels is quantified, and on the other, the scheduled irrigation plan synchronises energy production and consumption.

Case study
The PIN of the University of Alicante, SE Spain (Fig. 6) is analysed as a case study. The irrigated area of the garden is 0.67 km 2 , and it comprises n l = 891 pipes of polyvinyl chloride and fibre cement: Hazen-Williams roughness coefficients equal to 100, a total length of 23 km and diameters below 200 mm. There are n n = 160 consumption nodes that embody a valve to control when water is delivered (or not) to each consumption node. The water must be distributed to the consumption nodes with pressure above P th = 25 m.w.c.
The scenarios studied here are: • Case 0 (current operation scheme). The PIN in this scenario works four days a week on-grid. The water injected into the network is equal to 3078.2 m 3 /week, a value is 439.7 m 3 /day, and its rate remains constant to allow for comparison between the Cases. • Case I (following the proposed scheduling algorithm): The daily irrigation time is T p = 15 h (i.e. a typical value for Spanish latitudes in July), a value composed of k = 60 slices of Δt = 15 min each. This condition means that the irrigation schedule may vary every 15 min; in short, when a valve is opened, it will deliver water for, at least, this time. These numbers must meet the constraint • T p = k ⋅ Δt . With these premises, the potential irrigation schedules can be computed as 2 k * n n = 2 60 * 160 = 1.685 * 10 66 combinations. To analyse seasonal variation, we analyse Case I in July and in December (the month with the lowest irradiance in these latitudes). Corresponding to heuristic indications provided by irrigation network managers and gardeners, irrigation in December is estimated to be half as much as in July (the month with the highest water demand). The scenarios considered are used to test the performance of the system sizing and planning algorithm. In case of wanting to optimise in both scenarios simultaneously, an additional energy source or storage system should be considered. However, this would be outside the present investigation, as discussed in the conclusion Section.
Because of the operational work, the utility manager identified the greatest flow to be injected into the system (28.57 l/s). This value was determined as the lower network flow rate threshold Q low, th (Pardo et al. 2020) and presents the smallest flow at which a consumption node was found with pressure below 25 m.w.c. Therefore, by injecting a flow below this limit, the practitioner knows that no pressures below the service pressure will exist.
Besides, it should be highlighted that the power absorbed by every pump can be calculated with Eq. (3). This specific plot only considers three pumps because of the greatest flow conditions.
Equation (13)  is providing water to plots, the algorithm prefers to supply as much volume as possible with the same power consumed. Figure 2 indicates the greatest flow rate injected into the system equal to Q = 15 l/s with a power produced equal to 3.37 kW. The algorithm presents a discontinuity in this power as the algorithm must choose between consuming 3.37 kW, to offer the system Q = 15 l/s or 5.60 l/s (the point at which the discontinuity starts). Flows selected by the algorithm are displayed with a continuous curve (Fig. 2). Hence, the highest flow rate supplied by one pump is fixed to Q = 11.66 l/s for practical purposes. So, larger flow rates need two pumps running in parallel (Fig. 3). The lower network flow rate threshold (28.57 l/s) is the maximum that can be supplied into the network to avoid pressure problems at the consumption nodes.

Energy production data
To determine the energy produced by a single PV panel, we calculate irradiance from the Duffie and Beckman equations (Duffie and Beckman 2013). Several parameters influence the hourly energy produced by PV arrays. The values used can be found in Table 1.
Under the conditions of equal sunset hour angle ( s ) and total day-generated energy, the irradiance equation results in a Kasten-Czeplak model (Eq. 14 for July and Eq. 15 for December).
The specific shape of these two functions is also shown in Fig. 8. And integrating the curve, a single module produces 189.1Wh/day in July and 70.16 Wh/day in December.

Numerical results for the new schedule
The first results are presented in Table 2. The algorithm solves the problem to deliver the daily volume (439.68 and 219.84 m 3 /day; half as much in winter as in summer) in July and December.   The available volume corresponds to the volume that could be extracted by handling all the power generated by the optimum number of solar PV modules. SSE is the objective function for the scheduling sub-problem described in Eq. (9)-the difference between the needed (total volume) and available volumes-being an indicator of the goodness of fit between the energy provided by the PV modules and that needed to feed the irrigation network. Additionally, the difference in volume (between the volume that could be delivered during the day and that delivered with the new irrigation schedule) in each slice for the proposed solution is shown in Fig. 9. The results of the July simulation are shown on the left-hand side, while the December simulation is shown on the right. It should be noted that (Fig. 9) July incorporates many more slices (from 6.25 to 16.75 h) where flows can be delivered than in December (from 8.5 to 14.5 h). This is a direct consequence of the fact that there are more hours of irradiance in July (Fig. 8). Finally, the ideal solution implies that at all times of the day, as much flow as possible can be delivered. The surplus flow equals 0 at all times of the day.

New schedule for the cases
The algorithm also returns an amount of data indicating when each node must open to deliver water to crops. The specific result can be shown as a matrix with 160 rows (i.e. number of nodes) and k = 60 columns (i.e. number of slices). Likewise, Fig. 10 shows the injected flow per pump and the number of pumps operating at every time of the day. As using the second pump in parallel involves high energy consumption, the algorithm intends to enlarge the time supplying the maximum flow rate with one pumping unit. Figure 10 also depicts the current situation where the irrigation time starts at 19:00 h. Note that the current situation (Case 0) involves irrigating only four nights per week, and with the future schedule (Case I, July), the irrigation pattern repeats daily for seven days.

Energy consumption and production with the new schedule considering seasonal variation
In Case I (July), the gardens of the University are irrigated employing the flow distribution represented in Fig. 10. This number accounts for an energy consumption equal to 49.95 kWh/day. While the first pump operates 10.75 h per day (from 6:45 to 17:30 h), the second pump runs for 2.75 h (from 10:45 h to 13:30 h) and the remaining (third and fourth pumps) do not switch on during the whole day. This daily expenditure and production can be observed in Fig. 11 (left side). The least-square scheduling algorithm fitted the power production and consumption by changing the schedule to convert the PIN into an off-grid system.   Figure 11 (right side) shows the daily energy expenditure and production in December-the period of lowest irradiance (in this latitude) and lower water demand by the crops. The pumping devices work in December for 6.25 h per day (from 9:00 to 15:15 h), a limitation imposed by the sunshine hours. It is equal to 23.10 kWh per day.

Discussion
It bears no surprise that powering the pumping station of a PIN with PV panels in a stand-alone system (off-grid system) is a viable result (Agostini et al. 2021). Even more so in locations with medium-to-high solar irradiance, stand-alone PV systems achieved high renewable power generation reliabilities (Campana et al. 2015). However, optimal fitting the energy produced with the energy consumed is a complicated task and needs an optimisation algorithm. The least square algorithm has been tested on a real PIN, depending on solar irradiance level and the power rating of PV modules. The installation was sized to deliver the water demanded by crops (352 modules for July and 435 in December, Table 1). This algorithm is deterministic and returns a quick result (0.37-0.51 s) compared to the genetic algorithm.
The result of the simulation in both months shows that although the water consumption (and therefore the energy) needed for irrigation is lower in December, more panels must be installed because of the lower energy produced. The energy production is more restrictive than the decrease in consumption, and the decision-makers should size the installation with 435 panels if they want to work as an off-grid system all year round.
Results show that the SPWS can extract 441.2 and 219.91 m 3 /day (in July and December) when the average water consumption is 439.68 and 219.84 m 3 /day, respectively. Equation 9 allows calculating the discrepancy between the flow demanded by crops (scheduled in Case I) and the flow that can be supplied. This discrepancy has been minimised for both simulations by the least squares algorithm and plotted in Fig. 9. This approach can be extrapolated to any other pressurised irrigation network and any other location. Without a doubt, according to latitude, the number of irradiance hour per year vary and results can be more or less profitable (Pardo et al. 2022a).
Pumps work now for 49.5 h/week absorbing 63.83 kWh/ day in July (Chabour et al. 2022). The algorithm found the best schedule (i.e. which also reduces energy consumption) with the pumping devices running seven days during sunny hours. The algorithm adjusts the energy consumption to the energy production of the solar panels-delivering the same volume of water to the crops. Figure 10 depicts flow injected into the irrigation network (Case 0; flow injected in the current situation). The new irrigation schedule delivers water for 75.75 h per week, consuming 49.95 kWh/day. Comparing both scenarios, this new schedule saves 63.83-49.95 = 13.88 kWh/day in July. It is also worth mentioning that in the July simulation, two pumps were started for 2.75 h/day, while in the December simulation, only one pumping unit was used.
Earlier approaches (Todde et al. 2019) quantified 67 and 41% energy savings in their case studies in Morocco and Portugal. This work saved 21.74% of the energy used, a moderate value compared to those overwhelming values presented before. However, interesting to highlight that this approach is focused on minimising the installation size by scheduling water demanded by crops, the energy reduction was not the mission. This new off-grid system (Case I) will save the emissions associated with the current state (Case 0) 63.83*365 = 23,297.95kWh/year, with no unsupplied demands and with pressures above the service threshold (25 m.w.c.). Other approaches satisfied 96% of irrigation requirements García et al. (2020), which can be accepted as a different approach to other requirements.
With the results presented by the algorithm, we can calculate the daily energy produced 352*0.1891 = 66.57kWh/ day (435*0.0701 = 30.52 kWh/day) in the simulations performed for July (and December). The energy consumption is equal to 49.95 and 23.10 kWh/day in July and December (pumps run 75.25 and 43.75 h per week in each simulation). Besides, these figures highlight that 75.03% (or 75.71%) of the energy produced is consumed in pumping units while 24.97% (or 24.29%) left cannot be used. Similar values of misused energy (25.14%) were achieved in Gómez Melgar et al. (2020) after rescheduling energy demands in buildings. Finally, the next step in this research focuses on reducing unused energy of this produced in the PV system. Dispersed solar PV panel placement and energy storage are the best strategies (Richardson and Harvey 2015), including the lithium-ion battery (Terlouw et al. 2019).

Conclusions
Pressurised irrigation networks are very energy hungry in regions where rainfall is scarce; a large amount of energy is used every day to pump the water needed by crops. A stand-alone (off-grid) solar-powered energy system allows to supply the required volume of water to crops throughout the week at all hours of sunshine, with less environmental impact. However, efficiently fitting the energy produced with the energy consumed is a complex procedure.
First, this paper adopts a least-square optimisation algorithm for scheduling water delivery to crops. The energy management strategy is achieved in a way that the system is programmed using the proposed algorithm and works autonomously so that the shut-off valves open and close (automatically controlled) to get the new operating scheme. As a result, the sum of these demands (produced by opening of the irrigation valves) results in a total flow, and subsequently energy, supplied by the pumping system. Furthermore, following the proposed algorithm, the energy consumed by water pumps fits the energy produced in PV solar modules, while satisfying the water need and minimising the number of PV modules needed. An objective function to minimise the sum of squares errors is proposed to assess the variations between the target flow rate and the real injected flow. This algorithm is deterministic and returns a quick result (0.37-0.51 s) compared to the genetic algorithm (days).
Lastly, the algorithm efficiently returns as an output the irrigation scheduled plan to consume the highest energy available by solar PV modules. This method has been tested in the actual PIN in San Vicente Campus, the University of Alicante, Spain (while applying to any other location). Currently, this network can work seven days a week with less energy consumption and is based only on solar PV energy. A huge amount of energy (21.74%) and tons of carbon dioxide (CO 2 ) can be saved per year by using the proposed algorithm, which results in economic and environmental savings. Energy savings are moderate when compared to other approaches, but this approach keeps the hypothesis that all water demands are fully covered, and the algorithm minimises the solar-powered installation sizing.
Some guidelines for future work emerge from this study. First, the effect of shadows on solar PV electricity production should be carried out and addressed for new versions of the developed software tool. Second, the hybrid solution of solar PV complemented with wind energy could be explored as this solution could solve the temporal uncertainty in PV generation (as wind power production is heavier at night-time). Future research projects should consider the effect of a battery storing the surplus energy achieved at midday (which the case study revealed 24.97%, values like others found in literature). At last, the environmental and/or economic perspective has not been considered in the analysis of the optimization results. These terms deserve attention from the stakeholder's perspective.
Author's contribution FJN involved in study conception and design, methodology, software, formal analysis and writing review and editing. MAP involved in conceptualisation, methodology, formal analysis, data curation, analysis of results and writing review. H.EC involved in methodology, data collection, draft manuscript preparation, formal analysis, software and editing. TA involved in analysis of results and writing review and editing. All authors reviewed the results and approved the definitive version of the manuscript.
Funding Open Access funding provided thanks to the CRUE-CSIC agreement with Springer Nature. Open Access funding provided thanks to the CRUE-CSIC agreement with Springer Nature. This work was supported by the research project "DESENREDA" through the 2021 call "Estancias de movilidad en el extranjero Jose Castillejo" of the Ministerio de Universidades (CAS21/00085) and for the project "Hi-Edu Carbon" Erasmus Plus Programme, Key Action KA22021, action type (2021-1-SK01-KA220-HED-000023274.
Data availability Data are available upon request.

Conflict of interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
Ethical approval Not applicable. Consent to participate Not applicable.

Consent for publication Not applicable.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http:// creat iveco mmons. org/ licen ses/ by/4. 0/.