# Hybrid Renewable Systems for Small Energy Communities: What Is the Best Solution?
## 2 Methods and Developments  
### Smart Optimization Model  
Hybrid energy systems are very versatile and complex, due to the operation and management of different energy sources, demands, and constraints; it is crucial to seek the most optimized values corresponding to each energy sector/unit [48]. The thinnest modification of the energy balance throughout the season can produce significant deviations from optimal results. Therefore, once the input data is defined in the simulation model and the preliminary results are computed, several smart optimization simulations are carried out for each water allocation, seeking to improve the results obtained, depending on the selected optimized configuration [49]. Different objective optimization functions, such as the GRG Nonlinear (MS-Solver) and the NSGA-II (Python), can be selected and tested on the model. The multi-objective optimization, NSGA-II, can be integrated in the model with Python, through the Pymooframework. The chosen method for the following case study, the GRG Nonlinear, seeks better results through gradient patterns, making it very dependent on the initial values for the decision variables, resulting in mostly local best solutions; nevertheless, the option multistart was enabled to improve the precision of the GRG Nonlinear method, mixing its fast-computing power with the complexity and precision of evolutionary methods, functioning similarly to genetic algorithms (GA) [50]. With the multistart option, the optimization process can seek a global solution. The population size was 250, with no set initial seed; the convergence requirement was considered 0.0001. The model's energy management process involves multiple sources and systems and a defined hierarchy. The main steps/subsystems that summarize/integrate the model are described next. Figures 1-5 describe the mentioned subsystems and their mathematical algorithm that dictates the energy/water management. Step I--Primary Renewable Energy Sources: Hourly data on solar (S\({}^{i}\)) or wind (W\({}^{i}\)) energy production is obtained from the PVGIS database. If solar energy is the main source, it is checked if it can meet the energy demand. Any excess energy indicates a surplus. Step II--Energy and Water Demand Fulfillment: Energy needs (E\({}_{c}^{i}\)) can be met through solar/wind, hydropower, and grid electricity or batteries. The water demand (A\({}^{i}\)) refers to the specific water volume required to be retrieved from the PHS reservoir. The renewables surplus (S\({}_{*W}\)) is deducted as presented in Figure 2.  
Figure 1: Scheme of control center to connect intermittent renewables and energy demand. Figure 2: Steps I and II, renewable surplus computation. Step III--Pumped Storage Hydropower (PSH): When solar/wind energy is insufficient, hydropower is required, corresponding to a load-responsive generation. Surplus solar/wind energy can pump water to store potential energy. Pumping and turbine operations depend on reservoir volume constraints. Step IV--Reservoir Management: The upper reservoir has a set capacity (maximum and minimum). Each hour's reservoir volume (V\({}_{\text{R}}\)i) is updated based on energy use and input/output  
Step V--Energy Surplus/Deficit and Alternative Selection: After the PHS iteration balance, the system might produce a surplus (E,\({}^{i}\)) or deficit (E.\({}^{i}\)) of energy that benefits from the presence of an auxiliary system. Step VI--Grid Energy: If alternative A is selected, the electric grid is utilized if renewable sources and hydropower cannot meet the energy demand. Excess energy can be sold, while energy deficits are covered by buying from the grid, with hourly tariffs determining costs and profits, as described in Figure 4.  
Step VII--Off-Grid Solutions with Batteries: In off-grid setups, batteries store excess energy and supply energy during deficits, ensuring that energy needs are fully met. This alternative replaces the conventional electric grid configuration. Figure 4: Step VI, Alternative A-grid computation.