A Decision Support System Tool to Manage the Flexibility in Renewable Energy-Based Power Systems

: Renewable Energy Sources (RES) have taken on an increasingly important role in the energy mix in the last few years, and it has been forecasted that this trend will continue in the future. The energy production from these sources is not dispatchable, and the increasing penetration of RES in energy mixes may therefore lead to a progressive loss of generation control and predictability. It has become clear that, to reach higher RES penetration levels, it is essential to increase power system ﬂexibility in order to ensure stable operations are maintained. An ICT (Information and Communication Technology) tool that may be used to manage and optimize the ﬂexibility o ﬀ ered by energy storage and conversion systems is described in this paper with speciﬁc reference to the Decision Support System (DSS) developed within the H2020 PLANET (PLAnning and operational tools for optimizing energy ﬂows and synergies between energy NETworks) project. The paper focuses on how the PLANET DSS tool evaluates, manages, and dispatches the ﬂexibility of Power to Gas / Heat (P2X) technologies. Moreover, the tool has been used to analyze a realistic case in order to show how the PLANET DSS tool could be used to evaluate the energy and economic beneﬁts of taking advantage of the ﬂexibility of P2X technologies.


Introduction
The world's mean temperature has risen by 0.8 • C since the beginning of the twentieth century [1] due to an increase in anthropogenic greenhouse gas emissions [2]. The European Union (EU) has outlined ambitious objectives to reduce this dangerous trend [3,4]. Renewable Energy Sources (RES) will play a fundamental role in the near future, as the power sector alone is responsible for around 30% of global emissions [5]. Because of the intrinsic nature of RES, the energy production of these sources is not dispatchable, and as their share of the energy mix increases, so will the challenges concerning the balancing of consumption and generation.
In an increased RES penetration scenario, a greater degree of flexibility in the energy dispatch system is required to handle unpredictable variations of energy production and facilitate the RES integration in the existing infrastructures [6]. The key requirements to achieve proper grid operations include a wide range of technologies and solutions, such as energy storage (e.g., Virtual Energy Storage VES [7,8]), energy conversion (e.g., Power-to-Gas (P2G) [9,10] and Power-to-Heat (P2H) [11]), which becomes very important to be able to define appropriate systems of measurement and prediction of energy flows [14] in order to be able to analyze the flexibility potential within energy systems.
In these scenarios, energy flows within energy systems are somewhat complicated and intricate, due to the interconnection of different energy networks and the increase in stochasticity resulting from distributed generation. For this reason, it is important to have computer simulation tools available to analyze these interconnected energy flows and to evaluate the energy and economic impact of different technologies and regulations on the entire system [15,16].
A specific ICT DSS tool has been proposed by The EU-Funded H2020 PLANET project [17] to analyze and optimize the flexibility of P2X energy conversion technologies. The project provides an ICT platform to support network operators/planners, P2X plant managers, load aggregators, and policy makers in order to increase the integration of renewables.
Several software programs are available in the literature to simulate energy flows in a Multi Energy System (MES) [16,18,19]. The main advantage of using the PLANET DSS lies in the fact that the tool is built on a web platform: through the web platform, the users can setup and execute a remote simulation, and in this way the various actors can benefit from using a dedicated supercomputer for their simulation, to which they would otherwise not have access. Moreover, due to middleware-based communication, Demand-Response (DR) signals exchanged between the tool modules (e.g., the output of the flexibility usage optimization module) can easily be transmitted to real-world equipment in order to update DR commands. In this way, the functionality of the PLANET platform is superior to that of a typical simulation tool, as it may be used by DSOs to perform DR scheduling, if appropriate Machine-to-Machine (M2M) interfaces are developed. An important feature of the tool is that the different mathematical models and modules interact with a seamless exchange of data in a co-simulation process. The co-simulation of the different modules (see also reference [20]) makes DSS very flexible and scalable, and as such each module can easily be modified or replaced in a plug and play fashion. The PLANET platform allows existing P2X unit managers to register their unit model and perform simulations in order to assess whether it would be beneficial for their units to participate in DR operations. This paper is a progression of the work presented in references [21,22]. In the previous work, the role of each component involved in the PLANET architecture was explained, while this paper focuses on the particular aspect of how the flexibility of the energy conversion technologies is evaluated and managed within PLANET DSS. In order to better clarify the strengths of the PLANET tool, a description of a use case, where the flexibility of a P2G plant is used to alleviate Reverse Power Flow (RPF) issues caused by excess RES generation, has been included in the paper. The case study is used as an example to show how the tool optimizes P2X utilization as a function of the available flexibility and the energy flows in the grid. A schematic representation of the analyzed energy system is shown in Figure 1, together with the involved energy flows and the energy conversion plants that act as connectors between the networks.   The Grid Simulation component. Figure 2 reports the high-level architecture of the PLANET tool, identifies all the different ICT components, and shows how they are related to each other. High-level architecture of the PLANET (PLAnning and operational tools for optimizing energy flows and synergies between energy NETworks) tool: components and exchanged information [22]. Figure 2, the user can interact with the PLANET tool through the IDOC frontend, which is accessible via a web-based User Interface (UI). Through the UI, the user can initialize the energy scenario (by defining the networks, demand/supply modules, and grid-connected asset parameters) and, at the end of the simulation, can visualize the results. The energy scenario is saved in the PLANET Database (DB) and all the initialization parameters are then dispatched, by the IDOC back-end, to the corresponding modules.

