## 1. Introduction

The fast-growing penetration of distributed energy resources (DERs), such as distributed renewables, energy storage, electric vehicles, and controllable loads, poses significant challenges to the centralized power systems with unidirectional power flow. Successful integration of heterogeneous DERs calls for a paradigm shift to a decentralized power system with bidirectional power flow.

A large body of literature has focused on the energy management and energy trading of various DERs managed by an aggregator. For example, a service-centric virtual power plant (VPP) was studied in (koraki2017wind) to integrate renewable energy into an electricity market enabled by the cooperation between the VPP and the distribution system operator. A similar work (kasaei2017optimal) proposed to aggregate distributed generators, energy storage, and controllable loads in a VPP to mitigate the impact of the variable generations. More recent research explored various types of services that DERs can provide. For example, as an emerging service, energy trading was explored in (nguyen2018optimizing; alam2019peer). In (nguyen2018optimizing), an optimization model was presented to maximize the economic benefits for solar-battery distributed generations in a peer-to-peer (P2P) energy trading scenario. In (alam2019peer), the authors developed an algorithm to optimize the energy cost for smart homes under P2P energy trading and evaluated the impact of energy trading in a microgrid. However, the above studies adopted a centralized solution to the energy management of DERs, which is not practical as DERs are usually not owned by the aggregator.

Distributed optimization attracted research attention as a promising solution to manage DERs. The alternating direction method of multipliers (ADMM) method has been used to facilitate energy trading among interconnected microgrids (wang2016incentivizing) and smart homes (yang2020cooperative). A decentralized optimization algorithm was proposed in (li2016admm) to optimize the demand response of electric vehicles. A fully distributed algorithm was proposed in (chen2018fully) using ADMM and the consensus mechanism. The above studies contributed to the distributed or decentralized energy management of DERs. However, the computing and communication process embedded in the distributed algorithm needs a trusted and verifiable computing environment, which becomes one of the major obstacles to implementing distributed transactive energy paradigm.

Blockchain (swan2015blockchain), as a distributed ledger, can remove the barrier of lacking a trusted and verifiable computing environment. Blockchain is a tamper-proof decentralized ledger maintained by a group of nodes through the consensus algorithm (xiao2020survey). Furthermore, the blockchain supports the execution of generic computer programs as smart contracts, resulting in the proliferation of various decentralized applications (eth). Existing studies in (mengelkamp2018designing) deployed a blockchain-based P2P energy trading platform to facilitate online payments for a microgrid in Brooklyn of New York City. In addition, many existing studies employed blockchain technology as a secure and convenient online payment tool (bao2020survey; mollah2020blockchain).

Our work adopts the blockchain as a trustable computing machine to implement the distributed transactive energy management algorithm for DERs and also as a secure communication and payment tool. We formulate a cost minimization problem to optimize DERs’ interactions, including energy trading, energy scheduling, and grid services. We also decompose the cost minimization problem and solve it using ADMM to manage DERs in a distributed fashion. We design a blockchain system as a trustable transactive energy management platform and implement the distributed algorithm in a smart contract, which opens up opportunities for trustable and efficient integration of DERs in the smart grid.

## 2. System Model

Variable | Definition | Meaning |
---|---|---|

Grid usage of prosumer | ||

Renewable generation of prosumer | ||

Flexible appliance of prosumer | ||

Inflexible appliance of prosumer | ||

Energy purchased by prosumer from | ||

Battery charging of prosumer | ||

Battery discharging of prosumer | ||

prosumer ’s ancillary service |

We consider a cluster of prosumers owning DERs in a virtual power plant (VPP) system and denote prosumers , where is the total number of the prosumers as shown in Fig. 1. The prosumers have renewable energy generators (e.g., solar panels and small wind turbines) and various in-house appliances such as air conditioners and washers. Each prosumer also installs a battery energy storage system (BESS). The smart meter and the home energy management system manage and schedule the above appliances and energy trading with the outside. We focuses on the day-ahead scheduling and denote the operational horizon by with one-hour time slot.

We summarize the notations in Tab. 1

. Note that the boldfaced variables are vectors for one-day profiles. For example,

represents the prosumer ’s grid power usage in the -th time slot, and represents its grid usage of the whole day. Therefore, prosumer ’s electricity charge to the grid operator is , where is the energy rate and is the peak electricity rate.Each prosumer has two types of electric appliances: flexible appliances and inflexible appliances. The flexible appliances, such as the washer and dryer, are time-shiftable, so that they can be scheduled over the operational horizon. By contrast, inflexible appliances (e.g., the house lighting and refrigerator) cannot be adjusted or shifted over time. We assume that the prosumer has a preferred schedule for the flexible appliances, denoted by . Therefore, the deviations from the preferred schedule incurs a discomfort cost for prosumer denoted by .

