DSO Flexibility Market Framework for Renewable Energy Community of Nanogrids

: With the introduction of the renewable energy communities in the current electrical market environment, it becomes possible to aggregate small generation resources and users’ loads to exchange power within the aggregation and at the same time provide services to the electrical system. The renewable energy community of users equipped with nanogrid technology allows performing an adequate level of ﬂexibility. It may be the solution to coordinate in the best possible way the energy resources in order to increase the community self-consumption and to provide ancillary services to the grid. In this paper, a model for the interaction between the Distribution System Operator (DSO)—Transmission System Operator (TSO) and the energy community based on nanogrids is proposed and an operational example is presented.


Introduction
The European Commission (EC) recognizes the importance of end users and energy communities in future energy markets, hence, as part of the Clean Energy Package (CEP) [1] the EC started to renovate the existing market design. In particular, CEP gives far-reaching market access rights to consumers and allows for new market participants (energy communities, facilitators, and aggregators). Therefore, all organized electricity markets (day-ahead, intra-day, balancing, ancillary services, capacity) as a consequence will have to be adapted. The EC recognizes also the importance of the role which the Distribution System Operators (DSOs) will play during this process of evolution [2].
Indeed, with the increase of distributed energy resources (DER), distribution systems have been recently affected by the deep involvement of small generation power resources which have led to a reduction of the system controllability. Within the high uncertainty that characterizes this context, the energy sector heads toward bottom-up models where flexible resources are controlled and coordinated by mean of a massive use of small energy storage systems (ESSs), which are able to meet energy self-sufficiency, self-consumption and offer also support to the electrical grid by providing ancillary services (ASs) [3].
To this end, use of nanogrids technology [4] that integrate a combination of local generators, consumption loads and ESS, represents the link between the energy efficiency and the development of the Energy Communities powered by Renewable sources (RECs). In particular, a nanogrid for Home Application (nGfHA) is a small size DC micro-grid in which the micro-production sources, ESS and loads are connected to the common DC bus through appropriate AC/DC or DC/DC power converters [5,6].
The interface between nGfHA and the power grid is realized through a DC/AC converter called PEI (Power Electrical Interface), which is a bi-directional power converter 1.
Internal flexibility of the aggregation aimed at improving its energy efficiency by increasing the self-consumption. It represents an implementation of the Demand Side Management (DSM) concept where each member of the community is able to respond in order to achieve a reduction in its energy supply costs; 2.
External flexibility realized through the implementation of Demand Response (DR) activities, in which end users offer ancillary services to the network operators, i.e., DSO and Transmission System Operator (TSO), obtaining an accepted remuneration.
As in [9], a management model of a nanogrid community, developed in the ComESto project [10,11] and denoted in the following as ComESto model, has been exploited in order to take advantage of nGfHA for internal and external flexibility.
Enabling and protecting the open participation of the markets (both energy and ancillary services ones) in the resources connected on the distribution grids, as indicated in the EC Regulation 2019/943 [12] and Directive 2019/944 [13], assumes that new roles and coordination models between system operators have to be developed, so to ensure the safe and reliable operation of the network.
According to the EC Regulations, the DSO is not responsible for the balancing services, which therefore remain a task of the TSO. Moreover, same regulations state that the provision of balancing services of resources located in the distribution network must be agreed between DSO and TSO. At the same time, as reported in the consultation document 322/19 of the Italian energy regulator (ARERA), the DSOs can procure local regulation services (non-frequency) to manage their network. As expressed above, it is necessary to develop a 'coordination framework' between the two system operators regarding the procurement of AS, in order to effectively exploit the flexibility resources on the distribution network, minimizing the potential conflicts between the two system operators for the attribution of the regulation services offered within the market.
In the literature, there is a lack of coordination models that consider the optimal management of the internal and external flexibility of RECs of nanogrids as a resource for the entire system. Moreover, a market model to efficiently enable the participation of DERs to the Ancillary Services Market (ASM) in a scenario of high penetration degree of DERs and in the light of the most recent regulatory developments, is still to be investigated.
This paper proposes a model for ASM on the distribution network based on the traffic light model [14]; such a model allows RECs, and in particular energy communities equipped with nanogrids, to provide their external flexibility as a service to the system when the distribution network is in yellow or red state and the community selfconsumption cannot take place efficiently [15].
The model deepens the study of interactions between the DSO and the aggregations of customers (producer, consumers, prosumages) that aim to improve local energy efficiency and to support the grid regulation actions. In line with the EC Directive 2019/944 the maximum customer aggregation perimeters are set to the Medium-Low Voltage (MV-LV) substations, which are also defined as Dispatching Points (DPs). Therefore, there is a correspondence between DPs and RECs.
In this paper, first the main results regarding flexibility market in some H2020 projects and EC directives are illustrated as starting point. Then the ComEsto management model is briefly recalled. Finally, the interaction model TSO-DSO-aggregator is outlined and then an operative example is reported. This paper seeks to combine useful outcomes of other projects experiences and recent regulations in order to propose a suitable market model, for practical application. Compared to other studies, which have sought interesting solutions but often only at a theoretical level, this study seeks an approach that can be applicable in reality, thanks to a careful assessment of feasibility, in relation to current and future market scenarios, conducted in collaboration with one of the most important Italian DSOs.

