An Optimization Based Community Model of Consumers and Prosumers: A Real-Time Simulation and Emulation Approach

The electricity consumption pattern is being increased day by day. Currently, network operators are moving towards renewable energy resources and applying demand response programs. However, the small and medium scale consumers and producers are needed to be aggregated and participate in the electricity markets as a unique resource. This paper proposes an optimization-based community model for aggregating the small scales consumers and producers. The model includes a central controller, which is considered as an aggregator, and several local community managers to keep the network balanced locally. Furthermore. real-time simulation approach and several real devices as hardware-in-the-loop are used to validate the system under practical challenges. The results of the paper reveal a gap between the simulation and experimental results and prove the performance of system in real-time mode using actual devices.


Introduction
The actual trend of power systems operation and continued growth of consumption forced the network operators all around the world to consider Distributed Renewable Energy Resources (DRERs), such as Photovoltaic (PV) and wind turbine [1]. In order to effectively merge the large scale of DRERs in the network, further tactical services are needed, such as Demand Response (DR) program [2]. In fact, DR brings flexibility in the current trend of power systems, enabling the network operator to relieve congestion of the grid and reduce the peak periods [3] [4]. DR program is defined as the modification in the consumption patterns of the end-users in order to respond to the incentives paid by DR entity [5]. Based on the information provided by [6], there is a limitation for minimum reduction capacity by consumers and prosumers (consumers who can also produce electricity) in order to participate in the DR programs (i.e. 100 kW [7]). This limitation makes the small and medium electricity customers almost incapable to participate in these kinds of management programs [8]. Therefore, the need of a third-party entity is evident in this context (i.e. aggregator), in order to aggregate all small and medium consumers and prosumers and participate them as a unique resource in the electricity markets [9]. This paper presents an optimization-based community model for electricity consumers and producers. The model contains a central controller unit (i.e. aggregator), and several local community managers to control the electricity network locally, as Fig. 1 shows. An optimization algorithm is also used for the community model to optimally schedule the resources and apply DR programs [10]. Furthermore, real-time simulation and several laboratory resources are employed using Hardware-In-the-Loop (HIL) method, to survey the performance of the model by actual consumers and producers.
There are plenty of related works in this context. In [11], the authors presented a smart community model to control the energy resources of its member by establishing contract. Also, a single period optimization algorithm was used in the same work to minimize the operational cost of the community by applying different types of DR programs. In [12], a real-time simulation model has been presented for a curtailment service provider, and an optimization problem was used to perform energy scheduling and applying DR programs. In [13], a real-time commercial aggregator model has been presented that utilized flexibilities offered by its customers to participate in the market bids and negotiations. The emulation results of the same work showed the effect of participating DRERs and microgrids for minimizing the congestion management of the network. The work presented in [14] focused on an aggregation model for optimal energy resource scheduling. The same work also proposed several automation layers in an office building that can be used by the aggregator for decision support techniques and participation in DR programs. Finally, in [15], a decentralized framework has been developed for a small rural community to enable the users to participate in DR programs. The framework consists of several controlling subsystems, and the real-time operation of the system have been surveyed through a case study.
However, the contribution of this paper is centred on two levels: (i) Real-Time Simulation: to develop a Simulink model for the community model, running in real-time and obtaining the simulation results; (ii) Laboratory Emulation: to test the model with actual and laboratory resources under practical challenges and technical issues. Also, the novelty of this work is to develop a community platform that integrates both theoretical and practical concepts in a unique model. This enables the users to take advantage of practical characteristics, such as behaviour of devices in actual environment, into the theoretical models.
After this introductory section, the real-time simulation model for community is described in Section 2. The components modelling used for system are shown in Section 3, and the proposed optimization method is described in Section 4. A case study in Section 5 is set to validate the system, and its results are presented in Section 6. Finally, Section 7 explains the main conclusions of the work.

