Keywords

1 Introduction

Newmarket structures have emerged as an alternative to face an increasing penetration of distributed energy resources (DERs) in low voltage distribution networks (LVDN), where some more empowered, aware and active consumers have opted for self-consumption and to include storage energy systems to reduce the electricity bill and their dependence from the grid [14]. Peer-to-peer energy trading belongs to this new structure that seeks to increase self-generated energy efficiency by selling and buying its surplus within of small-scale smart-grid community. The residential areas composed of prosumers and consumers willing to exchange surplus energy are the baseline of this local energy market (LEM) [13]. However, the design of a platform that allows this new paradigm’s correct operation is still under research, becoming the focus of many works over the last years [1,2,3,4,5,6,7,8,9].

The work done by [5] establishes a framework for local energy trading, presenting definitions and classification of market players and the different market-clearing approaches in the literature. Likewise, a state-of-the-art and perspective are presented in [6], discussing the critical aspect for a proper P2P energy trading, which are: trading platforms, physical infrastructure, policy, market design, information and communication technology (ICT) infrastructure. Under the market design aspect (the focus of the model proposed in this article), there are three subcategories: centralized, decentralized or distributed markets. The first one could maximize the community’s social welfare because a coordinator decides the energy amount exchange. In the decentralized market, the users have complete control over their devices, and they decide when selling or buying; however, the total community efficiency is affected. The distributed market design is between the two above, where a coordinator provides accurate information about pricing and the community requirement, and the peer decides when sell/buy, generating better coordination between them than decentralized design [6].

Two approaches are presented in [2] to compare the community-based and decentralized market based on optimal power flow (OPF) and continuous double auction (CDA), respectively. The work in [3] presents a bidding-based Hierarchical P2P energy transaction optimization model, which considers the prosumer’s objective in terms of standard and green energy preference. The authors in [4] propose a bi-level optimization model for the decentralized P2P energy market without considering technical constraints; however, the proposed method in [4] achieves proper peers coordination without sacrificing privacy. A multi-class energy management concept is used in [9] to presents a P2P energy platform that allows coordinate trading among peers with preferences beyond the typical financial criteria, minimizing losses and battery depreciation. A game-theoretic approach is applied by [7] and [1] for P2P energy trading using the cooperative and the noncooperative game, respectively. However, both studies are not based on the power flow equations, and therefore, they do not include technical constraints in their formulation. The work done by [8] proposes a decentralized market clearing mechanism for the P2P energy trading considering the agents’ privacy, power losses, and the utilization fees for using the third-party-owned network, where the fees are proportional to the electrical distance between producers and consumers.

The article’s major contribution is a scalable and new P2P energy trading model, based on graph theory and the power flow equations, for a small-scale community local energy market with a centralized market design, considering high DERs penetration and flexible demand.

The rest of the paper is organized as follows. Section 2 describes the mixed-linear programming problem. Section 3 presents the computational results under two cases of study. Finally, the following steps to expand the model are discussed in Sect. 4.

2 Peer-to-Peer Energy Trading Model

The formulation presented in this article pretends to model a small local community market with penetration of rooftop PV systems, batteries and flexible demand. Through the purchase and sale of energy exchanged among peers, the community minimize the electricity purchased to the grid and maximize the use of the DERs, considering the following assumptions:

  • The information related to the power loaded, generated and stored by peers is known.

  • There is a safety mechanism to buy and sell energy within the small local market.

  • The community is connected to an external grid which provides the remaining energy.

  • The community buy and sell energy under a global internal market price and not an individual price.

  • The peers seek to minimize their cost and maximize their benefits.

  • The energy bought/sold to the grid is connected to the respective bus (not to slack bus), such that the power flow within the lines is only the energy exchanged among peers and not the energy from/to the grid.

  • The power flow equations have been considered in their linear form (DC).

The last two assumptions aim to simplify the formulation, at least in this first approach, to improve the model’s explanation, operation and results. Specifically, when the energy bought/sold to the grid is considered in the bus and does not in the slack-bus, all energy flows in the system belongs to the local market. Thus, the mixed-linear programming problem (MILP) is the following:

