scieee AI-readable full text Open interactive document viewer

Optimal pumping flow algorithm to improve pumping station operations in irrigation systems

Bonet Gil, Enrique,Yubero de Mateo, Maria Teresa

Abstract

In Spain, irrigated agriculture is the most water-intensive sector, consuming around of 80% of water resources. Moreover, irrigation water distribution systems are the infrastructure by which one-third of water resource losses take place. Monitoring and controlling operations in irrigation canals are essential for mitigating leakages and water waste in operational actions. On the other hand, energy consumption by agriculture is around 5% of usage in developed countries and even higher in undeveloped countries. Although it is a small part of the total energy supply for a country, energy waste reduces the competitiveness of the agriculture sector, which continually reduces profit margins in an economic sector with very low profit margins already. The tool developed in this paper aims to increase the efficiency of water and energy management in the agricultural sector and is included in an overall control diagram for scheduled irrigation management. This tool, the optimal pumping flow (OPF algorithm), optimizes the pumping flow from the irrigation canal to the irrigation reservoir in terms of water level at the canal and reservoir, crop flow demand, system constraints, and energy prices. Regarding the results, the OPF algorithm can calculate the optimum pumping operations, being able to optimize water resource usage and energy expenses by ensuring that the water level at reservoirs remains within a specified range and that pump flow never exceeds a threshold. Further, it allows for the management of pump operations outside of peak hours. On the other hand, the OPF algorithm is also integrated into the overall control diagram in a second test. Here, the OPF algorithm collaborates with a control canal algorithm such as the GoRoSo algorithm to optimize canal gates and pump operations, respectively. In this scenario, OPF reduces cumulative energy expenses by 58% compared to the scenario where the pump station operates only when the reservoir water level is below a certain threshold.

Full text

