Clearing method of regional power spot market based on blockchain and distributed data security reading algorithm

: With the progress of society, the supply of electricity has become an inevitable choice for the development of all walks of life. The stability, safety, and economic dispatch of the electric energy system directly impact the entire country ’ s economic development, from national defense, military, and even people ’ s daily life, all closely associated with the smooth running of the network. In the aspect of power grid planning and operation, the economic security dispatching problem of power system is a very typical optimization problem. The problem is how to maximize the operating cost of the system under the premise of satisfying the system ’ s load limit and safety and stability. Due to the rapid development of power technology, the research on power system security and economic planning is essential. As an important means to promote China ’ s energy structure adjustment and promote the supply side structural reform, the regional spot electricity market is playing an increasingly important role in building a resource optimization allocation mechanism, improving China ’ s energy resource allocation e ﬃ ciency, and promoting social and economic development. However, the development of China ’ s regional spot power market is still in its infancy, and the transaction price of the regional spot power market is quite di ﬀ erent from that of other countries. It was given these problems, this article discusses the use of particle swarm algorithms for secure and economic scheduling of power systems in the context of securely reading blockchains and distributed data. The research results showed that: The introduction of environmental pollution penalty programs improved the priority dispatch of wind and photovoltaic power when considering environmental penalty programs and backup penalties for wind and photovoltaic power. The setting of the coe ﬃ cient of the environmental penalty term depended on the designer ’ s emphasis on the priority scheduling of wind power and photovoltaic (PV) power generation (PG), and the standby capacity penalty clause achieved reasonable dispatch and utilization of wind power and PV PG, which reduced the dramatic ﬂ uctuations and intermittent volume of the system, and facilitated safe and consistent operation of the network. The research of this paper shows the positive relationship between the blockchain and distributed data security reading algorithm and the clearing method of regional spot power market, and points out a new method for its development.


Introduction
The degree of electric power industry development is an essential symbol of a country's economic development. Electricity is an important part of China's national economy, an important pillar of the national economy, and a national development strategy. During the "Thirteenth Five-Year Plan" period, China's economy has developed rapidly, and the demand for electric energy in various industries has continued to increase. In addition to ensuring the quality of power supply, it is also necessary to improve the quality of power, improve the economics of power grid operation, and reduce environmental pollution.
Power security and economic dispatch, that is, the load distribution of the power grid, is currently mainly implemented by computers. Therefore, different calculation methods have an impact on the final load distribution. On the premise of improving the overall economic benefits of the power system, it can effectively reduce the environmental pollution caused by coal-fired power plants. The traditional economic plan is mainly to reduce the cost of PG, but with the concept and development of sustainable development, increasingly governments and scholars have begun to pay attention to the environmental problems brought about by PG. The government advocates the establishment of a frugal society, promotes energy conservation and emission reduction, and strictly controls the exhaust gas of thermal power plants. Energy saving is the key to sustainable development. Therefore, the problem of load economic dispatch of power system is discussed in depth. In order to solve this problem, this paper takes regional spot electricity market as the research background, proposes a clearing method based on blockchain and distributed data security reading algorithm, and verifies the effectiveness of the proposed method through simulation. Based on the analysis of the factors that affect the clearing results of the spot electricity market, this paper proposes a regional spot electricity market clearing method (DATACS) based on the distributed data security reading algorithm. This method uses the blockchain technology as the distributed database and combines the distributed security writing algorithm with security verification to ensure that both parties of the transaction are not deceived, stolen, or tampered, to ensure that the transaction data information is not tampered; at the same time, the algorithm of "blockchain+distributed data security reading" is introduced to improve the clearing speed and ensure the accuracy of clearing results; Finally, a refreshing method based on blockchain and blockchain+distributed data security reading algorithm is proposed.
This research mainly introduced the actual operation of wind power and PV PG after grid connection and obtained the safe and economic dispatching method of power system by conducting research and certification through particle swarm algorithm. The innovation of this paper was that the particle swarm optimization (PSO) algorithm was selected as the optimization solution method, the program was written on the MATLAB software, and the 10-unit system was selected as an example for simulation, and the optimization scheme of the start-stop and output of the units before and after the wind power and PV PG was connected to the grid was solved. And the impact of wind power and PV PG on the PG cost was summed up. Finally, the method was simulated and the result indicated that the method is valid.