Starting Points
The CEP, due to the wider role that the DSOs are expected to play in the future scenario, pushes the member states to provide an appropriate legal framework to allow and incentivize DSOs to procure regulation services from resources connected to distribution networks. According to article n.32 of the EC Regulation 2019/943, the services procurement process must be conducted in a transparent and non-discriminatory manner. DSOs are also required to define standardized market products, ensuring effective participation of all market participants, including DR. Moreover, appropriate forms of cooperation between DSOs and TSOs shall ensure an effective participation for DERs also in retail, wholesale, and balancing markets.
In [16], three DSO-TSO coordination options are shown, with details on related activities, benefits, and drawbacks. As shown in Table 1, one of the options foresees giving DSOs a lot of flexibility providing them with strong incentive regulation.  In the following, an overview of the results of the Smart-Net and Nodes projects is provided. These projects, among others, are considered the most in line within the scope of our proposed model and preparatory to the definition of the market framework and the DSO-TSO-Aggregator coordination scheme of this work.

Smart-Net
The European Research Project Smart-Net in [17] analyzes and compares several interactions models between the TSO and the DSO for what regards the exchange of information for monitoring and the acquisition of ancillary services. The aim of the project was to analyze several coordination schemes evaluating the efficiency from a technicaleconomic point of view, assuming a scenario where local needs for regulation services in the distribution systems co-exist with system needs for ancillary services (balancing and congestion management); indeed the optimal use of distributed resources (DER) needs of coordination schemes between system operators.
By increasing the coordination level, system operators are able to support each other efficiently in their respective networks operation, minimizing the risk that the actions taken by one operator contradict the actions taken by the other. This means also that system operators have to cooperate to increase the observability of the network, improving its data quality and transparency.
The need for greater cooperation between system operators is widely recognized especially in a scenario that provides a great presence of production plants from renewable energy sources (RES) in the grids and a growing participation of DERs in ancillary services markets. Much research has largely focused on the impact and possibilities of RES and DERs in providing services to system operators through the distribution network, including pricing mechanisms and relationships between aggregators and DSOs. For example, the work proposed in [18] analyzes different concepts of interaction between system operators (coordination schemes) which results may suggest to the regulatory authorities to make the appropriate regulatory and market changes in order to improve the way in which TSOs and DSOs interact. The coordination scheme is defined as that set of relationships between TSO and DSO where the roles and responsibilities of each system operator in the procurement and use of regulation services, offered by resources connected to the distribution network, are described. In this vision, each proposed coordination scheme is characterized by a set of roles assumed by the TSO, DSO, and other unregulated market operators.
A role is defined as the expected behavior and responsibilities attributed to a specific market party, which is unique and thus cannot be shared. To foster the active participation of DER connected to the distribution network on the ancillary services markets, the role of the DSO is subject to evolution: the DSOs could play a role as active system managers, technology enablers, data managers and innovators. Depending on the coordination scheme, some system operator roles may be added, extended, changed, or moved.
The coordination schemes proposed in Smart-Net take into account the current and future needs of network operators. Today, in many cases, the TSO directly uses the resources connected to the distribution network, without the involvement of the DSO. Furthermore, local markets where flexibility-based services can be purchased are not yet a reality.
The coordination between TSO and DSO, considering AS procurement and local services, is proposed in SmartNet according to five different coordination schemes: Integrated Flexibility market model.
As initially reported, with a role of neutral market facilitators, DSOs support the participation of resources connected to the distribution network in the flexibility market. The DSO could support the TSO by providing solutions to local problems by contributing to system-level security. When the DSO is involved in the role of market manager, it is able to negotiate flexibility services to solve local problems. The mechanism of a coordination between TSO and DSO and the related network information exchange, are essential in the flexibility activation provided by DER, since the TSO decisions might influence the DSO activity and vice versa.

Centralized AS market model (CS_A)
The Centralized AS market model is characterized by a single AS market for resources connected both to the transmission and distribution network. This market is managed by TSO, which is also the only buyer and it procures services directly from the distributed resources connected to the distribution network. The role of the DSO is very limited. Indeed, the DSO is not involved in the TSO's acquisition and activation of flexibility, except in the case where a system pre-qualification process is implemented. The pre-qualification can be defined as a process who takes place before the market, through which the DSO verifies that the activation of resources on the distribution network requested by the TSO does not lead to further issues in the distribution network.

Local AS market model (CS_B)
The local market model is characterized by a separated local flexibility market managed by the DSO, in which it is the sole buyer. In this market distribution, network resources are first offered to the DSO, which has the priority to use local resources for local congestions management. The unused remaining offers are aggregated by the DSO and transferred to the AS market managed by the TSO. The aggregation of offers by the DSO could be organized as a simple 'pass-through' of offers from the local market favored by the aggregator (commercial part, CMP). Alternatively, the DSO could aggregate the offers in a way that better fits the requirements of the TSO.
In addition, the DSO ensures that only offers that satisfy the constraints of the local distribution network are accepted or transferred.

Shared Balancing Responsibility model (CS_C)
The shared balancing responsibility model consists of an AS market for the resources connected to the transmission grid, managed by the TSO, and a local market for the resources connected to the distribution network, managed by the DSO. Shared responsibilities between TSO and DSO are arranged according to a predefined resources schedule. The difference with the previous coordination scheme is that the resources from the distribution network cannot be offered to the TSO market and each system operator acts on the resources connected to its own network. In this way, the TSO transfers responsibility for local balancing to the DSO, while it remains responsible for balancing the transmission network. Unlike the other coordination schemes, the DSO takes on a new role, namely the responsibility for balancing the distribution network according to a schedule (profile) planned in advance between the TSO and the DSO.