As indicated in
The asset models are developed in the MATLAB/Simulink environment. Each flexible asset receives from the SCCE controller the optimum working set-points, the energy consumption/generations of these modules is saved in the DB and sent to the grid simulation component. The mathematical models of the assets are validated by real data from the pilot plants of the project: one in France for VES and one in Italy for P2H [21]. Meanwhile, the P2G model are validated using data obtained from the high-fidelity P2G process simulator model, which is based on the Apros ® simulator [23] developed in the Neo Carbon Energy project [24].
Depending on the operating parameters defined by the user and the working conditions at each time step of the simulation, each asset can offer a certain degree of flexibility to the system (This concept is defined in more detail in Section 3). The SCCE, developed as a Phyton script, calculates the optimal operation set-points of the assets (P2G, P2H, VES) according to the available flexibility and the grid requirements. The optimization algorithm has been set in order to optimize the network energy flows, and in particular to reduce the Reverse Power Flow. For more information about the optimization process performed by SCCE, please see reference [25]. The grid simulator component receives the energy flows of all the involved modules, performs a power flow calculation (the power flow will be solved with the eMEGAsim Power Grid simulator of OPAL-RT [26]), provides the simulation results to the PLANET DB and to the IDOC back-end for the visualization of the simulation results. The OPAL-RT simulator allows the behavior of the power grids to be simulated High-level architecture of the PLANET (PLAnning and operational tools for optimizing energy flows and synergies between energy NETworks) tool: components and exchanged information [22]. Figure 2, the user can interact with the PLANET tool through the IDOC front-end, which is accessible via a web-based User Interface (UI). Through the UI, the user can initialize the energy scenario (by defining the networks, demand/supply modules, and grid-connected asset parameters) and, at the end of the simulation, can visualize the results. The energy scenario is saved in the PLANET Database (DB) and all the initialization parameters are then dispatched, by the IDOC back-end, to the corresponding modules.

As indicated in
The asset models are developed in the MATLAB/Simulink environment. Each flexible asset receives from the SCCE controller the optimum working set-points, the energy consumption/generations of these modules is saved in the DB and sent to the grid simulation component. The mathematical models of the assets are validated by real data from the pilot plants of the project: one in France for VES and one in Italy for P2H [21]. Meanwhile, the P2G model are validated using data obtained from the high-fidelity P2G process simulator model, which is based on the Apros ® simulator [23] developed in the Neo Carbon Energy project [24].
Depending on the operating parameters defined by the user and the working conditions at each time step of the simulation, each asset can offer a certain degree of flexibility to the system (This concept is defined in more detail in Section 3). The SCCE, developed as a Phyton script, calculates the optimal operation set-points of the assets (P2G, P2H, VES) according to the available flexibility and the grid requirements. The optimization algorithm has been set in order to optimize the network energy flows, and in particular to reduce the Reverse Power Flow. For more information about the optimization process performed by SCCE, please see reference [25]. The grid simulator component receives the energy flows of all the involved modules, performs a power flow calculation (the power flow will be solved with the eMEGAsim Power Grid simulator of OPAL-RT [26]), provides the simulation results to the PLANET DB and to the IDOC back-end for the visualization of the simulation results. The OPAL-RT simulator allows the behavior of the power grids to be simulated in detail. This software has already been widely used in literature for the analysis of electrical networks [27][28][29]. The backend components are grouped into two main categories, which are outlined below.

PLANET Middleware
The middleware is a cloud platform that typically allows devices such as meters and sensors to be registered in order to collect measurements from these "field" devices and forward them to ICT modules that utilize this information for higher-level functionalities. In addition, in the case of field actuators, the middleware can route operating commands from the cloud to the actuators. The middleware usage in PLANET can be two-fold: • it is currently used to set up simulators as devices, in such a way that the operator is able to select between different simulator providers. After its configuration, the middleware routes the simulation control commands from the PLANET IDOC (web-app UI) to the preconfigured simulator; • in the next PLANET prototype, it will be used to route the communications between the central simulator that calculates the power flow of the grid section under investigation and the remote simulators that model the operation of the P2X and VES units, that is, it will a) transmit flexibility information from the unit models to the central simulator and b) receive unit operating points from the SCCE. Once this has been achieved, the "co-simulation" scenarios that implement an envisioned real-world system operation will be tested and evaluated.