The future smart grid allows prosumers to freely trade energy with each other to utilize renewable energy better. The system operator sets a fixed price for the P2P energy trading, which is assumed to be lower than the typical price of the grid. Then prosumer ’s payment for P2P energy trading is . Note that a positive indicates prosumer ’s overall payment to other prosumers, and a negative indicates its overall revenue in the energy trading.

The prosumers’ energy storage can store extra energy and discharge to support appliances when needed. The VPP system can provide ancillary service to the grid by aggregating the prosumer’s energy storage. Let denote the energy level of prosumer ’s battery in time slot . Since is decided by the charge/discharge operations of the energy storage, we have , where the coefficient indicates the efficiency of the battery. Because charge/discharge operations degrade the lifespan of the energy storage with a cost of .

The VPP system operator incentivizes the prosumers to reserve energy in their energy storage for load regulation or spinning reserve by paying them with some rewards to provide the ancillary service. The reserved energy can be immediately dispatched from the VPP to the grid for various grid services (melo2016robust). By storing energy in the battery, prosumer can receive the reward , where is the reward price in time slot . This price is set by the grid operator based on the forecasted grid load.

## 3. Problem Formulation

We formulate a total cost minimization problem for all prosumers with each prosumer’s cost defined as

(1) |

which consists of costs for energy supplies, load scheduling, energy storage operation, and ancillary service.

The energy supply and demand of each prosumer must be balanced, and we have

(2) |

Therefore, the total cost minimization problem of all prosumers in the VPP is formulated as

(3) | ||||

where the solution represents the optimal energy management schedules for all the VPP prosumers. Specifically, , where represents prosumer ’s optimal energy schedule on grid usage, renewable generation, flexible appliance scheduling, energy storage operation, and ancillary service, respectively.

The conventional VPP system employs a central coordinator who collects all the prosumers’ information and solves the optimization problem of (3) in a centralized manner. This method, however, has three major drawbacks that impediment its feasibility. First, the effectiveness of this method depends on the correctness of the coordinator, which incurs the risk of single-point failure. Second, it incurs significant privacy concerns because the prosumers have to reveal all of their private information regarding DERs to the coordinator. Third, the solution cannot be verified and trusted by the prosumers because the operation of the coordinator is a “black box” to them.

To address these drawbacks, we design a distributed transactive energy management algorithm that can attain the optimal solution while preserving prosumers’ privacy. Furthermore, by implementing the proposed algorithm in smart contract on the blockchain, we guarantee the correctness of the results and remove the need for a centralized coordinator.

We employ the primal-dual-type method (jakovetic2020primal) to solve the optimization problem in (3). Based on ADMM (boyd2011distributed), we introduce auxiliary variables for prosumer ’s energy trading decisions in time slot , and dual variables . The original optimization problem in (3) can be written as two subproblems below.

The primal problem:

(4) | ||||

The dual problem:

(5) | ||||

where the coefficient denotes the penalty sensitivity of the auxiliary variables.

The primal-dual method works in an iterative manner. The primal problem updates the prosumers’ decisions, including the energy trading decisions and other scheduling decisions. The dual problem uses to update the auxiliary variables and the dual variables , which are used by the primal problem in the next iteration. We measure the convergence error by the Euclidean distance between the auxiliary variable and its original variable . Since the optimization problem in (3) is convex, the algorithm solving primal and dual problems can converge to the optimal solution.

## 4. System Implementation

### 4.1. Design of the Blockchain System

We build the underlying blockchain system based on the source code of Ethereum Release 1.7 (geth)

. Ethereum is a well-verified mainstream blockchain project that has been applied in many areas. It is open-source so that we can modify its source code to tailor the blockchain to smart grid scenarios. Furthermore, Ethereum enables us to implement the energy management algorithm in the previous section as the smart contract.

The prosumer’s smart meter runs the blockchain software to become a blockchain node, since the smart meter is an embedded device that supports the operating system and application software. The smart meters connect to the blockchain network via the communication links such as LoRa and 5G Narrowband IoT. As shown in Fig. 2, the blockchain nodes form a peer-to-peer network that supports data communication and the operation of the blockchain.

The consensus protocol, which is used to synchronized the states of all the blockchain nodes, has a critical impact on the performance of the blockchain. To run the blockchain on the smart meter, we modified the consensus protocol from PoW (proof of work) to PoA (proof of authority) because the computational complexity of PoW is prohibitively high for the smart meters hardware. The blockchain nodes in Fig. 2 can be divided into *validators* and *normal nodes*. The validators form a committee to receive the transactions, execute smart contracts, and package them to generate a new block in a round-robin manner. The validators can also vote to add a normal node into or remove a validator out of the committee. The normal nodes are the normal prosumers that can send transactions and interact with the smart contract. The normal nodes can access the data on the blockchain and verify the execution of the transactions.

