A Local Electricity and Carbon Trading Method for Multi-Energy Microgrids Considering Cross-Chain Interaction

The objective of this paper is to propose a local electricity and carbon trading method for interconnected multi-energy microgrids. A local electricity market and a local carbon market are established, allowing microgrids to trade electricity and carbon allowance within the microgrid network. Specifically, excessive electricity and carbon allowance of a microgrid can be shared with other microgrids that require them. A local electricity trading problem and a local carbon trading problem are formulated for multi-energy microgrids using the Nash bargaining theory. Each Nash bargaining problem can be decomposed into two subproblems, including an energy/carbon scheduling problem and a payment bargaining problem. By solving the subproblems of the Nash bargaining problems, the traded amounts of electricity/carbon allowance between microgrids and the corresponding payments will be determined. In addition, to enable secure information interactions and trading payments, we introduce an electricity blockchain and a carbon blockchain to record the trading data for microgrids. The novelty of the usage of the blockchain technology lies in using a notary mechanism-based cross-chain interaction method to achieve value transfer between blockchains. The simulation results show that the proposed local electricity and carbon trading method has great performance in lowering total payments and carbon emissions for microgrids.


Introduction
With the benefits of promoting a sustainable society and reducing carbon emissions, many countries greatly support the use of renewable energy to replace traditional fossil fuels [1]. Installing distributed power sources, e.g., photovoltaic panels and wind turbines, in microgrids will provide many advantages, such as reducing energy procurement costs and lowering carbon emissions by consuming renewable energy [2]. To reduce the curtailment of renewable energy and long-distance electricity transmission, the local electricity trading mechanism is introduced into the power market, which will allow microgrids to become prosumers that can buy and sell electricity in the local electricity market [3]. Through local electricity trading, microgrids will have an opportunity to obtain revenues by selling their excess renewable energy. Therefore, local electricity trading provides economic and environmental benefits for microgrids [4].
Considering that microgrids are both energy consumers and carbon emitters, the inclusion of microgrids in the electricity and carbon markets is necessary [5]. With the construction of electricity transmission infrastructure between microgrids, local electricity trading can be conducted within the microgrid network. In addition, microgrids should 1.
We propose a Nash bargaining-based local electricity and carbon trading method for interconnected multi-energy microgrids, which helps to determine the traded amounts of electricity and carbon allowance between microgrids and the corresponding local electricity and carbon payments of microgrids in a fair manner; 2.
We introduce an electricity blockchain and a carbon blockchain for secure information interactions and payments, while electricity coins and carbon coins are introduced as cryptocurrencies for these two blockchains, respectively; 3.
A notary mechanism-based cross-chain interaction method is proposed to achieve value transfer between the electricity and carbon blockchains.
The rest of this paper is structured in the following manner: Section 2 describes the system model of the microgrid and microgrid network. Section 3 develops the mathematical formulation of the local electricity and carbon trading problems. Section 4 introduces the electricity and carbon blockchains and presents the cross-chain interaction method. Case studies are conducted in Section 5. Finally, we conclude this paper in Section 6.