$$\begin{aligned} \begin{array}{lr} minimize \quad z = \displaystyle \sum _{i\in {\mathbb B}} \displaystyle \sum _{t\in {\mathbb T}} \lambda ^{bg}_t p^{bg}_{i,t} - \lambda ^{sg} p^{sg}_{i,t} + \lambda ^{bm}_t p^{bm}_{i,t} \\ \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad - \lambda ^{sm}_t p^{sm}_{i,t} + \displaystyle \sum _{(i,j)\in {\mathbb L}} \displaystyle \sum _{t\in {\mathbb T}} p_{i,j,t}. \end{array} \end{aligned}$$
(1)

The objective function in (1) comprises, from left to right: the energy bought (\(p^{bg}\)) and sold (\(p^{sm}\)) to the grid, the energy traded within the local market (\(p^{bm}\),\(p^{sm}\)) (where the Lambdas indicates the respective trading prices), and the energy flow among peers (\(p_{i,j,t}\)). Thus, (1) is subject to the following constraints:

Nodes constraints; \(\forall i \in {\mathbb B}, \forall t \in {\mathbb T}\)

$$\begin{aligned} \displaystyle \sum _{(i,j)\in {\mathbb L}} p_{i,j,t} = pg_{i,t} - pl_{i,t} + p^{bg}_{i,t} - p^{sg}_{i,t} + (ds_{i,t} - ch_{i,t}). \end{aligned}$$
(2)

Under the assumption of the DC version of the OPF, the constraints of the lines possess the following structure; \(\forall (i,j) \in {\mathbb L}, \forall t \in {\mathbb T}\)

$$\begin{aligned} p_{i,j,t} = \frac{\theta _{i,t}-\theta _{j,t}}{x_{i,j}}. \end{aligned}$$
(3)

Equation (2) represents, from left to right, the power injected by the PV systems (pg), the load (pl), power bought/sold to the grid, and the power injected (ds) or absorbed (ch) by the storage system. Equation (3) is the classic DC-OPF for the branches, and it does not present any variation.

The power injected limits by the rooftop system, the voltages, and the flow between nodes are explained as follows:

Power injected by the PV system; \(\forall i \in {\mathbb B}\)

$$\begin{aligned} 0 \le pg_{i,t} \le I^{pg}_i \beta ^p_i PG^{max}_t. \end{aligned}$$
(4)

Voltage limits; \(\forall i \in {\mathbb B}, \forall t \in {\mathbb T}\)

$$\begin{aligned} V^{min} \le v_{i,t} \le V^{max}. \end{aligned}$$
(5)

Energy flow among peers; \(\forall (i,j) \in {\mathbb L}, \forall t \in {\mathbb T}\)

$$\begin{aligned} p_{i,j,t} \le S^{max}_{i,j}. \end{aligned}$$
(6)

In Eq. (4), the power injected by the rooftop system is bounded by; a binary vector (\(I^{pg}_i\)) that indicates if there is a PV system installed in the bus; the power system capacity (\(\beta ^p_i\)); and the maximum power (\(PG^{max}_t\)) that can be injected by the system into a specific period t (see Sect. 3).

The battery behaviour is represented through the follows constraints; \(\forall i \in {\mathbb B}, \forall t \in {\mathbb T}\)

$$\begin{aligned} soc_{i,t+1} = soc_{i,t} + (\varphi ch_{i,t} - \frac{ds_{i,t}}{\varphi })\varDelta t, \end{aligned}$$
(7)
$$\begin{aligned} I^{bt}_i \beta ^b_i SOC^{min}_t \le soc_{i,t} \le I^{bt}_i \beta ^b_i SOC^{max}_t, \end{aligned}$$
(8)
$$\begin{aligned} ch_{i,t} \le M^{bt} w_{i,t}, \end{aligned}$$
(9)
$$\begin{aligned} ds_{i,t} \le M^{bt}(1 - w_{i,t}) - M^{bt}(1 - I^{bt}), \end{aligned}$$
(10)
$$\begin{aligned} w_{i,t} \le I^{bt}. \end{aligned}$$
(11)

