## 2 Materials and Methods
### Simulation, Optimization, and Sensitivity Analysis  
For each one of the five cases, two sets of simulations were carried out for its supply by a standalone system. One set incorporated PV generation and storage in batteries. The other set incorporated hybrid PV-diesel generation and storage in batteries. This made a total of 10 groups of simulations, 5 with fully PV systems and 5 with hybrid systems. The simulation and optimization processes were carried out with iHOGA software (improved Hybrid Optimization by Genetic Algorithms) [7; 13]. This software simulates the technical and economic operation of the possible solutions of the system. Each possible solution is a combination of the various elements that make up the PV or hybrid system. Figure 3: Annual profile of the energy demand of the five cases. Once the necessary information is entered, iHOGA simulates all possible combinations of components. Among them, it discards those that do not meet the technical conditions, such as the satisfaction of demand. Among the technically acceptable solutions, economic optimization consists of the search for the one that obtains the minimum NPC (Net Present Cost) (1). \[NPC=\sum_{n=0}^{N}\frac{C_{n}}{\left(1+d\right)^{n}} \tag{1}\]  
where \(NPC\): Net Present Cost [\(\epsilon\)]; \(C_{n}\): cost in period \(n\) (investment, O&M, replacement, and fuel costs) [\(\epsilon\)]; \(N\): analysis period; \(d\): annual discount rate. The Levelized Cost of Energy (LCOE) (2) is also calculated, to compare the energy production costs. \[LCOE=NPC/\left\{\sum_{n=1}^{N}\left[Q_{n}/(1+d)^{n}\right]\right\} \tag{2}\]  
where \(LCOE\): Levelized Cost of Energy [\(\epsilon\)/kWh]; \(Q_{n}\): energy in year n [kWh]. For each case study, iHOGA was provided with data on energy demand, ambient temperature, and solar irradiation, all of them over a year, on an hourly basis. To calculate the irradiation on the plane of the PV panels, the available surfaces in each case study were taken into account (Table 2). Thus, the installation of the panels in coplanar mounting on the roofs of the winery, the pig farm, and the two houses were simulated, with their actual azimuths and tilts. In the case of irrigation pumping, the mounting on a fixed structure on the ground was simulated, so the calculation of azimuth and tilt was included in the optimization of the case itself. In addition to the specific data of each case, iHOGA was supplied with technical data and economic parameters. The technical data consist of the characteristics of the elements that will be allowed to use to compose the systems. This includes PV panels, inverters, batteries, diesel generators, etc. For each element, its electrical characteristics, efficiency, lifespan, acquisition cost, operation, and maintenance costs, etc. were incorporated. All of them correspond to commercially available elements, with the characteristics provided by their manufacturers and the market prices in Spain in December 2020. These data are shown in Table 3, Table 4, and Appendix A. The costs assumed by the owner of the installation, which are higher than the price of the components, were used. They are shown in Table 3. Regarding the acquisition cost intervals indicated for batteries, the lowest prices per kWh correspond to the larger batteries, while the highest prices correspond to the batteries of smaller capacity, which are those used in domestic systems (cases of single-family home and second home). These data constitute a conservative scenario, in whose election various reports were considered, for PV panels [40,41] and batteries [42,43]. The considered price of diesel is 0.7 \(\epsilon\)/L and its annual variation of +1.5%.