Related word
Since the 1930s, with the rapid development of power technology, the power market around the world is also developing rapidly, and the demand for power grids is also increasing. Therefore, this paper makes an in-depth discussion on the economical dispatch of the power grid. In recent years, many experts and scholars from various countries have conducted in-depth discussions on the economic dispatch of the power system and strive to find the best optimal solution in order to achieve greater economic benefits. Wang Z proposed a transformative architecture for the normal operation and self-healing of networked microgrid (MG) [1]. Nabae A proposed a new control strategy to stabilize the power system voltage [2]. Arani A discovered a flywheel energy storage system capable of electrical communication with the grid [3]. Jin T studied clean resources and optimized dispatching PG [4]. Palensky P and his team studied how different energy technologies such as power electronics, machines, grids, and markets, including communication technologies, can be built into a multidisciplinary multidomain system [5]. A lot of research on the power system has been done, focusing on expounding various safe and economical dispatching methods, which lays the foundation for future research. However, the above power system research lacks the support of scientific theory, which will make it unconvincing. It is necessary to introduce scientific algorithms for this.
In view of the lack of scientific theory support for the above-mentioned power system research, this paper adopted the particle swarm algorithm to study the safety and economic dispatch method of power systems. There have been many research results for the application of this algorithm. The application of Ren-W-PSo in 3D hydrofoil optimization design is feasible and effective [6]. Zhang X investigated the hybrid algorithm of particle swarm and artificial fish swarm methods for designing variogram parameter fitting [7]. Almahdi S extended the study of asset allocation and recalibration control systems for loopaugmented models with complex client constraints through particle swarm animation [8]. On the basis of knowledge reasoning and second-order vibration particle swarm algorithm, Yazhou Y U established a pile foundation optimization design system [9]. Xuan S researched PSO algorithm for the characterization of high loss piezoelectric composites [10]. These studies include a large number of PSO applications, some of which are used in the optimization design of 3D hydrofoils, and some are used for optimization algorithms. These studies can all prove the practicality of PSO. This paper applied PSO to the construction of safe and economic dispatch of power systems, which made the article more convincing and laid a solid foundation for the use of particle swarm automation in the electric energy network.
3 Regional connection, distributed data, particle swarm optimization algorithm and construction of regional electricity spot market 3.1 Blockchain technology The blockchain system architecture is shown in Figure 1.
Blockchain is a distributed library in which the stored data is synthesized as relevant chunks of data by introducing cryptographic algorithms, blockchain principles, and cryptography-related techniques. The nodes in the blockchain system are connected through P2P (peer-to-peer network), there is no central node in the system, and it has the characteristics of equality and autonomy. The four major characteristics of blockchain are: decentralized, immutable, collectively maintained, and open and transparent [11,12].
The centralized system maintains the ledger of the established credit center, and the user entrusts the operation to the credit center for execution. In a decentralized system, each user maintains a ledger. By jointly maintaining the consistency of their respective ledgers, users themselves complete the work of the credit center. In an ideal blockchain system, there is no authoritative control organization, and all nodes follow the principle of "code law" to achieve free expansion of high-availability system functions [13]. However, the technology is not yet mature in practice, and technical bugs and social engineering problems limit the realization of complete decentralization. A decentralized system must have different interest groups in order to maintain it together, and the data structure that cannot be modified is the cooperation between nodes, and the shared data can keep each node in the same state, thereby ensuring distribution. system consistency [14].

