Federating Smart Cluster Energy Grids for Peer-to-Peer Energy Sharing and Trading

With the rapid growth in clean distributed energy resources involving micro-generation and flexible loads, users can actively manage their own energy and have the capability to enter in a market of energy services as prosumers while reducing their carbon footprint. The coordination between these distributed energy resources is essential in order to ensure fair trading and equality in resource sharing among a community of prosumers. Peer-to-Peer (P2P) networks can provide the underlying mechanisms for supporting such coordination and offer incentives to prosumers to participate in the energy market. In particular, the federation of energy clusters with P2P networks has the potential to unlock access to energy resources and lead to the development of new energy services in a fast-growing sharing energy economy. In this paper, we present the formation and federation of smart energy clusters using P2P networks with a view to decentralise energy markets and enable access and use of clean energy resources. We implement a P2P framework to support the federation of energy clusters and study the interaction of consumers and producers in a market of energy resources and services. We demonstrate how energy exchanges and energy costs in a federation are influenced by the energy demand, the size of energy clusters and energy types. We conduct our modelling and analysis based on a real fish industry case study in Milford Haven, South Wales, as part of the EU H2020 INTERREG piSCES project.


I. INTRODUCTION
The new era of smart clusters energy grids technologies can bring significant improvements in the energy management and generation mix of energy networks. Renewable energy generation, optimisation of supply and demand and demand-side management techniques will become more pervasive in the energy landscape helping rural and urban clusters to be at the forefront of new smart grid economies. The digitalisation of smart grids with more data driven mechanisms for flexible consumption and use of renewable at consumers sites can lead to the formation of smart energy clusters enabling users to control of their energy and participate as ''prosumers'' in a market of energy services [1].
With the climate change agenda, there is a need to develop smarter energy solutions that can address the industry The associate editor coordinating the review of this manuscript and approving it for publication was Xianming Ye.
limitations and achieve many of the attributes necessary to manage the smart grid with its thermal loads with renewable energy integration at remote locations. If the old energy systems are depicted as large centralised power generation with old, unidirectional infrastructure, the new smart energy solutions need to be based on distributed local energy generation shared in a dynamic environment where supply and demand can be better managed, and inefficiencies reduced [2]. There is also a tendency towards small energy clusters which can act like micro-grids and have the ability to trade with each other and eventually roll up to a regional and then national level to form the smart grid [3]. In general, the architecture of existing energy systems is centralised, with few proposed decentralised energy models [4], involving microgeneration [5] and storage models where consumers are not involved actively within the energy market. Centralisation and the lack of active involvement of consumers are primarily determined by limited technological solutions and VOLUME 8, 2020 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ inaccurate incentive models for energy providers and consumers to engage with the energy landscape.
Recently, prosumers are increasingly generating their own energy by investing in solar panels and micro-wind installations and move towards community development. An example is the 300 community energy projects in Scotland [6], where energy services are shared across a community of users much connecting urban and rural communities with technology innovations. In such energy communities, users are enabled to exchange their energy services within a local market by maximising the benefits of renewable energy by trialling new technologies and making clever use of heat or power [7]. Energy transactions can be coordinated through the use of P2P networks based on their powerful coordination mechanisms for energy exchanges via scheduling and monitoring. Blockchain is a method for maintaining such transactions as an immutable ledger suitable for individual homes or industries to value the excess of energy generated by solar panels or stored on batteries, for trading in a local market [8]. Industries and energy businesses need to become more competitive by promoting more efficiennt strategies for cost optimisation of energy consumption. In fish industries, for example, energy consumption and costs are continuously increasing with heavy environmental impact from carbon emissions demanding for more intelligent techniques for managing their energy load, production and consumption [9], [10].
With the recent advent of the sharing economies, consumers can be motivated to participate in a leasing economy where services are used for a shorter period and more accessible via the concept of community sharing [11], [12]. The ability to participate in such a sharing economy also provides greater choice for both the consumer and the provider, enabling a much greater flexibility in being able to switch between multiple market offerings, thereby increasing consumption from consumers by not being restricted to products or price constraints from a single producer.These relationships provide strong basis for enabling a P2P energy sharing environment where energy consumers and providers are free to trade openly based on their resources availability.
In an energy sharing market, consumers requesting energy services and providers generating energy types can also act as micro-entrepreneurs that can monetize their offerings. P2P energy sharing networks can enable the discovery of suitable providers able to meet particular, often specific and individual demand from consumers. P2P sharing models also provide the ability to associate some degree of confidence in the likelihood of the energy provider being able to meet their advertised energy capability. Energy consumers and providers become therefore, independent contractors, working for themselves with control over their service requests and associated quality of service [13].
Federating energy clusters using Peer-to-Peer (P2P) networks can bring numerous advantages in energy delivery through loss reduction and more informed consumption schemes in the decentralisation of common market sellers, buyers and brokers. The advantages of sharing energy are linked to the flexibility of the micro-grids by decreasing the demand and grid load in relation to local demand [14]. The creation of federated energy clusters can lead to new consumption models between consumers and providers and can incentivise energy actors to participate in a secure and more efficient market place. The energy network can be scaled up to reduce the limitations of traditional energy businesses [15] by facilitating trades and energy sharing across energy clusters. Such P2P networks introduce more robust coordination of the energy exchange process by registering a log of relevant parameters such as time and location for energy transactions [16].
In this paper, we explore the formation and federation of smart cluster energy grids using P2P networks with a real case study application from the fish industry. The paper aims to deliver a P2P energy federation model with a view to incentivise the development of distributed energy systems. We explain how the federation of energy clusters can enable the integration of the existing energy market actors into a more flexible community ecosystem that can serve to small and medium enterprise, local business and consumers. We implement several simulation scenarios to enable a holistic evaluation of various behaviours of energy actors and study their interactions when participating in a market of energy services. We validate our analysis with data and energy models from a real fish industry case study from Milford Haven port, South Wales, UK, as part of the EU INTERREG piSCES project.
The rest of the paper is organised as follows: In Section II we report related works in the field of smart energy clusters. In Section IV, we present the overall methodology of the paper with associated policies and models. In Section V, the energy community cluster simulation is presented, followed by different evaluation scenarios for supporting the research objectives. The results of the experiments are presented in Section V-C. The validation of our research in a real case study project is presented in Section VI. Discussions and conclusions are presented in Section VII and Section VIII, respectively.

