Thermoeconomic Analysis of Biomethane Production Plants: A Dynamic Approach

: This work analyses the two most diffused technologies for biogas upgrading, namely water scrubbing and membrane separation. In order to carry out such analysis, these two technologies are coupled with photovoltaic panels and an electric energy storage system. The optimal water scrubbing renewable plant achieves a primary energy saving of 5.22 GWh/year and an operating cost saving of 488 k € /year, resulting in the best plant. It was compared to a reference system based on a cogenerator unit, directly supplied by biogas, producing thermal and electric energy, and delivered to the district heating network and to the electric grid. The proﬁtability of both plants depends on the electric energy and biomethane exporting price. The proposed bigas upgrading plant achieves a payback period lower than 10 years with a biomethane selling price greater than 0.55 € /Sm 3 and a primary energy saving index around 25–30% with a null share of thermal energy exported by the cogeneration plant.


Introduction
Organic waste is becoming more and more attractive for the production of different types of biofuels, ref. [1] such as biomethane, biogas, etc. [2]. In fact, such biofuels can be used to produce heat and power [3]. For example, in Combined heat and power (CHP) systems [4], the biofuel is used to match both internal loads of the treatment plant and the energy demands of the user. In many other cases, the produced biofuels can be used for a twofold goal: (i) to supply energy to the public grid and to the district heating networks [5]; and (ii) supply fuel to the vehicles equipped with internal combustion engines (ICE). In developing countries, a large part of the biogas production is aimed at thermal energy generation, and it is rarely upgraded into biomethane [6]. For instance, in Brazil, a large part of the biogas production is used for household use, but in recent years the government pushed the local stakeholders to increase the production of biomethane for the purpose of electric generation [7]. In Ref. [8], a life cycle assessment (LCA) is proposed for the waste management of pig manure. This analysis proved the feasibility of biomethane production for a breeding facility. The LCA approach is widely used in the literature to show the potential of biogas production and its upgrading in several developing countries [9]. In fact, similar analyses are proposed by researchers in developing countries such as Ethiopia [10], Colombia [11], India [12], Mexico [13], and many others [14]. Biogas potential in avoiding greenhouse gas (GHG) emissions is widely known [15]. Biogas mainly consists of a mixture of methane (CH 4 ) (in concentration ranging from 45% to 65% [16]), carbon dioxide (CO 2 ) and other minor components, such as ammonia, hydrogen sulphide (H 2 S), nitrogen and water [17]. The non-methane components are considered as inert compounds, because they reduce the mixture lower heating value (typically Lower heating value (LHV) equal to up to 28 MJ/m 3 [18]), flame speed, and flammability limit. Moreover, such inert compounds also cause an increase in energy usage during transportation [19]. A plurality of devices is respectively, membranes and adsorption, 0.21-0.3 kWh/Nm 3 and 0.46 kWh/Nm 3 [39], respectively, organic physical scrubbing 0.49 kWh/Nm 3 [48].
The biogas upgrading process also involves additional costs compared to the direct utilization of biogas, which can be performed in a CHP unit [49]. However, the biogas upgrading strategy is attractive from a circular economy perspective as its utilization may (i) reduce the imports of natural gas; (ii) reduce CO 2 emissions; and (iii) enhance the exploitation of local renewable energy resources [50]. In this framework, in order to reduce the high energy consumption of the process and to achieve promising energy savings, the integration of renewable energy technologies with the biogas upgrading is becoming more attractive. Several studies have shown that the high energy demand of the present biomethanation technologies can be significantly reduced by considering novel, sustainable, and feasible technologies by also improving their economic feasibility [51].
Solar source technologies are widely studied in coupling with the biomethanation units. Su et al. [52] developed a mathematical model to simulate a hybrid system including concentrated photovoltaic thermal (CPVT) collectors and biogas upgrading technology. The thermal energy of the solar collectors is used for heating the digester unit, whereas the electric energy is used to supply the biogas upgrading unit to produce biomethane. The proposed configuration allows to reduce the amount of electricity withdrawn from the grid by 48.38%, increasing biomethane production by 86.08%. A more sustainable and efficient biomethane production, with the reduction of the high thermal energy consumption of upgrading systems based on the chemical absorption, is proposed in reference [53]. Here, CPVT collectors produce the heat required by the solvent regeneration and digester unit, whereas the electricity can be used to match the power demand of the biogas plant. The dynamic simulation of the proposed system shows that CPVT collectors can match 17% of the thermal energy demand and 51.1% of the electricity demand. The electric energy excess, roughly 140. 3 MWh/year, is exported to the grid. In the study of Curto et al. [54], biogas was upgraded to natural gas by means of a methanation process, exploiting the hydrogen, produced via electrolyzers driven by the electricity provided by solar and wind fields. Two regions featured by high wind or solar availability are considered for carrying out the study: the United Kingdom and Spain. This research suggests that the biogas upgrading plant driven by renewables installed in the United Kingdom exhibits better economic results with respect the one installed in Spain because of the lower PV capital cost in the United Kingdom.