System Model
In this section, we will first present the basic structures of multi-energy microgrids and their connective topology. Then, the detailed models of various energy devices and the operation constraints of microgrids are given. Figure 1 shows the basic structure of a multi-energy microgrid. Each microgrid i ∈ M contains the following components: a wind turbine (WT), a combined heat and power (CHP) unit, a gas boiler (GB), an electrolyzer (ELE), a hydrogen fuel cell (HFC), electric storage (ES), heat storage (HS), and hydrogen storage (H 2 S). Three different types of load demands for microgrids should be met: electric loads (ELs), heat loads (HLs), and hydrogen loads (H 2 Ls). Microgrids will participate in both local electricity and carbon markets. Thus, each microgrid can sell its excess renewable energy to other microgrids that need to purchase electricity. In the meantime, the carbon allowance of microgrids can be traded within the microgrid network.  Figure 2 presents the schematic model of the microgrid network that is composed of three microgrids (i.e., MG-1, MG-2, and MG-3). Let M = {1, . . . , M} denote the set of M microgrids. Microgrids can purchase electricity and gas from the electric and gas utilities. In the meantime, microgrids can purchase insufficient or sell surplus carbon allowance in the central carbon market. Microgrids are connected to each other through electricity transmission infrastructures, which enables local electricity trading within the microgrid network. Moreover, microgrids are connected to each other through the wireless communication network, which realizes the information transmission between microgrids [19,20]. The operation horizon T = {1, . . . T} is composed of T equal time slots, and each time slot is denoted as t ∈ T . A microgrid manager is responsible for scheduling energy and carbon allowance and clearing local electricity and carbon markets for microgrids. Note that the carbon trading can be conducted not only in a global market or national market, but also in the local markets. Many researchers, e.g., [10,15,21], have focused on the ability of local carbon markets and entities in the markets to trade carbon allowance with each other. Specifically, entities participating in local carbon markets can include microgrids [15], energy hubs [21], and plug-in electric vehicles [10], etc. Thus, we believe that it is reasonable to integrate multi-energy microgrids into the local carbon market. Moreover, the local carbon market considered in this paper is similar to the global/national carbon markets. The carbon emissions of a multi-energy microgrid can be calculated as Equation (23). Then, each microgrid can sell its excess carbon allowance to other microgrids that need to purchase carbon allowance. Thus, we believe that the local carbon trading between microgrids can emulate the global/national carbon markets.

Microgrid Operation Constraints
The detailed models of energy devices and the operation constraints of microgrids are formulated as follows.
(1) Power sources: Each microgrid can purchase electricity and gas from utilities, and the wind turbine will supply renewable energy for the microgrid. Let P GRID t,i and P GAS t,i denote the amounts of electricity and gas purchased from the utilities, respectively; let P WT t,i denote the scheduled wind power. We have: where P GRID i,max and P GAS i,max denote the maximum amounts of electricity and gas that microgrid i can purchase from the electric and gas utilities, respectively, and P WT,gen t,i denotes the wind power output of microgrid i in time slot t.
(2) CHP: Let P CHP,g t,i denote the gas consumption of the CHP. Its electricity and heat outputs are defined as P CHP,e t,i and P CHP,h t,i , respectively. The operation constraints of the CHP can be described by: where η CHP,e (3) GB: The GB can consume gas to satisfy the heat demands of the microgrid. Let P GB,g t,i denote the gas consumption of the GB. Its heat output is denoted as P GB,h t,i . The GB should satisfy the following constraints: where η GB,h i denotes the heat conversion efficiency of the GB; P GB,g i,max denotes the maximum gas consumption of the GB. . The operation constraints of the ELE are given as: where η ELE,h 2 i denotes the hydrogen conversion efficiency of the ELE; P ELE,e i,max denotes the maximum electricity consumption of the ELE.
(5) HFC: The HFC can generate electricity by consuming hydrogen. Let P HFC,h 2 t,i denote the hydrogen consumption of the HFC. Its electricity output is denoted as P HFC,e t,i . The operation constraints of the HFC are given as: where η HFC,e i denotes the electricity conversion efficiency of the HFC and P HFC,h 2 i,max represents the maximum hydrogen consumption of the HFC. The operation constraints of the STO can be described by: where E STO i,max and E STO i,min represent the maximum and minimum energy levels of the STO, respectively; P STO.c i,max and P STO,d i,max represent the maximum charging and discharging power of the STO, respectively; E STO 0,i and E STO T,i denote the energy levels of the STO in the initial and terminal time slots, respectively. Note that constraint (18) denotes that the energy levels of the STO are equal in the initial and terminal time slots [22].
(7) Power balance equations: The electricity, heat, hydrogen, and gas balance equations of microgrid i are shown as: where P j t,i , ∀i, j ∈ M, i = j denotes the electricity that microgrid i trades with microgrid j. If microgrid i purchases electricity from microgrid j, P j t,i is positive; otherwise, microgrid i sells electricity to microgrid j, and P j t,i is negative. (8) Carbon emissions and trading: Let W CO 2 i,t denote the carbon emissions of microgrid i, which can be expressed as [23]: where em CHP i , em GB i , em ELE i , em HFC i and em ES i denote the carbon emission factors of CHP, GB, ELE, HFC, and ES, respectively; em GRID i denotes the carbon emission factor associated with the electricity procurement from the electric utility. In the carbon cap-and-trade market, microgrids will be allocated certain amounts of carbon allowance for free. When microgrids purchase or sell carbon allowance in the central carbon market, they should satisfy: where W CO 2 ,buy i,max and W CO 2 ,sell i,max denote the maximum amounts of carbon allowance that microgrid i can purchase or sell in the central carbon market during one day.
(9) Carbon balance equation: The carbon balance equation means that the total amount of carbon allowance owned by microgrid i is equal to its total carbon emissions, which can be formulated as: where W CO 2 ,a i represents the allocated carbon allowance of microgrid i; and W CO 2 ,j i , ∀i, j ∈ M, i = j denotes the amount of carbon allowance that microgrid i trades with microgrid j.
If microgrid i purchases carbon allowance from microgrid j, W CO 2 ,j i is positive; otherwise, microgrid i sells carbon allowance to microgrid j, and W CO 2 ,j i is negative. (10) Local market clearing constraints: The local electricity and carbon trading must satisfy the following market clearing constraints: Note that due to the close distances between microgrids, we neglect the energy losses during the electricity transmission.