Equation (7) indicates the state of charge of the battery, which is bounded in Eq. (8) by the battery capacity, multiplied by its minimum/maximum operating range and multiplied by a binary vector (\(I^{bt}\)) which is 1 when a bus possesses a storage system installed. Likewise, Eq. (9) indicates the charge power of the battery, such that when it is charging, \(w_{i,t}\) takes value 1; otherwise, the battery is discharging through Eq. (10). If there is no battery installed (\(I^{bt}=0\)), \(w_{i,t}\) must be zero (see Eq.(11)), and the other battery constraints are also zero.

Flexible Demand, Therefore; \(\forall i \in {\mathbb B}, \forall t \in {\mathbb T}\)

$$\begin{aligned} pl_{i,t} = PL_{i,t} + \displaystyle \sum _{d \in {\mathbb D}} \tau ^d_{i,t} Pfd^d. \end{aligned}$$
(12)

Therefore; \(\forall i \in {\mathbb B}, \forall d \in {\mathbb D}\)

$$\begin{aligned} \displaystyle \sum _{d \in {\mathbb D}} \tau ^d_{i,t} = Nfd^d_i. \end{aligned}$$
(13)

The total electricity load in Eq. (12) is composed of unmanageable demand (\(PL_{i,t}\)) and flexible demand (\(Pfd^d\)), which could be activated at any time t depend on the generation and consumption level, in order to minimize the energy purchased to the grid. Thus, the binary variable \(\tau ^d_{i,t}\) is 1 when the flexible load is activated and zero otherwise, allowing different types of flexible loads activated in the same period t, such as air conditioner, wash, and dish machine. Eq (13) indicates the total numbers of hours that a type of demand must be activated at a certain time horizon.

The local energy market is modelled through the following set of constraints. Therefore; \(\forall i \in {\mathbb B}, \forall t \in {\mathbb T}\)

$$\begin{aligned} pg_{i,t} + ds_{i,t} = p^{sc}_{i,t} + p^{sm}_{i,t} + p^{sg}_{i,t} + ch_{i,t}, \end{aligned}$$
(14)
$$\begin{aligned} p^{sm}_{i,t} + p^{sg}_{i,t} \le (pg_{i,t} + ds_{i,t} - pl_{i,t}) + M(1 - y1_{i,t}), \end{aligned}$$
(15)
$$\begin{aligned} p^{sm}_{i,t} + p^{sg}_{i,t} \le y1_{i,t} + M(1 - y2_{i,t}), \end{aligned}$$
(16)
$$\begin{aligned} y1_{i,t} + y2_{i,t} = 1, \end{aligned}$$
(17)
$$\begin{aligned} \displaystyle \sum _{(i,j)\in {\mathbb L}} p_{i,j,t} \le p^{sm}_{i,t}, \end{aligned}$$
(18)
$$\begin{aligned} \displaystyle \sum _{(j,i)\in {\mathbb L}} p_{j,i,t} \le p^{bm}_{i,t}. \end{aligned}$$
(19)

Equation (14) represents the relation between i) the power injected from the generator plus the battery (power available to use), with ii) how to assign this power to: meet the load (\(p^{sc}_{i,t}\)), sell the remaining energy to the local market (\(p^{sm}_{i,t}\)) /grid (\(p^{sg}_{i,t}\)), or charge the battery (\(ch_{i,t}\)). Equations (15)–(17) represents the energy amount that can be sold by a user (peer) at a specific time. Specifically, Eqs. (15) and (16) explain: if the user has generation and/or energy stored, this energy must satisfy first its electricity load. Once the load is complete, the remaining energy can be sold in the local market; otherwise, the power sold to the grid or the market must be zero. Equation (17) is composed of two sets of binary variables that allow the proper operation of the Eqs. (15) and (16) supported by M, which is a significant positive number. Thus, y1 takes the value 1 when the generator’s power plus the power injected from the battery is greater than the electricity load, and in the case when the load is greater than the power available to use, y2 takes the value 1. Equation (18) indicates that all the energy that leaves node i is energy sold to the market, and Eq. (19) that all the energy reaching node i is energy bought to the market.

Market clearing constraint; \(\forall t \in {\mathbb T}\)