Novelty and Aim of the Study
The adoption of renewable energy technologies to enhance the biomethane sustainable production was investigated in the previously presented literature review. The applications are mainly focused on the production of biogas integrated by solar energy, achieving promising energy savings. Several applications are considered, namely the solar-assisted biodigester [55], PV panels coupled with a biodigester [56,57], solar heating systems into fixed dome digesters [58], and studies based on life cycle energy and cost analysis of small scale biogas plants coupled with solar PV panels [59]. However, to the best of the authors' knowledge, there is still no work in the literature which performs a detailed thermoeconomic comparison of biogas upgrading technologies coupled with a photovoltaic and electric energy storage system. In particular, the novelties of this work can be listed as follows.

•
The development of a comprehensive dynamic simulation model for the renewable biomethane production based on photovoltaic and lithium-ion battery.

•
The coupling of PV panels and a lithium-ion storage system to increase the selfconsumed energy and sustainability of the biomethane production. • A thermoeconomic comparison of the water scrubbing and membrane separation technologies in order to assess which achieves a more sustainable biomethane production. • A detailed analysis in order to assess the optimal capacity mix of the considered technologies, i.e., PV capacity, battery capacity, water scrubber operating pressure, membrane separation operating pressure and the number of membrane separation stages for detecting the optimal layout.

Layout
The proposed plant aims to integratine renewable sources of energy, i.e., a photovoltaic field, into a biogas upgrading plant, as shown in Figure 1. Note that three layouts are studied and compared in this work. These layouts only differ for the selcted biogas upgrading technology, namely water scrubbing, two-stage membrane separation, and three-stage membrane separation.
The electricity produced by the PV field is used to match the electric energy demand of the biogas upgraing plant consitsting of the biogas upgrading unit and its auxiliary components. This plant is also equipped with an electric energy storage system that consists of a lithium-ion battery (LIB).
In the case of scarce or null solar production, the electric energy is first withdrawn from the LIB. Note that the battery discharge is allowed only if the battery state of charge (SoC) ranges from 5% to 90%. Conversely, in the case of solar production higher than plant energy demand, the surplus electric production is delivered to the LIB until its SoC reaches the maximum allowed value of 90%. When the battery SoC is higher than the upper treshold, i.e., SoC = 90%, the electric energy is delivered to the grid. The electric energy storage is used both to increase the energy self-sufficiency of the system proposed and to shave the peaks of electricity export into the grid during the most irradiated periods. In the presented plant, the biogas flow rate provided to the upgrading unit is supposed to be constant, thanks to a tank buffer at the downstream of the anaerobic digester. This solution is commonly applied in the design of biogas upgrading plants. In fact, such an approach is able to avoid sharp variations of the biogas flow rate that may worsen the performance and the security of the plant.  The electricity produced by the PV field is used to match the electric energy demand of the biogas upgraing plant consitsting of the biogas upgrading unit and its auxiliary components. This plant is also equipped with an electric energy storage system that consists of a lithium-ion battery (LIB).
In the case of scarce or null solar production, the electric energy is first withdrawn from the LIB. Note that the battery discharge is allowed only if the battery state of charge (SoC) ranges from 5% to 90%. Conversely, in the case of solar production higher than plant energy demand, the surplus electric production is delivered to the LIB until its SoC reaches the maximum allowed value of 90%. When the battery SoC is higher than the upper treshold, i.e., SoC = 90%, the electric energy is delivered to the grid. The electric energy storage is used both to increase the energy self-sufficiency of the system proposed and to shave the peaks of electricity export into the grid during the most irradiated periods. In the presented plant, the biogas flow rate provided to the upgrading unit is supposed to be constant, thanks to a tank buffer at the downstream of the anaerobic digester. This solution is commonly applied in the design of biogas upgrading plants. In fact, such an approach is able to avoid sharp variations of the biogas flow rate that may worsen the performance and the security of the plant.

Membrane Model
Concerning membrane separation (MS) biogas upgrading technology, compressors and membranes play a crucial role. The components of the systems include:

