Reducing CO 2 Emissions for PV-CHP Hybrid Systems by Using a Hierarchical Control Algorithm

: National targets for CO 2 reduction in the German building sector have stagnated due to low refurbishment rates. This paper proposes an alternative approach using highly efﬁcient, decentralized energy systems. By combining photovoltaic (PV) systems and combined heat and power (CHP) plants controlled by a modiﬁed hierarchical control algorithm, CO 2 emissions can be reduced. Results from a single-family home show a 13% CO 2 reduction with only 11% higher operational costs on heating days. On summer days, up to 50% CO 2 emissions can be avoided without additional costs. The control algorithm easily adapts to changing input parameters, making it suitable for different countries and business cases. Overall, with its modiﬁed control, the PV-CHP hybrid system can effectively reduce CO 2 emissions and adapt to varying conditions. The control can be easily used for other energy systems, like fuel cells or heat pumps.


Introduction
The European Green Deal sets an ambitious target of achieving climate neutrality by 2050, with a particular focus on reducing greenhouse gas emissions, including carbon dioxide.The German Climate Action Plan has established national targets for various sectors, including buildings, aiming to reduce CO 2 emissions to 72 million tons of CO 2 equivalent by 2030, which represents a 66% decrease compared to the 1990 level.However, progress towards these targets has been limited, largely due to the low rate of building renovations.Older buildings in Germany often rely on high-temperature heating systems fueled by oil or natural gas, which contribute significantly to CO 2 emissions.While incentivizing building energy efficiency measures is a long-term solution, there is a need for short-term strategies to enhance the efficiency of energy systems.In this context, photovoltaic (PV) systems and combined heat and power plants (CHP) offer potential solutions.PV systems have the capability to reduce the primary energy factor, and CHP plants can improve energy efficiency.By integrating these technologies, it becomes possible to address the immediate challenge of reducing CO 2 emissions in the building sector.

Control Approaches in Thermal-Electrical Systems
The motivation behind integrating thermal and electrical energy systems as thermalelectrical systems was to enhance the self-consumption rate of decentralized PV systems by introducing additional loads, such as a heat pump (HP).In a study by Fischer et al. [1], a comparison between various control strategies for PV-battery-heat pump systems was conducted.Four rule-based controllers were contrasted with a convex MPC approach.While the MPC approach effectively increased self-consumption, the rule-based methods offered lower computational demands.Additionally, the research revealed that increasing the thermal storage size without utilizing an MPC did not yield significant benefits.
Control approaches for thermal-electrical systems are numerous in the literature and are presented in a review in [10].It shows the characteristics of thermal-electrical energy system model control and planning methods and existing modeling tools and frameworks.The author presents top-down, bottom-up and hybrid methods and mathematical approaches ranging from linear programming, dynamic programming, mixed-integer programming, and stochastic programming to using artificial intelligence.
In conclusion, the extensive research on control strategies for thermal-electrical systems in the context of renewable energy integration has provided valuable insights into enhancing system performance and energy self-sufficiency using model predictive control and rule-based control approaches.However, the hierarchical control approach presented in this paper represents the next crucial step in advancing this field, in particular, if applying it to PV-CHP hybrid systems.

PV-CHP Hybrid Sytems
The energy management of combined PV-CHP systems has been explored using different control approaches, including rule-based controls and model predictive control (MPC) algorithms.A study conducted by Houwing et al. in [11] focused on the economic benefits of employing an MPC algorithm in a residential PV-CHP hybrid system.The authors of the study examined the operating costs associated with an optimized control scheme and compared them to those of a conventional rule-based control scheme specifically during the winter period.Surprisingly, they found that significant advantages could be achieved even in situations where feed-in tariffs were not available.By leveraging the MPC algorithm, the researchers demonstrated improved economic performance for the PV-CHP hybrid system.This study highlights the potential of employing advanced control strategies in optimizing the operation of residential PV-CHP systems, leading to enhanced cost-effectiveness and overall system performance.
In a study conducted by Romera-Rodríguez et al. [12] in Spain, an analysis of five sites was performed to assess the potential of hybrid systems in reducing primary energy consumption.The findings revealed that hybrid systems were effective in reducing energy consumption.However, when considering life-cycle costs, a conventional system consisting of an electric grid and a natural gas boiler was found to be economically superior.Another life cycle analysis, as reported in Balcombe et al. [13], was conducted to evaluate the environmental impacts of a hybrid system compared to a conventional power grid with a natural gas boiler for heating.The results indicated a significant improvement in all environmental indicators, ranging from a 35% reduction in fossil fuel depletion to a 100% reduction in terrestrial ecotoxicity.In a different study by Brandoni et al. [14], the sizing of components in a hybrid system was investigated.Unlike solar technologies, the size of micro-CHP systems was found to be strongly influenced by factors such as investment costs, energy loads, and tariffs.The study suggests that while a hybrid system can effectively reduce household primary energy consumption, it is crucial to appropriately determine its size based on specific costs and conditions, considering the mentioned factors.These studies provide valuable insights into the performance, economic viability, and appropriate sizing of hybrid systems.Understanding the trade-offs and considering various factors is essential in optimizing the benefits of hybrid systems and their integration into energy systems.
In a study by Balcombe et al. [15], a PV-CHP hybrid system was implemented in 30 different household types.The analysis focused on factors such as the self-sufficiency fraction, grid demand profiles, and economic costs to the consumer.The results revealed that the hybrid system increased the self-sufficiency fraction and improved grid demand profiles in terms of ramp-ups.However, it was observed that the system provided benefits primarily when the energy demand was high, exceeding 4300 kWh per year.A simulation study conducted in Calgary, Canada, by Nosrat et al. [16], examined the potential for greenhouse gas emission reduction using low-cost PV-CHP hybrid systems in new communities.The findings indicated that hybrid PV-CHP technologies could effectively replace conventional energy systems in such communities.The importance of building characteristics in the context of energy system control was highlighted in a study by Narayanan et al. [17].The research focused on geometry, building physics, energy efficiency, and their influence on the control of energy systems.Each house's energy system, comprising solar thermal collectors, PV, gas boiler, fuel cell CHP, thermal storage, and electrical storage, was optimized and compared.These studies emphasize the significance of considering specific factors such as energy demand, building characteristics, and economic viability when implementing PV-CHP hybrid systems.Such considerations contribute to optimizing system performance, enhancing energy self-sufficiency, and reducing greenhouse gas emissions.
In recent studies, combined heat and power (CHP) systems have been increasingly investigated in the context of district heating and in combination with other energy systems.One such study, conducted by the authors of [18], provides a comprehensive analysis of the impact of cooling generation in CHP plants using absorption chillers on power generation and primary energy consumption.The research findings suggest that to effectively utilize excess heat from CHP systems and achieve efficient cooling production, the recommended configuration includes an 0.8 MW absorption cooler and 11.6 MW heat pumps.Implementing this setup would result in a significant reduction in primary energy consumption for cooling generation, approximately 1.9 times less compared to local cooling methods.By optimizing the utilization of excess heat from CHP systems and integrating efficient cooling technologies, like absorption chillers and heat pumps, the study demonstrates the potential for substantial energy savings in the context of district heating.This highlights the importance of considering CHP systems in conjunction with other energy systems to enhance overall energy efficiency and reduce primary energy consumption.