$$\begin{aligned} \displaystyle \sum _{i \in {\mathbb B}} p^{sm}_{i,t} = \displaystyle \sum _{i \in {\mathbb B}} p^{bm}_{i,t}. \end{aligned}$$
(20)

Equation (13) indicates that the total energy sold to the local market must be bought. Therefore, following the market constraints already explained, a user (peer) with a self-consumption system is under the following scenarios:

$$\begin{aligned} \begin{array}{ccc} \textit{a) if} \quad pg_{i,t} + ds_{i,t} > pl_{i,t}, &{} \ \ \text {sell to} &{} \text {Market: }p^{sm}_{i,t} = p^{bm}_{i,t} \\ &{} \qquad &{} \text {Grid: Remaining}\\ \textit{b) if} \quad pg_{i,t} + ds_{i,t} < pl_{i,t}, &{} \qquad \ \text {bought to} &{} \text {Market: }p^{bm}_{i,t} = p^{sm}_{i,t} \\ &{} \qquad &{} \text {Grid: Remaining}\\ \textit{c) if} \quad pg_{i,t} + ds_{i,t} = pl_{i,t}, &{} \quad \ \ \text {nothing.} &{} \qquad \qquad \end{array} \end{aligned}$$

In the first scenario, if the self-generation is greater than the load, the remaining energy could be sold to the grid or the local market, such that the energy available to sell within the community must be equal to the market load. However, for selling within the market to make sense, the pricing should be under the following pattern:

$$\begin{aligned} \lambda ^{sg}_t \le \lambda ^{sm}_t \le \lambda ^{bg}_t, \lambda ^{sm}_t = \lambda ^{bm}_t. \end{aligned}$$
(21)

Therefore, the user would prefer to sell its remaining energy to the market before the grid because the internal market price is always greater than \(\lambda ^{sg}_t\). On the other hand, the users always would choose to buy energy to the internal market than the grid because it is cheaper than \(\lambda ^{bg}_t\). Under this context, the objective function must be rewritten as follows:

$$\begin{aligned} z = \displaystyle \sum _{i\in {\mathbb B}} \displaystyle \sum _{t\in {\mathbb T}} \lambda ^{bg}_t p^{bg}_{i,t} - \lambda ^{sg} p^{sg}_{i,t} + \displaystyle \sum _{(i,j)\in {\mathbb L}} \displaystyle \sum _{t\in {\mathbb T}} p_{i,j,t}. \end{aligned}$$
(22)

In Eq. (22), the local market’s energy traded has been deleted because the energy sold and bought always are equal in amount and price.

3 Computational Results

This section presents the data used to test the model under two IEEE bus systems with their respective results. The first network, corresponding to the IEEE 5-bus system, is used as a slight case of study to facilitate the results explanations and show clearly the data type obtained from the model and its operation before being tested in a second case study corresponding to the 33 nodes distribution network. The two study cases compare the total energy bought when there is no energy traded among peers and when it is. The aim is to quantify the savings produced by the energy exchange among peers with PV and storage systems. The formulation has been programmed in Pyomo-Python using CPLEX as the solver.

3.1 Data

The load profiles have been taken from [10], the energy price [11], and the PV power output from [12], where the weather conditions belong to Barcelona, Spain. Figure 1 shows the relationship between these curves such that everyone has been normalized to be in function of the maximum power capacity. i.e., if the power capacity of the PV system is 10 kW, then every hour of the PV normalized curve (between 0 and 1) represents the power than can be injected into the system at that hour. Thus the PV curve in Fig. 1 is the PG max vector used in the formulation. Likewise, the normalized curves belonging to the load profiles are multiplied by the maximum power load at every bus to obtain the load at every hour. The price to sell energy to the grid has been assumed in 1/3 of the buy price.

Fig. 1.
figure 1

Profiles used in the first case of study

3.2 IEEE 5 Bus System

The small case study [16] considers five nodes, six lines, and three buses with load profiles where buses 2, 3, and 4 possess a maximum power of 7, 5, and 3.5 kW, respectively. Besides, node 2 and 4 have installed a rooftop PV system of 10 and 5 kW, and bus 4 has a storage device of 10 kWh with a power charge/discharge of 5 kW which start charged at 50%. Two types of flexible demand are included: a consumption of 1.5 and 2.5 kWh, which must be activated within the 24 h time horizon.