Common TSO-DSO AS Market Model (CS_D)
In this model, both the resources connected to the transmission and those connected to the distribution system participate in the same market. The flexibility is assigned to the system operator who has the highest priority, with the aim of reducing total costs and maximizing the social welfare. Therefore, there is no initial priority for TSO or DSO.
This model has two alternatives: the centralized one (for simplicity defined in the following as CS_D1), where all the offers take place in a single market session by considering both transmission and distribution network constraints, and the decentralized one (for simplicity defined in the following as CS_D2), where the results of a first market session based on the distribution system needs are used as an input for a second market optimization, which takes into account the transmission system constraints as well.
The second variant is similar to the local AS market model, except that in this scheme the DSO does not have the priority of using first the local resources, as the resources are allocated to the system operator with the highest priority.

Integrated Flexibility Market Model (CS_E)
In this model, the market is open to both regulated (TSO, DSO) and non-regulate parties (BRP, aggregators, and participants in the commercial market). The presence of non-regulated parties requires the presence of an independent market operator to ensure neutrality, which must have also a role in the data management and the economic compensation of the market.
The common market for flexibility is organized according to a series of auctions and it is managed by the independent/neutral market operator. There is no priority and resources are assigned to the parties who have the highest availability to pay.

Evaluation of the Coordination Models
In SmartNet a cost-benefit analysis was carried out to evaluate each scheme and identify the best one [19,20]. The total cost of procuring resources was used as an indicator.
According to the SmartNet outcomes, the centralized model (CS_A), where the role of the DSO is limited, is less efficient than the centralized variant proposed in the TSO-DSO common market model (CS_D1), which includes the constraints of the distribution networks if congestions are not negligible. Furthermore, SmartNet results have pointed out that local DSO market models (CS_B and CS_C) could be more expensive than the centralized models (CS_A and CS_D).
The Shared Balancing Responsibility model (CS_C), besides being economically inefficient, contradicts the EC regulation that is emerging in Europe as reported in [12,13], since this model presupposes a guaranteed balance first by local resources (distribution) and then by global resources (transmission), while the EC trend is to target a single balance.
Lastly, the integrated flexibility model (CS_E) was not simulated with the same level of detail as the others, since it was considered too complex and unlikely to be feasible.

Nodes
The project focuses on the study of a marketplace to improve grid operation, which exploits additional flexibility potential and enhances congestion management options for grid operators. The scope of Nodes is to facilitate flexibility trading, with a focus on the assets localization and the ability of end users/suppliers to deviate from previously defined energy schedules. With these two features, in particular with the focus on localization of the resources, Nodes adds a significant feature set compared to European day-ahead (DA) and intraday (ID) markets.
Without an integrated market concept for DERs, DSO's use of flexibility might be very expensive, since the DSO might only need local flexibility for a few hours per year. Therefore, if the flexibility can be used elsewhere when is not needed locally, it can reduce costs for the DSO and at the same time increase opportunities for the sellers (end users) creating a win-win situation for both parties. The DSOs, however, have no marketplace to purchase local flexibility to solve local grid issues. The TSO today buys many kinds of reserves and balancing powers from Balancing Responsible Parties (BRPs), Aggregators, and others. BRPs trade with other BRPs on ID and DA markets. Usually, TSO markets need large flexible resources, which means that most of the local flexibility is unable to participate. The Nodes marketplace tries to identify a way to give value to local flexibility [21] reducing this gap.
The main goal is to increase value for flexibility providers reducing costs for the DSO, also giving the opportunity to have the flexibility not used locally to be sold to the TSO and/or BRPs at the transmission grid level. The project also aims to create a link between the flexibility marketplace with the existing platforms that operate intraday and balancing markets. This would create a fully integrated marketplace for flexibility. The current market shows lack of market-based flexibility that DSOs can use in their grid management. The existing ID, DA and balancing markets are not geographically granular enough for the DSO to solve local congestions and other grid management issues.
The market designed in Nodes consider that flexibility assets need to be tagged with their location, as example meter-ID and GPS coordinates can be associated or as alternative the postal code can be used. All flexibility within a Grid Location (GL) can be aggregated by the flexibility provider to one or more offers into the platform. The TSOs or the DSOs are free to decide how granular they want the offers, for example how large the GLs should be. In principle, a DSO can define a GL to be all units below a specific feeder. For the TSO, a relevant GL can be a geographic area under a Highest-Voltage transformer but much larger than what the DSO needs. A GL initiated by the TSO can be an aggregate of GLs initiated by the DSOs.
DSOs and TSOs are those who need flexibility. BRPs might trade again with committed flexibility with other parties as BRPs which offer flexibility to a cheaper costs. These buyers will have to define their willingness to pay for activation of flexibility at particular GLs and add this information into the Nodes platform. Flexibility is made available by the providers who will act on behalf of the owners of the flexibility assets and place these offers into platform represented by their capability to modify their power profile. The flexibility providers will need to have a business model and technology that make possible to activate the flexibility by those who have bought it.
For the majority of operating hours during a year, the flexibility is needed only a few hundred hours per year. For the rest of the hours which flexibility is not needed locally it can still have a value in the rest of the system, e.g., for balancing purposes by the TSO or in the ID market for the BRPs. Nodes establishes an interface that makes the flexibility available for these markets. Depending on whether the flexibility assets are sold, the flexibility providers can also differentiate their offers, locally or centrally. Selling locally at one specific GL in many cases can be risky, as there are fewer alternatives if the seller needs to rebalance due to unavailability of some assets. Contractual positions within ID market are much easier to rebalance. Thus, the price for flexibility is likely to be cheaper in the ID market than at a specific GL. The flexibility providers will register their flexible users linked to each GL. It will be possible to define several portfolios within each GL and differentiate the price and other properties as ramping capability (max/min), source, production, consumption, max/min activation time and max/min activation duration etc.
In some cases, DSOs might prefer increasing consumption instead of ramping down renewables. TSOs might have preferences for activation time and ramping when products are sold in their balancing markets. The platform of a local flexible market can filter buyers of flexibility optimizing grid costs according to their actual need for flexibility.
An offer of flexibility is given by a combination of parameters, as shown in Figure 1, and it is on the basis of these parameters that buyers of flexibility can filter the offers. offers into platform represented by their capability to modify their power profile. The flexibility providers will need to have a business model and technology that make possible to activate the flexibility by those who have bought it.
For the majority of operating hours during a year, the flexibility is needed only a few hundred hours per year. For the rest of the hours which flexibility is not needed locally it can still have a value in the rest of the system, e.g., for balancing purposes by the TSO or in the ID market for the BRPs. Nodes establishes an interface that makes the flexibility available for these markets.
Depending on whether the flexibility assets are sold, the flexibility providers can also differentiate their offers, locally or centrally. Selling locally at one specific GL in many cases can be risky, as there are fewer alternatives if the seller needs to rebalance due to unavailability of some assets. Contractual positions within ID market are much easier to rebalance. Thus, the price for flexibility is likely to be cheaper in the ID market than at a specific GL. The flexibility providers will register their flexible users linked to each GL. It will be possible to define several portfolios within each GL and differentiate the price and other properties as ramping capability (max/min), source, production, consumption, max/min activation time and max/min activation duration etc.
In some cases, DSOs might prefer increasing consumption instead of ramping down renewables. TSOs might have preferences for activation time and ramping when products are sold in their balancing markets. The platform of a local flexible market can filter buyers of flexibility optimizing grid costs according to their actual need for flexibility.
An offer of flexibility is given by a combination of parameters, as shown in Figure 1, and it is on the basis of these parameters that buyers of flexibility can filter the offers. From the buyer's side, DSOs can create available parameters to define local products that they can use when requesting flexibility. These templates can then serve as a basis for the DSO to enter availability contracts according to their specific needs, handling the activation of the flexibility by market platform. With the same platform distributed flexibility is connected to the TSO markets as well.