Local Electricity and Carbon Trading
In this section, we present the mathematical formulations of the local electricity trading problem and local carbon trading problem. Since the scheduling horizons and market mechanisms of the energy market and carbon market are different, we consider that the local electricity trading and local carbon trading are conducted sequentially. Specifically, the local electricity trading is conducted in each time slot t ∈ T and the local carbon trading is conducted after the energy scheduling, i.e., after t = 24.

Non-cooperative Benchmarks
In the non-cooperative benchmarks, microgrids will not exchange electricity and carbon allowance with each other, i.e., the local electricity and carbon trading will not be conducted. Thus, the electricity and carbon balance equations of microgrid i should be revised as: For the local electricity trading problem, the objective of each microgrid is to minimize its operation cost F OPE i , which consists of electricity purchase cost F GRID i , gas purchase cost F GAS i , and storage degradation cost F S,deg i . The operation cost of microgrid i is given as: where λ e t and λ Here, we define {F NC,e i |i ∈ M} as the optimal objective function value of the P1-NC i .
Let F CE i denote the total carbon cost of microgrid i. We have: where β b and β s denote the buying and selling prices of carbon allowance in the central carbon market, respectively. Let P2-NC i denote the carbon cost minimization problem of microgrid i in the non-cooperative benchmarks. We have: subject to: (24), (25), and (30), |i ∈ M} as the optimal objective function value of the P2-NC i .

Local Trading Payments
Microgrids should pay for the electricity and carbon allowance that are traded in the local markets. Let π j i and γ j i denote the payments associated with the electricity and carbon trading between microgrids i and j, respectively. If microgrid i makes payments to microgrid j, π j i and γ j i will be positive; otherwise, microgrid i receives payments from microgrid j, π j i and γ j i will be negative. The following payment balance equations should be satisfied: π Let F PAY,e i and F PAY,c i denote the total payments of microgrid i for local electricity trading and local carbon trading, respectively. We have: A microgrid will only participate in the local electricity and carbon trading if it can reduce the total payment for the microgrid. Thus, we have:

Nash Bargaining Problems
We denote the Nash bargaining problems of the local electricity trading and local carbon trading as P1-NB and P2-NB, respectively. The P1-NB is shown as follows:

P1-NB:
, P j t,i , π j i |t ∈ T , i ∈ M, j ∈ M\i, STO ∈ S}. By solving the P1-NB, the energy scheduling results and the local electricity trading payments will be obtained for microgrids. Note that based on the energy-scheduling results, the carbon emissions of microgrids can be calculated by (23).