Table 1 shows the results for bus 4 that includes self-generation and battery. Thus, it is easy to observe the following behaviour:

  • Hour 1: The load is composed only by unmanageable demand that is fulfilled with energy from the battery, which means that the load is equal to the self-consumption.

  • Hour 2–7: There is not battery discharged, and therefore the energy is bought to the grid.

  • Hour 10–16: There is power generated from the PV system, which in hour 10 generate 1.1 kW, of which 0.5 kW are for self-consumption; the remaining is summed to the 2.1 kW discharged from the battery to sell 2.7 kW to the market. In hour 13, the power generated reaches 5 kW, of which 3 kW belong to self-consumption composed of a fixed load of 0.5 kW and a flexible demand of 2.5 kW; the remaining 2 kW are used to charge the battery with 1.5 kW and sell to the market 0.5 kW.

  • Hour 17–24: In the remaining hours, the battery supplies the energy to meet the load. Thus, the only hours when bus 4 buy energy to the grid is when the electricity price is the lowest (see Fig. 1).

Figure 2 shows schematically how the nodes exchange energy into the local market at hour 12. Bus 3 is a consumer without flexible devices or PV system, while nodes 2 and 4 are prosumer, which sells the remaining energy to node 3, showing the energy flow in Fig. 2.

Table 3 shows a final comparison between three different scenarios: (A) System without DERs penetration, (B) System with DERs but without energy traded among peers, and (C) System with DERs and energy traded. Thus, in case (B) the energy bought to the grid is 102.8 kW, corresponding to 67.68% of the total demand; however, when there are energy traded, the energy from the grid is 78.6 kW, 51.7% of the total load, which means that the community local market has reduced the grid dependence in 23.6%. In saving terms, the community electricity bill for 24 h arise to 9.15€ in scenario (A); however, under (B) scenario, the cost decreases to 5.68€ and considering energy traded among peers 4.79€, which means a 15.7% in saving regarding the scenario (B) and 47.6% of the scenario (A) (Table 2).

Table 1. 5-test system case: bus 4 results
Fig. 2.
figure 2

IEEE 5 bus system: energy traded, 12 am

Table 2. 5-test system case: summary table results

3.3 IEEE 33 Bus System

The second case of study considers the IEEE 33 bus system [15], which has been modified to includes a high DERs penetration, i.e., the PVs and Batteries power installed represents 61.8% and 70.9%, respectively, of the total power demanded. The DN has 33 nodes, 32 lines, and 32 load points, where the load profiles used in Fig. 1 has been replicated to the 33 bus system.

Table 3 shows the comparison results for the same scenarios explained in the previous section. Thus, the internal market; traded 10% of the total load; the self-consumption round the 27% for scenarios (B) and (C); the batteries provide 8% of the energy to meet the load; and the scenario (C) shows a lower dependence from the external grid purchasing 12% less than the scenario with DERs but without energy traded. In terms of savings, scenario (C) continues been the most efficient because it paid 9.13% less than scenario (B) and 39.7% less than scenario (A). These results are aligned with the first case of study, and they are consistent with the expected values for an energy local trading market.

Table 3. 33-test system case: summary table results

4 Discussion and Next Steps

The model presented in this paper allows computing the efficiency obtained when a community network with high DERs penetration exchange energy among peers to met the load, minimizing the energy purchased to an external grid. Besides, the formulation proposed could favour creating local energy markets identifying and quantifying every user share, addressing one of the main barriers of this new market structures. However, the formulation presents several assumptions that could relax to improve significantly the model proposed. For example:

  • Use the AC power flow equations to represents more realistic technical constraints.

  • Consider the slack bus like interconnection point among peers to sell or buy energy to the grid, and size possible congestion level produced by the energy exchanged.

  • Include electric vehicles and observe their role when they are connected and operate like flexible service to the users.

  • Change the global internal trading price to a competitive price to move toward a decentralized market design, where the model proposed to act as a master problem to identify the energy amount that should be traded, and a subproblem could establish the final price for every user that could buy or sell energy into the local market.