A New Management Method for Reliable Peer-to-Peer Energy Sharing in Power Distribution Systems

The current expansion of renewable energies, restructuring in power systems, and high tendency to preserve the privacy of energy customers could lead to significant changes in distribution systems. Accordingly, studies on local markets have introduced a suitable framework for energy trading known as the Peer-to-Peer (P2P) market in distribution systems. Several research works have been done on the P2P market modeling and optimization in recent years. This paper aims to develop an appropriate P2P market framework in which the distribution system operator (DSO) can rerun the P2P market and maneuver in the case of the network failure. Respectively, in case of any grid failure, the P2P market can be adjusted according to new conditions of the grid, which is not studied in the previously developed methodologies. In addition to enabling the P2P framework to be usable when a network failure occurs in the system, this paper proposes a reliability cost model associated with participated sellers in the P2P market, which enables buyers to consider the reliability of the sellers in their decisions. Consequently, the developed scheme facilitates the reliable operation of distribution systems in a distributed manner. Finally, the developed structure is simulated on a 33-bus test system to analyze its effectiveness in operating the system.

The probability of the UMA's curtailment in scenario k considered by buyer DMA j. τ cur ij,k Time duration of seller DMA i's curtailment in scenario k considered by buyer DMA j. τ cur uj,k Time duration of the UMA's curtailment in scenario k considered by buyer DMA j.T year Time duration of one year (its unit should be similar to t). a j , b j , c j Damage coefficients of buyer DMA j.N cur i Number of curtailments for seller i in the duration of the last year.N cur uma Number of curtailments for the UMA in the duration of the last year.

I. INTRODUCTION A. BACKGROUND
Nowadays, the high penetration of distributed energy resources, the restructuring of power systems, and the appearance of privatization have intensively affected distribution networks.As a result, consumers prefer to produce energy at some hours of the day by utilizing local energy resources to improve their own profits.This leads distribution systems to face a new concept called prosumer which refers to an entity that can be either a producer or a consumer at any time interval of a day.In this context, some prosumers would tend to be sellers of energy, while others would want to purchase energy within each time interval of a day.These trends usually give rise to a tendency towards power exchanges in distribution networks at a price lower than the cleared energy price of the upstream wholesale market.In consequence, these local power exchanges would result in the development of local power markets in modern distribution systems [1].Local markets in distribution networks provide the opportunity to earn profit for both sellers and buyers, decreasing the dependency of distribution grids on the main grid, and enhancing the efficiency of distribution networks [2].

B. LITERATURE REVIEW
Recently, various types of local power markets in distribution networks have been studied by academic researchers.In this regard, [1] has reviewed a wide range of local markets and classified their players, objectives, and clearing methods along with an analysis of scalability, network constraints, and required overhead interactions.According to [3] and [4], energy market management methods can be divided into two general groups: centralized methods and decentralized methods.Centralized methods manage the power system in the presence of a central entity, which gathers all prosumers' operational data to run a general optimization problem and determines the optimum answer for all society members.However, in the decentralized methods, every prosumer independently runs an optimization problem to obtain the optimum answer to its problem with the aim of maximizing its own profit.Although the answers given by the centralized method would be the global optimum points, the decentralized approach is more preferable to be used in distribution management as it preserves the privacy of prosumers by eliminating the central entity.
In the context of local markets, recent works have shown the inclination for utilizing the decentralized peer-to-peer (P2P) power market framework within distribution networks based on its prominent advantages [5].In this structure, each prosumer would be able to independently trade energy with others without any need for a central organization or a mediator to decide about its affairs.Therefore, each prosumer optimizes its own benefits with respect to market information [5], [6], [7].In this regard, [8] reviews developed transaction-based energy as well as P2P trading frameworks.Moreover, [2] categorizes essential elements of a P2P power market using a hierarchical model and designs a P2P market framework considering game theory concepts.Accordingly, considering the methods for distributed operation of the network, previously studied research works in a similar context are summarized and compared with the approach proposed in this paper in Table 1.

C. RESEARCH GAP AND MOTIVATION
In the previously developed market models, all bids of sellers and buyers are considered to be completely exchanged after the clearance process.In other words, sellers are considered 40598 VOLUME 12, 2024 Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.to be 100% reliable for delivering the purchased power to buyers.Nevertheless, practically, there is no guarantee for sellers to generate and deliver the exact purchased power since there are possibilities of curtailments due to unexpected generation failures and insufficient production.