Real-Time Simulation Approach for Community
This section describes the theory of the proposed community model. As Fig. 1 illustrates, there is a central management entity in the model, which is an aggregator. Also, there are several local managers that are responsible for local communities of consumers and prosumers. In fact, the aggregator is accountable for communicating with each local community manager to keep the network balanced and perform other tactical services, such as DR programs. The main purpose of using local community managers behind of aggregator is that the energy balance being performed locally in several small communities, which then can be employed in the local transactive systems and peer-to-peer electricity markets. Moreover, the aggregator in this model is an entity between the upstream level and demand-side level of the power system. In the upstream level, it negotiates with the market operators, and in demand-side, it deals with local community managers for defining the DR programs, and purchase or sell energy to them. The main focus of this paper is given to the downstream level of the aggregator and technically validating the performance of the community model. In this community model, the main intention of the aggregator is to supply the electricity demand from the local energy resources and prevent purchasing energy from the electricity markets. In fact, the aggregator is not owning any resources, and it only controls and manages the rate of consumption by applying for DR programs and paying remunerations to the consumers and purchase the surplus of the generated power by the prosumers.
Therefore, aggregator in this model is not accountable for the technical validation of the network, such as voltage or frequency control. These technical management of the network in this model is considered as the responsibilities of the grid operators, such as Distribution network operators (DSO). Furthermore, the aggregator is able to perform energy transaction between the local communities to keep the network balance without buying energy from the electricity markets. Also, the aggregator is able to perform scheduling of the resources by relying on the external supplier (electricity markets), RERs available in the community, and DR programs. While the aggregator keeps the network balance between all local communities, it can negotiate in the electricity markets with the flexibilities provided by each local community. In fact, the aggregator can present several bids in the market with the available energy from the local communities and a certain price that has been obtained based on the financial profits of the customers.

Components Modelling
This section presents the real-time simulation architecture, and proposed model for the HIL methodology. The main player of this model is OP5600 (www.opal-rt.com). In fact, OP5600 is capable to run the MATLABTM/Simulink models in real-time that enables the operator to integrate the real data in the Simulink environment via HIL methodology.
In other words, OP5600 integrates the emulation and simulation results in a unique model that can be used for the management and control scenarios, such as optimization algorithms and resources scheduling. This integration enables the system to have more reliable results to verify and validate the performance of the model under practical challenges namely voltage variations, frequency instabilities, devices response time, etc. Fig. 2 shows the Simulink model concerning a part of the community electricity network placed. As Fig. 2 demonstrates, all consumers are modelled by a three-phase dynamic load model, where all of them are connected and supplied by a three-phase source model. Furthermore, there are several three-phase series RLC branch blocks to simulate the impedance of each line in the network. By this way, the model can provide the most accurate and near to real results.
In Fig. 2, the colour of each block indicates its role in the community model. Dark green and red blocks are showing the consumers of the community (e.g., residential and commercial buildings), and light green blocks are the RERs (e.g., PV units). As it was mentioned, real laboratory devices are integrated into the proposed Simulink model via HIL methodology. For this purpose, three network players of the community model are dedicated for the HIL devices and considered these three players are real consumers and producers, as Fig.2 shows. The HIL devices are two laboratory load banks and a real top roof PV installation. The two load banks are a 30 kW and a 4 kVA loads considered as two HIL consumers in the model. In the 30 kW load, there are four relays that increase or decrease the desire rate of consumption, and in 4 kVA load, there is an Arduino® (www.arduino.cc), which manages the amount of consumption.
In the top roof PV, the model only acquires the real-time generation data and integrates them in the Simulink. The nominal generation rate of this PV installation is 10 kW. The hardware installation and configuration of the HIL devices have been developed by the authors in the scope of their previous works, and more detailed information is available on [16].
To sum up, by using the Simulink models shown in this section, the user can specify any rate of consumption and generation to be simulated and emulated through the full simulation models as well as the HIL devices. Also, it is possible to compare the results obtained from real equipment with the gained results from the full simulation models.