Distributed data storage system discipline
(1) Analysis of the relevant characteristics of data access time For users, it is a very effective measure to enhance the user experience to be able to quickly access data without the limitation of network conditions when accessing data. For distributed data storage systems, considering file security, user data is generally divided into multiple file blocks and stored on different nodes [15]. Therefore, when storing the number of vibrations, it is necessary to select those nodes that can meet the security requirements and reduce the data access time. When storing data, it is necessary to consider factors such as the distance between nodes and users, network conditions, etc., to select appropriate storage nodes to reduce data access time [16].
(2) Analysis of relevant characteristics of data consistency maintenance For the traditional client-server structure (C/S), the consistency maintenance of the distributed data storage system can be independent of the server. A C/S structure, in which the red node 0 represents the master node of the file, and the other nodes represent the replica nodes. When the file of node 0 is updated, other nodes should also make corresponding updates, but it must be distributed by the server [17]. In another P2P system, node 7 is the primary data node for file k, and nodes 1, 2, 4, and 6 are replica nodes for file k. When it is updated to k, the new file k must replace k in nodes 1, 2, 4, 6 as soon as possible and completely, since there is no server, the propagation of the update mainly depends on the data transfer between nodes [18]. The summary is shown in Figure 2.

Origin of basic PSO
PSO was developed in the 1990s, and its basic idea came from the research on the foraging of birds and fishes in nature. This method has the advantages of simple operation, high calculation accuracy, and good convergence [19]. Therefore, this method has been highly valued by scholars all over the world and has been verified in practice. PSO algorithm is a new algorithm, which has been well applied in many science and engineering [20].

Principles of basic PSO
(1) Original particle swarm algorithm In the traditional particle swarm approach, the particles simulate the foraging behavior of birds, and the particles are randomly assigned to a problem or the solution space of a function, and the function is evaluated by its current position. In the optimization algorithm, the particle will determine its trajectory in the search space according to four factors: the particle itself, the best position in the particle history, the best particle position in the particle swarm, random disturbance, etc. When all particles in the swarm can successfully make a single migration, the swarm will go through a full iteration. The whole group cooperates with each other in the process of optimization and moves towards the optimal point of the appropriate function. The structure is shown in Figure 3. Objective function is a function used to measure the accuracy of model prediction results in machine learning. It is usually defined as a loss function that calculates and minimizes the error between the predicted value of the model and the actual target value. In the optimization process, people update the model parameters by differentiating the objective function or gradient descent, so that it can better fit the training data.
When training the model, we need to update the model parameters by optimizing the objective function, so that it gradually approaches the optimal state. Common optimization algorithms include gradient descent, stochastic gradient descent, adam, etc. Among them, gradient descent is one of the most basic optimization algorithms. The specific implementation method is to update the model parameters according to the gradient direction of the objective function, so that it moves in the direction of smaller error. In each iteration, the gradient of the objective function at the current parameter point is calculated, and the model parameters are updated with a certain step size (learning rate) until the convergence condition is reached [21].
This means that when optimizing, the particles will find the optimal solution space according to the current optimal value and the current overall optimal value. The mathematical expression is as: In Formula (1), i = 1,2, …,n, f = 1,2, …,m, 1 are the number of iterations; v 1 is the self-cognitive constant; c 2 is the particleto-group knowledge coefficient; t 1 and t 2 are random numbers, evenly distributed in [0,1]. In addition, a maximum speed b max that limits the particle flight is also defined, which can be used to prevent particles from moving away from the search space. At the same time, v 1 and v h are continuously updated during the iterative evolution of particles, and the final output Pg is the optimal solution obtained by the PSO algorithm through iteration. c of is a coordinate used to represent any point in the search space that treats the current position as a solution to the problem to be optimized. When searching, when the current position of the particle is better than the previous position, the current position will be saved into vector a o , and the best result will be stored in a h . In the optimization process, the purpose of the algorithm is to find a better position to achieve continuous updates of a o and a h . The particle can obtain the coordinates of the next location from its own search velocity b o and current position c o .
(2) Particle swarm algorithm with inertia weight In order to better optimize the solution space and optimize the convergence performance of the basic PSO algorithm, the concept of inertia weight is introduced into the basic PSO algorithm, and the original expression is modified as: The inertia weight is used to reflect the size of the current particle velocity. The ability to discover and develop particles can be balanced by using inertia weights, which benefits from the rational selection of inertia weights. Specifically as shown in Figure 4.
It can be seen from Figure 4 that the original PSO algorithm is a special case of inertia weight ω = 1, as shown in Formula (5).
Particle motion process, c 1 is the current search point; c l+1 is the adjusted search point; b 1 is the current speed; b l+1 is the adjusted speed of the particle; b ahest is the speed based on b hbest ; b hbest is the speed based on gbest. The result is shown in Figure 5.