Research Goal and Innovation
In conclusion, the literature highlights the interest in exploring combined heat and power (CHP) systems, particularly in the context of district heating and their integration with other energy systems.Several studies have shed light on various aspects of CHP systems, including their impact on energy consumption, greenhouse gas emissions, and economic viability.Furthermore, the review emphasizes the significance of intelligent control systems for managing complex building systems with multiple energy sources.The studies demonstrate the need for such control systems to optimize the operation of CHP systems, improve energy efficiency, and ensure effective utilization of excess heat.
The primary goal of this paper is to apply a hierarchical, combined control algorithm for CO 2 minimization in the context of PV-CHP systems.A key aspect of the algorithm is its unique ability to consider forecast deviations, which allows for an in-depth analysis of the impact of uncertainties on various cost functions.By incorporating forecast deviations, the control algorithm can effectively analyze and quantify the influence of these uncertainties on different cost functions.This capability represents a significant advancement in the field, as previous algorithms typically focused on a single cost function, such as minimizing operating costs or grid interaction.In contrast, the proposed control algorithm introduces a new level of flexibility, being the first to work with multiple cost functions and systematically assess the effect of forecast uncertainties on each of them.The analysis of the influence of forecast deviations on different cost functions is performed using carefully defined key performance indicators (KPIs).These KPIs serve as quantitative metrics to evaluate and compare the algorithm's performance with and without forecast uncertainties, shedding light on the trade-offs between cost optimization and CO 2 emission reduction in a realistic scenario.
To achieve this goal, the subsequent investigation involves the simulation of an efficient energy system designed for a single-family house, comprising a photovoltaic (PV) system and a combined heat and power (CHP) unit and incorporating flexibilities like a battery and a thermal energy storage (TES).To optimally regulate the energy system, a hierarchical control algorithm is employed.What sets this control algorithm apart from others is its consideration of forecast derivatives and its compensatory actions through a low-level rule-based control [19].Prior studies have demonstrated the high adaptability [20] and robustness of these control algorithms.They can be directly implemented in existing components and have already undergone testing on a laboratory test bench [21].
The paper presents a new building block of a novel and highly flexible hierarchical control algorithm, which not only focuses on cost and grid interaction minimization but also prioritizes CO 2 emission reduction.

Materials and Methods
The Section 2 of the study begins by providing a description of the energy components used in the research, which include the PV system, CHP unit, battery, and thermal energy storage (TES).Each component's specifications and functionalities are outlined to establish a clear understanding of the energy system setup.Following the description of the energy components, the hierarchical control algorithm employed in the study is introduced.This algorithm serves as the basis for optimizing the operation of the energy system.Its hierarchical structure and control strategy are explained, highlighting its ability to adapt to changing conditions and input parameters.Two variants for cost minimization and CO 2 minimization are then defined.These variants represent different objectives to be pursued during the optimization process.The cost minimization variant aims to minimize operating costs, while the CO 2 minimization variant seeks to reduce the carbon dioxide emissions associated with the power system.Additionally, two modes are introduced to compare the performance of the model predictive control (MPC) algorithm with perfect forecast with the combined control algorithm and a persistent forecast.These modes represent different control approaches and serve as benchmarks for evaluating the effectiveness of the hierarchical control algorithm.To assess the performance of the energy system and control algorithms, a small case study is conducted using data from three different days throughout the year.These days are selected to capture variations in energy demand and weather conditions, allowing for a comprehensive analysis of system performance under different scenarios.