•
Compressors, which compress the inlet gas to the rated operating pressure, providing the driving force for the whole process • Spiral wound membrane modules, where the separation between CO 2 and CH 4 occurs Several configurations may be developed considering a variable number of membranes and compressors. As mentioned before, this work addresses two-stage MS and three-stage MS. For example, a layout of a three-stage MS biogas upgrading unit is shown in Figure 2.
providing the driving force for the whole process • Spiral wound membrane modules, where the separation between CO2 and occurs Several configurations may be developed considering a variable numb membranes and compressors. As mentioned before, this work addresses two-stag and three-stage MS. For example, a layout of a three-stage MS biogas upgrading u shown in Figure 2. The model used for the simulation of the membrane system is based on the pri that a gaseous mixture can be fractionated as a function of the different permeability components in polymeric films (membranes) [60]. In particular, when the compresse is supplied to a module, the pressure difference across the membrane genera permeate, rich in permeable compound (i.e., CO2), and a residual flow, defin retentate, rich in non-permeable components, i.e., CH4. Further details of this mod discussed in reference [61]. The presented model also includes the assessment of th recovery ηCH4 and the average composition of the permeate yave, respectively, Equatio and (2).
where θ is the permeated supply fraction.

Water Scrubber Model
The simplified layout of the plant related to the pressure water scrubbing techn is represented in Figure 3. The system consists of the following components: • Absorption column (scrubber): a tower where the biogas and the water are counter flow arrangement.

•
Compressors: a first compressor is used to increase the pressure of the b entering the column; a second compressor is used to increase the pressure outlet biomethane flow up to the low pressure network, about 7 bar. • Pump: a circulation pump is needed for the water supplying the top of the scr at the operating pressure. The model used for the simulation of the membrane system is based on the principle that a gaseous mixture can be fractionated as a function of the different permeability of its components in polymeric films (membranes) [60]. In particular, when the compressed gas is supplied to a module, the pressure difference across the membrane generates a permeate, rich in permeable compound (i.e., CO 2 ), and a residual flow, defined as retentate, rich in non-permeable components, i.e., CH 4 . Further details of this model are discussed in reference [61]. The presented model also includes the assessment of the CH 4 recovery η CH4 and the average composition of the permeate y ave , respectively, Equations (1) and (2).
where θ is the permeated supply fraction.

Water Scrubber Model
The simplified layout of the plant related to the pressure water scrubbing technology is represented in Figure 3. The system consists of the following components: • Absorption column (scrubber): a tower where the biogas and the water are fed in counter flow arrangement.

•
Compressors: a first compressor is used to increase the pressure of the biogas entering the column; a second compressor is used to increase the pressure of the outlet biomethane flow up to the low pressure network, about 7 bar. • Pump: a circulation pump is needed for the water supplying the top of the scrubber at the operating pressure. • Cooler: it cools down the outlet gas exiting the compressor. In fact, due to the pressure increase, the gas temperature increases, lowering its solubility. Therefore, a cooling process is needed to control the gas outlet temperature. • Filter: this device filters the impurities in the water entering the scrubber. • Dryer: it removes water from the biomethane gas mixture in order to avoid any reduction of its heating value.
The model is derived by the algorithm provided by Ref. [62], which was validated against experimental results (i.e., data available in Ref. [63]). The simulation model of the water scrubber technology allows one to evaluate the performance of the system according to the one-dimensional mass balances of the species involved for an element of the column of infinitesimal height, in both the liquid and gaseous phases.
Concerning the calculation of the partial pressure of gaseous phase, it is assumed that this is directly derived from its mole fraction, which is related to the mass fraction according to the Raoult Law [64]. Boundary conditions and assumptions of the model are further discussed in Ref. [62], where all the packing characteristics are explained. Furthermore, the most widely used semi-empirical correlations for the calculation of the Henry coefficients, Diffusive coefficients, Equilibrium constants, and Mass Transfer parameters are shown. The system of Equations (3)-(6) was implemented in MatLab using the ode15s solver specifying the initial conditions, i.e., the mass fractions of CO 2 and CH 4 in the inlet gas and in the outlet liquid from the scrubber, and the integration interval, i.e., from the basis to the top of the scrubber. The calculation procedure involves iterating the integration interval, i.e., the height of the scrubber, until the desired outlet conditions are reached. For further details regarding the anaerobic digestion modelling and dynamic simulation, we recommend reviewing the other works of the authors [65]. • Cooler: it cools down the outlet gas exiting the compressor. In fact, due to the pressure increase, the gas temperature increases, lowering its solubility. Therefore, a cooling process is needed to control the gas outlet temperature.