Market Entities and Involved Roles
In line with the main EC Directive, the REDII (2018/2001, arts. [21][22], the entity with legal status that interacts with grid operators, can be the aggregator in ComESto model. The mentioned aggregator is therefore the entity who acts on behalf of the community and interfaces distribution-transmission grid operators and regulated market operators with the aim of achieving the community goals. According to the wide nomenclature in the literature, the entity accountable for local services to the DSO is defined as the Flexibility Service Provider (FSP) while the entity involved in global services is the Balancing Service Provider (BSP). As shown afterwards, the aggregator can perform activities of energy supplier (ESP), Balancing Responsible Party, FSP and BSP. From the buyer's side, DSOs can create available parameters to define local products that they can use when requesting flexibility. These templates can then serve as a basis for the DSO to enter availability contracts according to their specific needs, handling the activation of the flexibility by market platform. With the same platform distributed flexibility is connected to the TSO markets as well.

Market Entities and Involved Roles
In line with the main EC Directive, the REDII (2018/2001, arts. [21][22], the entity with legal status that interacts with grid operators, can be the aggregator in ComESto model. The mentioned aggregator is therefore the entity who acts on behalf of the community and interfaces distribution-transmission grid operators and regulated market operators with the aim of achieving the community goals. According to the wide nomenclature in the literature, the entity accountable for local services to the DSO is defined as the Flexibility Service Provider (FSP) while the entity involved in global services is the Balancing Service Provider (BSP). As shown afterwards, the aggregator can perform activities of energy supplier (ESP), Balancing Responsible Party, FSP and BSP.
The ESP party is necessary to purchase and sell energy to the end users. It supervises and monitors the energy exchange among prosumers over time and it also deals with the commercial operation of end users. This implies a private agreement among ESP, end-user,s and aggregator.
The BRP is accountable for local dispatching thus it defines the renewable energy generation and consumption baselines for the entire community (aggregated end users).
The aggregation can provide also grid services that can be classified as local flexibility services, which are non-frequency services to be offered to the DSO (e.g., congestions management and voltage control), and global services to be offered to the TSO (i.e., frequency and balancing services), both provided by the services provider entities. In Figure 2, information flows and operation link among different entities within the community are shown. and monitors the energy exchange among prosumers over time and it also deals with the commercial operation of end users. This implies a private agreement among ESP, enduser,s and aggregator.
The BRP is accountable for local dispatching thus it defines the renewable energy generation and consumption baselines for the entire community (aggregated end users).
The aggregation can provide also grid services that can be classified as local flexibility services, which are non-frequency services to be offered to the DSO (e.g., congestions management and voltage control), and global services to be offered to the TSO (i.e., frequency and balancing services), both provided by the services provider entities. In Figure 2, information flows and operation link among different entities within the community are shown. In detail, FSP deals with local markets both as regards the trading of energy within the community, with the aim of maximizing self-consumption, and as regards the provision of services to the DSO. The BSP on the contrary responds to the offers of the aggregator accepted in the ASM (as the Italian market 'Mercato dei Servizi di Dispacciamento'-MSD) by the TSO, for which a validation process by the DSO exists.
The idea behind the interaction model between DSO-TSO and aggregator is the Traffic Light Model (TLM), frequently emerging in Smart Grid solutions on distribution grids [22].
According to this mechanism, for a specific network segment, in a given time period, TLM describes by means of a color (green, yellow, or red) the status of the grid segment. Depending on the color, in the grid segments, different rules are applied and different market entities are involved. In Figure 3, the interactions between the different involved entities in the management model of the market are shown. Due to financial reasons (e.g., avoid fixed costs duplication) different roles can be performed by the aggregator as a single entity aimed both toward self-consumption increase and services provision.
The entities who deal with the increase of community self-consumption (ESP and BRP) represent the Self-consumption Management Entity (SCME), while the management of the flexibility services is delegated to the Service Management Entity (SME), composed of BSP and FSP. In detail, FSP deals with local markets both as regards the trading of energy within the community, with the aim of maximizing self-consumption, and as regards the provision of services to the DSO. The BSP on the contrary responds to the offers of the aggregator accepted in the ASM (as the Italian market 'Mercato dei Servizi di Dispacciamento'-MSD) by the TSO, for which a validation process by the DSO exists.
The idea behind the interaction model between DSO-TSO and aggregator is the Traffic Light Model (TLM), frequently emerging in Smart Grid solutions on distribution grids [22].
According to this mechanism, for a specific network segment, in a given time period, TLM describes by means of a color (green, yellow, or red) the status of the grid segment. Depending on the color, in the grid segments, different rules are applied and different market entities are involved. In Figure 3, the interactions between the different involved entities in the management model of the market are shown. Due to financial reasons (e.g., avoid fixed costs duplication) different roles can be performed by the aggregator as a single entity aimed both toward self-consumption increase and services provision.

Local Energy Market (LEM)
The local energy market takes place through a flexibility mechanism which is based on a reward applied on the base price of the energy supply. These economic advantages, obtained by maximizing the energy self-consumption, are redistributed among the end users who have participated to achieve the common target by maintaining adherence to their energy profile schedule. The maintaining of the programmed profile is possible using different types of energy storage systems as long as integrated with nanogrids.
When the community matching between the proposed profiles by the BRP and the actual The entities who deal with the increase of community self-consumption (ESP and BRP) represent the Self-consumption Management Entity (SCME), while the management of the flexibility services is delegated to the Service Management Entity (SME), composed of BSP and FSP.

Local Energy Market (LEM)
The local energy market takes place through a flexibility mechanism which is based on a reward applied on the base price of the energy supply. These economic advantages, obtained by maximizing the energy self-consumption, are redistributed among the end users who have participated to achieve the common target by maintaining adherence to their energy profile schedule. The maintaining of the programmed profile is possible using different types of energy storage systems as long as integrated with nanogrids.
When the community matching between the proposed profiles by the BRP and the actual energy behavior at maximum, the community self-consumption increases and then the price of the energy absorption by the aggregation, indicated with PA (purchase price), decreases to a minimum value. At the same time, the price of generated energy within the community, increases up to a maximum value. The purchase price could be considered to be the remuneration price for the investment in renewable generation plants, which depends on the costs of realization of the renewable plants and storage systems [23]. PA price is only a theoretical value, in reality being able to set such a price would mean having completely programmable systems which would require large storage systems whose economic advantage needs to be evaluated and taken into account in the price definition.
What certainly happens is that by increasing the adherence between the real profiles and the scheduled profiles, which are designed to maximize self-consumption, the economic advantage of the community increases, and this advantage is reflected in a benefit both on the price of the purchased and sold energy by the users of the aggregation.
Once the energy purchase and sale prices within the aggregation have been determined, it will be more advantageous for both producers and consumers, if the adherence between real and scheduled profiles is maintained, so that degree of self-consumption of the aggregation increases.
Let us assume that in the planning phase (day N−1) the energy price in the energy community is equal to PVP (expected selling price) for producers and PAP (expected purchase price) for consumers, and that the hourly energy quantities to be consumed/saved or supplied are determined. The aim of the energy community is to maximize the selfconsumption degree. The benefit of increasing the self-consumption is a reduction of the procurement cost for consumers (PAP−PA) and an increase of the remuneration for producers (PA−PVP).
This economic advantage must be redistributed among those who have 'actually' contributed to the achievement of the target, who will obtain a 'prize'. The prize value is determined ex-post, taking into account the minimum price practicable in the case of maximum self-consumption for the aggregation (PA), which also corresponds to the maximum remuneration for producers. Therefore, the benefit for end users is: Under optimal conditions PVP ≤ PA ≤ PAP, therefore there is a common advantage between consumers and producers. An additional economic advantage comes from the provision of dispatching services to the network, local services for the DSO and global services to the TSO.

Interaction Model DSO-TSO
The future scenario of energy system considered in ComESto is characterized by a massive presence of flexibility resources connected on the distribution network. It is, therefore, a long-term network scenario with a high probability of power congestions in the distribution grid.
A local AS market managed by the DSO is preferable in such a context as it gives to DSOs a lot of flexibility but require strong regulation for incentive definition. Example of a such regulation could be a price cap with a quality bonus and an efficiency improvement component since once DSO has the right incentives it could foresee its own future tariff revenues and procure ASs under long-term contracts accordingly. Price cap regulation has been used also in the UK and the Netherlands, under an RPI-X regime. On the basis of total expenditures of the DSO, a trade-off between capital costs (new network capacity) and operational costs (procuring flexibility) could be regulated [16].
Moreover, the results of the SmartNet project have shown that in these conditions the preferable coordination scheme is the common market (CS_D). Hence, a TSO-DSO common market scheme is adopted in the ComESto model, similar to the decentralized SmartNet variant introduced in Section 3 (CS_D2).
A first local market session, based on the DSO needs, will provide the input for a second global market optimization, which will also include TSO needs. The peculiarity of the ComESto model lies in the services procurement process. In line with the proposals of the Italian energy regulator contained in the consultation document 322/19, there is no possibility for the DSO to procure services for frequency regulation. Therefore, as detailed in the document, the products procured on the local ASM by the DSO will be long-term capacity contracts, to be activated when needed in the ID market. The possibility of purchasing services from resources that do not have a capacity contract is not excluded, although, under the same technical and economic conditions, the resources previously reserved in capacity are selected as a priority. Due to this mechanism, the activation request of the DSO should normally be considered a priority, except in the case of more critical security needs for the TSO. Finally, the accepted offers for the DSO and for the TSO are published on the Global and Local Ancillary Service Market platform (GLASM). In this way, flexibility is assigned to the system operator who has higher priority, in order to minimize the overall system costs and therefore maximize social well-being.
In the ComESto model: • TSO is only accountable for the real time physical balancing of the electricity system, so it is the manager of the related market. It manages the global ASM, where after a process of validation by the DSO, it can also procure flexibility resources connected to the distribution network. • DSO procures ancillary services different from those aimed at frequency regulation ('not-frequency' services) in a local market; it defines the demand for local services to be supplied by DERs as well as the services to be activated when an emergency event occurs; it operates as a market facilitator and validator for the operations on the distribution network requested by the TSO; it operates in near real time with the aggregator to activate services offered by the resources connected to distribution networks.
A key role is played by the aggregator as it gathers resources placed on the distribution network. In particular, the aggregator: • offers network services in aggregate form on the GLASM; • selects among its users the resources to execute the orders, which derive from the offers accepted on the two market levels, first local and then global; • in phase of selection of the units for offers on the ASM, the aggregator coordinates with the DSO to avoid problems on the network possibly caused by the activation of these resources connected to the distribution networks.
The GLASM refers to the market and its related platform. In the GLASM, the offers for sale and purchase of regulation services are collected and matched. As represented in Figure 4, GLASM is a common platform which is interfaced with the existing ASM platform (for example MSD platform in Italy). As previously reported, a flexibility offered by an active user with flexibility assets is represented by its capability to modify consumption (or generation) power profile and offer of flexibility is given by a combination of different parameters, as reported in Figure 1. Offers are prepared considering the capacity (quantity) to modify power profile (consumption or generation), location onto the grid and time interval.
When active users are available for flexibility in a specific time interval, the aggregator places the offer in GLASM without knowing whether the offer will be accepted by DSOs or TSOs, since the matching between offers and bids is based on the system operators needs and priority. On the basis of the first market session (local session), it is checked whether DSOs require flexibility; if not, a second market session (global session) checks whether the flexibility offer matches with a TSO request on ASM as reported in the following Figure 5 that highlights the entire sequence of the operations in the case local services are not required by the DSO in the local session. Indeed, it is important noting in Figure 5 that when an offer from DER is submitted, if it is not required by DSO and it matches with a global service request done in ASM by the TSO, the aggregator coordinates with the DSO, which performs a pre-qualification process. The latter is an important "check" to ensure that the activation will not represent a problem for the distribution grid. If activation is possible, then the validated global service is communicated to the TSO, which can accept the offer. If the offer is accepted, then the resources activation becomes a mandatory task of the aggregator (in particular for its BSP) which is accountable for allocating the controlled resources as validated by the DSO in the pre-qualification phase. Therefore, the aggregator has to ensures the service execution toward the TSO.
In the case a flexibility offer is accepted by the DSO for a local service, see Figure 6, for the efficient operation of the distribution network, the aggregator (by mean of its FSP) selects the active users that can satisfy the DSO requests and executes the activation orders. In such a case, FSP is accountable for the service execution toward the DSO. The aggregator has several responsibilities regarding the management of the relationships between DERs and system operators. It will have to manage the role of provider, to aggregate generation/consumption resources and to activate services upon request of the DSO and/or the TSO through its BSP or FSP. Only in case of emergency does the DSO itself intervene directly on the resources that have given availability for this type of service.
Finally, the ComESto platform represents a contact point intended as a place where DSO communicates with the Aggregator which is a web platform. The communication between Aggregator and prosumer is actuated by mean of the nanogrids' control where the signals are generated through the standard messaging protocol MQTT.

Flexibility Market in Distribution Network
To describe the local services that the users in the distribution network can provide, it is necessary to introduce some of the model features.
Given the radial operation of the distribution network the DPs are identified in the MV-LV nodes (secondary substations). With respect to these DPs, the DSO will procure ancillary services from the aggregators under the DPs, according to specific requirements as: (1) control of the voltage profiles on the MV-LV busbars of the secondary substations; (2) current control on the MV and LV lines.
Regarding the aggregation size, the smallest units that can offer flexibility are the 'nanogrids', which are domestic electrical systems with a rated power lower than 5 kW. Participation in the aggregation of larger production, consumption, storage systems can be taken into consideration.
With reference to the end-user's requirements to participate flexible market, the only physical and technical requirement for the prosumer is represented by its capacity to be an active and flexible user. As a resource connected to the distribution grid of the DSO, end users can participate to a local and global ancillary service market, which represent a common interface with the existing Ancillary Service Market of the TSO.
Management costs and fees for the local market management might be requested; however, these costs can be compensated by costs reduction, avoided grid reinforcements, services to TSO and other savings obtained by the DSOs.
Regardless of the placement in the network of the managed resources, an aggregator may submit offers on the local market by referring to the single DP, therefore considering only the subtended resources under a specific DP. This definition reflects the proximity feature of the energy communities currently expressed by the Italian legislation and by the Italian Authority [24] and delegates the aggregators as reference entity to provide services.
In the local market, frequency regulation services are not considered; therefore it is not necessary to procure ex-ante regulation reserves. For these reasons, a market similar to the TSO Balancing Market could be implemented: 6 daily sessions (every 4 h) in which after the power profiles resulting from the energy market sessions, the DSO will request the provision of capacity products previously procured and reserved, or it will purchase other services offered on the market at more advantageous conditions. Alternatively, according to the evolution of the ASM defined in the European Regulations UE 2015/1222 (CACM) [25], UE 2017/2195 (Balancing) [26], it could also be considered a continuous bargaining mechanism in the intraday market. When more aggregations are under a DPs, the offers will be selected according to a criterion of technical-economic convenience. If only an aggregate is present, it is expected that the service's purchase price will be regulated by a maximum value.
Therefore, in the ComESto local market model, there are five types of products for Ancillary Services, better described in Table 3. The congestions management and the voltage control services can be procured both as normal spot products offered in GLASM and through a first phase of capacity negotiation (on a multi-year basis, the DSO procures, through the aggregator, the availability of an aggregate to maintain an active regulation power margin) and a second phase of activation of the respective capacity. One last service provides the possibility for the DSO, in the case of an emergency, to directly control and change the power schedule of a specific resource, without considering the aggregator. Table 3. Local macro-services procurable by the DSO.

CONGESTION MANAGEMENT 1-Congestion Management Capacity (Multi) Year
In the planning phase, the DSO procures regulation capacity to manage potential congestions, ensuring compliance with the current limits on the branches and the voltage variation limits at the nodes. They are purchased at a 'capacity price'.

2-Congestion Management Real Time Spot
It is purchased at the offered price (pay as bid) for all execution time intervals and aim to reduce the exploitation of the branches and/or the voltage variation at the nodes. Under the same technical and economic conditions, the resources previously reserved in capacity are selected as a priority.

3-Voltage Control-Capacity Reactive Power (Multi) Year
In the planning phase, the DSO procures regulation capacity of reactive power injection/absorption to maintain the grid voltage set point under normal operating conditions. It is purchased at a 'capacity price'.

Spot
It is purchased at the offered price (pay as bid) for all execution time intervals to maintain the grid voltage set point under normal operating conditions. At the same technical and economic conditions, the resources previously reserved in capacity are selected as a priority.

5-Voltage Control Active Power-in emergency Spot
Active power injection/absorption to maintain the grid voltage set point in emergency operating conditions.

Example of Ancillary Services Procurement
In this section, a scheme that shows the logic of the model is represented. This representation expresses both the possible activation of global and local services procured from DERs on the distribution grid.
Prior to the daily sessions of GLASM, a long-term capacity negotiation is conducted between the DSO and aggregators. This does not have a specific time frame as it can occur at any time of the year. As for the daily ASM sessions, offers and bids are presented on the ComESto platform with details of the power to be activated in each MV and/or LV node. The market manager matches supply and demand within the two market sessions. In the first session offers are selected to meet the DSO bids for non-frequency services. In this case, the check for power flows compatibility is not required, since the compliance with the network constraints is already implicit in the requests of the DSO. The local services involve both the activation of capacity reserved products and not contracted resources. If only one aggregator with a valid capacity contract is able to provide the service, due to the position of its users in the involved DPs, the request of DSO becomes an activation order for it.
Normally the requests for services made by the DSO should be considered to be a priority, unless emergency conditions on the high voltage network are present, both because the exploitation of flexibility resources is a fundamental prerequisite for enabling the connection of DERs on the distribution network and because often they will be requests of activation for services previously reserved as capacity contracts.
In the second market session, the remaining flexibility is offered to the TSO, after the DSO checks whether the offers are compatible with the power flows programmed on its network (validation). The results of the first session may be modified by the second session optimization if: emergency conditions are detected in the HV network and there is a significant aggregation that can effectively contribute to resolve it without endangering the distribution network operations; -redistribution of DERs flexibility does not affect the first optimization more than a predetermined percentage threshold in terms of capacity or economic value.
Once in the GLASM bids and offers have been matched, the selected offers become activation orders for the aggregators, which distribute the power to be activated among their resources using a distribution coefficient (αi) to properly address the capacity of users to be activated. For example, the global service offer in Figure 7 (Off.1) is obtained by the global aggregated capacity (P*, Q*). The aggregator, based on the information it receives in real time from managed resources, allocates to the available resources the overall capacity to be activated using αi. Obviously, the distribution must be done according to the validated program by the DSO in the pre-qualification phase. emergency conditions are detected in the HV network and there is a significant aggregation that can effectively contribute to resolve it without endangering the distribution network operations; -redistribution of DERs flexibility does not affect the first optimization more than a predetermined percentage threshold in terms of capacity or economic value.
Once in the GLASM bids and offers have been matched, the selected offers become activation orders for the aggregators, which distribute the power to be activated among their resources using a distribution coefficient (αi) to properly address the capacity of users to be activated. For example, the global service offer in Figure 7 (Off.1) is obtained by the global aggregated capacity (P*, Q*). The aggregator, based on the information it receives in real time from managed resources, allocates to the available resources the overall capacity to be activated using αi. Obviously, the distribution must be done according to the validated program by the DSO in the pre-qualification phase. Additionally, for local services, the aggregator distributes the power request among the aggregated resources through the distribution coefficient (αi). As an example, the offer for local services in Figure 7 (Off.2) is given by the total aggregated capacity to be activated (P*, Q*). The aggregator, always considering the information it receives in real time from the managed resources, separates the overall request in several smaller orders to be sent to the available resources located within the network section where the service is required.
If the accepted offers of service are not satisfied, the system operators can apply penalties to the service provider (the aggregator) on both the global and local ASM. If an aggregator does not comply with an accepted offer by the TSO on the ASM due to a DSO request for a subsequent operation, the TSO could apply penalties to the DSO unless the DSO request is necessary for an emergency situation on its grid.

Execution Methods of Services
The supplier/aggregator has a flexibility provision agreement with the consumer and a supply agreement with the distribution network operator. The DSO, knowing the potentialities of the flexibility made available by the resources connected to the distribution network, guarantees an adequate remuneration to users who decide to participate in this mechanism. Additionally, for local services, the aggregator distributes the power request among the aggregated resources through the distribution coefficient (αi). As an example, the offer for local services in Figure 7 (Off.2) is given by the total aggregated capacity to be activated (P*, Q*). The aggregator, always considering the information it receives in real time from the managed resources, separates the overall request in several smaller orders to be sent to the available resources located within the network section where the service is required.
If the accepted offers of service are not satisfied, the system operators can apply penalties to the service provider (the aggregator) on both the global and local ASM. If an aggregator does not comply with an accepted offer by the TSO on the ASM due to a DSO request for a subsequent operation, the TSO could apply penalties to the DSO unless the DSO request is necessary for an emergency situation on its grid.

Execution Methods of Services
The supplier/aggregator has a flexibility provision agreement with the consumer and a supply agreement with the distribution network operator. The DSO, knowing the potentialities of the flexibility made available by the resources connected to the distribution network, guarantees an adequate remuneration to users who decide to participate in this mechanism. Figure 8 illustrates the process of using flexibility in the target interaction model. The typical situation is represented by the yellow state of the traffic light, while the red one is the typical situation where an emergency occurs. In the following a description of the process is shown: (1) The grid operator has all relevant information required for forecasting purposes (i.e., network constraints, load profiles, production forecasts). (2) The grid operator carries out forecasts regarding the state of the network, in particular for network sections in which the operator has identified a general flexibility need, using the information above mentioned (1). (3) Based on these forecasts, the network operator determines for each network section an associated color that represent the status. If the traffic light is in the green state (4) the forecasts of the network operator indicate that no adjustment of the expected load/injection is necessary. If the state of the traffic light is green, the retailer/aggregator controls the systems/resources that he manages according to the contract supply conditions. Generation plants can feed energy into the system freely for energy supply. Conversely, if the forecasts of the network operator indicate that there is a potential network constraints violation, then an adjustment of the expected load/injection in the network section is necessary. In this case, the operator activates the yellow phase of the traffic light for the corresponding network and submit a service request. (1) The grid operator has all relevant information required for forecasting purposes (i.e., network constraints, load profiles, production forecasts). (2) The grid operator carries out forecasts regarding the state of the network, in particular for network sections in which the operator has identified a general flexibility need, using the information above mentioned (1). (3) Based on these forecasts, the network operator determines for each network section an associated color that represent the status. If the traffic light is in the green state (4) the forecasts of the network operator indicate that no adjustment of the expected load/injection is necessary. If the state of the traffic light is green, the retailer/aggregator controls the systems/resources that he manages according to the contract supply conditions. Generation plants can feed energy into the system freely for energy supply. Conversely, if the forecasts of the network operator indicate that there is a potential network constraints violation, then an adjustment of the expected load/injection in the network section is necessary. In this case, the operator activates the yellow phase of the traffic light for the corresponding network and submit a service request. The selected aggregator generates a new power scheduling taking into account the adjustment requested by the DSO (6). Then it implements this program by distributing it among the available resources connected to the specific portion of the distribution network, according to an optimal distribution. (7) Therefore, the aggregator sends the signal of the new program to each involved resource (8). The signal is forwarded to the user's control system (nanogrid) (9). The control system (nanogrid) of the user processes the received signal (10) and implements the power schedules adjustment (11). The user measurement system, which is assumed to be a Smart Meter, tracks and provides the measured data for service certification (13).
The meter data are used also for accounting purposes. The accounting is completed The selected aggregator generates a new power scheduling taking into account the adjustment requested by the DSO (6). Then it implements this program by distributing it among the available resources connected to the specific portion of the distribution network, according to an optimal distribution. (7) Therefore, the aggregator sends the signal of the new program to each involved resource (8). The signal is forwarded to the user's con-trol system (nanogrid) (9). The control system (nanogrid) of the user processes the received signal (10) and implements the power schedules adjustment (11). The user measurement system, which is assumed to be a Smart Meter, tracks and provides the measured data for service certification (13).
The meter data are used also for accounting purposes. The accounting is completed on the basis of a time series of values measured on the real load profile (14). In fact, the measured values are useful for certifying the provision of the flexibility service between the aggregator and the distribution (or transmission) network operator (15).

Conclusions
Recent European directives introduced the renewable energy community as a new actor in the electricity market. Its fundamental purpose is to aggregate distributed generation and loads of a small geographical area in order to exchange power among them and provide services to the power system. In this context, a management model of a community of nanogrids, capable of increasing the self-consumption of the community and delivering services to the power system, was proposed in a previous paper [9]. Due to their useful size, energy communities have an impact on the distribution network mainly, so it is necessary to design an appropriate flexibility market to address the problem of congestions in the distribution network and to deliver ancillary services to the power system. In this paper, according to the results of a recent H2020 project on this topic and the EC Directives, a framework that shows interactions between DSOs and Renewable energy communities and that guarantees probability of success is proposed. The framework is based on the wellknown concept of traffic light model and introduces a possible set of services to be used by the DSO.