The PV-CHP Hybrid System
The subsequent subsection focuses on a detailed description of the PV-CHP system, including its components and input parameters.

Sizing of Components
The parameters and dimensions of the system components used in this study for the combined control algorithm are based on available products from the companies Vaillant Deutschland GmbH & Co. KG, SMA Solar Technology AG, and Saft Batterien GmbH.This study focused on using existing components with basic component controls and combining them with the new hierarchical control approach.

Electrical Components
The electrical components are a PV system (3.2 kWp) represented by a measured time series from 2013 in Kassel (see Figure A3) and a Li-ion battery (4.2 kWh) including charging (0.9 efficiency), discharging (0.92 efficiency), and self-discharging losses (0.987 per 10 min).The power grid is included via a point of common coupling (PCC).The electrical energy that the PV or CHP system cannot generate is compensated by the grid, and energy not consumed in the single-family home, which can not be stored in the battery can be fed into the grid.The battery may not interact directly with the grid.

Thermal Components
The thermal components include a gas-fired cogeneration plant (CHP: 1 kW el /2.4 kW th ), a gas boiler, and a conventional thermal storage tank (300 L) used as a buffer tank.All heat sources feed their thermal energy into the power plant, while the storage tank directly supplies heat to meet all space heating and hot water needs.The CHP feasible operation region (FOR) is defined by the upper and lower values as shown in Table 1.The CHP unit operates in two modes: on and off.When switched on, the CHP must run for 30 min, and when switched off, it must rest for at least 30 min until it can be switched on again.These constraints are implemented in the control algorithm.An additional gas boiler provides energy for thermal peak loads and covers the higher heat demand in winter with a power range from 2.4 kW th to 20 kW th .In the algorithm, the upper limit is chosen much higher so that the solver can always find an optimized solution.The generated energy is fed into the buffer storage of 300 L. If needed, the heat is taken for space heating or domestic hot water.
Table 1.The CHP feasible operation region (FOR) is determined based on the consumption of natural gas, considering assumed efficiencies of η CHPel = 0.657 for producing thermal energy and η CHPel = 0.263 for producing electricity.This results in a linear relation with a factor of 2.5 between the thermal and electrical power and energy of the CHP.

CHP Electricity Data
CHP Thermal Data Minimum 0.0 kW el 0.0 kW th Maximum 1.0 kW el 2.5 kW th