Solution Method
The Nash bargaining problems P1-NB and P2-NB are non-convex, as they have nonconvex objective functions. Specifically, the P1-NB will maximize the differences between disagreement point F NC,e i and total operation cost (F OPE i + F PAY,e i ) of microgrid i through bargaining, while the P2-NB will maximize the differences between disagreement point F NC,c i and total carbon cost (F CE i + F PAY,c i ) through bargaining. The product formulations in the objective functions will guarantee that the benefits of cooperation can be fairly distributed by microgrids that participate in the local electricity and carbon markets [7]. Based on the findings of the previous research [5], the Nash bargaining problems P1-NB and P2-NB can be solved via decomposition into two subproblems, respectively.
In this paper, the P1-NB is decomposed into an energy-scheduling problem S1-ET and an electricity payment bargaining problem S2-EP. The P2-NB is decomposed into a carbon scheduling problem S1-CT and a carbon payment bargaining problem S2-CP. The S1-ET and S2-EP are presented as follows: S1-ET: subject to: (1)- (22), and (27), , P j t,i |t ∈ T , i ∈ M, j ∈ M\i, STO ∈ S}. Solving the S1-ET determines the energy scheduling and trading results for each microgrid i ∈ M. S2-EP: denotes the optimal operation cost of microgrid i, which is obtained by solving the S1-ET. Solving the S2-EP determines the electricity trading payments for microgrids. Now, we present the S1-CT and S2-CP as follows: S1-CT: subject to: (24)- (26), and (28), The carbon scheduling and trading results of microgrids will be obtained by solving the S1-CT. S2-CP: subject to: (37) and (41), where decision variables Φ CP = {γ j i |i ∈ M, j ∈ M\i};F CE i denotes the optimal carbon cost of microgrid i, which is obtained by solving the S1-CT. The carbon trading payments of microgrids will be obtained by solving the S2-CP.
The constraints and objective functions of the scheduling problems S1-ET and S1-CT are linear, which means that the S1-ET and S1-CT are both convex problems. We can obtain the optimal energy and carbon allowance scheduling results for microgrids. Thus, the non-convexity of the Nash bargaining problems will not prevent us from obtaining the optimal scheduling results for microgrids.
The non-convexity of the Nash bargaining problems P1-NB and P2-NB helps to arrange the usage of energy and carbon allowance and conduct payment bargaining. Solving the Nash bargaining problems can not only obtain the optimal energy and carbon allowance scheduling results, but also the corresponding local payments for microgrids. The corresponding local payments of microgrids will help to fairly distribute the profits obtained from cooperation among microgrids. Moreover, although the Nash bargaining problems P1-NB and P2-NB are non-convex, we can obtain the globally optimal solutions for these two problems. This is because each Nash bargaining problem can be solved by decomposing it into two convex subproblems. The optimal solutions of the subproblems can be found, and the solutions are the Nash bargaining solutions as well [5].

Solution Procedures
The S1-ET and S1-CT are convex problems, which can be easily solved by off-theshelf solvers, e.g., Gurobi [24]. However, the S2-EP and S2-CP are non-convex problems. By taking the log and negating the objective functions of the S2-EP and S2-CP, we can rewrite the objective functions of these two problems as follows: Under the new objective functions, the S2-EP and S2-CP will become convex problems as well. We can solve these two problems using commercial solvers, e.g., Ipopt [25].
The implementations of the local electricity and carbon trading between microgrids are presented in Figure 3. Step 1: Initialization Step 2: Noncooperative benchmark Step 3: Nash bargaining Step 4: Subproblems

Cross-Chain Interaction Method
In this section, we first introduce the electricity and carbon blockchains. Then, a notary mechanism-based cross-chain interaction method is proposed to realize the value transfer between the electricity blockchain and the carbon blockchain.

Electricity and Carbon Blockchains
Two private blockchains, an electricity blockchain and a carbon blockchain, are considered in this paper. These two blockchains act as digital databases and store the metadata of local electricity and carbon trading information of microgrids. The microgrid manager is responsible for recording the trading information of microgrids in the electricity and carbon blockchains. The trading information includes pseudonyms of microgrids, transaction data, and a timestamp of transaction generation. The trading information will be structured into blocks, and the blocks are chronologically added into the blockchains. The information of the blocks can only be accessed by microgrids and the microgrid manager. Two different digital cryptocurrencies, named electricity coins and carbon coins, are introduced into the electricity blockchain and the carbon blockchain, respectively. The electricity coins and carbon coins are used as currencies in the local electricity market and local carbon market, respectively.
Here, we take the local electricity trading between microgrids as an example to illustrate the operation mechanism of the electricity blockchain. Firstly, the microgrid manager will solve the Nash bargaining problem of local electricity trading to obtain the local electricity payments for microgrids. Each microgrid has an electricity wallet to store its own electricity coins, which will be used to pay for the electricity obtained through local electricity trading. Then, the microgrid manager will implement the payments for microgrids, transferring the electricity coins between the electricity wallets of microgrids. Thus, the local electricity trading payments can be completed. The implementation of the local electricity trading and the corresponding electricity coin transfer are shown in Figure 4. Note that when a microgrid does not have enough electricity coins, it can exchange the fiat currency for the electricity coins via the microgrid manager. The microgrid manager will complete the exchanges in the cryptocurrency exchange center.

