Advanced Flexibility Market for System Services Based on TSO–DSO Coordination and Usage of Distributed Resources

The high and growing share of renewable sources and the more important role of Distributed Energy Resources (DERs) in the Distribution System (DS) is leading to a need for more efficient coordination of those sources. In future power systems, TSO–DSO coordination will play a key role in providing flexibility services. Lack of proper coordination of sources may lead to congestion in the network or to a lack of possibility to generate or consume energy on a requested level. The crucial aspect is that the TSO–DSO coordination must be based on an active role of all participants: TSO, DSO, generation units and the demand. This paper presents the possible application of the TSO–DSO coordination by providing the flexibility services from DS to the Transmission System (TS). The paper presents the complex optimization of TS, DS and its coordination. The main goal of the paper is to show the possibility of the application of the flexibility market into the current system design. It requires the creation of a new platform, where the offers of the flexibility services could be submitted and then exchanged between entities. The paper shows that the usage of flexibility services may decrease the operational cost of the system, and the DERs providing those services may benefit from an additional source of income.


Introduction
Nowadays, changes in the electricity sector are creating a need for new developments, mainly due to substantial increase of Renewable Energy Sources (RES) generation, but also due to growth in Energy Storage (ES), demand response and demand from the growing sector of electric vehicles. The increase of renewable sources is mainly driven by the European Union target of 32% share of renewable energy [1]. The main issue that arises is variability and uncertainty of the operation of renewable sources and Electric Vehicles (EVs). In the case of variability of renewable energy sources the operator has no possibility to store energy generated simultaneously, whereas in the case of EVs it is possible to manage the load on the level of particular facility or a group of facilities. An example of EVs facility management is presented in [2]. The operation of energy storage and the demand response may be planned and executed with high certainty. A large number of renewable sources and other distributed sources will be located in the distribution grid. With the growth of power generated by renewable sources, the TSO may not be able to plan and balance accurately the operation of the whole network. That is the reason why the distribution network will have to participate in future flexibility services. The large field in novelties will be related to the distribution grid, which will be forced to go through a transformation. The distribution grid is now mainly the sink of the network, where large power plants are the source. Shortly, this paradigm may change, due to growth in power generated within the distribution grid. It may turn out that instead of the transfer of energy from TS to DS, which usually occurs, DS will transfer energy to TS, due to surplus of generation over demand.
The main goal of the future system is to maximize the use of intermittent renewable energy sources, which produce energy only in specific conditions, whereas the large power plants at this time will be able to cover residual demand. When the conditions will be less favorable, then the large power plants will cover most of the demand. At this time the distribution grid is not prepared for the flow in both directions; what is more, most of the lines are not monitored in real-time. This presents a great challenge to maintain and handle the data of thousands of lines and other equipment. It requires a large amount of financial effort and years of well thought out investments. The other issue is an aspect of the operation of the distribution system; there is a need to treat it as an area that can be balanced to some extent. Moreover, there is a need to use flexible resources located in DS, when there is a need from a technical or economical point of view. What is more, now the distribution system is working in a "fit-and-forget" approach [3], which is related to the state in which infrastructure is oversized, to be able to cover peak values of the flow. This approach probably will exist and gain importance in the future, due to an increase in installed power of distributed generation and changes within the power system.
The article is organized as follows: At first, the literature review is presented; the following part presents an introduction of the mathematical formulation of the problem; the next section shows the model identification and case studies. The paper ends with the conclusions followed by appendixes.