•
Filter: this device filters the impurities in the water entering the scrubber. • Dryer: it removes water from the biomethane gas mixture in order to avoid any reduction of its heating value. The model is derived by the algorithm provided by Ref. [62], which was validated against experimental results (i.e., data available in Ref. [63]). The simulation model of the water scrubber technology allows one to evaluate the performance of the system according to the one-dimensional mass balances of the species involved for an element of the column of infinitesimal height, in both the liquid and gaseous phases.

Auxiliary Units Model
The biogas upgrading units are coupled with auxiliary units. The water scrubbing unit also includes a multistage reciprocating compressor for the inlet biogas, a pump for the supply water, a blower, and a cooler for cooling down the incoming gas flow rate. The models adopted for these components are selected according to Ref. [19] and are reported below. The power consumption of the multistage reciprocating compressor with two stages was calculated fixing the efficiency of the unit, as follows: For the pump, the shaft power was calculated according to the following equation: where the total head is calculated, according to Ref. [19], as the sum of three terms related to the pressure difference, the heigth of the column, and the friction factor. The equation for the assessment of the blower power demand is the same as for the pump, considering the air flow rate instead of the water flow rate: The cooler was designed to cool the gas down to the column operating temperature. The equation used to assess the power needed for cooling the gas down is based on a simple energy balance on the unit:

TRNSYS Model
Finally, the simulation model of whole plant is developed in Transient System Simulation Tool (TRNSYS) enviroment. Here, for sake of brevity, only the main TRNSYS library is listed. Type 94 of the TRNSYS library was used to simulate the performance of PV panels. This model is based on the so-called "four parameters" model, and can be used to simulate single or polycrystalline silicon PV systems involving electrical storage batteries, and direct load coupling and utility grid connections. For further details see ref. [66].
Type 47 of the TRNSYS library was used to simulate the electric energy storage system by using the Shepard mathematic model. Note that the storage system model related to Type 47 is suitable to model lead acid batteries. In order to simulate a lithium-ion battery, the parameters of Type 47 are modified to fit the performance of a commercial lithium battery according to the work available in Ref. [67].
The dynamic simulations are carried out by taking into account the hourly Meteonorm weather data files for the weather zone of Stuttgart (Germany) in order to simulate the performance of the components of the plant featured by weather dependent parameters.

Thermoeconomic Model
The model includes the assessment of the capital cost of the upgrading unit and auxiliaries as well as the operating costs due to the maintenance and replacement of components and electric energy consumption. The capital cost of the scrubber system is a function of the treated biogas volumetric flow rate. Considering a specific cost of 5400 €/Nm 3 /h [68], the total capital cost, I scrubber , is 427.50 k€. The capital cost of the PV panels and electric energy storage system are equal to 1000 €/kW and 200 €/kWh, respectively, according to Ref. [69]. For the membrane system, the total capital cost, I membrane , considers the cost of pumps, compressors and the membranes in area A. The membranes area A depends on the compression ratio of the various stages and the specific cost per m 2 of the selected membrane. A polymide membrane is selected, featured by a specific cost C membrane of 50 €/m 2 [70]. The designed area considers that the outlet biomethane only includes CO 2 at 2% and considers the inlet biogas flow rate F feed (Nm 3 /s), the pressure difference ∆P (Pa) between the inlet and outles sections of the mebrane, and the average permeability of the biogas Q av (GPU, gas permeance unit) (weighted according to the fractions of biogas components x i,feed and the related permeability Q i ) [70]. The equation for the calculation of the membrane area cost is reported as follows [60]: The pumps and the compressors are selected according to the pressure drop and the flow rate of the biogas. Then, these devices are selected from the "Fini" and "Salmson" data sheet and price lists [71]. The maintenance cost of the scrubber system is assumed to be equal to 9% of the total capital cost I scrubber [70], whereas for the membrane systems, the membrane replacement cost (MRC) is considered according to a yearly replacement rate (ν), equal to 0.25, and a membrane replacement price (K mr ) equal to 25 €/m 2 [70]: The yearly maintenance costs of pumps and compressors are assumed to be 1% of the capital cost. The specific cost of the electric energy withdrawn from the grid is assumed equal to 0.20 €/kWh [72].
The economic analysis is based on the evaluation of the basic economic indexes used to evaluate the economic feasibility of energy plants, i.e., the simple payback (SPB), net present value (NPV), and the profit index (PI). The NPV index is evaluated considering a lifetime of 10 years and a discount factor of 5%. CHP electric and thermal rated efficiency are 43% and 44.9%, respectively [23]. The specific capital cost of the cogenerator is 1700 €/kW e [61]. The yearly maintenance cost is equal to 2% of the capital cost (357.5 k€/y).
To evaluate the primary energy and operating costs of the cogenerator, the approach considered in the ref. [61] is implemented. In particular, the avoided CO 2 emissions, primary energy, and costs are estimated considering that the energy outputs of the cogenerator will be matched by the national electric grid with a rated electric efficiency equal to 46% and a gas-fired boiler with a rated thermal efficiency equal to 95% [73].
A selling price for the produced thermal energy equal to 0.05 €/kWh is assumed; however, three reference scenarios are evaluated considering different fractions of recovered thermal energy with respect to the total produced thermal energy, i.e., 0%, 50% and 100%. To consider this variation of the thermal recovery from the cogenerator, a sensitivity analysis is carried out, varying the thermal fraction as follows: The selling price of the produced electric energy by cogenerator is considered variable from 0.06 to 0.17 €/kWh, as well as the selling price of the biomethane in proposed systems from 0.20 to 0.40 €/Sm 3 , in order to estimate the economic feasibility of the proposed systems according to several feed-in tariff policies. Table 1 shows all the parameters adopted in the thermoeconomic analysis discussed above.

