Harmonic error prediction and dynamic compensation method based on diffusion model neural network

CN122983455APending Publication Date: 2026-10-27广东隆元科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611043927.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-14
Publication Date
2026-10-27

AI Technical Summary

Technical Problem

这类方法虽然在一定程度上能够改善部分场景下的计量误差,但其本质上大多仍属于确定性点估计或静态映射方式,对于复杂谐波工况下误差分布的随机性和多样性刻画不足,难以真实反映误差随谐波结构变化而呈现出的波动范围和概率特征

Benefits of technology

[0023]本发明的有益效果是:本发明针对复杂谐波工况下电能表计量误差呈现非线性、时变性和随机性的技术特点,不再采用传统静态标定、经验查表或普通回归模型直接进行单点补偿,而是通过构建全景谐波特征向量,全面引入电压、电流波形中的谐波幅值、相位、畸变率、功率因数及有功功率等多维工况信息,使模型能够更加完整地表征电能表所处的实际运行状态,从源头上提高误差建模的针对性和准确性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122983455A_ABST
    Figure CN122983455A_ABST
Patent Text Reader

Abstract

The application discloses a harmonic error prediction and dynamic compensation method based on a diffusion model neural network, and relates to the technical field of electric energy metering and intelligent signal processing. The method acquires real-time voltage and current sampling waveform data in the operation process of an electric energy meter, extracts harmonic amplitude, phase, distortion rate, power factor and active power and the like features, constructs a panoramic harmonic feature vector, and inputs the panoramic harmonic feature vector into a one-dimensional conditional diffusion model as a condition to predict metering errors; and then, according to the predicted errors, the original metering results are dynamically compensated, and the compensated metering values are output. The application can effectively improve the accuracy, robustness and dynamic adaptability of electric energy metering under complex harmonic working conditions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of electricity meters, and specifically to a method for predicting and dynamically compensating harmonic errors based on a diffusion model neural network. Background Technology

[0002] As a core infrastructure device in the electricity metering system, the accuracy of electricity meters directly affects the reliability of electricity trade settlement, fair billing, and grid operation status assessment. With the large-scale integration of new energy power generation equipment, electric vehicle charging devices, variable frequency speed control equipment, rectifier equipment, and various nonlinear loads into the power system, the voltage and current waveforms in the distribution network are no longer limited to ideal sine waves. Harmonic pollution problems are becoming increasingly prominent, and the actual operating environment of electricity meters is becoming more complex. Against this backdrop, the metering error of electricity meters under harmonic conditions has gradually become a significant factor affecting metering accuracy and operational reliability.

[0003] Existing electricity meters are typically designed, calibrated, and verified under relatively standard power frequency sinusoidal conditions or finite harmonic conditions. However, in practical applications, the power grid often contains multiple harmonic components with constantly changing amplitude, phase, and frequency. Furthermore, different harmonics are coupled with load characteristics, power factor, waveform distortion, and other operating parameters, causing the metering error to exhibit significant nonlinear, time-varying, and random fluctuation characteristics. Especially in scenarios with strong harmonics, multiple operating condition switching, and rapid load fluctuations, the fixed calibration parameters or static compensation mechanisms of traditional electricity meters are difficult to accurately adapt to the complex, real-time changing conditions, easily leading to increased metering deviations and affecting the accuracy and stability of actual measurement results.

[0004] To address the aforementioned issues, existing technologies offer several solutions for correcting or compensating for electricity meter errors. These solutions employ methods such as empirical formulas, error lookup tables, linear fitting, piecewise fitting, and ordinary neural network regression to model errors under specific operating conditions and output compensation values. While these methods can improve metering errors in certain scenarios to some extent, they are essentially deterministic point estimations or static mapping methods. They are insufficient in characterizing the randomness and diversity of error distribution under complex harmonic conditions, and fail to accurately reflect the fluctuation range and probabilistic characteristics of errors as harmonic structures change. When faced with real-world operating environments characterized by diverse harmonic types, complex combinations, and significant differences in load types, traditional methods are prone to insufficient fitting ability, weak generalization ability, and unstable compensation accuracy.