Literature Review
The main goal of TSO in TSO-DSO coordination is to ensure balance and to manage congestion. The main application of the flexibility services may be found in voltage and frequency control, as well as in congestion management [4]. There are services in TS such as spinning reserve that can provide a large amount of energy in a short period. There are some other services as flexible ramping products, which can increase or decrease the power to some extent. The flexibility at the TSO level is usually based on large generators, although the flexibility can be achieved by usage of renewable sources, aggregators, Virtual Power Plants (VPPs) and demand side response. Those sources can adapt to TSOs' flexibility needs; nonetheless frequently their costs are higher than large generators. The large customer may react to the price signals sent by TSO and reduce or increase its demand, while there is a space for such an action. The other solution is to perform a curtailment of the renewable sources; however, it is mostly used in menacing situations that may threaten system security [5]. Nonetheless, the future power system will be facing the need for curtailment more frequently.
The DSOs own the same types of flexible resources, although they are smaller in power and their number is larger. The main services that may be provided by DERs are voltage control and local congestion management [4]. DERs from DS may be curtailed to decrease the generation from DS; thus, it will allow to smooth the profile on the TS-DS interface. The largest incentive to DERs and also to demand side response will be to implement dynamic tariffs as an impulse to adapt to system needs. This will encourage a change in the demand based on the price signals [5]. There are multiple issues connected with the integration of Distributed Resources (DRs) into the system: The challenges of charging and discharging electric vehicles [6], finding an appropriate optimization technique in wind farms [7], finding an adequate optimization technique in EVs [2] or coordination of wind energy and pumped storage power plants [8]. Contracting strategies of renewable sources and hybrid power sources are strongly investigated in the research [9]. DSOs may be responsible for optimization and managing congestion in their grid; additionally, they may provide some additional services to TSO. This may include the flexibility services, ancillary services, balancing, etc.
There are ideas to apply the active generation from TS in the congestion management by the concept of traffic lights [3,10]. Reference [11] proposed to assign each state from the traffic light concept to the proper state of congestion. The green state is associated with congestion pricing, the yellow state with redispatching and the red one with the curtailment either of generators or loads. The green state embraces results from auctioning process, which can relieve the congestion. If not, the TSO applies the redispatch and if the issue is still present, the TSO is forced to curtail the sources. The amount of redispatch performed by TSO depends on the market transactions, and the market design connected with congestion pricing and also with the stage of grid development. The same approach may be applied in DS; it may consist of a similar pricing system and curtailment of the sources in DS. Shortly, one of the actions taken by DSO may be the prequalification and validation of the flexibility services. The prequalification means the verification whether any of the constraints are not violated in DS. There is an interesting approach, in which DSO may in the future consist of many microgrid structures, which will be controlled independently and the DSO will take care of the coordination of interconnected DS grids [12].
Usage of services from active sources has to be properly managed without creating additional congestion in the distribution grid. Due to that, the verification process has to be performed, in which DSO will confirm which services and to what extent they can be performed without violating any of the constraints. Flexibility services that can be offered for TSO will be aggregated. In Particular, possibility of curtailment of small renewable generation or possible decrease in demands of consumers will be accumulated in an offer. The impact of services may differ in significance due to the amount of power produced by the particular power plant. The solution to this may be the aggregation of a large number of small resources into more significant offers. This is one of the main prospects, which will have the highest chance to be successful in TSO-DSO coordination. TSO operates on large volumes of energy; that is why it is important to aggregate power from distribution system offers. The other advantage to using aggregated power in TSO-DSO coordination is that the renewable sources may not be properly predicted and such risk can be mitigated by aggregation. Then it may be possible to use the other source with higher predictability such as energy storage or demand response, which can be easily planned with high accuracy. Most TSO networks are meshed, whereas most DSO networks are radial. Due to that, they need to be described by different power flow methods. The meshed networks tend to be more reliable, whereas in DS, due to its radial connections, outages may appear [13].
The main challenge which confronted by DSO is the reinforcement of the network and equipping it with real-time measurement devices. The other challenge for the DSO may be the prequalification process, which if applied may be computationally intensive. DSOs will have to move investments into smart grids, which will be fully adapted to bidirectional flow. DSOs will have to perform a more active operation in their system. The key question is how to properly integrate the flexible sources within the system. Potential solutions may be found in [10], where the integrated scheme of TSO-DSO coordination is presented as Active System Management (ASM). Nowadays, the DSO has to integrate the resources in its network, whereas in the future it will have to interconnect them as well as manage their operation. An important part will be played by the aggregation of resources by an aggregator or in VPP [14,15]. The main goal of the future flexibility market will be to provide a power profile to TSO, with deviations in plus and minus, given by aggregators and resources in DS.
TSO-DSO coordination may be performed in different concepts; the probable schemes of this coordination, resulting from [16], are presented in detail below. It divides the responsibility between TSO and DSO and creates a few kinds of markets. Some projects, taken into consideration, give new approaches to the TSO-DSO coordination. There are some projects taking place on how to properly integrate the flexible sources within the system. There is a concept called "web of cells", which is an approach not based on the existing architecture. It is a division of the area into smaller ones, to ensure the maximization of usage of distributed sources locally [10]. The other project, which is based on existing systems and real-time monitoring is "IDE4L". It is based on creating a common platform, which can be easily connected to already existing systems. Another project, LINK-Solution, focuses on creating the smart power grid in which every component connected to the grid may be modeled.
SmartNet is one of the most promising projects, due to having coordination between TSO-DSO on two levels: Technical and market. Additionally, it integrates distributed resources in one platform. It proposes a few different coordination schemes between TSO and DSO, which may be implemented in the ancillary services, but it may be expanded further into balancing and the energy market. There are centralized ancillary services (ASs), shared balancing responsibility, common TSO-DSO, local AS market and integrated flexibility market model [16]. Centralized ancillary services is a model in which the TSO is active and the DSO is passive. It is a common market, in which only TSO buys the energy from resources from the DS and is the one that is operating the whole system. The DSO role is limited only to provide the prequalification of the power flow within the grid. The shared balancing market is similar to the previous scheme, although the main difference is that both markets are operated separately and sources from DS cannot be used in the general market. The responsibility of balancing the grid rests on a particular participant. The role of the operators is to balance their grids. The Common TSO-DSO AS market model is one common market in TS and DS, in which TSO and DSO operate simultaneously. The model takes into consideration constraints of the whole transmission system, as well as distribution constraints. The local AS market model consists of two separate markets, one local operated by DSO, in which DSO has the priority to use resources from DS. After that, the rest of the offers not applied in the market are transferred to the general market operated by TSO. The integrated flexibility model is a common market for TSO and DSO. What is more, the non-regulated parties will have a chance to participate in the flexibility market. In this scheme, there is a need to provide an independent market operator to ensure neutrality [4]. Detailed descriptions of the different coordination schemes and their advantages and disadvantages may be found in [4,17,18]. The practical models of the following coordination schemes may be found in [19][20][21]. The other view on the flexibility market may be found in [22], where the coordination between three parties is taken into consideration: TSO-DSO-retailer. Reference [23] considers the comparison of only two schemes, TSO central ancillary services and DSO local services market. The conclusions are drawn into more potential to maximize the social welfare of DSO local services market over TSO central ancillary services.
The coordination between parties in the power system may implement a new way to manage congestion. Instead of using costly redispatch and producing power in a power plant with a higher cost, there is an idea to use DERs, at a lower cost. However, it may occur that for some periods or areas the redispatch will be the cheapest solution. After the prequalification, there is a need to collect the offers, sort them in the merit order and choose the cost-effective ones, which will manage congestion. The framework of the congestion management by TSO and DSO is shown in detail in [10]. Prequalification is one of the first steps in the TSO-DSO coordination process described in papers, although the scheme presented in this research does not require the prequalification of the units. While it is very important to check if the offers accepted do not violate any constraints in the network.
There are various solution methods regarding the modeling of TSO and DSO networks, starting from linear based models, through non-linear, mixed integer and mixed integer nonlinear programming ending with quadratic programming. However, the most convenient and appropriate method may be mixed integer linear programming due to the simplicity and convergence [14]. Another subject is consideration of reactive power in the model of the DS and another one is the decision on how to model the power flow. There are some models that resolve the issue of TSO-DSO coordination using AC optimal power flow as in [24,25]. To reflect the real power flow the most appropriate method would be to use it in modeling AC power flow on two levels. However, simplified DC power flow with losses was established as equally efficient in TS [26]. An interesting approach to TSO-DSO coordination is shown in [27], although it may be extended with power flow in DS and flexible choice of offers on the interface TS-DS. An interesting approach is shown in [28], which considers two systems, DSO and TSO with real modeling of the system including the full power flow in both systems. The DC power flow is taken into consideration in both systems. Regarding the offers from DERs or generation sources, reference [24] used a bid function, whereas reference [25] presented the linear cost function for thermal generators. As has been previously presented, reference [26] uses set of fixed profiles for 24 h differentiated by cost. The current paper presents another approach in which the offers are established separately for periods. The model applied in the article considers three binary approaches, according to [29,30]; there are some two-binary [31] or single binary [32] approaches, although the three-binary approach was applied.
The key point of this paper is the strategy for coordination of operation between entities TSO and DSO. The current approach is that TSO maintains the sources from its grid, whereas resources from DS are not coordinated and do not provide any services to the operator, as shown in Figure 1a in red, green and white. Their output is based on the dispatch resulting from the day ahead market, although DERs do not participate in balancing market and the large ones may be curtailed. The main rule is that the TSO maintains TS by resources connected to its grid and the other ones are visible to TS as a constant profile in the TS-DS interface. This paper establishes a new approach to coordination of sources from DS for purposes of TS. There is a need for proper coordination between entities to make this feasible and economically justified. The coordination of sources by TSO not only embraces the sources from TS but also allows using resources from DS. Its purpose is to decrease the operation costs of the power system, by extending the range of offers. The new approach of TSO-DSO coordination is given in Figure 1b, the usage of offers is lower and distributed among the most cost-efficient ones.
The concept of taking into consideration the TS and DS to show the coordination in complete form is applied in the article. The network constraints are considered in TS as well as in DS. The concept includes variable resources (DERs) in DS and other resources (RES and ES) in TS. The networks include renewable generation (solar and wind), other sources (like biogas power plants), ES and active and passive load. In the article, TS is modeled by DC power flow similarly to [29,30] extended by losses, whereas DS is modeled by AC power flow according to [33].
The main advantages of this paper are: • Complete formulation of the coordination concept. • Representation of networks in detailed form with constraints included. • Presentation of offers for periods separately, instead of a fixed profile for the whole planning period.
The novelties in comparison to other studies are: • Introduction of the five phase cycle of coordination between TSO and DSO instead of prequalification process. The cycle verifies the possibility of fulfilment of already chosen offers. • The formulation of energy storage with initial dispatch included