D. CONTRIBUTION
Knowing that there exist inevitable contingency occurrence possibilities in power systems, a P2P power market framework is designed in this paper for post-contingency conditions, which enables the distribution system operator (DSO) to maneuver and rerun the P2P market in case of contingency occurrences in the network.
Also, it seems that the consideration of a suitable cost function to assess the sellers' reliability in supplying the energy would be necessary for P2P power markets in future decentralized networks.Hence, as the DSO records all sellers' curtailment data in the market, it could inform buyers regarding the reliability of seller agents.In this paper, without loss of generality, it is assumed that the number of curtailments in the last year as well as the average and the standard deviation of sellers' curtailment durations would be given to buyer agents.Having these curtailment data, buyers estimate their reliability costs for a better decision on selecting reliable sellers to purchase energy.
Besides the contingency and seller-reliability cost function, in this work, a new network loss cost allocation plan is devised for the P2P framework, in which the DSO would calculate and allocate network loss prices for each buyer at every iteration of the algorithm.In this context, every buyer would also estimate its loss cost in its optimization and trading plan.The contributions of this paper can be mentioned briefly as the following points: • Designing a P2P market framework and analyzing its ability to be run in post-contingency conditions in a distribution system.
• Developing and applying a cost function for buyers to model the sellers' reliability in supplying the requested energy in the designed P2P market.
• Implementation of a network loss price allocation plan to optimize the clearing process in the developed P2P market framework.

E. PAPER ORGANIZATION
In this paper, the overall system modeling, as well as the model assumptions, is presented in II. A. Afterward, in II.B, the developed framework is illustrated, and the mathematical modeling is presented in II.C.Then, the details of the P2P market model-how the optimization problem works, how loss costs are included, and the implementation of sellers' reliability-are explained in II.D. Finally, the results of applying the proposed framework on the 33-bus test system are presented in section III, followed by conclusions in section IV.

II. METHODOLOGY A. SYSTEM MODELING
In the context of this paper, P2P power trading takes place at the distribution level of the power system.In this regard, a simplified model of the considered test network is presented in Fig. 1.As shown in this figure, every bus of the distribution system is considered to be managed by an independently working downstream market aggregator (DMA), and each DMA is connected to only one bus of the system.Therefore, in the proposed model, the total number of the DMAs in a power system are equal to the number of system-buses.
A DMA is an entity in the distribution system that aggregates the whole power amounts of the consumers or producers (which are connected to their related bus), and participates in the P2P market on behalf of them.These producers or consumers (called prosumers) represent smaller entities engaged in the generation or consumption of energy in a small scale.Given the modest scale of production or consumption by these prosumers, the paper's proposed model assumes the aggregation of multiple prosumers into groups by DMAs.The number of prosumers within a DMA can range from one to several, and in consideration of network configuration, all prosumers linked to the DMA's bus are considered prosumers of that particular DMA.
In addition to prosumers and DMAs, there are two more roles in the proposed P2P market; i.e., DSO and upstream market aggregator (UMA).In this regard, the responsibility of the DSO is to monitor the functionality of DMAs in order to ensure that trades, exchanges, and settlements are executed properly within the market framework.On the other hand, the UMA is an entity that could participate in the upstream network market.In this regard, UMA will be able to participate to the available markets including energy market in the upstream network.As a result, it would purchase excess energy from the downstream market and sell it in the upstream market, and vice versa during energy shortages.The proposed P2P market framework has the ability to be also utilized in the contingency conditions.In this regard, whenever a contingency happens in the system, the P2P market could be rerun with respect to the system's new configuration knowing that the system will also be reconfigured to its usual configuration after the clearance of the contingency.In the proposed structure, the designed P2P market determines the power requests for the next day which covers several time intervals demonstrated by T = {1, 2, . . ., t, . . ., |T |}.Within each time interval, every DMA could choose to be a seller or a buyer, which is allowed to sell/buy to/from different buyers/sellers.
In this model, DMAs independently participate in the market and schedule their local resources in order to maximize their profits.Additionally, in this paper, it is assumed that there are |N | DMAs in the distribution system shown by the N = {1, 2, . . ., n, . . ., |N |} which are partitioned into two groups of sellers ( i.e., set S) and buyers (i.e., set B) at each time interval (i.e., S ∪ B = N , S ∩ B = φ).Finally, every DMA is connected to a bus in the system and can operate photovoltaic (PV), wind turbine (WT), and energy storage system (ESS) units.

