Data-Driven Optimal Design of a CHP Plant for a Hospital Building: Highlights on the Role of Biogas and Energy Storages on the Performance

: Combined heat and power (CHP) generation plants are an assessed valuable solution to signiﬁcantly reduce primary energy consumption and carbon dioxide emissions. Nevertheless, the primary energy saving (PES) and CO 2 reduction potentials of this solution are strictly related to the accurate deﬁnition and management of thermal and electric loads. Data-driven analysis could represent a signiﬁcant contribution for optimizing the CHP plant design and operation and then to fully deploy this potential. In this paper, the use of a bi-level optimization approach for the design of a CHP is applied to a real application (a large Italian hospital in Rome). Based on historical data of the hospital thermal and electric demand, clustering analysis is applied to identify a limited number of load patterns representative of the annual load. These selected patterns are then used as input data in the design procedure. A Mixed Integer Linear Programming coupled with a Genetic Algorithm is implemented to optimize the energy dispatch and size of the CHP plant, respectively, with the aim of maximizing the PES while minimizing total costs and carbon emissions. Finally, the effects of integrating biogas from the Anaerobic Digestion (AD) of the Spent Coffee Ground (SCG) and Energy Storage (ES) technologies are investigated. The results achieved provide a benchmark for the application of these technologies in this speciﬁc ﬁeld, highlighting performances and beneﬁts with respect to traditional approaches. The effective design of the CHP unit allows for achieving CO 2 reduction in the order of 10%, ensuring economic savings (up to 40%), when compared with a baseline conﬁguration where no CHP is installed. Further environmental beneﬁts can be achieved by means of the integration of AD and ES pushing the CO 2 savings up to 20%, still keeping the economical convenience of the capital investment.