Transmission System Model
The model presented below allows to define commitment and dispatch of generation units connected directly to TS. It is based on initial load profiles, offers of generation units, Active Industrial Loads (AILs) and ES. TSO model for unit commitment and economic dispatch is based on [29,30] in terms of unit commitment, power system and thermal unit constraints.

Unit Commitment and Economic Dispatch of Conventional Sources
An essential element of the model is the formulation of constraints for large centrally dispatched units, presented in Equations (1)- (10). (1) Equation (1) is a basic binary constraint for a three-binary formulation with on and off states, turning on and turning off variables. Next, Equation (2) describes the maximal power constraint, which considers the reserve R t,n and states of the unit U t,n , V t,n , W t,n . Equation (3) determines minimal power constraint for unit with consideration of reserve.
Equation (4) restricts a start up of the unit, if the unit was in operation in the last tu n hours before the planned start up. Correspondingly, the down time of unit td n is specified by Equation (5). P t,n + R t,n − P t−1,n ≥ p ru n (6) − P t,n + P t−1,n ≥ p rd n (7) Equations (6) and (7) define, respectively, ramp up and ramp down of large units. Equation (8) determines the amount of energy generated during starts and shutdowns of large units. Finally, Equations (9) and (10) present variables of hot and cold starts of the unit to allow differentiation between them.