Adaptive quantum PSO
The delta potential drop is introduced in the quantum particle swarm algorithm compared with the standard particle swarm algorithm. It is assumed that the particle is  descending with the potential of δ, the velocity and position in the quantum space will change dynamically and randomly due to the motion of the particle. Then the wave function φ(U ) is used to represent the dynamics of the par- nt is the relative point position probability of the particle appearing and the position expression of the particle is: In Formula (6), i ∼ i (0,1), Z = 1 β = j 2 nt is the characteristic length of the delta potential drop. Since it changes with time y, the position of the particle can be expressed as: Since y is a discrete time, C(y) is a random variable. When y → ∞, if Z(y) > 0, the position C(y) converges to the point q according to probability.
These are the particle positions studied under the condition of m-dimensional potential drop, so the same is true for n-dimensional space: It is let the attractor Q = (Q o1 , Q o2 … Q om ), in each dimension direction, take Q m as the coordinate and P ok as the center to establish a one-dimensional delta potential, for each dimension the wave function of particle o for P ok : The position is: i o, k (y)∼i(0 − 1) The mean best position (nbest) is introduced, which is defined as: Then there are: Then the position is: Among them, β is the contraction and expansion factor, and the dynamic change of β can adjust the particle search area and improve the performance of the algorithm. Formula (13) is called the position iteration expression of quantum PSO. To sum up, the particle position update of QPSO is summarized as: Among them, Q o and Q f are the optimal solution of particles and the optimal solution of the population, respectively; nbest is the average best position of particles in the population; β is a parameter that needs to be determined in addition to the number of iterations and population size in QPSO, which is called the shrinkage expansion factor.

Construction of regional spot electricity market
(1) Regional spot electricity market The purpose of the construction of the regional spot electricity market is to improve the energy utilization efficiency, promote the adjustment of the energy structure, optimize the energy production and consumption structure, provide the end users with price signals and guide their reasonable consumption, to reduce the total social energy consumption. The core of the spot electricity market is to form the final settlement price of electricity through market transactions, based on which the optimal allocation of electricity can be achieved.
(2) Principle and process of clearing method for regional spot electricity market based on distributed data security reading algorithm.
The regional spot market clearing method based on the distributed data security reading algorithm aims at "all parties to the transaction can directly encrypt the transaction data", and introduces the blockchain technology into the clearing process of the spot market to ensure the security of the spot market information. The clearing method of the spot market of electric power in the region is to ensure that the data will not be cheated, stolen, or tampered when it is written to the block by introducing the blockchain technology and taking the "unchangeable" data as the guarantee, thus ensuring that the transaction data will not be damaged or forged. The secure writing data based on the distributed secure writing algorithm refers to that the read data is sent and received in the encrypted data format, that is, "unchangeable". By verifying the security of smart contracts in a distributed transaction environment, a distributed database is finally generated and built on the blockchain. At the same time, the blockchain is used as a distributed database to store the transactions of each participant, ensuring the two core goals of "tamper proof" and "traceability".
4 Impact of grid-connected wind power and PV PG on PG costs