B. CONTINGENCY MANAGEMENT PLAN
As mentioned previously, there is a possibility of contingency occurrences in distribution systems which cannot be ignored in analyzing P2P power markets.This contingency could include failures in distribution network components (such as lines and buses), short circuit incidences, or in general, any event that prevents the network from properly conveying electricity to prosumers.Therefore, the proposed model in this paper aims to consider an appropriate framework for P2P markets, within which the contingency in the distribution system could be managed.
In the designed framework of this paper, the P2P power market is run for all time intervals of the next day.Thus, in normal circumstances, the cleared market is usable on the next day.However, if a contingency happens in the distribution system on the next day, the scheduled market is unable to be followed in the system.In this case, because the proposed model has the ability to maneuver on the contingency cases, the DSO can rerun the market at the contingency occurrence cases with the new configuration of the network.
In this regard, a contingency management plan is devised in this paper to be executed in the case of a contingency occurrence.According to this plan, after a contingency occurrence, the section of the distribution system in which the failure has happened will be detected.Afterward, this section will be isolated by the nearest switches in the system.By doing so, the system is ready to be reconfigured in order to connect the isolated healthy parts to the main grid.To this end, there could be some predefined reconfiguration plans in the distribution system; for example, a tie line could be connected by certain switches to convey the electricity to the healthy parts of the network.At the time the configuration is being done, a repair team will be sent to the contingency area to find the problem and estimate the repairing time period.Subsequently, the new configuration of the grid as well as the estimated time for contingency clearance will be announced to the grid operator.Hence, the P2P power market will be re-run for the remaining time intervals of the day.In consequence, the optimized power transaction results will be updated and used for both the repairing time period as well as after-repairing time intervals.
These contingency managing measures are briefly rendered in Fig. 2. as a schematic diagram.It should be taken into account that this paper mainly addresses the last step (i.e., rerunning the P2P market), given that the other steps-which primarily deal with managing the system immediately following the contingency-have already been accomplished [32].

C. OVERALL PROCESS OF THE PROPOSED P2P MARKET FRAMEWORK
A suitable market structure is required to enable DMAs to trade power with each other while modeling the power loss in the network and considering the contingency occurrences.In such a structure, all of the roles in the market should be able to interact efficiently with each other.Accordingly, in this 40600 VOLUME 12, 2024 Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.section, a suitable framework for the P2P market is proposed which consists of several steps that are run one by one for market clearance.In this context, the overall flowchart of the proposed scheme is represented in Fig. 3.According to the presented flowchart, first of all, the UMA should announce its selling and purchasing prices.In fact, in this model, it is assumed that the UMA has two fixed prices for selling and purchasing power to/from DMAs at each time interval.The DMAs, on the other side, could sell/buy any arbitrary amount of power to/from UMA, which could benefit both buyers and sellers.For buyers, it would help them to obtain their required power in the case of power shortage when they are not able to purchase from the seller DMAs.Moreover, in case that sellers have extra power without any requested demand from the buyers, they could sell their extra power to UMA.
After the first step, in the next step, for the sake of market discipline in the proposed framework, DSO forbids the participation of DMAs which are not connected to the grid.
In the third step, DMAs should determine their role (seller or buyer) in the market.Note that DMAs could choose different roles at different time intervals based on their surplus/shortage in power generation.
In the next step, in order to consider the curtailment probability for sellers, buyers use the historical data to take into account the reliability of each seller in their purchases.
Afterward, in the next step, sellers would initialize their power prices and announce them to buyers.Note that sellers based on their historical behavior and the operational condition of the market could independently determine their preferred prices.
After the price initialization step, the DSO calculates network loss prices for every buyer and announces it to the respective DMA.In this paper, the loss prices of a buyer are defined as costs that the buyer should pay for UMA in case that they purchase one kW of power from sellers.Buyers will consider these prices in their decisions for purchasing power from sellers.The detailed calculation process of these prices by the DSO will be explained in the mathematical modeling sections.It is noteworthy that UMA is considered as the responsible party for providing the loss power for the distribution system from the upstream network so that all buyers would pay their loss cost to the UMA.In other words, UMA is an entity that would enable the distribution system to provide the required power loss in the network for demand-supply balance.Respectively, UMA facilitates the exchange of power with the upper transmission network in the developed scheme.
In the next step of the algorithm, every DMA runs its own optimization problem to make the optimum decision for the P2P market.In this regard, sellers would primarily determine their optimum amount of power for selling, while buyers would determine their optimum power purchase associated with each seller entity.
Afterward, considering the total amount of requested power and available power supply, each seller updates its power price.In this context, if a seller's demand is more than its supply amount, it will increase its price; otherwise, it will decrease its announced price to incentivize buyers to purchase more power at the respected time interval.This process would discover the power prices in a way that demand and supply for each seller would be balanced.
In the last step, the termination criteria (which are described in section D) are checked in the market.In case of approval, the process of market clearance is finished, and the DSO would be able to calculate the trading bills for DMAs' settlements.In contrast, if the criteria are rejected, the DSO should calculate new loss prices for buyers.Hence, this iterative process will be continued until the termination criteria are obtained.