Generation from Other Resources in TS
Additionally, the TS model consists of renewable sources: Wind and solar. The power output of both is defined by Equation (11). Equation uses variables CUR PV t,n and CUR W ND t,n to allow curtailment of those resources. Equation (12) defines the limits of maximal and minimal curtailment.
The model may use active industrial load, which is directly connected to transmission grid. Loads may be reduced by the certain factor, which must be compensated for in other periods of time. The limits of maximal reduction and increase are presented in Equations (13) and (14). Equation (15) determines the final profile of the industrial load connected in the node, on the basis of profile, installed power and activation of load shift. The whole reduction of the load must be covered by load increase. In other words, the whole shifted load is compensated for in other periods of time. It is implemented by usage of Equation (16).
The Energy Storage System (ESS) in TS is described in a similar manner as in [15,27,[34][35][36]. Firstly, Equation (17) determines the output of energy storage in a time period in a particular node. The State Of Charge (SOC) is limited by the minimum and maximum values, as shown in Equation (18). Equation (19) defines SOC of a particular energy storage system on the basis of the previous state, operation of discharging and charging in a considered period of time. At this point, it is important to emphasize that the model allows to define the energy es e n and power es p n of particular ESSs separately. Equations (20)-(22) provide a constraint that only one of the operation modes is possible per one period. In other words ESS may either charge or discharge in one period. Decision variables in (20) are restricted to binaries and the equation determines that only one of the variables may be a non-zero.
ES t,n = (es p n · P DIS t,n − es p n · P CH A t,n ) (17) soc min n ≤ SOC t,n ≤ soc max n SOC t,n · es e n = SOC t−1,n · es e n − es p n · P DIS t,n es e f n + es p n · P CH A t,n · es e f n

Power Flow in TS
The power flow is described based on [26] with the extension of power losses. It is a simplification of AC power flow represented by DC power flow with linearized losses in lines. Equation (23) (28) and (29) allow to calculate nodal angle difference divided into segments for linearization purposes.
Equation (30) determines linearized losses in line and Equation (31) allows to calculate the sum of losses from lines connected to the considered node.
Finally, the section of power flow is finished with cross border exchange. Equation (32) presents inflows and outflows on the basis of a given profile and declared power of interconnection. It results in a simple formulation, which corresponds to the real case, where day-ahead market cross boarder exchange may be considered as a parameter of balancing market realized by TSO. cb t,n = cb ex t,n · cb cap n (32)

Nodal Balance of Production and Consumption
Equation (33)  (p min n · U t,n + P t,n + PST t,n ) + RES t,n + ES t,n + NSE t,n + cb t,n = d t,n + AIL t,n + ODSO n,t + NET t,n + NL t,n

Objective Function and Its Components
Conventional unit cost is based on no-load costs, costs of starts depending on the state of the unit, generation cost and CO 2 allowance price component. The formulation is presented in Equation (34).
C Conv t,n = U t,n · c nl n + C csu n · SI t,n,1 + C hsu n · SI t,n,2 + (U t,n · p min n + P t,n ) · (c gen n + pri CO2 ) (34) In the model RES may be curtailed; however, it is connected with an additional cost of curtailment. Equation (35) determines cost of curtailment on the basis of amount of power curtailed and price, equally for both technologies, photovoltaic (PV) and wind generation.
(wnd t,q · wnd loc n,q · p wnd n · c curwnd n · CUR W ND t,n ) (35) Component of energy storage in the objective function covers costs of charging and its reduction by power injected into the TS during discharging; this formulation is presented in Equation (36).
In the case of active industrial loads, TSO covers costs of load shift. Thus, in Equation (37) power is calculated twice; it is multiplied by the price and divided by two.
Equation (38) determines the cost of non-served energy. Moreover, this component gives flexibility to the model calculation. If the input parameters are chosen appropriately, then NSE t,n is equal to zero.
Finally, Equation (39) defines the sum of all components-total cost. The objective function is minimized.

DS Model
This section describes the DS model. It considers not only active power but also reactive power to better reflect real power flow in DS. It is delivered based on DistFlow methodology, applied in [33]. DistFlow methodology is widely applied in problems describing power flow in radial networks of DS [37,38].

Point of Common Coupling (PCC)
The equations below describe the limits of energy transferred between TS and DS in both directions. Equations (40) and (41) create limits for solely active and reactive power, respectively. Then Equations (42) and (43) cover areas, where active and reactive power is transmitted; reactive power is limited to a certain level according to the needed level of active power.

Distributed Generation (DG)
Firstly, the power output of DG is defined by the modification of initial self-dispatch by accepted increase and decrease offers; it is realized with Equation (44). Constraints for active and reactive power are constructed in the same manner as in the case of PCC. Those formulations of generation limits are defined for active and reactive power, respectively, in Equations (45) and (46). Additionally, mixed generation of both active and reactive power is determined in Equation (47). P DG t,n = pow n,t · p max n + DG P t,n − DG N t,n p min n · U t,n ≤ P DG t,n ≤ p max n · U t,n − p max n · U t,n ≤ Q DG t,n ≤ p max n · U t,n − o · p max n + P DG t,n ≤ Q DG t,n ≤ o · p max n − P DG t,n

Active Demand of Load
Demands are divided into commercial, residential and industrial types. All of the equations given below to commercial load can be easily adapted to residential or industrial type. Equation (48) exemplifies final demand of commercial loads, which is modified by accepted offers: COM P t,n and COM N t,n . Equations (49) and (50) describe, respectively, maximal level of demand shift and equality between increased and decreased demand. Reactive power of demand is calculated by using constant power factor, as in Equation (51). The total amount of power shifted in the commercial demand is limited by Equation (52). Industrial and residential loads are described in the same manner; thus, they are not described in this section.
COM P t,n ≤ co cr ; COM N t,n ≤ co cr (49)

Generation from Other DERs
Generation from DERs embraces PV, wind generation and ES, which will be described below.
• Photovoltaic generation PV t,n = pv t · p pv n · (1 − CUR PV t,n ) (53) The power output of PV is calculated based on generation profile, installed power and activated curtailment, as presented in Equation (53). Maximal curtailment activation is limited by Equation (54).
• Wind generation Equations that describe wind generation are shown as Equations (55) and (56). The first one differs from the formulation for PV, whereas the second one is identical. The difference between the generation form of PV and wind generation has the source in the usage of multiple wind generation profiles. Wind generation profile allows to differentiate generation between a few locations. In the case of PV, the generation profile is identical.

• Energy Storage
Firstly, in modelling energy storage Equations (57) and (58)  soc min n ≤ SOC t,n ≤ soc max n (57) The equations below differ from the formulation presented for the TS model. The main difference is in the usage of ini dis t,n and ini cha t,n , which defines a level of initial operation plan of ESS. The initial plan may be considered as a result of the day ahead market, which may be treated as a starting point for this model. Moreover, this formulation is original and is presented for the first time in this publication. None of the considered references presented a formulation with an initial state and binary restriction of charge and discharge. Details and advantages of this formulation are presented in Appendix A. Equation (62)  ES t,n = es p n · (P DIS t,n + ini dis t,n ) − es p n · (P CH A t,n + ini cha t,n ) SOC t,n · es e n = SOC t−1,n · es e n − es p n · P DIS t,n es e f + es p n · P CH A t,n · es e f + ini chat,n · es p n · es e f − ini dis t,n · es p n es e f (63) ini cha t,n + P CH A t,n − P DIS t,b ≤ CH A B t,n + ini dis t,n NET t,n = L ∑ l=1 (a n,l · P L l,t ) − o · f low − P L l,t ≤ Q L l,t ≤ o · f low + P L l,t (VNQ t,n · a n,l ) = 2 · (r · P L l,t + x · Q L l,t )

Balance
The consecutive section defines balance in nodes for active and reactive power separately. The active power balance in Equation (74) takes into account all resources available in the network, demands of load and inflows or outflows in a particular node. Equation (75) provides a reactive power balance; it is similar to active power balance excluding wind generation and PV generation, which in this concept do not contribute to reactive power. Both equations are presented in general form, where P PCC and Q PCC are not presented; thus, those are taken into account only for one node for each DS.
PV t,n + W I ND t,n + P DG t,n + ES t,n + NSE t,n = DEM t,n + NET t,n (74)

Objective Function
The section below describes components of the objective function and its final form. Firstly, the cost of distributed generation flexibility services is defined in Equation (76). The cost is defined as the cost of activation of flexibility service.
C DG t,n = DG P t,n · c pdg + DG Nt,n · c ndg (76) Then, Equation (77) exemplifies the cost of flexibility services provided by active loads. Components are divided into sums for each type of load. The price of flexibility provided by loads is differentiated according to load type; price is defined as the cost of load shift between considered periods. C DEM n,t = p com n · com t · (COM N t,n + COM P t,n ) + p ind n · ind t · (IND N t,n + I ND P t,n ) + p res n · res t · (RES N t,n + RES P t,n ) (77) The cost of curtailment has two components; the first corresponds with PV curtailment and the second with wind generation curtailment. The total cost of curtailment for both items is shown in Equation (78). The cost of curtailment for both PV and wind generation is defined as a share of day ahead market price, which results in a minor reduction of income for RES in the case of provision of flexibility services. C Curt t,n = pv t · p pv n · c cur · pri t · CUR PV t,n + Q ∑ q=1 (wnd t,q · wnd loc n,q · p wnd n · c cur · pri t · CUR W ND t,n ) The cost of flexibility services provided by ESS is presented in Equation (79). Similar to the cost of services provided by DG, ESSs are paid for when energy is activated concerning an offer in the flexibility market.
C ES t,n = c pes · es p n · P DIS t,n + c nes · es p n · P CH A t,n The model takes into account the possibility of not served energy, which should not be present in the normal state. Equations (80) and (81) define the cost of not served energy regarding active and reactive power.
C QNSE t,n = Q NSE t,n · c qnse (81) Equation (82) determines the objective function as the sum of previously presented components. The objective function is minimized to obtain minimal cost of operation.
(C DG t,n + C DEM t,n + C Curt t,n + C ES t,n + C NSE t,n + C QNSE t,n ) (82)

TSO-DSO Coordination
The TSO-DSO coordination introduced in this paper embraces the usage of distributed sources in DS. The proposed balancing market is extended by resources from DS or, in other words, it presents the idea of a future flexibility market. Advancement in the energy market requires tight coordination and data exchange at every step due to mutual relations between parties involved and dependencies between participants. The proposed design of a flexibility market with a balancing market included is shown in Figure 2. A more detailed view of the first three steps is shown in Figure 3. All stages from Figure 3 correspond with the ones shown before. Step 2c in Figure 3 was not included previously,since currently it is already a part of the balancing market. Offers and already contracted outputs from LDUs are crucial for balancing the market since those are the core that allows to balance the demand in the power system. In the first phase, the initial point of operation and offers are collected from DERs by DSO. The self-dispatch of DERs is created on the grounds of the day ahead market or other contracts. DERs send possible offers of increase or decrease regarding their capabilities for flexibility offer.
The second stage is focused on power flow in DS. Based on the information from DERs, DSO optimizes network operation with sources located in DS. Currently, this is limited only to small corrective actions; however, in the future with high penetration of RES such an action will play a key role in grid management. DERs may have the possibility to increase energy produced or decrease the generation in the flexibility market. The values of available power possible to be offered as flexibility may be used by DSO for DS management or by TSO for purposes of congestion management or optimization of energy cost in TS.
The general equations expressing the possibility to modify the actual generation level are presented below. Equation (83) defines maximal power that a source may offer for increase; Equation (84) determines the power to decrease the output.
P O f f d = P output t,n − p min n (84) The third stage embraces the TSO model balancing market, where offers of LDUs are corrected to provide electricity to the final user with affordable price and without violating network constraints. Moreover, the model takes into consideration offers collected by DSO. The TSO model optimizes resources in TS based on offers submitted by them and in DS based on offers collected and aggregated by DSO. The variable of acceptance (1) or rejection (0) of offer V o f f i is introduced. The Equation (85) of cost formulation is presented below.
The TSO role is to choose offers of increase or decrease, which will reduce total cost of system operation. The acceptance is multiplied by the power offered and their cost, resulting in components of, respectively, balance and objective function. The accepted offers in Figure 4 are presented in brighter colors on the chart, green for increase and red for reduction of generation. Furthermore, offers chosen by TSO are named as "requested offers" from DSO by TSO. The results of the third phase cover preparation of the schedule with requested-accepted offers and exchange this data with DSOs for final verification.
In some instances, there is a need to extend the TSO model by equations to reflect a better modelled environment. Regarding the possible shift provided by the active load, there is an added equality constraint, where the decrease of demand has to be equal to the increase of demand in another period of time. Equation (86) presents this example. It is based on an active industrial load.
A more detailed view of the two last steps is shown in the Figure 4. Both phases continue the coordination and a detailed description of the phases is presented below. The fourth stage includes the verification process by DSO. The operator performs power flow studies considering requested offers by TSO. The requested offers from TSO are considered in the model in the equations, which verifies whether the requested value (p req t ) may be realized and whether it will not result in violation of the network constraints. An example of an equation is presented below. The equation ensures that resource type i will provide a volume that is greater or equal to the already planned values (p used t ), increased by the additional TSO's request. Supplementary variable X t allows to not satisfy the criteria only if network constraints will be violated by the chosen offer.
The necessity of such verification increases due to the model formulation. Initially, DSO collects offers from DERs and eventually uses them to solve network constraints within DS. DSO passes offers to TSO without feasibility studies. Prequalification is computationally intensive or impossible to analyze in all possible options of offers potentially accepted by TSO. However, DSO verifies feasibility on the stage, where the request is known and only the feasibility of the chosen offers is confirmed. In other words, it is needed since in the first step DSO sends all the possible use of the resources without checking whether the offers do not violate the network constraints. Therefore this verification needs to be performed in the third step. Before the next phase, the verified offers with the final profile at PCC are sent back to TSO. The fifth stage embraces the final plan optimized by TSO including offers that are verified and able to be applied. The final plan is distributed among interested agents.
The pseudocode of the whole concept is presented in Figure 5 for clarification purposes. The code reflects phases presented above on charts.

Model Identification
The model consists of simple TS and three different DSs, which are connected to the third, fifth and eighth nodes of the transmission network. For simplification purposes, TS and DSs are analyzed on the single voltage level for each one. Both systems are designed straightforwardly and thus are relatively small; however, their size is sufficiently large to analyze the operation and verify the presented coordination scheme.

Transmission System Model
The purpose of the following subsection is to describe the TS used in the case studies. The system is presented in Figure 6. It consists of eight nodes; in each of them LDU and load are located. The load type for each node is defined in Appendix B.1. In the majority of nodes, generation facilities-wind generation, PV and energy storage-are located, beside typical distributed dispatchable generation and load. In two nodes large active industrial loads are located. The system is built out of twelve lines, which create multiple loops within the network. In line with the previous section, the system is based on a single voltage level.

Distribution System Model
In the following subsection three different DSs are presented in Figure 7. Each of the DSs consists of seven nodes and six lines, but in different arrangement. The first DS is connected to third node of the TS, the second DS is connected to fifth node of the TS and the third DS is connected to the eighth node of the TS. The data regarding parameters of sources, demand and network are presented in Appendix B.2. In the DSs the following units are considered: Demand, active demand, DG, PV, wind energy generation and ES.

Case Studies
The case studies are divided into two parts: Comparison of business as usual (S1) and the operation with flexibility market offers (S2). The second part embraces comparison between the same scenarios (S3-business as usual; S4-flexibility market) differing in the share of renewable energy. RESs are tripled in installed power when compared to initial scenarios S1 and S2.
The concept requires two platforms of data exchange: First to collect and exchange data between DSOs and DERs located in DS and second to exchange data between TSO and DSO. The needs in the area of software and hardware are to be clarified on further steps of implementation. Authors suggest that DSO should coordinate the first platform, whereas the second should be managed by TSO.

Comparison of Different Scenarios S1 and S2
The first part of case studies embraces comparison between business as usual and operation with flexibility services provided by DR. The decrease of system operation costs in scenario S2 compared to business as usual is −0.32%. This value added was obtained by the use of three DSs connected to TS. The important thing is that those networks represent less than 10% of the total demand in the network. If the share of active market participants will be more significant, then higher benefits of the flexibility market should be expected.
The income of resources participating in flexibility services was investigated. The increase of income in distributed generation, which provides flexibility services, grew by 3.87% in comparison to the income in business as usual. In the case of ES, the income was increased by 4.96%. To conclude, the resources may benefit from the existence of an additional market, in parallel to income from the energy market.
The distribution of the income of DG in DS 1 regarding the regular operation (initial income from energy market) and the final one including income from flexibility market is shown in Figure 8. The income of DG is computed according to Equation (76). The usage of the flexibility offers influences the distribution of income by increasing it in high demand periods when the price of DERs is lower than the price of LDU.  Table 1 presents the parameters of energy transferred in PCC after the third and fifth steps. It presents four parameters of profile: Sum of energy transferred and average, minimum and maximum values for each DS. The sum of energy is reduced in the final flow for each network: −9.65% in the case of DS1, −10.68% in the case of DS2 and −84.68% in the case of DS3. The exchange is reduced by DERs located in DS. Generally, resources generate more in peak hours to reduce the cost of the whole network. The maximum flow of energy between TS and DS decreased, similarly to the average. In the case of minimal flow, the index grew. The positive sign of flow in PCC means that the energy is transferred from TS to DS, whereas the negative sign of flow in PCC means the opposite transfer. The chart in Figure 9 shows the profile of exchange in PCC for DS 3 in a 24 h period. It presents that the values differ the most when demand or price are on the extreme points. In other words, the model smooths exchange between TS and DS, the peaks are shaved and the valleys are filled. The following graph Figure 10 presents the value of the energy transmitted from TSO to demand, including active DS. The sum of the profile decreased by 0.93% in the scenario using flexibility services S2 in comparison to scenario S1. It can be concluded that the distribution systems in the future will be able to smooth the profile and reduce the exchange with TSO. Figure 10. Total demand, including DS in scenario S1 (business as usual) and S2 (flexibility market).
The other comparison embraces the operation of ES in node 6 in DS 1, as shown in Figure 11. It shows the initial energy plan, which is performed by ES initially on the base of its participation in the energy market. Additionally, it presents the operation plan with flexibility activation from DSO, which is the result of the third step in scenario S2 using flexibility services. Finally, it shows the plan after the fifth step in the same scenario. The ES operation plan shows the change in ES operation, taking into consideration firstly the activation of flexibility from DSO and secondly services activation from both TSO and DSO. Figure 11. Energy of ES in node 6 in DS 1.

Analysis of Influence in the Case of High Renewable Installed Power
This section encompasses the comparison of the base scenario shown before and the scenario of probable future power systems with high RES penetration. This scenario will consist of an increased amount of renewable energy along with an increased amount of ES. The scenario takes into consideration tripled power of RES and ES. In scenario S4, the whole system costs are decreased by 3.32% in comparison with using a business as usual approach. The overview of four scenarios is presented below in Table 2. The first scenarios, S1 and S2, involve the base case regarding power in renewable sources, whereas scenarios S3 and S4 involve an increased amount of renewable energy. Due to the different amount of installed power of renewable energy sources, the pair of scenarios S1 and S2 should not be compared directly with pair S3 and S4. Scenario S1 shows the results of business as usual, similarly to scenario S3, whereas scenarios S2 and S4 present the cases based on flexibility services offered in both networks.

Conclusions
Future power systems consisting of a large number of renewable sources and DERs will need strong TSO-DSO cooperation to provide better utilization of those sources and lower operation cost of the network with flexibility services. TSO-DSO coordination will play a key role in system operation and congestion management in future power systems.
Therefore, the paper presented the framework of TSO-DSO coordination, which will be focused on the creation and usage of the flexibility market. To efficiently use renewable sources and DERs from DS, it will be necessary to provide flexibility offers from those sources that can be possibly used for TSO and DSO purposes. The paper introduced the entire optimization of the TSO system, the DSO system and its coordination. The main goal of the paper was to show the possibility of application of the flexibility market into the existing system and a comparison between them.
The case studies presented that TSO-DSO coordination decreased the operational costs of the whole system in comparison to business as usual-power system management system using corrective measures. The paper showed that this coordination brings benefits to the sources that offer their services in a flexibility market, in the form of an additional income. Due to the design of the coordination, the offers are used only if those are more beneficial than conventional corrective measures in the TS network. The case studies demonstrated that, using flexibility services, the transfer from TS to DS is reduced. On account of that, it can be concluded that in the future DS will be able to smooth the profile on the TS-DS interface and reduce the exchange with TS, by reason of increased usage of flexibility services. Finally, the study presented that the flexibility services may decrease system operation cost, especially if the system has a high share of RES.
The next steps of the research may cover areas such as different pricing mechanisms and the influence of the evolution of energy mix on the future flexibility of the system and an extended analysis of different scenarios of network development. Sum of losses in lines connected to the node n PST t,n Power from starts and shutdowns NSE t,n Non-served active energy P t,n Power output of unit n in t above p min R t,n Reserve provided by unit SI t,n,s Startup type of unit depending on unit state s ODSO t,n Distribution system profile C Conv t,n Cost of conventional units C Curt t,n Cost of curtailment of units C ES t,n Cost of energy storage C AL t,n Cost of active load C NSE t,n Cost of non-served energy P PCC t Active power from PCC Q PCC t Reactive power from PCC P DG t,n Active power output from dispatchable generation Q DG t,n Reactive power output from dispatchable generation DG N t,n Active power of DG decrease DG P t,n Active power of DG increase COM P t,n Commercial demand increase COM N t,n Commercial demand decrease I ND P t,n Industrial demand increase I ND N t,n Industrial demand decrease RES P t,n Residential demand increase RES N t,n Residential demand decrease COM t,n Final active power in commercial demand Q COM t,n Final reactive power in commercial demand PV t,n Power output of PV W I ND t,n Power output of wind generation Q ES t,n Reactive power of ES P L l,t Active power in line Q L l,t Reactive power in line QET t,n Net reactive power flow for node V NQ t,n Squared nodal voltage DEM t,n Demand Q NSE t,n Non-served reactive energy Q DEM t,n Reactive power of demand C QNSE t,n Cost of non-served reactive energy Optimization models frequently define operation of the ES as a variable without any initial conditions, such as a result of energy market cleared before.
ini dis t,n + P DIS t,n − P CH A t,b ≤ DIS B t,n + ini cha t,n (A2) ini cha t,n + P CH A t,n − P DIS t,b ≤ CH A B t,n + ini dis t,n (A3) The equations of the classical formulation of the ES model are presented in the main text (in Equations (20)-(22)). They are used to restrict charge or discharge in the same period using binary variables. This article provides a novel alternative approach presented in Equations (A1)-(A3); it allows to incorporate the initial operation of ESS. Figure A1 presents some of the possible options of the flexibility market influence on ESS. Points below describes some of them: • The second period describes the initial dispatch assumed for maximal available power of discharge. The flexibility offer covers the whole range up to the maximal power of charging, but opposite offers are not allowed. Since the offer is not activated, initial dispatch becomes the final operation point. • In the fourth cycle the plan according to self-dispatch was to discharge partially; due to significant flexibility offer acceptation, ESS is moved to charge area. • The sixth stage provides the ESS state, which is planned to charge with maximal power. Due to accepted offers, the operation point is moved to full discharge. In this period solely the flexibility offer of generation reduction and discharge was available. • The eighth state shows only flexibility activation in charging without any initial dispatch. • In period nine the planned initial dispatch was increased by the accepted flexibility offer in the discharge direction.
An assumption made in other models results in a sub-optimal representation of ESSs since those initially set create income on the basis of price arbitrage. Simplification used in TS results in insignificant misconception since balancing market defines the commitment and dispatch in optimization. Novel formulation presented allows to incorporate the initial state of ESS, which is a result of day ahead market or other transactions performed before flexibility market operation. In the authors' point of view, it is important especially in the case of DS, where flexibility market will provide small corrective actions.

Appendix B. Parameters and Constants
This appendix presents data used in model verification-simulations. All data are presented for the base case. The first part describes TS; the second describes DS.       Table A11. Table representing the incidence matrix of the network in different DSs a n,l .