II. RELATED WORK
Addressing global warming with the implementation of intelligent systems can improve renewable energy utilisation while decreasing the carbon emissions to support the green energy agenda [17]. Such renewable energy sources represent a vital sustainability factor for the next decades [18]. According to the US Department of energy, the use of renewable energy sources will increase to about 18% of the total amount of energy use by 2040 [19], [20].
As a smart grid involves a coordinated use of the electricity network with subsystems that can support and integrate several behaviours and actions for a network of connected users, generators, consumers, a direct impact on the economic efficiency and sustainability is also required when reducing energy losses and maximising the quality and security of energy supply [53], [54]. Smart grids stimulate the integration of renewable energy resources with local energy systems and can increase the reliability of the power systems. In smart grids, consumers play a vital role, as they can manage the energy system smartly to reduce power consumption in peak periods and improve the overall energy efficiency [55]- [57]. Transmission of electricity from producers to consumers with the aid of computer systems through control automation, continuous monitoring and optimisation of the distribution system can also be facilitated by a smart grid with a view to reducing the cost and increasing the reliability [58], [61].
Peer-to-Peer networks have been used for energy grids to manage the excess of energy and to support energy distribution within a shared energy pool of consumers and providers. The individual energy nodes of the P2P based micro-grids have autonomy and can act independently using fault tolerance techniques to ensure grid reliability and self-adaptabiliy. In a P2P energy network with energy nodes forming microgrids, each producer and consumer can join or leave the grid at any time based on collective behaviours that are defined by the community itself [59]. Similarly, P2P energy networks can have different energy services (solar, thermal, wind, hydro) that can be efficiently harnessed, stored and transmitted among users of the energy network. This can lead to the emergence of energy communities that have specific rules in relation to energy usage, participation policies specified by the users of the community [60].
Sharing in P2P energy networks involves a robust decision making process and a reliable mathematical model to ensure equity of shared interests and optimal motivation between prosumers. Several studies use game theory for P2P energy trading as a mean to ensure reliability in supporting energy exchanges, whereby the use of P2P networks for energy trading becomes a cost optimization problem with different types of algorithms [62], [63].
Recently, P2P sharing economies have introduced new efficacious trading models to enable prosumers in a smart energy community to share their energy surplus with others. To accomplish such energy trading, an open and more flexible environment is required to enable interaction between consumers and producers [62], [63]. Several studies have applied game theory approaches for energy trading due to their feasible and effective methods to handle interactions between energy actors. As reported by related studies, the P2P energy trading can be facilitated using different types of algorithms. For example, the Stackelberg equilibrium game was used in [64]- [67] to optimise the energy cost and social benefit in P2P energy system; a game theory approach was developed in [32], [68]- [71] to optimise energy use and maximise energy incomes for P2P energy prosumers. Harish et al. [72] proposed a nonlinear optimisation problem to minimise energy costs and losses during transmission while Long et al. [73] developed a linear programming problem to maximise the local balance between participants. Zhang et al. [74] and Nguyen et al. [75] applied a mixed-integer linear programming method for P2P energy trading.
A simulation of P2P energy systems is supported in the ''Elecbay'' platform [76] that devises P2P energy trading environment for a grid-connected micro-grid. Elecbay can simulate buyers, sellers, suppliers (suppliers can act as buyers or sellers) that have the ability to sell and buy energy by scheduling the energy devices in their own premises typically for small-scale residential and commercial buildings. In previous work, we have also investigated incentive models for users to contribute with services over a P2P network [13], [77]. This can range from bartering of resources, improving the social standing of a participant within an community or obtaining financial rewards. It was observed that in open markets it is necessary for service consumers to discover suitable providers of interest greatly leveraging on the advantages offered by P2P networks. The P2P simulation leverages on the ''sharing economy'' principles with view to unlocking the energy trading in local distribution networks [76]. Such P2P sharing allows each energy nodes to decide with which energy node to trade (buy from or sell to) energy according to its own objective, e.g. minimum costs, a specific energy type, most reliable energy supply, etc. We demonstrate such P2P energy sharing principles by implementing a scalable P2P simulation environment that has the capability to support energy transactions among energy nodes while also enabling monitoring and control of the energy distribution network. In addition, different trading rules can be implemented by a simulation platform with significant influences on the decisions made by peers when trading with other peers.
In this paper, we propose a modelling and implementation for P2P energy markets. We simulate a forward market projection to understand how such energy markets can evolve when various indigenous and exogenous factors change, as illustrated in Figure 1a. We devise a scalable experimental framework that enables the validation of the following research questions: • How to simulate a forward energy market environment where energy consumers and producers organised in clusters can carry out energy trading with each other; • How to conduct scalable analysis and optimisation strategies for P2P energy markets with a view to support VOLUME 8, 2020 the development of smart industrial grids for ensuring their transition towards clean energy; We aim to implement and test scalability factors in energy markets with the objective to demonstrate more decentralised and adequate energy sharing models for industries. We also propose more informed strategies for managing production and consumption at the cluster level via energy analysis based on data and specifications from a real fish industrial site.