[0005] Furthermore, while existing error prediction methods based on machine learning or deep learning offer stronger nonlinear fitting capabilities compared to traditional linear models, most still directly map operating conditions to a single error output value, primarily focusing on mean regression or optimal point prediction. They lack the ability to effectively express the uncertainty, distribution, and multimodal characteristics of errors. In complex harmonic environments, errors are often not simple single-valued functions but rather probabilistic changes resulting from the combined influence of multiple factors. Using a single numerical prediction method can easily lead to insufficient description of the actual error state, thus affecting the reliability of the final compensation result. Meanwhile, while some complex models possess strong theoretical prediction capabilities, their large scale and complex inference processes make it difficult to meet the real-time, stability, and deployability requirements of online applications, limiting their widespread application in electricity meter-side or edge-side devices.

[0006] Therefore, how to construct a method and system that can fully utilize the harmonic information of voltage and current waveforms to effectively predict errors and combine the prediction results to implement real-time or near-real-time dynamic compensation of the original metering results, in response to the nonlinear, random and dynamic changes of the metering error under complex harmonic operating conditions, has become a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0007] To address the aforementioned problems, this invention provides a method for harmonic error prediction and dynamic compensation based on a diffusion model neural network, which can effectively overcome the shortcomings of existing technologies.

[0008] This invention is achieved through the following technical solution: a method for predicting and dynamically compensating harmonic errors based on a diffusion model neural network, comprising the following steps: S1. Obtain real-time voltage sampling waveform data and current sampling waveform data of the energy meter under operating conditions; S2. Perform harmonic feature analysis on the voltage sampling waveform data and current sampling waveform data, and construct a panoramic harmonic feature vector c; S3. Using the panoramic harmonic feature vector c as a conditional input, a one-dimensional conditional diffusion model is used to generate a predicted measurement error value corresponding to the current harmonic operating condition. S4. Based on the predicted metering error value, dynamically compensate the original metering result of the electricity meter and output the compensated electricity metering value.

[0009] As a preferred technical solution, step S2 includes: performing fast Fourier transform frequency domain analysis on the voltage waveform v[n] and current waveform i[n] within the sampling window; Extract the voltage amplitude of the fundamental frequency and the 2nd to 50th harmonics. Current amplitude and phase angle , ,in ; Calculate waveform distortion and power-related characteristics, including at least the total harmonic distortion of voltage. Total harmonic distortion of current At least two of the following: power factor PF and active power P; The above features are spliced ​​together and normalized to obtain the panoramic harmonic feature vector c.

[0010] As a preferred technical solution, the panoramic harmonic feature vector c includes at least all or some of the feature terms in the following formula:

[0011] Where A represents the amplitude, This indicates the phase angle.

[0012] As a preferred technical solution, the model training phase of step S3 includes a forward diffusion process, which is as follows: Labeling of true measurement error Gaussian noise is added step by step to obtain the noisy error state. ,satisfy:

[0013] in, , These are noise scheduling parameters.

[0014] As a preferred technical solution, the training objective of step S3 is noise prediction, and the loss function used is:

[0015] in, This is a noise prediction network.

[0016] As a preferred technical solution, step S3 introduces a classifier-free guidance mechanism, the noise prediction method of which is as follows:

[0017] in, This indicates unconditional input. This is the guiding coefficient.

[0018] As a preferred technical solution, to implement the classifier-free guidance mechanism, during the training phase, the conditional input c is set to null with a preset probability p, thereby learning unconditional branches. .

[0019] The harmonic error prediction and dynamic compensation method based on diffusion model neural network according to claim 6 is characterized in that: the inverse denoising generation process in step S3 adopts DDIM accelerated sampling, and the... Substitute into DDIM reverse update to obtain until the predicted measurement error value is generated. .

[0020] As a preferred technical solution, the one-dimensional conditional diffusion model employs a one-dimensional residual convolutional network, which includes: The time step embedding module is used to map the diffusion time step t to a time embedding vector; A conditional embedding module is used to map the panoramic harmonic feature vector c into a conditional embedding vector; An adaptive normalization modulation module is used to generate scaling and offset factors based on the time embedding vector and the conditional embedding vector, and to modulate the intermediate features of the network to enhance the control capability of harmonic features over the error generation process.

[0021] As a preferred technical solution, step S4 satisfies any of the following compensation methods: When the predicted measurement error value is a relative error At that time, the compensated electricity metering value is: When the prediction measurement error value is absolute error At that time, the compensated electricity metering value is:

[0022] in, This is the original measurement result; Step S4 also includes anomaly constraints: when or When the threshold is exceeded, the amplitude is limited or the output is reverted to the preset calibration compensation strategy to ensure the stability of the metering output.

[0023] The beneficial effects of this invention are as follows: Addressing the nonlinear, time-varying, and random characteristics of metering errors under complex harmonic conditions, this invention no longer employs traditional static calibration, empirical table lookup, or ordinary regression models for direct single-point compensation. Instead, it constructs a panoramic harmonic feature vector, comprehensively incorporating multi-dimensional operating condition information such as harmonic amplitude, phase, distortion rate, power factor, and active power from voltage and current waveforms. This enables the model to more completely represent the actual operating state of the electricity meter, improving the pertinence and accuracy of error modeling from the source.

[0024] This invention employs a one-dimensional conditional diffusion model to generate and predict measurement errors. Compared to traditional deterministic regression methods, it can more effectively characterize the random fluctuation characteristics and nonlinear variation laws of error distribution under complex harmonic conditions. This makes the generated predicted error values ​​more consistent with the error evolution characteristics under real working conditions, thereby improving the authenticity, stability, and adaptability of the error prediction results.

[0025] This invention introduces a classifier-free guidance mechanism into the conditional diffusion model, which enables the panoramic harmonic features to have a stronger constraint and control capability on the error generation process. It can effectively enhance the generalization performance between different harmonic structures, different load types, and different operating scenarios, and avoid the problems of prediction offset or compensation inaccuracy in existing models when the operating conditions change significantly, thereby improving the applicability of this invention in complex power grid environments.

[0026] This invention achieves dynamic compensation of electricity metering values ​​by directly applying the predicted metering error value to the original metering result. It can promptly correct the original metering deviation under conditions of harmonic pollution, nonlinear load connection, and rapid changes in operating conditions, significantly improving the accuracy and robustness of the compensated metering result, thereby enhancing the metering reliability of the electricity meter in actual operation.

[0027] This invention further employs an accelerated sampling strategy, which can reduce the number of reverse denoising iterations while ensuring the quality of error prediction, reduce the online inference latency of the model, improve the deployment feasibility of the system at the end of the power meter or edge device, and meet the requirements of real-time performance and stability for practical engineering applications.

[0028] The present invention can also limit the compensation result or switch to a preset compensation strategy when the prediction error exceeds a reasonable range or the input characteristics are abnormal through an anomaly constraint and backoff compensation mechanism, thereby preventing excessive fluctuations in the compensation output and improving the safety and stability of the overall system operation. Attached Figure Description

[0029] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. 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.

[0030] Figure 1 This is a flowchart of the method of the present invention; Figure 2 This is a structural block diagram of the present invention. Detailed Implementation

[0031] All features disclosed in this specification, or steps in all methods or processes disclosed herein, may be combined in any way, except for mutually exclusive features and / or steps.

[0032] Any feature disclosed in this specification (including any appended claims, abstract, and drawings) may be replaced by other equivalent or similar features for a similar purpose, unless specifically stated otherwise. That is, unless specifically stated otherwise, each feature is merely one example of a series of equivalent or similar features.

[0033] refer to Figure 1 As shown, this invention provides a method for predicting and dynamically compensating for harmonic errors in electricity meters based on a conditional diffusion model, comprising the following steps: S1: Acquire real-time voltage and current sampling waveform data of the electricity meter under operating conditions; in one embodiment, obtain the voltage sampling sequence through the electricity meter sampling module. With current sampling sequence Where n is the sampling point number. Preferably, the sampling data is updated using a sliding window method, and parameters such as the sampling frequency f, window length N, and window step size are recorded to ensure the continuity of feature extraction and error compensation. In one embodiment, to obtain the true metering error label required for model training, a standard electricity metering device or standard electricity meter is used to measure the electricity metering value under the same operating condition to obtain a reference electricity metering value. The original metering result output by the electricity meter is recorded as... Then the true measurement error label can be defined as the relative error. Or defined as absolute error The aforementioned This indicates the actual measurement error label mentioned above.

