Optimising a Biogas and Photovoltaic Hybrid System for Sustainable Power Supply in Rural Areas

Featured Application: Optimising the composition of a hybrid system of a biomass power plant and a photovoltaic plant to reduce energy costs and the environmental impact for a small rural population (energy community). It can be used as a guide for designing and managing similar hybrid systems for energy cost savings and improving energy autonomy. Abstract: This paper proposes a method for evaluating the optimal conﬁguration of a hybrid system (biomass power plant and photovoltaic plant), which is connected to the electrical grid, to achieve minimum energy costs. The study is applied to a small rural municipality in the Valencian Community, Spain, as an energy community. The approach takes into account the daily energy demand variation and price curves for energy that are either imported or exported to the grid. The optimal conﬁguration is determined by the highest internal rate of return (IRR) over a 12-year period while providing a 20% discount in electricity prices for the energy community. The approach is extrapolated to an annual period using the statistical data of sunny and cloudy days, considering 23.8% of the year as cloudy. The methodology provides a general procedure for hybridising both plants and the grid to meet the energy needs of a small rural population. In the analysed case, an optimal combination of 140 kW of rated power from the biogas generator was found, which is lower than the maximum demand of 366 kW and 80 kW installed power in the photovoltaic plant, resulting in an IRR of 6.13% over 12 years. Sensitivity studies for data variations are also provided.