III. MILFORD HAVEN INDUSTRIAL SITE
Milford Haven Port represents the UK's largest energy port and has the largest oil and gas business capable of delivering around 30% of the UK gas demand. The port operates a fish processing industry where large quantities of fish are shipped and processed to other factories and supermarkets. The port has a cluster of buildings customized with appliances where the fish processing activities are carried out. The port uses energy from the local PVs (photovoltaics) and a solar farm. The site aims to reduce energy consumption and CO 2 emissions by developing a smart energy cluster that can manage energy production and consumption more effectively in the port [78].

A. THE SITE OF INDUSTRIAL BUILDINGS
The port has five main buildings producing energy from local PVs linked to the national grid: Packaway, K SHed, M Shed, F Shed and J Shed (see Figure 1b).
Packaway Building is the main building of the site and contains several energy-consuming appliances: flake ice machine, ice flake, box washing machine, lighting and smart meters. The Packaway building has a PV production capability with 50 kW panels supplying the building with a total output of 275 W per panel with two DC-AC inverters.
K Shed is a warehouse with a cold room used by clients to store fish. The cold room is supplied primarily from solar photovoltaic panels with 50 kW capacity.
M Shed has an internal lighting system and several appliances. Building units B&C are used as storage facilities, while Unit A is used as a boat repair facility and as an office area for an incident response contractor. The simulation has been design based on real site configurations identifying a number of consumption (i.e. ice flake, cold room, etc.) and production units (i.e. photovoltaics).
The site level has a number of buildings forming a cluster (i.e. Packaway, F Shed, etc) with their associated production and consumption behaviors whereas the building level relates to several consumption and production units. These entities and their interactions have been modelled in a simulation framework with the objective to increase scalability in analysis and deliver a forward market perspective for industries. These assumptions and framework variables have also been utilized in Section VI to deliver the ''in-cluster'' energy optimization.

B. SMART ENERGY CLUSTER SCENARIO
In the Milford Haven energy cluster, we identify the following consumption and production units in relation to a set of objectives as presented below.
Consumption and production units: • Ice Flake machine -The ice storage system is under operation all the time during the day and can be optimised by determining operating schedules based on daily demand.
• Cold room-The cold room is the main appliance in the building identifying a fairly high power consumption. Determining the correct temperature set-point and an optimised operating schedule can lead to a significant reduction in energy use.
• Box washing machine -The box washing machine has a power capacity of 50 kWh and only works on a limited daily interval.
• Lighting -The lighting system in this building is about 23 double tubes of 25 W each and is only used during the night.
• Solar PVs -The solar PV system for each building has a capacity of 50 kW with panels installed across all buildings on the premises. Objectives: • Energy consumption and cost minimization -Based on energy management strategies the objective is to propose exchange strategies that can reduce energy consumption and costs.
• PV generation and storage optimisation -The aim is to determine how production evolves based on different schedules with a view to analyze production peaks and developing efficient energy storage strategies.
• CO2 emissions reduction -This involves finding the correct consumption-production equilibrium and a more efficient use of renewables for each pilot building.

IV. MODELING P2P FEDERATED ENERGY CLUSTERS
In this section, we present the P2P federated environment to simulate scenarios and test the research hypothesis. The system works with a set of energy nodes (peer-nodes) identifying providers and consumers P = {p s1 , p s2 , . . . , p k }, that form energy clusters, where each producer can generate one or multiple types of renewable energy services (solar, geothermal, wind, hydro) in a specified quantity and with an associated cost. Each consumer node can place energy requests periodically based on a predefined probability. Within the system, we enable the interaction between different energy clusters and nodes (consumers and producers), as illustrated in Figure 2, where producer and consumer nodes can be organised in clusters. We model each energy cluster to have a set of energy nodes that are programmed to produce or request energy based on their preferences and production capability. An energy node represents an independent entity of the energy network that can produce or consume energy services during the simulation process. Based on the modelling, energy nodes are by default included in a cluster where nodes from the same cluster are forming an energy network in the network graph. By default, energy nodes are programmed to exchange energy inside the cluster or federating energy services across clusters when different exchange criteria are applied [79].
The proposed model simulates a scaled energy network (electrical network) in which energy clusters arise having certain energy types and certain demand levels as in a smart grid model. In the simulation, the energy network is a Peerto-Peer network, in which each energy node has a maximum number of links. Each link is bidirectional; a connection of a node a to another node b implies a connection of node b to node a. Links are undirected so the entire energy network can be considered as an undirected graph where each vertex is a energy node and each edge is a link in the energy network. In the simulation, energy nodes try to perform energy exchanges under different configuration scenarios based on their links with neighbors nodes (i.e. trading paths) under the restrictions of availability of energy resources and simulation constraints.
The formation of clusters is performed randomly with nodes organised into clusters where two types of interactions between the nodes: (i) in-federation energy exchanges (in Section V) where energy exchanges take place across multiple clusters and (ii) in-cluster energy exchanges (in Section VI) where energy exchanges take part inside the cluster.