[0034] S2: Perform harmonic feature analysis on the voltage and current sampled waveform data to construct a panoramic harmonic feature vector containing harmonic amplitude, phase and distortion characteristics; In one embodiment, step S2 includes: S21: Sample the voltage waveform within the sampling window With current waveform Perform frequency domain analysis using Fast Fourier Transform (FFT); S22: Extract the voltage amplitude of the fundamental frequency and the 2nd to 50th harmonics. Current amplitude and phase angle , where h∈{1,2,…,50}; S23: Calculate waveform distortion and power-related characteristics, including at least the total harmonic distortion of voltage. Total harmonic distortion of current At least two of the following: power factor PF and active power P; S24: The above features are concatenated and normalized to generate a panoramic harmonic feature vector c, which provides conditional input for subsequent error prediction.

[0035] In one embodiment, the panoramic harmonic feature vector c can be expressed as:

[0036] in, For normalization operations, maximum-minimum normalization or z-score normalization are preferred; phase angle features are preferably subjected to periodic mapping or expansion processing to improve feature stability.

[0037] S3: Predicting the metering error of electricity meters based on a one-dimensional conditional diffusion model; In one embodiment, the panoramic harmonic feature vector c is used as a conditional input, and a classifier-free guidance mechanism is introduced. Through a reverse denoising generation process, the random noise state is gradually restored to generate a predicted measurement error value corresponding to the current harmonic operating condition. In one embodiment, the predicted measurement error value is preferably a relative error. This improves portability under different measurement ranges and load conditions; in another embodiment, the predicted measurement error value can also be an absolute error. This allows for direct addition / subtraction compensation of the original measurement results.

[0038] In one embodiment, the training phase of the conditional diffusion model includes a forward diffusion process, which involves: directing the input of the true measurement error labels... Gaussian noise is gradually added to obtain the noisy error state at step t. Its expression is:

[0039] Where t is the diffusion time step; It is Gaussian noise; It is the identity matrix; This is the cumulative noise figure; , These are noise scheduling parameters.

[0040] In one embodiment, a conditional denoising network is constructed. To predict the noise term, the noise prediction loss function is used for training, and the formula is as follows:

[0041] in, For network parameters, This is due to training losses.

[0042] In one embodiment, to enhance conditional control capabilities, step S3 introduces a classifier-free guidance mechanism, whose noise prediction method is as follows:

[0043] in, This indicates unconditional input; w is a guiding coefficient used to adjust the strength of conditional constraints. This is the noise prediction result after fusion.

[0044] In one embodiment, the reverse denoising generation process employs a DDIM accelerated sampling strategy to reduce the number of reverse iteration steps and improve online inference speed. Preferably, the number of sampling steps is less than the number of training diffusion steps, thereby meeting the deployment requirements of electricity meter end-side or edge devices.

[0045] S4: Based on the predicted metering error value, dynamically compensate the original metering result of the electricity meter and output the compensated electricity metering value.

[0046] In one embodiment, when the prediction error is a relative error At that time, the compensated electricity metering value is:

[0047] When the prediction error is an absolute error At that time, the compensated electricity metering value is:

[0048] in, This is the original meter reading from the electricity meter. This is the compensated electricity metering value.

[0049] In one embodiment, to ensure compensation stability, step S4 further includes anomaly constraint processing: when the prediction error exceeds a preset threshold range or the input features are abnormal, the prediction error is limited or rolled back to a preset calibration compensation strategy to avoid output oscillation.

[0050] refer to Figure 2 As shown, the present invention also provides a system for predicting and dynamically compensating for harmonic errors in electricity meters based on a conditional diffusion model. The system includes the following modules: a data acquisition module, used to acquire voltage and current sampling waveform data of the electricity meter under operating conditions; Feature construction module: Used to perform FFT frequency domain analysis on the sampled waveform, extract the amplitude and phase of the fundamental wave and the 2nd to 50th harmonics, and combine with... , Features such as PF and P generate the panoramic harmonic feature vector c; Conditional diffusion error prediction module: It is used to take the panoramic harmonic feature vector as a conditional input, generate the predicted measurement error value through a one-dimensional conditional diffusion model, and introduce a classifier-free guidance mechanism and DDIM accelerated sampling strategy. Dynamic compensation module: Used to dynamically compensate the original metering results of the electricity meter based on the predicted metering error value, and output the compensated electricity metering value. ; Output and Application Module: Used to output compensation results and support measurement data recording, measurement quality assessment or operation status monitoring.