Backend Orchestration Scripts
These scripts are responsible for the synchronization and serialization of operations of the various components of the system. Indicatively, the following scripts can be mentioned: • scripts that can be used to retrieve topology information about the grid and the energy resources connected to the grid nodes. This information is created by the user, via the IDOC UI, and the scripts translate these parameters into properly structured files (JavaScript Object Notation JSON) that are then used by the simulator; • scripts that can be used to retrieve uncontrollable electricity and heat demands and formulate them according to the simulation time-step and horizon that the user selects via the UI. These files are currently stored statically in the backend of the platform. This information is supposed to be provided by the Distribution System Operators of electric and heat networks (DSO-e, DSO-h). For the grid-planning use of the PLANET system, this information comes from historical measurements covering a timespan of one year. It has been envisioned that for the operational use, these files will be dynamically created, as outputs of the load (heat and electricity) forecasting algorithms that the DSOs employ; • scripts that can be used to retrieve meteorological, photovoltaic (PV), and Wind turbine generation data utilizing the renewable.ninja service [30] according to the location chosen by the user. The scripts retrieve the physical and operating characteristics of the PV and wind turbines that may be connected to the electric branch nodes and create the request according to the appropriate structure dictated by the renewables.ninja Application Program Interface (API). The results are then stored in the PLANET DB for use by the simulator. The RES parameters and their connection nodes are specified by the user, via the IDOC UI, as part of the simulation scenario creation process; • scripts that can be used to retrieve simulation results and (a) present them to the user via visualizations and charts and (b) store them in the PLANET MongoDB database. Other scripts that fall into the same category are the ones that handle the comparison of results from two or more previously executed simulations.

Frontend Web User Interface
The frontend is the web-based interface that the user accesses in order to set up and execute a simulation. Several functionalities have been included in this preliminary operational prototype: • scenario creator: in this UI section, the user is able to create a simulation scenario in a step-by-step manner so as to avoid overloading the user. The scenario includes the name, description, the selection of the electric grid template from those already stored in the system (provided by the DSOs), the adding, editing, and deleting of renewables, loads, and flexibility units at each grid node, the editing of the properties of each of the aforementioned technologies, and the adding of economic parameters regarding the CAPEX and OPEX of the units, as well as emissions-related costs; • simulation execution: in this section, the user is able to select a previously created scenario and instruct the remote simulator to execute it. This is done via the previously mentioned backend scripts. After the simulation has been performed, the results are visualized for the user. The results include energy flows between the energy networks, the power timeseries values and energy values over the entire simulation horizon, economic results (e.g., Levelized Cost of Electricity (LCOE)), carbon dioxide (CO2) emissions, and the Simple Payback period (SP) of the technologies; • simulation comparison: in this section, the user is able to select two or more previously run simulations and compare the results.
The flowchart of the PLANET DSS UI utilization steps is depicted in Figure 3. In the first step, the user registers himself/herself and creates a new energy scenario (location, horizon, grids, technologies and economic parameters). In the second step, the user starts the scenario simulation and visualizes the results (for example, the fulfillment of the electricity demand through different energy sources, as reported in Figure 3). In the third step, the user can compare the obtained results with a previous scenario (for example, Figure 3 compares the electric power withdrawn from the external electricity network for two different scenarios).  scripts that can be used to retrieve simulation results and (a) present them to the user via visualizations and charts and (b) store them in the PLANET MongoDB database. Other scripts that fall into the same category are the ones that handle the comparison of results from two or more previously executed simulations.