Components Modelling
This section discusses the proposed optimization method for the community model. The objective is to find a balance locally to minimize the operational costs. For this purpose, the proposed optimization algorithm considers a linear cost for each resource and performs the optimization in line with the costs in each single period, t.
In this way, the following optimization algorithm has been developed where all consumers participate in DR programs (PDR). Distributed Generation (PDG) units and External Supplier (PSupplier) are the energy providers in this model. All the consumers from DR programs should have a pre-contracted reduction limit as well as the remuneration tariffs associated with each one. Equation (1) presents the objective function of the problem. In (1), C is the associated cost for each resource.

Min OF = ∑ [PDG (p,t) CDG (p,t)] + ∑ [PDR (c,t) CDR (c,t)] + ∑ [PSupplier (s,t) CSupplier (s,t)]
( This function is from the local community managers standpoint and considers all the different participants and their associated costs. The goal is to guarantee the balance in the local communities, as shown in (2). In the hypothesis of the local communities, the manager won't be able to find the equilibrium locally with only production from DG units, an external supplier is applied. The idea is to only use external suppliers in extreme case, giving always priority to the DG units in the local community network.

∑ [Pinitial (c,t) -PDR(c,t)] = ∑ [PDG (p,t)] + ∑ [PSupplier (s,t)]
(2) Equation 2 shows that sum of consumption (should be the possible reduction from DR program for each consumer to its initial load -PInitial) equals the sum of production (all DG units and Suppliers) to find the network balance. In this objective function, there are other constraints that should be considered. Firstly, the restriction associated with the consumers belonging to DR programs, and the maximum reduction capacity (P Max DR) is presented in (3).

PDR (c,t) ≤ PDR Max (c,t)
For distributed resources, the DG units are limited by (4) and (5) being the upper bound and the total amount that can be used from DG units, respectively. In the case of PV production, (4) and (5) would come as equality equations, so all the PV production should be used.

∑ [PDG (p,t)] ≤ PDG Total
In the case that external suppliers are needed, (6) -(9) are introduced. The upper bound and the total available amount helps the local community managers to restrict the use of this option.

P Reg
Supplier(sr,t) ≤ P RegMax Supplier (sr,t) In fact, in this optimization two types of external suppliers are considered: Regular (P reg supplier); and Additional (P add supplier). The additional supplier is considered as an auxiliary supplier that would be used while the regular supplier is not able to provide the committed amount of energy. Also, additional supplier is considered as a more expensive resource comparing to the regular supplier.
In this way, P regMax supplier and P addMax supplier are maximum power from a regular or additional supplier respectively. Also, P regTotal supplier and P addTotal supplier are total power allowed from all the regular and additional suppliers respectively. Therefore, the use of external supplier is being optimized by the proposed algorithm to minimize the costs, while network balance has been respected in all communities.
The output of optimization algorithm proposed in this section is a requested amount of power for each consumer to reduce its demand in a certain period. The actual implementation of this demand reduction request in a real load will depend on the electrical grid conditions. This is in fact one of the advantages of using real-time simulation (in this paper OP5600) and laboratorial equipment for consumption modelling. In this way, the actual demand reduction will be validated to be included in the simulation results, namely for remuneration purposes.

Case Study
This section focuses on a case study in order to test and validate the functionalities of the developed community model. For this purpose, it is considered there are four villages in the proposed community network that each is being controlled by local community manager. The number of consumers and producers in this community network is shown in Table 1. Therefore, there are 156 consumers and 108 PV units in the community in total. The consumption and generation profile of the entire community network considered for dayahead scheduling are illustrated in Fig. 3.
As it is clear in Fig. 3, a huge part of consumption and generation of the community is dedicated to the Village 1. The profiles shown in Fig. 3 -B has been created by aggregating several real generation data from GECAD research center database, Porto, Portugal. As it was mentioned in Section 4, the priority of the system is to supply the electricity demand from the local generation resources (i.e. PV units). In the periods that the local resources are not adequate to supply the demand, the system decides to purchase energy from an external supplier or apply DR programs to reduce the consumption. This is dependent on the market prices and the incentives that are being paid to the customers for applying DR. There are two types of electricity prices considered in this case study, as Fig. 4 shows. In fact, the market price belongs to the energy that aggregator purchases from the electricity markets and External Supplier price are for the energy that aggregator sells to the local community managers.  The electricity market price shown in Fig. 4 have been adapted from Portuguese sector of Iberian Electricity Markets (MIBEL -www.omie.es). Also, the External Supplier price is based on Time-Of-Use (TOU) scheme according to the tariffs provided by incumbent Portuguese electricity retailer in the liberalized market (EDP Commercial -www.edp.pt). Furthermore, a linear cost considered for the energy resources of the community. Also, Table 2 shows the linear remuneration costs regarding DR programs considered for each consumer based on its type. These costs are for load reduction, and in this case, study it is considered that 7% of initial consumption belongs to the maximum load reduction capacity of customers.

Results
In this section, the optimization methodology is being solved by RStudio ® tools (www.rstudio.com) using the presented case study data, and the results are shown. The algorithm is solved on a personal computer with Intel® Xeon® CPU @2.10 GHz, and 16 GB RAM. The total solving time of the optimization problem was 6.92 seconds, which the average time per iteration was 0.04 seconds, and 51.3 MB was used during the problem solving. While the optimization results have been adapted, they will be provided to OP5600 to validate the system using real devices. Considering the accumulated results from all villages, Fig. 5 presents the difference between the initial load profile of all communities and DR reduction results while applying the optimization methodology. The highest reduction value from DR programs is reached around the period of 46, reducing the initial load from 305.98 kW to 284.56 kW. Fig. 6 shows the optimization results for all the resources, from aggregator point of view. According to Fig. 6, the highest supply from PV units in this case study is 24% of the total production needed to satisfy the demand of the community. In village 1, the total remuneration cost during the case study is 52.57 m.u./kWh, and in village 2, the total remuneration equals to 44.39 m.u./kWh. Also, in village 3 and 4, the total remuneration cost is respectively 14.09 and 0.16 m.u./kWh.  Moreover, since there are a lot of consumers and producers in the model, only some sample results are demonstrated. Fig. 7 -(A) shows the consumption profile of a residential building that has been fully simulated by community Simulink model. Also, Fig. 7 -(B) shows the consumption profile of a public building in community network emulated by the HIL devices. The results shown in Fig. 7 is for 96 periods of 7 seconds (672 seconds in total).
As Fig. 7 -(B) shows, while the consumption rates are being changed, the laboratory devices need some time to reach the favourable rate of consumption. In fact, this is the main differences between the laboratory experiments and simulation models; in the simulation environment the consumption rates change instantly (Fig. 7 -(A)), although, the consumption profile emulated by the HIL devices used in this model require some times to reach the favourable rates since several technical challenges and practical conditions are involved, such as voltage and frequency variations.

Conclusions
An optimization-based community model was proposed in this paper. The model contained an aggregator and several local community managers to optimally schedule resources and apply for demand response programs. Also, a real-time simulation model was shown to validate the proposed community model. The actual implementation of demand reduction and consumption profiles were shown as well.
This implementation of some resources in practice validated the performance of the model under practical challenges and electrical grid conditions. In fact, this is the advantage of using real-time simulation and laboratory equipment, since the actual demand reduction is being integrated with a full simulation model. So, the system is able to provide more reliable results, which can be useful in network management scenarios, such as remuneration and scheduling purposes. This work has received funding from Portugal 2020 under SIMOCE project, from H2020 project DOMINOES, and from FEDER Funds through COMPETE program and from National Funds through (FCT) under the project UIDB/00760/2020, and CEECIND/02887/2017.