A. FORMALISING THE CLUSTER FEDERATION
To model the federated cluster system, we consider a set of exchanges t = {e 1 , e 2 , e 3 , . . . , e n }, where each e i represents an energy exchange (transaction), programmed to be executed during the simulation and p i identifies the corresponding price of the energy exchange. Energy node has bidirectional connectivity, where each network edge has specific properties in each direction.
In the set of exchanges, one exchange e i is configured with a set of parameters: [energy − type, quantity, price, payoff ]. The execution of the energy exchange is programmed based on a predefined request probability where an exchange e i involves a price to be paid by the consumer and a payoff to be received by the provider. The coordination of the exchanges for a cluster is performed by the energy cluster manager as illustrated in Figure 2, which manages the interactions of all energy nodes in the system. In the initialization phase, each cluster manager registers the energy capability of each node and coordinates the entire exchange process. We assume that during the simulation, every energy node can deliver a limited energy capability (type and quantity).
The federation is coordinated by an assignment function f (t s ) that allocates energy capabilities to all energy nodes: f (t s ) : P → S, where t s identifies the energy type associated to a node and P identifies the group of nodes from the system and S represents the number of energy capabilities.

1) ENERGY EXCHANGE PROCESSING
To model the energy sharing framework, we consider a set of energy requests assigned to energy nodes in a cluster as presented in Figure 2. The exchange process is coordinated by the community manager, which selects energy requests in relation to a specified energy capability and can broadcast/multicast the energy request with associated constraints to its local energy cluster. When the cluster manager receives an energy request, multiple candidate energy nodes can subscribe to provide the energy capability referred to in the request. Alternatively, an energy request can be satisfied by the joint contribution of nodes when an energy request has an increased energy quantity to be satisfied. Within the clusters, the following cases can be identified: • CM i request of energy services with capabilities that exist in the local energy cluster: • CM i request of energy services with capabilities that need to be delivered by using multiple energy nodes • CM i request of energy services within a certain price range • CM i request of energy services with associated price ranges based on the energy services delivered within the local cluster In general, when an energy request is received from the cluster manager (CM), the responding energy node p i will: (i) parse the incoming energy request and measure the energy capability associated with the request t i . When an energy node p i decides to deliver the requested energy service, the cluster manager will update the remaining energy capability within the cluster, marking node p i as unavailable for other exchanges or (ii) returns a message to the cluster manager (as a message exchange) presenting the intention to collaborate with energy nodes in its local energy cluster or outside the cluster, for executing the requested energy transaction.
In the cluster federation, we measure the total of energy exchanges (see equation 1), total energy cost (see equation 2) and total energy consumption (see equation 3) as metrics to determine the impact of different variables on the federation in different simulation scenarios. As presented in Equation 1, n represents the total number of exchanges: where e ij represents the quantity of energy exchanged between two energy nodes i and f and n represents the number of exchanges in the system.
where the parameters of the energy.network(t) change during the simulation based on the quantity of energy quantity(t) being exchanged between two nodes. The cost cost(t) identifies the price of the exchange (t), plus an additional payoff α which is the incentive for an energy node to engage with the exchange.
where s k represents the quantity of energy that an energy node k is consuming and r represents the number of consumer nodes in the cluster.

V. IN-FEDERATION CLUSTER ENERGY EXCHANGES
We devise the cluster federation environment utilizing P2P simulation as a mean to analyze and test different exchange scenarios while exploring the specificities of energy clusters and their federation. The simulation of the energy federated cluster system can provide useful insights into the development of a holistic energy system with detailed analysis of scalability and performance metrics.
A. SIMULATOR To model the P2P energy clusters and associated dynamics in energy service exchanges, we have used PeerSim simulator.
In PeerSim [80] components are flexible and can provide two important advantages for the energy clusters simulation: (i) scalability in testing an increasing number of nodes and exchanges and (ii) dynamism in adding and removing energy nodes during a simulation. PeerSim modules and corresponding implementations for the simulation of energy cluster federation can support a variety of different system configurations, where the P2P network is modelled as a collection of peer-nodes (i.e. energy nodes), where each node has a list of associated protocols. A simulation starts in the initialisation phase where energy nodes and exchanges are programmed through the mean of initialisers and controls -facilitating a sequential simulation where energy nodes can have different types (producers and consumers) and exchanges are facilitated via the mechanism of ''event scheduling''. The simulation is developed over a particular network infrastructure where energy nodes are configured to execute different energy exchanges based on a Poisson distribution. Such distribution is also used to express a number of energy exchange events that can occur in a fixed period of time (cycles). The Poisson distribution is applied when counting the number of discrete events and the random variable can only take non-negative integer values. It is closely connected to the exponential distribution, which (among other applications) is used to measure the time between arrivals of the events. The Poisson distribution was chosen from the need to simulate expected events such as energy exchanges that occur independently and have a certain frequency in the system, and when the number of participants is high. As energy exchanges are submitted according to a predefined probability distribution, the experiments require sufficient cycles to ensure that an adequate number of transactions have been made.
The configuration adopted in the experiments is the following: • The size of the federated energy cluster system (N): 1000; • • Energy exchange payoffs: in the federation model, the incentive reward for each energy exchange is 1. Our framework is designed to handle the level of demand as a process that can induce fluctuation for the overall energy exchange process. For simulating the variation of demand within the market, our framework uses several assumptions. Therefore, one specific level of demand is simulated by using one view parameter. The view represents the number of neighbors assigned to each energy node within the system. The variation of the demand was ensured by PeerSim controllers, which can inject different numbers of requesting energy nodes at each simulation cycle.The following configuration parameters are used by this controller: • control.c1 peersim.dynamics.DynamicNetwork • control.c1.maxsize vmax • control.c1.add vadd • control.c1.step vstep • control.c1.from vfrom • control.c1.until vuntil The ''DynamicNetwork'' is a module provided within PeerSim which helps the simulation process to work with a differing number of energy nodes at each simulation cycles. It includes various Java packages initializing the energy network or modifying it during simulation. The maxsize parameter represents the maximum number of energy nodes that one simulation process can use; the add parameter defines the number of energy nodes injected at each step requesting energy services. The step parameter defines the stage of exchange in cycles for each injected energy node. The parameter from specifies the starting number of energy nodes to simulate while the until parameter defines the maximum limit on the number of energy nodes that the simulation can use.