Case Study
As discussed before in the section System Layout, three different biogas upgrading plants are studied and compared. Such plants are coupled with a sewage sludge treatment plant located in Stuttgart (Baden-Wuttemberg, Germany). This plant is equipped with an anaerobic digester producing biogas from sewage sludge. In particular, such plant pruduces rougly 83.46 Sm 3 /h of biogas, which consist of 62% of CH 4 and 38% of CO 2 , Table 2. Despite the variability of the biogas flow rate, it is assumed that the investigated biogas upgrading systems are supplied by a fixed flow rate of biogas. This assumption is consistent with the use of a gasometer and a buffer tank included between the digester and the biogas upgrading unit as buffer, making the inlet flow rate constant and equal to the average value of 83.46 Sm 3 /h ( Table 2). Regarding the biogas temperature trend, it was less variable with respect to the flow rate trend due to the high volume of the digester and the high specific heat of the contained mass. The renewable plant includes a PV field with a rated efficiency of 18% and a lithium-ion battery, and their parameters are reported in Table 2. The proposed layout performances are compared against the current state of the art in a biogas power plant, which consists of a cogeneration plant. When the biogas is used by a cogeneration reciprocating engine, heat and electricity are simultaneously produced. In particular, the cogenerator is supplied by a constant flow rate of biogas, which is the same of the proposed layouts, i.e., 83.46 Sm 3 /h. The cogenerator is featured by a rated power of 210.3 kW (Table 2 [23]) and produces 1842. 25 MWh/year of electric energy and 1923. 65 MWh/year of thermal energy, which are delivered to the electric grid and to local facilities, respectively.

Results
This section is divided into two subsections. In the first one, the optimal response surfaces for all the considered biogas upgrading plants are evaluated and discussed. In the second one, the optimal layouts are compared against the current state of the art in biogas power plants, i.e., a cogenerator burning biogas for producing thermal energy and electricity. The electricity and the thermal energy produced are exported.