Cross-Chain Interactions
Since the electricity and carbon coins are used in the local electricity market and local carbon market, respectively, it is necessary to realize the exchange between these two types of cryptocurrencies. In this paper, a cross-chain interaction method is proposed to achieve the value transfer between the electricity blockchain and carbon blockchain. Through the cross-chain interactions, the electricity coins and carbon coins can be exchanged. In this way, the profits obtained through the local electricity/carbon trading can be used to cover the payments of the local carbon/electricity trading.
We use the notary mechanism to realize the cross-chain interaction. In the notary mechanism, a notary is introduced and is responsible for the cross-chain interactions. During the cross-chain interactions, the notary acts as a trusted third party to realize the exchange of electricity coins and carbon coins and truly record the exchange results in the blockchains. Based on the cryptocurrency exchange requests, the notary will achieve cryptocurrency exchange in the cryptocurrency exchange center. In this paper, we consider that the microgrid manager will act as the notary.
Here, we take the exchange of electricity coins into carbon coins as an example to illustrate the processes of a cross-chain interaction. Figure 5 shows the processes of exchanging the electricity coins into carbon coins. The detailed steps of the cross-chain interaction are shown as follows:

1.
Microgrid i transfers electricity coins from its electricity wallet to the wallet of the notary; 2.
The notary receives the cryptocurrency exchange request and transfers the received electricity coins to the cryptocurrency exchange center; 3.
The notary exchanges the electricity coins into the carbon coins based on the exchange rate between the electricity coins and carbon coins; 4.
The exchanged carbon coins are transferred into the wallet of the notary; 5.
The notary transfers the carbon coins from its wallet to the carbon wallet of microgrid i.

Case Studies
To verify the performance of local electricity and carbon trading between multi-energy microgrids, experiments are conducted in this section on a microgrid network consisting of three interconnected microgrids. All simulations are conducted in Matlab.

Scenario Description
The test system is shown in Figure 2. Each microgrid has the same structures and energy devices. The optimization horizon is one day, and each time slot ∆t is equal to one hour. Figure 6 depicts the electricity, heat, and hydrogen demands and wind power generation of microgrids. Figure 7 presents the electricity prices of the electric utility, which are obtained from the PJM database [26]. The gas prices are constant in all time slots, and are equal to 0.0571 $/kW [8]. The buying and selling prices of carbon allowance in the central carbon market are 0.06 $/kg and 0.02 $/kg, respectively [15]. The maximum amounts of electricity and gas that microgrids can purchase from the utilities in each time slot are both set as 1000 kW. Other parameters related to microgrids are tabulated in Table 1. Moreover, we consider that one electricity coin can be exchanged for USD 1 and one carbon coin can be exchanged for USD 2. That is, one carbon coin can be exchanged for two electricity coins.   Figure 8 depicts the electricity trading profiles between microgrids. In Figure 8, if the shared electricity between microgrid i and j is a positive value, it means that microgrid i will purchase electricity from microgrid j; otherwise, if the shared electricity between microgrid i and j is a negative value, it means that microgrid i will sell electricity to microgrid j. It can be seen that microgrid 1 can obtain electricity in the daytime because of its high load demands but low wind power output during that period. Moreover, microgrid 2 will transmit electricity to the other microgrids during the day and microgrid 3 will supply electricity to other microgrids from time slots 10 to 24. This demonstrates that each microgrid actively participates in local electricity trading and acts as an electricity buyer or seller in different time slots.  Figure 9 shows the initial carbon allowance and carbon emissions of microgrids. It can be seen that the carbon emissions of microgrids 1 and 3 exceed their allocated carbon allowance, but the carbon emissions of microgrid 2 are lower than its allocated carbon allowance. Specifically, microgrids 1 and 3 should purchase another 57.0121 kg and 21.7490 kg of carbon allowance, respectively. Microgrid 2 can sell 87.2163 kg of carbon allowance in the central or local carbon markets. Through local carbon trading, microgrids 1 and 3 can receive a total of 78.7611 kg of carbon allowance from microgrid 2. Therefore, microgrids 1 and 3 will not purchase carbon allowance from the central carbon market, while microgrid 2 will sell the remaining 8.4552 kg of carbon allowance in the central carbon market. Since the buying price of carbon allowance in the central carbon market is higher than the selling price, we know that local carbon trading can lower the total carbon cost of microgrids.  Figure 10 presents the clearing results of the local electricity market. The net electricity trading payments of microgrids are shown in the figure. According to the Nash bargaining solutions of the local electricity trading problem, the net electricity trading payments of microgrids 1 and 2 are 3.5511$ and 5.5938$, respectively. The net electricity trading payment of microgrid 3 is −9.1449$, which means that microgrid 3 will receive the revenue by sharing its electricity with other microgrids. This is because microgrid 3 mainly shares its electricity with other microgrids when the electricity prices are relatively high. Thus, microgrid 3 makes the greatest contribution in lowering the payment for microgrids. Figure 11 presents the clearing results of the local carbon market. The net carbon trading payments of microgrids are presented in the figure. It can be seen that microgrids 1 and 3 should pay for their received carbon allowance, and their corresponding payments are 0.6090$ and 1.5964$, respectively. Microgrid 2 shares its excess carbon allowance with other microgrids. Thus, it will receive 2.2054$.