Introduction
Global warming, rapid population growth (the population is forecast to reach 9.7 billion people by the 2050 [1]), and, more recently, the global COVID-19 pandemic are critical societal, economic, and engineering challenges. During the recent COP 26 in Glasgow, the most recent international agreement concerning global warming, a limit to the rise in global average temperature to 1. 5 Celsius degrees has been fixed, and for the first time, individual countries have been forced to phase down unabated coal power and inefficient subsidies for fossil fuels [2]. Furthermore, besides greenhouse gas (GHG) reduction, waste management and virgin raw material utilization are also very relevant challenges. A move to a "Circular Economy" development model-namely, a significant reduction of wastes and virgin raw materials utilization-cannot be postponed in order to satisfy the worldwide growing demand for energy and goods with an effective management of the available resources and almost waste-free utilization processes. below the predicted level and a consequent loss of energy efficiency, as well as economic revenue [24]. In detail, in the standard design methodologies of CHP plants, the dynamics of heat and power demand are quite often not properly taken into account and average values are taken as reference. As described in [25], a dynamic design procedure can solve these limits, but it requires previous knowledge of representative loads for the application that should further not be influenced by singularities related to the specific observation period. In [25], clustering the load starting from the historical data in order to obtain a typical load profile not affected by singularities [25] is a solution introduced to address this problem.
Besides the development of smart design strategies, the problem of the optimization scheduling of Multi Energy Systems (MESs) based on the CHP system, RES, and ES is also crucial and is well studied in the literature [26][27][28][29][30]. There are several approaches to deal with this problem, among them the improved differential evolutionary algorithm [27,31] and Particle Swarm Optimization, and other types of evolutionary algorithm in a bi-level optimization framework, which combines Mixed Integer Linear Programming (MILP) and Evolutionary Algorithm [28,[32][33][34][35][36], have been extensively investigated in the recent literature.
The work presented in this paper is based on the latter approach that has been effectively tested in previous work by the authors for different applications, ranging from university buildings [33] to Net Zero Energy Factories [32]. In the context previously defined, the main contribution of the present study is the application of the proposed methodology to simultaneously optimize the economic and environmental targets considering of a CHP civil application integrating Anaerobic Digestion (AD) of the SCG and its value chain, as well as Energy Storage (ES) technologies. Referring to the specific case of a large hospital building, the study allows us to understand the limits of the proposed approach with respect to traditional solutions; therefore, it provides a unique reference benchmark for the energy performance of this type of application. The major novelties of the study can be summarized in the following points:

•
Proposes a bi-level optimal design for the integration of Biogas from Anaerobic Digestion (AD) and Energy Storage (ES) technologies (Thermal Energy Storage-TES and Battery Energy Storage System (BESS) for CHP applications; • Uses the developed design and control algorithm on a real case study (the energy system of a hospital facility located in Rome) to evaluate the potential benefits arising from the innovative approach. Hospitals have in fact often used CHP power systems due to the relevant electric and thermal power consumed and the demands' contemporaneity; • Provides energy and environmental KPIs as a benchmark for a real case study for a hospital building.

System Layout
This study presents the definition of an optimal CHP and Anaerobic Digestion configuration for the hospital "Policlinico Tor Vergata," located in Rome, Italy.
This application has been chosen as hospitals are ideal applications for CHP powerplants as they are able to successfully match electricity and heat demands during the whole year [37]; on the other hand, some economic advantages arise from the CHP installation: 1.
The in situ cogeneration of electricity and heat is cheaper than the separated generation.

2.
Financial incentives are available in Italy (as in the rest of the EU) for the CHP units that achieve specific performance goals [37].
The building (Figure 1) is characterized by an overall surface of about 140,000 m 2 with a central structure of four horizontal levels, intended for diagnosis and treatment, and two eleven-level building units with vertical development, designed for hospital stays (500 beds). 2. Financial incentives are available in Italy (as in the rest of the EU) for the CHP units that achieve specific performance goals [37].
The building (Figure 1) is characterized by an overall surface of about 140,000 m 2 with a central structure of four horizontal levels, intended for diagnosis and treatment, and two eleven-level building units with vertical development, designed for hospital stays (500 beds). The hospital is equipped with a 350 kW NaBr absorption solar cooling system, a 100 kWp photovoltaic (PV) power plant, and a 2 MW CHP plant based on a reciprocating Internal Combustion Engine (ICE) fueled by natural gas. Among the available CHP technologies, the ICE was selected to match the power to heat ratio (PHR) of the building. Its size was defined based on a static characterization of the thermal and electric load, i.e., using the load duration curves (Figure 2). In particular, the 2 MW power output value was chosen to have the CHP plant operating at the nominal design set-point for the whole year. The current system configuration further makes the system eligible for highefficiency incentives (HE-CHP), according to the Italian law, as the PES, calculated with Equation (1) [37], is 23,78%: The hospital is equipped with a 350 kW NaBr absorption solar cooling system, a 100 kWp photovoltaic (PV) power plant, and a 2 MW CHP plant based on a reciprocating Internal Combustion Engine (ICE) fueled by natural gas. Among the available CHP technologies, the ICE was selected to match the power to heat ratio (PHR) of the building. Its size was defined based on a static characterization of the thermal and electric load, i.e., using the load duration curves (Figure 2). In particular, the 2 MW power output value was chosen to have the CHP plant operating at the nominal design set-point for the whole year.
with a central structure of four horizontal levels, intended for diagnosis and trea and two eleven-level building units with vertical development, designed for ho stays (500 beds). The hospital is equipped with a 350 kW NaBr absorption solar cooling system kWp photovoltaic (PV) power plant, and a 2 MW CHP plant based on a recipro Internal Combustion Engine (ICE) fueled by natural gas. Among the available technologies, the ICE was selected to match the power to heat ratio (PHR) of the bu Its size was defined based on a static characterization of the thermal and electric loa using the load duration curves ( Figure 2). In particular, the 2 MW power output was chosen to have the CHP plant operating at the nominal design set-point for the year. The current system configuration further makes the system eligible for efficiency incentives (HE-CHP), according to the Italian law, as the PES, calculated Equation (1) [37], is 23,78%: The current system configuration further makes the system eligible for high-efficiency incentives (HE-CHP), according to the Italian law, as the PES, calculated with Equation (1) [37], is 23.78%: (1) where η th chp (η el chp ) is the ratio between the heat (electric energy) produced in CHP mode and the primary energy used by the CHP unit, whereas η th ri f (η el ri f ) is the reference efficiency for standalone thermal (electric) energy conversion. However, the present CHP unit design has been developed using a rather conservative approach to primary energy savings and does not explicitly consider the overall carbon emission reduction. Thus, in this study, the dynamic characterization of both thermal and electric loads is integrated into the design method of the CHP plant to explore the additional technical, economic, and environmental benefits of other design choices and evaluate the potential role of energy storage systems as well. The following sections describe the proposed dynamic load modeling and the novel method used for the optimal design of the CHP unit.
Furthermore, the present study investigates the integration of the AD of SCG in the energy system of the PTV using biogas for co-burning with or completely substituting the fossil methane to fuel the CHP unit. To minimize costs and the carbon footprint, a specific SCG supply chain is designed using SDG collected in the city coffee shops and its neighborhood close to the hospital building. The amount of coffee powder in each coffee shop is computed based on the average number of coffees sold every day in a single shop in Italy: around 175 cups, which means about 1.5 kg of coffee per shop per day [38]. Every day a truck collects the SCG and deliveries them from the bars to the AD unit of the PTV. The CO 2 emitted by the truck is computed as a GHG emission of the ES, but the CO 2 emitted from the combustion of biogas is not taken into account, as it is a part of the carbon cycle of the biomass itself. The data on coffee to SCG and the characteristics of SCG were measured in the laboratory of the University of Rome Tor Vergata through several experimental tests (Mass conversion coffee-SCG = 2.27 and Volatile Solids/SCG mass = 31.5%). Further details about the whole process modeling, from transportation to biogas production, are reported in the Appendix A for the sake of clarity.

Modeling of Thermal and Electric Load
A comprehensive characterization of thermal and electric loads for the hospital is crucial to assess the further potential in PES and carbon emission reduction with different CHP configurations. An approach based on an unsupervised machine learning method (clustering) is proposed, with the main scope of defining representative load profiles and avoiding the influence of singularities in the optimization of the CHP configuration. Real historical data over one year from the hospital building is used as an input for the proposed model.
According to the analysis proposed in [39], a time horizon of one week has been chosen for load profile clustering as a good compromise between the final number of clusters and pattern variation. Considering the optimal number of clusters, defined with a silhouette criterion, the annual thermal and electric weekly load profiles have been assigned to three different clusters with a k-mean algorithm. The so-defined clusters are then able to take into account typical seasonal variations and a rather accurate dynamic representation of load profile patterns. The consistency of this assumption has been validated by looking at the high value of the silhouette parameter of each weekly curve and the detected similarity of clusters as observed during the year. The final clusters and centroids for both thermal and electric loads are shown in Figure 3.

Optimal Design Method
System configuration and control should be defined, taking into account not only economic targets, but also environmental ones as both objectives contribute to the reduction in primary energy consumption to unlock the potential benefits of a CHP plant. Moreover, a long enough time horizon considered during the design procedure allows to represent the potential set of operating conditions more accurately. According to such remarks, a bi-level optimization approach has been adopted in this study: a low-level mixed integer linear programming (MILP) algorithm to optimally schedule the CHP unit (considering the eventual biogas from the AD), TES, and BESS, and an upper-level genetic algorithm (GA) to define the component sizes. Both control and design algorithms implement a multi-objective optimization, where the decision variables are defined to maximize the PES and minimize the capital expenditures and the operating expenses, in particular, to minimize economic (Obj eco ) and environmental (Obj ebv ) objectives. A detailed description of the bi-level optimization approach is described in Appendix B.

Optimal Design Method
System configuration and control should be defined, taking into account not only economic targets, but also environmental ones as both objectives contribute to the reduction in primary energy consumption to unlock the potential benefits of a CHP plant. Moreover, a long enough time horizon considered during the design procedure allows to represent the potential set of operating conditions more accurately. According to such remarks, a bi-level optimization approach has been adopted in this study: a low-level mixed integer linear programming (MILP) algorithm to optimally schedule the CHP unit (considering the eventual biogas from the AD), TES, and BESS, and an upper-level genetic algorithm (GA) to define the component sizes. Both control and design algorithms implement a multi-objective optimization, where the decision variables are defined to maximize the PES and minimize the capital expenditures and the operating expenses, in particular, to minimize economic ( ) and environmental ( ) objectives. A detailed description of the bi-level optimization approach is described in Appendix B.

Optimal Solution through the Pareto Plot
Solutions to multi-objective problems are multiple; all of the non-dominant solutions can be found on the Pareto front. The choice between these equivalent solutions can be made by using several approaches. Since the objective of the design optimization is the minimization of both economic and environmental impact, the ideal solution can be considered as the origin of the objective axes (zero emissions and costs). Therefore, the best solution among the sizing points of the Pareto front is the design that minimizes the distance from this ideal reference. The optimal design can then be perturbated by introducing two weighting factors to observe the influence of stressing the importance of one objective with respect to the other (Equation (2)).
For each optimal Pareto front, five different combinations of economic and environmental weights are tested, as reported in Table 1. Optimal Solution through the Pareto Plot Solutions to multi-objective problems are multiple; all of the non-dominant solutions can be found on the Pareto front. The choice between these equivalent solutions can be made by using several approaches. Since the objective of the design optimization is the minimization of both economic and environmental impact, the ideal solution can be considered as the origin of the objective axes (zero emissions and costs). Therefore, the best solution among the sizing points of the Pareto front is the design that minimizes the distance from this ideal reference. The optimal design can then be perturbated by introducing two weighting factors to observe the influence of stressing the importance of one objective with respect to the other (Equation (2)).
For each optimal Pareto front, five different combinations of economic and environmental weights are tested, as reported in Table 1.

Results
In the following section, the results of the optimal design process are shown for three different scenarios.
Each scenario increases the complexity of the hospital Energy System with the aim of highlighting the role of each technology in maximizing the advantage from the CHP in terms of cost and emissions.
First of all, in "SCENARIO 1", the sizing of only the CHP unit is performed. This analysis aims to show the advantages of the CHP dynamic sizing.
In "SCENARIO 2", the AD is added to the energy system. The presence of the AD increases the complexity of the sizing phase; in fact, its effects are dual. On the one hand, costs and emissions of SCG delivery to the hospital represent a new source of expenditure and environmental impact of the energy system. On the other hand, the biogas produced reduces the purchase of natural gas from the national grid, and consequently its cost and related emissions. Therefore, SCENARIO 2 allows us to analyze these aspects, seeking for an optimal configuration. Finally, in "SCENARIO 3" the integration of ESs is analyzed to show how they can further improve the overall performance of the system. In particular, it is expected that TES would give advantages using the heat surplus of CHP units, whereas the BESS would help stabilize its electrical power production. The performance of the TES could be further enhanced using an advanced system such as TES with nano-incorporated phase change materials, which increase its performance in terms of velocity of charging/discharging and thermal behavior [40].
The three simulated scenario are summarized in the following: • SCENARIO 1-Optimal design of the CHP plant; • SCENARIO 2-Optimal design of the CHP plant integrated with the AD reactor; • SCENARIO 3-Optimal design of the CHP plant and the AD reactor, integrating TES and BESS.
All the results have been presented as relative variation with respect to the reference case where no CHP plant is installed, i.e., electric power provided by the grid, whereas thermal demand is supplied by the traditional boiler.

Scenario 1-CHP Optimal Design
In Figure 4, the Pareto fronts for all the simulated scenarios are reported in order to analyze the trade-off between the two objective variables reported as relative values with respect to the static design solution. In particular, the one referred to in Scenario 1 is reported in green stars. It can be noticed that, regardless of the CHP size, the advantages with respect to the reference case vary in a limited range. CO 2 emissions are reduced between 8 to 10% at maximum, and cost benefits range from 37 to 40%. As a matter of fact, positive effects are observed both on the environmental and economic objectives in the optimal design range; however, limits are encountered due to the intrinsic characteristics of the thermal and electric demands.  Observing Figure 4, it can be noticed that potential benefits can be achieved also with respect to the static design solution both for the economic and environmental targets. Indeed, the dynamic optimization tends to increase the CHP size (Table 2) which is, however, limited by two main factors: • The loss of efficiency due to the waste heat occurring when electric and heat demands Observing Figure 4, it can be noticed that potential benefits can be achieved also with respect to the static design solution both for the economic and environmental targets. Indeed, the dynamic optimization tends to increase the CHP size (Table 2) which is, however, limited by two main factors:

•
The loss of efficiency due to the waste heat occurring when electric and heat demands are not matched ( Figure 5).

•
The investment and maintenance costs that increase with the CHP size. Observing Figure 4, it can be noticed that potential benefits can be achieved a respect to the static design solution both for the economic and environmental Indeed, the dynamic optimization tends to increase the CHP size (Table 2) w however, limited by two main factors: • The loss of efficiency due to the waste heat occurring when electric and heat d are not matched ( Figure 5).

•
The investment and maintenance costs that increase with the CHP size.
Further considerations can be made by looking directly at the results of design choice based on the minimization of the distance from the ideal target (Ta   Further considerations can be made by looking directly at the results of the best design choice based on the minimization of the distance from the ideal target (Table 2).
The CHP demonstrates its economic convenience up to a size of 5 MW, after which the positive effects saturate due to the reduction in the total efficiency and incentives. However, this configuration-obtaining the maximization of the weight of the economic objective-reduces the environmental benefits through PES, thus avoiding CO 2 emissions. Increasing the weight of the environmental objective, the optimal CHP size progressively decreases, saturating at a size of 3.5 MW. Indeed, a CHP plant with a smaller size would lead to a reduction in PES as well.

Scenario 2-CHP and AD Optimal Design
The addition of AD in the energy system has a complex impact on the system performance. On one side, it increases its resilience to external disturbance; on the other side, it increases costs and partially favors the reduction in CO 2 emissions. Considerations about the two latter aspects can be made looking at the results of the Pareto front and the sizing results as a function of the weighting factor ( Figure 4-blue stars, and Table 3). First of all, it can be noticed that the integration of biogas into the energy system allows for extending the limit of the maximum achievable benefits in terms of the environmental target. Savings up to 20% in CO 2 emissions can be obtained by increasing the weight of the environmental factor in the objective function. It is worth recalling that the analysis also accounts for CO 2 emissions related to feedstock transportation. However, due to the high cost of the SCG transportation system, the economic target results are negatively affected by this design solution, although savings up to 20% are achieved with respect to the reference case. In fact, if the weight of the economic target is increased, the optimization algorithm leads back to a design solution without the AD integration (Table 3).

Scenario 3-CHP, TES, BESS and AD Optimal Design
In CHP applications, ES technologies can help to increase the flexibility of the energy system, allowing for a greater match between electric and thermal demands. As a result, the integration of TES and a BESS positively affects the performance under several perspectives ( Figure 4). In particular, it allows:

•
The extension of the maximum benefits achievable (up to 42% and 22%, respectively, for costs and emissions reductions); • The reduction in the carbon emissions at a given economic target. Table 4 reports on the optimal design solution for different weighting factors. It can be observed that TES favors the most economically convenient solutions, extending the limits of the maximum size of the CHP plant. BESS instead plays a crucial role towards the reduction in the CO 2 emissions since it allows for achieving high PES values also at a smaller CHP size.

Discussion of the Results
Further analysis has been carried out on the balanced design solutions (α eco = α env = 0.5) to thoroughly understand the differences among the performances of the scenarios.
First, the hospital energy system performances obtained using the clustered and the real data are compared in order to assess the robustness of the proposed approach. Figures 6 and 7 show the total annual costs and the CO 2 emissions per bed for all the simulated scenarios evaluated using either the real or the clustered load data. Results are always close each other (max deviation of about 2%), confirming that the synthesized load is representative of the dynamic behavior of the hospital electric and thermal demands. Moreover, the analysis offers significant benchmark parameters. In particular, it can be observed that the energy cost per bed in a standard configuration (CASE 0) is slightly below kEUR 12, and that the CHP unit can allow, if properly designed, to reduce this value up to a minimum of about 7 kEUR. The introduction of the AD and ESs leads to a slight increase in the total energy cost per bed (5.07% and 8.94%, respectively, for Scenario 2 and 3). However, the cost increase is counterbalanced by the reduction in the CO 2 emissions that decrease by about 7.62% and 10.82% with respect to Scenario 1, respectively, for Scenarios 2 and 3. scenarios evaluated using either the real or the clustered load data. Results are alway close each other (max deviation of about 2%), confirming that the synthesized load i representative of the dynamic behavior of the hospital electric and thermal demands Moreover, the analysis offers significant benchmark parameters. In particular, it can b observed that the energy cost per bed in a standard configuration (CASE 0) is slightl below kEUR 12, and that the CHP unit can allow, if properly designed, to reduce thi value up to a minimum of about 7 kEUR. The introduction of the AD and ESs leads to slight increase in the total energy cost per bed (5.07% and 8.94%, respectively, for Scenari 2 and 3). However, the cost increase is counterbalanced by the reduction in the CO emissions that decrease by about 7.62% and 10.82% with respect to Scenario 1 respectively, for Scenarios 2 and 3.  A further discussion can be made observing the fraction of fossil primary energy consumption (FPEC) required to supply the energy consuming technologies (Figure 8). I can be, in fact, observed that moving towards more complex systems, the fraction o energy consumed at the boiler is significantly reduced (from 38 to about 15%). On th other hand, due to the increased CHP size, the percentage of FPEC is increased. The AD integration, as well as the integration of the ES technologies, leads to a general reduction in the overall FPEC (from 99 GWh to 91 and 88 GWh). The influence of the CHP on th FPEC is slightly decreased and it is compensated by a soft increase in either the boiler o the grid fractions. It is worth noting that for this calculation an efficiency of 47.6% for th grid is used as reported in [41]. A further discussion can be made observing the fraction of fossil primary energy consumption (FPEC) required to supply the energy consuming technologies (Figure 8). It can be, in fact, observed that moving towards more complex systems, the fraction of energy consumed at the boiler is significantly reduced (from 38 to about 15%). On the other hand, due to the increased CHP size, the percentage of FPEC is increased. The AD integration, as well as the integration of the ES technologies, leads to a general reduction in the overall FPEC (from 99 GWh to 91 and 88 GWh). The influence of the CHP on the FPEC is slightly decreased and it is compensated by a soft increase in either the boiler or the grid fractions. It is worth noting that for this calculation an efficiency of 47.6% for the grid is used as reported in [41]. integration, as well as the integration of the ES technologies, leads to a general reduction in the overall FPEC (from 99 GWh to 91 and 88 GWh). The influence of the CHP on the FPEC is slightly decreased and it is compensated by a soft increase in either the boiler or the grid fractions. It is worth noting that for this calculation an efficiency of 47.6% for the grid is used as reported in [41].  Recent energy crises have made the resilience to energy sources market fluctuations crucial while evaluating the performance of an energy system. For this reason, a sensitivity analysis to the electricity and methane prices is performed.
As reported in Figure 9, all the configurations of the CHP powerplant perform better if compared with the reference case in response to changes in electricity price. Moreover, due the high size of the CHP plant, the energy system presents high sensitivity to the natural gas price (Figure 10). Due to the high cost of transportation of SCG, the natural gas savings by the AD has a marginal effect from the economic point of view. However, in Figure 10 it can be appreciated how the increase in the complexity of the energy system also increases its resilience to natural gas price fluctuations. Recent energy crises have made the resilience to energy sources market fluctuations crucial while evaluating the performance of an energy system. For this reason, a sensitivity analysis to the electricity and methane prices is performed.
As reported in Figure 9, all the configurations of the CHP powerplant perform better if compared with the reference case in response to changes in electricity price. Moreover due the high size of the CHP plant, the energy system presents high sensitivity to the natural gas price (Figure 10). Due to the high cost of transportation of SCG, the natura gas savings by the AD has a marginal effect from the economic point of view. However in Figure 10 it can be appreciated how the increase in the complexity of the energy system also increases its resilience to natural gas price fluctuations.

Conclusions
In this study, an optimal design methodology for a combined heat and power p coupled to a thermal and electric energy storage system has been proposed and app to a hospital building. System component sizes have been defined using a bi-level m objective optimization approach with the aim of minimizing both CO2 emissions and costs (capital expenditures and operating expenses). Clustering analyses have performed to carry out the design optimization with representative annual thermal electric load profiles. The effects of the integration of different energy storage technologies and biogas produced by the anaerobic digestion (AD) of spent c grounds (SCG) into the combined heat and power (CHP) plant installed at the Tor Ver Hospital (PTV) are evaluated in terms of primary energy savings, GHG emissions, economic convenience of the overall energy system.

Conclusions
In this study, an optimal design methodology for a combined heat and power plant coupled to a thermal and electric energy storage system has been proposed and applied to a hospital building. System component sizes have been defined using a bi-level multiobjective optimization approach with the aim of minimizing both CO 2 emissions and total costs (capital expenditures and operating expenses). Clustering analyses have been performed to carry out the design optimization with representative annual thermal and electric load profiles. The effects of the integration of different energy storage (ES) technologies and biogas produced by the anaerobic digestion (AD) of spent coffee grounds (SCG) into the combined heat and power (CHP) plant installed at the Tor Vergata Hospital (PTV) are evaluated in terms of primary energy savings, GHG emissions, and economic convenience of the overall energy system.
The major findings of the work can be resumed in the following points.
• Compared with a static design, a dynamic procedure would allow for achieving better performance in terms of both economic and environmental perspectives.

•
The minimum total energy cost per bed is achieved for the optimized CHP plant at about 7 kEUR/per bed, whereas to achieve the best performance in terms of CO 2 emissions, the integration of the AD process and ES technologies is needed, allowing to reduce the carbon foot print up to about 38 tons/per bed.

•
The introduction of biogas from SCG AD helps to extend the positive influence on CO 2 emissions (saving up to 20% with respect to the reference case), but it negatively affects the economic performance due to the high costs of transportation. • Further benefits both in terms of economic and environmental targets can be achieved through a proper design of the Thermal and Battery Energy Storages-with maximum obtainable savings up to 42% and 22%, respectively, increasing costs and the emission weighing factor. Funding: This research received no external funding.

Conflicts of Interest:
The authors declare no conflict of interest.

Appendix A
In this section, the data used for the Anaerobic Digestion modeling are explained. All the information for AD is computed as a function of the hourly production of biomethane (CH 4 AD , (kWh)). This is evaluated using Cumulative Methane Production (CMP HRT ) during the Hydraulic Retention Time (HRT) of the SCG.
The electrical power required by the digester (P AD ) is calculated as 9.32% of the power obtainable by the electric conversion of the biogas into electricity, as reported in [44], whereas the thermal power needed for the AD process (Q AD ) is the heat flow required to keep constant the temperature of the reactor. It is, therefore, equal to the heat dispersion due to the heat flow along the reactor walls and the sensible heat losses in the daily charge/discharge of reactor for heating the SCG in input and exit of the warm digestate and it has been estimated by numerical simulation equal to 28.9% of the power obtainable by the electric conversion of the biogas into electricity.
The CO 2 emissions related to the transportation of SCG (CO 2,AD ) have been accounted as described in Equation (A5) [45].
The operation and maintenance costs, as well as the investment costs are evaluated as a function of the nominal ICE power [46] and the digester size, both function of the nominal power of the AD system [47].
Thus, the final equations are:

Appendix B
The dynamic design of the energy system is carried out by using a bi-level optimization approach. The upper-level multi-objective GA has annual cost and annual emissions of CO 2 as objective functions. They are described in Equations (A6) and (A7), respectively: The components sizing constraints are reported in Table A1. GA choses the sizes of the energy system elements, then the optimal energy flow is scheduled by a low-level Mixed Integer Linear Programming (MILP) algorithm.