B. CONFIGURATION
The P2P energy cluster federation model has been tested with different functional scenarios where parameters such as the connectivity of the energy network, the number of energy producers and energy consumers, and the set of energy types have been varied. The Peersim simulation system has imported the Newscast protocol [81] in order to manage the overlay network topology of the cluster federation. We have divided a simulation process into cycles starting with an energy network formed of 1000 energy nodes. The community simulation begins at cycle 0, where 25% of the nodes are scheduled to send energy requests. Energy providers nodes can respond to the incoming energy requests based on the different types of energy services allocated to different producers nodes.
The energy cluster federation graph is developed using a PeerSim module that organises the network into a stable artificial social network (ASN) with small-world features (see Figure 3). We continue with a random graph based on which the topology converges to a small-world characteristic social network graph [83]. The connection of energy nodes is based on a probability of rewiring, and a rewire duration, deciding when and how many energy nodes will rewire. This can modify the topology of the federation during simulation, allowing energy nodes to drop connections and to migrate between clusters. The protocol enables the formation of federated clusters that coordinate their different energy types in order to improve level of utilisation and performance.
Our simulation experiments describe circumstances under which ''in-federation'' and ''in-cluster'' interactions of individual energy nodes are identified as energy exchanges. In particular, in our experiments, we have adopted the following assumptions based on which the P2P energy market is devised: • Consumer and producer nodes holding specific energy types, seek to exchange energy resources within a community of neighbours nodes.
• These energy nodes are participating in a markets where energy requests need to be satisfied and energy offers are produced based on different energy production capabilities.
• Energy nodes are organised in clusters where a particular energy capability and demand is available via energy exchanges with energy nodes belonging to connected, self-organizational networks.
• Energy nodes are modelled as agents of a self-adaptable network, where each agent can have different behaviours and is linked to a set of neighbors nodes. During the simulation requests and exchanges are initialised at the beginning of the simulation complemented with a continuous dynamic demand that allows requests to appear with a periodic frequency of cycles. The system is able to continuously adapt to new energy requests by producing a particular number of energy transactions in the system. The validation presented in the following section aims to address the following objectives: VOLUME 8, 2020 • To provide a forward energy market perspective enabling energy consumers and producers organised in energy clusters to carry out P2P energy trading with each other; • To devise a scalable P2P energy simulation for analysing different energy consumption, production and costs scenarios using different trading strategies; and • To draw insights and lessons learnt to inform the development of industrial smart grids and their transition towards integrating clean energy sources

C. RESULTS
Using the simulation framework presented in Section V, several scenarios have been tested to assess the impact on the P2P energy cluster federation of different parameters and variables.

1) EXPERIMENT 1: TOTAL OF SERVICE EXCHANGES WITH DEMAND
In this experiment we configure the demand in the federation based on different request probabilities (10%, 25%, 50% and 75% -representing the percentage of nodes requesting energy services) in order to determine the impact of demand on the total amount of energy service exchanges. As presented in Figure 4a, the energy service requests increase proportionally with the probability of requests whereas the total of exchanges reaches a maximum for a probability of requests of 25% and 50% respectively. This is determined by the capacity of the federation to only accommodate a proportion of energy requests before reaching saturation. This experiment shows that federated energy clusters can handle increased energy demands, but a specific correlation between energy demand and the number of consumers and producers needs to be considered when designing a federated energy cluster system.

2) EXPERIMENT 2a: TOTAL OF SERVICE EXCHANGES WITH ENERGY TYPES
To conduct this experiment we consider that energy nodes in the federation can exchange services of different types where an energy type refers to a renewable energy resource (solar, wind, geothermal, hydro, etc.) with an associated cost. Figure 4b illustrates the total of energy exchanges and a total of service requests when using different energy types. It can be identified that service requests have a slight increase when using different energy types, whereas the total of energy exchanges fluctuates based on different energy types configurations. The optimum number of energy types is 3, which during the simulation generates a peak in the total number of service requests. When using 4 or 5 types of energy services types, the total number of exchanges seems to be lower than for the case of 3 energy types. This is determined by the P2P federation mechanisms which generate more exchanges when using 3 types of energy services influencing the actual market to reach an equilibrium between demand and supply but also saturation in accommodating services requests.

3) EXPERIMENT 2b: TOTAL OF SERVICE EXCHANGES WITH DEMAND FREQUENCY
This experiment shows how different demand levels for energy types can be scheduled in a federation. Assuming that nodes can produce different energy types, the experiment considers a simulation of 2 types and 5 types, respectively, with different demand duration. We use the '' dynamics controller'' which supports the injection of new energy nodes requesting services in different periods during the simulation (i.e. from cycle X to cycle Y). For this experiment, we consider four demand scenarios at each cycle (i) 10 new node requests in demand, (ii) 20 new node requests, (iii) 30 new node requests and (iv) 100 new node requests, respectively. From Figure 4c we observe that dynamic frequency impacts the overall number of exchanges. When using specific energy types, the number of exchanges is limited although the demand is continuously increasing. For 2 energy types, the number of exchanges is increasing significantly in the context of different demand configurations. The federation is influenced by the dynamic demand factors where new demand requests bring an increase of energy exchanges. The sensitivity of exchanges for 2 types of energy seems to be higher than for 5 types, however an increase of demand for 5 types produces a higher number of energy exchanges in the system.