Cross-Chain Interaction Results
As shown in Figures 10 and 11, microgrid 2 will make a payment in the local electricity market but will receive a payoff in the local carbon market. Microgrid 3 will receive a payment in the local electricity market but will make a payment in the local carbon market. Thus, microgrids 2 and 3 can conduct the cross-chain interactions between the electricity blockchain and carbon blockchain.
After the implementation of local electricity and carbon trading, the microgrid manager will record the information of local electricity and carbon trading into the blockchains. Then, the cross-chain interactions will be conducted. Through local electricity and carbon trading, microgrid 2 will obtain 1.1027 carbon coins and will pay out 5.5938 electricity coins, while microgrid 3 will receive 9.1449 electricity coins and will pay out 0.7982 carbon coins. Thus, microgrid 2 can exchange all of its carbon coins into 2.2054 electricity coins, which will be used to pay for the obtained electricity. In the meantime, microgrid 3 can exchange 1.5964 electricity coins into carbon coins, which will be used to pay for the obtained carbon allowance. It is the cross-chain interactions that enables the value transfer between the electricity blockchain and carbon blockchain.

Comparison Results under Different Market Settings
To demonstrate the performance of the proposed market settings in lowering payments and carbon emissions for microgrids, four different market settings are compared, as shown in Table 2.  Figure 12 shows the comparison results of total costs and carbon emissions of microgrids under different market settings. It can be observed that under the proposed market setting, microgrids will have the lowest total cost and carbon emissions. Specifically, compared to Case 1, i.e., non-cooperative benchmarks, the total cost of microgrids decreases by 17.35% and the total carbon emissions of microgrids decrease by 35.09%. It can be explained that (i) local electricity trading allows microgrids to use more renewable energy while reducing the procurement of electricity; (ii) local carbon trading enables microgrids to lower the procurement of carbon allowance.

Conclusions
In this paper, we propose a local electricity and carbon trading method for multi-energy microgrids. The local electricity and carbon trading problems are formulated using the Nash bargaining theory. We solve the Nash bargaining problems by decomposing each problem into an energy/carbon scheduling problem and a payment bargaining problem. In addition, blockchain technology is used to record the transaction data and realize secure information interactions. A notary-mechanism-based cross-chain interaction method is proposed, achieving the value transfer between the electricity blockchain and carbon blockchain. The simulation results show that the proposed method is economically and environmentally beneficial for microgrids. Compared to the non-cooperative benchmarks, 17.35% of total cost and 35.09% of carbon emissions are reduced for microgrids. In future research, we will explore cross-chain interactions between electricity and carbon blockchains using other mechanisms, e.g., side chain and Hash locking.