[0051] The above modules are in a progressive relationship, completing the task of error prediction and dynamic compensation under complex harmonic conditions; The present invention discloses a method and system for predicting and dynamically compensating harmonic errors in electricity meters based on a conditional diffusion model. By constructing a panoramic harmonic feature vector and introducing a conditional diffusion generation mechanism, it achieves effective prediction of metering errors under complex harmonic operating conditions and dynamically compensates for the original metering results. This significantly improves metering accuracy and robustness and is applicable to various harmonic pollution and nonlinear load scenarios.

[0052] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions conceived without inventive effort should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope defined in the claims.

Claims

1. A method for predicting and dynamically compensating harmonic errors based on a diffusion model neural network, characterized in that, Includes the following steps: S1. Obtain real-time voltage sampling waveform data and current sampling waveform data of the energy meter under operating conditions; S2. Perform harmonic feature analysis on the voltage sampling waveform data and current sampling waveform data, and construct a panoramic harmonic feature vector c; S3. Using the panoramic harmonic feature vector c as a conditional input, a one-dimensional conditional diffusion model is used to generate a predicted measurement error value corresponding to the current harmonic operating condition. S4. Based on the predicted metering error value, dynamically compensate the original metering result of the electricity meter and output the compensated electricity metering value.

2. The method for harmonic error prediction and dynamic compensation based on diffusion model neural network according to claim 1, characterized in that: Step S2 includes: performing fast Fourier transform frequency domain analysis on the voltage waveform v[n] and current waveform i[n] within the sampling window; Extract the voltage amplitude of the fundamental frequency and the 2nd to 50th harmonics. Current amplitude and phase angle , ,in ; Calculate waveform distortion and power-related characteristics, including at least the total harmonic distortion of voltage. Total harmonic distortion of current At least two of the following: power factor PF and active power P; The above features are spliced ​​together and normalized to obtain the panoramic harmonic feature vector c.

3. The method for harmonic error prediction and dynamic compensation based on a diffusion model neural network according to claim 2, characterized in that: The panoramic harmonic feature vector c includes at least all or some of the feature terms in the following formula: Where A represents the amplitude, This indicates the phase angle.

4. The method for harmonic error prediction and dynamic compensation based on a diffusion model neural network according to claim 1, characterized in that: The model training phase in step S3 includes a forward diffusion process, which is as follows: Labeling of true measurement error Gaussian noise is added step by step to obtain the noisy error state. ,satisfy: in, , These are noise scheduling parameters.

5. The method for harmonic error prediction and dynamic compensation based on a diffusion model neural network according to claim 4, characterized in that: The training objective of step S3 is noise prediction, and the loss function used is: in, This is a noise prediction network.

6. The method for harmonic error prediction and dynamic compensation based on a diffusion model neural network according to claim 1, characterized in that: Step S3 introduces a classifier-free guidance mechanism, and its noise prediction method is as follows: in, This indicates unconditional input. This is the guiding coefficient.

7. The method for harmonic error prediction and dynamic compensation based on a diffusion model neural network according to claim 6, characterized in that: To implement the classifier-free guidance mechanism, during the training phase, the conditional input c is set to null with a preset probability p, thereby learning unconditional branches. .

8. The method for harmonic error prediction and dynamic compensation based on a diffusion model neural network according to claim 6, characterized in that: The reverse denoising generation process in step S3 uses DDIM to accelerate sampling, and the... Substitute into DDIM reverse update to obtain until the predicted measurement error value is generated. .

9. The method for harmonic error prediction and dynamic compensation based on a diffusion model neural network according to claim 1, characterized in that: The one-dimensional conditional diffusion model employs a one-dimensional residual convolutional network, which includes: The time step embedding module is used to map the diffusion time step t to a time embedding vector; A conditional embedding module is used to map the panoramic harmonic feature vector c into a conditional embedding vector; An adaptive normalization modulation module is used to generate scaling and offset factors based on the time embedding vector and the conditional embedding vector, and to modulate the intermediate features of the network to enhance the control capability of harmonic features over the error generation process.

10. The method for harmonic error prediction and dynamic compensation based on a diffusion model neural network according to claim 1, characterized in that: Step S4 satisfies any of the following compensation methods: When the predicted measurement error value is a relative error At that time, the compensated electricity metering value is: When the prediction measurement error value is absolute error At that time, the compensated electricity metering value is: in, This is the original measurement result; Step S4 also includes anomaly constraints: when or When the threshold is exceeded, the amplitude is limited or the output is reverted to the preset calibration compensation strategy to ensure the stability of the metering output.