Optimal Response Surface
This study aims at detecting the optimal response surfaces of the proposed layouts by means of the response surface methodology [74]. Such an approach is able to display the response, i.e., object functions, of complex layouts and systems using empirical and numerical methods [75]. Therefore, this approach is able to figure out the optimal configurations [75,76]. Thus, this approach can be exploited for detecting the Pareto frontier of the studied system [76,77]. In order to detect the optimal response surface of the proposed renewable layout based on water scrubbing upgrading technology (water scrubbing plant WSP), the operative pressure of the scrubber (see System Model and System Layout) is varied from 1.20 bar to 20 bar, the photovoltaic field capacity is varied from 10 kW to 400 kW and the battery capacity is varied from 91 kWh to 569 kWh. Figure 4 summarizes the results of these analyses, displaying the selected object functions, namely costs (C) and primary energy (PE). Note that the operating costs are negative because the savings due to the biomethane exporting and energy saving certificates overcame the plant operating costs due to maintenance and the purchasing of electric energy. PE is negative for similar reasons; in fact, the primary energy linked with the volume of biomethane exported is significantly higher than the primary energy consumption due to the electricity withdrawn from the grid.    [75,76]: the optimal layout, achieving a C of −488 k€/year and a PE of 5. 22 GWh/year, consists of a rated operative pressure of 1.20 bar, a PV field of capacity of approximately 200 kW and a lithium-ion battery of a capacity of roughly 182 kWh. In particular, this layout is featured by the lower bound of the operative pressure. In fact, the plant performance worsens as the scrubber operative pressure increases. This trend is related to the fact that the increase of the scrubber operative pressure leads to a negligible enhancement in biomethane quality (i.e., percentage of CO 2 ) and a negligible increase of biomethane production. The increase of the operative pressure reduces the height of the scrubber column: the desired purity of biomethane (i.e., CO 2 concentration less equal to 2%) is achieved by a shorter scrubber column. However, the investment cost of the plant does not depend on the height of the scrubber column, but it depends only on the volume of biogas processed by the plant [68]. At the same time, the increase of operative pressure leads to a significant increase of the plant power demand.
The fact that the optimal layout is featured by a PV field capacity of 200 kW and a battery capacity of 182 kWh is clearly explained by Figure 5. In particular, Figure 5 displays the energy performances of the WSP when the PV field capacity and battery capacity are simultaneously varied, and the operative pressure is equal to 1.20 bar. The best layout is able to maximize the share of the plant electricity demand (E el,LOAD ) matched by the self-consumed energy (E el,self ), almost limiting the surplus electricity exported to the grid (E el,toGRID ). In fact, for such a configuration, the self-consumed energy meets roughly 92% of the plant load, while 64% of the produced renewable electricity (E el,PV ) is exported to the grid. In particular, such a layout is almost grid-independent, as the battery (P el,fromLIB ) is able to match the plant power demand (P el,LOAD ) throughout the day, as shown in Figure 6. According to these results, the battery is crucial in achieving the grid-independence: the share of plant electricity demand matched by the battery ranges from 50% to 60% on a monthly basis, as shown in Figure 6.
A larger PV field further increases the surplus electricity without significantly reducing the electricity withdrawn from the grid. This trend worsens the economic performance of the renewable plant. In fact, the increase of the PV field capacity increases the maintenance costs, which overcomes the gains due to electricity exporting for larger PV field capacity. In fact, as shown in Figure 6, the battery would not be able to store a further share of photovoltaic electricity. Concerning the electric energy storage system, the plant is not able to exploit the discharge depth of high-capacity LIB because of the low-rated power demand of the WSP using 1.20 bara as the operative pressure. Figure 7 displays the optimal response surface for the renewable plant adopting twostage and three-stage membrane separation upgrading technology (2SMP and 3SMP). The layouts featured by the higher operating pressure and the higher battery and PV capacity achieve the best results for 2SMP, i.e., a PE of roughly −5.02 GWh/year and a C of about −483 k€/year. This result is related with the fact that the increase of the operating pressure improves the amount of biomethane produced by this kind of plant. In fact, the higher the pressure the higher the driving force of the membrane separation process (see System Model). This allows the membrane to separate a higher share of CH 4 from the biogas mixture.
Higher operating pressures lead to higher power demand for plant compressors. Therefore, the plant adopting a higher operative pressure is able to exploit a higher share of the produced renewable electricity. In fact, as clearly displayed in Figure 8, the plant adopting an operative pressure of 20 bar, a PV field capacity of 400 kW and a battery capacity of 365 kWh is able to self-consume almost 50% of the produced electricity (see E el,toGRID /E el,PV Figure 8). At the same time, roughly 90% of plant electricity demand is met by the self-consumed electricity (E el,self ). This point is clearly displayed by Figure 9. In fact, the photovoltaic field (P el,PV ) with the lithium-ion battery (P el,fromLIB ) meets the power load (P el,LOAD ) throughout the day without withdrawing electricity from the grid (P el,fromGRID ), Figure 9. According to the aforementioned trends, the plant is almost grid self-independent from February to October. The battery plays a crucial role in such a plant, matching around 40 ÷ 60% of E el,LOAD , Figure 9.    Figure 10 displays the energy performance of the proposed renewable plant adopting a two-stage membrane biogas upgrading process for a storage system capacity of 364 kWh and a simultaneously varying system-rated pressure and photovoltaic capacity. This figure is consistent with the above described trends. In fact, as explained before, the increase of the rated operating pressure significantly increases the plant power demand, allowing the plant to exploit a higher share of renewable produced electricity (see also Figure 9). Then, for higher operating pressure and higher PV field, the electricity exported to the grid (E el,toGRID ) is limited, but the self-produced electricity (E el,self ) matches roughly 90% of the plant electricity demand. Sustainability 2022, 14, x FOR PEER REVIEW 14 of 24      The optimal response surface and the Pareto frontier for 3SMP is displayed in Figure 7. The optimal 3SMP consists of a rated pressure of 10 bar, a PV field of 400 kW and a battery capacity of 365 kWh. The operative costs (C) of this plant are around −486 k€/year, while the primary energy (PE) is around −5.06 GWh/year. The increase of the operative pressure leads to a decrease of the plant's overall performance because of the significant increasing of the power demand of the plant, due to the compressors. At the same time, this increase causes a very limited enhancement in biomethane production and quality. In other words, the marginal electric cost of biomethane production rapidly increases beyond 10 bar. The fact that the 3SMP with an operative pressure of 10 bar achieves best results with respect to 2SMP adopting an operative pressure of 20 bar (the optimal 2 stage membrane separation layout) is related with the fact that such 3SMP uses less electricity for producing more biomethane. In fact, 2SMP is featured by a rated specific production ratio of 0.38 kWh/Sm 3 , whereas 3SMP is featured by a specific production ratio of 0.36 kWh/Sm 3 . Moreover, since the increase in the upgrading plants' number of stages leads to an enhancement in the purity of the biomethane produced, the 3SMP achieves better results with respect to 2SMP, adopting a lower operative pressure, i.e., 10 bar vs 20 bar. These results are consistent with the results and studies available in the open literature [78,79]. However, more stages lead to greater technological complexity of the plant due to the higher number of compressors and sensors. Therefore, in this framework, 3SMP may be considered the optimal tradeoff among biomethane purity and plant complexity.  The fact that the 2SMP optimal layouts is featured by the upper bound of the PV field and the battery capacity is equal to 364 kWh is for the same reasons as discussed above for 2SMP. These trends are shown in Figures 11 and 12. In fact, these figures highlight that the system is almost grid independent, in particular 90% of the plant energy demand is matched by the produced electricity ( Figure 11). In fact, the battery is able to store a significant amount of the surplus renewable power produced by the PV field and to use this stored energy for matching the plant electricity demand for the whole day ( Figure 12).    Figure 13 displays the energy results for the three-stage membrane separation biogas upgrading plant integrated with a battery capacity of 364 kWh, varying the rated operating pressure and the capacity of the photovoltaic field. This figure is consistent with the trend discussed above and confirms that the layout adopting a rated pressure of 10 bar is the optimal one. In this case, roughly 90% of E el,LOAD is matched by the self-produced electricity. The increase of the operative pressure leads to a significant increase of plant power demand, reducing the share of E el,LOAD met by the renewable electricity. Finally, comparing WSP, 2SMP and 2SMP, the first one achieves better results. These trends are related with the lower demand of energy of water scrubbing (WS) technology with respect to membrane separation (MS) technology. In particular, MS achieves the same volume of biomethane production using a lower amount of electricity. In particular, WS has a specific production cost of 0.16 kWh/Sm 3 , whereas two-stage MS and three-stage MS have a specific production ratio of 0.38 kWh/Sm 3 and 0.36 kWh/Sm 3 , respectively.
Considering the integration of MS and WS with the renewable plant including a photovoltaic field and a lithium-ion battery, the specific production ratio dramatically decreases. In particular, the optimal WS layout achieves a ratio of 0.009 kWh/Sm 3 , whereas the optimal two-stage and three-stage MS achieves a ratio of 0.020 kWh/Sm 3 and 0.018 kWh/Sm 3 . These values are significantly lower with respect to the ones available in the literature due to the adoption of renewable energy sources.