Introduction
The presence of a climate emergency, global pollution, and biodiversity crisis is becoming increasingly evident.A new bioeconomy is needed to make economic growth sustainable and prevent ecological collapse.This transition to a renewable energy-based economy instead of fossil fuels is partially occurring in developed countries [1][2][3].Specifically, new regulations are being created in Europe to promote the installation of renewable energies [4,5], such as the European Directive 2018/2001/EU [6].This directive establishes strategic actions for 2020-2030, known as "Clean Energy for All Europeans".The main objectives are to promote renewable energies, mitigate the climate impact, and reduce the dependency on fossil fuels, to achieve a sustainable energy system [7,8].These measures are focused on the long-term goal of making the European Union climate neutral by 2050 [9].As a consequence of these new policies, various energy community initiatives have been developed in Europe in recent years [10,11].These energy communities are organised to produce, distribute, and consume renewable energy in a more efficient and sustainable way.There are various initiatives and organisations at the European level that promote the development of energy communities throughout Europe, such as the European federation of citizen energy cooperatives [12].In general, energy communities can contribute to improving energy efficiency, reducing energy costs, and fostering innovation in energy production and use [13].In addition, they can help to promote citizen participation, sustainability, and local development [14].
One of the most relevant renewable energy sources in recent years in Europe has been photovoltaic (PV) [15,16].This energy source has been used both in energy communities [17,18] and for self-consumption [19,20] and electricity generation [21,22].However, it has a number of shortcomings, such as a limited or no energy management capacity and it has a strong dependence on weather conditions [23].This makes it necessary to have other support systems.In this scenario, biogas (BG) (a mixture of methane, carbon dioxide, and trace amounts of other gases) is starting to become increasingly important [24,25].It is a renewable energy resource that is easy to store and manage.In addition, the process of anaerobic digestion that is carried out allows for the treatment of organic matter from different types of waste (sewage treatment sludge, animal manure, biowaste, etc.) [26].These associated environmental, economic, technical, and climate benefits, as well as new renewable energy policies, have led to an increase in BG production in the European Union.In 2015, a total of 18,000 million Nm 3 of methane were produced (half of the world's production), positioning the EU as the world's largest producer of biomethane [27], reaching a biomethane production of 2286 bcm in 2018 [28].By 2030, Europe will produce 35 bcm, representing 10% of the total EU gas demand [29].By 2050, combined BG and biomethane production will reach 95 bcm, which could cover 30-40% of the total 2050 gas demand, according to the European BG Association [30].In order to achieve this generation, an improvement in terms of the optimisation of performance, quality, speed, and robustness of the BG production process is necessary.Therefore, there are projects that are funded by the European Union, such as the Natural and Synthetic Microbial Communities for Sustainable Production of Optimised BG (Ref.: 1010004706-Micro4Biogas) [31], which have the ambitious overall goal of drastically optimising the BG production process through bioaugmentation strategies based on the microbial strains that naturally inhabit the production tanks.Subsequently, these BG plants must be integrated into networks in order to manage this renewable resource.Possible uses of BG as an energy source include electricity generation, heating, and transportation [32].In addition to improving BG production, there is also a focus on upgrading it to biomethane to achieve a better performance of the equipment due to a better gas composition [33,34].
If we analyse the specific case of Spain, according to data from the Ministry for Ecological Transition and the Demographic Challenge [35], there are a total of 146 BG facilities with an energy production of 2.74 TWh.Among the operating plants, only one facility converts BG into biomethane and injects it into the gas pipeline network.Compared to the rest of Europe, where there are about 19,000 facilities of which 725 inject biomethane into the gas network, BG has experienced low development in Spain [36].However, the country has great potential and large industries in the agricultural, food, and waste management sectors that can quickly activate the market, as indicated in the 2021-2030 Spain National Integrated Energy and Climate Plan [37].Despite the great potential of BG in Spain [38], there is a large gap in the literature on these types of facilities in combination with other renewable resources for electricity generation [39] and their subsequent use for the supply of small rural municipalities in Spain, as detailed in the literature review.

Literature Review
The use of PV energy and biomass (BM) is highly advanced and has been thoroughly studied separately on a worldwide level.On the one hand, PV energy is the most widely used renewable resource due to the large number of solar resources available on the planet [40].On the other hand, while BM has been widely used on a small scale in developing countries, in recent years it has gained great importance as an energy vector for sustainable development [41].In this literature review, we will not address the studies carried out on these types of installations on their own, but rather the works that analyse the combination of both technologies.
In developing countries, the hybridisation of PV systems with BG digesters has been widely embraced, particularly on a small scale.The main reason for this is the high number of sunny hours, the abundance of organic waste for processing, and the widespread electrical supply issues in these regions, as demonstrated in [42].In [43], a small hybridisation of 1 kW of PV and 3.5 kVA of BG is carried out to study the amortisation of the system based on Indian regulations.The tests carried out show that the amortisation of these systems ranges from 6.45 to 17 years, in addition to improving the reliability of the electrical supply.On the other hand, the work carried out in [44] proposes the simulation of a 3.0 kW integrated PV/BG power generation model (2.84 kW solar system and 4.0 Nm 3 BG system), with the aim of providing a stable source of power for a house in a remote area or village.While the proposed system significantly improves the electrical supply, it still largely depends on the general electrical grid.That is why the authors of [45] use an on-grid PV/BG/diesel system for the electrification of a small village in Iran.In this study, the production ratio of each technology is sought, with the aim of minimising the cost of energy production.With this system, there is a reduced dependence on the general electrical grid, as there is a diesel generator that can act in emergency cases.If we analyse the studies carried out to seek self-consumption of small homes/municipalities, [46] analyses the feasibility of a 12.9 kWp off-grid mini-grid power system with a 1 kW BG generator to supply a remote area in Bangladesh.Due to the conditions of the country itself, the amortisation of this system is estimated at 6.9 years, reducing CO2 emissions and allowing for more economical and reliable energy.Finally, the application of PVs and BM is also interesting in agriculture and livestock farming, due to the great availability of organic matter for the BM digester.In [47], it is analysed how BM alone is not as economically or energetically profitable for a stable, requiring the hybridisation with a PV system to obtain better economic results.While in [48], the technical and economic feasibility for the electrification of an apple farm is analysed, through the modelling of a system of 25 PV modules, 2 BM generators, and a battery.
Therefore, in developing countries, the hybridisation of PV and BG systems is very interesting for self-consumption in rural areas.This is due to their short amortisation period and the improvement in the reliability of the electrical supply, as analysed in [49], which considering 20 different installations.In this study, BM digesters between 2.4 and 4.8 Nm 3 and PV installations between 40 and 85 kWp are analysed to obtain the payback.This work concludes that these systems have a payback of less than 5 years.However, this combination of renewable resources is also starting to be considered as an energy solution for electric vehicle charging [50].For this, different solar PV systems (3 kW, 4.5 kW, 6 kW, and 9 kW) are available, where the most efficient is the 4.5 kW since it is amortised in 12 years.Two 5 kW BG generators are used as support in the hours when there is no solar generation.
In Europe, new regulations are leading to energy communities that combine PV and BM.For this reason, energy management systems are being developed in which BM plays an important role in stabilising the electricity grid when there is a large PV installation [51].Similarly, in [52], an optimisation of a PV-and BM-based system is carried out, where it is determined that although it can supply the proposed demand, the system performance is only 40%.On the other hand, due to the distribution of sunny hours, BM has a great weight to ensure the necessary power during the winter months in solar plants where energy is stored in the form of heat [53].Moreover, the combination of these technologies is interesting for the domestic self-consumption of single-family homes [54].In this work it is demonstrated that with low-power systems (1 kW of PV, a 1 kW BG generator, a small 1 kW wind turbine, and a battery system) it is possible to not depend on the electrical grid.
If we analyse the particular case of Spain, it has a great potential for the installation of these renewable resources.Specifically, in [55], a replicable, multi-criteria spatial approach based on a geographical information system to estimate the potential of solar PV, wind, and BM energy technologies that could be implemented in the short-term in a given territory is shown.The results of this work show that the combination of these resources could generate 3.8 times the current electricity consumption of the municipality and would only require 1.5% of the total area of the municipality.However, due to administrative barriers, it is not possible to implement this in the short term.On the other hand, reference [56] presents a methodology to optimise a grid-connected hybrid renewable energy system that hybridises photovoltaic, wind, and forest BM energy sources, considering the cost and environmental impact criteria from a life-cycle perspective.It is concluded that because those renewable systems with the least climate impact are the most expensive, renewable resources are still not presented as a great alternative for massive electricity generation.On a smaller scale of electricity generation, in [57] a method is shown for managing a solar thermal plant, using BG as an energy support system, with the aim of improving the profitability of the installation.
Therefore, after analysing all the studies carried out considering large-scale plants, the combination of PV and BM is not yet profitable in Spain.However, for the supply of buildings, it is interesting if the necessary surface is available.For example, in [58], self-consumption for a slaughterhouse is sought through both systems.For this, there are 79 kWe of BG and 225 kWe of PVs, obtaining a payback of 9 years and an internal rate of return (IRR) of 9%.On the other hand, in [59], an existing near Zero Energy Building (nZEB) and zero carbon emissions building on a university campus are analysed.In this case, BM is described as helping to reduce the carbon footprint of buildings under new European regulations.However, in urban environments, the implementation of BM is not easy or economically attractive.In [60], the combination of BM and PVs is proposed to supply electricity to educational buildings.Although the results show that for these urban buildings PVs are more convenient, the limitation of the available surfaces makes it necessary to use other renewable resources to increase the percentage of renewable energy used.In this case, BM is a possible solution, but it has a high current cost.
Table 1 summarises the studied works, classifying them according to the size of the installations, whether they improve the electricity supply, and how economically attractive these systems are, which provides some insights to the advantages and disadvantages of each proposed solution.Economically Attractive X -

Research Motivation
After analysing the literature regarding hybrid PV and BM installations, a literary gap has been detected regarding the study of these systems to supply rural municipalities in Spain.Therefore, in this work, BG will be analysed as an electricity-generating element combined with a PV plant for a small rural municipality.Specifically, based on the amount of available BM resources (livestock waste), a BG production plant will be proposed and a detailed study of the optimal power of the BG-fed electricity generator will be carried out.The size of the PV plant to be installed to achieve the maximum benefit for the community energy partners and minimise the IRR of the investment will also be determined.Powers between 110-250 kW for the BG plant generator and between 50-250 kW for the PV plant will be considered.All of this will be subsequently applied in the design of a hybrid renewable energy system for the supply of this small rural municipality located in the Valencian Community (Spain).
The rest of the paper is structured as follows: Section 2 describes the components of the hybrid system to be analysed.Subsequently, Section 3 details the method used to obtain the optimal power of each system to minimise the IRR.Section 4 presents the results obtained after analysing the different cases.The discussion of the results is given in Section 5. Finally, Section 6 shows the conclusions of the study and the requirements for future research work.

Hybrid System Components
The study was conducted in a small rural municipality in the Valencian Community (Spain), located at the UTM coordinates zone 30 (659,610; 4423,302), with a population of fewer than 400 inhabitants.Due to its location, it presents a series of deficiencies concerning the electricity and gas supply.On the one hand, it is located at the end of an electrical line, so the neighbours have numerous problems with power outages.In addition, due to the lack of nearby facilities, there is no natural gas distribution network to connect to.Therefore, heating is mainly based on the burning of forestry resources and/or electric heaters.
For the completion of this work, the electrical demand of 2021 will be used as the starting point.The usefulness of building the BG production plant and its size will be justified based on consumption requirements.In addition, the feasibility of adding a PV plant to that facility will be analysed in terms of improving self-consumption and reducing demand from the grid.

BG Production
Because of the municipalities' location, the economy is based mainly on agriculture and livestock.With a large number of farms, there is a need to manage the waste generated by the animals.Although traditionally these organic manures were used as fertilisers in agriculture, there are now regulations that regulate and prohibit these practices [61][62][63][64].Therefore, the BM plant was born out of necessity to manage these livestock wastes.Due to environmental regulations, and for safety reasons, the plant must be located far from the urban centre (3 km).In addition, to avoid cross-contamination between farms, the regulations stipulate that the plant cannot be located within 1 km of a farm.
Therefore, it is decided to use the BG plant for the exclusive production of electricity, due to the following reasons: -There is a great distance between the urban centre and the generating plant.Therefore, it is not optimal for district heating.-There are no gas pipelines in any part of the municipality.The cost of the gas infrastructure makes it neither technically nor economically feasible to build a municipal gas distribution network.-Gas for heating would only be used in the cold winter months.The consumption during the rest of the year would be low, as it would only be used by a few residents for cooking.-There is a high voltage power line that feeds the municipality, which is located a few meters away from the BG plant.

Available Resources
There are a large number of farms in the municipality, mainly chicken, rabbit, pig, and calf farms.The estimated residues are shown in Table 2.The residues data have been obtained from reports provided by the municipality about the farms in the surrounding areas and they have been completed using values from [65].This study considers only livestock waste, but there are other interesting wastes in the municipality for BG production, such as sludge from water treatment plants and the organic fraction of solid urban waste.

BG Plant
BG production varies with the methanogenic capacity of the organic matter, which depends on the type of anaerobic fermentation process.A mesophilic process will be used, for which it will be necessary to maintain a temperature in the digester between 25 • C and 45 • C, with an average value of 35 • C.
The average daily amount of waste available is 27.07 t/day.With a retention time of 30 days and a density of approximately 1000 kg/Nm 3 , the useful volume required for the reactor is 812 m 3 .A cylindrical reactor with a diameter of 14.38 m and a useful height of 5 m (6 m total height), which is covered with a double membrane (polyester and PVC), is used to obtain a gasometer, with a volume of 400 m 3 .
The production of biomethane (Q) in Nm 3 /day will be where q is the methanogenic capacity, which depends on the substrate temperature, composition, pH (should be close to 7), and retention time, mainly.Its value in the conditions of this installation can range between 0.19 and 0.25.A value of 0.228 will be taken.The factor m is the feed rate of volatile solids (m = 3800 kg/day), resulting in a production of 867 Nm 3 (methane)/day.Although BG production varies with ambient temperature, a relationship of Q = Q(T) cannot be established, due to the large thermal inertia of the substrate volume in the digester, so a stable gas production will be assumed.
The methane produced is part of the mixture called BG in a variable proportion between 45% and 70%.As an average value, 60% can be taken.The lower calorific value of the BG is 5.6 kWh/Nm 3 , so that the total available energy will be E = 8094 kWh/day.
With an internal combustion engine coupled with a generator, with an efficiency of 29%, the electrical energy will be E e = 2509 kWh/day and the useful thermal energy will be E t = 3909 kWh/day.
In cold weather (outside temperature of 0 • C), to maintain a substrate temperature of 35 • C a heat input is required which will be estimated using Equation (2): where P c is the flow of heat losses in W; γ h is the thermal conductivity of concrete (1.63 W•K −1 •m −1 ); T i is the internal surface temperature (35 • C); T 0 is the external surface temperature (0 • C); S is the surface (1 m 2 ); and e is the wall thickness (0.15 m), which results in For the average temperature of the municipality (14 Although it is a cylindrical digester, due to its large diameter and small wall thickness, the calculation has been approximated as if it were a flat wall.
The wetted surface of the digester wall is 225.9 m 2 , resulting in a heat input requirement of 2060 kWh/day, which can be provided by the useful thermal energy of the internal combustion engine.The excess thermal energy will be used for drying wood waste from the area.
Figure 1 shows the flow diagram that will follow the BG generation process, for its subsequent use as fuel in a BG generator.
;  is the internal surface temperature (35 °C);  is the external surface temperature (0 °C);  is the surface (1 m 2 ); and  is the wall thickness (0.15 m), which results in  = 380 W/m 2 .
For the average temperature of the municipality (14 °C), the heat required is 228 W/m 2 .
Although it is a cylindrical digester, due to its large diameter and small wall thickness, the calculation has been approximated as if it were a flat wall.
The wetted surface of the digester wall is 225.9 m 2 , resulting in a heat input requirement of 2060 kWh/day, which can be provided by the useful thermal energy of the internal combustion engine.The excess thermal energy will be used for drying wood waste from the area.
Figure 1 shows the flow diagram that will follow the BG generation process, for its subsequent use as fuel in a BG generator.

PV Plant
The power produced by the PV installation can be estimated very accurately from the ambient temperature and irradiance, data that can be easily obtained using the PVGIS programme [66].Factors influencing the actual irradiance value (such as air clarity index and atmosphere mass) are already considered in the irradiance predictions of the PVGIS programme.The wind speed influences the cell temperature, but for moderate winds (up to 3 m/s), the influence is very small.The average annual wind speed at the chosen site is 2.4 m/s at 10 m above the ground, so no correction for wind will be applied in this study.
Applying the standard model, the following equation is obtained:

PV Plant
The power produced by the PV installation can be estimated very accurately from the ambient temperature and irradiance, data that can be easily obtained using the PVGIS programme [66].Factors influencing the actual irradiance value (such as air clarity index and atmosphere mass) are already considered in the irradiance predictions of the PVGIS programme.The wind speed influences the cell temperature, but for moderate winds (up to 3 m/s), the influence is very small.The average annual wind speed at the chosen site is 2.4 m/s at 10 m above the ground, so no correction for wind will be applied in this study.
Applying the standard model, the following equation is obtained: In these equations: P M (G) is the maximum panel's power in W. P M1 is the maximum panel's power in W with G = 1000 W/m 2 .P M0 is the standard maximum panel's power in W in standard test conditions (STC).G is the irradiance in W/m 2 normal to the panel.
V 0 (G) is the open-circuit voltage of the panel in V.
V 01 is the open-circuit voltage of the panel in V with G = 1000 W/m 2 .V 0 is the standard open-circuit voltage of the panel in V (STC).I cc (G) is the short-circuit current of the panel in A. With these equations, using the measured irradiance and temperature data, the generated power curves for two different situations (a sunny day and a cloudy day) are performed.The sunny day corresponds to 29 March 2021, whereas the cloudy day corresponds to 7 October 2021.These generation profiles are shown in Figure 2.

Demand Loads
The last essential element for the study is to know what the demand is like.The actual curves recorded by the research group in the population will be used.The records for the entire year of 2021 have been analysed.A typical day has been selected from these records,

Demand Loads
The last essential element for the study is to know what the demand is like.The actual curves recorded by the research group in the population will be used.The records for the entire year of 2021 have been analysed.A typical day has been selected from these records, with values very close to the average values.The typical consumption pattern considered in this study is shown in Figure 3.

Methods
Starting from the current demand of the municipality, the following is studied: 1.The current cost of electric supply from the grid, without including any renewable

Methods
Starting from the current demand of the municipality, the following is studied: 1.
The current cost of electric supply from the grid, without including any renewable installations.This value is obtained according to the average prices published by the Spanish system's operators on their website (Red Eléctrica de España) [67].This will be the reference value for comparing the other situations.
With the previous demand curve and the following price curve, the daily supply cost is obtained, to which a cost of EUR 14.4 for the contracted power term is added, resulting in a cost of 702.27 EUR/day.The prices used for the study are shown in Figure 4.

Methods
Starting from the current demand of the municipality, the following is studied: 1.The current cost of electric supply from the grid, without including any renewable installations.This value is obtained according to the average prices published by the Spanish system's operators on their website (Red Eléctrica de España) [67].This will be the reference value for comparing the other situations.
With the previous demand curve and the following price curve, the daily supply cost is obtained, to which a cost of EUR 14.4 for the contracted power term is added, resulting in a cost of 702.27 EUR/day.The prices used for the study are shown in Figure 4. 2. The cost of the supply if the BG-generating plant and the PV power station are added.
Since the design of the BG plant is conditioned by the amount of waste available in the municipality, it will have the necessary size for the treatment of all the waste; therefore, the production of BG, in stationary regime, will be considered constant.However, the consumption of BG can be variable, depending on the power of the electric generator

2.
The cost of the supply if the BG-generating plant and the PV power station are added.
Since the design of the BG plant is conditioned by the amount of waste available in the municipality, it will have the necessary size for the treatment of all the waste; therefore, the production of BG, in stationary regime, will be considered constant.However, the consumption of BG can be variable, depending on the power of the electric generator that is installed.This power will be one of the objectives of the optimisation problem that is proposed.
The rated power of the PV plant will be another objective of the optimisation problem.This power is limited by the available space and the capital required for its installation, so it could be quite large; however, as demonstrated in this paper, the major benefit obtained from this plant is to reduce the demand for energy from the grid, whereas the sale of surplus energy provides much less benefit.
The equations of the problem are described below.For every instant t: P D = P G + P P + P B + P E (10) where P D is the demanded power in W, P G is the power supplied by the grid in W, P P is the power generated by the PV panels in W, P B is the power generated by the BG plant in W, and P E ≤ 0 is the surplus generation in W. It must be noted that if P E ≤ 0, then P G = 0, and P D < P P + P B .For this work, the possibility to sell the surplus generation P E is assumed.The total operation cost will be: where C x is the cost of the energy supplied by x in EUR/h as detailed below, for which a detailed explanation can be found in Appendix A: -C G is the cost of the energy bought from the grid.-C P is the cost of the energy produced by the PV installation.An investment value of I P = 1.5 EUR/W has been used, considering the cost of panels, electronic inverters, wiring, support structures, and plot renting [68].-C B (P B ) is the cost of the energy produced by the BG reactor.The investment cost of this plant in EUR has been estimated as I B = 200, 000 + 1500•P m + 750•V b , where P m is the rated power of the motor-generator to be installed (in kW) and V b is the volume of the BG reactor (in m 3 ).-Finally, in those moments in which P B + P P > P D , the surplus P E = P D − P P − P B will be sold to the grid at a price C E , which is shown in Figure 4, according to the average prices published by the Spanish system's operators on their website (Red Eléctrica de España) [67].
The main target of the daily management of the system is Using an hourly time interval, Equation ( 12) can be rewritten as The variables to be used in the management algorithm are as follows: -Investment selection: Rated power of the PV plant, P pr .Rated power of the BG plant's motor-generator, P m .
-Resources management: Hourly electric generation of the BG plant's generator.
The ultimate objective of the proposed strategy is to optimise the selection of investment opportunities.To achieve this, a financial criterion of maximum IRR over a 12-year period will be employed, since this period is substantially lower than the expected life of facilities.The use of IRR is justified because not only does it indicates profitability, but it also quantifies the value of the investment.Additionally, it is commonly used to compare different options.Other financial indicators such as the net present value could be used, but IRR gives the results in percentage, which simplifies the comparison between scenarios.In calculating IRR, the initial expenditure will be the value of the investment in both a BG plant and a PV plant, while annual income will be derived from the sale of energy to consumers (S e ) and the income from the sale of surplus, minus payments made to the grid for the purchase of energy.The following equations explain these concepts: ) In Equation ( 15), C G P G (0) is the total energy cost without any renewable power plant and α is the discount offered to the users in the cooperative energy community for participating in the project in %.In this work, a value of α = 20% is proposed to make the project attractive for the potential partners.
The procedure to solve this optimisation problem is shown in Figure 5.It is also summarised in the steps listed below.
-Select the values of P pr and P m within the possible ranges.
-Optimise the operation of the BG plant and obtain the value of Equation ( 13).and  is the discount offered to the users in the cooperative energy community for participating in the project in %.In this work, a value of  = 20% is proposed to make the project attractive for the potential partners.
The procedure to solve this optimisation problem is shown in Figure 5.It is also summarised in the steps listed below.In this paper, given its exploratory approach, the entire range of values for  and  will be swept.As can be seen in the results graphs, the problem is well-suited for the application of gradient-based optimisation methods.
The problem is subject to the following constraints: - The reactor size is based on the amount of available waste, so it will be fixed (812 m 3 ).As a result, a uniform BG production of 1445 Nm 3 /day will be accepted.-All BG produced during the day must be consumed.This is established by making the volume of gas stored at the end of the day ( (24)) equal to that at the beginning of the day ( (0)).This ensures stable operation.In this paper, given its exploratory approach, the entire range of values for P pr and P m will be swept.As can be seen in the results graphs, the problem is well-suited for the application of gradient-based optimisation methods.
The problem is subject to the following constraints: -The reactor size is based on the amount of available waste, so it will be fixed (812 m 3 ).As a result, a uniform BG production of 1445 Nm 3 /day will be accepted.-All BG produced during the day must be consumed.This is established by making the volume of gas stored at the end of the day (V g (24)) equal to that at the beginning of the day (V g (0)).This ensures stable operation.-The stored gas volume must be as follows: -Pm must ensure the consumption of all daily gas.Higher Pm values provide greater flexibility in managing gas consumption at the plant.The selected range is - The internal combustion engine used by the generator can vary its power over a wide range, but at low powers its operation is unstable, and its performance deteriorates greatly.The following constraint will be considered: -The PV plant is considered unmanageable.Its power production depends on the irradiance and temperature conditions.The main benefit of its use is self-consumption, avoiding reliance on power from the grid.Beyond a certain power level, the additional benefit it provides is only the sale of excess energy.Given that its size will not be very large, this sale is made through a commercial company, with very low prices paid.Therefore, the ratio of benefit to investment decreases at a certain plant size.The selected range is 50 kW ≤ P pr ≤ 250 kW -Although the behaviour of a typical day is only analysed, the differences between a sunny day and a cloudy day are very large, so two scenarios are studied: one sunny and one cloudy.Reviewing irradiance data for one year in the area allows the establishment of a percentage of 23.8% of cloudy days (87 cloudy days and 278 sunny days).The results of the analyses will be weighted with these percentages.

Results
The use of the BG power plant with the grid (without PVs) produces savings that reach a maximum value for P m = 140 kW (Figure 6), while if only the PVs are installed, the benefit increases substantially with the installed power in the lower range, but then the increase becomes slower, and from P pr = 150 kW, this benefit is produced exclusively by the sale of excess energy (Figure 7), therefore the economic margin decreases.
When both installations are combined, it is observed that, after a certain size, the incremental benefit (B I = ∆B/∆I) decreases, making the necessary investment less attractive.
The study carried out allows a verification of the benefit obtained with different compositions of the hybrid installation with respect to the cost corresponding to the supply exclusively from the grid.This benefit has been calculated by weighing the results of a cloudy scenario and a sunny one, considering a percentage of 23.8% of cloudy days according to the meteorological data history.As shown in Figure 8, increasing the power of the PV installation produces a growing benefit because there is a greater amount of surplus energy that is sold.However, it is also clear from the results that the improvement in this benefit is becoming increasingly small.

-
The stored gas volume must be as follows: 20 Nm ≤  () ≤ 400 Nm ∀ - must ensure the consumption of all daily gas.Higher  values provide greater flexibility in managing gas consumption at the plant.The selected range is - The internal combustion engine used by the generator can vary its power over a wide range, but at low powers its operation is unstable, and its performance deteriorates greatly.The following constraint will be considered: -The PV plant is considered unmanageable.Its power production depends on the irradiance and temperature conditions.The main benefit of its use is self-consumption, avoiding reliance on power from the grid.Beyond a certain power level, the additional benefit it provides is only the sale of excess energy.Given that its size will not be very large, this sale is made through a commercial company, with very low prices paid.Therefore, the ratio of benefit to investment decreases at a certain plant size.The selected range is -Although the behaviour of a typical day is only analysed, the differences between a sunny day and a cloudy day are very large, so two scenarios are studied: one sunny and one cloudy.Reviewing irradiance data for one year in the area allows the establishment of a percentage of 23.8% of cloudy days (87 cloudy days and 278 sunny days).The results of the analyses will be weighted with these percentages.

Results
The use of the BG power plant with the grid (without PVs) produces savings that reach a maximum value for  = 140 kW (Figure 6), while if only the PVs are installed, the benefit increases substantially with the installed power in the lower range, but then the increase becomes slower, and from  = 150 kW, this benefit is produced exclusively by the sale of excess energy (Figure 7), therefore the economic margin decreases.When both installations are combined, it is observed that, after a certain size, the incremental benefit ( = ∆/∆) decreases, making the necessary investment less attractive.
The study carried out allows a verification of the benefit obtained with different compositions of the hybrid installation with respect to the cost corresponding to the supply exclusively from the grid.This benefit has been calculated by weighing the results of a cloudy scenario and a sunny one, considering a percentage of 23.8% of cloudy days according to the meteorological data history.As shown in Figure 8, increasing the power of the PV installation produces a growing benefit because there is a greater amount of surplus energy that is sold.However, it is also clear from the results that the improvement in this benefit is becoming increasingly small.From a financial perspective, it is much clearer to analyse the IRR of the whole.With this analysis, it is observed that the optimal configuration obtains a maximum value of IRR = 6.13% for  = 140 kW and  = 80 kW, while achieving a 20% discount on the price of energy from the grid for cooperative members, compared to the cost of energy without the use of renewable resources.This can be seen in Figure 9.When both installations are combined, it is observed that, after a certain size, the incremental benefit ( = ∆/∆) decreases, making the necessary investment less attractive The study carried out allows a verification of the benefit obtained with different compositions of the hybrid installation with respect to the cost corresponding to the supply exclusively from the grid.This benefit has been calculated by weighing the results of a cloudy scenario and a sunny one, considering a percentage of 23.8% of cloudy days according to the meteorological data history.As shown in Figure 8, increasing the power of the PV installation produces a growing benefit because there is a greater amount of surplus energy that is sold.However, it is also clear from the results that the improvement in this benefit is becoming increasingly small.From a financial perspective, it is much clearer to analyse the IRR of the whole.With this analysis, it is observed that the optimal configuration obtains a maximum value of IRR = 6.13% for  = 140 kW and  = 80 kW, while achieving a 20% discount on the price of energy from the grid for cooperative members, compared to the cost of energy without the use of renewable resources.This can be seen in Figure 9. From a financial perspective, it is much clearer to analyse the IRR of the whole.With this analysis, it is observed that the optimal configuration obtains a maximum value of IRR = 6.13% for P m = 140 kW and P pr = 80 kW, while achieving a 20% discount on the price of energy from the grid for cooperative members, compared to the cost of energy without the use of renewable resources.This can be seen in Figure 9.
For the optimal hybrid system obtained, Appendix B shows some numeric data that specifies the characteristics of the systems.Additionally, Figure 10 shows the operation of both plants of the optimal system on the typical sunny and cloudy days with the constraints described in the proposed method.For the optimal hybrid system obtained, Appendix B shows some numeric data that specifies the characteristics of the systems.Additionally, Figure 10 shows the operation of both plants of the optimal system on the typical sunny and cloudy days with the constraints described in the proposed method.For the optimal hybrid system obtained, Appendix B shows some numeric data that specifies the characteristics of the systems.Additionally, Figure 10 shows the operation of both plants of the optimal system on the typical sunny and cloudy days with the constraints described in the proposed method.

Discussion
This study develops a general procedure for studying the optimal hybridisation of a BG plant with a PV plant and the grid to supply energy to a small rural population.The results obtained in this case may vary under certain conditions.
An increase in the price of grid energy increases the benefit but has little influence on the optimal composition of the system.
An increase in the sale price of the excess energy makes it more attractive to increase the installed power of PV, but the variation in the composition of the optimal hybrid system is small.
In this study, a repercussion of C v = −0.1 EUR/kWh has been assigned to the energy produced by BG, by assigning a price to waste producers for their processing and elimination in the plant.The changes in this value have a slight impact on the benefit, but the optimal composition of the hybrid system is not significantly modified.
To complete this work, a set of scenarios modifying certain variables have been completely simulated.The optimal configurations and the value of IRR in the studied cases are shown in Table 3.
Finally, as a comment related to the results of this study, taking into account that, around the optimal point, the IRR gradient is very smooth, an increase in the PV power would barely affect this result and it would provide greater autonomy of supply to the population, especially improving the results on cloudy days.This can be seen in Figure 11, which represents the evolution of the IRR as a function of the P pr at a BG capacity of P m = 140 kW.

Conclusions
The main contribution of this paper is the development of a method of analysis for a hybrid system formed by a BM power plant and a PV plant, with the support of the electrical network, to determine the optimal configuration of the hybrid system that allows

Conclusions
The main contribution of this paper is the development of a method of analysis for a hybrid system formed by a BM power plant and a PV plant, with the support of the electrical network, to determine the optimal configuration of the hybrid system that allows the maximum possible savings in energy costs.This method has been applied to the design of the indicated system for a small rural municipality in the Valencian Community (Spain), under the structure of an energy community (collective self-consumption, according to regulations in Spain), and considers the variation of demand throughout the day, along with daily price curves for energy imported from or exported to the grid.
For each possible combination of power in the electric generator of the BM plant and the nominal power of the PV plant, it is necessary to optimise the management of the power produced by the BM plant.This optimisation makes it possible to obtain the minimum cost of daily energy, while maintaining the restrictions imposed on the BM system, which are summarised in maintaining stable BG production over time, guaranteeing the consumption of all the gas produced, and a residual volume at the end of the day equal to that which existed at the beginning of the day.
The criterion adopted for the decision on the optimal composition of the hybrid system has been the highest IRR for a period of 12 years, together with the condition of guaranteeing to the members of the energy community a discount of 20% on the cost of the energy.
The approach carried out has been extrapolated to an annual period, assuming a typical demand curve of the municipality as the most representative of the way of consuming electrical energy and analysing the operation on a sunny day and a cloudy day and weighing the results, considering that 23.8% of the days of the year are cloudy, as can be deduced from the analysis of the irradiance registered during a year in the municipality.As an optimal application of the method developed to control the operation of the hybrid system, it is proposed to integrate, in the management algorithms, the demand and irradiance prediction values and use dynamic values of energy prices (purchase and sale) in the grid.This complete application can be extended with real data over a period of one year or even with the use of energy forecasts for real management as future research.Finally, the analysis of multiple simultaneous variations on the different variables can be studied to provide a more robust sensitivity analysis in future works.

Appl. Sci. 2023, 13 , 2155 8 of 20 I
cc1 is the short-circuit current of the panel in A with G = 1000 W/m 2 .I cc0 is the standard short-circuit current of the panel in A (STC).C p is the power/temperature coefficient of the panel in • C −1 .T out is the outside air temperature in • C. T NOCT is the temperature of the cell in NOCT (normally operated condition test) conditions in • C. υ(v) is the correction of the temperature with the wind speed in • C. A value of υ(v) = 0 m/s is assumed.C v is the voltage/temperature coefficient of the panel.n is a factor dependent on the panel (n ∼ = 1.2).k B is the Boltzmann constant (1.380 649 × 10 −23 J K −1 ).e is the electron charge (1.6 × 10 −19 C).C I is the current/temperature coefficient of the panel in • C −1 .With these equations, using the measured irradiance and temperature data, the generated power curves for two different situations (a sunny day and a cloudy day) are performed.The sunny day corresponds to 29 March 2021, whereas the cloudy day corresponds to 7 October 2021.These generation profiles are shown in Figure 2. In these equations:  () is the maximum panel's power in W.  is the maximum panel's power in W with G = 1000 W/m 2 . is the standard maximum panel's power in W in standard test conditions (STC). is the irradiance in W/m 2 normal to the panel. () is the open-circuit voltage of the panel in V.  is the open-circuit voltage of the panel in V with G = 1000 W/m 2 . is the standard open-circuit voltage of the panel in V (STC). () is the short-circuit current of the panel in A.  is the short-circuit current of the panel in A with G = 1000 W/m 2 . is the standard short-circuit current of the panel in A (STC). is the power/temperature coefficient of the panel in °C−1 . is the outside air temperature in °C. is the temperature of the cell in NOCT (normally operated condition test) conditions in °C.() is the correction of the temperature with the wind speed in °C.A value of () = 0 m/s is assumed. is the voltage/temperature coefficient of the panel. is a factor dependent on the panel ( ≅ 1.2). is the Boltzmann constant (1.380 649 × 10 −23 J K −1 ). is the electron charge (1.6 × 10 −19 C).  is the current/temperature coefficient of the panel in °C−1 .

Figure 2 .
Figure 2. Average hourly generation per kW of installed power with solar panels on a typical sunny and cloudy day.

Figure 2 .
Figure 2. Average hourly generation per kW of installed power with solar panels on a typical sunny and cloudy day.
Appl.Sci.2023, 13, x FOR PEER REVIEW 9 of 21 with values very close to the average values.The typical consumption pattern considered in this study is shown in Figure 3.
-Obtain C G (P G ) + C E (P E ) in that scenario.-Calculate B and obtain the IRR.-Modify the values of P pr and P m and repeat the process.

-
Select the values of  and  within the possible ranges.-Optimise the operation of the BG plant and obtain the value of Equation (13).-Obtain  ( ) +  ( ) in that scenario.-Calculate  and obtain the IRR.-Modify the values of  and  and repeat the process.

Figure 5 .
Figure 5. Flowchart of the proposed method.

Figure 5 .
Figure 5. Flowchart of the proposed method.

Figure 6 .
Figure 6.Average daily benefit with a BG plant (the green area represents the most profitable powers).

Figure 6 .
Figure 6.Average daily benefit with a BG plant (the green area represents the most profitable powers).

Figure 7 .
Figure 7. Average daily benefit with a PV plant (the green area represents the powers with the highest slope).

Figure 8 .
Figure 8.Average daily benefit (in EUR/day) with both plants.

Figure 7 .
Figure 7. Average daily benefit with a PV plant (the green area represents the powers with the highest slope).

Figure 7 .
Figure 7. Average daily benefit with a PV plant (the green area represents the powers with the highest slope).

Figure 8 .
Figure 8.Average daily benefit (in EUR/day) with both plants.

Figure 8 .
Figure 8.Average daily benefit (in EUR/day) with both plants.

Figure 10 .
Figure 10.Operation of the hybrid system in the typical sunny and cloudy days.

Figure 10 .
Figure 10.Operation of the hybrid system in the typical sunny and cloudy days.

Figure 10 .
Figure 10.Operation of the hybrid system in the typical sunny and cloudy days.

Figure 11 .
Figure 11.IRR (in %) for each Pp with Pm = 140 kW (the green area represents the powers with the lowest slope).

Figure 11 .
Figure 11.IRR (in %) for each P p with P m = 140 kW (the green area represents the powers with the lowest slope).

Table 1 .
Studies carried out on hybridisation of PV and BM installations.

Table 2 .
Estimated yearly residues in the municipality.

Table 3 .
Alternative scenarios studied for sensitivity analysis.