D. MATHEMATICAL MODELING OF DMAS' COST FUNCTIONS
In the proposed model, DMAs should consider all kinds of costs/benefits while optimizing their resources.In this regard, the total cost function of DMA n at time interval t (i.e.,f total n,t ) is proposed as equation ( 1) which consists of different types of costs described in the rest of this section.

1) RENEWABLE ENERGY RESOURCES' COST FUNCTION
In this paper, PVs and WTs are considered as renewable energy sources (RESs) whose maintenance and operational costs could be modeled by the DMAs in their respective cost functions shown in ( 2)-( 3) [19].Operating ESS units by a DMA increases its flexibility toward price spikes in the energy market.Moreover, the implementation of ESSs by DMAs also enhances the overall flexibility of the system [10].In this context, the ESS cost for a DMA and its corresponding constraints would be modeled as the following mathematical statements: 3) DMA POWER CONSUMPTION MODELLING The flexibility of the power consumption by a DMA could be applied by modeling a utility function to consider the utility for different amounts of power consumption.In fact, whenever a DMA consumes a certain amount of power, it earns utility corresponding with its power consumption.
In other words, utility in the context of energy consumption refers to the benefits, advantages, or conveniences gained by a consumer through the use of power.In this regard, by increasing the consumption amount, the utility earned by the DMA also increases considering the fact that the variation of utility increase will diminish for higher power consumption.In consequence, the utility function for DMA n could be modeled by equation (8).Note that this utility function could be used as a cost function by considering its negative value shown in equation ( 10) [6], [25], [33].
In the utility function, the factors 0 ≤ ψ n,t and 0 ≤ γ n are introduced as a consumption parameter and a predetermined constant factor, respectively.Additionally, P utility n,t and ψ n,t γ n are the minimum and maximum consumption amounts of the related DMA.

4) TRADING COST FUNCTION OF DMAS
In the framework of the P2P market, DMAs trade with each other in order to maximize their profits (or minimize their costs).Therefore, they should consider a cost function that models the costs/benefits of power trading.This process enables them to optimize their resources and make their best decision.In this regard, the trading cost function of a DMA is considered as equation (11).Note that in case DMA n is a buyer, the second and fourth terms of the equation will be ignored (i.e., P sell n,t = 0 and P SU n,t = 0).Moreover, if DMA n is a seller, the first and third terms of the equation will be similarly ignored (i.e., P buy in,t = 0, ∀i ∈ S and P BU n,t = 0).
It is noteworthy that in the developed scheme, the side that requests for the transition must pay for the power loss of the transition.For instance, a buyer who wants to purchase power from a seller must accept the loss cost of that power transition.Hence, in equation ( 11), DMAs consider the loss prices announced by the DSO in each iteration in addition to sellers' prices.

E. MATHEMATICAL MODELING OF THE P2P MARKET
In this section, the P2P market framework will be illustrated in more detail along with the mathematical formulations.

1) OPTIMIZATION MODELING OF DMAs
DMAs (i.e., buyers and sellers) would optimize their local resources while participating in the P2P market to determine their power exchange with other DMAs as well as the UMA.As a result, DMAs need to solve an optimization problem in order to determine the power purchasing/selling from other DMAs, their ESS charging/discharging, power consumption, and the amount of purchasing/selling power from/to the UMA.In this regard, its associated optimization problem is modeled as follows: Subject to the constraints (3), ( 5) to ( 7), (9), and the power balance constraint which is defined as: where, P oc n,t implies the power amount that DMA n could not exchange with the grid in case of open circuit at time interval t.In other words, P oc n,t models the inevitably unused power in case of contingency occurrences, when a DMA has an extra power amount but cannot sell it to the grid.
It is noteworthy to mention that, for sellers, P buy in,t = 0, ∀i ∈ S and P BU n,t = 0; while, for buyers P sell n,t = 0 and P SU n,t = 0 should be also considered in the constraints of the optimization problem.