Energy and Economic Analysis
The optimal layouts assessed in the previous section are compared with the conventional state of the art in a biogas power plant, which consists of a reciprocating engine burning the produced biogas (CHP). The electricity produced by such an engine is exported to the electric national grid, getting fees that may range from 0.06 €/kWh to 0.22 €/kWh. The thermal energy recovered from the engine is purchased by local facilities, with a selling price of 0.05 €/kWh. The ratio of thermal energy exported is varied according to the parameter α, see Equation (13).
As expected, the increase of the parameter α leads to a significant enhancement of the reference system, i.e., the cogeneration plant, letting CHP achieve better results with respect to the proposed optimal scenarios. In fact, for value of α greater than 0.50, PES becomes negative, which means that the avoided primary energy of CHP is greater than the proposed scenarios, as shown in Figure 14. Therefore, the ratio of thermal energy exported to local users is crucial, in fact such point is able to make the conventional approach of burning biogas into a CHP plant more energy convenient with respect to every biogas upgrading strategy. This result is deeply related with the fact that the biogas upgrading process is remarkably energy demanding. Note that the surplus electricity exported to the grid is limited, accounting for less than 13% of the avoided primary energy for all proposed scenarios. Finally, Figure 14 confirms that the water scrubbing process reaches better results from the energy point of view. Figure 15 summarizes the economic performance of the proposed optimal scenarios compared with CHP. In particular, the electricity and natural gas selling costs are mutually varied. The economic performance of the analyzed scenarios is dramatically affected by the natural gas selling price (j NG ). In fact, for a value of j NG greater than 0.55 €/Sm 3 , all the scenarios achieve a SPB lower than 10 years, regardless the electric energy selling cost and the share of thermal energy exported.