Input Parameter
The cost is taken as EUR 0.0652 for natural gas and EUR 0.2838 for electricity.The feedin tariff for PV is EUR 0.1256 , and for CHP it is EUR 0.09392.For CHP, the cost of cold start is set at EUR 0.02, and the energy provided by the CHP consumed in the family house is paid at EUR 0.005.The emission coefficients are assumed to be 587 g/kWh, 202 g/kWh, and 0 g/kWh for the German electricity mix, natural gas, and PV energy, respectively.Model variables are, for example, the prediction horizon (which is set to 6 hours in the following) and the optimization time steps (10 min).Parameters such as the PV profiles are taken from measured data in the Kassel region with one-minute resolution.The load profiles are calculated from the time series of VDI4655 (https://www.vdi.de/richtlinien/details/vdi-4655-referenzlastprofile-von-wohngebaeuden-fuer-strom-heizung-und-trinkwarmwass er-sowie-referenzerzeugungsprofile-fuer-fotovoltaikanlagen (accessed on 24 June 2023)).The VDI4655 data set contains household electrical and thermal loads for ten prototypical days.

Hiearchical Control Algorithm
Figure 1 illustrates the overall concept of a hierarchical control strategy for a thermalelectrical system.At the highest level, the control strategy involves planning the energy system, encompassing the selection and sizing of components, which is not part of the current analysis (indicated by grey shading).The subsequent control level employs (economic) model predictive control (EMPC in the following MPC) to optimize operating costs or CO 2 emission.Alongside, the third control level, the rule-based control, forms the central focus of this study, thus referred to as a two-level control.The rule-based control ensures a reliable power supply by making adjustments to the setpoints generated from the optimization process when forecast deviations occur.Finally, the last control level pertains to the component controllers, provided by the component manufacturers, which are responsible for ensuring the safety and security of the energy components.This level, represented with grey shading, is not subject to modification in this work.The information flow between the control levels involves the optimization level sending optimized setpoints to individual components, while constantly receiving current values from each individual plant for subsequent control steps.
The part of the hierarchical control algorithm discussed in this study can be broken down to two-level control and is described as the combined control in [19].The primary controller is a model predictive control (MPC) based optimiser mixed integer linear programming (MILP) that calculates schedules for the next 6 to 24 h (prediction horizon) for each component to realise the minimum operating cost for the PV-CHP hybrid system.
The first value of the schedule is used as the set point for the components and serves as the input parameter for the secondary control-based controller.Here, a comparison of the setpoints with the actual values is performed.The secondary controller updates the setpoints within the 10 min between two optimizations to account for the differences between the forecast and the actual situation using predefined rules.The rules are mainly based on following the operation plan of the MPC as closely as possible.If this is not possible self-consumption is prioritized.The MPC and the rule-based controller are implemented in Python.The optimization problem is solved using pyomo [22,23] with a CPLEX solver.Further details on the combined controller can be found in [19].

Control Variants
In contrast to the idea of minimizing OPEX for the occupant of the single-family home, a new approach was derived here.The cost function was replaced by a CO 2 minimization equation.The results of the two cost functions are compared below and described by two variants.

Variant 1
The first variant represents the system optimization to minimum OPEX.This variant is used as a benchmark to be compared with the new approach described in Variant 2.

Variant 2
This variant describes the optimization towards a CO 2 minimal control strategy.The objective function J(k) of the MPC is formulated to achieve minimal CO 2 production.The function is presented by the following equation gas • P aux gas,j (k) + e CO 2 grid • P grid imp,j (k) with N p as the prediction horizon, e CO 2 gas is the emission coefficient of natural gas, P aux gas is the power provided by the gas boiler, e CO 2  grid is the emission coefficient of the German electricity mix, P grid imp,j (k) is the power provided by the grid, e CO 2  PV is the emission coefficient of PV energy and P PV prod,j (k) is the power of the PV-system.The calculation is performed for each time step k of the studied period.In the following study, k ∈ {1, ..., 180}, with one day with a step size of 10 min, which would be k ∈ {1, ..., 144} plus the time steps of the prediction horizon of N P = 6 h again with a step size of 10 min, which is 36, adding up to 180 time steps for one day.Additionally, it is important to note that k can be chosen freely, and we have conducted tests using a time period of up to 1 year + 6 h to assess the robustness of the control strategy.To calculate the cost for each time step k the optimization is performed for the time period with the length of a shifting prediction horizon N p = 36 which relates to a period of 6 hours with a resolution of 10 min.The index for the optimization time period is j, which is also shifting for each index k.So the j ∈ {k, k + 1, k + 2, ..., k + 36} for each k ∈ {1, ..., 144}.
Additional equations and constraints must be specified in the system model to evaluate the objective function.They are the same as in variant 1.Two essential constraints in the model are the electrical and thermal energy balance.A parameter description is presented in the Appendix C, while additional constraints are given in [19] as well as the description of the secondary control based on a rule-based control strategy.

Control Modes
The hierarchical control was developed to account for the differences between the predicted setpoints and the actual values.This idea is studied for both control variants and described by control modes.

Mode A
The first mode is a kind of benchmark mode, where it is assumed that the amount and timing of energy production by the PV system and the amount and timing of energy demand are accurately known.This is simulated using the optimizer with a perfect prediction.The secondary controller is not needed in this mode and is used to test the optimizer without the effect of forecast derivation.

Mode B
The MPC algorithm includes all variables and parameters as in Mode A, but this time the predicted and actual input values are assumed to be different.The forecasting method is called persistence forecasting, where it is assumed that the values will be the same today as they were yesterday at the corresponding time.The secondary rule-based controller takes over in the time interval of 10 min between two optimization time steps.The basic rule is to keep the optimized operation plans from the MPC.The setpoints are changed according to the effects of the actual values of measured generated PV energy and measured electricity, heating and hot water demand.This can lead to deviations from the optimized battery state of charge (SOC) or temperatures in the TES.Therefore, electricity must be drawn from the grid when the battery is empty, or the CHP or gas boiler must be turned on or off, depending on the new temperature of the TES.The results in detail are shown in the next section.
This methodology section presented a systematic approach to studying the energy system and control algorithms.It established a clear framework for evaluating the performance of the system, considering both cost and CO 2 minimization objectives and comparing different control approaches through a case study involving various days throughout the year.

Results
In this section, the results of the study are presented, focusing on example daily profiles with a resolution of 10 min.The analysis encompasses important performance parameters of the thermal-electric power system.The calculations were conducted for three distinct typical days: a summer day, a winter day, and a day in April, which represents the transition period between seasons in Germany.These days were selected to capture different scenarios and situations for a thermal-electric power system.

•
On a summer day, the PV system generates a substantial amount of energy (see Figure A3), but no space heating is required due to high outdoor temperatures.
The thermal load primarily consists of a hot water profile.

•
In contrast, on a winter day, there is a significant demand for space heating, but the PV system contributes minimal energy (see Figure A3).

•
The transition period day poses a unique challenge as it requires managing both PV energy production (see Figure A3) and space heating demand simultaneously.To illustrate the influence of different control options, a day from the transition period is presented as an example.This example highlights the varying performance of the system under different control settings.Additionally, several other parameters related to system performance are presented for the three typical days.
By examining these results, insights can be gained into the effectiveness and efficiency of the control options in managing the thermal-electric power system.The presented profiles and parameters provide a comprehensive understanding of system performance and aid in evaluating the impact of different control approaches on the overall energy system operation.More results are presented in the Appendix B.

Comparison of Control Variants
Figure 2 depicts the daily time profiles for the two optimization variants: cost optimization (Variant 1) and CO 2 optimization (Variant 2).The figure consists of two sets of panels, with the left panels representing the results for cost optimization and the right panels representing the results for CO 2 optimization.In the top panels of each set, the electrical load of the single-family home is displayed.The load is visualized using different colors to represent the origin of the energy.Each color corresponds to a specific energy source or generation method.Moving to the lower fields of the panels, the generated energy is shown as positive values, indicating the energy produced by the system.This includes energy generated from the PV system and other sources.On the other hand, the energy drawn from the grid is displayed as negative values, representing the energy consumed from the grid.In Variant 1, the electrical load of the single-family home is primarily covered by the CHP plant, represented by the dark green color in the top panels.When the required power exceeds the maximum capacity of the CHP plant, the battery (pink) is utilized to provide additional energy.During the initial hours of the day, the battery is discharged to meet the load.However, this initial discharge is an artefact resulting from the battery being initialized with 50% state of charge (SOC), and this energy is considered free of charge and without CO 2 emissions.
In contrast, Variant 2 shows a more diversified approach to meet the electrical load.The load is fulfilled by multiple options, including the CHP plant (dark green), PV system (light green), battery (pink), and grid (black).The CHP plant charges the battery, which then alternately supplies energy to meet the electrical load.When the PV system generates excess energy, it is directly consumed by the single-family home.However, at certain moments, peaks in energy demand necessitate drawing energy from the grid to cover the shortfall.This grid interaction can be observed in the bottom panels, which visualize the energy exchange with the grid.In Variant 1, 100% of the PV energy is fed back into the grid, along with the electrical energy generated by the CHP plant that is not immediately required to meet the household load.On the other hand, Variant 2 prioritizes self-consumption, with the majority of the residual energy generated by the PV system being fed into the grid.The strategy of Variant 1 is focused on producing more energy than is needed, allowing for the sale of excess energy to the grid and earning income.In contrast, Variant 2 adopts a self-consumption strategy, aiming to produce only the energy necessary to cover the load.This approach minimizes energy production and, consequently, reduces CO 2 emissions to a minimum level.These observations highlight the distinct approaches of the two optimization variants, emphasizing the trade-off between maximizing energy generation and earnings (Variant 1) and minimizing energy production and CO 2 emissions (Variant 2).
Figure 3 further illustrates the differences between Variant 1 and Variant 2 in terms of energy generation.The left panels represent Variant 1, while the right panels represent Variant 2. In the top two panels, the energy generated by the PV system is displayed.In Variant 1, all the energy generated by the PV system is fed back into the grid, indicated by the light red color.Conversely, in Variant 2, the generated energy is utilized through a combination of direct consumption (light green), battery charging (purple), and grid injection (light red).This approach aims to maximize self-consumption and reduce energy export to the grid.Moving to the bottom panels, the electrical energy produced by the CHP system is shown.In Variant 1, the CHP system operates continuously for 24 h, providing the necessary electrical energy to meet the household load (dark green).On the other hand, Variant 2 adopts a more dynamic approach, with the CHP system being switched on and off regularly.This strategy prevents excessive energy production and ensures that the system does not generate more CO 2 emissions than necessary.In Variant 2, any excess energy generated by the CHP system (dark green) that cannot be directly consumed is stored in the battery (dark blue).This energy can then be utilized later when the demand exceeds the capacity of the CHP system or the PV system.These visual representations in Figure 3 provide a clear comparison between the two optimization variants, showcasing the distinct patterns of energy generation and utilization.Variant 1 focuses on maximizing energy production and exporting excess energy to the grid, while Variant 2 prioritizes self-consumption and aims to minimize CO 2 emissions by adjusting the operation of the CHP system and utilizing energy storage capabilities.

Comparison of Control Modes
To study the effect of a non-perfect forecast of PV generation and electrical and thermal household loads the results of two modes have been computed.
In Figure 4, the results for Variant 2 are presented, focusing on Mode A (left panels) and Mode B (right panels).The upper panels illustrate the electrical load, while the lower panels depict the network interaction at the point of common coupling.For Mode A, which assumes perfect predictions, the results align with those shown in Figure 2, where a maximum self-consumption strategy is achieved.The actual electricity demand closely matches the predicted profile, resulting in efficient energy utilization.However, in Mode B, which considers persistent prediction errors, a different scenario unfolds.The actual electricity demand exceeds the predicted profile, leading to energy imports from the grid (indicated by black areas) to fulfil the household load.As a consequence, the CO 2 emissions increase since the grid-supplied electricity has higher emissions compared to the natural gas used in the system.
Moving on to Figure 5, which focuses on energy generation, a similar pattern emerges as in Figure 3.In both modes, PV energy is primarily utilized for direct consumption (light green).However, the impact of imperfect predictions becomes evident, particularly in the operation of the CHP system.In Mode B, where the predicted load is lower than the actual load, the runtime of the CHP system is reduced compared to the perfect schedule.This adjustment reflects the system's adaptive response to the discrepancies between forecasts and actual conditions.These findings highlight the significance of accurate predictions in optimizing the operation of the PV-CHP hybrid system.Mode A demonstrates the potential benefits of perfect forecasts, allowing for optimal energy utilization and CO 2 emissions reduction.However, Mode B highlights the challenges posed by persistent prediction errors, emphasizing the need for hierarchical control strategies to effectively manage and mitigate the impact of these uncertainties.

Key Performance Indicators
The evaluation of key performance indicators (KPIs) provides further insights into the performance of the studied energy system.The KPIs are defined in [19] and are used to assess the system's operating costs (OPEX) and CO 2 emissions.
On the selected day in April, the total energy demand amounted to 11.4 kWh, with 85 kWh of electrical energy and 14.88 kWh generated by the PV system to meet a portion of the demand.
The comparison of KPIs for Variant A and Variant B, as presented in Table 2, along with the results shown in Figures 6 and 7, reveals the following findings: 1.
Both variants and modes demonstrate lower operating costs compared to a conventional system.CO 2 emissions are comparable to a conventional system when the system is gas-fired.However, an oil-based system would result in significantly higher emission levels.2.
The conventional system was not extensively modeled, neglecting factors such as losses in storage systems.Therefore, the values of the conventional system should be considered as limit values, and a more detailed simulation would allow for a more realistic comparison.

3.
In both variants, a significant portion of the energy generated by the PV system is fed back into the grid.This would have a positive effect on the CO 2 equivalent of the grid electricity, which is not considered in the selected KPIs but should be taken into account.

4.
The presence of a feed-in tariff leads to longer run times for Variant A, resulting in a factor of 2 more energy produced than needed for the single-family home.This extended operation has a positive effect on the lifetime of the CHP plants compared to a permanent on/off situation.5.
Variant B exhibits higher self-consumption, with 98% of the CHP energy being selfconsumed.The strategy following emission optimization clearly prioritizes selfconsumption.

6.
Both variants demonstrate a high degree of self-sufficiency.7.
The grid connection is primarily used for energy injection.However, deviations between weather or load forecasts and actual values may necessitate grid electricity to compensate for the shortfall.8.
The battery is utilized to compensate for differences between forecast setpoints and real values in Variant B. This effect occurs when high self-consumption is intended, and the emission value of grid-supplied electricity is high.9.
The usage pattern of the battery differs between the two variants.In the costoptimized case (Variant A), the battery is predominantly charged and discharged to utilize PV energy later in the evening.In the CO 2 -optimized Variant B, the battery is employed to store electricity from the CHP, resulting in more battery cycles per day, particularly in winter.10.The runtime of the CHP in Variant B is approximately three to five times shorter than in Variant A on all three days, leading to a significantly lower energy yield (refer to Figure 6).With CO 2 -optimized control, a PV-CHP hybrid system can achieve a reduction of about 13% in CO 2 emissions on a transition day.11.The OPEX for the transition day is approximately 11% higher in the CO 2 -optimized control compared to the cost-optimized control.12.The figures in Table 2 are evaluated for a day with space heating demand.On a summer day, the reduction in CO 2 emissions ranges from 35% to 50% with almost no additional cost.However, the total amount of avoided emissions is much lower on a summer day compared to a cold day (approximately 0.2 kg/day on a summer day versus about 4 kg/day on a cold day) (see Figure 7).

Conventional System
The KPIs could also be compared to the results of a conventional system.As a conventional system, it is assumed that the electricity is supplied by the grid, while heat demand is met using natural gas.It is important to note that the mentioned hypothetical conventional system is not modeled in detail but is a simplified representation without detailed modeling of losses and controls.Therefore, the calculated OPEX and CO 2 emissions serve as reference values rather than precise estimates.

Conventional System
The KPIs could also be compared to the results of a conventional system.As a conventional system, it is assumed that the electricity is supplied by the grid, while heat demand is met using natural gas.It is important to note that the mentioned hypothetical conventional system is not modeled in detail but is a simplified representation without detailed modeling of losses and controls.Therefore, the calculated OPEX and CO 2 emissions serve as reference values rather than precise estimates.The reference OPEX values

Conventional System
The KPIs could also be compared to the results of a conventional system.As a conventional system, it is assumed that the electricity is supplied by the grid, while heat demand is met using natural gas.It is important to note that the mentioned hypothetical conventional system is not modeled in detail but is a simplified representation without detailed modeling of losses and controls.Therefore, the calculated OPEX and CO 2 emissions serve as reference values rather than precise estimates.The reference OPEX values  The reference OPEX values for the conventional system are EUR 8.76, with EUR 5.52 allocated to heat demand and EUR 3.24 for electricity from the grid.In comparison, all the considered modes and variants of the PV-CHP hybrid system exhibit lower OPEX values than the reference.It is worth mentioning that the analysis focuses on operational costs and does not consider investment costs.
Regarding CO 2 emissions, the conventional system would produce 23.87 kg CO 2 , with 6.69 kg emitted from grid electricity and 17.17 kg from natural gas usage.These figures closely align with the CO 2 -optimized PV-CHP hybrid system and are even lower when accounting for the forecast uncertainties in Mode B. This outcome is expected when comparing a realistic simulation with an idealized system.Additionally, it's important to note that the CO 2 -reduced electricity fed back into the grid positively affects the emission value of the grid-supplied electricity.
In an alternative scenario, assuming the heat demand is met using oil (with emissions of approximately 319 g/kWh), the total emission for that day would be around 33.91 kg.This emission level is significantly higher than the emissions of the PV-CHP hybrid system, further highlighting the environmental benefits of the studied system.

Summary and Conclusions
An existing hierarchical control has been modified to account for minimal CO 2 emissions in a PV-CHP hybrid system.Due to the high quality of the control algorithm only the cost function needed to be replaced while the rest of the MPC system model could be used.The system's performance was compared with a cost-optimized control.Two variants, each with perfect and persistent forecasts, were evaluated to understand their impact on the results.The analysis has been conducted for three typical days, but it can be done for longer time periods as well.To measure the performance KPI are introduced to compare the variants and modes quantitatively.The new cost function led to significant differences in time profiles and component usage.The cost-optimized variant, incorporating feed-in tariffs, resulted in a higher CHP plant production rate and longer runtime.The CO 2 -optimized variant focused on maximizing self-consumption of decentralized energy, using CHP electricity in conjunction with PV energy to meet the electrical load.

Performance Evaluation
The new cost function is resulting in significant changes in time profiles and component usage.To analyze the performance, the KPIs are compared for two variants and two control modes.One of the KPIs is the total operational costs.The cost-optimized variant, incorporating feed-in tariffs, exhibited higher CHP plant production and longer runtime, while the CO 2 -optimized variant focused on maximizing self-consumption.Despite distinct daily profiles, both variants showed similar total cost of ownership and CO 2 emissions, with a 13% reduction in emissions and 11% higher operating costs for Variant 2. The study highlights the importance of considering forecast uncertainties when optimizing energy systems and showcases the potential benefits of a PV-CHP hybrid system over conventional systems.

Safety Monitoring
The KPIs, such as the running time of the CHP system and the number of battery cycles, provide valuable insights into system operation and energy storage utilization.It is also possible to interpret these metrics in the context of system safety.Frequent turning on and off of the CHP system can lead to increased wear and tear of equipment, potentially compromising its reliability and operational integrity.This heightened wear and tear may also raise the risk of accidents and unexpected system failures.Similarly, battery aging is a critical aspect that needs to be addressed in assessing system safety.Over time, the battery's capacity and performance degrade due to repeated charge-discharge cycles.This degradation could affect the overall stability and safety of the energy storage system, necessitating careful monitoring and preventive maintenance to ensure safe operation.While KPIs like CHP running time and battery cycles but also cold starts of the CHP provide valuable performance insights (see Figure 6), their interpretation must be accompanied by a thorough evaluation of system safety.By taking proactive measures to address potential safety risks, one can enhance the reliability and longevity of CHP systems and energy storage technologies, promoting a safer and sustainable energy landscape.

Scalability
Scalability refers to the algorithm's ability to handle various energy system configurations, sizes, and complexities.Beyond its successful application in controlling the specific PV-CHP system studied in this paper, the algorithm exhibits adaptability to other types of energy systems as well.It can effectively be tailored to address the unique characteristics of different components, load profiles, and operational conditions.The scalability ensures that the algorithm remains effective and efficient, regardless of the energy system's size and complexity, making it a viable solution for a wide range of real-world scenarios.One example is the published application of the algorithm on a microgrid [19].Moreover, the promising results obtained from this study have sparked the motivation to further explore the algorithm's capabilities in future publications.These upcoming endeavors will focus on utilizing the control algorithm to manage other energy systems, including heat pumps and additional renewable energy sources such as wind parks in larger systems.One of the follow-up questions is also about the impact of the algorithm on the power grid.Such endeavors are expected to strengthen the algorithm's standing as a powerful tool for achieving sustainable and environmentally-friendly energy management across various domains.

Limits
While the paper successfully introduces a novel control algorithm capable of minimizing CO 2 emissions in PV-CHP systems, it is essential to acknowledge its limitations.The study's primary focus lies in optimizing system performance and reducing CO 2 emissions without conducting a comprehensive environmental analysis of the entire energy system's impacts.The research does not delve into other environmental factors, such as manufacturing, implementation and waste generation, which may influence the overall sustainability and environmental performance of the system.

Overall Conclusion
In conclusion, the research findings presented in this paper clearly demonstrate the versatility and potential applicability of the proposed control algorithm in optimizing energy systems.The introduction of a CO 2 -emission-minimizing cost function represents a significant contribution to the ongoing efforts to align energy systems with sustainable objectives.Unlike existing algorithms, the proposed approach demonstrates exceptional adaptability, accommodating three distinct cost functions, including the newly introduced CO 2 -emission-minimizing cost function.This adaptability allows the algorithm to comprehensively optimize energy systems, significantly contributing to sustainable energy system optimization.
Furthermore, the hierarchical control algorithm incorporates the capability to consider forecast uncertainties, an essential aspect of real-world applications.By using defined key performance indicators, the study not only compares both cost functions under perfect forecast conditions but also quantitatively assesses their effects with and without forecast deviations.This rigorous analysis sheds light on the robustness and effectiveness of the different cost functions in real systems under uncertainty, enabling for the first time a comprehensive evaluation of their impact on system performance and CO 2 emission reduction.Such an approach facilitates a deeper understanding of the algorithm's performance in practical scenarios and enhances its applicability for diverse energy system configurations.Overall, this paper provides valuable insights into the potential of hierarchical control algorithms as powerful tools in the pursuit of sustainable energy systems.The upper plot represents the actual thermal demand, comprising space heating and domestic hot water, while the lower panel illustrates the forecasted values for Variant 2. The observed difference between the actual and forecasted values poses a challenge in achieving optimal control setpoints for the energy components.Therefore, the algorithm, particularly the low-level rule-based control, must diligently ensure that the energy components maintain proximity to the optimized values to enhance system performance.

Appendix B
To understand the developed control framework, here are shown some more results.The hierarchical control is applied for the calculation of a whole year.In this paper, the days have been taken out as an example to show the seasonal effect.For another example, the results for one week are shown here in Figures A4-A9.

Appendix C
Table A1.Parameter and variables used for the hierarchical control algorithm.For more equations of the system model, see [19].

Figure 1 .
Figure 1.Hierarchical control strategy used here for thermal electrical systems.The boxes represent the different control levels.Starting on the top level the arrows show the possible ways of communication and transfer of information from one control level to the next.

Figure 2 .
Figure 2.For Variant 1 (left panels) and Variant 2 (right panels), the electrical load profile (upper panels) and the grid interaction at the point of common coupling (lower panels) are shown.

Figure 3 .
Figure 3.For Variant 1 (left panels) and Variant 2 (right panels), the PV generation (upper panels) and the energy generated by the CHP plant (lower panels) are shown.

Figure 4 .
Figure 4.For Variant 2, the electrical load profile (upper panels) and the grid interaction at the point of common coupling (lower panels) for Mode A perfect forecast (left panels) and Mode B (right panels) persistent forecast (right panels) are shown.

Figure 5 .
Figure 5.For Variant 2, the PV generation (upper panels) and the energy generated by the CHP plant (lower panels) for Mode A perfect forecast (left panels) and Mode B (right panels) persistent forecast (right panels) are shown.

Figure 6 .
Figure 6.Battery cycles per day and CHP running times for all three typical days.Results are shown for Variant 1 "Costs optimized" (brown) and Variant 2 "CO 2 optimized" (red).

Figure 7 .
Figure 7. Operational costs and CO 2 emission for a perfect forecast (left panel) and for persistent forecast (right panel) for all three typical days.

Figure 6 .
Figure 6.Battery cycles per day and CHP running times for all three typical days.Results are shown for Variant 1 "Costs optimized" (brown) and Variant 2 "CO 2 optimized" (red).

Figure 6 .
Figure 6.Battery cycles per day and CHP running times for all three typical days.Results are shown for Variant 1 "Costs optimized" (brown) and Variant 2 "CO 2 optimized" (red).

Figure 7 .
Figure 7. Operational costs and CO 2 emission for a perfect forecast (left panel) and for persistent forecast (right panel) for all three typical days.

Figure 7 .
Figure 7. Operational costs and CO 2 emission for a perfect forecast (left panel) and for persistent forecast (right panel) for all three typical days.

Figure A1 .
Figure A1.Results of the thermal and electrical energy demand of a household by applying the VDI4655 for the region of Kassel, Germany, depending on temperature and other parameters.The days are used to construct an annual load profile for the assessment of the hierarchical control algorithm.

Figure A1 .
Figure A1.Results of the thermal and electrical energy demand of a household by applying the VDI4655 for the region of Kassel, Germany, depending on temperature and other parameters.The days are used to construct an annual load profile for the assessment of the hierarchical control algorithm.

Figure A2 .
Figure A2.The provided figures display the thermal demand for a transient period in April 2013.The upper plot represents the actual thermal demand, comprising space heating and domestic hot water, while the lower panel illustrates the forecasted values for Variant 2. The observed difference between the actual and forecasted values poses a challenge in achieving optimal control setpoints for the energy components.Therefore, the algorithm, particularly the low-level rule-based control, must diligently ensure that the energy components maintain proximity to the optimized values to enhance system performance.

Figure A3 .
Figure A3.PV profiles used in the analysis.Upper panel: annual PV profile for the year 2013 measured in Kassel, Germany.Lower panels: two days as an example for the winter, transient, and summer periods, respectively.

Figure A4 .
Figure A4.Results for the PV-CHP hybrid system for 9 days in August.On the left side, the electrical load and the grid exchange are shown.On the right side is the PV generation and the generation by the CHP system.Energies and powers as indicated in the legend.

Figure A5 .
Figure A5.Results for the PV-CHP hybrid system for 9 days in August.On the left side profiles for the battery are shown, while the right side presents the profiles for the thermal storage.Energies and powers as indicated in the legend.

Figure A6 .
Figure A6.Results for the PV-CHP hybrid system for 9 days in April.On the left side, the electrical load and the grid exchange are shown.On the right side is the PV generation and the generation by the CHP system.Energies and powers as indicated in the legend.

Figure A7 .
Figure A7.Results for the PV-CHP hybrid system for 9 days in April.On the left side profiles for the battery are shown, while the right side presents the profiles for the thermal storage.Energies and powers as indicated in the legend.

Figure A8 .
Figure A8.Results for the PV-CHP hybrid system for 9 days in January.On the left side, the electrical load and the grid exchange are shown.On the right side is the PV generation and the generation by the CHP system.Energies and powers as indicated in the legend.

Figure A9 .
Figure A9.Results for the PV-CHP hybrid system for 9 days in January.On the left side profiles for the battery are shown, while the right side presents the profiles for the thermal storage.Energies and powers as indicated in the legend.
is the electrical energy imported from the grid, E batt dis (k) is the electrical energy discharged by the battery, E load DHW (k) is the thermal energy needed for domestic hot water, E load SH (k) is the thermal energy needed for space heating, E TES char (k) is the thermal energy charged by the TES E CHP th (k) is the thermal energy produced by the CHP, E TES dis (k) is the thermal energy discharged by the TES and E boiler th (k) is the thermal energy produced by the gas boiler.
with E load el (k) is the electrical load, E batt char (k) is the electrical energy charged by the battery, E grid exp (k) is the electrical energy exported to the grid, E CHP el (k) is the electrical energy produced by the CHP, E PV prod (k) is the electrical energy produced by the PV-system, E grid imp (k)

Table 2 .
Key performance indicators for two modes and two variants.

Table 2 .
Key performance indicators for two modes and two variants.

Table 2 .
Key performance indicators for two modes and two variants.