2) PRICE UPDATING PROCESS FOR SELLERS
As mentioned, sellers update their prices in each iteration of running the P2P market framework with respect to their supply-demand status.In this regard, the price of the current iteration for seller i is obtained using the price of the previous iteration as shown below: In equation ( 14), ϑ i is the convergence factor which means that its higher values would cause faster but inaccurate convergence, while lower values would lead to slower but accurate convergence.

3) THE TERMINATION CRITERION
In the proposed market framework, in each iteration, the DSO checks the following two conditions for every seller, and the iterative process of the market will be finished only if at least one of these conditions is satisfied.
• The price of the current iteration is approximately equal to the price of the previous iteration, or mathematically: • The seller's price fluctuates between π av − ε f and π av + ε f in the last L f iterations.
Where, ε π and ε f are small numbers for price and fluctuation, respectively.Moreover, π av is the average of the last L f prices.
It is noteworthy that the first condition means that the seller's price is almost not changing while the second condition is preventing the seller from fluctuations in the price value.Note that the price fluctuations may delay the termination of the algorithm and cause system costs due to long-time processing.Therefore, the convergence of the developed algorithm is ensured by the aforementioned two conditions.

4) CONVERGENCE IMPROVEMENTS
For better and faster convergence of the proposed algorithm, several methods have been utilized as below: ) Step length control method: according to this method as presented in [26], the purchasing power by buyers from sellers is confined between two lower and higher values in order to relieve the price tensions and make price changes smoother through the iterations.Similarly, the prices of sellers could be confined between two amounts, which prevents abrupt deviations in sellers' prices.In this regard, this method is applied for power purchases and price values as follows: (1 − δ P ) P buy ij,t (l) ≤ P buy ij,t (l + 1) P buy ij,t (l + 1) ≤ (1 ) Learning process method: This method considers the previous v prices of the sellers in the calculation of their prices [26].In this regard, to improve the convergence status, the following formulation replaces equation ( 14):

5) POWER LOSS IMPLEMENTATION
In the proposed model, whenever a buyer purchases power from a seller, it pays costs according to the price values.However, this power transition from the seller to the buyer would cause power losses in the distribution network.In this context, in the proposed model, the UMA would have the responsibility of generating the power loss.Hence, the buyer who requests to purchase power from a seller or from the UMA must pay the loss cost of the related transition to the UMA.Moreover, the seller that wants to sell power to the UMA must pay the loss cost to the UMA.In this regard, in the proposed framework, the DSO would calculate a certain price for every power transition.In other words, if buyer j buys 1kW power from seller i, it must pay the cost not only due to the purchased power (with the price of π seller i,t ) but also due to the associated power loss (with the price of π loss ij,t ).Moreover, if a seller entity sells 1kW power to the UMA, it must pay the loss cost; therefore, its overall payment will be equal to . Similarly, when a buyer purchases 1kW power from the UMA, its total paying amount equals . Based on the above discussions, the allocated power loss to DMAs in each iteration of running the proposed P2P market could be calculated as follows: π BU ,loss j,t where, TPL l t shows the total power loss in iteration l and time interval t.Additionally, TPL l,buy ij,t is the total power loss if buyer j purchases 1kW more power from seller i.Moreover, TPL l,BU j,t shows the total power loss if buyer j purchases 1kW more power from UMA.In addition, TPL l,SU i,t presents the total power loss if seller i sells 1kW more power to the UMA.
DSO calculates these prices in every iteration (except the first iteration in which all the loss prices are equal to zero), using the power transition data of the previous iteration.In this regard, to calculate the power loss price for a certain transition (i.e., a certain pair of buyer and seller), DSO runs the power flow analysis in two scenarios.In the first scenario, the DSO uses the previous iteration's transition data of the market so that the obtained loss is equal to the total loss of the system assuming all transitions are settled.In the second scenario, the data for loss calculation is the same as the first scenario, but with the assumption of transferring 1kW more power for the certain transition whose power price is of interest to be calculated.The subtraction of the two calculated values would demonstrate the effects of the power transition on the increase of the power loss in the system, when the buyer purchases 1kW more power.Hence, as the power loss would be supplied by the UMA, the loss price for the transition would be obtained by multiplying the allocated power loss values by the UMA's selling price (i.e., π BU t ).Similar descriptions could be deduced for power transactions with UMA.