Agriculture 2024, 14, 463. https://doi.org/10.3390/agriculture14030463 www.mdpi.com/journal/agriculture Article Optimal Pumping Flow Algorithm to Improve Pumping Station Operations in Irrigation Systems Enrique Bonet * and María Teresa Yubero Department of Mining, Industrial and ICT Engineering, Universitat Politécnica de Catalunya (UPC), Les Bases Avenue 61-73, 08242 Manresa, Spain; [email protected] * Correspondence: enriq[email protected] Abstract: In Spain, irrigated agriculture is the most water-intensive sector, consuming around of 80% of water resources. Moreover, irrigation water distribution systems are the infrastructure by which one-third of water resource losses take place. Monitoring and controlling operations in irrigation canals are essential for mitigating leakages and water waste in operational actions. On the other hand, energy consumption by agriculture is around 5% of usage in developed countries and even higher in undeveloped countries. Although it is a small part of the total energy supply for a country, energy waste reduces the competitiveness of the agriculture sector, which continually reduces profit margins in an economic sector with very low profit margins already. The tool developed in this paper aims to increase the efficiency of water and energy management in the agricultural sector and is included in an overall control diagram for scheduled irrigation management. This tool, the optimal pumping flow (OPF algorithm), optimizes the pumping flow from the irrigation canal to the irrigation reservoir in terms of water level at the canal and reservoir, crop flow demand, system constraints, and energy prices. Regarding the results, the OPF algorithm can calculate the optimum pumping operations, being able to optimize water resource usage and energy expenses by ensuring that the water level at reservoirs remains within a specified range and that pump flow never exceeds a threshold. Further, it allows for the management of pump operations outside of peak hours. On the other hand, the OPF algorithm is also integrated into the overall control diagram in a second test. Here, the OPF algorithm collaborates with a control canal algorithm such as the GoRoSo algorithm to optimize canal gates and pump operations, respectively. In this scenario, OPF reduces cumulative energy expenses by 58% compared to the scenario where the pump station operates only when the reservoir water level is below a certain threshold. Keywords: agricultural demands; irrigation canal control; pump flow optimization; open channel flow; optimization algorithms 1. Introduction As is well known, water and energy are scarce resources. On planet Earth, 97.6% of water is found in seas and oceans, while the remaining 2.4% is freshwater, which is distributed as follows: according to Gleick Peter Gilbert F. [1], 1.9% of this total is in glaciers and polar ice caps, 0.5% is groundwater, and 0.02% is in surface water (rivers, lakes, reservoirs, etc.), as shown in Figure 1. It is estimated that only 0.025% of the total water on Earth is drinkable. Global water use has multiplied sixfold in the last 100 years and continues to increase by 1% annually due to population growth, economic development, and consumption patterns. Climate change has a negative impact on the quantity and quality of available water needed to meet global human needs according to UNESCO [2]. The global population is rapidly growing, with expectations of reaching 8 billion people in 2030 and being just shy of 10 billion people in 2050 according to the United Nations [3], both of which are figures that suggest an imminent surge in global food demand. Citation: Bonet, E.; Yubero, M.T. Optimal Pumping Flow Algorithm to Improve Pumping Station Operations in Irrigation Systems. Agriculture 2024 , 14, 463. https://doi.org/10.3390/ agriculture14030463 Academic Editors: Claudia Di Bene, Valentina Baratella and Silvia Vanino Received: 5 February 2024 Revised: 28 February 2024 Accepted: 5 March 2024 Published: 12 March 2024 Copyright: © 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/license s/by/4.0/). Agriculture 2024, 14, 463 2 of 27 Figure 1. Global water distribution graph in [1] (data source: Igor Shiklomanov's chater "World fresh water resources" in Peter H. Gleik (editor), 1993, Water in Crisis: A guide to the World's Fresh Water Resources. (Numbers are rounded)). Climate change manifests itself in the increased frequency and magnitude of extreme events such as heatwaves, heavy precipitation, and storms, among others. Water quality will be affected by rising temperatures, decreased dissolved oxygen levels, and consequently reduced self-purification capacity in freshwater reservoirs. Additionally, the degradation of ecosystems sensitive to climate change, such as forests and wetlands, should be taken into account. This not only leads to biodiversity losses, but also affects the services provided by these ecosystems, such as water purification, carbon storage, flood protection, and water supply according to Salimi S. et al. [4]. Optimizing energy use is a crucial goal for the agriculture sector. This is not just useful for economic sustainability but environmental sustainability as well, reducing water losses due to wrong operations and CO2 emissions, which are quite high even now according to Romano G. et al. [5]. As shown in Figure 2, the primary energy sources in Spain were oil and natural gas, with 39.6% and 21% shares of the market in 2017, respectively. These were usually used to generate electricity according to International Energy Agency [6]. On the other hand, by 2021, wind energy had become the increasingly leading source of renewable energy. This is shown in Figure 2, which illustrates the evolution of energy sources in Spain. In 2015, 27% of consumed energy came from renewable sources, while by 2020, this percentage had increased to 31%. Therefore, there is a clear trend towards an increased consumption of renewable energy. As such, we have to reduce fuel source use but we have also to optimize energy consumption by reducing CO2 emissions. Figure 2. Energy supply distribution in Spain in 2015 and 2021 (data source: International Energy Agency: https://www.iea.org/countries/spain (accessed 12 October 2023)). Agriculture 2024, 14, 463 3 of 27 On the other hand, there exists a huge problem in agriculture surrounding increasing labour, seed, and machinery costs, as well as energy costs, during recent years. In that sense, the increase in energy cost reduces agriculture competitiveness in developed countries, as well as increasing the CO2 emissions to the atmosphere, so all actions derived from reducing energy expenses and optimizing energy consumption in the agriculture sector are mandatory. The energy price in Spain is established by the marginalist system. The main characteristic of this system is that the energy price is estimated by the point of intersection between demand and supply; see Peña J. I. [7]. The intersection point represents the maximum price at which the energy package is sold, so all sellers who have proposed an energy price value equal to or lower than the market price will sell their energy package. Conversely, for all buyers who have presented an offer equal to or higher than the energy market price, all offers will be accepted. Therefore, this system encourages energy producers to adopt a strategy where their offers have the lowest possible price, contributing to a more efficient energy generation system. The greater the difference between the intersection price and the energy production cost, the higher the profit margin. This margin is often used in competitive markets where supply and demand interact to determine prices. It helps to ensure that resources are allocated efficiently and that production is aligned with consumer demand. However, in scenarios where energy demand grows rapidly and energy resources decrease, the energy price also grows sharply. Regarding the current scenario, taking action to increase water savings and optimize energy costs is crucial for the agriculture sector. This is the reason why we developed the OPF algorithm, which optimizes pumping flow trajectories to minimize energy expenses and manage crop water demand. In the bibliography, there are several authors who have proposed various initiatives to optimize pumping stations. For instance, Alizadeh et al. [8] focused on pump type selection, capacity, number of units and energy cost, using the Lagrange method to solve the optimization problem. Instead, Müller et al. [9] employed mixed-integer nonlinear and mixed-integer linear model approaches to address the optimization problem. Additionally, other authors such as Khwaja and Tung [10] and Egito et al. [11] proposed the use of genetic algorithms to solve the optimization problem. All of them used different approaches to solve the same objective: pump station energy optimization. In that sense, the OPF algorithm has been developed in this manuscript to optimize pumping energy expenses. However, this algorithm operates within an overall control diagram that manages an irrigation system, with each algorithm optimizing a specific process within the diagram. In this sense, the OPF algorithm optimizes pumping flow trajectories during a period of time and it is applied to join with the GoRoSo algorithm, which is a feedforward control algorithm; see Soler et al. [12], who optimized the irrigation canal gates operations. Both algorithms work together in order to optimize the irrigation system operations, i.e., canal operation using GoRoSo and pumping station operation using OPF. In this manuscript, the OPF algorithm has been described and tested in several numerical examples to manage irrigation systems. First of all, the algorithm was tested considering two individual pumping stations supplying two separate regulatory reservoirs. In a second example, the OPF algorithm was assessed in conjunction with the GoRoSo algorithm in a more complex case based on the test cases introduced by the ASCE Task Committee on Canal Automation Algorithms, as discussed by Clemmens [13]. In both cases, the robustness and sensitivity of the algorithm were evaluated. 2. Methodology Control systems for irrigation canals were developed to improve water infrastructure operations, with the main objective being to meet the water demands of crops for every irrigation cycle. In that sense, water demand could be planned in advance, but crop requirements are dynamic over time due to climatic factors. Therefore, the main tools of control systems in irrigation canals should be implemented considering both steady state Agriculture 2024, 14, 463 4 of 27 and unstable conditions through online and offline control algorithms. These algorithms are able to adjust operations, mainly gate operations and switching pumps on/off, based on water demands and system constraints. All these algorithms estimate the correct operations to increase efficiency in irrigation systems, which depend on water level sensors and actuators to propose the correct operations. However, all of them must contribute synchronously to fulfill the main objective, as there are dependencies among all algorithms. Therefore, coordination of actions is mandatory for the correct development of every task to save water resources and energy, as depicted in Figure 3. For this reason, the construction of any modern online–offline predictive control model involves multiple different algorithms working together. Figure 3. Overall control diagram of irrigation canal 1. “Crop needs and desired hydrographs for canal outlets”: The crop needs are estimated to obtain the water demand. In that sense, water demand is also translated to “desired water level” (Y*) at several sections of the irrigation canal. 2. “Offline computation of the reference trajectories”: The desired water levels (Y*) are provided to the GoRoSo algorithm (offline reference trajectory computation), which calculates the optimum canal gate trajectory (Ur) during an irrigation period to minimize gate movements while maintaining the desired water level at specific canal sections. This is essential for diverting the correct water demand through the gravity orifice offtake, as illustrated in Figure 4. The GoRoSo algorithm is a feedforward Agriculture 2024, 14, 463 5 of 27 control algorithm that calculates the optimum canal gate trajectories in advance of the next irrigation cycle, according to Soler et al. [12]. 3. “Offline parameter identification”: The estimation of particular hydraulic coefficients, such as Manning coefficient or gate discharge coefficient; see the FCA algorithm (Bonet et al. [14]) or Coon W. F. [15]. 4. “Offline pumping trajectory computation”: A pumping station is required to supply flow from the irrigation canal to a higher regulatory reservoir. In that sense, the regulating reservoir also supplies water to irrigation crops; see Figure 4. The OPF algorithm introduced in this manuscript calculates the optimum pumping flow trajectory during a period of time in order to reduce energy consumption and expenses associated with providing for crop water demand and maintaining system requirements. Other authors have proposed different algorithms in this area such as Lindell E. et al. [16], Bohórqueza J. et al. [17], McCormick G. and Powell A R. S. [18] or Reis, A.L. [19]. 5. “Online current state computation”: In order to evaluate the correct behaviour of the irrigation system, it is imperative to measure the current state of the irrigation system. In this regard, all data stored in the database are crucial, such as “U” (gate position) and YM (measured water level), previously measured by sensors at target points in the canal. Anomalies between the measured water level and the desired water level at target points are because of flow disturbances introduced to the system. In such circumstances, the CSE algorithm is able to estimate the flow disturbances in the canal (Bonet E. [20]), representing the real water demand in the canal. Additionally, the algorithm can determine the current hydrodynamic state of the canal, which is highly valuable in any scenario. The hydrodynamic state of a canal is defined as the velocity and water level at each cross-section of the canal. 6. “Online predictive control”: In case of water anomalies regarding the irrigation system state planification, it is necessary to estimate the real water demand and the current hydrodynamic state of the canal, which are provided by the CSE algorithm. In this context, the real water demand, reference gate trajectories, and the hydrodynamic canal state are supplied to the control algorithm, known as “Online Predictive Control”, which must recalculate a new gate trajectory (U) in real-time to return to the reference behaviour for a predictive horizon time period. There is an extensive bibliography of feedback control algorithms that recalculate the gate trajectories, such as those proposed by Aguilar J. V. et al. [21], Litrico et al. [22], Clemmens et al. [23], GoRoSoBo (Bonet E. et al. [24]), and Wahlin et al. [25]. In order to introduce the OPF algorithm in the overall control diagram of an irrigation canal, it would be useful to divide the diagram into two parts: the online and the offline computation, although the offline computation module (green box in Figure 3) could be applied independently of online modules. This paper is only focused on the offline computation module because the OPF algorithm was exclusively applied for planning tasks. Specifically, the OPF algorithm will support the operational tasks by estimating the pumping operations for a planned irrigation period (not in real-time). The offline module is applied for operational purposes in a planning mode, whereas the online module is only applied in the case of a highly dynamic system with unknown processes. The main processes developed by each algorithm in the online computations are beyond the scope of this manuscript but can be reviewed in Bonet E. [24]. Regarding offline computation processes, the sequential processes included in this manuscript are as follows: the offline computation module starts once offline parameter identification has estimated the correct hydraulic coefficients, so a feedforward control algorithm, such as GoRoSo, calculates the optimum canal gate trajectories for a horizon period of time (also called irrigation cycle) in order to reach the irrigation management objectives, i.e., water level targets at specific canal sections, in order to supply the correct water flow demand at the gravity orifice offtake; see Figure 4. GoRoSo also considers pumping flow trajectories at specific canal sections (water flow to regulatory reservoirs above the irrigation canal) for a horizon period of time. Once GoRoSo finishes all Agriculture 2024, 14, 463 6 of 27 calculations, the output information is shared with the OPF algorithm, which recalculates the optimum pumping flow trajectories regarding new canal water levels, system behaviour and requirements (i.e., regulation reservoirs, pipelines and irrigation canal) and crop demand (located further up than irrigation canal), minimizing energy consumption and expenses. An iterative procedure is applied to the algorithm to achieve a convergence criterion previously defined to obtain the optimum solution; see Figure 3. In that sense, the OPF algorithm is working together with GoRoSo in an iterative process in order to estimate the optimum pumping flow trajectories and canal gate trajectories, respectively, for planning and managing the irrigation system properly. The development of the GoRoSo algorithm is beyond the scope of this paper, which can be reviewed in Soler et al. [11]. In this paper, we focus on offline pumping trajectory computation solved by the OPF algorithm. The optimum pumping flow trajectory is crucial for any pumping station and irrigation system management due to high energy expenses as well as pumping station maintenance costs. In this sense, higher energy expenses affect the farmers’ P&L, reducing the irrigation system’s competitiveness. Figure 4. Simplified overall control diagram (offline computation) applied to an irrigation system. In conclusion, the OPF algorithm presented in this manuscript is conceived as an algorithm included in the “offline pumping trajectory computation” process at the overall control diagram of an irrigation system. The algorithm estimates the optimum pumping Agriculture 2024, 14, 463 7 of 27 flow trajectories, reducing energy expenses and providing for the crop water demand, maintaining system requirements for a regulated period of time. The OPF solves an optimization problem implemented as a constrained linear optimization problem using the SLSQP method (sequential least square programming), whose solution is the pumping flow trajectories associated with a minimum energy expense. 2.1. SLSQP (Sequential Least Square Programming) SLSQP is designed to solve non-linear problems efficiently. Specifically, this method solves the system by performing a quadratic approximation of the objective function and the constraints, thus avoiding the direct calculation of the Hessian matrix. The steps involved in the optimization of the resolution to the problem are as follows: Consider a nonlinear optimization problem from Equation (1) min 𝑥𝑥 𝑓𝑓(𝑥𝑥 𝑘𝑘 ) 𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼 𝑐𝑐𝑐𝑐𝐼𝐼𝑐𝑐𝐼𝐼𝑐𝑐𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝑐𝑐: ℎ(𝑥𝑥)≥0 𝐸𝐸𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼 𝑐𝑐𝑐𝑐𝐼𝐼𝑐𝑐𝐼𝐼𝑐𝑐𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝑐𝑐: 𝑔𝑔(𝑥𝑥)= 0 (1 ) The Lagrangian function of this problem is as follows: 𝐿𝐿(𝑥𝑥,𝜆𝜆,𝜎𝜎)=𝑓𝑓(𝑥𝑥)−𝜆𝜆ℎ(𝑥𝑥)−𝜎𝜎𝑔𝑔(𝑥𝑥) (2 ) where 𝜆𝜆 and 𝜎𝜎 are the Lagrange multipliers (scalars). On the other hand, we can evaluate the incremental solution as follows: 𝑐𝑐(𝑥𝑥𝑘𝑘+∆𝑥𝑥)=𝑐𝑐(𝑥𝑥𝑘𝑘)+𝑐𝑐′(𝑥𝑥𝑘𝑘)∆𝑥𝑥 + 1 2𝑐𝑐′′(𝑥𝑥𝑘𝑘)∆𝑥𝑥2 𝑑𝑑𝑐𝑐(𝑥𝑥𝑘𝑘+∆𝑥𝑥) 𝑑𝑑𝑥𝑥=𝑑𝑑 𝑑𝑑𝑥𝑥�𝑐𝑐(𝑥𝑥𝑘𝑘)+𝑐𝑐′(𝑥𝑥𝑘𝑘)∆𝑥𝑥 + 1 2𝑐𝑐′′(𝑥𝑥𝑘𝑘)∆𝑥𝑥2�=𝑐𝑐′(𝑥𝑥𝑘𝑘)+𝑐𝑐′′(𝑥𝑥𝑘𝑘)∆𝑥𝑥= 0 ∆𝑥𝑥= 𝑠𝑠′(𝑥𝑥𝑘𝑘) 𝑠𝑠′′(𝑥𝑥𝑘𝑘)=𝑥𝑥𝑘𝑘+1−𝑥𝑥𝑘𝑘 (3 ) Applying the Newton standard method to optimization problems (1) and (2) considering the incremental solution approach (3), �𝑥𝑥𝑘𝑘+1 𝜆𝜆𝑘𝑘+1 𝜎𝜎𝑘𝑘+1�=�𝑥𝑥𝑘𝑘 𝜆𝜆𝑘𝑘 𝜎𝜎𝑘𝑘�−�∇𝑥𝑥𝑥𝑥 2𝐿𝐿 ∇h∇g ∇hT0 0 ∇𝑔𝑔T0 0 � −1 � � � � � � � � � � � � � �∇f + 𝜆𝜆𝑘𝑘∇h + 𝜎𝜎𝑘𝑘∇g ℎ 𝑔𝑔� � � � � � � � � � � � � � ∇2ℒ ∇ℒ �𝑥𝑥𝑘𝑘+1 𝜆𝜆𝑘𝑘+1 𝜎𝜎𝑘𝑘+1�=�𝑥𝑥𝑘𝑘 𝜆𝜆𝑘𝑘 𝜎𝜎𝑘𝑘�−(∇2𝐿𝐿)−1∇L (4 ) Nevertheless, the ∇2𝐿𝐿 matrix is frequently a singular or ill-conditioned matrix, so the Newton step term (𝑑𝑑 𝑑𝑑= (∇2𝐿𝐿)−1∇L) cannot be calculated directly. Instead, the basic sequential quadratic programming algorithm (SQP algorithm) defines an appropriate search direction “d” as an iteration process to solve the Newton step. The sequential quadratic problem is applied as follows: Agriculture 2024, 14, 463 8 of 27 𝑀𝑀𝐼𝐼𝐼𝐼𝑑𝑑 𝑓𝑓(𝑥𝑥𝑘𝑘)+∇𝑓𝑓(𝑥𝑥𝑘𝑘)𝑇𝑇𝑑𝑑+1 2𝑑𝑑∇𝑥𝑥𝑥𝑥 2𝐿𝐿(𝑥𝑥𝑘𝑘,𝜆𝜆𝑘𝑘,𝜎𝜎𝑘𝑘)𝑑𝑑 𝑅𝑅𝐼𝐼𝑔𝑔𝐼𝐼𝑐𝑐𝑑𝑑𝐼𝐼𝐼𝐼𝑔𝑔 ℎ(𝑥𝑥𝑘𝑘)+∇h(xk)Td≥0 𝑔𝑔(𝑥𝑥𝑘𝑘)+∇g(xk)T𝑑𝑑= 0 (5 ) Once the Newton step term is found, the process is repeated by a number “i” of iterations until convergence is reached; see Figure 5. The main reason to choose this method is solving an equation system with non-linear constraints, which is a robust method with a fast convergence rate in comparison to other methods such as de Nelder–Mead or Powell. Figure 5. Scheme of SLSQP method. 2.2. The OPF Algorithm The OPF algorithm solves the mass and energy balance equation at irrigation canals and regulation reservoirs regarding water levels and crop water demands. On the other hand, the algorithm also considers the hydraulic power and energy expense equations related to the pumping station and energy price market, respectively. A summary of the OPF algorithm schedule is the following. The algorithm solves a constrained optimization problem where the unknown variable is the pumping flow trajectory, where the objective function is the energy expense during the irrigation cycle, the inequality constraints refer to the maximum and minimum water levels of the reservoir as well as the maximum pumping flow, and the equality constraint makes reference to the mass and energy balance equation. 2.2.1. Objective Function: Energy Expenses Equation The hydraulic power equation for a pumping station is the following: 𝑃𝑃𝑡𝑡(𝐼𝐼)=𝜌𝜌𝑔𝑔�𝑄𝑄𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝(𝐼𝐼)𝐻𝐻𝐻𝐻𝑘𝑘 (𝐼𝐼)� 𝐸𝐸𝑒𝑒𝑥𝑥𝑝𝑝𝑒𝑒𝑝𝑝𝑠𝑠𝑒𝑒𝑠𝑠(𝐼𝐼)=𝑃𝑃𝑡𝑡(𝐼𝐼)𝛥𝛥𝐼𝐼𝐸𝐸𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑒𝑒(𝐼𝐼) (6 ) Agriculture 2024, 14, 463 9 of 27 where 𝜌𝜌 is the water density, 𝑔𝑔 is the gravity term, Δt is the time step, 𝑄𝑄 𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝(𝐼𝐼) is the pumping flow trajectory from the canal to the reservoir, i.e., a vector with x elements (x being the number of pump flow operations during a horizon time of period), and 𝐻𝐻𝐻𝐻 (𝐼𝐼) is the pump head trajectory among the irrigation canal section and the reservoir, i.e., a vector with x elements as well; see Figure 4. On the other hand, Eexpenses(t) is the energy expenses trajectory during the horizon time period and Eprice is the energy price trajectory during the horizon time period, both vectors with an x element. In that sense, the optimal solution is obtained by minimizing the performance criterium, where Eminimum(t) is the minimum energy expense trajectory (i.e., nonenergy cost). 𝑀𝑀𝐼𝐼𝐼𝐼𝐼𝐼𝑀𝑀𝐼𝐼𝑀𝑀𝐼𝐼 𝐽𝐽(𝐸𝐸)=𝑀𝑀𝐼𝐼𝐼𝐼𝐼𝐼𝑀𝑀𝐼𝐼𝑀𝑀𝐼𝐼 �1 2�𝐸𝐸𝑒𝑒𝑥𝑥𝑝𝑝𝑒𝑒𝑝𝑝𝑠𝑠𝑒𝑒𝑠𝑠(𝐼𝐼)−𝐸𝐸𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝(𝐼𝐼)�𝑇𝑇�𝐸𝐸𝑒𝑒𝑥𝑥𝑝𝑝𝑒𝑒𝑝𝑝𝑠𝑠𝑒𝑒𝑠𝑠(𝐼𝐼)−𝐸𝐸𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝(𝐼𝐼)�� (7 ) We have to mention that pump characteristics curves have not been considered in the OPF algorithm in order to reduce the complexity of the system. In that sense, the pumping station efficiency value is considered as 1. Every pump flow operation period is equal to the energy price discretization, i.e., 1 h, and we consider incompressible flow. Regarding pumping flow trajectories, pump head trajectory and energy price can be approached by piecewise functions, so these functions are also defined by vectors considering a constant value for every time step (Δt). 2.2.2. Inequality Constraints The inequality constraints applied in the equation system are the following: Reservoir Condition The reservoir water level must be located among a water level range of values due to maintenance and operation constraints; see Figure 6. 𝐻𝐻𝑝𝑝𝑝𝑝𝑝𝑝<𝐻𝐻(𝐼𝐼)<𝐻𝐻𝑝𝑝𝑚𝑚𝑥𝑥 (8 ) where H is the water level at the regulatory reservoirs, Ta is the width of the wall of a reservoir, and Hmax and Hmin are the maximum and minimum water levels at the reservoir, respectively. Figure 6. Inequality constraints regarding reservoir conditions. Pumping Station Condition The pipeline, which connects the irrigation canal and regulatory reservoir (see Figure 7), is working regarding a maximum water flow in order to keep the pipe wall integrity. 𝑄𝑄𝑘𝑘pumping(𝐼𝐼)<𝑄𝑄𝑝𝑝𝑚𝑚𝑥𝑥 (9 ) where Qmax is the pipeline's maximum flow allowed according to canal geometry and conditions (water level) as well as the pipeline size and velocity requirements. Agriculture 2024, 14, 463 16 of 27 Figure 12. Pumping flow at stations nº1 and nº2 (column chart) vs. water level at regulatory reservoirs nº1 and nº2 (line chart) in scenario I. 3.2. Scenario II: Pumping Flow Optimization Considering Two Regulation Reservoirs and Nonstationary Water Level at the Irrigation Canal Based on the ASCE Test Case This scenario is developed according to the overall control diagram (offline computation). First of all, GoRoSo calculates the optimum gate trajectories regarding scheduled water demands, i.e., gravity orifice offtake for the complete irrigation cycle and initial pumping flow trajectories. All this information is shared with the OPF algorithm which calculates again the optimum pumping flow trajectories regarding regulatory reservoir condition, crop water demand, irrigation canal condition and as energy expenses. As we mentioned before, all these processes are running in an iterative way, so GoRoSo and OPF recalculate the optimum gates and pumping flow trajectories once again until convergence is reached. The iterative process stops when the residual error is minimized and there are no changes in the gate and pumping flow trajectories, reaching an optimal solution. The processes template of the overall control diagram is introduced in Figure 5. In this scenario II, the OPF algorithm is also tested assuming two regulation reservoirs are connected to a pumping station, but the irrigation canals’s behaviour is also considered. In that sense, both pumping stations introduce water level and flow perturbations at the irrigation canal just in case pumping stations are operating. Therefore, pumping stations can influence the flow conditions in the canal. In conclusion, the OPF algorithm operates alongside the GoRoSo algorithm, as both algorithms calculate pumping flow trajectories and canal gates trajectories, respectively, in an iterative process. For this scenario, we introduce the test cases that were proposed by the ASCE committee to evaluate control algorithms (Clemmens et al. [13]), so irrigation canal features for the GoRoSo algorithm are provided by test case 22. On the other hand, the OPF algorithm considers the same initial and boundary conditions and equality constraints as described in scenario I. Instead, the pipeline inequality constraint was adapted to the new scenario II, with a maximum pumping flow of 1 m3/s, because boundary conditions were estimated considering a higher crop flow demand than scenario I. Agriculture 2024, 14, 463 17 of 27 3.2.1. Irrigation Canal The ASCE committee’s proposed test cases (Clemmens et al. [13]) are evaluated using the Corning Canal, which is based on the upstream portion of the actual Corning Canal in California. This canal is characterized by its length, gentle slope, and significant storage capacity. Spanning 28 km, the canal features trapezoidal cross-sections and is divided into eight pools separated by rectangular gates. The canal is delimited by a total of nine points (numbered 0 to 8), as illustrated in Figure 13. The first point (0) solely contains the initial sluice gate, serving as a boundary between the canal and a large reservoir; it is not considered a checkpoint. Additional hydraulic structures along the canal include orifice offtakes, emergency lateral spillways, and pump stations, all located at the downstream end of each pool, where water level measurements are taken. Figure 13 illustrates the geometry of the canal, including the numbering scheme for the pools and nodes utilized. Table 5 provides an overview of the general characteristics of the canal pools, while Table 6 outlines the features of the hydraulic control structures at each node. Additionally, Table 6 includes the pump station number corresponding to a specific target point. Table 5. Features of Corning Canal pools. Pool Number Pool Length (km) Bottom Slope Side Slopes (H:V) Manning’s Coefficient (n) Bottom Width (m) Canal Depth (m) I 7 10 × 10 −4 1.5:1 0.02 7 2.5 II 3 10 × 10 −4 1.5:1 0.02 7 2.5 III 3 10 × 10 −4 1.5:1 0.02 7 2.5 IV 4 10 × 10 −4 1.5:1 0.02 6 2.3 V 4 10 × 10 −4 1.5:1 0.02 6 2.3 VI 3 10 × 10 −4 1.5:1 0.02 5 2.3 VII 2 10 × 10 −4 1.5:1 0.02 5 1.9 VIII 2 10 × 10 −4 1.5:1 0.02 5 1.9 Table 6. Corning Canal control structures (0* the pumping station only pumps the excess flow from the last pool of the canal). Target Points Gate Discharge Coefficient Gate Width (m) Gate Height (m) Step (m) Length from Gate 1 (km) Orifice Offtake Height (m) Lateral Spillway Height (m) Pump Station Number 0 0.61 7 2.3 0.2 0 - 3 - 1 0.61 7 2.3 0.2 7 1.05 2.5 1 2 0.61 7 2.3 0.2 10 1.05 2.5 2 3 0.61 7 2.3 0.2 13 1.05 2.5 - 4 0.61 6 2.1 0.2 17 0.95 2.3 - 5 0.61 6 2.1 0.2 21 0.95 2.3 - 6 0.61 5 1.8 0.2 24 0.85 1.9 - 7 0.61 5 1.8 0.2 26 0.85 1.9 - 8 - - - - 28 0.85 1.9 0* As previously mentioned, the test case presented in this paper is based on test case 2-2. The simulation’s time horizon is set at 12 h (43,200 s). The time interval between successive control actions for canal gates is established at T = 900 s (15 min). However, for Agriculture 2024, 14, 463 18 of 27 pumping flow actions, the time interval between successive control actions is set at T = 3600 s (1 h). Thus, canal gates can operate four times faster than pumping stations. The upper boundary condition is set by a constant water level provided by a large reservoir upstream from the first gate at the Corning Canal, which is equal to 3 m over the entire simulation . Conversely, the boundary conditions for each pool are determined by the discharge through the gravity orifice offtake and the flow extracted by the pump, both located downstream of each pool. At the end of the canal, the pump extracts a constant water flow of 3 m3/s. The initial conditions for the test case, detailed in Table 7, correspond to the initial steady state of the canal, as well as the gravity flow demand at the orifice offtake. It be should noted that pump stations are not operating at initial conditions, so the flow perturbations introduced into the canal when pump stations start to operate are significant. Figure 13. Corning Canal profile. The triangles mark the position of checkpoints (which are defined by a pump station, gravity orifice offtake, lateral discharge, gate and water level sensor; see the figure on the right). The first pool is number I and the first checkpoint is number 1. Table 7. Corning Canal initial and boundary conditions. Pool Number Gravity Orifice Offtake Flow (m 3 /s) Check Initial Flow (m 3 /s) Target Water Level (m) Pumping Flow (m 3 /s) Heading - 13.5 - 0 I 1.0 12.5 2.1 0 II 1.0 11.5 2.1 0 III 1.0 10.5 2.1 0 IV 1.0 9.5 1.9 0 V 2.5 7.0 1.9 0 VI 2.0 5.0 1.7 0 Agriculture 2024, 14, 463 19 of 27 VII 1.0 4.0 1.7 0 VIII 1.0 3.0 1.7 3 Furthermore, the canal is required to maintain certain values of water levels at the checkpoints as it controls the flows through the gravity orifice offtakes, and the watermaster must deliver the scheduled delivery demands downstream of the canal during the whole irrigation cycle, which, in this test case, lasts 12 h. The desired water levels or target levels are introduced in Table 7 for each checkpoint in the Corning Canal, which is also the location to measure the water level at every time step (every 900 s). 3.2.2. Reservoir and Pipeline System On the other hand, the reservoir features and initial conditions, as well as pipeline features, are represented in Tables 8–10. Table 8. Regulatory reservoir features. Regulatory Reservoir Number Square Reservoir Bottom (Width and Length) (m) Reservoir Wall Slope (H:V) Reservoir Depth (m) 1 303 1/3:1 2 2 311 1/3:1 2 Table 9. Regulatory reservoirs and system initial conditions. Regulatory Reservoir Number Initial H reservoir (Height among Bottom and Water Level at Regulatory Reservoir (m.c.a.) Htotal (Total Height among Irrigation Canal Bottom and Regulatory Reservoir Water Level) (m.c.a.) *Y (Water Level at Canal Section ) (m.c.a.) h Pumping Height (Htotal-Y) (m.c.a.) 1 1.5 38 m.c.a. 2 m.c.a. 36 m.c.a. 2 1.5 38 m.c.a. 2 m.c.a. 36 m.c.a. *Y: water level at a particular canal section which matches with pump stations. Table 10. Pipeline features. Pipeline (Connected with Regulatory Reservoir Number) Length (m) Diameter (mm) Absolute Pipe Roughness (mm) 1 1100 800 0.5 2 1100 800 0.5 3.2.3. Constraint Conditions The inequality constraint conditions adopted in this test are the following: 1 𝑀𝑀.𝑐𝑐.𝐼𝐼. < 𝐻𝐻𝑝𝑝(𝐼𝐼)< 1.8 𝑀𝑀.𝑐𝑐.𝐼𝐼 Q𝑘𝑘pumping(𝐼𝐼)< 1 𝑀𝑀 𝑐𝑐 3 (15 ) 3.2.4. Crop Flow Demand The crop flow demand is based on flow demand in scenario I, although the number of trees in this scenario has increased by a lot because there are 5000 ha of cherry trees and 6250 ha of peach trees (considering 2880 trees per ha); see Figure 14. The crop flow demand Agriculture 2024, 14, 463 20 of 27 has been estimated taking into account the irrigation canal conditions as well as the horizon time period (12 h). Figure 14. The crop water demands associated with regulatory reservoirs 1 (left) and 2 (right), i.e., cherry crops and peach crops, respectively. 3.2.5. Energy Prices The energy price is similar to that in Table 4 proposed for scenario II, although the energy price for several time steps has been increased; the second, third and ninth hours have been increased five times in order to check the adaptability of the OPF algorithm in case of big changes in electricity tariffs. 3.2.6. Results As you can see in Figure 15, the OPF algorithm optimizes the pumping flow trajectories, because both pumping stations are consuming energy just in case the energy price is cheaper, e.g., between the fourth and eighth hour. On the other hand, we can see from Figure 16 that reservoir nº2, which is related to a greater crop water demand, has larger water level fluctuations than reservoir nº1 during the time horizon. In this sense, pumping station nº2 is also operating when the water reservoir is full of water (4–8 h), increasing the water level to 1.6 m.c.a. (from 1.5 m.c.a. to 1.6 m.c.a.) when the energy price is cheaper. The algorithm is looking to increase the water volume of reservoir nº2 because crop flow demand is going to increase in the future, when the energy price will be more expensive. On the other hand, the OPF algorithm calculates an optimum solution considering that the water level of the reservoir cannot be below 1 m.c.a. (inequality constraint). But in any case, the pumping flow is never greater than 1 m3/s, which is the other inequality constraint. On the other hand, the reservoir water level will be recovered to the initial water level (1.5 m.c.a.) over the next 12 h at night, when the energy price is also cheap. Regarding the GoRoSo algorithm, canal gate trajectories have been recalculated considering new pumping flow trajectories, for instance, when pump station nº2 is pumping its flow at the first hour, gate nº0 (upstream of pumping station nº2) is opening to increase the flow into the irrigation canal (the gate reference position is 0.3 in the case where the pump stations are not operating and 0.475 in the case where the pump stations are operating during the first hour; see Figure 17), because the water level at target point nº2 (in the same location as pump station nº2; see Figure 13) is decreasing; see Figure 18. On the other side, gate nº2 closes at the first hour in order to reduce the downstream flow, because gate nº2 is in the same location as pump station nº2 and target point 2; see Figure 13 and Figure 17. In this sense, gate nº2 reduces the downstream flow at the first hour, in order to keep the water level at target point 2 (and supply the water demand at the gravity orifice’s offtake), which is also decreasing due to pump station nº2. Once extra flow from gate nº0 arrives at target point 2, after the first hour, gate nº2 starts to open because the water levels at the downstream target points (3,4,5,6,7) are also decreasing, and GoRoSo wants Agriculture 2024, 14, 463 21 of 27 to recover them as soon as possible. In the end, taking into account that pumping stations are not operative from the ninth to twelfth hour, all gates recover their initial positions in order to keep the water level at canal target points just considering the water demand at the gravity orifice’s offtake. On the other hand, water levels are measured by sensors at target points. The accuracy of these measurements may vary depending on the sensor used, which could potentially impact the accuracy of the GoRoSo algorithm. Additionally, sensitivity analysis was performed to address errors in water level measurements by the sensor. However, this analysis is beyond the scope of this manuscript but can be referenced in Bonet, E. 2015 [27]. Figure 15. The energy price vs. cumulative energy expenses at pump stations nº1 and nº2 in scenario II. Figure 16. Pumping flow at stations nº1 and nº2 vs. water level at regulatory reservoirs nº1 and nº2 in scenario II. Agriculture 2024, 14, 463 22 of 27 Figure 17. Gates nº0, 1 and 2 in scenario II. Figure 18. Water level at target points 1 (pump station nº1 location) and 2 (pump station nº2 location) in scenario II. In the case of the OPF algorithm not being applied in scenario II, it would be difficult to estimate the optimal pumping flow trajectories due to the complexity of this scenario. In this specific scenario, pump stations would only operate in the case of water level at the reservoirs decreasing so much and water level prediction at reservoirs being below 1 m.c.a. during the time horizon. This new version of scenario II has been proposed in order to compare with the last version of scenario II. The results of this new version of scenario II are shown in Figures 19 and 20. Agriculture 2024, 14, 463 23 of 27 Figure 19. The energy price vs. cumulative energy expenses at pump stations nº1 and nº2 in scenario II (new version). Figure 20. Pumping flow at stations nº1 and nº2 vs. water level at regulatory reservoirs nº1 and nº2 in scenario II (new version). If we compare the first and second versions of scenario II, we can conclude that the OPF algorithm is able to reduce the cumulative energy expenses by a percentage of 58%, which is a huge amount of money in just 12 h. 4. Conclusions The pumping flow trajectory is an essential parameter to operate a pumping station. Not using tools such as the OPF algorithm can increase the energy expense and consumption at the pumping station, as well as reduce the competitiveness of the irrigation system and farmers. Nowadays, the agriculture margins are so low that considering the optimization of pumping flow trajectories should be mandatory for a watermaster. The OPF algorithm is formulated regarding the energy and mass conservation equation and applying particular constraints associated with the water infrastructure. The OPF Agriculture 2024, 14, 463 24 of 27 algorithm estimates the optimum pumping flow trajectory in order to reduce energy expenses regarding crop flow demand as well as energy consumption. The OPF solves an optimization problem using the SLSQP method (sequential least square programming), which is implemented as a constrained non-linear optimization problem using a robust method with a fast convergence rate in comparison to other methods such as Nelder–Mead or Powell. Two different scenarios were proposed to test the OPF algorithm. Scenario I was proposed to assess the logic of the algorithm’s control when operating a pump station in an irrigation system, as well as to evaluate the algorithm’s robustness and sensitivity. Instead, scenario II was proposed to test OPF together with the GoRoSo algorithm in order to check the good performance of the overall control diagram considering a test case based on the ASCE test cases. The first scenario showed us that OPF calculated the optimal pumping flow trajectories according to the energy price during off-peak time periods, which was possible as crop water demand could be supplied just by pumping during those periods with reservoir support. On the other hand, the algorithm always respects the requirements of equality and inequality constraints, i.e., the water level of the reservoir of over 1 m.c.a. and the pumping flow from 0 to 25 m3/h in scenario I. The second scenario was developed considering two versions. In the first one, it is quite interesting to look at the algorithm’s synchronisation because GoRoSo and OPF have to keep the water levels constant at the target points in the canal and provide crop flow demands from the reservoir during the time horizon. The result shows us the complexity of estimating the best solution in the case of a multiparameter optimization problem. In scenario II, the OPF algorithm also considered a price energy per hour to estimate optimal pumping flow trajectories, but pumping station nº2 operated when the water level reservoir was close to 1.5 m.c.a. (4–8 h), increasing the water level to 1.6 m.c.a. This happened because the energy price was cheaper during the first hours and the crop water demand was going to increase a lot during the next hours when energy price was more expensive. On the other hand, the GoRoSo algorithm had to prepare the irrigation canal state (water level at the target point) for the new boundary conditions (pumping flow) over the next hours. In addition, the irrigation canal opened gate number 0 and closed gate number 2, as the water level was expected to decrease at target point number 2 during the first hour because the pumping station started to operate. In the second version of scenario II, the GoRoSo algorithm worked without the OPF algorithm, so pump stations were only operating in the case of water level prediction at the reservoir decreasing below 1 m.c.a. during the time horizon. Comparing both versions, the OPF algorithm was able to reduce the cumulative energy expenses by 58%. In light of the results obtained, the optimal pumping flow (OPF algorithm) is shown to be a competent and robust algorithm for the estimation of optimal pumping flow trajectories. Subsequently, its implementation in the overall control scheme of irrigation canals (offline computation module) was mandatory. On the other hand, the overall control diagram of irrigation canals, including OPF algorithms, has operational limitations, which are evident in the manuscript, and future prospects aim to improve both. For instance, the OPF algorithm could be also implemented in the real-time module to improve energy expenses in real-time. On the other hand, the OPF algorithm should be applicable in cases of non-fully rough turbulent flow, along with upgrades considering various pump station configurations, introducing different characteristic curves of centrifugal pumps, water losses, and configurations of serial or parallel pumps. Author Contributions: All authors contributed to the study's conception and design. Material preparation, data collection and analysis were performed by Enrique Bonet Gil and María Teresa Yubero de Mateo. The first draft of the manuscript was written by E.B. and M.T.Y. and both authors read Agriculture 2024, 14, 463 25 of 27 and approved the final manuscript. All authors have read and agreed to the published version of the manuscript. Funding: The authors declare that no funds, grants, or other support were received during the preparation of this manuscript. Institutional Review Board Statement: This material is the authors’ own original work, which has not been previously published elsewhere. The paper is not currently being considered for publication elsewhere. The paper reflects the authors’ own research and analysis in a truthful and complete manner. The paper properly credits the meaningful contributions of co-authors. The results are appropriately placed in the context of prior and existing research. All sources used are properly disclosed (correct citation). Literal copying of text must be indicated as such by using quotation marks and giving proper references. All authors have been personally and actively involved in substantial work leading to the paper and will take public responsibility for its content. (The author and coauthor approve it. Enrique Bonet and Maria Teresa Yubero (12/03/2024)) Informed Consent Statement: Informed consent was obtained from all individual participants included in the study. Data Availability Statement: All data underlying the results are available as part of the article and no additional source data are required. If any reviewer needs additional data or documents, they can be delivered. Conflicts of Interest: The authors declare no conflicts of interest. Nomenclature A(y) The area of the wet section which depends on the water level “y” ASCE American Society of Civil Engineers c The gate width; CSE Canal Survey Estimation algorithm bj The j-gate width f(x) Objective function ρ Density E expenses Energy expenses during horizon time period E minimum Minimum energy expenses trajectory E price Energy price during the horizon time of period ET 0 Reference evapotranspiration per tree ET c Crop evapotranspiration per tree f Darcy Weisbach coefficient FCA Friction Coefficient Algorithm g Gravity GoRoSo Gómez Rodellar Soler GoRoSoBo Gómez Rodellar Soler Bonet g(x) Equality constraints equations h(x) Inequality constraints equations H reservoir Water level at the reservoir H b Pumping head H max Maximum water level at the reservoir H min Minimum water level at the reservoir h pumping height Height among water surface at irrigation canal regulatory reservoir H total Total height among irrigation canal bottom and regulatory reservoir water level IEC International Energy Agency J(E) Residual function K c Dimensionless parameter depending on the type of crop and period of the year λ Lagrange multipliers mp Number of pump stations mc Number of types of crops n Manning coefficient nc Number of checkpoints np Number of pools