### 4.2. Decentralized Algorithm

As shown in Fig. 2, the implementation of the decentralized algorithm aims to solve the primal-dual problem in Section 3. The primal problem is locally solved by the prosumers’ smart meters using the quadratic programming package of the GNU Octave (octave); therefore, the prosumers’ private energy schedule information is protected. The dual problem is solved by the smart contract that is deployed by the VPP operator on the blockchain, which guarantees the transparency and correctness of the results. The prosumers can exchange the value of auxiliary variables with the smart contract by sending transactions to call the smart contract functions.

We implement the smart contract in Solidity (solidity) to provide three core functions. Func A solves the dual optimization problem. Note here we implement Func A as a pre-defined function in Go language because Solidity does not support floating-point computation yet. Func B sets new values to the variables that store the prosumers’ energy trading decisions . The prosumers can call this function to update their local trading decisions in each iteration. Func C outputs the values of the dual variables and the auxiliary variables computed by the first function. The prosumers can call this function to read the latest values of and in each iteration. The complete process of the algorithm is listed in Algorithm 1 in the appendix.

## 5. Evaluation

To evaluate the performance of the blockchain system, we build a test network with 48 NanoPi Neo2 (nanopi) as shown in Fig. 3

. The details of the test network are described in Appendix A.1. We measure the transaction confirmation delay (TCD) and throughput of the blockchain system with different numbers of validators (5, 10, and 20). The TCD measures the time that elapses from the moment when the node transmits a transaction to the moment when the block containing this transaction is decided by the consensus algorithm. Fig.

4a shows that the TCDs with different numbers of validators are quite close and all below ms. The throughput measured in transactions per second (TPS) is shown in Fig. 4b. In the experiment, we gradually increase the transaction transmit rate and measure the average number of confirmed transactions. We observe that the throughput increases and saturated at TPS, which is the peak throughput of the blockchain. The experimental result shows that the underlying blockchain is able to support the execution of the decentralized transactive energy management algorithm.To evaluate the performance of the Algorithm 1, we collect the energy usage data from the real-world smart grid system, including solar/wind power generations (wang2015joint) and in-house energy consumption records (pecan). We let 10 NanoPis be the prosumers and simulate for seven days. Fig. 5 shows the optimal energy trading of two typical prosumers. Prosumer 7 has higher renewable generations and sells a lot to others, whereas prosumer 6 is short of local renewables hence frequently buys energy from other prosumers.

## 6. Conclusion

We developed a blockchain system for the transactive energy management of distributed energy resources in a smart grid. We considered a comprehensive model of DERs and employed the ADMM to design a decentralized optimization algorithm. To guarantee the transparency and correctness of the algorithm, we designed a blockchain system tailored for smart meters, and implemented the decentralized algorithm in smart contract. Moreover, we build a test network of 48 NanoPis to validate the blockchain and use real-world data to evaluate the blockchain-based transactive energy management algorithm. Experiments showed that the blockchain can achieve a throughput of 150TPS with a latency below 76ms, and the transactive energy management algorithm could improve the efficiency of the smart grid.

###### Acknowledgements.

This work is in part supported by the National Natural Science Foundation of China (project no.61901280) and the FIT Academic Staff Funding of Monash University.## References

## Appendix A Implementation Details

### a.1. Hardware Configuration of the Test Network

We build a small-scale test network in Fig. 3a to evaluate the feasibility and performance of the proposed blockchain-based transactive energy management method. We use the NanoPi Neo2 in Fig. 3b to emulate the hardware of the smart meter. The NanoPi Neo2 is a low-power industrial embedded device with ARM-A53 (quad-core 1.5GHz) CPU, 1GB memory, and 16GB SD card, which is similar to the hardware configuration of a smart meter. We connect 48 NanoPis by a router to set up the test network. Each NanoPi runs a Ubuntu Core 16.04 operating system and the modified Ethereum client software (based on Release 1.7).

To run the blockchain on the NanoPi Neo2, we modified the consensus protocol from PoW (proof of work) to PoA (proof of authority) to reduce its computational complexity. In our test, running a PoW node on the NanoPi consumes 100% of the quad-core CPU time and all of its memory, which heavily slows down the operating system. By contrast, a PoA validator node consumes about 1.2% CPU time, 565MB memory, and 157MB storage (when block height is 33846); a PoA normal node consumes about 0.7% CPU time, 390MB memory, and 23MB storage. Therefore, the hardware requirements can be satisfied by inexpensive embedded devices and modern smart meters.

Comments

There are no comments yet.