6) RELIABILITY MODELING OF SELLERS
In the proposed P2P market, as mentioned previously, buyers purchase their next day's power from the sellers.Nevertheless, on the next day, the power generation units of a seller may fail; therefore, it cannot deliver the supposed power amount to buyers.In this situation, the buyer whose requested power would not be supplied would confront a heavy cost.In this regard, in this paper, a new model is devised in order to consider the reliability of sellers.As a result, the output of the market would result in a reliable system.
In this model, the DSO would record the reliability data of all sellers and let the buyers know their power output curtailment information.Respectively, it is assumed that the number of curtailments in the duration of the last year, the average duration of power output curtailments, and their associated standard deviation for each seller would be announced to the buyer entities.It is noteworthy that the DSO announces this information to the buyers in the fourth step of the proposed algorithm (Fig. 3.).Moreover, in this paper, it is assumed that the curtailment duration parameters of sellers are modeled by the truncated normal distribution which is lied between zero and the time interval length (i.e., t).
After the announcement of the data by the DSO, buyers would obtain the probability of sellers' curtailments as well as the UMA's curtailment from the following equations: In this context, buyer j's cost due to a curtailment occurrence for a time duration of τ (i.e., C j ) could be calculated through the following equation [34].
Hence, to apply this cost in the developed scheme, buyers would first generate K scenarios utilizing the truncated normal distribution and then take the reliability of sellers into account according to the following cost function: where, f rel j,t models agent j's reliability cost; In addition, π rel ij,t and π BU ,rel j,t are the reliability prices of seller i and the UMA from the perspective of the buyer j.Such prices could be calculated from equations (25a) and (25b).Note that p ij,k , p uj,k , τ cur ij,k and τ cur uj,k are obtained from the truncated normal distribution given by the DSO.
π BU ,rel Consequently, with the implementation of the power curtailment probability, every buyer would be able to consider its reliability cost in its total cost function.Thus, buyers' total cost function (1) would be updated as follows:

III. CASE STUDY
For the sake of testing the proposed market framework, in this section, the model is simulated on the 33-bus test system [35] shown in Fig. 4. In this regard, the system voltage level is 12.66 kV and the base value of the power is 100 kVA.Moreover, 32 DMAs are assumed to be connected to the grid and every time interval is postulated to be one hour.
The number of buyers' scenarios is assumed to be 10 (i.e., K = 10) and the simulation is run in MATLAB with the help of Python (Pyomo package) for optimization sections.
In order to test the proposed model, it is assumed that in the distribution system, the DSO runs a P2P market for 24 hours of the next day; but at 10 th hour of the next day, a fault happens in the system.In consequence, the nearest switches to the fault area (demonstrated in Fig. 4.) are opened and the tie line is closed.Respectively, DMAs 13 to 17 are connected through the tie line to the network, but DMAs 9 to 12 would be isolated from the main grid.In addition, it is assumed that the repairing team predicts the repairing process duration and declares that the repair work will be finished in 8 hours.Therefore, the DSO runs another P2P market from 11 th hour to 24 th hour of the day knowing that the configuration of the network will be changed at the end of 18 th hour.In other words, at 18 th hour, the repairing team will complete its work, and the opened switches will be closed again.Thus, DMAs 9 to 12 would not be able to participate in the market from 11 th hour to 18 th hour.
In the rest of this section, the simulation results are represented.It is noteworthy that the data related to 1 th hour to 10 th hour are determined from the day-ahead P2P market (i.e., before failure), and the data related to hours 11 to 24 would be updated in the P2P market rerunning (i.e., post-contingency).In this regard, Fig. 5 shows the total traded amount of power with the UMA during 24 hours of the day.With respect to the obtained results, within each hour, at least one of the purchased/sold power from/to UMA is equal to zero, which means that the UMA has never acted as an illegal mediator in the market.
Figure 6 demonstrates all sellers' final converged prices along with the UMA's buying and selling prices within 24 hours of the day.According to Fig. 6, the prices of sellers are approximately between two values of the UMA prices within all time steps.The reason is that sellers could not declare their price values more/less than the UMA's purchasing/selling prices, otherwise, buyers/sellers will purchase/sell from/to the UMA.It is noteworthy that the network power loss and the reliability of sellers are modeled as price terms in the optimization objectives; therefore, sellers' prices could slightly extricate from the UMA's price range in some cases.
In order to investigate the convergence status of the algorithm, five sellers are selected at 17 th hour and their price values in all iterations are illustrated in Fig. 7.In this regard,  the algorithm has been terminated in 395 th iteration and the prices are almost fixed in the last iterations.It is noteworthy that since the sellers compete with each other, and the impact of network power losses on sellers' prices is small enough, the final values of sellers' prices are close to each other.This can be easily seen in the obtained results in Fig. 6.
To study the detailed power transactions, the power trading status at 13 th hour is depicted in the Fig. 8.In the presented Chord diagram, every DMA is shown by a small blue node, and the UMA is shown as 33 rd node.As it can be seen from the diagram, DMAs 9 to 12 could not be able to participate in the market because of the fault that happened in the network.In other words, DMAs 9-12 are isolated from the network due to the grid failure, therefore, they could not participate in the P2P power transactions at hour 13.
For the sake of investigating the power scheduling of DMAs, DMA 23 is chosen to study its optimized power generation/consumption during the operation period (i.e., 24 hours).In this regard, the PV generation of the DMA and its power consumption as well as its minimum/maximum power requirements at every hour of the day are represented in Fig. 9.Moreover, Fig. 10 shows the power amounts that the DMA has charged/discharged its ESS unit during the operational period.According to the obtained results, the   DMA has charged its ESS unit at hours when the power prices are low and discharged the unit at expensive hours.
Figure 11 shows the price of sellers along with the UMA's selling price at 21 st hour.Moreover, the network power loss price and the reliability price from the perspective of DMA 23 are demonstrated in Fig. 11.Additionally, the price  which is the summation of the mentioned three price types is also shown in Fig. 11.In this regard, because DMA 6 has minimum total price, DMA 23 has purchased 8.57 kW from DMA 6.This power purchase, along with the consumption and ESS charging status, is shown in Fig. 12 in order to investigate the power balance status of DMA 23 at 21 st hour.
Previously, in this section, the schedule of DMA 23 which is not isolated due to the contingency occurrences is investigated.However, the DMAs located in the isolated area would have different operational behavior.In this regard, the power generation amount, consumption amount, and unused power (i.e., open circuit power) of DMA 9 are indicated in Fig. 13.Moreover, the charged/discharged power of the ESS unit of DMA 9 is presented in Fig. 14.Note that DMA 9 has only the PV type of generation units.
Based on the obtained results, the DMA does not use its generated power within hours 11 to 17 as it is isolated and not to the main grid.Therefore, it could not sell the extra power to other DMAs during the repairing time period.It is noteworthy that it does not charge the ESS unit at hours 11 to 15.The reason behind this is that based on the determined results in the day-ahead market, the ESS is charged at hours 3 to 8 and is discharged at 10 owing to the higher price of power.Therefore, in post-contingency conditions, they are able to charge only 2 kW at because their ESS's capacity will be reached to its maximum level (i.e., E ESS n ).As a result, among all of the opened circuit power amounts, they would be able to use only 2 kW for ESS charging.Hence, the DMA decides to charge its ESS at 16 th hour and discharge again at 18 th hour when discharging is the only way to supply the power consumption.
As another example, DMA 12 is also located in the isolated area.Figure 15 shows the power generation, consumption, and the minimum/maximum limit of the consumption of DMA 12 followed by its ESS charging/discharging status in Fig. 16.In this context, regarding Fig. 15, DMA 12 could not supply its power need during the repairing time period inevitably.This is because not only is it isolated from the power grid within hours 11 to 17, but also its wind turbine generation is not sufficient.According to Fig. 16, the DMA tries to use its storage power at hours 10-14, 16, 17 to compensate for generation shortage.Note that with respect to the ESS's capacity constraint, the DMA could not discharge at all time intervals during hours 11-17.Therefore, at 15 th hour when the DMA 12's power shortage is comparatively low, it decides to charge its ESS to use it at the next hour.These studies show the application of the developed P2P scheme for energy management in multi-agent systems while considering the reliability of the sellers in supplying the purchased energy.However, for implementation of the developed framework, there should be a suitable telecommunication infrastructure in the distribution system.The telecommunication layer of a power system consists of communication devices, protocols, applications, and information flow, which should be able to transfer all peers' data within the power system [7].Additionally, although the computational burden in the decentralized P2P markets is low compared to the central structures, there should exist appropriate computers for all market-participators for their optimizations in the power system.