4) EXPERIMENT 2c: TOTAL OF SERVICE EXCHANGES WITH DEMAND DURATION
In this experiment we demonstrate how demand duration can influence the total number exchanges in the system. We have analyzed different demand configurations as (i) long demand  Figure 4d where long demand seems to produce more energy exchanges than medium and short demand duration. The results are also influenced by the limited number of cycles during which all requests need to be submitted and satisfied and the maximum number of nodes allowed in the system (1000) which constraints the number of requests submitted.

5) EXPERIMENT 3: TOTAL OF SERVICE EXCHANGES WITH CLUSTER SIZE
In this experiment, we are interested to understand the correlation between energy exchanges and the size of energy clusters in the federation and how such federation can be organised more efficiently. As reported in Figure 4e, the size of the energy clusters can significantly impact on the number of exchanges within the federation. As an energy cluster refers to a number of connected neighbors, the cluster size also has an energy distribution impact as it primarily identifies potential energy trade routes associated with a node. It is observed from Figure 4e, that the number of exchanges is increasing when using larger energy cluster wheres the total number service requests remains constant. When more neighbours nodes are available in a node's exchange view, more routes to exchange are available hence generating an increase in the total of exchanges. VOLUME 8, 2020

6) EXPERIMENT 4: TOTAL ENERGY COST AND CONSUMPTION WITH ENERGY TYPES
In previous experiments, we have investigated how different configuration parameters influence the total of energy exchanges. In this set of experiments, we are assuming that cost with energy consumption can be triggered by a particular inventive for users such as price with energy, accessibility of energy resources, cluster performance and level of payoffs.
In Figure 5a, we observe that cost with energy exchange and total energy consumption are influenced by the set of energy types available in the federation. A maximum in consumption and cost with energy is reached when the system utilises 4 energy types whereas when only 1 type of energy is used, consumption and costs are decreasing. This is based on the capacity of nodes to exchange energy from more energy sources and the ability of consumer nodes to consume energy at different prices. In such a context, the federation market is dynamic and opened where consumers and producers have increased flexibility in trading based on different energy types that are available within the federation.

7) EXPERIMENT 5: TOTAL ENERGY COST AND CONSUMPTION WITH CLUSTER SIZE
In this experiment, we assume that energy nodes can organise themselves in clusters based on criteria such as proximity, incentives or cluster performance. This experiment aims to identify what is the optimum size of an energy cluster in a federation and what is the impact on the total energy cost. We assume that the probability of energy requested is constant in value of 25%.
From Figure 5b, it can be observed that energy consumption and costs evolve with the cluster size. The optimum cluster sizes from a cost perspective is identified when energy nodes organise themselves in clusters of size 5 and 10 nodes, respectively. When utilising large clusters with size 15 and 20 respectively, the energy cost and consumption decrease because such clusters have increased numbers of consumers and producers but limited trading capability specified by the constant level service requests in demand.

8) EXPERIMENT 6: TOTAL ENERGY COST AND CONSUMPTION WITH NODE MIGRATION
In this experiment, we consider that energy nodes can change clusters and migrate across the federation based on different migration strategies. This has been implemented based on a probability to migrate that identifies the ability of an energy node to drop links and rewire to other nodes in a different cluster. In this experiment, we explore random migration identifying the migration of nodes to random clusters.
We have reported the impact of the migration of energy nodes in Figure 5c, with nodes having different migration thresholds. It can be identified that when nodes have 0.25 and 0.50 migration threshold (25%, 50% chances to migrate), the overall cost with energy increases whereas a migration threshold of 0.75 has less impact on the total cost. From the experiment, it is also observed that a 0.25 migration threshold increases the total of energy exchanges and consequently the energy consumption whereas other migration thresholds have no impact on energy consumption. This is determined by the fact that when nodes migrate, they need to pay the commission fee for entering in a new cluster. Giving that such migration happens randomly, and there are no criteria for nodes such as migrating to more wealthy clusters, the benefit of random node migration is limited.

9) EXPERIMENT 7: TOTAL ENERGY COST AND CONSUMPTION WITH MIGRATION STRATEGY
In this experiment, we propose four different migration strategies (i) ''no-migration'' where nodes do not migrate, (ii) ''mixed migration'' where nodes can migrate to random or more wealthy clusters, (iii) ''strategic migration'' where nodes migrate only to more wealthy clusters (with a higher level of payoffs) and (iv) ''random migration'' where nodes migrate randomly. We use a fixed migration probability of 25%.
As presented in Figure 5d, the strategic migration represents a direct benefit for the nodes but also for the entire federation of clusters. When energy nodes adopt strategic migration, the number of energy exchanges increases with direct impact on cost as migrating nodes are incentivised to participate in more energy transactions in the new clusters. Mixed migration also brings an increase in energy consumption, whereas no migration strategy produces a similar energy consumption as random migration but with a lower energy cost. When nodes migrate, they pay a commission fee cost to enter the new clusters but produce an increase in the number of exchanges. For the random migration, the cost increases but the energy consumption stagnates, which makes random migration less beneficial from a cost perspective.