Design experiments
In order to verify the feasibility of the PSO, a program was written in MATLAB to simulate and verify the 10-unit system, and the unit parameters and load prediction values were taken from the literature. The basic parameters of the 10 units are shown in Tables 1 and 2. According to the data of the 10 units, the minimum specific consumption of each unit is obtained, and they are sorted in descending order, and the priority order of the units is obtained as shown in Figure 6.
It can be seen from Figure 6 that the economical efficiency of unit 1 is the best, followed by unit 2, and the maximum output power of unit 1 and unit 2 is also the largest. Therefore, unit 1 and unit 2 are selected as the units bearing the base load, and the remaining units operate in sequence according to the priority of the load changes.
The load forecast value, wind power forecast value, and PV PG forecast value are shown in Figures 7 and 8, respectively.
The optimization scheduling simulation is carried out on the dynamic economic scheduling model of the power system including wind, light, and thermal power plants: the number of particle swarm population is 40, the inertia weight, and the learning factor. The simulation results are as follows: (1) Grid connection of wind power and PVs is not considered, and there is no environmental pollution penalty: The output of 10 units is shown in Table 3.
(2) Grid connection of wind power and PV power is considered, the pollution penalty item and the standby penalty of wind power and PV, PG are not considered.
The output of the unit is shown in Table 4. The economic cost of PG and the optimization process of PG cost after wind power and PV PG are connected to the grid can be found combined in Tables 3 and 4. The result is shown in Figure 9.
According to Figure 9, the final cost optimization result after multiple iterations is 567,190 yuan, and the economic cost of PG after wind power and PV PG are connected to the grid is 543,060 yuan. The output of the unit is shown in Table 5.
The optimization process of PG economic cost after grid connection and the comparison of PSO and QPSO algorithm results are shown in Figure 10.
It can be seen from Figure 10 that the PG cost is 641,011 yuan after considering the environmental pollution penalty and the wind power and PV PG backup penalty.

Data and results
The research results showed that the optimal solution of the QPSO algorithm was better than the optimal solution of the PSO algorithm, and the research results proved that the priority order method could improve the accuracy of seeking the optimal solution for the particle swarm algorithm. It can be seen from Figure 9 that when the wind power and PV PG were connected to the grid, the PG cost changed from 567,190 yuan to 543,060 yuan, and the cost was reduced. Due to the grid connection of wind farms and PV power plants, the output power of thermal power units was reduced, which had the effect of reducing coal consumption, showing the economic advantages of wind power and PV PG. It can be seen from Figure 10 that after considering the environmental pollution penalty and the reserve capacity penalty in the system objective function, the economic cost of the output of the unit of 641,011 yuan was higher than the economic cost of PG when it was not added, which was 543,060 yuan. This was because after wind power and PV PG were connected to the grid, although the output power of conventional thermal power units was reduced, the system needed to reserve more spinning reserve, which would affect the PG efficiency of thermal power units and increase the total cost of PG. When considering the environmental penalty item and the wind power and PV PG backup penalty,   the introduction of the environmental pollution penalty item improved the priority scheduling of wind power and PV PG. The setting of the coefficient of the environmental penalty term depended on the designer's emphasis on the priority scheduling of wind power and PV PG, while the reserve capacity penalty term realized the reasonable dispatching and utilization of wind power and PV PG, reduced the violent fluctuation and intermittent amount of the system, and was beneficial to the safe and stable operation of the system. The setting of the backup penalty coefficient and size depends on the designer's attention to the safety and stability of the system.   Figure 9: Iterative curve of system PG cost and economic cost.

Conclusions
With the current energy crisis and increasingly serious environmental problems, the development and utilization of renewable energy have become the focus of attention.
Wind energy and solar energy are the most representative renewable energy sources. Their advantages are rich in resources, pollution-free and renewable, but their disadvantages are randomness and volatility. These defects make the grid connection of wind and PV difficult to control and predict, which increases the difficulty of grid connection and brings new challenges to the economic dispatch of the power system. In this paper, we propose a regional spot market clearing method based on particle swarm optimization algorithm under distributed data security reading algorithm, which can ensure the integrity and reliability of clearing result information. The PG characteristics of wind PG and PV PG were firstly analyzed, to predict their output power, and a dynamic economic dispatch model of power system including wind, solar and thermal power stations was established. Then, the improved particle swarm algorithm was used on Matlab software to find the optimal PG scheme for the dispatch model. Finally, according to the characteristics of wind PG, the energy storage system was added to the dispatch model, and the 10-machine system was simulated and verified to prove the feasibility of solving the dispatch model and adding the energy storage system.