IV. CONCLUSION
Regarding the huge rise in the development of energy markets, especially the P2P framework for trading in distribution systems, and the importance of reliability in power networks, it seems the enrichment of such P2P structures is needed in a way that they become reliable against failure occurrences in the power grid.Therefore, in order to reach this aim, in this paper, a P2P power market structure is designed that has the ability to continue the trade in post-contingency conditions.Also, for the sake of buyers' precise decision-making, a reliability cost function is developed for them to consider sellers' reliability while participating in the P2P market.The developed model is applied on a 33-bus test system, which shows the capability of the model in case of network failure.In this regard, according to the results of the case study in this paper, the simulated power grid is experiencing a failure so that the buses related to DMAs 9 to 12 are isolated from 11 th hour to 18 th hour.However, the results indicate that the proposed method is capable of handling the post contingency condition due to a grid failure.As a result, the application of the proposed model would result in improving the reliability of the system, while facilitating the distributed P2P management of the system.It is noteworthy that based on the obtained results, the future expansion planning of flexible resources in the grid could be optimized to limit the social costs occurred in case of grid failure.
SAJJAD FATTAHEIAN-DEHKORDI (Graduate Student Member, IEEE) received the M.Sc.degree in electrical engineering and power systems from the Sharif University of Technology (SUT), Tehran, Iran, in 2014, and the joint Ph.D. degree from SUT and Aalto University, Espoo, Finland, in 2023.His research interests include power systems planning, operations, and economics, with a focus on issues relating to the high-integration of renewable energy resources into the systems.
HOSSEIN SABER received the B.Sc. degree in electrical engineering from the Amirkabir University of Technology, Tehran, Iran, in 2014, and the M.Sc.and Ph.D. degrees in power system engineering from the Sharif University of Technology, Tehran, in 2016 and 2022, respectively.His research interests include power system planning and operation, transactive energy, renewable energy integration, distributed energy resources, and optimization and its application in power systems.MATTI LEHTONEN received the master's and Licentiate degrees in electrical engineering from the Helsinki University of Technology, in and 1989, respectively, and the Doctor of Technology degree from the Tampere University of Technology, in 1992.He has been a Professor with the Helsinki University of Technology (now Aalto University), where he is currently the Head of the Power Systems and High Voltage Engineering Group.His research interests include power system planning and asset management, power system protection including earth fault problems, harmonic related issues, and the applications of information technology in distribution systems.

FIGURE 1 .
FIGURE 1.A simplified model for the P2P market structure.

FIGURE 2 .
FIGURE 2. The steps associated with the management of a contingency.

FIGURE 3 .
FIGURE 3. The overall flowchart of the proposed P2P market.

FIGURE 4 .
FIGURE 4. The IEEE 33-bus test system used in the simulation.

FIGURE 5 .
FIGURE 5. Exchanged power amount with the upstream network in 24 hours.

FIGURE 7 .
FIGURE 7. status of prices at 17 th hour.

FIGURE 8 .
FIGURE 8. Power trading status at 13 th hour.

FIGURE 9 .
FIGURE 9. Power generation and consumption status of DMA 23.

FIGURE 11 .
FIGURE 11.Sellers' prices 21 st hour from the perspective of DMA 23.
CHRISTIAN REHTANZ (Fellow, IEEE) received the Diploma and Ph.D. degrees in electrical engineering from Technical University Dortmund, Dortmund, Germany, and the Venia Legendi degree in electrical power systems from the Swiss Federal Institute of Technology, Zürich, Switzerland.Since 2005, he has been the Director of ABB Corporate Research in China, Beijing.Since 2007, he has been a Professor and the Head of the Institute of Energy Systems, Energy Efficiency, and Energy Economics (ie3), Technical University Dortmund.His research interests include multiagent systems and technologies for network enhancement and congestion relief, such as stability assessment, wide-area monitoring, protection, coordinated flexible ac transmission systems, and high-voltage direct current control.
Cost function that models utility of DMA n. associate editor coordinating the review of this manuscript and approving it for publication was Salvatore Favuzza .

TABLE 1 .
Taxonomy of reviewed research works.