Energy and Economic Analysis
The optimal layouts assessed in the previous section are compared with the conventional state of the art in a biogas power plant, which consists of a reciprocating engine burning the produced biogas (CHP). The electricity produced by such an engine is exported to the electric national grid, getting fees that may range from 0.06 €/kWh to 0.22 €/kWh. The thermal energy recovered from the engine is purchased by local facilities, with a selling price of 0.05 €/kWh. The ratio of thermal energy exported is varied according to the parameter α, see Equation (13).
As expected, the increase of the parameter α leads to a significant enhancement of the reference system, i.e., the cogeneration plant, letting CHP achieve better results with respect to the proposed optimal scenarios. In fact, for value of α greater than 0.50, PES becomes negative, which means that the avoided primary energy of CHP is greater than the proposed scenarios, as shown in Figure 14. Therefore, the ratio of thermal energy exported to local users is crucial, in fact such point is able to make the conventional approach of burning biogas into a CHP plant more energy convenient with respect to every biogas upgrading strategy. This result is deeply related with the fact that the biogas upgrading process is remarkably energy demanding. Note that the surplus electricity exported to the grid is limited, accounting for less than 13% of the avoided primary energy for all proposed scenarios. Finally, Figure 14 confirms that the water scrubbing process reaches bet- ter results from the energy point of view. Figure 15 summarizes the economic perfor mance of the proposed optimal scenarios compared with CHP. In particular, the electricit and natural gas selling costs are mutually varied. The economic performance of the ana lyzed scenarios is dramatically affected by the natural gas selling price (jNG). In fact, for value of jNG greater than 0.55 €/Sm 3 , all the scenarios achieve a SPB lower than 10 years regardless the electric energy selling cost and the share of thermal energy exported. However, when the thermal energy exported increases and jel increases, the RS i much more convenient than the proposed scenarios, achieving a higher amount of sav ings. Finally, Figure 15 confirms that water scrubbing biomethane upgrading technolog achieves better results with respect to membrane separation, since it is less energy de manding. Therefore, the water scrubbing plant purchases less electricity by the grid Moreover, water scrubbing is featured by lower costs for maintenance. The membran separation process involves very high costs for maintenance [70].

Conclusions
This work presents a comparison between two biogas upgrading technologies coupled with photovoltaic panels and an electric energy storage system: the water scrubbing and the membrane separation systems. The water scrubbing solution showed the best results: an operating pressure of 1.20 bar, a photovoltaic field of 200 kW and a lithium-ion battery of 182 kWh. This layout achieves a primary energy of −5. 22 GWh/year and a yearly However, when the thermal energy exported increases and j el increases, the RS is much more convenient than the proposed scenarios, achieving a higher amount of savings. Finally, Figure 15 confirms that water scrubbing biomethane upgrading technology achieves better results with respect to membrane separation, since it is less energy demanding. Therefore, the water scrubbing plant purchases less electricity by the grid. Moreover, water scrubbing is featured by lower costs for maintenance. The membrane separation process involves very high costs for maintenance [70].

Conclusions
This work presents a comparison between two biogas upgrading technologies coupled with photovoltaic panels and an electric energy storage system: the water scrubbing and the membrane separation systems. The water scrubbing solution showed the best results: an operating pressure of 1.20 bar, a photovoltaic field of 200 kW and a lithium-ion battery of 182 kWh. This layout achieves a primary energy of −5.22 GWh/year and a yearly cost of −488 k€/year. This plant arrangement was grid-independent, producing enough electricity to be able to meet about 92% of the plant demand.
The comparison with the conventional plant highlighted that: • when the share of thermal energy exported by the reference system is equal to zero, the assessed optimal scenarios achieve a primary energy saving index ranging at about 27%; • when the biomethane exporting price is greater than 0.55 €/Sm 3 , the simple payback is lower than 10 years, regardless of the electric energy exporting prices and the share of thermal energy exported.