Frontend Web User Interface
The frontend is the web-based interface that the user accesses in order to set up and execute a simulation. Several functionalities have been included in this preliminary operational prototype:  scenario creator: in this UI section, the user is able to create a simulation scenario in a stepby-step manner so as to avoid overloading the user. The scenario includes the name, description, the selection of the electric grid template from those already stored in the system (provided by the DSOs), the adding, editing, and deleting of renewables, loads, and flexibility units at each grid node, the editing of the properties of each of the aforementioned technologies, and the adding of economic parameters regarding the CAPEX and OPEX of the units, as well as emissions-related costs;  simulation execution: in this section, the user is able to select a previously created scenario and instruct the remote simulator to execute it. This is done via the previously mentioned backend scripts. After the simulation has been performed, the results are visualized for the user. The results include energy flows between the energy networks, the power timeseries values and energy values over the entire simulation horizon, economic results (e.g., Levelized Cost of Electricity (LCOE)), carbon dioxide (CO2) emissions, and the Simple Payback period (SP) of the technologies;  simulation comparison: in this section, the user is able to select two or more previously run simulations and compare the results.
The flowchart of the PLANET DSS UI utilization steps is depicted in Figure 3. In the first step, the user registers himself/herself and creates a new energy scenario (location, horizon, grids, technologies and economic parameters). In the second step, the user starts the scenario simulation and visualizes the results (for example, the fulfillment of the electricity demand through different energy sources, as reported in Figure 3). In the third step, the user can compare the obtained results with a previous scenario (for example, Figure 3 comp

Flexibility in the PLANET Architecture
Flexibility may be defined as the capability of a system to modify its energy generation/consumption profile in order to offer ancillary services to the grid. It is possible to define negative and positive forms of flexibility [31]. The following convention has been used in this paper: positive flexibility is defined as the capability of a system to increase its energy consumption or, equivalently, to reduce its production. Positive flexibility may be required when the RES generation exceeds the total load and there is a need to balance the energy in the network in order to maintain

Flexibility in the PLANET Architecture
Flexibility may be defined as the capability of a system to modify its energy generation/consumption profile in order to offer ancillary services to the grid. It is possible to define negative and positive forms of flexibility [31]. The following convention has been used in this paper: positive flexibility is defined as the capability of a system to increase its energy consumption or, equivalently, to reduce its production. Positive flexibility may be required when the RES generation exceeds the total load and there is a need to balance the energy in the network in order to maintain grid stability, for example by converting or storing excess RES energy. Negative flexibility is the capacity of a system to decrease the total energy consumption in the system itself, or to increase the total energy production [32], and this may be required when the RES production is lower than the total load or during a critical peak pricing event.
In an energy system scenario, flexibility can be provided by different technologies, for example: • pure load units (e.g., Electric vehicle charging stations [33]) can provide positive and negative flexibility by increasing/decreasing their electric load; • energy storage systems can offer positive flexibility by absorbing energy from the grid or negative flexibility by releasing stored energy [34]; • energy conversion units (P2G, P2H) can offer both positive and negative flexibility by modifying their operation set-points [35]; • generation units (e.g., Combined Heat and Power CHP) can increase/decrease the power introduced into the network and they therefore offer flexibility [36]; • the RES sources could also provide flexibility by modulating the power production (with the constraint of the variable maxim output being driven by the weather conditions) [37,38].
The Power Node approach, proposed in reference [39], had been adopted to calculate and evaluate the available flexibility. The advantage of this method is that it can be used to define the flexibility of any conceivable power system with the same mathematical equations. For the sake of clarity, the same nomenclature proposed in reference [39] has been maintained, while the sign convention has been modified slightly in order to better clarify the power flow in the present cases. Figure 4 reports all the possible power exchanges between the electric grid and a general device. The same notations could be adopted for power generation plants, power conversion units (P2G, P2H), electric storages, and for pure load units.
Energies 2019, 12, x FOR PEER REVIEW 6 of 16 grid stability, for example by converting or storing excess RES energy. Negative flexibility is the capacity of a system to decrease the total energy consumption in the system itself, or to increase the total energy production [32], and this may be required when the RES production is lower than the total load or during a critical peak pricing event. In an energy system scenario, flexibility can be provided by different technologies, for example:  pure load units (e.g., Electric vehicle charging stations [33]) can provide positive and negative flexibility by increasing/decreasing their electric load;  energy storage systems can offer positive flexibility by absorbing energy from the grid or negative flexibility by releasing stored energy [34];  energy conversion units (P2G, P2H) can offer both positive and negative flexibility by modifying their operation set-points [35];  generation units (e.g., Combined Heat and Power CHP) can increase / decrease the power introduced into the network and they therefore offer flexibility [36];  the RES sources could also provide flexibility by modulating the power production (with the constraint of the variable maxim output being driven by the weather conditions) [37,38].
The Power Node approach, proposed in reference [39], had been adopted to calculate and evaluate the available flexibility. The advantage of this method is that it can be used to define the flexibility of any conceivable power system with the same mathematical equations. For the sake of clarity, the same nomenclature proposed in reference [39] has been maintained, while the sign convention has been modified slightly in order to better clarify the power flow in the present cases. Figure 4 reports all the possible power exchanges between the electric grid and a general device. The same notations could be adopted for power generation plants, power conversion units (P2G, P2H), electric storages, and for pure load units. [MW] is the energy flow that exits the system ( 0 e.g., Synthetic Natural Gas SNG, heat) or the energy flow that enters into the system ( 0, e.g., Natural Gas NG, wind energy) by the device;  [MW] represents an unserved load ( 0, e.g., demand curtailment) or an enforced energy loss ( 0, e.g., RES curtailment);  0 [MW] is the energy storage loss.
The general Power Node equation is: where: is the internal storage capacity (C = 0, for a non-buffered unit); is the electric consumption of the device and η load is the charging/conversion efficiency; • u gen ≥ 0 [MW] is the electric generation of the device and η gen is its efficiency; • ξ [MW] is the energy flow that exits the system (ξ > 0 e.g., Synthetic Natural Gas SNG, heat) or the energy flow that enters into the system (ξ < 0, e.g., Natural Gas NG, wind energy) by the device; • ω [MW] represents an unserved load (ω > 0, e.g., demand curtailment) or an enforced energy loss (ω < 0, e.g., RES curtailment); is the energy storage loss.
The general Power Node equation is: Generally, each term in the above equation may be either controllable or non-controllable. v, η load and η gen . may be fixed or state dependent (e.g., v = f (SoC)).
The electricity load/generator of the device is constrained as: Equations (2) and (3) represent the maximum and minimum power generation/load, which are normally defined on the basis of the nominal power and the minimum working power. Equations (4) and (5) pertain to the restriction due to the ramp rate capacity of the device. More details on Power Node modeling are reported in references [39][40][41].
If a general P2X energy conversion device is considered as an example, the Power Node equation for the k simulation time step, can be written as: where term C is the internal energy storage capacity (e.g., a heat storage of a P2H or a SNG vessel for P2G), SoC P2X is its normalized State of Charge and v P2X is its energy loss. ξ P2X is the X energy vector provided externally and η P2X is the efficiency of the P2X process. The unit can modify its electric load, u load,P2X , by modifying the internal storage SoC and/or the X energy exported outside the plant. For a load unit, the available flexibility can be defined as: where u f easible P2X is the electric load of the unit in one of the possible working conditions and u 0 P2X is the unit electricity load. The ξ f easible P2X term is the amount of X energy that may be exported outside the plant without violating the external constraints (e.g., the district heating or gas grid capacity). It is possible to define ξ max P2X ≥ 0 and ξ min P2X ≥ 0; these represent the maximum and minimum flows of energy vector X that may be exported. Term C Combining Equations (7)-(9), it is possible to define the positive and negative power capacity flexibility (π + , π − ): Energies 2020, 13, 153 The terms represent the storage and the external constraints at simulation step k. The limitation, due to the minimum and maximum power loads, is defined by u min P2X and u max P2X . The terms u 0 P2X (k) + . u min P2X ∆k and u 0 P2X (k) + . u max P2X ∆k guarantee that the power increase/decrease during discretization interval ∆k does not exceed the ramp rate constraints.
The flexibility of the unit at step k (π + P2X and π − P2X ) is sent to and managed by the SCCE control system. Figure 5 reports the flexibility information flow. The flexibility generated by the energy storage/convention modules (VES P2G P2H) is sent to the SCCE. This component has the task of regulating the setpoints of the flexible components, according to their availability, and the generation and consumption of the network nodes. In short, the SCCE, when necessary, raises or lowers the setpoint of the flexible components in order to mitigate the problems of the networks. For more information on SCCE, see references [21,25]. power loads, is defined by and . The terms ∆ and ∆ guarantee that the power increase/decrease during discretization interval ∆ does not exceed the ramp rate constraints. The flexibility of the unit at step ( and ) is sent to and managed by the SCCE control system. Figure 5 reports the flexibility information flow. The flexibility generated by the energy storage/convention modules (VES P2G P2H) is sent to the SCCE. This component has the task of regulating the setpoints of the flexible components, according to their availability, and the generation and consumption of the network nodes. In short, the SCCE, when necessary, raises or lowers the setpoint of the flexible components in order to mitigate the problems of the networks. For more information on SCCE, see references [21,25].

Use Case Development
In order to demonstrate the current potential of PLANETʹs preliminary operational prototype, the tool was used to simulate an energy scenario and then to improve its energy performance by exploiting the flexibility of a P2G system.

The Analyzed Scenario
The analyzed scenario represents a typical future scenario characterized by a high penetration of renewables that could cause problems for the electric grid. The possible energy flows are schematized in Figure 1. A medium voltage network feeder, consisting of eight nodes connected in series, was analyzed (see Figure 6). Uncontrollable loads, PV plants, a CHP plant, and a P2G asset are connected to the electric gird (see Table 1).

Use Case Development
In order to demonstrate the current potential of PLANET's preliminary operational prototype, the tool was used to simulate an energy scenario and then to improve its energy performance by exploiting the flexibility of a P2G system.

The Analyzed Scenario
The analyzed scenario represents a typical future scenario characterized by a high penetration of renewables that could cause problems for the electric grid. The possible energy flows are schematized in Figure 1. A medium voltage network feeder, consisting of eight nodes connected in series, was analyzed (see Figure 6). Uncontrollable loads, PV plants, a CHP plant, and a P2G asset are connected to the electric gird (see Table 1). Each node of the grid has been associated with an aggregated uncontrollable electric load. The uncontrollable load profile of the -th node ( ) is defined as: (12) where is the per-unit aggregated profile stored in the PLANET DB and is the aggregated peak load of the node defined by the user in the PLANET UI.  Each node of the grid has been associated with an aggregated uncontrollable electric load. The uncontrollable load profile of the i-th node (u node i ) is defined as: where pu el is the per-unit aggregated profile stored in the PLANET DB and P node i is the aggregated peak load of the i node defined by the user in the PLANET UI.
As for the uncontrollable load, the production from renewable sources was also determined using per-unit profiles (pu PV ), scaled according to the user defined installed power (P nominal,PV ). The per unit profiles are downloaded in the back-end of the UI from the renewable.ninja website [30], according to the user selected location of the RES plant (in this study, the scenario is located in the city of Turin, north-west Italy).
The P2G system is composed of an electrolyzer and a methanizer. The electrolyzer converts electric power into hydrogen, which is then converted into SNG during the methanation process. The P2G process can be summarized by means of the following equation: where u P2G is the electric input power, q SNG is the produced SNG energy flow, while η el and η meth are the conversion efficiencies of the electrolysis and methanation processes, respectively. All of the produced SNG is injected directly into the gas grid, whose capacity, for the sake of simplicity, has been assumed to be unlimited. The CHP converts the chemical energy of the fuel ( . m NG LHV NG ) into electricity (u CHP ) and heat (q CHP ): It has been assumed that the District Heating (DH) supplies all the heat demand loads in the analyzed area. The heat is mainly produced by the CHP plants and from backup gas boilers (Gas to Heat G2H). The heat produced during the methanation process of the P2G plant supplies the DH network with a revenue of 45 €/MWh of heat.
The user may also change other parameters, whether of an economic or technology nature, but the default values proposed by the tool itself have been used for the present study.

P2G Flexibility and the Objective Function
P2G systems can rapidly change their working set point, Polymer Electrolyte Membrane (PEM) electrolyzer can be completely ramped up and down (0÷100% range) in just a few seconds [10]. In order to make the hydrogen react with CO2 and produce SNG, the methanizer must be kept at the working temperature [44,45] and, for simplicity reasons, it was here considered that the methanizer is kept at the correct temperature during operation of the plant with no additional cost or energy consumption. The time step used in this analysis is one hour, and for this reason the P2G ramp constraint is negligible. The considered P2G system has no internal storage, and the produced SNG is considered to be injected directly into the NG network (whose capacity is considered unlimited). For this case study, the flexibility of P2G can therefore be rewritten as: This flexibility can be used to optimize the operation of the system. In this study, operation of the P2G has been optimized, by the SCCE control, in order to absorb the overproduction of renewables and reduce the Reverse Power Flow. In fact, distributed generation energy scenarios, especially with a high RES penetration, may have to deal with an overproduction of energy as the uncontrolled production of renewables exceeds the instantaneous energy demand. When this happens, the over-production of energy is absorbed by the transmission network. This situation represents a non-optimal utilization of the renewables. Moreover, even though the Reverse Power Flow does not lead to a violation of the voltage and current limits, the protection scheme that is currently implemented in the distribution grid was not designed to handle the Reverse Power Flow, and for this reason the system is not able to guarantee adequate protection for the distribution system in such situations [46,47].
The SCCE receives the generation and consumption of the nodes and the flexibility of all the scenario assets (in this case only the P2G plant flexibility) as input. The objective of the control algorithm is to minimize the energy generation/consumption imbalance for each node of the network. In this way, the Reverse Power Flow is optimized indirectly. If it is not possible to balance generation and production in the unbalanced nodes (due to an insufficient flexibility present in that node), the SCCE exploits the flexibility of the assets installed in the nodes closest to the unbalanced one.

Results and Discussion
The PLANET tool was used to analyze the flexibility of a P2G plant and how its flexibility can be used in a high penetration renewable energy scenario. The scenario was first analyzed without any energy conversion assets and then with the installation of the P2G plant.
The aggregated electricity production and the electric load profiles in the analyzed gird branch for the case of no P2G installation are reported in Figure 7 for four typical days (in April). It can be seen that the load in the considered scenario is satisfied by the photovoltaic energy (53% on an annual basis), by the electricity produced by the CHP plants (21% on an annual basis) and by taking energy from the high voltage network (26% on an annual basis). Although the penetration of renewables in the considered scenario is around 50%, the large amount of installed PV power causes very high energy overproductions that are not consumed within the considered network. This overproduction amounts to about 40% of the total PV production and causes nearly 2400 hours of Reverse Power Flow during the whole year. Figure 8. It is possible to note that the flexible unit allows the electric load to be increased during RES overproduction, and this leads to an increase in the renewable energy utilization and a decrease in the Reverse Power Flow. The evolution of the flexibility of P2G is shown in Figure 9. At each time step, these flexibility values are sent to the SCCE controller (as schematized in Figure 5), which regulates the P2G Load (dashed gray curve) according to its flexibility and the grid power flows. The P2G system is not in operation at point 1, and the positive flexibility is therefore maximum since the plant could potentially increase its electric consumption up to the nominal power. The negative flexibility is zero, because the plant cannot further decrease its energy consumption. At this point, there is no overproduction of renewable energy (black dashed curve) and SCCE keeps the P2G turned off since there is no need to absorb any excess energy from the grid. The P2G is turned on at point 2 as the SCCE has detected an increase in renewable energy production. The positive P2G flexibility decreases as the plant is working closer to its nominal power, although, on the other hand, it gains negative flexibility as the plant is able to decrease the consumed power. In fact, control system exploits the generated negative flexibility at point 3 and uses it to lower the P2G set point in order to reduce the loads on the network.
P2G works at its nominal power at point 4. As such, the system controller cannot increase the surplus energy absorbed by P2G any further. At this point, the positive flexibility of P2G is zero as the plant is already working at is nominal capacity, and, at the same time, the negative flexibility reaches its maximum value. It can be noted that the P2G load follows and therefore completely absorbs the RES surplus up to point 3 thanks to the SCCE optimization control, while the P2G system is not able to absorb all the RES surplus energy between 15:00 and 16:00 due to its limited flexibility.   The energy flow of the same scenario, but with the installation of 1.5 MW of P2G, is depicted in Figure 8. It is possible to note that the flexible unit allows the electric load to be increased during RES overproduction, and this leads to an increase in the renewable energy utilization and a decrease in the Reverse Power Flow. The evolution of the flexibility of P2G is shown in Figure 9. At each time step, these flexibility values are sent to the SCCE controller (as schematized in Figure 5), which regulates the P2G Load (dashed gray curve) according to its flexibility and the grid power flows. The P2G system is not in operation at point 1, and the positive flexibility is therefore maximum since the plant could potentially increase its electric consumption up to the nominal power. The negative flexibility is zero, because the plant cannot further decrease its energy consumption. At this point, there is no overproduction of renewable energy (black dashed curve) and SCCE keeps the P2G turned off since there is no need to absorb any excess energy from the grid. The P2G is turned on at point 2 as the SCCE has detected an increase in renewable energy production. The positive P2G flexibility decreases as the plant is working closer to its nominal power, although, on the other hand, it gains negative flexibility as the plant is able to decrease the consumed power. In fact, control system exploits the generated negative flexibility at point 3 and uses it to lower the P2G set point in order to reduce the loads on the network. P2G works at its nominal power at point 4. As such, the system controller cannot increase the surplus energy absorbed by P2G any further. At this point, the positive flexibility of P2G is zero as the plant is already working at is nominal capacity, and, at the same time, the negative flexibility reaches its maximum value. It can be noted that the P2G load follows and therefore completely absorbs the RES surplus up to point 3 thanks to the SCCE optimization control, while the P2G system is not able to absorb all the RES surplus energy between 15:00 and 16:00 due to its limited flexibility.   The PLANET tool was used to evaluate the scenario from an energy and an economic point of view. As reported in Figure 10a, even with 1.5 MW of P2G, the Reverse Power Flow, cannot be completely absorbed. Nevertheless, thanks to the flexibility of the 1.5 MW P2G plant, the Reverse Power Flow can be greatly reduced over the entire year: by more than 60 % in terms of energy and by about 40% in terms of duration. It is interesting to note that even with a small amount of installed P2G, compare to the PV nominal power, the effects on the Reverse Power Flow are remarkable. With an installed power of P2G equal to 10% of the PV nominal power, it is possible to achieve a reduction of the Reverse Power Flow of about 20% in terms of duration and about 40% in terms of energy (see Figure 10b). Figure 11 compares the Simple Payback period (SP) with the price of the produced SNG, considering the current investment costs and the cost forecast for 2030, as proposed in reference [43]. The results obtained by the DSS show that, although the P2G plant benefits from the energy flows in the scenario, it may not be economically convenient due to the high investment costs and to the low full load hours of around 1900 per year. In fact, it can be noted that to have an SP of 10 years, considering the most optimistic CAPEX value, the SNG cost would need to be 85 €/MWh. Instead, considering the current CAPEX of these plants, the SNG would need to be incentivized to nearly 190 €/MWh in order to make this technology economically advantageous.  The PLANET tool was used to evaluate the scenario from an energy and an economic point of view. As reported in Figure 10a, even with 1.5 MW of P2G, the Reverse Power Flow, cannot be completely absorbed. Nevertheless, thanks to the flexibility of the 1.5 MW P2G plant, the Reverse Power Flow can be greatly reduced over the entire year: by more than 60 % in terms of energy and by about 40% in terms of duration. It is interesting to note that even with a small amount of installed P2G, compare to the PV nominal power, the effects on the Reverse Power Flow are remarkable. With an installed power of P2G equal to 10% of the PV nominal power, it is possible to achieve a reduction of the Reverse Power Flow of about 20% in terms of duration and about 40% in terms of energy (see Figure 10b). The PLANET tool was used to evaluate the scenario from an energy and an economic point of view. As reported in Figure 10a, even with 1.5 MW of P2G, the Reverse Power Flow, cannot be completely absorbed. Nevertheless, thanks to the flexibility of the 1.5 MW P2G plant, the Reverse Power Flow can be greatly reduced over the entire year: by more than 60 % in terms of energy and by about 40% in terms of duration. It is interesting to note that even with a small amount of installed P2G, compare to the PV nominal power, the effects on the Reverse Power Flow are remarkable. With an installed power of P2G equal to 10% of the PV nominal power, it is possible to achieve a reduction of the Reverse Power Flow of about 20% in terms of duration and about 40% in terms of energy (see Figure 10b). Figure 11 compares the Simple Payback period (SP) with the price of the produced SNG, considering the current investment costs and the cost forecast for 2030, as proposed in reference [43]. The results obtained by the DSS show that, although the P2G plant benefits from the energy flows in the scenario, it may not be economically convenient due to the high investment costs and to the low full load hours of around 1900 per year. In fact, it can be noted that to have an SP of 10 years, considering the most optimistic CAPEX value, the SNG cost would need to be 85 €/MWh. Instead, considering the current CAPEX of these plants, the SNG would need to be incentivized to nearly 190 €/MWh in order to make this technology economically advantageous.   Figure 11 compares the Simple Payback period (SP) with the price of the produced SNG, considering the current investment costs and the cost forecast for 2030, as proposed in reference [43]. The results obtained by the DSS show that, although the P2G plant benefits from the energy flows in the scenario, it may not be economically convenient due to the high investment costs and to the low full load hours of around 1900 per year. In fact, it can be noted that to have an SP of 10 years, considering the most optimistic CAPEX value, the SNG cost would need to be 85 €/MWh. Instead, considering the current CAPEX of these plants, the SNG would need to be incentivized to nearly 190 €/MWh in order to make this technology economically advantageous.

Conclusions
Because of the increase in distributed generation and the non-dispatchability of renewable energy sources, energy system simulation software has become fundamental to analyze the more and more complex energy systems that are emerging and to find the best solution from both an economic and an environmental point of view. The PLANET project has developed an ICT DSS tool for grid operators, P2X plant managers, and policy makers. This DSS tool was built specifically to analyze and optimize the flexibility of P2X energy conversion technologies. The tool can be used to analyze energy systems at a district scale. Through a web UI, it is possible to define the scenario that has to be analyzed by choosing the network loads, the technologies connected to the network, and their corresponding sizes. The user can also choose the geographical location of the scenario and, according to the user's choice, the simulation is initialized with the corresponding meteorological and RES generation data.
The PLANET DDS tool has been introduced in this paper and how the flexibility of the involved technologies is managed within the tool has been analyzed in detail. Moreover, the mathematical model used to evaluate the available flexibility has been presented. The flexibility is calculated by means of the Power Node approach. This method is very powerful as it can be applied to any technology (whether generation or loads assets) that is connected to the electrical network.
An example of a possible case study has been presented in order to show how flexibility is managed and dispatched and, at the same time, to show the potential of the tool. The analyzed case study concerns a high penetration renewable energy scenario. When the scenario was first analyzed without any energy conversion assets, the tool allowed us to verify that even with a 50% renewable penetration, there are large energy overproductions that can cause grid balancing problems. The same scenario was analyzed with the installation of a P2G planet. The control system regulated the set point of a flexible asset in order to optimize the energy flows according to the step by step flexibility of P2G. The tool was also used to evaluate the system from an energy and economic point of view by using the Reverse Power Flow reduction, in terms of energy and time, and the Simple Payback period of the P2G plant as a function of its size and CAPEX. The tool has made it possible to verify that the use of P2G flexibility has an important impact, in the chosen scenario, on the reduction of the Reverse Power Flow, but that the cost of this technology is currently too high and, due to the low number of full load hours, it would be necessary to have a particularly high SNG sales price to obtain a positive economic balance of the plant.

Conclusions
Because of the increase in distributed generation and the non-dispatchability of renewable energy sources, energy system simulation software has become fundamental to analyze the more and more complex energy systems that are emerging and to find the best solution from both an economic and an environmental point of view. The PLANET project has developed an ICT DSS tool for grid operators, P2X plant managers, and policy makers. This DSS tool was built specifically to analyze and optimize the flexibility of P2X energy conversion technologies. The tool can be used to analyze energy systems at a district scale. Through a web UI, it is possible to define the scenario that has to be analyzed by choosing the network loads, the technologies connected to the network, and their corresponding sizes. The user can also choose the geographical location of the scenario and, according to the user's choice, the simulation is initialized with the corresponding meteorological and RES generation data.
The PLANET DDS tool has been introduced in this paper and how the flexibility of the involved technologies is managed within the tool has been analyzed in detail. Moreover, the mathematical model used to evaluate the available flexibility has been presented. The flexibility is calculated by means of the Power Node approach. This method is very powerful as it can be applied to any technology (whether generation or loads assets) that is connected to the electrical network.
An example of a possible case study has been presented in order to show how flexibility is managed and dispatched and, at the same time, to show the potential of the tool. The analyzed case study concerns a high penetration renewable energy scenario. When the scenario was first analyzed without any energy conversion assets, the tool allowed us to verify that even with a 50% renewable penetration, there are large energy overproductions that can cause grid balancing problems. The same scenario was analyzed with the installation of a P2G planet. The control system regulated the set point of a flexible asset in order to optimize the energy flows according to the step by step flexibility of P2G. The tool was also used to evaluate the system from an energy and economic point of view by using the Reverse Power Flow reduction, in terms of energy and time, and the Simple Payback period of the P2G plant as a function of its size and CAPEX. The tool has made it possible to verify that the use of P2G flexibility has an important impact, in the chosen scenario, on the reduction of the Reverse Power Flow, but that the cost of this technology is currently too high and, due to the low number of full load hours, it would be necessary to have a particularly high SNG sales price to obtain a positive economic balance of the plant.