An intelligent contract of power system physical constraint and a blockchain implementation method thereof
Patent Information
- Application Number
- CN202511540128.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-27
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2045-10-27
AI Technical Summary
[0005]因此,本发明提供了一种电力系统物理约束智能合约及其区块链实现方法解决了现有区块链电力交易平台无法对交易进行电网物理安全性自动验证,导致信息域与物理域脱节的关键问题
[0017] The beneficial effects of this invention are as follows: by rapidly decoupling power flow calculation to simulate the power grid state after a transaction, and combining it with a dynamic weight adjustment algorithm for adaptive constraint verification, the smart contract possesses forward-looking risk assessment and accurate verification capabilities, fundamentally solving the problem of the disconnect between blockchain transactions and physical security. While ensuring processing efficiency, it significantly improves the safety of power grid operation. The Byzantine fault-tolerant consensus mechanism is used to conduct distributed confirmation of the verification conclusions, ensuring the correctness and immutability of the verification results even in the event of some node anomalies.
Smart Images

Figure CN121744350B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of smart contract technology, and in particular to a smart contract for physical constraints of power systems and its blockchain implementation method. Background Technology
[0002] With the development of the energy internet and distributed energy, blockchain technology, due to its advantages such as decentralization and transparency, is being applied to electricity trading platforms. Existing technical solutions typically utilize smart contracts to achieve transaction matching and fund settlement, for example, by recording transaction information on the blockchain and verifying signatures to complete peer-to-peer electricity transactions. This type of method improves transaction efficiency and reduces intermediary costs.
[0003] However, existing technologies primarily focus on economic logic and information security, without deeply considering the physical security constraints of power systems. Power transmission must strictly adhere to physical laws such as power flow equations, line capacity, and voltage stability. Existing blockchain trading platforms lack the ability to verify whether transactions lead to line overload or voltage exceedances. Their smart contracts can only process on-chain information such as transaction format and account balance, and cannot assess the impact of transactions on the physical security of the power grid. This may result in transactions reached on the blockchain being infeasible in the actual power grid, or even causing operational risks. The disconnect between the information domain and the physical domain limits the deep application of blockchain in core power business. Summary of the Invention
[0004] In view of the aforementioned existing problems, the present invention is proposed.
[0005] Therefore, this invention provides a smart contract for physical constraints of power systems and its blockchain implementation method, which solves the key problem that existing blockchain power trading platforms cannot automatically verify the physical security of power grid transactions, resulting in a disconnect between the information domain and the physical domain.
[0006] To solve the above-mentioned technical problems, the present invention provides the following technical solution: In a first aspect, the present invention provides a smart contract for physical constraints of a power system and a blockchain implementation method thereof, which includes deploying a smart contract on a blockchain and configuring the initial topology of the power grid, equipment parameters and basic physical constraints in the smart contract; The data interface node obtains real-time power grid status data from the power data acquisition and monitoring unit, and performs preprocessing and data quality assessment on the real-time power grid status data. The transaction initiator constructs a power transaction request and digitally signs it using a private key, then broadcasts it to the blockchain. The smart contract calls the transaction verification function and, in conjunction with the real-time power grid status data, performs a fast decoupled power flow calculation to simulate the operating state after the power transaction request is executed. The smart contract, based on the simulated running state after the execution of the power trading request, applies a dynamic weight adjustment algorithm to obtain the real-time weights of the physical constraints, and executes constraint verification logic. The constraint verification logic discretizes the continuous physical constraints into binary judgment conditions and performs a logical AND operation to generate a preliminary verification conclusion for the power trading request. The blockchain verification node performs consensus verification on the block containing the preliminary verification conclusion based on the Byzantine fault tolerance mechanism, and records the block on the chain after reaching a consensus. The power grid control center executes power grid dispatch instructions based on the power transaction request obtained on the blockchain, and the smart contract updates its internal state.
[0007] As a preferred embodiment of the smart contract for power system physical constraints and its blockchain implementation method according to the present invention, the method includes the following steps: Deploying a smart contract on the blockchain and configuring the initial topology of the power grid, equipment parameters, and basic physical constraints in the smart contract. Create and deploy the core smart contract on the selected blockchain, call the management function of the deployed core smart contract, and write the initial topology of the power grid into the core smart contract; Call the configuration function of the core smart contract for the initial topology of the power grid to configure the device parameters into the core smart contract; Call the constraint setting function of the core smart contract for the initial topology and equipment parameters of the power grid, and set the basic physical constraints into the core smart contract; Call the activation function of the core smart contract that has completed the initial configuration of the power grid topology, equipment parameters and basic physical constraints, and activate the core smart contract.
[0008] As a preferred embodiment of the power system physical constraint smart contract and its blockchain implementation method described in this invention, the data interface node obtains real-time power grid status data from the power data acquisition and monitoring unit, and performs preprocessing and data quality assessment on the real-time power grid status data, including the following steps: The data interface node obtains real-time power grid status data from the power data acquisition and monitoring unit. The data interface node performs data cleaning on the real-time power grid status data, identifying and removing outliers from the real-time power grid status data. The data interface node applies a standardized algorithm to the cleaned real-time power grid status data to eliminate the influence of different physical quantities in the real-time power grid status data. The data interface node inputs the standardized real-time power grid status data into the data quality assessment model to calculate the quality index of the real-time power grid status data. The data interface node determines the feasibility of real-time power grid status data based on the quality indicators output by the data quality assessment model. Based on the maximum measurement error range allowed by the power unit safe operation procedure and the percentile of the quality indicator distribution obtained by the data quality assessment model in the historical fault-free operation cycle, a quality threshold is set. When the quality indicator is higher than the quality threshold, the real-time power grid status data is submitted to the smart contract.
[0009] As a preferred embodiment of the smart contract for physical constraints of the power system and its blockchain implementation method according to the present invention, the transaction initiator constructs a power transaction request and digitally signs it using a private key, then broadcasts it to the blockchain, including the following steps: The transaction initiator determines the transaction volume, transaction price, transaction time window, and counterparty node information for the electricity transaction request; The transaction initiator assembles the power transaction request into a complete power transaction request data packet according to a predefined structured format; The transaction initiator uses its own asymmetric encryption private key to digitally sign the complete power transaction request data packet. The transaction initiator then binds the digital signature to the complete power transaction request data packet to form a signed power transaction request.
[0010] The transaction initiator broadcasts the signed electricity transaction request to the nodes of the blockchain network, and the blockchain network nodes receive and verify the legality of the format of the signed electricity transaction request. Blockchain network nodes store legally formatted, signed electricity transaction requests into a transaction pool, where they are processed by smart contracts.
[0011] As a preferred embodiment of the smart contract for power system physical constraints and its blockchain implementation method described in this invention, the smart contract calls a transaction verification function, combines the real-time power grid status data, and performs a fast decoupled power flow calculation to simulate the operating state after the power transaction request is executed, including the following steps: The smart contract receives and verifies the digital signature of the power transaction request, and the transaction verification function of the smart contract calls the real-time power grid status data that has been preprocessed and assessed for data quality. The transaction verification function of the smart contract applies the power change amount of the power transaction request to the real-time power grid status data to form the hypothetical unit state after the transaction. The transaction verification function of the smart contract is based on the hypothetical unit state after the transaction, and constructs an active power-phase angle correction equation for fast decoupling power flow calculation. The transaction verification function of the smart contract iteratively solves the active power-phase angle correction equation and the reactive power-voltage correction equation, and the power imbalance is less than the convergence tolerance. The smart contract's transaction verification function outputs an iterative solution to obtain the node voltage phase angle, voltage amplitude, and line power, simulating the operating state after the power transaction request is executed.
[0012] As a preferred embodiment of the smart contract for power system physical constraints and its blockchain implementation method described in this invention, the smart contract obtains the real-time weights of the physical constraints by applying a dynamic weight adjustment algorithm based on the simulated running state after the power trading request is executed, and executes constraint verification logic. The constraint verification logic discretizes the continuous physical constraints into binary judgment conditions and performs a logical AND operation to generate a preliminary verification conclusion for the power trading request, including the following steps: The smart contract obtains the operating status data after simulating the execution of the power trading request, and calculates the risk assessment value of the current hypothetical power grid operating status based on the operating status data after simulating the execution of the power trading request. The smart contract inputs the risk assessment value into a dynamic weight adjustment algorithm to obtain the real-time weight of the physical constraints; The smart contract applies real-time weights to physical constraints to adjust the safety margin coefficient during the discretization of continuous physical constraints. The smart contract uses a safety margin coefficient to discretize continuous physical constraints into binary judgment conditions. The smart contract performs a logical AND operation on the binary judgment conditions of all physical constraints. The smart contract generates a preliminary verification conclusion for the power trading request based on the results of the logic and operations.
[0013] As a preferred embodiment of the smart contract for physical constraints of the power system and its blockchain implementation method described in this invention, the blockchain verification node performs consensus verification on the block containing the preliminary verification conclusion based on the Byzantine fault tolerance mechanism, and records the block on the chain after reaching consensus, including the following steps: The blockchain verification node receives the consensus block of the preliminary verification conclusion. The blockchain verification node independently verifies the preliminary verification conclusion and related transaction data in the consensus block based on the Byzantine fault tolerance mechanism. Each blockchain verification node votes on the consensus block based on its independent verification results. The blockchain verification nodes collect and statistically analyze the voting results of each verification node in the network. The consensus threshold preset by the Byzantine fault tolerance mechanism is used to determine whether consensus has been reached. After consensus is reached, the blockchain verification node adds the block to be reached to the blockchain and broadcasts the new blockchain state to the entire network.
[0014] As a preferred embodiment of the smart contract for physical constraints of the power system and its blockchain implementation method described in this invention, the power grid control center executes power grid dispatch instructions based on the power transaction request obtained on the blockchain, and the smart contract updates its internal state, including the following steps: The power grid control center monitors the blockchain and captures the event of the power transaction request being successfully uploaded to the chain. The power grid control center parses the uploaded power transaction request and extracts power dispatch information. Based on the extracted power dispatch information, the power grid control center generates power grid dispatch instructions, which are then sent to the physical power grid for execution. The smart contract detects that the power transaction request has been successfully uploaded to the blockchain and confirmed. Based on the confirmed power transaction request content, the smart contract updates the internally maintained power grid state variables.
[0015] In a second aspect, the present invention provides a computer device including a memory and a processor, wherein the memory stores a computer program, wherein: when the computer program is executed by the processor, it implements any step of the power system physical constraint smart contract and its blockchain implementation method as described in the first aspect of the present invention.
[0016] Thirdly, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein: when the computer program is executed by a processor, it implements any step of the power system physical constraint smart contract and its blockchain implementation method as described in the first aspect of the present invention.
[0017] The beneficial effects of this invention are as follows: by rapidly decoupling power flow calculation to simulate the power grid state after a transaction, and combining it with a dynamic weight adjustment algorithm for adaptive constraint verification, the smart contract possesses forward-looking risk assessment and accurate verification capabilities, fundamentally solving the problem of the disconnect between blockchain transactions and physical security. While ensuring processing efficiency, it significantly improves the safety of power grid operation. The Byzantine fault-tolerant consensus mechanism is used to conduct distributed confirmation of the verification conclusions, ensuring the correctness and immutability of the verification results even in the event of some node anomalies. Attached Figure Description
[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 A flowchart for smart contracts for physical constraints in power systems and their blockchain implementation methods.
[0020] Figure 2 A schematic diagram is constructed for an electricity trading request. Detailed Implementation
[0021] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0022] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.
[0023] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.
[0024] Example 1, referring to Figure 1 and Figure 2 This is the first embodiment of the present invention, which provides a smart contract for physical constraints of a power system and its blockchain implementation method, including the following steps: S1. Deploy smart contracts on the blockchain and configure the initial topology of the power grid, equipment parameters, and basic physical constraints in the smart contracts.
[0025] S1.1 Create and deploy the core smart contract on the selected blockchain, call the management function of the deployed core smart contract, and write the initial topology of the power grid into the core smart contract.
[0026] Furthermore, on the selected blockchain platform, the core smart contract code is written using Solidity or Go smart contract programming languages. After compilation, the code is sent to the blockchain network via a deployment transaction signed by the contract deployer's account. Miners or validators in the network execute this transaction and successfully record the core smart contract code on the chain, generating a unique contract address. Subsequently, the deployer's account constructs a call transaction that points to the deployed core smart contract address and calls a predefined management function within the core smart contract, with permissions limited to the deployer only. For example, a function named `initializeGridTopology` receives a structured data parameter containing the initial topology information of the power grid, such as an array of node connections and a list of line identifiers. After the call transaction is confirmed by the blockchain network, the logic in the `initializeGridTopology` function is executed, permanently writing the incoming initial topology information of the power grid into the core smart contract's storage space.
[0027] S1.2 Call the configuration function of the core smart contract for the initial topology of the power grid to configure the device parameters into the core smart contract.
[0028] Furthermore, based on the initial topology of the power grid already contained in the core smart contract, the deployer account constructs another call transaction, pointing to the core smart contract address and calling a predefined configuration function. When calling the configureDeviceParameters function, a structured data parameter is passed in. This data parameter contains device parameter information, such as the maximum and minimum output values of generator sets, and the turns ratio and impedance values of transformers. These device parameters establish a mapping relationship with the previously written initial topology of the power grid through their associated node or line identifiers. The configureDeviceParameters function stores the device parameters in the core smart contract and binds them to the corresponding power grid topology elements.
[0029] S1.3 Call the constraint setting function of the core smart contract for the initial topology and equipment parameters of the power grid, and set the basic physical constraints into the core smart contract.
[0030] Furthermore, based on the initial topology and equipment parameters of the power grid already contained in the core smart contract, the deployer account constructs a call transaction to invoke a predefined constraint setting function in the core smart contract. When calling the setBasicPhysicalConstraints function, a structured data parameter is passed in. This data parameter lists the basic physical constraints, such as the safe operating upper and lower limits of node voltages, and the long-term allowable current carrying capacity of each line. The function execution logic writes the basic physical constraints as constants or configurable variables into the core smart contract.
[0031] S1.4 Call the activation function of the core smart contract that has completed the initial topology, equipment parameters and basic physical constraints configuration of the power grid, and activate the core smart contract.
[0032] Furthermore, after confirming that the core smart contract has completed the configuration of the initial topology, equipment parameters, and basic physical constraints of the power grid, the deployer account constructs the final initialization call transaction, invoking an activation function in the core smart contract. The activateContract function may contain logic to check whether the aforementioned configuration is complete, such as verifying that key parameters are not empty, and then sets the value of a state variable that marks the running state of the core smart contract from false to true. This state change means that the core smart contract is ready and will begin to accept and process external power transaction requests.
[0033] S2. The data interface node obtains real-time power grid status data from the power data acquisition and monitoring unit, and performs preprocessing and data quality assessment on the real-time power grid status data.
[0034] S2.1 The data interface node obtains real-time power grid status data from the power data acquisition and monitoring unit. The data interface node performs data cleaning on the real-time power grid status data, and identifies and removes outliers from the real-time power grid status data.
[0035] Furthermore, the data interface node establishes a connection with the power data acquisition and monitoring unit through a standard communication protocol, periodically acquiring real-time power grid status data containing information such as voltage, current, and power. After acquiring the real-time power grid status data, the data interface node runs a data cleaning algorithm. This algorithm, based on statistical principles, scans the real-time power grid status data stream and identifies outliers that significantly deviate from the normal range. The identified outliers are removed from the data sequence. For the gaps left by the removed data points, linear interpolation or normal data from adjacent time points is used to fill them, ensuring the continuity of the real-time power grid status data sequence.
[0036] S2.2 The data interface node applies a standardized algorithm to the real-time power grid status data after data cleaning to eliminate the influence of different physical quantities in the real-time power grid status data.
[0037] Furthermore, the data interface node applies a standardization algorithm to the cleaned real-time power grid status data. This algorithm processes the measured values of different physical dimensions in the real-time power grid status data separately. The standardization algorithm calculates the mean and standard deviation of the historical data for each type of measurement value, then subtracts the mean from the current measurement value and divides it by the standard deviation to obtain standardized real-time power grid status data with a mean of zero and a standard deviation of one. This process eliminates the numerical scale differences between data of different dimensions such as voltage and power, making all real-time power grid status data transform to the same order of magnitude.
[0038] S2.3 The data interface node inputs the standardized real-time power grid status data into the data quality assessment model to calculate the quality index of the real-time power grid status data.
[0039] The expression for the quality indicator is: ; in, For quality indicators, The first in the real-time power grid status data One measurement value, For the first The expected value corresponding to each measurement. This represents the noise standard deviation.
[0040] Furthermore, the data interface node inputs the standardized real-time power grid status data into the data quality assessment model, which is constructed based on the Gaussian distribution probability concept. The data quality assessment model compares each current measurement value in the standardized real-time power grid status data with a corresponding expected value, which can be derived from short-term status prediction results or historical data from the same period. The data quality assessment model calculates the square of the deviation between the current measurement value and the expected value, divides it by twice the square of the noise standard deviation, and finally takes the negative exponent to obtain a quality index ranging from zero to one. The noise standard deviation is a preset parameter that reflects the inherent noise level of the measuring equipment.
[0041] S2.4 The data interface node determines the feasibility of real-time power grid status data based on the quality indicators output by the data quality assessment model. Based on the maximum measurement error range allowed by the power unit safe operation procedure and the percentile of the quality indicator distribution obtained by the data quality assessment model in the historical fault-free operation cycle, a quality threshold is set. When the quality indicator is higher than the quality threshold, the real-time power grid status data is submitted to the smart contract.
[0042] Furthermore, the data interface node determines the feasibility of real-time power grid status data based on the quality indicators output by the data quality assessment model. The quality threshold is set based on two criteria: first, the maximum measurement error range allowed by the power unit's safe operation procedures, which defines the basic accuracy requirements for acceptable data; and second, the distribution of quality indicators calculated by the data quality assessment model during historical fault-free operation cycles, for example, taking the 95th percentile of historical quality indicator data as the threshold benchmark. A final quality threshold is determined by combining these two criteria. When the quality indicator calculated by the data quality assessment model is higher than this quality threshold, the data interface node packages the corresponding standardized real-time power grid status data and submits it to the smart contract on the blockchain. If the quality indicator is lower than the threshold, an alarm is triggered and a backup data source may be activated.
[0043] S3. The transaction initiator constructs an electricity transaction request and uses its private key to digitally sign it and broadcast it to the blockchain.
[0044] S3.1 The transaction initiator determines the transaction volume, transaction price, transaction time window, and counterparty node information of the power transaction request.
[0045] Furthermore, the initiator of the transaction determines the specific parameters of the electricity transaction request based on its own power generation or consumption needs. These parameters include the planned amount of electricity to be traded, the electricity price for the transaction, the time window consisting of the start and end times of the transaction, and the counterparty node information, which is the unique address identifier of the counterparty on the blockchain network. S3.2 The transaction initiator assembles the power transaction request into a complete power transaction request data packet according to a predefined structured format.
[0046] Furthermore, the transaction initiator assembles the determined transaction volume, transaction price, transaction time window, and counterparty node information according to a predefined structured data format of the blockchain network and core smart contract. This predefined structured format is usually in JSON format, which clearly specifies the name, type, and order of each field. The assembly process involves filling the corresponding fields of the structured format with the values of the transaction volume, transaction price, transaction time window, and counterparty node information to form a complete power transaction request data packet that can be parsed by machines.
[0047] S3.3 The transaction initiator uses its own asymmetric encryption private key to perform digital signature operation on the complete power transaction request data packet. The transaction initiator binds the digital signature to the complete power transaction request data packet to form a signed power transaction request.
[0048] Furthermore, the transaction initiator uses its own asymmetric encryption private key to perform digital signature calculation on the complete power transaction request data packet. The digital signature calculation process is to first calculate the hash digest of the power transaction request data packet, and then encrypt the hash digest using the asymmetric encryption private key to generate a unique digital signature. The transaction initiator binds the digital signature to the complete power transaction request data packet, usually adding the digital signature as an additional field to the data packet or storing it alongside the data packet, together forming a signed power transaction request.
[0049] S3.4 The transaction initiator broadcasts the signed electricity transaction request to the nodes of the blockchain network. The blockchain network nodes receive and verify the legality of the format of the signed electricity transaction request.
[0050] Furthermore, the transaction initiator broadcasts the signed electricity transaction request to the blockchain network nodes it is connected to. After receiving the signed electricity transaction request, the blockchain network nodes first verify its format validity. The checks include whether the electricity transaction request data packet contains all required fields, whether the field data types are correct, and whether the values such as the transaction electricity or transaction price are within a reasonable range (e.g., non-negative). This verification does not involve the validity of the signature, but only performs syntax and basic semantic checks.
[0051] S3.5 Blockchain network nodes store legally formatted and signed electricity transaction requests into the transaction pool, where they are processed by smart contracts.
[0052] Furthermore, signed electricity transaction requests that have passed the format validity verification are stored by blockchain network nodes in a temporary storage area called a transaction pool; the transaction pool is a collection of signed electricity transaction requests waiting to be included in a block; the blockchain network's miners or validators select signed electricity transaction requests from the transaction pool and package them into a new candidate block for subsequent processing by the core smart contract.
[0053] S4. The smart contract calls the transaction verification function, combines real-time power grid status data, and performs fast decoupled power flow calculation to simulate the running state after the power transaction request is executed.
[0054] S4.1 The smart contract receives and verifies the digital signature of the power transaction request. The smart contract's transaction verification function calls the real-time power grid status data that has been preprocessed and assessed for data quality.
[0055] Furthermore, after the transaction verification function of the core smart contract is triggered, it first receives the signed electricity transaction request extracted from the transaction pool. The transaction verification function uses the asymmetric encryption public key publicly stored on the blockchain by the transaction initiator to decrypt the digital signature of the electricity transaction request, obtaining a hash digest A. The transaction verification function calculates a hash digest B on the electricity transaction request data packet itself. The validity of the digital signature is verified by comparing whether hash digest A and hash digest B are consistent. If they are consistent, the verification is successful. After successful verification, the transaction verification function calls the preprocessed and data quality-assessed real-time power grid status data from the data storage area published on the chain by the data interface node. This data contains information such as the voltage and power injection of each node at the current moment.
[0056] S4.2 The transaction verification function of the smart contract applies the power change of the power transaction request to the real-time grid status data to form the hypothetical unit state after the transaction.
[0057] Furthermore, the transaction verification function parses the power transaction request data packet, extracting the transaction amount, transaction time window, and node information of both parties. Based on the transaction amount and transaction direction, the transaction verification function calculates the power injection changes caused by this power transaction request at the seller node and buyer node, respectively. For example, the decrease in power injection at the seller node is equal to the increase in power injection at the buyer node. The transaction verification function then adds the calculated power change to the corresponding node power injection value in the real-time grid status data obtained from the data interface node, thereby forming a new power distribution state assuming that the power transaction request has been executed. This state is the hypothetical unit state after the transaction.
[0058] S4.3 The transaction verification function of the smart contract is based on the hypothetical unit state after the transaction, and constructs an active power-phase angle correction equation for fast decoupling power flow calculation.
[0059] Furthermore, the transaction verification function calculates the active power imbalance between the current state and the target power balance state based on the node power injection data in the hypothetical unit state after the transaction. The transaction verification function uses the initial topology and equipment parameters (such as line reactance) of the power grid pre-stored in the core smart contract to construct the imaginary part of the node admittance matrix. This matrix primarily reflects the relationship between branch reactance and active power flow and voltage phase angle; the active power-phase angle correction equation is constructed as follows: = • ,in The equation represents the phase angle correction vector of the node voltage to be solved; this equation ignores the coupling between active power and voltage amplitude, achieving fast decoupling.
[0060] S4.4 The transaction verification function of the smart contract iteratively solves the active power-phase angle correction equation and the reactive power-voltage correction equation, and the power imbalance is less than the convergence tolerance.
[0061] Furthermore, while constructing the active power-phase angle correction equation, the transaction verification function also constructs the reactive power-voltage correction equation for fast decoupled power flow calculation based on the hypothetical unit state after the transaction. In the form of ,in This refers to the reactive power imbalance. For a matrix based on branch susceptance, The node voltage magnitude correction is to be solved; the transaction verification function iteratively solves the active power-phase angle correction equation and the reactive power-voltage correction equation; in each iteration, the active power-phase angle correction equation is solved first to obtain... After updating the phase angle, the reactive power-voltage correction equation is then solved to obtain... Update the voltage amplitude; the iterative process continues until the power imbalance at all nodes is reached. and The absolute maximum value is less than the preset convergence tolerance.
[0062] S4.5 The transaction verification function of the smart contract outputs an iterative solution to obtain the node voltage phase angle, voltage amplitude, and line power, simulating the operating state after the power transaction request is executed.
[0063] Furthermore, once the iterative process meets the convergence condition, the transaction verification function outputs the node voltage phase angle vector and node voltage magnitude vector obtained from the final iterative solution. Based on the node voltage phase angle vector and node voltage magnitude vector, combined with the branch parameters in the initial topology of the power grid, the transaction verification function calculates the power distribution of each line, i.e., the line power. The node voltage phase angle vector, node voltage magnitude vector, and line power together constitute the operating state after the simulated power transaction request is executed.
[0064] S5. Based on the running status after the execution of the simulated power trading request, the smart contract applies a dynamic weight adjustment algorithm to obtain the real-time weights of the physical constraints, and executes the constraint verification logic. The constraint verification logic discretizes the continuous physical constraints into binary judgment conditions and performs a logical AND operation to generate the preliminary verification conclusion of the power trading request.
[0065] S5.1 The smart contract obtains the operating status data after the execution of the simulated power trading request. Based on the operating status data after the execution of the simulated power trading request, the smart contract calculates the risk assessment value of the current hypothetical power grid operating status.
[0066] The expression for the risk assessment value is: ; in, For at any time The first related to the transaction Risk assessment values at each level The number of lines being monitored. The first operational status data after the execution of the proposed power transaction request. Real-time power flow of the line, For the first The maximum safe transmission capacity of the line, The number of nodes in the monitored set. For node indexing, The first step is to simulate the operational status data after the power transaction request is executed. The voltage amplitude at each node, For the first The rated voltage value of each node, This is the magnification factor. This is the index for the line.
[0067] Furthermore, the system simulates the operational status data after the execution of a power trading request. This data includes node voltage phase angle, node voltage amplitude, and line power. Based on this data, the smart contract calculates a risk assessment value for the current hypothetical power grid operation. The risk assessment value calculation process involves: traversing all monitored lines, calculating the ratio of the real-time power flow of each line to the maximum safe transmission capacity of the first line, and squaring the ratio to amplify the risk of exceeding limits; simultaneously traversing all monitored nodes, calculating the ratio of the absolute deviation of the voltage amplitude of each node from the rated voltage value of the first node to the maximum allowable voltage deviation, and squaring the ratio; and summing the risk components of all lines and all nodes according to preset weights to obtain the comprehensive risk assessment value at the first level related to the transaction at time t.
[0068] S5.2 The smart contract inputs the risk assessment value into the dynamic weight adjustment algorithm to obtain the real-time weight of the physical constraints.
[0069] Furthermore, the risk assessment value is input into the dynamic weight adjustment algorithm. The expression of the dynamic weight adjustment algorithm is: the real-time weight of the physical constraint is equal to the sum of the product of the physical constraint's base weight multiplied by one, the adjustment coefficient, and the risk assessment value. The base weight of the physical constraint is a static value set in advance according to the importance of the constraint, and the adjustment coefficient is a preset constant that controls the sensitivity. The higher the risk assessment value, the greater the real-time weight of the physical constraint, making the constraint more decisive in subsequent verification.
[0070] S5.3. Apply real-time weights to physical constraints in smart contracts and adjust the safety margin coefficients during the discretization of continuous physical constraints.
[0071] Furthermore, smart contracts use the real-time weights of physical constraints obtained from the dynamic weight adjustment algorithm to adjust the safety margin coefficient in the discretization determination process of continuous physical constraints. The adjustment method is to divide the original safety margin coefficient of the physical constraint by the real-time weight of the physical constraint to obtain a tightened new safety margin coefficient. The larger the real-time weight of the physical constraint, the more critical the constraint is in the current state, and the smaller the calculated new safety margin coefficient is, thus making the discretization determination condition of the constraint more stringent and the tolerance range narrower.
[0072] S5.4 Smart contracts use a safety margin coefficient to discretize continuous physical constraints into binary judgment conditions. The smart contract performs a logical AND operation on all the binary judgment conditions of physical constraints.
[0073] Furthermore, the smart contract uses the adjusted new safety margin coefficient to execute constraint verification logic. The constraint verification logic operates on each physical constraint: for line power constraints, it determines whether the real-time power flow of the line is less than or equal to the line's maximum safe transmission capacity multiplied by the new safety margin coefficient; if true, it outputs "true," otherwise it outputs "false." For node voltage constraints, it determines whether the node's voltage amplitude is between the upper and lower limits defined by the rated voltage multiplied by the new safety margin coefficient; if true, it outputs "true," otherwise it outputs "false." The smart contract performs a logical AND operation on the binary judgment conditions (true or false) generated after discretizing all physical constraints; that is, the result of the logical AND operation is true only when all binary judgment conditions are true.
[0074] S5.5 The smart contract generates preliminary verification conclusions for the electricity transaction request based on the results of the logic and operations.
[0075] Furthermore, the smart contract generates a preliminary verification conclusion for the electricity trading request based on the result of the logical AND operation; if the result of the logical AND operation is true, the preliminary verification conclusion is passed; if the result of the logical AND operation is false, the preliminary verification conclusion is rejected; the preliminary verification conclusion and related state data are encapsulated.
[0076] S6. Blockchain verification nodes use the Byzantine fault tolerance mechanism to perform consensus verification on blocks containing preliminary verification conclusions, and record the blocks on the chain after reaching a consensus.
[0077] S6.1 The blockchain verification node receives the consensus block with preliminary verification results. The blockchain verification node independently verifies the preliminary verification results and related transaction data in the consensus block based on the Byzantine fault tolerance mechanism.
[0078] Furthermore, the blockchain verification nodes receive the consensus block containing preliminary verification conclusions and related electricity transaction request data, packaged by the miner nodes. Each blockchain verification node independently verifies the preliminary verification conclusions and related transaction data within the consensus block, based on the requirements of the Byzantine fault tolerance mechanism. The verification process includes: the blockchain verification node locally re-executes the smart contract's transaction verification function, using the electricity transaction request data from the consensus block and the latest known real-time grid status data to re-perform rapid decoupled power flow calculation, risk assessment value calculation, dynamic weight adjustment, and constraint verification logic, generating a local verification conclusion; the blockchain verification node compares the locally generated verification conclusion with the preliminary verification conclusion contained in the consensus block to determine if they are consistent. S6.2 Each blockchain verification node votes on the consensus block based on the results of its independent verification. The blockchain verification node collects and tallies the voting results of each verification node in the network.
[0079] Furthermore, the consensus block is voted on; if the locally generated verification conclusion is consistent with the preliminary verification conclusion contained in the consensus block, the blockchain verification node votes in favor; if they are inconsistent, the blockchain verification node votes against. The blockchain verification node broadcasts its own voting results to other verification nodes through the network, and also collects the voting results from other verification nodes in the network; the blockchain verification node counts all the collected voting results.
[0080] S6.3. Based on the consensus threshold preset by the Byzantine fault tolerance mechanism, the consensus is judged. After the consensus is reached, the blockchain verification node adds the block to be agreed to the blockchain and broadcasts the new blockchain state to the entire network.
[0081] Furthermore, the blockchain verification nodes determine whether consensus has been reached based on the consensus threshold preset by the Byzantine fault tolerance mechanism. The consensus threshold is set at a ratio of more than two-thirds of the total number of verification nodes. If the calculated ratio of affirmative votes exceeds the two-thirds consensus threshold, it is determined that consensus has been reached. Once consensus is reached, the blockchain verification node responsible for producing the block appends the block to be consensus to the end of the local blockchain, forming a new longest chain. The blockchain verification node broadcasts the updated new blockchain state to the entire network, notifying all other nodes to synchronize this new block, thereby completing the on-chain process.
[0082] S7. The power grid control center executes power grid dispatch instructions based on the power transaction requests obtained on the blockchain, and the smart contract updates its internal state.
[0083] S7.1 The power grid control center listens to the blockchain, captures the event of a power transaction request being successfully uploaded to the chain, parses the uploaded power transaction request, and extracts power dispatch information.
[0084] Furthermore, the power grid control center runs a blockchain event listener that continuously scans newly added blocks on the blockchain. When the listener captures a new block and the block's transaction records contain a power transaction request with a successful on-chain status, it determines that a power transaction request has been successfully on-chain. The power grid control center then fully reads the original data packet of the power transaction request from the transaction data of that block. The power grid control center parses the power transaction request data packet to extract key power dispatch information, including at least the transaction amount, the transaction execution time window, and the identifiers of the seller and buyer nodes involved in the transaction.
[0085] S7.2 The power grid control center generates power grid dispatch instructions based on the extracted power dispatch information, and then sends the power grid dispatch instructions to the physical power grid for execution.
[0086] Furthermore, the power grid control center generates specific power grid dispatch instructions based on the power dispatch information extracted from the power trading request. The traded electricity is decomposed into specific, executable power adjustment instructions according to the trading time window. The instructions clearly specify the power injection or extraction value to be set for a specific node at a specific time point. The power grid control center issues the generated power grid dispatch instructions to the corresponding execution units in the physical power grid in accordance with standard protocols through the power dispatch data network.
[0087] S7.3 The smart contract detects that the power transaction request has been successfully uploaded to the chain and confirmed. Based on the confirmed power transaction request content, the smart contract updates the internally maintained power grid state variables.
[0088] Furthermore, by listening to blockchain events, the smart contract monitors whether the power transaction request has been successfully recorded on the chain and confirmed by a sufficient number of subsequent blocks, thus ensuring that the transaction is irreversible. The smart contract then updates its internally maintained grid state variables based on the confirmed power transaction request content, especially the transaction amount and the transaction node: in the smart contract's state storage, the power injection value of the seller node is reduced, and the power injection value of the buyer node is increased, with the adjustment amount equal to the transaction amount.
[0089] This embodiment also provides a computer device applicable to the case of power system physical constraint smart contracts and their blockchain implementation method, including: a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the power system physical constraint smart contracts and their blockchain implementation method as proposed in the above embodiment.
[0090] The computer device can be a terminal, comprising a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the computer device's casing, or an external keyboard, touchpad, or mouse.
[0091] This embodiment also provides a storage medium storing a computer program. When executed by a processor, the program implements the method for implementing smart contracts for power system physical constraints and their blockchain implementation as proposed in the above embodiments. The storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Red-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0092] In summary, this invention achieves the following: by rapidly decoupling power flow calculations to simulate the power grid state after a transaction, and combining this with a dynamic weight adjustment algorithm for adaptive constraint verification, the smart contract possesses forward-looking risk assessment and accurate verification capabilities. This fundamentally solves the problem of the disconnect between blockchain transactions and physical security, significantly improving power grid operation security while ensuring processing efficiency. Furthermore, the use of a Byzantine fault-tolerant consensus mechanism for distributed confirmation of verification conclusions ensures the correctness and immutability of verification results even in the event of some node anomalies.
[0093] Example 2, referring to Tables 1, 2, and 3, is the second embodiment of the present invention. This embodiment provides a smart contract for physical constraints of a power system and its blockchain implementation method, including the following steps: Power system constraint modeling Definition of power system state variables: (1) in, For nodes The set of state variables The node voltage amplitude, Inject current into the node, Active power Reactive power This is the voltage phase angle.
[0094] Node power balance constraints: (2) in, For nodes Active power injection, The total number of nodes. For nodes voltage amplitude, The modulus of the elements of the admittance matrix. For nodes voltage phase angle, It is the admittance angle.
[0095] Voltage constraint conditions: (3) in, For nodes Lower voltage limit For nodes Voltage limit.
[0096] Line capacity constraints: (4) in, For the line Apparent power The active power of the line. The reactive power of the line. This represents the maximum line capacity.
[0097] Generator output constraints: (5) in, For generator Those who have made contributions , These represent the lower and upper limits of the generator's active power output.
[0098] Constraint Discretization Transformation Voltage-constrained discretization: (6) in, For nodes The voltage constraint verification results are 1, which indicates that the constraint is satisfied and 0 indicates that the constraint is violated.
[0099] Power balance constraint discretization: (7) in, For nodes The power balance constraint verification results The power is calculated based on the power flow. For scheduling planned power, This is for power balance tolerance.
[0100] Discretization of line capacity constraints: (8) in, For the line The capacity constraint verification results, This is the safety margin factor, typically taken as 0.9-0.95.
[0101] System overall constraint verification: (9) in, The system's overall constraint verification results are as follows: For the set of routes, It equals 1 only when all constraints are satisfied.
[0102] Smart contract architecture design Contract state variable definition: (10) in, This is the state of the smart contract. For power grid topology, For node data, For line data, This is the set of constraints.
[0103] Transaction verification function: (11) in, To verify the results, For transaction data, This represents the current system state.
[0104] Constraint verification logic: (12) in, To constrain the verification results, The total number of constraints. For the first A function to verify each constraint. Represents logical AND operations.
[0105] Dynamic weight adjustment: (13) in, For a moment constraint The weight, Based on weights, To adjust the coefficient, To constrain The risk assessment value.
[0106] Fast power flow calculation algorithm: Newton-Raphson Fajokian matrix: (14) in, , This is the power imbalance quantity. , , , Divide the Jacobian matrix into blocks. , This refers to the voltage phase angle and amplitude correction.
[0107] Rapid decoupling and simplification of power flow: (15) (16) Among them, by ignoring coupling terms and This decomposes power flow calculation into two independent sub-problems.
[0108] Iterative convergence criterion: (17) in, To achieve convergence tolerance, a value of 10⁻⁴ is typically used.
[0109] Real-time data interface design Data acquisition model: (18) in, For a moment Real-time data, For system frequency, This is for device status information.
[0110] Data preprocessing: (19) in, For standardized data, The original data, The mean of the data. This represents the standard deviation of the data.
[0111] Data quality assessment: (20) in, This is a data quality indicator, where N is the number of data points. For predicted values, This represents the noise standard deviation.
[0112] Blockchain consensus mechanism Proof-of-Stake Consensus: ;(twenty one) in, For the verifier The probability of being selected. For the verifier rights, The holding period of the equity.
[0113] Block verification conditions: ;(twenty two) Wherein, ValidBlock represents the block verification result. For the first The verification results of each transaction, A correct random number. This is a valid timestamp.
[0114] Consensus convergence condition: ;(twenty three) in, As a consensus outcome, The number of validators who agree. The total number of validators. This is the consensus threshold.
[0115] Security verification mechanism Cryptographic hash function: ;(twenty four) in, The block hash value, For block data, It is a random number. The hash value is the hash value of the previous block, and || indicates a data join operation.
[0116] Digital signature verification: (25) in, For signature verification results, For digital signatures, For signature messages This is the public key.
[0117] Smart contract security check: (26) in, For the results of the safety inspection, For reentrancy attack checks, For overflow checking, Access control checks are performed.
[0118] Performance optimization strategies: Parallel computing acceleration: (27) in, For parallel computing time, For serial computation time, Number of processor cores For parallel efficiency.
[0119] Cache optimization: (28) in, For cache hit rate, To cache the hit count, This is used to cache the number of misses.
[0120] Memory usage optimization: (29) in, For memory usage, For the first The size of each data structure For use of the mark.
[0121] Fault tolerance mechanism design: Byzantine fault tolerance threshold: (30) in, The acceptable number of malicious nodes. This represents the total number of nodes in the network.
[0122] Fault detection function: (31) in, For fault detection results, For nodes The response For the expected response, This is the fault threshold.
[0123] System availability: (32) in, For system availability, Mean time between failures (MTBF) This represents the average repair time.
[0124] Algorithm Flow System initialization and configuration phase After the system starts, a basic data model of the power system is established. The system state variable set is defined using formula (1), including the voltage amplitude, voltage phase angle, injected current, active power and reactive power of each node. The smart contract state is initialized according to formula (10), and the power grid topology, node data, line data and constraint condition set are configured to establish a complete system data structure.
[0125] Load the power system operation constraint parameters, apply formula (3) to set the upper and lower limits of the voltage of each node, and use the formula.
[0126] Configure the capacity limits for each line and set the output range of each generator according to formula (5). These constraint parameters constitute the basic rule base for smart contract verification. Configure the basic parameters of the blockchain network, including node address, consensus threshold and key management, and set the parameters of the proof-of-stake consensus mechanism using formula (21) to determine the stake and holding time of each verification node.
[0127] Establish a real-time data interface, configure the data acquisition model according to formula (18), and set the acquisition frequency and transmission protocol for voltage, power, frequency, and device status. Apply the data preprocessing algorithm of formula (19) to standardize the raw data and eliminate the influence of different dimensions. Use formula (20) to establish a data quality assessment mechanism, set noise thresholds and quality judgment standards, and provide a reliable data foundation for subsequent constraint verification.
[0128] System security configuration is performed. The hash function of formula (24) is used to establish the blockchain data structure, and the digital signature verification mechanism is configured through formula (25) to ensure the integrity and immutability of transaction data. The smart contract security check mechanism is established by applying formula (26), and reentrancy attack protection, overflow detection and access control rules are configured. The Byzantine fault tolerance threshold is set according to formula (30) to determine the number of malicious nodes that the system can tolerate and to establish a distributed fault tolerance framework.
[0129] Configure performance optimization parameters and design a parallel computing strategy using formula (27), allocating computing tasks according to the number of processor cores and parallel efficiency. Apply formula (28) to initialize the cache management mechanism, setting the cache capacity and replacement strategy to improve the efficiency of repetitive computations. Configure a memory management scheme according to formula (29), optimizing the memory usage of data structures to ensure efficient system operation in resource-constrained environments.
[0130] Power system constraint modeling and discretization stage A mathematical constraint model is established based on the physical characteristics of the power system. The node power balance equation is constructed using formula (2), and the active power injection of each node is calculated, taking into account the effects of voltage amplitude, phase angle, and admittance matrix. This equation ensures the energy conservation of the power system and is the most basic physical constraint. A constraint priority mechanism is established, and the dynamic weight adjustment algorithm of formula (13) is applied to assess the importance of each constraint based on the real-time operation risk of the system, and assign higher verification priority to key constraints.
[0131] The continuity constraint is converted into a discretized verification condition that can be executed by the smart contract. The node voltage constraint is discretized using formula (6), and the judgment logic of the upper and lower limits of voltage is set. When the node voltage is within the allowable range, the constraint verification result is 1, otherwise it is 0. The power balance constraint is discretized using formula (7), and a power balance tolerance parameter is introduced to allow a reasonable deviation between the calculated power and the scheduled power, so as to avoid misjudgment caused by numerical error.
[0132] The line capacity constraint is discretized using formula (8), and a safety margin coefficient is introduced to ensure that the apparent power of the line does not exceed a certain proportion of the rated capacity (usually 90-95%), thereby improving the line utilization rate while ensuring safety. Formula (9) is used to establish the system's overall constraint verification logic. The verification results of all constraints are combined through logical AND operation. Only when all constraints are satisfied at the same time will the system determine that the transaction is physically feasible.
[0133] Establish a verification and calibration mechanism for the constraint model. Verify the model's accuracy through historical operating data and offline simulation analysis, and adjust tolerance parameters and margin coefficients to ensure that the discretized constraints guarantee system safety without being overly conservative. Design an emergency response mechanism for constraint violations, and formulate corresponding handling strategies for constraint violations of different severity levels.
[0134] Smart contract development and deployment phase Discretized power system constraints are converted into smart contract code, and constraint verification logic is implemented using programming languages such as Solidity. A transaction verification function is designed based on formula (11), defining the input parameters as transaction data and the current system state, and the output as the verification result. Formula (12) is applied to implement the core logic of constraint verification, using a loop to call each constraint checking function and combining logic and operations to verify the result.
[0135] Design the contract's data structure, defining state variables according to formula (10), including power grid topology, node data, line data, and constraint parameters. Establish a data update interface to support dynamic updates of system state and online adjustments of constraint parameters. Implement the dynamic weight adjustment function of formula (13), enabling the contract to adaptively adjust the verification rigor based on real-time risk assessment.
[0136] Implement contract security audits, apply the security check mechanism of formula (26), and use static analysis tools to detect potential reentrancy vulnerabilities, integer overflow risks, and access control defects. Perform formal verification to ensure the consistency between contract logic and constraint model, deploy smart contracts to the blockchain network, use formula (24) to calculate the hash value of contract code, and ensure that the deployed contract is completely consistent with the audited version.
[0137] Configure contract permissions and access control, setting authorized addresses for calling contract verification functions to prevent unauthorized access. Establish a contract upgrade mechanism to support dynamic updates of constraint parameters without affecting the core verification logic of the contract. Test the performance and reliability of the contract by simulating large-scale transaction scenarios on a test network to verify the contract's throughput and response time.
[0138] Real-time data integration and processing stage: Establish a data interface with the power system SCADA (Supervisory Control and Data Acquisition) system, and use the data acquisition model of formula (18) to obtain the system operating status in real time, including the voltage, power, system frequency and equipment operating status of each node. Design a data transmission protocol to ensure the real-time performance and integrity of the data, and set a reasonable sampling frequency and communication cycle.
[0139] The collected raw data is preprocessed, and the standardization algorithm of formula (19) is applied to transform data of different dimensions into a unified standardized space to eliminate the influence of data scale differences. Data cleaning is carried out to identify and remove outlier data points, and interpolation or filtering techniques are used to fill in missing data to ensure the continuity and reliability of the data.
[0140] The data quality is evaluated using formula (20), the deviation between the measured and predicted values is calculated, and the reliability of the data is judged by combining the statistical characteristics of noise. Warnings are issued for data that does not meet quality standards, triggering data re-collection or the use of backup data sources. A data synchronization mechanism is established to ensure that all nodes in the blockchain network obtain consistent system status data, avoiding discrepancies in verification results caused by data inconsistency.
[0141] Implement smart contracts and integrity protection, use the hash function of formula (24) to perform data digest calculation, and verify the credibility of the data source through the digital signature mechanism of formula (25) to prevent data from being tampered with during transmission. Establish a data backup and recovery mechanism, regularly store historical data, and provide data support for fault recovery and post-event analysis. Design a data compression algorithm to reduce the amount of data transmitted while ensuring accuracy and optimize network bandwidth utilization.
[0142] Transaction verification and power flow calculation phase: The system receives power trading requests from the blockchain network and extracts power dispatch information from the transactions, including key parameters such as the trading parties, the amount of electricity traded, and the trading time period. It then calls the smart contract's transaction verification function according to formula (11), passing the transaction data and the current system state as input parameters to the contract.
[0143] Fast power flow calculations are performed to assess the impact of transactions on the system's operating state. First, the node power balance is calculated using formula (2), and the power injection of each node is adjusted according to the transactions. The Jacobian matrix is constructed using the Newton-Raphson method of formula (14), establishing a linear relationship between the power imbalance and the voltage correction. To improve the calculation speed, the fast decoupling algorithm of formulas (15) and (16) is used to decompose the coupled power flow equations into active power-phase subproblems and reactive power-voltage subproblems, which are then solved iteratively.
[0144] The convergence of the iteration is determined according to formula (17). The iteration stops when the power imbalance is less than the convergence tolerance, and the system operating state after the transaction is executed is obtained. The voltage amplitude and phase angle of each node and the power distribution of each line are calculated to provide state data for constraint verification. Parallel computing technology is adopted, and the acceleration strategy of formula (27) is applied to calculate the power flow equations of multiple nodes on a multi-core processor at the same time, which significantly shortens the calculation time.
[0145] Formula (12) is used to execute the constraint verification logic, calling each constraint check function in sequence. Formula (6) is used to verify whether the voltage of each node is within the allowable range, and formula (7) is used to check whether the power balance deviation is within the tolerance range, according to the formula.
[0146] Determine whether the apparent power of each line exceeds the capacity limit. By combining the verification results of all constraints using formula (9), use logical AND operation to determine the overall feasibility of the transaction.
[0147] If a transaction satisfies all physical constraints, execution is permitted, and the system state and blockchain ledger are updated. If a transaction violates any constraints, execution is rejected, and detailed information about the constraint violation is returned to the transaction initiator, including the specific type of violation, the degree of violation, and suggested adjustments. The transaction verification process and results are recorded, the hash value of the verification record is calculated using formula (24), and a digital signature is performed using formula (25) to ensure the traceability and immutability of the verification process.
[0148] Consensus mechanism execution and block generation phase: In a distributed blockchain network, multiple verification nodes independently perform transaction verification. The proof-of-stake consensus mechanism using formula (21) calculates the probability of being selected to generate a block based on each verification node's stake and holding time, ensuring a fair distribution of verification power. The selected verification node performs transaction verification, and other nodes verify the node's calculation results.
[0149] Using the block verification conditions in formula (22), the verification results of all transactions in the block, the correctness of the random number, and the validity of the timestamp are checked. The validity of the block is determined by a combination of logic and operations. Only when all conditions are met is the block considered valid. The consensus convergence judgment in formula (23) is applied to count the number of verification nodes that agree with the block. When the agreement ratio exceeds the consensus threshold (usually 2 / 3), the block is confirmed and added to the blockchain.
[0150] The Byzantine fault tolerance mechanism using formula (30) ensures that even if malicious verification nodes exist, the system can still reach a correct consensus as long as the number of malicious nodes does not exceed 1 / 3 of the total number of nodes. This mechanism guarantees the credibility of the physical constraint verification results and prevents malicious nodes from manipulating transaction execution by publishing false verification results.
[0151] The block hash value is calculated according to formula (24). After concatenating the block data, the random number, and the hash value of the previous block, a SHA-256 hash operation is performed to generate a unique block identifier. The block is digitally signed using formula (25). Verification nodes use their private keys to sign the block hash, and other nodes use their corresponding public keys to verify the validity of the signature, ensuring the credibility of the block source and the integrity of the data.
[0152] System monitoring and dynamic adjustment phase: Establish a system performance monitoring mechanism to monitor the accuracy and efficiency of constraint verification in real time. Apply the fault detection function of formula (31) to monitor the response of each verification node. When the deviation between the node response and the expected value exceeds the threshold, the node is marked as a potential fault node. Use formula (32) to calculate system availability and evaluate the overall reliability of the system based on the mean time between failures and the mean time to repair.
[0153] Analyze system operation data to identify performance bottlenecks and optimization opportunities. Apply formula (27) to evaluate the acceleration effect of parallel computing and adjust the task allocation strategy according to the actual parallel efficiency. Use formula (28) to monitor cache hit rate, optimize caching strategies and data prefetching algorithms, and improve the efficiency of repetitive computations. Analyze memory usage according to formula (29), identify memory leaks and redundant data structures, and optimize memory management schemes.
[0154] Implement dynamic constraint adjustment, applying the dynamic weighting mechanism of formula (13), and assess the importance of each constraint based on the real-time operational risk of the system. When the system load is light and the operational margin is sufficient, appropriately relax the strictness of constraint verification to improve transaction flexibility; when the system load is close to the limit and the operational risk increases, increase the strictness of constraint verification to ensure system security. Regularly update constraint parameters and adjust the upper and lower limits of constraints in formulas (3), (4), and (5) according to equipment maintenance, network topology changes, etc.
[0155] Establish a fault diagnosis and recovery mechanism. When a system anomaly is detected, use formula (31) to locate the faulty node and start the backup node to replace the faulty node. Apply the availability index of formula (32) to guide the system maintenance strategy, reasonably arrange equipment maintenance and system upgrade time, and maximize system availability.
[0156] Performance evaluation and optimization feedback phase: Collect system operation data and statistically analyze key performance indicators such as transaction verification accuracy, verification time, and throughput. Analyze the verification effect of different transaction types, identify scenarios with low verification accuracy or excessive computation time, and optimize the verification algorithm accordingly. Evaluate the rationality of the constraint discretization parameters and adjust the tolerance and margin coefficients in formulas (6), (7), and (8) based on actual operating experience.
[0157] The data quality assessment results using formula (20) are used to analyze the impact of data quality on verification accuracy and optimize the data acquisition and preprocessing process. Statistical analysis is performed using the standardized parameters of formula (19) to ensure the effectiveness of data preprocessing. Based on the data acquisition model of formula (18), the impact of sampling frequency and transmission delay on system real-time performance is evaluated, and the data interface configuration is optimized.
[0158] The effectiveness of the security mechanism is evaluated, and the security checks of formula (26) are analyzed to determine whether all potential vulnerabilities have been identified. The smart contract code is improved based on the security audit results. The Byzantine fault tolerance capability of formula (30) is tested by simulating attacks from malicious nodes of different proportions to verify the fault tolerance threshold of the system. The security strength of the cryptographic mechanisms of formulas (24) and (25) is evaluated, and the hash algorithm and signature scheme are updated based on the latest cryptographic research.
[0159] Simulation verification A real-world power system operating environment was simulated using a MATLAB-based test system based on the IEEE 118-node standard. The simulation platform includes complete blockchain network, smart contract, and power system constraint verification capabilities. Test scenarios cover various conditions, including normal operation, fault conditions, and large-scale transactions. Smart contracts were developed based on the Ethereum platform, and constraint verification logic was implemented using the Solidity language.
[0160] Table 1: Performance Comparison of Different Constraint Verification Methods
[0161] Table 2: Performance under different system sizes
[0162] Table 3: Validation Effect Analysis of Different Transaction Types
[0163] Simulation results demonstrate that the proposed power system physical constraint smart contract method achieves excellent results in terms of verification accuracy, real-time performance, and scalability. The verification accuracy reaches 98.7%, the verification time is controlled within 85 milliseconds, and the throughput reaches 265 transactions per second. In tests across different system scales, the method exhibits good scalability, maintaining a success rate of 95.8% even in ultra-large-scale systems. Analysis of verification performance for different transaction types shows that the method provides reliable constraint verification for transactions of varying complexity. The smart contract security has undergone rigorous testing, and no major security vulnerabilities were found. The system has strong fault tolerance, capable of operating normally even with 30% node failure. In terms of energy consumption, it reduces energy consumption by more than 60% compared to traditional centralized methods, demonstrating significant economic benefits. Experiments fully verify the feasibility and effectiveness of this method in practical applications.
[0164] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A smart contract for physical constraints in a power system and its blockchain implementation method, characterized in that: This includes deploying a smart contract on a blockchain and configuring the initial topology of the power grid, equipment parameters, and basic physical constraints within the smart contract, comprising the following steps: Create and deploy the core smart contract on the selected blockchain, call the management function of the deployed core smart contract, and write the initial topology of the power grid into the core smart contract; Call the configuration function of the core smart contract for the initial topology of the power grid to configure the device parameters into the core smart contract; Call the constraint setting function of the core smart contract for the initial topology and equipment parameters of the power grid, and set the basic physical constraints into the core smart contract; Call the activation function of the core smart contract that has completed the initial topology, equipment parameters and basic physical constraints configuration of the power grid, and activate the core smart contract; The data interface node obtains real-time power grid status data from the power data acquisition and monitoring unit, and performs preprocessing and data quality assessment on the real-time power grid status data. The transaction initiator constructs an electricity transaction request and digitally signs it using a private key, then broadcasts it to the blockchain. The smart contract calls the transaction verification function, combines the real-time power grid status data, and performs a fast decoupled power flow calculation to simulate the operating state after the power transaction request is executed, including the following steps: The smart contract receives and verifies the digital signature of the power transaction request, and the transaction verification function of the smart contract calls the real-time power grid status data that has been preprocessed and assessed for data quality. The transaction verification function of the smart contract applies the power change amount of the power transaction request to the real-time power grid status data to form the hypothetical unit state after the transaction. The transaction verification function of the smart contract is based on the hypothetical unit state after the transaction, and constructs an active power-phase angle correction equation for fast decoupling power flow calculation. The transaction verification function of the smart contract iteratively solves the active power-phase angle correction equation and the reactive power-voltage correction equation, and the power imbalance is less than the convergence tolerance. The smart contract's transaction verification function outputs an iterative solution to obtain the node voltage phase angle, voltage amplitude, and line power, simulating the operating state after the power transaction request is executed; The smart contract, based on the simulated running state after the execution of the power trading request, applies a dynamic weight adjustment algorithm to obtain the real-time weights of the physical constraints, and executes constraint verification logic. The constraint verification logic discretizes the continuous physical constraints into binary judgment conditions and performs a logical AND operation to generate a preliminary verification conclusion for the power trading request. The blockchain verification node performs consensus verification on the block containing the preliminary verification conclusion based on the Byzantine fault tolerance mechanism, and records the block on the chain after reaching a consensus. The power grid control center executes power grid dispatch instructions based on the power transaction request obtained on the blockchain, and the smart contract updates its internal state.
2. The smart contract for physical constraints of power systems and its blockchain implementation method as described in claim 1, characterized in that: The data interface node acquires real-time power grid status data from the power data acquisition and monitoring unit, and performs preprocessing and data quality assessment on the real-time power grid status data, including the following steps: The data interface node obtains real-time power grid status data from the power data acquisition and monitoring unit. The data interface node performs data cleaning on the real-time power grid status data, identifying and removing outliers from the real-time power grid status data. The data interface node applies a standardized algorithm to the cleaned real-time power grid status data to eliminate the influence of different physical quantities in the real-time power grid status data. The data interface node inputs the standardized real-time power grid status data into the data quality assessment model to calculate the quality of the real-time power grid status data. The data interface node determines the feasibility of real-time power grid status data based on the quality indicators output by the data quality assessment model. Based on the maximum measurement error range allowed by the power unit safe operation procedure and the percentile of the quality indicator distribution obtained by the data quality assessment model in the historical fault-free operation cycle, a quality threshold is set. When the quality indicator is higher than the quality threshold, the real-time power grid status data is submitted to the smart contract.
3. The smart contract for physical constraints of a power system and its blockchain implementation method as described in claim 1, characterized in that: The transaction initiator constructs an electricity transaction request and digitally signs it using a private key, then broadcasts it to the blockchain, including the following steps: The transaction initiator determines the transaction volume, transaction price, transaction time window, and counterparty node information for the electricity transaction request; The transaction initiator assembles the power transaction request into a complete power transaction request data packet according to a predefined structured format; The transaction initiator uses its own asymmetric encryption private key to perform a digital signature operation on the complete power transaction request data packet. The transaction initiator then binds the digital signature to the complete power transaction request data packet to form a signed power transaction request. The transaction initiator broadcasts the signed electricity transaction request to the nodes of the blockchain network, and the blockchain network nodes receive and verify the legality of the format of the signed electricity transaction request. Blockchain network nodes store legally formatted, signed electricity transaction requests into a transaction pool, where they are processed by smart contracts.
4. The smart contract for physical constraints of a power system and its blockchain implementation method as described in claim 1, characterized in that: The smart contract, based on the simulated running state after the execution of the power trading request, applies a dynamic weight adjustment algorithm to obtain the real-time weights of the physical constraints, and executes constraint verification logic. This constraint verification logic discretizes the continuous physical constraints into binary judgment conditions and performs a logical AND operation to generate a preliminary verification conclusion for the power trading request, including the following steps: The smart contract obtains the operating status data after simulating the execution of the power trading request, and calculates the risk assessment value of the current hypothetical power grid operating status based on the operating status data after simulating the execution of the power trading request. The smart contract inputs the risk assessment value into a dynamic weight adjustment algorithm to obtain the real-time weight of the physical constraints; The smart contract applies real-time weights to physical constraints to adjust the safety margin coefficient during the discretization of continuous physical constraints. The smart contract uses a safety margin coefficient to discretize continuous physical constraints into binary judgment conditions. The smart contract performs a logical AND operation on the binary judgment conditions of all physical constraints. The smart contract generates a preliminary verification conclusion for the power trading request based on the results of the logic and operations.
5. The smart contract for physical constraints of a power system and its blockchain implementation method as described in claim 4, characterized in that: Blockchain verification nodes perform consensus verification on blocks containing the preliminary verification conclusions based on the Byzantine fault tolerance mechanism. After reaching a consensus, the blocks are recorded on the blockchain, including the following steps: The blockchain verification node receives the consensus block of the preliminary verification conclusion. The blockchain verification node independently verifies the preliminary verification conclusion and related transaction data in the consensus block based on the Byzantine fault tolerance mechanism. Each blockchain verification node votes on the consensus block based on its independent verification results. The blockchain verification nodes collect and statistically analyze the voting results of each verification node in the network. The consensus threshold preset by the Byzantine fault tolerance mechanism is used to determine whether consensus has been reached. After consensus is reached, the blockchain verification node adds the block to be reached to the blockchain and broadcasts the new blockchain state to the entire network.
6. The smart contract for physical constraints of a power system and its blockchain implementation method as described in claim 5, characterized in that, The power grid control center executes power grid dispatch instructions based on the power trading request obtained on the blockchain. The smart contract updates its internal state, including the following steps: The power grid control center monitors the blockchain and captures the event of the power transaction request being successfully uploaded to the chain. The power grid control center parses the uploaded power transaction request and extracts power dispatch information. Based on the extracted power dispatch information, the power grid control center generates power grid dispatch instructions, which are then sent to the physical power grid for execution. The smart contract detects that the power transaction request has been successfully uploaded to the blockchain and confirmed. Based on the confirmed power transaction request content, the smart contract updates the internally maintained power grid state variables.
7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, it implements the steps of the power system physical constraint smart contract and its blockchain implementation method as described in any one of claims 1 to 6.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by the processor, it implements the steps of the power system physical constraint smart contract and its blockchain implementation method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
CT induction power supply system based on cooperative control and distributed optimization and control method
CN120197819A
Multi-dimensional intelligent management method and system for whole-process cost
CN120317907A