10) EXPERIMENT 8: TOTAL ENERGY COST AND CONSUMPTION WITH PAYOFFS
In this experiment, we test how different payoffs levels of energy exchanges can influence the cost and energy consumption. We consider that each energy transaction can have different levels of payoffs based on which energy nodes are incentivised to engage in energy exchanges.
The results reported in Figure 5e show that energy consumption and associated costs in the federation are directly related to the level of payoffs. When using 1m.u.(monetary units) payoffs, nodes are less incentivised to participate in energy exchanges whereas when increasing the payoffs to 3m.u.and 4m.u., respectively, the costs and energy consumption increase significantly. The main objective of the federation is to increase the number of exchanges and energy consumption by using the mechanism of payoffs to identify an equilibrium between energy consumption and total costs with a view to creating cost-efficient energy communities. As this experiment demonstrates, the mechanism of payoffs can ease the development of energy communities by engage energy nodes with energy transactions.

VI. IN-CLUSTER ENERGY EXCHANGES
In this section, we demonstrate how energy exchanges can be managed at the level of a single cluster. We use the case study of Milford Haven port where five buildings with their consumption and production units form a P2P energy network as presented in Section III-B. We have developed energy models for all the buildings in port using Energy-Plus [82]. 1 For modelling the P2P energy cluster, we have considered production and consumption units such as appliances, PV modules, inverters with specific weather data and operation schedules. Based on the site requirements, we have added a primary energy storage environment by testing different battery capacities and electric boats as secondary storage solutions.
The scenario presented in Section III and the energy models of the buildings have been imported in Matlab with associated variables with the objective to configure the smart P2P cluster model. Below we present two control strategies: (i) Rule based control strategy and (ii) Optimisation control strategy with a comparison of their efficiency around consumption and production.
In Algorithm 1 we use the following abbreviations: SOC1 is state of charge for main battery, SOC2 is state of charge for secondary battery, P c2 is the power consumption of building 2, BESS 1 is building energy storage system 1, BESS 2 is building energy storage system 2, P price is the updated price tariff, P ref is the reference price.

A. RULE BASED CONTROL STRATEGY
Below, we present two main ''in-cluster'' scenarios, based on the cluster management decision algorithm from Algorithm 1 where each building can (i) use energy in operation, (ii) store energy in battery, (iii) send energy to grid (iv) charge electrical boats or (v) share in P2P with other buildings.

1) EXPERIMENT 1: ENERGY CONSUMPTION IN THE SITE WHEN USING STORAGE CAPABILITY
In this experiment, we investigate how energy consumption evolves within the five buildings in Milford Haven port when using a battery storage capacity and electric boats as secondary storage. This experiment reports on the following metrics (i)''Power Consumption'' identifying the total energy consumed in a 24 hours interval, (ii) ''Battery power'' identifying the amount of energy charged and discharged from/to a battery, (iii)''Solar energy'' identifying the amount of energy produced within the site, (iv)''Electric vehicle <discharge>'' identifying the amount of energy discharged from the electrical boats for operating appliances, (v) ''Power from Grid'' identifying the amount of energy bought from the main grid and (vi) ''Electric Vehicle-charge'' representing the amount of energy charged on the electrical boats. The objective of the experiment is to minimise energy consumption and costs by using flexibility from storage and solar energy production. 1 EnergyPlus is an energy simulation system that engineers, architects and researchers use to model energy consumption (https://energyplus.net/) Algorithm 1 ''In-Cluster'' Rule Based Control Algorithm 1: procedure P2P ENERGY SHARING CONTROL

28:
Stage 5: 29: if SOC2>20 then 30: then −→ discharge BESS 2 31: else −→ Buy energy from grid Figure 6a, shows energy consumption, production and storage for a 24 hours interval based on existing operation constraints. It can be observed that between 12pm and 3pm, the grid consumption ''Power from Grid'' becomes negative while the production ''Solar energy'' increases. When energy production increases, the energy is mainly used to operate the appliances, and the excess is stored on the batteries and electric boats. Electric boats are charged only when main storage batteries are fully charged, and the operation of appliances is reduced. Electric boats are discharged at high energy demands and energy capacity is available only in the electrical boat storage.

2) EXPERIMENT 2: ENERGY CONSUMPTION IN THE SITE WHEN USING A SMART P2P GRID
In this experiment, we investigate how energy consumption and production fluctuate within the site when using a smart P2P grid model. As a comparison basis, we are using the standard (as-is)''without SG (smart grid)'' scenario with real energy readings from the Milford Haven port. We explore three main metrics such as (i) ''with SG:Power demand'' representing the energy consumption in a smart P2P grid model, (ii) with ''SG:Power supply'' representing the supplied energy in the context of a smart P2P grid, (ii) ''with SG:Energy storage'' representing storage capability in a Smart P2P grid model, (iv) ''without SG: Power demand'' representing energy consumption without a smart grid and (v) ''without SM:Power supply'' representing energy supplied to the site in a no-smart grid context. From Figure 6b we observe that the excess of energy production is stored on the battery whereas, in a regular grid (without-SM) configuration, the excess of the energy production is sent to the national grid. The experiment demonstrates that smart P2P energy grids can optimise the consumption of energy and make more informed use of the energy excess in peak production periods.

3) OPTIMISATION BASED CONTROL STRATEGY
The optimisation has been configured to minimise the objective function ''net cost of electricity'' to the site over the optimisation period by scheduling P2P energy exchanges. This can be calculated by: where C is net cost, t is the timestep, T is the number of timesteps in the optimisation period, P Sell t , is the amount of electricity purchased (kWh), P Buy t , is the price of purchasing electricity at each timestep (p/kWh), P Sell t , is the amount of electricity sold (kWh), and P Fit t is the feed-in tariff sale price (p/kWh). The optimisation variables are B t , the net battery charging or discharging over the timestep t (kWh), and SOC t , the battery state of charge at timestep t (kWh). These variables must remain within certain bounds depending on the optimisation scenario. B t must remain between the peak discharging and charging rates, ±7.5kWh in our case. SOC t must remain between 0 and the capacity of the battery, 40.5kWh in our case. It is assumed the system can purchase and sell an infinite amount of energy to / from the energy network in three scenarios (i) Scenario 1: No Strategy, (ii) Scenario 2: Rule Based Control Strategy and (iii) Scenario 3: Optimisation Control Strategy. Figure 7 demonstrates the optimal solution of energy flows by proving a comparison for all three scenarios. To understand the logic of the optimisation, the TOU tariff is plot on a secondary graph. The results demonstrate that the battery is used much more actively under the optimisation-based control scenario. The battery is charged during the early hours when the electricity prices are cheapest, even though this means purchasing more electricity from the energy network during this period than for scenario 2. This ensures the battery is full by timestep 10 so it can be discharged to reduce purchased electricity to 0 for the next few hours when electricity prices are moderately cheaper. Another interesting note is the increase in purchasing of electricity at timestep 25, 31 and 32. This stores enough electricity to minimise purchased electricity during the peak price periods (33)(34)(35)(36)(37)(38) whereas the rule-based control runs out of charge before the peak pricing ends. This demonstrates that a predictive, optimisation-based approach can achieve significant cost savings over rule-based control based on the flexibility provided by the battery storage.

VII. DISCUSSION
The distribution of energy systems requires more informed and reliable management of users, agents and energy transactions. As energy grids are moving towards decentralisation, there is a need for supporting communication between energy prosumers within an open energy sharing ecosystem. Such decentralisation of the energy market involves aspects related to energy loss and risks due to the heterogeneous nature of the energy network infrastructure, which can impact the grid.
In P2P federation, the total of energy exchanges is a metric to monitor the status of the system and track energy exchanges that have been incurred based on an initial configuration at start time. Our simulation investigates how the energy demand intervals can induce fluctuation in energy exchanges and costs. The level of energy exchanges can be aggregated across the entire federation and reflects the value benefit achieved by the system and the community impact when the interval for trading services is varied. The federation of energy clusters leads to the emergence of a sharing economy where a number of providers and consumers perform energy exchanges showing how a local economy reacts to variation in competing energy consumers and providers.
In this study, we propose a federation of energy clusters where prosumers need to be active agents able to trade their own energy services in a sharing market. The federation of energy clusters over P2P networks can bring advantages for coordination of users and resources and can promote autonomy in use, fair access to resources, high level of connectivity between energy actors. Such federation can incentivise sharing and trading across energy suppliers and consumers, taking into account node characteristics, interactions and objectives by ensuring scalability, adaptability and decentralising access to green energy resources in hybrid energy ecosystems.

VIII. CONCLUSION
This research investigates the federation of energy clusters with their formation and usage mechanisms as a means to incentivise more sustainable and efficient use of energy in communities. In this paper, we conduct modelling and analysis on federated energy clusters with a real use-case from the fish processing industry. We aim to understand the specificities of P2P energy clusters by analysing different factors and their impact in a cluster federation landscape. We explore two main scenarios in relation to the federation of energy clusters (i) ''in-federation'' analysis where exchanges can take place across energy clusters and (ii) ''in-cluster'' analysis where energy nodes identifying buildings in the Milford Haven port can exchange energy based on different control strategies.
To validate our work, we use data and requirements from a real industrial site identifying energy-consuming and production units. Based on the trial project, we import site information in the simulation framework with a view to find new ways of optimising energy consumption and cost for industrial sites. We demonstrate the impact of energy demand, cluster size and the number of types for the establishment of the cluster federation. We also provide a cost perspective by measuring the impact of cost with energy exchanges when nodes can migrate to other energy clusters, and when payoff levels with transactions are increased. The overall aim was is to investigate the federation of energy systems by proposing new methods for reducing the carbon footprint for energy-intensive industries and transition to clean energy. Such federation brings particular cost advantages for industries and stakeholders and can provide a more competitive integration of small and medium energy businesses within the wholesale energy market. In future, we will deploy the federation in a blockchain system in the attempt to advance industrial digitalization with new energy delivery schemes such as smart contracts. The energy transactions will be supported by crypto-currency payments of smart contracts and executed in a secured distributed ledger environment.
JONATHAN REYNOLDS received the Ph.D. degree with the BRE Institute of Sustainable Engineering, Cardiff University. His research applied machine learning techniques and genetic algorithm optimizations to improve the control strategies in buildings, and district energy networks. The research aimed to exploit growing interest in the smart grid, the Internet of Things, and Artificial Intelligence to address the vital sustainability challenges of the future.
YACINE REZGUI (Member, IEEE) is currently a Professor of building systems and informatics from Cardiff University, Cardiff, U.K., and the Founding Director of the BRE Centre in Sustainable Engineering, sponsored by the Building Research Establishment (BRE), U.K. He has successfully completed over 40 research and development projects at a national (U.K., EPSRC, and TSB) and international (European Framework Programs five, six and seven) level. He conducts research in informatics, including ontology engineering and artificial intelligence applied to the built environment. He has over 200 refereed publications in the above areas, which appeared in Proceedings of the Royal Society A, and several the IEEE Transaction journals, including the IEEE TRANSACTIONS ON SYSTEMS, MAN, AND CYBERNETICTICS. VOLUME 8, 2020